Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions apps/swap-widgets-react-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const walletConnect = walletConnectModule({
/**
* Chains required to be supported by all wallets connecting to your DApp
*/
requiredChains: [1, 42161, 8453, 80094],
requiredChains: [1, 42161, 8453, 80094, 999],
/**
* Chains required to be supported by all wallets connecting to your DApp
*/
Expand All @@ -39,24 +39,56 @@ init({
token: "ETH",
label: "Ethereum Mainnet",
rpcUrl: "https://ethereum.kyberengineering.io",
namespace: "evm",
},
{
id: "0xa4b1", // 42161 in hex
token: "ETH",
label: "Arbitrum One",
rpcUrl: "https://arbitrum.llamarpc.com",
namespace: "evm",
},
{
id: "0x89",
token: "MATIC",
label: "Polygon",
rpcUrl: "https://polygon.kyberengineering.io",
namespace: "evm",
},
{
id: "0x138de",
token: "BERA",
label: "Berachain",
rpcUrl: "https://rpc.berachain.com",
namespace: "evm",
},
{
id: "0x3e7",
token: "HYPE",
label: "HyperEvm",
rpcUrl: "https://rpc.hyperliquid.xyz/evm",
namespace: "evm",
},
{
id: "0x38",
token: "BNB",
label: "BSC",
rpcUrl: "https://bsc-dataseed.binance.org/",
namespace: "evm",
},
{
id: "0x2105",
token: "ETH",
label: "Base",
rpcUrl: "https://mainnet.base.org",
namespace: "evm",
},
{
id: "0x92",
token: "S",
label: "Sonic",
rpcUrl: "https://rpc.soniclabs.com",
namespace: "evm",
},
],
});
Expand All @@ -83,17 +115,17 @@ function App() {
if (!connectedWallets.length) return;

const connectedWalletsLabelArray = connectedWallets.map(
({ label }) => label
({ label }) => label,
);
window.localStorage.setItem(
"connectedWallets",
JSON.stringify(connectedWalletsLabelArray)
JSON.stringify(connectedWalletsLabelArray),
);
}, [connectedWallets, wallet]);

