Compare commits

..

9 Commits

Author SHA1 Message Date
Richard Moore
11c250ff7c Updated package-lock for security reasons; dev dependency only. 2019-08-26 16:08:41 -04:00
Richard Moore
c303199d26 Fixed typo in error message (#592). 2019-08-26 15:59:43 -04:00
Richard Moore
ae458a1a49 Updated dist files. 2019-08-22 17:45:59 -04:00
Richard Moore
760a5aec74 Fixed ENS lookupAddress when the resolver isn't configured (#581). 2019-08-22 17:42:23 -04:00
Richard Moore
2967efc2b0 Updated dist files. 2019-08-22 15:27:28 -04:00
Richard Moore
24f243e689 Allow Secret Storage wallet address to be optional (#582). 2019-08-22 15:22:20 -04:00
Richard Moore
d719064628 Updated package-lock for lodash security advisory; the package is only a development dependency, so no urgent need to publish, just for developers (lodash/lodash#4336). 2019-07-15 19:22:21 -03:00
Richard Moore
a7d0b41d98 Reduce number of HDNode tests which cause TravisCI to timeout. 2019-07-09 20:16:37 -04:00
Richard Moore
a980fc3db0 Updated dist files. 2019-07-09 16:56:49 -04:00
21 changed files with 1036 additions and 1048 deletions

2
_version.d.ts vendored
View File

@@ -1 +1 @@
export declare const version = "4.0.32";
export declare const version = "4.0.36";

View File

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

49
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.32";
exports.version = "4.0.36";
},{}],2:[function(require,module,exports){
"use strict";
@@ -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 : {})
@@ -11143,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)
@@ -14339,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;
@@ -15750,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;
}

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.32";
export const version = "4.0.36";
}
declare module 'ethers/utils/bignumber' {

2
dist/shims.js vendored

File diff suppressed because one or more lines are too long

1969
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -1087,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)

View File

@@ -1 +1 @@
export const version = "4.0.32";
export const version = "4.0.36";

View File

@@ -1221,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);

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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],
});
}
});

View File

@@ -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}

View File

@@ -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);

View File

@@ -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.

View File

@@ -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;

View File

@@ -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;
}