diff --git a/src/lib/decodeData.test.ts b/src/lib/decodeData.test.ts index 39545ebf..662e5e16 100644 --- a/src/lib/decodeData.test.ts +++ b/src/lib/decodeData.test.ts @@ -284,6 +284,27 @@ describe('decodeData', () => { expect(decodedData.value).to.eql(3); }); + it('parses type Array correctly, return empty array when value is 0x', () => { + const decodedData = decodeData( + { + keyName: 'LSP12IssuedAssets[]', + value: '0x', + }, + [ + { + name: 'LSP12IssuedAssets[]', + key: '0x7c8c3416d6cda87cd42c71ea1843df28ac4850354f988d55ee2eaa47b6dc05cd', + keyType: 'Array', + valueContent: 'Address', + valueType: 'address', + }, + ], + ); + + expect(decodedData.name).to.eql('LSP12IssuedAssets[]'); + expect(decodedData.value).to.eql([]); + }); + it('decodes dynamic keys', () => { const decodedData = decodeData( [ diff --git a/src/lib/decodeData.ts b/src/lib/decodeData.ts index 05050361..a6b7cefd 100644 --- a/src/lib/decodeData.ts +++ b/src/lib/decodeData.ts @@ -196,7 +196,7 @@ export function decodeKey(schema: ERC725JSONSchema, value) { switch (lowerCaseKeyType) { case 'array': { // If user has requested a key which does not exist in the contract, value will be: 0x and value.find() will fail. - if (!value) { + if (!value || value === '0x') { return []; }