HyperledgerHandsOn / trade-finance-logistics

Trade Finance and Logistics based on Letter of Credit and Proof of Shipment
Apache License 2.0
178 stars 1.5k forks source link

error invoke requestTrade #44

Open woodyjon opened 5 years ago

woodyjon commented 5 years ago

in page 106, I do $ peer chaincode invoke -n tw -c '{"Args":["requestTrade","50000","Wood for Toys"]}' -C tradechannel. I get the following error: Incorrect number of arguments. Expecting 3: {ID, Amount, Description of Goods}. Found 2)

It seems logical to me as the in the go code of func requestTrade() (in tradeWorkflow.go), the args is only 2 elements long as the name of the function is not included. But then also, I do not understand what you expect in line 206 in args[0] when you do tradeKey, err = getTradeKey(stub, args[0])

I use trade-finance-logistics master, fabric 1.1, trade_workflow_v1.

Thank you for your support.

VRamakrishna commented 5 years ago

Please check the errata I mentioned on the other thread. We noticed a few errors as well as the version number omission and submitted them to the publishers.

If you can't find the errata on the Packt site, I'll post it here.

woodyjon commented 5 years ago

Ho I see. Yes indeed, it works with the errata ;-) Big thank you for getting back so quickly.

For people who encounter the same issue, here it is:

Full errata here: https://www.packtpub.com/books/content/support/33475

specifically for this issue:

Errata type: code Page no 106

This:

  1. Put a new trade agreement on the ledger with the following command: $ peer chaincode invoke -n tw -c '{"Args":["requestTrade", "50000", "Wood for Toys"]}' -C tradechannel
  2. Retrieve the trade agreement from the ledger with the following command: $ peer chaincode invoke -n tw -c '{"Args":["getTradeStatus", "50000"]}' -C tradechannel

Should be:

  1. Put a new trade agreement with a unique ID trade-12 on the ledger with the following command: $ peer chaincode invoke -n tw -c '{"Args":["requestTrade", "trade-12", "50000", "Wood for Toys"]}' -C tradechannel

  2. Retrieve the trade agreement with the ID trade-12 from the ledger with the following command: $ peer chaincode invoke -n tw -c '{"Args":["getTradeStatus", "trade-12"]}' -C tradechannel