2022-04-08 16:54:43 +02:00
|
|
|
const blacklistedHosts = [
|
|
|
|
'goerli.infura.io',
|
|
|
|
'mainnet.infura.io',
|
2022-09-14 20:26:45 +02:00
|
|
|
'sepolia.infura.io',
|
2022-04-08 16:54:43 +02:00
|
|
|
];
|
|
|
|
|
2022-03-07 20:23:04 +01:00
|
|
|
async function setupMocking(server, testSpecificMock) {
|
2022-04-08 16:54:43 +02:00
|
|
|
await server.forAnyRequest().thenPassThrough({
|
|
|
|
beforeRequest: (req) => {
|
|
|
|
const { host } = req.headers;
|
|
|
|
if (blacklistedHosts.includes(host)) {
|
|
|
|
return {
|
|
|
|
url: 'http://localhost:8545',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
});
|
2022-02-16 15:21:41 +01:00
|
|
|
|
2022-04-06 10:05:45 +02:00
|
|
|
await server.forPost('https://api.segment.io/v1/batch').thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-08-26 01:07:31 +02:00
|
|
|
await server
|
|
|
|
.forPost('https://sentry.io/api/0000000/envelope/')
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
json: {},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
await server
|
|
|
|
.forPost('https://sentry.io/api/0000000/store/')
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
json: {},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-07-20 19:39:40 +02:00
|
|
|
await server
|
|
|
|
.forGet('https://www.4byte.directory/api/v1/signatures/')
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
json: {
|
|
|
|
count: 1,
|
|
|
|
next: null,
|
|
|
|
previous: null,
|
|
|
|
results: [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
created_at: null,
|
|
|
|
text_signature: 'deposit()',
|
|
|
|
hex_signature: null,
|
|
|
|
bytes_signature: null,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-03-07 20:23:04 +01:00
|
|
|
await server
|
2022-02-16 15:21:41 +01:00
|
|
|
.forGet('https://gas-api.metaswap.codefi.network/networks/1/gasPrices')
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
json: {
|
|
|
|
SafeGasPrice: '1',
|
|
|
|
ProposeGasPrice: '2',
|
|
|
|
FastGasPrice: '3',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
2022-02-22 17:48:12 +01:00
|
|
|
|
2022-03-16 17:06:13 +01:00
|
|
|
await server
|
|
|
|
.forGet(
|
|
|
|
'https://gas-api.metaswap.codefi.network/networks/1/suggestedGasFees',
|
|
|
|
)
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
json: {
|
|
|
|
low: {
|
|
|
|
suggestedMaxPriorityFeePerGas: '1',
|
|
|
|
suggestedMaxFeePerGas: '20.44436136',
|
|
|
|
minWaitTimeEstimate: 15000,
|
|
|
|
maxWaitTimeEstimate: 30000,
|
|
|
|
},
|
|
|
|
medium: {
|
|
|
|
suggestedMaxPriorityFeePerGas: '1.5',
|
|
|
|
suggestedMaxFeePerGas: '25.80554517',
|
|
|
|
minWaitTimeEstimate: 15000,
|
|
|
|
maxWaitTimeEstimate: 45000,
|
|
|
|
},
|
|
|
|
high: {
|
|
|
|
suggestedMaxPriorityFeePerGas: '2',
|
|
|
|
suggestedMaxFeePerGas: '27.277766977',
|
|
|
|
minWaitTimeEstimate: 15000,
|
|
|
|
maxWaitTimeEstimate: 60000,
|
|
|
|
},
|
|
|
|
estimatedBaseFee: '19.444436136',
|
|
|
|
networkCongestion: 0.14685,
|
|
|
|
latestPriorityFeeRange: ['0.378818859', '6.555563864'],
|
|
|
|
historicalPriorityFeeRange: ['0.1', '248.262969261'],
|
|
|
|
historicalBaseFeeRange: ['14.146999781', '28.825256275'],
|
|
|
|
priorityFeeTrend: 'down',
|
|
|
|
baseFeeTrend: 'up',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-04-06 10:05:45 +02:00
|
|
|
await server
|
|
|
|
.forGet('https://swap.metaswap.codefi.network/featureFlags')
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
json: [
|
|
|
|
{
|
|
|
|
ethereum: {
|
2022-09-29 18:03:38 +02:00
|
|
|
fallbackToV1: false,
|
2022-04-06 10:05:45 +02:00
|
|
|
mobileActive: true,
|
|
|
|
extensionActive: true,
|
|
|
|
},
|
|
|
|
bsc: {
|
2022-09-29 18:03:38 +02:00
|
|
|
fallbackToV1: false,
|
2022-04-06 10:05:45 +02:00
|
|
|
mobileActive: true,
|
|
|
|
extensionActive: true,
|
|
|
|
},
|
|
|
|
polygon: {
|
2022-09-29 18:03:38 +02:00
|
|
|
fallbackToV1: false,
|
2022-04-06 10:05:45 +02:00
|
|
|
mobileActive: true,
|
|
|
|
extensionActive: true,
|
|
|
|
},
|
|
|
|
avalanche: {
|
2022-09-29 18:03:38 +02:00
|
|
|
fallbackToV1: false,
|
2022-04-06 10:05:45 +02:00
|
|
|
mobileActive: true,
|
|
|
|
extensionActive: true,
|
|
|
|
},
|
|
|
|
smartTransactions: {
|
|
|
|
mobileActive: false,
|
|
|
|
extensionActive: false,
|
|
|
|
},
|
|
|
|
updated_at: '2022-03-17T15:54:00.360Z',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-04-04 17:02:29 +02:00
|
|
|
await server
|
|
|
|
.forGet('https://token-api.metaswap.codefi.network/tokens/1337')
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
json: [
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
symbol: 'BAT',
|
|
|
|
decimals: 18,
|
|
|
|
name: 'Basic Attention Token',
|
|
|
|
iconUrl:
|
|
|
|
'https://assets.coingecko.com/coins/images/677/thumb/basic-attention-token.png?1547034427',
|
|
|
|
aggregators: [
|
|
|
|
'aave',
|
|
|
|
'bancor',
|
|
|
|
'coinGecko',
|
|
|
|
'oneInch',
|
|
|
|
'paraswap',
|
|
|
|
'pmm',
|
|
|
|
'zapper',
|
|
|
|
'zerion',
|
|
|
|
'zeroEx',
|
|
|
|
],
|
|
|
|
occurrences: 9,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-07-19 17:22:38 +02:00
|
|
|
await server
|
|
|
|
.forGet('https://token-api.metaswap.codefi.network/token/0x539')
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
json: {},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-07-18 16:43:30 +02:00
|
|
|
await server
|
|
|
|
.forGet(
|
2022-11-15 16:00:02 +01:00
|
|
|
'https://static.metaswap.codefi.network/api/v1/tokenIcons/1337/0x0d8775f648430679a709e98d2b0cb6250d2887ef.png',
|
|
|
|
)
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
await server
|
|
|
|
.forGet(
|
|
|
|
'https://static.metaswap.codefi.network/api/v1/tokenIcons/1337/0x2efa2cb29c2341d8e5ba7d3262c9e9d6f1bf3711.png',
|
2022-07-18 16:43:30 +02:00
|
|
|
)
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-08-11 17:02:19 +02:00
|
|
|
await server
|
|
|
|
.forGet('https://min-api.cryptocompare.com/data/price')
|
|
|
|
.withQuery({ fsym: 'ETH', tsyms: 'USD' })
|
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
json: {
|
|
|
|
USD: '1700',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-02-22 17:48:12 +01:00
|
|
|
testSpecificMock(server);
|
2022-02-16 15:21:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { setupMocking };
|