Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emchristiansen/82c2a2f6d201afb47996042867c99416 to your computer and use it in GitHub Desktop.
Save emchristiansen/82c2a2f6d201afb47996042867c99416 to your computer and use it in GitHub Desktop.
Contract code:
{ parameter
(or (or (unit %default)
(pair %getBalance address (or (address %fA12) (pair %fA20 address nat))))
(or (nat %setTmp) (list %setTmpFromFA20Callback (pair (pair address nat) nat)))) ;
storage nat ;
code { SELF %setTmp ;
SELF %setTmpFromFA20Callback ;
DIG 2 ;
UNPAIR ;
IF_LEFT
{ IF_LEFT
{ DIG 2 ; DIG 3 ; DROP 3 ; NIL operation ; PAIR }
{ SWAP ;
DROP ;
UNPAIR ;
PUSH nat 0 ;
NIL operation ;
DIG 3 ;
IF_LEFT
{ DIG 4 ;
DROP ;
PUSH string "FA12 getBalance" ;
SWAP ;
CONTRACT %getBalance (pair address (contract nat)) ;
IF_NONE { PUSH string "None: " ; CONCAT ; FAILWITH } { SWAP ; DROP } ;
PUSH mutez 0 ;
DIG 5 ;
DIG 5 ;
PAIR ;
TRANSFER_TOKENS }
{ DIG 5 ;
DROP ;
UNPAIR ;
PUSH string "FA20 balance_of" ;
SWAP ;
CONTRACT %balance_of
(pair (list (pair address nat)) (contract (list (pair (pair address nat) nat)))) ;
IF_NONE { PUSH string "None: " ; CONCAT ; FAILWITH } { SWAP ; DROP } ;
PUSH mutez 0 ;
DIG 6 ;
NIL (pair address nat) ;
DIG 4 ;
DIG 7 ;
PAIR ;
CONS ;
PAIR ;
TRANSFER_TOKENS } ;
CONS ;
PAIR } }
{ SWAP ;
DIG 2 ;
DIG 3 ;
DROP 3 ;
IF_LEFT
{ NIL operation ; PAIR }
{ IF_CONS
{ CDR ;
SWAP ;
IF_CONS
{ DROP 3 ; PUSH string "FA20 callback argument length != 1" ; FAILWITH }
{ NIL operation ; PAIR } }
{ PUSH string "FA20 callback argument length != 1" ; FAILWITH } } } } }
Parameter:
(Left (Right
(Pair "tz1dkUXrcScDxMTUkNuzTg5iBRHevn7KFBMW"
(Left "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn"))))
Error:
"Either no parameter was supplied to a contract with a non-unit parameter type, a non-unit parameter was passed to an account, or a parameter was supplied of the wrong type",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment