mirror of
https://github.com/oceanprotocol/ens-proxy.git
synced 2024-12-02 05:57:34 +01:00
Simplifying getWeb3 config
This commit is contained in:
parent
443525436a
commit
3fe1c9c873
@ -11,29 +11,19 @@ import {
|
|||||||
|
|
||||||
let ens: any
|
let ens: any
|
||||||
|
|
||||||
function getOceanConfig(network: string | number): Config {
|
async function getWeb3(): Promise<Web3> {
|
||||||
const config = new ConfigHelper().getConfig(
|
const config = new ConfigHelper().getConfig(
|
||||||
network,
|
1,
|
||||||
network === 'polygon' ||
|
process.env.INFURA_PROJECT_ID
|
||||||
network === 'moonbeamalpha' ||
|
|
||||||
network === 1287 ||
|
|
||||||
network === 'bsc' ||
|
|
||||||
network === 56 ||
|
|
||||||
network === 'gaiaxtestnet' ||
|
|
||||||
network === 2021000
|
|
||||||
? undefined
|
|
||||||
: process.env.INFURA_PROJECT_ID
|
|
||||||
) as Config
|
) as Config
|
||||||
return config as Config
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getDummyWeb3(chainId: number): Promise<Web3> {
|
|
||||||
const config = getOceanConfig(chainId)
|
|
||||||
return new Web3(config.nodeUri)
|
return new Web3(config.nodeUri)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createUrqlClient() {
|
async function createUrqlClient() {
|
||||||
const config = getOceanConfig(1)
|
const config = new ConfigHelper().getConfig(
|
||||||
|
1,
|
||||||
|
process.env.INFURA_PROJECT_ID
|
||||||
|
) as Config
|
||||||
const client = createClient({
|
const client = createClient({
|
||||||
url: `${config.subgraphUri}/subgraphs/name/oceanprotocol/ocean-subgraph`,
|
url: `${config.subgraphUri}/subgraphs/name/oceanprotocol/ocean-subgraph`,
|
||||||
exchanges: [dedupExchange, fetchExchange]
|
exchanges: [dedupExchange, fetchExchange]
|
||||||
@ -45,7 +35,7 @@ export async function getEns(): Promise<any> {
|
|||||||
const _ens =
|
const _ens =
|
||||||
ens ||
|
ens ||
|
||||||
new ENS({
|
new ENS({
|
||||||
provider: (await getDummyWeb3(1)).currentProvider,
|
provider: (await getWeb3()).currentProvider,
|
||||||
ensAddress: getEnsAddressVendor(1)
|
ensAddress: getEnsAddressVendor(1)
|
||||||
})
|
})
|
||||||
ens = _ens
|
ens = _ens
|
||||||
|
Loading…
x
Reference in New Issue
Block a user