Conversation
8b1785b to
be04334
Compare
mcmire
left a comment
There was a problem hiding this comment.
This looks pretty good so far! I just had a few comments.
| return this.#mutationPolicy.execute(async () => { | ||
| const response = await fetch(new URL(path, this.#baseUrl), { | ||
| method: 'POST', | ||
| headers, | ||
| body: JSON.stringify(body), | ||
| }); | ||
|
|
||
| if (!response.ok && !acceptedStatuses.includes(response.status)) { | ||
| throw new HttpError( | ||
| response.status, | ||
| `POST ${path} failed with status '${response.status}'`, | ||
| ); | ||
| } | ||
|
|
||
| return response; | ||
| }); |
There was a problem hiding this comment.
After I gave you the suggest to use the service policy manually like this, I came across another PR that someone else posted here: https://github.com/MetaMask/core/pull/8260/changes#diff-df87c072da30a25c3d5d0291f962f6b7c52da863a4d1e79a11752d89bc471c4cR204.
Basically it seems that we can use fetchQuery, but pass staleTime: 0 to effectively turn off caching. Can you try that and see how that works? So this would look something like:
| return this.#mutationPolicy.execute(async () => { | |
| const response = await fetch(new URL(path, this.#baseUrl), { | |
| method: 'POST', | |
| headers, | |
| body: JSON.stringify(body), | |
| }); | |
| if (!response.ok && !acceptedStatuses.includes(response.status)) { | |
| throw new HttpError( | |
| response.status, | |
| `POST ${path} failed with status '${response.status}'`, | |
| ); | |
| } | |
| return response; | |
| }); | |
| return this.fetchQuery({ | |
| queryKey: [ | |
| // ... you might want to pass this in ... | |
| ], | |
| queryFn: async () => { | |
| const response = await fetch(new URL(path, this.#baseUrl), { | |
| method: 'POST', | |
| headers, | |
| body: JSON.stringify(body), | |
| }); | |
| if (!response.ok && !acceptedStatuses.includes(response.status)) { | |
| throw new HttpError( | |
| response.status, | |
| `POST ${path} failed with status '${response.status}'`, | |
| ); | |
| } | |
| return response; | |
| }), | |
| staleTime: 0, | |
| }); |
| }); | ||
|
|
||
| this.#baseUrl = baseUrl; | ||
| this.#getAccessToken = getAccessToken; |
There was a problem hiding this comment.
Where will this access token come from in the clients? Will this come from another controller or service? If so, then it would be better to use the messenger to retrieve this value instead of taking a callback.
packages/chomp-api-service/README.md
Outdated
| @@ -0,0 +1,15 @@ | |||
| # `@metamask/chom-api-service` | |||
There was a problem hiding this comment.
Typo?
| # `@metamask/chom-api-service` | |
| # `@metamask/chomp-api-service` |
There was a problem hiding this comment.
In addition to modifying these files you should also add chomp-api-service to the root tsconfig.json and tsconfig.build.json files to ensure that TypeScript knows about it (and its relationship to other packages) in development.
|
|
||
| ### Added | ||
|
|
||
| - Add `ChompApiService` ([#8361](https://github.com/MetaMask/core/pull/8413)) |
There was a problem hiding this comment.
Pr number here is different then the link
| const IntentEntryArrayStruct = array( | ||
| type({ | ||
| account: string(), | ||
| delegationHash: string(), |
There was a problem hiding this comment.
can we use hex validations here as they are defined in types?
| signerAddress: string; | ||
| status: string; | ||
| createdAt: string; | ||
| }; |
There was a problem hiding this comment.
Could this and GetUpgradeResponse be merged into a single type since they are the same?
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
|
@metamaskbot publish-preview |
0e8c506 to
08b3d87
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Explanation
References
Checklist