@lifi/sdk 4.0.0-beta.3 → 4.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/cjs/actions/getContractCallsQuote.js +10 -10
  2. package/dist/cjs/actions/getContractCallsQuote.js.map +1 -1
  3. package/dist/cjs/actions/getQuote.js +11 -11
  4. package/dist/cjs/actions/getQuote.js.map +1 -1
  5. package/dist/cjs/actions/getRelayerQuote.js +11 -11
  6. package/dist/cjs/actions/getRelayerQuote.js.map +1 -1
  7. package/dist/cjs/core/BaseStepExecutor.js +52 -53
  8. package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
  9. package/dist/cjs/core/StatusManager.js +116 -133
  10. package/dist/cjs/core/StatusManager.js.map +1 -1
  11. package/dist/cjs/core/TaskPipeline.js +1 -2
  12. package/dist/cjs/core/TaskPipeline.js.map +1 -1
  13. package/dist/cjs/core/storage.js +1 -4
  14. package/dist/cjs/core/storage.js.map +1 -1
  15. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +1 -2
  16. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
  17. package/dist/cjs/errors/SDKError.d.ts +2 -2
  18. package/dist/cjs/errors/SDKError.js +5 -6
  19. package/dist/cjs/errors/SDKError.js.map +1 -1
  20. package/dist/cjs/errors/baseError.d.ts +1 -1
  21. package/dist/cjs/errors/baseError.js +2 -3
  22. package/dist/cjs/errors/baseError.js.map +1 -1
  23. package/dist/cjs/errors/errors.js +1 -2
  24. package/dist/cjs/errors/errors.js.map +1 -1
  25. package/dist/cjs/errors/httpError.js +6 -7
  26. package/dist/cjs/errors/httpError.js.map +1 -1
  27. package/dist/cjs/utils/checkPackageUpdates.js +1 -1
  28. package/dist/cjs/utils/withDedupe.d.ts +1 -1
  29. package/dist/cjs/utils/withDedupe.js +1 -2
  30. package/dist/cjs/utils/withDedupe.js.map +1 -1
  31. package/dist/cjs/version.d.ts +1 -1
  32. package/dist/cjs/version.js +1 -1
  33. package/dist/cjs/version.js.map +1 -1
  34. package/dist/esm/actions/getContractCallsQuote.js +10 -10
  35. package/dist/esm/actions/getContractCallsQuote.js.map +1 -1
  36. package/dist/esm/actions/getQuote.js +11 -11
  37. package/dist/esm/actions/getQuote.js.map +1 -1
  38. package/dist/esm/actions/getRelayerQuote.js +11 -11
  39. package/dist/esm/actions/getRelayerQuote.js.map +1 -1
  40. package/dist/esm/core/BaseStepExecutor.js +52 -53
  41. package/dist/esm/core/BaseStepExecutor.js.map +1 -1
  42. package/dist/esm/core/StatusManager.js +116 -133
  43. package/dist/esm/core/StatusManager.js.map +1 -1
  44. package/dist/esm/core/TaskPipeline.js +1 -2
  45. package/dist/esm/core/TaskPipeline.js.map +1 -1
  46. package/dist/esm/core/storage.js +1 -4
  47. package/dist/esm/core/storage.js.map +1 -1
  48. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +1 -2
  49. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
  50. package/dist/esm/errors/SDKError.d.ts +2 -2
  51. package/dist/esm/errors/SDKError.d.ts.map +1 -1
  52. package/dist/esm/errors/SDKError.js +5 -6
  53. package/dist/esm/errors/SDKError.js.map +1 -1
  54. package/dist/esm/errors/baseError.d.ts +1 -1
  55. package/dist/esm/errors/baseError.d.ts.map +1 -1
  56. package/dist/esm/errors/baseError.js +2 -3
  57. package/dist/esm/errors/baseError.js.map +1 -1
  58. package/dist/esm/errors/errors.js +1 -2
  59. package/dist/esm/errors/errors.js.map +1 -1
  60. package/dist/esm/errors/httpError.js +6 -7
  61. package/dist/esm/errors/httpError.js.map +1 -1
  62. package/dist/esm/utils/checkPackageUpdates.js +1 -1
  63. package/dist/esm/utils/withDedupe.d.ts +1 -1
  64. package/dist/esm/utils/withDedupe.d.ts.map +1 -1
  65. package/dist/esm/utils/withDedupe.js +1 -2
  66. package/dist/esm/utils/withDedupe.js.map +1 -1
  67. package/dist/esm/version.d.ts +1 -1
  68. package/dist/esm/version.js +1 -1
  69. package/dist/esm/version.js.map +1 -1
  70. package/package.json +2 -2
  71. package/src/version.ts +1 -1
  72. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +0 -12
  73. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.js +0 -14
  74. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +0 -9
  75. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.js +0 -16
  76. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +0 -12
  77. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.js +0 -14
  78. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +0 -9
  79. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.js +0 -11
@@ -1,4 +1,3 @@
1
- import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js";
2
1
  import { ExecuteStepRetryError } from "../errors/errors.js";
3
2
  import { StatusManager } from "./StatusManager.js";
4
3
  //#region src/core/BaseStepExecutor.ts
@@ -8,62 +7,62 @@ const defaultInteractionSettings = {
8
7
  allowExecution: true
9
8
  };
10
9
  var BaseStepExecutor = class {
10
+ executionOptions;
11
+ statusManager;
12
+ allowUserInteraction = true;
13
+ allowExecution = true;
11
14
  constructor(options) {
12
- _defineProperty(this, "executionOptions", void 0);
13
- _defineProperty(this, "statusManager", void 0);
14
- _defineProperty(this, "allowUserInteraction", true);
15
- _defineProperty(this, "allowExecution", true);
16
- _defineProperty(this, "setInteraction", (settings) => {
17
- const interactionSettings = {
18
- ...defaultInteractionSettings,
19
- ...settings
20
- };
21
- this.allowUserInteraction = interactionSettings.allowInteraction;
22
- this.statusManager.allowUpdates(interactionSettings.allowUpdates);
23
- this.allowExecution = interactionSettings.allowExecution;
24
- });
25
- _defineProperty(this, "createBaseContext", async (client, step, retryParams) => {
26
- const fromChain = await client.getChainById(step.action.fromChainId);
27
- const toChain = await client.getChainById(step.action.toChainId);
28
- return {
29
- client,
30
- step,
31
- fromChain,
32
- toChain,
33
- isBridgeExecution: fromChain.id !== toChain.id,
34
- retryParams,
35
- statusManager: this.statusManager,
36
- executionOptions: this.executionOptions,
37
- allowUserInteraction: this.allowUserInteraction
38
- };
39
- });
40
- _defineProperty(this, "executeStep", async (client, step, retryParams) => {
41
- try {
42
- step.execution = this.statusManager.initializeExecution(step);
43
- const baseContext = await this.createBaseContext(client, step, retryParams);
44
- const context = await this.createContext(baseContext);
45
- await this.createPipeline(context).run(context);
46
- return step;
47
- } catch (error) {
48
- const action = step.execution?.actions?.at(-1);
49
- const parsed = await this.parseErrors(error, step, action, retryParams);
50
- if (!(parsed instanceof ExecuteStepRetryError)) if (action) this.statusManager.updateAction(step, action.type, "FAILED", { error: {
51
- message: parsed.cause?.message,
52
- code: parsed.code
53
- } });
54
- else this.statusManager.updateExecution(step, {
55
- status: "FAILED",
56
- error: {
57
- message: parsed.cause?.message,
58
- code: parsed.code
59
- }
60
- });
61
- throw parsed;
62
- }
63
- });
64
15
  this.statusManager = new StatusManager(options.routeId);
65
16
  this.executionOptions = options.executionOptions;
66
17
  }
18
+ setInteraction = (settings) => {
19
+ const interactionSettings = {
20
+ ...defaultInteractionSettings,
21
+ ...settings
22
+ };
23
+ this.allowUserInteraction = interactionSettings.allowInteraction;
24
+ this.statusManager.allowUpdates(interactionSettings.allowUpdates);
25
+ this.allowExecution = interactionSettings.allowExecution;
26
+ };
27
+ createBaseContext = async (client, step, retryParams) => {
28
+ const fromChain = await client.getChainById(step.action.fromChainId);
29
+ const toChain = await client.getChainById(step.action.toChainId);
30
+ return {
31
+ client,
32
+ step,
33
+ fromChain,
34
+ toChain,
35
+ isBridgeExecution: fromChain.id !== toChain.id,
36
+ retryParams,
37
+ statusManager: this.statusManager,
38
+ executionOptions: this.executionOptions,
39
+ allowUserInteraction: this.allowUserInteraction
40
+ };
41
+ };
42
+ executeStep = async (client, step, retryParams) => {
43
+ try {
44
+ step.execution = this.statusManager.initializeExecution(step);
45
+ const baseContext = await this.createBaseContext(client, step, retryParams);
46
+ const context = await this.createContext(baseContext);
47
+ await this.createPipeline(context).run(context);
48
+ return step;
49
+ } catch (error) {
50
+ const action = step.execution?.actions?.at(-1);
51
+ const parsed = await this.parseErrors(error, step, action, retryParams);
52
+ if (!(parsed instanceof ExecuteStepRetryError)) if (action) this.statusManager.updateAction(step, action.type, "FAILED", { error: {
53
+ message: parsed.cause?.message,
54
+ code: parsed.code
55
+ } });
56
+ else this.statusManager.updateExecution(step, {
57
+ status: "FAILED",
58
+ error: {
59
+ message: parsed.cause?.message,
60
+ code: parsed.code
61
+ }
62
+ });
63
+ throw parsed;
64
+ }
65
+ };
67
66
  };
