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

Add function decodeArrayKey #481

Open
1 of 4 tasks
CJ42 opened this issue Nov 5, 2024 · 0 comments
Open
1 of 4 tasks

Add function decodeArrayKey #481

CJ42 opened this issue Nov 5, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@CJ42
Copy link
Collaborator

CJ42 commented Nov 5, 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

erc725.js exposes a function encodeArrayKey but does not provide the equivalent for decoding.

This function would be useful to act similar to decodeMappingKey for array data key for indexes, by returning for instance:

  • the full array key name
  • the index as a number

Example of how to use this function could look like this:

ERC725.decodeArrayKey(
  '0xdf30dba06db6a30e65354d9a64c6098600000000000000000000000000000005',
  'AddressPermissions[]',
);
// [
//   { 
//      keyName: 'AddressPermissions[]', 
//      index: 5
//   }
// ]

Note: this function should also easily decode large numbers as indexes. For instance:

ERC725.decodeArrayKey(
  '0xdf30dba06db6a30e65354d9a64c60986000000000000000000000000499602d2',
  'AddressPermissions[]',
);
// [
//   { 
//      keyName: 'AddressPermissions[]', 
//      index: 1234567890
//   }
// ]

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.)

image
@CJ42 CJ42 added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant