From 4de8b1cb77de99c49dc83b1650abc6cec2a0538e Mon Sep 17 00:00:00 2001 From: shottah Date: Fri, 26 Jul 2024 23:17:59 -0400 Subject: [PATCH] feat: downgrade @openzeppelin/contracts@4.9.4 --- contracts/Token.sol | 8 ++++---- deploy/deploy.ts | 7 +++++++ package.json | 2 +- test/minting.test.ts | 7 ++++--- test/transfer.test.ts | 5 +---- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/contracts/Token.sol b/contracts/Token.sol index 20d68a1..ebabb1a 100644 --- a/contracts/Token.sol +++ b/contracts/Token.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.20; import "@openzeppelin/contracts/access/Ownable.sol"; -import "@openzeppelin/contracts/utils/Pausable.sol"; +import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; /// @title Kolektivo TTD Token @@ -18,7 +18,7 @@ contract KolektivoTTD is Ownable, Pausable, ERC20 { /// @dev Check this list on transfer for special events mapping(address => bool) _isImpactPartner; - constructor() ERC20("Kolektivo Trinidad & Tobago Dollar", "KTTD") Ownable(msg.sender) {} + constructor() ERC20("Kolektivo Trinidad & Tobago Dollar", "KTTD") Ownable() {} /// @notice Disburse tokens to an account. /// @dev Only the owner can disburse tokens, and they are @@ -37,11 +37,11 @@ contract KolektivoTTD is Ownable, Pausable, ERC20 { super._transfer(address(this), address(0), amount); } - function _update(address from, address to, uint256 amount) internal virtual override { + function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { if (_isImpactPartner[to]) { emit ImpactPartnerTransfer(from, to, amount); } - super._update(from, to, amount); + super._beforeTokenTransfer(from, to, amount); } function addPartner(address account) external onlyOwner { diff --git a/deploy/deploy.ts b/deploy/deploy.ts index 11761d9..d86916c 100644 --- a/deploy/deploy.ts +++ b/deploy/deploy.ts @@ -4,6 +4,13 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { deployer } = await hre.getNamedAccounts(); const { deploy } = hre.deployments; + + const token = await deploy("KolektivoTTD", { + from: deployer, + log: true, + }); + + console.log("Token deployed to:", token.address); }; export default func; diff --git a/package.json b/package.json index 929a7bd..95559bb 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain" }, "dependencies": { - "@openzeppelin/contracts": "^5.0.1" + "@openzeppelin/contracts": "^4.9.4" }, "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/test/minting.test.ts b/test/minting.test.ts index a5cf06d..145f98e 100644 --- a/test/minting.test.ts +++ b/test/minting.test.ts @@ -50,14 +50,15 @@ describe("Minting", function () { const [_, alice] = await ethers.getSigners(); await this.token.connect(this.signers.admin).mint(alice.address, 100n); await this.token.connect(this.signers.admin).pause(); + await expect(await this.token.connect(this.signers.admin).paused()).to.be.true; }); it("cannot mint when paused", async function () { const transferAmount = 100n; const [_, bob] = await ethers.getSigners(); - await expect( - this.token.connect(this.signers.admin).mint(bob.address, transferAmount), - ).to.be.revertedWithCustomError(this.token, "EnforcedPause"); + await expect(this.token.connect(this.signers.admin).mint(bob.address, transferAmount)).to.be.revertedWith( + "Pausable: paused", + ); }); }); }); diff --git a/test/transfer.test.ts b/test/transfer.test.ts index 3974b74..25c9fa5 100644 --- a/test/transfer.test.ts +++ b/test/transfer.test.ts @@ -46,10 +46,7 @@ describe("Transfering", function () { it("can transfer when paused", async function () { const transferAmount = 100n; const [_, alice, bob] = await ethers.getSigners(); - await expect(this.token.connect(alice).transfer(bob.address, transferAmount)).to.not.be.revertedWithCustomError( - this.token, - "EnforcedPause", - ); + await expect(this.token.connect(alice).transfer(bob.address, transferAmount)).to.not.be.reverted; }); });