Skip to content

refactor BWS server support methods#4148

Open
tmcollins4 wants to merge 2 commits intobitpay:masterfrom
tmcollins4:bws-organize-server-support
Open

refactor BWS server support methods#4148
tmcollins4 wants to merge 2 commits intobitpay:masterfrom
tmcollins4:bws-organize-server-support

Conversation

@tmcollins4
Copy link
Copy Markdown
Contributor

Description

Refactors WalletService server-support methods out of the large server.ts file into focused helper modules.

Changelog

  • Move advertisement helpers into server/advertisements.ts.
  • Move auth/session/version helpers into server/auth.ts.
  • Move logging helpers into server/logging.ts.
  • Move Moralis helper methods into server/moralis.ts.
  • Move tx note helpers into server/notes.ts.
  • Move notification subscription helpers into server/notifications.ts.
  • Move fiat/service config/cache helpers into server/services.ts.
  • Move upgrade-check constants and logic into server/shared.ts and server/upgrade.ts.
  • Keep WalletService public methods as delegating wrappers to preserve the existing API.

Testing Notes

  • Ran BWS lint and production build.
  • Ran the full BWS test suite.
  • Ran BWC lint and test suite.

Checklist

  • I have read CONTRIBUTING.md and verified that this PR follows the guidelines and requirements outlined in it.

Copy link
Copy Markdown

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

Note

Copilot was unable to run its full agentic suite in this review.

Refactors WalletService server-support logic out of the monolithic server.ts into dedicated helper modules, keeping the public WalletService API as delegating wrappers.

Changes:

  • Extracted upgrade checks, request arg validation, and multiple server support methods into new src/lib/server/*.ts helper modules.
  • Updated WalletService to delegate to these helper modules (auth, logging, notifications, services, moralis, notes, advertisements).
  • Centralized shared helpers/constants (checkRequired, UPGRADES) in server/shared.ts.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/bitcore-wallet-service/src/lib/server/upgrade.ts New module implementing upgrade-path evaluation + logging.
packages/bitcore-wallet-service/src/lib/server/shared.ts New shared helpers/constants (checkRequired, UPGRADES).
packages/bitcore-wallet-service/src/lib/server/services.ts New module for fiat/services/config/cache helpers.
packages/bitcore-wallet-service/src/lib/server/notifications.ts New module for notification + subscription helpers.
packages/bitcore-wallet-service/src/lib/server/notes.ts New module for tx note helpers.
packages/bitcore-wallet-service/src/lib/server/moralis.ts New module for Moralis helper methods.
packages/bitcore-wallet-service/src/lib/server/logging.ts New module for lock + logger helper methods.
packages/bitcore-wallet-service/src/lib/server/auth.ts New module for instance/auth/session/version helpers.
packages/bitcore-wallet-service/src/lib/server/advertisements.ts New module for advertisement helpers.
packages/bitcore-wallet-service/src/lib/server.ts Rewired WalletService to delegate to helper modules; removed inlined implementations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +86 to +88
export function getAllAdverts(service: WalletService, opts, cb: Callback) {
service._runLocked(cb, next => {
service.getAllAdverts(opts, next);
Comment on lines +44 to +55
service._runLocked(
cb,
next => {
checkIfAdvertExistsAlready(opts.adId, (err, advert) => {
if (err) throw err;
if (advert) {
service.storage.storeAdvert(advert, next);
}
});
},
10 * 1000
);
}

export function getServicesData(_service: WalletService, opts, cb: Callback) {
const externalServicesConfig: ExternalServicesConfig = structuredClone(config.services);

const { Utils } = Common;

export function checkRequired(obj, args, cb?: (e: any) => void) {
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.

2 participants