-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve deployemnt scripts for nfg-collection
- Loading branch information
Andres Adjimann
committed
Dec 16, 2024
1 parent
4291ff9
commit be592bc
Showing
4 changed files
with
104 additions
and
60 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
61 changes: 61 additions & 0 deletions
61
packages/deploy/deploy/28_nft_collection/03_check_nft_collection_beacon.ts
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,61 @@ | ||
import {ZeroAddress} from 'ethers'; | ||
import {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import {DEPLOY_TAGS} from '../../hardhat.config'; | ||
import { | ||
getEventArgsFromReceipt, | ||
saveDeployment, | ||
} from '../../utils/hardhatDeployUtils'; | ||
import {getNamedAccounts} from 'hardhat'; | ||
|
||
// usually the deployments are done via defender proposals. | ||
// This step lets us continue the deployment after proposal execution | ||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const {deployments, ethers} = hre; | ||
const beaconAlias = ethers.encodeBytes32String('nft-collection-v2'); | ||
const implementation = await deployments.get('NFTCollection_Implementation'); | ||
const beaconAddress = await deployments.read( | ||
'CollectionFactory', | ||
'aliasToBeacon', | ||
beaconAlias | ||
); | ||
if (beaconAddress == ZeroAddress) { | ||
throw new Error('Beacon deployment missing'); | ||
} | ||
const d = await deployments.getOrNull('NFTCollection_Beacon'); | ||
if (!d) { | ||
await saveDeployment( | ||
deployments, | ||
beaconAddress, | ||
'NFTCollection_Beacon', | ||
'UpgradeableBeacon' | ||
); | ||
} | ||
|
||
const beaconArtifact = await deployments.getArtifact('UpgradeableBeacon'); | ||
const beacon = await ethers.getContractAt(beaconArtifact.abi, beaconAddress); | ||
const i = await beacon.implementation(); | ||
if (i != implementation.address) { | ||
throw new Error( | ||
'something went wrong: Beacon already deployed but has wrong implementation address, must call updateBeaconImplementation' | ||
); | ||
} | ||
const factory = await deployments.get('CollectionFactory'); | ||
const o = await beacon.owner(); | ||
if (o != factory.address) { | ||
throw new Error( | ||
'something went wrong: Beacon already deployed but has wrong owner' | ||
); | ||
} | ||
}; | ||
|
||
export default func; | ||
func.tags = [ | ||
'PolygonNFTCollection', | ||
'PolygonNFTCollection_Beacon', | ||
'PolygonNFTCollectionBeacon_check', | ||
DEPLOY_TAGS.L2, | ||
DEPLOY_TAGS.L2_PROD, | ||
DEPLOY_TAGS.L2_TEST, | ||
]; | ||
func.dependencies = ['PolygonNFTCollectionBeacon_deploy']; |
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
be592bc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage for this commit
Coverage Report