forked from hyperledger/fabric-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement TypeScript version of asset-transfer-ledger-queries
This commit implements the TypeScript version of the asset-transfer-ledger-queries Chaincode. Resolves hyperledger#1232 Signed-off-by: Satoshi Ito <satoshi.ito.tf@hitachi.com>
- Loading branch information
1 parent
aa0c9d3
commit 0d9e87d
Showing
8 changed files
with
607 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...sfer-ledger-queries/chaincode-typescript/META-INF/statedb/couchdb/indexes/indexOwner.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"index":{"fields":["docType","owner"]},"ddoc":"indexOwnerDoc", "name":"indexOwner","type":"json"} |
13 changes: 13 additions & 0 deletions
13
asset-transfer-ledger-queries/chaincode-typescript/eslint.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import js from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
export default tseslint.config(js.configs.recommended, ...tseslint.configs.strictTypeChecked, { | ||
languageOptions: { | ||
ecmaVersion: 2023, | ||
sourceType: 'module', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}); |
25 changes: 25 additions & 0 deletions
25
asset-transfer-ledger-queries/chaincode-typescript/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "asset-transfer-ledger-queries", | ||
"version": "0.0.1", | ||
"description": "Hyperledger Fabric Asset Transfer Chaincode written in TypeScript", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"lint": "eslint src", | ||
"start": "fabric-chaincode-node start" | ||
}, | ||
"author": "Hyperledger", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"fabric-contract-api": "~2.5", | ||
"fabric-shim": "~2.5" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.19.33", | ||
"@eslint/js": "^9.3.0", | ||
"@tsconfig/node18": "^18.2.4", | ||
"eslint": "^8.57.0", | ||
"typescript": "~5.4.5", | ||
"typescript-eslint": "^7.11.0" | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
asset-transfer-ledger-queries/chaincode-typescript/src/asset.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { Object, Property } from 'fabric-contract-api'; | ||
|
||
@Object() | ||
export class Asset { | ||
@Property() | ||
public docType?: string; | ||
|
||
@Property() | ||
public ID: string = ''; | ||
|
||
@Property() | ||
public color: string = ''; | ||
|
||
@Property() | ||
public size: number = 0; | ||
|
||
@Property() | ||
public owner: string = ''; | ||
|
||
@Property() | ||
public appraisedValue: number = 0; | ||
} | ||
|
||
@Object() | ||
export class HistoryQueryResult { | ||
@Property() | ||
record: Asset | null = null; | ||
|
||
@Property() | ||
txId: string = ''; | ||
|
||
@Property() | ||
timestamp: Date = new Date(0); | ||
|
||
@Property() | ||
isDelete: boolean = false; | ||
} | ||
|
||
@Object() | ||
export class PaginatedQueryResult { | ||
@Property() | ||
records: Asset[] = []; | ||
|
||
@Property() | ||
fetchedRecordsCount: number = 0; | ||
|
||
@Property() | ||
bookmark: string = ''; | ||
} |
Oops, something went wrong.