First of all, I have a code like below. Here I want to dynamically select a network in a simple way.
<code>import * as Solana from '@multiplechain/solana/node'
import * as Bitcoin from '@multiplechain/bitcoin/node'
import * as EvmChains from '@multiplechain/evm-chains/node'
export enum Type {
COIN = Solana.types.TransactionTypeEnum.COIN,
TOKEN = Solana.types.TransactionTypeEnum.TOKEN,
}
const networks = {
evmchains: EvmChains,
bitcoin: Bitcoin,
solana: Solana,
}
export type Keys = keyof typeof networks
export const selectNetwork = (key: Keys) => networks[key]
</code>
<code>import * as Solana from '@multiplechain/solana/node'
import * as Bitcoin from '@multiplechain/bitcoin/node'
import * as EvmChains from '@multiplechain/evm-chains/node'
export enum Type {
COIN = Solana.types.TransactionTypeEnum.COIN,
TOKEN = Solana.types.TransactionTypeEnum.TOKEN,
}
const networks = {
evmchains: EvmChains,
bitcoin: Bitcoin,
solana: Solana,
}
export type Keys = keyof typeof networks
export const selectNetwork = (key: Keys) => networks[key]
</code>
import * as Solana from '@multiplechain/solana/node'
import * as Bitcoin from '@multiplechain/bitcoin/node'
import * as EvmChains from '@multiplechain/evm-chains/node'
export enum Type {
COIN = Solana.types.TransactionTypeEnum.COIN,
TOKEN = Solana.types.TransactionTypeEnum.TOKEN,
}
const networks = {
evmchains: EvmChains,
bitcoin: Bitcoin,
solana: Solana,
}
export type Keys = keyof typeof networks
export const selectNetwork = (key: Keys) => networks[key]
But whenever I try to use the following, I get the following error for services.TransactionListener. Can anyone help me with this?
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
<code>import { selectNetwork, Keys } from './multiplechain'
const network = selectNetwork(data.providerConfig.code as Keys)
const provider = new network.Provider(data.providerConfig as any)
const listener = new network.services.TransactionListener(provider)
</code>
<code>import { selectNetwork, Keys } from './multiplechain'
const network = selectNetwork(data.providerConfig.code as Keys)
const provider = new network.Provider(data.providerConfig as any)
const listener = new network.services.TransactionListener(provider)
</code>
import { selectNetwork, Keys } from './multiplechain'
const network = selectNetwork(data.providerConfig.code as Keys)
const provider = new network.Provider(data.providerConfig as any)
const listener = new network.services.TransactionListener(provider)