This repository has been archived by the owner on Oct 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AP-743: Deployment Script: Logging of TX Hashes (#370)
* Add generic deploy contract function * Update getContractName to accept types as well * Update Diamond-related tasks to use new 'deploy' script * Small refactor in cutDiamond * Refactor deploy * Add deployBehindProxy helper * Make deploy and deployBehindProxy accept factory instance * Revert change to utils/getContractName.ts * Partial: update Deployment to the deploy's generic Deployment<T> type * Create ProxyDeployment type * Split deploy registrar and local registrar scripts * Add dividers to deploy(BehindProxy * Partial: update deployments called in deployAngelProtocl up to deployIndexFund * Update all scripts to use new deploy and deployBehindProxy helpers * Move env.config to config/ * Set types/ as one of root files in tsconfig.json * Update all types imports in tasks/scripts * Add divider at the end of 'deploy' * Move CONFIG into separate config.ts file * Revert contract-address.json * Revert "Move CONFIG into separate config.ts file" This reverts commit 1812364. * Revert "Add divider at the end of 'deploy'" This reverts commit 0a473f4. * Remove divider from deploy * Update error handling * Remove unnecessary changes
- Loading branch information
Nenad Misic
authored
Sep 7, 2023
1 parent
c9bfe25
commit b03cf59
Showing
82 changed files
with
675 additions
and
877 deletions.
There are no files selected for viewing
File renamed without changes.
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
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 |
---|---|---|
|
@@ -74,4 +74,5 @@ export const CONFIG: Config = { | |
}, | ||
}; | ||
|
||
export * from "./env.config"; | ||
export * from "./fees"; |
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
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
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
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
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
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import {ContractFactory} from "ethers"; | ||
import {IDiamondCut} from "typechain-types"; | ||
import {Deployment} from "types"; | ||
|
||
export type FacetCut = {facetName: string; cut: IDiamondCut.FacetCutStruct}; | ||
export type FacetCut = { | ||
deployment: Deployment<ContractFactory>; | ||
cut: IDiamondCut.FacetCutStruct; | ||
}; |
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 |
---|---|---|
@@ -1,58 +1,49 @@ | ||
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers"; | ||
import {HardhatRuntimeEnvironment} from "hardhat/types"; | ||
import {GasFwdFactory__factory, GasFwd__factory} from "typechain-types"; | ||
import {Deployment, getAddresses, getContractName, logger, updateAddresses} from "utils"; | ||
import {Deployment} from "types"; | ||
import {deploy, logger, updateAddresses} from "utils"; | ||
|
||
type Data = { | ||
deployer: SignerWithAddress; | ||
proxyAdmin: string; | ||
factoryOwner: string; | ||
registrar?: string; | ||
registrar: string; | ||
}; | ||
|
||
export async function deployGasFwd( | ||
{deployer, proxyAdmin, factoryOwner, registrar}: Data, | ||
hre: HardhatRuntimeEnvironment | ||
): Promise<{factory: Deployment; implementation: Deployment}> { | ||
logger.out("Deploying Gas Forwarder..."); | ||
|
||
logger.out("Deploying GasFwd implementation..."); | ||
const GF = new GasFwd__factory(deployer); | ||
const gf = await GF.deploy(); | ||
await gf.deployed(); | ||
logger.out(`Address: ${gf.address}`); | ||
|
||
const addresses = await getAddresses(hre); | ||
let registrarAddress = registrar ? registrar : addresses.registrar.proxy; | ||
|
||
logger.out("Deploying factory..."); | ||
const GFF = new GasFwdFactory__factory(deployer); | ||
const constructorArguments: Parameters<GasFwdFactory__factory["deploy"]> = [ | ||
gf.address, | ||
): Promise<{ | ||
factory: Deployment<GasFwdFactory__factory>; | ||
implementation: Deployment<GasFwd__factory>; | ||
}> { | ||
const implementation = await deploy(new GasFwd__factory(deployer)); | ||
|
||
const factory = await deploy(new GasFwdFactory__factory(deployer), [ | ||
implementation.contract.address, | ||
proxyAdmin, | ||
registrarAddress, | ||
]; | ||
const gff = await GFF.deploy(...constructorArguments); | ||
await gff.deployed(); | ||
logger.out(`Address: ${gff.address}`); | ||
registrar, | ||
]); | ||
|
||
logger.out(`Transferring ownership to: ${factoryOwner}...`); | ||
const tx = await gff.transferOwnership(factoryOwner); | ||
const tx = await factory.contract.transferOwnership(factoryOwner); | ||
logger.out(`Tx hash: ${tx.hash}`); | ||
await tx.wait(); | ||
const newOwner = await factory.contract.owner(); | ||
if (newOwner !== factoryOwner) { | ||
throw new Error(`Error updating owner: expected '${factoryOwner}', actual: '${newOwner}'`); | ||
} | ||
|
||
await updateAddresses( | ||
{ | ||
gasFwd: { | ||
implementation: gf.address, | ||
factory: gff.address, | ||
implementation: implementation.contract.address, | ||
factory: factory.contract.address, | ||
}, | ||
}, | ||
hre | ||
); | ||
|
||
return { | ||
implementation: {address: gf.address, contractName: getContractName(GF)}, | ||
factory: {address: gff.address, contractName: getContractName(GFF), constructorArguments}, | ||
}; | ||
return {implementation, factory}; | ||
} |
Oops, something went wrong.