Kunstmaan / Kunstmaan/hyperledger-fabric-node-chaincode-utils

parseParameters requires a parameter to be JSON

Open
#11 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
21
Forks
14
PR merge metrics
No merged PRs in 30d

Description

TL;DR parseParameters shouldn't write a error level log for failure to JSON parse an arg. Make it debug level.

---

parseParameters works fine if you are sending your chaincode arguments as JSON objects or numbers. But litters error logs if you don't... which seems unnecessary.

Example:
['changeOwner', 'asset_1', 'user_2'] would result in 2 error logs
- "failed to parse param user_1"
- "failed to parse param user_2"

I guess the assumption is that developers will send those arguments as an array:
['changeOwner', ['asset_1', 'user_2']]
However, doing this makes destructing parsedParameters in ChaincodeBase.js:105 less useful
` let payload = await method.call(this, stub, this.getTransactionHelperFor(stub), ...parsedParameters);`

Example ideal use case:
```
// In chaincode
function changeOwner(asset, new_owner){
// Change the asset owner.
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at parseParameters and its use in ChaincodeBase.js:105, then inspect how non-JSON arguments are logged. Confirm that ordinary string arguments no longer produce error-level messages while JSON parsing behavior remains unchanged; verify the resulting logging behavior with the project's existing checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
blockchain
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.