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

[Console] New javascript console runtime #2001

Merged
merged 12 commits into from Nov 2, 2023

Conversation

hyunsooda
Copy link
Contributor

Proposed changes

Ported from ethereum/go-ethereum#20470.

This PR resolves #2000.

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Copy link
Contributor

@ian0371 ian0371 left a comment

Choose a reason for hiding this comment

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

Experimentally tested and confirmed that the issue has been solved.

ian0371

This comment was marked as duplicate.

@blukat29
Copy link
Contributor

Tested that the runtime is ES6 and existing functions are intact.

Details
  • ES6 (JS2015) features (https://www.w3schools.com/js/js_es6.asp)
    • Just checking that the runtime is ES6. Not testing full features.
    • let, const keyword
      > const x = 1; let y = 2;
      undefined
      > x + y
      3
      
    • Arrow functions
      > const f = (x, y) => x*y;
      undefined
      > f(2,3)
      6
      
  • Injected variables
    • console
      > console.log(123); console.error(456);
       123
       456
      
    • bignumber.js (https://mikemcl.github.io/bignumber.js/)
      > var b = new BigNumber("100")
      undefined
      > b.plus(23)
      123
      
    • Web3
      > Web3
      function Web3(provider)
      > web3.currentProvider
      {
        send: function github.com/klaytn/klaytn/console/jsre.MakeCallback.func1(),
        sendAsync: function github.com/klaytn/klaytn/console/jsre.MakeCallback.func1()
      }
      
    • RPCs
      > admin.datadir
      "/home/ubuntu/klaytn/data"
      > admin.sleep(1)
      true
      > debug.isPProfRunning()
      false
      > eth.blockNumber
      136624296
      > klay.blockNumber
      136624299
      > net.networkID
      1001
      > personal.listAccounts
      []
      > rpc.modules
      {
        admin: "1.0",
        debug: "1.0",
        eth: "1.0",
        klay: "1.0",
        net: "1.0",
        personal: "1.0",
        rpc: "1.0",
        web3: "1.0"
      }
      
    • loadScript
      > loadScript("hello.js")
       hello from loaded script
      
    • inspect
      > console.log({ x: 1 })
       [object Object]
      > inspect({ x: 1 })
      {
        x: 1
      }
      
    • Timer
      > setTimeout(() => console.log(1), 1000)
      {}
      >  1
      
      > var t = setInterval(() => console.log(2), 1000)
      undefined
      >  2
       2
       2
      > clearInterval(t)
      undefined
      
  • Autocomplete
     > eth.<TAB><TAB>
     eth._requestManager            eth.getBlockNumber             eth.getTransactionReceipt
     eth.accounts                   eth.getBlockTransactionCount   eth.getUncle
     eth.blockNumber                eth.getBlockUncleCount         eth.getWork
     eth.call                       eth.getCode                    eth.hashrate
    

blukat29
blukat29 previously approved these changes Oct 25, 2023
@hyunsooda hyunsooda dismissed stale reviews from blukat29 and ian0371 via 0144968 October 30, 2023 07:52
@yoomee1313
Copy link
Contributor

It seems that you need to resolve the conflict one more time. Could you resolve the conflict?

@blukat29
Copy link
Contributor

blukat29 commented Nov 2, 2023

Resolved on GitHub. PTAL.

@hyunsooda
Copy link
Contributor Author

hyunsooda commented Nov 2, 2023

LGTM. Thank you

@blukat29 blukat29 merged commit c597b59 into klaytn:dev Nov 2, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Console] Javascript console has a bug and lacks syntactic features
4 participants