Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/action #130

Merged
merged 36 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cec5647
chore: create new token
SGiaccobasso Sep 23, 2024
9ad979d
Merge branch 'feat/new-tokens-validation' into test/action
SGiaccobasso Sep 23, 2024
6163831
chore: update yml
SGiaccobasso Sep 23, 2024
ab63736
chore: update yml
SGiaccobasso Sep 23, 2024
aa561e0
chore: update yml
SGiaccobasso Sep 23, 2024
4966773
chore: update yml
SGiaccobasso Sep 23, 2024
4635289
chore: update yml
SGiaccobasso Sep 24, 2024
f0236f4
chore: update yml
SGiaccobasso Sep 24, 2024
2d9ca8a
chore: update yml
SGiaccobasso Sep 24, 2024
d617825
chore: update script
SGiaccobasso Sep 24, 2024
b0ac587
chore: update script
SGiaccobasso Sep 24, 2024
ee553be
chore: add test token
SGiaccobasso Sep 24, 2024
55df272
chore: change order of tests
SGiaccobasso Sep 24, 2024
10d2503
chore: ethers import
SGiaccobasso Sep 24, 2024
779234c
chore: change ethers version
SGiaccobasso Sep 24, 2024
0cc9efc
chore: change ethers version
SGiaccobasso Sep 24, 2024
4881ed0
chore: change ethers version
SGiaccobasso Sep 24, 2024
727756d
chore: change ethers version
SGiaccobasso Sep 24, 2024
99c6d25
chore: change ethers version
SGiaccobasso Sep 24, 2024
6787e0d
chore: change ethers version
SGiaccobasso Sep 24, 2024
75d3c8f
chore: node v
SGiaccobasso Sep 24, 2024
1c4f090
chore: node v
SGiaccobasso Sep 24, 2024
a6c63d7
chore: node v
SGiaccobasso Sep 24, 2024
8a5667d
chore: node v
SGiaccobasso Sep 24, 2024
acde4ec
chore: node v
SGiaccobasso Sep 24, 2024
94a64cd
chore: node v
SGiaccobasso Sep 24, 2024
77cbb8f
chore: node v
SGiaccobasso Sep 24, 2024
19f13e2
chore: node v
SGiaccobasso Sep 24, 2024
632fa82
chore: node v
SGiaccobasso Sep 24, 2024
dfeab94
chore: node v
SGiaccobasso Sep 24, 2024
02084c6
chore: node v
SGiaccobasso Sep 24, 2024
bb77c7a
chore: node v
SGiaccobasso Sep 24, 2024
ed5d2ee
chore: local validation
SGiaccobasso Sep 24, 2024
b370672
chore: remove test token
SGiaccobasso Sep 24, 2024
8fedb85
chore: simplify structure
SGiaccobasso Sep 24, 2024
4596364
chore: merge
SGiaccobasso Sep 24, 2024
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
20 changes: 2 additions & 18 deletions .github/workflows/validate-tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,5 @@ jobs:
- name: Install dependencies
run: bun install

- name: Extract and validate new tokens
run: |
git fetch origin ${{ github.base_ref }}
git show origin/${{ github.base_ref }}:registry/mainnet/interchain/squid.tokenlist.json > base_file.json
cp registry/mainnet/interchain/squid.tokenlist.json current_file.json

bun run - <<EOF
import * as fs from 'fs/promises';

const base = JSON.parse(await fs.readFile('base_file.json', 'utf8'));
const current = JSON.parse(await fs.readFile('current_file.json', 'utf8'));
const newTokens = Object.entries(current.tokens)
.filter(([id, token]) => !base.tokens[id])
.reduce((obj, [id, token]) => ({ ...obj, [id]: token }), {});
await fs.writeFile('new_tokens.json', JSON.stringify(newTokens, null, 2));
EOF

