Skip to content

Commit ed32132

Browse files
authored
feat(ng): evm tx fee widget (#406)
1 parent 8ab6681 commit ed32132

File tree

95 files changed

+2811
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2811
-205
lines changed

apps/legacy/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"typecheck": "yarn tsc --skipLibCheck --noEmit"
1616
},
1717
"dependencies": {
18-
"@avalabs/avalanche-module": "1.9.10",
18+
"@avalabs/avalanche-module": "0.0.0-fix-nft-set-approval-for-all-20250829175304",
1919
"@avalabs/avalanchejs": "5.1.0-alpha.2",
20-
"@avalabs/bitcoin-module": "1.9.10",
20+
"@avalabs/bitcoin-module": "0.0.0-fix-nft-set-approval-for-all-20250829175304",
2121
"@avalabs/bridge-unified": "4.0.3",
2222
"@avalabs/core-bridge-sdk": "3.1.0-alpha.60",
2323
"@avalabs/core-chains-sdk": "3.1.0-alpha.60",
@@ -30,13 +30,13 @@
3030
"@avalabs/core-token-prices-sdk": "3.1.0-alpha.60",
3131
"@avalabs/core-utils-sdk": "3.1.0-alpha.60",
3232
"@avalabs/core-wallets-sdk": "3.1.0-alpha.60",
33-
"@avalabs/evm-module": "1.9.10",
33+
"@avalabs/evm-module": "0.0.0-fix-nft-set-approval-for-all-20250829175304",
3434
"@avalabs/glacier-sdk": "3.1.0-alpha.60",
35-
"@avalabs/hvm-module": "1.9.10",
35+
"@avalabs/hvm-module": "0.0.0-fix-nft-set-approval-for-all-20250829175304",
3636
"@avalabs/hw-app-avalanche": "0.14.1",
37-
"@avalabs/svm-module": "1.9.10",
37+
"@avalabs/svm-module": "0.0.0-fix-nft-set-approval-for-all-20250829175304",
3838
"@avalabs/types": "3.1.0-alpha.60",
39-
"@avalabs/vm-module-types": "1.9.10",
39+
"@avalabs/vm-module-types": "0.0.0-fix-nft-set-approval-for-all-20250829175304",
4040
"@blockaid/client": "0.10.0",
4141
"@coinbase/cbpay-js": "1.6.0",
4242
"@core/common": "workspace:*",

apps/legacy/src/localization/locales/en/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@
10461046
"Transaction has been cancelled": "Transaction has been cancelled",
10471047
"Transaction has been rejected": "Transaction has been rejected",
10481048
"Transaction has failed": "Transaction has failed",
1049-
"Transaction pre-exution is unavailable. The displayed token list might be incomplete.": "Transaction pre-exution is unavailable. The displayed token list might be incomplete.",
1049+
"Transaction pre-execution is unavailable. The displayed token list might be incomplete.": "Transaction pre-execution is unavailable. The displayed token list might be incomplete.",
10501050
"Transaction rejected": "Transaction rejected",
10511051
"Transaction timed out": "Transaction timed out",
10521052
"Transfer": "Transfer",

apps/legacy/src/pages/SignTransaction/components/TxBalanceChange.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const TxBalanceChange = ({
4242
tooltip={
4343
showNoPreExecWarning
4444
? t(
45-
'Transaction pre-exution is unavailable. The displayed token list might be incomplete.',
45+
'Transaction pre-execution is unavailable. The displayed token list might be incomplete.',
4646
)
4747
: ''
4848
}

apps/next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@avalabs/core-wallets-sdk": "3.1.0-alpha.60",
2323
"@avalabs/k2-alpine": "1.228.0",
2424
"@avalabs/types": "3.1.0-alpha.60",
25-
"@avalabs/vm-module-types": "1.9.10",
25+
"@avalabs/vm-module-types": "0.0.0-fix-nft-set-approval-for-all-20250829175304",
2626
"@core/common": "workspace:*",
2727
"@core/messaging": "workspace:*",
2828
"@core/service-worker": "workspace:*",

apps/next/src/components/CollapsedTokenAmount.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
Stack,
33
StackProps,
4+
Tooltip,
45
Typography,
56
TypographyProps,
67
} from '@avalabs/k2-alpine';
@@ -66,21 +67,23 @@ export const CollapsedTokenAmount = ({
6667

6768
if (fraction && indexOfNonZero) {
6869
return (
69-
<Stack
70-
direction="row"
71-
width="100%"
72-
justifyContent="flex-end"
73-
{...stackProps}
74-
>
75-
<Typography {...finalRegularProps}>{integer}.0</Typography>
76-
<Typography {...finalOverlineProps}>{zeroCount}</Typography>
77-
<Typography {...finalRegularProps}>
78-
{fraction.slice(
79-
indexOfNonZero,
80-
indexOfNonZero + MAX_DIGITS_AFTER_CONSECUTIVE_ZEROES,
81-
)}
82-
</Typography>
83-
</Stack>
70+
<Tooltip title={amount}>
71+
<Stack
72+
direction="row"
73+
width="100%"
74+
justifyContent="flex-end"
75+
{...stackProps}
76+
>
77+
<Typography {...finalRegularProps}>{integer}.0</Typography>
78+
<Typography {...finalOverlineProps}>{zeroCount}</Typography>
79+
<Typography {...finalRegularProps}>
80+
{fraction.slice(
81+
indexOfNonZero,
82+
indexOfNonZero + MAX_DIGITS_AFTER_CONSECUTIVE_ZEROES,
83+
)}
84+
</Typography>
85+
</Stack>
86+
</Tooltip>
8487
);
8588
}
8689
return <Typography {...finalRegularProps}>{amount}</Typography>;

apps/next/src/components/Forms/InvisibleInput.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ const NAME_INPUT_STYLES = {
1010
textAlign: 'center',
1111
} as const;
1212

13-
const InvisibileInput = styled('input')(({ theme }) => ({
13+
export const InvisibileInput = styled('input')(({ theme }) => ({
1414
background: 'transparent',
1515
border: 0,
1616
paddingInline: theme.spacing(2),
1717
lineHeight: 1,
1818
outline: 'none',
1919
color: theme.palette.text.primary,
2020
textOverflow: 'ellipsis',
21+
'&::-webkit-outer-spin-button, &::-webkit-inner-spin-button': {
22+
'-webkit-appearance': 'none',
23+
margin: 0,
24+
},
25+
'input[type=number]': {
26+
'-moz-appearance': 'textfield',
27+
},
2128
}));
2229

2330
export const InvisibleNameInput = styled(InvisibileInput)(NAME_INPUT_STYLES);

apps/next/src/config/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { TransactionPriority } from '@core/types';
2+
13
export const CORE_WEB_BASE_URL =
24
process.env.CORE_WEB_BASE_URL ?? 'https://core.app';
35
export const BUG_BOUNTIES_URL =
@@ -9,3 +11,6 @@ export const CORE_FEEDBACK_URL =
911
'https://docs.google.com/forms/d/e/1FAIpQLSdUQiVnJoqQ1g_6XTREpkSB5vxKKK8ba5DRjhzQf1XVeET8Rw/viewform?usp=pp_url&entry.2070152111=Core%20browser%20extension&entry.903657115=${extensionVersion}&entry.1148340936=${os}';
1012

1113
export const DARK_THEME_SURFACE_COLOR = '#404046';
14+
15+
export const DEFAULT_FEE_PRESET: TransactionPriority = 'low';
16+
export const DEFAULT_FEE_PRESET_C_CHAIN: TransactionPriority = 'high';
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NetworkFee, NetworkWithCaipId } from '@core/types';
2+
import { useEffect, useState } from 'react';
3+
4+
import { useNetworkFeeContext } from '@core/ui';
5+
6+
export const useCurrentFeesForNetwork = (network: NetworkWithCaipId) => {
7+
const { getNetworkFee } = useNetworkFeeContext();
8+
9+
const [networkFee, setNetworkFee] = useState<NetworkFee | null>();
10+
11+
useEffect(() => {
12+
getNetworkFee(network.caipId).then(setNetworkFee);
13+
}, [getNetworkFee, network]);
14+
15+
return networkFee;
16+
};

apps/next/src/hooks/useMaxAmountForTokenSend/useMaxAmountForTokenSend.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ export const useMaxAmountForTokenSend = (
4949
useEffect(() => {
5050
if (!token || !from) return;
5151

52-
let isMounted = true;
53-
5452
getNetworkFee(token.coreChainId)
5553
.then((networkFee) => {
56-
if (!networkFee || !isMounted) {
54+
if (!networkFee) {
5755
return;
5856
}
5957

@@ -66,19 +64,19 @@ export const useMaxAmountForTokenSend = (
6664
from.addressBTC,
6765
to,
6866
getNetwork(token.coreChainId),
69-
).then((res) => isMounted && setResult(res));
67+
).then(setResult);
7068
} else if (isAvmCapableAccount(from) && isXChainToken(token)) {
7169
getXChainMaxAmount(
7270
from,
7371
isLedgerWallet,
7472
getNetwork(token.coreChainId),
75-
).then((res) => isMounted && setResult(res));
73+
).then(setResult);
7674
} else if (isPvmCapableAccount(from) && isPChainToken(token)) {
7775
getPChainMaxAmount(
7876
from,
7977
isLedgerWallet,
8078
getNetwork(token.coreChainId),
81-
).then((res) => isMounted && setResult(res));
79+
).then(setResult);
8280
} else if (
8381
isSvmCapableAccount(from) &&
8482
(isSolanaNativeToken(token) || isSolanaSplToken(token))
@@ -98,10 +96,6 @@ export const useMaxAmountForTokenSend = (
9896
error,
9997
);
10098
});
101-
102-
return () => {
103-
isMounted = false;
104-
};
10599
}, [token, getNetworkFee, from, to, getNetwork, isLedgerWallet]);
106100

107101
return result;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { useMemo } from 'react';
2+
import { TokenType } from '@avalabs/vm-module-types';
3+
4+
import { NativeTokenBalance, NetworkWithCaipId } from '@core/types';
5+
import { useTokensWithBalances } from '@core/ui';
6+
7+
type UseNativeTokenArgs = { network: NetworkWithCaipId };
8+
9+
export const useNativeToken = ({ network }: UseNativeTokenArgs) => {
10+
const tokens = useTokensWithBalances({ network });
11+
12+
return useMemo(
13+
() => tokens.find(({ type }) => type === TokenType.NATIVE),
14+
[tokens],
15+
) as NativeTokenBalance;
16+
};

0 commit comments

Comments
 (0)