Skip to content

Commit

Permalink
fix: account selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ap211unitech committed Jun 24, 2024
1 parent 8d0248a commit b1248a7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
49 changes: 26 additions & 23 deletions apps/hestia/src/components/sendAndReceive/withdraw/withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,30 +243,33 @@ export const Withdraw = () => {
</div>
</div>

{!isDestinationPolkadex && (
<div className="flex flex-col gap-2 border-l-2 border-primary-base px-8 pb-5 relative">
<Typography.Text size="lg" bold>
To Account
</Typography.Text>
<div className="border border-primary rounded-sm px-2 py-4">
<SelectWallet
account={destinationAccount}
setAccount={(e) => setDestinationAccount(e)}
evm={destinationChain?.type !== ChainType.Substrate}
/>
</div>
<div
className={classNames(
"flex item-center justify-center bg-primary rounded-full w-4 h-4 p-0.5 absolute top-0 -left-2.5",
destinationAccount && "bg-primary-base"
)}
>
{destinationAccount && (
<RiCheckLine className="w-full h-full" />
)}
</div>
<div className="flex flex-col gap-2 border-l-2 border-primary-base px-8 pb-5 relative">
<Typography.Text size="lg" bold>
To Account
</Typography.Text>
<div
className={classNames(
"border border-primary rounded-sm px-2 py-4",
isDestinationPolkadex && "pointer-events-none opacity-60"
)}
>
<SelectWallet
account={destinationAccount}
setAccount={(e) => setDestinationAccount(e)}
evm={destinationChain?.type !== ChainType.Substrate}
/>
</div>
)}
<div
className={classNames(
"flex item-center justify-center bg-primary rounded-full w-4 h-4 p-0.5 absolute top-0 -left-2.5",
destinationAccount && "bg-primary-base"
)}
>
{destinationAccount && (
<RiCheckLine className="w-full h-full" />
)}
</div>
</div>

<div className="flex flex-col gap-2 pb-5 px-8 relative">
<div className="flex items-center justify-between gap-2">
Expand Down
26 changes: 16 additions & 10 deletions packages/core/src/providers/user/sendAndReceive/withdraw/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,25 @@ export const DirectWithdrawProvider = ({ children }: PropsWithChildren) => {
const sourceAccountSelected = useMemo(() => selectedWallet, [selectedWallet]);

/* Destination Chain */
const destinationAccountSelected = useMemo(
() =>
const isDestinationPolkadex = useMemo(
() => !!(destinationChain?.genesis === GENESIS[0]),
[destinationChain?.genesis]
);

const destinationAccountSelected = useMemo(() => {
if (isDestinationPolkadex) return selectedWallet;
return (
destinationAccount ??
(destinationChain?.type === ChainType.Substrate
? selectedWallet
: undefined),
[destinationAccount, selectedWallet, destinationChain?.type]
);
: undefined)
);
}, [
destinationAccount,
selectedWallet,
destinationChain?.type,
isDestinationPolkadex,
]);

const destinationConnector = useMemo(
() => destinationChain && getChainConnector(destinationChain.genesis),
Expand All @@ -71,11 +82,6 @@ export const DirectWithdrawProvider = ({ children }: PropsWithChildren) => {
setSelectedAsset(selectedAsset);
};

const isDestinationPolkadex = useMemo(
() => !!(destinationChain?.genesis === GENESIS[0]),
[destinationChain?.genesis]
);

/* Asset */
const supportedAssets = useMemo(() => {
if (isDestinationPolkadex) {
Expand Down

0 comments on commit b1248a7

Please sign in to comment.