diff --git a/.changeset/ninety-lobsters-enjoy.md b/.changeset/ninety-lobsters-enjoy.md new file mode 100644 index 000000000..341446f20 --- /dev/null +++ b/.changeset/ninety-lobsters-enjoy.md @@ -0,0 +1,5 @@ +--- +'@skip-go/widget': patch +--- + +fix autoset address override manual address diff --git a/packages/widget/src/components/RenderWalletList.tsx b/packages/widget/src/components/RenderWalletList.tsx index 8219db85a..5d95464f3 100644 --- a/packages/widget/src/components/RenderWalletList.tsx +++ b/packages/widget/src/components/RenderWalletList.tsx @@ -13,6 +13,7 @@ import { chainAddressesAtom } from "@/state/swapExecutionPage"; import { clearAssetInputAmountsAtom } from "@/state/swapPage"; import NiceModal from "@ebay/nice-modal-react"; import { Modals } from "@/modals/registerModals"; +import { ChainType } from "@skip-go/client"; export type RenderWalletListProps = { title: string; @@ -73,7 +74,7 @@ export const RenderWalletList = ({ ...prev, [destinationIndex]: { chainID: chainId, - chainType: chainType as "evm" | "cosmos" | "svm", + chainType: chainType as ChainType, address: address, source: "wallet", wallet: { diff --git a/packages/widget/src/hooks/useAutoSetAddress.ts b/packages/widget/src/hooks/useAutoSetAddress.ts index 305174db6..e4453f466 100644 --- a/packages/widget/src/hooks/useAutoSetAddress.ts +++ b/packages/widget/src/hooks/useAutoSetAddress.ts @@ -64,13 +64,13 @@ export const useAutoSetAddress = () => { const chainType = chain.chainType; switch (chainType) { case "cosmos": { + if (chainAddresses[index].address) return; const wallets = createCosmosWallets(chainID); const wallet = wallets.find( (w) => w.walletName === sourceWallet.cosmos?.walletName ); if (!wallet) { if (!openModal) return; - if (chainAddresses[index].address) return; NiceModal.show(Modals.SetAddressModal, { signRequired: isSignRequired, chainId: chainID, @@ -79,8 +79,6 @@ export const useAutoSetAddress = () => { return; } try { - if (chainAddresses[index].address) return; - const address = await wallet?.getAddress?.({ signRequired: isSignRequired, }); @@ -108,6 +106,7 @@ export const useAutoSetAddress = () => { break; } case "svm": { + if (chainAddresses[index]?.address) return; const wallets = createSolanaWallets(); const wallet = wallets.find( (w) => w.walletName === sourceWallet.svm?.walletName @@ -149,6 +148,7 @@ export const useAutoSetAddress = () => { break; } case "evm": { + if (chainAddresses[index]?.address) return; const wallets = createEvmWallets(chainID); const wallet = wallets.find( (w) => w.walletName === sourceWallet.evm?.walletName diff --git a/packages/widget/src/modals/SetAddressModal/SetAddressModal.tsx b/packages/widget/src/modals/SetAddressModal/SetAddressModal.tsx index e3a75ad37..aa0e54711 100644 --- a/packages/widget/src/modals/SetAddressModal/SetAddressModal.tsx +++ b/packages/widget/src/modals/SetAddressModal/SetAddressModal.tsx @@ -18,6 +18,7 @@ import { chainAddressesAtom } from "@/state/swapExecutionPage"; import NiceModal from "@ebay/nice-modal-react"; import { Modals } from "../registerModals"; import { useIsMobileScreenSize } from "@/hooks/useIsMobileScreenSize"; +import { ChainType } from "@skip-go/client"; export type SetAddressModalProps = ModalProps & { signRequired?: boolean; @@ -95,7 +96,7 @@ export const SetAddressModal = createModal((modalProps: SetAddressModalProps) => ...prev, [destinationIndex]: { chainID: chainId, - chainType: chainType as "evm" | "cosmos" | "svm", + chainType: chainType as ChainType, address: manualWalletAddress, source: "input", },