Initially, I have the following code snippet where I aim to dynamically choose a network in a straightforward manner.
import * as Ethereum from '@multiplechain/ethereum/node'
import * as Bitcoin from '@multiplechain/bitcoin/node'
import * as BinanceChains from '@multiplechain/binance-chains/node'
export enum Type {
ETH = Ethereum.types.TransactionTypeEnum.ETH,
BTC = Bitcoin.types.TransactionTypeEnum.BTC,
}
const networks = {
binancechains: BinanceChains,
bitcoin: Bitcoin,
ethereum: Ethereum,
}
export type Options = keyof typeof networks
export const chooseNetwork = (option: Options) => networks[option]
However, whenever I attempt to utilize the code below, I encounter an error related to services.TransactionListener. Could someone assist me with this issue?
Error:
This expression is not constructable. Each member of the union type 'typeof TransactionListener | typeof TransactionListener | typeof TransactionListener' has construct signatures, but none of those signatures are compatible with each other.ts(2351) (property) TransactionListener: typeof TransactionListener | typeof TransactionListener | typeof TransactionListener
import { chooseNetwork, Options } from './multiplechain'
const chosenNetwork = chooseNetwork(data.providerConfig.code as Options)
const provider = new chosenNetwork.Provider(data.providerConfig as any)
const listener = new chosenNetwork.services.TransactionListener('ETH')