-
Notifications
You must be signed in to change notification settings - Fork 0
Wp 4622/api ts mbe #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8a58773 to
1797b29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the BitGo Express integration by updating type definitions and introducing new API routers and response handlers.
- Updated request types to use the new BitGo type and added an isBitGoRequest type guard.
- Introduced new routers for health check, enclaved express, and API spec endpoints using the @api-ts libraries.
- Adjusted wallet generation to integrate with the updated BitGo type and its associated casting.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/request.ts | Replaced BitGoBase with BitGo and added a type guard for client request verification. |
| src/shared/responseHandler.ts | Added a unified response handler wrapper for service functions. |
| src/routes/master.ts | Removed legacy health check and BitGo setup middleware; integrated new router-based endpoints. |
| src/masterBitgoExpress/routers/* | Added new API routers for health check, enclaved express, and API spec endpoints integration. |
| src/masterBitgoExpress/generateWallet.ts | Updated the wallet generation code to use an explicit cast to BitGoBase—reflecting a change in type usage. |
| package.json | Added new dependencies for the @api-ts libraries and updated version references. |
Comments suppressed due to low confidence (1)
src/masterBitgoExpress/generateWallet.ts:121
- The use of double casting ('bitgo as unknown as BitGoBase') indicates a potential type mismatch between the BitGo type in requests and the BitGoBase expected by the Wallet constructor. Consider updating the types or refactoring the Wallet constructor to accept the BitGo type directly to maintain type safety.
wallet: new Wallet(bitgo as unknown as BitGoBase, baseCoin, newWallet),
pranavjain97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're converting routes from master and calling them "enclave" spec
|
|
||
| const result: WalletWithKeychains = { | ||
| wallet: new Wallet(bitgo, baseCoin, newWallet), | ||
| wallet: new Wallet(bitgo as unknown as BitGoBase, baseCoin, newWallet), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Shoudn't GenerateWalletOptions have bitgo as BitGoBase?
src/routes/master.ts
Outdated
| next(); | ||
| }; | ||
| } | ||
| import { createEnclavedApiRouter } from '../masterBitgoExpress/routers/enclavedApiSpec'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called createMasterApiRouter
| }); | ||
|
|
||
| // Create router with handlers | ||
| export function createEnclavedExpressRouter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is master express API router
| }); | ||
|
|
||
| // Create router with handlers | ||
| export function createEnclavedApiRouter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export function createEnclavedApiRouter( | |
| export function createMasterApiRouter( |
| }; | ||
|
|
||
| // API Specification | ||
| export const EnclavedApiSpec = apiSpec({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export const EnclavedApiSpec = apiSpec({ | |
| export const MasterApiSpec = apiSpec({ |
| @@ -0,0 +1,111 @@ | |||
| import * as t from 'io-ts'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this is masterApiSpec
pranavjain97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why do we need a new routers folder. Can we use the existing routes folder and add them to the master file
1797b29 to
51a181e
Compare
file becomes too large, around or just over 500 lines as is and will become even more larger once we add in the tss routes + recovery. Would prefer if we could keep things encapsulated |
Yeah originally had named it such so it would be referencing the api on enclaved that master is calling but in hindsight that is kinda confusing. |
51a181e to
f98962b
Compare
| }; | ||
|
|
||
| // API Specification | ||
| export const EnclavedExpressApiSpec = apiSpec({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export const EnclavedExpressApiSpec = apiSpec({ | |
| export const MasterExpressApiSpec = apiSpec({ |
No description provided.