Skip to content

Commit

Permalink
Use deployment address from defender
Browse files Browse the repository at this point in the history
  • Loading branch information
alavarello committed Apr 29, 2024
1 parent 1ec61c5 commit dfcbfca
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion scripts/deploy/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
CONTRACT_NAMES,
deploy,
getDeployedContractAddress,
getDeploymentAddress,
logDeployment,
saveDeployment,
} from '../utils';
Expand All @@ -17,7 +18,7 @@ async function main() {
await saveDeployment(registry, CONTRACT_NAMES.REGISTRY);
await logDeployment(registry, CONTRACT_NAMES.REGISTRY, [nameHashAddress]);

await registry.grantRole(ADD_AUTHORIZER_ROLE, await ethers.provider.getSigner());
await registry.grantRole(ADD_AUTHORIZER_ROLE, await getDeploymentAddress());
const sciAuthorizer = await getDeployedContractAddress('SciAuthorizer');
await registry.setAuthorizer(1, sciAuthorizer);
}
Expand Down
10 changes: 8 additions & 2 deletions scripts/deploy/sciAuthorizer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { ethers } from 'hardhat';
import { CONTRACT_NAMES, deploy, logDeployment, saveDeployment } from '../utils';
import {
CONTRACT_NAMES,
deploy,
getDeploymentAddress,
logDeployment,
saveDeployment,
} from '../utils';
import { IS_AUTHORIZED } from '../../utils/roles';

async function main() {
const SCIAuthorizerFactory = await ethers.getContractFactory(CONTRACT_NAMES.SCI_AUTHORIZER);
const sciAuthorizer = await deploy(SCIAuthorizerFactory);

await sciAuthorizer.grantRole(IS_AUTHORIZED, await ethers.provider.getSigner());
await sciAuthorizer.grantRole(IS_AUTHORIZED, await getDeploymentAddress());

await saveDeployment(sciAuthorizer, CONTRACT_NAMES.SCI_AUTHORIZER);
await logDeployment(sciAuthorizer, CONTRACT_NAMES.SCI_AUTHORIZER, []);
Expand Down
9 changes: 9 additions & 0 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@ export async function deploy(factory: ContractFactory, args?: unknown[]): Promis
constructorArgs: args,
salt: 'oGxABr7U4iCnq598aK5Ai25jcgXq6kbaAD859BJWJ2ytvJkzpy',
verifySourceCode: true,
licenseType: 'GNU AGPLv3',
});
}

export async function getDeploymentAddress(): Promise<string> {
const deploymentProcess = await defender.getDeployApprovalProcess();
const address = deploymentProcess.address;
if (!address) throw Error('Deployment Address undefined');

return address;
}

export async function saveDeployment(contract: BaseContract, contractName: string) {
const filePath = await generateDeploymentPath();

Expand Down

0 comments on commit dfcbfca

Please sign in to comment.