diff --git a/.github/workflows/xtoken-home-dev.yml b/.github/workflows/xtoken-home-dev.yml index bc85745..76a8cb3 100644 --- a/.github/workflows/xtoken-home-dev.yml +++ b/.github/workflows/xtoken-home-dev.yml @@ -29,6 +29,4 @@ jobs: alias_domain: "xtoken-home-dev" enable_cache: true enable_notify_comment: true - enable_notify_slack: true - slack_channel: helix-ui slack_webhook: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} diff --git a/.github/workflows/xtoken-home-prd.yml b/.github/workflows/xtoken-home-prd.yml index a7c258f..14c66f3 100644 --- a/.github/workflows/xtoken-home-prd.yml +++ b/.github/workflows/xtoken-home-prd.yml @@ -34,5 +34,5 @@ jobs: enable_cache: true enable_notify_comment: true enable_notify_slack: true - slack_channel: helix-ui + slack_channel: helixbox-ui slack_webhook: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} diff --git a/.github/workflows/xtoken-ui-dev.yml b/.github/workflows/xtoken-ui-dev.yml index 61c0e5a..4255a52 100644 --- a/.github/workflows/xtoken-ui-dev.yml +++ b/.github/workflows/xtoken-ui-dev.yml @@ -31,8 +31,6 @@ jobs: script_build: npm run build:mainnet -w xtoken-ui dist_path: packages/xtoken-ui/dist enable_notify_comment: true - enable_notify_slack: true - slack_channel: helix-ui slack_webhook: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} - uses: ./.github/actions/smart-vercel @@ -49,6 +47,4 @@ jobs: alias_domain: "xtokenui-dev-testnet" enable_cache: true enable_notify_comment: true - enable_notify_slack: true - slack_channel: helix-ui slack_webhook: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} diff --git a/.github/workflows/xtoken-ui-prd.yml b/.github/workflows/xtoken-ui-prd.yml index df98bdc..79ad697 100644 --- a/.github/workflows/xtoken-ui-prd.yml +++ b/.github/workflows/xtoken-ui-prd.yml @@ -35,7 +35,7 @@ jobs: prod_mode: true enable_cache: true enable_notify_slack: true - slack_channel: helix-ui + slack_channel: helixbox-ui slack_webhook: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} - uses: ./.github/actions/smart-vercel @@ -53,5 +53,5 @@ jobs: prod_mode: true enable_cache: true enable_notify_slack: true - slack_channel: helix-ui + slack_channel: helixbox-ui slack_webhook: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} diff --git a/.github/workflows/xtoken-ui-stg.yml b/.github/workflows/xtoken-ui-stg.yml index fc0ca65..65241b8 100644 --- a/.github/workflows/xtoken-ui-stg.yml +++ b/.github/workflows/xtoken-ui-stg.yml @@ -32,8 +32,6 @@ jobs: project_name: xtoken-ui alias_domain: "xtokenui-stg-mainnet" enable_cache: true - enable_notify_slack: true - slack_channel: helix-ui slack_webhook: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} - uses: ./.github/actions/smart-vercel @@ -49,6 +47,4 @@ jobs: project_name: xtoken-ui-test alias_domain: "xtokenui-stg-testnet" enable_cache: true - enable_notify_slack: true - slack_channel: helix-ui slack_webhook: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} diff --git a/package.json b/package.json index 41fb3b5..53620fe 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "workspaces": [ "packages/*" ], - "author": "Helix Bridge", + "author": "Helixbox", "license": "ISC", "bugs": { "url": "https://github.com/helix-bridge/xtoken-monorepo/issues" diff --git a/packages/xtoken-home/public/logo.svg b/packages/xtoken-home/public/logo.svg index b1a569b..678d8ec 100644 --- a/packages/xtoken-home/public/logo.svg +++ b/packages/xtoken-home/public/logo.svg @@ -1,11 +1,5 @@ - - - - - \ No newline at end of file + + + + + diff --git a/packages/xtoken-home/public/social/twitter.svg b/packages/xtoken-home/public/social/twitter.svg deleted file mode 100644 index 836d859..0000000 --- a/packages/xtoken-home/public/social/twitter.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/packages/xtoken-home/public/social/x.svg b/packages/xtoken-home/public/social/x.svg new file mode 100644 index 0000000..5c0aa70 --- /dev/null +++ b/packages/xtoken-home/public/social/x.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/xtoken-home/src/app/page.tsx b/packages/xtoken-home/src/app/page.tsx index 471f116..d9d0fba 100644 --- a/packages/xtoken-home/src/app/page.tsx +++ b/packages/xtoken-home/src/app/page.tsx @@ -6,16 +6,16 @@ export default function Home() {
- Logo + Logo - XToken, Helix's Bridge as a Service Open Platform + XToken, Helixbox's Bridge as a Service Open Platform - XToken BAAS(Bridge as a Service) offers professional cross-chain token mapping bridge services tailored for + XToken BaaS(Bridge as a Service) offers professional cross-chain token mapping bridge services tailored for cryptocurrency token issuance projects or custodial applications. Clients maintain full control over - contracts and asset permissions. Our comprehensive services include BAAS solution consulting, contract + contracts and asset permissions. Our comprehensive services include BaaS solution consulting, contract deployment, indexing, and UI cloud services. Custom domain provisioning is also available. For inquiries, - please contact hello@helixbridge.app. + please contact hello@helix.box.
diff --git a/packages/xtoken-home/src/components/footer.tsx b/packages/xtoken-home/src/components/footer.tsx index 6999ac7..a5132f8 100644 --- a/packages/xtoken-home/src/components/footer.tsx +++ b/packages/xtoken-home/src/components/footer.tsx @@ -10,18 +10,18 @@ export default function Footer({ className }: Props) {
- {`© ${new Date().getFullYear()} Developed by Helix Bridge Team`} + {`© ${new Date().getFullYear()} Developed by Helixbox Team`}
Github - - Twitter + + Twitter Discord - + Email
diff --git a/packages/xtoken-ui/package.json b/packages/xtoken-ui/package.json index 154ce1a..45fd1c3 100644 --- a/packages/xtoken-ui/package.json +++ b/packages/xtoken-ui/package.json @@ -23,7 +23,7 @@ "keywords": [ "xtoken", "xtoken-monorepo", - "helixbridge" + "helixbox-bridge" ], "license": "MIT", "bugs": { diff --git a/packages/xtoken-ui/src/bridges/base.ts b/packages/xtoken-ui/src/bridges/base.ts index a2662ef..54ee339 100644 --- a/packages/xtoken-ui/src/bridges/base.ts +++ b/packages/xtoken-ui/src/bridges/base.ts @@ -23,6 +23,7 @@ import { import { Address, PublicClient as ViemPublicClient, TransactionReceipt, createPublicClient, http } from "viem"; import { PublicClient as WagmiPublicClient, WalletClient } from "wagmi"; import erc20Abi from "../abi/erc20"; +import { TX_CONFIRMATIONS } from "../config"; export abstract class BaseBridge { protected logo: BridgeLogo = { symbol: "", horizontal: "" }; @@ -254,7 +255,7 @@ export abstract class BaseBridge { account: owner, }); const hash = await this.walletClient.writeContract(request); - return this.publicClient.waitForTransactionReceipt({ hash }); + return this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } diff --git a/packages/xtoken-ui/src/bridges/helix-lpbridge.ts b/packages/xtoken-ui/src/bridges/helix-lpbridge.ts index bcba63f..47bfa32 100644 --- a/packages/xtoken-ui/src/bridges/helix-lpbridge.ts +++ b/packages/xtoken-ui/src/bridges/helix-lpbridge.ts @@ -2,6 +2,7 @@ import { BridgeConstructorArgs, GetFeeArgs, TransferOptions } from "../types/bri import { BaseBridge } from "./base"; import { Address, TransactionReceipt } from "viem"; import { HistoryRecord } from "../types/graphql"; +import { TX_CONFIRMATIONS } from "../config"; export class HelixLpBridge extends BaseBridge { private readonly prefix = BigInt("0x6878000000000000"); @@ -77,7 +78,7 @@ export class HelixLpBridge extends BaseBridge { const hash = await (this.sourceToken?.type === "native" ? this.walletClient.writeContract(nativeParams) : this.walletClient.writeContract(defaultParams)); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } @@ -104,7 +105,7 @@ export class HelixLpBridge extends BaseBridge { value: await this.getBridgeFee(), gas: this.getTxGasLimit(), }); - return this.publicClient.waitForTransactionReceipt({ hash }); + return this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } @@ -136,7 +137,7 @@ export class HelixLpBridge extends BaseBridge { value: fee, }) : this.walletClient.writeContract({ address, abi, gas, functionName: "increaseFee", args: [transferId, fee] })); - return await this.publicClient.waitForTransactionReceipt({ hash }); + return await this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } diff --git a/packages/xtoken-ui/src/bridges/helixbridge-dvmdvm.ts b/packages/xtoken-ui/src/bridges/helixbridge-dvmdvm.ts index 524ee6d..fc070c5 100644 --- a/packages/xtoken-ui/src/bridges/helixbridge-dvmdvm.ts +++ b/packages/xtoken-ui/src/bridges/helixbridge-dvmdvm.ts @@ -2,6 +2,7 @@ import { BridgeConstructorArgs, TransferOptions } from "../types/bridge"; import { BaseBridge } from "./base"; import { Address, TransactionReceipt } from "viem"; import { HistoryRecord } from "../types/graphql"; +import { TX_CONFIRMATIONS } from "../config"; /** * DVM <=> DVM @@ -95,7 +96,7 @@ export class HelixBridgeDVMDVM extends BaseBridge { const hash = await (this.sourceToken.type === "native" ? this.walletClient.writeContract(nativeParams) : this.walletClient.writeContract(defaultParams)); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } @@ -141,7 +142,7 @@ export class HelixBridgeDVMDVM extends BaseBridge { const hash = await (this.targetToken?.type === "native" ? this.walletClient.writeContract(nativeParams) : this.walletClient.writeContract(defaultParams)); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } @@ -207,7 +208,7 @@ export class HelixBridgeDVMDVM extends BaseBridge { args: [this.specVersion.source, this.gasLimit, messageNonce, sendTokenAddress, record.sender, sendAmount], }); } - return hash && this.publicClient.waitForTransactionReceipt({ hash }); + return hash && this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } diff --git a/packages/xtoken-ui/src/bridges/helixbridge-dvmevm.ts b/packages/xtoken-ui/src/bridges/helixbridge-dvmevm.ts index 5c9235b..735eb2a 100644 --- a/packages/xtoken-ui/src/bridges/helixbridge-dvmevm.ts +++ b/packages/xtoken-ui/src/bridges/helixbridge-dvmevm.ts @@ -2,6 +2,7 @@ import { BridgeConstructorArgs, TransferOptions } from "../types/bridge"; import { BaseBridge } from "./base"; import { Address, TransactionReceipt } from "viem"; import { HistoryRecord } from "../types/graphql"; +import { TX_CONFIRMATIONS } from "../config"; /** * DVM <=> EVM @@ -78,7 +79,7 @@ export class HelixBridgeDVMEVM extends BaseBridge { const hash = await (this.sourceToken.type === "native" ? this.walletClient.writeContract(nativeParams) : this.walletClient.writeContract(defaultParams)); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } @@ -124,7 +125,7 @@ export class HelixBridgeDVMEVM extends BaseBridge { const hash = await (this.targetToken.type === "native" ? this.walletClient.writeContract(nativeParams) : this.walletClient.writeContract(defaultParams)); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } @@ -160,7 +161,7 @@ export class HelixBridgeDVMEVM extends BaseBridge { ], gas: this.getTxGasLimit(), }); - return this.publicClient.waitForTransactionReceipt({ hash }); + return this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } @@ -207,7 +208,7 @@ export class HelixBridgeDVMEVM extends BaseBridge { args: [transferId, sendTokenAddress, record.sender, sendAmount], }); } - return hash && this.publicClient.waitForTransactionReceipt({ hash }); + return hash && this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } diff --git a/packages/xtoken-ui/src/bridges/l2bridge.ts b/packages/xtoken-ui/src/bridges/l2bridge.ts index f621633..d580319 100644 --- a/packages/xtoken-ui/src/bridges/l2bridge.ts +++ b/packages/xtoken-ui/src/bridges/l2bridge.ts @@ -1,3 +1,4 @@ +import { TX_CONFIRMATIONS } from "../config"; import { BridgeConstructorArgs, TransferOptions } from "../types/bridge"; import { BaseBridge } from "./base"; import { Address, TransactionReceipt, encodeAbiParameters } from "viem"; @@ -73,7 +74,7 @@ export class L2ArbitrumBridge extends BaseBridge { return this.sourcePublicClient.estimateContractGas(defaultParams); } else if (this.walletClient) { const hash = await this.walletClient.writeContract(defaultParams); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } diff --git a/packages/xtoken-ui/src/bridges/xtoken-next.ts b/packages/xtoken-ui/src/bridges/xtoken-next.ts index 3f47cf4..9fc724a 100644 --- a/packages/xtoken-ui/src/bridges/xtoken-next.ts +++ b/packages/xtoken-ui/src/bridges/xtoken-next.ts @@ -16,6 +16,7 @@ import { isTronChain, waitForTronTransactionReceipt, } from "../utils"; +import { TX_CONFIRMATIONS } from "../config"; export class XTokenNextBridge extends BaseBridge { constructor(args: BridgeConstructorArgs) { @@ -261,7 +262,7 @@ export class XTokenNextBridge extends BaseBridge { return this.sourcePublicClient.estimateContractGas(defaultParams); } else if (this.walletClient) { const hash = await this.walletClient.writeContract(defaultParams); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } else { const defaultParams = { @@ -287,7 +288,7 @@ export class XTokenNextBridge extends BaseBridge { return this.sourcePublicClient.estimateContractGas(defaultParams); } else if (this.walletClient) { const hash = await this.walletClient.writeContract(defaultParams); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } else if (this.crossInfo?.action === "redeem" && this.sourcePublicClient && account) { @@ -306,7 +307,7 @@ export class XTokenNextBridge extends BaseBridge { return this.sourcePublicClient.estimateContractGas(defaultParams); } else if (this.walletClient) { const hash = await this.walletClient.writeContract(defaultParams); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } else { const defaultParams = { @@ -323,7 +324,7 @@ export class XTokenNextBridge extends BaseBridge { return this.sourcePublicClient.estimateContractGas(defaultParams); } else if (this.walletClient) { const hash = await this.walletClient.writeContract(defaultParams); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } @@ -473,7 +474,7 @@ export class XTokenNextBridge extends BaseBridge { const guard = await this._getTargetGuard(); if (record.recvTokenAddress && guard && this.contract && this.walletClient && this.publicClient) { - const hash = await this.walletClient.writeContract({ + const { request } = await this.publicClient.simulateContract({ abi: (await import("../abi/guard-next")).default, functionName: "claim", args: [ @@ -488,7 +489,8 @@ export class XTokenNextBridge extends BaseBridge { address: guard, gas: this.getTxGasLimit(), }); - return this.publicClient.waitForTransactionReceipt({ hash }); + const hash = await this.walletClient.writeContract(request); + return this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } @@ -577,7 +579,7 @@ export class XTokenNextBridge extends BaseBridge { gas: this.getTxGasLimit(), value: feeAndParams.fee, }); - return this.publicClient.waitForTransactionReceipt({ hash }); + return this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } else if (this.crossInfo?.action === "redeem") { @@ -649,7 +651,7 @@ export class XTokenNextBridge extends BaseBridge { gas: this.getTxGasLimit(), value: feeAndParams.fee, }); - return this.publicClient.waitForTransactionReceipt({ hash }); + return this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } diff --git a/packages/xtoken-ui/src/bridges/xtoken-v3.ts b/packages/xtoken-ui/src/bridges/xtoken-v3.ts index bb50636..93265a7 100644 --- a/packages/xtoken-ui/src/bridges/xtoken-v3.ts +++ b/packages/xtoken-ui/src/bridges/xtoken-v3.ts @@ -2,6 +2,7 @@ import { BridgeConstructorArgs, GetFeeArgs, HistoryRecord, Token, TransferOption import { BaseBridge } from "."; import { Address, Hex, TransactionReceipt, encodeFunctionData, isAddressEqual } from "viem"; import { fetchMsglineFeeAndParams, getMessagerAddress } from "../utils"; +import { TX_CONFIRMATIONS } from "../config"; export class XTokenV3Bridge extends BaseBridge { constructor(args: BridgeConstructorArgs) { @@ -72,7 +73,7 @@ export class XTokenV3Bridge extends BaseBridge { return this.sourcePublicClient.estimateContractGas(defaultParams); } else if (this.walletClient) { const hash = await this.walletClient.writeContract(defaultParams); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } else if (this.crossInfo?.action === "redeem") { const defaultParams = { @@ -89,7 +90,7 @@ export class XTokenV3Bridge extends BaseBridge { return this.sourcePublicClient.estimateContractGas(defaultParams); } else if (this.walletClient) { const hash = await this.walletClient.writeContract(defaultParams); - return this.sourcePublicClient.waitForTransactionReceipt({ hash }); + return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } @@ -197,7 +198,7 @@ export class XTokenV3Bridge extends BaseBridge { address: guardContract, gas: this.getTxGasLimit(), }); - return this.publicClient.waitForTransactionReceipt({ hash }); + return this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } @@ -299,7 +300,7 @@ export class XTokenV3Bridge extends BaseBridge { } } - return hash && this.publicClient.waitForTransactionReceipt({ hash }); + return hash && this.publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); } } } diff --git a/packages/xtoken-ui/src/components/faucet.tsx b/packages/xtoken-ui/src/components/faucet.tsx index 6aaeeaa..f42cadc 100644 --- a/packages/xtoken-ui/src/components/faucet.tsx +++ b/packages/xtoken-ui/src/components/faucet.tsx @@ -8,6 +8,7 @@ import abi from "../abi/faucet"; import Tooltip from "../ui/tooltip"; import CountLoading from "../ui/count-loading"; import Modal from "../ui/modal"; +import { TX_CONFIRMATIONS } from "../config"; interface Props { sourceChain: ChainConfig; @@ -40,7 +41,7 @@ export default function Faucet({ sourceChain, sourceToken, onSuccess = () => und functionName: "faucet", args: [1n <= allow ? allow - 1n : allow], }); - const receipt = await publicClient.waitForTransactionReceipt({ hash }); + const receipt = await publicClient.waitForTransactionReceipt({ hash, confirmations: TX_CONFIRMATIONS }); notifyTransaction(receipt, sourceChain); setBusy(false); diff --git a/packages/xtoken-ui/src/components/footer.tsx b/packages/xtoken-ui/src/components/footer.tsx index f35afaf..3562698 100644 --- a/packages/xtoken-ui/src/components/footer.tsx +++ b/packages/xtoken-ui/src/components/footer.tsx @@ -3,7 +3,7 @@ import { PropsWithChildren } from "react"; export default function Footer() { return (
- {`© ${new Date().getFullYear()} Powered by Helix Bridge`} + {`© ${new Date().getFullYear()} Powered by Helixbox Bridge`} diff --git a/packages/xtoken-ui/src/components/transaction-status.tsx b/packages/xtoken-ui/src/components/transaction-status.tsx index 6849906..0de4cc4 100644 --- a/packages/xtoken-ui/src/components/transaction-status.tsx +++ b/packages/xtoken-ui/src/components/transaction-status.tsx @@ -186,7 +186,7 @@ export default function TransactionStatus({ record }: Props) { It seems to be taking longer than usual.{" "} { const params = new URLSearchParams(window.location.hash.split("?")[1]); const pT = params.get(UrlSearchParamKey.TOKEN_CATEGORY); - const _token = tokenOptions.find(({ category }) => category === pT) || tokenOptions[0]; + const _tokenOption = tokenOptions.find(({ category }) => category === pT); + const _token = _tokenOption || tokenOptions[0]; const pSC = params.get(UrlSearchParamKey.SOURCE_CHAIN); const _sourceChainOptions = getSourceChainOptions(_token.category); - const _sourceChain = _sourceChainOptions.find(({ network }) => network === pSC) || _sourceChainOptions[0]; + const _sourceChainOption = _sourceChainOptions.find(({ network }) => network === pSC); + const _sourceChain = _sourceChainOption || _sourceChainOptions[0]; const pST = params.get(UrlSearchParamKey.SOURCE_TOKEN); const _sourceTokenOptions = getSourceTokenOptions(_sourceChain, _token.category); - const _sourceToken = _sourceTokenOptions.find(({ symbol }) => symbol === pST) || _sourceTokenOptions[0]; + const _sourceTokenOption = _sourceTokenOptions.find(({ symbol }) => symbol === pST); + const _sourceToken = _sourceTokenOption || _sourceTokenOptions[0]; const pTC = params.get(UrlSearchParamKey.TARGET_CHAIN); const _targetChainOptions = getTargetChainOptions(_sourceToken); - const _targetChain = _targetChainOptions.find(({ network }) => network === pTC) || _targetChainOptions[0]; + const _targetChainOption = _targetChainOptions.find(({ network }) => network === pTC); + const _targetChain = _targetChainOption || _targetChainOptions[0]; const pTT = params.get(UrlSearchParamKey.TARGET_CHAIN); const _targetTokenOptions = getTargetTokenOptions(_sourceToken, _targetChain); - const _targetToken = _targetTokenOptions.find(({ symbol }) => symbol === pTT) || _targetTokenOptions[0]; + const _targetTokenOption = _targetTokenOptions.find(({ symbol }) => symbol === pTT); + const _targetToken = _targetTokenOption || _targetTokenOptions[0]; + + isOpenedWithoutUrlParams.current = !( + _tokenOption || + _sourceChainOption || + _sourceTokenOption || + _targetChainOption || + _targetTokenOption + ); sourceChainRef.current = _sourceChain; sourceTokenRef.current = _sourceToken; @@ -121,22 +138,27 @@ export default function TransferProvider({ children }: PropsWithChildren { - const params = onlyTokenCategory - ? new URLSearchParams() - : new URLSearchParams(searchParamsRef.current.toString()); - params.set(UrlSearchParamKey.TOKEN_CATEGORY, tokenRef.current.category); - if (!onlyTokenCategory) { - params.set(UrlSearchParamKey.SOURCE_CHAIN, sourceChainRef.current.network); - params.set(UrlSearchParamKey.SOURCE_TOKEN, sourceTokenRef.current.symbol); - params.set(UrlSearchParamKey.TARGET_CHAIN, targetChainRef.current.network); - params.set(UrlSearchParamKey.TARGET_TOKEN, targetTokenRef.current.symbol); - } - navigate(`?${params.toString()}`); - }, - [navigate], - ); + const changeUrl = useCallback(() => { + if ( + isOpenedWithoutUrlParams.current && + !hasUserManuallyChangedTokenParams.current && + !hasUserManuallyChangedOtherParams.current + ) { + return; + } + const justTokenCategoryChanged = isOpenedWithoutUrlParams.current && !hasUserManuallyChangedOtherParams.current; + const params = justTokenCategoryChanged + ? new URLSearchParams() + : new URLSearchParams(searchParamsRef.current.toString()); + params.set(UrlSearchParamKey.TOKEN_CATEGORY, tokenRef.current.category); + if (!justTokenCategoryChanged) { + params.set(UrlSearchParamKey.SOURCE_CHAIN, sourceChainRef.current.network); + params.set(UrlSearchParamKey.SOURCE_TOKEN, sourceTokenRef.current.symbol); + params.set(UrlSearchParamKey.TARGET_CHAIN, targetChainRef.current.network); + params.set(UrlSearchParamKey.TARGET_TOKEN, targetTokenRef.current.symbol); + } + navigate(`?${params.toString()}`); + }, [navigate]); useEffect(() => { const _token = tokenRef.current; @@ -176,6 +198,7 @@ export default function TransferProvider({ children }: PropsWithChildren { + hasUserManuallyChangedTokenParams.current = true; setToken(_token); const _sourceChainOptions = getSourceChainOptions(_token.category); @@ -200,13 +223,14 @@ export default function TransferProvider({ children }: PropsWithChildren { + hasUserManuallyChangedOtherParams.current = true; const _sourceTokenOptions = getSourceTokenOptions(_sourceChain, tokenRef.current.category); const _sourceToken = _sourceTokenOptions.find(({ symbol }) => symbol === sourceTokenRef.current.symbol) || _sourceTokenOptions[0]; @@ -231,6 +255,7 @@ export default function TransferProvider({ children }: PropsWithChildren { + hasUserManuallyChangedOtherParams.current = true; const _targetChainOptions = getTargetChainOptions(_sourceToken); const _targetChain = _targetChainOptions.find(({ id }) => id === targetChainRef.current.id) || _targetChainOptions[0]; @@ -250,6 +275,7 @@ export default function TransferProvider({ children }: PropsWithChildren { + hasUserManuallyChangedOtherParams.current = true; const _targetTokenOptions = getTargetTokenOptions(sourceTokenRef.current, _targetChain); const _targetToken = _targetTokenOptions.find(({ symbol }) => symbol === targetTokenRef.current.symbol) || _targetTokenOptions[0]; @@ -263,6 +289,7 @@ export default function TransferProvider({ children }: PropsWithChildren { + hasUserManuallyChangedOtherParams.current = true; setTargetToken(_targetToken); changeUrl(); }, @@ -270,6 +297,7 @@ export default function TransferProvider({ children }: PropsWithChildren { + hasUserManuallyChangedOtherParams.current = true; const _sourceChain = targetChainRef.current; const _sourceTokenOptions = getSourceTokenOptions(_sourceChain, tokenRef.current.category); const _sourceToken = diff --git a/packages/xtoken-ui/src/utils/chain.ts b/packages/xtoken-ui/src/utils/chain.ts index f32f077..c393bf1 100644 --- a/packages/xtoken-ui/src/utils/chain.ts +++ b/packages/xtoken-ui/src/utils/chain.ts @@ -10,7 +10,7 @@ import { lineaChain, mantleChain, pangolinChain, - pangoroChain, + // pangoroChain, polygonChain, polygonZkEvmChain, scrollChain, @@ -81,9 +81,9 @@ export function getChainConfig(chainIdOrNetwork?: ChainID | Network | null): Cha case ChainID.SEPOLIA: case "sepolia": return sepoliaChain; - case ChainID.PANGORO_TANSSI: - case "pangoro-dvm": - return pangoroChain; + // case ChainID.PANGORO_TANSSI: + // case "pangoro-dvm": + // return pangoroChain; case ChainID.TRON_SHASTA: case "tron-shasta": return tronShastaChain; @@ -118,7 +118,7 @@ export function getChainConfigs(askAll?: boolean) { bscChain, optimismChain, gnosisChain, - pangoroChain, + // pangoroChain, koiChain, tronShastaChain, tronChain,