Skip to content

Commit 8b153cd

Browse files
committed
fix: pipeline
1 parent 28102bc commit 8b153cd

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

shared/lib/transactions.utils.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { NestedTransactionMetadata } from '@metamask/transaction-controller';
2+
import { isBatchTransaction } from './transactions.utils';
3+
4+
describe('Transactions utils', () => {
5+
describe('isBatchTransaction', () => {
6+
it('returns true when nestedTransactions has items', () => {
7+
const nested: NestedTransactionMetadata[] = [
8+
{ to: '0x1', data: '0x' },
9+
];
10+
expect(isBatchTransaction(nested)).toBe(true);
11+
});
12+
13+
it('returns false when nestedTransactions is empty', () => {
14+
expect(isBatchTransaction([])).toBe(false);
15+
});
16+
17+
it('returns false when nestedTransactions is undefined', () => {
18+
expect(isBatchTransaction(undefined)).toBe(false);
19+
});
20+
});
21+
});

shared/lib/transactions.utils.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NestedTransactionMetadata } from "@metamask/transaction-controller";
2+
3+
/**
4+
* Determines if a transaction is a batch transaction.
5+
*
6+
* @param nestedTransactions - An array of nested transaction.
7+
* @returns A boolean indicating whether the transaction is a batch transaction.
8+
*/
9+
export function isBatchTransaction(
10+
nestedTransactions: NestedTransactionMetadata[] | undefined,
11+
): boolean {
12+
return Boolean(nestedTransactions?.length)
13+
;
14+
}

ui/pages/confirmations/hooks/alerts/transactions/AccountTypeMessage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function AccountTypeMessage() {
2020
rel="noreferrer noopener"
2121
color={TextColor.primaryDefault}
2222
>
23-
{t('learnMore')}
23+
{t('learnMoreUpperCaseWithDot')}
2424
</ButtonLink>,
2525
])}
2626
</Text>

ui/pages/confirmations/hooks/alerts/transactions/useAccountTypeUpgrade.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import { getMockConfirmStateForTransaction } from '../../../../../../test/data/c
99
import { renderHookWithConfirmContextProvider } from '../../../../../../test/lib/confirmations/render-helpers';
1010
import { AccountTypeMessage } from './AccountTypeMessage';
1111
import { useAccountTypeUpgrade } from './useAccountTypeUpgrade';
12+
import { isBatchTransaction } from '../../../../../../shared/lib/transactions.utils';
1213

1314
jest.mock('../../../../../../shared/lib/transactions.utils');
1415

1516
const FROM_MOCK = '0x1234567890abcdef1234567890abcdef12345678';
1617
const TO_MOCK = '0x1234567890abcdef1234567890abcdef12345678';
17-
const NESTED_TRANSACTIONS_MOCK = [{ data: '0x', to: TO_MOCK, from: FROM_MOCK }];
18+
const NESTED_TRANSACTIONS_MOCK = [{ data: '0x', to: TO_MOCK }];
1819
const ACCOUNT_ADDRESS_MOCK = '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc';
1920
const TRANSACTION_ID_MOCK = '123-456';
2021

@@ -48,6 +49,7 @@ function runHook({
4849
}
4950

5051
describe('useAccountTypeUpgrade', () => {
52+
const isBatchTransactionMock = jest.mocked(isBatchTransaction);
5153
beforeEach(() => {
5254
jest.resetAllMocks();
5355
});
@@ -57,6 +59,7 @@ describe('useAccountTypeUpgrade', () => {
5759
});
5860

5961
it('returns an alert when the transaction is a batch transaction', () => {
62+
isBatchTransactionMock.mockReturnValue(true)
6063
expect(
6164
runHook({
6265
currentConfirmation: {

ui/pages/confirmations/hooks/alerts/transactions/useAccountTypeUpgrade.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import { Alert } from '../../../../../ducks/confirm-alerts/confirm-alerts';
66
import { RowAlertKey } from '../../../../../components/app/confirm/info/row/constants';
77
import { Severity } from '../../../../../helpers/constants/design-system';
88
import { AccountTypeMessage } from './AccountTypeMessage';
9+
import { isBatchTransaction } from '../../../../../../shared/lib/transactions.utils';
910

1011
export function useAccountTypeUpgrade(): Alert[] {
1112
const t = useI18nContext();
1213
const { currentConfirmation } = useConfirmContext<TransactionMeta>();
1314
const { nestedTransactions } = currentConfirmation ?? {};
1415

15-
const isBatch = Boolean(nestedTransactions?.length);
16+
const isBatch = isBatchTransaction(nestedTransactions);
1617

1718
return useMemo(() => {
1819
if (!isBatch) {

0 commit comments

Comments
 (0)