From 6336ce2a14e31ee3d6993171355ad6765c81650b Mon Sep 17 00:00:00 2001 From: minato32 Date: Tue, 14 Oct 2025 16:48:16 +0530 Subject: [PATCH 1/7] fix : added validation for address and image url n addImageForm.yml --- .github/ISSUE_TEMPLATE/2-addImageForm.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/2-addImageForm.yml b/.github/ISSUE_TEMPLATE/2-addImageForm.yml index 5b643b9d..c496942b 100644 --- a/.github/ISSUE_TEMPLATE/2-addImageForm.yml +++ b/.github/ISSUE_TEMPLATE/2-addImageForm.yml @@ -36,14 +36,18 @@ body: id: address attributes: label: Address + description: "Must be a valid 0x-prefixed address (40 hexadecimal characters). Example: 0x1234...abcd" placeholder: 0x... validations: required: true + pattern: "^0x[a-fA-F0-9]{40}$" + - type: input id: imageUrl attributes: label: Image URL - description: Ideally a 256x256 PNG or SVG file. But we'll take care of optimizing it later. - placeholder: https://gateway.pinata.cloud/ipfs/Qme9B6jRpGtZsRFcPjHvA5T4ugFuL4c3SzWfxyMPa59AMo + description: "Ideally a 256x256 PNG or SVG file. But we'll take care of optimizing it later." + placeholder: "https://gateway.pinata.cloud/ipfs/Qme9B6jRpGtZsRFcPjHvA5T4ugFuL4c3SzWfxyMPa59AMo" validations: required: true + pattern: "^(https?://[\\w.-]+(?:/[\\w\\-.~!$&'()*+,;=:@%]*)*)$" From 43325faeaeae5e178d68aeaa1f5c8542a06d6b13 Mon Sep 17 00:00:00 2001 From: minato32 <77087663+minato32@users.noreply.github.com> Date: Tue, 14 Oct 2025 16:51:27 +0530 Subject: [PATCH 2/7] Create validate-token-address.yml to check if address exist on chain --- .github/workflows/validate-token-address.yml | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/validate-token-address.yml diff --git a/.github/workflows/validate-token-address.yml b/.github/workflows/validate-token-address.yml new file mode 100644 index 00000000..ed11ae9e --- /dev/null +++ b/.github/workflows/validate-token-address.yml @@ -0,0 +1,43 @@ +name: Validate Token Address +on: + issues: + types: [opened, edited] + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Extract address and network + id: extract + uses: actions/github-script@v7 + with: + script: | + const body = context.payload.issue.body; + const address = body.match(/Address\s*\n\s*0x[a-fA-F0-9]{40}/)?.[0].split('\n')[1].trim(); + const network = body.match(/Network\s*\n\s*(.*)/)?.[1].trim(); + core.setOutput('address', address); + core.setOutput('network', network); + - name: Validate onchain + run: | + npm install ethers + node -e " + const { ethers } = require('ethers'); + const network = '${{ steps.extract.outputs.network }}'; + const address = '${{ steps.extract.outputs.address }}'; + const rpc = { + MAINNET: 'https://rpc.ankr.com/eth', + GNOSIS_CHAIN: 'https://rpc.gnosischain.com', + ARBITRUM_ONE: 'https://arb1.arbitrum.io/rpc', + POLYGON: 'https://polygon-rpc.com' + }[network]; + if (!rpc) process.exit(0); + const provider = new ethers.JsonRpcProvider(rpc); + provider.getCode(address).then(code => { + if (code === '0x') { + console.error('❌ Address not found on', network); + process.exit(1); + } else { + console.log('✅ Address exists on', network); + } + }); + " From 8cecc3e2ec236c7a14b3c55e02cc80e526a9029d Mon Sep 17 00:00:00 2001 From: minato32 <77087663+minato32@users.noreply.github.com> Date: Tue, 14 Oct 2025 16:57:15 +0530 Subject: [PATCH 3/7] Update validate-token-address.yml to add label and comment on issue --- .github/workflows/validate-token-address.yml | 117 +++++++++++++++---- 1 file changed, 92 insertions(+), 25 deletions(-) diff --git a/.github/workflows/validate-token-address.yml b/.github/workflows/validate-token-address.yml index ed11ae9e..7097c81e 100644 --- a/.github/workflows/validate-token-address.yml +++ b/.github/workflows/validate-token-address.yml @@ -1,43 +1,110 @@ name: Validate Token Address + on: issues: types: [opened, edited] jobs: - validate: + validate-address: runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Install ethers.js + run: npm install ethers + - name: Extract address and network id: extract uses: actions/github-script@v7 with: script: | const body = context.payload.issue.body; - const address = body.match(/Address\s*\n\s*0x[a-fA-F0-9]{40}/)?.[0].split('\n')[1].trim(); - const network = body.match(/Network\s*\n\s*(.*)/)?.[1].trim(); - core.setOutput('address', address); - core.setOutput('network', network); - - name: Validate onchain + + // Extract Network + const networkMatch = body.match(/Network\s*\n\s*(.*)/); + const network = networkMatch ? networkMatch[1].trim() : null; + + // Extract Address + const addressMatch = body.match(/Address\s*\n\s*(0x[a-fA-F0-9]{40})/); + const address = addressMatch ? addressMatch[1].trim() : null; + + core.setOutput('network', network || ''); + core.setOutput('address', address || ''); + + - name: Validate on-chain address + id: validate run: | - npm install ethers node -e " - const { ethers } = require('ethers'); - const network = '${{ steps.extract.outputs.network }}'; + const { ethers } = require('ethers'); + + const network = '${{ steps.extract.outputs.network }}'; + const address = '${{ steps.extract.outputs.address }}'; + + if (!address) { + console.log('No address provided.'); + process.exit(1); + } + + const rpcMap = { + MAINNET: 'https://rpc.ankr.com/eth', + GNOSIS_CHAIN: 'https://rpc.gnosischain.com', + ARBITRUM_ONE: 'https://arb1.arbitrum.io/rpc', + BASE: 'https://mainnet.base.org', + POLYGON: 'https://polygon-rpc.com', + AVALANCHE: 'https://api.avax.network/ext/bc/C/rpc', + BNB: 'https://bsc-dataseed.binance.org/', + LENS: '' + }; + + const rpcUrl = rpcMap[network]; + if (!rpcUrl) { + console.log('No RPC for network, skipping check.'); + process.exit(0); + } + + const provider = new ethers.JsonRpcProvider(rpcUrl); + + provider.getCode(address).then(code => { + if (code === '0x') { + console.log('Address not found on chain.'); + process.exit(1); + } else { + console.log('Address exists on chain.'); + } + }).catch(err => { + console.error('Error checking address:', err); + process.exit(1); + }); + " + + - name: Add comment and label if invalid + if: failure() + uses: actions/github-script@v7 + with: + script: | + const issue_number = context.issue.number; const address = '${{ steps.extract.outputs.address }}'; - const rpc = { - MAINNET: 'https://rpc.ankr.com/eth', - GNOSIS_CHAIN: 'https://rpc.gnosischain.com', - ARBITRUM_ONE: 'https://arb1.arbitrum.io/rpc', - POLYGON: 'https://polygon-rpc.com' - }[network]; - if (!rpc) process.exit(0); - const provider = new ethers.JsonRpcProvider(rpc); - provider.getCode(address).then(code => { - if (code === '0x') { - console.error('❌ Address not found on', network); - process.exit(1); - } else { - console.log('✅ Address exists on', network); - } + const network = '${{ steps.extract.outputs.network }}'; + + // Add comment + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number, + body: `⚠️ The address \`${address || 'N/A'}\` does not exist or is invalid on network \`${network || 'N/A'}\`. Please verify.` + }); + + // Add label + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number, + labels: ['invalid-address'] }); - " From 696f6c21213265f3b460b0a601126b710f05659f Mon Sep 17 00:00:00 2001 From: minato32 Date: Wed, 15 Oct 2025 15:49:40 +0530 Subject: [PATCH 4/7] Add issue check and valid rpcs --- .github/workflows/validate-token-address.yml | 75 +++++++++++++------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/.github/workflows/validate-token-address.yml b/.github/workflows/validate-token-address.yml index 7097c81e..6d00ef32 100644 --- a/.github/workflows/validate-token-address.yml +++ b/.github/workflows/validate-token-address.yml @@ -4,16 +4,21 @@ on: issues: types: [opened, edited] +permissions: + contents: read + issues: write + jobs: validate-address: + if: ${{ contains(join(github.event.issue.labels.*.name, ','), 'addImage') }} runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20 @@ -40,48 +45,68 @@ jobs: - name: Validate on-chain address id: validate + timeout-minutes: 2 + env: + NETWORK: ${{ steps.extract.outputs.network }} + ADDRESS: ${{ steps.extract.outputs.address }} run: | node -e " - const { ethers } = require('ethers'); + const { ethers } = require("ethers"); - const network = '${{ steps.extract.outputs.network }}'; - const address = '${{ steps.extract.outputs.address }}'; + const network = process.env.NETWORK; + const address = process.env.ADDRESS; if (!address) { - console.log('No address provided.'); + console.log("No address provided."); + process.exit(1); + } + + if (!ethers.isAddress(address)) { + console.log("Address is not valid"); process.exit(1); } const rpcMap = { - MAINNET: 'https://rpc.ankr.com/eth', - GNOSIS_CHAIN: 'https://rpc.gnosischain.com', - ARBITRUM_ONE: 'https://arb1.arbitrum.io/rpc', - BASE: 'https://mainnet.base.org', - POLYGON: 'https://polygon-rpc.com', - AVALANCHE: 'https://api.avax.network/ext/bc/C/rpc', - BNB: 'https://bsc-dataseed.binance.org/', - LENS: '' + MAINNET: "https://rpc.mevblocker.io", + GNOSIS_CHAIN: "https://gnosis.oat.farm", + ARBITRUM_ONE: "https://arbitrum-one.public.blastapi.io", + BASE: "https://base.drpc.org", + POLYGON: "https://polygon-bor-rpc.publicnode.com", + AVALANCHE: "https://api.avax.network/ext/bc/C/rpc", + BNB: "https://public-bsc-mainnet.fastnode.io", + LENS: "https://lens.drpc.org", }; const rpcUrl = rpcMap[network]; if (!rpcUrl) { - console.log('No RPC for network, skipping check.'); + console.log("No RPC for network, skipping check."); process.exit(0); } const provider = new ethers.JsonRpcProvider(rpcUrl); - provider.getCode(address).then(code => { - if (code === '0x') { - console.log('Address not found on chain.'); + provider + .getCode(address) + .then((code) => { + if (code === "0x") { + console.log("Address not found on chain."); + process.exit(1); + } else { + console.log("Address exists on chain."); + } + }) + .catch((err) => { + if ( + err && + (err.code === "INVALID_ARGUMENT" || /invalid address/i.test(String(err))) + ) { + console.log("Address not found on chain."); + process.exit(1); + } + console.error("Error checking address:", err); process.exit(1); - } else { - console.log('Address exists on chain.'); - } - }).catch(err => { - console.error('Error checking address:', err); - process.exit(1); - }); + }); + " - name: Add comment and label if invalid From 008744cc36fe9bf9628f47d42879ef715b89c445 Mon Sep 17 00:00:00 2001 From: minato32 Date: Wed, 15 Oct 2025 16:56:44 +0530 Subject: [PATCH 5/7] Add version hash --- .github/workflows/validate-token-address.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-token-address.yml b/.github/workflows/validate-token-address.yml index 6d00ef32..81bf3a40 100644 --- a/.github/workflows/validate-token-address.yml +++ b/.github/workflows/validate-token-address.yml @@ -15,10 +15,10 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@69747b3848c30fc048b8eb496dcc7a6384f500d2 - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@69747b3848c30fc048b8eb496dcc7a6384f500d2 with: node-version: 20 From 6b67e849f4f1ee67c168e711a8858b610baacead Mon Sep 17 00:00:00 2001 From: minato32 Date: Wed, 15 Oct 2025 18:21:07 +0530 Subject: [PATCH 6/7] add version 5 hash --- .github/workflows/validate-token-address.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate-token-address.yml b/.github/workflows/validate-token-address.yml index 81bf3a40..25dcd141 100644 --- a/.github/workflows/validate-token-address.yml +++ b/.github/workflows/validate-token-address.yml @@ -15,15 +15,15 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@69747b3848c30fc048b8eb496dcc7a6384f500d2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - name: Set up Node.js - uses: actions/setup-node@69747b3848c30fc048b8eb496dcc7a6384f500d2 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 20 - name: Install ethers.js - run: npm install ethers + run: npm install ethers@5 - name: Extract address and network id: extract From 0ae39bef72252a19c5ff285889c09ba240f03f86 Mon Sep 17 00:00:00 2001 From: minato32 Date: Thu, 16 Oct 2025 12:26:44 +0530 Subject: [PATCH 7/7] Add actions version --- .github/workflows/validate-token-address.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/validate-token-address.yml b/.github/workflows/validate-token-address.yml index 25dcd141..128b4263 100644 --- a/.github/workflows/validate-token-address.yml +++ b/.github/workflows/validate-token-address.yml @@ -4,8 +4,8 @@ on: issues: types: [opened, edited] -permissions: - contents: read +permissions: + contents: read issues: write jobs: @@ -23,11 +23,11 @@ jobs: node-version: 20 - name: Install ethers.js - run: npm install ethers@5 + run: npm install ethers - name: Extract address and network id: extract - uses: actions/github-script@v7 + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea with: script: | const body = context.payload.issue.body; @@ -46,13 +46,13 @@ jobs: - name: Validate on-chain address id: validate timeout-minutes: 2 - env: - NETWORK: ${{ steps.extract.outputs.network }} + env: + NETWORK: ${{ steps.extract.outputs.network }} ADDRESS: ${{ steps.extract.outputs.address }} run: | node -e " - const { ethers } = require("ethers"); - + (() => { + const {ethers} = import('ethers') const network = process.env.NETWORK; const address = process.env.ADDRESS; @@ -106,12 +106,12 @@ jobs: console.error("Error checking address:", err); process.exit(1); }); - + })() " - name: Add comment and label if invalid if: failure() - uses: actions/github-script@v7 + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea with: script: | const issue_number = context.issue.number;