import { Api , ApiConfig , CoreConfig } from "../core/api" ; import { GaiaRest } from "./rest" ; import * as CmnCdc from "../common/codec" ; import * as Bank from "../x/bank" ; import * as Distribution from "../x/distribution" ; import * as Gov from "../x/gov" ; import * as Slashing from "../x/slashing" ; import * as Staking from "../x/staking" ; import * as Wasm from "../x/wasm" ; import { defaultTxEncoder } from "../common/stdTx" ; import { stdTxBuilder } from "../common/stdTxBuilder" ; import { Context } from "../core/context" ; import { Account } from "../core/account" ; import { BIP44 } from "../core/bip44" ; import { defaultBech32Config } from "../core/bech32Config" ; import { Codec } from "@chainapsis/ts-amino" ; import { queryAccount } from "../core/query" ; import * as Crypto from "../crypto" ; export class GaiaApi extends Api < GaiaRest > { constructor ( config , coreConfig = { } ) { super ( config , { ... { txEncoder : defaultTxEncoder , txBuilder : stdTxBuilder , restFactory : ( context ) => { return new GaiaRest ( context ) ; } , queryAccount : ( context , address ) : Promise < Account > => { return queryAccount ( context . get ( "rpcInstance" ) , address , coreConfig . bech32Config ? coreConfig . bech32Config . bech32PrefixAccAddr : "cosmos" ) ; } , bech32Config : defaultBech32Config ( "cosmos" ) , bip44 : new BIP44 ( 44 , 118 , 0 ) , registerCodec : ( codec ) => { CmnCdc . registerCodec ( codec ) ; Crypto . registerCodec ( codec ) ; Bank . registerCodec ( codec ) ; Distribution . registerCodec ( codec ) ; Gov . registerCodec ( codec ) ; Slashing . registerCodec ( codec ) ; Staking . registerCodec ( codec ) ; Wasm . registerCodec ( codec ) ; } } , ... coreConfig } ) ; } }