mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
salt value unexported
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
This commit is contained in:
parent
815197bc86
commit
52a3e655a4
3 changed files with 7 additions and 9 deletions
|
|
@ -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<void> {
|
|||
|
||||
// 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,
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
||||
|
|
|
|||
|
|
@ -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<T>(data: string): T {
|
||||
return JSON.parse(data);
|
||||
}
|
||||
|
||||
export const randomBytes = crpto.randomBytes(256).toString('hex');
|
||||
|
|
|
|||
Loading…
Reference in a new issue