@lifi/sdk-provider-stellar 4.2.2 → 4.2.3
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 +37 -0
- package/dist/esm/core/tasks/helpers/buildApproveTransaction.js +1 -1
- package/dist/esm/core/tasks/helpers/buildApproveTransaction.js.map +1 -1
- package/dist/esm/core/tasks/helpers/deriveTransactionHash.js +2 -1
- package/dist/esm/core/tasks/helpers/deriveTransactionHash.js.map +1 -1
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.js +2 -2
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.js.map +1 -1
- package/dist/esm/core/tasks/helpers/waitForStellarTransaction.js +1 -1
- package/dist/esm/core/tasks/helpers/waitForStellarTransaction.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/core/tasks/helpers/buildApproveTransaction.ts +1 -1
- package/src/core/tasks/helpers/deriveTransactionHash.ts +4 -2
- package/src/core/tasks/helpers/submitStellarTransaction.ts +2 -2
- package/src/core/tasks/helpers/waitForStellarTransaction.ts +1 -1
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @lifi/sdk-provider-stellar
|
|
2
2
|
|
|
3
|
+
## 4.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#457](https://github.com/lifinance/sdk/pull/457) [`71b03eb`](https://github.com/lifinance/sdk/commit/71b03eb93d8d9af42759e05a359260f5ffd1e87f) Thanks [@chybisov](https://github.com/chybisov)! - Bump `@stellar/stellar-sdk` from 16.2.0 to 17.0.1.
|
|
8
|
+
|
|
9
|
+
v17 rebuilds the XDR namespace as a class based API and switches every byte
|
|
10
|
+
returning API from `Buffer` to `Uint8Array`. The public API of this package is
|
|
11
|
+
unchanged.
|
|
12
|
+
|
|
13
|
+
`deriveTransactionHash` called `.toString('hex')` on the result of
|
|
14
|
+
`transaction.hash()`. That is a `Uint8Array` now, whose `toString` ignores the
|
|
15
|
+
argument and returns comma separated decimals, so the digest is built from the
|
|
16
|
+
bytes instead. The helper still returns the same 64 character lowercase hex
|
|
17
|
+
string, which `StellarSignAndExecuteTask.unit.spec.ts` asserts against an
|
|
18
|
+
independently computed digest.
|
|
19
|
+
|
|
20
|
+
`submitStellarTransaction` and `waitForStellarTransaction` read the failure
|
|
21
|
+
reason through `result().switch().name`. The generated XDR classes expose
|
|
22
|
+
`result` as a readonly field with a `type` discriminant, so both read
|
|
23
|
+
`result.type`. The variant names are unchanged, and a new test pins the failure
|
|
24
|
+
variant into the error message.
|
|
25
|
+
|
|
26
|
+
`toXDR` and `TransactionBuilder.fromXDR` are both deprecated in v17 in favour of
|
|
27
|
+
`toXdr` and `fromXdr`, and both remain as aliases. All seven call sites moved to
|
|
28
|
+
the new names.
|
|
29
|
+
|
|
30
|
+
Two behaviour notes that need no code change here. v17 raises its Node floor to
|
|
31
|
+
22.12.0, and CI runs Node 26. v17 also sends `useUpgradedAuth: true` on every
|
|
32
|
+
simulation rather than omitting the key, which turns on CAP-71 address
|
|
33
|
+
credentials. The two read paths simulate methods that need no authorization, and
|
|
34
|
+
the approve path authorizes with the transaction source account, so a live
|
|
35
|
+
mainnet simulation records `sorobanCredentialsSourceAccount` and the flag has no
|
|
36
|
+
effect. Mainnet is on protocol 27, which activates CAP-71 in any case.
|
|
37
|
+
- Updated dependencies [[`954bc4b`](https://github.com/lifinance/sdk/commit/954bc4bda013b470102041810daf95cb4f9181a1)]:
|
|
38
|
+
- @lifi/sdk@4.6.1
|
|
39
|
+
|
|
3
40
|
## 4.2.2
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -23,7 +23,7 @@ const buildApproveTransaction = async (client, token, from, spender, amount, net
|
|
|
23
23
|
fee: BASE_FEE,
|
|
24
24
|
networkPassphrase
|
|
25
25
|
}).addOperation(new Contract(token).call("approve", Address.fromString(from).toScVal(), Address.fromString(spender).toScVal(), nativeToScVal(amount, { type: "i128" }), nativeToScVal(latestLedger.sequence + APPROVAL_TTL_LEDGERS, { type: "u32" }))).setTimeout(300).build();
|
|
26
|
-
return (await server.prepareTransaction(transaction)).
|
|
26
|
+
return (await server.prepareTransaction(transaction)).toXdr();
|
|
27
27
|
});
|
|
28
28
|
//#endregion
|
|
29
29
|
export { buildApproveTransaction };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildApproveTransaction.js","names":[],"sources":["../../../../../src/core/tasks/helpers/buildApproveTransaction.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n Address,\n BASE_FEE,\n Contract,\n nativeToScVal,\n TransactionBuilder,\n} from '@stellar/stellar-sdk'\nimport { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'\n\n/**\n * How long the granted allowance stays live, in ledgers. Ledgers close roughly\n * every 5s, so this is ~24h — far longer than the seconds between approving and\n * executing, but enough that a user who steps away mid-route doesn't have to\n * approve twice.\n */\nconst APPROVAL_TTL_LEDGERS = 17_280\n\n/**\n * Builds and simulation-assembles a SAC `approve(from, spender, amount,\n * expiration_ledger)` transaction, returning the unsigned envelope XDR.\n *\n * Uses `prepareTransaction`, which simulates and folds the footprint, auth\n * entries and resource fee into the envelope in one step — the client-side\n * equivalent of what the backend's invocation builder does for route\n * transactions.\n */\nexport const buildApproveTransaction = async (\n client: SDKClient,\n token: string,\n from: string,\n spender: string,\n amount: bigint,\n networkPassphrase: string\n): Promise<string> =>\n callStellarRpcsWithRetry(client, async (server) => {\n const [account, latestLedger] = await Promise.all([\n server.getAccount(from),\n server.getLatestLedger(),\n ])\n\n const transaction = new TransactionBuilder(account, {\n fee: BASE_FEE,\n networkPassphrase,\n })\n .addOperation(\n new Contract(token).call(\n 'approve',\n Address.fromString(from).toScVal(),\n Address.fromString(spender).toScVal(),\n nativeToScVal(amount, { type: 'i128' }),\n nativeToScVal(latestLedger.sequence + APPROVAL_TTL_LEDGERS, {\n type: 'u32',\n })\n )\n )\n .setTimeout(300)\n .build()\n\n const prepared = await server.prepareTransaction(transaction)\n return prepared.
|
|
1
|
+
{"version":3,"file":"buildApproveTransaction.js","names":[],"sources":["../../../../../src/core/tasks/helpers/buildApproveTransaction.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n Address,\n BASE_FEE,\n Contract,\n nativeToScVal,\n TransactionBuilder,\n} from '@stellar/stellar-sdk'\nimport { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'\n\n/**\n * How long the granted allowance stays live, in ledgers. Ledgers close roughly\n * every 5s, so this is ~24h — far longer than the seconds between approving and\n * executing, but enough that a user who steps away mid-route doesn't have to\n * approve twice.\n */\nconst APPROVAL_TTL_LEDGERS = 17_280\n\n/**\n * Builds and simulation-assembles a SAC `approve(from, spender, amount,\n * expiration_ledger)` transaction, returning the unsigned envelope XDR.\n *\n * Uses `prepareTransaction`, which simulates and folds the footprint, auth\n * entries and resource fee into the envelope in one step — the client-side\n * equivalent of what the backend's invocation builder does for route\n * transactions.\n */\nexport const buildApproveTransaction = async (\n client: SDKClient,\n token: string,\n from: string,\n spender: string,\n amount: bigint,\n networkPassphrase: string\n): Promise<string> =>\n callStellarRpcsWithRetry(client, async (server) => {\n const [account, latestLedger] = await Promise.all([\n server.getAccount(from),\n server.getLatestLedger(),\n ])\n\n const transaction = new TransactionBuilder(account, {\n fee: BASE_FEE,\n networkPassphrase,\n })\n .addOperation(\n new Contract(token).call(\n 'approve',\n Address.fromString(from).toScVal(),\n Address.fromString(spender).toScVal(),\n nativeToScVal(amount, { type: 'i128' }),\n nativeToScVal(latestLedger.sequence + APPROVAL_TTL_LEDGERS, {\n type: 'u32',\n })\n )\n )\n .setTimeout(300)\n .build()\n\n const prepared = await server.prepareTransaction(transaction)\n return prepared.toXdr()\n })\n"],"mappings":";;;;;;;;;AAgBA,MAAM,uBAAuB;;;;;;;;;;AAW7B,MAAa,0BAA0B,OACrC,QACA,OACA,MACA,SACA,QACA,sBAEA,yBAAyB,QAAQ,OAAO,WAAW;CACjD,MAAM,CAAC,SAAS,gBAAgB,MAAM,QAAQ,IAAI,CAChD,OAAO,WAAW,IAAI,GACtB,OAAO,gBAAgB,CACzB,CAAC;CAED,MAAM,cAAc,IAAI,mBAAmB,SAAS;EAClD,KAAK;EACL;CACF,CAAC,CAAC,CACC,aACC,IAAI,SAAS,KAAK,CAAC,CAAC,KAClB,WACA,QAAQ,WAAW,IAAI,CAAC,CAAC,QAAQ,GACjC,QAAQ,WAAW,OAAO,CAAC,CAAC,QAAQ,GACpC,cAAc,QAAQ,EAAE,MAAM,OAAO,CAAC,GACtC,cAAc,aAAa,WAAW,sBAAsB,EAC1D,MAAM,MACR,CAAC,CACH,CACF,CAAC,CACA,WAAW,GAAG,CAAC,CACf,MAAM;CAGT,QAAO,MADgB,OAAO,mBAAmB,WAAW,EAAA,CAC5C,MAAM;AACxB,CAAC"}
|
|
@@ -8,7 +8,8 @@ import { TransactionBuilder } from "@stellar/stellar-sdk";
|
|
|
8
8
|
* hash first and resume by polling instead of re-signing.
|
|
9
9
|
*/
|
|
10
10
|
const deriveTransactionHash = (signedTxXdr, networkPassphrase) => {
|
|
11
|
-
|
|
11
|
+
const transaction = TransactionBuilder.fromXdr(signedTxXdr, networkPassphrase);
|
|
12
|
+
return Array.from(transaction.hash(), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
12
13
|
};
|
|
13
14
|
//#endregion
|
|
14
15
|
export { deriveTransactionHash };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deriveTransactionHash.js","names":[],"sources":["../../../../../src/core/tasks/helpers/deriveTransactionHash.ts"],"sourcesContent":["import { type Transaction, TransactionBuilder } from '@stellar/stellar-sdk'\n\n/**\n * Derives the canonical transaction hash from a signed base64 envelope.\n *\n * The hash is a function of the envelope and the network passphrase, so it is\n * knowable before submission — which is what lets a signing task persist the\n * hash first and resume by polling instead of re-signing.\n */\nexport const deriveTransactionHash = (\n signedTxXdr: string,\n networkPassphrase: string\n): string => {\n const transaction = TransactionBuilder.
|
|
1
|
+
{"version":3,"file":"deriveTransactionHash.js","names":[],"sources":["../../../../../src/core/tasks/helpers/deriveTransactionHash.ts"],"sourcesContent":["import { type Transaction, TransactionBuilder } from '@stellar/stellar-sdk'\n\n/**\n * Derives the canonical transaction hash from a signed base64 envelope.\n *\n * The hash is a function of the envelope and the network passphrase, so it is\n * knowable before submission — which is what lets a signing task persist the\n * hash first and resume by polling instead of re-signing.\n */\nexport const deriveTransactionHash = (\n signedTxXdr: string,\n networkPassphrase: string\n): string => {\n const transaction = TransactionBuilder.fromXdr(\n signedTxXdr,\n networkPassphrase\n ) as Transaction\n return Array.from(transaction.hash(), (byte) =>\n byte.toString(16).padStart(2, '0')\n ).join('')\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,yBACX,aACA,sBACW;CACX,MAAM,cAAc,mBAAmB,QACrC,aACA,iBACF;CACA,OAAO,MAAM,KAAK,YAAY,KAAK,IAAI,SACrC,KAAK,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CACnC,CAAC,CAAC,KAAK,EAAE;AACX"}
|
|
@@ -27,14 +27,14 @@ const TRY_AGAIN_DELAY_MS = 2e3;
|
|
|
27
27
|
* core is telling us the envelope was not queued, not that it is invalid.
|
|
28
28
|
*/
|
|
29
29
|
const submitStellarTransaction = async (client, signedTxXdr, networkPassphrase) => {
|
|
30
|
-
const transaction = TransactionBuilder.
|
|
30
|
+
const transaction = TransactionBuilder.fromXdr(signedTxXdr, networkPassphrase);
|
|
31
31
|
for (let attempt = 0; attempt < TRY_AGAIN_ATTEMPTS; attempt++) {
|
|
32
32
|
const response = await callStellarRpcsWithRetry(client, (server) => server.sendTransaction(transaction));
|
|
33
33
|
switch (response.status) {
|
|
34
34
|
case "PENDING":
|
|
35
35
|
case "DUPLICATE": return response.hash;
|
|
36
36
|
case "TRY_AGAIN_LATER": break;
|
|
37
|
-
default: throw new TransactionError(LiFiErrorCode.TransactionFailed, `Stellar transaction submission failed: ${response.errorResult?.result
|
|
37
|
+
default: throw new TransactionError(LiFiErrorCode.TransactionFailed, `Stellar transaction submission failed: ${response.errorResult?.result.type ?? response.status}`);
|
|
38
38
|
}
|
|
39
39
|
if (attempt < 2) await new Promise((resolve) => setTimeout(resolve, TRY_AGAIN_DELAY_MS));
|
|
40
40
|
}
|
|
@@ -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.
|
|
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.type ?? 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,QAAQ,SAAS,QAElD;EACJ;EAEA,IAAI,UAAU,GACZ,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,kBAAkB,CAAC;CAE1E;CAEA,MAAM,IAAI,iBACR,cAAc,mBACd,uCACF;AACF"}
|
|
@@ -32,7 +32,7 @@ const waitForStellarTransaction = async (client, transactionHash, pollingInterva
|
|
|
32
32
|
try {
|
|
33
33
|
const response = await callStellarRpcsWithRetry(client, (server) => server.getTransaction(transactionHash));
|
|
34
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
|
|
35
|
+
if (response.status === Api.GetTransactionStatus.FAILED) throw new TransactionError(LiFiErrorCode.TransactionFailed, `Stellar transaction ${transactionHash} failed: ${response.resultXdr?.result.type ?? "unknown reason"}`);
|
|
36
36
|
} catch (error) {
|
|
37
37
|
if (error instanceof TransactionError) throw error;
|
|
38
38
|
lastTransportError = error instanceof Error ? error : new Error(String(error));
|
|
@@ -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 { 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
|
|
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.type ?? '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,QAAQ,kBAEvC;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"}
|
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 = '4.2.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-stellar'\nexport const version = '4.2.3'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk-provider-stellar",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.3",
|
|
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
|
-
"@lifi/sdk": "4.6.
|
|
32
|
-
"@stellar/stellar-sdk": "^
|
|
31
|
+
"@lifi/sdk": "4.6.1",
|
|
32
|
+
"@stellar/stellar-sdk": "^17.0.1"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
@@ -11,9 +11,11 @@ export const deriveTransactionHash = (
|
|
|
11
11
|
signedTxXdr: string,
|
|
12
12
|
networkPassphrase: string
|
|
13
13
|
): string => {
|
|
14
|
-
const transaction = TransactionBuilder.
|
|
14
|
+
const transaction = TransactionBuilder.fromXdr(
|
|
15
15
|
signedTxXdr,
|
|
16
16
|
networkPassphrase
|
|
17
17
|
) as Transaction
|
|
18
|
-
return transaction.hash()
|
|
18
|
+
return Array.from(transaction.hash(), (byte) =>
|
|
19
|
+
byte.toString(16).padStart(2, '0')
|
|
20
|
+
).join('')
|
|
19
21
|
}
|
|
@@ -33,7 +33,7 @@ export const submitStellarTransaction = async (
|
|
|
33
33
|
signedTxXdr: string,
|
|
34
34
|
networkPassphrase: string
|
|
35
35
|
): Promise<string> => {
|
|
36
|
-
const transaction = TransactionBuilder.
|
|
36
|
+
const transaction = TransactionBuilder.fromXdr(
|
|
37
37
|
signedTxXdr,
|
|
38
38
|
networkPassphrase
|
|
39
39
|
) as Transaction
|
|
@@ -54,7 +54,7 @@ export const submitStellarTransaction = async (
|
|
|
54
54
|
throw new TransactionError(
|
|
55
55
|
LiFiErrorCode.TransactionFailed,
|
|
56
56
|
`Stellar transaction submission failed: ${
|
|
57
|
-
response.errorResult?.result
|
|
57
|
+
response.errorResult?.result.type ?? response.status
|
|
58
58
|
}`
|
|
59
59
|
)
|
|
60
60
|
}
|
|
@@ -49,7 +49,7 @@ export const waitForStellarTransaction = async (
|
|
|
49
49
|
throw new TransactionError(
|
|
50
50
|
LiFiErrorCode.TransactionFailed,
|
|
51
51
|
`Stellar transaction ${transactionHash} failed: ${
|
|
52
|
-
response.resultXdr?.result
|
|
52
|
+
response.resultXdr?.result.type ?? 'unknown reason'
|
|
53
53
|
}`
|
|
54
54
|
)
|
|
55
55
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk-provider-stellar'
|
|
2
|
-
export const version = '4.2.
|
|
2
|
+
export const version = '4.2.3'
|