Skip to content

Commit b999229

Browse files
committed
support sonic chain
1 parent d3f2635 commit b999229

File tree

6 files changed

+69
-17
lines changed

6 files changed

+69
-17
lines changed

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@ensofinance/sdk": "^1.0.1",
1414
"@ensofinance/shortcuts-widget": "workspace:*",
15-
"@rainbow-me/rainbowkit": "^2.2.1",
15+
"@rainbow-me/rainbowkit": "^2.2.4",
1616
"@tanstack/react-query": "^5.62.10",
1717
"@uidotdev/usehooks": "^2.4.1",
1818
"next-themes": "^0.4.4",

app/src/App.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ function App() {
6363
>
6464
<img src={logoUrl} alt={"Enso"} style={{ height: "50px" }} />
6565

66-
<div>
67-
<ConnectButton />
68-
</div>
66+
<ConnectButton />
6967
</div>
7068

7169
<div

app/src/components/Providers.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ import {
1111
gnosis,
1212
polygon,
1313
berachain,
14+
sonic,
1415
} from "viem/chains";
1516
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
1617
import { WagmiProvider } from "wagmi";
1718
import React from "react";
1819

1920
const berachainWithIcon = {
2021
...berachain,
21-
iconUrl: "https://assets.coingecko.com/coins/images/25235/large/BERA.png?1738822008",
22+
iconUrl:
23+
"https://assets.coingecko.com/coins/images/25235/large/BERA.png?1738822008",
24+
};
25+
const sonicWithIcon = {
26+
...sonic,
27+
iconUrl:
28+
"https://assets.coingecko.com/coins/images/38108/standard/200x200_Sonic_Logo.png",
2229
};
2330

2431
const config = getDefaultConfig({
@@ -29,6 +36,7 @@ const config = getDefaultConfig({
2936
base,
3037
arbitrum,
3138
berachainWithIcon,
39+
sonicWithIcon,
3240
zksync,
3341
optimism,
3442
bsc,

pnpm-lock.yaml

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

widget/src/constants.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ const DAI_TOKEN: Token = {
6161
logoURI:
6262
"https://assets.coingecko.com/coins/images/11062/large/Identity-Primary-DarkBG.png",
6363
};
64+
const SONIC_TOKEN: Token = {
65+
address: ETH_ADDRESS,
66+
name: "Sonic",
67+
symbol: "S",
68+
decimals: 18,
69+
logoURI:
70+
"https://assets.coingecko.com/coins/images/38108/standard/200x200_Sonic_Logo.png",
71+
};
6472

6573
export enum SupportedChainId {
6674
MAINNET = 1,
@@ -77,6 +85,7 @@ export enum SupportedChainId {
7785
GNOSIS = 100,
7886
AVALANCHE = 43114,
7987
BERACHAIN = 80094,
88+
SONIC = 146,
8089
// ARBITRUM_RINKEBY = 421611,
8190
// OPTIMISM_GOERLI = 420,w
8291
// GOERLI = 5,
@@ -100,6 +109,7 @@ export const GECKO_CHAIN_NAMES: { [key in SupportedChainId]: string } = {
100109
[SupportedChainId.GNOSIS]: "xdai",
101110
[SupportedChainId.AVALANCHE]: "avalanche",
102111
[SupportedChainId.BERACHAIN]: "berachain",
112+
[SupportedChainId.SONIC]: "sonic",
103113
};
104114

105115
export const MOCK_IMAGE_URL =
@@ -120,6 +130,7 @@ export const CHAINS_ETHERSCAN: Record<SupportedChainId, string> = {
120130
[SupportedChainId.GNOSIS]: "https://gnosisscan.io/",
121131
[SupportedChainId.AVALANCHE]: "https://cchain.explorer.avax.network",
122132
[SupportedChainId.BERACHAIN]: "https://berascan.com",
133+
[SupportedChainId.SONIC]: "https://sonicscan.io",
123134
};
124135

125136
export const USDC_ADDRESS: Record<SupportedChainId, Address> = {
@@ -133,7 +144,8 @@ export const USDC_ADDRESS: Record<SupportedChainId, Address> = {
133144
[avalanche.id]: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
134145
[gnosis.id]: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
135146
[bsc.id]: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
136-
[80094]: "0x549943e04f40284185054145c6e4e9568c1d3241",
147+
[SupportedChainId.BERACHAIN]: "0x549943e04f40284185054145c6e4e9568c1d3241",
148+
[SupportedChainId.SONIC]: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
137149
};
138150

139151
export const NATIVE_ETH_CHAINS = [
@@ -157,6 +169,7 @@ export const CHAINS_NATIVE_TOKENS: Record<SupportedChainId, Token> = {
157169
[SupportedChainId.POLYGON]: MATIC_TOKEN,
158170
[SupportedChainId.BERACHAIN]: BERA_TOKEN,
159171
[SupportedChainId.GNOSIS]: DAI_TOKEN,
172+
[SupportedChainId.SONIC]: SONIC_TOKEN,
160173
};
161174

162175
export const SWAP_LIMITS: Record<Address, number> = {

widget/src/util/common.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ const getOogaboogaList: () => Promise<Token[]> = () =>
4646
: token.address.toLowerCase(),
4747
})),
4848
);
49+
//
50+
// const getShadowList: (chainId: number) => Promise<Token[]> = () =>
51+
// fetch(
52+
// `https://raw.githubusercontent.com/Shadow-Exchange/shadow-assets/main/blockchains/sonic/tokenlist.json`,
53+
// )
54+
// .then((res) => res.json())
55+
// .then((data) =>
56+
// data.tokens[0]
57+
// .map((token: any) => ({
58+
// ...token,
59+
// address: token.address?.toLowerCase(),
60+
// logoURI: `https://raw.githubusercontent.com/Shadow-Exchange/shadow-assets/main/blockchains/sonic/assets/${token.address}/logo.png`,
61+
// }))
62+
// .filter(({ address }) => address),
63+
// );
4964

5065
const getOneInchTokenList = (chainId: number) =>
5166
fetch("https://tokens.1inch.io/v1.2/" + chainId)
@@ -66,20 +81,38 @@ const getChainSymbolSortPriority = (chainId: SupportedChainId) => {
6681
UNI: 3,
6782
SUSHI: 3,
6883
AAVE: 3,
84+
USDCE: 2,
6985
};
7086
switch (chainId) {
7187
default:
7288
return defaultPriority;
7389
}
7490
};
7591

92+
const sonicAdditionalTokens = // TODO: remove after it comes in list for sonic
93+
new Promise<Token[]>((resolve) =>
94+
resolve([
95+
{
96+
address: "0x6047828dc181963ba44974801FF68e538dA5eaF9",
97+
name: "Tether USD",
98+
symbol: "USDT",
99+
decimals: 6,
100+
logoURI:
101+
"https://assets.coingecko.com/coins/images/325/large/Tether.png",
102+
},
103+
]),
104+
);
105+
76106
const getCurrentChainTokens = (chainId: SupportedChainId) => {
77107
let getters: Promise<Token[] | undefined>[] = [];
78108

79109
switch (chainId) {
80110
case SupportedChainId.BERACHAIN:
81111
getters = [getOogaboogaList()];
82112
break;
113+
case SupportedChainId.SONIC:
114+
getters = [getGeckoList(chainId), sonicAdditionalTokens];
115+
break;
83116
default:
84117
// priority for oneInch tokens
85118
getters = [getOneInchTokenList(chainId), getGeckoList(chainId)];

0 commit comments

Comments
 (0)