Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing length for CompactBytesArray encoding / uint32 #397

Open
Hugoo opened this issue Mar 25, 2024 · 1 comment
Open

Missing length for CompactBytesArray encoding / uint32 #397

Hugoo opened this issue Mar 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Hugoo
Copy link
Contributor

Hugoo commented Mar 25, 2024

It seems that there is an encoding issue for the following:

✅ decodeData

ERC725.decodeData(
    [
      {
        keyName: "LSP18RoyaltiesRecipients",
        value: "0x001c24871b3dbf969fdccf9d9beee0b56bdaef2a73a6eb885c5900001388",
      },
    ],
    [
      {
        name: "LSP18RoyaltiesRecipients",
        key: "0xc0569ca6c9180acc2c3590f36330a36ae19015a19f4e85c28a7631e3317e6b9d",
        keyType: "Singleton",
        valueType: "(bytes4,address,uint32)[CompactBytesArray]",
        valueContent: "(Bytes4,Address,Number)",
      },
    ]
  );

Returns:

{
  key: '0xc0569ca6c9180acc2c3590f36330a36ae19015a19f4e85c28a7631e3317e6b9d',
  name: 'LSP18RoyaltiesRecipients',
  value: [
    [
      '0x24871b3d',
      '0xbF969fdCCf9D9bEEe0b56bdaEF2a73a6eb885C59',
      5000
    ]
  ]
}

❌ encodeData

The encoding is wrong

ERC725.encodeData(
    [
      {
        keyName: "LSP18RoyaltiesRecipients",
        value: [
          "0x24871b3d",
          "0xbF969fdCCf9D9bEEe0b56bdaEF2a73a6eb885C59",
          "5000",
        ],
      },
    ],
    [
      {
        name: "LSP18RoyaltiesRecipients",
        key: "0xc0569ca6c9180acc2c3590f36330a36ae19015a19f4e85c28a7631e3317e6b9d",
        keyType: "Singleton",
        valueType: "(bytes4,address,uint32)[CompactBytesArray]",
        valueContent: "(Bytes4,Address,Number)",
      },
    ]
  );

Returns:

{
  keys: ['0xc0569ca6c9180acc2c3590f36330a36ae19015a19f4e85c28a7631e3317e6b9d'],
  values: ['0x24871b3dbf969fdccf9d9beee0b56bdaef2a73a6eb885c591388']
}

Expected value:

  1. Missing length
  2. Missing 0000 for the utin32
❌ 0x%%%%24871b3dbf969fdccf9d9beee0b56bdaef2a73a6eb885c59%%%%1388
✅ 0x001c24871b3dbf969fdccf9d9beee0b56bdaef2a73a6eb885c5900001388

Related to:

@Hugoo Hugoo added the bug Something isn't working label Mar 25, 2024
@m4r-v1n
Copy link

m4r-v1n commented Jun 17, 2024

Version 0.27.0 couldn't properly parse tuples with CompactBytesArray:

error: Could not encode 4200. Value type uint32)[CompactBytesArray is unknown

It gets uint32 as uint32)[CompactBytesArray ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants