forked from aragon/osx-plugin-template-hardhat
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: update deploy script #33
Draft
clauBv23
wants to merge
4
commits into
develop
Choose a base branch
from
feat/update-deploy-script
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
68f8cc9
feat: import the Placeholder to de able to deploy it
clauBv23 6d34798
feat: update the scripts to be able to get the plugin reo and the plu…
clauBv23 382bed0
feat: some cleaning
clauBv23 d582907
feat: modify the update plugin script to get the addresses from the c…
clauBv23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import { | |
PluginRepo__factory, | ||
PluginRepoFactory__factory, | ||
} from '@aragon/osx-ethers'; | ||
import {ethers} from 'hardhat'; | ||
import {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import path from 'path'; | ||
|
@@ -27,6 +28,7 @@ import path from 'path'; | |
* @param {HardhatRuntimeEnvironment} hre | ||
*/ | ||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
// todo change this log | ||
console.log( | ||
`Creating the '${pluginEnsDomain( | ||
hre | ||
|
@@ -36,23 +38,55 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | |
const [deployer] = await hre.ethers.getSigners(); | ||
|
||
// Get the Aragon `PluginRepoFactory` from the `osx-commons-configs` | ||
const productionNetworkName = getProductionNetworkName(hre); | ||
const network = getNetworkNameByAlias(productionNetworkName); | ||
if (network === null) { | ||
throw new UnsupportedNetworkError(productionNetworkName); | ||
} | ||
const networkDeployments = getLatestNetworkDeployment(network); | ||
if (networkDeployments === null) { | ||
throw `Deployments are not available on network ${network}.`; | ||
let pluginRepoFactoryAddress; | ||
let subdomainRegistrar; | ||
if ( | ||
process.env.PLUGIN_REPO_FACTORY_ADDRESS && | ||
process.env.PLUGIN_REPO_FACTORY_ADDRESS !== ethers.constants.AddressZero | ||
) { | ||
// use this factory | ||
pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; | ||
|
||
const pluginRepoFactory = PluginRepoFactory__factory.connect( | ||
pluginRepoFactoryAddress, | ||
deployer | ||
); | ||
|
||
const pluginRepoRegistry = PluginRepoRegistry__factory.connect( | ||
await pluginRepoFactory.pluginRepoRegistry(), | ||
deployer | ||
); | ||
subdomainRegistrar = await pluginRepoRegistry.subdomainRegistrar(); | ||
} else { | ||
// get the factory from osx-commons-configs deployments | ||
const productionNetworkName = getProductionNetworkName(hre); | ||
const network = getNetworkNameByAlias(productionNetworkName); | ||
if (network === null) { | ||
throw new UnsupportedNetworkError(productionNetworkName); | ||
} | ||
const networkDeployments = getLatestNetworkDeployment(network); | ||
if (networkDeployments === null) { | ||
throw `Deployments are not available on network ${network}.`; | ||
} | ||
pluginRepoFactoryAddress = networkDeployments.PluginRepoFactory.address; | ||
|
||
subdomainRegistrar = | ||
networkDeployments.PluginENSSubdomainRegistrarProxy.address; | ||
} | ||
// subdomain will depend on if the framework has the ens or not | ||
const subdomain = | ||
subdomainRegistrar !== ethers.constants.AddressZero | ||
? PLUGIN_REPO_ENS_SUBDOMAIN_NAME | ||
: 'empty'; // todo set to empty when is possible | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why |
||
|
||
const pluginRepoFactory = PluginRepoFactory__factory.connect( | ||
networkDeployments.PluginRepoFactory.address, | ||
pluginRepoFactoryAddress, | ||
deployer | ||
); | ||
|
||
// Create the `PluginRepo` through the Aragon `PluginRepoFactory` | ||
const tx = await pluginRepoFactory.createPluginRepo( | ||
PLUGIN_REPO_ENS_SUBDOMAIN_NAME, | ||
subdomain, | ||
deployer.address | ||
); | ||
|
||
|
@@ -90,24 +124,46 @@ func.skip = async (hre: HardhatRuntimeEnvironment) => { | |
console.log(`\n🏗️ ${path.basename(__filename)}:`); | ||
|
||
// Check if the ens record exists already | ||
const {pluginRepo, ensDomain} = await findPluginRepo(hre); | ||
let pluginRepoAddress; | ||
let ensDomain = ''; | ||
if ( | ||
!process.env.PLUGIN_REPO_ADDRESS || | ||
process.env.PLUGIN_REPO_ADDRESS === ethers.constants.AddressZero | ||
) { | ||
// try getting the plugin repo from the ens | ||
const res = await findPluginRepo(hre); | ||
pluginRepoAddress = res.pluginRepo?.address; | ||
ensDomain = res.ensDomain; | ||
} else { | ||
// use the provided plugin repo address | ||
pluginRepoAddress = process.env.PLUGIN_REPO_ADDRESS; | ||
|
||
if (pluginRepo !== null) { | ||
console.log( | ||
`ENS name '${ensDomain}' was claimed already at '${ | ||
pluginRepo.address | ||
}' on network '${getProductionNetworkName(hre)}'. Skipping deployment...` | ||
`Plugin Repo already deployed at '${pluginRepoAddress}' on network '${getProductionNetworkName( | ||
hre | ||
)}'. Skipping deployment...` | ||
); | ||
return true; | ||
} | ||
|
||
if (pluginRepoAddress) { | ||
console.log( | ||
`ENS name '${ensDomain}' was claimed already at '${pluginRepoAddress}' on network '${getProductionNetworkName( | ||
hre | ||
)}'. Skipping deployment...` | ||
); | ||
|
||
// todo if the plugin repo was already published should it be verified? | ||
hre.aragonToVerifyContracts.push({ | ||
address: pluginRepo.address, | ||
address: pluginRepoAddress, | ||
args: [], | ||
}); | ||
|
||
return true; | ||
} else { | ||
console.log(`ENS name '${ensDomain}' is unclaimed. Deploying...`); | ||
|
||
// todo change this log | ||
console.log( | ||
`ENS name '${ensDomain}' is unclaimed. Deploying Plugin Repo...` | ||
); | ||
return false; | ||
} | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think instead of 2 lines, which is still not trustful, it's better to directly check if process.env.PLUGIN_REPO_FACTORY_ADDRESS is a type of address. This will eliminate 2 checks.
These 2 checks are not trustworthy because if i set PLUGIN_REPO_FACTORY_ADDRESS=blax, this will still work which is wrong.