floating / ethereum-provider Goto Github PK
View Code? Open in Web Editor NEWA standalone EthereumProvider class, just supply the connection
License: GNU General Public License v3.0
A standalone EthereumProvider class, just supply the connection
License: GNU General Public License v3.0
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' ] } ]
/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)
"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
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.