diff --git a/src/Contracts.svelte b/src/Contracts.svelte index 2526db2..f6fa664 100644 --- a/src/Contracts.svelte +++ b/src/Contracts.svelte @@ -20,6 +20,7 @@ } let errorMessage = ''; let successMessage = ''; + let infoMessage = ''; let contractAddress = ''; let contractApproved = false; let checked = false; @@ -66,11 +67,21 @@ const enumerateTokens = async () => { enumeratePending = true; - setupContracts(); - let bal = await $contracts.nftenum.methods.balanceOf($selectedAccount).call(); - for(let i = 0; i < bal; i++) { - let tokenId = await $contracts.nftenum.methods.tokenOfOwnerByIndex($selectedAccount, i); - enumeratedTokens.push(tokenId); + try { + setupContracts(); + } catch(e) { + console.log(`error: ${e}`); + return false; + } + try { + let bal = await $contracts.nftenum.methods.balanceOf($selectedAccount).call(); + for (let i = 0; i < bal; i++) { + let tokenId = await $contracts.nftenum.methods.tokenOfOwnerByIndex($selectedAccount, i).call(); + enumeratedTokens.push(Number(tokenId)); + } + } catch(e) { + console.log(e); + return false; } enumeratePending = false; } @@ -361,14 +372,14 @@ {#if contractAddress} -
+
{/if} -
+