You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using promise.then fails when arguments are being passed to the callback function.
The logs confirm that the args are encoded correctly.
exportfunctionreverseWordThree(): void{constword=newWord("sample")constcontract="words.examples"constmethod="reverse"// setup args object for cross-contract call as key-value of contract method parameters// note: the method signature in the words contract is reverse(word: Word)letreverseArgs=newReverseArgs(word)letpromise=ContractPromise.create(contract,// contract account namemethod,// contract method namereverseArgs.encode(),// serialized contract method arguments encoded as Uint8Array10000000,// gas attached to the callu128.Zero// attached deposit to be sent with the call)// Setting up args for the callbackletresponseArgs=newReverseArgs(newWord("elpmas"));logging.log(responseArgs);// <-- this encodes it to print it.logging.log(context.contractName)letcallbackPromise=promise.then(context.contractName,"_onReverseCalledTwo",responseArgs.encode(),//<- Passing empty byte array works for function that doesn't expect args2);callbackPromise.returnAsResult();}exportfunction_onReverseCalledTwo(word: Word): bool{constdrow=word;letresults=ContractPromise.getResults();assert(results.length>0,"should be contract promise result");letreverseResult=results[0];// logging.log(results[0]);// Verifying the remote contract call succeeded.if(reverseResult.status==1){// Decoding data from the bytes buffer into the local object.letword=decode<Word>(reverseResult.buffer);logging.log(word);returnword.text==drow.text}returnfalse}
Describe the bug
Using
promise.then
fails when arguments are being passed to the callback function.The logs confirm that the args are encoded correctly.
To Reproduce
See https://gitpod.io/#https://github.com/near/near-sdk-as/tree/cross_contract_bug
It should fail on start, but to rerun
yarn test:vm
, or in thevm
directory,yarn ts-node test.ts
The test is
vm/test.ts
and the corresponding AS file isassembly/__tests__/sentences.ts
Expected behavior
Not fail when passing input args to
then
Screenshots
Version (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: