Skip to content

Commit 4748bdc

Browse files
authored
test: add mock for batch transactions (#21962)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds Polygon/EIP-7702 and transaction-sentinel mocks, refactors Polymarket mocks (cash-out, RPC, event details), and updates/extends E2E tests including a withdraw spec scaffold. > > - **Feature flags** > - Add Polygon (`0x89`) entries to `confirmations_eip_7702.contracts` and extend `supportedChains`. > - **Polymarket mocks** > - **EIP-7702/Polygon support**: Add `POLYGON_EIP7702_CONTRACT_ADDRESS` and `EIP7702_CODE_FORMAT`; return EIP-7702 code for `eth_getCode` of `USER_WALLET_ADDRESS`. > - **Transaction Sentinel**: New `polymarket-transaction-sentinel-response.ts` and `POLYMARKET_TRANSACTION_SENTINEL_MOCKS` for `infura_simulateTransactions`. > - **RPC enhancements**: Broaden `/proxy` matcher; handle proxy wallet `eth_call` selector `0xaffed0e0`; add `eth_getTransactionCount` and `eth_estimateGas` responses. > - **Cash-out flow**: Consolidate into `POLYMARKET_POST_CASH_OUT_MOCKS` (mocks CLOB order, updates USDC balance, high-priority balance refresh); deprecate `POLYMARKET_CASH_OUT_BALANCE_LOAD_MOCKS`; add `POLYMARKET_WITHDRAW_BALANCE_LOAD_MOCKS`; helper `MOCK_BATCH_TRANSACTIONS`. > - **Event details**: Rename default event export to `POLYMARKET_EVENT_DETAILS_BLUE_JAYS_MARINERS_RESPONSE`; add/export `POLYMARKET_EVENT_DETAILS_SPURS_PELICANS_RESPONSE`; update mocks to use them. > - **RPC responses**: Add `TRANSACTION_COUNT_RESULT`. > - **E2E tests** > - Update `predict-cash-out.spec.ts` to use new cash-out mocks and remove force-refresh mock. > - Add `predict-withdraw.spec.ts` (withdraw flow scaffold) using new mocks. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c6301fd. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 3d3f9c3 commit 4748bdc

File tree

8 files changed

+755
-383
lines changed

8 files changed

+755
-383
lines changed

e2e/api-mocking/mock-responses/feature-flags-mocks.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ export const confirmationsRedesignedFeatureFlags = [
6666
'0x5b394cc656b760fc15e855f9b8b9d0eec6337328361771c696d7f5754f0348e06298d34243e815ff8b5ce869e5f310c37dd100c1827e91b56bb208d1fafcf3a71c',
6767
},
6868
],
69+
'0x89': [
70+
{
71+
address: '0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B',
72+
signature:
73+
'0x302aa2d59940e88f35d2fa140fe6a1e9dc682218a444a7fb2d88f007fbe7792b2b8d615f5ae1e4f184533a02c47d8ac0f6ba3f591679295dff93c65095c0f03d1b',
74+
},
75+
],
6976
},
70-
supportedChains: ['0xaa36a7', '0x539', '0x1'],
77+
supportedChains: ['0xaa36a7', '0x539', '0x1', '0x89'],
7178
},
7279
},
7380
];
@@ -104,8 +111,16 @@ export const remoteFeatureEip7702 = [
104111
'0x5b394cc656b760fc15e855f9b8b9d0eec6337328361771c696d7f5754f0348e06298d34243e815ff8b5ce869e5f310c37dd100c1827e91b56bb208d1fafcf3a71c',
105112
},
106113
],
114+
'0x89': [
115+
{
116+
name: 'Polygon',
117+
signature:
118+
'0x302aa2d59940e88f35d2fa140fe6a1e9dc682218a444a7fb2d88f007fbe7792b2b8d615f5ae1e4f184533a02c47d8ac0f6ba3f591679295dff93c65095c0f03d1b',
119+
address: '0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B',
120+
},
121+
],
107122
},
108-
supportedChains: ['0xaa36a7', '0x539', '0x1'],
123+
supportedChains: ['0xaa36a7', '0x539', '0x1', '0x89'],
109124
},
110125
},
111126
];

e2e/api-mocking/mock-responses/polymarket/polymarket-constants.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ export const MULTICALL_CONTRACT_ADDRESS =
2727
'0xca11bde05977b3631167028862be2a173976ca11';
2828
export const CONDITIONAL_TOKENS_CONTRACT_ADDRESS =
2929
'0x4d97dcd97ec945f40cf65f87097ace5ea0476045';
30+
export const POLYGON_EIP7702_CONTRACT_ADDRESS =
31+
'0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B';
32+
33+
// EIP-7702 format: 0xef01 (magic byte) + 00 (padding) + 20-byte contract address
34+
// This format indicates an EOA is upgraded with EIP-7702
35+
export const EIP7702_CODE_FORMAT = (contractAddress: string): string => {
36+
const addressWithoutPrefix = contractAddress.toLowerCase().replace('0x', '');
37+
// EIP-7702 format: ef01 (magic byte) + 00 (padding byte) + 20-byte address (40 hex chars)
38+
return `0xef0100${addressWithoutPrefix}`;
39+
};

e2e/api-mocking/mock-responses/polymarket/polymarket-event-details-response.ts

Lines changed: 230 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Endpoint: /events/60362
44
*/
55

6-
export const POLYMARKET_EVENT_DETAILS_RESPONSE = {
6+
export const POLYMARKET_EVENT_DETAILS_BLUE_JAYS_MARINERS_RESPONSE = {
77
id: '60362',
88
ticker: 'mlb-tor-sea-2025-10-17',
99
slug: 'mlb-tor-sea-2025-10-17',
@@ -380,3 +380,232 @@ export const POLYMARKET_EVENT_DETAILS_RESPONSE = {
380380
deploying: false,
381381
gameId: 10076813,
382382
};
383+
384+
/**
385+
* Mock response data for Polymarket event details API endpoint
386+
* Event ID: 62553 - Spurs vs. Pelicans
387+
*/
388+
export const POLYMARKET_EVENT_DETAILS_SPURS_PELICANS_RESPONSE = {
389+
id: '62553',
390+
ticker: 'nba-sas-nop-2025-10-24',
391+
slug: 'nba-sas-nop-2025-10-24',
392+
title: 'Spurs vs. Pelicans',
393+
description:
394+
'In the upcoming NBA game, scheduled for October 24 at 8:00PM ET:\nIf the Spurs win, the market will resolve to "Spurs".\nIf the Pelicans win, the market will resolve to "Pelicans".\nIf the game is postponed, this market will remain open until the game has been completed.\nIf the game is canceled entirely, with no make-up game, this market will resolve 50-50.\nThe result will be determined based on the final score including any overtime periods.',
395+
resolutionSource: 'https://www.nba.com/',
396+
startDate: '2025-10-20T19:48:16.12238Z',
397+
creationDate: '2025-10-25T00:00:00Z',
398+
endDate: '2025-10-25T00:00:00Z',
399+
image:
400+
'https://polymarket-upload.s3.us-east-2.amazonaws.com/super+cool+basketball+in+red+and+blue+wow.png',
401+
icon: 'https://polymarket-upload.s3.us-east-2.amazonaws.com/super+cool+basketball+in+red+and+blue+wow.png',
402+
active: true,
403+
closed: false,
404+
archived: false,
405+
new: false,
406+
featured: false,
407+
restricted: true,
408+
liquidity: 286736.0313,
409+
volume: 810829.632579,
410+
openInterest: 0,
411+
createdAt: '2025-10-20T19:44:18.517198Z',
412+
updatedAt: '2025-10-24T20:16:37.479733Z',
413+
competitive: 0.9999750006249843,
414+
volume24hr: 601663.0284430003,
415+
volume1wk: 619816.1113160002,
416+
volume1mo: 619816.1113160002,
417+
volume1yr: 619816.1113160002,
418+
enableOrderBook: true,
419+
liquidityClob: 286736.0313,
420+
negRisk: false,
421+
commentCount: 133,
422+
markets: [
423+
{
424+
id: '641723',
425+
question: 'Spurs vs. Pelicans',
426+
conditionId:
427+
'0x12899fadc50f47afa5f8e145380a9c6f0262d75ea12749bbbcb4f8b50f96cf6b',
428+
slug: 'nba-sas-nop-2025-10-24',
429+
resolutionSource: 'https://www.nba.com/',
430+
endDate: '2025-10-25T00:00:00Z',
431+
liquidity: '180671.5616',
432+
startDate: '2025-10-20T19:45:23.832649Z',
433+
image:
434+
'https://polymarket-upload.s3.us-east-2.amazonaws.com/super+cool+basketball+in+red+and+blue+wow.png',
435+
icon: 'https://polymarket-upload.s3.us-east-2.amazonaws.com/super+cool+basketball+in+red+and+blue+wow.png',
436+
description:
437+
'In the upcoming NBA game, scheduled for October 24 at 8:00PM ET:\nIf the Spurs win, the market will resolve to "Spurs".\nIf the Pelicans win, the market will resolve to "Pelicans".\nIf the game is postponed, this market will remain open until the game has been completed.\nIf the game is canceled entirely, with no make-up game, this market will resolve 50-50.\nThe result will be determined based on the final score including any overtime periods.',
438+
outcomes: '["Spurs", "Pelicans"]',
439+
outcomePrices: '["0.615", "0.385"]',
440+
volume: '524574.695034',
441+
active: true,
442+
closed: false,
443+
marketMakerAddress: '',
444+
createdAt: '2025-10-20T19:44:19.000671Z',
445+
updatedAt: '2025-10-24T20:23:49.423914Z',
446+
new: false,
447+
featured: false,
448+
submitted_by: '0x91430CaD2d3975766499717fA0D66A78D814E5c5',
449+
archived: false,
450+
resolvedBy: '0x65070BE91477460D8A7AeEb94ef92fe056C2f2A7',
451+
restricted: true,
452+
groupItemThreshold: '0',
453+
questionID:
454+
'0xa42fab8d0df30928181953f2f77de88bbb0b1244a9bb2781d86f22d91553bc4a',
455+
enableOrderBook: true,
456+
orderPriceMinTickSize: 0.01,
457+
orderMinSize: 5,
458+
volumeNum: 524574.695034,
459+
liquidityNum: 180671.5616,
460+
endDateIso: '2025-10-25',
461+
startDateIso: '2025-10-20',
462+
hasReviewedDates: true,
463+
volume24hr: 316414.12729000027,
464+
volume1wk: 334567.2101630003,
465+
volume1mo: 334567.2101630003,
466+
volume1yr: 334567.2101630003,
467+
gameStartTime: '2025-10-25 00:00:00+00',
468+
secondsDelay: 3,
469+
clobTokenIds:
470+
'["110743925263777693447488608878982152642205002490046349037358337248548507433643", "38489710206351002266036612280230748165102516187175290608628298208123746725814"]',
471+
umaBond: '500',
472+
umaReward: '2',
473+
volume24hrClob: 316414.12729000027,
474+
volume1wkClob: 334567.2101630003,
475+
volume1moClob: 334567.2101630003,
476+
volume1yrClob: 334567.2101630003,
477+
volumeClob: 524574.695034,
478+
liquidityClob: 180671.5616,
479+
customLiveness: 0,
480+
acceptingOrders: true,
481+
negRisk: false,
482+
negRiskRequestID: '',
483+
ready: false,
484+
funded: false,
485+
acceptingOrdersTimestamp: '2025-10-20T19:45:03Z',
486+
cyom: false,
487+
competitive: 0.9869476177551876,
488+
pagerDutyNotificationEnabled: false,
489+
approved: true,
490+
rewardsMinSize: 0,
491+
rewardsMaxSpread: 0,
492+
spread: 0.01,
493+
oneDayPriceChange: 0.04,
494+
lastTradePrice: 0.62,
495+
bestBid: 0.61,
496+
bestAsk: 0.62,
497+
automaticallyActive: true,
498+
clearBookOnStart: true,
499+
manualActivation: false,
500+
negRiskOther: false,
501+
sportsMarketType: 'moneyline',
502+
umaResolutionStatuses: '[]',
503+
pendingDeployment: false,
504+
deploying: false,
505+
deployingTimestamp: '2025-10-20T19:44:33.4803Z',
506+
rfqEnabled: false,
507+
holdingRewardsEnabled: false,
508+
feesEnabled: false,
509+
},
510+
],
511+
outcomes: [
512+
{
513+
id: 'Spurs',
514+
title: 'Spurs',
515+
price: 0.615,
516+
tokens: [
517+
{
518+
id: '110743925263777693447488608878982152642205002490046349037358337248548507433643',
519+
price: 0.615,
520+
},
521+
],
522+
},
523+
{
524+
id: 'Pelicans',
525+
title: 'Pelicans',
526+
price: 0.385,
527+
tokens: [
528+
{
529+
id: '38489710206351002266036612280230748165102516187175290608628298208123746725814',
530+
price: 0.385,
531+
},
532+
],
533+
},
534+
],
535+
series: [
536+
{
537+
id: '10345',
538+
ticker: 'nba-2026',
539+
slug: 'nba-2026',
540+
title: 'NBA 2026',
541+
seriesType: 'single',
542+
recurrence: 'daily',
543+
image:
544+
'https://polymarket-upload.s3.us-east-2.amazonaws.com/super+cool+basketball+in+red+and+blue+wow.png',
545+
icon: 'https://polymarket-upload.s3.us-east-2.amazonaws.com/super+cool+basketball+in+red+and+blue+wow.png',
546+
active: true,
547+
closed: false,
548+
archived: false,
549+
featured: false,
550+
restricted: true,
551+
createdAt: '2025-10-02T17:23:18.780864Z',
552+
updatedAt: '2025-10-24T20:16:46.054922Z',
553+
volume: 7028670.008665,
554+
liquidity: 4244286.0135,
555+
commentCount: 297,
556+
},
557+
],
558+
tags: [
559+
{
560+
id: '1',
561+
label: 'Sports',
562+
slug: 'sports',
563+
forceShow: false,
564+
publishedAt: '2023-10-24 22:37:50.296+00',
565+
updatedBy: 15,
566+
createdAt: '2023-10-24T22:37:50.31Z',
567+
updatedAt: '2024-07-05T21:07:21.800664Z',
568+
forceHide: true,
569+
},
570+
{
571+
id: '745',
572+
label: 'NBA',
573+
slug: 'nba',
574+
forceShow: false,
575+
publishedAt: '2023-12-18 18:24:38.08+00',
576+
createdAt: '2023-12-18T18:24:38.098Z',
577+
updatedAt: '2024-06-18T14:52:57.582861Z',
578+
},
579+
{
580+
id: '100639',
581+
label: 'Games',
582+
slug: 'games',
583+
forceShow: false,
584+
createdAt: '2024-09-23T22:41:37.670714Z',
585+
},
586+
{
587+
id: '28',
588+
label: 'Basketball',
589+
slug: 'basketball',
590+
forceShow: false,
591+
publishedAt: '2023-11-02 21:04:25.152+00',
592+
createdAt: '2023-11-02T21:04:25.158Z',
593+
updatedAt: '2024-07-26T21:06:45.637044Z',
594+
},
595+
],
596+
cyom: false,
597+
showAllOutcomes: true,
598+
showMarketImages: false,
599+
enableNegRisk: false,
600+
automaticallyActive: true,
601+
eventDate: '2025-10-24',
602+
startTime: '2025-10-25T00:00:00Z',
603+
eventWeek: 3,
604+
seriesSlug: 'nba-2026',
605+
negRiskAugmented: false,
606+
pendingDeployment: false,
607+
deploying: false,
608+
gameId: 20022560,
609+
homeTeamName: 'Pelicans',
610+
awayTeamName: 'Spurs',
611+
};

0 commit comments

Comments
 (0)