From cdc4810c694820c933eb26c6b3142895dd2e92c0 Mon Sep 17 00:00:00 2001 From: wenty22 Date: Thu, 14 Nov 2024 15:18:32 +0800 Subject: [PATCH 1/6] feat: Hide SOL native token address --- .release/.changeset/pre.json | 1 + .release/.changeset/stale-files-kick.md | 6 ++++++ packages/canonical-bridge-sdk/CHANGELOG.md | 6 ++++++ packages/canonical-bridge-sdk/package.json | 2 +- packages/canonical-bridge-widget/CHANGELOG.md | 6 ++++++ packages/canonical-bridge-widget/package.json | 2 +- .../canonical-bridge-widget/src/core/utils/address.ts | 7 ++++++- .../components/SelectModal/ChooseTokenModal.tsx | 2 +- .../components/SelectButton/TokenSelectButton.tsx | 6 +++++- .../components/TransferOverview/RouteInfo/RouteTitle.tsx | 1 + .../TransferOverview/RouteInfo/TokenInfoTooltip.tsx | 8 +++++++- .../src/modules/wallet/WalletProvider.tsx | 3 +-- 12 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 .release/.changeset/stale-files-kick.md diff --git a/.release/.changeset/pre.json b/.release/.changeset/pre.json index f97cf9b0..37aefe77 100644 --- a/.release/.changeset/pre.json +++ b/.release/.changeset/pre.json @@ -8,6 +8,7 @@ "changesets": [ "honest-jeans-greet", "mean-falcons-yell", + "stale-files-kick", "tasty-gifts-brush" ] } diff --git a/.release/.changeset/stale-files-kick.md b/.release/.changeset/stale-files-kick.md new file mode 100644 index 00000000..3ef14dad --- /dev/null +++ b/.release/.changeset/stale-files-kick.md @@ -0,0 +1,6 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +"@bnb-chain/canonical-bridge-sdk": patch +--- + +Fix phantom wallet deelink issue on mobile diff --git a/packages/canonical-bridge-sdk/CHANGELOG.md b/packages/canonical-bridge-sdk/CHANGELOG.md index 756c1256..db437ac6 100644 --- a/packages/canonical-bridge-sdk/CHANGELOG.md +++ b/packages/canonical-bridge-sdk/CHANGELOG.md @@ -1,5 +1,11 @@ # @bnb-chain/canonical-bridge-sdk +## 0.4.0-alpha.1 + +### Patch Changes + +- Fix phantom wallet deelink issue on mobile + ## 0.4.0-alpha.0 ### Minor Changes diff --git a/packages/canonical-bridge-sdk/package.json b/packages/canonical-bridge-sdk/package.json index e17d92c3..9bc3edef 100644 --- a/packages/canonical-bridge-sdk/package.json +++ b/packages/canonical-bridge-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-sdk", - "version": "0.4.0-alpha.0", + "version": "0.4.0-alpha.1", "description": "canonical bridge sdk", "author": "bnb-chain", "private": false, diff --git a/packages/canonical-bridge-widget/CHANGELOG.md b/packages/canonical-bridge-widget/CHANGELOG.md index 1c735917..5cc0c697 100644 --- a/packages/canonical-bridge-widget/CHANGELOG.md +++ b/packages/canonical-bridge-widget/CHANGELOG.md @@ -1,5 +1,11 @@ # @bnb-chain/canonical-bridge-widget +## 0.5.0-alpha.3 + +### Patch Changes + +- Fix phantom wallet deelink issue on mobile + ## 0.5.0-alpha.2 ### Patch Changes diff --git a/packages/canonical-bridge-widget/package.json b/packages/canonical-bridge-widget/package.json index 68565c26..44d65b39 100644 --- a/packages/canonical-bridge-widget/package.json +++ b/packages/canonical-bridge-widget/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-widget", - "version": "0.5.0-alpha.2", + "version": "0.5.0-alpha.3", "description": "canonical bridge widget", "author": "bnb-chain", "private": false, diff --git a/packages/canonical-bridge-widget/src/core/utils/address.ts b/packages/canonical-bridge-widget/src/core/utils/address.ts index a1812af4..89bf1b60 100644 --- a/packages/canonical-bridge-widget/src/core/utils/address.ts +++ b/packages/canonical-bridge-widget/src/core/utils/address.ts @@ -1,4 +1,5 @@ import { truncateHash } from '@/core/utils/string'; +import { ChainType } from '@/modules/aggregator'; export function formatAppAddress(params: { address?: string; @@ -49,7 +50,11 @@ export function isEvmAddress(address?: string) { return !!address && /^0x[a-f0-9]{40}$/i.test(address); } -export function isNativeToken(tokenAddress: string) { +export function isNativeToken(tokenAddress: string, chainType: ChainType = 'evm') { + if (chainType === 'solana') { + return tokenAddress === '11111111111111111111111111111111'; + } + return tokenAddress === '0x0000000000000000000000000000000000000000'; } diff --git a/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/ChooseTokenModal.tsx b/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/ChooseTokenModal.tsx index 485ddb69..52022532 100644 --- a/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/ChooseTokenModal.tsx +++ b/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/ChooseTokenModal.tsx @@ -86,7 +86,7 @@ export function ChooseTokenModal(props: ChooseTokenModalProps) { const isDisabled = !isChainOrTokenCompatible(item); const isActive = isSameAddress(item.address, selectedToken?.address) && isChainOrTokenCompatible(item); - const isNative = isNativeToken(item.address); + const isNative = isNativeToken(item.address, fromChain?.chainType); return ( - + {toTokenInfo && ( { const theme = useTheme(); - const nativeToken = useMemo(() => isNativeToken(tokenAddress), [tokenAddress]); + const nativeToken = useMemo( + () => isNativeToken(tokenAddress, chainType), + [chainType, tokenAddress], + ); return ( diff --git a/packages/canonical-bridge-widget/src/modules/wallet/WalletProvider.tsx b/packages/canonical-bridge-widget/src/modules/wallet/WalletProvider.tsx index 19c19f56..b81c2047 100644 --- a/packages/canonical-bridge-widget/src/modules/wallet/WalletProvider.tsx +++ b/packages/canonical-bridge-widget/src/modules/wallet/WalletProvider.tsx @@ -18,7 +18,6 @@ import * as allChains from 'viem/chains'; import { defaultTronConfig, tronLink } from '@node-real/walletkit/tron'; import { defaultSolanaConfig, - trustWallet as solanaTrustWallet, phantomWallet as solanaPhantomWallet, } from '@node-real/walletkit/solana'; import React from 'react'; @@ -53,7 +52,7 @@ export function WalletProvider(props: WalletProviderProps) { walletConnect(), ]; const tronWallets = [tronLink()]; - const solanaWallets = [solanaTrustWallet(), solanaPhantomWallet()]; + const solanaWallets = [solanaPhantomWallet()]; const tron = chainConfigs.find((e) => e.chainType === 'tron'); const solana = chainConfigs.find((e) => e.chainType === 'solana'); From bbfec693410d41d11a3c5e493448047720669e75 Mon Sep 17 00:00:00 2001 From: wenty22 Date: Thu, 14 Nov 2024 17:21:36 +0800 Subject: [PATCH 2/6] feat: Support solana --- .release/.changeset/hip-ladybugs-attend.md | 6 ++++++ .release/.changeset/pre.json | 1 + packages/canonical-bridge-sdk/CHANGELOG.md | 6 ++++++ packages/canonical-bridge-sdk/package.json | 2 +- packages/canonical-bridge-widget/CHANGELOG.md | 6 ++++++ packages/canonical-bridge-widget/package.json | 2 +- .../src/core/constants/index.ts | 2 ++ .../modules/transfer/hooks/useInputValidation.ts | 16 ++++++++++++++-- 8 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .release/.changeset/hip-ladybugs-attend.md diff --git a/.release/.changeset/hip-ladybugs-attend.md b/.release/.changeset/hip-ladybugs-attend.md new file mode 100644 index 00000000..c5d12dc5 --- /dev/null +++ b/.release/.changeset/hip-ladybugs-attend.md @@ -0,0 +1,6 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +"@bnb-chain/canonical-bridge-sdk": patch +--- + +Solana requires wallet have at least 0.05SOL to enabled a tx. diff --git a/.release/.changeset/pre.json b/.release/.changeset/pre.json index 37aefe77..b65c248f 100644 --- a/.release/.changeset/pre.json +++ b/.release/.changeset/pre.json @@ -6,6 +6,7 @@ "@bnb-chain/canonical-bridge-widget": "0.4.0" }, "changesets": [ + "hip-ladybugs-attend", "honest-jeans-greet", "mean-falcons-yell", "stale-files-kick", diff --git a/packages/canonical-bridge-sdk/CHANGELOG.md b/packages/canonical-bridge-sdk/CHANGELOG.md index db437ac6..d2737344 100644 --- a/packages/canonical-bridge-sdk/CHANGELOG.md +++ b/packages/canonical-bridge-sdk/CHANGELOG.md @@ -1,5 +1,11 @@ # @bnb-chain/canonical-bridge-sdk +## 0.4.0-alpha.2 + +### Patch Changes + +- Solana requires wallet have at least 0.05SOL to enabled a tx. + ## 0.4.0-alpha.1 ### Patch Changes diff --git a/packages/canonical-bridge-sdk/package.json b/packages/canonical-bridge-sdk/package.json index 9bc3edef..ad12d373 100644 --- a/packages/canonical-bridge-sdk/package.json +++ b/packages/canonical-bridge-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-sdk", - "version": "0.4.0-alpha.1", + "version": "0.4.0-alpha.2", "description": "canonical bridge sdk", "author": "bnb-chain", "private": false, diff --git a/packages/canonical-bridge-widget/CHANGELOG.md b/packages/canonical-bridge-widget/CHANGELOG.md index 5cc0c697..3fdf5fe1 100644 --- a/packages/canonical-bridge-widget/CHANGELOG.md +++ b/packages/canonical-bridge-widget/CHANGELOG.md @@ -1,5 +1,11 @@ # @bnb-chain/canonical-bridge-widget +## 0.5.0-alpha.4 + +### Patch Changes + +- Solana requires wallet have at least 0.05SOL to enabled a tx. + ## 0.5.0-alpha.3 ### Patch Changes diff --git a/packages/canonical-bridge-widget/package.json b/packages/canonical-bridge-widget/package.json index 44d65b39..1f7ff2cf 100644 --- a/packages/canonical-bridge-widget/package.json +++ b/packages/canonical-bridge-widget/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-widget", - "version": "0.5.0-alpha.3", + "version": "0.5.0-alpha.4", "description": "canonical bridge widget", "author": "bnb-chain", "private": false, diff --git a/packages/canonical-bridge-widget/src/core/constants/index.ts b/packages/canonical-bridge-widget/src/core/constants/index.ts index 8187a38b..e5189218 100644 --- a/packages/canonical-bridge-widget/src/core/constants/index.ts +++ b/packages/canonical-bridge-widget/src/core/constants/index.ts @@ -40,3 +40,5 @@ export const TIME = { export const MIN_FEE = 0.0001; export const REFETCH_INTERVAL = 8 * 1000; + +export const MIN_SOL_TO_ENABLED_TX = 0.05; diff --git a/packages/canonical-bridge-widget/src/modules/transfer/hooks/useInputValidation.ts b/packages/canonical-bridge-widget/src/modules/transfer/hooks/useInputValidation.ts index 84c47353..0d07a6eb 100644 --- a/packages/canonical-bridge-widget/src/modules/transfer/hooks/useInputValidation.ts +++ b/packages/canonical-bridge-widget/src/modules/transfer/hooks/useInputValidation.ts @@ -5,10 +5,15 @@ import { useCallback } from 'react'; import { formatNumber } from '@/core/utils/number'; import { useAppSelector } from '@/modules/store/StoreProvider'; import { useCurrentWallet } from '@/modules/wallet/CurrentWalletProvider'; +import { useSolanaBalance } from '@/modules/wallet/hooks/useSolanaBalance'; +import { MIN_SOL_TO_ENABLED_TX } from '@/core/constants'; export const useInputValidation = () => { const { chain } = useCurrentWallet(); + const { data } = useSolanaBalance(); + const solBalance = Number(data?.formatted); + const fromChain = useAppSelector((state) => state.transfer.fromChain); const validateInput = useCallback( ({ @@ -49,7 +54,14 @@ export const useInputValidation = () => { } if (!!balance) { - return { text: `${formatNumber(balance)}`, isError: false }; + if (fromChain?.chainType === 'solana' && solBalance < MIN_SOL_TO_ENABLED_TX) { + return { + text: `You should have at least ${MIN_SOL_TO_ENABLED_TX} SOL in your balance to perform this trade.`, + isError: true, + }; + } else { + return { text: `${formatNumber(balance)}`, isError: false }; + } } else { if (fromChain?.id === chain?.id && chain) { return { isError: true, text: 'You have insufficient balance' }; @@ -60,7 +72,7 @@ export const useInputValidation = () => { console.log(e); } }, - [chain, fromChain?.id], + [chain, fromChain?.chainType, fromChain?.id, solBalance], ); return { From 098d5615f64e5ac5f776ac3cec929f780c4517df Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 14 Nov 2024 08:56:15 +0000 Subject: [PATCH 3/6] chore: Update versions --- .release/.changeset/honest-jeans-greet.md | 5 ----- .release/.changeset/mean-falcons-yell.md | 5 ----- .release/.changeset/tasty-gifts-brush.md | 6 ------ packages/canonical-bridge-sdk/CHANGELOG.md | 8 ++++++++ packages/canonical-bridge-sdk/package.json | 4 ++++ packages/canonical-bridge-widget/CHANGELOG.md | 13 +++++++++++++ packages/canonical-bridge-widget/package.json | 4 ++++ 7 files changed, 29 insertions(+), 16 deletions(-) delete mode 100644 .release/.changeset/honest-jeans-greet.md delete mode 100644 .release/.changeset/mean-falcons-yell.md delete mode 100644 .release/.changeset/tasty-gifts-brush.md diff --git a/.release/.changeset/honest-jeans-greet.md b/.release/.changeset/honest-jeans-greet.md deleted file mode 100644 index 8d7def6c..00000000 --- a/.release/.changeset/honest-jeans-greet.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@bnb-chain/canonical-bridge-widget": patch ---- - -UI adjustment diff --git a/.release/.changeset/mean-falcons-yell.md b/.release/.changeset/mean-falcons-yell.md deleted file mode 100644 index 8d7def6c..00000000 --- a/.release/.changeset/mean-falcons-yell.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@bnb-chain/canonical-bridge-widget": patch ---- - -UI adjustment diff --git a/.release/.changeset/tasty-gifts-brush.md b/.release/.changeset/tasty-gifts-brush.md deleted file mode 100644 index 9a986623..00000000 --- a/.release/.changeset/tasty-gifts-brush.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@bnb-chain/canonical-bridge-widget": minor -"@bnb-chain/canonical-bridge-sdk": minor ---- - -Support solana diff --git a/packages/canonical-bridge-sdk/CHANGELOG.md b/packages/canonical-bridge-sdk/CHANGELOG.md index d2737344..6d089d6e 100644 --- a/packages/canonical-bridge-sdk/CHANGELOG.md +++ b/packages/canonical-bridge-sdk/CHANGELOG.md @@ -1,5 +1,6 @@ # @bnb-chain/canonical-bridge-sdk +<<<<<<< HEAD ## 0.4.0-alpha.2 ### Patch Changes @@ -11,6 +12,13 @@ ### Patch Changes - Fix phantom wallet deelink issue on mobile +======= +## 0.4.0 + +### Minor Changes + +- a6db440: Support solana +>>>>>>> 634d683a (chore: Update versions) ## 0.4.0-alpha.0 diff --git a/packages/canonical-bridge-sdk/package.json b/packages/canonical-bridge-sdk/package.json index ad12d373..5e30d9d1 100644 --- a/packages/canonical-bridge-sdk/package.json +++ b/packages/canonical-bridge-sdk/package.json @@ -1,6 +1,10 @@ { "name": "@bnb-chain/canonical-bridge-sdk", +<<<<<<< HEAD "version": "0.4.0-alpha.2", +======= + "version": "0.4.0", +>>>>>>> 634d683a (chore: Update versions) "description": "canonical bridge sdk", "author": "bnb-chain", "private": false, diff --git a/packages/canonical-bridge-widget/CHANGELOG.md b/packages/canonical-bridge-widget/CHANGELOG.md index 3fdf5fe1..4a8c96ff 100644 --- a/packages/canonical-bridge-widget/CHANGELOG.md +++ b/packages/canonical-bridge-widget/CHANGELOG.md @@ -1,5 +1,6 @@ # @bnb-chain/canonical-bridge-widget +<<<<<<< HEAD ## 0.5.0-alpha.4 ### Patch Changes @@ -11,6 +12,18 @@ ### Patch Changes - Fix phantom wallet deelink issue on mobile +======= +## 0.5.0 + +### Minor Changes + +- a6db440: Support solana + +### Patch Changes + +- e31ab8f: UI adjustment +- 6ab36a6: UI adjustment +>>>>>>> 634d683a (chore: Update versions) ## 0.5.0-alpha.2 diff --git a/packages/canonical-bridge-widget/package.json b/packages/canonical-bridge-widget/package.json index 1f7ff2cf..37fb9d2b 100644 --- a/packages/canonical-bridge-widget/package.json +++ b/packages/canonical-bridge-widget/package.json @@ -1,6 +1,10 @@ { "name": "@bnb-chain/canonical-bridge-widget", +<<<<<<< HEAD "version": "0.5.0-alpha.4", +======= + "version": "0.5.0", +>>>>>>> 634d683a (chore: Update versions) "description": "canonical bridge widget", "author": "bnb-chain", "private": false, From c2f5d2095e810b56b24d9f1a65fafd948a3c29b4 Mon Sep 17 00:00:00 2001 From: wenty22 Date: Thu, 14 Nov 2024 17:26:08 +0800 Subject: [PATCH 4/6] feat: Support solana --- packages/canonical-bridge-sdk/package.json | 4 ---- packages/canonical-bridge-widget/package.json | 4 ---- 2 files changed, 8 deletions(-) diff --git a/packages/canonical-bridge-sdk/package.json b/packages/canonical-bridge-sdk/package.json index 5e30d9d1..221b0534 100644 --- a/packages/canonical-bridge-sdk/package.json +++ b/packages/canonical-bridge-sdk/package.json @@ -1,10 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-sdk", -<<<<<<< HEAD - "version": "0.4.0-alpha.2", -======= "version": "0.4.0", ->>>>>>> 634d683a (chore: Update versions) "description": "canonical bridge sdk", "author": "bnb-chain", "private": false, diff --git a/packages/canonical-bridge-widget/package.json b/packages/canonical-bridge-widget/package.json index 37fb9d2b..2478e32c 100644 --- a/packages/canonical-bridge-widget/package.json +++ b/packages/canonical-bridge-widget/package.json @@ -1,10 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-widget", -<<<<<<< HEAD - "version": "0.5.0-alpha.4", -======= "version": "0.5.0", ->>>>>>> 634d683a (chore: Update versions) "description": "canonical bridge widget", "author": "bnb-chain", "private": false, From 37ee49de1e9befb89ed26c2a3f71cc49d6659c3b Mon Sep 17 00:00:00 2001 From: wenty22 Date: Thu, 14 Nov 2024 17:29:19 +0800 Subject: [PATCH 5/6] docs: Clear code --- packages/canonical-bridge-widget/CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/canonical-bridge-widget/CHANGELOG.md b/packages/canonical-bridge-widget/CHANGELOG.md index 8601fcd2..1f5a5eaa 100644 --- a/packages/canonical-bridge-widget/CHANGELOG.md +++ b/packages/canonical-bridge-widget/CHANGELOG.md @@ -21,10 +21,6 @@ ### Patch Changes - e31ab8f: UI adjustment -- 6ab36a6: UI adjustment <<<<<<< HEAD - > > > > > > > # 634d683a (chore: Update versions) - > > > > > > > - > > > > > > > main ## 0.5.0-alpha.2 From 6a2623b070c098a945b0aaa312563e94b9b97877 Mon Sep 17 00:00:00 2001 From: wenty22 Date: Thu, 14 Nov 2024 17:40:44 +0800 Subject: [PATCH 6/6] fix: Add tips for solana transfer --- .release/.changeset/stale-files-kick.md | 6 ------ .../{hip-ladybugs-attend.md => tough-toes-relax.md} | 0 .../src/modules/wallet/hooks/useSolanaAccount.ts | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 .release/.changeset/stale-files-kick.md rename .release/.changeset/{hip-ladybugs-attend.md => tough-toes-relax.md} (100%) diff --git a/.release/.changeset/stale-files-kick.md b/.release/.changeset/stale-files-kick.md deleted file mode 100644 index 3ef14dad..00000000 --- a/.release/.changeset/stale-files-kick.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@bnb-chain/canonical-bridge-widget": patch -"@bnb-chain/canonical-bridge-sdk": patch ---- - -Fix phantom wallet deelink issue on mobile diff --git a/.release/.changeset/hip-ladybugs-attend.md b/.release/.changeset/tough-toes-relax.md similarity index 100% rename from .release/.changeset/hip-ladybugs-attend.md rename to .release/.changeset/tough-toes-relax.md diff --git a/packages/canonical-bridge-widget/src/modules/wallet/hooks/useSolanaAccount.ts b/packages/canonical-bridge-widget/src/modules/wallet/hooks/useSolanaAccount.ts index 8d2aa4c3..23484709 100644 --- a/packages/canonical-bridge-widget/src/modules/wallet/hooks/useSolanaAccount.ts +++ b/packages/canonical-bridge-widget/src/modules/wallet/hooks/useSolanaAccount.ts @@ -11,6 +11,6 @@ export function useSolanaAccount() { return { address: publicKey?.toBase58(), isConnected: connected, - chainId: solana?.id, + chainId: connected ? solana?.id : undefined, }; }