bun run scripts/validate-token-configs.ts
- name: Run validation
run: bun run scripts/run-validation.ts
80 changes: 80 additions & 0 deletions registry/mainnet/interchain/squid.tokenlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -2502,6 +2502,86 @@
}
]
},
"0x1ac831937426660d5952bc9ae0dc7c895a3c3f5f159d3518813df30181404be6": {
"tokenId": "0x1ac831937426660d5952bc9ae0dc7c895a3c3f5f159d3518813df30181404be6",
"deployer": "0x7AAd74b7f0d60D5867B59dbD377a71783425af47",
"originalMinter": null,
"prettySymbol": "agETH",
"decimals": 18,
"originAxelarChainId": "ethereum",
"tokenType": "canonical",
"deploySalt": "0x",
"iconUrls": {
"svg": "https://raw.githubusercontent.com/axelarnetwork/axelar-configs/main/images/tokens/ageth.svg"
},
"deploymentMessageId": "0x9c77e79177ec83dff97c1d0749cd9d4cd2a7f2c6b36256d017df53819e10ab0e-476",
"chains": [
{
"symbol": "agETH",
"name": "Kelp Gain",
"axelarChainId": "ethereum",
"tokenAddress": "0xe1b4d34e8754600962cd944b535180bd758e6c2e",
"tokenManager": "0xa526eDa85A1CF901E77a33493852B0aFD910Ed0d",
"tokenManagerType": "lockUnlock"
},
{
"symbol": "agETH",
"name": "Kelp Gain",
"axelarChainId": "polygon",
"tokenAddress": "0x1bD0Fe8E92a157D3ef66C9FB9e38621252b407c2",
"tokenManager": "0xa526eDa85A1CF901E77a33493852B0aFD910Ed0d",
"tokenManagerType": "mintBurn"
},
{
"symbol": "agETH",
"name": "Kelp Gain",
"axelarChainId": "optimism",
"tokenAddress": "0x1bD0Fe8E92a157D3ef66C9FB9e38621252b407c2",
"tokenManager": "0xa526eDa85A1CF901E77a33493852B0aFD910Ed0d",
"tokenManagerType": "mintBurn"
},
{
"symbol": "agETH",
"name": "Kelp Gain",
"axelarChainId": "linea",
"tokenAddress": "0x1bD0Fe8E92a157D3ef66C9FB9e38621252b407c2",
"tokenManager": "0xa526eDa85A1CF901E77a33493852B0aFD910Ed0d",
"tokenManagerType": "mintBurn"
},
{
"symbol": "agETH",
"name": "Kelp Gain",
"axelarChainId": "base",
"tokenAddress": "0x1bD0Fe8E92a157D3ef66C9FB9e38621252b407c2",
"tokenManager": "0xa526eDa85A1CF901E77a33493852B0aFD910Ed0d",
"tokenManagerType": "mintBurn"
},
{
"symbol": "agETH",
"name": "Kelp Gain",
"axelarChainId": "scroll",
"tokenAddress": "0x1bD0Fe8E92a157D3ef66C9FB9e38621252b407c2",
"tokenManager": "0xa526eDa85A1CF901E77a33493852B0aFD910Ed0d",
"tokenManagerType": "mintBurn"
},
{
"symbol": "agETH",
"name": "Kelp Gain",
"axelarChainId": "blast",
"tokenAddress": "0x1bD0Fe8E92a157D3ef66C9FB9e38621252b407c2",
"tokenManager": "0xa526eDa85A1CF901E77a33493852B0aFD910Ed0d",
"tokenManagerType": "mintBurn"
},
{
"symbol": "agETH",
"name": "Kelp Gain",
"axelarChainId": "arbitrum",
"tokenAddress": "0x1bD0Fe8E92a157D3ef66C9FB9e38621252b407c2",
"tokenManager": "0xa526eDa85A1CF901E77a33493852B0aFD910Ed0d",
"tokenManagerType": "mintBurn"
}
]
},
"0x291401f2645b4a6a6439323c4db76a820439ace0a5ad7637e10a3f5adfdd7c33": {
"tokenId": "0x291401f2645b4a6a6439323c4db76a820439ace0a5ad7637e10a3f5adfdd7c33",
"deployer": "0xfb311Eb413a49389a2078284B57C8BEFeF6aFF67",
Expand Down
42 changes: 21 additions & 21 deletions scripts/run-validation.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { readFile, writeFile, unlink } from "fs/promises";
import { execSync } from "child_process";
import { readFile } from "fs/promises";
import { execSync, spawnSync } from "child_process";
import path from "path";

const tokenListPath = "registry/mainnet/interchain/squid.tokenlist.json";
const tempFile = "new_tokens.json";

async function cleanup() {
try {
await unlink(tempFile);
} catch {}
}

async function main() {
try {
Expand All @@ -27,23 +20,30 @@ async function main() {
);
const localTokens = JSON.parse(localContent).tokens;

// Extract new tokens to new_tokens.json
// Extract new tokens
const newTokens = Object.entries(localTokens)
.filter(([id]) => !mainTokens[id])
.reduce((obj, [id, token]) => ({ ...obj, [id]: token }), {});

await writeFile("new_tokens.json", JSON.stringify(newTokens, null, 2));
} catch (error) {
console.error("An error occurred:", error);
cleanup();
}
// Run validation script with new tokens as parameter
const result = spawnSync(
"bun",
["run", "scripts/validate-token-configs.ts"],
{
input: JSON.stringify(newTokens),
encoding: "utf-8",
stdio: ["pipe", "inherit", "inherit"],
}
);

// Run validation script
try {
execSync("bun run scripts/validate-token-configs.ts", { stdio: "inherit" });
} catch {
} finally {
cleanup();
if (result.status !== 0) {
throw new Error(`Validation script exited with status ${result.status}`);
}

console.log("All new token configurations are valid.");
} catch (error) {
console.error("Validation failed:", (error as Error).message);
process.exit(1);
}
}

Expand Down
11 changes: 8 additions & 3 deletions scripts/validate-token-configs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as fs from "fs";
import { ethers } from "ethers";
import axios from "axios";

Expand Down Expand Up @@ -43,7 +42,6 @@ const tokenManagerTypes = [
"gateway",
];
const ITSAddress = "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C";
const TOKEN_FILE_ROUTE = "./new_tokens.json";
const COINGECKO_API_KEY = "CG-3VGxh1K3Qk7jAvpt4DJA3LvB";
const COINGECKO_URL = "https://api.coingecko.com/api/v3/coins/";
const CHAIN_CONFIGS_URL =
Expand Down Expand Up @@ -111,6 +109,13 @@ const tokenManagerABI = [
* Section: Helper Functions
* =============================
*/

async function getInputTokens() {
const chunks: any[] = [];
for await (const chunk of process.stdin) chunks.push(chunk);
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
}

async function getAxelarChains() {
const { data } = await axios.get(CHAIN_CONFIGS_URL);
return data.chains;
Expand Down Expand Up @@ -374,7 +379,7 @@ async function validateDeployerAndSalt(
async function main() {
try {
// Read new token configurations from file
const newTokens = JSON.parse(fs.readFileSync(TOKEN_FILE_ROUTE, "utf8"));
const newTokens = await getInputTokens();
await validateTokenInfo(newTokens);
} catch (error) {
exitWithError((error as Error).message);
Expand Down
Loading