-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Secured agreement samples using gateway (#630)
* initial commit Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> Code refactor Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * readme Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * lint fix Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * adopted best practises Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * code refactor Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * updated azure pipeline to include the app Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * mapped json and client object Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * Moved contract interactions to contractWrapper Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * salt value unexported Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * moved try catch from contract wrapper to app Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * contract wrapper refactor moved interfaces from utils to contract wrapper Signed-off-by: sapthasurendran <saptha.surendran@ibm.com> * exported data objects Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
- Loading branch information
1 parent
8662b10
commit 4681fe7
Showing
10 changed files
with
847 additions
and
0 deletions.
There are no files selected for viewing
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,64 @@ | ||
# Asset transfer secured agreement sample | ||
|
||
The asset transfer events sample demonstrates how to transfer a private asset between two organizations without publicly sharing data . | ||
|
||
## About the sample | ||
|
||
This sample includes smart contract and application code in multiple languages. This sample shows how Fabric features state based endorsement, private data, and access control to provide secured transactions. | ||
|
||
### Application | ||
|
||
Refer [Secured asset transfer in Fabric](https://hyperledger-fabric.readthedocs.io/en/latest/secured_asset_transfer/secured_private_asset_transfer_tutorial.html) for application details . | ||
|
||
### Smart Contract | ||
|
||
The smart contract (in folder `chaincode-go`) implements the following functions to support the application: | ||
|
||
- CreateAsset | ||
- ChangePublicDescription | ||
- AgreeToSell | ||
- AgreeToBuy | ||
- VerifyAssetProperties | ||
- TransferAsset | ||
- ReadAsset | ||
- GetAssetPrivateProperties | ||
- GetAssetSalesPrice | ||
- GetAssetBidPrice | ||
- QueryAssetSaleAgreements | ||
- QueryAssetBuyAgreements | ||
- QueryAssetHistory | ||
|
||
## Running the sample | ||
|
||
Like other samples, the Fabric test network is used to deploy and run this sample. Follow these steps in order: | ||
|
||
1. Create the test network and a channel (from the `test-network` folder). | ||
``` | ||
./network.sh up createChannel -c mychannel -ca | ||
``` | ||
|
||
1. Deploy the smart contract implementations. | ||
``` | ||
# To deploy the go chaincode implementation | ||
./network.sh deployCC -ccn secured -ccp ../asset-transfer-secured-agreement/chaincode-go/ -ccl go -ccep "OR('Org1MSP.peer','Org2MSP.peer')" | ||
``` | ||
|
||
1. Run the application (from the `asset-transfer-secured-agreement` folder). | ||
``` | ||
# To run the Typescript sample application | ||
cd application-gateway-typescript | ||
npm install | ||
npm start | ||
# To run the Javascript sample application | ||
cd application-javascript | ||
node app.js | ||
``` | ||
|
||
## Clean up | ||
|
||
When you are finished, you can bring down the test network (from the `test-network` folder). The command will remove all the nodes of the test network, and delete any ledger data that you created. | ||
|
||
``` | ||
./network.sh down | ||
``` |
102 changes: 102 additions & 0 deletions
102
asset-transfer-secured-agreement/application-gateway-typescript/.eslintrc.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,102 @@ | ||
{ | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"root": true, | ||
"ignorePatterns": [ | ||
"dist/" | ||
], | ||
"extends": [ | ||
"eslint:recommended" | ||
], | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
4 | ||
], | ||
"quotes": [ | ||
"error", | ||
"single" | ||
] | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.ts" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"impliedStrict": true | ||
}, | ||
"project": [ | ||
"./tsconfig.json" | ||
] | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"rules": { | ||
"@typescript-eslint/comma-spacing": [ | ||
"error" | ||
], | ||
"@typescript-eslint/explicit-function-return-type": [ | ||
"error", | ||
{ | ||
"allowExpressions": true | ||
} | ||
], | ||
"@typescript-eslint/func-call-spacing": [ | ||
"error" | ||
], | ||
"@typescript-eslint/member-delimiter-style": [ | ||
"error" | ||
], | ||
"@typescript-eslint/indent": [ | ||
"error", | ||
4, | ||
{ | ||
"SwitchCase": 0 | ||
} | ||
], | ||
"@typescript-eslint/prefer-nullish-coalescing": [ | ||
"error" | ||
], | ||
"@typescript-eslint/prefer-optional-chain": [ | ||
"error" | ||
], | ||
"@typescript-eslint/prefer-reduce-type-parameter": [ | ||
"error" | ||
], | ||
"@typescript-eslint/prefer-return-this-type": [ | ||
"error" | ||
], | ||
"@typescript-eslint/quotes": [ | ||
"error", | ||
"single" | ||
], | ||
"@typescript-eslint/type-annotation-spacing": [ | ||
"error" | ||
], | ||
"@typescript-eslint/semi": [ | ||
"error" | ||
], | ||
"@typescript-eslint/space-before-function-paren": [ | ||
"error", | ||
{ | ||
"anonymous": "never", | ||
"named": "never", | ||
"asyncArrow": "always" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
14 changes: 14 additions & 0 deletions
14
asset-transfer-secured-agreement/application-gateway-typescript/.gitignore
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,14 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Compiled TypeScript files | ||
dist |
32 changes: 32 additions & 0 deletions
32
asset-transfer-secured-agreement/application-gateway-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,32 @@ | ||
{ | ||
"name": "asset-transfer-basic", | ||
"version": "1.0.0", | ||
"description": "Asset Transfer Secured Agreement Application implemented in typeScript using fabric-gateway", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"engines": { | ||
"node": ">=14" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"build:watch": "tsc -w", | ||
"lint": "eslint . --ext .ts", | ||
"prepare": "npm run build", | ||
"pretest": "npm run lint", | ||
"start": "node dist/app.js" | ||
}, | ||
"engineStrict": true, | ||
"author": "Hyperledger", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@hyperledger/fabric-gateway": "^1.0.0", | ||
"@grpc/grpc-js": "^1.5.0" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/node14": "^1.0.1", | ||
"@typescript-eslint/eslint-plugin": "^5.6.0", | ||
"@typescript-eslint/parser": "^5.6.0", | ||
"eslint": "^8.4.1", | ||
"typescript": "~4.5.2" | ||
} | ||
} |
Oops, something went wrong.