Skip to content

Commit

Permalink
feat: downgrade @openzeppelin/[email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
shottah committed Jul 27, 2024
1 parent 8a0ab6d commit 4de8b1c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
8 changes: 4 additions & 4 deletions contracts/Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
7 changes: 4 additions & 3 deletions test/minting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
});
});
});
5 changes: 1 addition & 4 deletions test/transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});

Expand Down

0 comments on commit 4de8b1c

Please sign in to comment.