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

Cannot use encodeData with a tuple of CompactBytesArray #488

Open
1 of 4 tasks
CJ42 opened this issue Nov 7, 2024 · 1 comment
Open
1 of 4 tasks

Cannot use encodeData with a tuple of CompactBytesArray #488

CJ42 opened this issue Nov 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@CJ42
Copy link
Collaborator

CJ42 commented Nov 7, 2024

I'm submitting a...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

The Typescript types fail in the following case below.

image
Error: Type '[string, string, string, string]' is not assignable to type 'string | number'

Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

The following test should pass and be able to be run without any Typescript errors:

describe('for CompactBytesArray of tuples `(...,...)[CompactBytesArray]`', () => {
      it(`encodes/decodes: [ ["0x00000002", "0xcafecafecafecafecafecafecafecafecafecafe", "0x11223344", "0xbb11bb11"] ] as (bytes4,address,bytes4,bytes4)[CompactBytesArray]`, () => {
        const schema = {
          name: 'AddressPermissions:AllowedCalls:<address>',
          key: '0x4b80742de2bf393a64c70000<address>',
          keyType: 'MappingWithGrouping',
          valueType: '(bytes4,address,bytes4,bytes4)[CompactBytesArray]',
          valueContent: '(BitArray,Address,Bytes4,Bytes4)',
        };

        const expectedEncodedValue =
          '0x002000000002cafecafecafecafecafecafecafecafecafecafe11223344bb11bb11';

        const result = ERC725.encodeData(
          [
            {
              keyName: 'AddressPermissions:AllowedCalls:<address>',
              dynamicKeyParts: address,
              value: [
                [
                  '0x00000002',
                  '0xcafecafecafecafecafecafecafecafecafecafe',
                  '0x11223344',
                  '0xbb11bb11',
                ],
              ],
            },
          ],
          [schema],
        );

        assert.equal(result.values[0], expectedEncodedValue);
      });
    });
  });
@CJ42 CJ42 added the bug Something isn't working label Nov 7, 2024
@CJ42
Copy link
Collaborator Author

CJ42 commented Nov 7, 2024

An example of the test above is provided in the branch fix/encodeData-CompactBytesArray

https://github.com/ERC725Alliance/erc725.js/tree/fix/encodeData-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

1 participant