import { ObservableQuery } from "../common" ; import { KVStore } from "@keplr-wallet/common" ; import Axios , { AxiosInstance } from "axios" ; import { override } from "mobx" ; import { ChainGetter } from "../common" ; import { HasMapStore } from "../common" ; export class ObservableChainQuery < T = unknown , E = unknown > extends ObservableQuery < T , E > { protected readonly _chainId : string ; protected readonly chainGetter : ChainGetter ; constructor ( kvStore , chainId , chainGetter , url ) { const chainInfo = chainGetter . getChain ( chainId ) ; const instance = Axios . create ( { ... { baseURL : chainInfo . rest , } , ... chainInfo . restConfig , } ) ; super ( kvStore , instance , url ) ; this . _chainId = chainId ; this . chainGetter = chainGetter ; } @ override protected get instance ( ) : AxiosInstance { const chainInfo = this . chainGetter . getChain ( this . chainId ) ; return Axios . create ( { ... { baseURL : chainInfo . rest , } , ... chainInfo . restConfig , } ) ; } get chainId ( ) : string { return this . _chainId ; } } export class ObservableChainQueryMap < T = unknown , E = unknown > extends HasMapStore < ObservableChainQuery < T , E > > { constructor ( protected readonly kvStore , protected readonly chainId , protected readonly chainGetter , creater ) { super ( creater ) ; } }