ERC725Alliance / erc725.js

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

any encode call should result in an array of `key`, `value` to be returned #140

Closed frozeman closed 2 years ago

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

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

{
  keys: [
    '0x3a47ab5bd3a594c3a8995f8fa58d0876c96819ca4516bd76100c92462f2f9dc0',
    '0x3a47ab5bd3a594c3a8995f8fa58d087600000000000000000000000000000000',
    '0xffddab5bd3a594c3a8995f8fa58d0876c96819ca4516bd76100c92462f2fddff'
  ],
  values: [
    '0x0000000000000000000000000000000000000000000000000000000000000001',
    '0xa3e6f38477d45727f6e6f853cdb479b0d60c0ac9',
    '0x123456789'
  ]
}
Hugoo commented 2 years ago

Adding specs from the issue: #134

const encodedDataOneKey = erc725.encodeData({
 '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5': {
    json: profileJson, // check instantiation.js to see the actual JSON
    url: 'ifps://QmQTqheBLZFnQUxu5RDs8tA9JtkxfZqMBcmGd9sukXxwRm',
  },
});

/**
{
  keys [ '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5'],
  values: [ '0x6f357c6a2404a2866f05e53e141eb61382a045e53c2fc54831daca9d9e1e039a11f739e1696670733a2f2f516d5154716865424c5a466e5155787535524473387441394a746b78665a714d42636d47643973756b587877526d']
}
*/
const encodedDataOneKey = erc725.encodeData({
  LSP3Profile: {
    json: profileJson, // check instantiation.js to see the actual JSON
    url: 'ifps://QmQTqheBLZFnQUxu5RDs8tA9JtkxfZqMBcmGd9sukXxwRm',
  },
});

/**
{
  keys [ '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5'],
  values: [ '0x6f357c6a2404a2866f05e53e141eb61382a045e53c2fc54831daca9d9e1e039a11f739e1696670733a2f2f516d5154716865424c5a466e5155787535524473387441394a746b78665a714d42636d47643973756b587877526d']
}
*/