How to use the fabric-network.DefaultEventHandlerStrategies.NETWORK_SCOPE_ANYFORTX 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.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

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 in memory wallet and NETWORK_SCOPE_ANYFORTX event strategy *****\n\n', async (t: tape.Test) => {
	const gateway = new Gateway();
	let org1EventHub: ChannelEventHub | undefined;
	let org2EventHub: ChannelEventHub | undefined;

	try {
		const wallet = await getWallet();
		const contract = await createContract(t, gateway, {
			clientTlsIdentity: tlsIdentityName,
			discovery: {
				enabled: false,
			eventHandlerOptions: {
				strategy: DefaultEventHandlerStrategies.NETWORK_SCOPE_ANYFORTX,
			identity: identityName,

		const transaction = contract.createTransaction('move');
		const transactionId = transaction.getTransactionID().getTransactionID();

		// Obtain an event hub that that will be used by the underlying implementation
		org1EventHub = await getInternalEventHubForOrg(gateway, 'Org1MSP');
		org2EventHub = await getInternalEventHubForOrg(gateway, 'Org2MSP');

		let org1EventFired = 0;
		let org2EventFired = 0;
		org1EventHub.registerTxEvent('all', (txId, code) => {
			if (code === 'VALID' && txId === transactionId) {
github hyperledger / fabric-sdk-node / test / ts-scenario / steps / lib / gateway.ts View on Github external
import { DefaultEventHandlerStrategies, DefaultQueryHandlerStrategies, Gateway, GatewayOptions, Wallet, Wallets, Identity, Contract, Network, TxEventHandlerFactory, QueryHandlerFactory, EventHubManager, Transaction, TransientMap } from 'fabric-network';
import * as fs from 'fs';
import * as path from 'path';
import { ChannelEventHub } from 'fabric-client';
import Client = require('fabric-client');

const stateStore: StateStore = StateStore.getInstance();
const txnTypes: string[] = ['evaluate', 'submit'];
const txnResponseTypes: string[] = ['evaluate', 'event', 'error', 'submit'];
const supportedWallets: string[] = [Constants.FILE_WALLET as string, Constants.MEMORY_WALLET as string, Constants.COUCH_WALLET as string];

const EventStrategies: any = {

const QueryStrategies: any = {

 * Create a gateway
 * @param {CommonConnectionProfileHelper} ccp The common connection profile
 * @param {Boolean} tls boolean true if tls network; otherwise false
 * @param {String} userName the user name to perform actions with
 * @param {String} orgName the Organization to which the user belongs
 * @param {String} gatewayName the name of the gateway
 * @param {Boolean} useDiscovery toggle discovery on
 * @param {String} walletType the type of wallet to back the gateway with (inMemory, fileBased, couchDB)