Skip to content

feat: implement async accelerate endpoint#245

Merged
pranishnepal merged 1 commit into
masterfrom
accelerate/WCN-887
Jun 17, 2026
Merged

feat: implement async accelerate endpoint#245
pranishnepal merged 1 commit into
masterfrom
accelerate/WCN-887

Conversation

@pranishnepal

Copy link
Copy Markdown
Contributor

What

This PR implements an asynchronous version of the accelerate endpoint so the work can be offloaded to the async job worker in the background.

ASYNC_OPERATIONS_TO_HANDLERS is being expanded with the new handler, following the Registry Design Pattern.

Ticket: WCN-887

Testing

  • Unit + Integ Test

@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

WCN-887

@pranishnepal pranishnepal marked this pull request as ready for review June 17, 2026 14:29
@pranishnepal pranishnepal requested review from a team as code owners June 17, 2026 14:29
@pranavjain97

Copy link
Copy Markdown
Contributor

@claude

@pranavjain97 pranavjain97 self-requested a review June 17, 2026 17:47
@pranishnepal pranishnepal mentioned this pull request Jun 17, 2026
import { buildMultisigSignBody, submitMultisigSignJob } from './utils/multisigSignUtils';
import { orThrow } from '../../shared/utils';

async function handleAccelerateAsync(params: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

handleSendMany inlines the prebuild/verify/submit steps, why extract a sub-function here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, handleSendMany shared common artifacts like signBody; the sync portion there would be one liner so kept it there-- there's more things involved with this one, the func was getting longer, so opted for Separation of Concerns

return (await wallet.submitTransaction(finalTxParams, requestTracer)) as Record<string, unknown>;
}

export async function submitSignedAccelerateToWp(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

submitSignedAccelerateToWp and submitSignedMultisigToWp are identical except for the _.pick. A single submitSignedTxToWp(..., { pickWhitelisted?: boolean }) would cover both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're valid to flag this - i on-purpose didn't abstract this, but now that i'm seeing a patter with another endpoint too, will clean this up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated - future PRs, just need to add a line or two to extend now

throw new BadRequestError('Transaction prebuild failed local validation');
}

return orThrow(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

null from submitMultisigSignJob can't happen here since this function only runs when async is enabled. orThrow is unnecessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's not only for this function though - it's a generic function that covers all invalid returns in general so i feel there's no harm here


function makeAccelerateTestConfig(
advancedWalletManagerUrl: string,
options: { asyncEnabled?: boolean } = {},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

makeAccelerateTestConfig will need to be copy-pasted into every future asyncified endpoint's test. should live in testUtils.ts as a shared helper.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, we can reuse this in consolidate etc, will update

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

Comment thread masterBitgoExpress.json
}
}
},
"202": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Curious, what is this file for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OpenAPI Spec!

Comment thread src/shared/utils.ts
* @param message Error message to throw if value is null or undefined
* @returns
*/
export function orThrow<T>(value: T | null | undefined, message: string): T {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why do we need a dedicated file for this short function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's a generic util, can be (and will be) used in other endpoints - stay tuned!

@vinhkhangtieu

Copy link
Copy Markdown

Curious for context, what does accelerate endpoint do?

This commit implements an asynchronous version of the accelerate
endpoint so the work can be offloaded to the async job worker in
the background.

Ticket: WCN-887
@pranishnepal

Copy link
Copy Markdown
Contributor Author

Curious for context, what does accelerate endpoint do?

accelerate the tx submitted previously to be processed faster on the chain!

@pranishnepal pranishnepal merged commit c8937e0 into master Jun 17, 2026
22 checks passed
@pranishnepal pranishnepal deleted the accelerate/WCN-887 branch June 17, 2026 19:37
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