Skip to content

Commit 0dff127

Browse files
authored
Merge branch 'main' into predict/add-wold-cup
2 parents 46961db + f3a256d commit 0dff127

37 files changed

Lines changed: 1610 additions & 531 deletions
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
diff --git a/dist/bridge-status-controller.cjs b/dist/bridge-status-controller.cjs
2+
index c8dcd1f18fd4395b13ac7945e533ae1a92553950..ced9b35dc96c65ffe7ac59d198f4ab2737ae24ac 100644
3+
--- a/dist/bridge-status-controller.cjs
4+
+++ b/dist/bridge-status-controller.cjs
5+
@@ -863,16 +863,27 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
6+
};
7+
// Record in bridge history with actual transaction metadata
8+
try {
9+
- // Create a bridge transaction metadata that includes the original txId
10+
+ /**
11+
+ * Patch to fix ondo swap activity tab status issue logged at
12+
+ * https://consensyssoftware.atlassian.net/browse/BETR-413
13+
+ *
14+
+ */
15+
+ // Create a bridge transaction metadata keyed by orderUid for intent polling
16+
const bridgeTxMetaForHistory = {
17+
...syntheticMeta,
18+
id: orderUid,
19+
- originalTransactionId: syntheticMeta.id, // Keep original txId for TransactionController updates
20+
};
21+
// Use orderId as the history key for intent transactions
22+
+ // IMPORTANT: pass originalTransactionId as a top-level argument so
23+
+ // `getInitialHistoryItem` reads it. Setting it on `bridgeTxMeta` is a no-op
24+
+ // because `getInitialHistoryItem` destructures `originalTransactionId` from
25+
+ // the top-level args, not from `bridgeTxMeta`. Without this, the field
26+
+ // falls back to `bridgeTxMeta.id` (the orderUid), severing the link between
27+
+ // the bridge history record and the synthetic TransactionController entry.
28+
const historyKey = __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
29+
accountAddress,
30+
bridgeTxMeta: bridgeTxMetaForHistory,
31+
+ originalTransactionId: syntheticMeta.id, // Keep original txId for TransactionController updates
32+
quoteResponse,
33+
slippagePercentage: 0,
34+
isStxEnabled: false,
35+
diff --git a/dist/bridge-status-controller.mjs b/dist/bridge-status-controller.mjs
36+
index 3c285a68a35e69b6898f5c811a000324044213c8..9e0b4ef973b167c39e142b60ca28cf32ea89f41a 100644
37+
--- a/dist/bridge-status-controller.mjs
38+
+++ b/dist/bridge-status-controller.mjs
39+
@@ -860,16 +860,27 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
40+
};
41+
// Record in bridge history with actual transaction metadata
42+
try {
43+
- // Create a bridge transaction metadata that includes the original txId
44+
+ /**
45+
+ * Patch to fix ondo swap activity tab status issue logged at
46+
+ * https://consensyssoftware.atlassian.net/browse/BETR-413
47+
+ *
48+
+ */
49+
+ // Create a bridge transaction metadata keyed by orderUid for intent polling
50+
const bridgeTxMetaForHistory = {
51+
...syntheticMeta,
52+
id: orderUid,
53+
- originalTransactionId: syntheticMeta.id, // Keep original txId for TransactionController updates
54+
};
55+
// Use orderId as the history key for intent transactions
56+
+ // IMPORTANT: pass originalTransactionId as a top-level argument so
57+
+ // `getInitialHistoryItem` reads it. Setting it on `bridgeTxMeta` is a no-op
58+
+ // because `getInitialHistoryItem` destructures `originalTransactionId` from
59+
+ // the top-level args, not from `bridgeTxMeta`. Without this, the field
60+
+ // falls back to `bridgeTxMeta.id` (the orderUid), severing the link between
61+
+ // the bridge history record and the synthetic TransactionController entry.
62+
const historyKey = __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
63+
accountAddress,
64+
bridgeTxMeta: bridgeTxMetaForHistory,
65+
+ originalTransactionId: syntheticMeta.id, // Keep original txId for TransactionController updates
66+
quoteResponse,
67+
slippagePercentage: 0,
68+
isStxEnabled: false,

app/components/UI/Card/hooks/useAssetBalances.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jest.mock('../../Ramp/Deposit/constants/networks', () => ({
6060
chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
6161
},
6262
}));
63-
jest.mock('../../../../util/number', () => ({
63+
jest.mock('../../../../util/number/bigint', () => ({
6464
balanceToFiatNumber: jest.fn((balance: string, rate: number) => {
6565
const bal = parseFloat(balance);
6666
return (bal * rate).toString();

app/components/UI/Card/hooks/useAssetBalances.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { useTokensWithBalance } from '../../Bridge/hooks/useTokensWithBalance';
88
import { isSolanaChainId } from '@metamask/bridge-controller';
99
import { selectCurrentCurrency } from '../../../../selectors/currencyRateController';
1010
import Engine from '../../../../core/Engine';
11-
import { balanceToFiatNumber } from '../../../../util/number';
1211
import { safeFormatChainIdToHex } from '../util/safeFormatChainIdToHex';
1312
import { TokenI } from '../../Tokens/types';
1413
import { MarketDataDetails } from '@metamask/assets-controllers';
@@ -17,6 +16,7 @@ import I18n from '../../../../../locales/i18n';
1716
import { deriveBalanceFromAssetMarketDetails } from '../../Tokens/util';
1817
import { buildTokenIconUrl } from '../util/buildTokenIconUrl';
1918
import { CARD_CHAIN_IDS } from '../constants';
19+
import { balanceToFiatNumber } from '../../../../util/number/bigint';
2020

2121
const extractTrailingCurrencyCode = (value: string): string | undefined => {
2222
const match = value.trim().match(/([A-Za-z]{3})$/);

app/components/UI/Card/hooks/useCardDelegation.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Logger from '../../../../util/Logger';
99
import { MetaMetricsEvents } from '../../../../core/Analytics';
1010
import { useAnalytics } from '../../../hooks/useAnalytics/useAnalytics';
1111
import { createMockUseAnalyticsHook } from '../../../../util/test/analyticsMock';
12-
import { toTokenMinimalUnit } from '../../../../util/number';
12+
import { toTokenMinimalUnit } from '../../../../util/number/bigint';
1313
import { safeToChecksumAddress } from '../../../../util/address';
1414
import { ARBITRARY_ALLOWANCE } from '../constants';
1515
import {
@@ -42,7 +42,7 @@ jest.mock('../../../../util/Logger', () => ({
4242
error: jest.fn(),
4343
}));
4444

45-
jest.mock('../../../../util/number', () => ({
45+
jest.mock('../../../../util/number/bigint', () => ({
4646
toTokenMinimalUnit: jest.fn(),
4747
}));
4848

@@ -223,7 +223,7 @@ describe('useCardDelegation', () => {
223223
});
224224

225225
// Setup utility mocks
226-
mockToTokenMinimalUnit.mockReturnValue('100000000000000000000');
226+
mockToTokenMinimalUnit.mockReturnValue(100000000000000000000n);
227227
mockSafeToChecksumAddress.mockImplementation(
228228
(address?: string) => (address as `0x${string}`) || undefined,
229229
);
@@ -401,7 +401,7 @@ describe('useCardDelegation', () => {
401401
const mockToken = createMockToken({ decimals: 6 });
402402
const params = createMockDelegationParams();
403403

404-
mockToTokenMinimalUnit.mockReturnValue('100000000');
404+
mockToTokenMinimalUnit.mockReturnValue(100000000n);
405405

406406
const { result } = renderHook(() => useCardDelegation(mockToken));
407407

@@ -1356,7 +1356,7 @@ describe('useCardDelegation', () => {
13561356
};
13571357

13581358
mockToTokenMinimalUnit.mockReturnValue(
1359-
'999999999999999999999999999000000000000000000',
1359+
999999999999999999999999999000000000000000000n,
13601360
);
13611361

13621362
const { result } = renderHook(() => useCardDelegation(mockToken));

app/components/UI/Card/hooks/useCardDelegation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { useAnalytics } from '../../../hooks/useAnalytics/useAnalytics';
2020
import { useEnsureCardNetworkExists } from './useEnsureCardNetworkExists';
2121
import { MetaMetricsEvents } from '../../../../core/Analytics';
2222
import { ARBITRARY_ALLOWANCE } from '../constants';
23-
import { toTokenMinimalUnit } from '../../../../util/number';
23+
import { toTokenMinimalUnit } from '../../../../util/number/bigint';
2424
import AppConstants from '../../../../core/AppConstants';
2525
import { safeToChecksumAddress } from '../../../../util/address';
2626
import { handleSnapRequest } from '../../../../core/Snaps/utils';

app/components/UI/Card/hooks/useNeedsGasFaucet.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';
44
import { isNonEvmChainId, isSolanaChainId } from '@metamask/bridge-controller';
55
import { Hex, CaipChainId } from '@metamask/utils';
66
import { BigNumber } from 'bignumber.js';
7-
import BN from 'bnjs4';
87
import Engine from '../../../../core/Engine';
98
import { useAccountNativeBalance } from '../../../Views/confirmations/hooks/useAccountNativeBalance';
109
import { selectMinSolBalance } from '../../../../selectors/bridgeController';
1110
import { selectSelectedInternalAccountFormattedAddress } from '../../../../selectors/accountsController';
1211
import { decGWEIToHexWEI } from '../../../../util/conversions';
13-
import { hexToBN } from '../../../../util/number';
12+
import { hexToBigInt } from '../../../../util/number/bigint';
1413
import { safeFormatChainIdToHex } from '../util/safeFormatChainIdToHex';
1514
import { CardFundingToken } from '../types';
1615
import { useLatestBalance } from '../../Bridge/hooks/useLatestBalance';
@@ -93,7 +92,7 @@ export const useNeedsGasFaucet = (
9392
/**
9493
* Estimate gas fee for EVM chains
9594
*/
96-
const estimateEvmGasFee = useCallback(async (): Promise<BN> => {
95+
const estimateEvmGasFee = useCallback(async (): Promise<bigint> => {
9796
try {
9897
const { GasFeeController } = Engine.context;
9998
const result = await GasFeeController.fetchGasFeeEstimates();
@@ -120,16 +119,16 @@ export const useNeedsGasFaucet = (
120119
break;
121120
}
122121

123-
const weiGasPrice = hexToBN(decGWEIToHexWEI(gasPrice));
124-
return weiGasPrice.muln(gasLimitWithBuffer);
122+
const weiGasPrice = hexToBigInt(decGWEIToHexWEI(gasPrice) as string);
123+
return weiGasPrice * BigInt(gasLimitWithBuffer);
125124
} catch (err) {
126125
// Return a conservative fallback estimate if gas estimation fails
127126
// Assume ~20 Gwei gas price as fallback
128-
const fallbackGasPrice = new BN('20000000000'); // 20 Gwei in Wei
127+
const fallbackGasPrice = 20000000000n; // 20 Gwei in Wei
129128
const gasLimitWithBuffer = Math.ceil(
130129
ERC20_APPROVE_GAS_LIMIT * GAS_LIMIT_BUFFER,
131130
);
132-
return fallbackGasPrice.muln(gasLimitWithBuffer);
131+
return fallbackGasPrice * BigInt(gasLimitWithBuffer);
133132
}
134133
}, []);
135134

@@ -144,10 +143,10 @@ export const useNeedsGasFaucet = (
144143

145144
try {
146145
const estimatedGasFee = await estimateEvmGasFee();
147-
const balanceBN = new BN(balanceWeiInHex.replace('0x', ''), 'hex');
146+
const balance = hexToBigInt(balanceWeiInHex);
148147

149148
// User needs faucet if balance is less than estimated gas fee
150-
return balanceBN.lt(estimatedGasFee);
149+
return balance < estimatedGasFee;
151150
} catch (err) {
152151
console.error('Error checking EVM faucet need:', err);
153152
// Assume needs faucet on error

app/components/UI/Earn/hooks/useTronClaimUnstakedTrx.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ describe('useTronClaimUnstakedTrx', () => {
2929
name: 'Tron Account',
3030
snap: {
3131
id: 'npm:@metamask/tron-wallet-snap',
32-
name: 'Tron Wallet Snap',
33-
enabled: true,
3432
},
3533
importTime: 0,
3634
keyring: { type: 'snap' },

0 commit comments

Comments
 (0)