Skip to content

Commit 5d0d34a

Browse files
committed
Enable hardware accounts for transaction confirmations
1 parent 1393baa commit 5d0d34a

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

app/components/Views/confirmations/context/ledger-context/ledger-context.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
isHardwareAccount,
1515
} from '../../../../../util/address';
1616
import useApprovalRequest from '../../hooks/useApprovalRequest';
17+
import { useTransactionMetadataRequest } from '../../hooks/transactions/useTransactionMetadataRequest';
1718
import LedgerSignModal from '../../components/modals/ledger-sign-modal';
1819

1920
export interface LedgerContextType {
@@ -36,7 +37,10 @@ export const LedgerContextProvider: React.FC<{
3637
children: ReactElement[] | ReactElement;
3738
}> = ({ children }) => {
3839
const { approvalRequest } = useApprovalRequest();
39-
const fromAddress = approvalRequest?.requestData?.from as string;
40+
const transactionMetadata = useTransactionMetadataRequest();
41+
const fromAddress =
42+
(approvalRequest?.requestData?.from as string) ||
43+
(transactionMetadata?.txParams?.from as string);
4044
const isLedgerAccount =
4145
isHardwareAccount(fromAddress, [ExtendedKeyringTypes.ledger]) ?? false;
4246
const [ledgerSigningInProgress, setLedgerSigningInProgress] =

app/components/Views/confirmations/hooks/useConfirmationRedesignEnabled.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe('useConfirmationRedesignEnabled', () => {
183183
expect(result.current.isRedesignedEnabled).toBe(false);
184184
});
185185

186-
it('returns false when from address is external hardware account', async () => {
186+
it('returns true when from address is external hardware account', async () => {
187187
confirmationRedesignFlagsMock.mockReturnValue({
188188
...disabledFeatureFlags,
189189
signatures: true,
@@ -198,7 +198,7 @@ describe('useConfirmationRedesignEnabled', () => {
198198
},
199199
);
200200

201-
expect(result.current.isRedesignedEnabled).toBe(false);
201+
expect(result.current.isRedesignedEnabled).toBe(true);
202202
});
203203

204204
it('only redesign if transactions is staking deposit', async () => {

app/components/Views/confirmations/hooks/useConfirmationRedesignEnabled.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
ConfirmationRedesignRemoteFlags,
1111
selectConfirmationRedesignFlags,
1212
} from '../../../../selectors/featureFlagController/confirmations';
13-
import { isHardwareAccount } from '../../../../util/address';
1413
import { isStakingConfirmation } from '../utils/confirm';
1514
import {
1615
REDESIGNED_APPROVE_TYPES,
@@ -39,12 +38,10 @@ function isRedesignedSignature({
3938
function isRedesignedTransaction({
4039
approvalRequestType,
4140
confirmationRedesignFlags,
42-
fromAddress,
4341
transactionMetadata,
4442
}: {
4543
approvalRequestType: ApprovalType;
4644
confirmationRedesignFlags: ConfirmationRedesignRemoteFlags;
47-
fromAddress: string;
4845
transactionMetadata?: TransactionMeta;
4946
}) {
5047
const transactionType = transactionMetadata?.type as TransactionType;
@@ -54,8 +51,7 @@ function isRedesignedTransaction({
5451
if (
5552
!isTransactionTypeRedesigned ||
5653
approvalRequestType !== ApprovalType.Transaction ||
57-
!transactionMetadata ||
58-
isHardwareAccount(fromAddress)
54+
!transactionMetadata
5955
) {
6056
return false;
6157
}
@@ -114,7 +110,6 @@ export const useConfirmationRedesignEnabled = () => {
114110
isRedesignedTransaction({
115111
approvalRequestType,
116112
confirmationRedesignFlags,
117-
fromAddress,
118113
transactionMetadata,
119114
}) ||
120115
isBatchTransaction(approvalRequestType),

app/components/Views/confirmations/legacy/SendFlow/Amount/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { connect } from 'react-redux';
1515
import {
1616
setSelectedAsset,
1717
prepareTransaction,
18-
setTransactionObject,
1918
resetTransaction,
2019
setMaxValueMode,
2120
} from '../../../../../../actions/transaction';
@@ -707,8 +706,7 @@ class Amount extends PureComponent {
707706
);
708707

709708
const shouldUseRedesignedTransferConfirmation =
710-
isRedesignedTransferConfirmationEnabledForTransfer &&
711-
!isHardwareAccount(transaction.from);
709+
isRedesignedTransferConfirmationEnabledForTransfer;
712710

713711
setSelectedAsset(selectedAsset);
714712
if (onConfirm) {

app/components/Views/confirmations/legacy/SendFlow/Amount/index.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { AmountViewSelectorsIDs } from '../../../../../../../e2e/selectors/SendF
1111
import { backgroundState } from '../../../../../../util/test/initial-root-state';
1212
import { setMaxValueMode } from '../../../../../../actions/transaction';
1313
import Routes from '../../../../../../constants/navigation/Routes';
14-
import { isHardwareAccount } from '../../../../../../util/address';
1514

1615
const mockTransactionTypes = TransactionTypes;
1716

@@ -229,14 +228,12 @@ describe('Amount', () => {
229228
const mockSelectConfirmationRedesignFlags = jest.mocked(
230229
selectConfirmationRedesignFlags,
231230
);
232-
const mockIsHardwareAccount = jest.mocked(isHardwareAccount);
233231

234232
beforeEach(() => {
235233
mockNavigate.mockClear();
236234
mockSelectConfirmationRedesignFlags.mockReturnValue({
237235
transfer: false,
238236
} as ReturnType<typeof selectConfirmationRedesignFlags>);
239-
mockIsHardwareAccount.mockReturnValue(false);
240237
});
241238

242239
it('renders correctly', () => {

0 commit comments

Comments
 (0)