GithubHelp home page GithubHelp logo

floating / ethereum-provider Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 10.0 514 KB

A standalone EthereumProvider class, just supply the connection

License: GNU General Public License v3.0

JavaScript 32.39% TypeScript 67.61%

ethereum-provider's People

Contributors

bpierre avatar bumi avatar floating avatar goosewobbler avatar mholtzman avatar pedrouid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ethereum-provider's Issues

sendAsync only supports objects as payloads but gets called with an array

I am trying to use eth-provider in combination with truffle (a truffle 4.x project). While trying to run a deployment script I am getting an TypeError: this._send(...).then is not a function error

I tried to debug that error and it seems that the sendAsync function is somehow called with an array as payload. But only a object is expected as param.
payload:

[ { jsonrpc: '2.0',
    id: 6,
    method: 'eth_getFilterChanges',
    params: [ '0x30a6dd9fd08ef418a2c9a932a51710a2' ] } ]

Trace

/home/bumi/src/kredits/truffle-kredits/node_modules/ethereum-provider/index.js:106
    return this._send(payload.method, payload.params).then(result => {
                                                      ^
TypeError: this._send(...).then is not a function
    at EthereumProvider.sendAsync (/home/bumi/src/kredits/truffle-kredits/node_modules/ethereum-provider/index.js:108:55)
    at EthereumProvider.sendAsync (/home/bumi/src/kredits/truffle-kredits/node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:128:1)
    at Provider.sendAsync (/home/bumi/src/kredits/truffle-kredits/node_modules/truffle/build/webpack:/packages/truffle-contract/contract.js:24:1)
    at RequestManager.poll (/home/bumi/src/kredits/truffle-kredits/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:230:1)
    at listOnTimeout (timers.js:327:15)
    at processTimers (timers.js:271:5)

Versions

"eth-provider": {
"version": "0.2.1"
» truffle version
Truffle v4.1.14 (core: 4.1.14)
Solidity v0.4.24 (solc-js)
» node --version
v11.9.0

subscription messages should trigger a "message" event, but don't.

Here is an example taken from EIP-1193:

// Example 4: Log new blocks
ethereum
  .request({
    method: 'eth_subscribe',
    params: ['newHeads'],
  })
  .then((subscriptionId) => {
    ethereum.on('message', (message) => {
      if (message.type === 'eth_subscription') {
        const { data } = message;
        if (data.subscription === subscriptionId) {
          if (typeof data.result === 'string' && data.result) {
            const block = data.result;
            console.log(`New block ${block.number}:`, block);
          } else {
            console.error(`Something went wrong: ${data.result}`);
          }
        }
      }
    });
  })
  .catch((error) => {
    console.error(
      `Error making newHeads subscription: ${error.message}.
       Code: ${error.code}. Data: ${error.data}`
    );
  });

This won't log anything. If I instead listen for an "eth_subscription" event then I get the right objects.

The part where it checks that the result field is a string is an error in the example as far as I can tell.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.