How to use the fabric-network.Wallets.newCouchDBWallet function in fabric-network

To help you get started, we’ve selected a few fabric-network examples, based on popular ways it is used in public projects.

github hyperledger / fabric-sdk-node / test / ts-scenario / steps / lib / gateway.ts View on Github external
if (!wallet) {
		BaseUtils.logMsg(`Creating wallet of type ${walletType}`);
		switch (walletType) {
			case Constants.MEMORY_WALLET:
				wallet = await Wallets.newInMemoryWallet();
				break;
			case Constants.FILE_WALLET:
				const tempDir: string = path.join(__dirname, Constants.LIB_TO_TEMP, Constants.FILE_WALLET);
				if (fs.existsSync(tempDir)) {
					BaseUtils.recursiveDirDelete(tempDir);
				}
				await fs.mkdirSync(tempDir);
				wallet = await Wallets.newFileSystemWallet(tempDir);
				break;
			case Constants.COUCH_WALLET:
				wallet = await Wallets.newCouchDBWallet({url: Constants.COUCH_WALLET_URL as string});
				break;
			default:
				BaseUtils.logAndThrow(`Unmatched wallet backing store`);
		}
	}

	// Might already have a user@org in that wallet
	const userId: string = `${userName}@${orgName}`;
	const userIdentity: Identity | undefined = await wallet.get(userId);

	// Will always be adding a gateway
	const gateway: Gateway = new Gateway();

	if (userIdentity) {
		// We have an identity to use
		BaseUtils.logMsg(`Identity ${userId} already exists in wallet and will be used`);
github hyperledger / fabric-sdk-node / test / typescript / integration / network-e2e / invoke.ts View on Github external
test('\n\n***** Network End-to-end flow: invoke transaction to move money using CouchDB wallet *****\n\n', async (t: tape.Test) => {
	const gateway = new Gateway();
	try {
		const couchDBWallet = await Wallets.newCouchDBWallet({url: 'http://localhost:5984'});
		await identitySetup(couchDBWallet);

		await gateway.connect(JSON.parse(ccp.toString()), {
			clientTlsIdentity: tlsIdentityName,
			discovery: {
				enabled: false,
			},
			identity: identityName,
			wallet: couchDBWallet,
		});
		t.pass('Connected to the gateway');

		const network = await gateway.getNetwork(channelName);
		t.pass('Initialized the channel, ' + channelName);

		const contract = await network.getContract(chaincodeId);