mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add configHelper
This commit is contained in:
parent
cee10e72cb
commit
21c8879efe
@ -5,6 +5,7 @@ import { Ocean } from './ocean/Ocean'
|
|||||||
import { LoggerInstance as Logger } from './utils/Logger'
|
import { LoggerInstance as Logger } from './utils/Logger'
|
||||||
import { Aquarius } from './aquarius/Aquarius'
|
import { Aquarius } from './aquarius/Aquarius'
|
||||||
import { DataTokens } from './datatokens/Datatokens'
|
import { DataTokens } from './datatokens/Datatokens'
|
||||||
|
import { ConfigHelper} from './utils/ConfigHelper'
|
||||||
|
|
||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
|
|
||||||
@ -20,4 +21,4 @@ export {
|
|||||||
OceanPlatformVersions
|
OceanPlatformVersions
|
||||||
} from './ocean/Versions'
|
} from './ocean/Versions'
|
||||||
|
|
||||||
export { Ocean, Account, Config, DID, Logger, Aquarius, DataTokens, utils }
|
export { Ocean, Account, Config, DID, Logger, Aquarius, DataTokens, utils , ConfigHelper}
|
||||||
|
33
src/utils/ConfigHelper.ts
Normal file
33
src/utils/ConfigHelper.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
export interface ConfigHelper {
|
||||||
|
network: string,
|
||||||
|
url: string,
|
||||||
|
factoryAddress: string
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const configs = [
|
||||||
|
{ network: 'development', url: 'http://localhost:8545', factoryAddress: null },
|
||||||
|
{ network: 'pacific', url: 'https://pacific.oceanprotocol.com', factoryAddress: '0x1234' },
|
||||||
|
{ network: 'mainnet', url: 'https://mainnet.infura.io/v3/YOUR-PROJECT-ID', factoryAddress: '0x1234' }
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export class ConfigHelper {
|
||||||
|
public getConfig(network: string): ConfigHelper {
|
||||||
|
const confighelp = new ConfigHelper
|
||||||
|
//fill unknown values
|
||||||
|
confighelp.factoryAddress = null
|
||||||
|
confighelp.url = null
|
||||||
|
confighelp.network = network
|
||||||
|
const knownconfig = configs.find(c => c.network === network)
|
||||||
|
if (knownconfig) {
|
||||||
|
confighelp.factoryAddress = knownconfig.factoryAddress
|
||||||
|
confighelp.url = knownconfig.url
|
||||||
|
confighelp.network = knownconfig.network
|
||||||
|
}
|
||||||
|
return (confighelp)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user