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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading