Skip to content

Commit 20ac05f

Browse files
committed
Preserve polygon token metadata in transaction pay smoke
1 parent 3cbae13 commit 20ac05f

1 file changed

Lines changed: 36 additions & 7 deletions

File tree

tests/smoke/confirmations/transactions/transaction-pay.spec.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,27 @@ async function testSpecificMock(mockServer: Mockttp) {
9393
}
9494

9595
async function mockPolygonTokenByAddress(mockServer: Mockttp) {
96+
const knownPolygonTokens: Record<
97+
string,
98+
{ symbol: string; decimals: number; name: string }
99+
> = {
100+
'0xc011a7e12a19f7b1f670d46f03b03f3342e82dfb': {
101+
symbol: 'pUSD',
102+
decimals: 6,
103+
name: 'Polymarket USD',
104+
},
105+
'0x3c499c542cef5e3811e1192ce70d8cc03d5c3359': {
106+
symbol: 'USDC',
107+
decimals: 6,
108+
name: 'USD Coin',
109+
},
110+
'0x2791bca1f2de4661ed88a30c99a7a9449aa84174': {
111+
symbol: 'USDC.e',
112+
decimals: 6,
113+
name: 'USD Coin (PoS)',
114+
},
115+
};
116+
96117
await mockServer
97118
.forGet('/proxy')
98119
.matching((request) => {
@@ -102,15 +123,23 @@ async function mockPolygonTokenByAddress(mockServer: Mockttp) {
102123
.thenCallback((request) => {
103124
const urlParam = new URL(request.url).searchParams.get('url') || '';
104125
const tokenUrl = new URL(urlParam);
105-
const address = tokenUrl.searchParams.get('address') ?? '';
126+
const address = (
127+
tokenUrl.searchParams.get('address') ?? ''
128+
).toLowerCase();
129+
const knownToken = knownPolygonTokens[address];
106130
return {
107131
statusCode: 200,
108-
json: {
109-
address: address.toLowerCase(),
110-
symbol: 'UNKNOWN',
111-
decimals: 18,
112-
name: 'Unknown Token',
113-
},
132+
json: knownToken
133+
? {
134+
address,
135+
...knownToken,
136+
}
137+
: {
138+
address,
139+
symbol: 'UNKNOWN',
140+
decimals: 18,
141+
name: 'Unknown Token',
142+
},
114143
};
115144
});
116145
}

0 commit comments

Comments
 (0)