raineorshine / solidity-repl

Ethereum Solidity REPL
ISC License
396 stars 33 forks source link

Add support for 'msg' and 'block' #21

Closed djmgit closed 6 years ago

djmgit commented 6 years ago

Added support for special commands like 'msg' and 'block'. Return a struct containing all the required data.

Fixes issue #7

djmgit commented 6 years ago

screenshot from 2018-06-21 21-54-21

djmgit commented 6 years ago

@raineorshine please have a look.

djmgit commented 6 years ago

@raineorshine I have updated my PR. Please have a look.

screenshot from 2018-06-25 01-13-49

block.blockhash is giving the following error:

> block.blockhash
Error compiling Solidity:

1  pragma solidity ^0.4.19;
2  contract ReplContainer {
3    function Main() constant returns (function (uint256) view returns (bytes32)) {
4      
5      return block.blockhash;
6    }
7  }

  :3:37: TypeError: Internal or recursive type is not allowed for public or external functions.
  function Main() constant returns (function (uint256) view returns (bytes32)) {
                                    ^----------------------------------------^
 :3:37: TypeError: Internal or recursive type is not allowed for public or external functions.
  function Main() constant returns (function (uint256) view returns (bytes32)) {
                                    ^----------------------------------------^

Error compiling Solidity
raineorshine commented 6 years ago

Thanks! I'll take a look. I can see now that block.blockhash has been deprecated, so you can ignore that one.

djmgit commented 6 years ago

@raineorshine I will be updating my PR ASAP.

djmgit commented 6 years ago

@raineorshine I have tried to address all of your suggestions, please have a look.

djmgit commented 6 years ago

@raineorshine I have done the required changes. I have also added tests. Please have a look. If I remove .toString from there, then its throwing error.

djmgit commented 6 years ago

@raineorshine I was wrong about the result thing, there was no need for .toString as result is already an array, I ignored the fact that the typeof command returns object for arrays too! I have removed the local variable returnType and have used the inline declarations in both places. Please have a look.

raineorshine commented 6 years ago

Thank you!