diff --git a/pages/multi/[address]/index.tsx b/pages/[chainName]/[address]/index.tsx similarity index 86% rename from pages/multi/[address]/index.tsx rename to pages/[chainName]/[address]/index.tsx index d2fd5aa..5c4df27 100644 --- a/pages/multi/[address]/index.tsx +++ b/pages/[chainName]/[address]/index.tsx @@ -1,6 +1,5 @@ import { MultisigThresholdPubkey, SinglePubkey } from "@cosmjs/amino"; import { Account, StargateClient } from "@cosmjs/stargate"; -import { assert } from "@cosmjs/utils"; import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin"; import { useRouter } from "next/router"; import { useCallback, useEffect, useState } from "react"; @@ -10,7 +9,7 @@ import MultisigMembers from "../../../components/dataViews/MultisigMembers"; import Button from "../../../components/inputs/Button"; import Page from "../../../components/layout/Page"; import StackableContainer from "../../../components/layout/StackableContainer"; -import { useAppContext } from "../../../context/AppContext"; +import { useChains } from "../../../context/ChainsContext"; import { explorerLinkAccount } from "../../../lib/displayHelpers"; import { getMultisigAccount } from "../../../lib/multisigHelpers"; @@ -22,8 +21,7 @@ function participantPubkeysFromMultisig( const Multipage = () => { const router = useRouter(); - const { state } = useAppContext(); - assert(state.chain.addressPrefix, "address prefix missing"); + const { chain } = useChains(); const [holdings, setHoldings] = useState([]); const [accountOnChain, setAccountOnChain] = useState(null); @@ -40,15 +38,13 @@ const Multipage = () => { async (address: string) => { setAccountError(null); try { - assert(state.chain.nodeAddress, "Node address missing"); - const client = await StargateClient.connect(state.chain.nodeAddress); - assert(state.chain.denom, "denom missing"); + const client = await StargateClient.connect(chain.nodeAddress); const tempHoldings = await client.getAllBalances(address); setHoldings(tempHoldings); - assert(state.chain.addressPrefix, "addressPrefix missing"); + const [newPubkey, newAccountOnChain] = await getMultisigAccount( address, - state.chain.addressPrefix, + chain.addressPrefix, client, ); setPubkey(newPubkey); @@ -59,7 +55,7 @@ const Multipage = () => { console.log("Account error:", error); } }, - [state.chain.addressPrefix, state.chain.denom, state.chain.nodeAddress], + [chain.addressPrefix, chain.nodeAddress], ); useEffect(() => { @@ -79,7 +75,7 @@ const Multipage = () => { {pubkey ? ( ) : null} @@ -111,7 +107,7 @@ const Multipage = () => { ) : null}