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

tokenIdentifier function returns principals that don't comply with the IC spec #37

Open
roman-kashitsyn opened this issue Mar 16, 2022 · 0 comments

Comments

@roman-kashitsyn
Copy link

IC Principals look like blobs, but they do have an internal structure described in https://smartcontracts.org/docs/interface-spec/index.html#principal.

The tokenIdentifier function contracts principals in a way that is not compatible with the public spec:

const tokenIdentifier = (principal, index) => {
const padding = Buffer("\x0Atid");
const array = new Uint8Array([
...padding,
...Principal.fromText(principal).toUint8Array(),
...to32bits(index),
]);
return Principal.fromUint8Array(array).toText();
};

Possible solutions:

  1. Use a raw Blob as an identifier (probably the simplest solution).
  2. Construct "derived ids" as described in the spec (using a canister ID as a registering principal, for example).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant