Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
50db94a
remove beforeTokenTranser and afterTokenTransfer hooks
JulissaDantes Nov 24, 2022
2e68978
Update contracts using the hooks
JulissaDantes Nov 25, 2022
bdd94d1
ERC20Snapshot changes
JulissaDantes Nov 25, 2022
e03c773
Update ERC20Snapshot mock
JulissaDantes Nov 28, 2022
616c148
Update changelog
JulissaDantes Nov 28, 2022
c2d0313
update changelog
JulissaDantes Nov 28, 2022
a81f1a5
update documentation
JulissaDantes Nov 28, 2022
caf4374
Merge branch 'next-v5.0' into refactor/erc20/mint-burn-transfer
JulissaDantes Nov 29, 2022
4f3adcb
update documentation
JulissaDantes Nov 29, 2022
bbecd36
Merge branch 'refactor/erc20/mint-burn-transfer' of https://github.co…
JulissaDantes Nov 29, 2022
054777e
Post merge fix
JulissaDantes Nov 29, 2022
b3da557
Update ERC20Votes
JulissaDantes Nov 29, 2022
27c7090
add overflow test
JulissaDantes Nov 30, 2022
b4ab7c7
Update contracts/token/ERC20/ERC20.sol
JulissaDantes Dec 2, 2022
dcbc275
Update contracts/token/ERC20/ERC20.sol
JulissaDantes Dec 2, 2022
c3350bd
Update ERC20
JulissaDantes Dec 5, 2022
8565f15
Merge branch 'refactor/erc20/mint-burn-transfer' of https://github.co…
JulissaDantes Dec 5, 2022
a56afc4
update ERC20Capped
JulissaDantes Dec 5, 2022
3ec8abf
Add format
JulissaDantes Dec 5, 2022
4213df3
update revert reason
JulissaDantes Dec 5, 2022
0fc5d3a
run lint
JulissaDantes Dec 5, 2022
975ed99
add checks for external transfer calls
JulissaDantes Dec 5, 2022
00ed155
update ERC20Test
JulissaDantes Dec 5, 2022
0d74d66
Update changelog
JulissaDantes Dec 5, 2022
7110896
Update CHANGELOG
JulissaDantes Dec 5, 2022
4e09ef8
Update CHANGELOG.md
JulissaDantes Dec 9, 2022
ed853fa
Update CHANGELOG.md
JulissaDantes Dec 9, 2022
a2bc30c
Update CHANGELOG.md
JulissaDantes Dec 9, 2022
ed66c58
update test
JulissaDantes Dec 12, 2022
5e67170
update ERC20
JulissaDantes Dec 12, 2022
fe5abf4
Handle zero address parameters
JulissaDantes Dec 12, 2022
1083de9
Update CHANGELOG.md
JulissaDantes Dec 13, 2022
a7a9ff1
Update CHANGELOG.md
JulissaDantes Dec 14, 2022
d6fdf53
Update CHANGELOG.md
JulissaDantes Dec 14, 2022
5e0688b
Update contracts/token/ERC20/ERC20.sol
JulissaDantes Dec 14, 2022
b66eb88
Update contracts/token/ERC20/ERC20.sol
JulissaDantes Dec 14, 2022
d55e714
Update contracts/token/ERC20/ERC20.sol
JulissaDantes Dec 14, 2022
8abfed7
Update unchecked reason
JulissaDantes Dec 14, 2022
278c6d0
Update contracts/token/ERC20/ERC20.sol
JulissaDantes Dec 14, 2022
56e648a
Update ERC20.sol
JulissaDantes Dec 14, 2022
2fc018e
run lint
JulissaDantes Dec 14, 2022
fa58b35
Add unchecked comment
JulissaDantes Dec 14, 2022
58a28b9
Update CHANGELOG.md
frangio Dec 14, 2022
a6ce9e1
Update CHANGELOG.md
frangio Dec 14, 2022
ee4b86a
update mock
JulissaDantes Dec 14, 2022
fc25740
Merge branch 'refactor/erc20/mint-burn-transfer' of https://github.co…
JulissaDantes Dec 14, 2022
30876ac
update docs
frangio Dec 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ERC20Snapshot changes
  • Loading branch information
JulissaDantes committed Nov 25, 2022
commit bdd94d131240abe66c141bdf8abb2d9c46aa0c0a
2 changes: 2 additions & 0 deletions contracts/mocks/ERC20SnapshotMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pragma solidity ^0.8.0;

import "../token/ERC20/extensions/ERC20Snapshot.sol";
import "hardhat/console.sol";

contract ERC20SnapshotMock is ERC20Snapshot {
constructor(
Expand All @@ -11,6 +12,7 @@ contract ERC20SnapshotMock is ERC20Snapshot {
address initialAccount,
uint256 initialBalance
) ERC20(name, symbol) {
console.log("we'll mint");
_mint(initialAccount, initialBalance);
}

Expand Down
4 changes: 4 additions & 0 deletions contracts/token/ERC20/extensions/ERC20Snapshot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Arrays.sol";
import "../../../utils/Counters.sol";
import "hardhat/console.sol";

/**
* @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and
Expand Down Expand Up @@ -127,13 +128,16 @@ abstract contract ERC20Snapshot is ERC20 {
) internal virtual override {
if (from == address(0)) {
// mint
console.log("mint", amount);
_updateTotalSupplySnapshot();
} else if (to == address(0)) {
// burn
console.log("burn", amount);
_updateAccountSnapshot(from);
_updateTotalSupplySnapshot();
} else {
// transfer
console.log("transfer", amount);
_updateAccountSnapshot(from);
_updateAccountSnapshot(to);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part will not work properly if update from 0 to 0

Expand Down
5 changes: 4 additions & 1 deletion test/token/ERC20/extensions/ERC20Snapshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,13 @@ contract('ERC20Snapshot', function (accounts) {
});
});

context('with balance changes after the snapshot', function () {
context.only('with balance changes after the snapshot', function () {
beforeEach(async function () {
console.log('transfer 10');
await this.token.transfer(recipient, new BN('10'), { from: initialHolder });
console.log('mint 50');
await this.token.mint(other, new BN('50'));
console.log('burn 20');
await this.token.burn(initialHolder, new BN('20'));
});

Expand Down