@lifi/sdk 4.0.0-beta.2 → 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 (88) 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/client/createClient.js +8 -7
  8. package/dist/cjs/client/createClient.js.map +1 -1
  9. package/dist/cjs/core/BaseStepExecutor.js +52 -53
  10. package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
  11. package/dist/cjs/core/StatusManager.js +116 -133
  12. package/dist/cjs/core/StatusManager.js.map +1 -1
  13. package/dist/cjs/core/TaskPipeline.js +1 -2
  14. package/dist/cjs/core/TaskPipeline.js.map +1 -1
  15. package/dist/cjs/core/storage.js +1 -4
  16. package/dist/cjs/core/storage.js.map +1 -1
  17. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +1 -2
  18. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
  19. package/dist/cjs/errors/SDKError.d.ts +2 -2
  20. package/dist/cjs/errors/SDKError.js +5 -6
  21. package/dist/cjs/errors/SDKError.js.map +1 -1
  22. package/dist/cjs/errors/baseError.d.ts +1 -1
  23. package/dist/cjs/errors/baseError.js +2 -3
  24. package/dist/cjs/errors/baseError.js.map +1 -1
  25. package/dist/cjs/errors/errors.js +1 -2
  26. package/dist/cjs/errors/errors.js.map +1 -1
  27. package/dist/cjs/errors/httpError.js +6 -7
  28. package/dist/cjs/errors/httpError.js.map +1 -1
  29. package/dist/cjs/types/core.d.ts +1 -0
  30. package/dist/cjs/utils/checkPackageUpdates.js +1 -1
  31. package/dist/cjs/utils/withDedupe.d.ts +1 -1
  32. package/dist/cjs/utils/withDedupe.js +1 -2
  33. package/dist/cjs/utils/withDedupe.js.map +1 -1
  34. package/dist/cjs/version.d.ts +1 -1
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/cjs/version.js.map +1 -1
  37. package/dist/esm/actions/getContractCallsQuote.js +10 -10
  38. package/dist/esm/actions/getContractCallsQuote.js.map +1 -1
  39. package/dist/esm/actions/getQuote.js +11 -11
  40. package/dist/esm/actions/getQuote.js.map +1 -1
  41. package/dist/esm/actions/getRelayerQuote.js +11 -11
  42. package/dist/esm/actions/getRelayerQuote.js.map +1 -1
  43. package/dist/esm/client/createClient.js +8 -7
  44. package/dist/esm/client/createClient.js.map +1 -1
  45. package/dist/esm/core/BaseStepExecutor.js +52 -53
  46. package/dist/esm/core/BaseStepExecutor.js.map +1 -1
  47. package/dist/esm/core/StatusManager.js +116 -133
  48. package/dist/esm/core/StatusManager.js.map +1 -1
  49. package/dist/esm/core/TaskPipeline.js +1 -2
  50. package/dist/esm/core/TaskPipeline.js.map +1 -1
  51. package/dist/esm/core/storage.js +1 -4
  52. package/dist/esm/core/storage.js.map +1 -1
  53. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +1 -2
  54. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
  55. package/dist/esm/errors/SDKError.d.ts +2 -2
  56. package/dist/esm/errors/SDKError.d.ts.map +1 -1
  57. package/dist/esm/errors/SDKError.js +5 -6
  58. package/dist/esm/errors/SDKError.js.map +1 -1
  59. package/dist/esm/errors/baseError.d.ts +1 -1
  60. package/dist/esm/errors/baseError.d.ts.map +1 -1
  61. package/dist/esm/errors/baseError.js +2 -3
  62. package/dist/esm/errors/baseError.js.map +1 -1
  63. package/dist/esm/errors/errors.js +1 -2
  64. package/dist/esm/errors/errors.js.map +1 -1
  65. package/dist/esm/errors/httpError.js +6 -7
  66. package/dist/esm/errors/httpError.js.map +1 -1
  67. package/dist/esm/types/core.d.ts +1 -0
  68. package/dist/esm/types/core.d.ts.map +1 -1
  69. package/dist/esm/utils/checkPackageUpdates.js +1 -1
  70. package/dist/esm/utils/withDedupe.d.ts +1 -1
  71. package/dist/esm/utils/withDedupe.d.ts.map +1 -1
  72. package/dist/esm/utils/withDedupe.js +1 -2
  73. package/dist/esm/utils/withDedupe.js.map +1 -1
  74. package/dist/esm/version.d.ts +1 -1
  75. package/dist/esm/version.js +1 -1
  76. package/dist/esm/version.js.map +1 -1
  77. package/package.json +2 -2
  78. package/src/client/createClient.ts +9 -7
  79. package/src/types/core.ts +1 -0
  80. package/src/version.ts +1 -1
  81. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +0 -12
  82. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.js +0 -14
  83. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +0 -9
  84. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.js +0 -16
  85. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +0 -12
  86. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.js +0 -14
  87. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +0 -9
  88. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.js +0 -11
@@ -1 +1 @@
1
- {"version":3,"file":"StatusManager.js","names":["getActionMessage","executionState"],"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":"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"}
1
+ {"version":3,"file":"StatusManager.js","names":["getActionMessage","executionState"],"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":"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"}
@@ -1,9 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js");
3
2
  //#region src/core/TaskPipeline.ts
