import { GasConfig } from "../tx" ; import { ChainGetter , CosmosMsgOpts } from "@keplr-wallet/stores" ; import { action , makeObservable , observable } from "mobx" ; import { useState } from "react" ; export class IBCTransferGasConfig extends GasConfig { @ observable . ref protected msgOpts : CosmosMsgOpts [ "ibcTransfer" ] ; constructor ( chainGetter , initialChainId , msgOpts ) { super ( chainGetter , initialChainId ) ; this . msgOpts = msgOpts ; makeObservable ( this ) ; } @ action setMsgOpts ( opts ) { this . msgOpts = opts ; } get gas ( ) : number { if ( this . _gasRaw == null ) { return this . msgOpts . gas ; } return super . gas ; } } export const useIBCTransferGasConfig = ( chainGetter , chainId , msgOpts ) => { const [ gasConfig ] = useState ( ( ) => new IBCTransferGasConfig ( chainGetter , chainId , msgOpts ) ) ; gasConfig . setChain ( chainId ) ; gasConfig . setMsgOpts ( msgOpts ) ; return gasConfig ; } ;