Skip to content

Commit

Permalink
add enum HandlerType for STATE_ADVANCEMENT_HANDLERS
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharqiewicz committed Jan 3, 2025
1 parent f5c08cd commit 7afd806
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/services/offrampingFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ export type StateTransitionFunction = (
const OFFRAMPING_STATE_LOCAL_STORAGE_KEY = 'offrampingState';
const minutesInMs = (minutes: number) => minutes * 60 * 1000;

const STATE_ADVANCEMENT_HANDLERS: Record<string, Partial<Record<OfframpingPhase, StateTransitionFunction>>> = {
squidrouter: {
enum HandlerType {
SQUIDROUTER = 'squidrouter',
XCM = 'xcm',
}

const STATE_ADVANCEMENT_HANDLERS: Record<HandlerType, Partial<Record<OfframpingPhase, StateTransitionFunction>>> = {
[HandlerType.SQUIDROUTER]: {
prepareTransactions,
squidRouter,
pendulumFundEphemeral,
Expand All @@ -145,7 +150,7 @@ const STATE_ADVANCEMENT_HANDLERS: Record<string, Partial<Record<OfframpingPhase,
stellarOfframp,
stellarCleanup,
},
xcm: {
[HandlerType.XCM]: {
prepareTransactions,
pendulumFundEphemeral,
executeAssetHubXCM,
Expand All @@ -165,10 +170,9 @@ function selectNextStateAdvancementHandler(
phase: OfframpingPhase,
): StateTransitionFunction | undefined {
if (isNetworkEVM(network)) {
return STATE_ADVANCEMENT_HANDLERS['squidrouter'][phase];
} else {
return STATE_ADVANCEMENT_HANDLERS['xcm'][phase];
return STATE_ADVANCEMENT_HANDLERS[HandlerType.SQUIDROUTER][phase];
}
return STATE_ADVANCEMENT_HANDLERS[HandlerType.XCM][phase];
}

export async function constructInitialState({
Expand Down

0 comments on commit 7afd806

Please sign in to comment.