Giter Club home page Giter Club logo

ethers.js's People

Contributors

ricmoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ethers.js's Issues

Implement Solidity Coder

The solidity coder provided uses libraries we otherwise already have similar libraries other places (such as sha3 and bignumber) which makes it take up as much space as the entire rest of this library.

The solidity library is also LGPL, which is one of only two components of ethers-wallet which are not MIT licensed. So, it is a fairly small amount of work to move the entire project to a completely MIT licensed project.

Make sure to test against the test cases here:
https://github.com/ethereum/solidity.js/tree/master/test

wallet.getBalance() is unreliable in production

I'm using the following code on both the local machine (dev server) and on the remote server (AWS Lightsail). When I'm developing locally everything works perfectly, but when the code runs on the remote server getBalance method ocasionally returns 0 (~3 out of 10 requests).

I added loggers to getResult and perform functions in json-rpc-provider.
Input to perform never changes (address and blocktag are always the same)
When a promise resolves to 0, output of getResult is Object {jsonrpc: "2.0", id: 42, result: "0x0"}

const testnet = true
const providerToken = '...'
const privateKey = '...'

const provider = new ethers.providers.InfuraProvider(testnet, providerToken)
const wallet = new ethers.Wallet(privateKey, provider )

wallet.getBalance()
  .then(balance => { console.log(balance.toString() }) // logs 0 ocasionally (3 out of 10 requests)

Any idea what is going on?

Wallet is not a constructor

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
const Wallet = require('ethers-wallet');

var UsersAndTransactions = function(address) {
  this.web3 = web3;
};

UsersAndTransactions.prototype.createWallet = function(passphrase) {
  const privateKey = web3.sha3(passphrase);
  const wallet = new Wallet(privateKey);
};


module.exports = UsersAndTransactions;
TypeError: Wallet is not a constructor
    at UsersAndTransactions.createWallet (/home/hayden/dev/ethereumwalletapi/users-and-transactions.js:12:18)

any ideas?

Trouble with address params for contracts

Do you happen to have a working example/test of a contract function that takes an address parameter? I'm having a lot of difficulties and it seems pretty obvious so I must be misunderstanding something. When I try something like:

  const contract = new Contract(contractAddress, contractAbi, provider)
  const res = await contract.functions.info('0x04a8593df3aca82ccfdcd8899f288262f7577d90')

Assuming 'info' is a mapping such as 'mapping (address => Info) public info;'

I keep getting 'invalid address' which is coming from this code: Interface.js

Any guidance here would be wonderful!

CI ends up with entropy.slice is not a function

Comming from wallet,createRandom(); I end up with the following:

TypeError: entropy.slice is not a function
    at mnemonicToEntropy (/home/travis/build/energychain/StromDAO-BusinessObject/node_modules/ethers/node_modules/ethers-wallet/hdnode.js:183:55)
    at Object.fromMnemonic (/home/travis/build/energychain/StromDAO-BusinessObject/node_modules/ethers/node_modules/ethers-wallet/hdnode.js:124:5)

The funny thing is, if I run it manually on my other sand boxes - everything seems to work fine. So the root cause is somewhere in versions of nodejs, modules etc... (i guess).

Getting function signatures from a Contract's interface without giving parameters.

Hello!

So I'm interested in grabbing a function's signature (or the 4 byte hash of it).

This works fine:

someContract.interface.functions.someFunction().signature;

// or the hash
someContract.interface.functions.someFunction().data.substring(0,10);

but if someFunction() has parameters, interface.js requires me to provide them despite them not being needed for the signature.

One way to work around this is to pass dummy, yet valid, values to the function:

// someFunction(uint, uint[5])

someContract.interface.functions.someFunction(0, new Array(5)) //...

but this sort of hardcoding pretty much defeats the point of grabbing the signature.

I just want to see if there is a way of doing this, and if not, if this would be something you would consider adding to ethers.

Recommended contract object design

I like your encoding work under the hood, good job. Here is my proposed design:

Usage

const Contract = require("ethers-io").contract;
const SimpleStore = new Contract({
    abi: [...],
    address: '0x....',
    provider: {...some provider object...},
    bytecode: '000...', // optional
    txObject: {from: '0x...', gas: 30000}, // optional
});

SimpleStore.new(...).then(..txObject..).then(..address..).catch(...);
SimpleStore.setValue(...).then(...).catch(...);
SimpleStore.getValue(....).then(....).catch(....);

The wallet object design is far too opinionated. The Contract module should be self-encapsulated with a slew of unit testing to ensure encoding/decoding is right. A wallet object should be involved only on the provider level, fed in via the provider object used in the contract instance. So in short, the wallet should be a web3 provider wrapper, WalletProvider that gets fed into the self-encapsulated Contract object.

Another proposed design is this:

Usage

const setupContract = require("ethers-io").setupContract;
const Contract = setupContract({
    provider: {...some provider object...},
    txObject: {from: '0x...', gas: 30000}, // optional
});

const SimpleStore = new Contract({
    abi: [...],
    address: '0x....',
    bytecode: '000...', // optional
});

SimpleStore.new(...).then(..txObject..).then(..address..).catch(...);
SimpleStore.setValue(...).then(...).catch(...);
SimpleStore.getValue(....).then(....).catch(....);

Here we include a contract setup method, which returns the contract instance. It's another design pattern that is potentially cleaner, but highly unopinionated.

I would also recommend making this module completely independent of ethers-io, but hosting in the ethers-io github org. It would be awesome if it was ethereumjs-contract or just eth-contract or if you want it ethers-io-contract.

Anyone of those I would be fine with.

With love from the motherland.

More testcases for error conditions.

We need to add a lot more test cases, specifically for when things should fail; the non-happy-path.

This will be part of the larger error refactor, where more meaningful and machine readable errors are generated from failure cases.

Nested array support

Hello -

Came here thanks to the helpful link at web3/web3.js#1137.

I was trying out the new experimental support for nested dynamical array in ABIEncoderV2.

Turns out there is currently no ABI decoder that supports it if I am not wrong.

Just wanted to open a ticket to make sure that this is also same with ethers.js.

Here is a quick test case I got:

Registry.sol

pragma solidity ^0.4.18;
pragma experimental SMTChecker;
pragma experimental ABIEncoderV2;

contract Registry {
	bool[][] matrix;

	function Registry() {
		bool[] memory test = new bool[](2);
		test[0] = true;
		test[1] = true;
		matrix.push(test);
	}
	function adjacency_matrix() constant returns (bool[][]) {
		return matrix;
	}
	function getLength() constant returns (uint length) {
		length = matrix.length;
	}
}

ethers-js.ts

import {Wallet, Contract, providers} from "ethers";
const wallet = new Wallet("0x8e6e5c8c3239e87ab550aa58d797c2c71355a1e4e2ef2342884a3462548b82d6", new providers.JsonRpcProvider(undefined, "development"));

const abi = [
	{
		"constant": true,
		"inputs": [],
		"name": "getLength",
		"outputs": [
			{
				"name": "length",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [],
		"name": "adjacency_matrix",
		"outputs": [
			{
				"name": "",
				"type": "bool[][]"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"inputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "constructor"
	}
];
const contract = new Contract("0x80446d11f150c883ab148b5c4014c3e859ff1662", abi, wallet);

const result = contract.adjacency_matrix();
result.then((res) => {console.log(res)}).catch((e) => {console.log(e)});

Result:

$ ts-node ethers-js.ts

{ Error: invalid type
    at throwError (/home/isaac/Development/truffle/node_modules/ethers-utils/throw-error.js:4:17)
    at getParamCoder (/home/isaac/Development/truffle/node_modules/ethers-contracts/interface.js:290:48)
    at /home/isaac/Development/truffle/node_modules/ethers-contracts/interface.js:587:21
    at Array.forEach (<anonymous>)
    at Function.decodeParams (/home/isaac/Development/truffle/node_modules/ethers-contracts/interface.js:586:11)
    at CallDescription.result.parse (/home/isaac/Development/truffle/node_modules/ethers-contracts/interface.js:406:50)
    at /home/isaac/Development/truffle/node_modules/ethers-contracts/contract.js:115:37
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7) type: '' }

Will update this issue with further details. I will be looking into (1) creating a test case for this or even (2) contributing.

Thanks
-Isaac

Interface event parse() incorrectly slices topics

Hey @ricmoo

I'm trying to replicate this from the Interface documentation using both provider.on() as shown and provider.getLogs():

var valueChangedInfo = iface.events.valueChanged();

// To listen for this event:
provider.on(valueChangedInfo.topics, function(data) {
    var result = valueChangedInfo.parse(data);

    console.log(result);
    // {
    //     0: "Hello World",
    //     oldValue: "Hello World",
    //     1: "Foobar!",
    //     newValue: "Foobar!",
    // }
});

First thing I discovered is that valueChangedInfo.parse(data) in the example should be valueChangedInfo.parse(valueChangedInfo.topics, data.data) because 1531793.

Now for the real problem; running parse() throws:

Error: invalid address  // whatever the first event datatype is
    at throwError (/Users/gregory/repos/ethers-finicking/node_modules/ethers-utils/throw-error.js:4:17)
    at Object.decode (/Users/gregory/repos/ethers-finicking/node_modules/ethers-contracts/interface.js:133:42)
    at /Users/gregory/repos/ethers-finicking/node_modules/ethers-contracts/interface.js:589:32
    at Array.forEach (native)
    at Function.decodeParams (/Users/gregory/repos/ethers-finicking/node_modules/ethers-contracts/interface.js:582:11)
    at EventDescription.result.parse (/Users/gregory/repos/ethers-finicking/node_modules/ethers-contracts/interface.js:461:59)
    at FallbackProvider.provider.on.e (/Users/gregory/repos/ethers-finicking/index.js:50:25)
    at FallbackProvider.emit (/Users/gregory/repos/ethers-finicking/node_modules/ethers-providers/provider.js:929:31)
    at /Users/gregory/repos/ethers-finicking/node_modules/ethers-providers/provider.js:403:34
    at Array.forEach (native)

which is Interface.decodeParams() failing on definining resultIndexed.

Removing the line if (!method.anonymous) { topics = topics.slice(1); } in interface.js seems to make it work fine.

Interface: getting names/types of inputs and outputs of a given function.

So this is a suggestion following from #44...

Since we are now attaching signature and sighash to interface.functions.someFunction I think another logical extension would be to also attach the inputs and outputs arrays from the abi.

This way searching the interface.abi array won't be needed which would make querying this information easier for any function. Perhaps we'd also want this for the events. It's also easy to add on to the current implementation since interface.functions.someFunction comes directly from the abi.

Break out transaction from wallet.js

Create a transaction.js in the wallet package, which is used by wallet, but further abstracts parsing and generating (for example, unsigned transactions).

Add adjustable number of digits to units.

The units library has been used for the conversion of ether to Wei, but can also be used for other tokens if more generalized; which is simple to do.

It will take in an additional, option parameter of number of decimals to convert between.

Discussion: should slice (and other missing ops) be shimmed? (e.g. slice in ReactNative)

I'm creating a ReactNative based app using this lib. When I run in iOS simulator, eveything goes fine. But when I run in my real Android device I'm having the following error:

[TypeError: undefined is not a function (evaluating 'data.slice(offset + junkLength, offset + 32)')]

It happens when I'm trying to execute the following piece of code after loading the wallet with my private key:

const updateBalance = () => (dispatch) => {
    const { contract, wallet } = store.getState().wallet;
    contract.functions.balanceOf(wallet.getAddress())
        .then(({ balance }) => dispatch({ type: UPDATE_BALANCE, payload: balance }));
}

Looking at the lib source, I figured out the place where this error can be located at in this:

var value = utils.bigNumberify(data.slice(offset + junkLength, offset + 32));

Do you have any idea of what might be happening?

ethers-providers 2.1.5 breaks getDefaultProvider()

#45
The error:

/Users/gregory/repos/ethers-finicking/node_modules/ethers-providers/provider.js:487
    if (typeof(network.chainId) !== 'number') { throw new Error('invalid chainId'); }
                      ^

TypeError: Cannot read property 'chainId' of undefined
    at Function._legacyConstructor (/Users/gregory/repos/ethers-finicking/node_modules/ethers-providers/provider.js:487:23)
    at new InfuraProvider (/Users/gregory/repos/ethers-finicking/node_modules/ethers-providers/infura-provider.js:22:28)
    at Object.getDefaultProvider (/Users/gregory/repos/ethers-finicking/node_modules/ethers-providers/index.js:12:9)
    at Object.<anonymous> (/Users/gregory/repos/ethers-finicking/index.js:5:33)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)

How to reproduce:
npm i [email protected]

var providers = require('ethers-providers');
var provider = providers.getDefaultProvider();  // throws here

Support for loose JSON-RPC providers (e.g. TestRPC)

While calling a function provider.getTransaction it throws an error invalid hexlify value.

Following transaction hash I got while creating transaction
Hash: 0x38796338be290d9733a362ae609bd507b9625a86b4262898c12715dcbaaf38c3

But while fetching transaction details gets the following error
error

Add extra methods to Etherscan provider.

It's fairly simple to fill out the remaining methods for Etherscan in the provider, and will barely affect the file size, so we might as well. It will likely take longer to write test cases than it will to implement. :)

Promise on Call

Using the following JS Code together with the browsified version of ehters-wallet:

var wallet = new Wallet(privateKey,'http://localhost:8545'); var contract = wallet.getContract('0xCE3b5fFca16ffF926c890f0885A3e90cEb89db0A',abi); contract.greenToken().then(function(tx) {console.log(tx);});

I end up with an error Uncaught (in promise) Error: invalid or missing value for params1 within the ABI the function called has no parameters
... "name":"greenToken","outputs":[{"name":"","type":"address"}],"type":"function"} ...

Any idea of what might be the expected params[1] ?

A balance check I do using the same wallet works fine:

wallet.getBalance().then(function(balance) {
    console.log("Balance()",balance);
});

Following is the full RPC response Value:

Error: invalid or missing value for params[1] at https://rawgit.com/ethers-io/ethers-wallet/master/dist/ethers-wallet.js:850:37 at XMLHttpRequest.request.onreadystatechange (https://rawgit.com/ethers-io/ethers-wallet/master/dist/ethers-wallet.js:878:21)
code
:
-32602

Looking at the RPC Chat to my GETH I see:

Request:
{"id":2,"jsonrpc":"2.0","method":"eth_call","params":[{"data":"0x02b32af5","from":"0x9d786c69dD95f4bFA4a76f3307c0f4EFA524538A","to":"0xCE3b5fFca16ffF926c890f0885A3e90cEb89db0A"}]}

Response
{"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"invalid or missing value for params[1]"}}

Using sign to get Signature of a Message

Dear all,

wallet.sign could be used to sign a transaction.

What I am wondering is, if there is a way to get the raw transaction (before signing) from ethers-wallet.

Background: This would allow to authenticate to a third party using the wallet - eq. signing without sending Tx to the blockchain.

Any idea welcome ...

Thanks,
Thorsten

Add encrypted mnemonic the Secret Storage JSON Wallet (see ethers.objc)

Hi,
Do you plan to add optionnal mnemonic encryption in the wallet object.

Cause now:

const Wallet = ethers.Wallet;
const wallet = Wallet.fromMnemonic(seedPhrase);
console.log('wallet pre encryption ', wallet);
// wallet pre encryption {
// privateKey: '0xfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
// provider: [Getter/Setter],
// defaultGasLimit: [Getter/Setter],
// address: '0x7112b2xxxxxxxxxxxxxx',
// sign: [Function],
// mnemonic: 'forward xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx',
// path: 'm/44\'/60\'/0\'/0/0' }

const encrypted = await wallet.encrypt(password);
const decrypted = await Wallet.fromEncryptedWallet(encrypted ,password);
console.log('Wallet post encryption ',decrypted);
// wallet pre encryption {
// privateKey: '0xfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
// provider: [Getter/Setter],
// defaultGasLimit: [Getter/Setter],
// address: '0x7112b2xxxxxxxxxxxxxx',
//  sign: [Function] }

In eth-lightwallet when you generate an encrypted keystore, you can regenerate the mnemonic phrase, is it in your roadmap now?
Anyway thanks for this all-in-one libs! great work!

Set gasLimit and gasPrice on contract transactions

I've been searching in the online documentation for a way to set my gasPrice and gasLimit when creating a transaction on a contract, but couldn't find a way to make it work. I attempted to modify the transaction while signing using a CustomSigner, but didn't had any success.

Is there any way to do it?

Fixed solidity type

Need to create a simple object to wrap fixed numbers.

  • whole
  • fraction
  • wholeBits
  • fractionBits
  • toNumber() (approximate as needed)

wallet.estimateGas method throws an error

CODE

const privateKey = '...'
const provider = 'https://ropsten.infura.io/jC3JIY42Jf0zCvTqJNMF'
const wallet = new ethers.Wallet(privateKey, provider)
const txo = {
  data: '0xa358c2fa0123000000000000000000000000000000000000000000000000000000000000'
  gasLimit: '0xF4240'
  gasPrice: '0x4A817C800'
  nonce: 4
  to: '0x394b88b676f289224bdc332f361be399ea064bd5'
  value: '0x60A24181E4000'
}
wallet.estimateGas(txo)
  .then(estimate => console.log(estimate)) // 'undefined'
  .catch(error => console.log(error)) // throws an error ====>

ERROR
Error: invalid argument 0: hex number has leading zero digits after 0x at getResult

in json-rpc-provider.js

console.log(params.transaction.value) // BN number
console.log(params.transaction.value.toHexString()) // 0x060a24181e4000
return this.send('eth_estimateGas', [getTransaction(params.transaction)]);

Notice that there's a leading zero in 0x060a24181e4000. If I set the value of value to numbers in the safe JS range everything works. Apparently, BN adds leading zeros and that's the cause of the problem. Here's relevant discussion ethereum/go-ethereum#14477. Basically all methods that accept a quantity cannot have leading zero's. Any advice what to do?

Use ethers-wallet without requiring the whole ethers library

The docs show the way to create a wallet instance as follows:

var Wallet = ethers.Wallet;

This requires including ethers as a dependency, as follows:

var ethers = require('ethers');

How can the wallet part of the library be used without requiring all parts of the library?

Function to generate mnemonic?

I don't see a way to generate a mnemonic/seed for the HDNode. Should I just use the bip39 library or am I missing something?

EtherscanProvider - Block exeeds Gas Limit

The last days I get a "Exceeds block gas limit" on every signed message if I am using Etherscan as a provider. Even a simple "send" of ethers fails with this message. Not sure if it is caused by ethers-wallet doing something different in latest release or something was changed on Etherscan side.

Deploy Contract results in a missed promise

Taking the following "active" code:
var deployTransaction = Contract.getDeployTransaction(bytecode, abi);

I end up with:

TypeError: Cannot read property 'apply' of undefined

So far I ensured that bytecode is valid (type String - not Buffer...), ABI is valid JSON Object. Deployment via MIST or Parity works fine (so bytecode & ABI is valid).

Any idea?

(I think.. the code in contracts.js makes a constructor mandatory).

Add `new` operation on `Contracts`.

There is currently no way to pass parameters into the constructor of a Contract, we need to add that.

Nick has suggested just a Contract.prototype.new(...) call, which returns a Promise, which is likely all it will be.

Is there a way to make Wallet.fromBrainWallet faster?

Hey! I'm looking for a way to make Wallet.fromBrainWallet method generate wallets faster than it does right now. I've looked through the source code hoping to find some variable responsible for holding delay value and make it smaller, but it's not as easy I thought. It takes a super genius to understand how this magic cryptographic stuff works. Is there an easy and simple way of making Wallet.fromBrainWallet generate wallets faster or there's no such a way and the solution involves major overhaul and countless cups of coffee? Any pointer to the right direction would be much appreciated!

fromWei/toWei equivalents

We need to be able to convert to/from wei/ether. I will likely copy most of the functionality from the existing ethers.io formatEther.

  • formatEther(weiAsBnOrHex, options) => decimalString
  • parseEther(stringAsDecimalOrNumber) => BN

Options:

  • round: 'up' | 'down' | 'round' | 'none' (default: none)
  • decimals: Number (default: 18)
  • commify: true | false (default: false)

UNMET PEER DEPENDENCY watchify@>=3 <4

i use sudo npm install ethers-wallet to installing
but it shows
UNMET PEER DEPENDENCY watchify@>=3 <4
plz help me thanks

osboxes@osboxes:~/ethereumjs-tx-master/examples$ sudo npm install [email protected] /home/osboxes/ethereumjs-tx-master
├── [email protected]  extraneous
└── UNMET PEER DEPENDENCY watchify@>=3 <4

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] requires a peer of watchify@>=3 <4 but none was installed.

Add PBKDF2 kdf support to SecretStorage.

Parity generates Version 3 JSON wallets with the PBKDF2 as the key derivation function (kdf).

Add support for this kdf and test against parity generated wallets.

React Native is slow

I'm creating a MVP of an application using this lib and decided to start with login form because it would be the easiest way to present the solution to the market I'm investing on.

When I run it in my computer's simulator, it just takes a couple seconds to finish the operation and going to the next page.

However, when I try it in the mobile device, it runs insanely slow, like progressing around 30% per minute.

Could it be related to the ARM processors capacity to do this kind of heavy calculation? I seen that the code for using this method to generate the key is mostly based on lots of math operations...

Add ENS support

My local development branch already has this added, but I'm creating an issue to help track it.

  • add namehash to utils
  • add resolveAddress(name) to provider
  • allow ENS names to be passed into any async function where an address is expected (e.g. Provider.prototype.getBalance); this will allow ENS names to be used trivially in sending, calling contracts, et cetera.

Unhandled promise rejection warning after subscribing to events

PREFACE
This code below works. It successfully logs events emitted by a contract. The problem is that once in a couple of minutes I get a warning (also below). I've tried instantiating provider with different params (mainnet, no token) and the warning was still there.

CODE

const testnet = true
const infuraToken= ''...''
const privateKey = '...'
const contractAddress = '...' 
const contractAbi = '...'

const provider = new ethers.providers.InfuraProvider(testnet , infuraToken)
const wallet = new ethers.Wallet(privateKey, provider)
const contract = new ethers.Contract(contractAddress, contractAbi, provider)

contract.onsomeevent = function (value) { ... } // commening out this piece of code makes errors dissapear

WARNING

(node:5524) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: invalid json response

FINAL PART
Thank you for this great library. It's a pleasure to use. Hope this issue will get solved soon. Anything I can do to help further investigate this problem?

Each new block triggers past events

I'm using this code to listen to contract events. Before today everything worked perfectly (with the exception of ocasional warning issue 27). Starting from today each new block triggers onsomeevent handler with all the past events that took place today. In other words, I get the same values over and over again with each new block.

const ethers = require('ethers')
const config = require('./config')

const provider = new ethers.providers.InfuraProvider(config.testnet, config.providerToken)
const wallet = new ethers.Wallet(config.privateKey, provider)
const contract = new ethers.Contract(config.contractAddress, config.contractAbi, wallet)

contract.onmake = function(hash) {
  console.log('Hash:', hash)
}

Anyone have anything similar?

Test support indexed dynamic parameters for events.

Indexed parameters are present as additional topics instead of in the data.

The function to get an event's description should take that into account in the parse, as well the indexed parameters should (optionally) be able to be passed in to further filter results.

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.