get url slug checks working

enumerate
lza_menace 2 years ago
parent 2fab003c42
commit 8c4cb0e82a

@ -20,6 +20,7 @@
} }
let errorMessage = ''; let errorMessage = '';
let successMessage = ''; let successMessage = '';
let infoMessage = '';
let contractAddress = ''; let contractAddress = '';
let contractApproved = false; let contractApproved = false;
let checked = false; let checked = false;
@ -66,11 +67,21 @@
const enumerateTokens = async () => { const enumerateTokens = async () => {
enumeratePending = true; enumeratePending = true;
setupContracts(); try {
let bal = await $contracts.nftenum.methods.balanceOf($selectedAccount).call(); setupContracts();
for(let i = 0; i < bal; i++) { } catch(e) {
let tokenId = await $contracts.nftenum.methods.tokenOfOwnerByIndex($selectedAccount, i); console.log(`error: ${e}`);
enumeratedTokens.push(tokenId); 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; enumeratePending = false;
} }
@ -361,14 +372,14 @@
<input class="u-full-width" type="text" placeholder="0x..." id="contractAddress" bind:value={contractAddress} on:change={checkSlug}> <input class="u-full-width" type="text" placeholder="0x..." id="contractAddress" bind:value={contractAddress} on:change={checkSlug}>
</div> </div>
{#if contractAddress} {#if contractAddress}
<div class="two columns"> <div class="three columns">
<label for="findTokens">Enumerate</label> <label for="findTokens">Enumerate</label>
<button id="findTokens" class="button" disabled={enumeratePending} on:click|preventDefault={enumerateTokens}> <button id="findTokens" class="button" disabled={enumeratePending} on:click|preventDefault={enumerateTokens}>
{#if enumeratePending}finding...{:else}Find Tokens{/if} {#if enumeratePending}finding...{:else}Find Tokens{/if}
</button> </button>
</div> </div>
{/if} {/if}
<div class="two columns"> <div class="three columns">
<label for="tokenStandard">Token Standard</label> <label for="tokenStandard">Token Standard</label>
<select class="u-full-width" id="tokenStandard" bind:value={selectedStandard} on:change={clearMessages}> <select class="u-full-width" id="tokenStandard" bind:value={selectedStandard} on:change={clearMessages}>
{#each tokenStandards as s} {#each tokenStandards as s}
@ -430,10 +441,13 @@
{#if successMessage} {#if successMessage}
<p class="successMessage">{successMessage}</p> <p class="successMessage">{successMessage}</p>
{/if} {/if}
{#if enumeratedTokens.length > 0} {#if infoMessage}
<p>Found the {enumeratedTokens.length} tokens owned by {$selectedAccount}:</p> <p class="infoMessage">{infoMessage}</p>
{/if}
{#if enumeratedTokens.length}
<p>Found {enumeratedTokens.length} tokens owned by {$selectedAccount}:</p>
<ul> <ul>
{#each enumeratedTokens as t, i} {#each enumeratedTokens as t}
<li>{t}</li> <li>{t}</li>
{/each} {/each}
</ul> </ul>

Loading…
Cancel
Save