Skip to content

Commit

Permalink
namespace loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Dec 20, 2024
1 parent 23b7df8 commit ccc3279
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/ui/src/components/modals/WalletConnectSigning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface SigningModalProps {

const ProposalSigning = ({ onClose, className, request, onSuccess }: SigningModalProps) => {
const { api, chainInfo } = useApi()
const { currentNamespace } = useGetWalletConnectNamespace()
const { currentNamespace, isLoading: isNamespaceLoading } = useGetWalletConnectNamespace()
const [isSubmitting, setIsSubmitting] = useState(false)
const { web3wallet } = useWalletConnect()
const {
Expand Down Expand Up @@ -84,13 +84,15 @@ const ProposalSigning = ({ onClose, className, request, onSuccess }: SigningModa
})

useEffect(() => {
if (isNamespaceLoading) return

const requestedChainId = request.params.chainId
if (requestedChainId !== currentNamespace) {
setErrorMessage(
`Wrong selected network in Multix. Please reject, then select the correct network and resubmit the transaction. Request with namespace: ${requestedChainId}`
`Wrong selected network in Multix. Please reject, then select the correct network and resubmit the transaction. Current Namespace: ${currentNamespace}, Request with namespace: ${requestedChainId}`
)
}
}, [currentNamespace, originAddress, request.params.chainId])
}, [currentNamespace, isNamespaceLoading, originAddress, request.params.chainId])

const isCorrectMultiproxySelected = useMemo(
() =>
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/hooks/useWalletConnectNamespace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useApi } from '../contexts/ApiContext'
export const useGetWalletConnectNamespace = () => {
const { client } = useApi()
const [genesisHash, setGenesisHash] = useState('')
const [isLoading, setIsLoading] = useState(true)

useEffect(() => {
if (!client) return
Expand All @@ -12,6 +13,7 @@ export const useGetWalletConnectNamespace = () => {
.getChainSpecData()
.then((data) => setGenesisHash(data.genesisHash))
.catch(console.error)
.finally(() => setIsLoading(false))
}, [client])

const genesisTruncated = useMemo(() => genesisHash.substring(2, 34), [genesisHash])
Expand All @@ -25,5 +27,5 @@ export const useGetWalletConnectNamespace = () => {
[namespace]
)

return { currentNamespace: namespace, getAccountsWithNamespace }
return { currentNamespace: namespace, getAccountsWithNamespace, isLoading }
}

0 comments on commit ccc3279

Please sign in to comment.