Skip to content

Commit

Permalink
ON-876: fixed checks, effects and interactions, also included deploy …
Browse files Browse the repository at this point in the history
…script
  • Loading branch information
ernanirst committed Jul 5, 2024
1 parent 84b8270 commit 87cc826
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
5 changes: 2 additions & 3 deletions contracts/ERC7589/ERC7589RolesRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ contract ERC7589RolesRegistry is IERC7589, ERC1155Holder, IERC7589LockTokensAndG
uint256 _tokenId = tokenLocks[_lockId].tokenId;
uint256 _tokenAmount = tokenLocks[_lockId].tokenAmount;
delete tokenLocks[_lockId];
emit TokensUnlocked(_lockId);

_transferFrom(address(this), _owner, _tokenAddress, _tokenId, _tokenAmount);
emit TokensUnlocked(_lockId);
}

function setRoleApprovalForAll(address _tokenAddress, address _operator, bool _approved) external {
Expand Down Expand Up @@ -253,8 +252,8 @@ contract ERC7589RolesRegistry is IERC7589, ERC1155Holder, IERC7589LockTokensAndG
require(_tokenAmount > 0, 'ERC7589RolesRegistry: tokenAmount must be greater than zero');
lockId_ = ++lockIdCount;
tokenLocks[lockId_] = TokenLock(_owner, _tokenAddress, _tokenId, _tokenAmount);
emit TokensLocked(_owner, lockId_, _tokenAddress, _tokenId, _tokenAmount);
_transferFrom(_owner, address(this), _tokenAddress, _tokenId, _tokenAmount);
emit TokensLocked(_owner, lockId_, _tokenAddress, _tokenId, _tokenAmount);
}

function _grantERC7589Role(
Expand Down
53 changes: 53 additions & 0 deletions scripts/ERC-7589/ERC7589RolesRegistry/01-deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import hre, { ethers, network } from 'hardhat'
import { AwsKmsSigner } from '@govtechsg/ethers-aws-kms-signer'
import { confirmOrDie, print, colors } from '../../../utils/misc'

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 IMMUTABLE_CONTRACT_NAME = 'ERC7589RolesRegistry'
const MARKETPLACE_CONTRACT = '0xB1D47B09aa6D81d7B00C3A37705a6A157B83C49F'

const networkConfig: any = network.config
const provider = new ethers.providers.JsonRpcProvider(networkConfig.url || '')

const deployer = new AwsKmsSigner(kmsCredentials).connect(provider)

async function main() {
const deployerAddress = await deployer.getAddress()

/** Deploy ERC7589RolesRegistry **/

await confirmOrDie(
`Deploying ${IMMUTABLE_CONTRACT_NAME} contract on: ${NETWORK} network with ${deployerAddress}. Continue?`,
)

const ERC7589RolesRegistryFactory = await ethers.getContractFactory(IMMUTABLE_CONTRACT_NAME, { signer: deployer })
const ERC7589RolesRegistry = await ERC7589RolesRegistryFactory.deploy(MARKETPLACE_CONTRACT, {
gasPrice: ethers.utils.parseUnits('100', 'gwei')

Check failure on line 32 in scripts/ERC-7589/ERC7589RolesRegistry/01-deploy.ts

View workflow job for this annotation

GitHub Actions / build_test_deploy

Insert `,`
})
await ERC7589RolesRegistry.deployed()

console.log(`${IMMUTABLE_CONTRACT_NAME} deployed at: ${ERC7589RolesRegistry.address}`)

print(colors.highlight, `Verifying contract ${IMMUTABLE_CONTRACT_NAME} on ${NETWORK}...`)
await hre.run('verify:verify', {
address: ERC7589RolesRegistry.address,
constructorArguments: [ MARKETPLACE_CONTRACT ],

Check failure on line 41 in scripts/ERC-7589/ERC7589RolesRegistry/01-deploy.ts

View workflow job for this annotation

GitHub Actions / build_test_deploy

Replace `·MARKETPLACE_CONTRACT·` with `MARKETPLACE_CONTRACT`
})
print(colors.success, `Contract ${IMMUTABLE_CONTRACT_NAME} verified!`)
}

main()
.then(async () => {
console.log('All done!')
})
.catch(error => {
console.error(error)
process.exitCode = 1
})

0 comments on commit 87cc826

Please sign in to comment.