-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1902 from skalenetwork/develop-to-3.19.0
Develop to 3.19.0
- Loading branch information
Showing
13 changed files
with
628 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
/** | ||
* ERC20Custom.sol - SKALE Test tokens | ||
* Copyright (C) 2022-Present SKALE Labs | ||
* @author Artem Payvin | ||
* | ||
* SKALE IMA is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* SKALE IMA is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
contract ERC20Custom { | ||
|
||
mapping (address => uint256) private _balances; | ||
|
||
mapping (address => mapping (address => uint256)) private _allowances; | ||
|
||
uint256 private _totalSupply; | ||
|
||
string private _name; | ||
string private _symbol; | ||
uint8 private _decimals; | ||
|
||
event Approval(address owner, address spender, uint256 amount); | ||
|
||
event Transfer(address from, address to, uint256 amount); | ||
|
||
constructor(string memory tokenName, string memory tokenSymbol) { | ||
_name = tokenName; | ||
_symbol = tokenSymbol; | ||
_decimals = 18; | ||
|
||
_mint(tx.origin, 10); | ||
} | ||
|
||
function mint(address account, uint256 amount) external returns (bool) { | ||
_mint(account, amount); | ||
return true; | ||
} | ||
|
||
/** | ||
* @dev burn - destroys token on msg sender | ||
* | ||
* NEED TO HAVE THIS FUNCTION ON SKALE-CHAIN | ||
* | ||
* @param amount - amount of tokens | ||
*/ | ||
function burn(uint256 amount) external { | ||
_burn(msg.sender, amount); | ||
} | ||
|
||
function name() public view returns (string memory) { | ||
return _name; | ||
} | ||
|
||
function symbol() public view returns (string memory) { | ||
return _symbol; | ||
} | ||
|
||
function decimals() public view returns (uint8) { | ||
return _decimals; | ||
} | ||
|
||
function totalSupply() public view returns (uint256) { | ||
return _totalSupply; | ||
} | ||
|
||
function balanceOf(address account) public view returns (uint256) { | ||
return _balances[account]; | ||
} | ||
|
||
function transfer(address recipient, uint256 amount) public virtual returns (bool) { | ||
this._transfer1(); | ||
return true; | ||
} | ||
|
||
function allowance(address owner, address spender) public view virtual returns (uint256) { | ||
return _allowances[owner][spender]; | ||
} | ||
|
||
function approve(address spender, uint256 amount) public virtual returns (bool) { | ||
_approve(msg.sender, spender, amount); | ||
return true; | ||
} | ||
|
||
function transferFrom(address sender, address recipient, uint256 amount) public virtual returns (bool) { | ||
_transfer(sender, recipient, amount); | ||
_approve( | ||
sender, | ||
msg.sender, | ||
_allowances[sender][msg.sender] - amount | ||
); | ||
return true; | ||
} | ||
|
||
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { | ||
_approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); | ||
return true; | ||
} | ||
|
||
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { | ||
_approve( | ||
msg.sender, | ||
spender, | ||
_allowances[msg.sender][spender] - subtractedValue | ||
); | ||
return true; | ||
} | ||
|
||
function _transfer1() public { | ||
} | ||
|
||
function _transfer(address sender, address recipient, uint256 amount) internal virtual { | ||
require(sender != address(0), "ERC20: transfer from the zero address"); | ||
require(recipient != address(0), "ERC20: transfer to the zero address"); | ||
|
||
_balances[sender] = _balances[sender] - amount; | ||
_balances[recipient] = _balances[recipient] + amount; | ||
emit Transfer(sender, recipient, amount); | ||
} | ||
|
||
function _mint(address account, uint256 amount) internal virtual { | ||
require(account != address(0), "ERC20: mint to the zero address"); | ||
|
||
_totalSupply = _totalSupply + amount; | ||
_balances[account] = _balances[account] + amount; | ||
emit Transfer(address(0), account, amount); | ||
} | ||
|
||
function _burn(address account, uint256 amount) internal virtual { | ||
require(account != address(0), "ERC20: burn from the zero address"); | ||
|
||
_balances[account] = _balances[account] - amount; | ||
_totalSupply = _totalSupply - amount; | ||
emit Transfer(account, address(0), amount); | ||
} | ||
|
||
function _approve(address owner, address spender, uint256 amount) internal virtual { | ||
require(owner != address(0), "ERC20: approve from the zero address"); | ||
require(spender != address(0), "ERC20: approve to the zero address"); | ||
|
||
_allowances[owner][spender] = amount; | ||
emit Approval(owner, spender, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/historicstate/hardhat/scripts/geth_traces/ERC20Custom.transfer.callTracer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"calls": [ | ||
{ | ||
"error": "out of gas", | ||
"from": "ERC20Custom.address", | ||
"gas": "0x51", | ||
"gasUsed": "0x30d", | ||
"input": "0x53bb9b8a", | ||
"to": "ERC20Custom.address", | ||
"type": "CALL" | ||
} | ||
], | ||
"error": "out of gas", | ||
"from": "OWNER.address", | ||
"gas": "0x6239", | ||
"gasUsed": "0x6239", | ||
"input": "0xa9059cbb000000000000000000000000ce5c7ca85f8cb94fa284a303348ef42add23f5e70000000000000000000000000000000000000000000000000000000000000001", | ||
"to": "ERC20Custom.address", | ||
"type": "CALL", | ||
"value": "0x0" | ||
} |
Oops, something went wrong.