Skip to content

Commit

Permalink
fix: backport legacy changes to generation script (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBHarley authored Apr 23, 2024
1 parent b18be43 commit 51dd425
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
32 changes: 26 additions & 6 deletions src/generate-token-list-from-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as viemChains from "viem/chains";

import { OptimismMintableERC20Abi } from "./abis/OptimismMintableERC20";
import { StandardBridgeAbi } from "./abis/StandardBridge";
import { L2StandardERC20Abi } from "./abis/L2StandardERC20";

interface SuperchainToken {
chainId: number;
Expand Down Expand Up @@ -52,6 +53,8 @@ async function main() {
readFileSync(join(__dirname, "..", "data", path, "data.json")).toString()
);

console.log(path);

const tokens: SuperchainToken[] = [];

function addToken({
Expand Down Expand Up @@ -118,7 +121,7 @@ async function main() {
transport: http(),
});

const [BRIDGE, REMOTE_TOKEN] = await Promise.all([
const [BRIDGE, REMOTE_TOKEN, l2Bridge, l1Token] = await Promise.all([
client
.readContract({
abi: OptimismMintableERC20Abi,
Expand All @@ -133,12 +136,29 @@ async function main() {
address: address as Address,
})
.catch(() => null),
client
.readContract({
abi: L2StandardERC20Abi,
functionName: "l2Bridge",
address: address as Address,
})
.catch(() => null),
client
.readContract({
abi: L2StandardERC20Abi,
functionName: "l1Token",
address: address as Address,
})
.catch(() => null),
]);

const localBridge = BRIDGE || l2Bridge;
const remoteToken = REMOTE_TOKEN || l1Token;

// mintable
if (BRIDGE && REMOTE_TOKEN) {
if (localBridge && remoteToken) {
const baseChainId = Object.entries(data.addresses).find(
([_, address]) => isAddressEqual(address as Address, REMOTE_TOKEN)
([_, address]) => isAddressEqual(address as Address, remoteToken)
);
if (!baseChainId) {
throw new Error(`No baseChainId found for ${data.symbol}:${chainId}`);
Expand All @@ -149,7 +169,7 @@ async function main() {
.readContract({
abi: StandardBridgeAbi,
functionName: "OTHER_BRIDGE",
address: BRIDGE,
address: localBridge,
})
.catch(() => null),
]);
Expand All @@ -158,13 +178,13 @@ async function main() {
}

addToken({
baseAddress: REMOTE_TOKEN,
baseAddress: remoteToken,
baseBridgeAddress: OTHER_BRIDGE,
baseChainId: parseInt(baseChainId[0]),

mintableChainId: parseInt(chainId),
mintableAddress: address,
mintableBridgeAddress: BRIDGE,
mintableBridgeAddress: localBridge,
});
}
}
Expand Down
30 changes: 29 additions & 1 deletion superchain.tokenlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"layer2",
"infrastructure"
],
"timestamp": "2024-04-23T21:26:10.211Z",
"timestamp": "2024-04-23T21:44:09.345Z",
"tokens": [
{
"name": "Wrapped MistCoin",
Expand Down Expand Up @@ -316,6 +316,34 @@
}
}
},
{
"name": "Tether USD",
"symbol": "USDT",
"decimals": 6,
"logoURI": "https://raw.githubusercontent.com/ethereum-optimism/ethereum-optimism.github.io/01d7d6bf2ff3735b412da924d1df746ddd8a77a8/data/USDT/logo.png",
"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"chainId": 1,
"extensions": {
"opTokenId": "USDT",
"standardBridgeAddresses": {
"8453": "0x3154Cf16ccdb4C6d922629664174b904d80F2C35"
}
}
},
{
"name": "Tether USD",
"symbol": "USDT",
"decimals": 6,
"logoURI": "https://raw.githubusercontent.com/ethereum-optimism/ethereum-optimism.github.io/01d7d6bf2ff3735b412da924d1df746ddd8a77a8/data/USDT/logo.png",
"address": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
"chainId": 8453,
"extensions": {
"opTokenId": "USDT",
"standardBridgeAddresses": {
"1": "0x4200000000000000000000000000000000000010"
}
}
},
{
"name": "ZynCoin",
"symbol": "ZYN",
Expand Down

0 comments on commit 51dd425

Please sign in to comment.