Skip to content

Commit 182e73d

Browse files
authored
Merge branch 'main' into predict/crypto-data-plumbing
2 parents 9a97c00 + 5bfd071 commit 182e73d

14 files changed

Lines changed: 108 additions & 169 deletions

File tree

app/components/UI/Bridge/_mocks_/bridgeControllerState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const optimismToken1Address =
1313
'0x0000000000000000000000000000000000000003' as Hex;
1414

1515
export const defaultBridgeControllerState = {
16-
quoteRequest: {},
16+
quoteRequest: [{}],
1717
quotes: [],
1818
quotesInitialLoadTime: null,
1919
quotesLastFetched: null,

app/components/UI/Bridge/hooks/useBridgeQuoteRequest/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export const useBridgeQuoteRequest = (
129129
await Engine.context.BridgeController.updateBridgeQuoteRequestParams(
130130
params,
131131
context,
132+
0,
133+
1,
132134
);
133135
}, [
134136
sourceToken,

app/components/UI/Bridge/hooks/useBridgeQuoteRequest/useBridgeQuoteRequest.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ describe('useBridgeQuoteRequest', () => {
253253
srcTokenAmount: '1500000000000000000', // 1.5 ETH in wei
254254
}),
255255
undefined,
256+
0,
257+
1,
256258
);
257259
});
258260

@@ -277,6 +279,8 @@ describe('useBridgeQuoteRequest', () => {
277279
srcTokenAmount: '0',
278280
}),
279281
undefined,
282+
0,
283+
1,
280284
);
281285
});
282286

@@ -312,6 +316,8 @@ describe('useBridgeQuoteRequest', () => {
312316
srcTokenAmount: '1000500000', // 1000.5 with 6 decimals
313317
}),
314318
undefined,
319+
0,
320+
1,
315321
);
316322
});
317323

@@ -386,6 +392,8 @@ describe('useBridgeQuoteRequest', () => {
386392
destWalletAddress: destSolanaAddress,
387393
}),
388394
undefined,
395+
0,
396+
1,
389397
);
390398

391399
// Reset mock
@@ -414,6 +422,8 @@ describe('useBridgeQuoteRequest', () => {
414422
gasIncluded: true,
415423
}),
416424
undefined,
425+
0,
426+
1,
417427
);
418428
});
419429

@@ -438,6 +448,8 @@ describe('useBridgeQuoteRequest', () => {
438448
gasIncluded: false,
439449
}),
440450
undefined,
451+
0,
452+
1,
441453
);
442454
});
443455

@@ -475,6 +487,8 @@ describe('useBridgeQuoteRequest', () => {
475487
gasIncluded7702: true,
476488
}),
477489
undefined,
490+
0,
491+
1,
478492
);
479493
});
480494

@@ -495,6 +509,8 @@ describe('useBridgeQuoteRequest', () => {
495509
gasIncluded7702: false,
496510
}),
497511
undefined,
512+
0,
513+
1,
498514
);
499515
});
500516
});
@@ -539,6 +555,8 @@ describe('useBridgeQuoteRequest', () => {
539555
gasIncluded7702: false,
540556
}),
541557
undefined,
558+
0,
559+
1,
542560
);
543561
});
544562
});
@@ -566,6 +584,8 @@ describe('useBridgeQuoteRequest', () => {
566584
insufficientBal: false,
567585
}),
568586
undefined,
587+
0,
588+
1,
569589
);
570590
});
571591

@@ -596,6 +616,8 @@ describe('useBridgeQuoteRequest', () => {
596616
insufficientBal: true,
597617
}),
598618
undefined,
619+
0,
620+
1,
599621
);
600622
});
601623

@@ -626,6 +648,8 @@ describe('useBridgeQuoteRequest', () => {
626648
insufficientBal: true,
627649
}),
628650
undefined,
651+
0,
652+
1,
629653
);
630654
});
631655

app/components/UI/Bridge/testUtils/index.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,41 @@
11
import {
22
type BridgeControllerState,
33
getDefaultBridgeControllerState,
4+
type GenericQuoteRequest,
45
} from '@metamask/bridge-controller';
56
import { initialState } from '../_mocks_/initialState';
67
import { mockBridgeReducerState } from '../_mocks_/bridgeReducerState';
78
import type { BridgeState } from '../../../../core/redux/slices/bridge';
89
import { RootState } from '../../../../reducers';
910
import { DeepPartial } from '../../../../util/test/renderWithProvider';
11+
import { merge } from 'lodash';
1012

1113
// Re-export all fixtures (no heavy dependencies)
1214
export * from './fixtures';
1315

