Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/ISSUE_TEMPLATE/2-addImageForm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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\\-.~!$&'()*+,;=:@%]*)*)$"
110 changes: 110 additions & 0 deletions .github/workflows/validate-token-address.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Validate Token Address

on:
issues:
types: [opened, edited]

jobs:
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;

// 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: |
node -e "
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 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']
});