Skip to content

Commit 049fb3b

Browse files
committed
Fix predict e2e cash-out and transaction pay mocks
1 parent 8b14ec9 commit 049fb3b

2 files changed

Lines changed: 41 additions & 29 deletions

File tree

tests/api-mocking/mock-responses/polymarket/polymarket-mocks.ts

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,30 +1461,43 @@ export const POLYMARKET_POST_CASH_OUT_MOCKS = async (mockServer: Mockttp) => {
14611461
const body = bodyText ? JSON.parse(bodyText) : {};
14621462
const order = body?.order;
14631463

1464-
// Verify the request matches cash-out order structure
1465-
// Only check consistent fields - allow variable values for dynamic fields (salt, tokenId, amounts, signature, owner)
1466-
return (
1467-
order &&
1468-
(body.orderType === 'FOK' || body.orderType === 'FAK') &&
1469-
order.maker?.toLowerCase() === PROXY_WALLET_ADDRESS.toLowerCase() &&
1470-
order.signer?.toLowerCase() === USER_WALLET_ADDRESS.toLowerCase() &&
1471-
order.taker === '0x0000000000000000000000000000000000000000' &&
1472-
order.expiration === '0' &&
1473-
order.nonce === '0' &&
1474-
typeof order.feeRateBps === 'string' &&
1475-
order.side === 'SELL' &&
1476-
order.signatureType === 2 &&
1477-
typeof order.salt === 'number' &&
1478-
typeof order.tokenId === 'string' &&
1479-
order.tokenId.length > 0 &&
1480-
typeof order.makerAmount === 'string' &&
1481-
order.makerAmount.length > 0 &&
1482-
typeof order.takerAmount === 'string' &&
1483-
order.takerAmount.length > 0 &&
1484-
typeof order.signature === 'string' &&
1485-
order.signature.startsWith('0x') &&
1486-
order.signature.length > 10
1487-
);
1464+
// Flexible matching: require SELL order to relayer endpoint.
1465+
// CLOB v2 cash-out payloads no longer include some legacy fields
1466+
// (for example taker/nonce/feeRateBps), so only validate stable fields.
1467+
if (!order || order.side !== 'SELL') {
1468+
return false;
1469+
}
1470+
1471+
if (
1472+
body.orderType !== undefined &&
1473+
body.orderType !== 'FOK' &&
1474+
body.orderType !== 'FAK'
1475+
) {
1476+
return false;
1477+
}
1478+
1479+
if (order.maker !== undefined && order.signer !== undefined) {
1480+
const makerMatch =
1481+
order.maker?.toLowerCase() === PROXY_WALLET_ADDRESS.toLowerCase();
1482+
const signerMatch =
1483+
order.signer?.toLowerCase() === USER_WALLET_ADDRESS.toLowerCase();
1484+
1485+
if (!makerMatch || !signerMatch) {
1486+
return false;
1487+
}
1488+
}
1489+
1490+
if (order.signature !== undefined) {
1491+
if (
1492+
typeof order.signature !== 'string' ||
1493+
!order.signature.startsWith('0x') ||
1494+
order.signature.length < 10
1495+
) {
1496+
return false;
1497+
}
1498+
}
1499+
1500+
return true;
14881501
} catch {
14891502
return false;
14901503
}

tests/api-mocking/mock-responses/transaction-pay.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,12 @@ export const RELAY_QUOTE_MOCK = {
275275
inputCurrency: {
276276
currency: {
277277
chainId: 137,
278-
address: '0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB',
279-
symbol: 'pUSD',
280-
name: 'Polymarket USD',
278+
address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
279+
symbol: 'USDC',
280+
name: 'USD Coin',
281281
decimals: 6,
282282
metadata: {
283-
logoURI:
284-
'https://static.cx.metamask.io/api/v1/tokenIcons/137/0xc011a7e12a19f7b1f670d46f03b03f3342e82dfb.png',
283+
logoURI: 'https://ethereum-optimism.github.io/data/USDC/logo.png',
285284
verified: true,
286285
},
287286
},

0 commit comments

Comments
 (0)