Added resetEventsBlock feature and fixed a problem with some INFURA nodes.

This commit is contained in:
ricmoo 2017-05-09 21:45:36 -04:00
parent 12eb60d2f7
commit 4b41c0e1a2
3 changed files with 32 additions and 6 deletions

@ -1,6 +1,6 @@
{
"name": "ethers-providers",
"version": "2.0.1",
"version": "2.0.2",
"description": "Service provider for Ethereum wallet library.",
"bugs": {
"url": "http://github.com/ethers-io/ethers.js/issues",

@ -94,11 +94,21 @@ function checkString(string) {
function checkBlockTag(blockTag) {
if (blockTag == null) { return 'latest'; }
if (utils.isHexString(blockTag)) { return blockTag; }
if (blockTag === 'earliest') { return '0x0'; }
if (blockTag === 'earliest') { blockTag = 0; }
if (typeof(blockTag) === 'number') {
return utils.hexlify(blockTag);
blockTag = utils.hexlify(blockTag);
}
if (utils.isHexString(blockTag)) {
// HACK: This seems to be a weird requirement some nodes have
// (e.g. INFURA on ropsten; INFURA on homestead is fine)
// Remove leading 0's from the hex blockTag
while (blockTag.length > 3 && blockTag.substring(0, 3) === '0x0') {
blockTag = '0x' + blockTag.substring(3);
}
return blockTag;
}
if (blockTag === 'latest' || blockTag === 'pending') {
@ -395,6 +405,11 @@ function Provider(testnet, chainId) {
self.doPoll();
}
utils.defineProperty(this, 'resetEventsBlock', function(blockNumber) {
lastBlockNumber = blockNumber;
self.doPoll();
});
var poller = null;
Object.defineProperty(this, 'polling', {
get: function() { return (poller != null); },
@ -708,7 +723,6 @@ utils.defineProperty(Provider.prototype, 'getEtherPrice', function() {
}
});
utils.defineProperty(Provider.prototype, 'doPoll', function() {
});

@ -213,7 +213,7 @@ function testEventsProvider(test, provider) {
}),
new Promise(function(resolve, reject) {
function callback(log) {
var result = callFallback.parse(log.data);
var result = callFallback.parse(log.topics, log.data);
if (result.sender !== wallet.address || !result.amount.eq(123)) {
//console.log('someone else is running the test cases');
return;
@ -411,11 +411,23 @@ function testDeploy(test) {
});
}
function testENSProvider(test, provider) {
provider.resolveName('foo.test').then(function(result) {
console.log(result);
test.done();
});
}
function testENS(test) {
testENSProvider(test, new providers.InfuraProvider(true));
}
module.exports = {
'read-only': testReadOnly,
'write': testWrite,
'events': testEvents,
'contracts': testContracts,
'deploy': testDeploy,
// 'ens': testENS,
};