diff --git a/src/pages/contract/ContractItemActions.tsx b/src/pages/contract/ContractItemActions.tsx index 0c2f1cb58..f6ab589df 100644 --- a/src/pages/contract/ContractItemActions.tsx +++ b/src/pages/contract/ContractItemActions.tsx @@ -1,16 +1,24 @@ import { useTranslation } from "react-i18next" -import { useAddress } from "data/wallet" +import { useAddress, useNetwork } from "data/wallet" +import { useInterchainAddresses } from "auth/hooks/useAddress" +import { getChainIDFromAddress } from "utils/bech32" +import { useContract } from "./Contract" +import ContractQuery from "./ContractQuery" import { Button, LinkButton } from "components/general" import { ModalButton } from "components/feedback" import { ExtraActions } from "components/layout" -import ContractQuery from "./ContractQuery" -import { useContract } from "./Contract" const ContractItemActions = () => { const { t } = useTranslation() - const connectedAddress = useAddress() + const networks = useNetwork() + const terraAddress = useAddress() + const addresses = useInterchainAddresses() const { address, admin } = useContract() + const chainID = getChainIDFromAddress(address, networks) + const connectedAddress = + chainID && addresses?.[chainID] ? addresses[chainID] : terraAddress + return ( { const { t } = useTranslation() - const address = useAddress() - const chainID = useChainID() + const networks = useNetwork() + const addresses = useInterchainAddresses() + const chainID = getChainIDFromAddress(contract, networks) ?? "" + const address = addresses?.[chainID ?? ""] /* form */ const form = useForm({ mode: "onChange" }) diff --git a/src/txs/wasm/UpdateAdminContractForm.tsx b/src/txs/wasm/UpdateAdminContractForm.tsx index 17965ebb3..3c37e33e6 100644 --- a/src/txs/wasm/UpdateAdminContractForm.tsx +++ b/src/txs/wasm/UpdateAdminContractForm.tsx @@ -2,9 +2,11 @@ import { useCallback, useMemo } from "react" import { useTranslation } from "react-i18next" import { useForm } from "react-hook-form" import { AccAddress, MsgUpdateContractAdmin } from "@terra-money/feather.js" -import { useAddress, useChainID } from "data/wallet" +import { useNetwork } from "data/wallet" +import { useInterchainAddresses } from "auth/hooks/useAddress" import { Form, FormItem } from "components/form" import { Input } from "components/form" +import { getChainIDFromAddress } from "utils/bech32" import validate from "../validate" import Tx from "../Tx" @@ -16,8 +18,10 @@ interface TxValues { const UpdateAdminContractForm = ({ contract }: { contract: AccAddress }) => { const { t } = useTranslation() - const address = useAddress() - const chainID = useChainID() + const networks = useNetwork() + const addresses = useInterchainAddresses() + const chainID = getChainIDFromAddress(contract, networks) ?? "" + const address = addresses?.[chainID ?? ""] /* form */ const form = useForm({ mode: "onChange" })