-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Implement TypeScript version of asset-transfer-ledger-queries #1309
base: main
Are you sure you want to change the base?
Implement TypeScript version of asset-transfer-ledger-queries #1309
Conversation
This commit implements the TypeScript version of the asset-transfer-ledger-queries Chaincode. Resolves hyperledger#1232 Signed-off-by: Satoshi Ito <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Some small changes I think are needed before merging:
- Remove
tslint.json
. The sample uses eslint (with typescript-eslint), not the deprecated tslint. I don't think think this tslint configuration file is used. - Include an
npm-shrinkwrap.json
file to minimise the chances of future breakages when dependencies release new versions by pinning the resolved dependency versions. Just runnpm install && npm shrinkwrap
locally, then check in the created shrinkwrap file. - Add a
.gitignore
in theasset-transfer-ledger-queries/chaincode-typescript
directory to ignore thedist
subdirectory generated by the TypeScript compilation. - Add
typescript
to the chaincode-language matrix in.github/workflows/test-network-ledger.yaml
so this chaincode is tested by the automated build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@satoshi-ito-ht
Thank you for your contribution.
I've also added some review comments, so please check them out.
|
||
@Info({ | ||
title: 'AssetTransfer', | ||
description: 'Smart contract for trading assets', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: 'Smart contract for trading assets', | |
description: 'Smart Contract for asset transfer ledger sample', |
It would be better to change the description to match the sample.
appraisedValue, | ||
}; | ||
|
||
await ctx.stub.putState(assetID, Buffer.from(JSON.stringify(asset))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it is not essential, in order to maintain JSON consistency, it seems better to use json-stringify-deterministic
and sort-keys-recursive
when inserting data, in the same way as asset-transfer-basic.
Please refer to here.
asset = JSON.parse(historyRecord.value.toString()) as Asset; | ||
} | ||
// Convert the timestamp to a Date object. | ||
const seconds = historyRecord.timestamp.seconds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timestamp includes nanos as a field, so I think it is necessary to convert this to Date as well.
interface Timestamp {
seconds: Long;
nanos: number;
}
This commit implements the TypeScript version of the asset-transfer-ledger-queries Chaincode.
Resolves #1232