import { SupplyTotal , SupplyTotalStargate } from "./types" ; import { KVStore } from "@keplr-wallet/common" ; import { ObservableChainQuery , ObservableChainQueryMap , } from "../../chain-query" ; import { ChainGetter } from "../../../common" ; import { autorun } from "mobx" ; export class ObservableChainQuerySupplyTotal extends ObservableChainQuery < SupplyTotal | SupplyTotalStargate > { constructor ( kvStore , chainId , chainGetter , denom ) { super ( kvStore , chainId , chainGetter , `/supply/total/${ denom }` ) ; autorun ( ( ) => { const chainInfo = this . chainGetter . getChain ( this . chainId ) ; if ( chainInfo . features && chainInfo . features . includes ( "stargate" ) ) { const url = `/bank/total/${ denom }` ; this . setUrl ( url ) ; } } ) ; } } export class ObservableQuerySupplyTotal extends ObservableChainQueryMap < SupplyTotal | SupplyTotalStargate > { constructor ( protected readonly kvStore , protected readonly chainId , protected readonly chainGetter ) { super ( kvStore , chainId , chainGetter , ( denom ) => { return new ObservableChainQuerySupplyTotal ( this . kvStore , this . chainId , this . chainGetter , denom ) ; } ) ; } getQueryDenom ( denom ) { return this . get ( denom ) ; } getQueryStakeDenom ( ) { const chainInfo = this . chainGetter . getChain ( this . chainId ) ; return this . get ( chainInfo . stakeCurrency . coinMinimalDenom ) ; } }