Skip to content

Commit 5363716

Browse files
author
Piotr
committed
Merge branch 'main' into blanksquare-rebranding
# Conflicts: # src/domains/shielder/components/TransactionDetailsModal/Title.tsx
2 parents c29d478 + f167cd9 commit 5363716

10 files changed

Lines changed: 117 additions & 142 deletions

File tree

src/domains/misc/components/Modal/Modal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ const Modal = ({
5858

5959
useEffect(() => {
6060
const handleEsc = (e: KeyboardEvent) => {
61-
if (e.key === 'Escape' && !nonDismissible) {
61+
if (e.key === 'Escape' && !nonDismissible && isTopModal) {
6262
triggerClose();
6363
}
6464
};
6565
document.addEventListener('keydown', handleEsc);
6666
return () => void document.removeEventListener('keydown', handleEsc);
67-
}, [nonDismissible, triggerClose]);
67+
}, [nonDismissible, triggerClose, isTopModal]);
6868

6969
const pages = Array.isArray(config) ? config : [config];
7070

src/domains/shielder/components/TokenList/Modals/SendModal/SelectAmountPage.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ type Props = {
3131
},
3232
onContinue: (amount: bigint) => void,
3333
hasInsufficientFees: boolean,
34+
value: string,
35+
onValueChange: (value: string) => void,
3436
};
3537

