diff --git a/aave_integration/config.ts b/aave_integration/config.ts index 518d48f06..641e700c6 100644 --- a/aave_integration/config.ts +++ b/aave_integration/config.ts @@ -18,5 +18,4 @@ export default { treasuryAddress: '0xd0A1E359811322d97991E03f863a0C30C2cF029C', agreementFee: 15, }, - testNet: true, } as NeverminedOptions diff --git a/src/keeper/Keeper.ts b/src/keeper/Keeper.ts index f8dedc7ca..6e4129b0d 100644 --- a/src/keeper/Keeper.ts +++ b/src/keeper/Keeper.ts @@ -151,8 +151,9 @@ export class Keeper extends Instantiable { `Keeper could not connect to ${await this.getNetworkName()} - ${err.message} ${err.stack}`, ) } + const chainId = Number((await this.web3.getNetwork()).chainId) - if (this.config.testNet) { + if (KeeperUtils.isTestnet(chainId)) { this.instances.dispenser = await Dispenser.getInstance(this.instantiableConfig) this.instances.token = await Token.getInstance(this.instantiableConfig) } @@ -210,7 +211,6 @@ export class Keeper extends Instantiable { eventHandler: new EventHandler(), } // version - const chainId = Number((await this.web3.getNetwork()).chainId) this.network = { chainId, version: this.didRegistry.version.replace('v', ''), diff --git a/src/keeper/utils.ts b/src/keeper/utils.ts index dfdbb65fc..02f9bf81e 100644 --- a/src/keeper/utils.ts +++ b/src/keeper/utils.ts @@ -60,7 +60,64 @@ export async function getNetworkName(networkId: number): Promise { throw new KeeperError(`Network with id ${networkId} not supported.`) } } - +export async function isTestnet(networkId: number): Promise { + switch (networkId) { + case 1: + return false + case 2: + return true + case 3: + return true + case 4: + return true + case 5: + return true + case 77: + return false + case 99: + return false + case 42: + return true + case 100: + return false + case 137: + return false + case 1337: + return true + case 3141: + return true + case 10200: + return true + case 31337: + return true + case 8996: + return true + case 8997: + return true + case 8998: + return true + case 42220: + return false + case 44787: + return true + case 62320: + return true + case 80001: + return true + case 42161: + return false + case 421613: + return true + case 1313161554: + return false + case 1313161555: + return true + case 1313161556: + return true + default: + throw new KeeperError(`Network with id ${networkId} not supported.`) + } +} // Wrapper for implementing web3 provider. Needed for OpenGSN export interface JsonRpcPayload { jsonrpc: string diff --git a/src/models/NeverminedOptions.ts b/src/models/NeverminedOptions.ts index f912250da..82eb17872 100644 --- a/src/models/NeverminedOptions.ts +++ b/src/models/NeverminedOptions.ts @@ -83,6 +83,4 @@ export class NeverminedOptions { * Use a gas station to calculate transaction fees */ public gasStationUri?: string - - public testNet?: boolean } diff --git a/test/config.ts b/test/config.ts index 137c9a1e2..aee61e244 100644 --- a/test/config.ts +++ b/test/config.ts @@ -18,7 +18,6 @@ const config = { treasuryAddress: '0xd0A1E359811322d97991E03f863a0C30C2cF029C', agreementFee: 15, }, - testNet: true, } as NeverminedOptions if (process.env.SEED_WORDS) {