allow user to input just a url slug

enumerate
lza_menace 2 years ago
parent efd89e3309
commit 2fab003c42

@ -332,6 +332,23 @@
}
gasCalculation = gasCalculation; // trigger recheck
}
const checkSlug = async() => {
if (!contractAddress.startsWith('0x')) {
try {
await fetch(`https://api.opensea.io/api/v1/collection/${contractAddress}`)
.then((response) => response.json())
.then((data) => {
let a = data['collection']['primary_asset_contracts'][0]['address'];
if (a) {
contractAddress = a;
}
});
} catch(e) {
console.log(`failed to convert collection slug to contract address: ${e}`);
}
}
}
</script>
@ -340,8 +357,8 @@
<form>
<div class="row">
<div class="six columns">
<label for="contractAddress">Contract Address</label>
<input class="u-full-width" type="text" placeholder="0x..." id="contractAddress" bind:value={contractAddress}>
<label for="contractAddress">Contract Address / Collection Slug</label>
<input class="u-full-width" type="text" placeholder="0x..." id="contractAddress" bind:value={contractAddress} on:change={checkSlug}>
</div>
{#if contractAddress}
<div class="two columns">

Loading…
Cancel
Save