@paraswap/dex-lib 2.20.3 → 2.21.1-chronos
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +19 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib.iml +9 -0
- package/.idea/vcs.xml +6 -0
- package/build/config.js +2 -4
- package/build/config.js.map +1 -1
- package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
- package/build/dex/aave-v3/tokens/avalanche.json +74 -0
- package/build/dex/aave-v3/tokens/fantom.json +62 -0
- package/build/dex/aave-v3/tokens/optimism.json +50 -0
- package/build/dex/aave-v3/tokens/polygon.json +116 -0
- package/build/dex/balancer-v2/balancer-v2.d.ts +3 -9
- package/build/dex/balancer-v2/balancer-v2.js +0 -83
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/constants.d.ts +0 -4
- package/build/dex/balancer-v2/constants.js +1 -6
- package/build/dex/balancer-v2/constants.js.map +1 -1
- package/build/dex/balancer-v2/types.d.ts +1 -20
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/curve-v1/constants.d.ts +0 -1
- package/build/dex/curve-v1/constants.js +1 -2
- package/build/dex/curve-v1/constants.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.d.ts +3 -9
- package/build/dex/curve-v1/curve-v1.js +4 -92
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/curve-v1/types.d.ts +0 -24
- package/build/dex/curve-v1/types.js +1 -6
- package/build/dex/curve-v1/types.js.map +1 -1
- package/build/dex/curve-v1-factory/constants.d.ts +0 -1
- package/build/dex/curve-v1-factory/constants.js +1 -2
- package/build/dex/curve-v1-factory/constants.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +4 -11
- package/build/dex/curve-v1-factory/curve-v1-factory.js +0 -87
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +0 -24
- package/build/dex/curve-v1-factory/types.js +1 -6
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/curve-v2.d.ts +7 -29
- package/build/dex/curve-v2.js +1 -91
- package/build/dex/curve-v2.js.map +1 -1
- package/build/dex/idex.d.ts +1 -1
- package/build/dex/index.js +2 -2
- package/build/dex/index.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +2 -2
- package/build/dex/pancakeswap-v3/types.d.ts +14 -0
- package/build/dex/pancakeswap-v3/types.js +3 -0
- package/build/dex/pancakeswap-v3/types.js.map +1 -0
- package/build/dex/pancakeswap-v3/utils.js.map +1 -1
- package/build/dex/quickswap/camelot-v3.d.ts +6 -0
- package/build/dex/quickswap/camelot-v3.js +19 -0
- package/build/dex/quickswap/camelot-v3.js.map +1 -0
- package/build/dex/simple-exchange.d.ts +0 -2
- package/build/dex/simple-exchange.js +0 -1
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/solidly/config.js +13 -0
- package/build/dex/solidly/config.js.map +1 -1
- package/build/dex/solidly/forks-override/chronos.d.ts +23 -0
- package/build/dex/solidly/forks-override/chronos.js +132 -0
- package/build/dex/solidly/forks-override/chronos.js.map +1 -0
- package/build/dex/solidly/solidly.js +1 -0
- package/build/dex/solidly/solidly.js.map +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.d.ts +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.js +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
- package/build/dex/uniswap-v3/constants.d.ts +0 -4
- package/build/dex/uniswap-v3/constants.js +1 -6
- package/build/dex/uniswap-v3/constants.js.map +1 -1
- package/build/dex/uniswap-v3/types.d.ts +3 -20
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +1 -7
- package/build/dex/uniswap-v3/uniswap-v3.js +1 -85
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex/woo-fi-v2/config.js +6 -6
- package/build/dex/zerox/index.d.ts +1 -1
- package/build/dex/zerox/index.js +1 -1
- package/build/dex/zerox/index.js.map +1 -1
- package/build/implementations/local-paraswap-sdk.js +1 -5
- package/build/implementations/local-paraswap-sdk.js.map +1 -1
- package/build/router/directswap.js +1 -7
- package/build/router/directswap.js.map +1 -1
- package/build/router/index.js.map +1 -1
- package/build/router/payload-encoder.js +6 -16
- package/build/router/payload-encoder.js.map +1 -1
- package/build/types.d.ts +0 -2
- package/build/utils.d.ts +0 -2
- package/build/utils.js +1 -5
- package/build/utils.js.map +1 -1
- package/package.json +4 -6
- package/src/config.ts +2 -5
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +0 -79
- package/src/dex/balancer-v2/balancer-v2.ts +4 -153
- package/src/dex/balancer-v2/constants.ts +0 -5
- package/src/dex/balancer-v2/types.ts +1 -21
- package/src/dex/curve-v1/constants.ts +0 -2
- package/src/dex/curve-v1/curve-v1-e2e.test.ts +0 -57
- package/src/dex/curve-v1/curve-v1.ts +5 -144
- package/src/dex/curve-v1/types.ts +0 -26
- package/src/dex/curve-v1-factory/constants.ts +0 -2
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +0 -1
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +4 -140
- package/src/dex/curve-v1-factory/types.ts +0 -26
- package/src/dex/curve-v2.ts +8 -169
- package/src/dex/idex.ts +0 -6
- package/src/dex/index.ts +2 -2
- package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +6 -3
- package/src/dex/pancakeswap-v3/pancakeswap-v3-integration.test.ts +14 -3
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +3 -3
- package/src/dex/pancakeswap-v3/utils.ts +4 -1
- package/src/dex/simple-exchange.ts +0 -6
- package/src/dex/solidly/config.ts +14 -0
- package/src/dex/solidly/forks-override/chronos.ts +206 -0
- package/src/dex/solidly/solidly-e2e.test.ts +205 -31
- package/src/dex/solidly/solidly-integration.test.ts +141 -0
- package/src/dex/solidly/solidly.ts +1 -0
- package/src/dex/uniswap-v2/uniswap-v2.ts +0 -6
- package/src/dex/uniswap-v3/constants.ts +0 -5
- package/src/dex/uniswap-v3/types.ts +3 -23
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +2 -100
- package/src/dex/uniswap-v3/uniswap-v3.ts +3 -138
- package/src/dex/woo-fi-v2/config.ts +6 -6
- package/src/dex/zerox/index.ts +0 -7
- package/src/implementations/local-paraswap-sdk.ts +1 -8
- package/src/router/directswap.ts +0 -23
- package/src/router/index.ts +2 -0
- package/src/router/payload-encoder.ts +5 -22
- package/src/types.ts +0 -2
- package/src/utils.ts +0 -5
- package/tests/constants-e2e.ts +9 -4
- package/tests/utils-e2e.ts +20 -140
- package/tests/utils.ts +0 -52
- package/src/abi/DirectSwap.json +0 -1018
- package/src/abi/swaap-v2/vault.json +0 -918
- package/src/dex/swaap-v2/config.ts +0 -19
- package/src/dex/swaap-v2/constants.ts +0 -37
- package/src/dex/swaap-v2/rate-fetcher.ts +0 -214
- package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +0 -172
- package/src/dex/swaap-v2/swaap-v2-integration.test.ts +0 -142
- package/src/dex/swaap-v2/swaap-v2.ts +0 -901
- package/src/dex/swaap-v2/types.ts +0 -95
- package/src/dex/swaap-v2/utils.ts +0 -36
- package/src/dex/swaap-v2/validators.ts +0 -128
package/tests/utils-e2e.ts
CHANGED
|
@@ -29,37 +29,12 @@ import { constructSimpleSDK, SimpleFetchSDK } from '@paraswap/sdk';
|
|
|
29
29
|
import axios from 'axios';
|
|
30
30
|
import { SmartToken, StateOverrides } from './smart-tokens';
|
|
31
31
|
import { GIFTER_ADDRESS } from './constants-e2e';
|
|
32
|
-
import {
|
|
32
|
+
import { sleep } from './utils';
|
|
33
33
|
import { assert } from 'ts-essentials';
|
|
34
34
|
|
|
35
35
|
export const testingEndpoint = process.env.E2E_TEST_ENDPOINT;
|
|
36
36
|
|
|
37
|
-
const
|
|
38
|
-
const testContractName = process.env.TEST_CONTRACT_NAME;
|
|
39
|
-
const testContractConfigFileName = process.env.TEST_CONTRACT_CONFIG_FILE_NAME;
|
|
40
|
-
const testContractRelativePath = process.env.TEST_CONTRACT_RELATIVE_PATH;
|
|
41
|
-
// Comma separated fields from config or actual values
|
|
42
|
-
const testContractDeployArgs = process.env.TEST_CONTRACT_DEPLOY_ARGS;
|
|
43
|
-
|
|
44
|
-
// If you want to test against deployed and verified contract
|
|
45
|
-
const deployedTestContractAddress = process.env.DEPLOYED_TEST_CONTRACT_ADDRESS;
|
|
46
|
-
const testContractType = process.env.TEST_CONTRACT_TYPE;
|
|
47
|
-
|
|
48
|
-
// Only for router tests
|
|
49
|
-
const testDirectRouterAbiPath = process.env.TEST_DIRECT_ROUTER_ABI_PATH;
|
|
50
|
-
|
|
51
|
-
const directRouterIface = new Interface(
|
|
52
|
-
testDirectRouterAbiPath ? require(testDirectRouterAbiPath) : '[]',
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const testContractBytecode = generateDeployBytecode(
|
|
56
|
-
testContractProjectRootPath,
|
|
57
|
-
testContractName,
|
|
58
|
-
testContractConfigFileName,
|
|
59
|
-
testContractRelativePath,
|
|
60
|
-
testContractDeployArgs,
|
|
61
|
-
testContractType,
|
|
62
|
-
);
|
|
37
|
+
const adapterBytecode = '';
|
|
63
38
|
|
|
64
39
|
const erc20Interface = new Interface(Erc20ABI);
|
|
65
40
|
const augustusInterface = new Interface(AugustusABI);
|
|
@@ -171,7 +146,7 @@ function allowTokenTransferProxyParams(
|
|
|
171
146
|
};
|
|
172
147
|
}
|
|
173
148
|
|
|
174
|
-
function
|
|
149
|
+
function deployAdapterParams(bytecode: string, network = Network.MAINNET) {
|
|
175
150
|
const ownerAddress = DEPLOYER_ADDRESS[network];
|
|
176
151
|
if (!ownerAddress) throw new Error('No deployer address set for network');
|
|
177
152
|
return {
|
|
@@ -181,51 +156,13 @@ function deployContractParams(bytecode: string, network = Network.MAINNET) {
|
|
|
181
156
|
};
|
|
182
157
|
}
|
|
183
158
|
|
|
184
|
-
function
|
|
185
|
-
contractAddress: Address,
|
|
186
|
-
network: Network,
|
|
187
|
-
functionName: string,
|
|
188
|
-
) {
|
|
159
|
+
function whiteListAdapterParams(contractAddress: Address, network: Network) {
|
|
189
160
|
const augustusAddress = generateConfig(network).augustusAddress;
|
|
190
161
|
if (!augustusAddress) throw new Error('No whitelist address set for network');
|
|
191
162
|
const ownerAddress = MULTISIG[network];
|
|
192
163
|
if (!ownerAddress) throw new Error('No whitelist owner set for network');
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
from: ownerAddress,
|
|
196
|
-
to: augustusAddress,
|
|
197
|
-
data: augustusInterface.encodeFunctionData('setImplementation', [
|
|
198
|
-
directRouterIface.getSighash(functionName),
|
|
199
|
-
contractAddress,
|
|
200
|
-
]),
|
|
201
|
-
value: '0',
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function augustusGrantRoleParams(
|
|
206
|
-
contractAddress: Address,
|
|
207
|
-
network: Network,
|
|
208
|
-
type: string = 'adapter',
|
|
209
|
-
) {
|
|
210
|
-
const augustusAddress = generateConfig(network).augustusAddress;
|
|
211
|
-
if (!augustusAddress) throw new Error('No whitelist address set for network');
|
|
212
|
-
const ownerAddress = MULTISIG[network];
|
|
213
|
-
if (!ownerAddress) throw new Error('No whitelist owner set for network');
|
|
214
|
-
|
|
215
|
-
let role: string;
|
|
216
|
-
switch (type) {
|
|
217
|
-
case 'adapter':
|
|
218
|
-
role =
|
|
219
|
-
'0x8429d542926e6695b59ac6fbdcd9b37e8b1aeb757afab06ab60b1bb5878c3b49';
|
|
220
|
-
break;
|
|
221
|
-
case 'router':
|
|
222
|
-
role =
|
|
223
|
-
'0x7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2';
|
|
224
|
-
break;
|
|
225
|
-
default:
|
|
226
|
-
throw new Error(`Unrecognized type ${type}`);
|
|
227
|
-
}
|
|
228
|
-
|
|
164
|
+
const role =
|
|
165
|
+
'0x8429d542926e6695b59ac6fbdcd9b37e8b1aeb757afab06ab60b1bb5878c3b49';
|
|
229
166
|
return {
|
|
230
167
|
from: ownerAddress,
|
|
231
168
|
to: augustusAddress,
|
|
@@ -237,21 +174,6 @@ function augustusGrantRoleParams(
|
|
|
237
174
|
};
|
|
238
175
|
}
|
|
239
176
|
|
|
240
|
-
export function formatDeployMessage(
|
|
241
|
-
type: 'router' | 'adapter',
|
|
242
|
-
address: Address,
|
|
243
|
-
forkId: string,
|
|
244
|
-
contractName: string,
|
|
245
|
-
contractPath: string,
|
|
246
|
-
) {
|
|
247
|
-
// This formatting is useful for verification on Tenderly
|
|
248
|
-
return `Deployed ${type} contract with env params:
|
|
249
|
-
TENDERLY_FORK_ID=${forkId}
|
|
250
|
-
TENDERLY_VERIFY_CONTRACT_ADDRESS=${address}
|
|
251
|
-
TENDERLY_VERIFY_CONTRACT_NAME=${contractName}
|
|
252
|
-
TENDERLY_VERIFY_CONTRACT_PATH=${contractPath}`;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
177
|
export async function testE2E(
|
|
256
178
|
srcToken: Token,
|
|
257
179
|
destToken: Token,
|
|
@@ -261,13 +183,12 @@ export async function testE2E(
|
|
|
261
183
|
dexKey: string,
|
|
262
184
|
contractMethod: ContractMethod,
|
|
263
185
|
network: Network = Network.MAINNET,
|
|
264
|
-
|
|
186
|
+
provider: Provider,
|
|
265
187
|
poolIdentifiers?: string[],
|
|
266
188
|
limitOrderProvider?: DummyLimitOrderProvider,
|
|
267
189
|
transferFees?: TransferFeeParams,
|
|
268
190
|
// Specified in BPS: part of 10000
|
|
269
191
|
slippage?: number,
|
|
270
|
-
sleepMs?: number,
|
|
271
192
|
) {
|
|
272
193
|
const amount = BigInt(_amount);
|
|
273
194
|
const ts = new TenderlySimulation(network);
|
|
@@ -281,63 +202,26 @@ export async function testE2E(
|
|
|
281
202
|
expect(allowanceTx!.success).toEqual(true);
|
|
282
203
|
}
|
|
283
204
|
|
|
284
|
-
if (
|
|
285
|
-
const whitelistTx = await ts.simulate(
|
|
286
|
-
augustusGrantRoleParams(
|
|
287
|
-
deployedTestContractAddress,
|
|
288
|
-
network,
|
|
289
|
-
testContractType || 'adapter',
|
|
290
|
-
),
|
|
291
|
-
);
|
|
292
|
-
expect(whitelistTx.success).toEqual(true);
|
|
293
|
-
|
|
294
|
-
if (testContractType === 'router') {
|
|
295
|
-
const setImplementationTx = await ts.simulate(
|
|
296
|
-
augustusSetImplementationParams(
|
|
297
|
-
deployedTestContractAddress,
|
|
298
|
-
network,
|
|
299
|
-
contractMethod,
|
|
300
|
-
),
|
|
301
|
-
);
|
|
302
|
-
expect(setImplementationTx.success).toEqual(true);
|
|
303
|
-
}
|
|
304
|
-
} else if (testContractBytecode) {
|
|
205
|
+
if (adapterBytecode) {
|
|
305
206
|
const deployTx = await ts.simulate(
|
|
306
|
-
|
|
207
|
+
deployAdapterParams(adapterBytecode, network),
|
|
307
208
|
);
|
|
308
209
|
|
|
309
210
|
expect(deployTx.success).toEqual(true);
|
|
310
|
-
|
|
311
|
-
const contractAddress =
|
|
211
|
+
const adapterAddress =
|
|
312
212
|
deployTx.transaction.transaction_info.contract_address;
|
|
313
213
|
console.log(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
testContractRelativePath || '',
|
|
320
|
-
),
|
|
214
|
+
'Deployed adapter to address',
|
|
215
|
+
adapterAddress,
|
|
216
|
+
'used',
|
|
217
|
+
deployTx.gasUsed,
|
|
218
|
+
'gas',
|
|
321
219
|
);
|
|
220
|
+
|
|
322
221
|
const whitelistTx = await ts.simulate(
|
|
323
|
-
|
|
324
|
-
contractAddress,
|
|
325
|
-
network,
|
|
326
|
-
testContractType || 'adapter',
|
|
327
|
-
),
|
|
222
|
+
whiteListAdapterParams(adapterAddress, network),
|
|
328
223
|
);
|
|
329
224
|
expect(whitelistTx.success).toEqual(true);
|
|
330
|
-
|
|
331
|
-
if (testContractType === 'router') {
|
|
332
|
-
const setImplementationTx = await ts.simulate(
|
|
333
|
-
augustusSetImplementationParams(
|
|
334
|
-
contractAddress,
|
|
335
|
-
network,
|
|
336
|
-
contractMethod,
|
|
337
|
-
),
|
|
338
|
-
);
|
|
339
|
-
expect(setImplementationTx.success).toEqual(true);
|
|
340
|
-
}
|
|
341
225
|
}
|
|
342
226
|
|
|
343
227
|
const useAPI = testingEndpoint && !poolIdentifiers;
|
|
@@ -348,10 +232,6 @@ export async function testE2E(
|
|
|
348
232
|
|
|
349
233
|
if (paraswap.initializePricing) await paraswap.initializePricing();
|
|
350
234
|
|
|
351
|
-
if (sleepMs) {
|
|
352
|
-
await sleep(sleepMs);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
235
|
if (paraswap.dexHelper?.replaceProviderWithRPC) {
|
|
356
236
|
paraswap.dexHelper?.replaceProviderWithRPC(
|
|
357
237
|
`https://rpc.tenderly.co/fork/${ts.forkId}`,
|
|
@@ -465,13 +345,13 @@ export async function newTestE2E({
|
|
|
465
345
|
await ts.setup();
|
|
466
346
|
}
|
|
467
347
|
|
|
468
|
-
if (useTenderly &&
|
|
348
|
+
if (useTenderly && adapterBytecode) {
|
|
469
349
|
assert(
|
|
470
350
|
ts instanceof TenderlySimulation,
|
|
471
351
|
'`ts` is not an instance of TenderlySimulation',
|
|
472
352
|
);
|
|
473
353
|
const deployTx = await ts.simulate(
|
|
474
|
-
|
|
354
|
+
deployAdapterParams(adapterBytecode, network),
|
|
475
355
|
);
|
|
476
356
|
|
|
477
357
|
expect(deployTx.success).toEqual(true);
|
|
@@ -486,7 +366,7 @@ export async function newTestE2E({
|
|
|
486
366
|
);
|
|
487
367
|
|
|
488
368
|
const whitelistTx = await ts.simulate(
|
|
489
|
-
|
|
369
|
+
whiteListAdapterParams(adapterAddress, network),
|
|
490
370
|
);
|
|
491
371
|
expect(whitelistTx.success).toEqual(true);
|
|
492
372
|
}
|
package/tests/utils.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import { ethers } from 'ethers';
|
|
3
1
|
import { PoolPrices, PoolLiquidity, Address } from '../src/types';
|
|
4
2
|
import { SwapSide } from '../src/constants';
|
|
5
|
-
import { assert } from 'ts-essentials';
|
|
6
3
|
|
|
7
4
|
// Assuming that the amounts are increasing at same interval, and start with 0
|
|
8
5
|
export function checkPoolPrices(
|
|
@@ -76,52 +73,3 @@ export const sleep = (time: number) =>
|
|
|
76
73
|
new Promise(resolve => {
|
|
77
74
|
setTimeout(resolve, time);
|
|
78
75
|
});
|
|
79
|
-
|
|
80
|
-
export const generateDeployBytecode = (
|
|
81
|
-
testContractProjectRootPath: string | undefined,
|
|
82
|
-
testContractName: string | undefined,
|
|
83
|
-
testContractConfigFileName: string | undefined,
|
|
84
|
-
testContractRelativePath: string | undefined,
|
|
85
|
-
testContractDeployArgs: string | undefined,
|
|
86
|
-
testContractType: string | undefined,
|
|
87
|
-
): string => {
|
|
88
|
-
if (
|
|
89
|
-
!testContractProjectRootPath ||
|
|
90
|
-
!testContractName ||
|
|
91
|
-
!testContractConfigFileName ||
|
|
92
|
-
!testContractRelativePath ||
|
|
93
|
-
!testContractDeployArgs ||
|
|
94
|
-
!testContractType
|
|
95
|
-
) {
|
|
96
|
-
return '';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const artifactJsonPath = `${testContractProjectRootPath}/artifacts/${testContractName}.json`;
|
|
100
|
-
const configJsonPath = `${testContractProjectRootPath}/config/${testContractConfigFileName}.json`;
|
|
101
|
-
const fieldsToPickFromConfig = testContractDeployArgs.split(',');
|
|
102
|
-
|
|
103
|
-
const artifact = require(artifactJsonPath) as {
|
|
104
|
-
abi: ethers.ContractInterface;
|
|
105
|
-
bytecode: string;
|
|
106
|
-
};
|
|
107
|
-
// I don't want to type this testing thing. If something is wrong, I will just throw
|
|
108
|
-
const config = require(configJsonPath) as any;
|
|
109
|
-
const factory = new ethers.ContractFactory(artifact.abi, artifact.bytecode);
|
|
110
|
-
|
|
111
|
-
const args = fieldsToPickFromConfig.map(f => {
|
|
112
|
-
const value = config[f];
|
|
113
|
-
if (value === undefined) {
|
|
114
|
-
console.log(
|
|
115
|
-
`Field ${f} is not defined in configJsonPath=${configJsonPath}. Using value as it is`,
|
|
116
|
-
);
|
|
117
|
-
return f;
|
|
118
|
-
}
|
|
119
|
-
return value;
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const deployedBytecode = factory.getDeployTransaction(...args).data;
|
|
123
|
-
|
|
124
|
-
assert(deployedBytecode !== undefined, 'deployedBytecode is undefined');
|
|
125
|
-
|
|
126
|
-
return deployedBytecode.toString();
|
|
127
|
-
};
|