2

Can't pass optional params in Contract method. If I mark arg as optional I'm getting error from HL(version 1.4):

class MyContract extends Contract {

  async someMethod(ctx, arg1, arg2, optionalArg = undefined) {
   // do smth
  }

}

// And when I'm calling from client

const res = await contract.submitTransaction('someMethod', 'arg1', 'arg2', 'optional');

// I'm getting arguments error

[DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:0 - endorsement failed - 
Error: transaction returned with failure: 
Error: Expected 2 parameters, but 3 have been supplied

So Contract method somehow awaits only 2 parameters, but I defined 3...

MR.QUESTION
  • 359
  • 2
  • 9
  • 1
    Does it work ok if optionalArg doesn't have a default value ? If so then I suggest you raise a jira for the FABCN project at https://jira.hyperledger.org – david_k Feb 10 '20 at 14:22
  • @david_k thanks for answer. Nope, then it expects this parameter and throwing error. – MR.QUESTION Feb 11 '20 at 09:46
  • 1
    So it's a problem using parameters with default values, looks like it doesn't work. You will need to raise an issue at https://jira.hyperledger.org against the Fabric Chaincode Node project (FABCN). – david_k Feb 11 '20 at 13:22

0 Answers0