From 2fab003c429d7c908d7395b4e6e8e792f9acbcb7 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 24 Nov 2022 23:52:42 -0800 Subject: [PATCH] allow user to input just a url slug --- src/Contracts.svelte | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Contracts.svelte b/src/Contracts.svelte index 65217e7..2526db2 100644 --- a/src/Contracts.svelte +++ b/src/Contracts.svelte @@ -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}`); + } + } + } @@ -340,8 +357,8 @@
- - + +
{#if contractAddress}