Skip to content

Commit

Permalink
update default url at OceanApiClient
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Feb 5, 2024
1 parent dadd645 commit 31ad329
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/ocean-api-client/src/OceanApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'url-search-params-polyfill'
import AbortController from 'abort-controller'
import fetch from 'cross-fetch'
import { ApiException, ApiMethod, ApiPagedResponse, ApiResponse, ClientException, TimeoutException } from './'
import { NetworkName } from '@defichain/jellyfish-network'

/**
* OceanApiClient configurable options
Expand All @@ -24,7 +25,19 @@ export interface OceanApiClientOptions {
/**
* Network that ocean client is configured to
*/
network?: 'mainnet' | 'testnet' | 'devnet' | 'regtest' | 'changi' | string
network?: NetworkName | 'playground'
}

/**
* OceanApiClient default options
*/
function getDefaultOptions (network: NetworkName | 'playground'): OceanApiClientOptions {
return {
url: `https://${network}.ocean.jellyfishsdk.com`,
timeout: 60000,
version: 'v0',
network
}
}

/**
Expand All @@ -35,10 +48,7 @@ export class OceanApiClient {
protected readonly options: OceanApiClientOptions
) {
this.options = {
url: 'https://ocean.defichain.com',
timeout: 60000,
version: 'v1',
network: 'mainnet',
...getDefaultOptions(options?.network ?? 'mainnet'),
...options
}
this.options.url = this.options.url?.replace(/\/$/, '')
Expand Down

0 comments on commit 31ad329

Please sign in to comment.