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

[Bug] getSchema returns a schema name that contains the dynamic part for MappingWithGrouping #350

Closed
CJ42 opened this issue Nov 9, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@CJ42
Copy link
Collaborator

CJ42 commented Nov 9, 2023

I'm submitting a...

bug report

Summary

When using the function getSchema with data keys that are of type MappingWithGrouping, the schema returned contains the dynamic part like <address> in the example below.

This creates an issue as when comparing, or running tests (screenshots below), as it should return either:

  • AddressPermissions:Permissions or
  • AddressPermissions:Permissions:<address>
image

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 issue comes from the internal logic of the function that parse schemas. They append the :{address} at the end (line 134 below)

const findMappingWithGroupingSchemaForKey = (
key: string,
schemas: ERC725JSONSchema[],
): ERC725JSONSchema | null => {
const keySchema =
schemas.find(
(schema) => schema.key.substring(0, 26) === key.substring(0, 26),
) || null;
const address = key.substring(26);
if (keySchema) {
return {
...keySchema,
key,
name: `${keySchema.name.substring(
0,
keySchema.name.lastIndexOf(':'),
)}:${address}`,
};
}

Proposal

  • [] Return the exact same schema name containing even <address> (the dynamic part).
  • [] Add in the object returned an entry dynamicKeyPart that contains the dynamic key
  • [] Create a new developer friendly function called getHumanReadableKey (something like this) that would return the first part of the data key as words + the dynamic part, like in the screenshot above. For instance
ERC725.getHumanReadableKey('0x4b80742de2bf82acb3630000ea08aa95d02df6146bb999572e9ebd261a798ef6')
// returns: "AddressPermissions:Permissions:ea08aa95d02df6146bb999572e9ebd261a798ef6"
@Hugoo Hugoo added the bug Something isn't working label Mar 25, 2024
@CJ42
Copy link
Collaborator Author

CJ42 commented May 16, 2024

Closing as completed in #428

@CJ42 CJ42 closed this as completed May 16, 2024
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