4
3
  var TaskPipeline = class {
4
+ tasks;
5
5
  constructor(tasks) {
6
- require_defineProperty._defineProperty(this, "tasks", void 0);
7
6
  this.tasks = tasks;
8
7
  }
9
8
  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;+CAF3B,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,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js");
3
2
  //#region src/core/storage.ts
4
3
  var LocalStorageAdapter = class {
5
4
  get(key) {
@@ -13,9 +12,7 @@ var LocalStorageAdapter = class {
13
12
  }
14
13
  };
15
14
  var InMemoryStorage = class {
16
- constructor() {
17
- require_defineProperty._defineProperty(this, "store", /* @__PURE__ */ new Map());
18
- }
15
+ store = /* @__PURE__ */ new Map();
19
16
  get(key) {
20
17
  return this.store.get(key) ?? null;
21
18
  }
@@ -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;;+CACzC,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,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_defineProperty = require("../../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js");
3
2
  const require_errors_constants = require("../../errors/constants.js");
4
3
  const require_errors_errors = require("../../errors/errors.js");
5
4
  const require_core_BaseStepExecutionTask = require("../BaseStepExecutionTask.js");
@@ -7,9 +6,9 @@ const require_utils_getTransactionMessage = require("../../utils/getTransactionM
7
6
  const require_core_tasks_helpers_waitForTransactionStatus = require("./helpers/waitForTransactionStatus.js");
8
7
  //#region src/core/tasks/WaitForTransactionStatusTask.ts
9
8
  var WaitForTransactionStatusTask = class extends require_core_BaseStepExecutionTask.BaseStepExecutionTask {
9
+ actionType;
10
10
  constructor(actionType) {
11
11
  super();
12
- require_defineProperty._defineProperty(this, "actionType", void 0);
13
12
  this.actionType = actionType;
14
13
  }
15
14
  async run(context) {
@@ -1 +1 @@
1
- {"version":3,"file":"WaitForTransactionStatusTask.js","names":["BaseStepExecutionTask","waitForTransactionStatus","getTransactionFailedMessage","TransactionError","LiFiErrorCode"],"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,cAAkDA,mCAAAA,sBAAsB;CAGtE,YAAY,YAAiC;AAC3C,SAAO;+CAHA,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,MAAMC,oDAAAA,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,MAAMC,oCAAAA,4BACxB,QACA,MACA,GAAG,QAAQ,SAAS,kBAAkB,GAAG,KAAK,kBAC/C;AACD,SAAM,IAAIC,sBAAAA,iBACRC,yBAAAA,cAAc,mBACd,eACE,qEACF,EACD"}
1
+ {"version":3,"file":"WaitForTransactionStatusTask.js","names":["BaseStepExecutionTask","waitForTransactionStatus","getTransactionFailedMessage","TransactionError","LiFiErrorCode"],"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,cAAkDA,mCAAAA,sBAAsB;CACtE;CAEA,YAAY,YAAiC;AAC3C,SAAO;AACP,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,MAAMC,oDAAAA,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,MAAMC,oCAAAA,4BACxB,QACA,MACA,GAAG,QAAQ,SAAS,kBAAkB,GAAG,KAAK,kBAC/C;AACD,SAAM,IAAIC,sBAAAA,iBACRC,yBAAAA,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,16 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js");
3
2
  const require_version = require("../version.js");
4
3
  //#region src/errors/SDKError.ts
5
4
  var SDKError = class extends Error {
5
+ step;
6
+ action;
7
+ code;
8
+ name = "SDKError";
9
+ cause;
6
10
  constructor(cause, step, action) {
7
11
  const errorMessage = `${cause.message ? `[${cause.name}] ${cause.message}` : "Unknown error occurred"}\nLI.FI SDK version: ${require_version.version}`;
8
12
  super(errorMessage);
9
- require_defineProperty._defineProperty(this, "step", void 0);
10
- require_defineProperty._defineProperty(this, "action", void 0);
11
- require_defineProperty._defineProperty(this, "code", void 0);
12
- require_defineProperty._defineProperty(this, "name", "SDKError");
13
- require_defineProperty._defineProperty(this, "cause", void 0);
14
13
  this.name = "SDKError";
15
14
  this.step = step;
16
15
  this.action = action;
@@ -1 +1 @@
1
- {"version":3,"file":"SDKError.js","names":["version"],"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,uBAAuBA,gBAAAA;AAC7H,QAAM,aAAa;+CARrB,QAAA,KAAA,EAAe;+CACf,UAAA,KAAA,EAAwB;+CACxB,QAAA,KAAA,EAAe;+CACN,QAAO,WAAU;+CACjB,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":["version"],"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,uBAAuBA,gBAAAA;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,12 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_errors_utils_rootCause = require("./utils/rootCause.js");
3
- const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js");
4
3
  //#region src/errors/baseError.ts
5
4
  var BaseError = class extends Error {
5
+ code;
6
+ cause;
6
7
  constructor(name, code, message, cause) {
7
8
  super(message);
8
- require_defineProperty._defineProperty(this, "code", void 0);
9
- require_defineProperty._defineProperty(this, "cause", void 0);
10
9
  this.name = name;
11
10
  this.code = code;
12
11
  this.cause = cause;
@@ -1 +1 @@
1
- {"version":3,"file":"baseError.js","names":["getRootCause"],"sources":["../../../src/errors/baseError.ts"],"sourcesContent":["import type { ErrorCode, ErrorName } from './constants.js'\nimport { getRootCause } from './utils/rootCause.js'\n\n// Note: we use the BaseErrors to capture errors at specific points in the code\n// they can carry addition to help give more context\nexport class BaseError extends Error {\n code: ErrorCode\n override cause?: Error\n\n constructor(name: ErrorName, code: number, message: string, cause?: Error) {\n super(message)\n\n this.name = name\n this.code = code\n this.cause = cause\n\n const rootCause = getRootCause(this.cause)\n if (rootCause?.stack) {\n this.stack = rootCause.stack\n }\n }\n}\n"],"mappings":";;;;AAKA,IAAa,YAAb,cAA+B,MAAM;CAInC,YAAY,MAAiB,MAAc,SAAiB,OAAe;AACzE,QAAM,QAAQ;+CAJhB,QAAA,KAAA,EAAe;+CACN,SAAA,KAAA,EAAa;AAKpB,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,QAAQ;EAEb,MAAM,YAAYA,+BAAAA,aAAa,KAAK,MAAM;AAC1C,MAAI,WAAW,MACb,MAAK,QAAQ,UAAU"}
1
+ {"version":3,"file":"baseError.js","names":["getRootCause"],"sources":["../../../src/errors/baseError.ts"],"sourcesContent":["import type { ErrorCode, ErrorName } from './constants.js'\nimport { getRootCause } from './utils/rootCause.js'\n\n// Note: we use the BaseErrors to capture errors at specific points in the code\n// they can carry addition to help give more context\nexport class BaseError extends Error {\n code: ErrorCode\n override cause?: Error\n\n constructor(name: ErrorName, code: number, message: string, cause?: Error) {\n super(message)\n\n this.name = name\n this.code = code\n this.cause = cause\n\n const rootCause = getRootCause(this.cause)\n if (rootCause?.stack) {\n this.stack = rootCause.stack\n }\n }\n}\n"],"mappings":";;;AAKA,IAAa,YAAb,cAA+B,MAAM;CACnC;CACA;CAEA,YAAY,MAAiB,MAAc,SAAiB,OAAe;AACzE,QAAM,QAAQ;AAEd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,QAAQ;EAEb,MAAM,YAAYA,+BAAAA,aAAa,KAAK,MAAM;AAC1C,MAAI,WAAW,MACb,MAAK,QAAQ,UAAU"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js");
3
2
  const require_errors_baseError = require("./baseError.js");
4
3
  const require_errors_constants = require("./constants.js");
5
4
  //#region src/errors/errors.ts
@@ -44,9 +43,9 @@ var ValidationError = class extends require_errors_baseError.BaseError {
44
43
  * The execution layer catches this and retries executeStep(client, step, retryParams).
45
44
  */
46
45
  var ExecuteStepRetryError = class extends require_errors_baseError.BaseError {
46
+ retryParams;
47
47
  constructor(message, retryParams, cause) {
48
48
  super(require_errors_constants.ErrorName.ExecuteStepRetryError, require_errors_constants.LiFiErrorCode.InternalError, message, cause);
49
- require_defineProperty._defineProperty(this, "retryParams", void 0);
50
49
  this.retryParams = retryParams;
51
50
  }
52
51
  };
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["BaseError","ErrorName","LiFiErrorCode"],"sources":["../../../src/errors/errors.ts"],"sourcesContent":["import type { ExecuteStepRetryParams } from '../types/core.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorName, LiFiErrorCode } from './constants.js'\n\nexport class RPCError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.RPCError, code, message, cause)\n }\n}\n\nexport class ProviderError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.ProviderError, code, message, cause)\n }\n}\n\nexport class TransactionError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.TransactionError, code, message, cause)\n }\n}\n\nexport class UnknownError extends BaseError {\n constructor(message: string, cause?: Error) {\n super(ErrorName.UnknownError, LiFiErrorCode.InternalError, message, cause)\n }\n}\n\nexport class BalanceError extends BaseError {\n constructor(message: string, cause?: Error) {\n super(ErrorName.BalanceError, LiFiErrorCode.BalanceError, message, cause)\n }\n}\n\nexport class ServerError extends BaseError {\n constructor(message: string) {\n super(ErrorName.ServerError, LiFiErrorCode.InternalError, message)\n }\n}\n\nexport class ValidationError extends BaseError {\n constructor(message: string) {\n super(ErrorName.ValidationError, LiFiErrorCode.ValidationError, message)\n }\n}\n\n/**\n * Thrown by a step executor when executeStep should be retried with the given params\n * (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).\n * The execution layer catches this and retries executeStep(client, step, retryParams).\n */\nexport class ExecuteStepRetryError extends BaseError {\n readonly retryParams: ExecuteStepRetryParams\n\n constructor(\n message: string,\n retryParams: ExecuteStepRetryParams,\n cause?: Error\n ) {\n super(\n ErrorName.ExecuteStepRetryError,\n LiFiErrorCode.InternalError,\n message,\n cause\n )\n this.retryParams = retryParams\n }\n}\n"],"mappings":";;;;;AAIA,IAAa,WAAb,cAA8BA,yBAAAA,UAAU;CACtC,YAAY,MAAqB,SAAiB,OAAe;AAC/D,QAAMC,yBAAAA,UAAU,UAAU,MAAM,SAAS,MAAM;;;AAInD,IAAa,gBAAb,cAAmCD,yBAAAA,UAAU;CAC3C,YAAY,MAAqB,SAAiB,OAAe;AAC/D,QAAMC,yBAAAA,UAAU,eAAe,MAAM,SAAS,MAAM;;;AAIxD,IAAa,mBAAb,cAAsCD,yBAAAA,UAAU;CAC9C,YAAY,MAAqB,SAAiB,OAAe;AAC/D,QAAMC,yBAAAA,UAAU,kBAAkB,MAAM,SAAS,MAAM;;;AAI3D,IAAa,eAAb,cAAkCD,yBAAAA,UAAU;CAC1C,YAAY,SAAiB,OAAe;AAC1C,QAAMC,yBAAAA,UAAU,cAAcC,yBAAAA,cAAc,eAAe,SAAS,MAAM;;;AAI9E,IAAa,eAAb,cAAkCF,yBAAAA,UAAU;CAC1C,YAAY,SAAiB,OAAe;AAC1C,QAAMC,yBAAAA,UAAU,cAAcC,yBAAAA,cAAc,cAAc,SAAS,MAAM;;;AAI7E,IAAa,cAAb,cAAiCF,yBAAAA,UAAU;CACzC,YAAY,SAAiB;AAC3B,QAAMC,yBAAAA,UAAU,aAAaC,yBAAAA,cAAc,eAAe,QAAQ;;;AAItE,IAAa,kBAAb,cAAqCF,yBAAAA,UAAU;CAC7C,YAAY,SAAiB;AAC3B,QAAMC,yBAAAA,UAAU,iBAAiBC,yBAAAA,cAAc,iBAAiB,QAAQ;;;;;;;;AAS5E,IAAa,wBAAb,cAA2CF,yBAAAA,UAAU;CAGnD,YACE,SACA,aACA,OACA;AACA,QACEC,yBAAAA,UAAU,uBACVC,yBAAAA,cAAc,eACd,SACA,MACD;+CAZM,eAAA,KAAA,EAAmC;AAa1C,OAAK,cAAc"}
1
+ {"version":3,"file":"errors.js","names":["BaseError","ErrorName","LiFiErrorCode"],"sources":["../../../src/errors/errors.ts"],"sourcesContent":["import type { ExecuteStepRetryParams } from '../types/core.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorName, LiFiErrorCode } from './constants.js'\n\nexport class RPCError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.RPCError, code, message, cause)\n }\n}\n\nexport class ProviderError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.ProviderError, code, message, cause)\n }\n}\n\nexport class TransactionError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.TransactionError, code, message, cause)\n }\n}\n\nexport class UnknownError extends BaseError {\n constructor(message: string, cause?: Error) {\n super(ErrorName.UnknownError, LiFiErrorCode.InternalError, message, cause)\n }\n}\n\nexport class BalanceError extends BaseError {\n constructor(message: string, cause?: Error) {\n super(ErrorName.BalanceError, LiFiErrorCode.BalanceError, message, cause)\n }\n}\n\nexport class ServerError extends BaseError {\n constructor(message: string) {\n super(ErrorName.ServerError, LiFiErrorCode.InternalError, message)\n }\n}\n\nexport class ValidationError extends BaseError {\n constructor(message: string) {\n super(ErrorName.ValidationError, LiFiErrorCode.ValidationError, message)\n }\n}\n\n/**\n * Thrown by a step executor when executeStep should be retried with the given params\n * (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).\n * The execution layer catches this and retries executeStep(client, step, retryParams).\n */\nexport class ExecuteStepRetryError extends BaseError {\n readonly retryParams: ExecuteStepRetryParams\n\n constructor(\n message: string,\n retryParams: ExecuteStepRetryParams,\n cause?: Error\n ) {\n super(\n ErrorName.ExecuteStepRetryError,\n LiFiErrorCode.InternalError,\n message,\n cause\n )\n this.retryParams = retryParams\n }\n}\n"],"mappings":";;;;AAIA,IAAa,WAAb,cAA8BA,yBAAAA,UAAU;CACtC,YAAY,MAAqB,SAAiB,OAAe;AAC/D,QAAMC,yBAAAA,UAAU,UAAU,MAAM,SAAS,MAAM;;;AAInD,IAAa,gBAAb,cAAmCD,yBAAAA,UAAU;CAC3C,YAAY,MAAqB,SAAiB,OAAe;AAC/D,QAAMC,yBAAAA,UAAU,eAAe,MAAM,SAAS,MAAM;;;AAIxD,IAAa,mBAAb,cAAsCD,yBAAAA,UAAU;CAC9C,YAAY,MAAqB,SAAiB,OAAe;AAC/D,QAAMC,yBAAAA,UAAU,kBAAkB,MAAM,SAAS,MAAM;;;AAI3D,IAAa,eAAb,cAAkCD,yBAAAA,UAAU;CAC1C,YAAY,SAAiB,OAAe;AAC1C,QAAMC,yBAAAA,UAAU,cAAcC,yBAAAA,cAAc,eAAe,SAAS,MAAM;;;AAI9E,IAAa,eAAb,cAAkCF,yBAAAA,UAAU;CAC1C,YAAY,SAAiB,OAAe;AAC1C,QAAMC,yBAAAA,UAAU,cAAcC,yBAAAA,cAAc,cAAc,SAAS,MAAM;;;AAI7E,IAAa,cAAb,cAAiCF,yBAAAA,UAAU;CACzC,YAAY,SAAiB;AAC3B,QAAMC,yBAAAA,UAAU,aAAaC,yBAAAA,cAAc,eAAe,QAAQ;;;AAItE,IAAa,kBAAb,cAAqCF,yBAAAA,UAAU;CAC7C,YAAY,SAAiB;AAC3B,QAAMC,yBAAAA,UAAU,iBAAiBC,yBAAAA,cAAc,iBAAiB,QAAQ;;;;;;;;AAS5E,IAAa,wBAAb,cAA2CF,yBAAAA,UAAU;CACnD;CAEA,YACE,SACA,aACA,OACA;AACA,QACEC,yBAAAA,UAAU,uBACVC,yBAAAA,cAAc,eACd,SACA,MACD;AACD,OAAK,cAAc"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js");
3
2
  const require_errors_baseError = require("./baseError.js");
4
3
  const require_errors_constants = require("./constants.js");
5
4
  //#region src/errors/httpError.ts
@@ -39,17 +38,17 @@ const createInitialMessage = (response) => {
39
38
  return `Request failed with ${status ? `status code ${status}` : "an unknown error"}`;
40
39
  };
41
40
  var HTTPError = class extends require_errors_baseError.BaseError {
41
+ response;
42
+ status;
43
+ url;
44
+ fetchOptions;
45
+ type;
46
+ responseBody;
42
47
  constructor(response, url, options) {
43
48
  const errorClassification = getErrorClassificationFromStatusCode(response.status);
44
49
  const additionalMessage = errorClassification?.message ? `\n${errorClassification.message}` : "";
45
50
  const message = createInitialMessage(response) + additionalMessage;
46
51
  super(require_errors_constants.ErrorName.HTTPError, errorClassification.code, message);
47
- require_defineProperty._defineProperty(this, "response", void 0);
48
- require_defineProperty._defineProperty(this, "status", void 0);
49
- require_defineProperty._defineProperty(this, "url", void 0);
50
- require_defineProperty._defineProperty(this, "fetchOptions", void 0);
51
- require_defineProperty._defineProperty(this, "type", void 0);
52
- require_defineProperty._defineProperty(this, "responseBody", void 0);
53
52
  this.type = errorClassification.type;
54
53
  this.response = response;
55
54
  this.status = response.status;
@@ -1 +1 @@
1
- {"version":3,"file":"httpError.js","names":["ErrorName","LiFiErrorCode","ErrorMessage","BaseError"],"sources":["../../../src/errors/httpError.ts"],"sourcesContent":["import type { UnavailableRoutes } from '@lifi/types'\nimport type { ExtendedRequestInit } from '../types/request.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorMessage, ErrorName, LiFiErrorCode } from './constants.js'\n\ninterface ServerErrorResponseBody {\n code: number\n message: string\n errors?: UnavailableRoutes\n}\n\nconst statusCodeToErrorClassificationMap = new Map([\n [\n 400,\n { type: ErrorName.ValidationError, code: LiFiErrorCode.ValidationError },\n ],\n [404, { type: ErrorName.NotFoundError, code: LiFiErrorCode.NotFound }],\n [\n 409,\n {\n type: ErrorName.SlippageError,\n code: LiFiErrorCode.SlippageError,\n message: ErrorMessage.SlippageError,\n },\n ],\n [424, { type: ErrorName.ServerError, code: LiFiErrorCode.ThirdPartyError }],\n [429, { type: ErrorName.ServerError, code: LiFiErrorCode.RateLimitExceeded }],\n [500, { type: ErrorName.ServerError, code: LiFiErrorCode.InternalError }],\n])\n\nconst getErrorClassificationFromStatusCode = (code: number) =>\n statusCodeToErrorClassificationMap.get(code) ?? {\n type: ErrorName.ServerError,\n code: LiFiErrorCode.InternalError,\n }\n\nconst createInitialMessage = (response: Response) => {\n const statusCode =\n response.status || response.status === 0 ? response.status : ''\n const title = response.statusText || ''\n const status = `${statusCode} ${title}`.trim()\n const reason = status ? `status code ${status}` : 'an unknown error'\n return `Request failed with ${reason}`\n}\n\nexport class HTTPError extends BaseError {\n public response: Response\n public status: number\n public url: RequestInfo | URL\n public fetchOptions: ExtendedRequestInit\n public type?: ErrorName\n public responseBody?: ServerErrorResponseBody\n\n constructor(\n response: Response,\n url: RequestInfo | URL,\n options: ExtendedRequestInit\n ) {\n const errorClassification = getErrorClassificationFromStatusCode(\n response.status\n )\n const additionalMessage = errorClassification?.message\n ? `\\n${errorClassification.message}`\n : ''\n const message = createInitialMessage(response) + additionalMessage\n\n super(ErrorName.HTTPError, errorClassification.code, message)\n\n this.type = errorClassification.type\n this.response = response\n this.status = response.status\n this.message = message\n this.url = url\n this.fetchOptions = options\n }\n\n async buildAdditionalDetails(): Promise<void> {\n if (this.type) {\n this.message = `[${this.type}] ${this.message}`\n }\n\n try {\n this.responseBody = await this.response.json()\n\n if (this.responseBody?.message) {\n this.message += this.message.endsWith('.')\n ? ` ${this.responseBody.message.toString()}`\n : `. ${this.responseBody.message.toString()}`\n }\n } catch {}\n }\n}\n"],"mappings":";;;;;AAWA,MAAM,qCAAqC,IAAI,IAAI;CACjD,CACE,KACA;EAAE,MAAMA,yBAAAA,UAAU;EAAiB,MAAMC,yBAAAA,cAAc;EAAiB,CACzE;CACD,CAAC,KAAK;EAAE,MAAMD,yBAAAA,UAAU;EAAe,MAAMC,yBAAAA,cAAc;EAAU,CAAC;CACtE,CACE,KACA;EACE,MAAMD,yBAAAA,UAAU;EAChB,MAAMC,yBAAAA,cAAc;EACpB,SAASC,yBAAAA,aAAa;EACvB,CACF;CACD,CAAC,KAAK;EAAE,MAAMF,yBAAAA,UAAU;EAAa,MAAMC,yBAAAA,cAAc;EAAiB,CAAC;CAC3E,CAAC,KAAK;EAAE,MAAMD,yBAAAA,UAAU;EAAa,MAAMC,yBAAAA,cAAc;EAAmB,CAAC;CAC7E,CAAC,KAAK;EAAE,MAAMD,yBAAAA,UAAU;EAAa,MAAMC,yBAAAA,cAAc;EAAe,CAAC;CAC1E,CAAC;AAEF,MAAM,wCAAwC,SAC5C,mCAAmC,IAAI,KAAK,IAAI;CAC9C,MAAMD,yBAAAA,UAAU;CAChB,MAAMC,yBAAAA,cAAc;CACrB;AAEH,MAAM,wBAAwB,aAAuB;CAInD,MAAM,SAAS,GAFb,SAAS,UAAU,SAAS,WAAW,IAAI,SAAS,SAAS,GAElC,GADf,SAAS,cAAc,KACG,MAAM;AAE9C,QAAO,uBADQ,SAAS,eAAe,WAAW;;AAIpD,IAAa,YAAb,cAA+BE,yBAAAA,UAAU;CAQvC,YACE,UACA,KACA,SACA;EACA,MAAM,sBAAsB,qCAC1B,SAAS,OACV;EACD,MAAM,oBAAoB,qBAAqB,UAC3C,KAAK,oBAAoB,YACzB;EACJ,MAAM,UAAU,qBAAqB,SAAS,GAAG;AAEjD,QAAMH,yBAAAA,UAAU,WAAW,oBAAoB,MAAM,QAAQ;+CApBxD,YAAA,KAAA,EAAkB;+CAClB,UAAA,KAAA,EAAc;+CACd,OAAA,KAAA,EAAsB;+CACtB,gBAAA,KAAA,EAAiC;+CACjC,QAAA,KAAA,EAAgB;+CAChB,gBAAA,KAAA,EAAsC;AAiB3C,OAAK,OAAO,oBAAoB;AAChC,OAAK,WAAW;AAChB,OAAK,SAAS,SAAS;AACvB,OAAK,UAAU;AACf,OAAK,MAAM;AACX,OAAK,eAAe;;CAGtB,MAAM,yBAAwC;AAC5C,MAAI,KAAK,KACP,MAAK,UAAU,IAAI,KAAK,KAAK,IAAI,KAAK;AAGxC,MAAI;AACF,QAAK,eAAe,MAAM,KAAK,SAAS,MAAM;AAE9C,OAAI,KAAK,cAAc,QACrB,MAAK,WAAW,KAAK,QAAQ,SAAS,IAAI,GACtC,IAAI,KAAK,aAAa,QAAQ,UAAU,KACxC,KAAK,KAAK,aAAa,QAAQ,UAAU;UAEzC"}
1
+ {"version":3,"file":"httpError.js","names":["ErrorName","LiFiErrorCode","ErrorMessage","BaseError"],"sources":["../../../src/errors/httpError.ts"],"sourcesContent":["import type { UnavailableRoutes } from '@lifi/types'\nimport type { ExtendedRequestInit } from '../types/request.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorMessage, ErrorName, LiFiErrorCode } from './constants.js'\n\ninterface ServerErrorResponseBody {\n code: number\n message: string\n errors?: UnavailableRoutes\n}\n\nconst statusCodeToErrorClassificationMap = new Map([\n [\n 400,\n { type: ErrorName.ValidationError, code: LiFiErrorCode.ValidationError },\n ],\n [404, { type: ErrorName.NotFoundError, code: LiFiErrorCode.NotFound }],\n [\n 409,\n {\n type: ErrorName.SlippageError,\n code: LiFiErrorCode.SlippageError,\n message: ErrorMessage.SlippageError,\n },\n ],\n [424, { type: ErrorName.ServerError, code: LiFiErrorCode.ThirdPartyError }],\n [429, { type: ErrorName.ServerError, code: LiFiErrorCode.RateLimitExceeded }],\n [500, { type: ErrorName.ServerError, code: LiFiErrorCode.InternalError }],\n])\n\nconst getErrorClassificationFromStatusCode = (code: number) =>\n statusCodeToErrorClassificationMap.get(code) ?? {\n type: ErrorName.ServerError,\n code: LiFiErrorCode.InternalError,\n }\n\nconst createInitialMessage = (response: Response) => {\n const statusCode =\n response.status || response.status === 0 ? response.status : ''\n const title = response.statusText || ''\n const status = `${statusCode} ${title}`.trim()\n const reason = status ? `status code ${status}` : 'an unknown error'\n return `Request failed with ${reason}`\n}\n\nexport class HTTPError extends BaseError {\n public response: Response\n public status: number\n public url: RequestInfo | URL\n public fetchOptions: ExtendedRequestInit\n public type?: ErrorName\n public responseBody?: ServerErrorResponseBody\n\n constructor(\n response: Response,\n url: RequestInfo | URL,\n options: ExtendedRequestInit\n ) {\n const errorClassification = getErrorClassificationFromStatusCode(\n response.status\n )\n const additionalMessage = errorClassification?.message\n ? `\\n${errorClassification.message}`\n : ''\n const message = createInitialMessage(response) + additionalMessage\n\n super(ErrorName.HTTPError, errorClassification.code, message)\n\n this.type = errorClassification.type\n this.response = response\n this.status = response.status\n this.message = message\n this.url = url\n this.fetchOptions = options\n }\n\n async buildAdditionalDetails(): Promise<void> {\n if (this.type) {\n this.message = `[${this.type}] ${this.message}`\n }\n\n try {\n this.responseBody = await this.response.json()\n\n if (this.responseBody?.message) {\n this.message += this.message.endsWith('.')\n ? ` ${this.responseBody.message.toString()}`\n : `. ${this.responseBody.message.toString()}`\n }\n } catch {}\n }\n}\n"],"mappings":";;;;AAWA,MAAM,qCAAqC,IAAI,IAAI;CACjD,CACE,KACA;EAAE,MAAMA,yBAAAA,UAAU;EAAiB,MAAMC,yBAAAA,cAAc;EAAiB,CACzE;CACD,CAAC,KAAK;EAAE,MAAMD,yBAAAA,UAAU;EAAe,MAAMC,yBAAAA,cAAc;EAAU,CAAC;CACtE,CACE,KACA;EACE,MAAMD,yBAAAA,UAAU;EAChB,MAAMC,yBAAAA,cAAc;EACpB,SAASC,yBAAAA,aAAa;EACvB,CACF;CACD,CAAC,KAAK;EAAE,MAAMF,yBAAAA,UAAU;EAAa,MAAMC,yBAAAA,cAAc;EAAiB,CAAC;CAC3E,CAAC,KAAK;EAAE,MAAMD,yBAAAA,UAAU;EAAa,MAAMC,yBAAAA,cAAc;EAAmB,CAAC;CAC7E,CAAC,KAAK;EAAE,MAAMD,yBAAAA,UAAU;EAAa,MAAMC,yBAAAA,cAAc;EAAe,CAAC;CAC1E,CAAC;AAEF,MAAM,wCAAwC,SAC5C,mCAAmC,IAAI,KAAK,IAAI;CAC9C,MAAMD,yBAAAA,UAAU;CAChB,MAAMC,yBAAAA,cAAc;CACrB;AAEH,MAAM,wBAAwB,aAAuB;CAInD,MAAM,SAAS,GAFb,SAAS,UAAU,SAAS,WAAW,IAAI,SAAS,SAAS,GAElC,GADf,SAAS,cAAc,KACG,MAAM;AAE9C,QAAO,uBADQ,SAAS,eAAe,WAAW;;AAIpD,IAAa,YAAb,cAA+BE,yBAAAA,UAAU;CACvC;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,UACA,KACA,SACA;EACA,MAAM,sBAAsB,qCAC1B,SAAS,OACV;EACD,MAAM,oBAAoB,qBAAqB,UAC3C,KAAK,oBAAoB,YACzB;EACJ,MAAM,UAAU,qBAAqB,SAAS,GAAG;AAEjD,QAAMH,yBAAAA,UAAU,WAAW,oBAAoB,MAAM,QAAQ;AAE7D,OAAK,OAAO,oBAAoB;AAChC,OAAK,WAAW;AAChB,OAAK,SAAS,SAAS;AACvB,OAAK,UAAU;AACf,OAAK,MAAM;AACX,OAAK,eAAe;;CAGtB,MAAM,yBAAwC;AAC5C,MAAI,KAAK,KACP,MAAK,UAAU,IAAI,KAAK,KAAK,IAAI,KAAK;AAGxC,MAAI;AACF,QAAK,eAAe,MAAM,KAAK,SAAS,MAAM;AAE9C,OAAI,KAAK,cAAc,QACrB,MAAK,WAAW,KAAK,QAAQ,SAAS,IAAI,GACtC,IAAI,KAAK,aAAa,QAAQ,UAAU,KACxC,KAAK,KAAK,aAAa,QAAQ,UAAU;UAEzC"}
@@ -22,6 +22,7 @@ interface SDKBaseConfig {
22
22
  }
23
23
  interface SDKConfig extends Partial<Omit<SDKBaseConfig, "integrator">> {
24
24
  integrator: string;
25
+ providers?: SDKProvider[];
25
26
  }
26
27
  type RPCUrls = Partial<Record<ChainId, string[]>>;
27
28
  interface SDKProvider {
@@ -5,7 +5,7 @@ const checkPackageUpdates = async (packageName, packageVersion) => {
5
5
  try {
6
6
  const pkgName = packageName ?? "@lifi/sdk";
7
7
  const latestVersion = (await (await fetch(`https://registry.npmjs.org/${pkgName}/latest`)).json()).version;
8
- const currentVersion = packageVersion ?? "4.0.0-beta.2";
8
+ const currentVersion = packageVersion ?? "4.0.0-beta.4";
9
9
  if (latestVersion > currentVersion) console.warn(`${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`);
10
10
  } catch (_error) {}
11
11
  };
@@ -7,7 +7,7 @@
7
7
  declare class LruMap<value = unknown> extends Map<string, value> {
8
8
  maxSize: number;
9
9
  constructor(size: number);
10
- set(key: string, value: value): this;
10
+ override set(key: string, value: value): this;
11
11
  }
12
12
  type WithDedupeOptions = {
13
13
  enabled?: boolean | undefined;
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js");
3
2
  //#region src/utils/withDedupe.ts
4
3
  /**
5
4
  * Map with a LRU (Least recently used) policy.
@@ -7,9 +6,9 @@ const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.115.
7
6
  * https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
8
7
  */
9
8
  var LruMap = class extends Map {
9
+ maxSize;
10
10
  constructor(size) {
11
11
  super();
12
- require_defineProperty._defineProperty(this, "maxSize", void 0);
13
12
  this.maxSize = size;
14
13
  }
15
14
  set(key, value) {
@@ -1 +1 @@
1
- {"version":3,"file":"withDedupe.js","names":[],"sources":["../../../src/utils/withDedupe.ts"],"sourcesContent":["/**\n * Map with a LRU (Least recently used) policy.\n *\n * https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU\n */\nexport class LruMap<value = unknown> extends Map<string, value> {\n maxSize: number\n\n constructor(size: number) {\n super()\n this.maxSize = size\n }\n\n override set(key: string, value: value): this {\n super.set(key, value)\n if (this.maxSize && this.size > this.maxSize) {\n this.delete(this.keys().next().value!)\n }\n return this\n }\n}\n\n/** @internal */\nconst promiseCache = /*#__PURE__*/ new LruMap<Promise<any>>(8192)\n\ntype WithDedupeOptions = {\n enabled?: boolean | undefined\n id?: string | undefined\n}\n\n/** Deduplicates in-flight promises. */\nexport function withDedupe<T>(\n fn: () => Promise<T>,\n { enabled = true, id }: WithDedupeOptions\n): Promise<T> {\n if (!enabled || !id) {\n return fn()\n }\n if (promiseCache.get(id)) {\n return promiseCache.get(id)!\n }\n const promise = fn().finally(() => promiseCache.delete(id))\n promiseCache.set(id, promise)\n return promise\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,SAAb,cAA6C,IAAmB;CAG9D,YAAY,MAAc;AACxB,SAAO;+CAHT,WAAA,KAAA,EAAe;AAIb,OAAK,UAAU;;CAGjB,IAAa,KAAa,OAAoB;AAC5C,QAAM,IAAI,KAAK,MAAM;AACrB,MAAI,KAAK,WAAW,KAAK,OAAO,KAAK,QACnC,MAAK,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,MAAO;AAExC,SAAO;;;;AAKX,MAAM,+BAA6B,IAAI,OAAqB,KAAK;;AAQjE,SAAgB,WACd,IACA,EAAE,UAAU,MAAM,MACN;AACZ,KAAI,CAAC,WAAW,CAAC,GACf,QAAO,IAAI;AAEb,KAAI,aAAa,IAAI,GAAG,CACtB,QAAO,aAAa,IAAI,GAAG;CAE7B,MAAM,UAAU,IAAI,CAAC,cAAc,aAAa,OAAO,GAAG,CAAC;AAC3D,cAAa,IAAI,IAAI,QAAQ;AAC7B,QAAO"}
1
+ {"version":3,"file":"withDedupe.js","names":[],"sources":["../../../src/utils/withDedupe.ts"],"sourcesContent":["/**\n * Map with a LRU (Least recently used) policy.\n *\n * https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU\n */\nexport class LruMap<value = unknown> extends Map<string, value> {\n maxSize: number\n\n constructor(size: number) {\n super()\n this.maxSize = size\n }\n\n override set(key: string, value: value): this {\n super.set(key, value)\n if (this.maxSize && this.size > this.maxSize) {\n this.delete(this.keys().next().value!)\n }\n return this\n }\n}\n\n/** @internal */\nconst promiseCache = /*#__PURE__*/ new LruMap<Promise<any>>(8192)\n\ntype WithDedupeOptions = {\n enabled?: boolean | undefined\n id?: string | undefined\n}\n\n/** Deduplicates in-flight promises. */\nexport function withDedupe<T>(\n fn: () => Promise<T>,\n { enabled = true, id }: WithDedupeOptions\n): Promise<T> {\n if (!enabled || !id) {\n return fn()\n }\n if (promiseCache.get(id)) {\n return promiseCache.get(id)!\n }\n const promise = fn().finally(() => promiseCache.delete(id))\n promiseCache.set(id, promise)\n return promise\n}\n"],"mappings":";;;;;;;AAKA,IAAa,SAAb,cAA6C,IAAmB;CAC9D;CAEA,YAAY,MAAc;AACxB,SAAO;AACP,OAAK,UAAU;;CAGjB,IAAa,KAAa,OAAoB;AAC5C,QAAM,IAAI,KAAK,MAAM;AACrB,MAAI,KAAK,WAAW,KAAK,OAAO,KAAK,QACnC,MAAK,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,MAAO;AAExC,SAAO;;;;AAKX,MAAM,+BAA6B,IAAI,OAAqB,KAAK;;AAQjE,SAAgB,WACd,IACA,EAAE,UAAU,MAAM,MACN;AACZ,KAAI,CAAC,WAAW,CAAC,GACf,QAAO,IAAI;AAEb,KAAI,aAAa,IAAI,GAAG,CACtB,QAAO,aAAa,IAAI,GAAG;CAE7B,MAAM,UAAU,IAAI,CAAC,cAAc,aAAa,OAAO,GAAG,CAAC;AAC3D,cAAa,IAAI,IAAI,QAAQ;AAC7B,QAAO"}
@@ -1,6 +1,6 @@
1
1
  //#region src/version.d.ts
2
2
  declare const name = "@lifi/sdk";
3
- declare const version = "4.0.0-beta.2";
3
+ declare const version = "4.0.0-beta.4";
4
4
  //#endregion
5
5
  export { name, version };
6
6
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/version.ts
3
3
  const name = "@lifi/sdk";
4
- const version = "4.0.0-beta.2";
4
+ const version = "4.0.0-beta.4";
5
5
  //#endregion
6
6
  exports.name = name;
7
7
  exports.version = version;
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.0.0-beta.2'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.0.0-beta.4'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
@@ -21,16 +21,16 @@ const getContractCallsQuote = async (client, params, options) => {
21
21
  "contractCalls"
22
22
  ]) if (!params[requiredParameter]) throw new SDKError(new ValidationError(`Required parameter "${requiredParameter}" is missing.`));
23
23
  if (!isContractCallsRequestWithFromAmount(params) && !isContractCallsRequestWithToAmount(params)) throw new SDKError(new ValidationError(`Required parameter "fromAmount" or "toAmount" is missing.`));
24
- params.integrator ?? (params.integrator = client.config.integrator);
25
- params.slippage ?? (params.slippage = client.config.routeOptions?.slippage);
26
- params.referrer ?? (params.referrer = client.config.routeOptions?.referrer);
27
- params.fee ?? (params.fee = client.config.routeOptions?.fee);
28
- params.allowBridges ?? (params.allowBridges = client.config.routeOptions?.bridges?.allow);
29
- params.denyBridges ?? (params.denyBridges = client.config.routeOptions?.bridges?.deny);
30
- params.preferBridges ?? (params.preferBridges = client.config.routeOptions?.bridges?.prefer);
31
- params.allowExchanges ?? (params.allowExchanges = client.config.routeOptions?.exchanges?.allow);
32
- params.denyExchanges ?? (params.denyExchanges = client.config.routeOptions?.exchanges?.deny);
33
- params.preferExchanges ?? (params.preferExchanges = client.config.routeOptions?.exchanges?.prefer);
24
+ params.integrator ??= client.config.integrator;
25
+ params.slippage ??= client.config.routeOptions?.slippage;
26
+ params.referrer ??= client.config.routeOptions?.referrer;
27
+ params.fee ??= client.config.routeOptions?.fee;
28
+ params.allowBridges ??= client.config.routeOptions?.bridges?.allow;
29
+ params.denyBridges ??= client.config.routeOptions?.bridges?.deny;
30
+ params.preferBridges ??= client.config.routeOptions?.bridges?.prefer;
31
+ params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow;
32
+ params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny;
33
+ params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer;
34
34
  return await request(client.config, `${client.config.apiUrl}/quote/contractCalls`, {
35
35
  method: "POST",
36
36
  headers: { "Content-Type": "application/json" },
@@ -1 +1 @@
1
- {"version":3,"file":"getContractCallsQuote.js","names":[],"sources":["../../../src/actions/getContractCallsQuote.ts"],"sourcesContent":["import type {\n ContractCallsQuoteRequest,\n LiFiStep,\n RequestOptions,\n} from '@lifi/types'\nimport {\n isContractCallsRequestWithFromAmount,\n isContractCallsRequestWithToAmount,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a destination contract call\n * @param client - The SDK client\n * @param params - The configuration of the requested destination call\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns - Returns step.\n */\nexport const getContractCallsQuote = async (\n client: SDKClient,\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n // validation\n const requiredParameters: Array<keyof ContractCallsQuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n 'contractCalls',\n ]\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n if (\n !isContractCallsRequestWithFromAmount(params) &&\n !isContractCallsRequestWithToAmount(params)\n ) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"fromAmount\" or \"toAmount\" is missing.`\n )\n )\n }\n // apply defaults\n // option.order is not used in this endpoint\n params.integrator ??= client.config.integrator\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n // send request\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/quote/contractCalls`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,wBAAwB,OACnC,QACA,QACA,YACsB;AAUtB,MAAK,MAAM,qBARwD;EACjE;EACA;EACA;EACA;EACA;EACA;EACD,CAEC,KAAI,CAAC,OAAO,mBACV,OAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;AAGL,KACE,CAAC,qCAAqC,OAAO,IAC7C,CAAC,mCAAmC,OAAO,CAE3C,OAAM,IAAI,SACR,IAAI,gBACF,4DACD,CACF;AAIH,QAAO,eAAP,OAAO,aAAe,OAAO,OAAO;AACpC,QAAO,aAAP,OAAO,WAAa,OAAO,OAAO,cAAc;AAChD,QAAO,aAAP,OAAO,WAAa,OAAO,OAAO,cAAc;AAChD,QAAO,QAAP,OAAO,MAAQ,OAAO,OAAO,cAAc;AAC3C,QAAO,iBAAP,OAAO,eAAiB,OAAO,OAAO,cAAc,SAAS;AAC7D,QAAO,gBAAP,OAAO,cAAgB,OAAO,OAAO,cAAc,SAAS;AAC5D,QAAO,kBAAP,OAAO,gBAAkB,OAAO,OAAO,cAAc,SAAS;AAC9D,QAAO,mBAAP,OAAO,iBAAmB,OAAO,OAAO,cAAc,WAAW;AACjE,QAAO,kBAAP,OAAO,gBAAkB,OAAO,OAAO,cAAc,WAAW;AAChE,QAAO,oBAAP,OAAO,kBAAoB,OAAO,OAAO,cAAc,WAAW;AAElE,QAAO,MAAM,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,uBACxB;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,oBACjB;EACD,MAAM,KAAK,UAAU,OAAO;EAC5B,QAAQ,SAAS;EAClB,CACF"}
1
+ {"version":3,"file":"getContractCallsQuote.js","names":[],"sources":["../../../src/actions/getContractCallsQuote.ts"],"sourcesContent":["import type {\n ContractCallsQuoteRequest,\n LiFiStep,\n RequestOptions,\n} from '@lifi/types'\nimport {\n isContractCallsRequestWithFromAmount,\n isContractCallsRequestWithToAmount,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a destination contract call\n * @param client - The SDK client\n * @param params - The configuration of the requested destination call\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns - Returns step.\n */\nexport const getContractCallsQuote = async (\n client: SDKClient,\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n // validation\n const requiredParameters: Array<keyof ContractCallsQuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n 'contractCalls',\n ]\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n if (\n !isContractCallsRequestWithFromAmount(params) &&\n !isContractCallsRequestWithToAmount(params)\n ) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"fromAmount\" or \"toAmount\" is missing.`\n )\n )\n }\n // apply defaults\n // option.order is not used in this endpoint\n params.integrator ??= client.config.integrator\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n // send request\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/quote/contractCalls`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,wBAAwB,OACnC,QACA,QACA,YACsB;AAUtB,MAAK,MAAM,qBARwD;EACjE;EACA;EACA;EACA;EACA;EACA;EACD,CAEC,KAAI,CAAC,OAAO,mBACV,OAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;AAGL,KACE,CAAC,qCAAqC,OAAO,IAC7C,CAAC,mCAAmC,OAAO,CAE3C,OAAM,IAAI,SACR,IAAI,gBACF,4DACD,CACF;AAIH,QAAO,eAAe,OAAO,OAAO;AACpC,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,QAAQ,OAAO,OAAO,cAAc;AAC3C,QAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;AAC7D,QAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;AAC5D,QAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;AAC9D,QAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;AACjE,QAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;AAChE,QAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;AAElE,QAAO,MAAM,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,uBACxB;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,oBACjB;EACD,MAAM,KAAK,UAAU,OAAO;EAC5B,QAAQ,SAAS;EAClB,CACF"}
@@ -14,17 +14,17 @@ async function getQuote(client, params, options) {
14
14
  const isToAmountRequest = "toAmount" in params && params.toAmount !== void 0;
15
15
  if (!isFromAmountRequest && !isToAmountRequest) throw new SDKError(new ValidationError("Required parameter \"fromAmount\" or \"toAmount\" is missing."));
16
16
  if (isFromAmountRequest && isToAmountRequest) throw new SDKError(new ValidationError("Cannot provide both \"fromAmount\" and \"toAmount\" parameters."));
17
- params.integrator ?? (params.integrator = client.config.integrator);
18
- params.order ?? (params.order = client.config.routeOptions?.order);
19
- params.slippage ?? (params.slippage = client.config.routeOptions?.slippage);
20
- params.referrer ?? (params.referrer = client.config.routeOptions?.referrer);
21
- params.fee ?? (params.fee = client.config.routeOptions?.fee);
22
- params.allowBridges ?? (params.allowBridges = client.config.routeOptions?.bridges?.allow);
23
- params.denyBridges ?? (params.denyBridges = client.config.routeOptions?.bridges?.deny);
24
- params.preferBridges ?? (params.preferBridges = client.config.routeOptions?.bridges?.prefer);
25
- params.allowExchanges ?? (params.allowExchanges = client.config.routeOptions?.exchanges?.allow);
26
- params.denyExchanges ?? (params.denyExchanges = client.config.routeOptions?.exchanges?.deny);
27
- params.preferExchanges ?? (params.preferExchanges = client.config.routeOptions?.exchanges?.prefer);
17
+ params.integrator ??= client.config.integrator;
18
+ params.order ??= client.config.routeOptions?.order;
19
+ params.slippage ??= client.config.routeOptions?.slippage;
20
+ params.referrer ??= client.config.routeOptions?.referrer;
21
+ params.fee ??= client.config.routeOptions?.fee;
22
+ params.allowBridges ??= client.config.routeOptions?.bridges?.allow;
23
+ params.denyBridges ??= client.config.routeOptions?.bridges?.deny;
24
+ params.preferBridges ??= client.config.routeOptions?.bridges?.prefer;
25
+ params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow;
26
+ params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny;
27
+ params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer;
28
28
  for (const key of Object.keys(params)) if (params[key] === void 0 || params[key] === null) delete params[key];
29
29
  return await request(client.config, `${client.config.apiUrl}/${isFromAmountRequest ? "quote" : "quote/toAmount"}?${new URLSearchParams(params)}`, { signal: options?.signal });
30
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getQuote.js","names":[],"sources":["../../../src/actions/getQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type {\n QuoteRequest,\n QuoteRequestFromAmount,\n QuoteRequestToAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Quote for a token transfer\n */\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestToAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> {\n const requiredParameters: Array<keyof QuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n ]\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const isFromAmountRequest =\n 'fromAmount' in params && params.fromAmount !== undefined\n const isToAmountRequest =\n 'toAmount' in params && params.toAmount !== undefined\n\n if (!isFromAmountRequest && !isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Required parameter \"fromAmount\" or \"toAmount\" is missing.'\n )\n )\n }\n\n if (isFromAmountRequest && isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Cannot provide both \"fromAmount\" and \"toAmount\" parameters.'\n )\n )\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${new URLSearchParams(\n params as unknown as Record<string, string>\n )}`,\n {\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;AA6BA,eAAsB,SACpB,QACA,QACA,SACmB;AASnB,MAAK,MAAM,qBAR2C;EACpD;EACA;EACA;EACA;EACA;EACD,CAGC,KAAI,CAAC,OAAO,mBACV,OAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;CAIL,MAAM,sBACJ,gBAAgB,UAAU,OAAO,eAAe,KAAA;CAClD,MAAM,oBACJ,cAAc,UAAU,OAAO,aAAa,KAAA;AAE9C,KAAI,CAAC,uBAAuB,CAAC,kBAC3B,OAAM,IAAI,SACR,IAAI,gBACF,gEACD,CACF;AAGH,KAAI,uBAAuB,kBACzB,OAAM,IAAI,SACR,IAAI,gBACF,kEACD,CACF;AAIH,QAAO,eAAP,OAAO,aAAe,OAAO,OAAO;AACpC,QAAO,UAAP,OAAO,QAAU,OAAO,OAAO,cAAc;AAC7C,QAAO,aAAP,OAAO,WAAa,OAAO,OAAO,cAAc;AAChD,QAAO,aAAP,OAAO,WAAa,OAAO,OAAO,cAAc;AAChD,QAAO,QAAP,OAAO,MAAQ,OAAO,OAAO,cAAc;AAC3C,QAAO,iBAAP,OAAO,eAAiB,OAAO,OAAO,cAAc,SAAS;AAC7D,QAAO,gBAAP,OAAO,cAAgB,OAAO,OAAO,cAAc,SAAS;AAC5D,QAAO,kBAAP,OAAO,gBAAkB,OAAO,OAAO,cAAc,SAAS;AAC9D,QAAO,mBAAP,OAAO,iBAAmB,OAAO,OAAO,cAAc,WAAW;AACjE,QAAO,kBAAP,OAAO,gBAAkB,OAAO,OAAO,cAAc,WAAW;AAChE,QAAO,oBAAP,OAAO,kBAAoB,OAAO,OAAO,cAAc,WAAW;AAElE,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,KACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,KAEtC,QAAO,OAAO;AAIlB,QAAO,MAAM,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,GAAG,sBAAsB,UAAU,iBAAiB,GAAG,IAAI,gBACjF,OACD,IACD,EACE,QAAQ,SAAS,QAClB,CACF"}
1
+ {"version":3,"file":"getQuote.js","names":[],"sources":["../../../src/actions/getQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type {\n QuoteRequest,\n QuoteRequestFromAmount,\n QuoteRequestToAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Quote for a token transfer\n */\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestToAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> {\n const requiredParameters: Array<keyof QuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n ]\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const isFromAmountRequest =\n 'fromAmount' in params && params.fromAmount !== undefined\n const isToAmountRequest =\n 'toAmount' in params && params.toAmount !== undefined\n\n if (!isFromAmountRequest && !isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Required parameter \"fromAmount\" or \"toAmount\" is missing.'\n )\n )\n }\n\n if (isFromAmountRequest && isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Cannot provide both \"fromAmount\" and \"toAmount\" parameters.'\n )\n )\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${new URLSearchParams(\n params as unknown as Record<string, string>\n )}`,\n {\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;AA6BA,eAAsB,SACpB,QACA,QACA,SACmB;AASnB,MAAK,MAAM,qBAR2C;EACpD;EACA;EACA;EACA;EACA;EACD,CAGC,KAAI,CAAC,OAAO,mBACV,OAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;CAIL,MAAM,sBACJ,gBAAgB,UAAU,OAAO,eAAe,KAAA;CAClD,MAAM,oBACJ,cAAc,UAAU,OAAO,aAAa,KAAA;AAE9C,KAAI,CAAC,uBAAuB,CAAC,kBAC3B,OAAM,IAAI,SACR,IAAI,gBACF,gEACD,CACF;AAGH,KAAI,uBAAuB,kBACzB,OAAM,IAAI,SACR,IAAI,gBACF,kEACD,CACF;AAIH,QAAO,eAAe,OAAO,OAAO;AACpC,QAAO,UAAU,OAAO,OAAO,cAAc;AAC7C,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,QAAQ,OAAO,OAAO,cAAc;AAC3C,QAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;AAC7D,QAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;AAC5D,QAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;AAC9D,QAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;AACjE,QAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;AAChE,QAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;AAElE,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,KACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,KAEtC,QAAO,OAAO;AAIlB,QAAO,MAAM,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,GAAG,sBAAsB,UAAU,iBAAiB,GAAG,IAAI,gBACjF,OACD,IACD,EACE,QAAQ,SAAS,QAClB,CACF"}
@@ -21,17 +21,17 @@ const getRelayerQuote = async (client, params, options) => {
21
21
  "toChain",
22
22
  "toToken"
23
23
  ]) if (!params[requiredParameter]) throw new SDKError(new ValidationError(`Required parameter "${requiredParameter}" is missing.`));
24
- params.integrator ?? (params.integrator = client.config.integrator);
25
- params.order ?? (params.order = client.config.routeOptions?.order);
26
- params.slippage ?? (params.slippage = client.config.routeOptions?.slippage);
27
- params.referrer ?? (params.referrer = client.config.routeOptions?.referrer);
28
- params.fee ?? (params.fee = client.config.routeOptions?.fee);
29
- params.allowBridges ?? (params.allowBridges = client.config.routeOptions?.bridges?.allow);
30
- params.denyBridges ?? (params.denyBridges = client.config.routeOptions?.bridges?.deny);
31
- params.preferBridges ?? (params.preferBridges = client.config.routeOptions?.bridges?.prefer);
32
- params.allowExchanges ?? (params.allowExchanges = client.config.routeOptions?.exchanges?.allow);
33
- params.denyExchanges ?? (params.denyExchanges = client.config.routeOptions?.exchanges?.deny);
34
- params.preferExchanges ?? (params.preferExchanges = client.config.routeOptions?.exchanges?.prefer);
24
+ params.integrator ??= client.config.integrator;
25
+ params.order ??= client.config.routeOptions?.order;
26
+ params.slippage ??= client.config.routeOptions?.slippage;
27
+ params.referrer ??= client.config.routeOptions?.referrer;
28
+ params.fee ??= client.config.routeOptions?.fee;
29
+ params.allowBridges ??= client.config.routeOptions?.bridges?.allow;
30
+ params.denyBridges ??= client.config.routeOptions?.bridges?.deny;
31
+ params.preferBridges ??= client.config.routeOptions?.bridges?.prefer;
32
+ params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow;
33
+ params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny;
34
+ params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer;
35
35
  for (const key of Object.keys(params)) if (params[key] === void 0 || params[key] === null) delete params[key];
36
36
  const result = await request(client.config, `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(params)}`, { signal: options?.signal });
37
37
  if (result.status === "error") throw new BaseError(ErrorName.ServerError, result.data.code, result.data.message);
@@ -1 +1 @@
1
- {"version":3,"file":"getRelayerQuote.js","names":[],"sources":["../../../src/actions/getRelayerQuote.ts"],"sourcesContent":["import type {\n LiFiStep,\n RelayerQuoteResponse,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { QuoteRequest, QuoteRequestFromAmount } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a relayer quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Relayer quote for a token transfer\n */\nexport const getRelayerQuote = async (\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n const requiredParameters: Array<keyof QuoteRequestFromAmount> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'fromAmount',\n 'toChain',\n 'toToken',\n ]\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n const result = await request<RelayerQuoteResponse>(\n client.config,\n `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(\n params as unknown as Record<string, string>\n )}`,\n {\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAa,kBAAkB,OAC7B,QACA,QACA,YACsB;AAStB,MAAK,MAAM,qBARqD;EAC9D;EACA;EACA;EACA;EACA;EACA;EACD,CAEC,KAAI,CAAC,OAAO,mBACV,OAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;AAKL,QAAO,eAAP,OAAO,aAAe,OAAO,OAAO;AACpC,QAAO,UAAP,OAAO,QAAU,OAAO,OAAO,cAAc;AAC7C,QAAO,aAAP,OAAO,WAAa,OAAO,OAAO,cAAc;AAChD,QAAO,aAAP,OAAO,WAAa,OAAO,OAAO,cAAc;AAChD,QAAO,QAAP,OAAO,MAAQ,OAAO,OAAO,cAAc;AAC3C,QAAO,iBAAP,OAAO,eAAiB,OAAO,OAAO,cAAc,SAAS;AAC7D,QAAO,gBAAP,OAAO,cAAgB,OAAO,OAAO,cAAc,SAAS;AAC5D,QAAO,kBAAP,OAAO,gBAAkB,OAAO,OAAO,cAAc,SAAS;AAC9D,QAAO,mBAAP,OAAO,iBAAmB,OAAO,OAAO,cAAc,WAAW;AACjE,QAAO,kBAAP,OAAO,gBAAkB,OAAO,OAAO,cAAc,WAAW;AAChE,QAAO,oBAAP,OAAO,kBAAoB,OAAO,OAAO,cAAc,WAAW;AAElE,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,KACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,KAEtC,QAAO,OAAO;CAIlB,MAAM,SAAS,MAAM,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,iBAAiB,IAAI,gBAC3C,OACD,IACD,EACE,QAAQ,SAAS,QAClB,CACF;AAED,KAAI,OAAO,WAAW,QACpB,OAAM,IAAI,UACR,UAAU,aACV,OAAO,KAAK,MACZ,OAAO,KAAK,QACb;AAGH,QAAO,OAAO"}
1
+ {"version":3,"file":"getRelayerQuote.js","names":[],"sources":["../../../src/actions/getRelayerQuote.ts"],"sourcesContent":["import type {\n LiFiStep,\n RelayerQuoteResponse,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { QuoteRequest, QuoteRequestFromAmount } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a relayer quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Relayer quote for a token transfer\n */\nexport const getRelayerQuote = async (\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n const requiredParameters: Array<keyof QuoteRequestFromAmount> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'fromAmount',\n 'toChain',\n 'toToken',\n ]\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n const result = await request<RelayerQuoteResponse>(\n client.config,\n `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(\n params as unknown as Record<string, string>\n )}`,\n {\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAa,kBAAkB,OAC7B,QACA,QACA,YACsB;AAStB,MAAK,MAAM,qBARqD;EAC9D;EACA;EACA;EACA;EACA;EACA;EACD,CAEC,KAAI,CAAC,OAAO,mBACV,OAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;AAKL,QAAO,eAAe,OAAO,OAAO;AACpC,QAAO,UAAU,OAAO,OAAO,cAAc;AAC7C,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,QAAQ,OAAO,OAAO,cAAc;AAC3C,QAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;AAC7D,QAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;AAC5D,QAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;AAC9D,QAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;AACjE,QAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;AAChE,QAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;AAElE,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,KACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,KAEtC,QAAO,OAAO;CAIlB,MAAM,SAAS,MAAM,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,iBAAiB,IAAI,gBAC3C,OACD,IACD,EACE,QAAQ,SAAS,QAClB,CACF;AAED,KAAI,OAAO,WAAW,QACpB,OAAM,IAAI,UACR,UAAU,aACV,OAAO,KAAK,MACZ,OAAO,KAAK,QACb;AAGH,QAAO,OAAO"}