ERC725Alliance / erc725.js

Package to interact with ERC725 smart contracts
Apache License 2.0
38 stars 29 forks source link

return value of `LSP3IssuedAssets[]`, array values is wrong #139

Closed frozeman closed 2 years ago

frozeman commented 2 years ago
const encodedDataManyKeys = asset.encodeData({
    'LSP3IssuedAssets[]': [
      '0xa3e6F38477D45727F6e6f853Cdb479b0D60c0aC9',
    ],
)

should result in all keys flattened into one single array, to be used for a transaction

 {
  keys: [
    '0x3a47ab5bd3a594c3a8995f8fa58d0876c96819ca4516bd76100c92462f2f9dc0',
    '0x3a47ab5bd3a594c3a8995f8fa58d087600000000000000000000000000000000'
  ],
  values: [
    '0x0000000000000000000000000000000000000000000000000000000000000001',
    '0xa3e6f38477d45727f6e6f853cdb479b0d60c0ac9'
  ]
}

but results in:

{
  'LSP3IssuedAssets[]':
    key: "0x3a47ab5bd3a594c3a8995f8fa58d0876c96819ca4516bd76100c92462f2f9dc0"
    value: [
      {key: '0x3a47ab5bd3a594c3a8995f8fa58d0876c96819ca4516bd76100c92462f2f9dc0', value: '0x0000000000000000000000000000000000000000000000000000000000000001'},
      {key: '0x3a47ab5bd3a594c3a8995f8fa58d087600000000000000000000000000000000', value: '0xa3e6f38477d45727f6e6f853cdb479b0d60c0ac9'}
  ]
}
Hugoo commented 2 years ago

@frozeman If the input object has only one key:

const encodedDataManyKeys = asset.encodeData({
    'LSP3IssuedAssets[]': [
      '0xa3e6F38477D45727F6e6f853Cdb479b0D60c0aC9',
    ],
)

should the output be:

1) Direct result

{
  keys: [
    '0x3a47ab5bd3a594c3a8995f8fa58d0876c96819ca4516bd76100c92462f2f9dc0',
    '0x3a47ab5bd3a594c3a8995f8fa58d087600000000000000000000000000000000'
  ],
  values: [
    '0x0000000000000000000000000000000000000000000000000000000000000001',
    '0xa3e6f38477d45727f6e6f853cdb479b0d60c0ac9'
  ]
}

or:

2) Result is in map with key

{
  'LSP3IssuedAssets[]':
    {
      keys: [
        '0x3a47ab5bd3a594c3a8995f8fa58d0876c96819ca4516bd76100c92462f2f9dc0',
        '0x3a47ab5bd3a594c3a8995f8fa58d087600000000000000000000000000000000'
      ],
      values: [
        '0x0000000000000000000000000000000000000000000000000000000000000001',
        '0xa3e6f38477d45727f6e6f853cdb479b0d60c0ac9'
      ]
    }
}

i.e.: if the input object has only 1 key -> then the output object has no key and is the direct result. I think 2) is better in this case. Because here, the input is always an object.

frozeman commented 2 years ago
const encodedDataManyKeys = asset.encodeData({
    'LSP3IssuedAssets[]': [
      '0xa3e6F38477D45727F6e6f853Cdb479b0D60c0aC9',
    ],
    'LSP3Profile': {LSP3Profiel: .........}
)

results in

{
  keys: [
    '0x3a47ab5bd3a594c3a8995f8fa58d0876c96819ca4516bd76100c92462f2f9dc0',
    '0x3a47ab5bd3a594c3a8995f8fa58d087600000000000000000000000000000000',
    '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5'
  ],
  values: [
    '0x0000000000000000000000000000000000000000000000000000000000000001',
    '0xa3e6f38477d45727f6e6f853cdb479b0d60c0ac9',
     '0xf38477d45727f6e6f8f38477d45727f6e6f8f38477d45727f6e6f8a3e6f38477d45727f6e6f853cdb479b0d60c0ac9'
  ]
}
frozeman commented 2 years ago

Same in https://github.com/ERC725Alliance/erc725.js/issues/134

Hugoo commented 2 years ago

This issue is a duplicate of #140 - we will close this one and move the specs from this ticket to the issue #140