import { Secret20ContractTokenInfo } from "./types" ; import { KVStore } from "@keplr-wallet/common" ; import { ObservableChainQueryMap } from "../chain-query" ; import { ChainGetter , QueryError } from "../../common" ; import { ObservableQuerySecretContractCodeHash } from "./contract-hash" ; import { computed , makeObservable } from "mobx" ; import { ObservableSecretContractChainQuery } from "./contract-query" ; import { Keplr } from "@keplr-wallet/types" ; export class ObservableQuerySecret20ContactInfoInner extends ObservableSecretContractChainQuery < Secret20ContractTokenInfo > { protected nonce ? : Uint8Array ; constructor ( kvStore , chainId , chainGetter , protected readonly apiGetter , protected readonly contractAddress , protected readonly querySecretContractCodeHash ) { super ( kvStore , chainId , chainGetter , apiGetter , contractAddress , { token_info : { } } , querySecretContractCodeHash ) ; makeObservable ( this ) ; } get error ( ) : Readonly < QueryError < unknown > > | undefined { return ( super . error || this . querySecretContractCodeHash . getQueryContract ( this . contractAddress ) . error ) ; } @ computed get tokenInfo ( ) : Secret20ContractTokenInfo [ "token_info" ] | undefined { if ( ! this . response ) { return undefined ; } return this . response . data . token_info ; } } export class ObservableQuerySecret20ContractInfo extends ObservableChainQueryMap < Secret20ContractTokenInfo > { constructor ( protected readonly kvStore , protected readonly chainId , protected readonly chainGetter , protected readonly apiGetter , protected readonly querySecretContractCodeHash ) { super ( kvStore , chainId , chainGetter , ( contractAddress ) => { return new ObservableQuerySecret20ContactInfoInner ( this . kvStore , this . chainId , this . chainGetter , this . apiGetter , contractAddress , querySecretContractCodeHash ) ; } ) ; } getQueryContract ( contractAddress ) { return this . get ( contractAddress ) as ObservableQuerySecret20ContactInfoInner ; } }