@lifi/sdk-provider-stellar 0.0.0-preview-306a9fec → 4.2.0
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 +7 -7
- package/dist/esm/core/StellarStepExecutor.js +2 -1
- package/dist/esm/core/StellarStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/helpers/readAllowance.js +2 -1
- package/dist/esm/core/tasks/helpers/readAllowance.js.map +1 -1
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.js +1 -1
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.js.map +1 -1
- package/dist/esm/errors/parseStellarErrors.js +2 -1
- package/dist/esm/errors/parseStellarErrors.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +3 -3
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# @lifi/sdk-provider-stellar
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 4.2.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
- [
|
|
8
|
-
|
|
7
|
+
- [`fd1e9b5`](https://github.com/lifinance/sdk/commit/fd1e9b5ff481b35683d7b8557011c9c726446cdd) Thanks [@chybisov](https://github.com/chybisov)! - Add Stellar (STL) ecosystem support. Introduces the `@lifi/sdk-provider-stellar` package — address validation, Federation resolution, SAC-based balance reads, and route execution via `StellarStepExecutor` — and registers `ChainType.STL` in the SDK client's chain fetching so Stellar chains and RPC URLs load.
|
|
8
|
+
|
|
9
9
|
Execution signs the backend-generated Soroban envelope with the connected wallet, submits it over Stellar RPC, waits for on-chain confirmation, then tracks the transfer through the LI.FI status API. Because a Stellar envelope embeds the sender's account sequence number and a short-lived set of timebounds, the provider always requests a freshly built transaction immediately before signing rather than reusing the one attached to the quote. SAC allowances are granted first when a step requires one, and the approval is confirmed on-chain before the route transaction is requested.
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
`PrepareTransactionTask` gains a `shouldRefetchTransaction` hook. It defaults to the previous behaviour — fetch only when the step carries no transaction request — and the Stellar task overrides it, because a Stellar envelope embeds the sender's sequence number and cannot be reused.
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
`StellarProviderOptions.horizonUrl` is gone — nothing read it — and `StellarWallet.signAuthEntry` is now optional, because the router routes use source-account auth and the SDK never calls it. The provider also exports `DEFAULT_NETWORK_PASSPHRASE`, and refuses to sign when the connected wallet's network disagrees with the configured one.
|
|
14
14
|
|
|
15
15
|
### Patch Changes
|
|
16
16
|
|
|
17
|
-
- Updated dependencies [[`
|
|
18
|
-
- @lifi/sdk@
|
|
17
|
+
- Updated dependencies [[`fd1e9b5`](https://github.com/lifinance/sdk/commit/fd1e9b5ff481b35683d7b8557011c9c726446cdd)]:
|
|
18
|
+
- @lifi/sdk@4.4.0
|
|
@@ -42,7 +42,8 @@ var StellarStepExecutor = class extends BaseStepExecutor {
|
|
|
42
42
|
const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
43
43
|
const taskName = swapOrBridgeAction?.txHash ? swapOrBridgeAction.status === "DONE" ? WaitForTransactionStatusTask.name : StellarWaitForTransactionTask.name : CheckBalanceTask.name;
|
|
44
44
|
const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
|
|
45
|
-
|
|
45
|
+
const tasksToRun = tasks.slice(firstTaskIndex);
|
|
46
|
+
return new TaskPipeline(tasksToRun);
|
|
46
47
|
};
|
|
47
48
|
};
|
|
48
49
|
//#endregion
|
|
@@ -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;
|
|
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"}
|
|
@@ -14,7 +14,8 @@ import { Api } from "@stellar/stellar-sdk/rpc";
|
|
|
14
14
|
* is not retried against every RPC and is not buried in an `AggregateError`.
|
|
15
15
|
*/
|
|
16
16
|
const readAllowance = async (client, token, from, spender, networkPassphrase) => {
|
|
17
|
-
const
|
|
17
|
+
const source = new Account(from, "0");
|
|
18
|
+
const transaction = new TransactionBuilder(source, {
|
|
18
19
|
fee: BASE_FEE,
|
|
19
20
|
networkPassphrase
|
|
20
21
|
}).addOperation(new Contract(token).call("allowance", Address.fromString(from).toScVal(), Address.fromString(spender).toScVal())).setTimeout(30).build();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAllowance.js","names":[],"sources":["../../../../../src/core/tasks/helpers/readAllowance.ts"],"sourcesContent":["import { LiFiErrorCode, type SDKClient, TransactionError } from '@lifi/sdk'\nimport {\n Account,\n Address,\n BASE_FEE,\n Contract,\n scValToNative,\n TransactionBuilder,\n} from '@stellar/stellar-sdk'\nimport { Api } from '@stellar/stellar-sdk/rpc'\nimport { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'\n\n/**\n * Reads the SAC `allowance(from, spender)` via read-only simulation.\n *\n * An absent or expired allowance entry reads back as `0`, so callers can treat\n * the result as a plain numeric comparison without a separate existence check.\n *\n * The simulation is the only part that goes through `callStellarRpcsWithRetry`;\n * the result is classified outside it, so a deterministic contract-level failure\n * is not retried against every RPC and is not buried in an `AggregateError`.\n */\nexport const readAllowance = async (\n client: SDKClient,\n token: string,\n from: string,\n spender: string,\n networkPassphrase: string\n): Promise<bigint> => {\n // A zero-sequence account is sufficient for read-only simulation, and one\n // built envelope is reusable across servers because nothing about it is\n // server-specific.\n const source = new Account(from, '0')\n const transaction = new TransactionBuilder(source, {\n fee: BASE_FEE,\n networkPassphrase,\n })\n .addOperation(\n new Contract(token).call(\n 'allowance',\n Address.fromString(from).toScVal(),\n Address.fromString(spender).toScVal()\n )\n )\n .setTimeout(30)\n .build()\n\n // Only the transport call goes through the failover wrapper. It collapses\n // everything its callback throws into an `AggregateError`, so classifying\n // inside it would hide the error below from `parseStellarErrors`.\n const simulation = await callStellarRpcsWithRetry(client, (server) =>\n server.simulateTransaction(transaction)\n )\n\n // Fail rather than degrade to 0n: an unreadable allowance treated as \"needs\n // approval\" would prompt the user for an approval that cannot help.\n if (!Api.isSimulationSuccess(simulation) || !simulation.result) {\n throw new TransactionError(\n LiFiErrorCode.TransactionSimulationFailed,\n `Could not read the ${token} spending allowance for ${spender}${\n Api.isSimulationError(simulation) ? `: ${simulation.error}` : ''\n }`\n )\n }\n const allowance = scValToNative(simulation.result.retval)\n return allowance != null ? BigInt(allowance) : 0n\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAa,gBAAgB,OAC3B,QACA,OACA,MACA,SACA,sBACoB;
|
|
1
|
+
{"version":3,"file":"readAllowance.js","names":[],"sources":["../../../../../src/core/tasks/helpers/readAllowance.ts"],"sourcesContent":["import { LiFiErrorCode, type SDKClient, TransactionError } from '@lifi/sdk'\nimport {\n Account,\n Address,\n BASE_FEE,\n Contract,\n scValToNative,\n TransactionBuilder,\n} from '@stellar/stellar-sdk'\nimport { Api } from '@stellar/stellar-sdk/rpc'\nimport { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'\n\n/**\n * Reads the SAC `allowance(from, spender)` via read-only simulation.\n *\n * An absent or expired allowance entry reads back as `0`, so callers can treat\n * the result as a plain numeric comparison without a separate existence check.\n *\n * The simulation is the only part that goes through `callStellarRpcsWithRetry`;\n * the result is classified outside it, so a deterministic contract-level failure\n * is not retried against every RPC and is not buried in an `AggregateError`.\n */\nexport const readAllowance = async (\n client: SDKClient,\n token: string,\n from: string,\n spender: string,\n networkPassphrase: string\n): Promise<bigint> => {\n // A zero-sequence account is sufficient for read-only simulation, and one\n // built envelope is reusable across servers because nothing about it is\n // server-specific.\n const source = new Account(from, '0')\n const transaction = new TransactionBuilder(source, {\n fee: BASE_FEE,\n networkPassphrase,\n })\n .addOperation(\n new Contract(token).call(\n 'allowance',\n Address.fromString(from).toScVal(),\n Address.fromString(spender).toScVal()\n )\n )\n .setTimeout(30)\n .build()\n\n // Only the transport call goes through the failover wrapper. It collapses\n // everything its callback throws into an `AggregateError`, so classifying\n // inside it would hide the error below from `parseStellarErrors`.\n const simulation = await callStellarRpcsWithRetry(client, (server) =>\n server.simulateTransaction(transaction)\n )\n\n // Fail rather than degrade to 0n: an unreadable allowance treated as \"needs\n // approval\" would prompt the user for an approval that cannot help.\n if (!Api.isSimulationSuccess(simulation) || !simulation.result) {\n throw new TransactionError(\n LiFiErrorCode.TransactionSimulationFailed,\n `Could not read the ${token} spending allowance for ${spender}${\n Api.isSimulationError(simulation) ? `: ${simulation.error}` : ''\n }`\n )\n }\n const allowance = scValToNative(simulation.result.retval)\n return allowance != null ? BigInt(allowance) : 0n\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAa,gBAAgB,OAC3B,QACA,OACA,MACA,SACA,sBACoB;CAIpB,MAAM,SAAS,IAAI,QAAQ,MAAM,GAAG;CACpC,MAAM,cAAc,IAAI,mBAAmB,QAAQ;EACjD,KAAK;EACL;CACF,CAAC,CAAC,CACC,aACC,IAAI,SAAS,KAAK,CAAC,CAAC,KAClB,aACA,QAAQ,WAAW,IAAI,CAAC,CAAC,QAAQ,GACjC,QAAQ,WAAW,OAAO,CAAC,CAAC,QAAQ,CACtC,CACF,CAAC,CACA,WAAW,EAAE,CAAC,CACd,MAAM;CAKT,MAAM,aAAa,MAAM,yBAAyB,SAAS,WACzD,OAAO,oBAAoB,WAAW,CACxC;CAIA,IAAI,CAAC,IAAI,oBAAoB,UAAU,KAAK,CAAC,WAAW,QACtD,MAAM,IAAI,iBACR,cAAc,6BACd,sBAAsB,MAAM,0BAA0B,UACpD,IAAI,kBAAkB,UAAU,IAAI,KAAK,WAAW,UAAU,IAElE;CAEF,MAAM,YAAY,cAAc,WAAW,OAAO,MAAM;CACxD,OAAO,aAAa,OAAO,OAAO,SAAS,IAAI;AACjD"}
|
|
@@ -36,7 +36,7 @@ const submitStellarTransaction = async (client, signedTxXdr, networkPassphrase)
|
|
|
36
36
|
case "TRY_AGAIN_LATER": break;
|
|
37
37
|
default: throw new TransactionError(LiFiErrorCode.TransactionFailed, `Stellar transaction submission failed: ${response.errorResult?.result().switch().name ?? response.status}`);
|
|
38
38
|
}
|
|
39
|
-
if (attempt <
|
|
39
|
+
if (attempt < 2) await new Promise((resolve) => setTimeout(resolve, TRY_AGAIN_DELAY_MS));
|
|
40
40
|
}
|
|
41
41
|
throw new TransactionError(LiFiErrorCode.RateLimitExceeded, "Stellar RPC asked to try again later.");
|
|
42
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submitStellarTransaction.js","names":[],"sources":["../../../../../src/core/tasks/helpers/submitStellarTransaction.ts"],"sourcesContent":["import { LiFiErrorCode, type SDKClient, TransactionError } from '@lifi/sdk'\nimport { type Transaction, TransactionBuilder } from '@stellar/stellar-sdk'\nimport type { Api } from '@stellar/stellar-sdk/rpc'\nimport { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'\n\n/**\n * `TRY_AGAIN_LATER` says the envelope is valid but was not queued, so the fix\n * is to send the same envelope again. Submission is idempotent by hash, which\n * makes the retry free of side effects.\n */\nconst TRY_AGAIN_ATTEMPTS = 3\nconst TRY_AGAIN_DELAY_MS = 2_000\n\n/**\n * Submits a signed base64 envelope over Stellar RPC and returns the hash.\n *\n * Only the transport call goes through {@link callStellarRpcsWithRetry}, so a\n * dead RPC fails over to the next one. Classifying the response happens outside\n * that wrapper on purpose: the helper collapses everything its callback throws\n * into an `AggregateError`, which would hide a classified `TransactionError`\n * from `parseStellarErrors` and surface every rejection as an unknown error.\n *\n * `DUPLICATE` counts as success — it means this exact envelope already reached\n * the network, the expected outcome when failover retries a submission the first\n * RPC had in fact accepted. Soroban submission is idempotent by hash, so the\n * right move is to stop resubmitting and start polling.\n *\n * `TRY_AGAIN_LATER` is retried a bounded number of times rather than thrown:\n * core is telling us the envelope was not queued, not that it is invalid.\n */\nexport const submitStellarTransaction = async (\n client: SDKClient,\n signedTxXdr: string,\n networkPassphrase: string\n): Promise<string> => {\n const transaction = TransactionBuilder.fromXDR(\n signedTxXdr,\n networkPassphrase\n ) as Transaction\n\n for (let attempt = 0; attempt < TRY_AGAIN_ATTEMPTS; attempt++) {\n const response: Api.SendTransactionResponse =\n await callStellarRpcsWithRetry(client, (server) =>\n server.sendTransaction(transaction)\n )\n\n switch (response.status) {\n case 'PENDING':\n case 'DUPLICATE':\n return response.hash\n case 'TRY_AGAIN_LATER':\n break\n default:\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n `Stellar transaction submission failed: ${\n response.errorResult?.result().switch().name ?? response.status\n }`\n )\n }\n\n if (attempt < TRY_AGAIN_ATTEMPTS - 1) {\n await new Promise((resolve) => setTimeout(resolve, TRY_AGAIN_DELAY_MS))\n }\n }\n\n throw new TransactionError(\n LiFiErrorCode.RateLimitExceeded,\n 'Stellar RPC asked to try again later.'\n )\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;AAmB3B,MAAa,2BAA2B,OACtC,QACA,aACA,sBACoB;CACpB,MAAM,cAAc,mBAAmB,QACrC,aACA,iBACF;CAEA,KAAK,IAAI,UAAU,GAAG,UAAU,oBAAoB,WAAW;EAC7D,MAAM,WACJ,MAAM,yBAAyB,SAAS,WACtC,OAAO,gBAAgB,WAAW,CACpC;EAEF,QAAQ,SAAS,QAAjB;GACE,KAAK;GACL,KAAK,aACH,OAAO,SAAS;GAClB,KAAK,mBACH;GACF,SACE,MAAM,IAAI,iBACR,cAAc,mBACd,0CACE,SAAS,aAAa,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,SAAS,QAE7D;EACJ;EAEA,IAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"submitStellarTransaction.js","names":[],"sources":["../../../../../src/core/tasks/helpers/submitStellarTransaction.ts"],"sourcesContent":["import { LiFiErrorCode, type SDKClient, TransactionError } from '@lifi/sdk'\nimport { type Transaction, TransactionBuilder } from '@stellar/stellar-sdk'\nimport type { Api } from '@stellar/stellar-sdk/rpc'\nimport { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'\n\n/**\n * `TRY_AGAIN_LATER` says the envelope is valid but was not queued, so the fix\n * is to send the same envelope again. Submission is idempotent by hash, which\n * makes the retry free of side effects.\n */\nconst TRY_AGAIN_ATTEMPTS = 3\nconst TRY_AGAIN_DELAY_MS = 2_000\n\n/**\n * Submits a signed base64 envelope over Stellar RPC and returns the hash.\n *\n * Only the transport call goes through {@link callStellarRpcsWithRetry}, so a\n * dead RPC fails over to the next one. Classifying the response happens outside\n * that wrapper on purpose: the helper collapses everything its callback throws\n * into an `AggregateError`, which would hide a classified `TransactionError`\n * from `parseStellarErrors` and surface every rejection as an unknown error.\n *\n * `DUPLICATE` counts as success — it means this exact envelope already reached\n * the network, the expected outcome when failover retries a submission the first\n * RPC had in fact accepted. Soroban submission is idempotent by hash, so the\n * right move is to stop resubmitting and start polling.\n *\n * `TRY_AGAIN_LATER` is retried a bounded number of times rather than thrown:\n * core is telling us the envelope was not queued, not that it is invalid.\n */\nexport const submitStellarTransaction = async (\n client: SDKClient,\n signedTxXdr: string,\n networkPassphrase: string\n): Promise<string> => {\n const transaction = TransactionBuilder.fromXDR(\n signedTxXdr,\n networkPassphrase\n ) as Transaction\n\n for (let attempt = 0; attempt < TRY_AGAIN_ATTEMPTS; attempt++) {\n const response: Api.SendTransactionResponse =\n await callStellarRpcsWithRetry(client, (server) =>\n server.sendTransaction(transaction)\n )\n\n switch (response.status) {\n case 'PENDING':\n case 'DUPLICATE':\n return response.hash\n case 'TRY_AGAIN_LATER':\n break\n default:\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n `Stellar transaction submission failed: ${\n response.errorResult?.result().switch().name ?? response.status\n }`\n )\n }\n\n if (attempt < TRY_AGAIN_ATTEMPTS - 1) {\n await new Promise((resolve) => setTimeout(resolve, TRY_AGAIN_DELAY_MS))\n }\n }\n\n throw new TransactionError(\n LiFiErrorCode.RateLimitExceeded,\n 'Stellar RPC asked to try again later.'\n )\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;AAmB3B,MAAa,2BAA2B,OACtC,QACA,aACA,sBACoB;CACpB,MAAM,cAAc,mBAAmB,QACrC,aACA,iBACF;CAEA,KAAK,IAAI,UAAU,GAAG,UAAU,oBAAoB,WAAW;EAC7D,MAAM,WACJ,MAAM,yBAAyB,SAAS,WACtC,OAAO,gBAAgB,WAAW,CACpC;EAEF,QAAQ,SAAS,QAAjB;GACE,KAAK;GACL,KAAK,aACH,OAAO,SAAS;GAClB,KAAK,mBACH;GACF,SACE,MAAM,IAAI,iBACR,cAAc,mBACd,0CACE,SAAS,aAAa,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,SAAS,QAE7D;EACJ;EAEA,IAAI,UAAU,GACZ,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,kBAAkB,CAAC;CAE1E;CAEA,MAAM,IAAI,iBACR,cAAc,mBACd,uCACF;AACF"}
|
|
@@ -6,7 +6,8 @@ const parseStellarErrors = async (e, step, action) => {
|
|
|
6
6
|
e.action = e.action ?? action;
|
|
7
7
|
return e;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
const baseError = handleSpecificErrors(e);
|
|
10
|
+
return new SDKError(baseError, step, action);
|
|
10
11
|
};
|
|
11
12
|
const handleSpecificErrors = (e) => {
|
|
12
13
|
if (e instanceof AggregateError && e.errors.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseStellarErrors.js","names":[],"sources":["../../../src/errors/parseStellarErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseStellarErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\nconst handleSpecificErrors = (e: any): BaseError => {\n // `callStellarRpcsWithRetry` collapses every rejection into an AggregateError,\n // whose own message says nothing useful. Classify from the error it hides,\n // preferring one this package already classified.\n if (e instanceof AggregateError && e.errors.length) {\n const classified = e.errors.find(\n (error: unknown) => error instanceof BaseError\n )\n return handleSpecificErrors(classified ?? e.errors[0])\n }\n\n // A code this package set on purpose wins over message matching: an allowance\n // the SDK could not read is not an allowance the user has to grant.\n if (e instanceof BaseError) {\n return e\n }\n\n // Stellar Wallets Kit surfaces wallet rejections as messages rather than typed\n // errors, and the shape varies per wallet — match on the text, as Sui does.\n const message: string = typeof e === 'string' ? e : (e?.message ?? '')\n const normalized = message.toLowerCase()\n\n if (normalized.includes('reject') || normalized.includes('denied')) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, message, e)\n }\n\n // The envelope's timebounds lapsed while the user was in their wallet. The\n // route needs a freshly built envelope, which resuming the route produces.\n if (normalized.includes('tx_too_late') || normalized.includes('txtoolate')) {\n return new TransactionError(\n LiFiErrorCode.TransactionExpired,\n 'The Stellar transaction expired before it was submitted. Please request a new route to get a fresh transaction.',\n e\n )\n }\n\n // Another transaction from this account consumed the sequence number the\n // envelope was built against.\n if (normalized.includes('tx_bad_seq') || normalized.includes('txbadseq')) {\n return new TransactionError(\n LiFiErrorCode.TransactionConflict,\n 'The Stellar account sequence number changed before the transaction was submitted. Please request a new route to get a fresh transaction.',\n e\n )\n }\n\n if (\n normalized.includes('tx_insufficient_balance') ||\n normalized.includes('txinsufficientbalance')\n ) {\n return new TransactionError(LiFiErrorCode.InsufficientFunds, message, e)\n }\n\n if (\n normalized.includes('tx_insufficient_fee') ||\n normalized.includes('txinsufficientfee')\n ) {\n return new TransactionError(\n LiFiErrorCode.TransactionUnderpriced,\n message,\n e\n )\n }\n\n if (normalized.includes('allowance')) {\n return new TransactionError(LiFiErrorCode.AllowanceRequired, message, e)\n }\n\n if (\n normalized.includes('simulation') ||\n normalized.includes('simulate') ||\n normalized.includes('hosterror')\n ) {\n return new TransactionError(\n LiFiErrorCode.TransactionSimulationFailed,\n message,\n e\n )\n }\n\n return new UnknownError(message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;AAWA,MAAa,qBAAqB,OAChC,GACA,MACA,WACsB;CACtB,IAAI,aAAa,UAAU;EACzB,EAAE,OAAO,EAAE,QAAQ;EACnB,EAAE,SAAS,EAAE,UAAU;EACvB,OAAO;CACT;
|
|
1
|
+
{"version":3,"file":"parseStellarErrors.js","names":[],"sources":["../../../src/errors/parseStellarErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseStellarErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\nconst handleSpecificErrors = (e: any): BaseError => {\n // `callStellarRpcsWithRetry` collapses every rejection into an AggregateError,\n // whose own message says nothing useful. Classify from the error it hides,\n // preferring one this package already classified.\n if (e instanceof AggregateError && e.errors.length) {\n const classified = e.errors.find(\n (error: unknown) => error instanceof BaseError\n )\n return handleSpecificErrors(classified ?? e.errors[0])\n }\n\n // A code this package set on purpose wins over message matching: an allowance\n // the SDK could not read is not an allowance the user has to grant.\n if (e instanceof BaseError) {\n return e\n }\n\n // Stellar Wallets Kit surfaces wallet rejections as messages rather than typed\n // errors, and the shape varies per wallet — match on the text, as Sui does.\n const message: string = typeof e === 'string' ? e : (e?.message ?? '')\n const normalized = message.toLowerCase()\n\n if (normalized.includes('reject') || normalized.includes('denied')) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, message, e)\n }\n\n // The envelope's timebounds lapsed while the user was in their wallet. The\n // route needs a freshly built envelope, which resuming the route produces.\n if (normalized.includes('tx_too_late') || normalized.includes('txtoolate')) {\n return new TransactionError(\n LiFiErrorCode.TransactionExpired,\n 'The Stellar transaction expired before it was submitted. Please request a new route to get a fresh transaction.',\n e\n )\n }\n\n // Another transaction from this account consumed the sequence number the\n // envelope was built against.\n if (normalized.includes('tx_bad_seq') || normalized.includes('txbadseq')) {\n return new TransactionError(\n LiFiErrorCode.TransactionConflict,\n 'The Stellar account sequence number changed before the transaction was submitted. Please request a new route to get a fresh transaction.',\n e\n )\n }\n\n if (\n normalized.includes('tx_insufficient_balance') ||\n normalized.includes('txinsufficientbalance')\n ) {\n return new TransactionError(LiFiErrorCode.InsufficientFunds, message, e)\n }\n\n if (\n normalized.includes('tx_insufficient_fee') ||\n normalized.includes('txinsufficientfee')\n ) {\n return new TransactionError(\n LiFiErrorCode.TransactionUnderpriced,\n message,\n e\n )\n }\n\n if (normalized.includes('allowance')) {\n return new TransactionError(LiFiErrorCode.AllowanceRequired, message, e)\n }\n\n if (\n normalized.includes('simulation') ||\n normalized.includes('simulate') ||\n normalized.includes('hosterror')\n ) {\n return new TransactionError(\n LiFiErrorCode.TransactionSimulationFailed,\n message,\n e\n )\n }\n\n return new UnknownError(message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;AAWA,MAAa,qBAAqB,OAChC,GACA,MACA,WACsB;CACtB,IAAI,aAAa,UAAU;EACzB,EAAE,OAAO,EAAE,QAAQ;EACnB,EAAE,SAAS,EAAE,UAAU;EACvB,OAAO;CACT;CAEA,MAAM,YAAY,qBAAqB,CAAC;CAExC,OAAO,IAAI,SAAS,WAAW,MAAM,MAAM;AAC7C;AAEA,MAAM,wBAAwB,MAAsB;CAIlD,IAAI,aAAa,kBAAkB,EAAE,OAAO,QAAQ;EAClD,MAAM,aAAa,EAAE,OAAO,MACzB,UAAmB,iBAAiB,SACvC;EACA,OAAO,qBAAqB,cAAc,EAAE,OAAO,EAAE;CACvD;CAIA,IAAI,aAAa,WACf,OAAO;CAKT,MAAM,UAAkB,OAAO,MAAM,WAAW,IAAK,GAAG,WAAW;CACnE,MAAM,aAAa,QAAQ,YAAY;CAEvC,IAAI,WAAW,SAAS,QAAQ,KAAK,WAAW,SAAS,QAAQ,GAC/D,OAAO,IAAI,iBAAiB,cAAc,mBAAmB,SAAS,CAAC;CAKzE,IAAI,WAAW,SAAS,aAAa,KAAK,WAAW,SAAS,WAAW,GACvE,OAAO,IAAI,iBACT,cAAc,oBACd,mHACA,CACF;CAKF,IAAI,WAAW,SAAS,YAAY,KAAK,WAAW,SAAS,UAAU,GACrE,OAAO,IAAI,iBACT,cAAc,qBACd,4IACA,CACF;CAGF,IACE,WAAW,SAAS,yBAAyB,KAC7C,WAAW,SAAS,uBAAuB,GAE3C,OAAO,IAAI,iBAAiB,cAAc,mBAAmB,SAAS,CAAC;CAGzE,IACE,WAAW,SAAS,qBAAqB,KACzC,WAAW,SAAS,mBAAmB,GAEvC,OAAO,IAAI,iBACT,cAAc,wBACd,SACA,CACF;CAGF,IAAI,WAAW,SAAS,WAAW,GACjC,OAAO,IAAI,iBAAiB,cAAc,mBAAmB,SAAS,CAAC;CAGzE,IACE,WAAW,SAAS,YAAY,KAChC,WAAW,SAAS,UAAU,KAC9B,WAAW,SAAS,WAAW,GAE/B,OAAO,IAAI,iBACT,cAAc,6BACd,SACA,CACF;CAGF,OAAO,IAAI,aAAa,WAAW,aAAa,cAAc,CAAC;AACjE"}
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-stellar'\nexport const version = '
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-stellar'\nexport const version = '4.2.0'\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": "
|
|
3
|
+
"version": "4.2.0",
|
|
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": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@stellar/stellar-sdk": "^16.
|
|
32
|
-
"@lifi/sdk": "
|
|
31
|
+
"@stellar/stellar-sdk": "^16.2.0",
|
|
32
|
+
"@lifi/sdk": "4.4.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk-provider-stellar'
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '4.2.0'
|