14-
type BridgeControllerStateOverride = Partial<BridgeControllerState>;
15-
16+
type BridgeControllerStateOverride = Partial<
17+
Omit<BridgeControllerState, 'quoteRequest'>
18+
> & { quoteRequest?: Partial<GenericQuoteRequest> };
1619
/**
1720
* Creates a complete bridge controller state by merging default state with overrides
1821
* @param overrides - Partial state to override default values
1922
* @returns Complete bridge controller state
2023
*/
21-
export const createBridgeControllerState = (
22-
overrides: BridgeControllerStateOverride = {},
23-
): BridgeControllerState => ({
24-
...getDefaultBridgeControllerState(),
25-
...overrides,
26-
});
24+
export const createBridgeControllerState = ({
25+
quoteRequest,
26+
...overrides
27+
}: BridgeControllerStateOverride = {}): BridgeControllerState =>
28+
merge(
29+
getDefaultBridgeControllerState(),
30+
overrides,
31+
quoteRequest
32+
? {
33+
quoteRequest: Array.isArray(quoteRequest)
34+
? quoteRequest
35+
: [quoteRequest],
36+
}
37+
: {},
38+
);
2739

2840
/**
2941
* Creates a complete test state for bridge components/hooks

app/components/UI/Predict/providers/polymarket/depositWallet.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ describe('depositWallet', () => {
269269

270270
it('keeps polling when completion succeeds without a hash', async () => {
271271
mockFetch
272-
.mockResolvedValueOnce(mockResponse({ state: 'STATE_MINED' }))
272+
.mockResolvedValueOnce(mockResponse({ state: 'STATE_CONFIRMED' }))
273273
.mockResolvedValueOnce(
274274
mockResponse({
275-
state: 'STATE_MINED',
275+
state: 'STATE_CONFIRMED',
276276
transactionHash:
277277
'0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd',
278278
}),

app/components/UI/Predict/providers/polymarket/depositWallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const DEPOSIT_WALLET_DOMAIN_VERSION = '1';
2626
// allowed window to reduce intermittent "deadline too soon" failures.
2727
const DEPOSIT_WALLET_BATCH_DEADLINE_SECONDS = 300;
2828

29-
const RELAYER_SUCCESS_STATES = new Set(['STATE_MINED', 'STATE_CONFIRMED']);
29+
const RELAYER_SUCCESS_STATES = new Set(['STATE_CONFIRMED']);
3030
const RELAYER_FAILURE_STATES = new Set(['STATE_FAILED', 'STATE_INVALID']);
3131

3232
/**

app/components/Views/SocialLeaderboard/TraderPositionView/components/QuickBuyBottomSheet/useQuickBuyQuotes.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,12 @@ export function useQuickBuyQuotes({
256256
const controllerFields = {
257257
...metadataDeps.bridgeController,
258258
quotes: rawQuotes,
259-
quoteRequest: {
260-
...metadataDeps.bridgeController.quoteRequest,
261-
...quoteRequestPatch,
262-
},
259+
quoteRequest: [
260+
{
261+
...(metadataDeps.bridgeController.quoteRequest?.[0] ?? {}),
262+
...quoteRequestPatch,
263+
},
264+
],
263265
gasFeeEstimatesByChainId: metadataDeps.gasFeeEstimatesByChainId,
264266
...metadataDeps.multichainAssetsRates,
265267
...metadataDeps.tokenRates,

app/selectors/bridgeController/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const selectBridgeControllerState = (state: RootState) =>
1919
export const selectQuoteRequest = createSelector(
2020
selectBridgeControllerState,
2121
(bridgeControllerState: BridgeControllerState) =>
22-
bridgeControllerState.quoteRequest,
22+
bridgeControllerState.quoteRequest[0],
2323
);
2424

2525
// Create the BridgeAppState selector following the same pattern as in bridge slice

app/util/bridge/hooks/useSubmitBridgeTx.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ describe('useSubmitBridgeTx', () => {
142142
backgroundState: {
143143
...backgroundState,
144144
BridgeController: {
145-
quoteRequest: {
146-
slippage: 0.5,
147-
},
145+
quoteRequest: [
146+
{
147+
slippage: 0.5,
148+
},
149+
],
148150
},
149151
BridgeStatusController: {
150152
startPollingForBridgeTxStatus: jest.fn(),

app/util/test/initial-background-state.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,11 @@
698698
"assetExchangeRates": {},
699699
"minimumBalanceForRentExemptionInLamports": "0",
700700
"quoteFetchError": null,
701-
"quoteRequest": {
702-
"srcTokenAddress": "0x0000000000000000000000000000000000000000"
703-
},
701+
"quoteRequest": [
702+
{
703+
"srcTokenAddress": "0x0000000000000000000000000000000000000000"
704+
}
705+
],
704706
"quotes": [],
705707
"quotesInitialLoadTime": null,
706708
"quotesLastFetched": null,

0 commit comments

Comments
 (0)