Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce blocked addrs feature #30

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ func NewMinitiaApp(
appCodec,
runtime.NewKVStoreService(keys[evmtypes.StoreKey]),
accountKeeper,
bankKeeper,
communityPoolKeeper,
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
Expand Down
1 change: 1 addition & 0 deletions app/ibc-hooks/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ func _createTestInput(
appCodec,
runtime.NewKVStoreService(keys[evmtypes.StoreKey]),
accountKeeper,
bankKeeper,
communityPoolKeeper,
msgRouter,
queryRouter,
Expand Down
1 change: 1 addition & 0 deletions x/bank/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ func _createTestInput(
appCodec,
runtime.NewKVStoreService(keys[evmtypes.StoreKey]),
accountKeeper,
bankKeeper,
communityPoolKeeper,
msgRouter,
queryRouter,
Expand Down
2 changes: 1 addition & 1 deletion x/evm/contracts/counter/Counter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 23 additions & 2 deletions x/evm/contracts/custom_erc20/CustomERC20.go

Large diffs are not rendered by default.

64 changes: 41 additions & 23 deletions x/evm/contracts/custom_erc20/CustomERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ pragma solidity ^0.8.24;
import "../i_erc20/IERC20.sol";
import "../ownable/Ownable.sol";
import "../erc20_registry/ERC20Registry.sol";
import "../erc20_acl/ERC20ACL.sol";
import {ERC165, IERC165} from "../erc165/ERC165.sol";

contract CustomERC20 is IERC20, Ownable, ERC20Registry, ERC165 {
contract CustomERC20 is IERC20, Ownable, ERC20Registry, ERC165, ERC20ACL {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
Expand Down Expand Up @@ -42,32 +43,14 @@ contract CustomERC20 is IERC20, Ownable, ERC20Registry, ERC165 {
decimals = _decimals;
}

function transfer(
address recipient,
uint256 amount
) external register_erc20_store(recipient) returns (bool) {
balanceOf[msg.sender] -= amount;
balanceOf[recipient] += amount;
emit Transfer(msg.sender, recipient, amount);
return true;
}

function approve(address spender, uint256 amount) external returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}

function transferFrom(
function _transfer(
address sender,
address recipient,
uint256 amount
) external register_erc20_store(recipient) returns (bool) {
allowance[sender][msg.sender] -= amount;
) internal register_erc20_store(recipient) {
balanceOf[sender] -= amount;
balanceOf[recipient] += amount;
emit Transfer(sender, recipient, amount);
return true;
}

function _mint(
Expand All @@ -85,11 +68,46 @@ contract CustomERC20 is IERC20, Ownable, ERC20Registry, ERC165 {
emit Transfer(from, address(0), amount);
}

function mint(address to, uint256 amount) external onlyOwner {
function transfer(
address recipient,
uint256 amount
) external transferable(recipient) returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}

function approve(address spender, uint256 amount) external returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}

function transferFrom(
address sender,
address recipient,
uint256 amount
) external transferable(recipient) returns (bool) {
allowance[sender][msg.sender] -= amount;
_transfer(sender, recipient, amount);
return true;
}

function mint(address to, uint256 amount) external mintable(to) onlyOwner {
_mint(to, amount);
}

function burn(address from, uint256 amount) external onlyOwner {
function burn(
address from,
uint256 amount
) external burnable(from) onlyOwner {
_burn(from, amount);
}

function sudoTransfer(
address sender,
address recipient,
uint256 amount
) external onlyChain {
_transfer(sender, recipient, amount);
}
}
67 changes: 65 additions & 2 deletions x/evm/contracts/erc20/ERC20.go

Large diffs are not rendered by default.

68 changes: 47 additions & 21 deletions x/evm/contracts/erc20/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ pragma solidity ^0.8.24;
import "../i_erc20/IERC20.sol";
import "../ownable/Ownable.sol";
import "../erc20_registry/ERC20Registry.sol";
import "../erc20_acl/ERC20ACL.sol";
import {ERC165, IERC165} from "../erc165/ERC165.sol";

contract ERC20 is IERC20, Ownable, ERC20Registry, ERC165 {
contract ERC20 is IERC20, Ownable, ERC20Registry, ERC165, ERC20ACL {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
Expand Down Expand Up @@ -39,13 +40,36 @@ contract ERC20 is IERC20, Ownable, ERC20Registry, ERC165 {
decimals = _decimals;
}

function transfer(
function _transfer(
address sender,
address recipient,
uint256 amount
) external register_erc20_store(recipient) returns (bool) {
balanceOf[msg.sender] -= amount;
) internal register_erc20_store(recipient) {
balanceOf[sender] -= amount;
balanceOf[recipient] += amount;
emit Transfer(msg.sender, recipient, amount);
emit Transfer(sender, recipient, amount);
}

function _mint(
address to,
uint256 amount
) internal register_erc20_store(to) {
balanceOf[to] += amount;
totalSupply += amount;
emit Transfer(address(0), to, amount);
}

function _burn(address from, uint256 amount) internal {
balanceOf[from] -= amount;
totalSupply -= amount;
emit Transfer(from, address(0), amount);
}

function transfer(
address recipient,
uint256 amount
) external transferable(recipient) returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}

Expand All @@ -59,34 +83,36 @@ contract ERC20 is IERC20, Ownable, ERC20Registry, ERC165 {
address sender,
address recipient,
uint256 amount
) external register_erc20_store(recipient) returns (bool) {
) external transferable(recipient) returns (bool) {
allowance[sender][msg.sender] -= amount;
balanceOf[sender] -= amount;
balanceOf[recipient] += amount;
emit Transfer(sender, recipient, amount);
_transfer(sender, recipient, amount);
return true;
}

function _mint(
address to,
function mint(address to, uint256 amount) external mintable(to) onlyOwner {
_mint(to, amount);
}

function burn(
address from,
uint256 amount
) internal register_erc20_store(to) {
balanceOf[to] += amount;
totalSupply += amount;
emit Transfer(address(0), to, amount);
) external burnable(from) onlyOwner {
_burn(from, amount);
}

function _burn(address from, uint256 amount) internal {
balanceOf[from] -= amount;
totalSupply -= amount;
emit Transfer(from, address(0), amount);
function sudoTransfer(
address sender,
address recipient,
uint256 amount
) external onlyChain {
_transfer(sender, recipient, amount);
}

function mint(address to, uint256 amount) external onlyOwner {
function sudoMint(address to, uint256 amount) external onlyChain {
_mint(to, amount);
}

function burn(address from, uint256 amount) external onlyOwner {
function sudoBurn(address from, uint256 amount) external onlyChain {
_burn(from, amount);
}
}
Loading
Loading