Packages Breakdown
Last updated
Was this helpful?
Was this helpful?
// How mayachain-query constructs midgard
const defaultMidgardConfig: Record<Network, MidgardConfig> = {
mainnet: {
apiRetries: 3,
midgardBaseUrls: [
'https://midgard.ninerealms.com',
'https://midgard.thorchain.info',
'https://midgard.thorswap.net',
],
},
...
export class Midgard {
private config: MidgardConfig
readonly network: Network
private midgardApis: MidgardApi[]
constructor(network: Network = Network.Mainnet, config?: MidgardConfig) {
this.network = network
this.config = config ?? defaultMidgardConfig[this.network]
axiosRetry(axios, { retries: this.config.apiRetries, retryDelay: axiosRetry.exponentialDelay })
this.midgardApis = this.config.midgardBaseUrls.map((url) => new MidgardApi(new Configuration({ basePath: url })))
}// adding custom endpoints
const network = Network.Mainnet
const customMidgardConfig: MidgardConfig = {
apiRetries: 3,
midgardBaseUrls: [
'https://midgard.customURL.com',
],
}
const midgard = new Midgard(network, customMidgardConfig)
}// How thorchain-query constructs thornode
const defaultThornodeConfig: Record<Network, ThornodeConfig> = {
mainnet: {
apiRetries: 3,
thornodeBaseUrls: [
`https://thornode.ninerealms.com`,
`https://thornode.thorswap.net`,
`https://thornode.thorchain.info`,
],
},
...
export class Thornode {
private config: ThornodeConfig
private network: Network
...
constructor(network: Network = Network.Mainnet, config?: ThornodeConfig) {
this.network = network
this.config = config ?? defaultThornodeConfig[this.network]
axiosRetry(axios, { retries: this.config.apiRetries, retryDelay: axiosRetry.exponentialDelay })
this.transactionsApi = this.config.thornodeBaseUrls.map(
(url) => new TransactionsApi(new Configuration({ basePath: url })),
)
this.queueApi = this.config.thornodeBaseUrls.map((url) => new QueueApi(new Configuration({ basePath: url })))
this.networkApi = this.config.thornodeBaseUrls.map((url) => new NetworkApi(new Configuration({ basePath: url })))
this.poolsApi = this.config.thornodeBaseUrls.map((url) => new PoolsApi(new Configuration({ basePath: url })))
this.liquidityProvidersApi = this.config.thornodeBaseUrls.map(
(url) => new LiquidityProvidersApi(new Configuration({ basePath: url })),
)
}