You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the create in the constructor, this.generateOperation() calls this.#addToOpQueue() and this returns this.#opQueue, which is a promise. This promise is pushed to this.#ops (see below). In contrast, for the update operations, I call generateOperation() myself (with commit implicitly set to true), so that the operation op is pushed as a plain object (this.#ops.push(op)).
As described above, the operations are stored inconsistently. In addition, this leads to the previous property also being inconsistent.
The previous property of these operations is set as follows:
1st operation / create: unset as intended
2nd operation / first update: previous is a promise to the first (create) operation / opQueue
3rd operation / second update: previous is a pointer to the second operation / first update (plain object)
Consequently, I cannot generate a request for the second operation (first update) because op.previous is a promise (and op.previous.update therefore undefined):
awaitdid.generateRequest(1);// Fails:// .../did.js:69// signer: options.signer || LocalSigner.create(op.previous.update.privateJwk),// ^//// TypeError: Cannot read properties of undefined (reading 'privateJwk')// at DID.generateRequest (.../did.js:69:75)
Btw, personally, I think the recent refactoring with the opQueue and the promises does not make it easier to understand the code. If it is required to reference the operations as promises, then maybe some documentation/comments would help. I guess that operations passed into the constructor will be plain objects and not promises.
The text was updated successfully, but these errors were encountered:
The create operation is stored as a promise in
this.#ops
, whereas all other operations are stored as plain objects.Steps to reproduce / Cause of the bug
I create the following operations:
create
,update
,update
For the create in the constructor,
this.generateOperation()
callsthis.#addToOpQueue()
and this returnsthis.#opQueue
, which is a promise. This promise is pushed tothis.#ops
(see below). In contrast, for the update operations, I callgenerateOperation()
myself (with commit implicitly set to true), so that the operationop
is pushed as a plain object (this.#ops.push(op)
).ion-tools/src/did.js
Lines 10 to 15 in 02199dd
As described above, the operations are stored inconsistently. In addition, this leads to the
previous
property also being inconsistent.The
previous
property of these operations is set as follows:previous
is a promise to the first (create) operation / opQueueprevious
is a pointer to the second operation / first update (plain object)Consequently, I cannot generate a request for the second operation (first update) because op.previous is a promise (and op.previous.update therefore undefined):
Btw, personally, I think the recent refactoring with the opQueue and the promises does not make it easier to understand the code. If it is required to reference the operations as promises, then maybe some documentation/comments would help. I guess that operations passed into the constructor will be plain objects and not promises.
The text was updated successfully, but these errors were encountered: