From a96c4fa057a7956b890858fb54d47fe95268e245 Mon Sep 17 00:00:00 2001 From: Leon Date: Wed, 9 Oct 2024 11:10:53 +0800 Subject: [PATCH] fix: Babylon staking issue (#5955) * fix: pro sign * fix: psbt decodedTx * fix: send comfirm amount issues --------- Co-authored-by: weatherstar --- packages/kit-bg/src/vaults/impls/ada/settings.ts | 1 + packages/kit-bg/src/vaults/impls/btc/KeyringHardware.ts | 2 +- packages/kit-bg/src/vaults/types.ts | 2 ++ packages/kit/src/components/TxAction/TxActionTransfer.tsx | 5 ++--- .../views/Send/pages/SendConfirm/TxActionsContainer.tsx | 7 +++++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/kit-bg/src/vaults/impls/ada/settings.ts b/packages/kit-bg/src/vaults/impls/ada/settings.ts index 08ae1eac2ec..fd7314eec7d 100644 --- a/packages/kit-bg/src/vaults/impls/ada/settings.ts +++ b/packages/kit-bg/src/vaults/impls/ada/settings.ts @@ -45,6 +45,7 @@ const settings: IVaultSettings = { editFeeEnabled: false, replaceTxEnabled: false, estimatedFeePollingInterval: 600, + maxSendCanNotSentFullAmount: true, accountDeriveInfo, networkInfo: { diff --git a/packages/kit-bg/src/vaults/impls/btc/KeyringHardware.ts b/packages/kit-bg/src/vaults/impls/btc/KeyringHardware.ts index 4f1012e9c55..b8b5478f6ca 100644 --- a/packages/kit-bg/src/vaults/impls/btc/KeyringHardware.ts +++ b/packages/kit-bg/src/vaults/impls/btc/KeyringHardware.ts @@ -266,7 +266,7 @@ export class KeyringHardware extends KeyringHardwareBase { const signedPsbt = response.psbt; let rawTx = ''; - const finalizedPsbt = BitcoinJS.Psbt.fromHex(psbt.toHex(), { + const finalizedPsbt = BitcoinJS.Psbt.fromHex(signedPsbt, { network: btcNetwork, }); inputsToSign.forEach((v) => { diff --git a/packages/kit-bg/src/vaults/types.ts b/packages/kit-bg/src/vaults/types.ts index b3e8b80b4d2..62ead9b1776 100644 --- a/packages/kit-bg/src/vaults/types.ts +++ b/packages/kit-bg/src/vaults/types.ts @@ -222,6 +222,8 @@ export type IVaultSettings = { [networkId: string]: number; }; + maxSendCanNotSentFullAmount?: boolean; + preCheckDappTxFeeInfoRequired?: boolean; activateTokenRequired?: boolean; diff --git a/packages/kit/src/components/TxAction/TxActionTransfer.tsx b/packages/kit/src/components/TxAction/TxActionTransfer.tsx index 29396154e79..318465ed192 100644 --- a/packages/kit/src/components/TxAction/TxActionTransfer.tsx +++ b/packages/kit/src/components/TxAction/TxActionTransfer.tsx @@ -18,6 +18,7 @@ import { useAccountData } from '@onekeyhq/kit/src/hooks/useAccountData'; import { useSettingsPersistAtom } from '@onekeyhq/kit-bg/src/states/jotai/atoms'; import { ETranslations } from '@onekeyhq/shared/src/locale'; import accountUtils from '@onekeyhq/shared/src/utils/accountUtils'; +import networkUtils from '@onekeyhq/shared/src/utils/networkUtils'; import { EOnChainHistoryTxType } from '@onekeyhq/shared/types/history'; import { EDecodedTxDirection, @@ -569,8 +570,7 @@ function TxActionTransferDetailView(props: ITxActionProps) { isSendNativeToken && !isNil(nativeTokenTransferAmountToUpdate) && transfer.isNative && - block.direction === EDecodedTxDirection.OUT && - !isUTXO + block.direction === EDecodedTxDirection.OUT ? nativeTokenTransferAmountToUpdate : transfer.amount } ${ @@ -809,7 +809,6 @@ function TxActionTransferDetailView(props: ITxActionProps) { intl, isInternalStaking, isSendNativeToken, - isUTXO, nativeTokenTransferAmountToUpdate, network?.id, network?.logoURI, diff --git a/packages/kit/src/views/Send/pages/SendConfirm/TxActionsContainer.tsx b/packages/kit/src/views/Send/pages/SendConfirm/TxActionsContainer.tsx index 994d7c5cf46..584a52b9cf6 100644 --- a/packages/kit/src/views/Send/pages/SendConfirm/TxActionsContainer.tsx +++ b/packages/kit/src/views/Send/pages/SendConfirm/TxActionsContainer.tsx @@ -89,7 +89,10 @@ function TxActionsContainer(props: IProps) { isSendNativeTokenOnly = true; } - if (isSendNativeTokenOnly && !vaultSettings?.isUtxo) { + if ( + isSendNativeTokenOnly && + !vaultSettings?.maxSendCanNotSentFullAmount + ) { nativeTokenTransferBN = new BigNumber( transferPayload?.amountToSend ?? nativeTokenTransferBN, ); @@ -145,7 +148,7 @@ function TxActionsContainer(props: IProps) { updateNativeTokenTransferAmount, updateNativeTokenTransferAmountToUpdate, vaultSettings?.ignoreUpdateNativeAmount, - vaultSettings?.isUtxo, + vaultSettings?.maxSendCanNotSentFullAmount, vaultSettings?.maxSendFeeUpRatio, ]);