Skip to content

Commit e6467cb

Browse files
feat: upgrade to support BASE networks
1 parent 0356720 commit e6467cb

File tree

7 files changed

+120
-42
lines changed

7 files changed

+120
-42
lines changed

package-lock.json

Lines changed: 26 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"dependencies": {
4747
"@apollo/client": "^3.8.1",
4848
"@bosonprotocol/chat-sdk": "^1.3.1-alpha.9",
49-
"@bosonprotocol/react-kit": "^0.36.0-alpha.15",
49+
"@bosonprotocol/react-kit": "^0.36.0-alpha.16",
5050
"@davatar/react": "^1.10.4",
5151
"@ethersproject/address": "^5.6.1",
5252
"@ethersproject/units": "^5.7.0",

src/lib/constants/chainInfo.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ import polygonSquareLogoUrl from "assets/svg/polygon_square_logo.svg";
2020
import polygonMaticLogo from "assets/svg/polygon-matic-logo.svg";
2121
import ms from "ms";
2222

23-
import { LocalChainId, SupportedL1ChainId, SupportedL2ChainId } from "./chains";
23+
import {
24+
ChainId_BASE_SEPOLIA,
25+
ChainId_POLYGON_AMOY,
26+
LocalChainId,
27+
SupportedL1ChainId,
28+
SupportedL2ChainId
29+
} from "./chains";
2430
import {
2531
ARBITRUM_LIST,
2632
AVALANCHE_LIST,
@@ -205,7 +211,7 @@ const CHAIN_INFO: ChainInfoMap = {
205211
decimals: 18
206212
}
207213
},
208-
80002: {
214+
[ChainId_POLYGON_AMOY]: {
209215
networkType: NetworkType.L1,
210216
blockWaitMsBeforeWarning: ms(`10m`),
211217
bridge: "https://wallet.polygon.technology/polygon/bridge/deposit",
@@ -304,6 +310,22 @@ const CHAIN_INFO: ChainInfoMap = {
304310
squareLogoUrl: baseSquareLogo,
305311
nativeCurrency: { name: "Base Goerli Ether", symbol: "ETH", decimals: 18 }
306312
},
313+
[ChainId_BASE_SEPOLIA]: {
314+
networkType: NetworkType.L2,
315+
blockWaitMsBeforeWarning: ms(`10m`),
316+
bridge: "https://testnets.superbridge.app/base-sepolia",
317+
docs: "https://www.base.org",
318+
explorer: "https://sepolia.basescan.org/",
319+
infoLink: "https://info.uniswap.org/#/base-sepolia/",
320+
label: "Base Sepolia",
321+
logoUrl: ethereumLogoUrl,
322+
nativeCurrency: {
323+
name: "Ether",
324+
symbol: "ETH",
325+
decimals: 18
326+
},
327+
defaultListUrl: ""
328+
},
307329
[LocalChainId]: {
308330
networkType: NetworkType.L1,
309331
docs: "https://docs.uniswap.org/",

src/lib/constants/chains.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import { envChainIds } from "lib/config";
66

77
export const LocalChainId = 31337;
88
export const ChainId_POLYGON_AMOY = 80002;
9+
export const ChainId_BASE_SEPOLIA = 84532;
910

1011
export const UniWalletSupportedChains = [
1112
ChainId.MAINNET,
1213
// ChainId.ARBITRUM_ONE,
1314
// ChainId.OPTIMISM,
14-
ChainId.POLYGON
15-
// ChainId.BASE
15+
ChainId.POLYGON,
16+
ChainId.BASE
1617
];
1718

1819
export const CHAIN_IDS_TO_NAMES = {
@@ -21,7 +22,7 @@ export const CHAIN_IDS_TO_NAMES = {
2122
[ChainId.SEPOLIA]: "sepolia",
2223
[ChainId.POLYGON]: "polygon",
2324
[ChainId.POLYGON_MUMBAI]: "polygon_mumbai",
24-
80002: "polygon_amoy",
25+
[ChainId_POLYGON_AMOY]: "polygon_amoy",
2526
[ChainId.CELO]: "celo",
2627
[ChainId.CELO_ALFAJORES]: "celo_alfajores",
2728
[ChainId.ARBITRUM_ONE]: "arbitrum",
@@ -32,6 +33,7 @@ export const CHAIN_IDS_TO_NAMES = {
3233
[ChainId.AVALANCHE]: "avalanche",
3334
[ChainId.BASE]: "base",
3435
[ChainId.BASE_GOERLI]: "base_goerli",
36+
[ChainId_BASE_SEPOLIA]: "base_sepolia",
3537
[LocalChainId]: "local"
3638
} as const;
3739

@@ -41,7 +43,7 @@ export const CHAIN_IDS_TO_FRIENDLY_NAMES = {
4143
[ChainId.SEPOLIA]: "Sepolia",
4244
[ChainId.POLYGON]: "Polygon",
4345
[ChainId.POLYGON_MUMBAI]: "Polygon Mumbai",
44-
80002: "Polygon Amoy",
46+
[ChainId_POLYGON_AMOY]: "Polygon Amoy",
4547
[ChainId.CELO]: "Celo",
4648
[ChainId.CELO_ALFAJORES]: "Celo Alfajores",
4749
[ChainId.ARBITRUM_ONE]: "Arbitrum",
@@ -52,12 +54,14 @@ export const CHAIN_IDS_TO_FRIENDLY_NAMES = {
5254
[ChainId.AVALANCHE]: "Avalanche",
5355
[ChainId.BASE]: "Base",
5456
[ChainId.BASE_GOERLI]: "Base Goerli",
57+
[ChainId_BASE_SEPOLIA]: "Base Sepolia",
5558
[LocalChainId]: "Local Hardhat"
5659
} as const;
5760

5861
const SUPPORTED_CHAINS = [
5962
LocalChainId,
6063
ChainId_POLYGON_AMOY,
64+
ChainId_BASE_SEPOLIA,
6165
..._SUPPORTED_CHAINS
6266
] as const;
6367
export declare type SupportedChainsType = (typeof SUPPORTED_CHAINS)[number];
@@ -97,20 +101,21 @@ export function asSupportedChain(
97101

98102
export const SUPPORTED_GAS_ESTIMATE_CHAIN_IDS = [
99103
ChainId.MAINNET,
100-
ChainId.POLYGON
104+
ChainId.POLYGON,
101105
// ChainId.CELO,
102106
// ChainId.OPTIMISM,
103107
// ChainId.ARBITRUM_ONE
104108
// ChainId.BNB,
105109
// ChainId.AVALANCHE,
106-
// ChainId.BASE
110+
ChainId.BASE
107111
] as const;
108112

109113
export const TESTNET_CHAIN_IDS = [
110114
ChainId.GOERLI,
111115
ChainId.SEPOLIA,
112116
ChainId.POLYGON_MUMBAI,
113117
ChainId_POLYGON_AMOY,
118+
ChainId_BASE_SEPOLIA,
114119
LocalChainId
115120
// ChainId.ARBITRUM_GOERLI,
116121
// ChainId.OPTIMISM_GOERLI,
@@ -123,8 +128,8 @@ export const TESTNET_CHAIN_IDS = [
123128
*/
124129
export const L1_CHAIN_IDS = [
125130
ChainId.MAINNET,
126-
ChainId.GOERLI,
127-
// ChainId.SEPOLIA,
131+
// ChainId.GOERLI,
132+
ChainId.SEPOLIA,
128133
ChainId.POLYGON,
129134
ChainId.POLYGON_MUMBAI,
130135
ChainId_POLYGON_AMOY,
@@ -146,7 +151,8 @@ export const L2_CHAIN_IDS = [
146151
// ChainId.ARBITRUM_GOERLI,
147152
// ChainId.OPTIMISM,
148153
// ChainId.OPTIMISM_GOERLI
149-
// ChainId.BASE,
154+
ChainId.BASE,
155+
ChainId_BASE_SEPOLIA
150156
// ChainId.BASE_GOERLI
151157
] as const;
152158

@@ -166,6 +172,8 @@ export function getChainPriority(chainId: number): number {
166172
case ChainId.POLYGON:
167173
case ChainId.POLYGON_MUMBAI:
168174
case ChainId_POLYGON_AMOY:
175+
case ChainId.BASE:
176+
case ChainId_BASE_SEPOLIA:
169177
return 1;
170178
// case ChainId.ARBITRUM_ONE:
171179
// case ChainId.ARBITRUM_GOERLI:

src/lib/constants/providers.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import { ChainId } from "@uniswap/sdk-core";
77
import { CONFIG } from "lib/config";
88

99
import { AVERAGE_L1_BLOCK_TIME } from "./chainInfo";
10-
import { CHAIN_IDS_TO_NAMES, SupportedChainsType } from "./chains";
10+
import {
11+
CHAIN_IDS_TO_NAMES,
12+
ChainId_BASE_SEPOLIA,
13+
ChainId_POLYGON_AMOY,
14+
SupportedChainsType
15+
} from "./chains";
1116
const RPC_URLS = CONFIG.rpcUrls;
1217

1318
class AppJsonRpcProvider extends StaticJsonRpcProvider {
@@ -75,11 +80,12 @@ export const RPC_PROVIDERS: {
7580
[ChainId.ARBITRUM_GOERLI]: new AppJsonRpcProvider(ChainId.ARBITRUM_GOERLI),
7681
[ChainId.POLYGON]: new AppJsonRpcProvider(ChainId.POLYGON),
7782
[ChainId.POLYGON_MUMBAI]: new AppJsonRpcProvider(ChainId.POLYGON_MUMBAI),
78-
80002: new AppJsonRpcProvider(80002),
83+
[ChainId_POLYGON_AMOY]: new AppJsonRpcProvider(ChainId_POLYGON_AMOY),
7984
[ChainId.CELO]: new AppJsonRpcProvider(ChainId.CELO),
8085
[ChainId.CELO_ALFAJORES]: new AppJsonRpcProvider(ChainId.CELO_ALFAJORES),
8186
[ChainId.BNB]: new AppJsonRpcProvider(ChainId.BNB),
8287
[ChainId.AVALANCHE]: new AppJsonRpcProvider(ChainId.AVALANCHE),
8388
[ChainId.BASE]: new AppJsonRpcProvider(ChainId.BASE),
84-
[ChainId.BASE_GOERLI]: new AppJsonRpcProvider(ChainId.BASE_GOERLI)
89+
[ChainId.BASE_GOERLI]: new AppJsonRpcProvider(ChainId.BASE_GOERLI),
90+
[ChainId_BASE_SEPOLIA]: new AppJsonRpcProvider(ChainId_BASE_SEPOLIA)
8591
};

src/lib/constants/routing.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// a list of tokens by chain
22
import { ChainId, Currency, Token } from "@uniswap/sdk-core";
33

4+
import { ChainId_BASE_SEPOLIA, ChainId_POLYGON_AMOY } from "./chains";
45
import {
56
ARB,
67
BTC_BSC,
@@ -41,6 +42,7 @@ import {
4142
WBTC_POLYGON,
4243
WETH_AVALANCHE,
4344
WETH_POLYGON,
45+
WETH_POLYGON_AMOY,
4446
WETH_POLYGON_MUMBAI,
4547
WRAPPED_NATIVE_CURRENCY
4648
} from "./tokens";
@@ -111,6 +113,10 @@ export const COMMON_BASES: ChainCurrencyList = {
111113
nativeOnChain(ChainId.BASE_GOERLI),
112114
WRAPPED_NATIVE_CURRENCY[ChainId.BASE_GOERLI] as Token
113115
],
116+
[ChainId_BASE_SEPOLIA]: [
117+
nativeOnChain(ChainId_BASE_SEPOLIA),
118+
WRAPPED_NATIVE_CURRENCY[ChainId_BASE_SEPOLIA] as Token
119+
],
114120
[ChainId.POLYGON]: [
115121
nativeOnChain(ChainId.POLYGON),
116122
WETH_POLYGON,
@@ -124,6 +130,11 @@ export const COMMON_BASES: ChainCurrencyList = {
124130
WRAPPED_NATIVE_CURRENCY[ChainId.POLYGON_MUMBAI] as Token,
125131
WETH_POLYGON_MUMBAI
126132
],
133+
[ChainId_POLYGON_AMOY]: [
134+
nativeOnChain(ChainId_POLYGON_AMOY),
135+
WRAPPED_NATIVE_CURRENCY[ChainId_POLYGON_AMOY] as Token,
136+
WETH_POLYGON_AMOY
137+
],
127138

128139
[ChainId.CELO]: [
129140
nativeOnChain(ChainId.CELO),

0 commit comments

Comments
 (0)