Merge branch 'master' of github.com:ethers-io/ethers.js
This commit is contained in:
commit
ef71271db6
@ -12,6 +12,7 @@ ellipticPackage = JSON.stringify({ version: ellipticPackage.version });
|
||||
var npmVersion = require('./node_modules/ethers-' + name + '/package.json').version;
|
||||
var liveVersion = require('./' + name + '/package.json').version;
|
||||
if (npmVersion !== liveVersion) {
|
||||
console.log(name, ('npm=' + npmVersion), ('live=' + liveVersion));
|
||||
throw new Error('version mismatch for ' + name + ' - redo npm install');
|
||||
}
|
||||
|
||||
|
507
dist/ethers-contracts.js
vendored
507
dist/ethers-contracts.js
vendored
@ -29,15 +29,16 @@ function Contract(addressOrName, contractInterface, signerOrProvider) {
|
||||
contractInterface = new Interface(contractInterface);
|
||||
}
|
||||
|
||||
if (!signerOrProvider) { throw new Error('missing signer or provider'); }
|
||||
|
||||
var signer = signerOrProvider;
|
||||
var provider = null;
|
||||
|
||||
if (signerOrProvider.provider) {
|
||||
provider = signerOrProvider.provider;
|
||||
} else if (signerOrProvider) {
|
||||
} else {
|
||||
provider = signerOrProvider;
|
||||
signer = null;
|
||||
} else {
|
||||
throw new Error('missing provider');
|
||||
}
|
||||
|
||||
utils.defineProperty(this, 'address', addressOrName);
|
||||
@ -256,6 +257,10 @@ function Contract(addressOrName, contractInterface, signerOrProvider) {
|
||||
}, this);
|
||||
}
|
||||
|
||||
utils.defineProperty(Contract.prototype, 'connect', function(signerOrProvider) {
|
||||
return new Contract(this.address, this.interface, signerOrProvider);
|
||||
});
|
||||
|
||||
utils.defineProperty(Contract, 'getDeployTransaction', function(bytecode, contractInterface) {
|
||||
|
||||
if (!(contractInterface instanceof Interface)) {
|
||||
@ -272,7 +277,7 @@ utils.defineProperty(Contract, 'getDeployTransaction', function(bytecode, contra
|
||||
|
||||
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';
|
||||
|
||||
var Contract = require('./contract.js');
|
||||
@ -286,7 +291,7 @@ 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';
|
||||
|
||||
// See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI
|
||||
@ -347,8 +352,27 @@ function getKeys(params, key, allowEmpty) {
|
||||
return result;
|
||||
}
|
||||
|
||||
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 {
|
||||
consumed: 0,
|
||||
value: undefined
|
||||
}
|
||||
},
|
||||
dynamic: false
|
||||
};
|
||||
|
||||
function coderNumber(size, signed) {
|
||||
var name = ((signed ? 'int': 'uint') + size);
|
||||
return {
|
||||
name: name,
|
||||
type: name,
|
||||
encode: function(value) {
|
||||
value = utils.bigNumberify(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 coderBoolean = {
|
||||
name: 'boolean',
|
||||
type: 'boolean',
|
||||
encode: function(value) {
|
||||
return uint256Coder.encode(value ? 1: 0);
|
||||
},
|
||||
@ -391,7 +417,10 @@ var coderBoolean = {
|
||||
}
|
||||
|
||||
function coderFixedBytes(length) {
|
||||
var name = ('bytes' + length);
|
||||
return {
|
||||
name: name,
|
||||
type: name,
|
||||
encode: function(value) {
|
||||
value = utils.arrayify(value);
|
||||
if (length === 32) { return value; }
|
||||
@ -412,6 +441,8 @@ function coderFixedBytes(length) {
|
||||
}
|
||||
|
||||
var coderAddress = {
|
||||
name: 'address',
|
||||
type: 'address',
|
||||
encode: function(value) {
|
||||
value = utils.arrayify(utils.getAddress(value));
|
||||
var result = new Uint8Array(32);
|
||||
@ -452,6 +483,8 @@ function _decodeDynamicBytes(data, offset) {
|
||||
}
|
||||
|
||||
var coderDynamicBytes = {
|
||||
name: 'bytes',
|
||||
type: 'bytes',
|
||||
encode: function(value) {
|
||||
return _encodeDynamicBytes(utils.arrayify(value));
|
||||
},
|
||||
@ -464,6 +497,8 @@ var coderDynamicBytes = {
|
||||
};
|
||||
|
||||
var coderString = {
|
||||
name: 'string',
|
||||
type: 'string',
|
||||
encode: function(value) {
|
||||
return _encodeDynamicBytes(utils.toUtf8Bytes(value));
|
||||
},
|
||||
@ -475,24 +510,106 @@ var coderString = {
|
||||
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 {
|
||||
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) {
|
||||
if (!Array.isArray(value)) { throwError('invalid array'); }
|
||||
|
||||
var count = length;
|
||||
|
||||
var result = new Uint8Array(0);
|
||||
if (length === -1) {
|
||||
length = value.length;
|
||||
result = uint256Coder.encode(length);
|
||||
if (count === -1) {
|
||||
count = value.length;
|
||||
result = uint256Coder.encode(count);
|
||||
}
|
||||
|
||||
if (length !== value.length) { throwError('size mismatch'); }
|
||||
if (count !== value.length) { throwError('size mismatch'); }
|
||||
|
||||
value.forEach(function(value) {
|
||||
result = utils.concat([result, coder.encode(value)]);
|
||||
});
|
||||
var coders = [];
|
||||
value.forEach(function(value) { coders.push(coder); });
|
||||
|
||||
return result;
|
||||
return utils.concat([result, pack(coders, value)]);
|
||||
},
|
||||
decode: function(data, offset) {
|
||||
// @TODO:
|
||||
@ -500,98 +617,142 @@ function coderArray(coder, length) {
|
||||
|
||||
var consumed = 0;
|
||||
|
||||
var result;
|
||||
if (length === -1) {
|
||||
result = uint256Coder.decode(data, offset);
|
||||
length = result.value.toNumber();
|
||||
consumed += result.consumed;
|
||||
offset += result.consumed;
|
||||
var count = length;
|
||||
|
||||
if (count === -1) {
|
||||
var decodedLength = uint256Coder.decode(data, offset);
|
||||
count = decodedLength.value.toNumber();
|
||||
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 = coder.decode(data, offset);
|
||||
consumed += result.consumed;
|
||||
offset += result.consumed;
|
||||
value.push(result.value);
|
||||
}
|
||||
|
||||
return {
|
||||
consumed: consumed,
|
||||
value: value,
|
||||
}
|
||||
var result = unpack(coders, data, offset);
|
||||
result.consumed += consumed;
|
||||
return result;
|
||||
},
|
||||
dynamic: (length === -1)
|
||||
dynamic: (length === -1 || coder.dynamic)
|
||||
}
|
||||
}
|
||||
|
||||
// Break the type up into [staticType][staticArray]*[dynamicArray]? | [dynamicType] and
|
||||
// build the coder up from its parts
|
||||
var paramTypePart = new RegExp(/^((u?int|bytes)([0-9]*)|(address|bool|string)|(\[([0-9]*)\]))/);
|
||||
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]);
|
||||
switch (prefix) {
|
||||
case 'int': case 'uint':
|
||||
if (coder) { throwError('invalid type', { type: type }); }
|
||||
var size = parseInt(part[3] || 256);
|
||||
if (size === 0 || size > 256 || (size % 8) !== 0) {
|
||||
throwError('invalid type', { type: type });
|
||||
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 {
|
||||
coders: coders,
|
||||
name: 'tuple',
|
||||
type: type,
|
||||
encode: function(value) {
|
||||
|
||||
if (coders.length !== coders.length) {
|
||||
throwError('types/values mismatch', { type: type, values: values });
|
||||
}
|
||||
|
||||
return pack(coders, value);
|
||||
},
|
||||
decode: function(data, offset) {
|
||||
return unpack(coders, data, offset);
|
||||
},
|
||||
dynamic: dynamic
|
||||
};
|
||||
}
|
||||
|
||||
function getTypes(coders) {
|
||||
var type = coderTuple(coders).type;
|
||||
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');
|
||||
}
|
||||
coder = coderNumber(size / 8, (prefix === 'int'));
|
||||
break;
|
||||
|
||||
case 'bool':
|
||||
if (coder) { throwError('invalid type', { type: type }); }
|
||||
coder = coderBoolean;
|
||||
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) {
|
||||
throwError('invalid type ' + type);
|
||||
}
|
||||
coder = 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.push(accum);
|
||||
|
||||
if (!coder) { throwError('invalid type'); }
|
||||
return coder;
|
||||
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) {
|
||||
|
||||
var coder = paramTypeSimple[type];
|
||||
if (coder) { return coder; }
|
||||
|
||||
var match = type.match(paramTypeNumber);
|
||||
if (match) {
|
||||
var size = parseInt(match[2] || 256);
|
||||
if (size === 0 || size > 256 || (size % 8) !== 0) {
|
||||
throwError('invalid type', { type: type });
|
||||
}
|
||||
return coderNumber(size / 8, (match[1] === 'int'));
|
||||
}
|
||||
|
||||
var match = type.match(paramTypeBytes);
|
||||
if (match) {
|
||||
var size = parseInt(match[1]);
|
||||
if (size === 0 || size > 32) {
|
||||
throwError('invalid type ' + type);
|
||||
}
|
||||
return coderFixedBytes(size);
|
||||
}
|
||||
|
||||
var match = type.match(paramTypeArray);
|
||||
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) {
|
||||
for (var key in items) {
|
||||
utils.defineProperty(object, key, items[key]);
|
||||
@ -672,11 +833,13 @@ function Interface(abi) {
|
||||
var outputNames = getKeys(method.outputs, 'name', true);
|
||||
}
|
||||
|
||||
var signature = method.name + '(' + getKeys(method.inputs, 'type').join(',') + ')';
|
||||
var sighash = utils.keccak256(utils.toUtf8Bytes(signature)).substring(0, 10);
|
||||
var func = function() {
|
||||
var signature = method.name + '(' + getKeys(method.inputs, 'type').join(',') + ')';
|
||||
var result = {
|
||||
name: method.name,
|
||||
signature: signature,
|
||||
sighash: sighash
|
||||
};
|
||||
|
||||
var params = Array.prototype.slice.call(arguments, 0);
|
||||
@ -687,9 +850,7 @@ function Interface(abi) {
|
||||
throwError('too many parameters');
|
||||
}
|
||||
|
||||
signature = utils.keccak256(utils.toUtf8Bytes(signature)).substring(0, 10);
|
||||
|
||||
result.data = signature + Interface.encodeParams(inputTypes, params).substring(2);
|
||||
result.data = sighash + Interface.encodeParams(inputTypes, params).substring(2);
|
||||
if (method.constant) {
|
||||
result.parse = function(data) {
|
||||
return Interface.decodeParams(
|
||||
@ -706,6 +867,8 @@ function Interface(abi) {
|
||||
|
||||
defineFrozen(func, 'inputs', getKeys(method.inputs, 'name'));
|
||||
defineFrozen(func, 'outputs', getKeys(method.outputs, 'name'));
|
||||
utils.defineProperty(func, 'signature', signature);
|
||||
utils.defineProperty(func, 'sighash', sighash);
|
||||
|
||||
return func;
|
||||
})();
|
||||
@ -776,7 +939,9 @@ function Interface(abi) {
|
||||
};
|
||||
return populateDescription(new EventDescription(), result);
|
||||
}
|
||||
|
||||
defineFrozen(func, 'inputs', getKeys(method.inputs, 'name'));
|
||||
|
||||
return func;
|
||||
})();
|
||||
|
||||
@ -810,46 +975,12 @@ function Interface(abi) {
|
||||
utils.defineProperty(Interface, 'encodeParams', function(types, values) {
|
||||
if (types.length !== values.length) { throwError('types/values mismatch', {types: types, values: values}); }
|
||||
|
||||
var parts = [];
|
||||
|
||||
types.forEach(function(type, index) {
|
||||
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 coders = [];
|
||||
types.forEach(function(type) {
|
||||
coders.push(getParamCoder(type));
|
||||
});
|
||||
|
||||
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 utils.hexlify(data);
|
||||
return utils.hexlify(coderTuple(coders).encode(values));
|
||||
});
|
||||
|
||||
|
||||
@ -865,52 +996,40 @@ utils.defineProperty(Interface, 'decodeParams', function(names, types, 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 offset = 0;
|
||||
types.forEach(function(type, 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]) {
|
||||
coders.forEach(function(coder, index) {
|
||||
values[index] = result.value[index];
|
||||
if (names && names[index]) {
|
||||
var name = names[index];
|
||||
|
||||
// We reserve length to make the Result object arrayish
|
||||
if (name === 'length') {
|
||||
console.log('WARNING: result length renamed to _length');
|
||||
name = '_length';
|
||||
}
|
||||
|
||||
if (values[name] == null) {
|
||||
values[name] = result.value;
|
||||
values[name] = values[index];
|
||||
} else {
|
||||
console.log('WARNING: duplicate value - ' + name);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
values.length = types.length;
|
||||
|
||||
return values;
|
||||
});
|
||||
|
||||
//utils.defineProperty(Interface, 'getDeployTransaction', function(bytecode) {
|
||||
//});
|
||||
|
||||
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) {
|
||||
'use strict';
|
||||
|
||||
@ -963,7 +1082,7 @@ module.exports = Interface;
|
||||
|
||||
var Buffer;
|
||||
try {
|
||||
Buffer = require('buf' + 'fer').Buffer;
|
||||
Buffer = require('buffer').Buffer;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
@ -4200,7 +4319,7 @@ module.exports = Interface;
|
||||
};
|
||||
|
||||
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();
|
||||
|
||||
var windowSize = 4;
|
||||
@ -4339,7 +4458,9 @@ module.exports = Interface;
|
||||
};
|
||||
})(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');
|
||||
|
||||
@ -4373,6 +4494,15 @@ function getChecksumAddress(address) {
|
||||
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
|
||||
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); }
|
||||
|
||||
// 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) {
|
||||
address = address.toUpperCase();
|
||||
@ -4456,7 +4586,7 @@ module.exports = {
|
||||
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
|
||||
*
|
||||
@ -4537,6 +4667,10 @@ defineProperty(BigNumber.prototype, 'mod', function(other) {
|
||||
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) {
|
||||
return new BigNumber(this._bn.maskn(value));
|
||||
@ -4556,6 +4690,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);
|
||||
});
|
||||
@ -4596,7 +4734,7 @@ module.exports = {
|
||||
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
|
||||
*
|
||||
@ -4605,8 +4743,19 @@ module.exports = {
|
||||
var defineProperty = require('./properties.js').defineProperty;
|
||||
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) {
|
||||
if (!value || parseInt(value.length) != value.length) {
|
||||
if (!value || parseInt(value.length) != value.length || typeof(value) === 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -4635,11 +4784,11 @@ function arrayify(value, name) {
|
||||
result.push(parseInt(value.substr(i, 2), 16));
|
||||
}
|
||||
|
||||
return new Uint8Array(result);
|
||||
return addSlice(new Uint8Array(result));
|
||||
}
|
||||
|
||||
if (isArrayish(value)) {
|
||||
return new Uint8Array(value);
|
||||
return addSlice(new Uint8Array(value));
|
||||
}
|
||||
|
||||
throwError('invalid arrayify value', { name: name, input: value });
|
||||
@ -4661,7 +4810,7 @@ function concat(objects) {
|
||||
offset += arrays[i].length;
|
||||
}
|
||||
|
||||
return result;
|
||||
return addSlice(result);
|
||||
}
|
||||
function stripZeros(value) {
|
||||
value = arrayify(value);
|
||||
@ -4687,7 +4836,7 @@ function padZeros(value, length) {
|
||||
|
||||
var result = new Uint8Array(length);
|
||||
result.set(value, length - value.length);
|
||||
return result;
|
||||
return addSlice(result);
|
||||
}
|
||||
|
||||
|
||||
@ -4759,7 +4908,7 @@ module.exports = {
|
||||
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';
|
||||
|
||||
var sha3 = require('js-sha3');
|
||||
@ -4773,7 +4922,7 @@ function keccak256(data) {
|
||||
|
||||
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) {
|
||||
Object.defineProperty(object, name, {
|
||||
enumerable: true,
|
||||
@ -4786,7 +4935,7 @@ module.exports = {
|
||||
defineProperty: defineProperty,
|
||||
};
|
||||
|
||||
},{}],10:[function(require,module,exports){
|
||||
},{}],11:[function(require,module,exports){
|
||||
(function (global){
|
||||
var defineProperty = require('./properties.js').defineProperty;
|
||||
|
||||
@ -4813,7 +4962,7 @@ function defineEthersValues(values) {
|
||||
module.exports = defineEthersValues;
|
||||
|
||||
}).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';
|
||||
|
||||
function throwError(message, params) {
|
||||
@ -4826,7 +4975,7 @@ function throwError(message, params) {
|
||||
|
||||
module.exports = throwError;
|
||||
|
||||
},{}],12:[function(require,module,exports){
|
||||
},{}],13:[function(require,module,exports){
|
||||
|
||||
var convert = require('./convert.js');
|
||||
|
||||
@ -4941,7 +5090,7 @@ module.exports = {
|
||||
toUtf8String: bytesToUtf8,
|
||||
};
|
||||
|
||||
},{"./convert.js":7}],13:[function(require,module,exports){
|
||||
},{"./convert.js":8}],14:[function(require,module,exports){
|
||||
(function (process,global){
|
||||
/**
|
||||
* [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 : {})
|
||||
},{"_process":14}],14:[function(require,module,exports){
|
||||
},{"_process":15}],15:[function(require,module,exports){
|
||||
module.exports = undefined;
|
||||
},{}]},{},[2]);
|
||||
|
6
dist/ethers-contracts.min.js
vendored
6
dist/ethers-contracts.min.js
vendored
File diff suppressed because one or more lines are too long
1259
dist/ethers-providers.js
vendored
1259
dist/ethers-providers.js
vendored
File diff suppressed because it is too large
Load Diff
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
2024
dist/ethers-utils.js
vendored
2024
dist/ethers-utils.js
vendored
File diff suppressed because it is too large
Load Diff
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
1517
dist/ethers-wallet.js
vendored
1517
dist/ethers-wallet.js
vendored
File diff suppressed because one or more lines are too long
12
dist/ethers-wallet.min.js
vendored
12
dist/ethers-wallet.min.js
vendored
File diff suppressed because one or more lines are too long
911
dist/ethers.js
vendored
911
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
@ -10,10 +10,10 @@
|
||||
"version": "grunt dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethers-contracts": "^2.1.0",
|
||||
"ethers-providers": "^2.1.0",
|
||||
"ethers-utils": "^2.1.0",
|
||||
"ethers-wallet": "^2.1.0"
|
||||
"ethers-contracts": "^2.1.5",
|
||||
"ethers-providers": "^2.1.8",
|
||||
"ethers-utils": "^2.1.6",
|
||||
"ethers-wallet": "^2.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "^0.4.5",
|
||||
|
Loading…
Reference in New Issue
Block a user