Skip to content

Commit

Permalink
chore: add opbnb token list
Browse files Browse the repository at this point in the history
  • Loading branch information
chefjackson committed Sep 19, 2023
1 parent 8fdbab7 commit 8c7e1ad
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 30 deletions.
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ switch (command) {
throw new Error(`Failed to generate list ${listName}`);
}
break;
case 'makeindex':
case "makeindex":
await buildIndex(LISTS);
break;
case "fetch":
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions lists/pancakeswap-opbnb-default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "PancakeSwap opBNB Default",
"timestamp": "2023-09-19T04:04:09.611Z",
"version": {
"major": 0,
"minor": 0,
"patch": 6
},
"logoURI": "https://pancakeswap.finance/logo.png",
"keywords": [
"pancakeswap",
"default",
"opbnb"
],
"tokens": [
{
"name": "BTCB Token",
"symbol": "BTCB",
"address": "0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2",
"chainId": 204,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/opbnb/0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2.png"
},
{
"name": "Ethereum Token",
"symbol": "ETH",
"address": "0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea",
"chainId": 204,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/opbnb/0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea.png"
},
{
"name": "Wrapped BNB",
"symbol": "WBNB",
"address": "0x4200000000000000000000000000000000000006",
"chainId": 204,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/opbnb/0x4200000000000000000000000000000000000006.png"
},
{
"name": "Tether USD",
"symbol": "USDT",
"address": "0x9e5AAC1Ba1a2e6aEd6b32689DFcF62A509Ca96f3",
"chainId": 204,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/usdt.png"
}
]
}
16 changes: 8 additions & 8 deletions src/buildList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ export const buildList = async (listName: string, versionBump?: VersionBump): Pr
// sort them by symbol for easy readability (not applied to default list)
tokens: sort
? list.sort((t1, t2) => {
if (t1.chainId === t2.chainId) {
// CAKE first in extended list
if ((t1.symbol === "CAKE") !== (t2.symbol === "CAKE")) {
return t1.symbol === "CAKE" ? -1 : 1;
}
return t1.symbol.toLowerCase() < t2.symbol.toLowerCase() ? -1 : 1;
if (t1.chainId === t2.chainId) {
// CAKE first in extended list
if ((t1.symbol === "CAKE") !== (t2.symbol === "CAKE")) {
return t1.symbol === "CAKE" ? -1 : 1;
}
return t1.chainId < t2.chainId ? -1 : 1;
})
return t1.symbol.toLowerCase() < t2.symbol.toLowerCase() ? -1 : 1;
}
return t1.chainId < t2.chainId ? -1 : 1;
})
: list,
};
};
Expand Down
6 changes: 6 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,10 @@ export const LISTS = {
logoURI: "https://pancakeswap.finance/logo.png",
sort: true,
},
"pancakeswap-opbnb-default": {
name: "PancakeSwap opBNB Default",
keywords: ["pancakeswap", "default", "opbnb"],
logoURI: "https://pancakeswap.finance/logo.png",
sort: false,
},
} as const;
34 changes: 34 additions & 0 deletions src/tokens/pancakeswap-opbnb-default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "BTCB Token",
"symbol": "BTCB",
"address": "0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2",
"chainId": 204,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/opbnb/0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2.png"
},
{
"name": "Ethereum Token",
"symbol": "ETH",
"address": "0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea",
"chainId": 204,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/opbnb/0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea.png"
},
{
"name": "Wrapped BNB",
"symbol": "WBNB",
"address": "0x4200000000000000000000000000000000000006",
"chainId": 204,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/opbnb/0x4200000000000000000000000000000000000006.png"
},
{
"name": "Tether USD",
"symbol": "USDT",
"address": "0x9e5AAC1Ba1a2e6aEd6b32689DFcF62A509Ca96f3",
"chainId": 204,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/usdt.png"
}
]
68 changes: 48 additions & 20 deletions src/utils/publicClients.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,75 @@
import { createPublicClient, http, Chain } from "viem";
import { arbitrum, base, bsc, mainnet, polygonZkEvm, zkSync } from "viem/chains";



export const linea = {
id: 59_144,
name: 'Linea Mainnet',
network: 'linea-mainnet',
nativeCurrency: { name: 'Linea Ether', symbol: 'ETH', decimals: 18 },
name: "Linea Mainnet",
network: "linea-mainnet",
nativeCurrency: { name: "Linea Ether", symbol: "ETH", decimals: 18 },
rpcUrls: {
infura: {
http: ['https://linea-mainnet.infura.io/v3'],
webSocket: ['wss://linea-mainnet.infura.io/ws/v3'],
http: ["https://linea-mainnet.infura.io/v3"],
webSocket: ["wss://linea-mainnet.infura.io/ws/v3"],
},
default: {
http: ['https://rpc.linea.build'],
webSocket: ['wss://rpc.linea.build'],
http: ["https://rpc.linea.build"],
webSocket: ["wss://rpc.linea.build"],
},
public: {
http: ['https://rpc.linea.build'],
webSocket: ['wss://rpc.linea.build'],
http: ["https://rpc.linea.build"],
webSocket: ["wss://rpc.linea.build"],
},
},
blockExplorers: {
default: {
name: 'Etherscan',
url: 'https://lineascan.build',
name: "Etherscan",
url: "https://lineascan.build",
},
etherscan: {
name: 'Etherscan',
url: 'https://lineascan.build',
name: "Etherscan",
url: "https://lineascan.build",
},
blockscout: {
name: 'Blockscout',
url: 'https://explorer.linea.build',
name: "Blockscout",
url: "https://explorer.linea.build",
},
},
contracts: {
multicall3: {
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
blockCreated: 42,
},
},
testnet: false,
} as const satisfies Chain
} as const satisfies Chain;

export const opbnb = {
id: 204,
name: "opBNB Mainnet",
network: "opbnb",
nativeCurrency: { name: "BNB", symbol: "BNB", decimals: 18 },
rpcUrls: {
default: {
http: ["https://opbnb-mainnet-rpc.bnbchain.org"],
},
public: {
http: ["https://opbnb-mainnet-rpc.bnbchain.org"],
},
},
blockExplorers: {
default: {
name: "opBNBScan",
url: "https://opbnbscan.com",
},
},
contracts: {
multicall3: {
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
blockCreated: 512881,
},
},
testnet: true,
} as const satisfies Chain;

export const publicClients = {
[mainnet.id]: createPublicClient({
Expand Down Expand Up @@ -75,5 +100,8 @@ export const publicClients = {
chain: base,
transport: http(),
}),
[opbnb.id]: createPublicClient({
chain: opbnb,
transport: http(),
}),
};

3 changes: 2 additions & 1 deletion test/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import getTokenChainData from "../src/utils/getTokensChainData.js";
import { getAptosCoinsChainData } from "../src/utils/getAptosCoinChainData.js";
import { LISTS } from "../src/constants.js";
import { arbitrum, base, bsc, mainnet, polygonZkEvm, zkSync } from "viem/chains";
import { linea } from "../src/utils/publicClients.js";
import { linea, opbnb } from "../src/utils/publicClients.js";

const CASES = Object.entries(LISTS).map(([key, value]) =>
"test" in value ? ([key, value.test] as const) : ([key] as const)
Expand Down Expand Up @@ -49,6 +49,7 @@ const multiChainLogoPath = {
[arbitrum.id]: "/arbitrum",
[linea.id]: "/linea",
[base.id]: "/base",
[opbnb.id]: "/opbnb",
};

// Modified https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get
Expand Down

0 comments on commit 8c7e1ad

Please sign in to comment.