1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

typing & test tweaks

This commit is contained in:
Matthias Kretschmann 2020-09-08 20:30:52 +02:00
parent 44a26f687f
commit 785aac3137
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 9 additions and 6 deletions

View File

@ -47,10 +47,13 @@ npm install @oceanprotocol/lib
## 🏄 Quick Start
```js
import { Ocean, ConfigHelper } from '@oceanprotocol/lib'
```ts
import { Ocean, Config, ConfigHelper } from '@oceanprotocol/lib'
const defaultConfig = new ConfigHelper().getConfig('rinkeby', 'YOUR_INFURA_PROJECT_ID')
const defaultConfig: Config = new ConfigHelper().getConfig(
'rinkeby',
'YOUR_INFURA_PROJECT_ID'
)
const config = {
...defaultConfig,

View File

@ -53,7 +53,7 @@ export class ConfigHelper {
public getConfig(
network: ConfigHelperNetworkName | ConfigHelperNetworkId,
infuraProjectId?: string
): ConfigHelperConfig {
): Config {
const filterBy = typeof network === 'string' ? 'network' : 'chainId'
const config = configs.find((c) => c[filterBy] === network)

View File

@ -5,7 +5,7 @@ describe('ConfigHelper', () => {
it('should get config based on network name', () => {
const network = 'rinkeby'
const config = new ConfigHelper().getConfig(network)
assert(config.network === network)
assert(config.nodeUri.includes(network))
})
it('should get config based on network name, and add passed Infura ID', () => {
@ -18,7 +18,7 @@ describe('ConfigHelper', () => {
it('should get config based on chain ID', () => {
const network = 4
const config = new ConfigHelper().getConfig(network)
assert(config.chainId === network)
assert(config.nodeUri.includes('rinkeby'))
})
it('should return nothing with unknown network', () => {