]> git.ardis.lu - erc-165-calculator/commitdiff
Dynamically populate <select> from interfaces.json
authorArdis Lu <ardisglu@gmail.com>
Sat, 13 Apr 2024 06:19:14 +0000 (23:19 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 13 Apr 2024 06:19:14 +0000 (23:19 -0700)
index.html
interfaces.json

index 7a33a2cf625825c15071a80f6ceaf6632e36a8d0..5ff22a90dd74062754805a17ae5ce33d45e87dc0 100644 (file)
       <label for="presets" class="visually-hidden">Presets</label>
       <select name="presets" id="presets">
         <option value="Custom">Custom</option>
-        <option value="ERC-20">ERC-20</option>
-        <option value="ERC-20-Optional">ERC-20 (including optional)</option>
-        <option value="ERC-165">ERC-165</option>
-        <option value="ERC-721">ERC-721</option>
-        <option value="ERC-1155">ERC-1155</option>
-        <option value="ERC-1271">ERC-1271</option>
-        <option value="ERC-1363">ERC-1363</option>
-        <option value="ERC-1363-Receiver">ERC-1363 Receiver</option>
-        <option value="ERC-1363-Spender">ERC-1363 Spender</option>
-        <option value="ERC-4906">ERC-4906</option>
-        <option value="ERC-5805">ERC-5805</option>
-        <option value="ERC-6551-Account">ERC-6551 Account</option>
-        <option value="ERC-6551-Executor">ERC-6551 Executor</option>
       </select>
       <textarea name="functions" id="functions" required></textarea>
 
     const textarea = document.querySelector('textarea');
     const output = document.querySelector('output');
 
+    for (const i of Object.keys(interfaces)) {
+      select.insertAdjacentHTML('beforeend', `<option value="${i}">${i}</option>`);
+    }
+
     let customFunctions = '';
     select.addEventListener('change', e => {
       const selection = e.target.value;
index 5d0c28158574c4dccdcf822b6be0348581edca84..8bd4338d8a733e98808a91fbd8c4e0011611b889 100644 (file)
@@ -7,7 +7,7 @@
     "approve(address _spender, uint256 _value)",
     "allowance(address _owner, address _spender)"
   ],
-  "ERC-20-Optional": [
+  "ERC-20 (including optional)": [
     "name()",
     "symbol()",
     "decimals()",
     "approveAndCall(address spender, uint256 value)",
     "approveAndCall(address spender, uint256 value, bytes memory data)"
   ],
-  "ERC-1363-Receiver": [
+  "ERC-1363 Receiver": [
     "onTransferReceived(address operator, address from, uint256 value, bytes memory data)"
   ],
-  "ERC-1363-Spender": [
+  "ERC-1363 Spender": [
     "onApprovalReceived(address owner, uint256 value, bytes memory data)"
   ],
   "ERC-4906": "0x49064906",
     "delegate(address delegatee)",
     "delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s)"
   ],
-  "ERC-6551-Account": [
+  "ERC-6551 Account": [
     "token()",
     "state()",
     "isValidSigner(address signer, bytes calldata context)"
   ],
-  "ERC-6551-Executor": [
+  "ERC-6551 Executor": [
     "execute(address to, uint256 value, bytes calldata data, uint8 operation)"
   ]
 }
\ No newline at end of file
This page took 0.034664 seconds and 4 git commands to generate.