Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ li {
<a class="github-fork-ribbon" href="https://github.com/iainnash/ether.actor" data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a>
<p>powered by etherscan for ABIs and cloudflare for ethereum endpoints<p>
<p>now querying ${hostFirst}. supports: <a href="https://ether.actor/">ethereum</a>, <a href="https://goerli.ether.actor">goerli</a>, <a href="https://polygon.ether.actor">polygon</a>, <a href="https://mumbai.ether.actor">mumbai</a></p>
<p><a href="https://bsc.ether.actor/">bsc</a>, <a href="https://bsc-testnet.ether.actor">bsc-testnet</a>, <a href="https://kovan-optimism.ether.actor">kovan optimism</a>, <a href="https://optimism.ether.actor">optimism</a></p>
<p><a href="https://bsc.ether.actor/">bsc</a>, <a href="https://bsc-testnet.ether.actor">bsc-testnet</a>, <a href="https://kovan-optimism.ether.actor">kovan optimism</a>, <a href="https://optimism.ether.actor">optimism</a>, <a href="https://arbitrum.ether.actor">arbitrum</a></p>
<br />
<p>try it:</p>
<ul>
Expand Down
1 change: 1 addition & 0 deletions src/constants/chainid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export const OPTIMISM_GOERLI_CHAIN = 420
export const OPTIMISM_CHAIN = 10
export const BASE_GOERLI_CHAIN = 84531
export const BASE_CHAIN = 8453
export const ARBITRUM_CHAIN = 42161;
10 changes: 10 additions & 0 deletions src/ethereum/ethereum.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
OPTIMISM_CHAIN,
ZORA_CHAIN,
ZORA_GOERLI_CHAIN,
ARBITRUM_CHAIN,
} from 'src/constants/chainid';

const NETWORK_CONFIGS = JSON.parse(process.env.RPC_NETWORK_CONFIGS);
Expand Down Expand Up @@ -115,6 +116,15 @@ const NETWORK_CONFIGS = JSON.parse(process.env.RPC_NETWORK_CONFIGS);
custom: 'https://testnet.rpc.zora.energy',
useDefaultProvider: false,
}),
EthersModule.forRoot({
token: 'arbitrum',
network: {
chainId: ARBITRUM_CHAIN,
name: 'arbitrum',
},
custom: NETWORK_CONFIGS.arbitrum || 'https://arb1.arbitrum.io/rpc',
useDefaultProvider: false,
}),
],
})
export class EthereumModule {}
11 changes: 10 additions & 1 deletion src/ethereum/ethereum.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
MUMBAI_NETWORK,
} from 'nestjs-ethers';
import { EtherscanProvider, StaticJsonRpcProvider } from '@ethersproject/providers';
import { OPTIMISM_CHAIN, OPTIMISM_GOERLI_CHAIN, ZORA_CHAIN, ZORA_GOERLI_CHAIN, BASE_CHAIN, BASE_GOERLI_CHAIN } from 'src/constants/chainid';
import { OPTIMISM_CHAIN, OPTIMISM_GOERLI_CHAIN, ZORA_CHAIN, ZORA_GOERLI_CHAIN, BASE_CHAIN, BASE_GOERLI_CHAIN, ARBITRUM_CHAIN } from 'src/constants/chainid';

// const last = EtherscanProvider.prototype.getBaseUrl;
EtherscanProvider.prototype.getBaseUrl = function () {
Expand Down Expand Up @@ -52,6 +52,9 @@ EtherscanProvider.prototype.getBaseUrl = function () {
if (this.network.chainId === BASE_CHAIN) {
return 'https://api.basescan.org/';
}
if (this.network.chainId === ARBITRUM_CHAIN) {
return 'https://api.arbiscan.io/';
}

throw new Error('undefined chain');
};
Expand Down Expand Up @@ -81,6 +84,8 @@ export class EthereumService {
private readonly baseProvider: StaticJsonRpcProvider,
@InjectEthersProvider('base-goerli')
private readonly baseGoerliProvider: StaticJsonRpcProvider,
@InjectEthersProvider('arbitrum')
private readonly arbitrumProvider: StaticJsonRpcProvider,
) {}

getNetworkId(host: string) {
Expand Down Expand Up @@ -117,6 +122,8 @@ export class EthereumService {
return BASE_CHAIN;
case 'base-goerli':
return BASE_GOERLI_CHAIN;
case 'arbitrum':
return ARBITRUM_CHAIN;
}
throw new NotFoundException();
}
Expand Down Expand Up @@ -149,6 +156,8 @@ export class EthereumService {
return this.baseProvider;
case BASE_GOERLI_CHAIN:
return this.baseGoerliProvider;
case ARBITRUM_CHAIN:
return this.arbitrumProvider;
}
}

Expand Down