@@ -26,7 +26,7 @@ module ESDT
2626 | transferESDTsAux(Bytes, Bytes, List) [function, total]
2727 // -------------------------------------------------------------------
2828 rule transferESDTs(FROM, TO, L)
29- => transferESDTsAux(FROM, TO, L)
29+ => transferESDTsAux(FROM, TO, L)
3030 ~> appendToOutAccount(TO, OutputTransfer(FROM, L))
3131
3232 rule transferESDTsAux(FROM:Bytes, TO:Bytes, ListItem(T:ESDTTransfer) Ts)
@@ -45,7 +45,7 @@ module ESDT
4545 ~> addToESDTBalance(FROM, TOKEN, 0 -Int VALUE, false)
4646 ~> addToESDTBalance(TO, TOKEN, VALUE, true)
4747
48- rule transferESDT(FROM, TO, esdtTransfer(TOKEN, VALUE, NONCE))
48+ rule transferESDT(FROM, TO, esdtTransfer(TOKEN, VALUE, NONCE))
4949 => checkAccountExists(FROM)
5050 ~> checkAccountExists(TO)
5151 ~> checkESDTBalance(FROM, keyWithNonce(TOKEN, NONCE), VALUE)
@@ -146,18 +146,21 @@ module ESDT
146146 ...
147147 </account>
148148 // <instrs> (#waitCommands ~> _) #Or .K </instrs>
149- [priority(61)]
149+ [priority(61), preserves-definedness]
150+ // preserves-definedness:
151+ // - ACCT exists prior so the account map is defined
152+ // - TOKEN does not exist prior in esdtData, otherwise the rule above with higher priority would apply.
150153
151154 rule [addToESDTBalance-new-err-instrs-empty]:
152155 <commands> addToESDTBalance(_ACCT, _TOKEN, _DELTA, false)
153- => #exception(ExecutionFailed, b"new NFT data on sender")
156+ => #exception(ExecutionFailed, b"new NFT data on sender")
154157 ...
155158 </commands>
156159 <instrs> .K </instrs>
157160 [priority(61)]
158161 rule [addToESDTBalance-new-err-instrs-wait]:
159162 <commands> addToESDTBalance(_ACCT, _TOKEN, _DELTA, false)
160- => #exception(ExecutionFailed, b"new NFT data on sender")
163+ => #exception(ExecutionFailed, b"new NFT data on sender")
161164 ...
162165 </commands>
163166 <instrs> #waitCommands ... </instrs>
@@ -244,10 +247,10 @@ module ESDT
244247 rule BuiltinFunction2Bytes(#ESDTLocalMint) => b"ESDTLocalMint"
245248
246249 rule [ESDTLocalMint]:
247- <commands> processBuiltinFunction(#ESDTLocalMint, SND, DST, <vmInput>
250+ <commands> processBuiltinFunction(#ESDTLocalMint, SND, DST, <vmInput>
248251 <callValue> VALUE </callValue>
249252 <callArgs> ARGS </callArgs>
250- _
253+ _
251254 </vmInput>)
252255 => checkBool(VALUE ==Int 0, "built in function called with tx value is not allowed")
253256 ~> checkBool(size(ARGS) >=Int 2, "invalid arguments to process built-in function")
@@ -273,17 +276,17 @@ module ESDT
273276 rule BuiltinFunction2Bytes(#ESDTLocalBurn) => b"ESDTLocalBurn"
274277
275278 rule [ESDTLocalBurn]:
276- <commands> processBuiltinFunction(#ESDTLocalBurn, SND, DST, <vmInput>
279+ <commands> processBuiltinFunction(#ESDTLocalBurn, SND, DST, <vmInput>
277280 <callValue> VALUE </callValue>
278281 <callArgs> ARGS </callArgs>
279- _
282+ _
280283 </vmInput>)
281284 => checkBool(VALUE ==Int 0, "built in function called with tx value is not allowed")
282285 ~> checkBool(size(ARGS) >=Int 2, "invalid arguments to process built-in function")
283286 ~> checkBool(SND ==K DST, "invalid receiver address")
284287 ~> checkAccountExists(SND)
285288 // TODO If the token has the 'BurnRoleForAll' global property, skip 'checkAllowedToExecute'
286- ~> checkAllowedToExecute(SND, getArg(ARGS, 0), ESDTRoleLocalBurn)
289+ ~> checkAllowedToExecute(SND, getArg(ARGS, 0), ESDTRoleLocalBurn)
287290 ~> checkBool( lengthBytes(getArg(ARGS, 1)) <=Int 100
288291 , "invalid arguments to process built-in function")
289292 ~> checkESDTBalance(SND, getArg(ARGS, 0), getArgUInt(ARGS, 1))
@@ -304,10 +307,10 @@ module ESDT
304307 rule BuiltinFunction2Bytes(#ESDTNFTBurn) => b"ESDTNFTBurn"
305308
306309 rule [ESDTNFTBurn]:
307- <commands> processBuiltinFunction(#ESDTNFTBurn, SND, DST, <vmInput>
310+ <commands> processBuiltinFunction(#ESDTNFTBurn, SND, DST, <vmInput>
308311 <callValue> VALUE </callValue>
309312 <callArgs> ARGS </callArgs>
310- _
313+ _
311314 </vmInput>)
312315 => checkBool(VALUE ==Int 0, "built in function called with tx value is not allowed")
313316 ~> checkBool(size(ARGS) >=Int 2, "invalid arguments to process built-in function")
@@ -346,11 +349,11 @@ module ESDT
346349 rule BuiltinFunction2Bytes(#ESDTTransfer) => b"ESDTTransfer"
347350
348351 rule [ESDTTransfer]:
349- <commands> processBuiltinFunction(#ESDTTransfer, SND, DST,
350- <vmInput>
352+ <commands> processBuiltinFunction(#ESDTTransfer, SND, DST,
353+ <vmInput>
351354 <callValue> VALUE </callValue>
352355 <callArgs> ARGS </callArgs>
353- _
356+ _
354357 </vmInput> #as VMINPUT)
355358 => checkBool(VALUE ==Int 0, "built in function called with tx value is not allowed")
356359 ~> checkBool(size(ARGS) >=Int 2, "invalid arguments to process built-in function")
@@ -373,11 +376,11 @@ module ESDT
373376 [symbol(determineIsSCCallAfter)]
374377 // ----------------------------------------------
375378 rule [determineIsSCCallAfter-call]:
376- <commands> determineIsSCCallAfter(SND, DST, FUNC, <vmInput>
379+ <commands> determineIsSCCallAfter(SND, DST, FUNC, <vmInput>
377380 <callArgs> ARGS </callArgs>
378381 <gasProvided> GAS </gasProvided>
379382 <gasPrice> GAS_PRICE </gasPrice>
380- _
383+ _
381384 </vmInput>)
382385 => newWasmInstance(DST, CODE)
383386 ~> mkCall( DST
@@ -431,11 +434,11 @@ module ESDT
431434 rule BuiltinFunction2Bytes(#MultiESDTNFTTransfer) => b"MultiESDTNFTTransfer"
432435
433436 rule [MultiESDTNFTTransfer]:
434- <commands> processBuiltinFunction(#MultiESDTNFTTransfer, SND, DST,
435- <vmInput>
437+ <commands> processBuiltinFunction(#MultiESDTNFTTransfer, SND, DST,
438+ <vmInput>
436439 <callValue> VALUE </callValue>
437440 <callArgs> ARGS </callArgs>
438- _
441+ _
439442 </vmInput> #as VMINPUT)
440443 => checkBool(VALUE ==Int 0, "built in function called with tx value is not allowed")
441444 ~> checkBool(size(ARGS) >=Int 4, "invalid arguments to process built-in function")
@@ -480,8 +483,8 @@ module ESDT
480483 rule parseESDTTransfers(_, _) => .List
481484 [owise]
482485
483- rule parseESDTTransfersH(N, ListItem(wrap(TOK)) ListItem(wrap(NONCE)) ListItem(wrap(AMT)) REST)
484- => ListItem( esdtTransfer(
486+ rule parseESDTTransfersH(N, ListItem(wrap(TOK)) ListItem(wrap(NONCE)) ListItem(wrap(AMT)) REST)
487+ => ListItem( esdtTransfer(
485488 TOK, Bytes2Int(AMT, BE, Unsigned), Bytes2Int(NONCE, BE, Unsigned)
486489 ))
487490 parseESDTTransfersH(N -Int 1, REST)
@@ -501,11 +504,11 @@ module ESDT
501504 rule BuiltinFunction2Bytes(#ESDTNFTCreate) => b"ESDTNFTCreate"
502505
503506 rule [ESDTNFTCreate]:
504- <commands> processBuiltinFunction(#ESDTNFTCreate, SND, DST,
505- <vmInput>
507+ <commands> processBuiltinFunction(#ESDTNFTCreate, SND, DST,
508+ <vmInput>
506509 <callValue> VALUE </callValue>
507510 <callArgs> ARGS </callArgs>
508- _
511+ _
509512 </vmInput>)
510513 => checkBool(VALUE ==Int 0, "built in function called with tx value is not allowed")
511514 ~> checkBool(size(ARGS) >=Int 7, "invalid arguments to process built-in function")
@@ -546,7 +549,7 @@ module ESDT
546549 // --------------------------------------------------------------------------------------------
547550 rule ESDTNFTCreate.meta(SND, ARGS)
548551 => esdtMetadata( ...
549- name: getArg(ARGS, 2),
552+ name: getArg(ARGS, 2),
550553 nonce: getLatestNonce(SND, ESDTNFTCreate.token(ARGS)) +Int 1,
551554 creator: SND,
552555 royalties: getArgUInt(ARGS, 3),
@@ -615,11 +618,11 @@ module ESDT
615618 rule BuiltinFunction2Bytes(#ESDTNFTAddQuantity) => b"ESDTNFTAddQuantity"
616619
617620 rule [ESDTNFTAddQuantity]:
618- <commands> processBuiltinFunction(#ESDTNFTAddQuantity, SND, DST,
619- <vmInput>
621+ <commands> processBuiltinFunction(#ESDTNFTAddQuantity, SND, DST,
622+ <vmInput>
620623 <callValue> VALUE </callValue>
621624 <callArgs> ARGS </callArgs>
622- _
625+ _
623626 </vmInput>)
624627
625628 => checkBool(VALUE ==Int 0, "built in function called with tx value is not allowed")
@@ -665,11 +668,11 @@ module ESDT
665668 rule BuiltinFunction2Bytes(#ESDTNFTTransfer) => b"ESDTNFTTransfer"
666669
667670 rule [ESDTNFTTransfer]:
668- <commands> processBuiltinFunction(#ESDTNFTTransfer, SND, DST,
669- <vmInput>
671+ <commands> processBuiltinFunction(#ESDTNFTTransfer, SND, DST,
672+ <vmInput>
670673 <callValue> VALUE </callValue>
671674 <callArgs> ARGS </callArgs>
672- _
675+ _
673676 </vmInput> #as VMINPUT)
674677
675678 => checkBool(VALUE ==Int 0, "built in function called with tx value is not allowed")
@@ -695,11 +698,11 @@ module ESDT
695698
696699 // ESDTNFTAddURI & TOKEN & NONCE & URI1 & URI2 ...
697700 rule [ESDTNFTAddURI]:
698- <commands> processBuiltinFunction(#ESDTNFTAddURI, SND, DST,
699- <vmInput>
701+ <commands> processBuiltinFunction(#ESDTNFTAddURI, SND, DST,
702+ <vmInput>
700703 <callValue> VALUE </callValue>
701704 <callArgs> ARGS </callArgs>
702- _
705+ _
703706 </vmInput>)
704707
705708 => checkBool(VALUE ==Int 0, "built in function called with tx value is not allowed")
@@ -779,7 +782,7 @@ module ESDT
779782 [priority(60)]
780783
781784 rule [checkAllowedToExecute-fail]:
782- <commands> checkAllowedToExecute(_ADDR, _TOK, _ROLE)
785+ <commands> checkAllowedToExecute(_ADDR, _TOK, _ROLE)
783786 => #exception(UserError, b"action is not allowed") ...
784787 </commands>
785788 <instrs> .K </instrs>
0 commit comments