diff --git a/.github/workflows/validate-tokens.yml b/.github/workflows/validate-tokens.yml index 7172201..e215c17 100644 --- a/.github/workflows/validate-tokens.yml +++ b/.github/workflows/validate-tokens.yml @@ -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 - < !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 diff --git a/registry/mainnet/interchain/squid.tokenlist.json b/registry/mainnet/interchain/squid.tokenlist.json index 32663f8..a54e457 100644 --- a/registry/mainnet/interchain/squid.tokenlist.json +++ b/registry/mainnet/interchain/squid.tokenlist.json @@ -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", diff --git a/scripts/run-validation.ts b/scripts/run-validation.ts index dce319d..d847c80 100644 --- a/scripts/run-validation.ts +++ b/scripts/run-validation.ts @@ -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 { @@ -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); } } diff --git a/scripts/validate-token-configs.ts b/scripts/validate-token-configs.ts index f02f31d..21e5f24 100644 --- a/scripts/validate-token-configs.ts +++ b/scripts/validate-token-configs.ts @@ -1,4 +1,3 @@ -import * as fs from "fs"; import { ethers } from "ethers"; import axios from "axios"; @@ -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 = @@ -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; @@ -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);