From 31dca406878f4c8398f5bc10d109ecf5c1573954 Mon Sep 17 00:00:00 2001 From: modship Date: Thu, 5 Sep 2024 11:35:55 +0200 Subject: [PATCH] Fix undefined chainId --- frontend/src/components/MNSManagement.tsx | 7 ++++--- frontend/src/utils/write-mns-sc.tsx | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/MNSManagement.tsx b/frontend/src/components/MNSManagement.tsx index 9039e75..9cae970 100644 --- a/frontend/src/components/MNSManagement.tsx +++ b/frontend/src/components/MNSManagement.tsx @@ -10,7 +10,8 @@ interface MNSManagementProps { export function MNSManagement(props: MNSManagementProps) { const { customClass } = props; - const { massaClient, connectedAccount, currentProvider } = useAccountStore(); + const { massaClient, connectedAccount, currentProvider, chainId } = + useAccountStore(); const { list, listSpinning, @@ -25,9 +26,9 @@ export function MNSManagement(props: MNSManagementProps) { const connected = !!connectedAccount && !!currentProvider; useEffect(() => { - if (!connectedAccount || !massaClient || listSpinning) return; + if (!connectedAccount || !massaClient || listSpinning || !chainId) return; getUserEntryList({ address: connectedAccount.address() }); - }, [connectedAccount, massaClient]); + }, [connectedAccount, massaClient, chainId]); return (
{!connected ? ( diff --git a/frontend/src/utils/write-mns-sc.tsx b/frontend/src/utils/write-mns-sc.tsx index ceda185..4479a8e 100644 --- a/frontend/src/utils/write-mns-sc.tsx +++ b/frontend/src/utils/write-mns-sc.tsx @@ -81,7 +81,7 @@ function getScAddress(chainId: bigint | undefined) { case CHAIN_ID.MainNet: return MAINNET_SC_ADDRESS; default: - throw new Error('Environnement SC_ADDRESS not found'); + throw new Error('SC_ADDRESS not found for chainId : ' + chainId); } } @@ -338,6 +338,8 @@ export function useWriteMNS(client?: Client) { ): Promise { setListSpinning(true); const SC_ADDRESS = getScAddress(chainId); + console.log('SC_ADDRESS', SC_ADDRESS); + let resultBalance = await client?.smartContracts().readSmartContract({ targetAddress: SC_ADDRESS, targetFunction: 'balanceOf',