Skip to content

Commit

Permalink
Merge pull request #208 from api3dao/chain-support-validation
Browse files Browse the repository at this point in the history
Add chain-support.json validation
  • Loading branch information
bbenligiray authored Sep 25, 2024
2 parents 5b2ebb7 + 0a84ae6 commit a5cf7a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
9 changes: 4 additions & 5 deletions data/chain-support.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"bsc",
"bsc-testnet",
"bsquared",
"blast-sepolia-testnet",
"camp-sepolia-testnet",
"conflux",
"conflux-testnet",
Expand Down Expand Up @@ -77,10 +76,10 @@
"rari",
"rari-arbitrum-sepolia-testnet",
"rsk",
"sei",
"sei-testnet",
"scroll",
"scroll-sepolia-testnet",
"sei",
"sei-testnet",
"soneium-sepolia-testnet",
"sonic-testnet",
"taiko",
Expand Down Expand Up @@ -166,10 +165,10 @@
"polygon-zkevm-sepolia-testnet",
"rari",
"rari-arbitrum-sepolia-testnet",
"sei",
"sei-testnet",
"scroll",
"scroll-sepolia-testnet",
"sei",
"sei-testnet",
"soneium-sepolia-testnet",
"sonic-testnet",
"taiko",
Expand Down
4 changes: 2 additions & 2 deletions data/manager-multisig.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
"kroma-sepolia-testnet": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26",
"lightlink": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26",
"lightlink-sepolia-testnet": "0x5aB00E30453EEAd35025A761ED65d51d74574C24",
"manta": "0x0D4136b033807C5298a77E2ad7ebE8ce05207D2d",
"manta-sepolia-testnet": "0x29AbCeDfa34a229536962b3061913842F103A916",
"linea": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26",
"linea-sepolia-testnet": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26",
"lukso": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26",
"lukso-testnet": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26",
"lumia": "0x026A473DAB17ef658Ca09d726c70b4570A76188b",
"lumia-sepolia-testnet": "0x026A473DAB17ef658Ca09d726c70b4570A76188b",
"manta": "0x0D4136b033807C5298a77E2ad7ebE8ce05207D2d",
"manta-sepolia-testnet": "0x29AbCeDfa34a229536962b3061913842F103A916",
"mantle": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26",
"mantle-sepolia-testnet": "0x25C6f371Cf8d4200B89dF84f9dE69d011013B086",
"merlin": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26",
Expand Down
20 changes: 15 additions & 5 deletions scripts/validate-deployment-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@ import managerMultisigAddresses from '../data/manager-multisig.json';

function main() {
const chainAliases = new Set(CHAINS.map((chain) => chain.alias));
[
Object.keys(managerMultisigAddresses),
const records: Record<string, string[]> = {
managerMultisigAddresses: Object.keys(managerMultisigAddresses),
chainsSupportedByDapis,
chainsSupportedByMarket,
chainsSupportedByOevAuctions,
].map((supportedChainAliases) => {
supportedChainAliases.map((supportedChainAlias) => {
};

Object.entries(records).forEach(([fieldName, supportedChainAliases]) => {
supportedChainAliases.forEach((supportedChainAlias) => {
if (!chainAliases.has(supportedChainAlias)) {
throw new Error(`Supported chain with alias ${supportedChainAlias} does not exist`);
throw new Error(`Supported chain in ${fieldName} with alias ${supportedChainAlias} does not exist`);
}
});
if (new Set(supportedChainAliases).size !== supportedChainAliases.length) {
throw new Error(`Duplicates found in ${fieldName}`);
}
const sortedSupportedChainAliases = [...supportedChainAliases].sort();
if (JSON.stringify(supportedChainAliases) !== JSON.stringify(sortedSupportedChainAliases)) {
throw new Error(`${fieldName} is not sorted`);
}
});

Object.entries(managerMultisigAddresses).map(([alias, address]) => {
if (!ethers.isAddress(address)) {
throw new Error(`Manager multisig address of ${alias}, ${address as string}, is not valid`);
Expand Down

0 comments on commit a5cf7a2

Please sign in to comment.