Compare commits

..

4 Commits

Author SHA1 Message Date
Richard Moore
c93b48920e Increment JSON-RPC ID for JsonRpcProviders for environments that unsafely manage callbacks (#489). 2019-04-18 13:49:37 +02:00
Richard Moore
04c92bb8d5 Updated dist files. 2019-03-08 14:29:59 -05:00
Richard Moore
16c9745326 Added goerli to InfuraProvider (#421). 2019-03-08 14:28:39 -05:00
Richard Moore
05648177aa Updated dist files. 2019-02-15 13:44:33 -05:00
19 changed files with 73 additions and 60 deletions

2
_version.d.ts vendored
View File

@@ -1 +1 @@
export declare const version = "4.0.25";
export declare const version = "4.0.27";

View File

@@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "4.0.25";
exports.version = "4.0.27";

47
dist/ethers.js vendored
View File

@@ -1,7 +1,7 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethers = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "4.0.25";
exports.version = "4.0.27";
},{}],2:[function(require,module,exports){
"use strict";
@@ -10712,18 +10712,20 @@ var BaseProvider = /** @class */ (function (_super) {
if (confirmations == null) {
confirmations = 1;
}
if (confirmations === 0) {
return this.getTransactionReceipt(transactionHash);
}
return new Promise(function (resolve) {
var handler = function (receipt) {
if (receipt.confirmations < confirmations) {
return;
}
_this.removeListener(transactionHash, handler);
resolve(receipt);
};
_this.on(transactionHash, handler);
return this.getTransactionReceipt(transactionHash).then(function (receipt) {
if (confirmations === 0 || (receipt && receipt.confirmations >= confirmations)) {
return receipt;
}
return (new Promise(function (resolve) {
var handler = function (receipt) {
if (receipt.confirmations < confirmations) {
return;
}
_this.removeListener(transactionHash, handler);
resolve(receipt);
};
_this.on(transactionHash, handler);
}));
});
};
BaseProvider.prototype.getBlockNumber = function () {
@@ -11799,6 +11801,9 @@ var InfuraProvider = /** @class */ (function (_super) {
case 'rinkeby':
host = 'rinkeby.infura.io';
break;
case 'goerli':
host = 'goerli.infura.io';
break;
case 'kovan':
host = 'kovan.infura.io';
break;
@@ -11998,7 +12003,7 @@ var JsonRpcSigner = /** @class */ (function (_super) {
}
return _this.provider._wrapTransaction(tx, hash);
});
}, { onceBlock: _this.provider }).catch(function (error) {
}, { fastRetry: 250, onceBlock: _this.provider }).catch(function (error) {
error.transactionHash = hash;
throw error;
});
@@ -15066,12 +15071,7 @@ var networks = {
chainId: 5,
ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010",
name: "goerli",
_defaultProvider: function (providers) {
if (providers.EtherscanProvider) {
return new providers.EtherscanProvider("goerli");
}
return null;
}
_defaultProvider: ethDefaultProvider('goerli')
},
kovan: {
chainId: 42,
@@ -16918,6 +16918,7 @@ function poll(func, options) {
}
}, options.timeout);
}
var fastTimeout = options.fastRetry || null;
var attempt = 0;
function check() {
return func().then(function (result) {
@@ -16940,6 +16941,12 @@ function poll(func, options) {
if (timeout > options.ceiling) {
timeout = options.ceiling;
}
// Fast Timeout, means we quickly try again the first time
if (fastTimeout) {
attempt--;
timeout = fastTimeout;
fastTimeout = null;
}
setTimeout(check, timeout);
}
return null;

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -266,7 +266,7 @@ declare module 'ethers/utils/shims' {
}
declare module 'ethers/_version' {
export const version = "4.0.25";
export const version = "4.0.27";
}
declare module 'ethers/utils/bignumber' {
@@ -1041,6 +1041,7 @@ declare module 'ethers/utils/web' {
ceiling?: number;
interval?: number;
onceBlock?: OnceBlockable;
fastRetry?: number;
};
export function fetchJson(connection: string | ConnectionInfo, json: string, processFunc: (value: any) => any): Promise<any>;
export function poll(func: () => Promise<any>, options?: PollOptions): Promise<any>;

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "ethers",
"version": "4.0.25",
"version": "4.0.27",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "ethers",
"version": "4.0.25",
"version": "4.0.27",
"description": "Ethereum wallet library.",
"main": "./index.js",
"types": "./index.d.ts",

View File

@@ -656,18 +656,20 @@ var BaseProvider = /** @class */ (function (_super) {
if (confirmations == null) {
confirmations = 1;
}
if (confirmations === 0) {
return this.getTransactionReceipt(transactionHash);
}
return new Promise(function (resolve) {
var handler = function (receipt) {
if (receipt.confirmations < confirmations) {
return;
}
_this.removeListener(transactionHash, handler);
resolve(receipt);
};
_this.on(transactionHash, handler);
return this.getTransactionReceipt(transactionHash).then(function (receipt) {
if (confirmations === 0 || (receipt && receipt.confirmations >= confirmations)) {
return receipt;
}
return (new Promise(function (resolve) {
var handler = function (receipt) {
if (receipt.confirmations < confirmations) {
return;
}
_this.removeListener(transactionHash, handler);
resolve(receipt);
};
_this.on(transactionHash, handler);
}));
});
};
BaseProvider.prototype.getBlockNumber = function () {

View File

@@ -42,6 +42,9 @@ var InfuraProvider = /** @class */ (function (_super) {
case 'rinkeby':
host = 'rinkeby.infura.io';
break;
case 'goerli':
host = 'goerli.infura.io';
break;
case 'kovan':
host = 'kovan.infura.io';
break;

View File

@@ -155,7 +155,7 @@ var JsonRpcSigner = /** @class */ (function (_super) {
}
return _this.provider._wrapTransaction(tx, hash);
});
}, { onceBlock: _this.provider }).catch(function (error) {
}, { fastRetry: 250, onceBlock: _this.provider }).catch(function (error) {
error.transactionHash = hash;
throw error;
});

View File

@@ -1 +1 @@
export const version = "4.0.25";
export const version = "4.0.27";

View File

@@ -32,6 +32,9 @@ export class InfuraProvider extends JsonRpcProvider {
case 'rinkeby':
host = 'rinkeby.infura.io';
break;
case 'goerli':
host = 'goerli.infura.io';
break;
case 'kovan':
host = 'kovan.infura.io';
break;

View File

@@ -50,6 +50,11 @@ function getLowerCase(value: string): string {
const _constructorGuard = {};
// Some environments (Trust Wallet and company) use a global map
// to track JSON-RPC ID, so we try to keep IDs unique across all
// connections. See #489.
let _nextId = 42;
export class JsonRpcSigner extends Signer {
readonly provider: JsonRpcProvider;
private _index: number;
@@ -250,7 +255,7 @@ export class JsonRpcProvider extends BaseProvider {
let request = {
method: method,
params: params,
id: 42,
id: (_nextId++),
jsonrpc: "2.0"
};

View File

@@ -86,12 +86,7 @@ const networks: { [name: string]: Network } = {
chainId: 5,
ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010",
name: "goerli",
_defaultProvider: (providers: any): any => {
if (providers.EtherscanProvider) {
return new providers.EtherscanProvider("goerli");
}
return null;
}
_defaultProvider: ethDefaultProvider('goerli')
},
kovan: {

View File

@@ -414,12 +414,6 @@ function testProvider(providerName, networkName) {
['default', 'homestead', 'ropsten', 'rinkeby', 'kovan', 'goerli'].forEach(function(networkName) {
['getDefaultProvider', 'InfuraProvider', 'EtherscanProvider', 'Web3Provider'].forEach(function(providerName) {
if (networkName === "goerli") {
if (providerName === "InfuraProvider" || providerName === "Web3Provider") {
return;
}
}
// @TODO: Remove this! Temporary because Etherscan is down
//if (providerName === 'EtherscanProvider') {
// console.log("******** Remove this soon! Etherscan is having issues.");

View File

@@ -70,12 +70,7 @@ var networks = {
chainId: 5,
ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010",
name: "goerli",
_defaultProvider: function (providers) {
if (providers.EtherscanProvider) {
return new providers.EtherscanProvider("goerli");
}
return null;
}
_defaultProvider: ethDefaultProvider('goerli')
},
kovan: {
chainId: 42,

1
utils/web.d.ts vendored
View File

@@ -17,6 +17,7 @@ export declare type PollOptions = {
ceiling?: number;
interval?: number;
onceBlock?: OnceBlockable;
fastRetry?: number;
};
export declare function fetchJson(connection: string | ConnectionInfo, json: string, processFunc: (value: any) => any): Promise<any>;
export declare function poll(func: () => Promise<any>, options?: PollOptions): Promise<any>;

View File

@@ -179,6 +179,7 @@ function poll(func, options) {
}
}, options.timeout);
}
var fastTimeout = options.fastRetry || null;
var attempt = 0;
function check() {
return func().then(function (result) {
@@ -201,6 +202,12 @@ function poll(func, options) {
if (timeout > options.ceiling) {
timeout = options.ceiling;
}
// Fast Timeout, means we quickly try again the first time
if (fastTimeout) {
attempt--;
timeout = fastTimeout;
fastTimeout = null;
}
setTimeout(check, timeout);
}
return null;