Toniq-Labs / stoic-identity

Identity for DFINITY's IC HttpAgent (to connect to a Stoic wallet via Stoic Connect)
MIT License
27 stars 16 forks source link

Bump Dfinity package deps #2

Closed jorgenbuilder closed 3 years ago

jorgenbuilder commented 3 years ago

EDIT I don't think mismatched versions were the issue, but perhaps some worthwhile changes here nonetheless.

Mismatching versions of @dfinity/agent (0.9.1 / 0.10.0) causes errors when hashing principals. We should bump these versions for that reason, and perhaps bump stoic identity to version 1.5.1.

// Line 30 of @dfinity/agent/esm/request_id.js
else if (value instanceof Principal) {
    return hash(value.toUint8Array());
}

I believe 0.10.0 added a new parameter _arr to the Principal class, so this value instanceof Principal returns falsy. Maybe @dfinity/agent should do a different check, like value.hasOwnProperty(toUint8Array) which would be less error prone here. I'll mention that on the forums. For now I think we should get this in.

jorgenbuilder commented 3 years ago

Seems there's a broken import with @dfinity/candid 0.10.0... will take a look.

jorgenbuilder commented 3 years ago

I was receiving the following error, which the latest commit seems to have fixed:

POST http://localhost:8000/api/v2/canister/rrkah-fqaaa-aaaaa-aaaaq-cai/call
422 (Unprocessable Entity)
call @ index.ts:205
async function (async)
call @ index.ts:166
caller @ actor.ts:349
handler @ actor.ts:372
(anonymous) @ account.tsx:19

index.ts:213 Uncaught (in promise) Error: Server returned an error:
  Code: 422 (Unprocessable Entity)
  Body: Could not parse body as submit message: Invalid CBOR encoding: invalid type: map, expected byte array

    at HttpAgent.call (index.ts:213)
    at async caller (actor.ts:349)