36-
const SelectAmountPage = ({ onContinue, token, hasInsufficientFees }: Props) => {
38+
const SelectAmountPage = ({ onContinue, token, hasInsufficientFees, value, onValueChange }: Props) => {
3739
const { address } = useWallet();
3840
const chainConfig = useChain();
3941

40-
const [value, setValue] = useState('');
4142
const [isExceedingBalance, setIsExceedingBalance] = useState(false);
4243

44+
const amount = token.decimals ? fromDecimals(value, token.decimals) : 0n;
45+
4346
const { fees, totalFee, isLoading } = useShielderFees({ token, operation: 'send' });
4447

4548
const {
@@ -56,7 +59,6 @@ const SelectAmountPage = ({ onContinue, token, hasInsufficientFees }: Props) =>
5659
return result > 0n ? result : 0n;
5760
}, [token, totalFee]);
5861

59-
const amount = token.decimals ? fromDecimals(value, token.decimals) : 0n;
6062
const hasNotSelectedAmount = amount <= 0n;
6163
const isButtonDisabled = hasNotSelectedAmount || isExceedingBalance || hasInsufficientFees;
6264

@@ -80,7 +82,7 @@ const SelectAmountPage = ({ onContinue, token, hasInsufficientFees }: Props) =>
8082
maxAmount={maxAmountToSend}
8183
token={token}
8284
effectiveAssetValue={value}
83-
onAssetValueChange={setValue}
85+
onAssetValueChange={onValueChange}
8486
accountAddress={address}
8587
onAssetBalanceExceeded={setIsExceedingBalance}
8688
/>

src/domains/shielder/components/TokenList/Modals/SendModal/SendModal.tsx

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const SendModal = ({ token }: Props) => {
2626
const { address } = useWallet();
2727
const [addressTo, setAddressTo] = useState('');
2828
const [amount, setAmount] = useState(0n);
29+
const [inputValue, setInputValue] = useState('');
2930
const { withdraw, isWithdrawing } = useWithdraw();
3031
const [page, setPage] = useState(0);
3132
const { close } = useModalControls();
@@ -63,52 +64,49 @@ const SendModal = ({ token }: Props) => {
6364
return (
6465
<Modal
6566
page={page}
66-
config={
67-
[
68-
{
69-
title: 'Send',
70-
content: (
71-
<SelectAccountPage
72-
key="select-account"
73-
addressTo={addressTo}
74-
setAddressTo={setAddressTo}
75-
onConfirmClick={onConfirm}
76-
/>
77-
),
78-
},
79-
{
80-
title: 'Send',
81-
content: (
82-
<SelectAmountPage
83-
key="select-amount"
84-
token={token}
85-
onContinue={handleSelectAmount}
86-
hasInsufficientFees={hasInsufficientFees}
87-
/>
88-
),
89-
},
90-
{
91-
title: 'Send',
92-
content: (
93-
<ConfirmPage
94-
key="confirmation"
95-
amount={amount}
96-
token={token}
97-
addressTo={validatedAddressTo}
98-
onConfirm={handleWithdraw}
99-
isLoading={isWithdrawing}
100-
buttonLabel={
101-
hasInsufficientFees ?
102-
`Insufficient ${token.symbol} Balance` :
103-
isWithdrawing ? 'Sending privately' : 'Confirm'
104-
}
105-
addressFrom={address}
106-
hasInsufficientFees={hasInsufficientFees}
107-
/>
108-
),
109-
},
110-
]
111-
}
67+
config={[
68+
{
69+
title: 'Send',
70+
content: (
71+
<SelectAccountPage
72+
addressTo={addressTo}
73+
setAddressTo={setAddressTo}
74+
onConfirmClick={onConfirm}
75+
/>
76+
),
77+
},
78+
{
79+
title: 'Send',
80+
content: (
81+
<SelectAmountPage
82+
token={token}
83+
onContinue={handleSelectAmount}
84+
hasInsufficientFees={hasInsufficientFees}
85+
value={inputValue}
86+
onValueChange={setInputValue}
87+
/>
88+
),
89+
},
90+
{
91+
title: 'Send',
92+
content: (
93+
<ConfirmPage
94+
amount={amount}
95+
token={token}
96+
addressTo={validatedAddressTo}
97+
onConfirm={handleWithdraw}
98+
isLoading={isWithdrawing}
99+
buttonLabel={
100+
hasInsufficientFees ?
101+
`Insufficient ${token.symbol} Balance` :
102+
isWithdrawing ? 'Sending privately' : 'Confirm'
103+
}
104+
addressFrom={address}
105+
hasInsufficientFees={hasInsufficientFees}
106+
/>
107+
),
108+
},
109+
]}
112110
/>
113111
);
114112
};

src/domains/shielder/components/TokenList/Modals/ShieldModal/SelectAmountPage.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ type Props = {
3131
},
3232
onContinue: (amount: bigint) => void,
3333
hasInsufficientFees: boolean,
34+
value: string,
35+
onValueChange: (value: string) => void,
3436
};
3537

36-
const SelectAmountPage = ({ onContinue, token, hasInsufficientFees }: Props) => {
38+
const SelectAmountPage = ({ onContinue, token, hasInsufficientFees, value, onValueChange }: Props) => {
3739
const { address } = useWallet();
3840
const chainConfig = useChain();
3941

40-
const [value, setValue] = useState('');
4142
const [isExceedingBalance, setIsExceedingBalance] = useState(false);
4243

4344
const amount = token.decimals ? fromDecimals(value, token.decimals) : 0n;
@@ -85,7 +86,7 @@ const SelectAmountPage = ({ onContinue, token, hasInsufficientFees }: Props) =>
8586
maxAmount={maxAmountToShield}
8687
token={token}
8788
effectiveAssetValue={value}
88-
onAssetValueChange={setValue}
89+
onAssetValueChange={onValueChange}
8990
accountAddress={address}
9091
onAssetBalanceExceeded={setIsExceedingBalance}
9192
/>

src/domains/shielder/components/TokenList/Modals/ShieldModal/ShieldModal.tsx

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const ShieldModal = ({ token }: Props) => {
2525
const { address } = useWallet();
2626
const { close } = useModalControls();
2727
const [amount, setAmount] = useState(0n);
28+
const [inputValue, setInputValue] = useState('');
2829
const chainConfig = useChain();
2930
const { shield, isShielding, reset } = useShield();
3031
const [page, setPage] = useState(0);
@@ -63,40 +64,38 @@ const ShieldModal = ({ token }: Props) => {
6364
<Modal
6465
page={page}
6566
onClose={handleReset}
66-
config={
67-
[
68-
{
69-
title: 'Shield',
70-
content: (
71-
<SelectAmountPage
72-
key="select-amount"
73-
token={token}
74-
onContinue={handleSelectAmount}
75-
hasInsufficientFees={hasInsufficientFees}
76-
/>
77-
),
78-
},
79-
{
80-
title: 'Shield',
81-
content: (
82-
<ConfirmPage
83-
key="confirmation"
84-
amount={amount}
85-
token={token}
86-
onConfirm={() => void handleShield()}
87-
isLoading={isShielding}
88-
buttonLabel={
89-
hasInsufficientFees ?
90-
`Insufficient ${chainConfig?.nativeCurrency.symbol} Balance` :
91-
isShielding ? 'Shielding' : 'Confirm'
92-
}
93-
addressFrom={address}
94-
hasInsufficientFees={hasInsufficientFees}
95-
/>
96-
),
97-
},
98-
]
99-
}
67+
config={[
68+
{
69+
title: 'Shield',
70+
content: (
71+
<SelectAmountPage
72+
token={token}
73+
onContinue={handleSelectAmount}
74+
hasInsufficientFees={hasInsufficientFees}
75+
value={inputValue}
76+
onValueChange={setInputValue}
77+
/>
78+
),
79+
},
80+
{
81+
title: 'Shield',
82+
content: (
83+
<ConfirmPage
84+
amount={amount}
85+
token={token}
86+
onConfirm={() => void handleShield()}
87+
isLoading={isShielding}
88+
buttonLabel={
89+
hasInsufficientFees ?
90+
`Insufficient ${chainConfig?.nativeCurrency.symbol} Balance` :
91+
isShielding ? 'Shielding' : 'Confirm'
92+
}
93+
addressFrom={address}
94+
hasInsufficientFees={hasInsufficientFees}
95+
/>
96+
),
97+
},
98+
]}
10099
/>
101100
);
102101
};

src/domains/shielder/components/TokenList/TokenListItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const TokenListItem = ({ token }: Props) => {
5050
variables.token.address === token.address &&
5151
variables.token.isNative === token.isNative;
5252
},
53-
});
53+
}) && selectedAccountType === 'public';
5454

