@getclave/lifi-sdk
Version:
LI.FI Any-to-Any Cross-Chain-Swap SDK
68 lines • 3.15 kB
TypeScript
import type { ChainId, LiFiStep } from '@lifi/types';
import type { Execution, ExecutionStatus, LiFiStepExtended, Process, ProcessStatus, ProcessType } from './types';
export type FindOrCreateProcessProps = {
step: LiFiStepExtended;
type: ProcessType;
chainId?: ChainId;
status?: ProcessStatus;
startedAt?: number;
};
/**
* Manages status updates of a route and provides various functions for tracking processes
* @param {string} routeId The route dd this StatusManger belongs to.
* @returns {StatusManager} An instance of StatusManager.
*/
export declare class StatusManager {
private readonly routeId;
private shouldUpdate;
constructor(routeId: string);
/**
* Initializes the execution object of a Step.
* @param step The current step in execution
* @returns The initialized execution object for this step and a function to update this step
*/
initExecutionObject: (step: LiFiStepExtended) => Execution;
/**
* Updates the execution object of a Step.
* @param step The current step in execution
* @param status The status for the execution
* @param execution Optional. Information about received tokens
* @returns The step with the updated execution object
*/
updateExecution(step: LiFiStepExtended, status: ExecutionStatus, execution?: Partial<Execution>): LiFiStep;
/**
* Finds a process of the specified type in the step's execution
* @param step The step to search in
* @param type The process type to find
* @param status Optional status to update the process with if found
* @returns The found process or undefined if not found
*/
findProcess(step: LiFiStepExtended, type: ProcessType, status?: ProcessStatus): Process | undefined;
/**
* Create and push a new process into the execution.
* @param step The step that should contain the new process.
* @param type Type of the process. Used to identify already existing processes.
* @param chainId Chain Id of the process.
* @param status By default created process is set to the STARTED status. We can override new process with the needed status.
* @returns Returns process.
*/
findOrCreateProcess: ({ step, type, chainId, status, startedAt, }: FindOrCreateProcessProps) => Process;
/**
* Update a process object.
* @param step The step where the process should be updated
* @param type The process type to update
* @param status The status the process gets.
* @param [params] Additional parameters to append to the process.
* @returns The update process
*/
updateProcess: (step: LiFiStepExtended, type: ProcessType, status: ProcessStatus, params?: Partial<Process>) => Process;
/**
* Remove a process from the execution
* @param step The step where the process should be removed from
* @param type The process type to remove
*/
removeProcess: (step: LiFiStepExtended, type: ProcessType) => void;
updateStepInRoute: (step: LiFiStep) => LiFiStep;
allowUpdates(value: boolean): void;
}
//# sourceMappingURL=StatusManager.d.ts.map