-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b74159
commit 76bf375
Showing
78 changed files
with
1,942 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Server } from 'http'; | ||
|
||
export declare function startMockServer(): Promise<Server>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const fs = require('fs').promises; | ||
const path = require('path'); | ||
|
||
const express = require('express'); | ||
|
||
const app = express(); | ||
const PORT = 3000; | ||
|
||
/** | ||
* @typedef {import('express').Request} Request | ||
* @typedef {import('express').Response} Response | ||
* @typedef {import('http').Server} Server | ||
*/ | ||
|
||
/** | ||
* Middleware to serve JSON files based on request paths and query parameters. | ||
* @param {Request} req - Express request object | ||
* @param {Response} res - Express response object | ||
*/ | ||
app.use(async (req, res) => { | ||
try { | ||
const filePath = req.path.slice(1).replace(/\//g, '_'); | ||
let filename = '_' + filePath; // Add leading underscore to match your file naming | ||
for (const [key, value] of Object.entries(req.query)) { | ||
filename += `_${key}_${value}`; | ||
} | ||
filename = filename.slice(0, 200) + '.json'; | ||
|
||
const dir = path.join(__dirname, 'responses'); | ||
const jsonPath = path.join(dir, filename); | ||
|
||
console.log('Attempting to read file:', jsonPath); | ||
|
||
const data = await fs.readFile(jsonPath, 'utf8'); | ||
res.json(JSON.parse(data)); | ||
} catch (error) { | ||
console.error(`Error serving request ${req.path}:`, error); | ||
Check failure Code scanning / CodeQL Use of externally-controlled format string High
Format string depends on a
user-provided value Error loading related location Loading |
||
res.status(404).json({ error: 'Not found', details: error.message }); | ||
} | ||
}); | ||
Check failure Code scanning / CodeQL Missing rate limiting High
This route handler performs
a file system access Error loading related location Loading |
||
|
||
/** | ||
* Starts the mock server. | ||
* @returns {Promise<Server>} A promise that resolves to the HTTP server instance. | ||
*/ | ||
const startMockServer = () => { | ||
return new Promise((resolve) => { | ||
const server = app.listen(PORT, () => { | ||
console.log(`Mock API server running on http://localhost:${PORT}`); | ||
resolve(server); | ||
}); | ||
}); | ||
}; | ||
|
||
if (require.main === module) { | ||
startMockServer(); | ||
} | ||
|
||
module.exports = { startMockServer }; |
391 changes: 391 additions & 0 deletions
391
...0Ee7A142d267C1f36714E4a8F75612F20a79720_refuel_false_sellAmount_10000000000000000000.json
Large diffs are not rendered by default.
Oops, something went wrong.
174 changes: 174 additions & 0 deletions
174
...s_0xa0Ee7A142d267C1f36714E4a8F75612F20a79720_sellToken_0xEeeeeEeeeEeEeeEeEeEeeEEEeee.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
{ | ||
"sellTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", | ||
"sellTokenAsset": { | ||
"assetCode": "eth", | ||
"decimals": 18, | ||
"iconUrl": "https://rainbowme-res.cloudinary.com/image/upload/v1668565116/assets/ethereum/eth.png", | ||
"name": "Ethereum", | ||
"network": "mainnet", | ||
"symbol": "ETH", | ||
"networks": { | ||
"1": { | ||
"address": "eth", | ||
"decimals": 18 | ||
}, | ||
"10": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
}, | ||
"42161": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
}, | ||
"56": { | ||
"address": "0x2170ed0880ac9a755fd29b2688956bd959f933f8", | ||
"decimals": 18 | ||
}, | ||
"7777777": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
}, | ||
"81457": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
}, | ||
"8453": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
} | ||
}, | ||
"chainId": 1, | ||
"price": { | ||
"value": 2434.55, | ||
"available": true | ||
}, | ||
"totalPrice": { | ||
"value": 243455.00000000003, | ||
"available": true | ||
} | ||
}, | ||
"buyTokenAddress": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", | ||
"buyTokenAsset": { | ||
"assetCode": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", | ||
"decimals": 8, | ||
"iconUrl": "https://rainbowme-res.cloudinary.com/image/upload/v1693266228/assets/ethereum/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599.png", | ||
"name": "Wrapped Bitcoin", | ||
"network": "mainnet", | ||
"symbol": "WBTC", | ||
"networks": { | ||
"1": { | ||
"address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", | ||
"decimals": 8 | ||
}, | ||
"10": { | ||
"address": "0x68f180fcce6836688e9084f035309e29bf0a2095", | ||
"decimals": 8 | ||
}, | ||
"137": { | ||
"address": "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6", | ||
"decimals": 8 | ||
}, | ||
"42161": { | ||
"address": "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f", | ||
"decimals": 8 | ||
}, | ||
"43114": { | ||
"address": "0x50b7545627a5162f82a992c33b87adc75187b218", | ||
"decimals": 8 | ||
}, | ||
"81457": { | ||
"address": "0xf7bc58b8d8f97adc129cfc4c9f45ce3c0e1d2692", | ||
"decimals": 8 | ||
} | ||
}, | ||
"chainId": 1, | ||
"price": { | ||
"value": 61905.71794377755, | ||
"available": true | ||
}, | ||
"totalPrice": { | ||
"value": 240833.52001920715, | ||
"available": true | ||
} | ||
}, | ||
"allowanceTarget": "0x00000000009726632680fb29d3f7a9734e3010e2", | ||
"allowanceNeeded": false, | ||
"to": "0x111111125421ca6dc452d289314280a0f8842a65", | ||
"data": "0xa76dfc3b0000000000000000000000000000000000000000000000000000000016f4ce9b2000000000000000000000004585fe77225b41b697c938b018e2ac67ac5a20c0d6f29312", | ||
"sellAmount": "100000000000000000000", | ||
"sellAmountMinusFees": "99150000000000000000", | ||
"sellAmountDisplay": "100000000000000000000", | ||
"sellAmountInEth": "100000000000000000000", | ||
"buyAmount": "389032755", | ||
"buyAmountMinusFees": "389032755", | ||
"buyAmountDisplay": "389032755", | ||
"buyAmountDisplayMinimum": "385142428", | ||
"buyAmountInEth": "98923217851022626296", | ||
"tradeAmountUSD": 243455.00000000003, | ||
"tradeFeeAmountUSD": 2069.3675000000003, | ||
"value": "100000000000000000000", | ||
"gasPrice": "49368914981", | ||
"source": "1inch", | ||
"protocols": [ | ||
{ | ||
"name": "UNISWAP_V3", | ||
"part": 100 | ||
} | ||
], | ||
"feeTokenAsset": { | ||
"assetCode": "eth", | ||
"decimals": 18, | ||
"iconUrl": "https://rainbowme-res.cloudinary.com/image/upload/v1668565116/assets/ethereum/eth.png", | ||
"name": "Ethereum", | ||
"network": "mainnet", | ||
"symbol": "ETH", | ||
"networks": { | ||
"1": { | ||
"address": "eth", | ||
"decimals": 18 | ||
}, | ||
"10": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
}, | ||
"42161": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
}, | ||
"56": { | ||
"address": "0x2170ed0880ac9a755fd29b2688956bd959f933f8", | ||
"decimals": 18 | ||
}, | ||
"7777777": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
}, | ||
"81457": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
}, | ||
"8453": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"decimals": 18 | ||
} | ||
}, | ||
"chainId": 1, | ||
"price": { | ||
"value": 2434.55, | ||
"available": true | ||
}, | ||
"totalPrice": { | ||
"value": 2069.3675000000003, | ||
"available": true | ||
} | ||
}, | ||
"fee": "850000000000000000", | ||
"feeInEth": "850000000000000000", | ||
"feePercentageBasisPoints": "8500000000000000", | ||
"tradeType": "exact_input", | ||
"from": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720", | ||
"defaultGasLimit": "350000", | ||
"swapType": "normal", | ||
"txTarget": "0x00000000009726632680fb29d3f7a9734e3010e2", | ||
"chainId": 1 | ||
} |
Oops, something went wrong.