Skip to content

Conversation

@mohammadalfaiyazbitgo
Copy link
Contributor

No description provided.

This comment was marked as outdated.

This comment was marked as outdated.

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo force-pushed the WP-4622/api-ts-mbe branch 2 times, most recently from 8a58773 to 1797b29 Compare June 9, 2025 18:58
@mohammadalfaiyazbitgo mohammadalfaiyazbitgo marked this pull request as ready for review June 9, 2025 18:58
Copy link

Copilot AI left a 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),

Copy link
Contributor

@pranavjain97 pranavjain97 left a 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),
Copy link
Contributor

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?

next();
};
}
import { createEnclavedApiRouter } from '../masterBitgoExpress/routers/enclavedApiSpec';
Copy link
Contributor

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(
Copy link
Contributor

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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function createEnclavedApiRouter(
export function createMasterApiRouter(

};

// API Specification
export const EnclavedApiSpec = apiSpec({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const EnclavedApiSpec = apiSpec({
export const MasterApiSpec = apiSpec({

@@ -0,0 +1,111 @@
import * as t from 'io-ts';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this is masterApiSpec

Copy link
Contributor

@pranavjain97 pranavjain97 left a 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

@mohammadalfaiyazbitgo
Copy link
Contributor Author

Also, why do we need a new routers folder. Can we use the existing routes folder and add them to the master file

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

@mohammadalfaiyazbitgo
Copy link
Contributor Author

You're converting routes from master and calling them "enclave" spec

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.

};

// API Specification
export const EnclavedExpressApiSpec = apiSpec({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const EnclavedExpressApiSpec = apiSpec({
export const MasterExpressApiSpec = apiSpec({

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo merged commit 6de52b8 into master Jun 9, 2025
3 checks passed
@mohammadalfaiyazbitgo mohammadalfaiyazbitgo deleted the WP-4622/api-ts-mbe branch June 9, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants