forked from erigontech/erigon
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
905 rpc debug tracetransaction is missing error and revert reason for…
… reverted txs (#945) * Added contracts and stream trace modification * added panic revert handling * added correct contract for reproducing
- Loading branch information
Showing
6 changed files
with
169 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
interface IERC20 { | ||
function totalSupply() external view returns (uint); | ||
function balanceOf(address account) external view returns (uint); | ||
function transfer(address recipient, uint amount) external returns (bool); | ||
function allowance(address owner, address spender) external view returns (uint); | ||
function approve(address spender, uint amount) external returns (bool); | ||
function transferFrom(address sender, address recipient, uint amount) external returns (bool); | ||
|
||
event Transfer(address indexed from, address indexed to, uint value); | ||
event Approval(address indexed owner, address indexed spender, uint value); | ||
} | ||
|
||
contract MyToken is IERC20 { | ||
uint override public totalSupply; | ||
mapping(address => uint) override public balanceOf; | ||
mapping(address => mapping(address => uint)) override public allowance; | ||
uint8 public decimals = 18; | ||
|
||
constructor() { | ||
} | ||
|
||
function transfer(address recipient, uint amount) override external returns (bool) { | ||
balanceOf[msg.sender] -= amount; | ||
balanceOf[recipient] += amount; | ||
emit Transfer(msg.sender, recipient, amount); | ||
return true; | ||
} | ||
|
||
function approve(address spender, uint amount) override external returns (bool) { | ||
allowance[msg.sender][spender] = amount; | ||
emit Approval(msg.sender, spender, amount); | ||
return true; | ||
} | ||
|
||
function transferFrom(address sender, address recipient, uint amount) override external returns (bool) { | ||
allowance[sender][msg.sender] -= amount; | ||
balanceOf[sender] -= amount; | ||
balanceOf[recipient] += amount; | ||
emit Transfer(sender, recipient, amount); | ||
return true; | ||
} | ||
|
||
function mint(uint amount) external { | ||
balanceOf[msg.sender] += amount; | ||
totalSupply += amount; | ||
emit Transfer(address(0), msg.sender, amount); | ||
} | ||
|
||
function burn(uint amount) external { | ||
balanceOf[msg.sender] -= amount; | ||
totalSupply -= amount; | ||
emit Transfer(msg.sender, address(0), amount); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,27 @@ | ||
// deploys contracts and calls a method to produce delegate call | ||
async function main() { | ||
try { | ||
const ERC20 = await hre.ethers.getContractFactory("MyToken"); | ||
|
||
// Deploy the contracts | ||
const erc20 = await ERC20.deploy(); | ||
|
||
// Wait for the deployment transactions to be mined | ||
await erc20.waitForDeployment(); | ||
|
||
console.log(`erc20 deployed to: ${await erc20.getAddress()}`); | ||
|
||
const transferFromResult = await erc20.transferFrom("0x5294ef2a2519BedC457D75b8FE5b132CCE32036a", "0xb218d64f29e5768B5Cc9b791B5514a2C611eE547", 1, {gasLimit: 1000000}); | ||
console.log('transferFromResult method call transaction: ', transferFromResult.hash); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |