import { createModule , action } from "vuex-class-component" ; import { GetBalanceParam , TokenBalanceReturn , TransferParam } from "@/types/bancor" ; import { vxm } from "@/store" ; import { store } from "../../../store" ; const VuexModule = createModule ( { strict : false } ) ; export class NetworkModule extends VuexModule . With ( { namespaced : "network/" } ) { chains = [ "eos" , "eth" ] ; get currentNetwork ( ) { if ( store . state . routeModule && store . state . routeModule . params && store . state . routeModule . params . service ) { return store . state . routeModule . params . service ; } else { return "eth" ; } } get balances ( ) { return vxm [ `${ this . currentNetwork }Network` ] [ "balances" ] ; } get balance ( ) { return vxm [ `${ this . currentNetwork }Network` ] [ "balance" ] ; } get networkId ( ) { return vxm [ `${ this . currentNetwork }Network` ] [ "networkId" ] ; } get protocol ( ) { return vxm [ `${ this . currentNetwork }Network` ] [ "protocol" ] ; } @ action async resetBalances ( ) { return this . $store . dispatch ( `eosNetwork/resetBalances` , null , { root : true } ) ; } @ action async transfer ( params ) { return this . dispatcher ( [ "transfer" , params ] ) ; } @ action async getBalances ( params ) { return this . dispatcher ( [ "getBalances" , params ] ) ; } @ action async dispatcher ( [ methodName , params ] ) { return this . $store . dispatch ( `${ this . currentNetwork }Network/${ methodName }` , params , { root : true } ) ; } }