Skip to content

Commit 8ef0a3a

Browse files
authored
chore: Bump constants & update enable token script (#900)
For testnet definitions.
1 parent af93fb1 commit 8ef0a3a

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"pre-commit-hook": "sh scripts/preCommitHook.sh"
4343
},
4444
"dependencies": {
45-
"@across-protocol/constants": "^3.1.35",
45+
"@across-protocol/constants": "^3.1.37",
4646
"@coral-xyz/anchor": "^0.30.1",
4747
"@defi-wonderland/smock": "^2.3.4",
4848
"@eth-optimism/contracts": "^0.5.40",

tasks/enableL1TokenAcrossEcosystem.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { task } from "hardhat/config";
22
import assert from "assert";
3-
import { CHAIN_IDs, MAINNET_CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "../utils/constants";
3+
import { CHAIN_IDs, MAINNET_CHAIN_IDs, TESTNET_CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "../utils/constants";
44
import { askYesNoQuestion, resolveTokenOnChain, isTokenSymbol, minimalSpokePoolInterface } from "./utils";
55
import { TokenSymbol } from "./types";
66

@@ -9,13 +9,13 @@ const NO_SYMBOL = "----";
99
const NO_ADDRESS = "------------------------------------------";
1010

1111
// Supported mainnet chain IDs.
12-
const enabledChainIds = Object.values(MAINNET_CHAIN_IDs)
13-
.map(Number)
14-
.filter((chainId) => chainId !== CHAIN_IDs.BOBA)
15-
.sort((x, y) => x - y);
16-
17-
const chainPadding = enabledChainIds[enabledChainIds.length - 1].toString().length;
18-
const formatChainId = (chainId: number): string => chainId.toString().padStart(chainPadding, " ");
12+
const enabledChainIds = (hubChainId: number) => {
13+
const chainIds = hubChainId === CHAIN_IDs.MAINNET ? MAINNET_CHAIN_IDs : TESTNET_CHAIN_IDs;
14+
return Object.values(chainIds)
15+
.map(Number)
16+
.filter((chainId) => chainId !== CHAIN_IDs.BOBA)
17+
.sort((x, y) => x - y);
18+
};
1919

2020
const getChainsFromList = (taskArgInput: string): number[] =>
2121
taskArgInput
@@ -65,18 +65,19 @@ task("enable-l1-token-across-ecosystem", "Enable a provided token across the ent
6565
const [signer] = await hre.ethers.getSigners();
6666

6767
// Remove chainIds that are in the ignore list.
68+
const _enabledChainIds = enabledChainIds(hubChainId);
6869
let inputChains: number[] = [];
6970
try {
70-
inputChains = (chains?.split(",") ?? enabledChainIds).map(Number);
71+
inputChains = (chains?.split(",") ?? _enabledChainIds).map(Number);
7172
console.log(`\nParsed 'chains' argument:`, inputChains);
7273
} catch (error) {
7374
throw new Error(`Failed to parse 'chains' argument ${chains} as a comma-separated list of numbers.`);
7475
}
75-
if (inputChains.length === 0) inputChains = enabledChainIds;
76+
if (inputChains.length === 0) inputChains = _enabledChainIds;
7677
else if (inputChains.some((chain) => isNaN(chain) || !Number.isInteger(chain) || chain < 0)) {
7778
throw new Error(`Invalid chains list: ${inputChains}`);
7879
}
79-
const chainIds = enabledChainIds.filter((chainId) => inputChains.includes(chainId));
80+
const chainIds = _enabledChainIds.filter((chainId) => inputChains.includes(chainId));
8081

8182
console.log("\nLoading L2 companion token address for provided L1 token.");
8283
const tokens = Object.fromEntries(
@@ -121,9 +122,11 @@ task("enable-l1-token-across-ecosystem", "Enable a provided token across the ent
121122
let i = 0; // counter for logging.
122123
const skipped: { [originChainId: number]: number[] } = {};
123124
const routeChainIds = Object.keys(tokens).map(Number);
125+
const chainPadding = _enabledChainIds[enabledChainIds.length - 1].toString().length;
126+
const formatChainId = (chainId: number): string => chainId.toString().padStart(chainPadding, " ");
124127
routeChainIds.forEach((fromId) => {
125128
const formattedFromId = formatChainId(fromId);
126-
const { symbol, address: inputToken } = tokens[fromId];
129+
const { address: inputToken } = tokens[fromId];
127130
skipped[fromId] = [];
128131
routeChainIds.forEach((toId) => {
129132
if (fromId === toId || [fromId, toId].some((chainId) => tokens[chainId].symbol === NO_SYMBOL)) {

utils/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export {
33
MAINNET_CHAIN_IDs,
44
PRODUCTION_NETWORKS,
55
PUBLIC_NETWORKS,
6+
TESTNET_CHAIN_IDs,
67
TOKEN_SYMBOLS_MAP,
78
} from "@across-protocol/constants";
89

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

5-
"@across-protocol/constants@^3.1.35":
6-
version "3.1.35"
7-
resolved "https://registry.yarnpkg.com/@across-protocol/constants/-/constants-3.1.35.tgz#80ee8e569bc5c1fc94b5087d357d9612fd782151"
8-
integrity sha512-2Fj9mqBEVQu4Bsq6o7helUkhEjpce+uqni0pTV51y1QOEQdgAJU5U5BNQFXUMUDMQRaM3DqB4ys89GVJ4TuA/w==
5+
"@across-protocol/constants@^3.1.37":
6+
version "3.1.37"
7+
resolved "https://registry.yarnpkg.com/@across-protocol/constants/-/constants-3.1.37.tgz#7f1da248abe809eb9fb621f1876fbde78ec3509b"
8+
integrity sha512-qPRntmeIDxgOwfXhPl90Mf61Fb4k20ecCc0N9Cco+5fSJE9PM4oI6Jq8VYnewyMPglYHZ1kMcdCPWYGebUs0Aw==
99

1010
"@across-protocol/contracts@^0.1.4":
1111
version "0.1.4"

0 commit comments

Comments
 (0)