Skip to content

Commit

Permalink
Fix manual wallet input EVM (#543)
Browse files Browse the repository at this point in the history
Co-authored-by: Nur Fikri <[email protected]>
  • Loading branch information
ericHgorski and codingki authored Dec 6, 2024
1 parent 330b429 commit 187d91d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-lobsters-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skip-go/widget': patch
---

fix autoset address override manual address
3 changes: 2 additions & 1 deletion packages/widget/src/components/RenderWalletList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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: {
Expand Down
6 changes: 3 additions & 3 deletions packages/widget/src/hooks/useAutoSetAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -79,8 +79,6 @@ export const useAutoSetAddress = () => {
return;
}
try {
if (chainAddresses[index].address) return;

const address = await wallet?.getAddress?.({
signRequired: isSignRequired,
});
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
},
Expand Down

0 comments on commit 187d91d

Please sign in to comment.