This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rithvikvibhu/new-deploy-verify
New deploy code and contract verification script (+misc)
- Loading branch information
Showing
11 changed files
with
331 additions
and
23 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
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 @@ | ||
deployments/ |
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const fs = require('fs'); | ||
|
||
const namespace = 'matic' | ||
|
||
module.exports = async ({getNamedAccounts, deployments}) => { | ||
const {deploy, execute} = deployments; | ||
const {deployer} = await getNamedAccounts(); | ||
|
||
const ENSRegistry = await deploy('ENSRegistry', { | ||
from: deployer, | ||
args: [], | ||
log: true, | ||
}); | ||
|
||
const Root = await deploy('Root', { | ||
from: deployer, | ||
args: [ENSRegistry.address], | ||
log: true, | ||
}); | ||
|
||
// Set ENSRegistry's owner to Root | ||
if (ENSRegistry.newlyDeployed) { | ||
await execute( | ||
'ENSRegistry', | ||
{ | ||
from: deployer, | ||
log: true | ||
}, | ||
'setOwner', | ||
// args: | ||
'0x0000000000000000000000000000000000000000000000000000000000000000', Root.address | ||
); | ||
} | ||
|
||
const TrustedXNHNSOracle = await deploy('TrustedXNHNSOracle', { | ||
from: deployer, | ||
args: [namespace], | ||
log: true, | ||
}); | ||
|
||
const HNSRegistrar = await deploy('HNSRegistrar', { | ||
from: deployer, | ||
args: [ENSRegistry.address, namespace, TrustedXNHNSOracle.address], | ||
log: true, | ||
}); | ||
|
||
// Set Root's controller to HNSRegistrar | ||
if (Root.newlyDeployed) { | ||
await execute( | ||
'Root', | ||
{ | ||
from: deployer, | ||
log: true | ||
}, | ||
'setController', | ||
// args: | ||
HNSRegistrar.address, true | ||
); | ||
} | ||
|
||
// Allow HNSRegistrar to call XNHNSOracle | ||
if (TrustedXNHNSOracle.newlyDeployed || Root.newlyDeployed) { | ||
await execute( | ||
'TrustedXNHNSOracle', | ||
{ | ||
from: deployer, | ||
log: true | ||
}, | ||
'setCallerPermission', | ||
// args: | ||
HNSRegistrar.address, true | ||
); | ||
} | ||
|
||
const PublicResolver = await deploy('PublicResolver', { | ||
from: deployer, | ||
args: [ENSRegistry.address], | ||
log: true, | ||
}); | ||
|
||
fs.writeFileSync('artifacts/ENSRegistry.address', ENSRegistry.address); | ||
fs.writeFileSync('artifacts/Root.address', Root.address); | ||
fs.writeFileSync('artifacts/TrustedXNHNSOracle.address', TrustedXNHNSOracle.address); | ||
fs.writeFileSync('artifacts/HNSRegistrar.address', HNSRegistrar.address); | ||
fs.writeFileSync('artifacts/PublicResolver.address', PublicResolver.address); | ||
}; | ||
|
||
module.exports.tags = ['all']; |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const fs = require('fs'); | ||
const hre = require('hardhat'); | ||
|
||
const namespace = 'matic'; | ||
|
||
// Comment ones you don't want to verify (lazy peeps customizable way) | ||
const contractNames = [ | ||
'ENSRegistry', | ||
'Root', | ||
'TrustedXNHNSOracle', | ||
'HNSRegistrar', | ||
'PublicResolver' | ||
]; | ||
|
||
// Gather all addresses from artifacts directory | ||
const addresses = {}; | ||
fs.readdirSync(`${hre.config.paths.artifacts}`, {withFileTypes: true}).map(file => { | ||
if (!file.isFile() || !file.name.endsWith('.address')) return; | ||
addresses[file.name.replace(/\.address$/, '')] = fs.readFileSync(`${hre.config.paths.artifacts}/${file.name}`)?.toString() || null; | ||
}) | ||
console.log('Addresses:', addresses); | ||
|
||
// Constructor arguments needed to verify | ||
const constructorArguments = { | ||
'ENSRegistry': [], | ||
'Root': [addresses.ENSRegistry], | ||
'TrustedXNHNSOracle': [namespace], | ||
'HNSRegistrar': [addresses.ENSRegistry, namespace, addresses.TrustedXNHNSOracle], | ||
'PublicResolver': [addresses.ENSRegistry], | ||
}; | ||
console.log('Constructor Arguments:', constructorArguments); | ||
|
||
|
||
// Verify all (uncommented) contracts | ||
async function main() { | ||
for (const name of contractNames) { | ||
console.log(`Verifying contract ${name}...`); | ||
|
||
const address = addresses[name]; | ||
|
||
if (!address || !address.length) { | ||
console.log('No address found, skipping.'); | ||
continue; | ||
} | ||
|
||
try { | ||
await hre.run('verify:verify', { | ||
address: address, | ||
constructorArguments: constructorArguments[name], | ||
}); | ||
} catch (error) { | ||
const alreadyVerified = error.message.includes('Contract source code already verified') || | ||
error.message.includes('Already Verified') | ||
if (alreadyVerified) { | ||
console.log('Already verified, skipping.'); | ||
} else { | ||
throw error; | ||
} | ||
} | ||
|
||
console.log('Done!') | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error) | ||
process.exit(1) | ||
}) |
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 @@ | ||
src/contracts/ |
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
Oops, something went wrong.