5555
const isWithdrawing = !!useIsMutating({
5656
predicate: mutation => {
@@ -60,7 +60,7 @@ const TokenListItem = ({ token }: Props) => {
6060
variables.token.address === token.address &&
6161
variables.token.isNative === token.isNative;
6262
},
63-
});
63+
}) && selectedAccountType === 'shielded';
6464

6565
const isProcessing = isShielding || isWithdrawing;
6666
const processingText = isShielding ? 'Shielding' : isWithdrawing ? 'Sending privately' : undefined;

src/domains/shielder/components/TransactionDetailsModal/ActivityDetailsModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const ActivityDetailsModal = (props: Props) => {
5757
{ isNative: true as const };
5858

5959
const operation = transaction?.type === 'Withdraw' ? 'send' : 'shield';
60+
6061
const { fees, totalFee: estimatedTotalFee } = useShielderFees({
6162
token,
6263
operation,

src/domains/shielder/components/TransactionDetailsModal/Title.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,13 @@ const Container = styled.div`
6060
display: flex;
6161
justify-content: center;
6262
flex-direction: column;
63-
${typography.subtitle2};
6463
65-
& > p {
64+
& > :first-of-type {
65+
${typography.subtitle2};
66+
};
67+
68+
& > :last-of-type {
6669
${typography.caption2};
67-
color:${vars('--color-neutral-foreground-3-rest')}
68-
}
70+
color:${vars('--color-neutral-foreground-3-rest')}
71+
};
6972
`;

0 commit comments

Comments
 (0)