-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Storage hooks * Read existing storage * set storage hooks
- Loading branch information
1 parent
b86e46d
commit 8dd30e7
Showing
12 changed files
with
208 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
```k | ||
module MX-STORAGE-HOOKS | ||
imports MX-COMMON-SYNTAX | ||
imports MX-STORAGE-TOOLS-SYNTAX | ||
rule MX#storageLoad(mxStringValue(Key:String), Destination:MxValue ) | ||
=> storageLoad(getCallee(), Key, Destination) | ||
rule MX#storageStore(mxStringValue(Key:String), Value:MxWrappedValue) | ||
=> storageStore(getCallee(), Key, Value) | ||
endmodule | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
```k | ||
module MX-STORAGE-TOOLS-SYNTAX | ||
imports MX-COMMON-SYNTAX | ||
imports STRING-SYNTAX | ||
syntax MxInstructions ::= storageLoad(address: String, key: String, destination: MxValue) | ||
| storageStore(address: String, key: String, value: MxWrappedValue) | ||
endmodule | ||
module MX-STORAGE-TOOLS | ||
imports private COMMON-K-CELL | ||
imports private MX-ACCOUNTS-CONFIGURATION | ||
imports private MX-COMMON-SYNTAX | ||
imports private MX-STORAGE-TOOLS-SYNTAX | ||
imports private STRING-SYNTAX | ||
rule | ||
<k> | ||
storageLoad(... address: Address:String, key: Key:String, destination: Destination:MxValue) | ||
=> storeHostValue(Destination, Value) | ||
... | ||
</k> | ||
<mx-account-address> Address </mx-account-address> | ||
<mx-account-storage-key> Key </mx-account-storage-key> | ||
<mx-account-storage-value> Value </mx-account-storage-value> | ||
[priority(50)] | ||
rule | ||
<k> | ||
storageLoad(... address: Address:String, key: _Key:String, destination: Destination:MxValue) | ||
=> storeHostValue(Destination, mxWrappedEmpty) | ||
... | ||
</k> | ||
<mx-account-address> Address </mx-account-address> | ||
[priority(100)] | ||
rule | ||
<k> | ||
storageStore(... address: Address:String, key: Key:String, value: Value:MxWrappedValue) | ||
=> .K | ||
... | ||
</k> | ||
<mx-account-address> Address </mx-account-address> | ||
<mx-account-storage-key> Key </mx-account-storage-key> | ||
<mx-account-storage-value> _ => Value </mx-account-storage-value> | ||
[priority(50)] | ||
rule | ||
<k> | ||
storageStore(... address: Address:String, key: Key:String, value: Value:MxWrappedValue) | ||
=> .K | ||
... | ||
</k> | ||
<mx-account-address> Address </mx-account-address> | ||
<mx-account-storage> | ||
.Bag => | ||
<mx-account-storage-item> | ||
<mx-account-storage-key> Key </mx-account-storage-key> | ||
<mx-account-storage-value> Value </mx-account-storage-value> | ||
</mx-account-storage-item> | ||
... | ||
</mx-account-storage> | ||
[priority(100)] | ||
endmodule | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
addAccount("Owner"); | ||
setCallee("Owner"); | ||
|
||
push mxIntValue(12); | ||
push mxStringValue("MyKey"); | ||
call 2 MX#storageLoad; | ||
push_store_data; | ||
check_eq mxIntValue(12); | ||
check_eq mxWrappedEmpty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
addAccount("Owner"); | ||
setCallee("Owner"); | ||
setStorage("Owner", "MyKey", mxStringValue("Hello")); | ||
|
||
push mxIntValue(12); | ||
push mxStringValue("MyKey"); | ||
call 2 MX#storageLoad; | ||
push_store_data; | ||
check_eq mxIntValue(12); | ||
check_eq wrappedMx(mxStringValue("Hello")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
addAccount("Owner"); | ||
setCallee("Owner"); | ||
|
||
push wrappedMx(mxStringValue("Hello")); | ||
push mxStringValue("MyKey"); | ||
call 2 MX#storageStore; | ||
|
||
push mxIntValue(12); | ||
push mxStringValue("MyKey"); | ||
call 2 MX#storageLoad; | ||
push_store_data; | ||
check_eq mxIntValue(12); | ||
check_eq wrappedMx(mxStringValue("Hello")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
addAccount("Owner"); | ||
setCallee("Owner"); | ||
setStorage("Owner", "MyKey", mxStringValue("Hello")); | ||
|
||
push wrappedMx(mxStringValue("World")); | ||
push mxStringValue("MyKey"); | ||
call 2 MX#storageStore; | ||
|
||
push mxIntValue(12); | ||
push mxStringValue("MyKey"); | ||
call 2 MX#storageLoad; | ||
push_store_data; | ||
check_eq mxIntValue(12); | ||
check_eq wrappedMx(mxStringValue("World")) |