-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: add tempo transactions support on Mobile #27142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
256129e
d85f948
df3c761
8e9488b
001cf69
279da5a
2458ca1
c5b8b84
2512f8a
b58e67d
39e7df1
700827a
a80facd
3067458
61271f9
b7dc473
c8c4b28
ce049d3
4ca642a
16e149c
f338bb8
00a09e1
89667cf
f9be910
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import React, { useCallback, useState } from 'react'; | ||
| import React, { useCallback, useMemo, useState } from 'react'; | ||
| import { TouchableOpacity } from 'react-native'; | ||
| import Icon, { | ||
| IconName, | ||
|
|
@@ -13,16 +13,20 @@ | |
| import { useTransactionMetadataRequest } from '../../../hooks/transactions/useTransactionMetadataRequest'; | ||
| import { useIsInsufficientBalance } from '../../../hooks/useIsInsufficientBalance'; | ||
| import { useTransactionBatchesMetadata } from '../../../hooks/transactions/useTransactionBatchesMetadata'; | ||
| import useNetworkInfo from '../../../hooks/useNetworkInfo'; | ||
| import { GasFeeTokenIcon, GasFeeTokenIconSize } from '../gas-fee-token-icon'; | ||
| import { GasFeeTokenModal } from '../gas-fee-token-modal'; | ||
| import styleSheet from './selected-gas-fee-token.styles'; | ||
| import { useNativeCurrencySymbol } from '../../../hooks/useNativeCurrencySymbol'; | ||
|
|
||
| export function SelectedGasFeeToken() { | ||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
| const transactionMetadata = useTransactionMetadataRequest(); | ||
| const transactionBatchesMetadata = useTransactionBatchesMetadata(); | ||
| const { chainId: chainIdSingle, gasFeeTokens } = transactionMetadata || {}; | ||
| const { | ||
| chainId: chainIdSingle, | ||
| gasFeeTokens, | ||
| excludeNativeTokenForFee, | ||
| } = transactionMetadata || {}; | ||
| const { chainId: chainIdBatch } = transactionBatchesMetadata || {}; | ||
| const chainId = chainIdSingle ?? chainIdBatch; | ||
| const hasGasFeeTokens = Boolean(gasFeeTokens?.length); | ||
|
|
@@ -50,19 +54,34 @@ | |
| hasGasFeeTokens && | ||
| (!hasOnlyFutureNativeToken || supportsFutureNative); | ||
|
|
||
| const { networkNativeCurrency: nativeCurrency } = useNetworkInfo(chainId); | ||
| const nonNativeGasFeeTokensLength = useMemo( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since in all other EVM blockchains, the native token is implicitly always an option, we calculate an alternative that doesn't count the native token for chains without any.
|
||
| () => | ||
| ( | ||
| gasFeeTokens?.filter( | ||
| (token) => | ||
| token.tokenAddress && token.tokenAddress !== NATIVE_TOKEN_ADDRESS, | ||
| ) ?? [] | ||
| ).length, | ||
| [gasFeeTokens], | ||
| ); | ||
| // Disable fee token choice selection if only 1 token available. | ||
| // Taking in account networks that don't have a native token. | ||
| const hasMoreThanOneGasFeeTokenToChooseFrom = excludeNativeTokenForFee | ||
| ? supportsGasFeeTokens && nonNativeGasFeeTokensLength > 1 | ||
| : supportsGasFeeTokens; | ||
|
|
||
| const { nativeCurrencySymbol } = useNativeCurrencySymbol(chainId); | ||
|
|
||
| const handlePress = useCallback(() => { | ||
| if (!supportsGasFeeTokens) { | ||
| if (!hasMoreThanOneGasFeeTokenToChooseFrom) { | ||
| return; | ||
| } | ||
|
|
||
| setIsModalOpen(true); | ||
| }, [supportsGasFeeTokens]); | ||
| }, [hasMoreThanOneGasFeeTokenToChooseFrom]); | ||
|
|
||
| const nativeTicker = nativeCurrency; | ||
| const gasFeeToken = useSelectedGasFeeToken(); | ||
| const symbol = gasFeeToken?.symbol ?? nativeTicker; | ||
| const gasTokenSymbol = gasFeeToken?.symbol ?? nativeCurrencySymbol; | ||
|
|
||
| return ( | ||
| <> | ||
|
|
@@ -73,14 +92,14 @@ | |
| onPress={handlePress} | ||
| style={styles.gasFeeTokenButton} | ||
| testID="selected-gas-fee-token" | ||
| disabled={!supportsGasFeeTokens} | ||
| disabled={!hasMoreThanOneGasFeeTokenToChooseFrom} | ||
| > | ||
| <GasFeeTokenIcon | ||
| tokenAddress={gasFeeToken?.tokenAddress ?? NATIVE_TOKEN_ADDRESS} | ||
| size={GasFeeTokenIconSize.Sm} | ||
| /> | ||
| <Text testID="selected-gas-fee-token-symbol">{symbol}</Text> | ||
| {supportsGasFeeTokens && ( | ||
| <Text testID="selected-gas-fee-token-symbol">{gasTokenSymbol}</Text> | ||
|
Check warning on line 101 in app/components/Views/confirmations/components/gas/selected-gas-fee-token/selected-gas-fee-token.tsx
|
||
| {hasMoreThanOneGasFeeTokenToChooseFrom && ( | ||
| <Icon | ||
| testID="selected-gas-fee-token-arrow" | ||
| name={IconName.ArrowDown} | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.