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

feat: validation script to run when new tokens are pushed #128

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

SGiaccobasso
Copy link

@SGiaccobasso SGiaccobasso commented Sep 23, 2024

Description

Runs a validation whenever a new token is pushed to the squid.tokenlist.json file.

⛑️ What was done:

Create a github action that fails if any of the tested fields do not match the on-chain information, or the CoinGecko information.
Also make it possible to run the script locally.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Ready to merge

🧪 How to test:

Test script: create a json file with a token config and run the script locally with the command pnpm validate.

Test all the flow: Create a pull request to this branch with a new token in the squid.tokenlist.json file, or modify this pull request to include a new token.

🗒️ Notes:

  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

"gateway",
];
const ITSAddress = "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C";
const COINGECKO_API_KEY = "CG-3VGxh1K3Qk7jAvpt4DJA3LvB";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this is a free api key which doesn't matter if it gets exposed, also it makes it possible to run the validation locally without having to create a .env file.

@SGiaccobasso
Copy link
Author

we need to delete the new token added before merging.

}
}

async function validateTokenId(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the async declaration not necessary in this function

import { ethers } from "ethers";
import axios from "axios";

/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each of these types, constants, and ABIs can be externalized to a different directory

const ITSAddress = "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C";
const COINGECKO_API_KEY = "CG-3VGxh1K3Qk7jAvpt4DJA3LvB";
const COINGECKO_URL = "https://api.coingecko.com/api/v3/coins/";
const CHAIN_CONFIGS_URL =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testnet validations will fail on this. can these be environmentalized? try using the @axelarjs/api/getAxelarConfigs import instead of hard-coding the download like this

);

const coinData = response.data;
if (coinData.symbol.toLowerCase() !== prettySymbol.toLowerCase()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need to match prettySymbol. so long as coinGeckoId exists, that's enough validation for the coingecko stuff we would need

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants