From: Ardis Lu Date: Mon, 5 Aug 2024 02:51:23 +0000 (-0700) Subject: Show message if nothing is found X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=e67510883eda8fdb937fc8d22d33b9efc30df418;p=erc-1967-inspector Show message if nothing is found --- diff --git a/index.html b/index.html index 22884dd..5a0674a 100644 --- a/index.html +++ b/index.html @@ -183,7 +183,7 @@ return output; }; - document.querySelector('form').addEventListener('submit', e => { + document.querySelector('form').addEventListener('submit', async e => { e.preventDefault(); const contract = e.target.elements['contract'].value.replaceAll(/\s/g, ''); const rpc = e.target.elements['rpc'].value; @@ -195,8 +195,20 @@ controller?.abort(); // Abort any previous in-flight requests controller = new AbortController(); - slotLookup(rpc, contract).then(arr => arr.forEach(i => slotOutput.insertAdjacentHTML('beforeend', `

${i.id}: ${i.data}

`))); - eventLookup(rpc, contract).then(arr => arr.forEach(i => eventOutput.insertAdjacentHTML('beforeend', `

${i.id} (block ${i.blockNumber}): ${i.data}

`))); + const slots = await slotLookup(rpc, contract); + if (slots.length > 0) { + slots.forEach(i => slotOutput.insertAdjacentHTML('beforeend', `

${i.id}: ${i.data}

`)); + } + else { + slotOutput.insertAdjacentHTML('beforeend', '

No addresses found.

'); + } + const events = await eventLookup(rpc, contract); + if (events.length > 0) { + events.forEach(i => eventOutput.insertAdjacentHTML('beforeend', `

${i.id} (block ${i.blockNumber}): ${i.data}

`)); + } + else { + eventOutput.insertAdjacentHTML('beforeend', '

No events found.

'); + } });