useEffect(() => {
const previouslyConnectedWallets = JSON.parse(
window.localStorage.getItem("connectedWallets") || "[]"
window.localStorage.getItem("connectedWallets") || "[]",
);

if (previouslyConnectedWallets?.length) {
Expand Down Expand Up @@ -164,6 +196,7 @@ function App() {
324: "0x493257fd37edb34451f62edf8d2a0c418852ba4c",
8453: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
80094: "0x549943e04f40284185054145c6e4e9568c1d3241",
999: "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb",
};

const [feeSetting, setFeeSetting] = useState({
Expand All @@ -178,7 +211,9 @@ function App() {

console.log("wallet", wallet?.accounts[0].address);

const [, setChain] = useSetChain();
const [chains, setChain] = useSetChain();
console.log(chains);

const [customChainId, setCustomChainId] = useState(chainId);

return (
Expand Down Expand Up @@ -254,6 +289,7 @@ function App() {
<option value={8453}>Base</option>
<option value={80094}>Bera</option>
<option value={146}>Sonic</option>
<option value={999}>HyperEvm</option>
</select>
<label>chainId</label>
</div>
Expand Down Expand Up @@ -419,7 +455,8 @@ function App() {
}}
onSwitchChain={() => {
setChain({
chainId: chainId.toString(),
chainId: "0x" + customChainId.toString(16),
chainNamespace: "evm",
});
}}
enableRoute={enableRoute}
Expand Down
2 changes: 1 addition & 1 deletion packages/swap-widgets/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kyberswap/widgets",
"license": "MIT",
"version": "2.1.0",
"version": "2.1.1",
"type": "module",
"scripts": {
"dev": "tsup --watch",
Expand Down
4 changes: 2 additions & 2 deletions packages/swap-widgets/src/components/TradeRouting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

return (
<StyledWrap ref={shadowRef} backgroundColor={backgroundColor}>
<ScrollContainer innerRef={scrollRef} vertical={false} onScroll={handleShadow}>
{React.createElement(ScrollContainer as any, { innerRef: scrollRef, vertical: false, onScroll: handleShadow },

Check failure on line 59 in packages/swap-widgets/src/components/TradeRouting/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `ScrollContainer·as·any,` with `⏎········ScrollContainer·as·any,⏎·······`
<StyledHops length={route?.subRoutes?.length} ref={contentRef}>
{route.subRoutes.map((subRoute, index, arr) => {
const token = route.path[index + 1]
Expand Down Expand Up @@ -125,8 +125,8 @@
</React.Fragment>
)
})}
</StyledHops>

Check failure on line 128 in packages/swap-widgets/src/components/TradeRouting/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
</ScrollContainer>
)}
</StyledWrap>
)
}
Expand Down
24 changes: 23 additions & 1 deletion packages/swap-widgets/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
beraTokens,
sonicTokens,
} from './tokens'
import hyperEvmTokens from './tokens/hyperevm'

export enum ZIndex {
UNDERLAYER = -1,
Expand Down Expand Up @@ -129,6 +130,14 @@ export const NATIVE_TOKEN: {
chainId: 146,
logoURI: 'https://www.soniclabs.com/favicon.ico',
},
999: {
name: 'HYPE',
symbol: 'HYPE',
decimals: 18,
address: NATIVE_TOKEN_ADDRESS,
chainId: 199,
logoURI: 'https://storage.googleapis.com/ks-setting-1d682dca/5735d731-d5da-4ba4-af94-2e945110130c1750316953655.png',
},
}

export const WRAPPED_NATIVE_TOKEN: {
Expand Down Expand Up @@ -270,6 +279,14 @@ export const WRAPPED_NATIVE_TOKEN: {
chainId: 146,
logoURI: 'https://sonicscan.org/token/images/wrappedsonic_32.svg',
},
999: {
name: 'Wrapped HYPE',
decimals: 18,
symbol: 'WHYPE',
address: '0x5555555555555555555555555555555555555555',
chainId: 999,
logoURI: 'https://s2.coinmarketcap.com/static/img/coins/64x64/35881.png',
},
}

export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
Expand All @@ -294,6 +311,7 @@ export const DEFAULT_TOKENS: {
5000: mantleTokens,
80094: beraTokens,
146: sonicTokens,
999: hyperEvmTokens,
}

export const MULTICALL_ADDRESS: { [chainId: number]: string } = {
Expand All @@ -314,6 +332,7 @@ export const MULTICALL_ADDRESS: { [chainId: number]: string } = {
5000: '0xcA11bde05977b3631167028862bE2a173976CA11',
80094: '0xcA11bde05977b3631167028862bE2a173976CA11',
146: '0xcA11bde05977b3631167028862bE2a173976CA11',
999: '0xcA11bde05977b3631167028862bE2a173976CA11',
}

export const AGGREGATOR_PATH: { [chainId: number]: string } = {
Expand All @@ -334,6 +353,7 @@ export const AGGREGATOR_PATH: { [chainId: number]: string } = {
5000: 'mantle',
80094: 'berachain',
146: 'sonic',
999: 'hyperevm',
}

export const SCAN_LINK: { [chainId: number]: string } = {
Expand All @@ -354,13 +374,14 @@ export const SCAN_LINK: { [chainId: number]: string } = {
5000: 'https://explorer.mantle.xyz',
80094: 'https://berascan.com',
146: 'https://sonicscan.org',
999: 'https://hyperevmscan.io',
}

export const DefaultRpcUrl: { [chainId: number]: string } = {
1: 'https://ethereum.kyberengineering.io',
137: 'https://polygon-rpc.com',
56: 'https://bsc.kyberengineering.io',
43114: 'https://avalanche.kyberengineering.io',
43114: 'https://api.avax.network/ext/bc/C/rpc',
250: 'https://rpc.fantom.network',
25: '', // cronos deprecated
42161: 'https://arbitrum.kyberengineering.io',
Expand All @@ -374,6 +395,7 @@ export const DefaultRpcUrl: { [chainId: number]: string } = {
5000: 'https://rpc.mantle.xyz',
80094: 'https://rpc.berachain.com',
146: 'https://rpc.soniclabs.com',
999: 'https://rpc.hyperliquid.xyz/evm',
}

export const SUPPORTED_NETWORKS = Object.keys(SCAN_LINK)
Loading
Loading