|
|
@ -7,18 +7,21 @@
|
|
|
|
import ShipIt from './lib/shipit.json';
|
|
|
|
import ShipIt from './lib/shipit.json';
|
|
|
|
|
|
|
|
|
|
|
|
const progress = tweened(0, {
|
|
|
|
const progress = tweened(0, {
|
|
|
|
duration: 300,
|
|
|
|
duration: 800,
|
|
|
|
easing: cubicOut
|
|
|
|
easing: cubicOut
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const shipit = '0x76Ae5B6E75F6e05BcaD1028F78A83f974fc96A8B';
|
|
|
|
const shipit = '0x76Ae5B6E75F6e05BcaD1028F78A83f974fc96A8B';
|
|
|
|
let errorMessage = '';
|
|
|
|
let errorMessage = '';
|
|
|
|
let successMessage = '';
|
|
|
|
let successMessage = '';
|
|
|
|
let contractAddress = '';
|
|
|
|
let contractAddress = '';
|
|
|
|
let contractApproved = true;
|
|
|
|
let contractApproved = false;
|
|
|
|
let checked = false;
|
|
|
|
let checked = false;
|
|
|
|
let checksPending = false;
|
|
|
|
let checksPending = false;
|
|
|
|
let transferPending = false;
|
|
|
|
let transferPending = false;
|
|
|
|
let approvalPending = false;
|
|
|
|
let approvalPending = false;
|
|
|
|
|
|
|
|
let approvalRequired = false;
|
|
|
|
|
|
|
|
let revokeRequired = false;
|
|
|
|
|
|
|
|
let revokePending = false;
|
|
|
|
let gasCalculation = [];
|
|
|
|
let gasCalculation = [];
|
|
|
|
let selectedStandard = 1;
|
|
|
|
let selectedStandard = 1;
|
|
|
|
let gasPrice = 0;
|
|
|
|
let gasPrice = 0;
|
|
|
@ -47,6 +50,7 @@
|
|
|
|
approvalPending = true;
|
|
|
|
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;
|
|
|
|
|
|
|
|
approvalRequired = false;
|
|
|
|
} catch(e) {
|
|
|
|
} catch(e) {
|
|
|
|
errorMessage = `Failed to approve contract: ${e.message}`;
|
|
|
|
errorMessage = `Failed to approve contract: ${e.message}`;
|
|
|
|
approvalPending = false;
|
|
|
|
approvalPending = false;
|
|
|
@ -54,6 +58,18 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const revokeShipIt = async () => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
revokePending = true;
|
|
|
|
|
|
|
|
await $contracts.nft.methods.setApprovalForAll(shipit, false).send({from: $selectedAccount});
|
|
|
|
|
|
|
|
contractApproved = false;
|
|
|
|
|
|
|
|
} catch(e) {
|
|
|
|
|
|
|
|
errorMessage = `Failed to revoke contract: ${e.message}`;
|
|
|
|
|
|
|
|
revokePending = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const isApproved = async () => {
|
|
|
|
const isApproved = async () => {
|
|
|
|
return await $contracts.nft.methods.isApprovedForAll($selectedAccount, shipit).call({from: $selectedAccount});
|
|
|
|
return await $contracts.nft.methods.isApprovedForAll($selectedAccount, shipit).call({from: $selectedAccount});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -141,6 +157,7 @@
|
|
|
|
let approved = await $contracts.nft.methods.isApprovedForAll($selectedAccount, shipit).call();
|
|
|
|
let approved = await $contracts.nft.methods.isApprovedForAll($selectedAccount, shipit).call();
|
|
|
|
if (!approved) {
|
|
|
|
if (!approved) {
|
|
|
|
errorMessage = 'ShipIt requires approval to bulk transfer tokens; click the "Approve" button to view gas estimations and savings';
|
|
|
|
errorMessage = 'ShipIt requires approval to bulk transfer tokens; click the "Approve" button to view gas estimations and savings';
|
|
|
|
|
|
|
|
approvalRequired = true;
|
|
|
|
checksPending = false;
|
|
|
|
checksPending = false;
|
|
|
|
contractApproved = false;
|
|
|
|
contractApproved = false;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -305,39 +322,39 @@
|
|
|
|
{#if checksPending}checking...{:else}Check{/if}
|
|
|
|
{#if checksPending}checking...{:else}Check{/if}
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
{#if !contractApproved}
|
|
|
|
{#if revokeRequired}
|
|
|
|
|
|
|
|
<button class="button-primary" disabled={revokePending} on:click|preventDefault={revokeShipIt}>
|
|
|
|
|
|
|
|
{#if revokePending}revoking...{:else}Revoke{/if}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if approvalRequired}
|
|
|
|
<button class="button-primary" disabled={approvalPending} on:click|preventDefault={approveShipIt}>
|
|
|
|
<button class="button-primary" disabled={approvalPending} on:click|preventDefault={approveShipIt}>
|
|
|
|
{#if approvalPending}pending...{:else}Approve{/if}
|
|
|
|
{#if approvalPending}pending...{:else}Approve{/if}
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
|
|
{#if $progress > 0 && $progress < 1}
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="row">
|
|
|
|
<div class="eight columns">
|
|
|
|
<div class="twelve columns">
|
|
|
|
<progress value={$progress}></progress>
|
|
|
|
{#if $progress > 0 && $progress < 1}
|
|
|
|
|
|
|
|
<progress value={$progress}></progress>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
{#each gasCalculation as m, i}
|
|
|
|
|
|
|
|
{#if i == 3}
|
|
|
|
|
|
|
|
<li class="successMessage">{m}</li>
|
|
|
|
|
|
|
|
{:else}
|
|
|
|
|
|
|
|
<li>{m}</li>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{/each}
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
{#if errorMessage}
|
|
|
|
|
|
|
|
<p class="errorMessage">{errorMessage}</p>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if successMessage}
|
|
|
|
|
|
|
|
<p class="successMessage">{successMessage}</p>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
{#each gasCalculation as m, i}
|
|
|
|
|
|
|
|
{#if i == 3}
|
|
|
|
|
|
|
|
<li class="successMessage">{m}</li>
|
|
|
|
|
|
|
|
{:else}
|
|
|
|
|
|
|
|
<li>{m}</li>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{/each}
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{#if errorMessage}
|
|
|
|
|
|
|
|
<p class="errorMessage">{errorMessage}</p>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{#if successMessage}
|
|
|
|
|
|
|
|
<p class="successMessage">{successMessage}</p>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
<style>
|
|
|
|
<style>
|
|
|
|
.errorMessage {
|
|
|
|
.errorMessage {
|
|
|
|