diff --git a/src/components/MetaInfo/parts/AccountItem.tsx b/src/components/MetaInfo/parts/AccountItem.tsx index 4f79ca11f..64ce37aad 100644 --- a/src/components/MetaInfo/parts/AccountItem.tsx +++ b/src/components/MetaInfo/parts/AccountItem.tsx @@ -5,15 +5,10 @@ import MetaInfoStyles from 'components/MetaInfo/style'; import useGeneralStyles from 'components/MetaInfo/hooks/useGeneralStyles'; import { getSchemaColor, renderColContent } from 'components/MetaInfo/shared'; import { View } from 'react-native'; -import { useSelector } from 'react-redux'; import useGetAccountByAddress from 'hooks/screen/useGetAccountByAddress'; -import { RootState } from 'stores/index'; -import { findNetworkJsonByGenesisHash } from 'utils/getNetworkJsonByGenesisHash'; import { toShort } from 'utils/index'; import Typography from '../../design-system-ui/typography'; import { AccountProxyAvatar } from 'components/design-system-ui/avatar/account-proxy-avatar'; -import { isAddress } from '@subwallet/keyring'; -import { reformatAddress } from '@subwallet/extension-base/utils'; export interface AccountInfoItem extends InfoItemBase { address: string; @@ -26,41 +21,18 @@ const AccountItem: React.FC = ({ label, address: accountAddress, name: accountName, - networkPrefix: addressPrefix, }: AccountInfoItem) => { const theme = useSubWalletTheme().swThemes; const _style = MetaInfoStyles(theme); const { labelGeneralStyle, valueGeneralStyle } = useGeneralStyles(theme); - const chainInfoMap = useSelector((state: RootState) => state.chainStore.chainInfoMap); - const account = useGetAccountByAddress(accountAddress); const name = useMemo(() => { return accountName || account?.name; }, [account?.name, accountName]); - const address = useMemo(() => { - let addPrefix = 42; - - if (addressPrefix !== undefined) { - addPrefix = addressPrefix; - } - - if (account?.originGenesisHash) { - const network = findNetworkJsonByGenesisHash(chainInfoMap, account.originGenesisHash); - - if (network) { - addPrefix = network.substrateInfo?.addressPrefix ?? addPrefix; - } - } - - if (!accountAddress || !isAddress(accountAddress)) { - return accountAddress; - } - - return reformatAddress(accountAddress, addPrefix); - }, [account, accountAddress, addressPrefix, chainInfoMap]); + const shortAddress = toShort(accountAddress); const valueStyle = useMemo(() => { return { @@ -87,7 +59,7 @@ const AccountItem: React.FC = ({ - + {!!name && ( @@ -95,7 +67,7 @@ const AccountItem: React.FC = ({ )} - {toShort(address)} + {shortAddress} diff --git a/src/providers/DataContext.tsx b/src/providers/DataContext.tsx index 56eef1cc9..adcd21362 100644 --- a/src/providers/DataContext.tsx +++ b/src/providers/DataContext.tsx @@ -49,6 +49,7 @@ import { subscribeCampaignPopupData, subscribeCampaignBannerData, subscribeCampaignConfirmationData, + subscribeConfirmationRequestsTon, } from 'stores/utils'; import React, { useContext, useEffect, useRef } from 'react'; import { Provider } from 'react-redux'; @@ -355,6 +356,12 @@ export const DataContextProvider = ({ children }: DataContextProviderProps) => { relatedStores: ['requestState'], isStartImmediately: true, }); + _DataContext.addHandler({ + ...subscribeConfirmationRequestsTon, + name: 'subscribeConfirmationRequestsTon', + relatedStores: ['requestState'], + isStartImmediately: true, + }); _DataContext.addHandler({ ...subscribeTransactionRequests, name: 'subscribeTransactionRequests', diff --git a/src/screens/Confirmations/parts/Sign/Ton.tsx b/src/screens/Confirmations/parts/Sign/Ton.tsx index c51164c8b..43643900c 100644 --- a/src/screens/Confirmations/parts/Sign/Ton.tsx +++ b/src/screens/Confirmations/parts/Sign/Ton.tsx @@ -80,13 +80,13 @@ export const TonSignArea = (props: Props) => { show('Transaction expired', { type: 'danger' }); onCancel(); } - - setLoading(true); - Platform.OS === 'android' && setTimeout(() => DeviceEventEmitter.emit(OPEN_UNLOCK_FROM_MODAL), 250); - onConfirmPassword(onApprovePassword)()?.catch(() => { - setLoading(false); - }); } + + setLoading(true); + Platform.OS === 'android' && setTimeout(() => DeviceEventEmitter.emit(OPEN_UNLOCK_FROM_MODAL), 250); + onConfirmPassword(onApprovePassword)()?.catch(() => { + setLoading(false); + }); }, [hideAll, onApprovePassword, onCancel, onConfirmPassword, show, txExpirationTime]); useEffect(() => { @@ -111,7 +111,12 @@ export const TonSignArea = (props: Props) => { - diff --git a/src/screens/Transaction/SendFund/index.tsx b/src/screens/Transaction/SendFund/index.tsx index 88e7d3067..29538a6c7 100644 --- a/src/screens/Transaction/SendFund/index.tsx +++ b/src/screens/Transaction/SendFund/index.tsx @@ -512,7 +512,7 @@ export const SendFund = ({ ); const handleBasicSubmit = useCallback( - (values: TransferFormValues): Promise => { + (values: TransferFormValues, options: TransferOptions): Promise => { const { asset, chain, destChain, from: _from, to, value } = values; let sendPromise: Promise; @@ -527,6 +527,7 @@ export const SendFund = ({ tokenSlug: asset, value: value, transferAll: isTransferAll, + transferBounceable: options.isTransferBounceable, }); } else { // Make cross chain transfer @@ -538,6 +539,7 @@ export const SendFund = ({ to, value, transferAll: isTransferAll, + transferBounceable: options.isTransferBounceable, }); } @@ -580,7 +582,7 @@ export const SendFund = ({ ); const doSubmit = useCallback( - (values: TransferFormValues) => { + (values: TransferFormValues, options: TransferOptions) => { if (isShowWarningOnSubmit(values)) { return; } @@ -612,7 +614,7 @@ export const SendFund = ({ const submitPromise: Promise | undefined = stepType === CommonStepType.TOKEN_APPROVAL ? handleSnowBridgeSpendingApproval(values) - : handleBasicSubmit(values); + : handleBasicSubmit(values, options); const rs = await submitPromise; const success = onSuccess(isLastStep, needRollback)(rs); @@ -684,7 +686,7 @@ export const SendFund = ({ completeBtnTitle: 'Continue', customIcon: , onCompleteModal: () => { - doSubmit(values); + doSubmit(values, options); confirmModal.hideConfirmModal(); }, onCancelModal: () => confirmModal.hideConfirmModal(), @@ -713,7 +715,7 @@ export const SendFund = ({ shouldTouch: true, }); options.isTransferBounceable = true; - doSubmit({ ...values, to: formattedAddress }); + doSubmit({ ...values, to: formattedAddress }, options); confirmModal.hideConfirmModal(); }, onCancelModal: () => { @@ -732,7 +734,7 @@ export const SendFund = ({ return; } - doSubmit(values); + doSubmit(values, options); }, [isTransferAll, chainValue, destChainValue, doSubmit, chainInfoMap, confirmModal, theme.colorWarning, setValue], ); @@ -994,7 +996,7 @@ export const SendFund = ({ let currentValues = getValues(); setForceTransferAll(false); setLoading(true); - doSubmit(currentValues); + onSubmit(currentValues); }, }, ], @@ -1009,6 +1011,7 @@ export const SendFund = ({ nativeTokenBalance.decimals, nativeTokenBalance.symbol, nativeTokenSlug, + onSubmit, tokenBalance.decimals, tokenBalance.symbol, ]); diff --git a/src/stores/base/RequestState.ts b/src/stores/base/RequestState.ts index daf5d8b4e..b6bc24ef2 100644 --- a/src/stores/base/RequestState.ts +++ b/src/stores/base/RequestState.ts @@ -52,6 +52,9 @@ export const CONFIRMATIONS_FIELDS: Array = [ 'evmWatchTransactionRequest', 'errorConnectNetwork', 'connectWCRequest', + 'tonSignatureRequest', + 'tonSendTransactionRequest', + 'tonWatchTransactionRequest', ]; export interface ConfirmationQueueItem { diff --git a/src/stores/utils/index.ts b/src/stores/utils/index.ts index 32f522f32..281adbf56 100644 --- a/src/stores/utils/index.ts +++ b/src/stores/utils/index.ts @@ -9,6 +9,7 @@ import { CampaignBanner, ChainStakingMetadata, ConfirmationsQueue, + ConfirmationsQueueTon, CrowdloanJson, KeyringState, MantaPayConfig, @@ -187,6 +188,17 @@ export const subscribeConfirmationRequests = lazySubscribeMessage( updateConfirmationRequests, ); +export const updateConfirmationRequestsTon = (data: ConfirmationsQueueTon) => { + store.dispatch({ type: 'requestState/updateConfirmationRequestsTon', payload: data }); +}; + +export const subscribeConfirmationRequestsTon = lazySubscribeMessage( + 'pri(confirmationsTon.subscribe)', + null, + updateConfirmationRequestsTon, + updateConfirmationRequestsTon, +); + export const updateTransactionRequests = (data: Record) => { // Convert data to object with key as id