Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support contract parameter type List Signature #261

Closed
qiluge opened this issue Mar 17, 2020 · 1 comment
Closed

support contract parameter type List Signature #261

qiluge opened this issue Mar 17, 2020 · 1 comment

Comments

@qiluge
Copy link

qiluge commented Mar 17, 2020

let invoke = async () => {
    const contractAddress = 'KT1Jdcchcq1zBw1VTr1cMEPTTpQnikX3tXUq';
    const contractParameters = `parameter (or (unit %default) (pair %withdraw (pair (pair (mutez %amount) (list signature %signatures)) (address %to)) (string %txId)));`;
    const entryPoints = await conseilJS.TezosContractIntrospector.generateEntryPointsFromParams(contractParameters);
    entryPoints.forEach(p => {
        console.log(`${p.name}(${p.parameters.map(pp => (pp.name || 'unnamed') + '/' + pp.type).join(', ')})`);
    });
    const parameter = entryPoints[1].generateInvocationString(1200000,
        ["edsigtt9FQZSbtLvLx8UVZA1RJ29R7V9WUmmoSBjCcww1Y1pg3aXqWjspCFRc9kJ1MocXV7sMeULWtJuD8XLszQCk4J5FWC5ykh",
            "edsigtpzq77tPRMeK1n9kdUiTroMfvnmGBXiQNib5cpRnAi4tiUReVydHQskB3q4hLvkaxpDYqP7ecUXzc2dR1sAvvYDbMG1idL"],
            "tz1WfxXzNgcsMrQBV6YHChmyQgNVvfo44ihi", "123123123");
    console.log("parameter is %s", parameter);
    const nodeResult = await conseilJS.TezosNodeWriter.sendContractInvocationOperation(tezosServer, keys, contractAddress,
        0, 1000000, '', 60000, 800000, 'Withdraw',
        parameter, conseilJS.TezosParameterFormat.Michelson);
    let jsonResult = JSON.stringify(nodeResult);
    console.log(jsonResult);
};

invoke().catch(e =>
    console.log(e)
);

the code encourtered a problem:

Default(unnamed/unit)
Withdraw(Amount/mutez, Signatures/list (signature), To/address, TxId/string)
parameter is (Right (Pair (Pair (Pair 1200000 (edsigtt9FQZSbtLvLx8UVZA1RJ29R7V9WUmmoSBjCcww1Y1pg3aXqWjspCFRc9kJ1MocXV7sMeULWtJuD8XLszQCk4J5FWC5ykh,edsigtpzq77tPRMeK1n9kdUiTroMfvnmGBXiQNib5cpRnAi4tiUReVydHQskB3q4hLvkaxpDYqP7ecUXzc2dR1sAvvYDbMG1idL)) tz1WfxXzNgcsMrQBV6YHChmyQgNVvfo44ihi) 123123123))
Error: invalid syntax at line 1 col 35:

  (Right (Pair (Pair (Pair 1200000 (edsigtt9FQZSbtLvLx8UVZA1RJ29R7V9WUmmoSBjCcww1Y1pg3aXqWjspCFRc9kJ1MocXV7sMeULWtJuD8XLszQCk4J5FWC5ykh,edsigtpzq77tPRMeK1n9kdUiTroMfvnmGBXiQNib5cpRnAi4tiUReVydHQskB3q4hLvkaxpDYqP7ecUXzc2dR1sAvvYDbMG1idL)) tz1WfxXzNgcsMrQBV6YHChmyQgNVvfo44ihi) 123123123))
                                    ^
    at Lexer._token (G:\工作\tezos\xtz-wallet-service\node_modules\moo\moo.js:518:13)
    at Lexer.next (G:\工作\tezos\xtz-wallet-service\node_modules\moo\moo.js:465:19)
    at Parser.feed (G:\工作\tezos\xtz-wallet-service\node_modules\nearley\lib\nearley.js:270:30)
    at preProcessMichelsonScript.forEach.p (G:\工作\tezos\xtz-wallet-service\node_modules\conseiljs\dist\chain\tezos\TezosLanguageUtil.js:157:63)
    at Array.forEach (<anonymous>)
    at Object.translateParameterMichelsonToMicheline (G:\工作\tezos\xtz-wallet-service\node_modules\conseiljs\dist\chain\tezos\TezosLanguageUtil.js:157:41)
    at constructContractInvocationOperation (G:\工作\tezos\xtz-wallet-service\node_modules\conseiljs\dist\chain\tezos\TezosNodeWriter.js:310:79)
    at Object.<anonymous> (G:\工作\tezos\xtz-wallet-service\node_modules\conseiljs\dist\chain\tezos\TezosNodeWriter.js:291:33)
    at Generator.next (<anonymous>)
    at fulfilled (G:\工作\tezos\xtz-wallet-service\node_modules\conseiljs\dist\chain\tezos\TezosNodeWriter.js:4:58)

Process finished with exit code 0

I see the page of smartpy explorer http://smartpy.io/demo/explore.html?address=KT1Jdcchcq1zBw1VTr1cMEPTTpQnikX3tXUq shows it not support sp.TList(sp.TSignature)
image

So, if I want to use List Signature parameter to invoke contract, how should I write code. Can you give me some example?

Thanks!

@qiluge
Copy link
Author

qiluge commented Mar 17, 2020

transfer parameter to json code manually could solve this problem.

@qiluge qiluge closed this as completed Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant