mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge pull request #204 from oceanprotocol/feature/config-chainId
added chainId in configs
This commit is contained in:
commit
8473e797a4
@ -8,9 +8,7 @@ process.stdout.write(
|
|||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
{
|
{
|
||||||
version: require('../package.json').version,
|
version: require('../package.json').version,
|
||||||
commit: execSync(`git rev-parse HEAD`)
|
commit: execSync(`git rev-parse HEAD`).toString().trim()
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
' '
|
' '
|
||||||
|
@ -53,4 +53,4 @@ const generateJson = () => {
|
|||||||
spinnerTypedoc.succeed('Generated TypeDoc json.')
|
spinnerTypedoc.succeed('Generated TypeDoc json.')
|
||||||
}
|
}
|
||||||
|
|
||||||
generateJson()
|
generateJson()
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
|
import { config } from 'process'
|
||||||
|
|
||||||
export interface ConfigHelper {
|
export interface ConfigHelper {
|
||||||
|
chainId?: number
|
||||||
network: string
|
network: string
|
||||||
url: string
|
url: string
|
||||||
factoryAddress: string
|
factoryAddress: string
|
||||||
@ -10,6 +13,7 @@ export interface ConfigHelper {
|
|||||||
|
|
||||||
const configs = [
|
const configs = [
|
||||||
{
|
{
|
||||||
|
chaindId: null,
|
||||||
network: 'development',
|
network: 'development',
|
||||||
url: 'http://localhost:8545',
|
url: 'http://localhost:8545',
|
||||||
factoryAddress: null,
|
factoryAddress: null,
|
||||||
@ -18,6 +22,7 @@ const configs = [
|
|||||||
poolFactoryAddress: null
|
poolFactoryAddress: null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
chainId: 4,
|
||||||
network: 'rinkeby',
|
network: 'rinkeby',
|
||||||
url: 'https://rinkeby.infura.io/v3',
|
url: 'https://rinkeby.infura.io/v3',
|
||||||
factoryAddress: '0xcDfEe5D80041224cDCe9AE2334E85B3236385EA3',
|
factoryAddress: '0xcDfEe5D80041224cDCe9AE2334E85B3236385EA3',
|
||||||
@ -27,6 +32,7 @@ const configs = [
|
|||||||
poolFactoryAddress: '0xA4531C624A3D88323a1e178DABe1233AF178701B'
|
poolFactoryAddress: '0xA4531C624A3D88323a1e178DABe1233AF178701B'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
chainId: 1,
|
||||||
network: 'mainnet',
|
network: 'mainnet',
|
||||||
url: 'https://mainnet.infura.io/v3',
|
url: 'https://mainnet.infura.io/v3',
|
||||||
factoryAddress: '0x1234',
|
factoryAddress: '0x1234',
|
||||||
@ -41,6 +47,7 @@ export class ConfigHelper {
|
|||||||
public getConfig(network: string, infuraProjectId?: string): ConfigHelper {
|
public getConfig(network: string, infuraProjectId?: string): ConfigHelper {
|
||||||
const confighelp = new ConfigHelper()
|
const confighelp = new ConfigHelper()
|
||||||
// fill unknown values
|
// fill unknown values
|
||||||
|
confighelp.chainId = null
|
||||||
confighelp.factoryAddress = null
|
confighelp.factoryAddress = null
|
||||||
confighelp.url = null
|
confighelp.url = null
|
||||||
confighelp.network = network
|
confighelp.network = network
|
||||||
@ -52,6 +59,35 @@ export class ConfigHelper {
|
|||||||
const knownconfig = configs.find((c) => c.network === network)
|
const knownconfig = configs.find((c) => c.network === network)
|
||||||
|
|
||||||
if (knownconfig) {
|
if (knownconfig) {
|
||||||
|
confighelp.chainId = knownconfig.chainId
|
||||||
|
confighelp.factoryAddress = knownconfig.factoryAddress
|
||||||
|
confighelp.oceanTokenAddress = knownconfig.oceanTokenAddress
|
||||||
|
confighelp.url = `${knownconfig.url}/${infuraProjectId}`
|
||||||
|
confighelp.network = knownconfig.network
|
||||||
|
confighelp.metadataStoreUri = knownconfig.metadataStoreUri
|
||||||
|
confighelp.providerUri = knownconfig.providerUri
|
||||||
|
confighelp.poolFactoryAddress = knownconfig.poolFactoryAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
return confighelp
|
||||||
|
}
|
||||||
|
|
||||||
|
public getConfigById(chainId: number, infuraProjectId?: string): ConfigHelper {
|
||||||
|
const confighelp = new ConfigHelper()
|
||||||
|
// fill unknown values
|
||||||
|
confighelp.chainId = chainId
|
||||||
|
confighelp.factoryAddress = null
|
||||||
|
confighelp.url = null
|
||||||
|
confighelp.network = null
|
||||||
|
confighelp.oceanTokenAddress = null
|
||||||
|
confighelp.metadataStoreUri = null
|
||||||
|
confighelp.providerUri = null
|
||||||
|
confighelp.poolFactoryAddress = null
|
||||||
|
|
||||||
|
const knownconfig = configs.find((c) => c.chainId === chainId)
|
||||||
|
|
||||||
|
if (knownconfig) {
|
||||||
|
confighelp.chainId = knownconfig.chainId
|
||||||
confighelp.factoryAddress = knownconfig.factoryAddress
|
confighelp.factoryAddress = knownconfig.factoryAddress
|
||||||
confighelp.oceanTokenAddress = knownconfig.oceanTokenAddress
|
confighelp.oceanTokenAddress = knownconfig.oceanTokenAddress
|
||||||
confighelp.url = `${knownconfig.url}/${infuraProjectId}`
|
confighelp.url = `${knownconfig.url}/${infuraProjectId}`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user