-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdeployContracts.ts
More file actions
707 lines (625 loc) · 24.3 KB
/
deployContracts.ts
File metadata and controls
707 lines (625 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
import moduleAlias from 'module-alias';
moduleAlias.addAlias('./artifacts', '../artifacts');
moduleAlias.addAlias('./publish', '../publish');
import { Wallet } from '@ethersproject/wallet';
import { BaseContract, Contract, Overrides, constants, ContractTransaction } from 'ethers';
import { readFileSync, writeFileSync } from 'fs';
import Pino from 'pino';
import sha256 from 'sha256';
import CONTRACTS from '../src/contracts';
import {
CONTRACT_FACTORY,
ContractDeployment,
ContractDeploymentInner,
ContractName,
FactoryContstructor,
SQContracts,
SubqueryNetwork,
} from '../src/types';
import { getLogger } from './logger';
import {
ConsumerHost,
ConsumerRegistry,
DisputeManager,
EraManager,
IndexerRegistry,
InflationController,
PlanManager,
PriceOracle,
ProjectRegistry,
ProxyAdmin,
ProxyAdmin__factory,
PurchaseOfferMarket,
RewardsDistributor,
RewardsHelper,
RewardsPool,
RewardsStaking,
SQToken,
ServiceAgreementRegistry,
Settings,
Staking,
StakingManager,
StateChannel,
VSQToken,
Vesting,
TransparentUpgradeableProxy__factory,
TokenExchange,
OpDestination,
SQTGift,
SQTRedeem,
Airdropper,
VTSQToken,
RewardsBooster,
StakingAllocation,
L2SQToken,
AirdropperLite,
L2Vesting,
UniswapPriceOracle,
} from '../src';
import { Config, ContractConfig, Contracts, UPGRADEBAL_CONTRACTS } from './contracts';
import { l1StandardBridge } from './L1StandardBridge';
let wallet: Wallet;
let network: SubqueryNetwork;
let logger: Pino.Logger;
let confirms: number;
let config: ContractConfig;
let deployment: Partial<ContractDeployment> = {};
function clearObject(obj: Record<string, unknown>) {
const keys = Object.keys(obj);
for (const key of keys) {
delete obj[key];
}
}
function codeToHash(code: string) {
return sha256(Buffer.from(code.replace(/^0x/, ''), 'hex'));
}
async function getOverrides(): Promise<Overrides> {
const price = await wallet.provider.getGasPrice();
// console.log(`gasprice: ${price.toString()}`)
// price = price.add(15000000000); // add extra 15 gwei
return { gasPrice: price };
}
export function saveDeployment(name: string, deployment: Partial<ContractDeployment>) {
const filePath = `${__dirname}/../publish/${name}.json`;
writeFileSync(filePath, JSON.stringify(deployment, null, 4));
}
function loadDeployment(name: string) {
const filePath = `${__dirname}/../publish/${name}.json`;
const deployment = JSON.parse(readFileSync(filePath, 'utf8'));
getLogger('Load Deployments').info(`Load deployment for network: ${name} from ${filePath}:`);
return deployment;
}
async function deployContract<T extends BaseContract>(
name: ContractName,
target: 'root' | 'child',
options?: {
proxyAdmin?: ProxyAdmin;
initConfig?: (string | number | string[])[];
deployConfig?: Config[];
}
): Promise<T> {
if (!deployment[target]) {
deployment[target] = {} as unknown;
}
const contractAddress = deployment[target][name]?.address;
if (contractAddress) {
logger?.info(`🎃 Contract ${name} already deployed at ${contractAddress}`);
return CONTRACT_FACTORY[name].connect(contractAddress, wallet) as T;
}
logger?.info('🤞 Deploying contract');
let contract: T;
let innerAddress = '';
const { proxyAdmin, initConfig } = options ?? {};
const deployConfig = options?.deployConfig ?? [];
if (proxyAdmin) {
[contract, innerAddress] = await deployProxy<T>(proxyAdmin, CONTRACT_FACTORY[name], wallet, confirms);
} else {
const overrides = await getOverrides();
contract = (await new CONTRACT_FACTORY[name](wallet).deploy(...deployConfig, overrides)) as T;
logger?.info(`🔎 Tx hash: ${contract.deployTransaction.hash}`);
await contract.deployTransaction.wait(confirms);
}
logger?.info(`🚀 Contract address: ${contract.address}`);
if (initConfig) {
logger?.info('🤞 Init contract');
const defaultConfig = config[name] ?? [];
const params = [...initConfig, ...defaultConfig];
const overrides = await getOverrides();
// @ts-expect-error type missing
const tx = await contract.initialize(...params, overrides);
logger?.info(`🔎 Tx hash: ${tx.hash}`);
await tx.wait(confirms);
logger?.info(`🚀 Contract initialized`);
}
updateDeployment(deployment, name, contract, innerAddress, target);
return contract;
}
export const deployProxy = async <C extends Contract>(
proxyAdmin: ProxyAdmin,
ContractFactory: FactoryContstructor,
wallet: Wallet,
confirms: number
): Promise<[C, string]> => {
const contractFactory = new ContractFactory(wallet);
const contractLogic = await contractFactory.deploy(await getOverrides());
logger?.info(`🔎 Tx hash: contractLogic ${contractLogic.deployTransaction.hash}`);
await contractLogic.deployTransaction.wait(confirms);
const transparentUpgradeableProxyFactory = new TransparentUpgradeableProxy__factory(wallet);
const contractProxy = await transparentUpgradeableProxyFactory.deploy(
contractLogic.address,
proxyAdmin.address,
[],
await getOverrides()
);
logger?.info(`🔎 Tx hash: contractProxy ${contractProxy.deployTransaction.hash}`);
await contractProxy.deployTransaction.wait(confirms);
const proxy = contractFactory.attach(contractProxy.address) as C;
// @ts-expect-error type missing
proxy.deployTransaction = contractLogic.deployTransaction;
return [proxy, contractLogic.address];
};
function updateDeployment(
deployment: Partial<ContractDeployment>,
name: ContractName,
contract: Contract,
innerAddr: string,
target: 'root' | 'child'
) {
const address = contract.address;
const txHash = contract.deployTransaction.hash;
if (process.env.DEPLOY_PRINT === 'true') {
console.log(`${name} ${contract.address} deployed at tx ${txHash}`);
}
deployment[target][name] = {
innerAddress: innerAddr,
address,
bytecodeHash: codeToHash(CONTRACTS[name].bytecode),
lastUpdate: new Date().toUTCString(),
};
saveDeployment(network, deployment);
}
export async function deployRootContracts(
_wallet: Wallet,
_config: ContractConfig,
options?: { network: SubqueryNetwork; confirms: number; history: boolean }
): Promise<[Partial<ContractDeployment>, Partial<Contracts>]> {
wallet = _wallet;
config = _config;
confirms = options?.confirms ?? 1;
network = options?.network ?? 'local';
logger = network === 'local' ? undefined : getLogger('Deployer');
if (options?.history) {
const localDeployment = loadDeployment(network);
deployment = localDeployment;
} else {
clearObject(deployment);
}
try {
const proxyAdmin = await deployContract<ProxyAdmin>('ProxyAdmin', 'root');
logger?.info('🤞 ProxyAdmin');
const settings = await deployContract<Settings>('Settings', 'root', { proxyAdmin, initConfig: [] });
logger?.info('🤞 Settings');
const settingsAddress = settings.address;
// deploy SQToken contract
const sqtToken = await deployContract<SQToken>('SQToken', 'root', {
deployConfig: [constants.AddressZero, ...config['SQToken']],
});
logger?.info('🤞 SQToken');
// deploy InflationController
const inflationController = await deployContract<InflationController>('InflationController', 'root', {
initConfig: [settingsAddress],
proxyAdmin,
});
logger?.info('🤞 InflationController');
// setup minter
let tx: ContractTransaction;
const sqtMinter = await sqtToken.getMinter();
if (sqtMinter !== inflationController.address) {
if (network === 'mainnet') {
logger?.warn(`SQToken minter is ${sqtMinter}, not same as inflationController`);
} else {
logger?.info(`🤞 Set SQToken minter, change from ${sqtMinter} to ${inflationController.address}`);
tx = await sqtToken.setMinter(inflationController.address);
logger?.info(`tx: ${tx.hash}`);
await tx.wait(confirms);
}
}
// deploy VTSQToken
const vtSQToken = await deployContract<VTSQToken>('VTSQToken', 'root', {
deployConfig: [constants.AddressZero],
});
logger?.info('🤞 VTSQToken');
//deploy vesting contract
const vesting = await deployContract<Vesting>('Vesting', 'root', {
deployConfig: [sqtToken.address, vtSQToken.address],
});
logger?.info('🤞 Vesting');
// set vesting contract as the minter of vtSQToken
const vtSQTMinter = await vtSQToken.minter();
if (vtSQTMinter !== vesting.address) {
logger?.info(`🤞 Set VTSQToken minter, change from ${vtSQTMinter} to ${vesting.address}`);
tx = await vtSQToken.setMinter(vesting.address);
await tx.wait(confirms);
}
let opDestination: OpDestination;
if (network !== 'testnet-mumbai') {
//deploy OpDestination contract
opDestination = await deployContract<OpDestination>('OpDestination', 'root', {
deployConfig: [
sqtToken.address,
deployment.child?.SQToken?.address ?? constants.AddressZero,
l1StandardBridge[network]?.address ?? constants.AddressZero,
],
});
logger?.info('🤞 OpDestination');
}
const inflationDest = await inflationController.inflationDestination();
if (inflationDest !== opDestination.address) {
logger?.info(`🤞 Set inflationDestination, change from ${inflationDest} to ${opDestination.address}`);
tx = await inflationController.setInflationDestination(opDestination.address);
await tx.wait(confirms);
}
const baseRecipient = await opDestination.xcRecipient();
if (network === 'mainnet') {
const treasury = '0x31E99bdA5939bA2e7528707507b017f43b67F89B';
if (baseRecipient !== treasury) {
logger?.info(`🤞 Set OpDestination's xcRecipient, change from ${baseRecipient} to ${treasury}`);
tx = await opDestination.setXcRecipient(treasury);
await tx.wait(confirms);
}
}
// deploy VTSQToken
const airdropperLite = await deployContract<AirdropperLite>('AirdropperLite', 'root', {
proxyAdmin,
initConfig: [],
});
logger?.info('🤞 AirdropLite');
logger?.info('🤞 Set addresses');
tx = await settings.setBatchAddress(
[SQContracts.SQToken, SQContracts.InflationController, SQContracts.Vesting],
[sqtToken.address, inflationController.address, vesting.address]
);
await tx.wait(confirms);
// Register addresses on settings contract
return [
deployment,
{
inflationController,
rootToken: sqtToken,
vtSQToken,
proxyAdmin,
vesting,
opDestination,
airdropperLite,
},
];
} catch (error) {
getLogger('ContractDeployment').info(`Failed to deploy contracts: ${JSON.stringify(error)}`);
saveDeployment(network, deployment);
}
}
export async function deployContracts(
_wallet: Wallet,
_config: ContractConfig,
options?: { network: SubqueryNetwork; confirms: number; history: boolean }
): Promise<[Partial<ContractDeployment>, Partial<Contracts>]> {
wallet = _wallet;
config = _config;
confirms = options?.confirms ?? 1;
network = options?.network ?? 'local';
logger = network === 'local' ? undefined : getLogger('Child Deployer');
if (options?.history) {
const localDeployment = loadDeployment(network);
deployment = localDeployment;
} else {
clearObject(deployment);
}
try {
const proxyAdmin = await deployContract<ProxyAdmin>('ProxyAdmin', 'child');
const settings = await deployContract<Settings>('Settings', 'child', { proxyAdmin, initConfig: [] });
const settingsAddress = settings.address;
// We don't need to deploy ChildErc20, polygon team will do it for us when we request tokenMapping
// deploy SQToken contract
let sqtToken;
if (network === 'local') {
sqtToken = await deployContract<SQToken>('SQToken', 'child', {
deployConfig: [...config['SQToken']],
});
} else {
sqtToken = await deployContract<L2SQToken>('L2SQToken', 'child', {
deployConfig: [...config['L2SQToken']],
});
}
// deploy VSQToken contract
const vsqtToken = await deployContract<VSQToken>('VSQToken', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy Staking contract
const staking = await deployContract<Staking>('Staking', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy StakingManager contract
const stakingManager = await deployContract<StakingManager>('StakingManager', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy Era manager
const eraManager = await deployContract<EraManager>('EraManager', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy IndexerRegistry contract
const indexerRegistry = await deployContract<IndexerRegistry>('IndexerRegistry', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy ProjectRegistry contract
const projectRegistry = await deployContract<ProjectRegistry>('ProjectRegistry', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy PlanManager contract
const planManager = await deployContract<PlanManager>('PlanManager', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy PurchaseOfferMarket contract
const purchaseOfferMarket = await deployContract<PurchaseOfferMarket>('PurchaseOfferMarket', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy ServiceAgreementRegistry contract
const serviceAgreementRegistry = await deployContract<ServiceAgreementRegistry>(
'ServiceAgreementRegistry',
'child',
{
proxyAdmin,
initConfig: [settingsAddress, [planManager.address, purchaseOfferMarket.address]],
}
);
const tokenExchange = await deployContract<TokenExchange>('TokenExchange', 'child', { initConfig: [] });
// deploy RewardsDistributor contract
const rewardsDistributor = await deployContract<RewardsDistributor>('RewardsDistributor', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy RewardsPool contract
const rewardsPool = await deployContract<RewardsPool>('RewardsPool', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy RewardsStaking contract
const rewardsStaking = await deployContract<RewardsStaking>('RewardsStaking', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy RewardsHelper contract
const rewardsHelper = await deployContract<RewardsHelper>('RewardsHelper', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy stateChannel contract
const stateChannel = await deployContract<StateChannel>('StateChannel', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy ConsumerHost contract
const consumerHost = await deployContract<ConsumerHost>('ConsumerHost', 'child', {
proxyAdmin,
initConfig: [settingsAddress, sqtToken.address, stateChannel.address],
});
// deploy DisputeManager contract
const disputeManager = await deployContract<DisputeManager>('DisputeManager', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy ConsumerRegistry contract
const consumerRegistry = await deployContract<ConsumerRegistry>('ConsumerRegistry', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy PriceOracle contract
const priceOracle = await deployContract<PriceOracle>('PriceOracle', 'child', {
proxyAdmin,
initConfig: [10, 3600],
});
// delpoy SQTGift (NFT) contract
const sqtGift = await deployContract<SQTGift>('SQTGift', 'child', {
proxyAdmin,
initConfig: [],
});
// deploy SQTRedeem (NFT redeem) contract
const sqtRedeem = await deployContract<SQTRedeem>('SQTRedeem', 'child', {
proxyAdmin,
initConfig: [sqtToken.address],
});
//deploy Airdropper contract
const airdropper = await deployContract<Airdropper>('Airdropper', 'child', {
proxyAdmin,
initConfig: [],
});
// deploy rewardsBooster contract
const rewardsBooster = await deployContract<RewardsBooster>('RewardsBooster', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
// deploy StakingAllocation contract
const stakingAllocation = await deployContract<StakingAllocation>('StakingAllocation', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
//deploy vesting contract
const l2Vesting = await deployContract<L2Vesting>('L2Vesting', 'child', {
proxyAdmin,
initConfig: [settingsAddress],
});
//deploy uniswapPriceOracle contract
const uniswapPriceOracle = await deployContract<UniswapPriceOracle>('UniswapPriceOracle', 'child', {
deployConfig: [...config['UniswapPriceOracle']],
});
// Register addresses on settings contract
logger?.info('🤞 Set settings addresses');
const txToken = await settings.setBatchAddress(
[
SQContracts.SQToken,
SQContracts.Staking,
SQContracts.StakingManager,
SQContracts.RewardsDistributor,
SQContracts.RewardsPool,
SQContracts.RewardsStaking,
SQContracts.RewardsHelper,
SQContracts.PriceOracle,
SQContracts.IndexerRegistry,
SQContracts.ProjectRegistry,
SQContracts.EraManager,
SQContracts.PlanManager,
SQContracts.ServiceAgreementRegistry,
SQContracts.DisputeManager,
SQContracts.StateChannel,
SQContracts.ConsumerRegistry,
SQContracts.RewardsBooster,
SQContracts.StakingAllocation,
],
[
sqtToken.address,
staking.address,
stakingManager.address,
rewardsDistributor.address,
rewardsPool.address,
rewardsStaking.address,
rewardsHelper.address,
priceOracle.address,
indexerRegistry.address,
projectRegistry.address,
eraManager.address,
planManager.address,
serviceAgreementRegistry.address,
disputeManager.address,
stateChannel.address,
consumerRegistry.address,
rewardsBooster.address,
stakingAllocation.address,
]
);
await txToken.wait(confirms);
logger?.info('🚀 Set settings success');
return [
deployment,
{
settings,
token: sqtToken,
vtoken: vsqtToken,
staking,
stakingManager,
eraManager,
indexerRegistry,
projectRegistry,
planManager,
purchaseOfferMarket,
serviceAgreementRegistry,
// serviceAgreementExtra,
rewardsDistributor,
rewardsPool,
rewardsStaking,
rewardsHelper,
rewardsBooster,
proxyAdmin,
stateChannel,
consumerHost,
disputeManager,
tokenExchange,
priceOracle,
consumerRegistry,
sqtGift,
sqtRedeem,
airdropper,
stakingAllocation,
l2Vesting,
},
];
} catch (error) {
getLogger('ContractDeployment').info(`Failed to deploy contracts: ${JSON.stringify(error)}`);
saveDeployment(network, deployment);
}
}
export const upgradeContract = async (
proxyAdmin: ProxyAdmin,
proxyAddress: string,
ContractFactory: FactoryContstructor,
_wallet: Wallet,
confirms: number,
implementationOnly: boolean
): Promise<[string, Contract]> => {
wallet = _wallet;
const contractFactory = new ContractFactory(wallet);
const contract = await contractFactory.deploy(await getOverrides());
await contract.deployTransaction.wait(confirms);
if (!implementationOnly) {
const tx = await proxyAdmin.upgrade(proxyAddress, contract.address);
await tx.wait(confirms);
}
return [contract.address, contract];
};
export async function upgradeContracts(configs: {
wallet: Wallet;
deployment: ContractDeployment;
confirms: number;
checkOnly: boolean;
implementationOnly: boolean;
target: string;
matcher?: string[];
network: SubqueryNetwork;
}): Promise<ContractDeployment> {
const { deployment, confirms, checkOnly, implementationOnly, target, matcher } = configs;
wallet = configs.wallet;
network = configs.network;
const logger = getLogger('Upgrade Contract');
logger.info(`Upgrade contract with wallet ${wallet.address}`);
let _deployment: ContractDeploymentInner;
let proxyAdmin: ProxyAdmin;
if (target === 'root') {
_deployment = deployment.root;
proxyAdmin = ProxyAdmin__factory.connect(deployment.root.ProxyAdmin.address, wallet);
} else if (target === 'child') {
_deployment = deployment.child;
proxyAdmin = ProxyAdmin__factory.connect(deployment.child.ProxyAdmin.address, wallet);
}
const changed: (keyof typeof CONTRACTS)[] = [];
for (const contract of Object.keys(UPGRADEBAL_CONTRACTS)) {
if (matcher && !matcher.includes(contract)) {
continue;
}
const bytecodeHash = codeToHash(CONTRACTS[contract].bytecode);
if (_deployment[contract] && bytecodeHash !== _deployment[contract].bytecodeHash) {
changed.push(contract as unknown as keyof typeof CONTRACTS);
} else {
logger.info(`Contract ${contract} not changed`);
}
}
if (!changed.length) {
logger.info('No Contracts Changed');
return;
}
logger.info(`Contract Changed: ${changed.join(',')}`);
if (checkOnly) return deployment;
for (const contractName of changed) {
const [_, factory] = UPGRADEBAL_CONTRACTS[contractName];
if (!_deployment[contractName]) {
console.warn(`contract ${contractName} not deployed`);
continue;
}
logger.info(`Upgrading ${contractName}`);
const { address } = _deployment[contractName];
const [innerAddr] = await upgradeContract(proxyAdmin, address, factory, wallet, confirms, implementationOnly);
_deployment[contractName] = {
innerAddress: innerAddr,
address,
bytecodeHash: codeToHash(CONTRACTS[contractName].bytecode),
lastUpdate: new Date().toUTCString(),
};
saveDeployment(network, deployment);
}
return deployment;
}