From 52a3e655a40472e398e59f6a02be33a0e569509b Mon Sep 17 00:00:00 2001 From: sapthasurendran Date: Fri, 20 May 2022 14:31:42 +0530 Subject: [PATCH] salt value unexported Signed-off-by: sapthasurendran --- .../application-gateway-typescript/src/app.ts | 5 ++--- .../application-gateway-typescript/src/contractWrapper.ts | 8 +++++--- .../application-gateway-typescript/src/utils.ts | 3 --- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/asset-transfer-secured-agreement/application-gateway-typescript/src/app.ts b/asset-transfer-secured-agreement/application-gateway-typescript/src/app.ts index 40e90a57..4a0bd2ff 100644 --- a/asset-transfer-secured-agreement/application-gateway-typescript/src/app.ts +++ b/asset-transfer-secured-agreement/application-gateway-typescript/src/app.ts @@ -8,7 +8,6 @@ import { connect } from '@hyperledger/fabric-gateway'; import { newGrpcConnection, newIdentity, newSigner, tlsCertPathOrg1, peerEndpointOrg1, peerNameOrg1, certPathOrg1, mspIdOrg1, keyDirectoryPathOrg1, tlsCertPathOrg2, peerEndpointOrg2, peerNameOrg2, certPathOrg2, mspIdOrg2, keyDirectoryPathOrg2 } from './connect'; import { ContractWrapper } from './contractWrapper'; -import { randomBytes } from './utils'; const channelName = 'mychannel'; const chaincodeName = 'secured'; @@ -50,11 +49,11 @@ async function main(): Promise { // Get the smart contract from the network for Org1. const contractOrg1 = gatewayOrg1.getNetwork(channelName).getContract(chaincodeName); - const contractWrapperOrg1 = new ContractWrapper(contractOrg1, mspIdOrg1, randomBytes); + const contractWrapperOrg1 = new ContractWrapper(contractOrg1, mspIdOrg1); // Get the smart contract from the network for Org2. const contractOrg2 = gatewayOrg2.getNetwork(channelName).getContract(chaincodeName); - const contractWrapperOrg2 = new ContractWrapper(contractOrg2, mspIdOrg2, randomBytes); + const contractWrapperOrg2 = new ContractWrapper(contractOrg2, mspIdOrg2); // Create an asset by organization Org1, this only requires the owning organization to endorse. await contractWrapperOrg1.createAsset({ AssetId: assetKey, diff --git a/asset-transfer-secured-agreement/application-gateway-typescript/src/contractWrapper.ts b/asset-transfer-secured-agreement/application-gateway-typescript/src/contractWrapper.ts index 724eec6e..fdaca2c5 100644 --- a/asset-transfer-secured-agreement/application-gateway-typescript/src/contractWrapper.ts +++ b/asset-transfer-secured-agreement/application-gateway-typescript/src/contractWrapper.ts @@ -6,18 +6,20 @@ import { Contract } from '@hyperledger/fabric-gateway'; import { TextDecoder } from 'util'; import { Asset, AssetJSON, AssetPrice, AssetPriceJSON, AssetPrivateData, AssetProperties, AssetPropertiesJSON, GREEN, parse, RED, RESET } from './utils'; +import crpto from 'crypto'; + +const randomBytes = crpto.randomBytes(256).toString('hex'); export class ContractWrapper { readonly #contract: Contract; readonly #org: string; readonly #utf8Decoder = new TextDecoder(); - readonly #randomBytes: string; + readonly #randomBytes: string = randomBytes; - public constructor(contract: Contract, org: string, randomBytes: string) { + public constructor(contract: Contract, org: string) { this.#contract = contract; this.#org = org; - this.#randomBytes = randomBytes; } public async createAsset(asset: Asset, privateData: AssetPrivateData): Promise { diff --git a/asset-transfer-secured-agreement/application-gateway-typescript/src/utils.ts b/asset-transfer-secured-agreement/application-gateway-typescript/src/utils.ts index 5cc9c419..73b9ec6a 100644 --- a/asset-transfer-secured-agreement/application-gateway-typescript/src/utils.ts +++ b/asset-transfer-secured-agreement/application-gateway-typescript/src/utils.ts @@ -3,7 +3,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ -import crpto from 'crypto'; export const RED = '\x1b[31m\n'; export const GREEN = '\x1b[32m\n'; @@ -56,5 +55,3 @@ export interface AssetPrice { export function parse(data: string): T { return JSON.parse(data); } - -export const randomBytes = crpto.randomBytes(256).toString('hex');