feat: implement async accelerate endpoint#245
Conversation
3034d66 to
a919e92
Compare
| import { buildMultisigSignBody, submitMultisigSignJob } from './utils/multisigSignUtils'; | ||
| import { orThrow } from '../../shared/utils'; | ||
|
|
||
| async function handleAccelerateAsync(params: { |
There was a problem hiding this comment.
handleSendMany inlines the prebuild/verify/submit steps, why extract a sub-function here?
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
submitSignedAccelerateToWp and submitSignedMultisigToWp are identical except for the _.pick. A single submitSignedTxToWp(..., { pickWhitelisted?: boolean }) would cover both.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Updated - future PRs, just need to add a line or two to extend now
| throw new BadRequestError('Transaction prebuild failed local validation'); | ||
| } | ||
|
|
||
| return orThrow( |
There was a problem hiding this comment.
null from submitMultisigSignJob can't happen here since this function only runs when async is enabled. orThrow is unnecessary.
There was a problem hiding this comment.
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 } = {}, |
There was a problem hiding this comment.
makeAccelerateTestConfig will need to be copy-pasted into every future asyncified endpoint's test. should live in testUtils.ts as a shared helper.
There was a problem hiding this comment.
Good point, we can reuse this in consolidate etc, will update
| } | ||
| } | ||
| }, | ||
| "202": { |
| * @param message Error message to throw if value is null or undefined | ||
| * @returns | ||
| */ | ||
| export function orThrow<T>(value: T | null | undefined, message: string): T { |
There was a problem hiding this comment.
Why do we need a dedicated file for this short function?
There was a problem hiding this comment.
It's a generic util, can be (and will be) used in other endpoints - stay tuned!
|
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
a919e92 to
6dcdfd7
Compare
accelerate the tx submitted previously to be processed faster on the chain! |
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_HANDLERSis being expanded with the new handler, following the Registry Design Pattern.Ticket: WCN-887
Testing