-
Notifications
You must be signed in to change notification settings - Fork 2
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
Added a script so we can grant the executor role to MultiCallDeploy #54
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b9a5fd5
Added a script so we can grant the executor role to MultiCallDeploy
shirren a6948e1
Removed contract address hard coding
shirren 1bc260e
Using env for multicalldeploy contract address
shirren 5ebaaa4
Removed reference to private keys in config as we use ledgers
shirren 2bdbea4
PR feedback
shirren 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,59 @@ | ||
import * as hre from 'hardhat'; | ||
import { Contract, ContractFactory, ContractFunction, Transaction } from 'ethers'; | ||
import promptSync from 'prompt-sync'; | ||
|
||
import { EnvironmentInfo, loadEnvironmentInfo } from './environment'; | ||
import { newContractFactory, waitForInput } from './helper-functions'; | ||
import { newWalletOptions, WalletOptions } from './wallet-options'; | ||
|
||
/** | ||
* GrantExecutorRole grants the `EXECUTOR` role to a given address. This function can only | ||
* be invoked by the wallet with the `DEFAULT_ADMIN_ROLE` role. | ||
**/ | ||
async function grantExecutorRole(): Promise<EnvironmentInfo> { | ||
const env = loadEnvironmentInfo(hre.network.name); | ||
const { network, multiCallDeployContractAddress } = env; | ||
const prompt = promptSync(); | ||
|
||
// Setup wallet with default admin role | ||
const wallets: WalletOptions = await newWalletOptions(env); | ||
|
||
// Attach to contract | ||
const contractName = "MultiCallDeploy"; | ||
const contractFactory: ContractFactory = await newContractFactory(wallets.getWallet(), contractName); | ||
|
||
console.log(`[${network}] Confirm contract address ${multiCallDeployContractAddress} ...`); | ||
const multiCallDeploy: Contract = await contractFactory.attach(multiCallDeployContractAddress); | ||
|
||
// Obtain the executor role reference | ||
const executorRole = await multiCallDeploy.EXECUTOR_ROLE(); | ||
console.log(`[${network}] Executor role ${executorRole}`); | ||
|
||
const newAddress = prompt(`[${network}] New address to be added to the executor role: `); | ||
console.log(`[${network}] Confirm new address ${newAddress} ...`); | ||
|
||
await waitForInput(); | ||
|
||
// Only grant the role if the wallet does not already have access to this to this role. | ||
const isExecutor = await multiCallDeploy.hasRole(executorRole, newAddress.trim()); | ||
if (!isExecutor) { | ||
const tx = await multiCallDeploy.grantExecutorRole(newAddress.trim()); | ||
await tx.wait(); | ||
console.log(`[${network}] Executor role granted to ${newAddress}`); | ||
shirren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
console.log(`[${network}] ${newAddress} already has the executor role`); | ||
} | ||
|
||
return env; | ||
} | ||
|
||
// Call primary function | ||
grantExecutorRole() | ||
.then((env: EnvironmentInfo) => { | ||
console.log(`[${env.network}] Grant successful...`); | ||
process.exit(0); | ||
}) | ||
.catch(err => { | ||
console.error(err.message); | ||
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
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.
Alternative which may be simpler:
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.
@Edwardjes do you mind if I keep the 2 step? The function
newContractFactory
is one I wrote that is also used by the deployment scripts, and for consistency i'd like they be all the same without a more pervasive change. Thoughts?