Skip to content

Commit

Permalink
Fix undefined chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
modship committed Sep 5, 2024
1 parent b3a2c37 commit 31dca40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions frontend/src/components/MNSManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]);

Check warning on line 31 in frontend/src/components/MNSManagement.tsx

View workflow job for this annotation

GitHub Actions / lint-frontend

React Hook useEffect has missing dependencies: 'getUserEntryList' and 'listSpinning'. Either include them or remove the dependency array
return (
<div className={customClass}>
{!connected ? (
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/utils/write-mns-sc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -338,6 +338,8 @@ export function useWriteMNS(client?: Client) {
): Promise<DnsUserEntryListResult[]> {
setListSpinning(true);
const SC_ADDRESS = getScAddress(chainId);
console.log('SC_ADDRESS', SC_ADDRESS);

let resultBalance = await client?.smartContracts().readSmartContract({
targetAddress: SC_ADDRESS,
targetFunction: 'balanceOf',
Expand Down

0 comments on commit 31dca40

Please sign in to comment.