Add ability to produce a request ID from a request#74
Conversation
|
Hydra is now somehow failing with an evaluation error: |
|
But only on darwin... |
|
I'm now able to reproduce this locally: We're using napalm (by @nmattia), and it looks like it's having trouble naming or producing a derivation from the I have no idea what triggered this. |
|
Is this possibly related to any upstream changes @paulyoung ? |
|
Shouldn't be – everything is pinned 😕 |
|
Perhaps |
|
I seem to have fixed the issue by regenerating the lock file 😑 |
| return new Uint8Array(Buffer.from(hex, "hex").buffer); | ||
| // Named `BinaryBlob` as opposed to `Blob` so not to conflict with | ||
| // https://developer.mozilla.org/en-US/docs/Web/API/Blob | ||
| export type BinaryBlob = Uint8Array & { __blob__: void }; |
There was a problem hiding this comment.
Interesting -- thanks Paul!
There was a problem hiding this comment.
This is where I first read about this approach: microsoft/TypeScript#25709 (comment)
| "output-file-sync": "^2.0.0", | ||
| "slash": "^2.0.0", | ||
| "source-map": "^0.6.1" | ||
| "source-map": "^0.5.0" |
There was a problem hiding this comment.
Not sure why but this is a generated file anyway.
| // NOTE: `nonce` is optional in the spec, but we provide it so that requests | ||
| // are unique and we avoid a bug in the client when the same request is | ||
| // submitted more than once: https://dfinity.atlassian.net/browse/DFN-895 | ||
| nonce?: BinaryBlob; |
| sender_sig: new Uint8Array(64) as BinaryBlob, | ||
| }; | ||
|
|
||
| const requestId = await requestIdOf(request); |
There was a problem hiding this comment.
Note to self (and anyone interested): I was hoping we have a way to call the client inside the tests and extend this test to incorporate the handler. However, after talking with @paulyoung it seems there is no easy and not time-consuming way to do this: deferred. 😢
There was a problem hiding this comment.
To clarify, I was specifically talking about browser-based end-to-end tests. A Node.js version should be easier to get to sooner.
js-user-library/src/requestId.ts
Outdated
| }; | ||
|
|
||
| export const requestIdOf = async (request: Request): Promise<RequestId> => { | ||
| const { sender_pubkey, sender_sig, ...rest } = request; |
There was a problem hiding this comment.
nit: I would rename the rest -- usually with rest you get the impression that it is left out dropped. It is the other way around here though.
There was a problem hiding this comment.
The remaining properties are called rest properties and I couldn't think of a better name at the time 😄
I'll rename it to fields.
|
|
||
| const traversed: Array<[BinaryBlob, BinaryBlob]> = await Promise.all(hashed); | ||
|
|
||
| const sorted: Array<[BinaryBlob, BinaryBlob]> = traversed |
There was a problem hiding this comment.
Do we need the sorting here? (I am missing the reason here.)
There was a problem hiding this comment.
determinism.
Edit: Apparently it is in the spec -- tt @paulyoung
eftychis
left a comment
There was a problem hiding this comment.
LGTM -- I have 1 question, 1 comment, and a really nit one (feel free to ignore it).
Extracted from #56, with some changes.
This adds some minimal type information for requests for now.