Removed stray localName in array sub-coders.
This commit is contained in:
parent
059b03e090
commit
aa48dfcdf4
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ethers",
|
||||
"version": "3.0.22",
|
||||
"version": "3.0.23",
|
||||
"description": "Ethereum wallet library.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -173,6 +173,26 @@ describe('ABI Coder ABIv2 Decoding', function() {
|
||||
it(('decodes ABIv2 parameters - ' + test.name + ' - ' + test.types), function() {
|
||||
var decoded = coder.decode(types, result);
|
||||
assert.ok(equals(decoded, values), 'decoded positional parameters - ' + title);
|
||||
|
||||
// Test for mutation
|
||||
// https://github.com/ethers-io/ethers.js/issues/200
|
||||
// https://github.com/ethers-io/ethers.js/issues/201
|
||||
|
||||
// @TODO: Expose parseParameter
|
||||
// Check that it works with objects as well as strings
|
||||
var expandedTypes = [];
|
||||
types.forEach(function(type) {
|
||||
var sig = 'function foo(' + type + ' foo)';
|
||||
var abi = ethers.utils.AbiCoder.parseSignature(sig);
|
||||
expandedTypes.push(abi.inputs[0]);
|
||||
});
|
||||
|
||||
var typesBefore = JSON.stringify(expandedTypes);
|
||||
|
||||
decoded = coder.decode(expandedTypes, result);
|
||||
assert.ok(equals(decoded, values), 'decoded positional parameters - ' + title);
|
||||
|
||||
assert.equal(typesBefore, JSON.stringify(expandedTypes), 'decoding does not modify the types');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -758,8 +758,17 @@ function coderArray(coerceFunc, coder, length, localName) {
|
||||
offset += decodedLength.consumed;
|
||||
}
|
||||
|
||||
// We don't want the children to have a localName
|
||||
var subCoder = {
|
||||
name: coder.name,
|
||||
type: coder.type,
|
||||
encode: coder.encode,
|
||||
decode: coder.decode,
|
||||
dynamic: coder.dynamic
|
||||
};
|
||||
|
||||
var coders = [];
|
||||
for (var i = 0; i < count; i++) { coders.push(coder); }
|
||||
for (var i = 0; i < count; i++) { coders.push(subCoder); }
|
||||
|
||||
var result = unpack(coders, data, offset);
|
||||
result.consumed += consumed;
|
||||
|
Loading…
Reference in New Issue
Block a user