68
67
  //#endregion
69
68
  export { BaseStepExecutor };
@@ -1 +1 @@
1
- {"version":3,"file":"BaseStepExecutor.js","names":[],"sources":["../../../src/core/BaseStepExecutor.ts"],"sourcesContent":["import { ExecuteStepRetryError } from '../errors/errors.js'\nimport type { SDKError } from '../errors/SDKError.js'\nimport type {\n ExecuteStepRetryParams,\n ExecutionAction,\n ExecutionOptions,\n InteractionSettings,\n LiFiStepExtended,\n SDKClient,\n StepExecutor,\n StepExecutorOptions,\n} from '../types/core.js'\nimport type {\n StepExecutorBaseContext,\n StepExecutorContext,\n} from '../types/execution.js'\nimport { StatusManager } from './StatusManager.js'\nimport type { TaskPipeline } from './TaskPipeline.js'\n\n// Please be careful when changing the defaults as it may break the behavior (e.g., background execution)\nconst defaultInteractionSettings = {\n allowInteraction: true,\n allowUpdates: true,\n allowExecution: true,\n}\n\nexport abstract class BaseStepExecutor implements StepExecutor {\n protected executionOptions?: ExecutionOptions\n protected statusManager: StatusManager\n\n public allowUserInteraction = true\n public allowExecution = true\n\n constructor(options: StepExecutorOptions) {\n this.statusManager = new StatusManager(options.routeId)\n this.executionOptions = options.executionOptions\n }\n\n setInteraction = (settings?: InteractionSettings): void => {\n const interactionSettings = {\n ...defaultInteractionSettings,\n ...settings,\n }\n this.allowUserInteraction = interactionSettings.allowInteraction\n this.statusManager.allowUpdates(interactionSettings.allowUpdates)\n this.allowExecution = interactionSettings.allowExecution\n }\n\n private createBaseContext = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams\n ): Promise<StepExecutorBaseContext> => {\n const fromChain = await client.getChainById(step.action.fromChainId)\n const toChain = await client.getChainById(step.action.toChainId)\n\n const isBridgeExecution = fromChain.id !== toChain.id\n\n return {\n client,\n step,\n fromChain,\n toChain,\n isBridgeExecution,\n retryParams,\n statusManager: this.statusManager,\n executionOptions: this.executionOptions,\n allowUserInteraction: this.allowUserInteraction,\n }\n }\n\n abstract createContext(\n baseContext: StepExecutorBaseContext\n ): Promise<StepExecutorContext>\n\n abstract createPipeline(context: StepExecutorContext): TaskPipeline\n\n abstract parseErrors(\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n ): Promise<SDKError | ExecuteStepRetryError>\n\n executeStep = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams\n ): Promise<LiFiStepExtended> => {\n try {\n step.execution = this.statusManager.initializeExecution(step)\n\n const baseContext = await this.createBaseContext(\n client,\n step,\n retryParams\n )\n const context = await this.createContext(baseContext)\n const pipeline = this.createPipeline(context)\n\n await pipeline.run(context)\n\n return step\n } catch (error: any) {\n // Derive failing action from last in execution.actions\n const action = step.execution?.actions?.at(-1)\n const parsed = await this.parseErrors(error, step, action, retryParams)\n if (!(parsed instanceof ExecuteStepRetryError)) {\n if (action) {\n this.statusManager.updateAction(step, action.type, 'FAILED', {\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n })\n } else {\n this.statusManager.updateExecution(step, {\n status: 'FAILED',\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n })\n }\n }\n throw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;KACd,EACF,CAAC;QAEF,MAAK,cAAc,gBAAgB,MAAM;KACvC,QAAQ;KACR,OAAO;MACL,SAAS,OAAO,OAAO;MACvB,MAAM,OAAO;MACd;KACF,CAAC;AAGN,UAAM;;IAET;AA7FC,OAAK,gBAAgB,IAAI,cAAc,QAAQ,QAAQ;AACvD,OAAK,mBAAmB,QAAQ"}
1
+ {"version":3,"file":"BaseStepExecutor.js","names":[],"sources":["../../../src/core/BaseStepExecutor.ts"],"sourcesContent":["import { ExecuteStepRetryError } from '../errors/errors.js'\nimport type { SDKError } from '../errors/SDKError.js'\nimport type {\n ExecuteStepRetryParams,\n ExecutionAction,\n ExecutionOptions,\n InteractionSettings,\n LiFiStepExtended,\n SDKClient,\n StepExecutor,\n StepExecutorOptions,\n} from '../types/core.js'\nimport type {\n StepExecutorBaseContext,\n StepExecutorContext,\n} from '../types/execution.js'\nimport { StatusManager } from './StatusManager.js'\nimport type { TaskPipeline } from './TaskPipeline.js'\n\n// Please be careful when changing the defaults as it may break the behavior (e.g., background execution)\nconst defaultInteractionSettings = {\n allowInteraction: true,\n allowUpdates: true,\n allowExecution: true,\n}\n\nexport abstract class BaseStepExecutor implements StepExecutor {\n protected executionOptions?: ExecutionOptions\n protected statusManager: StatusManager\n\n public allowUserInteraction = true\n public allowExecution = true\n\n constructor(options: StepExecutorOptions) {\n this.statusManager = new StatusManager(options.routeId)\n this.executionOptions = options.executionOptions\n }\n\n setInteraction = (settings?: InteractionSettings): void => {\n const interactionSettings = {\n ...defaultInteractionSettings,\n ...settings,\n }\n this.allowUserInteraction = interactionSettings.allowInteraction\n this.statusManager.allowUpdates(interactionSettings.allowUpdates)\n this.allowExecution = interactionSettings.allowExecution\n }\n\n private createBaseContext = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams\n ): Promise<StepExecutorBaseContext> => {\n const fromChain = await client.getChainById(step.action.fromChainId)\n const toChain = await client.getChainById(step.action.toChainId)\n\n const isBridgeExecution = fromChain.id !== toChain.id\n\n return {\n client,\n step,\n fromChain,\n toChain,\n isBridgeExecution,\n retryParams,\n statusManager: this.statusManager,\n executionOptions: this.executionOptions,\n allowUserInteraction: this.allowUserInteraction,\n }\n }\n\n abstract createContext(\n baseContext: StepExecutorBaseContext\n ): Promise<StepExecutorContext>\n\n abstract createPipeline(context: StepExecutorContext): TaskPipeline\n\n abstract parseErrors(\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n ): Promise<SDKError | ExecuteStepRetryError>\n\n executeStep = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams\n ): Promise<LiFiStepExtended> => {\n try {\n step.execution = this.statusManager.initializeExecution(step)\n\n const baseContext = await this.createBaseContext(\n client,\n step,\n retryParams\n )\n const context = await this.createContext(baseContext)\n const pipeline = this.createPipeline(context)\n\n await pipeline.run(context)\n\n return step\n } catch (error: any) {\n // Derive failing action from last in execution.actions\n const action = step.execution?.actions?.at(-1)\n const parsed = await this.parseErrors(error, step, action, retryParams)\n if (!(parsed instanceof ExecuteStepRetryError)) {\n if (action) {\n this.statusManager.updateAction(step, action.type, 'FAILED', {\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n })\n } else {\n this.statusManager.updateExecution(step, {\n status: 'FAILED',\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n })\n }\n }\n throw parsed\n }\n }\n}\n"],"mappings":";;;AAoBA,MAAM,6BAA6B;CACjC,kBAAkB;CAClB,cAAc;CACd,gBAAgB;CACjB;AAED,IAAsB,mBAAtB,MAA+D;CAC7D;CACA;CAEA,uBAA8B;CAC9B,iBAAwB;CAExB,YAAY,SAA8B;AACxC,OAAK,gBAAgB,IAAI,cAAc,QAAQ,QAAQ;AACvD,OAAK,mBAAmB,QAAQ;;CAGlC,kBAAkB,aAAyC;EACzD,MAAM,sBAAsB;GAC1B,GAAG;GACH,GAAG;GACJ;AACD,OAAK,uBAAuB,oBAAoB;AAChD,OAAK,cAAc,aAAa,oBAAoB,aAAa;AACjE,OAAK,iBAAiB,oBAAoB;;CAG5C,oBAA4B,OAC1B,QACA,MACA,gBACqC;EACrC,MAAM,YAAY,MAAM,OAAO,aAAa,KAAK,OAAO,YAAY;EACpE,MAAM,UAAU,MAAM,OAAO,aAAa,KAAK,OAAO,UAAU;AAIhE,SAAO;GACL;GACA;GACA;GACA;GACA,mBAPwB,UAAU,OAAO,QAAQ;GAQjD;GACA,eAAe,KAAK;GACpB,kBAAkB,KAAK;GACvB,sBAAsB,KAAK;GAC5B;;CAgBH,cAAc,OACZ,QACA,MACA,gBAC8B;AAC9B,MAAI;AACF,QAAK,YAAY,KAAK,cAAc,oBAAoB,KAAK;GAE7D,MAAM,cAAc,MAAM,KAAK,kBAC7B,QACA,MACA,YACD;GACD,MAAM,UAAU,MAAM,KAAK,cAAc,YAAY;AAGrD,SAFiB,KAAK,eAAe,QAAQ,CAE9B,IAAI,QAAQ;AAE3B,UAAO;WACA,OAAY;GAEnB,MAAM,SAAS,KAAK,WAAW,SAAS,GAAG,GAAG;GAC9C,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,QAAQ,YAAY;AACvE,OAAI,EAAE,kBAAkB,uBACtB,KAAI,OACF,MAAK,cAAc,aAAa,MAAM,OAAO,MAAM,UAAU,EAC3D,OAAO;IACL,SAAS,OAAO,OAAO;IACvB,MAAM,OAAO;IACd,EACF,CAAC;OAEF,MAAK,cAAc,gBAAgB,MAAM;IACvC,QAAQ;IACR,OAAO;KACL,SAAS,OAAO,OAAO;KACvB,MAAM,OAAO;KACd;IACF,CAAC;AAGN,SAAM"}
@@ -1,4 +1,3 @@
1
- import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js";
2
1
  import { getActionMessage } from "./actionMessages.js";
3
2
  import { executionState } from "./executionState.js";
4
3
  //#region src/core/StatusManager.ts
@@ -6,142 +5,35 @@ import { executionState } from "./executionState.js";
6
5
  * Manages status updates of a route and provides various functions for tracking actions.
7
6
  */
8
7
  var StatusManager = class {
8
+ routeId;
9
+ shouldUpdate = true;
9
10
  constructor(routeId) {
10
- _defineProperty(this, "routeId", void 0);
11
- _defineProperty(this, "shouldUpdate", true);
12
- _defineProperty(
13
- this,
14
- /**
15
- * Initializes the execution object of a Step.
16
- * @param step The current step in execution
17
- * @returns The initialized execution object for this step
18
- */
19
- "initializeExecution",
20
- (step) => {
21
- if (!step.execution) {
22
- step.execution = {
23
- startedAt: Date.now(),
24
- status: "PENDING",
25
- actions: []
26
- };
27
- this.updateStepInRoute(step);
28
- }
29
- if (step.execution.status === "FAILED") {
30
- step.execution.startedAt = Date.now();
31
- step.execution.status = "PENDING";
32
- step.execution.signedAt = void 0;
33
- step.execution.error = void 0;
34
- this.updateStepInRoute(step);
35
- }
36
- return step.execution;
37
- }
38
- );
39
- _defineProperty(
40
- this,
41
- /**
42
- * Create and push a new action into the execution.
43
- * Caller is responsible for ensuring an action of this type does not already exist.
44
- * @param step The step that should contain the new action.
45
- * @param type Type of the action.
46
- * @param chainId Chain Id of the action.
47
- * @param status The initial status for the new action.
48
- * @returns The created action.
49
- */
50
- "createAction",
51
- ({ step, type, chainId, status }) => {
52
- if (!step.execution) throw new Error("Execution hasn't been initialized.");
53
- const newAction = {
54
- type,
55
- message: getActionMessage(type, status),
56
- status,
57
- chainId
58
- };
59
- step.execution.actions.push(newAction);
60
- this.updateStepInRoute(step);
61
- return newAction;
62
- }
63
- );
64
- _defineProperty(
65
- this,
66
- /**
67
- * Find an existing action by type and update it, or create a new one if none exists.
68
- * @param step The step that should contain the action.
69
- * @param type Type of the action. Used to identify already existing actions.
70
- * @param chainId Chain Id of the action (used when creating).
71
- * @param status The status to set on the found or newly created action.
72
- * @returns The updated or newly created action.
73
- */
74
- "initializeAction",
75
- ({ step, type, chainId, status }) => {
76
- if (this.findAction(step, type)) return this.updateAction(step, type, status, { error: void 0 });
77
- return this.createAction({
78
- step,
79
- type,
80
- chainId,
81
- status
82
- });
83
- }
84
- );
85
- _defineProperty(
86
- this,
87
- /**
88
- * Update an action object.
89
- * @param step The step where the action should be updated
90
- * @param type The action type to update
91
- * @param status The status the action gets.
92
- * @param [params] Additional parameters to append to the action.
93
- * @returns The updated action
94
- */
95
- "updateAction",
96
- (step, type, status, params) => {
97
- if (!step.execution) throw new Error("Can't update an empty step execution.");
98
- const currentAction = this.findAction(step, type);
99
- if (!currentAction) throw new Error("Can't find an action for the given type.");
100
- switch (status) {
101
- case "CANCELLED": break;
102
- case "FAILED":
103
- step.execution.status = "FAILED";
104
- if (params?.error) step.execution.error = params.error;
105
- break;
106
- case "DONE": break;
107
- case "PENDING":
108
- step.execution.status = "PENDING";
109
- if (params?.signedAt) step.execution.signedAt = params.signedAt;
110
- break;
111
- case "RESET_REQUIRED":
112
- case "MESSAGE_REQUIRED":
113
- case "ACTION_REQUIRED":
114
- step.execution.status = "ACTION_REQUIRED";
115
- break;
116
- default: break;
117
- }
118
- currentAction.status = status;
119
- currentAction.message = getActionMessage(type, status);
120
- if (params) {
121
- const { signedAt: _signedAt, ...rest } = params;
122
- Object.assign(currentAction, rest);
123
- }
124
- step.execution.actions = [...step.execution.actions.filter((action) => action.status === "DONE"), ...step.execution.actions.filter((action) => action.status !== "DONE")];
125
- this.updateStepInRoute(step);
126
- return currentAction;
127
- }
128
- );
129
- _defineProperty(this, "updateStepInRoute", (step) => {
130
- if (!this.shouldUpdate) return step;
131
- const data = executionState.get(this.routeId);
132
- if (!data) throw new Error("Execution data not found.");
133
- const stepIndex = data.route.steps.findIndex((routeStep) => routeStep.id === step.id);
134
- if (stepIndex === -1) throw new Error("Couldn't find a step to update.");
135
- data.route.steps[stepIndex] = {
136
- ...data.route.steps[stepIndex],
137
- ...step
138
- };
139
- data.executionOptions?.updateRouteHook?.(data.route);
140
- return data.route.steps[stepIndex];
141
- });
142
11
  this.routeId = routeId;
143
12
  }
144
13
  /**
14
+ * Initializes the execution object of a Step.
15
+ * @param step The current step in execution
16
+ * @returns The initialized execution object for this step
17
+ */
18
+ initializeExecution = (step) => {
19
+ if (!step.execution) {
20
+ step.execution = {
21
+ startedAt: Date.now(),
22
+ status: "PENDING",
23
+ actions: []
24
+ };
25
+ this.updateStepInRoute(step);
26
+ }
27
+ if (step.execution.status === "FAILED") {
28
+ step.execution.startedAt = Date.now();
29
+ step.execution.status = "PENDING";
30
+ step.execution.signedAt = void 0;
31
+ step.execution.error = void 0;
32
+ this.updateStepInRoute(step);
33
+ }
34
+ return step.execution;
35
+ };
36
+ /**
145
37
  * Updates the execution object of a Step.
146
38
  * @param step The current step in execution
147
39
  * @param execution Partial execution data to merge
@@ -166,6 +58,97 @@ var StatusManager = class {
166
58
  if (!step.execution?.actions) throw new Error("Execution hasn't been initialized.");
167
59
  return step.execution.actions.find((p) => p.type === type);
168
60
  }
61
+ /**
62
+ * Create and push a new action into the execution.
63
+ * Caller is responsible for ensuring an action of this type does not already exist.
64
+ * @param step The step that should contain the new action.
65
+ * @param type Type of the action.
66
+ * @param chainId Chain Id of the action.
67
+ * @param status The initial status for the new action.
68
+ * @returns The created action.
69
+ */
70
+ createAction = ({ step, type, chainId, status }) => {
71
+ if (!step.execution) throw new Error("Execution hasn't been initialized.");
72
+ const newAction = {
73
+ type,
74
+ message: getActionMessage(type, status),
75
+ status,
76
+ chainId
77
+ };
78
+ step.execution.actions.push(newAction);
79
+ this.updateStepInRoute(step);
80
+ return newAction;
81
+ };
82
+ /**
83
+ * Find an existing action by type and update it, or create a new one if none exists.
84
+ * @param step The step that should contain the action.
85
+ * @param type Type of the action. Used to identify already existing actions.
86
+ * @param chainId Chain Id of the action (used when creating).
87
+ * @param status The status to set on the found or newly created action.
88
+ * @returns The updated or newly created action.
89
+ */
90
+ initializeAction = ({ step, type, chainId, status }) => {
91
+ if (this.findAction(step, type)) return this.updateAction(step, type, status, { error: void 0 });
92
+ return this.createAction({
93
+ step,
94
+ type,
95
+ chainId,
96
+ status
97
+ });
98
+ };
99
+ /**
100
+ * Update an action object.
101
+ * @param step The step where the action should be updated
102
+ * @param type The action type to update
103
+ * @param status The status the action gets.
104
+ * @param [params] Additional parameters to append to the action.
105
+ * @returns The updated action
106
+ */
107
+ updateAction = (step, type, status, params) => {
108
+ if (!step.execution) throw new Error("Can't update an empty step execution.");
109
+ const currentAction = this.findAction(step, type);
110
+ if (!currentAction) throw new Error("Can't find an action for the given type.");
111
+ switch (status) {
112
+ case "CANCELLED": break;
113
+ case "FAILED":
114
+ step.execution.status = "FAILED";
115
+ if (params?.error) step.execution.error = params.error;
116
+ break;
117
+ case "DONE": break;
118
+ case "PENDING":
119
+ step.execution.status = "PENDING";
120
+ if (params?.signedAt) step.execution.signedAt = params.signedAt;
121
+ break;
122
+ case "RESET_REQUIRED":
123
+ case "MESSAGE_REQUIRED":
124
+ case "ACTION_REQUIRED":
125
+ step.execution.status = "ACTION_REQUIRED";
126
+ break;
127
+ default: break;
128
+ }
129
+ currentAction.status = status;
130
+ currentAction.message = getActionMessage(type, status);
131
+ if (params) {
132
+ const { signedAt: _signedAt, ...rest } = params;
133
+ Object.assign(currentAction, rest);
134
+ }
135
+ step.execution.actions = [...step.execution.actions.filter((action) => action.status === "DONE"), ...step.execution.actions.filter((action) => action.status !== "DONE")];
136
+ this.updateStepInRoute(step);
137
+ return currentAction;
138
+ };
139
+ updateStepInRoute = (step) => {
140
+ if (!this.shouldUpdate) return step;
141
+ const data = executionState.get(this.routeId);
142
+ if (!data) throw new Error("Execution data not found.");
143
+ const stepIndex = data.route.steps.findIndex((routeStep) => routeStep.id === step.id);
144
+ if (stepIndex === -1) throw new Error("Couldn't find a step to update.");
145
+ data.route.steps[stepIndex] = {
146
+ ...data.route.steps[stepIndex],
147
+ ...step
148
+ };
149
+ data.executionOptions?.updateRouteHook?.(data.route);
150
+ return data.route.steps[stepIndex];
151
+ };
169
152
  allowUpdates(value) {
170
153
  this.shouldUpdate = value;
171
154
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StatusManager.js","names":[],"sources":["../../../src/core/StatusManager.ts"],"sourcesContent":["import type { ChainId, LiFiStep } from '@lifi/types'\nimport type {\n Execution,\n ExecutionAction,\n ExecutionActionStatus,\n ExecutionActionType,\n LiFiStepExtended,\n} from '../types/core.js'\nimport { getActionMessage } from './actionMessages.js'\nimport { executionState } from './executionState.js'\n\ntype ActionProps = {\n step: LiFiStepExtended\n type: ExecutionActionType\n chainId: ChainId\n status: ExecutionActionStatus\n}\n\n/**\n * Manages status updates of a route and provides various functions for tracking actions.\n */\nexport class StatusManager {\n private readonly routeId: string\n private shouldUpdate = true\n\n constructor(routeId: string) {\n this.routeId = routeId\n }\n\n /**\n * Initializes the execution object of a Step.\n * @param step The current step in execution\n * @returns The initialized execution object for this step\n */\n initializeExecution = (step: LiFiStepExtended): Execution => {\n if (!step.execution) {\n step.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [],\n }\n this.updateStepInRoute(step)\n }\n\n // Change status to PENDING after resuming from FAILED\n if (step.execution.status === 'FAILED') {\n step.execution.startedAt = Date.now()\n step.execution.status = 'PENDING'\n step.execution.signedAt = undefined\n step.execution.error = undefined\n this.updateStepInRoute(step)\n }\n\n return step.execution\n }\n\n /**\n * Updates the execution object of a Step.\n * @param step The current step in execution\n * @param execution Partial execution data to merge\n * @returns The step with the updated execution object\n */\n updateExecution(\n step: LiFiStepExtended,\n execution: Partial<Execution>\n ): LiFiStep {\n if (!step.execution) {\n throw Error(\"Can't update empty execution.\")\n }\n step.execution = {\n ...step.execution,\n ...execution,\n }\n this.updateStepInRoute(step)\n return step\n }\n\n /**\n * Finds an action of the specified type in the step's execution\n * @param step The step to search in\n * @param type The action type to find\n * @returns The found action or undefined if not found\n */\n findAction(\n step: LiFiStepExtended,\n type: ExecutionActionType\n ): ExecutionAction | undefined {\n if (!step.execution?.actions) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const action = step.execution.actions.find((p) => p.type === type)\n\n return action\n }\n\n /**\n * Create and push a new action into the execution.\n * Caller is responsible for ensuring an action of this type does not already exist.\n * @param step The step that should contain the new action.\n * @param type Type of the action.\n * @param chainId Chain Id of the action.\n * @param status The initial status for the new action.\n * @returns The created action.\n */\n createAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const newAction: ExecutionAction = {\n type,\n message: getActionMessage(type, status),\n status,\n chainId,\n }\n\n step.execution.actions.push(newAction)\n this.updateStepInRoute(step)\n return newAction\n }\n\n /**\n * Find an existing action by type and update it, or create a new one if none exists.\n * @param step The step that should contain the action.\n * @param type Type of the action. Used to identify already existing actions.\n * @param chainId Chain Id of the action (used when creating).\n * @param status The status to set on the found or newly created action.\n * @returns The updated or newly created action.\n */\n initializeAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n const action = this.findAction(step, type)\n\n if (action) {\n return this.updateAction(step, type, status, {\n error: undefined,\n })\n }\n\n return this.createAction({ step, type, chainId, status })\n }\n\n /**\n * Update an action object.\n * @param step The step where the action should be updated\n * @param type The action type to update\n * @param status The status the action gets.\n * @param [params] Additional parameters to append to the action.\n * @returns The updated action\n */\n updateAction = (\n step: LiFiStepExtended,\n type: ExecutionActionType,\n status: ExecutionActionStatus,\n params?: Partial<ExecutionAction & { signedAt?: number }>\n ): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Can't update an empty step execution.\")\n }\n const currentAction = this.findAction(step, type)\n\n if (!currentAction) {\n throw new Error(\"Can't find an action for the given type.\")\n }\n\n switch (status) {\n case 'CANCELLED':\n break\n case 'FAILED':\n step.execution.status = 'FAILED'\n if (params?.error) {\n step.execution.error = params.error\n }\n break\n case 'DONE':\n break\n case 'PENDING':\n step.execution.status = 'PENDING'\n if (params?.signedAt) {\n step.execution.signedAt = params.signedAt\n }\n break\n case 'RESET_REQUIRED':\n case 'MESSAGE_REQUIRED':\n case 'ACTION_REQUIRED':\n step.execution.status = 'ACTION_REQUIRED'\n break\n default:\n break\n }\n\n currentAction.status = status\n currentAction.message = getActionMessage(type, status)\n // set extra parameters or overwrite the standard params set in the switch statement\n if (params) {\n const { signedAt: _signedAt, ...rest } = params\n Object.assign(currentAction, rest)\n }\n // Sort actions, the ones with DONE status go first\n step.execution.actions = [\n ...step.execution.actions.filter((action) => action.status === 'DONE'),\n ...step.execution.actions.filter((action) => action.status !== 'DONE'),\n ]\n this.updateStepInRoute(step) // updates the step in the route\n return currentAction\n }\n\n updateStepInRoute = (step: LiFiStep): LiFiStep => {\n if (!this.shouldUpdate) {\n return step\n }\n const data = executionState.get(this.routeId)\n\n if (!data) {\n throw new Error('Execution data not found.')\n }\n\n const stepIndex = data.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n\n if (stepIndex === -1) {\n throw new Error(\"Couldn't find a step to update.\")\n }\n\n data.route.steps[stepIndex] = { ...data.route.steps[stepIndex], ...step }\n\n data.executionOptions?.updateRouteHook?.(data.route)\n return data.route.steps[stepIndex]\n }\n\n allowUpdates(value: boolean): void {\n this.shouldUpdate = value\n }\n}\n"],"mappings":";;;;;;;AAqBA,IAAa,gBAAb,MAA2B;CAIzB,YAAY,SAAiB;wBAHZ,WAAA,KAAA,EAAe;wBACxB,gBAAe,KAAI;;;;;;;;GAW3B;IAAuB,SAAsC;AAC3D,QAAI,CAAC,KAAK,WAAW;AACnB,UAAK,YAAY;MACf,WAAW,KAAK,KAAK;MACrB,QAAQ;MACR,SAAS,EAAE;MACZ;AACD,UAAK,kBAAkB,KAAK;;AAI9B,QAAI,KAAK,UAAU,WAAW,UAAU;AACtC,UAAK,UAAU,YAAY,KAAK,KAAK;AACrC,UAAK,UAAU,SAAS;AACxB,UAAK,UAAU,WAAW,KAAA;AAC1B,UAAK,UAAU,QAAQ,KAAA;AACvB,UAAK,kBAAkB,KAAK;;AAG9B,WAAO,KAAK;;GACb;;;;;;;;;;;;GAmDD;IAAgB,EACd,MACA,MACA,SACA,aACkC;AAClC,QAAI,CAAC,KAAK,UACR,OAAM,IAAI,M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AK;AAC5B,WAAO;;GACR;wBAED,sBAAqB,SAA6B;AAChD,OAAI,CAAC,KAAK,aACR,QAAO;GAET,MAAM,OAAO,eAAe,IAAI,KAAK,QAAQ;AAE7C,OAAI,CAAC,KACH,OAAM,IAAI,MAAM,4BAA4B;GAG9C,MAAM,YAAY,KAAK,MAAM,MAAM,WAChC,cAAc,UAAU,OAAO,KAAK,GACtC;AAED,OAAI,cAAc,GAChB,OAAM,IAAI,MAAM,kCAAkC;AAGpD,QAAK,MAAM,MAAM,aAAa;IAAE,GAAG,KAAK,MAAM,MAAM;IAAY,GAAG;IAAM;AAEzE,QAAK,kBAAkB,kBAAkB,KAAK,MAAM;AACpD,UAAO,KAAK,MAAM,MAAM;IACzB;AArNC,OAAK,UAAU;;;;;;;;CAoCjB,gBACE,MACA,WACU;AACV,MAAI,CAAC,KAAK,UACR,OAAM,MAAM,gCAAgC;AAE9C,OAAK,YAAY;GACf,GAAG,KAAK;GACR,GAAG;GACJ;AACD,OAAK,kBAAkB,KAAK;AAC5B,SAAO;;;;;;;;CAST,WACE,MACA,MAC6B;AAC7B,MAAI,CAAC,KAAK,WAAW,QACnB,OAAM,IAAI,MAAM,qCAAqC;AAKvD,SAFe,KAAK,UAAU,QAAQ,MAAM,MAAM,EAAE,SAAS,KAAK;;CAsJpE,aAAa,OAAsB;AACjC,OAAK,eAAe"}
1
+ {"version":3,"file":"StatusManager.js","names":[],"sources":["../../../src/core/StatusManager.ts"],"sourcesContent":["import type { ChainId, LiFiStep } from '@lifi/types'\nimport type {\n Execution,\n ExecutionAction,\n ExecutionActionStatus,\n ExecutionActionType,\n LiFiStepExtended,\n} from '../types/core.js'\nimport { getActionMessage } from './actionMessages.js'\nimport { executionState } from './executionState.js'\n\ntype ActionProps = {\n step: LiFiStepExtended\n type: ExecutionActionType\n chainId: ChainId\n status: ExecutionActionStatus\n}\n\n/**\n * Manages status updates of a route and provides various functions for tracking actions.\n */\nexport class StatusManager {\n private readonly routeId: string\n private shouldUpdate = true\n\n constructor(routeId: string) {\n this.routeId = routeId\n }\n\n /**\n * Initializes the execution object of a Step.\n * @param step The current step in execution\n * @returns The initialized execution object for this step\n */\n initializeExecution = (step: LiFiStepExtended): Execution => {\n if (!step.execution) {\n step.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [],\n }\n this.updateStepInRoute(step)\n }\n\n // Change status to PENDING after resuming from FAILED\n if (step.execution.status === 'FAILED') {\n step.execution.startedAt = Date.now()\n step.execution.status = 'PENDING'\n step.execution.signedAt = undefined\n step.execution.error = undefined\n this.updateStepInRoute(step)\n }\n\n return step.execution\n }\n\n /**\n * Updates the execution object of a Step.\n * @param step The current step in execution\n * @param execution Partial execution data to merge\n * @returns The step with the updated execution object\n */\n updateExecution(\n step: LiFiStepExtended,\n execution: Partial<Execution>\n ): LiFiStep {\n if (!step.execution) {\n throw Error(\"Can't update empty execution.\")\n }\n step.execution = {\n ...step.execution,\n ...execution,\n }\n this.updateStepInRoute(step)\n return step\n }\n\n /**\n * Finds an action of the specified type in the step's execution\n * @param step The step to search in\n * @param type The action type to find\n * @returns The found action or undefined if not found\n */\n findAction(\n step: LiFiStepExtended,\n type: ExecutionActionType\n ): ExecutionAction | undefined {\n if (!step.execution?.actions) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const action = step.execution.actions.find((p) => p.type === type)\n\n return action\n }\n\n /**\n * Create and push a new action into the execution.\n * Caller is responsible for ensuring an action of this type does not already exist.\n * @param step The step that should contain the new action.\n * @param type Type of the action.\n * @param chainId Chain Id of the action.\n * @param status The initial status for the new action.\n * @returns The created action.\n */\n createAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const newAction: ExecutionAction = {\n type,\n message: getActionMessage(type, status),\n status,\n chainId,\n }\n\n step.execution.actions.push(newAction)\n this.updateStepInRoute(step)\n return newAction\n }\n\n /**\n * Find an existing action by type and update it, or create a new one if none exists.\n * @param step The step that should contain the action.\n * @param type Type of the action. Used to identify already existing actions.\n * @param chainId Chain Id of the action (used when creating).\n * @param status The status to set on the found or newly created action.\n * @returns The updated or newly created action.\n */\n initializeAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n const action = this.findAction(step, type)\n\n if (action) {\n return this.updateAction(step, type, status, {\n error: undefined,\n })\n }\n\n return this.createAction({ step, type, chainId, status })\n }\n\n /**\n * Update an action object.\n * @param step The step where the action should be updated\n * @param type The action type to update\n * @param status The status the action gets.\n * @param [params] Additional parameters to append to the action.\n * @returns The updated action\n */\n updateAction = (\n step: LiFiStepExtended,\n type: ExecutionActionType,\n status: ExecutionActionStatus,\n params?: Partial<ExecutionAction & { signedAt?: number }>\n ): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Can't update an empty step execution.\")\n }\n const currentAction = this.findAction(step, type)\n\n if (!currentAction) {\n throw new Error(\"Can't find an action for the given type.\")\n }\n\n switch (status) {\n case 'CANCELLED':\n break\n case 'FAILED':\n step.execution.status = 'FAILED'\n if (params?.error) {\n step.execution.error = params.error\n }\n break\n case 'DONE':\n break\n case 'PENDING':\n step.execution.status = 'PENDING'\n if (params?.signedAt) {\n step.execution.signedAt = params.signedAt\n }\n break\n case 'RESET_REQUIRED':\n case 'MESSAGE_REQUIRED':\n case 'ACTION_REQUIRED':\n step.execution.status = 'ACTION_REQUIRED'\n break\n default:\n break\n }\n\n currentAction.status = status\n currentAction.message = getActionMessage(type, status)\n // set extra parameters or overwrite the standard params set in the switch statement\n if (params) {\n const { signedAt: _signedAt, ...rest } = params\n Object.assign(currentAction, rest)\n }\n // Sort actions, the ones with DONE status go first\n step.execution.actions = [\n ...step.execution.actions.filter((action) => action.status === 'DONE'),\n ...step.execution.actions.filter((action) => action.status !== 'DONE'),\n ]\n this.updateStepInRoute(step) // updates the step in the route\n return currentAction\n }\n\n updateStepInRoute = (step: LiFiStep): LiFiStep => {\n if (!this.shouldUpdate) {\n return step\n }\n const data = executionState.get(this.routeId)\n\n if (!data) {\n throw new Error('Execution data not found.')\n }\n\n const stepIndex = data.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n\n if (stepIndex === -1) {\n throw new Error(\"Couldn't find a step to update.\")\n }\n\n data.route.steps[stepIndex] = { ...data.route.steps[stepIndex], ...step }\n\n data.executionOptions?.updateRouteHook?.(data.route)\n return data.route.steps[stepIndex]\n }\n\n allowUpdates(value: boolean): void {\n this.shouldUpdate = value\n }\n}\n"],"mappings":";;;;;;AAqBA,IAAa,gBAAb,MAA2B;CACzB;CACA,eAAuB;CAEvB,YAAY,SAAiB;AAC3B,OAAK,UAAU;;;;;;;CAQjB,uBAAuB,SAAsC;AAC3D,MAAI,CAAC,KAAK,WAAW;AACnB,QAAK,YAAY;IACf,WAAW,KAAK,KAAK;IACrB,QAAQ;IACR,SAAS,EAAE;IACZ;AACD,QAAK,kBAAkB,KAAK;;AAI9B,MAAI,KAAK,UAAU,WAAW,UAAU;AACtC,QAAK,UAAU,YAAY,KAAK,KAAK;AACrC,QAAK,UAAU,SAAS;AACxB,QAAK,UAAU,WAAW,KAAA;AAC1B,QAAK,UAAU,QAAQ,KAAA;AACvB,QAAK,kBAAkB,KAAK;;AAG9B,SAAO,KAAK;;;;;;;;CASd,gBACE,MACA,WACU;AACV,MAAI,CAAC,KAAK,UACR,OAAM,MAAM,gCAAgC;AAE9C,OAAK,YAAY;GACf,GAAG,KAAK;GACR,GAAG;GACJ;AACD,OAAK,kBAAkB,KAAK;AAC5B,SAAO;;;;;;;;CAST,WACE,MACA,MAC6B;AAC7B,MAAI,CAAC,KAAK,WAAW,QACnB,OAAM,IAAI,MAAM,qCAAqC;AAKvD,SAFe,KAAK,UAAU,QAAQ,MAAM,MAAM,EAAE,SAAS,KAAK;;;;;;;;;;;CAcpE,gBAAgB,EACd,MACA,MACA,SACA,aACkC;AAClC,MAAI,CAAC,KAAK,UACR,OAAM,IAAI,MAAM,qCAAqC;EAGvD,MAAM,YAA6B;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AAI,CAAC,KAAK,aACR,QAAO;EAET,MAAM,OAAO,eAAe,IAAI,KAAK,QAAQ;AAE7C,MAAI,CAAC,KACH,OAAM,IAAI,MAAM,4BAA4B;EAG9C,MAAM,YAAY,KAAK,MAAM,MAAM,WAChC,cAAc,UAAU,OAAO,KAAK,GACtC;AAED,MAAI,cAAc,GAChB,OAAM,IAAI,MAAM,kCAAkC;AAGpD,OAAK,MAAM,MAAM,aAAa;GAAE,GAAG,KAAK,MAAM,MAAM;GAAY,GAAG;GAAM;AAEzE,OAAK,kBAAkB,kBAAkB,KAAK,MAAM;AACpD,SAAO,KAAK,MAAM,MAAM;;CAG1B,aAAa,OAAsB;AACjC,OAAK,eAAe"}
@@ -1,8 +1,7 @@
1
- import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js";
2
1
  //#region src/core/TaskPipeline.ts
3
2
  var TaskPipeline = class {
3
+ tasks;
4
4
  constructor(tasks) {
5
- _defineProperty(this, "tasks", void 0);
6
5
  this.tasks = tasks;
7
6
  }
8
7
  async run(context) {
@@ -1 +1 @@
1
- {"version":3,"file":"TaskPipeline.js","names":[],"sources":["../../../src/core/TaskPipeline.ts"],"sourcesContent":["import type { StepExecutorContext, TaskResult } from '../types/execution.js'\nimport type { BaseStepExecutionTask } from './BaseStepExecutionTask.js'\n\nexport class TaskPipeline {\n private readonly tasks: BaseStepExecutionTask[]\n\n constructor(tasks: BaseStepExecutionTask[]) {\n this.tasks = tasks\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n for (const task of this.tasks) {\n const shouldRun = await task.shouldRun(context)\n if (!shouldRun) {\n continue\n }\n const result = await task.run(context)\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n if (result.context && typeof result.context === 'object') {\n Object.assign(context, result.context)\n }\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;AAGA,IAAa,eAAb,MAA0B;CAGxB,YAAY,OAAgC;wBAF3B,SAAA,KAAA,EAA8B;AAG7C,OAAK,QAAQ;;CAGf,MAAM,IAAI,SAAmD;AAC3D,OAAK,MAAM,QAAQ,KAAK,OAAO;AAE7B,OAAI,CADc,MAAM,KAAK,UAAU,QAAQ,CAE7C;GAEF,MAAM,SAAS,MAAM,KAAK,IAAI,QAAQ;AACtC,OAAI,OAAO,WAAW,SACpB,QAAO,EAAE,QAAQ,UAAU;AAE7B,OAAI,OAAO,WAAW,OAAO,OAAO,YAAY,SAC9C,QAAO,OAAO,SAAS,OAAO,QAAQ;;AAI1C,SAAO,EAAE,QAAQ,aAAa"}
1
+ {"version":3,"file":"TaskPipeline.js","names":[],"sources":["../../../src/core/TaskPipeline.ts"],"sourcesContent":["import type { StepExecutorContext, TaskResult } from '../types/execution.js'\nimport type { BaseStepExecutionTask } from './BaseStepExecutionTask.js'\n\nexport class TaskPipeline {\n private readonly tasks: BaseStepExecutionTask[]\n\n constructor(tasks: BaseStepExecutionTask[]) {\n this.tasks = tasks\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n for (const task of this.tasks) {\n const shouldRun = await task.shouldRun(context)\n if (!shouldRun) {\n continue\n }\n const result = await task.run(context)\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n if (result.context && typeof result.context === 'object') {\n Object.assign(context, result.context)\n }\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";AAGA,IAAa,eAAb,MAA0B;CACxB;CAEA,YAAY,OAAgC;AAC1C,OAAK,QAAQ;;CAGf,MAAM,IAAI,SAAmD;AAC3D,OAAK,MAAM,QAAQ,KAAK,OAAO;AAE7B,OAAI,CADc,MAAM,KAAK,UAAU,QAAQ,CAE7C;GAEF,MAAM,SAAS,MAAM,KAAK,IAAI,QAAQ;AACtC,OAAI,OAAO,WAAW,SACpB,QAAO,EAAE,QAAQ,UAAU;AAE7B,OAAI,OAAO,WAAW,OAAO,OAAO,YAAY,SAC9C,QAAO,OAAO,SAAS,OAAO,QAAQ;;AAI1C,SAAO,EAAE,QAAQ,aAAa"}
@@ -1,4 +1,3 @@
1
- import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js";
2
1
  //#region src/core/storage.ts
3
2
  var LocalStorageAdapter = class {
4
3
  get(key) {
@@ -12,9 +11,7 @@ var LocalStorageAdapter = class {
12
11
  }
13
12
  };
14
13
  var InMemoryStorage = class {
15
- constructor() {
16
- _defineProperty(this, "store", /* @__PURE__ */ new Map());
17
- }
14
+ store = /* @__PURE__ */ new Map();
18
15
  get(key) {
19
16
  return this.store.get(key) ?? null;
20
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","names":[],"sources":["../../../src/core/storage.ts"],"sourcesContent":["export interface SDKStorage {\n get(key: string): string | null | Promise<string | null>\n set(key: string, value: string): void | Promise<void>\n remove(key: string): void | Promise<void>\n}\n\nexport class LocalStorageAdapter implements SDKStorage {\n get(key: string): string | null {\n return window.localStorage.getItem(key)\n }\n\n set(key: string, value: string): void {\n window.localStorage.setItem(key, value)\n }\n\n remove(key: string): void {\n window.localStorage.removeItem(key)\n }\n}\n\nexport class InMemoryStorage implements SDKStorage {\n private store = new Map<string, string>()\n\n get(key: string): string | null {\n return this.store.get(key) ?? null\n }\n\n set(key: string, value: string): void {\n this.store.set(key, value)\n }\n\n remove(key: string): void {\n this.store.delete(key)\n }\n}\n\nexport function createDefaultStorage(): SDKStorage {\n if (typeof window !== 'undefined' && window.localStorage) {\n return new LocalStorageAdapter()\n }\n return new InMemoryStorage()\n}\n"],"mappings":";;AAMA,IAAa,sBAAb,MAAuD;CACrD,IAAI,KAA4B;AAC9B,SAAO,OAAO,aAAa,QAAQ,IAAI;;CAGzC,IAAI,KAAa,OAAqB;AACpC,SAAO,aAAa,QAAQ,KAAK,MAAM;;CAGzC,OAAO,KAAmB;AACxB,SAAO,aAAa,WAAW,IAAI;;;AAIvC,IAAa,kBAAb,MAAmD;;wBACzC,yBAAQ,IAAI,KAAqB,CAAA;;CAEzC,IAAI,KAA4B;AAC9B,SAAO,KAAK,MAAM,IAAI,IAAI,IAAI;;CAGhC,IAAI,KAAa,OAAqB;AACpC,OAAK,MAAM,IAAI,KAAK,MAAM;;CAG5B,OAAO,KAAmB;AACxB,OAAK,MAAM,OAAO,IAAI;;;AAI1B,SAAgB,uBAAmC;AACjD,KAAI,OAAO,WAAW,eAAe,OAAO,aAC1C,QAAO,IAAI,qBAAqB;AAElC,QAAO,IAAI,iBAAiB"}
1
+ {"version":3,"file":"storage.js","names":[],"sources":["../../../src/core/storage.ts"],"sourcesContent":["export interface SDKStorage {\n get(key: string): string | null | Promise<string | null>\n set(key: string, value: string): void | Promise<void>\n remove(key: string): void | Promise<void>\n}\n\nexport class LocalStorageAdapter implements SDKStorage {\n get(key: string): string | null {\n return window.localStorage.getItem(key)\n }\n\n set(key: string, value: string): void {\n window.localStorage.setItem(key, value)\n }\n\n remove(key: string): void {\n window.localStorage.removeItem(key)\n }\n}\n\nexport class InMemoryStorage implements SDKStorage {\n private store = new Map<string, string>()\n\n get(key: string): string | null {\n return this.store.get(key) ?? null\n }\n\n set(key: string, value: string): void {\n this.store.set(key, value)\n }\n\n remove(key: string): void {\n this.store.delete(key)\n }\n}\n\nexport function createDefaultStorage(): SDKStorage {\n if (typeof window !== 'undefined' && window.localStorage) {\n return new LocalStorageAdapter()\n }\n return new InMemoryStorage()\n}\n"],"mappings":";AAMA,IAAa,sBAAb,MAAuD;CACrD,IAAI,KAA4B;AAC9B,SAAO,OAAO,aAAa,QAAQ,IAAI;;CAGzC,IAAI,KAAa,OAAqB;AACpC,SAAO,aAAa,QAAQ,KAAK,MAAM;;CAGzC,OAAO,KAAmB;AACxB,SAAO,aAAa,WAAW,IAAI;;;AAIvC,IAAa,kBAAb,MAAmD;CACjD,wBAAgB,IAAI,KAAqB;CAEzC,IAAI,KAA4B;AAC9B,SAAO,KAAK,MAAM,IAAI,IAAI,IAAI;;CAGhC,IAAI,KAAa,OAAqB;AACpC,OAAK,MAAM,IAAI,KAAK,MAAM;;CAG5B,OAAO,KAAmB;AACxB,OAAK,MAAM,OAAO,IAAI;;;AAI1B,SAAgB,uBAAmC;AACjD,KAAI,OAAO,WAAW,eAAe,OAAO,aAC1C,QAAO,IAAI,qBAAqB;AAElC,QAAO,IAAI,iBAAiB"}
@@ -1,4 +1,3 @@
1
- import { _defineProperty } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js";
2
1
  import { LiFiErrorCode } from "../../errors/constants.js";
3
2
  import { TransactionError } from "../../errors/errors.js";
4
3
  import { BaseStepExecutionTask } from "../BaseStepExecutionTask.js";
@@ -6,9 +5,9 @@ import { getTransactionFailedMessage } from "../../utils/getTransactionMessage.j
6
5
  import { waitForTransactionStatus } from "./helpers/waitForTransactionStatus.js";
7
6
  //#region src/core/tasks/WaitForTransactionStatusTask.ts
8
7
  var WaitForTransactionStatusTask = class extends BaseStepExecutionTask {
8
+ actionType;
9
9
  constructor(actionType) {
10
10
  super();
11
- _defineProperty(this, "actionType", void 0);
12
11
  this.actionType = actionType;
13
12
  }
14
13
  async run(context) {
@@ -1 +1 @@
1
- {"version":3,"file":"WaitForTransactionStatusTask.js","names":[],"sources":["../../../../src/core/tasks/WaitForTransactionStatusTask.ts"],"sourcesContent":["import type { ExtendedTransactionInfo, FullStatusData } from '@lifi/types'\nimport { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { ExecutionActionType } from '../../types/core.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { getTransactionFailedMessage } from '../../utils/getTransactionMessage.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport { waitForTransactionStatus } from './helpers/waitForTransactionStatus.js'\n\nexport class WaitForTransactionStatusTask extends BaseStepExecutionTask {\n readonly actionType: ExecutionActionType\n\n constructor(actionType: ExecutionActionType) {\n super()\n this.actionType = actionType\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const {\n client,\n step,\n statusManager,\n pollingIntervalMs,\n toChain,\n isBridgeExecution,\n } = context\n\n // At this point, we should have a txHash or taskId\n // taskId is used for custom integrations that don't use the standard transaction hash\n let transactionHash: string | undefined\n try {\n const swapOrBridgeAction = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n transactionHash = swapOrBridgeAction?.txHash || swapOrBridgeAction?.taskId\n\n // Wait for the transaction status on the destination chain\n if (!transactionHash) {\n throw new Error('Transaction hash is undefined.')\n }\n\n const action = statusManager.initializeAction({\n step,\n type: this.actionType,\n chainId:\n this.actionType === 'RECEIVING_CHAIN'\n ? step.action.toChainId\n : step.action.fromChainId,\n status: 'PENDING',\n })\n\n const statusResponse = (await waitForTransactionStatus(\n client,\n statusManager,\n transactionHash,\n step,\n action.type,\n pollingIntervalMs\n )) as FullStatusData\n\n const statusReceiving =\n statusResponse.receiving as ExtendedTransactionInfo\n\n // Update action status\n statusManager.updateAction(step, action.type, 'DONE', {\n chainId: statusReceiving?.chainId || toChain.id,\n substatus: statusResponse.substatus,\n substatusMessage: statusResponse.substatusMessage,\n txHash: statusReceiving?.txHash,\n txLink:\n statusReceiving?.txLink ||\n `${toChain.metamask.blockExplorerUrls[0]}tx/${statusReceiving?.txHash}`,\n })\n\n // Update execution status\n statusManager.updateExecution(step, {\n status: 'DONE',\n ...(statusResponse.sending.amount && {\n fromAmount: statusResponse.sending.amount,\n }),\n ...(statusReceiving?.amount && { toAmount: statusReceiving.amount }),\n ...(statusReceiving?.token && { toToken: statusReceiving.token }),\n internalTxLink: statusResponse?.lifiExplorerLink,\n externalTxLink: statusResponse?.bridgeExplorerLink,\n gasCosts: [\n {\n amount: statusResponse.sending.gasAmount,\n amountUSD: statusResponse.sending.gasAmountUSD,\n token: statusResponse.sending.gasToken,\n estimate: statusResponse.sending.gasUsed,\n limit: statusResponse.sending.gasUsed,\n price: statusResponse.sending.gasPrice,\n type: 'SEND',\n },\n ],\n })\n\n return { status: 'COMPLETED' }\n } catch (e: any) {\n const htmlMessage = await getTransactionFailedMessage(\n client,\n step,\n `${toChain.metamask.blockExplorerUrls[0]}tx/${transactionHash}`\n )\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n htmlMessage ??\n 'Failed while waiting for status of destination chain transaction.',\n e\n )\n }\n }\n}\n"],"mappings":";;;;;;;AASA,IAAa,+BAAb,cAAkD,sBAAsB;CAGtE,YAAY,YAAiC;AAC3C,SAAO;wBAHA,cAAA,KAAA,EAA+B;AAItC,OAAK,aAAa;;CAGpB,MAAM,IAAI,SAAmD;EAC3D,MAAM,EACJ,QACA,MACA,eACA,mBACA,SACA,sBACE;EAIJ,IAAI;AACJ,MAAI;GACF,MAAM,qBAAqB,cAAc,WACvC,MACA,oBAAoB,gBAAgB,OACrC;AACD,qBAAkB,oBAAoB,UAAU,oBAAoB;AAGpE,OAAI,CAAC,gBACH,OAAM,IAAI,MAAM,iCAAiC;GAGnD,MAAM,SAAS,cAAc,iBAAiB;IAC5C;IACA,MAAM,KAAK;IACX,SACE,KAAK,eAAe,oBAChB,KAAK,OAAO,YACZ,KAAK,OAAO;IAClB,QAAQ;IACT,CAAC;GAEF,MAAM,iBAAkB,MAAM,yBAC5B,QACA,eACA,iBACA,MACA,OAAO,MACP,kBACD;GAED,MAAM,kBACJ,eAAe;AAGjB,iBAAc,aAAa,MAAM,OAAO,MAAM,QAAQ;IACpD,SAAS,iBAAiB,WAAW,QAAQ;IAC7C,WAAW,eAAe;IAC1B,kBAAkB,eAAe;IACjC,QAAQ,iBAAiB;IACzB,QACE,iBAAiB,UACjB,GAAG,QAAQ,SAAS,kBAAkB,GAAG,KAAK,iBAAiB;IAClE,CAAC;AAGF,iBAAc,gBAAgB,MAAM;IAClC,QAAQ;IACR,GAAI,eAAe,QAAQ,UAAU,EACnC,YAAY,eAAe,QAAQ,QACpC;IACD,GAAI,iBAAiB,UAAU,EAAE,UAAU,gBAAgB,QAAQ;IACnE,GAAI,iBAAiB,SAAS,EAAE,SAAS,gBAAgB,OAAO;IAChE,gBAAgB,gBAAgB;IAChC,gBAAgB,gBAAgB;IAChC,UAAU,CACR;KACE,QAAQ,eAAe,QAAQ;KAC/B,WAAW,eAAe,QAAQ;KAClC,OAAO,eAAe,QAAQ;KAC9B,UAAU,eAAe,QAAQ;KACjC,OAAO,eAAe,QAAQ;KAC9B,OAAO,eAAe,QAAQ;KAC9B,MAAM;KACP,CACF;IACF,CAAC;AAEF,UAAO,EAAE,QAAQ,aAAa;WACvB,GAAQ;GACf,MAAM,cAAc,MAAM,4BACxB,QACA,MACA,GAAG,QAAQ,SAAS,kBAAkB,GAAG,KAAK,kBAC/C;AACD,SAAM,IAAI,iBACR,cAAc,mBACd,eACE,qEACF,EACD"}
1
+ {"version":3,"file":"WaitForTransactionStatusTask.js","names":[],"sources":["../../../../src/core/tasks/WaitForTransactionStatusTask.ts"],"sourcesContent":["import type { ExtendedTransactionInfo, FullStatusData } from '@lifi/types'\nimport { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { ExecutionActionType } from '../../types/core.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { getTransactionFailedMessage } from '../../utils/getTransactionMessage.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport { waitForTransactionStatus } from './helpers/waitForTransactionStatus.js'\n\nexport class WaitForTransactionStatusTask extends BaseStepExecutionTask {\n readonly actionType: ExecutionActionType\n\n constructor(actionType: ExecutionActionType) {\n super()\n this.actionType = actionType\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const {\n client,\n step,\n statusManager,\n pollingIntervalMs,\n toChain,\n isBridgeExecution,\n } = context\n\n // At this point, we should have a txHash or taskId\n // taskId is used for custom integrations that don't use the standard transaction hash\n let transactionHash: string | undefined\n try {\n const swapOrBridgeAction = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n transactionHash = swapOrBridgeAction?.txHash || swapOrBridgeAction?.taskId\n\n // Wait for the transaction status on the destination chain\n if (!transactionHash) {\n throw new Error('Transaction hash is undefined.')\n }\n\n const action = statusManager.initializeAction({\n step,\n type: this.actionType,\n chainId:\n this.actionType === 'RECEIVING_CHAIN'\n ? step.action.toChainId\n : step.action.fromChainId,\n status: 'PENDING',\n })\n\n const statusResponse = (await waitForTransactionStatus(\n client,\n statusManager,\n transactionHash,\n step,\n action.type,\n pollingIntervalMs\n )) as FullStatusData\n\n const statusReceiving =\n statusResponse.receiving as ExtendedTransactionInfo\n\n // Update action status\n statusManager.updateAction(step, action.type, 'DONE', {\n chainId: statusReceiving?.chainId || toChain.id,\n substatus: statusResponse.substatus,\n substatusMessage: statusResponse.substatusMessage,\n txHash: statusReceiving?.txHash,\n txLink:\n statusReceiving?.txLink ||\n `${toChain.metamask.blockExplorerUrls[0]}tx/${statusReceiving?.txHash}`,\n })\n\n // Update execution status\n statusManager.updateExecution(step, {\n status: 'DONE',\n ...(statusResponse.sending.amount && {\n fromAmount: statusResponse.sending.amount,\n }),\n ...(statusReceiving?.amount && { toAmount: statusReceiving.amount }),\n ...(statusReceiving?.token && { toToken: statusReceiving.token }),\n internalTxLink: statusResponse?.lifiExplorerLink,\n externalTxLink: statusResponse?.bridgeExplorerLink,\n gasCosts: [\n {\n amount: statusResponse.sending.gasAmount,\n amountUSD: statusResponse.sending.gasAmountUSD,\n token: statusResponse.sending.gasToken,\n estimate: statusResponse.sending.gasUsed,\n limit: statusResponse.sending.gasUsed,\n price: statusResponse.sending.gasPrice,\n type: 'SEND',\n },\n ],\n })\n\n return { status: 'COMPLETED' }\n } catch (e: any) {\n const htmlMessage = await getTransactionFailedMessage(\n client,\n step,\n `${toChain.metamask.blockExplorerUrls[0]}tx/${transactionHash}`\n )\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n htmlMessage ??\n 'Failed while waiting for status of destination chain transaction.',\n e\n )\n }\n }\n}\n"],"mappings":";;;;;;AASA,IAAa,+BAAb,cAAkD,sBAAsB;CACtE;CAEA,Y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E,QAAQ,aAAa;WACvB,GAAQ;GACf,MAAM,cAAc,MAAM,4BACxB,QACA,MACA,GAAG,QAAQ,SAAS,kBAAkB,GAAG,KAAK,kBAC/C;AACD,SAAM,IAAI,iBACR,cAAc,mBACd,eACE,qEACF,EACD"}
@@ -8,8 +8,8 @@ declare class SDKError extends Error {
8
8
  step?: LiFiStep;
9
9
  action?: ExecutionAction;
10
10
  code: ErrorCode;
11
- name: string;
12
- cause: BaseError;
11
+ override name: string;
12
+ override cause: BaseError;
13
13
  constructor(cause: BaseError, step?: LiFiStep, action?: ExecutionAction);
14
14
  }
15
15
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"SDKError.d.ts","names":[],"sources":["../../../src/errors/SDKError.ts"],"mappings":";;;;;;cAQa,QAAA,SAAiB,KAAA;EAC5B,IAAA,GAAO,QAAA;EACP,MAAA,GAAS,eAAA;EACT,IAAA,EAAM,SAAA;EACN,IAAA;EACA,KAAA,EAAgB,SAAA;EAEhB,WAAA,CAAY,KAAA,EAAO,SAAA,EAAW,IAAA,GAAO,QAAA,EAAU,MAAA,GAAS,eAAA;AAAA"}
1
+ {"version":3,"file":"SDKError.d.ts","names":[],"sources":["../../../src/errors/SDKError.ts"],"mappings":";;;;;;cAQa,QAAA,SAAiB,KAAA;EAC5B,IAAA,GAAO,QAAA;EACP,MAAA,GAAS,eAAA;EACT,IAAA,EAAM,SAAA;EAAA,SACG,IAAA;EAAA,SACA,KAAA,EAAO,SAAA;EAEhB,WAAA,CAAY,KAAA,EAAO,SAAA,EAAW,IAAA,GAAO,QAAA,EAAU,MAAA,GAAS,eAAA;AAAA"}
@@ -1,15 +1,14 @@
1
- import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js";
2
1
  import { version } from "../version.js";
3
2
  //#region src/errors/SDKError.ts
4
3
  var SDKError = class extends Error {
4
+ step;
5
+ action;
6
+ code;
7
+ name = "SDKError";
8
+ cause;
5
9
  constructor(cause, step, action) {
6
10
  const errorMessage = `${cause.message ? `[${cause.name}] ${cause.message}` : "Unknown error occurred"}\nLI.FI SDK version: ${version}`;
7
11
  super(errorMessage);
8
- _defineProperty(this, "step", void 0);
9
- _defineProperty(this, "action", void 0);
10
- _defineProperty(this, "code", void 0);
11
- _defineProperty(this, "name", "SDKError");
12
- _defineProperty(this, "cause", void 0);
13
12
  this.name = "SDKError";
14
13
  this.step = step;
15
14
  this.action = action;
@@ -1 +1 @@
1
- {"version":3,"file":"SDKError.js","names":[],"sources":["../../../src/errors/SDKError.ts"],"sourcesContent":["import type { LiFiStep } from '@lifi/types'\nimport type { ExecutionAction } from '../types/core.js'\nimport { version } from '../version.js'\nimport type { BaseError } from './baseError.js'\nimport type { ErrorCode } from './constants.js'\n\n// Note: SDKError is used to wrapper and present errors at the top level\n// Where opportunity allows we also add the step and the action related to the error\nexport class SDKError extends Error {\n step?: LiFiStep\n action?: ExecutionAction\n code: ErrorCode\n override name = 'SDKError'\n override cause: BaseError\n\n constructor(cause: BaseError, step?: LiFiStep, action?: ExecutionAction) {\n const errorMessage = `${cause.message ? `[${cause.name}] ${cause.message}` : 'Unknown error occurred'}\\nLI.FI SDK version: ${version}`\n super(errorMessage)\n this.name = 'SDKError'\n this.step = step\n this.action = action\n this.cause = cause\n this.stack = this.cause.stack\n this.code = cause.code\n }\n}\n"],"mappings":";;;AAQA,IAAa,WAAb,cAA8B,MAAM;CAOlC,YAAY,OAAkB,MAAiB,QAA0B;EACvE,MAAM,eAAe,GAAG,MAAM,UAAU,IAAI,MAAM,KAAK,IAAI,MAAM,YAAY,yBAAyB,uBAAuB;AAC7H,QAAM,aAAa;wBARrB,QAAA,KAAA,EAAe;wBACf,UAAA,KAAA,EAAwB;wBACxB,QAAA,KAAA,EAAe;wBACN,QAAO,WAAU;wBACjB,SAAA,KAAA,EAAgB;AAKvB,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,SAAS;AACd,OAAK,QAAQ;AACb,OAAK,QAAQ,KAAK,MAAM;AACxB,OAAK,OAAO,MAAM"}
1
+ {"version":3,"file":"SDKError.js","names":[],"sources":["../../../src/errors/SDKError.ts"],"sourcesContent":["import type { LiFiStep } from '@lifi/types'\nimport type { ExecutionAction } from '../types/core.js'\nimport { version } from '../version.js'\nimport type { BaseError } from './baseError.js'\nimport type { ErrorCode } from './constants.js'\n\n// Note: SDKError is used to wrapper and present errors at the top level\n// Where opportunity allows we also add the step and the action related to the error\nexport class SDKError extends Error {\n step?: LiFiStep\n action?: ExecutionAction\n code: ErrorCode\n override name = 'SDKError'\n override cause: BaseError\n\n constructor(cause: BaseError, step?: LiFiStep, action?: ExecutionAction) {\n const errorMessage = `${cause.message ? `[${cause.name}] ${cause.message}` : 'Unknown error occurred'}\\nLI.FI SDK version: ${version}`\n super(errorMessage)\n this.name = 'SDKError'\n this.step = step\n this.action = action\n this.cause = cause\n this.stack = this.cause.stack\n this.code = cause.code\n }\n}\n"],"mappings":";;AAQA,IAAa,WAAb,cAA8B,MAAM;CAClC;CACA;CACA;CACA,OAAgB;CAChB;CAEA,YAAY,OAAkB,MAAiB,QAA0B;EACvE,MAAM,eAAe,GAAG,MAAM,UAAU,IAAI,MAAM,KAAK,IAAI,MAAM,YAAY,yBAAyB,uBAAuB;AAC7H,QAAM,aAAa;AACnB,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,SAAS;AACd,OAAK,QAAQ;AACb,OAAK,QAAQ,KAAK,MAAM;AACxB,OAAK,OAAO,MAAM"}
@@ -3,7 +3,7 @@ import { ErrorCode, ErrorName } from "./constants.js";
3
3
  //#region src/errors/baseError.d.ts
4
4
  declare class BaseError extends Error {
5
5
  code: ErrorCode;
6
- cause?: Error;
6
+ override cause?: Error;
7
7
  constructor(name: ErrorName, code: number, message: string, cause?: Error);
8
8
  }
9
9
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"baseError.d.ts","names":[],"sources":["../../../src/errors/baseError.ts"],"mappings":";;;cAKa,SAAA,SAAkB,KAAA;EAC7B,IAAA,EAAM,SAAA;EACN,KAAA,GAAiB,KAAA;EAEjB,WAAA,CAAY,IAAA,EAAM,SAAA,EAAW,IAAA,UAAc,OAAA,UAAiB,KAAA,GAAQ,KAAA;AAAA"}
1
+ {"version":3,"file":"baseError.d.ts","names":[],"sources":["../../../src/errors/baseError.ts"],"mappings":";;;cAKa,SAAA,SAAkB,KAAA;EAC7B,IAAA,EAAM,SAAA;EAAA,SACG,KAAA,GAAQ,KAAA;EAEjB,WAAA,CAAY,IAAA,EAAM,SAAA,EAAW,IAAA,UAAc,OAAA,UAAiB,KAAA,GAAQ,KAAA;AAAA"}
@@ -1,11 +1,10 @@
1
1
  import { getRootCause } from "./utils/rootCause.js";
2
- import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js";
3
2
  //#region src/errors/baseError.ts
4
3
  var BaseError = class extends Error {
4
+ code;
5
+ cause;
5
6
  constructor(name, code, message, cause) {
6
7
  super(message);
7
- _defineProperty(this, "code", void 0);
8
- _defineProperty(this, "cause", void 0);
9
8
  this.name = name;
10
9
  this.code = code;
11
10
  this.cause = cause;