Merge branch 'master' of github.com:ethers-io/ethers.js

This commit is contained in:
Richard Moore 2017-11-12 16:02:17 -05:00
commit ef71271db6
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295
12 changed files with 3595 additions and 2674 deletions

@ -12,6 +12,7 @@ ellipticPackage = JSON.stringify({ version: ellipticPackage.version });
var npmVersion = require('./node_modules/ethers-' + name + '/package.json').version; var npmVersion = require('./node_modules/ethers-' + name + '/package.json').version;
var liveVersion = require('./' + name + '/package.json').version; var liveVersion = require('./' + name + '/package.json').version;
if (npmVersion !== liveVersion) { if (npmVersion !== liveVersion) {
console.log(name, ('npm=' + npmVersion), ('live=' + liveVersion));
throw new Error('version mismatch for ' + name + ' - redo npm install'); throw new Error('version mismatch for ' + name + ' - redo npm install');
} }

@ -29,15 +29,16 @@ function Contract(addressOrName, contractInterface, signerOrProvider) {
contractInterface = new Interface(contractInterface); contractInterface = new Interface(contractInterface);
} }
if (!signerOrProvider) { throw new Error('missing signer or provider'); }
var signer = signerOrProvider; var signer = signerOrProvider;
var provider = null; var provider = null;
if (signerOrProvider.provider) { if (signerOrProvider.provider) {
provider = signerOrProvider.provider; provider = signerOrProvider.provider;
} else if (signerOrProvider) { } else {
provider = signerOrProvider; provider = signerOrProvider;
signer = null; signer = null;
} else {
throw new Error('missing provider');
} }
utils.defineProperty(this, 'address', addressOrName); utils.defineProperty(this, 'address', addressOrName);
@ -256,6 +257,10 @@ function Contract(addressOrName, contractInterface, signerOrProvider) {
}, this); }, this);
} }
utils.defineProperty(Contract.prototype, 'connect', function(signerOrProvider) {
return new Contract(this.address, this.interface, signerOrProvider);
});
utils.defineProperty(Contract, 'getDeployTransaction', function(bytecode, contractInterface) { utils.defineProperty(Contract, 'getDeployTransaction', function(bytecode, contractInterface) {
if (!(contractInterface instanceof Interface)) { if (!(contractInterface instanceof Interface)) {
@ -272,7 +277,7 @@ utils.defineProperty(Contract, 'getDeployTransaction', function(bytecode, contra
module.exports = Contract; module.exports = Contract;
},{"./interface.js":3,"ethers-utils/address.js":5,"ethers-utils/bignumber.js":6,"ethers-utils/convert.js":7,"ethers-utils/properties.js":9}],2:[function(require,module,exports){ },{"./interface.js":3,"ethers-utils/address.js":6,"ethers-utils/bignumber.js":7,"ethers-utils/convert.js":8,"ethers-utils/properties.js":10}],2:[function(require,module,exports){
'use strict'; 'use strict';
var Contract = require('./contract.js'); var Contract = require('./contract.js');
@ -286,7 +291,7 @@ module.exports = {
require('ethers-utils/standalone.js')(module.exports); require('ethers-utils/standalone.js')(module.exports);
},{"./contract.js":1,"./interface.js":3,"ethers-utils/standalone.js":10}],3:[function(require,module,exports){ },{"./contract.js":1,"./interface.js":3,"ethers-utils/standalone.js":11}],3:[function(require,module,exports){
'use strict'; 'use strict';
// See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI // See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI
@ -347,8 +352,27 @@ function getKeys(params, key, allowEmpty) {
return result; return result;
} }
function coderNumber(size, signed) { var coderNull = {
name: 'null',
type: '',
encode: function(value) {
return utils.arrayify([]);
},
decode: function(data, offset) {
if (offset > data.length) { throw new Error('invalid null'); }
return { return {
consumed: 0,
value: undefined
}
},
dynamic: false
};
function coderNumber(size, signed) {
var name = ((signed ? 'int': 'uint') + size);
return {
name: name,
type: name,
encode: function(value) { encode: function(value) {
value = utils.bigNumberify(value).toTwos(size * 8).maskn(size * 8); value = utils.bigNumberify(value).toTwos(size * 8).maskn(size * 8);
//value = value.toTwos(size * 8).maskn(size * 8); //value = value.toTwos(size * 8).maskn(size * 8);
@ -378,6 +402,8 @@ function coderNumber(size, signed) {
var uint256Coder = coderNumber(32, false); var uint256Coder = coderNumber(32, false);
var coderBoolean = { var coderBoolean = {
name: 'boolean',
type: 'boolean',
encode: function(value) { encode: function(value) {
return uint256Coder.encode(value ? 1: 0); return uint256Coder.encode(value ? 1: 0);
}, },
@ -391,7 +417,10 @@ var coderBoolean = {
} }
function coderFixedBytes(length) { function coderFixedBytes(length) {
var name = ('bytes' + length);
return { return {
name: name,
type: name,
encode: function(value) { encode: function(value) {
value = utils.arrayify(value); value = utils.arrayify(value);
if (length === 32) { return value; } if (length === 32) { return value; }
@ -412,6 +441,8 @@ function coderFixedBytes(length) {
} }
var coderAddress = { var coderAddress = {
name: 'address',
type: 'address',
encode: function(value) { encode: function(value) {
value = utils.arrayify(utils.getAddress(value)); value = utils.arrayify(utils.getAddress(value));
var result = new Uint8Array(32); var result = new Uint8Array(32);
@ -452,6 +483,8 @@ function _decodeDynamicBytes(data, offset) {
} }
var coderDynamicBytes = { var coderDynamicBytes = {
name: 'bytes',
type: 'bytes',
encode: function(value) { encode: function(value) {
return _encodeDynamicBytes(utils.arrayify(value)); return _encodeDynamicBytes(utils.arrayify(value));
}, },
@ -464,6 +497,8 @@ var coderDynamicBytes = {
}; };
var coderString = { var coderString = {
name: 'string',
type: 'string',
encode: function(value) { encode: function(value) {
return _encodeDynamicBytes(utils.toUtf8Bytes(value)); return _encodeDynamicBytes(utils.toUtf8Bytes(value));
}, },
@ -475,24 +510,106 @@ var coderString = {
dynamic: true dynamic: true
}; };
function coderArray(coder, length) { function alignSize(size) {
return parseInt(32 * Math.ceil(size / 32));
}
function pack(coders, values) {
var parts = [];
coders.forEach(function(coder, index) {
parts.push({ dynamic: coder.dynamic, value: coder.encode(values[index]) });
})
var staticSize = 0, dynamicSize = 0;
parts.forEach(function(part, index) {
if (part.dynamic) {
staticSize += 32;
dynamicSize += alignSize(part.value.length);
} else {
staticSize += alignSize(part.value.length);
}
});
var offset = 0, dynamicOffset = staticSize;
var data = new Uint8Array(staticSize + dynamicSize);
parts.forEach(function(part, index) {
if (part.dynamic) {
//uint256Coder.encode(dynamicOffset).copy(data, offset);
data.set(uint256Coder.encode(dynamicOffset), offset);
offset += 32;
//part.value.copy(data, dynamicOffset); @TODO
data.set(part.value, dynamicOffset);
dynamicOffset += alignSize(part.value.length);
} else {
//part.value.copy(data, offset); @TODO
data.set(part.value, offset);
offset += alignSize(part.value.length);
}
});
return data;
}
function unpack(coders, data, offset) {
var baseOffset = offset;
var consumed = 0;
var value = [];
coders.forEach(function(coder) {
if (coder.dynamic) {
var dynamicOffset = uint256Coder.decode(data, offset);
var result = coder.decode(data, baseOffset + dynamicOffset.value.toNumber());
// The dynamic part is leap-frogged somewhere else; doesn't count towards size
result.consumed = dynamicOffset.consumed;
} else {
var result = coder.decode(data, offset);
}
if (result.value != undefined) {
value.push(result.value);
}
offset += result.consumed;
consumed += result.consumed;
});
return { return {
value: value,
consumed: consumed
}
return result;
}
function coderArray(coder, length) {
var type = (coder.type + '[' + (length >= 0 ? length: '') + ']');
return {
coder: coder,
length: length,
name: 'array',
type: type,
encode: function(value) { encode: function(value) {
if (!Array.isArray(value)) { throwError('invalid array'); } if (!Array.isArray(value)) { throwError('invalid array'); }
var count = length;
var result = new Uint8Array(0); var result = new Uint8Array(0);
if (length === -1) { if (count === -1) {
length = value.length; count = value.length;
result = uint256Coder.encode(length); result = uint256Coder.encode(count);
} }
if (length !== value.length) { throwError('size mismatch'); } if (count !== value.length) { throwError('size mismatch'); }
value.forEach(function(value) { var coders = [];
result = utils.concat([result, coder.encode(value)]); value.forEach(function(value) { coders.push(coder); });
});
return result; return utils.concat([result, pack(coders, value)]);
}, },
decode: function(data, offset) { decode: function(data, offset) {
// @TODO: // @TODO:
@ -500,98 +617,142 @@ function coderArray(coder, length) {
var consumed = 0; var consumed = 0;
var result; var count = length;
if (length === -1) {
result = uint256Coder.decode(data, offset); if (count === -1) {
length = result.value.toNumber(); var decodedLength = uint256Coder.decode(data, offset);
consumed += result.consumed; count = decodedLength.value.toNumber();
offset += result.consumed; consumed += decodedLength.consumed;
offset += decodedLength.consumed;
} }
var value = []; var coders = [];
for (var i = 0; i < count; i++) { coders.push(coder); }
for (var i = 0; i < length; i++) { var result = unpack(coders, data, offset);
var result = coder.decode(data, offset); result.consumed += consumed;
consumed += result.consumed; return result;
offset += result.consumed; },
value.push(result.value); dynamic: (length === -1 || coder.dynamic)
} }
}
function coderTuple(coders) {
var dynamic = false;
var types = [];
coders.forEach(function(coder) {
if (coder.dynamic) { dynamic = true; }
types.push(coder.type);
});
var type = ('tuple(' + types.join(',') + ')');
return { return {
consumed: consumed, coders: coders,
value: value, name: 'tuple',
type: type,
encode: function(value) {
if (coders.length !== coders.length) {
throwError('types/values mismatch', { type: type, values: values });
} }
return pack(coders, value);
}, },
dynamic: (length === -1) decode: function(data, offset) {
} return unpack(coders, data, offset);
},
dynamic: dynamic
};
} }
// Break the type up into [staticType][staticArray]*[dynamicArray]? | [dynamicType] and function getTypes(coders) {
// build the coder up from its parts var type = coderTuple(coders).type;
var paramTypePart = new RegExp(/^((u?int|bytes)([0-9]*)|(address|bool|string)|(\[([0-9]*)\]))/); return type.substring(6, type.length - 1);
}
function splitNesting(value) {
var result = [];
var accum = '';
var depth = 0;
for (var offset = 0; offset < value.length; offset++) {
var c = value[offset];
if (c === ',' && depth === 0) {
result.push(accum);
accum = '';
} else {
accum += c;
if (c === '(') {
depth++;
} else if (c === ')') {
depth--;
if (depth === -1) {
throw new Error('unbalanced parenthsis');
}
}
}
}
result.push(accum);
return result;
}
var paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
var paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
var paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/);
var paramTypeSimple = {
address: coderAddress,
bool: coderBoolean,
string: coderString,
bytes: coderDynamicBytes,
};
function getParamCoder(type) { function getParamCoder(type) {
var coder = null;
while (type) {
var part = type.match(paramTypePart);
if (!part) { throwError('invalid type', { type: type }); }
type = type.substring(part[0].length);
var prefix = (part[2] || part[4] || part[5]); var coder = paramTypeSimple[type];
switch (prefix) { if (coder) { return coder; }
case 'int': case 'uint':
if (coder) { throwError('invalid type', { type: type }); } var match = type.match(paramTypeNumber);
var size = parseInt(part[3] || 256); if (match) {
var size = parseInt(match[2] || 256);
if (size === 0 || size > 256 || (size % 8) !== 0) { if (size === 0 || size > 256 || (size % 8) !== 0) {
throwError('invalid type', { type: type }); throwError('invalid type', { type: type });
} }
coder = coderNumber(size / 8, (prefix === 'int')); return coderNumber(size / 8, (match[1] === 'int'));
break; }
case 'bool': var match = type.match(paramTypeBytes);
if (coder) { throwError('invalid type', { type: type }); } if (match) {
coder = coderBoolean; var size = parseInt(match[1]);
break;
case 'string':
if (coder) { throwError('invalid type', { type: type }); }
coder = coderString;
break;
case 'bytes':
if (coder) { throwError('invalid type', { type: type }); }
if (part[3]) {
var size = parseInt(part[3]);
if (size === 0 || size > 32) { if (size === 0 || size > 32) {
throwError('invalid type ' + type); throwError('invalid type ' + type);
} }
coder = coderFixedBytes(size); return coderFixedBytes(size);
} else {
coder = coderDynamicBytes;
}
break;
case 'address':
if (coder) { throwError('invalid type', { type: type }); }
coder = coderAddress;
break;
case '[]':
if (!coder || coder.dynamic) { throwError('invalid type', { type: type }); }
coder = coderArray(coder, -1);
break;
// "[0-9+]"
default:
if (!coder || coder.dynamic) { throwError('invalid type', { type: type }); }
var size = parseInt(part[6]);
coder = coderArray(coder, size);
}
} }
if (!coder) { throwError('invalid type'); } var match = type.match(paramTypeArray);
return coder; if (match) {
var size = parseInt(match[2] || -1);
return coderArray(getParamCoder(match[1]), size);
} }
if (type.substring(0, 6) === 'tuple(' && type.substring(type.length - 1) === ')') {
var coders = [];
splitNesting(type.substring(6, type.length - 1)).forEach(function(type) {
coders.push(getParamCoder(type));
});
return coderTuple(coders);
}
if (type === '') {
return coderNull;
}
throwError('invalid type', { type: type });
}
function populateDescription(object, items) { function populateDescription(object, items) {
for (var key in items) { for (var key in items) {
utils.defineProperty(object, key, items[key]); utils.defineProperty(object, key, items[key]);
@ -672,11 +833,13 @@ function Interface(abi) {
var outputNames = getKeys(method.outputs, 'name', true); var outputNames = getKeys(method.outputs, 'name', true);
} }
var func = function() {
var signature = method.name + '(' + getKeys(method.inputs, 'type').join(',') + ')'; var signature = method.name + '(' + getKeys(method.inputs, 'type').join(',') + ')';
var sighash = utils.keccak256(utils.toUtf8Bytes(signature)).substring(0, 10);
var func = function() {
var result = { var result = {
name: method.name, name: method.name,
signature: signature, signature: signature,
sighash: sighash
}; };
var params = Array.prototype.slice.call(arguments, 0); var params = Array.prototype.slice.call(arguments, 0);
@ -687,9 +850,7 @@ function Interface(abi) {
throwError('too many parameters'); throwError('too many parameters');
} }
signature = utils.keccak256(utils.toUtf8Bytes(signature)).substring(0, 10); result.data = sighash + Interface.encodeParams(inputTypes, params).substring(2);
result.data = signature + Interface.encodeParams(inputTypes, params).substring(2);
if (method.constant) { if (method.constant) {
result.parse = function(data) { result.parse = function(data) {
return Interface.decodeParams( return Interface.decodeParams(
@ -706,6 +867,8 @@ function Interface(abi) {
defineFrozen(func, 'inputs', getKeys(method.inputs, 'name')); defineFrozen(func, 'inputs', getKeys(method.inputs, 'name'));
defineFrozen(func, 'outputs', getKeys(method.outputs, 'name')); defineFrozen(func, 'outputs', getKeys(method.outputs, 'name'));
utils.defineProperty(func, 'signature', signature);
utils.defineProperty(func, 'sighash', sighash);
return func; return func;
})(); })();
@ -776,7 +939,9 @@ function Interface(abi) {
}; };
return populateDescription(new EventDescription(), result); return populateDescription(new EventDescription(), result);
} }
defineFrozen(func, 'inputs', getKeys(method.inputs, 'name')); defineFrozen(func, 'inputs', getKeys(method.inputs, 'name'));
return func; return func;
})(); })();
@ -810,46 +975,12 @@ function Interface(abi) {
utils.defineProperty(Interface, 'encodeParams', function(types, values) { utils.defineProperty(Interface, 'encodeParams', function(types, values) {
if (types.length !== values.length) { throwError('types/values mismatch', {types: types, values: values}); } if (types.length !== values.length) { throwError('types/values mismatch', {types: types, values: values}); }
var parts = []; var coders = [];
types.forEach(function(type) {
types.forEach(function(type, index) { coders.push(getParamCoder(type));
var coder = getParamCoder(type);
parts.push({dynamic: coder.dynamic, value: coder.encode(values[index])});
})
function alignSize(size) {
return parseInt(32 * Math.ceil(size / 32));
}
var staticSize = 0, dynamicSize = 0;
parts.forEach(function(part) {
if (part.dynamic) {
staticSize += 32;
dynamicSize += alignSize(part.value.length);
} else {
staticSize += alignSize(part.value.length);
}
}); });
var offset = 0, dynamicOffset = staticSize; return utils.hexlify(coderTuple(coders).encode(values));
var data = new Uint8Array(staticSize + dynamicSize);
parts.forEach(function(part, index) {
if (part.dynamic) {
//uint256Coder.encode(dynamicOffset).copy(data, offset);
data.set(uint256Coder.encode(dynamicOffset), offset);
offset += 32;
//part.value.copy(data, dynamicOffset); @TODO
data.set(part.value, dynamicOffset);
dynamicOffset += alignSize(part.value.length);
} else {
//part.value.copy(data, offset); @TODO
data.set(part.value, offset);
offset += alignSize(part.value.length);
}
});
return utils.hexlify(data);
}); });
@ -865,52 +996,40 @@ utils.defineProperty(Interface, 'decodeParams', function(names, types, data) {
} }
data = utils.arrayify(data); data = utils.arrayify(data);
var coders = [];
types.forEach(function(type) {
coders.push(getParamCoder(type));
});
var result = coderTuple(coders).decode(data, 0);
// @TODO: Move this into coderTuple
var values = new Result(); var values = new Result();
coders.forEach(function(coder, index) {
var offset = 0; values[index] = result.value[index];
types.forEach(function(type, index) { if (names && names[index]) {
var coder = getParamCoder(type);
if (coder.dynamic) {
var dynamicOffset = uint256Coder.decode(data, offset);
var result = coder.decode(data, dynamicOffset.value.toNumber());
offset += dynamicOffset.consumed;
} else {
var result = coder.decode(data, offset);
offset += result.consumed;
}
// Add indexed parameter
values[index] = result.value;
// Add named parameters
if (names[index]) {
var name = names[index]; var name = names[index];
// We reserve length to make the Result object arrayish
if (name === 'length') { if (name === 'length') {
console.log('WARNING: result length renamed to _length'); console.log('WARNING: result length renamed to _length');
name = '_length'; name = '_length';
} }
if (values[name] == null) { if (values[name] == null) {
values[name] = result.value; values[name] = values[index];
} else { } else {
console.log('WARNING: duplicate value - ' + name); console.log('WARNING: duplicate value - ' + name);
} }
} }
}); })
values.length = types.length; values.length = types.length;
return values; return values;
}); });
//utils.defineProperty(Interface, 'getDeployTransaction', function(bytecode) {
//});
module.exports = Interface; module.exports = Interface;
},{"ethers-utils/address":5,"ethers-utils/bignumber.js":6,"ethers-utils/convert.js":7,"ethers-utils/keccak256.js":8,"ethers-utils/properties.js":9,"ethers-utils/throw-error":11,"ethers-utils/utf8.js":12}],4:[function(require,module,exports){ },{"ethers-utils/address":6,"ethers-utils/bignumber.js":7,"ethers-utils/convert.js":8,"ethers-utils/keccak256.js":9,"ethers-utils/properties.js":10,"ethers-utils/throw-error":12,"ethers-utils/utf8.js":13}],4:[function(require,module,exports){
(function (module, exports) { (function (module, exports) {
'use strict'; 'use strict';
@ -963,7 +1082,7 @@ module.exports = Interface;
var Buffer; var Buffer;
try { try {
Buffer = require('buf' + 'fer').Buffer; Buffer = require('buffer').Buffer;
} catch (e) { } catch (e) {
} }
@ -4200,7 +4319,7 @@ module.exports = Interface;
}; };
Red.prototype.pow = function pow (a, num) { Red.prototype.pow = function pow (a, num) {
if (num.isZero()) return new BN(1); if (num.isZero()) return new BN(1).toRed(this);
if (num.cmpn(1) === 0) return a.clone(); if (num.cmpn(1) === 0) return a.clone();
var windowSize = 4; var windowSize = 4;
@ -4339,7 +4458,9 @@ module.exports = Interface;
}; };
})(typeof module === 'undefined' || module, this); })(typeof module === 'undefined' || module, this);
},{}],5:[function(require,module,exports){ },{"buffer":5}],5:[function(require,module,exports){
},{}],6:[function(require,module,exports){
var BN = require('bn.js'); var BN = require('bn.js');
@ -4373,6 +4494,15 @@ function getChecksumAddress(address) {
return '0x' + address.join(''); return '0x' + address.join('');
} }
// Shims for environments that are missing some required constants and functions
var MAX_SAFE_INTEGER = 0x1fffffffffffff;
function log10(x) {
if (Math.log10) { return Math.log10(x); }
return Math.log(x) / Math.LN10;
}
// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number // See: https://en.wikipedia.org/wiki/International_Bank_Account_Number
var ibanChecksum = (function() { var ibanChecksum = (function() {
@ -4382,7 +4512,7 @@ var ibanChecksum = (function() {
for (var i = 0; i < 26; i++) { ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); } for (var i = 0; i < 26; i++) { ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); }
// How many decimal digits can we process? (for 64-bit float, this is 15) // How many decimal digits can we process? (for 64-bit float, this is 15)
var safeDigits = Math.floor(Math.log10(Number.MAX_SAFE_INTEGER)); var safeDigits = Math.floor(log10(MAX_SAFE_INTEGER));
return function(address) { return function(address) {
address = address.toUpperCase(); address = address.toUpperCase();
@ -4456,7 +4586,7 @@ module.exports = {
getAddress: getAddress, getAddress: getAddress,
} }
},{"./convert":7,"./keccak256":8,"./throw-error":11,"bn.js":4}],6:[function(require,module,exports){ },{"./convert":8,"./keccak256":9,"./throw-error":12,"bn.js":4}],7:[function(require,module,exports){
/** /**
* BigNumber * BigNumber
* *
@ -4537,6 +4667,10 @@ defineProperty(BigNumber.prototype, 'mod', function(other) {
return new BigNumber(this._bn.mod(bigNumberify(other)._bn)); return new BigNumber(this._bn.mod(bigNumberify(other)._bn));
}); });
defineProperty(BigNumber.prototype, 'pow', function(other) {
return new BigNumber(this._bn.pow(bigNumberify(other)._bn));
});
defineProperty(BigNumber.prototype, 'maskn', function(value) { defineProperty(BigNumber.prototype, 'maskn', function(value) {
return new BigNumber(this._bn.maskn(value)); return new BigNumber(this._bn.maskn(value));
@ -4556,6 +4690,10 @@ defineProperty(BigNumber.prototype, 'lte', function(other) {
return this._bn.lte(bigNumberify(other)._bn); 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) { defineProperty(BigNumber.prototype, 'gte', function(other) {
return this._bn.gte(bigNumberify(other)._bn); return this._bn.gte(bigNumberify(other)._bn);
}); });
@ -4596,7 +4734,7 @@ module.exports = {
bigNumberify: bigNumberify bigNumberify: bigNumberify
}; };
},{"./convert":7,"./properties":9,"./throw-error":11,"bn.js":4}],7:[function(require,module,exports){ },{"./convert":8,"./properties":10,"./throw-error":12,"bn.js":4}],8:[function(require,module,exports){
/** /**
* Conversion Utilities * Conversion Utilities
* *
@ -4605,8 +4743,19 @@ module.exports = {
var defineProperty = require('./properties.js').defineProperty; var defineProperty = require('./properties.js').defineProperty;
var throwError = require('./throw-error'); var throwError = require('./throw-error');
function addSlice(array) {
if (array.slice) { return array; }
array.slice = function() {
var args = Array.prototype.slice.call(arguments);
return new Uint8Array(Array.prototype.slice.apply(array, args));
}
return array;
}
function isArrayish(value) { function isArrayish(value) {
if (!value || parseInt(value.length) != value.length) { if (!value || parseInt(value.length) != value.length || typeof(value) === 'string') {
return false; return false;
} }
@ -4635,11 +4784,11 @@ function arrayify(value, name) {
result.push(parseInt(value.substr(i, 2), 16)); result.push(parseInt(value.substr(i, 2), 16));
} }
return new Uint8Array(result); return addSlice(new Uint8Array(result));
} }
if (isArrayish(value)) { if (isArrayish(value)) {
return new Uint8Array(value); return addSlice(new Uint8Array(value));
} }
throwError('invalid arrayify value', { name: name, input: value }); throwError('invalid arrayify value', { name: name, input: value });
@ -4661,7 +4810,7 @@ function concat(objects) {
offset += arrays[i].length; offset += arrays[i].length;
} }
return result; return addSlice(result);
} }
function stripZeros(value) { function stripZeros(value) {
value = arrayify(value); value = arrayify(value);
@ -4687,7 +4836,7 @@ function padZeros(value, length) {
var result = new Uint8Array(length); var result = new Uint8Array(length);
result.set(value, length - value.length); result.set(value, length - value.length);
return result; return addSlice(result);
} }
@ -4759,7 +4908,7 @@ module.exports = {
isHexString: isHexString, isHexString: isHexString,
}; };
},{"./properties.js":9,"./throw-error":11}],8:[function(require,module,exports){ },{"./properties.js":10,"./throw-error":12}],9:[function(require,module,exports){
'use strict'; 'use strict';
var sha3 = require('js-sha3'); var sha3 = require('js-sha3');
@ -4773,7 +4922,7 @@ function keccak256(data) {
module.exports = keccak256; module.exports = keccak256;
},{"./convert.js":7,"js-sha3":13}],9:[function(require,module,exports){ },{"./convert.js":8,"js-sha3":14}],10:[function(require,module,exports){
function defineProperty(object, name, value) { function defineProperty(object, name, value) {
Object.defineProperty(object, name, { Object.defineProperty(object, name, {
enumerable: true, enumerable: true,
@ -4786,7 +4935,7 @@ module.exports = {
defineProperty: defineProperty, defineProperty: defineProperty,
}; };
},{}],10:[function(require,module,exports){ },{}],11:[function(require,module,exports){
(function (global){ (function (global){
var defineProperty = require('./properties.js').defineProperty; var defineProperty = require('./properties.js').defineProperty;
@ -4813,7 +4962,7 @@ function defineEthersValues(values) {
module.exports = defineEthersValues; module.exports = defineEthersValues;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./properties.js":9}],11:[function(require,module,exports){ },{"./properties.js":10}],12:[function(require,module,exports){
'use strict'; 'use strict';
function throwError(message, params) { function throwError(message, params) {
@ -4826,7 +4975,7 @@ function throwError(message, params) {
module.exports = throwError; module.exports = throwError;
},{}],12:[function(require,module,exports){ },{}],13:[function(require,module,exports){
var convert = require('./convert.js'); var convert = require('./convert.js');
@ -4941,7 +5090,7 @@ module.exports = {
toUtf8String: bytesToUtf8, toUtf8String: bytesToUtf8,
}; };
},{"./convert.js":7}],13:[function(require,module,exports){ },{"./convert.js":8}],14:[function(require,module,exports){
(function (process,global){ (function (process,global){
/** /**
* [js-sha3]{@link https://github.com/emn178/js-sha3} * [js-sha3]{@link https://github.com/emn178/js-sha3}
@ -5420,6 +5569,6 @@ module.exports = {
})(); })();
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"_process":14}],14:[function(require,module,exports){ },{"_process":15}],15:[function(require,module,exports){
module.exports = undefined; module.exports = undefined;
},{}]},{},[2]); },{}]},{},[2]);

File diff suppressed because one or more lines are too long

1235
dist/ethers-providers.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

1982
dist/ethers-utils.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

1475
dist/ethers-wallet.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

871
dist/ethers.js vendored

File diff suppressed because one or more lines are too long

12
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

@ -10,10 +10,10 @@
"version": "grunt dist" "version": "grunt dist"
}, },
"dependencies": { "dependencies": {
"ethers-contracts": "^2.1.0", "ethers-contracts": "^2.1.5",
"ethers-providers": "^2.1.0", "ethers-providers": "^2.1.8",
"ethers-utils": "^2.1.0", "ethers-utils": "^2.1.6",
"ethers-wallet": "^2.1.0" "ethers-wallet": "^2.1.4"
}, },
"devDependencies": { "devDependencies": {
"grunt": "^0.4.5", "grunt": "^0.4.5",