|
|
@ -13,6 +13,7 @@
|
|
|
|
let checked = false;
|
|
|
|
let checked = false;
|
|
|
|
let checksPending = false;
|
|
|
|
let checksPending = false;
|
|
|
|
let transferPending = false;
|
|
|
|
let transferPending = false;
|
|
|
|
|
|
|
|
let approvalPending = false;
|
|
|
|
let gasCalculation = [];
|
|
|
|
let gasCalculation = [];
|
|
|
|
let selectedStandard = 1;
|
|
|
|
let selectedStandard = 1;
|
|
|
|
let gasPrice = 0;
|
|
|
|
let gasPrice = 0;
|
|
|
@ -38,10 +39,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
const approveShipIt = async () => {
|
|
|
|
const approveShipIt = async () => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
approvalPending = true;
|
|
|
|
await $contracts.nft.methods.setApprovalForAll(shipit, true).send({from: $selectedAccount});
|
|
|
|
await $contracts.nft.methods.setApprovalForAll(shipit, true).send({from: $selectedAccount});
|
|
|
|
contractApproved = true;
|
|
|
|
contractApproved = true;
|
|
|
|
} catch(e) {
|
|
|
|
} catch(e) {
|
|
|
|
errorMessage = `Failed to approve contract: ${e.message}`;
|
|
|
|
errorMessage = `Failed to approve contract: ${e.message}`;
|
|
|
|
|
|
|
|
approvalPending = false;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -96,11 +99,17 @@
|
|
|
|
if (selectedStandard == 1) {
|
|
|
|
if (selectedStandard == 1) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
let owner = await $contracts.nft.methods.ownerOf(tokenId).call();
|
|
|
|
let owner = await $contracts.nft.methods.ownerOf(tokenId).call();
|
|
|
|
|
|
|
|
} catch(e) {
|
|
|
|
|
|
|
|
errorMessage = `Something went wrong; make sure you're using the right token standard for the contract: ${e.message}`;
|
|
|
|
|
|
|
|
checksPending = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (owner.toLowerCase() != $selectedAccount.toLowerCase()) { throw new Error(`You must own the token in order to send it (token ${tokenId})`); }
|
|
|
|
if (owner.toLowerCase() != $selectedAccount.toLowerCase()) { throw new Error(`You must own the token in order to send it (token ${tokenId})`); }
|
|
|
|
if (tokenIds.includes(tokenId)) { throw new Error(`Duplicate token ID found (token ${tokenId})`); }
|
|
|
|
if (tokenIds.includes(tokenId)) { throw new Error(`Duplicate token ID found (token ${tokenId})`); }
|
|
|
|
tokenIds.push(tokenId);
|
|
|
|
tokenIds.push(tokenId);
|
|
|
|
} catch(e) {
|
|
|
|
} catch(e) {
|
|
|
|
errorMessage = e;
|
|
|
|
errorMessage = e.toString();
|
|
|
|
checksPending = false;
|
|
|
|
checksPending = false;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -111,7 +120,7 @@
|
|
|
|
if (Number(tokenIds.length) > Number(balance)) { throw new Error(`Provided more tokens than balance (token ${tokenId}, balance ${balance})`); }
|
|
|
|
if (Number(tokenIds.length) > Number(balance)) { throw new Error(`Provided more tokens than balance (token ${tokenId}, balance ${balance})`); }
|
|
|
|
tokenIds.push(tokenId);
|
|
|
|
tokenIds.push(tokenId);
|
|
|
|
} catch(e) {
|
|
|
|
} catch(e) {
|
|
|
|
errorMessage = e;
|
|
|
|
errorMessage = e.toString();
|
|
|
|
checksPending = false;
|
|
|
|
checksPending = false;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -204,7 +213,7 @@
|
|
|
|
throw new Error(`Transaction failed: ${res}`)
|
|
|
|
throw new Error(`Transaction failed: ${res}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch(e) {
|
|
|
|
} catch(e) {
|
|
|
|
errorMessage = `Failed to execute bulk transfer: ${e.message}`;
|
|
|
|
errorMessage = `Failed to execute bulk transfer: ${e.toString()}`;
|
|
|
|
transferPending = false;
|
|
|
|
transferPending = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -291,7 +300,9 @@
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
{#if !contractApproved}
|
|
|
|
{#if !contractApproved}
|
|
|
|
<button class="button-primary" on:click|preventDefault={approveShipIt}>Approve</button>
|
|
|
|
<button class="button-primary" disabled={approvalPending} on:click|preventDefault={approveShipIt}>
|
|
|
|
|
|
|
|
{#if approvalPending}pending...{:else}Approve{/if}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
|
|