Closed aramakme closed 3 years ago
It looks like stoic-identity puts some node_modules underneath it with another copy of the agent libraries. I guess because of this it creates Principal and Principal$1 and Principal$2 as different object types. There fore the instanceof Principal doesn't work.
If I add a branch to hash_value in request_id.js I can get it to work:
else if (typeof value === 'object' &&
value !== null &&
value._isPrincipal == true &&
typeof value.toUint8Array === 'function') {
return hashValue(value.toUint8Array());
}
I'll make an issue on the agent project to include this branch. It is possible this was caused because I originally had 0.9.7 for my project and npm installed stoic-identity referencing agent 0.10.0 and now npm can't unwind things.
Thanks - yeah @jorgenbuilder came across the same sorts of things (as I have I in the past), definitely because of a mismatch I believe. Will try to see if we can make a fix from our end too incase they don't merge from the agent repo.
Kyle is going to try to get the fix into next version of agent-js: https://forum.dfinity.org/t/mismatching-dfinity-agent-versions-can-cause-hashing-issues/7359/4
Not sure if @aramakme already found a temporary fix, but this works for me: https://github.com/aviate-labs/dots/commit/136575e21b10015932916f8e3f2b3d3c5dc2f7d5
tldr: instanceof operator doesn't work well across modules in npm.
I think I have a messed up principal reference somewhere. I'm using vite and am trying to integrate Stoic.
Error:
This is how I set things up: canisterID is a Text agent is let stoicIdentity = await StoicIdentity.load();
myCanister = Actor.createActor(canister_idl, { agent, canisterId: canisterID });
The following are the results from the console when I put a break point at
A instanceof Principal - false A instanceof Principal$2 - true
I end up hitting:
Principal$2
{ "_arr": { "0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "6": 0, "7": 14, "8": 1, "9": 1 }, "_isPrincipal": true }
Do I need to wrap my canister id in something? Is there a ref inside the stoic Identity I can use?