@lifi/sdk-provider-stellar 4.3.5 → 4.3.7

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @lifi/sdk-provider-stellar
2
2
 
3
+ ## 4.3.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#505](https://github.com/lifinance/sdk/pull/505) [`56f9913`](https://github.com/lifinance/sdk/commit/56f9913ccbc0508c94122baf3b7bbbcaa867d95b) Thanks [@chybisov](https://github.com/chybisov)! - Pick the first pipeline task by class reference instead of by class name. In builds that mangle class names, a step could start or resume at the wrong task — for example, an unneeded `approve()` before a native-token swap.
8
+
9
+ ## 4.3.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [#500](https://github.com/lifinance/sdk/pull/500) [`6ffd1be`](https://github.com/lifinance/sdk/commit/6ffd1be6f6c2bd2b7f00cde9bcc72dfee56afe3d) Thanks [@chybisov](https://github.com/chybisov)! - Bump runtime dependencies: viem to 2.57.1, @solana/kit to 8.4.0, @stellar/stellar-sdk to
14
+ 17.2.0 and @mysten/sui to 2.33.2.
15
+
3
16
  ## 4.3.5
4
17
 
5
18
  ### Patch Changes
@@ -40,8 +40,9 @@ var StellarStepExecutor = class extends BaseStepExecutor {
40
40
  new WaitForTransactionStatusTask(isBridgeExecution ? "RECEIVING_CHAIN" : "SWAP")
41
41
  ];
42
42
  const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
43
- const taskName = swapOrBridgeAction?.txHash ? swapOrBridgeAction.status === "DONE" ? WaitForTransactionStatusTask.name : StellarWaitForTransactionTask.name : CheckBalanceTask.name;
44
- const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
43
+ const firstTask = swapOrBridgeAction?.txHash ? swapOrBridgeAction.status === "DONE" ? WaitForTransactionStatusTask : StellarWaitForTransactionTask : CheckBalanceTask;
44
+ const firstTaskIndex = tasks.findIndex((task) => task.constructor === firstTask);
45
+ if (firstTaskIndex === -1) throw new TransactionError(LiFiErrorCode.InternalError, "StellarStepExecutor.createPipeline: first task not found");
45
46
  const tasksToRun = tasks.slice(firstTaskIndex);
46
47
  return new TaskPipeline(tasksToRun);
47
48
  };
@@ -1 +1 @@
1
- {"version":3,"file":"StellarStepExecutor.js","names":[],"sources":["../../../src/core/StellarStepExecutor.ts"],"sourcesContent":["import {\n BaseStepExecutor,\n CheckBalanceTask,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n type SDKError,\n type StepExecutorBaseContext,\n TaskPipeline,\n TransactionError,\n WaitForTransactionStatusTask,\n} from '@lifi/sdk'\nimport { parseStellarErrors } from '../errors/parseStellarErrors.js'\nimport type {\n StellarStepExecutorContext,\n StellarStepExecutorOptions,\n StellarWallet,\n} from '../types.js'\nimport { StellarCheckAllowanceTask } from './tasks/StellarCheckAllowanceTask.js'\nimport { StellarPrepareTransactionTask } from './tasks/StellarPrepareTransactionTask.js'\nimport { StellarSetAllowanceTask } from './tasks/StellarSetAllowanceTask.js'\nimport { StellarSignAndExecuteTask } from './tasks/StellarSignAndExecuteTask.js'\nimport { StellarWaitForTransactionTask } from './tasks/StellarWaitForTransactionTask.js'\n\nexport class StellarStepExecutor extends BaseStepExecutor {\n private wallet: StellarWallet\n private networkPassphrase: string\n\n constructor(options: StellarStepExecutorOptions) {\n super(options)\n this.wallet = options.wallet\n this.networkPassphrase = options.networkPassphrase\n }\n\n checkWallet = (step: LiFiStepExtended): void => {\n // Prevent execution of the quote by wallet different from the one which requested the quote\n if (this.wallet.address !== step.action.fromAddress) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n\n // The provider resolves this from options first and the wallet second, so a\n // disagreement means the integrator configured one network while the user\n // connected to another. Signing would produce a txBAD_AUTH the user pays\n // for in a wasted signature.\n if (this.networkPassphrase !== this.wallet.networkPassphrase) {\n throw new TransactionError(\n LiFiErrorCode.ChainSwitchError,\n 'The connected Stellar wallet is on a different network than the route.'\n )\n }\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction\n ): Promise<SDKError> => parseStellarErrors(error, step, action)\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<StellarStepExecutorContext> => {\n return {\n ...baseContext,\n pollingIntervalMs: 3_000,\n wallet: this.wallet,\n networkPassphrase: this.networkPassphrase,\n checkWallet: this.checkWallet,\n }\n }\n\n override createPipeline = (\n context: StellarStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution } = context\n\n // Order is load-bearing: the allowance tasks must complete before the\n // transaction is prepared. Granting an allowance submits a transaction that\n // consumes the sender's sequence number, and the backend builds the route\n // envelope from a live account read — so an envelope prepared first would be\n // invalidated by the approval that follows it.\n const tasks = [\n new CheckBalanceTask(),\n new StellarCheckAllowanceTask(),\n new StellarSetAllowanceTask(),\n new StellarPrepareTransactionTask(),\n new StellarSignAndExecuteTask(),\n new StellarWaitForTransactionTask(),\n new WaitForTransactionStatusTask(\n isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'\n ),\n ]\n\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n // Three-way entry, as Bitcoin does. Stellar derives and persists the\n // transaction hash BEFORE submitting, so a hash on the action means an\n // envelope was signed and very likely broadcast. Resuming such a step at\n // CheckBalanceTask would re-prepare, re-sign and submit a SECOND\n // transaction — executing the swap twice. Resume at the confirmation poll\n // instead and let the already-broadcast transaction settle.\n const taskName = swapOrBridgeAction?.txHash\n ? swapOrBridgeAction.status === 'DONE'\n ? WaitForTransactionStatusTask.name\n : StellarWaitForTransactionTask.name\n : CheckBalanceTask.name\n\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor.name === taskName\n )\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n}\n"],"mappings":";;;;;;;;AAwBA,IAAa,sBAAb,cAAyC,iBAAiB;CACxD;CACA;CAEA,YAAY,SAAqC;EAC/C,MAAM,OAAO;EACb,KAAK,SAAS,QAAQ;EACtB,KAAK,oBAAoB,QAAQ;CACnC;CAEA,eAAe,SAAiC;EAE9C,IAAI,KAAK,OAAO,YAAY,KAAK,OAAO,aACtC,MAAM,IAAI,iBACR,cAAc,8BACd,mHACF;EAOF,IAAI,KAAK,sBAAsB,KAAK,OAAO,mBACzC,MAAM,IAAI,iBACR,cAAc,kBACd,wEACF;CAEJ;CAEA,eACE,OACA,MACA,WACsB,mBAAmB,OAAO,MAAM,MAAM;CAE9D,gBAAyB,OACvB,gBACwC;EACxC,OAAO;GACL,GAAG;GACH,mBAAmB;GACnB,QAAQ,KAAK;GACb,mBAAmB,KAAK;GACxB,aAAa,KAAK;EACpB;CACF;CAEA,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,sBAAsB;EAOpC,MAAM,QAAQ;GACZ,IAAI,iBAAiB;GACrB,IAAI,0BAA0B;GAC9B,IAAI,wBAAwB;GAC5B,IAAI,8BAA8B;GAClC,IAAI,0BAA0B;GAC9B,IAAI,8BAA8B;GAClC,IAAI,6BACF,oBAAoB,oBAAoB,MAC1C;EACF;EAEA,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,MACtC;EAQA,MAAM,WAAW,oBAAoB,SACjC,mBAAmB,WAAW,SAC5B,6BAA6B,OAC7B,8BAA8B,OAChC,iBAAiB;EAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,QACtC;EAEA,MAAM,aAAa,MAAM,MAAM,cAAc;EAE7C,OAAO,IAAI,aAAa,UAAU;CACpC;AACF"}
1
+ {"version":3,"file":"StellarStepExecutor.js","names":[],"sources":["../../../src/core/StellarStepExecutor.ts"],"sourcesContent":["import {\n BaseStepExecutor,\n CheckBalanceTask,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n type SDKError,\n type StepExecutorBaseContext,\n TaskPipeline,\n TransactionError,\n WaitForTransactionStatusTask,\n} from '@lifi/sdk'\nimport { parseStellarErrors } from '../errors/parseStellarErrors.js'\nimport type {\n StellarStepExecutorContext,\n StellarStepExecutorOptions,\n StellarWallet,\n} from '../types.js'\nimport { StellarCheckAllowanceTask } from './tasks/StellarCheckAllowanceTask.js'\nimport { StellarPrepareTransactionTask } from './tasks/StellarPrepareTransactionTask.js'\nimport { StellarSetAllowanceTask } from './tasks/StellarSetAllowanceTask.js'\nimport { StellarSignAndExecuteTask } from './tasks/StellarSignAndExecuteTask.js'\nimport { StellarWaitForTransactionTask } from './tasks/StellarWaitForTransactionTask.js'\n\nexport class StellarStepExecutor extends BaseStepExecutor {\n private wallet: StellarWallet\n private networkPassphrase: string\n\n constructor(options: StellarStepExecutorOptions) {\n super(options)\n this.wallet = options.wallet\n this.networkPassphrase = options.networkPassphrase\n }\n\n checkWallet = (step: LiFiStepExtended): void => {\n // Prevent execution of the quote by wallet different from the one which requested the quote\n if (this.wallet.address !== step.action.fromAddress) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n\n // The provider resolves this from options first and the wallet second, so a\n // disagreement means the integrator configured one network while the user\n // connected to another. Signing would produce a txBAD_AUTH the user pays\n // for in a wasted signature.\n if (this.networkPassphrase !== this.wallet.networkPassphrase) {\n throw new TransactionError(\n LiFiErrorCode.ChainSwitchError,\n 'The connected Stellar wallet is on a different network than the route.'\n )\n }\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction\n ): Promise<SDKError> => parseStellarErrors(error, step, action)\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<StellarStepExecutorContext> => {\n return {\n ...baseContext,\n pollingIntervalMs: 3_000,\n wallet: this.wallet,\n networkPassphrase: this.networkPassphrase,\n checkWallet: this.checkWallet,\n }\n }\n\n override createPipeline = (\n context: StellarStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution } = context\n\n // Order is load-bearing: the allowance tasks must complete before the\n // transaction is prepared. Granting an allowance submits a transaction that\n // consumes the sender's sequence number, and the backend builds the route\n // envelope from a live account read — so an envelope prepared first would be\n // invalidated by the approval that follows it.\n const tasks = [\n new CheckBalanceTask(),\n new StellarCheckAllowanceTask(),\n new StellarSetAllowanceTask(),\n new StellarPrepareTransactionTask(),\n new StellarSignAndExecuteTask(),\n new StellarWaitForTransactionTask(),\n new WaitForTransactionStatusTask(\n isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'\n ),\n ]\n\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n // Three-way entry, as Bitcoin does. Stellar derives and persists the\n // transaction hash BEFORE submitting, so a hash on the action means an\n // envelope was signed and very likely broadcast. Resuming such a step at\n // CheckBalanceTask would re-prepare, re-sign and submit a SECOND\n // transaction — executing the swap twice. Resume at the confirmation poll\n // instead and let the already-broadcast transaction settle.\n const firstTask = swapOrBridgeAction?.txHash\n ? swapOrBridgeAction.status === 'DONE'\n ? WaitForTransactionStatusTask\n : StellarWaitForTransactionTask\n : CheckBalanceTask\n\n // Compare classes, not names: a minifier can give two task classes the\n // same name.\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor === firstTask\n )\n if (firstTaskIndex === -1) {\n throw new TransactionError(\n LiFiErrorCode.InternalError,\n 'StellarStepExecutor.createPipeline: first task not found'\n )\n }\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n}\n"],"mappings":";;;;;;;;AAwBA,IAAa,sBAAb,cAAyC,iBAAiB;CACxD;CACA;CAEA,YAAY,SAAqC;EAC/C,MAAM,OAAO;EACb,KAAK,SAAS,QAAQ;EACtB,KAAK,oBAAoB,QAAQ;CACnC;CAEA,eAAe,SAAiC;EAE9C,IAAI,KAAK,OAAO,YAAY,KAAK,OAAO,aACtC,MAAM,IAAI,iBACR,cAAc,8BACd,mHACF;EAOF,IAAI,KAAK,sBAAsB,KAAK,OAAO,mBACzC,MAAM,IAAI,iBACR,cAAc,kBACd,wEACF;CAEJ;CAEA,eACE,OACA,MACA,WACsB,mBAAmB,OAAO,MAAM,MAAM;CAE9D,gBAAyB,OACvB,gBACwC;EACxC,OAAO;GACL,GAAG;GACH,mBAAmB;GACnB,QAAQ,KAAK;GACb,mBAAmB,KAAK;GACxB,aAAa,KAAK;EACpB;CACF;CAEA,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,sBAAsB;EAOpC,MAAM,QAAQ;GACZ,IAAI,iBAAiB;GACrB,IAAI,0BAA0B;GAC9B,IAAI,wBAAwB;GAC5B,IAAI,8BAA8B;GAClC,IAAI,0BAA0B;GAC9B,IAAI,8BAA8B;GAClC,IAAI,6BACF,oBAAoB,oBAAoB,MAC1C;EACF;EAEA,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,MACtC;EAQA,MAAM,YAAY,oBAAoB,SAClC,mBAAmB,WAAW,SAC5B,+BACA,gCACF;EAIJ,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,gBAAgB,SACjC;EACA,IAAI,mBAAmB,IACrB,MAAM,IAAI,iBACR,cAAc,eACd,0DACF;EAGF,MAAM,aAAa,MAAM,MAAM,cAAc;EAE7C,OAAO,IAAI,aAAa,UAAU;CACpC;AACF"}
@@ -1,5 +1,5 @@
1
1
  //#region src/version.d.ts
2
2
  export declare const name = "@lifi/sdk-provider-stellar";
3
- export declare const version = "4.3.5";
3
+ export declare const version = "4.3.7";
4
4
  //#endregion
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
2
  const name = "@lifi/sdk-provider-stellar";
3
- const version = "4.3.5";
3
+ const version = "4.3.7";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-stellar'\nexport const version = '4.3.5'\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-provider-stellar'\nexport const version = '4.3.7'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk-provider-stellar",
3
- "version": "4.3.5",
3
+ "version": "4.3.7",
4
4
  "description": "LI.FI Stellar SDK Provider for Any-to-Any Cross-Chain-Swap",
5
5
  "homepage": "https://github.com/lifinance/sdk",
6
6
  "bugs": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@lifi/sdk": "4.10.0",
32
- "@stellar/stellar-sdk": "^17.1.0"
32
+ "@stellar/stellar-sdk": "^17.2.0"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
@@ -104,15 +104,23 @@ export class StellarStepExecutor extends BaseStepExecutor {
104
104
  // CheckBalanceTask would re-prepare, re-sign and submit a SECOND
105
105
  // transaction — executing the swap twice. Resume at the confirmation poll
106
106
  // instead and let the already-broadcast transaction settle.
107
- const taskName = swapOrBridgeAction?.txHash
107
+ const firstTask = swapOrBridgeAction?.txHash
108
108
  ? swapOrBridgeAction.status === 'DONE'
109
- ? WaitForTransactionStatusTask.name
110
- : StellarWaitForTransactionTask.name
111
- : CheckBalanceTask.name
109
+ ? WaitForTransactionStatusTask
110
+ : StellarWaitForTransactionTask
111
+ : CheckBalanceTask
112
112
 
113
+ // Compare classes, not names: a minifier can give two task classes the
114
+ // same name.
113
115
  const firstTaskIndex = tasks.findIndex(
114
- (task) => task.constructor.name === taskName
116
+ (task) => task.constructor === firstTask
115
117
  )
118
+ if (firstTaskIndex === -1) {
119
+ throw new TransactionError(
120
+ LiFiErrorCode.InternalError,
121
+ 'StellarStepExecutor.createPipeline: first task not found'
122
+ )
123
+ }
116
124
 
117
125
  const tasksToRun = tasks.slice(firstTaskIndex)
118
126
 
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk-provider-stellar'
2
- export const version = '4.3.5'
2
+ export const version = '4.3.7'