@lifi/sdk-provider-stellar 0.0.0-preview-c328023 → 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 +9 -5
- package/dist/esm/StellarProvider.d.ts +7 -1
- package/dist/esm/StellarProvider.d.ts.map +1 -1
- package/dist/esm/StellarProvider.js +8 -2
- package/dist/esm/StellarProvider.js.map +1 -1
- package/dist/esm/actions/getStellarBalance.js +14 -5
- package/dist/esm/actions/getStellarBalance.js.map +1 -1
- package/dist/esm/actions/resolveStellarAddress.d.ts +8 -1
- package/dist/esm/actions/resolveStellarAddress.d.ts.map +1 -1
- package/dist/esm/actions/resolveStellarAddress.js +11 -2
- package/dist/esm/actions/resolveStellarAddress.js.map +1 -1
- package/dist/esm/client/getStellarRpc.d.ts +3 -3
- package/dist/esm/client/getStellarRpc.d.ts.map +1 -1
- package/dist/esm/client/getStellarRpc.js +2 -2
- package/dist/esm/client/getStellarRpc.js.map +1 -1
- package/dist/esm/core/StellarStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/StellarStepExecutor.js +3 -1
- package/dist/esm/core/StellarStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/StellarPrepareTransactionTask.d.ts +23 -16
- package/dist/esm/core/tasks/StellarPrepareTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/StellarPrepareTransactionTask.js +28 -28
- package/dist/esm/core/tasks/StellarPrepareTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/StellarWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/StellarWaitForTransactionTask.js +17 -3
- package/dist/esm/core/tasks/StellarWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/helpers/assertApprovalStillCovers.d.ts +21 -0
- package/dist/esm/core/tasks/helpers/assertApprovalStillCovers.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/assertApprovalStillCovers.js +29 -0
- package/dist/esm/core/tasks/helpers/assertApprovalStillCovers.js.map +1 -0
- package/dist/esm/core/tasks/helpers/probeStellarTransaction.d.ts +20 -0
- package/dist/esm/core/tasks/helpers/probeStellarTransaction.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/probeStellarTransaction.js +20 -0
- package/dist/esm/core/tasks/helpers/probeStellarTransaction.js.map +1 -0
- package/dist/esm/core/tasks/helpers/readAllowance.d.ts +4 -0
- package/dist/esm/core/tasks/helpers/readAllowance.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/readAllowance.js +12 -6
- package/dist/esm/core/tasks/helpers/readAllowance.js.map +1 -1
- package/dist/esm/core/tasks/helpers/resolveApprovalRequirement.js +1 -2
- package/dist/esm/core/tasks/helpers/resolveApprovalRequirement.js.map +1 -1
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.d.ts +3 -0
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.js +20 -6
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.js.map +1 -1
- package/dist/esm/core/tasks/helpers/waitForStellarTransaction.d.ts +8 -4
- package/dist/esm/core/tasks/helpers/waitForStellarTransaction.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/waitForStellarTransaction.js +26 -9
- package/dist/esm/core/tasks/helpers/waitForStellarTransaction.js.map +1 -1
- package/dist/esm/errors/parseStellarErrors.js +7 -2
- package/dist/esm/errors/parseStellarErrors.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/types.d.ts +10 -6
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.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/StellarProvider.ts +8 -1
- package/src/actions/getStellarBalance.ts +22 -6
- package/src/actions/resolveStellarAddress.ts +19 -2
- package/src/client/getStellarRpc.ts +6 -8
- package/src/core/StellarStepExecutor.ts +11 -0
- package/src/core/tasks/StellarPrepareTransactionTask.ts +31 -71
- package/src/core/tasks/StellarWaitForTransactionTask.ts +35 -7
- package/src/core/tasks/helpers/assertApprovalStillCovers.ts +48 -0
- package/src/core/tasks/helpers/probeStellarTransaction.ts +34 -0
- package/src/core/tasks/helpers/readAllowance.ts +42 -33
- package/src/core/tasks/helpers/resolveApprovalRequirement.ts +10 -10
- package/src/core/tasks/helpers/submitStellarTransaction.ts +41 -25
- package/src/core/tasks/helpers/waitForStellarTransaction.ts +44 -20
- package/src/errors/parseStellarErrors.ts +17 -5
- package/src/index.ts +4 -1
- package/src/types.ts +10 -6
- package/src/version.ts +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readAllowance } from "./readAllowance.js";
|
|
2
|
+
import { resolveApprovalRequirement } from "./resolveApprovalRequirement.js";
|
|
3
|
+
import { LiFiErrorCode, TransactionError } from "@lifi/sdk";
|
|
4
|
+
//#region src/core/tasks/helpers/assertApprovalStillCovers.ts
|
|
5
|
+
/**
|
|
6
|
+
* Fails the step before signing when the refreshed route needs an allowance the
|
|
7
|
+
* sender does not have.
|
|
8
|
+
*
|
|
9
|
+
* `StellarPrepareTransactionTask` re-quotes after `StellarSetAllowanceTask` has
|
|
10
|
+
* already written an allowance, and the re-quote replaces `includedSteps` and
|
|
11
|
+
* `estimate` wholesale. A fresh quote that names a different adapter, a
|
|
12
|
+
* different intermediate token, or a larger amount would revert `transfer_from`
|
|
13
|
+
* on-chain after a second signature.
|
|
14
|
+
*
|
|
15
|
+
* The check reads the chain rather than comparing against the resolved
|
|
16
|
+
* requirement: when the allowance already existed, the on-chain ceiling can be
|
|
17
|
+
* far above what this route asked for, and comparing the two would reject a
|
|
18
|
+
* route that works.
|
|
19
|
+
*/
|
|
20
|
+
const assertApprovalStillCovers = async (context) => {
|
|
21
|
+
if (!context.approval) return;
|
|
22
|
+
const refreshed = resolveApprovalRequirement(context.step);
|
|
23
|
+
if (!refreshed) return;
|
|
24
|
+
if (await readAllowance(context.client, refreshed.tokenAddress, context.wallet.address, refreshed.spender, context.networkPassphrase) < refreshed.amount) throw new TransactionError(LiFiErrorCode.TransactionUnprepared, "The refreshed Stellar route needs a token allowance the sender has not granted. Please request a new route.");
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { assertApprovalStillCovers };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=assertApprovalStillCovers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertApprovalStillCovers.js","names":[],"sources":["../../../../../src/core/tasks/helpers/assertApprovalStillCovers.ts"],"sourcesContent":["import { LiFiErrorCode, TransactionError } from '@lifi/sdk'\nimport type { StellarStepExecutorContext } from '../../../types.js'\nimport { readAllowance } from './readAllowance.js'\nimport { resolveApprovalRequirement } from './resolveApprovalRequirement.js'\n\n/**\n * Fails the step before signing when the refreshed route needs an allowance the\n * sender does not have.\n *\n * `StellarPrepareTransactionTask` re-quotes after `StellarSetAllowanceTask` has\n * already written an allowance, and the re-quote replaces `includedSteps` and\n * `estimate` wholesale. A fresh quote that names a different adapter, a\n * different intermediate token, or a larger amount would revert `transfer_from`\n * on-chain after a second signature.\n *\n * The check reads the chain rather than comparing against the resolved\n * requirement: when the allowance already existed, the on-chain ceiling can be\n * far above what this route asked for, and comparing the two would reject a\n * route that works.\n */\nexport const assertApprovalStillCovers = async (\n context: StellarStepExecutorContext\n): Promise<void> => {\n // Nothing was resolved before the refresh, so there is no grant to invalidate.\n if (!context.approval) {\n return\n }\n\n const refreshed = resolveApprovalRequirement(context.step)\n if (!refreshed) {\n return\n }\n\n const allowance = await readAllowance(\n context.client,\n refreshed.tokenAddress,\n context.wallet.address,\n refreshed.spender,\n context.networkPassphrase\n )\n\n if (allowance < refreshed.amount) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'The refreshed Stellar route needs a token allowance the sender has not granted. Please request a new route.'\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,MAAa,4BAA4B,OACvC,YACkB;CAElB,IAAI,CAAC,QAAQ,UACX;CAGF,MAAM,YAAY,2BAA2B,QAAQ,IAAI;CACzD,IAAI,CAAC,WACH;CAWF,IAAI,MARoB,cACtB,QAAQ,QACR,UAAU,cACV,QAAQ,OAAO,SACf,UAAU,SACV,QAAQ,iBACV,IAEgB,UAAU,QACxB,MAAM,IAAI,iBACR,cAAc,uBACd,6GACF;AAEJ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SDKClient } from "@lifi/sdk";
|
|
2
|
+
//#region src/core/tasks/helpers/probeStellarTransaction.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* What the network could tell us about a hash.
|
|
5
|
+
*
|
|
6
|
+
* `'not-found'` and `'unknown'` both mean "re-submit", but only `'not-found'`
|
|
7
|
+
* is a definite answer. A re-submit error after `'unknown'` may come from a
|
|
8
|
+
* transaction that in fact settled, so the caller must not report it.
|
|
9
|
+
*/
|
|
10
|
+
type StellarTransactionProbe = "landed" | "not-found" | "unknown";
|
|
11
|
+
/**
|
|
12
|
+
* Asks whether the network already knows a transaction, without waiting for it.
|
|
13
|
+
*
|
|
14
|
+
* Soroban RPC only knows a transaction once it has been applied, so `NOT_FOUND`
|
|
15
|
+
* stays ambiguous — never broadcast, or broadcast and still pending.
|
|
16
|
+
*/
|
|
17
|
+
declare const probeStellarTransaction: (client: SDKClient, transactionHash: string) => Promise<StellarTransactionProbe>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { StellarTransactionProbe, probeStellarTransaction };
|
|
20
|
+
//# sourceMappingURL=probeStellarTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probeStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/probeStellarTransaction.ts"],"mappings":";;;;;;;;;KAWY;;;;;;;cAQC,0BACX,QAAQ,WACR,4BACC,QAAQ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { callStellarRpcsWithRetry } from "../../../client/getStellarRpc.js";
|
|
2
|
+
import { Api } from "@stellar/stellar-sdk/rpc";
|
|
3
|
+
//#region src/core/tasks/helpers/probeStellarTransaction.ts
|
|
4
|
+
/**
|
|
5
|
+
* Asks whether the network already knows a transaction, without waiting for it.
|
|
6
|
+
*
|
|
7
|
+
* Soroban RPC only knows a transaction once it has been applied, so `NOT_FOUND`
|
|
8
|
+
* stays ambiguous — never broadcast, or broadcast and still pending.
|
|
9
|
+
*/
|
|
10
|
+
const probeStellarTransaction = async (client, transactionHash) => {
|
|
11
|
+
try {
|
|
12
|
+
return (await callStellarRpcsWithRetry(client, (server) => server.getTransaction(transactionHash))).status === Api.GetTransactionStatus.NOT_FOUND ? "not-found" : "landed";
|
|
13
|
+
} catch {
|
|
14
|
+
return "unknown";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { probeStellarTransaction };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=probeStellarTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probeStellarTransaction.js","names":[],"sources":["../../../../../src/core/tasks/helpers/probeStellarTransaction.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport { Api } from '@stellar/stellar-sdk/rpc'\nimport { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'\n\n/**\n * What the network could tell us about a hash.\n *\n * `'not-found'` and `'unknown'` both mean \"re-submit\", but only `'not-found'`\n * is a definite answer. A re-submit error after `'unknown'` may come from a\n * transaction that in fact settled, so the caller must not report it.\n */\nexport type StellarTransactionProbe = 'landed' | 'not-found' | 'unknown'\n\n/**\n * Asks whether the network already knows a transaction, without waiting for it.\n *\n * Soroban RPC only knows a transaction once it has been applied, so `NOT_FOUND`\n * stays ambiguous — never broadcast, or broadcast and still pending.\n */\nexport const probeStellarTransaction = async (\n client: SDKClient,\n transactionHash: string\n): Promise<StellarTransactionProbe> => {\n try {\n const response = await callStellarRpcsWithRetry(client, (server) =>\n server.getTransaction(transactionHash)\n )\n return response.status === Api.GetTransactionStatus.NOT_FOUND\n ? 'not-found'\n : 'landed'\n } catch {\n return 'unknown'\n }\n}\n"],"mappings":";;;;;;;;;AAmBA,MAAa,0BAA0B,OACrC,QACA,oBACqC;CACrC,IAAI;EAIF,QAAO,MAHgB,yBAAyB,SAAS,WACvD,OAAO,eAAe,eAAe,CACvC,EAAA,CACgB,WAAW,IAAI,qBAAqB,YAChD,cACA;CACN,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -5,6 +5,10 @@ import { SDKClient } from "@lifi/sdk";
|
|
|
5
5
|
*
|
|
6
6
|
* An absent or expired allowance entry reads back as `0`, so callers can treat
|
|
7
7
|
* the result as a plain numeric comparison without a separate existence check.
|
|
8
|
+
*
|
|
9
|
+
* The simulation is the only part that goes through `callStellarRpcsWithRetry`;
|
|
10
|
+
* the result is classified outside it, so a deterministic contract-level failure
|
|
11
|
+
* is not retried against every RPC and is not buried in an `AggregateError`.
|
|
8
12
|
*/
|
|
9
13
|
declare const readAllowance: (client: SDKClient, token: string, from: string, spender: string, networkPassphrase: string) => Promise<bigint>;
|
|
10
14
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAllowance.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/readAllowance.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"readAllowance.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/readAllowance.ts"],"mappings":";;;;;;;;;;;;cAsBa,gBACX,QAAQ,WACR,eACA,cACA,iBACA,8BACC"}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { callStellarRpcsWithRetry } from "../../../client/getStellarRpc.js";
|
|
2
2
|
import { LiFiErrorCode, TransactionError } from "@lifi/sdk";
|
|
3
|
-
import { Account, Address, BASE_FEE, Contract, TransactionBuilder,
|
|
3
|
+
import { Account, Address, BASE_FEE, Contract, TransactionBuilder, scValToNative } from "@stellar/stellar-sdk";
|
|
4
|
+
import { Api } from "@stellar/stellar-sdk/rpc";
|
|
4
5
|
//#region src/core/tasks/helpers/readAllowance.ts
|
|
5
6
|
/**
|
|
6
7
|
* Reads the SAC `allowance(from, spender)` via read-only simulation.
|
|
7
8
|
*
|
|
8
9
|
* An absent or expired allowance entry reads back as `0`, so callers can treat
|
|
9
10
|
* the result as a plain numeric comparison without a separate existence check.
|
|
11
|
+
*
|
|
12
|
+
* The simulation is the only part that goes through `callStellarRpcsWithRetry`;
|
|
13
|
+
* the result is classified outside it, so a deterministic contract-level failure
|
|
14
|
+
* is not retried against every RPC and is not buried in an `AggregateError`.
|
|
10
15
|
*/
|
|
11
|
-
const readAllowance = async (client, token, from, spender, networkPassphrase) =>
|
|
12
|
-
const
|
|
16
|
+
const readAllowance = async (client, token, from, spender, networkPassphrase) => {
|
|
17
|
+
const source = new Account(from, "0");
|
|
18
|
+
const transaction = new TransactionBuilder(source, {
|
|
13
19
|
fee: BASE_FEE,
|
|
14
20
|
networkPassphrase
|
|
15
21
|
}).addOperation(new Contract(token).call("allowance", Address.fromString(from).toScVal(), Address.fromString(spender).toScVal())).setTimeout(30).build();
|
|
16
|
-
const simulation = await server.simulateTransaction(transaction);
|
|
17
|
-
if (!
|
|
22
|
+
const simulation = await callStellarRpcsWithRetry(client, (server) => server.simulateTransaction(transaction));
|
|
23
|
+
if (!Api.isSimulationSuccess(simulation) || !simulation.result) throw new TransactionError(LiFiErrorCode.TransactionSimulationFailed, `Could not read the ${token} spending allowance for ${spender}${Api.isSimulationError(simulation) ? `: ${simulation.error}` : ""}`);
|
|
18
24
|
const allowance = scValToNative(simulation.result.retval);
|
|
19
25
|
return allowance != null ? BigInt(allowance) : 0n;
|
|
20
|
-
}
|
|
26
|
+
};
|
|
21
27
|
//#endregion
|
|
22
28
|
export { readAllowance };
|
|
23
29
|
|
|
@@ -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
|
|
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"}
|
|
@@ -29,10 +29,9 @@ const APPROVAL_AMOUNT_BUFFER_PERCENT = 10n;
|
|
|
29
29
|
* `fromToken`.
|
|
30
30
|
*/
|
|
31
31
|
const resolveApprovalRequirement = (step) => {
|
|
32
|
-
const includedStep = step.includedSteps?.find((includedStep) => !includedStep.estimate.skipApproval);
|
|
32
|
+
const includedStep = step.includedSteps?.find((includedStep) => !includedStep.estimate.skipApproval && !!includedStep.estimate.approvalAddress && StrKey.isValidContract(includedStep.estimate.approvalAddress));
|
|
33
33
|
if (!includedStep) return;
|
|
34
34
|
const spender = includedStep.estimate.approvalAddress;
|
|
35
|
-
if (!spender || !StrKey.isValidContract(spender)) return;
|
|
36
35
|
const amount = BigInt(includedStep.estimate.fromAmount);
|
|
37
36
|
return {
|
|
38
37
|
spender,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveApprovalRequirement.js","names":[],"sources":["../../../../../src/core/tasks/helpers/resolveApprovalRequirement.ts"],"sourcesContent":["import type { LiFiStep } from '@lifi/sdk'\nimport { StrKey } from '@stellar/stellar-sdk'\nimport type { StellarApprovalRequirement } from '../../../types.js'\n\n/**\n * Extra head-room, in percent, added on top of the leg's quoted `fromAmount`\n * when the allowance is written.\n */\nconst APPROVAL_AMOUNT_BUFFER_PERCENT = 10n\n\n/**\n * Resolves the SAC allowance a Stellar step needs, or `undefined` when it needs\n * none.\n *\n * The decision is made per **included leg**, never from `step.estimate`. Unlike\n * an EVM step — one transaction whose top-level estimate describes the approval\n * — a Stellar route is a single router invocation composed of several legs, and\n * the leg that pulls funds is the one whose spender and token the allowance has\n * to name. The route-level `estimate.approvalAddress` is only a summary and\n * falls back to a placeholder (a `G` wallet, or the EVM diamond), so honouring\n * it would approve a contract nobody ever charges.\n *\n * A leg is taken to need an allowance unless it says otherwise: only an\n * explicit `skipApproval: true` opts out, matching how the EVM and Tron\n * executors read the same flag. Legs that move funds with SAC `transfer` under\n * the sender's top-level `require_auth` — fee collection, soroswap — set it;\n * a leg that pulls with `transfer_from`, such as the CCTP cross, leaves it\n * unset or false and so gets an approval.\n *\n * The leg also carries the right token and amount: for swap→CCTP the allowance\n * is written against the intermediate USDC the swap produces, not the route's\n * `fromToken`.\n */\nexport const resolveApprovalRequirement = (\n step: LiFiStep\n): StellarApprovalRequirement | undefined => {\n // The pipeline grants at most one allowance per step, so the first leg that\n // needs one wins. Routes today ask for a single approval; a route whose legs\n //
|
|
1
|
+
{"version":3,"file":"resolveApprovalRequirement.js","names":[],"sources":["../../../../../src/core/tasks/helpers/resolveApprovalRequirement.ts"],"sourcesContent":["import type { LiFiStep } from '@lifi/sdk'\nimport { StrKey } from '@stellar/stellar-sdk'\nimport type { StellarApprovalRequirement } from '../../../types.js'\n\n/**\n * Extra head-room, in percent, added on top of the leg's quoted `fromAmount`\n * when the allowance is written.\n */\nconst APPROVAL_AMOUNT_BUFFER_PERCENT = 10n\n\n/**\n * Resolves the SAC allowance a Stellar step needs, or `undefined` when it needs\n * none.\n *\n * The decision is made per **included leg**, never from `step.estimate`. Unlike\n * an EVM step — one transaction whose top-level estimate describes the approval\n * — a Stellar route is a single router invocation composed of several legs, and\n * the leg that pulls funds is the one whose spender and token the allowance has\n * to name. The route-level `estimate.approvalAddress` is only a summary and\n * falls back to a placeholder (a `G` wallet, or the EVM diamond), so honouring\n * it would approve a contract nobody ever charges.\n *\n * A leg is taken to need an allowance unless it says otherwise: only an\n * explicit `skipApproval: true` opts out, matching how the EVM and Tron\n * executors read the same flag. Legs that move funds with SAC `transfer` under\n * the sender's top-level `require_auth` — fee collection, soroswap — set it;\n * a leg that pulls with `transfer_from`, such as the CCTP cross, leaves it\n * unset or false and so gets an approval.\n *\n * The leg also carries the right token and amount: for swap→CCTP the allowance\n * is written against the intermediate USDC the swap produces, not the route's\n * `fromToken`.\n */\nexport const resolveApprovalRequirement = (\n step: LiFiStep\n): StellarApprovalRequirement | undefined => {\n // The pipeline grants at most one allowance per step, so the first leg that\n // needs one wins. A spender also has to be a real Soroban contract (`C`)\n // address: anything else — a `G` wallet, an EVM address — cannot call\n // `transfer_from`, so it is a placeholder rather than a reason to stop\n // looking. Routes today ask for a single approval; a route whose legs pull\n // two different tokens would need the executor to loop instead.\n const includedStep = step.includedSteps?.find(\n (includedStep) =>\n !includedStep.estimate.skipApproval &&\n !!includedStep.estimate.approvalAddress &&\n StrKey.isValidContract(includedStep.estimate.approvalAddress)\n )\n if (!includedStep) {\n return undefined\n }\n\n const spender = includedStep.estimate.approvalAddress as string\n\n // `fromAmount` is a quote-time figure. A leg fed by an upstream swap is handed\n // whatever that swap actually produced, which can land above the quote, and\n // `transfer_from` reverts the whole invocation if the allowance is short by\n // even a stroop. The buffer absorbs that drift and costs nothing: an allowance\n // is a ceiling, so only the amount actually pulled is ever spent.\n //\n // Read off `estimate`, the same object `skipApproval` and `approvalAddress`\n // come from. `CheckBalanceTask`'s slippage rescue revises `action.fromAmount`\n // on the first leg only, and only downward, so the estimate stays an upper\n // bound either way.\n const amount = BigInt(includedStep.estimate.fromAmount)\n\n return {\n spender,\n tokenAddress: includedStep.action.fromToken.address,\n amount: amount + (amount * APPROVAL_AMOUNT_BUFFER_PERCENT) / 100n,\n }\n}\n"],"mappings":";;;;;;AAQA,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;AAyBvC,MAAa,8BACX,SAC2C;CAO3C,MAAM,eAAe,KAAK,eAAe,MACtC,iBACC,CAAC,aAAa,SAAS,gBACvB,CAAC,CAAC,aAAa,SAAS,mBACxB,OAAO,gBAAgB,aAAa,SAAS,eAAe,CAChE;CACA,IAAI,CAAC,cACH;CAGF,MAAM,UAAU,aAAa,SAAS;CAYtC,MAAM,SAAS,OAAO,aAAa,SAAS,UAAU;CAEtD,OAAO;EACL;EACA,cAAc,aAAa,OAAO,UAAU;EAC5C,QAAQ,SAAU,SAAS,iCAAkC;CAC/D;AACF"}
|
|
@@ -13,6 +13,9 @@ import { SDKClient } from "@lifi/sdk";
|
|
|
13
13
|
* the network, the expected outcome when failover retries a submission the first
|
|
14
14
|
* RPC had in fact accepted. Soroban submission is idempotent by hash, so the
|
|
15
15
|
* right move is to stop resubmitting and start polling.
|
|
16
|
+
*
|
|
17
|
+
* `TRY_AGAIN_LATER` is retried a bounded number of times rather than thrown:
|
|
18
|
+
* core is telling us the envelope was not queued, not that it is invalid.
|
|
16
19
|
*/
|
|
17
20
|
declare const submitStellarTransaction: (client: SDKClient, signedTxXdr: string, networkPassphrase: string) => Promise<string>;
|
|
18
21
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submitStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/submitStellarTransaction.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"submitStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/submitStellarTransaction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cA8Ba,2BACX,QAAQ,WACR,qBACA,8BACC"}
|
|
@@ -3,6 +3,13 @@ import { LiFiErrorCode, TransactionError } from "@lifi/sdk";
|
|
|
3
3
|
import { TransactionBuilder } from "@stellar/stellar-sdk";
|
|
4
4
|
//#region src/core/tasks/helpers/submitStellarTransaction.ts
|
|
5
5
|
/**
|
|
6
|
+
* `TRY_AGAIN_LATER` says the envelope is valid but was not queued, so the fix
|
|
7
|
+
* is to send the same envelope again. Submission is idempotent by hash, which
|
|
8
|
+
* makes the retry free of side effects.
|
|
9
|
+
*/
|
|
10
|
+
const TRY_AGAIN_ATTEMPTS = 3;
|
|
11
|
+
const TRY_AGAIN_DELAY_MS = 2e3;
|
|
12
|
+
/**
|
|
6
13
|
* Submits a signed base64 envelope over Stellar RPC and returns the hash.
|
|
7
14
|
*
|
|
8
15
|
* Only the transport call goes through {@link callStellarRpcsWithRetry}, so a
|
|
@@ -15,16 +22,23 @@ import { TransactionBuilder } from "@stellar/stellar-sdk";
|
|
|
15
22
|
* the network, the expected outcome when failover retries a submission the first
|
|
16
23
|
* RPC had in fact accepted. Soroban submission is idempotent by hash, so the
|
|
17
24
|
* right move is to stop resubmitting and start polling.
|
|
25
|
+
*
|
|
26
|
+
* `TRY_AGAIN_LATER` is retried a bounded number of times rather than thrown:
|
|
27
|
+
* core is telling us the envelope was not queued, not that it is invalid.
|
|
18
28
|
*/
|
|
19
29
|
const submitStellarTransaction = async (client, signedTxXdr, networkPassphrase) => {
|
|
20
30
|
const transaction = TransactionBuilder.fromXDR(signedTxXdr, networkPassphrase);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
for (let attempt = 0; attempt < TRY_AGAIN_ATTEMPTS; attempt++) {
|
|
32
|
+
const response = await callStellarRpcsWithRetry(client, (server) => server.sendTransaction(transaction));
|
|
33
|
+
switch (response.status) {
|
|
34
|
+
case "PENDING":
|
|
35
|
+
case "DUPLICATE": return response.hash;
|
|
36
|
+
case "TRY_AGAIN_LATER": break;
|
|
37
|
+
default: throw new TransactionError(LiFiErrorCode.TransactionFailed, `Stellar transaction submission failed: ${response.errorResult?.result().switch().name ?? response.status}`);
|
|
38
|
+
}
|
|
39
|
+
if (attempt < 2) await new Promise((resolve) => setTimeout(resolve, TRY_AGAIN_DELAY_MS));
|
|
27
40
|
}
|
|
41
|
+
throw new TransactionError(LiFiErrorCode.RateLimitExceeded, "Stellar RPC asked to try again later.");
|
|
28
42
|
};
|
|
29
43
|
//#endregion
|
|
30
44
|
export { submitStellarTransaction };
|
|
@@ -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 {
|
|
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"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { SDKClient } from "@lifi/sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { Api } from "@stellar/stellar-sdk/rpc";
|
|
3
3
|
//#region src/core/tasks/helpers/waitForStellarTransaction.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Polls `getTransaction` until the transaction is included in a ledger.
|
|
6
6
|
*
|
|
7
7
|
* `NOT_FOUND` is not an error — Soroban RPC only knows a transaction once it has
|
|
8
|
-
* been applied — so polling continues until the
|
|
9
|
-
*
|
|
8
|
+
* been applied — so polling continues until the deadline passes and the result
|
|
9
|
+
* is reported as a timeout rather than a failure.
|
|
10
|
+
*
|
|
11
|
+
* A transport failure costs one interval rather than the whole wait: every RPC
|
|
12
|
+
* can reject one read during a rate-limit burst while the transaction is
|
|
13
|
+
* perfectly healthy. The last such error rides along as the timeout's cause.
|
|
10
14
|
*
|
|
11
15
|
* The terminal classification is deliberately done outside
|
|
12
16
|
* {@link callStellarRpcsWithRetry}; only the read goes through the failover
|
|
13
17
|
* wrapper, which would otherwise wrap a classified error in an `AggregateError`.
|
|
14
18
|
*/
|
|
15
|
-
declare const waitForStellarTransaction: (client: SDKClient, transactionHash: string, pollingIntervalMs?: number) => Promise<
|
|
19
|
+
declare const waitForStellarTransaction: (client: SDKClient, transactionHash: string, pollingIntervalMs?: number) => Promise<Api.GetSuccessfulTransactionResponse>;
|
|
16
20
|
//#endregion
|
|
17
21
|
export { waitForStellarTransaction };
|
|
18
22
|
//# sourceMappingURL=waitForStellarTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/waitForStellarTransaction.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"waitForStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/waitForStellarTransaction.ts"],"mappings":";;;;;;;;;;;;;;;;;;cA6Ba,4BACX,QAAQ,WACR,yBACA,+BACC,QAAQ,IAAI"}
|
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
import { callStellarRpcsWithRetry } from "../../../client/getStellarRpc.js";
|
|
2
2
|
import { LiFiErrorCode, TransactionError } from "@lifi/sdk";
|
|
3
|
-
import {
|
|
3
|
+
import { Api } from "@stellar/stellar-sdk/rpc";
|
|
4
4
|
//#region src/core/tasks/helpers/waitForStellarTransaction.ts
|
|
5
|
-
const CONFIRM_POLL_ATTEMPTS = 30;
|
|
6
5
|
const CONFIRM_POLL_INTERVAL_MS = 3e3;
|
|
7
6
|
/**
|
|
7
|
+
* Outlives the backend's `[0, now + 300 s]` timebounds, so a transaction that
|
|
8
|
+
* has not been applied by the deadline is genuinely dead rather than still in
|
|
9
|
+
* flight. Expressed as a deadline, not an attempt count, so a caller-supplied
|
|
10
|
+
* polling interval cannot shorten the budget.
|
|
11
|
+
*/
|
|
12
|
+
const CONFIRM_TIMEOUT_MS = 33e4;
|
|
13
|
+
/**
|
|
8
14
|
* Polls `getTransaction` until the transaction is included in a ledger.
|
|
9
15
|
*
|
|
10
16
|
* `NOT_FOUND` is not an error — Soroban RPC only knows a transaction once it has
|
|
11
|
-
* been applied — so polling continues until the
|
|
12
|
-
*
|
|
17
|
+
* been applied — so polling continues until the deadline passes and the result
|
|
18
|
+
* is reported as a timeout rather than a failure.
|
|
19
|
+
*
|
|
20
|
+
* A transport failure costs one interval rather than the whole wait: every RPC
|
|
21
|
+
* can reject one read during a rate-limit burst while the transaction is
|
|
22
|
+
* perfectly healthy. The last such error rides along as the timeout's cause.
|
|
13
23
|
*
|
|
14
24
|
* The terminal classification is deliberately done outside
|
|
15
25
|
* {@link callStellarRpcsWithRetry}; only the read goes through the failover
|
|
16
26
|
* wrapper, which would otherwise wrap a classified error in an `AggregateError`.
|
|
17
27
|
*/
|
|
18
28
|
const waitForStellarTransaction = async (client, transactionHash, pollingIntervalMs = CONFIRM_POLL_INTERVAL_MS) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
const deadline = Date.now() + CONFIRM_TIMEOUT_MS;
|
|
30
|
+
let lastTransportError;
|
|
31
|
+
while (Date.now() < deadline) {
|
|
32
|
+
try {
|
|
33
|
+
const response = await callStellarRpcsWithRetry(client, (server) => server.getTransaction(transactionHash));
|
|
34
|
+
if (response.status === Api.GetTransactionStatus.SUCCESS) return response;
|
|
35
|
+
if (response.status === Api.GetTransactionStatus.FAILED) throw new TransactionError(LiFiErrorCode.TransactionFailed, `Stellar transaction ${transactionHash} failed: ${response.resultXdr?.result().switch().name ?? "unknown reason"}`);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error instanceof TransactionError) throw error;
|
|
38
|
+
lastTransportError = error instanceof Error ? error : new Error(String(error));
|
|
39
|
+
}
|
|
23
40
|
await new Promise((resolve) => setTimeout(resolve, pollingIntervalMs));
|
|
24
41
|
}
|
|
25
|
-
throw new TransactionError(LiFiErrorCode.Timeout, `Stellar transaction ${transactionHash} was not confirmed in time
|
|
42
|
+
throw new TransactionError(LiFiErrorCode.Timeout, `Stellar transaction ${transactionHash} was not confirmed in time.`, lastTransportError);
|
|
26
43
|
};
|
|
27
44
|
//#endregion
|
|
28
45
|
export { waitForStellarTransaction };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForStellarTransaction.js","names":[],"sources":["../../../../../src/core/tasks/helpers/waitForStellarTransaction.ts"],"sourcesContent":["import { LiFiErrorCode, type SDKClient, TransactionError } from '@lifi/sdk'\nimport {
|
|
1
|
+
{"version":3,"file":"waitForStellarTransaction.js","names":[],"sources":["../../../../../src/core/tasks/helpers/waitForStellarTransaction.ts"],"sourcesContent":["import { LiFiErrorCode, type SDKClient, TransactionError } from '@lifi/sdk'\nimport { Api } from '@stellar/stellar-sdk/rpc'\nimport { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'\n\nconst CONFIRM_POLL_INTERVAL_MS = 3_000\n\n/**\n * Outlives the backend's `[0, now + 300 s]` timebounds, so a transaction that\n * has not been applied by the deadline is genuinely dead rather than still in\n * flight. Expressed as a deadline, not an attempt count, so a caller-supplied\n * polling interval cannot shorten the budget.\n */\nconst CONFIRM_TIMEOUT_MS = 330_000\n\n/**\n * Polls `getTransaction` until the transaction is included in a ledger.\n *\n * `NOT_FOUND` is not an error — Soroban RPC only knows a transaction once it has\n * been applied — so polling continues until the deadline passes and the result\n * is reported as a timeout rather than a failure.\n *\n * A transport failure costs one interval rather than the whole wait: every RPC\n * can reject one read during a rate-limit burst while the transaction is\n * perfectly healthy. The last such error rides along as the timeout's cause.\n *\n * The terminal classification is deliberately done outside\n * {@link callStellarRpcsWithRetry}; only the read goes through the failover\n * wrapper, which would otherwise wrap a classified error in an `AggregateError`.\n */\nexport const waitForStellarTransaction = async (\n client: SDKClient,\n transactionHash: string,\n pollingIntervalMs: number = CONFIRM_POLL_INTERVAL_MS\n): Promise<Api.GetSuccessfulTransactionResponse> => {\n const deadline = Date.now() + CONFIRM_TIMEOUT_MS\n let lastTransportError: Error | undefined\n\n while (Date.now() < deadline) {\n try {\n const response = await callStellarRpcsWithRetry(client, (server) =>\n server.getTransaction(transactionHash)\n )\n\n if (response.status === Api.GetTransactionStatus.SUCCESS) {\n return response\n }\n\n if (response.status === Api.GetTransactionStatus.FAILED) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n `Stellar transaction ${transactionHash} failed: ${\n response.resultXdr?.result().switch().name ?? 'unknown reason'\n }`\n )\n }\n } catch (error) {\n // The ledger's verdict is terminal; only transport failures are retried.\n if (error instanceof TransactionError) {\n throw error\n }\n lastTransportError =\n error instanceof Error ? error : new Error(String(error))\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollingIntervalMs))\n }\n\n throw new TransactionError(\n LiFiErrorCode.Timeout,\n `Stellar transaction ${transactionHash} was not confirmed in time.`,\n lastTransportError\n )\n}\n"],"mappings":";;;;AAIA,MAAM,2BAA2B;;;;;;;AAQjC,MAAM,qBAAqB;;;;;;;;;;;;;;;;AAiB3B,MAAa,4BAA4B,OACvC,QACA,iBACA,oBAA4B,6BACsB;CAClD,MAAM,WAAW,KAAK,IAAI,IAAI;CAC9B,IAAI;CAEJ,OAAO,KAAK,IAAI,IAAI,UAAU;EAC5B,IAAI;GACF,MAAM,WAAW,MAAM,yBAAyB,SAAS,WACvD,OAAO,eAAe,eAAe,CACvC;GAEA,IAAI,SAAS,WAAW,IAAI,qBAAqB,SAC/C,OAAO;GAGT,IAAI,SAAS,WAAW,IAAI,qBAAqB,QAC/C,MAAM,IAAI,iBACR,cAAc,mBACd,uBAAuB,gBAAgB,WACrC,SAAS,WAAW,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,kBAElD;EAEJ,SAAS,OAAO;GAEd,IAAI,iBAAiB,kBACnB,MAAM;GAER,qBACE,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;EAC5D;EAEA,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,iBAAiB,CAAC;CACvE;CAEA,MAAM,IAAI,iBACR,cAAc,SACd,uBAAuB,gBAAgB,8BACvC,kBACF;AACF"}
|
|
@@ -6,9 +6,15 @@ 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) => {
|
|
13
|
+
if (e instanceof AggregateError && e.errors.length) {
|
|
14
|
+
const classified = e.errors.find((error) => error instanceof BaseError);
|
|
15
|
+
return handleSpecificErrors(classified ?? e.errors[0]);
|
|
16
|
+
}
|
|
17
|
+
if (e instanceof BaseError) return e;
|
|
12
18
|
const message = typeof e === "string" ? e : e?.message ?? "";
|
|
13
19
|
const normalized = message.toLowerCase();
|
|
14
20
|
if (normalized.includes("reject") || normalized.includes("denied")) return new TransactionError(LiFiErrorCode.SignatureRejected, message, e);
|
|
@@ -18,7 +24,6 @@ const handleSpecificErrors = (e) => {
|
|
|
18
24
|
if (normalized.includes("tx_insufficient_fee") || normalized.includes("txinsufficientfee")) return new TransactionError(LiFiErrorCode.TransactionUnderpriced, message, e);
|
|
19
25
|
if (normalized.includes("allowance")) return new TransactionError(LiFiErrorCode.AllowanceRequired, message, e);
|
|
20
26
|
if (normalized.includes("simulation") || normalized.includes("simulate") || normalized.includes("hosterror")) return new TransactionError(LiFiErrorCode.TransactionSimulationFailed, message, e);
|
|
21
|
-
if (e instanceof BaseError) return e;
|
|
22
27
|
return new UnknownError(message || ErrorMessage.UnknownError, e);
|
|
23
28
|
};
|
|
24
29
|
//#endregion
|
|
@@ -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) => {\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
|
|
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/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StellarProviderOptions, StellarSDKProvider, StellarSignOptions, StellarSignedAuthEntry, StellarSignedTransaction, StellarWallet, isStellarProvider } from "./types.js";
|
|
2
|
-
import { StellarProvider } from "./StellarProvider.js";
|
|
3
|
-
export { StellarProvider, type StellarProviderOptions, type StellarSDKProvider, type StellarSignOptions, type StellarSignedAuthEntry, type StellarSignedTransaction, type StellarWallet, isStellarProvider };
|
|
2
|
+
import { DEFAULT_NETWORK_PASSPHRASE, StellarProvider } from "./StellarProvider.js";
|
|
3
|
+
export { DEFAULT_NETWORK_PASSPHRASE, StellarProvider, type StellarProviderOptions, type StellarSDKProvider, type StellarSignOptions, type StellarSignedAuthEntry, type StellarSignedTransaction, type StellarWallet, isStellarProvider };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StellarProvider } from "./StellarProvider.js";
|
|
1
|
+
import { DEFAULT_NETWORK_PASSPHRASE, StellarProvider } from "./StellarProvider.js";
|
|
2
2
|
import { isStellarProvider } from "./types.js";
|
|
3
|
-
export { StellarProvider, isStellarProvider };
|
|
3
|
+
export { DEFAULT_NETWORK_PASSPHRASE, StellarProvider, isStellarProvider };
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -36,20 +36,24 @@ interface StellarWallet {
|
|
|
36
36
|
/** The network passphrase the wallet is expected to sign against. */
|
|
37
37
|
networkPassphrase: string;
|
|
38
38
|
signTransaction: (xdr: string, opts?: StellarSignOptions) => Promise<StellarSignedTransaction>;
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Optional: the router routes use source-account auth, so the SDK never calls
|
|
41
|
+
* this. Present so an adapter can forward the Stellar Wallets Kit method.
|
|
42
|
+
*/
|
|
43
|
+
signAuthEntry?: (authEntry: string, opts?: StellarSignOptions) => Promise<StellarSignedAuthEntry>;
|
|
40
44
|
}
|
|
41
45
|
interface StellarProviderOptions {
|
|
42
46
|
getWallet?: () => Promise<StellarWallet>;
|
|
43
47
|
/**
|
|
44
48
|
* Network passphrase for the Stellar network this provider targets.
|
|
45
49
|
* Defaults to the public (mainnet) network.
|
|
50
|
+
*
|
|
51
|
+
* Balance reads follow this option alone. Signing prefers it and falls back
|
|
52
|
+
* to the connected wallet's passphrase, and `StellarStepExecutor.checkWallet`
|
|
53
|
+
* refuses to sign when the two disagree — so a wallet on a different network
|
|
54
|
+
* fails before the user signs, while balances still read against the option.
|
|
46
55
|
*/
|
|
47
56
|
networkPassphrase?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Optional Horizon REST endpoint used for balance/account reads. When omitted
|
|
50
|
-
* the provider falls back to the Stellar RPC URLs resolved from the SDK client.
|
|
51
|
-
*/
|
|
52
|
-
horizonUrl?: string;
|
|
53
57
|
}
|
|
54
58
|
interface StellarSDKProvider extends SDKProvider {
|
|
55
59
|
setOptions(options: StellarProviderOptions): void;
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;;;UAaiB;EACf;EACA;;;;;;UAOe;EACf;EACA;;;;;;;UAQe;EACf;EACA;;;;;;UAOe;;EAEf;;EAEA;EACA,kBACE,aACA,OAAO,uBACJ,QAAQ
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;;;UAaiB;EACf;EACA;;;;;;UAOe;EACf;EACA;;;;;;;UAQe;EACf;EACA;;;;;;UAOe;;EAEf;;EAEA;EACA,kBACE,aACA,OAAO,uBACJ,QAAQ;;;;;EAKb,iBACE,mBACA,OAAO,uBACJ,QAAQ;;UAGE;EACf,kBAAkB,QAAQ;;;;;;;;;;EAU1B;;UAGe,2BAA2B;EAC1C,WAAW,SAAS;;iBAGN,kBACd,UAAU,cACT,YAAY;;;;;UAQE;;EAEf;;EAEA;;EAEA;;;UAIe;;EAEf;;;;;EAKA,WAAW;;EAEX;;UAGe,mCACP,qBACN;EACF,QAAQ;EACR;EACA,cAAc,MAAM;;UAGL,mCAAmC;EAClD,QAAQ;EACR"}
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["import {\n ChainType,\n type LiFiStepExtended,\n type SDKProvider,\n type StepExecutorContext,\n type StepExecutorOptions,\n} from '@lifi/sdk'\n\n/**\n * Options passed to a wallet signing call. Mirrors the Stellar Wallets Kit\n * (`@creit.tech/stellar-wallets-kit`) signing surface so a widget adapter can\n * forward calls directly.\n */\nexport interface StellarSignOptions {\n networkPassphrase?: string\n address?: string\n}\n\n/**\n * Result of signing a transaction envelope — a base64 XDR string plus the\n * signer's public key. Matches the Stellar Wallets Kit `signTransaction` return.\n */\nexport interface StellarSignedTransaction {\n signedTxXdr: string\n signerAddress?: string\n}\n\n/**\n * Result of signing a Soroban authorization entry. Matches the Stellar Wallets\n * Kit `signAuthEntry` return. Not required for the router routes (source-account\n * auth), exposed for future-proofing.\n */\nexport interface StellarSignedAuthEntry {\n signedAuthEntry: string\n signerAddress?: string\n}\n\n/**\n * The minimal signer surface the SDK provider needs from a connected wallet.\n * The widget builds this adapter from the Stellar Wallets Kit instance.\n */\nexport interface StellarWallet {\n /** The connected G-address (source account). */\n address: string\n /** The network passphrase the wallet is expected to sign against. */\n networkPassphrase: string\n signTransaction: (\n xdr: string,\n opts?: StellarSignOptions\n ) => Promise<StellarSignedTransaction>\n
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["import {\n ChainType,\n type LiFiStepExtended,\n type SDKProvider,\n type StepExecutorContext,\n type StepExecutorOptions,\n} from '@lifi/sdk'\n\n/**\n * Options passed to a wallet signing call. Mirrors the Stellar Wallets Kit\n * (`@creit.tech/stellar-wallets-kit`) signing surface so a widget adapter can\n * forward calls directly.\n */\nexport interface StellarSignOptions {\n networkPassphrase?: string\n address?: string\n}\n\n/**\n * Result of signing a transaction envelope — a base64 XDR string plus the\n * signer's public key. Matches the Stellar Wallets Kit `signTransaction` return.\n */\nexport interface StellarSignedTransaction {\n signedTxXdr: string\n signerAddress?: string\n}\n\n/**\n * Result of signing a Soroban authorization entry. Matches the Stellar Wallets\n * Kit `signAuthEntry` return. Not required for the router routes (source-account\n * auth), exposed for future-proofing.\n */\nexport interface StellarSignedAuthEntry {\n signedAuthEntry: string\n signerAddress?: string\n}\n\n/**\n * The minimal signer surface the SDK provider needs from a connected wallet.\n * The widget builds this adapter from the Stellar Wallets Kit instance.\n */\nexport interface StellarWallet {\n /** The connected G-address (source account). */\n address: string\n /** The network passphrase the wallet is expected to sign against. */\n networkPassphrase: string\n signTransaction: (\n xdr: string,\n opts?: StellarSignOptions\n ) => Promise<StellarSignedTransaction>\n /**\n * Optional: the router routes use source-account auth, so the SDK never calls\n * this. Present so an adapter can forward the Stellar Wallets Kit method.\n */\n signAuthEntry?: (\n authEntry: string,\n opts?: StellarSignOptions\n ) => Promise<StellarSignedAuthEntry>\n}\n\nexport interface StellarProviderOptions {\n getWallet?: () => Promise<StellarWallet>\n /**\n * Network passphrase for the Stellar network this provider targets.\n * Defaults to the public (mainnet) network.\n *\n * Balance reads follow this option alone. Signing prefers it and falls back\n * to the connected wallet's passphrase, and `StellarStepExecutor.checkWallet`\n * refuses to sign when the two disagree — so a wallet on a different network\n * fails before the user signs, while balances still read against the option.\n */\n networkPassphrase?: string\n}\n\nexport interface StellarSDKProvider extends SDKProvider {\n setOptions(options: StellarProviderOptions): void\n}\n\nexport function isStellarProvider(\n provider: SDKProvider\n): provider is StellarSDKProvider {\n return provider.type === ChainType.STL\n}\n\n/**\n * A SAC allowance an included leg of a Stellar route needs before the route can\n * be executed. Resolved by {@link resolveApprovalRequirement}.\n */\nexport interface StellarApprovalRequirement {\n /** Soroban `C`-address that calls `transfer_from` and so consumes the allowance. */\n spender: string\n /** SAC contract id of the token the allowance is written against. */\n tokenAddress: string\n /** Amount the allowance has to cover. */\n amount: bigint\n}\n\n/** Execution context passed between {@link StellarStepExecutor} tasks. */\nexport interface StellarTaskContext {\n /** Hash of the submitted route transaction. */\n transactionHash?: string\n /**\n * Resolved SAC allowance requirement, or `undefined` when no included leg\n * needs one. Set by `StellarCheckAllowanceTask`.\n */\n approval?: StellarApprovalRequirement\n /** Whether the sender's SAC allowance already covers {@link approval}. */\n hasSufficientAllowance?: boolean\n}\n\nexport interface StellarStepExecutorContext\n extends StepExecutorContext,\n StellarTaskContext {\n wallet: StellarWallet\n networkPassphrase: string\n checkWallet: (step: LiFiStepExtended) => void\n}\n\nexport interface StellarStepExecutorOptions extends StepExecutorOptions {\n wallet: StellarWallet\n networkPassphrase: string\n}\n"],"mappings":";;AA8EA,SAAgB,kBACd,UACgC;CAChC,OAAO,SAAS,SAAS,UAAU;AACrC"}
|
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/StellarProvider.ts
CHANGED
|
@@ -14,6 +14,13 @@ import { resolveStellarAddress } from './actions/resolveStellarAddress.js'
|
|
|
14
14
|
import { StellarStepExecutor } from './core/StellarStepExecutor.js'
|
|
15
15
|
import type { StellarProviderOptions, StellarSDKProvider } from './types.js'
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The network every read defaults to when the integrator configures none.
|
|
19
|
+
* Signing prefers the connected wallet's passphrase instead, and
|
|
20
|
+
* `StellarStepExecutor.checkWallet` refuses a route whose networks disagree.
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_NETWORK_PASSPHRASE: string = Networks.PUBLIC
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Validates a Stellar account address. Only ed25519 G-addresses are accepted as
|
|
19
26
|
* senders — muxed `M`-addresses and contract `C`-addresses are intentionally
|
|
@@ -42,7 +49,7 @@ export function StellarProvider(
|
|
|
42
49
|
client,
|
|
43
50
|
walletAddress,
|
|
44
51
|
tokens,
|
|
45
|
-
_options.networkPassphrase ??
|
|
52
|
+
_options.networkPassphrase ?? DEFAULT_NETWORK_PASSPHRASE
|
|
46
53
|
),
|
|
47
54
|
async getStepExecutor(options: StepExecutorOptions): Promise<StepExecutor> {
|
|
48
55
|
if (!_options.getWallet) {
|