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:
parent
44a26f687f
commit
785aac3137
@ -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,
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user