forked from tornado-packages/ethers.js
Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
023e946072 | ||
|
|
004cb826d2 | ||
|
|
bfcf224b2b | ||
|
|
c969fe5a68 | ||
|
|
8737f12e1b | ||
|
|
1267eeef4a | ||
|
|
11c250ff7c | ||
|
|
c303199d26 | ||
|
|
ae458a1a49 | ||
|
|
760a5aec74 | ||
|
|
2967efc2b0 | ||
|
|
24f243e689 | ||
|
|
d719064628 | ||
|
|
a7d0b41d98 | ||
|
|
a980fc3db0 | ||
|
|
a34ca6b3a3 | ||
|
|
ef91dcd757 | ||
|
|
a5296a9258 | ||
|
|
f827ae68e2 | ||
|
|
fbf15c0ffe | ||
|
|
10fdbe7274 | ||
|
|
384fc328f2 | ||
|
|
055694ae61 | ||
|
|
edf59d2c26 | ||
|
|
92c978e5c2 | ||
|
|
34397fa2aa | ||
|
|
19587eea3f | ||
|
|
4a9373e773 | ||
|
|
2997bae935 | ||
|
|
b0bd9ee162 | ||
|
|
7075c8c235 | ||
|
|
a4a532fe8e | ||
|
|
77c771bf76 | ||
|
|
c93b48920e | ||
|
|
04c92bb8d5 |
2
_version.d.ts
vendored
2
_version.d.ts
vendored
@@ -1 +1 @@
|
||||
export declare const version = "4.0.26";
|
||||
export declare const version = "4.0.37";
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = "4.0.26";
|
||||
exports.version = "4.0.37";
|
||||
|
||||
@@ -204,7 +204,7 @@ function runMethod(contract, functionName, estimateOnly) {
|
||||
tx.gasLimit = bignumber_1.bigNumberify(method.gas).add(21000);
|
||||
}
|
||||
if (!contract.signer) {
|
||||
errors.throwError('sending a transaction require a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction' });
|
||||
errors.throwError('sending a transaction requires a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction' });
|
||||
}
|
||||
// Make sure they aren't overriding something they shouldn't
|
||||
if (tx.from != null) {
|
||||
@@ -366,7 +366,7 @@ var Contract = /** @class */ (function () {
|
||||
Contract.prototype.fallback = function (overrides) {
|
||||
var _this = this;
|
||||
if (!this.signer) {
|
||||
errors.throwError('sending a transaction require a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction(fallback)' });
|
||||
errors.throwError('sending a transaction requires a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction(fallback)' });
|
||||
}
|
||||
var tx = properties_1.shallowCopy(overrides || {});
|
||||
['from', 'to'].forEach(function (key) {
|
||||
|
||||
126
dist/ethers.js
vendored
126
dist/ethers.js
vendored
@@ -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.26";
|
||||
exports.version = "4.0.37";
|
||||
|
||||
},{}],2:[function(require,module,exports){
|
||||
"use strict";
|
||||
@@ -252,7 +252,7 @@ function runMethod(contract, functionName, estimateOnly) {
|
||||
tx.gasLimit = bignumber_1.bigNumberify(method.gas).add(21000);
|
||||
}
|
||||
if (!contract.signer) {
|
||||
errors.throwError('sending a transaction require a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction' });
|
||||
errors.throwError('sending a transaction requires a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction' });
|
||||
}
|
||||
// Make sure they aren't overriding something they shouldn't
|
||||
if (tx.from != null) {
|
||||
@@ -414,7 +414,7 @@ var Contract = /** @class */ (function () {
|
||||
Contract.prototype.fallback = function (overrides) {
|
||||
var _this = this;
|
||||
if (!this.signer) {
|
||||
errors.throwError('sending a transaction require a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction(fallback)' });
|
||||
errors.throwError('sending a transaction requires a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction(fallback)' });
|
||||
}
|
||||
var tx = properties_1.shallowCopy(overrides || {});
|
||||
['from', 'to'].forEach(function (key) {
|
||||
@@ -8646,24 +8646,28 @@ exports.shr64_lo = shr64_lo;
|
||||
if (typeof Object.create === 'function') {
|
||||
// implementation from standard node.js 'util' module
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// old school shim for old browsers
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
var TempCtor = function () {}
|
||||
TempCtor.prototype = superCtor.prototype
|
||||
ctor.prototype = new TempCtor()
|
||||
ctor.prototype.constructor = ctor
|
||||
if (superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
var TempCtor = function () {}
|
||||
TempCtor.prototype = superCtor.prototype
|
||||
ctor.prototype = new TempCtor()
|
||||
ctor.prototype.constructor = ctor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9620,7 +9624,7 @@ module.exports = { browser: true };
|
||||
|
||||
}).call(this,require("timers").setImmediate)
|
||||
},{"timers":45}],44:[function(require,module,exports){
|
||||
(function (process,global){
|
||||
(function (process,global,clearImmediate){
|
||||
(function (global, undefined) {
|
||||
"use strict";
|
||||
|
||||
@@ -9797,8 +9801,8 @@ module.exports = { browser: true };
|
||||
attachTo.clearImmediate = clearImmediate;
|
||||
}(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
|
||||
|
||||
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"_process":42}],45:[function(require,module,exports){
|
||||
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").clearImmediate)
|
||||
},{"_process":42,"timers":45}],45:[function(require,module,exports){
|
||||
(function (global){
|
||||
module.exports = { setImmediate: global.setImmediate };
|
||||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
@@ -10076,6 +10080,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var address_1 = require("../utils/address");
|
||||
var bignumber_1 = require("../utils/bignumber");
|
||||
var bytes_1 = require("../utils/bytes");
|
||||
var constants_1 = require("../constants");
|
||||
var hash_1 = require("../utils/hash");
|
||||
var networks_1 = require("../utils/networks");
|
||||
var properties_1 = require("../utils/properties");
|
||||
@@ -10754,7 +10759,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.ready.then(function () {
|
||||
return properties_1.resolveProperties({ addressOrName: addressOrName, blockTag: blockTag }).then(function (_a) {
|
||||
var addressOrName = _a.addressOrName, blockTag = _a.blockTag;
|
||||
return _this.resolveName(addressOrName).then(function (address) {
|
||||
return _this._getAddress(addressOrName).then(function (address) {
|
||||
var params = { address: address, blockTag: checkBlockTag(blockTag) };
|
||||
return _this.perform('getBalance', params).then(function (result) {
|
||||
return bignumber_1.bigNumberify(result);
|
||||
@@ -10768,7 +10773,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.ready.then(function () {
|
||||
return properties_1.resolveProperties({ addressOrName: addressOrName, blockTag: blockTag }).then(function (_a) {
|
||||
var addressOrName = _a.addressOrName, blockTag = _a.blockTag;
|
||||
return _this.resolveName(addressOrName).then(function (address) {
|
||||
return _this._getAddress(addressOrName).then(function (address) {
|
||||
var params = { address: address, blockTag: checkBlockTag(blockTag) };
|
||||
return _this.perform('getTransactionCount', params).then(function (result) {
|
||||
return bignumber_1.bigNumberify(result).toNumber();
|
||||
@@ -10782,7 +10787,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.ready.then(function () {
|
||||
return properties_1.resolveProperties({ addressOrName: addressOrName, blockTag: blockTag }).then(function (_a) {
|
||||
var addressOrName = _a.addressOrName, blockTag = _a.blockTag;
|
||||
return _this.resolveName(addressOrName).then(function (address) {
|
||||
return _this._getAddress(addressOrName).then(function (address) {
|
||||
var params = { address: address, blockTag: checkBlockTag(blockTag) };
|
||||
return _this.perform('getCode', params).then(function (result) {
|
||||
return bytes_1.hexlify(result);
|
||||
@@ -10796,7 +10801,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.ready.then(function () {
|
||||
return properties_1.resolveProperties({ addressOrName: addressOrName, position: position, blockTag: blockTag }).then(function (_a) {
|
||||
var addressOrName = _a.addressOrName, position = _a.position, blockTag = _a.blockTag;
|
||||
return _this.resolveName(addressOrName).then(function (address) {
|
||||
return _this._getAddress(addressOrName).then(function (address) {
|
||||
var params = {
|
||||
address: address,
|
||||
blockTag: checkBlockTag(blockTag),
|
||||
@@ -11039,6 +11044,14 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
});
|
||||
});
|
||||
};
|
||||
BaseProvider.prototype._getAddress = function (addressOrName) {
|
||||
return this.resolveName(addressOrName).then(function (address) {
|
||||
if (address == null) {
|
||||
errors.throwError("ENS name not configured", errors.UNSUPPORTED_OPERATION, { operation: "resolveName(" + JSON.stringify(addressOrName) + ")" });
|
||||
}
|
||||
return address;
|
||||
});
|
||||
};
|
||||
// @TODO: Could probably use resolveProperties instead?
|
||||
BaseProvider.prototype._resolveNames = function (object, keys) {
|
||||
var promises = [];
|
||||
@@ -11047,7 +11060,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
if (result[key] == null) {
|
||||
return;
|
||||
}
|
||||
promises.push(this.resolveName(result[key]).then(function (address) {
|
||||
promises.push(this._getAddress(result[key]).then(function (address) {
|
||||
result[key] = address;
|
||||
return;
|
||||
}));
|
||||
@@ -11060,7 +11073,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.getNetwork().then(function (network) {
|
||||
// No ENS...
|
||||
if (!network.ensAddress) {
|
||||
errors.throwError('network does support ENS', errors.UNSUPPORTED_OPERATION, { operation: 'ENS', network: network.name });
|
||||
errors.throwError('network does not support ENS', errors.UNSUPPORTED_OPERATION, { operation: 'ENS', network: network.name });
|
||||
}
|
||||
// keccak256('resolver(bytes32)')
|
||||
var data = '0x0178b8bf' + hash_1.namehash(name).substring(2);
|
||||
@@ -11070,7 +11083,11 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
if (bytes_1.hexDataLength(data) !== 32) {
|
||||
return null;
|
||||
}
|
||||
return address_1.getAddress(bytes_1.hexDataSlice(data, 12));
|
||||
var address = address_1.getAddress(bytes_1.hexDataSlice(data, 12));
|
||||
if (address === constants_1.AddressZero) {
|
||||
return null;
|
||||
}
|
||||
return address;
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -11091,6 +11108,9 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
var nodeHash = hash_1.namehash(name);
|
||||
// Get the addr from the resovler
|
||||
return this._getResolver(name).then(function (resolverAddress) {
|
||||
if (resolverAddress == null) {
|
||||
return null;
|
||||
}
|
||||
// keccak256('addr(bytes32)')
|
||||
var data = '0x3b3b57de' + nodeHash.substring(2);
|
||||
var transaction = { to: resolverAddress, data: data };
|
||||
@@ -11101,7 +11121,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return null;
|
||||
}
|
||||
var address = address_1.getAddress(bytes_1.hexDataSlice(data, 12));
|
||||
if (address === '0x0000000000000000000000000000000000000000') {
|
||||
if (address === constants_1.AddressZero) {
|
||||
return null;
|
||||
}
|
||||
return address;
|
||||
@@ -11127,6 +11147,9 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
var transaction = { to: resolverAddress, data: data };
|
||||
return self.call(transaction);
|
||||
}).then(function (data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
// Strip off the "0x"
|
||||
data = data.substring(2);
|
||||
// Strip off the dynamic string pointer (0x20)
|
||||
@@ -11273,7 +11296,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
exports.BaseProvider = BaseProvider;
|
||||
properties_1.defineReadOnly(abstract_provider_1.Provider, 'inherits', properties_1.inheritable(abstract_provider_1.Provider));
|
||||
|
||||
},{"../errors":5,"../utils/address":59,"../utils/bignumber":62,"../utils/bytes":63,"../utils/hash":64,"../utils/networks":71,"../utils/properties":73,"../utils/rlp":75,"../utils/transaction":82,"../utils/utf8":84,"../utils/web":85,"./abstract-provider":49}],51:[function(require,module,exports){
|
||||
},{"../constants":3,"../errors":5,"../utils/address":59,"../utils/bignumber":62,"../utils/bytes":63,"../utils/hash":64,"../utils/networks":71,"../utils/properties":73,"../utils/rlp":75,"../utils/transaction":82,"../utils/utf8":84,"../utils/web":85,"./abstract-provider":49}],51:[function(require,module,exports){
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
@@ -11801,6 +11824,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;
|
||||
@@ -11818,6 +11844,7 @@ var InfuraProvider = /** @class */ (function (_super) {
|
||||
// Legacy API Access Token
|
||||
}
|
||||
else {
|
||||
errors.warn("The legacy INFURA apiAccesToken API is deprecated; please upgrade to a Project ID instead (see INFURA dshboard; https://infura.io)");
|
||||
_this = _super.call(this, 'https://' + host + '/' + projectId, standard) || this;
|
||||
properties_1.defineReadOnly(_this, 'apiAccessToken', projectId);
|
||||
properties_1.defineReadOnly(_this, 'projectId', null);
|
||||
@@ -11896,6 +11923,10 @@ function getLowerCase(value) {
|
||||
return value;
|
||||
}
|
||||
var _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.
|
||||
var _nextId = 42;
|
||||
var JsonRpcSigner = /** @class */ (function (_super) {
|
||||
__extends(JsonRpcSigner, _super);
|
||||
function JsonRpcSigner(constructorGuard, provider, addressOrIndex) {
|
||||
@@ -12082,7 +12113,7 @@ var JsonRpcProvider = /** @class */ (function (_super) {
|
||||
var request = {
|
||||
method: method,
|
||||
params: params,
|
||||
id: 42,
|
||||
id: (_nextId++),
|
||||
jsonrpc: "2.0"
|
||||
};
|
||||
return web_1.fetchJson(this.connection, JSON.stringify(request), getResult).then(function (result) {
|
||||
@@ -12268,6 +12299,7 @@ utils.defineProperty(Web3Signer, 'onchange', {
|
||||
});
|
||||
|
||||
*/
|
||||
var _nextId = 42;
|
||||
var Web3Provider = /** @class */ (function (_super) {
|
||||
__extends(Web3Provider, _super);
|
||||
function Web3Provider(web3Provider, network) {
|
||||
@@ -12301,7 +12333,7 @@ var Web3Provider = /** @class */ (function (_super) {
|
||||
var request = {
|
||||
method: method,
|
||||
params: params,
|
||||
id: 42,
|
||||
id: (_nextId++),
|
||||
jsonrpc: "2.0"
|
||||
};
|
||||
_this._sendAsync(request, function (error, result) {
|
||||
@@ -12311,10 +12343,10 @@ var Web3Provider = /** @class */ (function (_super) {
|
||||
}
|
||||
if (result.error) {
|
||||
// @TODO: not any
|
||||
var error = new Error(result.error.message);
|
||||
error.code = result.error.code;
|
||||
error.data = result.error.data;
|
||||
reject(error);
|
||||
var error_1 = new Error(result.error.message);
|
||||
error_1.code = result.error.code;
|
||||
error_1.data = result.error.data;
|
||||
reject(error_1);
|
||||
return;
|
||||
}
|
||||
resolve(result.result);
|
||||
@@ -12808,7 +12840,7 @@ var CoderFixedBytes = /** @class */ (function (_super) {
|
||||
};
|
||||
CoderFixedBytes.prototype.decode = function (data, offset) {
|
||||
if (data.length < offset + 32) {
|
||||
errors.throwError('insufficient data for ' + name + ' type', errors.INVALID_ARGUMENT, {
|
||||
errors.throwError('insufficient data for ' + this.name + ' type', errors.INVALID_ARGUMENT, {
|
||||
arg: this.localName,
|
||||
coderType: this.name,
|
||||
value: bytes_1.hexlify(data.slice(offset, offset + 32))
|
||||
@@ -14262,7 +14294,7 @@ var HDNode = /** @class */ (function () {
|
||||
result = result._derive(index);
|
||||
}
|
||||
else {
|
||||
throw new Error('invlaid path component - ' + component);
|
||||
throw new Error('invalid path component - ' + component);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -14293,7 +14325,7 @@ function fromExtendedKey(extendedKey) {
|
||||
return new HDNode(_constructorGuard, null, bytes_1.hexlify(key), parentFingerprint, chainCode, index, depth, null, null);
|
||||
// Private Key
|
||||
case "0x0488ade4":
|
||||
case "0x04358394 ":
|
||||
case "0x04358394":
|
||||
if (key[0] !== 0) {
|
||||
break;
|
||||
}
|
||||
@@ -14314,8 +14346,8 @@ function _fromSeed(seed, mnemonic) {
|
||||
return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic, 'm');
|
||||
}
|
||||
function fromMnemonic(mnemonic, wordlist, password) {
|
||||
// Check that the checksum s valid (will throw an error)
|
||||
mnemonicToEntropy(mnemonic, wordlist);
|
||||
// Normalize the mnemonic (also throws if the checksum is invalid)
|
||||
mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist);
|
||||
return _fromSeed(mnemonicToSeed(mnemonic, password), mnemonic);
|
||||
}
|
||||
exports.fromMnemonic = fromMnemonic;
|
||||
@@ -14534,6 +14566,7 @@ exports.formatUnits = units_1.formatUnits;
|
||||
exports.parseUnits = units_1.parseUnits;
|
||||
var web_1 = require("./web");
|
||||
exports.fetchJson = web_1.fetchJson;
|
||||
exports.poll = web_1.poll;
|
||||
////////////////////////
|
||||
// Enums
|
||||
var hmac_1 = require("./hmac");
|
||||
@@ -15068,12 +15101,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,
|
||||
@@ -15482,7 +15510,7 @@ function _decode(data, offset) {
|
||||
else if (data[offset] >= 0x80) {
|
||||
var length = data[offset] - 0x80;
|
||||
if (offset + 1 + length > data.length) {
|
||||
throw new Error('invlaid rlp data');
|
||||
throw new Error('invalid rlp data');
|
||||
}
|
||||
var result = bytes_1.hexlify(data.slice(offset + 1, offset + 1 + length));
|
||||
return { consumed: (1 + length), result: result };
|
||||
@@ -15729,7 +15757,7 @@ function decrypt(json, password, progressCallback) {
|
||||
return null;
|
||||
}
|
||||
var signingKey = new signing_key_1.SigningKey(privateKey);
|
||||
if (signingKey.address !== address_1.getAddress(data.address)) {
|
||||
if (data.address && signingKey.address !== address_1.getAddress(data.address)) {
|
||||
reject(new Error('address mismatch'));
|
||||
return null;
|
||||
}
|
||||
@@ -16726,7 +16754,7 @@ function parseBytes32String(bytes) {
|
||||
throw new Error('invalid bytes32 - not 32 bytes long');
|
||||
}
|
||||
if (data[31] !== 0) {
|
||||
throw new Error('invalid bytes32 sdtring - no null terminator');
|
||||
throw new Error('invalid bytes32 string - no null terminator');
|
||||
}
|
||||
// Find the null termination
|
||||
var length = 31;
|
||||
|
||||
2
dist/ethers.min.js
vendored
2
dist/ethers.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/ethers.min.js.map
vendored
2
dist/ethers.min.js.map
vendored
File diff suppressed because one or more lines are too long
7
dist/ethers.types.txt
vendored
7
dist/ethers.types.txt
vendored
@@ -232,7 +232,7 @@ declare module 'ethers/utils' {
|
||||
import { parse as parseTransaction, serialize as serializeTransaction } from 'ethers/utils/transaction';
|
||||
import { formatBytes32String, parseBytes32String, toUtf8Bytes, toUtf8String } from 'ethers/utils/utf8';
|
||||
import { commify, formatEther, parseEther, formatUnits, parseUnits } from 'ethers/utils/units';
|
||||
import { fetchJson } from 'ethers/utils/web';
|
||||
import { fetchJson, poll } from 'ethers/utils/web';
|
||||
import { SupportedAlgorithms } from 'ethers/utils/hmac';
|
||||
import { UnicodeNormalizationForm } from 'ethers/utils/utf8';
|
||||
import { CoerceFunc, EventFragment, FunctionFragment, ParamType } from 'ethers/utils/abi-coder';
|
||||
@@ -244,7 +244,7 @@ declare module 'ethers/utils' {
|
||||
import { ConnectionInfo, OnceBlockable, PollOptions } from 'ethers/utils/web';
|
||||
import { EncryptOptions, ProgressCallback } from 'ethers/utils/secret-storage';
|
||||
import { Wordlist } from 'ethers/utils/wordlist';
|
||||
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, isHexString, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, populateTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };
|
||||
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, isHexString, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, populateTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, poll, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };
|
||||
}
|
||||
|
||||
declare module 'ethers/wordlists' {
|
||||
@@ -266,7 +266,7 @@ declare module 'ethers/utils/shims' {
|
||||
}
|
||||
|
||||
declare module 'ethers/_version' {
|
||||
export const version = "4.0.26";
|
||||
export const version = "4.0.37";
|
||||
}
|
||||
|
||||
declare module 'ethers/utils/bignumber' {
|
||||
@@ -771,6 +771,7 @@ declare module 'ethers/providers/base-provider' {
|
||||
getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>;
|
||||
getLogs(filter: Filter | FilterByBlock): Promise<Array<Log>>;
|
||||
getEtherPrice(): Promise<number>;
|
||||
_getAddress(addressOrName: string): Promise<string>;
|
||||
resolveName(name: string | Promise<string>): Promise<string>;
|
||||
lookupAddress(address: string | Promise<string>): Promise<string>;
|
||||
static checkTransactionResponse(transaction: any): TransactionResponse;
|
||||
|
||||
2
dist/shims.js
vendored
2
dist/shims.js
vendored
File diff suppressed because one or more lines are too long
2375
package-lock.json
generated
2375
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ethers",
|
||||
"version": "4.0.27",
|
||||
"version": "4.0.37",
|
||||
"description": "Ethereum wallet library.",
|
||||
"main": "./index.js",
|
||||
"types": "./index.d.ts",
|
||||
@@ -34,7 +34,7 @@
|
||||
"browserify": "^16.2.3",
|
||||
"browserify-zlib": "^0.2.0",
|
||||
"dts-bundle": "^0.7.3",
|
||||
"eslint": "^5.0.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-plugin-promise": "^3.8.0",
|
||||
"ethereumjs-tx": "^1.3.5",
|
||||
"ethereumjs-util": "^5.2.0",
|
||||
@@ -64,5 +64,6 @@
|
||||
"type": "git",
|
||||
"url": "git://github.com/ethers-io/ethers.js.git"
|
||||
},
|
||||
"ethereum": "donations.ethers.eth",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
1
providers/base-provider.d.ts
vendored
1
providers/base-provider.d.ts
vendored
@@ -53,6 +53,7 @@ export declare class BaseProvider extends Provider {
|
||||
getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>;
|
||||
getLogs(filter: Filter | FilterByBlock): Promise<Array<Log>>;
|
||||
getEtherPrice(): Promise<number>;
|
||||
_getAddress(addressOrName: string): Promise<string>;
|
||||
private _resolveNames;
|
||||
private _getResolver;
|
||||
resolveName(name: string | Promise<string>): Promise<string>;
|
||||
|
||||
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var address_1 = require("../utils/address");
|
||||
var bignumber_1 = require("../utils/bignumber");
|
||||
var bytes_1 = require("../utils/bytes");
|
||||
var constants_1 = require("../constants");
|
||||
var hash_1 = require("../utils/hash");
|
||||
var networks_1 = require("../utils/networks");
|
||||
var properties_1 = require("../utils/properties");
|
||||
@@ -698,7 +699,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.ready.then(function () {
|
||||
return properties_1.resolveProperties({ addressOrName: addressOrName, blockTag: blockTag }).then(function (_a) {
|
||||
var addressOrName = _a.addressOrName, blockTag = _a.blockTag;
|
||||
return _this.resolveName(addressOrName).then(function (address) {
|
||||
return _this._getAddress(addressOrName).then(function (address) {
|
||||
var params = { address: address, blockTag: checkBlockTag(blockTag) };
|
||||
return _this.perform('getBalance', params).then(function (result) {
|
||||
return bignumber_1.bigNumberify(result);
|
||||
@@ -712,7 +713,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.ready.then(function () {
|
||||
return properties_1.resolveProperties({ addressOrName: addressOrName, blockTag: blockTag }).then(function (_a) {
|
||||
var addressOrName = _a.addressOrName, blockTag = _a.blockTag;
|
||||
return _this.resolveName(addressOrName).then(function (address) {
|
||||
return _this._getAddress(addressOrName).then(function (address) {
|
||||
var params = { address: address, blockTag: checkBlockTag(blockTag) };
|
||||
return _this.perform('getTransactionCount', params).then(function (result) {
|
||||
return bignumber_1.bigNumberify(result).toNumber();
|
||||
@@ -726,7 +727,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.ready.then(function () {
|
||||
return properties_1.resolveProperties({ addressOrName: addressOrName, blockTag: blockTag }).then(function (_a) {
|
||||
var addressOrName = _a.addressOrName, blockTag = _a.blockTag;
|
||||
return _this.resolveName(addressOrName).then(function (address) {
|
||||
return _this._getAddress(addressOrName).then(function (address) {
|
||||
var params = { address: address, blockTag: checkBlockTag(blockTag) };
|
||||
return _this.perform('getCode', params).then(function (result) {
|
||||
return bytes_1.hexlify(result);
|
||||
@@ -740,7 +741,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.ready.then(function () {
|
||||
return properties_1.resolveProperties({ addressOrName: addressOrName, position: position, blockTag: blockTag }).then(function (_a) {
|
||||
var addressOrName = _a.addressOrName, position = _a.position, blockTag = _a.blockTag;
|
||||
return _this.resolveName(addressOrName).then(function (address) {
|
||||
return _this._getAddress(addressOrName).then(function (address) {
|
||||
var params = {
|
||||
address: address,
|
||||
blockTag: checkBlockTag(blockTag),
|
||||
@@ -983,6 +984,14 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
});
|
||||
});
|
||||
};
|
||||
BaseProvider.prototype._getAddress = function (addressOrName) {
|
||||
return this.resolveName(addressOrName).then(function (address) {
|
||||
if (address == null) {
|
||||
errors.throwError("ENS name not configured", errors.UNSUPPORTED_OPERATION, { operation: "resolveName(" + JSON.stringify(addressOrName) + ")" });
|
||||
}
|
||||
return address;
|
||||
});
|
||||
};
|
||||
// @TODO: Could probably use resolveProperties instead?
|
||||
BaseProvider.prototype._resolveNames = function (object, keys) {
|
||||
var promises = [];
|
||||
@@ -991,7 +1000,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
if (result[key] == null) {
|
||||
return;
|
||||
}
|
||||
promises.push(this.resolveName(result[key]).then(function (address) {
|
||||
promises.push(this._getAddress(result[key]).then(function (address) {
|
||||
result[key] = address;
|
||||
return;
|
||||
}));
|
||||
@@ -1004,7 +1013,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return this.getNetwork().then(function (network) {
|
||||
// No ENS...
|
||||
if (!network.ensAddress) {
|
||||
errors.throwError('network does support ENS', errors.UNSUPPORTED_OPERATION, { operation: 'ENS', network: network.name });
|
||||
errors.throwError('network does not support ENS', errors.UNSUPPORTED_OPERATION, { operation: 'ENS', network: network.name });
|
||||
}
|
||||
// keccak256('resolver(bytes32)')
|
||||
var data = '0x0178b8bf' + hash_1.namehash(name).substring(2);
|
||||
@@ -1014,7 +1023,11 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
if (bytes_1.hexDataLength(data) !== 32) {
|
||||
return null;
|
||||
}
|
||||
return address_1.getAddress(bytes_1.hexDataSlice(data, 12));
|
||||
var address = address_1.getAddress(bytes_1.hexDataSlice(data, 12));
|
||||
if (address === constants_1.AddressZero) {
|
||||
return null;
|
||||
}
|
||||
return address;
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1035,6 +1048,9 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
var nodeHash = hash_1.namehash(name);
|
||||
// Get the addr from the resovler
|
||||
return this._getResolver(name).then(function (resolverAddress) {
|
||||
if (resolverAddress == null) {
|
||||
return null;
|
||||
}
|
||||
// keccak256('addr(bytes32)')
|
||||
var data = '0x3b3b57de' + nodeHash.substring(2);
|
||||
var transaction = { to: resolverAddress, data: data };
|
||||
@@ -1045,7 +1061,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return null;
|
||||
}
|
||||
var address = address_1.getAddress(bytes_1.hexDataSlice(data, 12));
|
||||
if (address === '0x0000000000000000000000000000000000000000') {
|
||||
if (address === constants_1.AddressZero) {
|
||||
return null;
|
||||
}
|
||||
return address;
|
||||
@@ -1071,6 +1087,9 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
var transaction = { to: resolverAddress, data: data };
|
||||
return self.call(transaction);
|
||||
}).then(function (data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
// Strip off the "0x"
|
||||
data = data.substring(2);
|
||||
// Strip off the dynamic string pointer (0x20)
|
||||
|
||||
@@ -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;
|
||||
@@ -59,6 +62,7 @@ var InfuraProvider = /** @class */ (function (_super) {
|
||||
// Legacy API Access Token
|
||||
}
|
||||
else {
|
||||
errors.warn("The legacy INFURA apiAccesToken API is deprecated; please upgrade to a Project ID instead (see INFURA dshboard; https://infura.io)");
|
||||
_this = _super.call(this, 'https://' + host + '/' + projectId, standard) || this;
|
||||
properties_1.defineReadOnly(_this, 'apiAccessToken', projectId);
|
||||
properties_1.defineReadOnly(_this, 'projectId', null);
|
||||
|
||||
@@ -51,6 +51,10 @@ function getLowerCase(value) {
|
||||
return value;
|
||||
}
|
||||
var _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.
|
||||
var _nextId = 42;
|
||||
var JsonRpcSigner = /** @class */ (function (_super) {
|
||||
__extends(JsonRpcSigner, _super);
|
||||
function JsonRpcSigner(constructorGuard, provider, addressOrIndex) {
|
||||
@@ -237,7 +241,7 @@ var JsonRpcProvider = /** @class */ (function (_super) {
|
||||
var request = {
|
||||
method: method,
|
||||
params: params,
|
||||
id: 42,
|
||||
id: (_nextId++),
|
||||
jsonrpc: "2.0"
|
||||
};
|
||||
return web_1.fetchJson(this.connection, JSON.stringify(request), getResult).then(function (result) {
|
||||
|
||||
@@ -27,6 +27,7 @@ utils.defineProperty(Web3Signer, 'onchange', {
|
||||
});
|
||||
|
||||
*/
|
||||
var _nextId = 42;
|
||||
var Web3Provider = /** @class */ (function (_super) {
|
||||
__extends(Web3Provider, _super);
|
||||
function Web3Provider(web3Provider, network) {
|
||||
@@ -60,7 +61,7 @@ var Web3Provider = /** @class */ (function (_super) {
|
||||
var request = {
|
||||
method: method,
|
||||
params: params,
|
||||
id: 42,
|
||||
id: (_nextId++),
|
||||
jsonrpc: "2.0"
|
||||
};
|
||||
_this._sendAsync(request, function (error, result) {
|
||||
@@ -70,10 +71,10 @@ var Web3Provider = /** @class */ (function (_super) {
|
||||
}
|
||||
if (result.error) {
|
||||
// @TODO: not any
|
||||
var error = new Error(result.error.message);
|
||||
error.code = result.error.code;
|
||||
error.data = result.error.data;
|
||||
reject(error);
|
||||
var error_1 = new Error(result.error.message);
|
||||
error_1.code = result.error.code;
|
||||
error_1.data = result.error.data;
|
||||
reject(error_1);
|
||||
return;
|
||||
}
|
||||
resolve(result.result);
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "4.0.26";
|
||||
export const version = "4.0.37";
|
||||
|
||||
@@ -262,7 +262,7 @@ function runMethod(contract: Contract, functionName: string, estimateOnly: boole
|
||||
}
|
||||
|
||||
if (!contract.signer) {
|
||||
errors.throwError('sending a transaction require a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction' })
|
||||
errors.throwError('sending a transaction requires a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction' })
|
||||
}
|
||||
|
||||
// Make sure they aren't overriding something they shouldn't
|
||||
@@ -478,7 +478,7 @@ export class Contract {
|
||||
|
||||
fallback(overrides?: TransactionRequest): Promise<TransactionResponse> {
|
||||
if (!this.signer) {
|
||||
errors.throwError('sending a transaction require a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction(fallback)' })
|
||||
errors.throwError('sending a transaction requires a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction(fallback)' })
|
||||
}
|
||||
|
||||
var tx: TransactionRequest = shallowCopy(overrides || {});
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { getAddress, getContractAddress } from '../utils/address';
|
||||
import { BigNumber, bigNumberify } from '../utils/bignumber';
|
||||
import { hexDataLength, hexDataSlice, hexlify, hexStripZeros, isHexString, stripZeros } from '../utils/bytes';
|
||||
import { AddressZero } from "../constants";
|
||||
import { namehash } from '../utils/hash';
|
||||
import { getNetwork } from '../utils/networks';
|
||||
import { defineReadOnly, inheritable, resolveProperties, shallowCopy } from '../utils/properties';
|
||||
@@ -816,7 +817,7 @@ export class BaseProvider extends Provider {
|
||||
getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber> {
|
||||
return this.ready.then(() => {
|
||||
return resolveProperties({ addressOrName: addressOrName, blockTag: blockTag }).then(({ addressOrName, blockTag }) => {
|
||||
return this.resolveName(addressOrName).then((address) => {
|
||||
return this._getAddress(addressOrName).then((address) => {
|
||||
let params = { address: address, blockTag: checkBlockTag(blockTag) };
|
||||
return this.perform('getBalance', params).then((result) => {
|
||||
return bigNumberify(result);
|
||||
@@ -829,7 +830,7 @@ export class BaseProvider extends Provider {
|
||||
getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number> {
|
||||
return this.ready.then(() => {
|
||||
return resolveProperties({ addressOrName: addressOrName, blockTag: blockTag }).then(({ addressOrName, blockTag }) => {
|
||||
return this.resolveName(addressOrName).then((address) => {
|
||||
return this._getAddress(addressOrName).then((address) => {
|
||||
let params = { address: address, blockTag: checkBlockTag(blockTag) };
|
||||
return this.perform('getTransactionCount', params).then((result) => {
|
||||
return bigNumberify(result).toNumber();
|
||||
@@ -842,7 +843,7 @@ export class BaseProvider extends Provider {
|
||||
getCode(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string> {
|
||||
return this.ready.then(() => {
|
||||
return resolveProperties({ addressOrName: addressOrName, blockTag: blockTag }).then(({ addressOrName, blockTag }) => {
|
||||
return this.resolveName(addressOrName).then((address) => {
|
||||
return this._getAddress(addressOrName).then((address) => {
|
||||
let params = {address: address, blockTag: checkBlockTag(blockTag)};
|
||||
return this.perform('getCode', params).then((result) => {
|
||||
return hexlify(result);
|
||||
@@ -855,7 +856,7 @@ export class BaseProvider extends Provider {
|
||||
getStorageAt(addressOrName: string | Promise<string>, position: BigNumberish | Promise<BigNumberish>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string> {
|
||||
return this.ready.then(() => {
|
||||
return resolveProperties({ addressOrName: addressOrName, position: position, blockTag: blockTag }).then(({ addressOrName, position, blockTag }) => {
|
||||
return this.resolveName(addressOrName).then((address) => {
|
||||
return this._getAddress(addressOrName).then((address) => {
|
||||
let params = {
|
||||
address: address,
|
||||
blockTag: checkBlockTag(blockTag),
|
||||
@@ -1108,6 +1109,15 @@ export class BaseProvider extends Provider {
|
||||
});
|
||||
}
|
||||
|
||||
_getAddress(addressOrName: string): Promise<string> {
|
||||
return this.resolveName(addressOrName).then((address) => {
|
||||
if (address == null) {
|
||||
errors.throwError("ENS name not configured", errors.UNSUPPORTED_OPERATION, { operation: "resolveName(" + JSON.stringify(addressOrName) + ")" });
|
||||
}
|
||||
return address;
|
||||
});
|
||||
}
|
||||
|
||||
// @TODO: Could probably use resolveProperties instead?
|
||||
private _resolveNames(object: any, keys: Array<string>): Promise<{ [key: string]: string }> {
|
||||
let promises: Array<Promise<void>> = [];
|
||||
@@ -1116,7 +1126,7 @@ export class BaseProvider extends Provider {
|
||||
|
||||
keys.forEach(function(key) {
|
||||
if (result[key] == null) { return; }
|
||||
promises.push(this.resolveName(result[key]).then((address: string) => {
|
||||
promises.push(this._getAddress(result[key]).then((address: string) => {
|
||||
result[key] = address;
|
||||
return;
|
||||
}));
|
||||
@@ -1132,7 +1142,7 @@ export class BaseProvider extends Provider {
|
||||
// No ENS...
|
||||
if (!network.ensAddress) {
|
||||
errors.throwError(
|
||||
'network does support ENS',
|
||||
'network does not support ENS',
|
||||
errors.UNSUPPORTED_OPERATION,
|
||||
{ operation: 'ENS', network: network.name }
|
||||
);
|
||||
@@ -1143,10 +1153,11 @@ export class BaseProvider extends Provider {
|
||||
let transaction = { to: network.ensAddress, data: data };
|
||||
|
||||
return this.call(transaction).then((data) => {
|
||||
|
||||
// extract the address from the data
|
||||
if (hexDataLength(data) !== 32) { return null; }
|
||||
return getAddress(hexDataSlice(data, 12));
|
||||
let address = getAddress(hexDataSlice(data, 12));
|
||||
if (address === AddressZero) { return null; }
|
||||
return address;
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1171,6 +1182,7 @@ export class BaseProvider extends Provider {
|
||||
|
||||
// Get the addr from the resovler
|
||||
return this._getResolver(name).then(function(resolverAddress) {
|
||||
if (resolverAddress == null) { return null; }
|
||||
|
||||
// keccak256('addr(bytes32)')
|
||||
let data = '0x3b3b57de' + nodeHash.substring(2);
|
||||
@@ -1181,7 +1193,7 @@ export class BaseProvider extends Provider {
|
||||
}).then(function(data) {
|
||||
if (hexDataLength(data) !== 32) { return null; }
|
||||
let address = getAddress(hexDataSlice(data, 12));
|
||||
if (address === '0x0000000000000000000000000000000000000000') { return null; }
|
||||
if (address === AddressZero) { return null; }
|
||||
return address;
|
||||
});
|
||||
}
|
||||
@@ -1209,6 +1221,8 @@ export class BaseProvider extends Provider {
|
||||
return self.call(transaction);
|
||||
|
||||
}).then(function(data) {
|
||||
if (data == null) { return null; }
|
||||
|
||||
// Strip off the "0x"
|
||||
data = data.substring(2);
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ export class InfuraProvider extends JsonRpcProvider {
|
||||
|
||||
// Legacy API Access Token
|
||||
} else {
|
||||
errors.warn("The legacy INFURA apiAccesToken API is deprecated; please upgrade to a Project ID instead (see INFURA dshboard; https://infura.io)");
|
||||
super('https://' + host + '/' + projectId, standard);
|
||||
defineReadOnly(this, 'apiAccessToken', projectId);
|
||||
defineReadOnly(this, 'projectId', null);
|
||||
|
||||
@@ -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"
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ utils.defineProperty(Web3Signer, 'onchange', {
|
||||
|
||||
*/
|
||||
|
||||
let _nextId = 42;
|
||||
|
||||
export class Web3Provider extends JsonRpcProvider {
|
||||
readonly _web3Provider: AsyncSendable;
|
||||
private _sendAsync: (request: any, callback: (error: any, response: any) => void) => void;
|
||||
@@ -65,10 +67,10 @@ export class Web3Provider extends JsonRpcProvider {
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
var request = {
|
||||
let request = {
|
||||
method: method,
|
||||
params: params,
|
||||
id: 42,
|
||||
id: (_nextId++),
|
||||
jsonrpc: "2.0"
|
||||
};
|
||||
|
||||
@@ -80,7 +82,7 @@ export class Web3Provider extends JsonRpcProvider {
|
||||
|
||||
if (result.error) {
|
||||
// @TODO: not any
|
||||
var error: any = new Error(result.error.message);
|
||||
let error: any = new Error(result.error.message);
|
||||
error.code = result.error.code;
|
||||
error.data = result.error.data;
|
||||
reject(error);
|
||||
|
||||
@@ -574,7 +574,7 @@ class CoderFixedBytes extends Coder {
|
||||
|
||||
decode(data: Uint8Array, offset: number): DecodedResult {
|
||||
if (data.length < offset + 32) {
|
||||
errors.throwError('insufficient data for ' + name + ' type', errors.INVALID_ARGUMENT, {
|
||||
errors.throwError('insufficient data for ' + this.name + ' type', errors.INVALID_ARGUMENT, {
|
||||
arg: this.localName,
|
||||
coderType: this.name,
|
||||
value: hexlify(data.slice(offset, offset + 32))
|
||||
|
||||
@@ -206,7 +206,7 @@ export class HDNode {
|
||||
if (index >= HardenedBit) { throw new Error('invalid path index - ' + component); }
|
||||
result = result._derive(index);
|
||||
} else {
|
||||
throw new Error('invlaid path component - ' + component);
|
||||
throw new Error('invalid path component - ' + component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ export function fromExtendedKey(extendedKey: string): HDNode {
|
||||
return new HDNode(_constructorGuard, null, hexlify(key), parentFingerprint, chainCode, index, depth, null, null);
|
||||
|
||||
// Private Key
|
||||
case "0x0488ade4": case "0x04358394 ":
|
||||
case "0x0488ade4": case "0x04358394":
|
||||
if (key[0] !== 0) { break; }
|
||||
return new HDNode(_constructorGuard, hexlify(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null, null);
|
||||
}
|
||||
@@ -261,8 +261,8 @@ function _fromSeed(seed: Arrayish, mnemonic: string): HDNode {
|
||||
}
|
||||
|
||||
export function fromMnemonic(mnemonic: string, wordlist?: Wordlist, password?: string): HDNode {
|
||||
// Check that the checksum s valid (will throw an error)
|
||||
mnemonicToEntropy(mnemonic, wordlist);
|
||||
// Normalize the mnemonic (also throws if the checksum is invalid)
|
||||
mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist);
|
||||
|
||||
return _fromSeed(mnemonicToSeed(mnemonic, password), mnemonic);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import { populateTransaction } from './transaction';
|
||||
import { parse as parseTransaction, serialize as serializeTransaction } from './transaction';
|
||||
import { formatBytes32String, parseBytes32String, toUtf8Bytes, toUtf8String } from './utf8';
|
||||
import { commify, formatEther, parseEther, formatUnits, parseUnits } from './units';
|
||||
import { fetchJson } from './web';
|
||||
import { fetchJson, poll } from './web';
|
||||
|
||||
|
||||
////////////////////////
|
||||
@@ -136,6 +136,8 @@ export {
|
||||
recoverPublicKey,
|
||||
verifyMessage,
|
||||
|
||||
poll,
|
||||
|
||||
|
||||
////////////////////////
|
||||
// Enums
|
||||
|
||||
@@ -127,7 +127,7 @@ function _decode(data: Uint8Array, offset: number): { consumed: number, result:
|
||||
} else if (data[offset] >= 0x80) {
|
||||
var length = data[offset] - 0x80;
|
||||
if (offset + 1 + length > data.length) {
|
||||
throw new Error('invlaid rlp data');
|
||||
throw new Error('invalid rlp data');
|
||||
}
|
||||
|
||||
var result = hexlify(data.slice(offset + 1, offset + 1 + length));
|
||||
|
||||
@@ -171,7 +171,7 @@ export function decrypt(json: string, password: Arrayish, progressCallback?: Pro
|
||||
}
|
||||
|
||||
var signingKey = new SigningKey(privateKey);
|
||||
if (signingKey.address !== getAddress(data.address)) {
|
||||
if (data.address && signingKey.address !== getAddress(data.address)) {
|
||||
reject(new Error('address mismatch'));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ export function parseBytes32String(bytes: Arrayish): string {
|
||||
|
||||
// Must be 32 bytes with a null-termination
|
||||
if (data.length !== 32) { throw new Error('invalid bytes32 - not 32 bytes long'); }
|
||||
if (data[31] !== 0) { throw new Error('invalid bytes32 sdtring - no null terminator'); }
|
||||
if (data[31] !== 0) { throw new Error('invalid bytes32 string - no null terminator'); }
|
||||
|
||||
// Find the null termination
|
||||
let length = 31;
|
||||
|
||||
@@ -6,6 +6,7 @@ var path = require('path');
|
||||
var utils = require('../utils.js');
|
||||
|
||||
function prefixAddress(address) {
|
||||
if (!address) { return null; }
|
||||
if (address.substring(0, 2) !== '0x') {
|
||||
address = '0x' + address;
|
||||
}
|
||||
@@ -25,6 +26,10 @@ Output.push({
|
||||
});
|
||||
*/
|
||||
|
||||
var addresses = {
|
||||
"582": "0x008aeeda4d805471df9b2a5b0f38a0c3bcba786b"
|
||||
};
|
||||
|
||||
var privateKeys = {
|
||||
'0x0b88d4b324ec24c8c078551e6e5075547157e5b6': '0xd4375d2a931db84ea8825b69a3128913597744d9236cacec675cc18e1bda4446',
|
||||
'0x2e326fa404fc3661de4f4361776ed9bbabdc26e3': '0xcf367fc32bf789b3339c6664af4a12263e9db0e0eb70f247da1d1165e150c487',
|
||||
@@ -33,7 +38,8 @@ var privateKeys = {
|
||||
'0x88a5c2d9919e46f883eb62f7b8dd9d0cc45bc290': '0xf03e581353c794928373fb0893bc731aefc4c4e234e643f3a46998b03cd4d7c5',
|
||||
'0x17c5185167401ed00cf5f5b2fc97d9bbfdb7d025': '0x4242424242424242424242424242424242424242424242424242424242424242',
|
||||
'0x012363d61bdc53d0290a0f25e9c89f8257550fb8': '0x4c94faa2c558a998d10ee8b2b9b8eb1fbcb8a6ac5fd085c6f95535604fc1bffb',
|
||||
'0x15db397ed5f682acb22b0afc6c8de4cdfbda7cbc': '0xcdf3c34a2ea0ff181f462856168f5851e68c37b583eb158403e43aeab4964fee'
|
||||
'0x15db397ed5f682acb22b0afc6c8de4cdfbda7cbc': '0xcdf3c34a2ea0ff181f462856168f5851e68c37b583eb158403e43aeab4964fee',
|
||||
'0x008aeeda4d805471df9b2a5b0f38a0c3bcba786b': '0x7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d'
|
||||
}
|
||||
|
||||
var mnemonics = {
|
||||
@@ -62,14 +68,16 @@ fs.readdirSync(walletPath).forEach(function(filename) {
|
||||
});
|
||||
|
||||
} else {
|
||||
let address = (addresses[name] || prefixAddress(data.address));
|
||||
Output.push({
|
||||
type: 'secret-storage',
|
||||
address: prefixAddress(data.address),
|
||||
hasAddress: !addresses[name],
|
||||
address: address,
|
||||
json: JSON.stringify(data),
|
||||
mnemonic: mnemonics[prefixAddress(data.address)] || '',
|
||||
mnemonic: mnemonics[address] || '',
|
||||
name: name,
|
||||
password: password,
|
||||
privateKey: privateKeys[prefixAddress(data.address)],
|
||||
privateKey: privateKeys[address],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"6087dab2f9fdbbfaddc31a909735c1e6"},"ciphertext":"5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46","kdf":"pbkdf2","kdfparams":{"c":262144,"dklen":32,"prf":"hmac-sha256","salt":"ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd"},"mac":"517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2"},"id":"3198bc9c-6672-5ab3-d995-4942343ae5b6","version":3}
|
||||
@@ -5,11 +5,20 @@ var assert = require('assert');
|
||||
var utils = require('./utils');
|
||||
var ethers = utils.getEthers(__filename);
|
||||
|
||||
function skip(name) {
|
||||
var match = name.match(/^random-([0-9]+)$/);
|
||||
if (match && parseInt(match[1]) > 512) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
describe('Test HD Node Derivation', function(test) {
|
||||
|
||||
var tests = utils.loadTests('hdnode');
|
||||
tests.forEach(function(test) {
|
||||
it('Derives the HD nodes - ' + test.name, function() {
|
||||
if (skip(test.name)) { return; }
|
||||
it('Derives the HD nodes - ' + test.name, function() {
|
||||
this.timeout(10000);
|
||||
|
||||
//var rootNode = new ethers.utils.HDNode.fromSeed(test.seed);
|
||||
@@ -87,6 +96,7 @@ describe('Test HD Node Derivation', function(test) {
|
||||
describe('Test HD Mnemonic Phrases', function testMnemonic() {
|
||||
var tests = utils.loadTests('hdnode');
|
||||
tests.forEach(function(test) {
|
||||
if (skip(test.name)) { return; }
|
||||
it(('converts mnemonic phrases - ' + test.name), function() {
|
||||
this.timeout(1000000);
|
||||
|
||||
@@ -128,3 +138,71 @@ testEasySeed(ethers.wordlists.zh_cn, 'zh_cn');
|
||||
testEasySeed(ethers.wordlists.zh_tw, 'zh_tw');
|
||||
testEasySeed(ethers.wordlists.it, 'it');
|
||||
testEasySeed(ethers.wordlists.ko, 'ko');
|
||||
|
||||
describe('Testnet Extended Key (#553)', function testMnemonic() {
|
||||
var tests = [
|
||||
{
|
||||
name: "testnet extended public key",
|
||||
extended: "tpubD6NzVbkrYhZ4Xbv9K5Ajt49a8XEPydLyfyFBNvqt3TRBa9S8L3PVoKBthRS8gimY2ZU2LQ3gXQKpXHRR6fu9W1rWp6jaBToyZ5ar7wbRNYs",
|
||||
node: {
|
||||
publicKey: "0x02ead6f326f28baf5af54ab4a1688d5784f92848bba73c004365da8871b1e8677e",
|
||||
parentFingerprint: "0x00000000",
|
||||
fingerprint: "0x68ff1104",
|
||||
address: "0xc17Ee49BA46A41FBdA2306d00DA5Ce410925a7cb",
|
||||
chainCode: "0x7eee1a867c6938de05f0677d290769a6db3d135d4c1b5ba84c753b56b027cfb7",
|
||||
index: 0,
|
||||
depth: 0
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "testnet extended private key",
|
||||
extended: "tprv8ZgxMBicQKsPe8tMRRW9UeVTZViTpJA56feQ6QoadBcnjfBMheZucpa2XHqF6iuRJSngkasg1yXD7VpGgGafFJwhY5RoETMSbiyEDBzxdCd",
|
||||
node: {
|
||||
privateKey: "0x949219063180d462349e358ec93cec1067fc346b37530e44b592a8a6dbe96d4c",
|
||||
publicKey: "0x02ead6f326f28baf5af54ab4a1688d5784f92848bba73c004365da8871b1e8677e",
|
||||
parentFingerprint: "0x00000000",
|
||||
fingerprint: "0x68ff1104",
|
||||
address: "0xc17Ee49BA46A41FBdA2306d00DA5Ce410925a7cb",
|
||||
chainCode: "0x7eee1a867c6938de05f0677d290769a6db3d135d4c1b5ba84c753b56b027cfb7",
|
||||
index: 0,
|
||||
depth: 0
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
tests.forEach(function(test) {
|
||||
it(test.name, function() {
|
||||
var node = ethers.utils.HDNode.fromExtendedKey(test.extended);
|
||||
Object.keys(test.node).forEach(function(key) {
|
||||
assert.equal(node[key], test.node[key], "does not match " + key);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Test Mnemonic is Case Agnostic", function() {
|
||||
function randomCase(seed, text) {
|
||||
return text.split("").map(function(c, index) {
|
||||
if (utils.randomNumber(seed + "-" + index, 0, 1000) > 500) {
|
||||
return c.toUpperCase();
|
||||
}
|
||||
return c
|
||||
}).join("");
|
||||
}
|
||||
|
||||
function addTest(mnemonic, altMnemonic) {
|
||||
it(altMnemonic, function() {
|
||||
var node = ethers.utils.HDNode.fromMnemonic(mnemonic);
|
||||
var altNode = ethers.utils.HDNode.fromMnemonic(altMnemonic);
|
||||
assert.equal(node.privateKey, altNode.privateKey, altMnemonic);
|
||||
});
|
||||
}
|
||||
|
||||
for (var i = 0; i < 128; i++) {
|
||||
var seed = "test-" + i;
|
||||
var entropy = utils.randomBytes(seed, 16, 16);
|
||||
var mnemonic = ethers.utils.HDNode.entropyToMnemonic(entropy);
|
||||
var altMnemonic = randomCase(seed, mnemonic);
|
||||
addTest(mnemonic, altMnemonic);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,8 +12,10 @@ describe('Test JSON Wallets', function() {
|
||||
it(('decrypts wallet - ' + test.name), function() {
|
||||
this.timeout(1200000);
|
||||
|
||||
assert.ok((ethers.utils.getJsonWalletAddress(test.json) !== null),
|
||||
'detect encrypted JSON wallet');
|
||||
if (test.hasAddress) {
|
||||
assert.ok((ethers.utils.getJsonWalletAddress(test.json) !== null),
|
||||
'detect encrypted JSON wallet');
|
||||
}
|
||||
|
||||
return Wallet.fromEncryptedJson(test.json, test.password).then(function(wallet) {
|
||||
assert.equal(wallet.privateKey, test.privateKey,
|
||||
|
||||
Binary file not shown.
@@ -480,7 +480,7 @@ var CoderFixedBytes = /** @class */ (function (_super) {
|
||||
};
|
||||
CoderFixedBytes.prototype.decode = function (data, offset) {
|
||||
if (data.length < offset + 32) {
|
||||
errors.throwError('insufficient data for ' + name + ' type', errors.INVALID_ARGUMENT, {
|
||||
errors.throwError('insufficient data for ' + this.name + ' type', errors.INVALID_ARGUMENT, {
|
||||
arg: this.localName,
|
||||
coderType: this.name,
|
||||
value: bytes_1.hexlify(data.slice(offset, offset + 32))
|
||||
|
||||
@@ -174,7 +174,7 @@ var HDNode = /** @class */ (function () {
|
||||
result = result._derive(index);
|
||||
}
|
||||
else {
|
||||
throw new Error('invlaid path component - ' + component);
|
||||
throw new Error('invalid path component - ' + component);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -205,7 +205,7 @@ function fromExtendedKey(extendedKey) {
|
||||
return new HDNode(_constructorGuard, null, bytes_1.hexlify(key), parentFingerprint, chainCode, index, depth, null, null);
|
||||
// Private Key
|
||||
case "0x0488ade4":
|
||||
case "0x04358394 ":
|
||||
case "0x04358394":
|
||||
if (key[0] !== 0) {
|
||||
break;
|
||||
}
|
||||
@@ -226,8 +226,8 @@ function _fromSeed(seed, mnemonic) {
|
||||
return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic, 'm');
|
||||
}
|
||||
function fromMnemonic(mnemonic, wordlist, password) {
|
||||
// Check that the checksum s valid (will throw an error)
|
||||
mnemonicToEntropy(mnemonic, wordlist);
|
||||
// Normalize the mnemonic (also throws if the checksum is invalid)
|
||||
mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist);
|
||||
return _fromSeed(mnemonicToSeed(mnemonic, password), mnemonic);
|
||||
}
|
||||
exports.fromMnemonic = fromMnemonic;
|
||||
|
||||
4
utils/index.d.ts
vendored
4
utils/index.d.ts
vendored
@@ -20,7 +20,7 @@ import { populateTransaction } from './transaction';
|
||||
import { parse as parseTransaction, serialize as serializeTransaction } from './transaction';
|
||||
import { formatBytes32String, parseBytes32String, toUtf8Bytes, toUtf8String } from './utf8';
|
||||
import { commify, formatEther, parseEther, formatUnits, parseUnits } from './units';
|
||||
import { fetchJson } from './web';
|
||||
import { fetchJson, poll } from './web';
|
||||
import { SupportedAlgorithms } from './hmac';
|
||||
import { UnicodeNormalizationForm } from './utf8';
|
||||
import { CoerceFunc, EventFragment, FunctionFragment, ParamType } from './abi-coder';
|
||||
@@ -32,4 +32,4 @@ import { Transaction, UnsignedTransaction } from './transaction';
|
||||
import { ConnectionInfo, OnceBlockable, PollOptions } from './web';
|
||||
import { EncryptOptions, ProgressCallback } from './secret-storage';
|
||||
import { Wordlist } from './wordlist';
|
||||
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, isHexString, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, populateTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };
|
||||
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, isHexString, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, populateTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, poll, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };
|
||||
|
||||
@@ -92,6 +92,7 @@ exports.formatUnits = units_1.formatUnits;
|
||||
exports.parseUnits = units_1.parseUnits;
|
||||
var web_1 = require("./web");
|
||||
exports.fetchJson = web_1.fetchJson;
|
||||
exports.poll = web_1.poll;
|
||||
////////////////////////
|
||||
// Enums
|
||||
var hmac_1 = require("./hmac");
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -98,7 +98,7 @@ function _decode(data, offset) {
|
||||
else if (data[offset] >= 0x80) {
|
||||
var length = data[offset] - 0x80;
|
||||
if (offset + 1 + length > data.length) {
|
||||
throw new Error('invlaid rlp data');
|
||||
throw new Error('invalid rlp data');
|
||||
}
|
||||
var result = bytes_1.hexlify(data.slice(offset + 1, offset + 1 + length));
|
||||
return { consumed: (1 + length), result: result };
|
||||
|
||||
@@ -125,7 +125,7 @@ function decrypt(json, password, progressCallback) {
|
||||
return null;
|
||||
}
|
||||
var signingKey = new signing_key_1.SigningKey(privateKey);
|
||||
if (signingKey.address !== address_1.getAddress(data.address)) {
|
||||
if (data.address && signingKey.address !== address_1.getAddress(data.address)) {
|
||||
reject(new Error('address mismatch'));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ function parseBytes32String(bytes) {
|
||||
throw new Error('invalid bytes32 - not 32 bytes long');
|
||||
}
|
||||
if (data[31] !== 0) {
|
||||
throw new Error('invalid bytes32 sdtring - no null terminator');
|
||||
throw new Error('invalid bytes32 string - no null terminator');
|
||||
}
|
||||
// Find the null termination
|
||||
var length = 31;
|
||||
|
||||
Reference in New Issue
Block a user