From 7f516a33530a2eba31c4b5f22e51e4ede231d8ae Mon Sep 17 00:00:00 2001 From: Daniel Lima Date: Mon, 29 Jan 2024 17:28:56 -0300 Subject: [PATCH] Polygon sft single role deploy --- config/index.ts | 1 + scripts/{ => roles-registry}/01-deploy.ts | 2 +- scripts/{ => roles-registry}/02-grant-role.ts | 4 +-- .../{ => roles-registry}/03-revoke-role.ts | 4 +-- .../01-deploy.ts | 36 +++++++++++++++++++ 5 files changed, 42 insertions(+), 5 deletions(-) rename scripts/{ => roles-registry}/01-deploy.ts (97%) rename scripts/{ => roles-registry}/02-grant-role.ts (95%) rename scripts/{ => roles-registry}/03-revoke-role.ts (96%) create mode 100644 scripts/sft-roles-registry-single-role/01-deploy.ts diff --git a/config/index.ts b/config/index.ts index 3904bab..2e99650 100644 --- a/config/index.ts +++ b/config/index.ts @@ -2,4 +2,5 @@ export const DeployAddresses = { ImmutableOwnerCreate2Factory: '0x066f91a9Aa4C33D4ea4c12aBee6f4cb4e919F71d', RolesRegistry: '0xB1b599Ec67ad23AF7FAC240191319822e674571A', KMSDeployer: '0x04c8c6c56dab836f8bd62cb6884371507e706806', + SftRolesRegistryPolygon: '0x071BC9F5aA747A9A8E8cE796e006d10dBf241E04', } diff --git a/scripts/01-deploy.ts b/scripts/roles-registry/01-deploy.ts similarity index 97% rename from scripts/01-deploy.ts rename to scripts/roles-registry/01-deploy.ts index 741f684..0feed88 100644 --- a/scripts/01-deploy.ts +++ b/scripts/roles-registry/01-deploy.ts @@ -1,6 +1,6 @@ import { ethers, network } from 'hardhat' import { AwsKmsSigner } from '@govtechsg/ethers-aws-kms-signer' -import { DeployAddresses } from '../config' +import { DeployAddresses } from '../../config' import { keccak256 } from 'ethers/lib/utils' const kmsCredentials = { diff --git a/scripts/02-grant-role.ts b/scripts/roles-registry/02-grant-role.ts similarity index 95% rename from scripts/02-grant-role.ts rename to scripts/roles-registry/02-grant-role.ts index fd6f0a5..0762155 100644 --- a/scripts/02-grant-role.ts +++ b/scripts/roles-registry/02-grant-role.ts @@ -1,7 +1,7 @@ import { ethers, network } from 'hardhat' import { AwsKmsSigner } from '@govtechsg/ethers-aws-kms-signer' -import { DeployAddresses } from '../config' -import { RoleAssignment } from '../test/types' +import { DeployAddresses } from '../../config' +import { RoleAssignment } from '../../test/types' const kmsCredentials = { accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'AKIAxxxxxxxxxxxxxxxx', // credentials for your IAM user with KMS access diff --git a/scripts/03-revoke-role.ts b/scripts/roles-registry/03-revoke-role.ts similarity index 96% rename from scripts/03-revoke-role.ts rename to scripts/roles-registry/03-revoke-role.ts index f470a80..d4f043e 100644 --- a/scripts/03-revoke-role.ts +++ b/scripts/roles-registry/03-revoke-role.ts @@ -1,7 +1,7 @@ import { ethers, network } from 'hardhat' import { AwsKmsSigner } from '@govtechsg/ethers-aws-kms-signer' -import { DeployAddresses } from '../config' -import { RoleAssignment } from '../test/types' +import { DeployAddresses } from '../../config' +import { RoleAssignment } from '../../test/types' const kmsCredentials = { accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'AKIAxxxxxxxxxxxxxxxx', // credentials for your IAM user with KMS access diff --git a/scripts/sft-roles-registry-single-role/01-deploy.ts b/scripts/sft-roles-registry-single-role/01-deploy.ts new file mode 100644 index 0000000..a330eb8 --- /dev/null +++ b/scripts/sft-roles-registry-single-role/01-deploy.ts @@ -0,0 +1,36 @@ +import { ethers, network } from 'hardhat' +import { AwsKmsSigner } from '@govtechsg/ethers-aws-kms-signer' + +const kmsCredentials = { + accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'AKIAxxxxxxxxxxxxxxxx', // credentials for your IAM user with KMS access + secretAccessKey: process.env.AWS_ACCESS_KEY_SECRET || 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // credentials for your IAM user with KMS access + region: 'us-east-1', // region of your KMS key + keyId: process.env.AWS_KMS_KEY_ID || 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // KMS key id +} + +const NETWORK = network.name +const CONTRACT_NAME = 'SftRolesRegistrySingleRole' + +const networkConfig: any = network.config +const provider = new ethers.providers.JsonRpcProvider(networkConfig.url || '') +const signer = new AwsKmsSigner(kmsCredentials).connect(provider) + +async function main() { + const operator = await signer.getAddress() + console.log(`Deploying ${CONTRACT_NAME} contract on: ${NETWORK} network with ${operator}`) + + const ContractFactory = await ethers.getContractFactory(CONTRACT_NAME) + const contract = await ContractFactory.deploy() + await contract.deployed() + + console.log(`${CONTRACT_NAME} deployed at: ${contract.address}`) +} + +main() + .then(async () => { + console.log('All done!') + }) + .catch(error => { + console.error(error) + process.exitCode = 1 + })