diff --git a/.github/actions/gh-pages/action.yaml b/.github/actions/gh-pages/action.yaml index cd1fdac1..2fe8d0fe 100644 --- a/.github/actions/gh-pages/action.yaml +++ b/.github/actions/gh-pages/action.yaml @@ -34,8 +34,8 @@ runs: - name: Install & build shell: bash run: | - node common/scripts/install-run-rush.js install -t @bnb-chain/canonical-bridge-ui - node common/scripts/install-run-rush.js build -t @bnb-chain/canonical-bridge-ui + node common/scripts/install-run-rush.js install -t canonical-bridge-ui + node common/scripts/install-run-rush.js build -t canonical-bridge-ui - name: Pushes to another repository uses: cpina/github-action-push-to-another-repository@main diff --git a/.gitignore b/.gitignore index 70dc58c8..d1ee4618 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ common/autoinstallers/*/.npmrc .env*.local .pnpm-store +.release/.npmrc \ No newline at end of file diff --git a/.release/.changeset/fluffy-rocks-count.md b/.release/.changeset/fluffy-rocks-count.md new file mode 100644 index 00000000..d54d34d3 --- /dev/null +++ b/.release/.changeset/fluffy-rocks-count.md @@ -0,0 +1,6 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +"@bnb-chain/canonical-bridge-sdk": patch +--- + +Only show supported networks in status popup diff --git a/.release/.changeset/great-jars-float.md b/.release/.changeset/great-jars-float.md new file mode 100644 index 00000000..89879d10 --- /dev/null +++ b/.release/.changeset/great-jars-float.md @@ -0,0 +1,6 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +"@bnb-chain/canonical-bridge-sdk": patch +--- + +Support switch network for tron & fix issues diff --git a/.release/.changeset/odd-lies-design.md b/.release/.changeset/odd-lies-design.md new file mode 100644 index 00000000..d54d34d3 --- /dev/null +++ b/.release/.changeset/odd-lies-design.md @@ -0,0 +1,6 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +"@bnb-chain/canonical-bridge-sdk": patch +--- + +Only show supported networks in status popup diff --git a/.release/.changeset/pre.json b/.release/.changeset/pre.json new file mode 100644 index 00000000..0fcb0e77 --- /dev/null +++ b/.release/.changeset/pre.json @@ -0,0 +1,15 @@ +{ + "mode": "pre", + "tag": "alpha", + "initialVersions": { + "@bnb-chain/canonical-bridge-sdk": "0.1.6", + "@bnb-chain/canonical-bridge-widget": "0.1.6" + }, + "changesets": [ + "fluffy-rocks-count", + "great-jars-float", + "odd-lies-design", + "stupid-mugs-push", + "tiny-lizards-cross" + ] +} diff --git a/.release/.changeset/stupid-mugs-push.md b/.release/.changeset/stupid-mugs-push.md new file mode 100644 index 00000000..2599685e --- /dev/null +++ b/.release/.changeset/stupid-mugs-push.md @@ -0,0 +1,6 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +"@bnb-chain/canonical-bridge-sdk": patch +--- + +Add tips for switching network in tronLink diff --git a/.release/.changeset/tiny-lizards-cross.md b/.release/.changeset/tiny-lizards-cross.md new file mode 100644 index 00000000..0c963e02 --- /dev/null +++ b/.release/.changeset/tiny-lizards-cross.md @@ -0,0 +1,6 @@ +--- +"@bnb-chain/canonical-bridge-widget": minor +"@bnb-chain/canonical-bridge-sdk": minor +--- + +Support tron diff --git a/apps/canonical-bridge-ui/core/components/ThemeProvider/index.tsx b/apps/canonical-bridge-ui/core/components/ThemeProvider/index.tsx index a00eb1ad..5e900bfb 100644 --- a/apps/canonical-bridge-ui/core/components/ThemeProvider/index.tsx +++ b/apps/canonical-bridge-ui/core/components/ThemeProvider/index.tsx @@ -11,6 +11,10 @@ const colorModeManager = createLocalStorageManager(`${env.APP_NAME}-color-mode`) export const ThemeProvider = ({ children }: ThemeProviderProps) => { const customTheme = { ...theme, + breakpoints: { + ...theme.breakpoints, + lg: '1080px', + }, config: { ...theme.config, initialColorMode: 'dark', @@ -20,7 +24,6 @@ export const ThemeProvider = ({ children }: ThemeProviderProps) => { global: ({ colorMode }: { colorMode: ColorMode }) => ({ body: { bg: theme.colors[colorMode].background[3], - minWidth: '998px', }, }), }, diff --git a/apps/canonical-bridge-ui/core/locales/en.ts b/apps/canonical-bridge-ui/core/locales/en.ts index 125000c6..d5d4b72d 100644 --- a/apps/canonical-bridge-ui/core/locales/en.ts +++ b/apps/canonical-bridge-ui/core/locales/en.ts @@ -13,8 +13,10 @@ export const en = { 'to.section.title': 'To', 'to.section.estimated-amount': 'Est. Amount Receive', 'to.section.account.label': 'Destination Address', - 'to.section.account.placeholder': 'Enter Destination Address', + 'to.section.account.placeholder': 'Enter {network} Address', 'to.section.account.invalid': 'Invalid address.', + 'to.section.confirm.text': + 'I confirmed the address is correct and not an exchange or contract address. Any tokens sent to an incorrect address will be unrecoverable.', 'you.send.title': 'You Send', 'you.receive.title': 'You Receive', @@ -36,6 +38,7 @@ export const en = { 'route.option.deBridge.title': 'deBridge', 'route.option.stargate.title': 'Stargate', 'route.option.layerZero.title': 'LayerZero', + 'route.option.meson.title': 'Meson', 'route.option.tag.best-time': 'Fastest', 'route.option.tag.highest-amount': 'Best Return', 'route.option.info.estimated-time': 'Est. Time:', @@ -44,8 +47,14 @@ export const en = { 'route.option.info.debridge-fee': 'deBridge Fee:', 'route.option.info.market-maker-fee': 'Market Maker Gas Costs:', 'route.option.info.base-fee': 'Base Fee:', + 'route.option.info.lp-fee': 'Liquidity Providers:', + 'route.option.info.service-fee': 'Service Fee:', 'route.option.info.protocol-fee': 'Protocol Fee:', + 'route.error.amount.max': 'Your send amount must be less than {max}', + 'route.error.amount.min': 'Your send amount must be greater than {min}', + 'route.error.amount.digits': 'The send amount must be less than 6 digits', + 'transfer.button.confirm': 'Send', 'transfer.button.approve': 'Approve', 'transfer.button.switch-network': 'Switch Network', @@ -87,8 +96,15 @@ export const en = { 'select-modal.destination.incompatible.tooltip': 'The token you’ve selected is incompatible with this network. Please select another token.', + 'wallet.button.connect-wallet': 'Connect Wallet', 'wallet.network.wrong-network': 'Wrong network', 'wallet.error.switch-network': 'An error occurred when attempting to switch the network. Please select another network or try again.', 'wallet.popover.disconnect': 'Disconnect', + 'wallet.preventing-modal.title': 'Oops!', + 'wallet.preventing-modal.desc': + 'Opening an app is not allowed on this site. Please go to BNB Chain Bridge site on your mobile browser to continue.', + 'wallet.switching-modal.title': 'Switch Network in Wallet', + 'wallet.switching-modal.desc': + 'Please go to the settings page and switch the network to TRON Mainnet', }; diff --git a/apps/canonical-bridge-ui/data-testnet/index.ts b/apps/canonical-bridge-ui/data-testnet/index.ts new file mode 100644 index 00000000..b1a69922 --- /dev/null +++ b/apps/canonical-bridge-ui/data-testnet/index.ts @@ -0,0 +1,40 @@ +import { useEffect, useState } from 'react'; +import { ITransferConfig } from '@bnb-chain/canonical-bridge-widget'; + +import mesonConfigTestnet from '@/data-testnet/meson/config.json'; + +export function useTestnetTransferConfig() { + const [transferConfig, setTransferConfig] = useState(); + + useEffect(() => { + const initConfig = async () => { + const transferConfig: ITransferConfig = { + defaultSelectedInfo: { + fromChainId: 97, + toChainId: 3448148188, + tokenSymbol: 'USDT', // USDT + amount: '', + }, + order: { + chains: [], + tokens: ['USDC', 'USDT'], + }, + displayTokenSymbols: {}, + meson: { + config: mesonConfigTestnet.result as any, + exclude: { + chains: [], + tokens: {}, + }, + bridgedTokenGroups: [], + }, + }; + + setTransferConfig(transferConfig); + }; + + initConfig(); + }, []); + + return transferConfig; +} diff --git a/apps/canonical-bridge-ui/data-testnet/meson/config.json b/apps/canonical-bridge-ui/data-testnet/meson/config.json new file mode 100644 index 00000000..ab7afe13 --- /dev/null +++ b/apps/canonical-bridge-ui/data-testnet/meson/config.json @@ -0,0 +1,118 @@ +{ + "result": [ + { + "id": "arb-sepolia", + "name": "Arbitrum Sepolia", + "chainId": "0x66eee", + "address": "0x0d12d15b26a32e72A3330B2ac9016A22b1410CB6", + "tokens": [ + { + "id": "usdc", + "addr": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d", + "min": "0.5", + "max": "20000", + "decimals": 6 + }, + { + "id": "eth", + "decimals": 18, + "min": "0.001", + "max": "2" + } + ] + }, + { + "id": "sepolia", + "name": "Sepolia Testnet", + "chainId": "0xaa36a7", + "address": "0x0d12d15b26a32e72A3330B2ac9016A22b1410CB6", + "tokens": [ + { + "id": "usdc", + "addr": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", + "decimals": 6, + "min": "0.5", + "max": "20000" + }, + { + "id": "usdt", + "addr": "0xd53e9530107a8d8856099d7d80126478d48e06dA", + "decimals": 6, + "min": "0.5", + "max": "20000" + }, + { + "id": "eth", + "decimals": 18, + "min": "0.001", + "max": "2" + } + ] + }, + { + "id": "bnb-testnet", + "name": "BNB Testnet", + "chainId": "0x61", + "address": "0x0d12d15b26a32e72A3330B2ac9016A22b1410CB6", + "tokens": [ + { + "id": "usdc", + "addr": "0x64544969ed7EBf5f083679233325356EbE738930", + "decimals": 18, + "min": "0.5", + "max": "20000" + }, + { + "id": "usdt", + "addr": "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd", + "decimals": 18, + "min": "0.5", + "max": "20000" + } + ] + }, + { + "id": "opt-sepolia", + "name": "OP Sepolia", + "chainId": "0xaa37dc", + "address": "0x0d12d15b26a32e72A3330B2ac9016A22b1410CB6", + "tokens": [ + { + "id": "usdc", + "addr": "0x5fd84259d66Cd46123540766Be93DFE6D43130D7", + "decimals": 6, + "min": "0.5", + "max": "20000" + }, + { + "id": "eth", + "decimals": 18, + "min": "0.001", + "max": "2" + } + ] + }, + { + "id": "tron-testnet", + "name": "Tron Nile Testnet", + "chainId": "3448148188", + "address": "TAp1rBTjC4tefEMR54vT2NDwLEhDL7E7Jo", + "tokens": [ + { + "id": "usdc", + "addr": "TNavP4dSwhGssWjX4gR8NvrMsgAQvBWoyY", + "decimals": 6, + "min": "0.5", + "max": "20000" + }, + { + "id": "usdt", + "addr": "THkCEyw2uaJYPfxb2BNizGuiosCkyAsbWW", + "decimals": 6, + "min": "0.5", + "max": "20000" + } + ] + } + ] +} diff --git a/apps/canonical-bridge-ui/data-testnet/testnetChains.ts b/apps/canonical-bridge-ui/data-testnet/testnetChains.ts new file mode 100644 index 00000000..c7e15cca --- /dev/null +++ b/apps/canonical-bridge-ui/data-testnet/testnetChains.ts @@ -0,0 +1,90 @@ +import { IChainConfig } from '@bnb-chain/canonical-bridge-widget'; + +export const testnetChains: IChainConfig[] = [ + { + id: 97, + name: 'BSC Testnet', + nativeCurrency: { + name: 'BNB', + symbol: 'BNB', + decimals: 18, + }, + rpcUrl: 'https://bsc-testnet.bnbchain.org', + explorer: { + name: 'BSC Testnet', + url: 'https://testnet.bscscan.com', + }, + }, + { + id: 1001, + name: 'Klaytn Testnet Baobab', + nativeCurrency: { + name: 'KLAY', + symbol: 'KLAY', + decimals: 18, + }, + rpcUrl: 'https://public-en-baobab.klaytn.net', + explorer: { + name: 'Klaytn Scope', + url: 'https://baobab.klaytnscope.com', + }, + }, + { + id: 11155111, + name: 'Sepolia', + nativeCurrency: { + name: 'Ether', + symbol: 'ETH', + decimals: 18, + }, + rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com', + explorer: { + name: 'Sepolia Scan', + url: 'https://sepolia.etherscan.io', + }, + }, + { + id: 421614, + name: 'Arbitrum Sepolia Testnet', + nativeCurrency: { + name: 'Ether', + symbol: 'ETH', + decimals: 18, + }, + rpcUrl: 'https://sepolia-rollup.arbitrum.io/rpc', + explorer: { + name: 'Sepolia ArbiScan', + url: 'https://sepolia.arbiscan.io/', + }, + }, + { + id: 11155420, + name: 'OP Sepolia', + nativeCurrency: { + name: 'ETH', + symbol: 'ETH', + decimals: 18, + }, + rpcUrl: 'https://sepolia.optimism.io', + explorer: { + name: 'OP Sepolia Scan', + url: 'https://sepolia-optimistic.etherscan.io', + }, + }, + { + id: 3448148188, + name: 'Tron Nile Testnet', + nativeCurrency: { + name: 'TRX', + symbol: 'TRX', + decimals: 6, + }, + rpcUrl: 'https://api.nileex.io', + explorer: { + name: 'Tron Nile Scan', + url: 'https://nile.tronscan.org/', + tokenUrlPattern: 'https://nile.tronscan.org/#/token20/{0}', + }, + chainType: 'tron', + }, +]; diff --git a/apps/canonical-bridge-ui/data/chains.ts b/apps/canonical-bridge-ui/data/chains.ts index d70ce658..03efe82a 100644 --- a/apps/canonical-bridge-ui/data/chains.ts +++ b/apps/canonical-bridge-ui/data/chains.ts @@ -818,4 +818,20 @@ export const chains: IChainConfig[] = [ url: 'https://explorer.harmony.one', }, }, + { + id: 728126428, + name: 'Tron', + nativeCurrency: { + name: 'TRX', + symbol: 'TRX', + decimals: 6, + }, + rpcUrl: 'https://api.trongrid.io', + explorer: { + name: 'Tron Scan', + url: 'https://tronscan.io/', + tokenUrlPattern: 'https://tronscan.io/#/token20/{0}', + }, + chainType: 'tron', + }, ]; diff --git a/apps/canonical-bridge-ui/data/index.ts b/apps/canonical-bridge-ui/data/index.ts index 6cd8767f..26ed63ef 100644 --- a/apps/canonical-bridge-ui/data/index.ts +++ b/apps/canonical-bridge-ui/data/index.ts @@ -9,6 +9,7 @@ import axios from 'axios'; import { env } from '@/core/env'; import stargateConfig from '@/data/stargate/config.json'; import layerZeroConfig from '@/data/layerZero/config.json'; +import mesonConfig from '@/data/meson/config.json'; export function useTransferConfig() { const [transferConfig, setTransferConfig] = useState(); @@ -31,8 +32,7 @@ export function useTransferConfig() { amount: '', }, order: { - // [Ethereum, Arbitrum, Base, Tron, Solana, Polygon, Avalanche, Blast, Linea, Optimism] - chains: [56, 204, 1, 42161, 8453, 1000, 7565164, 137, 43114, 81457, 59144, 10], + chains: [56, 204, 1, 42161, 8453, 728126428, 7565164, 137, 43114, 81457, 59144, 10], tokens: [ 'USDC', 'USDT', @@ -165,6 +165,14 @@ export function useTransferConfig() { }, bridgedTokenGroups: [], }, + meson: { + config: mesonConfig.result as any, + exclude: { + chains: [], + tokens: {}, + }, + bridgedTokenGroups: [], + }, }; setTransferConfig(transferConfig); diff --git a/apps/canonical-bridge-ui/data/meson/config.json b/apps/canonical-bridge-ui/data/meson/config.json new file mode 100644 index 00000000..746efda6 --- /dev/null +++ b/apps/canonical-bridge-ui/data/meson/config.json @@ -0,0 +1,35 @@ +{ + "result": [ + { + "id": "bnb", + "name": "BNB Smart Chain", + "chainId": "0x38", + "address": "0x25aB3Efd52e6470681CE037cD546Dc60726948D3", + "tokens": [ + { + "id": "usdt", + "addr": "0x55d398326f99059ff775485246999027b3197955", + "decimals": 18, + "min": "1.0", + "max": "20000" + } + ] + }, + + { + "id": "tron", + "name": "Tron", + "chainId": "728126428", + "address": "TKWqpzNucNNBMpfaE47F8CLhA8vzfNndH4", + "tokens": [ + { + "id": "usdt", + "addr": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", + "decimals": 6, + "min": "6.5", + "max": "20000" + } + ] + } + ] +} diff --git a/apps/canonical-bridge-ui/package.json b/apps/canonical-bridge-ui/package.json index 7bbdb91e..5774868e 100644 --- a/apps/canonical-bridge-ui/package.json +++ b/apps/canonical-bridge-ui/package.json @@ -1,6 +1,6 @@ { "name": "canonical-bridge-ui", - "version": "0.0.1", + "version": "0.1.0", "private": true, "scripts": { "dev": "next dev -p 3001", @@ -15,6 +15,7 @@ "@emotion/css": "~11.13.0", "@emotion/react": "~11.13.3", "@emotion/styled": "~11.13.0", + "@node-real/walletkit": "2.4.0-alpha.5", "@tanstack/react-query": "~5.50.1", "axios": "~1.6.8", "next": "~14.1.1", @@ -22,6 +23,7 @@ "polished": "~4.3.1", "react": "~18.3.1", "react-dom": "~18.3.1", + "supports-color": "~9.4.0", "viem": "~2.21.14", "wagmi": "^2" }, @@ -39,10 +41,12 @@ "@types/node": "^20", "@types/react": "~18.3.8", "@types/react-dom": "~18.3.0", + "encoding": "~0.1.13", "eslint": "^8.8.0", "eslint-config-next": "14.2.3", "lint-staged": "~13.0.3", "prettier": "~2.7.1", + "supports-color": "8.1.1", "typescript": "5.5.4" }, "lint-staged": { diff --git a/apps/canonical-bridge-ui/pages/_app.tsx b/apps/canonical-bridge-ui/pages/_app.tsx index 6c5bce8a..b27520a2 100644 --- a/apps/canonical-bridge-ui/pages/_app.tsx +++ b/apps/canonical-bridge-ui/pages/_app.tsx @@ -1,4 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import Head from 'next/head'; import { AppProps } from 'next/app'; import { ThemeProvider } from '@/core/components/ThemeProvider'; @@ -15,10 +16,15 @@ const queryClient = new QueryClient({ export default function App({ Component, ...restProps }: AppProps) { return ( - - - - - + <> + + + + + + + + + ); } diff --git a/apps/canonical-bridge-ui/pages/_document.tsx b/apps/canonical-bridge-ui/pages/_document.tsx index 71a51793..5014337d 100644 --- a/apps/canonical-bridge-ui/pages/_document.tsx +++ b/apps/canonical-bridge-ui/pages/_document.tsx @@ -10,6 +10,25 @@ export default class Document extends NextDocument { + +