Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

satoshi-ito-ht
Copy link
Contributor

This commit implements the TypeScript version of the asset-transfer-ledger-queries Chaincode.

Resolves #1232

This commit implements the TypeScript version of the asset-transfer-ledger-queries Chaincode.

Resolves hyperledger#1232

Signed-off-by: Satoshi Ito <[email protected]>
@satoshi-ito-ht satoshi-ito-ht requested a review from a team as a code owner February 27, 2025 05:51
@satota2 satota2 self-requested a review March 7, 2025 11:04
Copy link
Member

@bestbeforetoday bestbeforetoday left a 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:

  1. 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.
  2. 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 run npm install && npm shrinkwrap locally, then check in the created shrinkwrap file.
  3. Add a .gitignore in the asset-transfer-ledger-queries/chaincode-typescript directory to ignore the dist subdirectory generated by the TypeScript compilation.
  4. Add typescript to the chaincode-language matrix in .github/workflows/test-network-ledger.yaml so this chaincode is tested by the automated build.

Copy link
Contributor

@satota2 satota2 left a 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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)));
Copy link
Contributor

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;
Copy link
Contributor

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add TypeScript version of asset-transfer-ledger-queries chaincode
3 participants