I am trying to construct the storage needed to do an on chain contract call but I'm having trouble passing in the parameters. What is making it tricky is that one of the parameters is of type TContract, and next four parameters after that are associated with it.
Specifically, the parameters that corresponds to the types:
(pair (contract %k
(pair (pair (mutez %newCustBal) (mutez %newMerchBal))
(pair (bytes %newRevLock) (bool %valid))))
are supposed to be:
(Pair "KT1DskKf2HwDqoiL45PWZ7d72pn2jhfNxoos%receiveCall"
(Pair (Pair 1000000 29000000)
(Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))
But it seems to be affecting the pairing of the whole storage? Below is part of the output which contains the error including the whole storage parameter. In this pastebin link is the whole output from running the whole test, including the contract origination.
Invalid argument passed to contract KT1XLndPcmBKtsYcFtguZtstxeQKdLm2uxwy.
At (unshown) location 0, value
(Pair (Pair (Pair "randomchanid" (Pair 1000000 "dummy_g2"))
(Pair "KT1DskKf2HwDqoiL45PWZ7d72pn2jhfNxoos%receiveCall"
(Pair (Pair 1000000 29000000)
(Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))
(Pair 29000000 "dummy_merchPk0"))
(Pair (Pair "dummy_merchPk1" (Pair "dummy_merchPk2" "dummy_merchPk3"))
(Pair (Pair "dummy_merchPk4"
0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c)
(Pair "dummy_s1" "dummy_s2"))))
is invalid for type
pair (pair (pair (string %chanID) (pair (mutez %custBal) (string %g2)))
(pair (contract %k
(pair (pair (mutez %newCustBal) (mutez %newMerchBal))
(pair (bytes %newRevLock) (bool %valid))))
(pair (mutez %merchBal) (string %merchPk0))))
(pair (pair (string %merchPk1) (pair (string %merchPk2) (string %merchPk3)))
(pair (pair (string %merchPk4) (bytes %revLock)) (pair (string %s1) (string %s2)))).
At (unshown) location 1, primitive Pair expects 2 arguments but is given 3.
Fatal error:
transfer simulation failed
The issue with the above is that the second pair has three arguments (thanks FFF). However, if I fix this by putting it in another pair, I get a different error.
Invalid argument passed to contract KT1WHn9DZcF6Hg5k9LbzzUn8fe6KxELMs7vJ.
At (unshown) location 0, value
(Pair (Pair (Pair "randomchanid" (Pair 1000000 "dummy_g2"))
(Pair (Pair "KT1NcVoQseKE3ACPFEQCX19oVBh5ydEVdPaB%receiveCall"
(Pair (Pair 1000000 29000000)
(Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))
(Pair 29000000 "dummy_merchPk0")))
(Pair (Pair "dummy_merchPk1" (Pair "dummy_merchPk2" "dummy_merchPk3"))
(Pair (Pair "dummy_merchPk4"
0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c)
(Pair "dummy_s1" "dummy_s2"))))
is invalid for type
pair (pair (pair (string %chanID) (pair (mutez %custBal) (string %g2)))
(pair (contract %k
(pair (pair (mutez %newCustBal) (mutez %newMerchBal))
(pair (bytes %newRevLock) (bool %valid))))
(pair (mutez %merchBal) (string %merchPk0))))
(pair (pair (string %merchPk1) (pair (string %merchPk2) (string %merchPk3)))
(pair (pair (string %merchPk4) (bytes %revLock)) (pair (string %s1) (string %s2)))).
At (unshown) location 7, value
(Pair (Pair "KT1NcVoQseKE3ACPFEQCX19oVBh5ydEVdPaB%receiveCall"
(Pair (Pair 1000000 29000000)
(Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))
(Pair 29000000 "dummy_merchPk0"))
is invalid for type
pair (contract %k
(pair (pair (mutez %newCustBal) (mutez %newMerchBal))
(pair (bytes %newRevLock) (bool %valid))))
(pair (mutez %merchBal) (string %merchPk0)).
At (unshown) location 8, value
(Pair "KT1NcVoQseKE3ACPFEQCX19oVBh5ydEVdPaB%receiveCall"
(Pair (Pair 1000000 29000000)
(Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))
is invalid for type
contract
(pair (pair (mutez %newCustBal) (mutez %newMerchBal))
(pair (bytes %newRevLock) (bool %valid))).
At (unshown) location 8, unexpected primitive, only a string or a byte
sequence can be used here.
Fatal error:
transfer simulation failed
The issue seems to be with the types associated with the output of the contract call.
(contract %k (pair (pair (mutez %newCustBal) (mutez %newMerchBal)) (pair (bytes %newRevLock) (bool %valid))))
should be "KT1.."; not something else.