1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
This commit is contained in:
mihaisc 2021-12-08 06:35:48 -08:00 committed by GitHub
parent 061c4c76aa
commit b81eb8fd8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 30 deletions

View File

@ -132,10 +132,43 @@ export class Config {
*/
public authTokenExpiration?: number
// Parity config
/**
* Parity config
* @type {string}
*/
public parityUri?: string
public threshold?: number
/**
* Chain ID
* @type {number}
*/
chainId: number
/**
* Network name ex: mainnet, rinkeby, polygon
* @type {string}
*/
network: string
/**
* Url of the relevant subgraph instance ex: https://subgraph.mainnet.oceanprotocol.com
* @type {string}
*/
subgraphUri: string
/**
* Url of the blockchain exporer ex: https://etherscan.io
* @type {string}
*/
explorerUri: string
/**
* Ocean toke symbol on the chain, it's used just for convenience to reduce number of calls
* @type {string}
*/
oceanTokenSymbol: string
}
export default Config

View File

@ -5,16 +5,8 @@ import { homedir } from 'os'
import { default as DefaultContractsAddresses } from '@oceanprotocol/contracts/addresses/address.json'
import LoggerInstance from './Logger'
export interface ConfigHelperConfig extends Config {
networkId: number
network: string
subgraphUri: string
explorerUri: string
oceanTokenSymbol: string
}
const configHelperNetworksBase: ConfigHelperConfig = {
networkId: null,
const configHelperNetworksBase: Config = {
chainId: null,
network: 'unknown',
metadataCacheUri: 'https://aquarius.oceanprotocol.com',
nodeUri: 'http://localhost:8545',
@ -31,20 +23,20 @@ const configHelperNetworksBase: ConfigHelperConfig = {
startBlock: 0
}
export const configHelperNetworks: ConfigHelperConfig[] = [
export const configHelperNetworks: Config[] = [
{
...configHelperNetworksBase
},
{
// barge
...configHelperNetworksBase,
networkId: 8996,
chainId: 8996,
network: 'development',
metadataCacheUri: 'http://127.0.0.1:5000'
},
{
...configHelperNetworksBase,
networkId: 3,
chainId: 3,
network: 'ropsten',
nodeUri: 'https://ropsten.infura.io/v3',
providerUri: 'https://provider.ropsten.oceanprotocol.com',
@ -54,7 +46,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 4,
chainId: 4,
network: 'rinkeby',
nodeUri: 'https://rinkeby.infura.io/v3',
providerUri: 'https://provider.rinkeby.oceanprotocol.com',
@ -64,7 +56,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 1,
chainId: 1,
network: 'mainnet',
nodeUri: 'https://mainnet.infura.io/v3',
providerUri: 'https://provider.mainnet.oceanprotocol.com',
@ -74,7 +66,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 137,
chainId: 137,
network: 'polygon',
nodeUri: 'https://polygon-mainnet.infura.io/v3',
providerUri: 'https://provider.polygon.oceanprotocol.com',
@ -85,7 +77,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 1287,
chainId: 1287,
network: 'moonbeamalpha',
nodeUri: 'https://rpc.testnet.moonbeam.network',
providerUri: 'https://provider.moonbeamalpha.oceanprotocol.com',
@ -95,7 +87,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 2021000,
chainId: 2021000,
network: 'gaiaxtestnet',
nodeUri: 'https://rpc.gaiaxtestnet.oceanprotocol.com',
providerUri: 'https://provider.gaiaxtestnet.oceanprotocol.com',
@ -104,7 +96,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 2021001,
chainId: 2021001,
network: 'catenaxtestnet',
nodeUri: 'https://rpc.catenaxtestnet.oceanprotocol.com',
providerUri: 'https://provider.catenaxtestnet.oceanprotocol.com',
@ -114,7 +106,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 80001,
chainId: 80001,
network: 'mumbai',
nodeUri: 'https://polygon-mumbai.infura.io/v3',
providerUri: 'https://provider.mumbai.oceanprotocol.com',
@ -123,7 +115,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 56,
chainId: 56,
network: 'bsc',
nodeUri: 'https://bsc-dataseed.binance.org',
providerUri: 'https://provider.bsc.oceanprotocol.com',
@ -132,7 +124,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 44787,
chainId: 44787,
network: 'celoalfajores',
nodeUri: 'https://alfajores-forno.celo-testnet.org',
providerUri: 'https://provider.celoalfajores.oceanprotocol.com',
@ -141,7 +133,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 246,
chainId: 246,
network: 'energyweb',
nodeUri: 'https://rpc.energyweb.org',
providerUri: 'https://provider.energyweb.oceanprotocol.com',
@ -150,7 +142,7 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
},
{
...configHelperNetworksBase,
networkId: 1285,
chainId: 1285,
network: 'moonriver',
nodeUri: 'https://moonriver.api.onfinality.io/public',
providerUri: 'https://provider.moonriver.oceanprotocol.com',
@ -161,9 +153,9 @@ export const configHelperNetworks: ConfigHelperConfig[] = [
export class ConfigHelper {
/* Load contract addresses from env ADDRESS_FILE (generated by ocean-contracts) */
public getAddressesFromEnv(network: string): Partial<ConfigHelperConfig> {
public getAddressesFromEnv(network: string): Partial<Config> {
// use the defaults first
let configAddresses: Partial<ConfigHelperConfig>
let configAddresses: Partial<Config>
if (DefaultContractsAddresses[network]) {
const {
DTFactory,
@ -182,7 +174,7 @@ export class ConfigHelper {
dispenserAddress: Dispenser,
metadataContractAddress: Metadata,
oceanTokenAddress: Ocean,
networkId: chainId,
chainId: chainId,
startBlock: startBlock,
...(process.env.AQUARIUS_URI && { metadataCacheUri: process.env.AQUARIUS_URI })
}
@ -214,7 +206,7 @@ export class ConfigHelper {
dispenserAddress: Dispenser,
metadataContractAddress: Metadata,
oceanTokenAddress: Ocean,
networkId: chainId,
chainId: chainId,
startBlock: startBlock,
...(process.env.AQUARIUS_URI && { metadataCacheUri: process.env.AQUARIUS_URI })
}
@ -227,7 +219,7 @@ export class ConfigHelper {
}
public getConfig(network: string | number, infuraProjectId?: string): Config {
const filterBy = typeof network === 'string' ? 'network' : 'networkId'
const filterBy = typeof network === 'string' ? 'network' : 'chainId'
let config = configHelperNetworks.find((c) => c[filterBy] === network)
if (!config) {

View File

@ -4,3 +4,4 @@ export * from './Logger'
export * from './DatatokenName'
export * from './ContractParams'
export * from './FetchHelper'
export * from './ConfigHelper'