-
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.
- Loading branch information
1 parent
c98f1ca
commit f5f9185
Showing
6 changed files
with
143 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
```k | ||
module MX-ACCOUNTS-CONFIGURATION | ||
imports INT-SYNTAX | ||
imports STRING-SYNTAX | ||
configuration | ||
<mx-accounts> | ||
<mx-account multiplicity="*" type="Map"> | ||
// TODO: The address should be bytes. | ||
<mx-account-address> "" </mx-account-address> | ||
<mx-esdt-datas> | ||
<mx-esdt-data multiplicity="*" type="Map"> | ||
// TODO: The esdt-id should be bytes. | ||
<mx-esdt-id> | ||
<mx-esdt-id-name> "" </mx-esdt-id-name> | ||
<mx-esdt-id-nonce> 0 </mx-esdt-id-nonce> | ||
</mx-esdt-id> | ||
<mx-esdt-balance> 0 </mx-esdt-balance> | ||
</mx-esdt-data> | ||
</mx-esdt-datas> | ||
</mx-account> | ||
</mx-accounts> | ||
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,35 @@ | ||
```k | ||
module MX-ACCOUNTS-HOOKS | ||
imports private COMMON-K-CELL | ||
imports private MX-ACCOUNTS-CONFIGURATION | ||
imports private MX-COMMON-SYNTAX | ||
rule | ||
<k> MX#bigIntGetESDTExternalBalance | ||
( mxStringValue(Owner:String) | ||
, mxStringValue(TokenId:String) | ||
, mxIntValue(Nonce:Int) | ||
, .MxHookArgs | ||
) => MX#bigIntNew(mxIntValue(Balance)) ... </k> | ||
<mx-account-address> Owner </mx-account-address> | ||
<mx-esdt-id> | ||
<mx-esdt-id-name> TokenId </mx-esdt-id-name> | ||
<mx-esdt-id-nonce> Nonce </mx-esdt-id-nonce> | ||
</mx-esdt-id> | ||
<mx-esdt-balance> Balance:Int </mx-esdt-balance> | ||
[priority(50)] | ||
rule | ||
<k> MX#bigIntGetESDTExternalBalance | ||
( mxStringValue(Owner:String) | ||
, mxStringValue(TokenId:String) | ||
, mxIntValue(Nonce:Int) | ||
, .MxHookArgs | ||
) => MX#bigIntNew(mxIntValue(0)) ... </k> | ||
<mx-account-address> Owner </mx-account-address> | ||
[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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
addAccount("Owner"); | ||
|
||
push mxIntValue(0); | ||
push mxStringValue("MyToken"); | ||
push mxStringValue("Owner"); | ||
call 3 MX#bigIntGetESDTExternalBalance; | ||
get_big_int; | ||
check_eq mxIntValue(0); | ||
|
||
setBalance("Owner", "MyToken", 0, 1234); | ||
|
||
push mxIntValue(0); | ||
push mxStringValue("MyToken"); | ||
push mxStringValue("Owner"); | ||
call 3 MX#bigIntGetESDTExternalBalance; | ||
get_big_int; | ||
check_eq mxIntValue(1234) |