Skip to content

Cannot use encodeData with a tuple of CompactBytesArray #488

Description

@CJ42

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);
      });
    });
  });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions