Updated dist files.
This commit is contained in:
parent
811710c8f0
commit
eec9799706
62
dist/ethers-providers.js
vendored
62
dist/ethers-providers.js
vendored
@ -1175,10 +1175,12 @@ module.exports = InfuraProvider;
|
||||
var Provider = require('./provider.js');
|
||||
|
||||
var utils = (function() {
|
||||
var convert = require('ethers-utils/convert');
|
||||
return {
|
||||
defineProperty: require('ethers-utils/properties').defineProperty,
|
||||
|
||||
hexlify: require('ethers-utils/convert').hexlify,
|
||||
hexlify: convert.hexlify,
|
||||
isHexString: convert.isHexString,
|
||||
}
|
||||
})();
|
||||
|
||||
@ -1193,11 +1195,26 @@ function getResult(payload) {
|
||||
return payload.result;
|
||||
}
|
||||
|
||||
function stripHexZeros(value) {
|
||||
while (value.length > 3 && value.substring(0, 3) === '0x0') {
|
||||
value = '0x' + value.substring(3);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function getTransaction(transaction) {
|
||||
var result = {};
|
||||
|
||||
for (var key in transaction) {
|
||||
result[key] = utils.hexlify(transaction[key]);
|
||||
}
|
||||
|
||||
// Some nodes (INFURA ropsten; INFURA mainnet is fine) don't like extra zeros.
|
||||
['gasLimit', 'gasPrice', 'nonce', 'value'].forEach(function(key) {
|
||||
if (!result[key]) { return; }
|
||||
result[key] = stripHexZeros(result[key]);
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1231,23 +1248,35 @@ utils.defineProperty(JsonRpcProvider.prototype, 'perform', function(method, para
|
||||
return this.send('eth_gasPrice', []);
|
||||
|
||||
case 'getBalance':
|
||||
return this.send('eth_getBalance', [params.address, params.blockTag]);
|
||||
var blockTag = params.blockTag;
|
||||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); }
|
||||
return this.send('eth_getBalance', [params.address, blockTag]);
|
||||
|
||||
case 'getTransactionCount':
|
||||
return this.send('eth_getTransactionCount', [params.address, params.blockTag]);
|
||||
var blockTag = params.blockTag;
|
||||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); }
|
||||
return this.send('eth_getTransactionCount', [params.address, blockTag]);
|
||||
|
||||
case 'getCode':
|
||||
return this.send('eth_getCode', [params.address, params.blockTag]);
|
||||
var blockTag = params.blockTag;
|
||||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); }
|
||||
return this.send('eth_getCode', [params.address, blockTag]);
|
||||
|
||||
case 'getStorageAt':
|
||||
return this.send('eth_getStorageAt', [params.address, params.position, params.blockTag]);
|
||||
var position = params.position;
|
||||
if (utils.isHexString(position)) { position = stripHexZeros(position); }
|
||||
var blockTag = params.blockTag;
|
||||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); }
|
||||
return this.send('eth_getStorageAt', [params.address, position, blockTag]);
|
||||
|
||||
case 'sendTransaction':
|
||||
return this.send('eth_sendRawTransaction', [params.signedTransaction]);
|
||||
|
||||
case 'getBlock':
|
||||
if (params.blockTag) {
|
||||
return this.send('eth_getBlockByNumber', [params.blockTag, false]);
|
||||
var blockTag = params.blockTag;
|
||||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); }
|
||||
return this.send('eth_getBlockByNumber', [blockTag, false]);
|
||||
} else if (params.blockHash) {
|
||||
return this.send('eth_getBlockByHash', [params.blockHash, false]);
|
||||
}
|
||||
@ -5300,25 +5329,16 @@ function checkBlockTag(blockTag) {
|
||||
|
||||
if (blockTag === 'earliest') { return '0x0'; }
|
||||
|
||||
if (typeof(blockTag) === 'number') {
|
||||
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') {
|
||||
return blockTag;
|
||||
}
|
||||
|
||||
if (typeof(blockTag) === 'number') {
|
||||
return utils.hexlify(blockTag);
|
||||
}
|
||||
|
||||
if (utils.isHexString(blockTag)) { return blockTag; }
|
||||
|
||||
throw new Error('invalid blockTag');
|
||||
}
|
||||
|
||||
|
6
dist/ethers-providers.min.js
vendored
6
dist/ethers-providers.min.js
vendored
File diff suppressed because one or more lines are too long
6
dist/ethers-utils.js
vendored
6
dist/ethers-utils.js
vendored
@ -217,6 +217,10 @@ defineProperty(BigNumber.prototype, 'lte', function(other) {
|
||||
return this._bn.lte(bigNumberify(other)._bn);
|
||||
});
|
||||
|
||||
defineProperty(BigNumber.prototype, 'gt', function(other) {
|
||||
return this._bn.gt(bigNumberify(other)._bn);
|
||||
});
|
||||
|
||||
defineProperty(BigNumber.prototype, 'gte', function(other) {
|
||||
return this._bn.gte(bigNumberify(other)._bn);
|
||||
});
|
||||
@ -335,7 +339,7 @@ var defineProperty = require('./properties.js').defineProperty;
|
||||
var throwError = require('./throw-error');
|
||||
|
||||
function isArrayish(value) {
|
||||
if (!value || parseInt(value.length) != value.length) {
|
||||
if (!value || parseInt(value.length) != value.length || typeof(value) === 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
6
dist/ethers-utils.min.js
vendored
6
dist/ethers-utils.min.js
vendored
File diff suppressed because one or more lines are too long
91
dist/ethers-wallet.js
vendored
91
dist/ethers-wallet.js
vendored
@ -10278,6 +10278,8 @@ var aes = require('aes-js');
|
||||
var scrypt = require('scrypt-js');
|
||||
var uuid = require('uuid');
|
||||
|
||||
var hmac = require('ethers-utils/hmac');
|
||||
var pbkdf2 = require('ethers-utils/pbkdf2');
|
||||
var utils = require('ethers-utils');
|
||||
|
||||
var SigningKey = require('./signing-key.js');
|
||||
@ -10343,6 +10345,7 @@ utils.defineProperty(secretStorage, 'isValidWallet', function(json) {
|
||||
if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// @TODO: Put more checks to make sure it has kdf, iv and all that good stuff
|
||||
return true;
|
||||
});
|
||||
@ -10363,7 +10366,7 @@ utils.defineProperty(secretStorage, 'decryptCrowdsale', function(json, password)
|
||||
throw new Error('invalid encseed');
|
||||
}
|
||||
|
||||
var key = utils.pbkdf2(password, password, 2000, 32, utils.hmac.createSha256Hmac).slice(0, 16);
|
||||
var key = pbkdf2(password, password, 2000, 32, hmac.createSha256Hmac).slice(0, 16);
|
||||
|
||||
var iv = encseed.slice(0, 16);
|
||||
var encryptedSeed = encseed.slice(16);
|
||||
@ -10414,9 +10417,36 @@ utils.defineProperty(secretStorage, 'decrypt', function(json, password, progress
|
||||
return utils.keccak256(utils.concat([derivedHalf, ciphertext]));
|
||||
}
|
||||
|
||||
var getSigningKey = function(key, reject) {
|
||||
var ciphertext = arrayify(searchPath(data, 'crypto/ciphertext'));
|
||||
|
||||
var computedMAC = utils.hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2);
|
||||
if (computedMAC !== searchPath(data, 'crypto/mac').toLowerCase()) {
|
||||
reject(new Error('invalid password'));
|
||||
return null;
|
||||
}
|
||||
|
||||
var privateKey = decrypt(key.slice(0, 16), ciphertext);
|
||||
|
||||
if (!privateKey) {
|
||||
reject(new Error('unsupported cipher'));
|
||||
return null;
|
||||
}
|
||||
|
||||
var signingKey = new SigningKey(privateKey);
|
||||
if (signingKey.address !== utils.getAddress(data.address)) {
|
||||
reject(new Error('address mismatch'));
|
||||
return null;
|
||||
}
|
||||
|
||||
return signingKey;
|
||||
}
|
||||
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
var kdf = searchPath(data, 'crypto/kdf');
|
||||
if (kdf && typeof(kdf) === 'string' && kdf.toLowerCase() === 'scrypt') {
|
||||
if (kdf && typeof(kdf) === 'string') {
|
||||
if (kdf.toLowerCase() === 'scrypt') {
|
||||
var salt = arrayify(searchPath(data, 'crypto/kdfparams/salt'), 'crypto/kdfparams/salt');
|
||||
var N = parseInt(searchPath(data, 'crypto/kdfparams/n'));
|
||||
var r = parseInt(searchPath(data, 'crypto/kdfparams/r'));
|
||||
@ -10446,26 +10476,8 @@ utils.defineProperty(secretStorage, 'decrypt', function(json, password, progress
|
||||
} else if (key) {
|
||||
key = arrayify(key);
|
||||
|
||||
var ciphertext = arrayify(searchPath(data, 'crypto/ciphertext'));
|
||||
|
||||
var computedMAC = utils.hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2);
|
||||
if (computedMAC !== searchPath(data, 'crypto/mac').toLowerCase()) {
|
||||
reject(new Error('invalid password'));
|
||||
return;
|
||||
}
|
||||
|
||||
var privateKey = decrypt(key.slice(0, 16), ciphertext);
|
||||
|
||||
if (!privateKey) {
|
||||
reject(new Error('unsupported cipher'));
|
||||
return;
|
||||
}
|
||||
|
||||
var signingKey = new SigningKey(privateKey);
|
||||
if (signingKey.address !== utils.getAddress(data.address)) {
|
||||
reject(new Error('address mismatch'));
|
||||
return;
|
||||
}
|
||||
var signingKey = getSigningKey(key, reject);
|
||||
if (!signingKey) { return; }
|
||||
|
||||
if (progressCallback) { progressCallback(1); }
|
||||
resolve(signingKey);
|
||||
@ -10475,11 +10487,42 @@ utils.defineProperty(secretStorage, 'decrypt', function(json, password, progress
|
||||
}
|
||||
});
|
||||
|
||||
} else if (kdf.toLowerCase() === 'pbkdf2') {
|
||||
var salt = arrayify(searchPath(data, 'crypto/kdfparams/salt'), 'crypto/kdfparams/salt');
|
||||
|
||||
var prfFunc = null;
|
||||
var prf = searchPath(data, 'crypto/kdfparams/prf');
|
||||
if (prf === 'hmac-sha256') {
|
||||
prfFunc = hmac.createSha256Hmac;
|
||||
} else if (prf === 'hmac-sha512') {
|
||||
prfFunc = hmac.createSha512Hmac;
|
||||
} else {
|
||||
reject(new Error('unsupported prf'));
|
||||
return;
|
||||
}
|
||||
|
||||
var c = parseInt(searchPath(data, 'crypto/kdfparams/c'));
|
||||
|
||||
var dkLen = parseInt(searchPath(data, 'crypto/kdfparams/dklen'));
|
||||
if (dkLen !== 32) {
|
||||
reject( new Error('unsupported key-derivation derived-key length'));
|
||||
return;
|
||||
}
|
||||
|
||||
var key = pbkdf2(password, salt, c, dkLen, prfFunc);
|
||||
|
||||
var signingKey = getSigningKey(key, reject);
|
||||
if (!signingKey) { return; }
|
||||
|
||||
resolve(signingKey);
|
||||
|
||||
} else {
|
||||
// @TOOD: Support pbkdf2 kdf
|
||||
reject(new Error('unsupported key-derivation function'));
|
||||
}
|
||||
|
||||
} else {
|
||||
reject(new Error('unsupported key-derivation function'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -10601,7 +10644,7 @@ utils.defineProperty(secretStorage, 'encrypt', function(privateKey, password, op
|
||||
|
||||
module.exports = secretStorage;
|
||||
|
||||
},{"./signing-key.js":51,"aes-js":4,"ethers-utils":28,"scrypt-js":46,"uuid":49}],51:[function(require,module,exports){
|
||||
},{"./signing-key.js":51,"aes-js":4,"ethers-utils":28,"ethers-utils/hmac":27,"ethers-utils/pbkdf2":30,"scrypt-js":46,"uuid":49}],51:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
|
4
dist/ethers-wallet.min.js
vendored
4
dist/ethers-wallet.min.js
vendored
File diff suppressed because one or more lines are too long
9212
dist/ethers.js
vendored
9212
dist/ethers.js
vendored
File diff suppressed because one or more lines are too long
12
dist/ethers.min.js
vendored
12
dist/ethers.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user