Skip to content

Commit

Permalink
Implement TypeScript version of asset-transfer-ledger-queries
Browse files Browse the repository at this point in the history
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
satoshi-ito-ht committed Feb 27, 2025
1 parent aa0c9d3 commit 0d9e87d
Show file tree
Hide file tree
Showing 8 changed files with 607 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"index":{"fields":["docType","owner"]},"ddoc":"indexOwnerDoc", "name":"indexOwner","type":"json"}
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 asset-transfer-ledger-queries/chaincode-typescript/package.json
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 asset-transfer-ledger-queries/chaincode-typescript/src/asset.ts
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 = '';
}
Loading

0 comments on commit 0d9e87d

Please sign in to comment.