server works with backend via redis, serves chainInfo, more
This commit is contained in:
@@ -1,23 +1,13 @@
|
||||
import {ethers} from "ethers";
|
||||
|
||||
export const chains = {}
|
||||
|
||||
const _chainInfo = [
|
||||
{id:42161, name:'Arbitrum'},
|
||||
]
|
||||
for( const chain of _chainInfo )
|
||||
chains[chain.id] = chain
|
||||
|
||||
const providers = {} // indexed by chain id
|
||||
|
||||
export function getProvider(chainId) {
|
||||
let result = providers[chainId]
|
||||
if( result === undefined ) {
|
||||
let rpc_url = process.env['DEXORDER_RPC_URL_'+chainId]
|
||||
if( rpc_url === undefined ) {
|
||||
console.error(`WARNING: No provider found for chainId ${chainId}. Using localhost.`)
|
||||
rpc_url = 'http://localhost:8545'
|
||||
}
|
||||
if( rpc_url === undefined )
|
||||
throw Error(`WARNING: No provider found for chainId ${chainId}. Using localhost.`)
|
||||
result = rpc_url.startsWith('ws') ?
|
||||
new ethers.WebSocketProvider(rpc_url, chainId) :
|
||||
new ethers.JsonRpcProvider(rpc_url, chainId)
|
||||
|
||||
Reference in New Issue
Block a user