@lifi/sdk-provider-solana 4.0.7 → 4.1.1
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 +117 -0
- package/dist/cjs/actions/sendAndConfirmBundle.d.ts +18 -25
- package/dist/cjs/actions/sendAndConfirmBundle.js +33 -54
- package/dist/cjs/actions/sendAndConfirmBundle.js.map +1 -1
- package/dist/cjs/actions/sendAndConfirmTransaction.d.ts +14 -22
- package/dist/cjs/actions/sendAndConfirmTransaction.js +38 -55
- package/dist/cjs/actions/sendAndConfirmTransaction.js.map +1 -1
- package/dist/cjs/confirmation/abortableSleep.d.ts +19 -0
- package/dist/cjs/confirmation/abortableSleep.js +32 -0
- package/dist/cjs/confirmation/abortableSleep.js.map +1 -0
- package/dist/cjs/confirmation/confirmBundle.d.ts +43 -0
- package/dist/cjs/confirmation/confirmBundle.js +57 -0
- package/dist/cjs/confirmation/confirmBundle.js.map +1 -0
- package/dist/cjs/confirmation/confirmSignature.d.ts +29 -0
- package/dist/cjs/confirmation/confirmSignature.js +66 -0
- package/dist/cjs/confirmation/confirmSignature.js.map +1 -0
- package/dist/cjs/confirmation/createConfirmationDeadline.d.ts +51 -0
- package/dist/cjs/confirmation/createConfirmationDeadline.js +101 -0
- package/dist/cjs/confirmation/createConfirmationDeadline.js.map +1 -0
- package/dist/cjs/confirmation/pollUntilDeadline.d.ts +58 -0
- package/dist/cjs/confirmation/pollUntilDeadline.js +97 -0
- package/dist/cjs/confirmation/pollUntilDeadline.js.map +1 -0
- package/dist/cjs/confirmation/raceRpcs.d.ts +26 -0
- package/dist/cjs/confirmation/raceRpcs.js +93 -0
- package/dist/cjs/confirmation/raceRpcs.js.map +1 -0
- package/dist/cjs/confirmation/types.d.ts +18 -0
- package/dist/cjs/confirmation/types.js +9 -0
- package/dist/cjs/confirmation/types.js.map +1 -0
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js +30 -9
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js +5 -1
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js +20 -7
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/readSignature.d.ts +17 -0
- package/dist/cjs/core/tasks/readSignature.js +26 -0
- package/dist/cjs/core/tasks/readSignature.js.map +1 -0
- package/dist/cjs/core/tasks/unwrapConfirmation.d.ts +25 -0
- package/dist/cjs/core/tasks/unwrapConfirmation.js +24 -0
- package/dist/cjs/core/tasks/unwrapConfirmation.js.map +1 -0
- package/dist/cjs/rpc/jito/api/getBundleStatuses.d.ts +4 -2
- package/dist/cjs/rpc/registry.d.ts +37 -11
- package/dist/cjs/rpc/registry.js +103 -18
- package/dist/cjs/rpc/registry.js.map +1 -1
- package/dist/cjs/rpc/utils.js +1 -1
- package/dist/cjs/rpc/utils.js.map +1 -1
- package/dist/cjs/utils/KeypairWalletAdapter.js +10 -4
- package/dist/cjs/utils/KeypairWalletAdapter.js.map +1 -1
- package/dist/cjs/utils/getTransactionLifetime.d.ts +21 -0
- package/dist/cjs/utils/getTransactionLifetime.js +28 -0
- package/dist/cjs/utils/getTransactionLifetime.js.map +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/sendAndConfirmBundle.d.ts +18 -25
- package/dist/esm/actions/sendAndConfirmBundle.d.ts.map +1 -1
- package/dist/esm/actions/sendAndConfirmBundle.js +34 -55
- package/dist/esm/actions/sendAndConfirmBundle.js.map +1 -1
- package/dist/esm/actions/sendAndConfirmTransaction.d.ts +14 -22
- package/dist/esm/actions/sendAndConfirmTransaction.d.ts.map +1 -1
- package/dist/esm/actions/sendAndConfirmTransaction.js +38 -55
- package/dist/esm/actions/sendAndConfirmTransaction.js.map +1 -1
- package/dist/esm/confirmation/abortableSleep.d.ts +19 -0
- package/dist/esm/confirmation/abortableSleep.d.ts.map +1 -0
- package/dist/esm/confirmation/abortableSleep.js +31 -0
- package/dist/esm/confirmation/abortableSleep.js.map +1 -0
- package/dist/esm/confirmation/confirmBundle.d.ts +43 -0
- package/dist/esm/confirmation/confirmBundle.d.ts.map +1 -0
- package/dist/esm/confirmation/confirmBundle.js +55 -0
- package/dist/esm/confirmation/confirmBundle.js.map +1 -0
- package/dist/esm/confirmation/confirmSignature.d.ts +29 -0
- package/dist/esm/confirmation/confirmSignature.d.ts.map +1 -0
- package/dist/esm/confirmation/confirmSignature.js +64 -0
- package/dist/esm/confirmation/confirmSignature.js.map +1 -0
- package/dist/esm/confirmation/createConfirmationDeadline.d.ts +51 -0
- package/dist/esm/confirmation/createConfirmationDeadline.d.ts.map +1 -0
- package/dist/esm/confirmation/createConfirmationDeadline.js +93 -0
- package/dist/esm/confirmation/createConfirmationDeadline.js.map +1 -0
- package/dist/esm/confirmation/pollUntilDeadline.d.ts +58 -0
- package/dist/esm/confirmation/pollUntilDeadline.d.ts.map +1 -0
- package/dist/esm/confirmation/pollUntilDeadline.js +93 -0
- package/dist/esm/confirmation/pollUntilDeadline.js.map +1 -0
- package/dist/esm/confirmation/raceRpcs.d.ts +26 -0
- package/dist/esm/confirmation/raceRpcs.d.ts.map +1 -0
- package/dist/esm/confirmation/raceRpcs.js +92 -0
- package/dist/esm/confirmation/raceRpcs.js.map +1 -0
- package/dist/esm/confirmation/types.d.ts +18 -0
- package/dist/esm/confirmation/types.d.ts.map +1 -0
- package/dist/esm/confirmation/types.js +8 -0
- package/dist/esm/confirmation/types.js.map +1 -0
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js +30 -9
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js +5 -1
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js +20 -7
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/readSignature.d.ts +17 -0
- package/dist/esm/core/tasks/readSignature.d.ts.map +1 -0
- package/dist/esm/core/tasks/readSignature.js +25 -0
- package/dist/esm/core/tasks/readSignature.js.map +1 -0
- package/dist/esm/core/tasks/unwrapConfirmation.d.ts +25 -0
- package/dist/esm/core/tasks/unwrapConfirmation.d.ts.map +1 -0
- package/dist/esm/core/tasks/unwrapConfirmation.js +23 -0
- package/dist/esm/core/tasks/unwrapConfirmation.js.map +1 -0
- package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts +4 -2
- package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts.map +1 -1
- package/dist/esm/rpc/registry.d.ts +37 -11
- package/dist/esm/rpc/registry.d.ts.map +1 -1
- package/dist/esm/rpc/registry.js +102 -19
- package/dist/esm/rpc/registry.js.map +1 -1
- package/dist/esm/rpc/utils.js +1 -1
- package/dist/esm/rpc/utils.js.map +1 -1
- package/dist/esm/utils/KeypairWalletAdapter.d.ts.map +1 -1
- package/dist/esm/utils/KeypairWalletAdapter.js +11 -5
- package/dist/esm/utils/KeypairWalletAdapter.js.map +1 -1
- package/dist/esm/utils/getTransactionLifetime.d.ts +21 -0
- package/dist/esm/utils/getTransactionLifetime.d.ts.map +1 -0
- package/dist/esm/utils/getTransactionLifetime.js +27 -0
- package/dist/esm/utils/getTransactionLifetime.js.map +1 -0
- 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 +4 -4
- package/src/actions/sendAndConfirmBundle.ts +82 -142
- package/src/actions/sendAndConfirmTransaction.ts +82 -134
- package/src/confirmation/abortableSleep.ts +30 -0
- package/src/confirmation/confirmBundle.ts +121 -0
- package/src/confirmation/confirmSignature.ts +113 -0
- package/src/confirmation/createConfirmationDeadline.ts +174 -0
- package/src/confirmation/pollUntilDeadline.ts +182 -0
- package/src/confirmation/raceRpcs.ts +135 -0
- package/src/confirmation/types.ts +23 -0
- package/src/core/tasks/SolanaJitoWaitForTransactionTask.ts +49 -16
- package/src/core/tasks/SolanaSignAndExecuteTask.ts +15 -0
- package/src/core/tasks/SolanaStandardWaitForTransactionTask.ts +28 -17
- package/src/core/tasks/readSignature.ts +29 -0
- package/src/core/tasks/unwrapConfirmation.ts +59 -0
- package/src/rpc/jito/api/getBundleStatuses.ts +4 -2
- package/src/rpc/registry.ts +183 -25
- package/src/rpc/utils.ts +5 -2
- package/src/utils/KeypairWalletAdapter.ts +34 -9
- package/src/utils/getTransactionLifetime.ts +38 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,122 @@
|
|
|
1
1
|
# @lifi/sdk-provider-solana
|
|
2
2
|
|
|
3
|
+
## 4.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`b5ace9d`](https://github.com/lifinance/sdk/commit/b5ace9d9a2a0267ae4231b42035b55a0e1def72e)]:
|
|
8
|
+
- @lifi/sdk@4.6.0
|
|
9
|
+
|
|
10
|
+
## 4.1.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#454](https://github.com/lifinance/sdk/pull/454) [`d86f36f`](https://github.com/lifinance/sdk/commit/d86f36f6c85d738a97ad8207e5e519fbefee7040) Thanks [@chybisov](https://github.com/chybisov)! - Bump `@solana/kit` from 7.1.0 to 8.0.0.
|
|
15
|
+
|
|
16
|
+
v8 removes the deprecated compute-unit-limit estimation helpers
|
|
17
|
+
(`estimateComputeUnitLimitFactory`, `estimateAndSetComputeUnitLimitFactory`,
|
|
18
|
+
`fillTransactionMessageProvisoryComputeUnitLimit`), `getBigIntDowncastRequestTransformer`,
|
|
19
|
+
the fixed transaction size constants (`TRANSACTION_PACKET_SIZE`,
|
|
20
|
+
`TRANSACTION_PACKET_HEADER`, `TRANSACTION_SIZE_LIMIT`), and several
|
|
21
|
+
`@solana/instruction-plans` result types, and it stops writing to the execution context in
|
|
22
|
+
`createTransactionPlanExecutor`. This package uses none of them, so no migration was
|
|
23
|
+
needed. `assertIsTransactionWithinSizeLimit` survives, and its threshold is now
|
|
24
|
+
transaction-version-aware rather than a single constant.
|
|
25
|
+
|
|
26
|
+
Minor rather than patch: no exported signature changes, but `@solana/kit` is a regular
|
|
27
|
+
dependency whose types reach this package's public surface — `toAddress` is re-exported
|
|
28
|
+
from it, and `SolanaProviderOptions.signedTransactions` is typed with its `Transaction`.
|
|
29
|
+
Integrators who also depend on `@solana/kit` directly must move to 8.x, or they will
|
|
30
|
+
resolve two copies whose types do not interchange.
|
|
31
|
+
|
|
32
|
+
- [#448](https://github.com/lifinance/sdk/pull/448) [`1ab67e5`](https://github.com/lifinance/sdk/commit/1ab67e5b5d89446a9c08530c6d9c296179e1a359) Thanks [@chybisov](https://github.com/chybisov)! - Fix false `TransactionExpired` errors on Solana swaps that confirmed on-chain.
|
|
33
|
+
|
|
34
|
+
Confirmation stopped polling by comparing `getBlockHeight()` against a freshly
|
|
35
|
+
fetched blockhash's `lastValidBlockHeight`. At least one endpoint in the
|
|
36
|
+
default RPC set answers `getBlockHeight` with the slot number (~22M higher), so
|
|
37
|
+
that comparison was false on its first evaluation and the endpoint never polled
|
|
38
|
+
at all. Every swap then depended on the remaining endpoint alone.
|
|
39
|
+
|
|
40
|
+
Polling now stops when the signed transaction's own blockhash dies, probed via
|
|
41
|
+
`isBlockhashValid`, and in any case after a 90 second ceiling. `getBlockHeight`
|
|
42
|
+
is never read. The wait is hard-bounded: branches abort 5 seconds after the
|
|
43
|
+
ceiling, so allow ~95 seconds for the confirmation phase. A branch also gives up
|
|
44
|
+
early once its endpoint has gone 30 seconds without answering a status read,
|
|
45
|
+
which is long enough to ride out a throttling window rather than end the swap
|
|
46
|
+
inside one.
|
|
47
|
+
|
|
48
|
+
Minor rather than patch: no exported signature changes, but the error
|
|
49
|
+
classification integrators branch on does. Transitions, old → new:
|
|
50
|
+
|
|
51
|
+
- Standard path, no RPC returned a usable response: `TransactionError`
|
|
52
|
+
`TransactionExpired` (1018) → `RPCError` `RpcUnavailable` (1027).
|
|
53
|
+
- Jito path, bundle never confirmed: `UnknownError` `InternalError` (1000) →
|
|
54
|
+
`TransactionError` `TransactionExpired` (1018).
|
|
55
|
+
- Jito path, every Jito RPC failed: `UnknownError` (1000) → `RPCError` (1027).
|
|
56
|
+
- Jito path, no RPC supports bundle methods: `UnknownError` (1000) → `RPCError`
|
|
57
|
+
(1027).
|
|
58
|
+
- Jito path, confirmed bundle whose signatures an RPC had not indexed yet:
|
|
59
|
+
`TransactionError` `TransactionFailed` (1003) → success.
|
|
60
|
+
- Jito path, confirmed bundle whose status omits `transactions`:
|
|
61
|
+
`UnknownError` (1000) → success.
|
|
62
|
+
- Either path, a signed transaction carrying no fee payer signature: raw
|
|
63
|
+
`SolanaError` → `TransactionError` `TransactionUnprepared` (1002). Both wait
|
|
64
|
+
tasks read the signature before they submit, so this throw now stays inside
|
|
65
|
+
the `LiFiErrorCode` contract instead of reaching integrator error branching
|
|
66
|
+
as an unclassified error.
|
|
67
|
+
|
|
68
|
+
A confirmed Jito bundle no longer fails on missing per-signature data. A bundle
|
|
69
|
+
is atomic, so a `confirmed` status means every transaction in it landed; a
|
|
70
|
+
`null` or absent `getSignatureStatuses` result is indexing lag, not failure.
|
|
71
|
+
The bundle-level `err` is now read as well.
|
|
72
|
+
|
|
73
|
+
`txHash` and `txLink` are both recorded when the first RPC accepts the send,
|
|
74
|
+
rather than only after confirmation. A swap that broadcast and then failed to
|
|
75
|
+
confirm now reports its signature, so it can be looked up on chain. Neither is
|
|
76
|
+
written at signing time: a signed-but-unsent signature resolves to `null` on
|
|
77
|
+
every explorer, and simulation, a send failure, or a bundle route with no
|
|
78
|
+
Jito-capable RPC all sit between signing and the first broadcast. Signing does
|
|
79
|
+
clear both fields, so a route resumed from storage no longer reports the previous
|
|
80
|
+
run's signature - including when decoding the signed transaction fails, since
|
|
81
|
+
the clearing write now precedes the decode. A throwing `updateRouteHook` no
|
|
82
|
+
longer fails the step from the broadcast callback, and no longer changes which
|
|
83
|
+
error a failed confirmation reports. The action writes that follow a verdict
|
|
84
|
+
are not guarded: a hook that throws there still fails the step, as before.
|
|
85
|
+
|
|
86
|
+
Jito capability is probed once per endpoint and cached, rather than re-probed
|
|
87
|
+
before every bundle submission, and concurrent submissions now share one probe
|
|
88
|
+
per URL instead of each firing their own. Each cached answer carries its own
|
|
89
|
+
retry window. An endpoint that names the method unknown over JSON-RPC is
|
|
90
|
+
believed permanently; a bare HTTP 401 or 403 is not, because it never reached
|
|
91
|
+
the JSON-RPC layer and cannot distinguish a plan restriction from a provider
|
|
92
|
+
mid-deploy or an allowlist entry still propagating. Those retry after 15
|
|
93
|
+
minutes, so one transient refusal no longer removes a working endpoint for the
|
|
94
|
+
lifetime of the process.
|
|
95
|
+
|
|
96
|
+
For integrators: routes the backend builds as Jito bundles need a Jito-capable
|
|
97
|
+
Solana RPC. The default set has none, and for `ChainId.SOL` URLs supplied via
|
|
98
|
+
`rpcUrls` replace the defaults rather than merging. Without one, such a route
|
|
99
|
+
fails before submission with `RpcUnavailable` (1027).
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- [#448](https://github.com/lifinance/sdk/pull/448) [`1ab67e5`](https://github.com/lifinance/sdk/commit/1ab67e5b5d89446a9c08530c6d9c296179e1a359) Thanks [@chybisov](https://github.com/chybisov)! - Fix `KeypairWalletAdapter`, which could not sign any real transaction.
|
|
104
|
+
|
|
105
|
+
`assertIsTransactionWithBlockhashLifetime` tested for a `lifetimeConstraint`
|
|
106
|
+
property that no `@solana/kit` decoder reconstructs, so every transaction was
|
|
107
|
+
rejected with `Transaction does not have a blockhash lifetime`. Signing never
|
|
108
|
+
needed it — the blockhash travels inside `messageBytes`.
|
|
109
|
+
|
|
110
|
+
The result then re-encoded the pre-signing object, discarding the signature,
|
|
111
|
+
because `partiallySignTransaction` returns a new transaction rather than
|
|
112
|
+
mutating its argument.
|
|
113
|
+
|
|
114
|
+
The adapter is test-only, so no production integration is affected.
|
|
115
|
+
|
|
116
|
+
Also removes the unused `isJitoRpc` helper, superseded by `probeJitoRpc`.
|
|
117
|
+
- Updated dependencies [[`1ab67e5`](https://github.com/lifinance/sdk/commit/1ab67e5b5d89446a9c08530c6d9c296179e1a359)]:
|
|
118
|
+
- @lifi/sdk@4.5.0
|
|
119
|
+
|
|
3
120
|
## 4.0.7
|
|
4
121
|
|
|
5
122
|
### Patch Changes
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
+
import { BundleConfirmation } from "../confirmation/confirmBundle.js";
|
|
2
|
+
import { RaceResult } from "../confirmation/raceRpcs.js";
|
|
1
3
|
import { SDKClient } from "@lifi/sdk";
|
|
2
|
-
import {
|
|
4
|
+
import { Transaction } from "@solana/kit";
|
|
3
5
|
//#region src/actions/sendAndConfirmBundle.d.ts
|
|
4
|
-
type SignatureStatus = {
|
|
5
|
-
slot: bigint;
|
|
6
|
-
confirmations: bigint | null;
|
|
7
|
-
err: TransactionError | null;
|
|
8
|
-
confirmationStatus: Commitment | null;
|
|
9
|
-
status: Readonly<{
|
|
10
|
-
Err: TransactionError;
|
|
11
|
-
}> | Readonly<{
|
|
12
|
-
Ok: null;
|
|
13
|
-
}>;
|
|
14
|
-
};
|
|
15
|
-
type BundleResult = {
|
|
16
|
-
bundleId: string;
|
|
17
|
-
txSignatures: Signature[];
|
|
18
|
-
signatureResults: (SignatureStatus | null)[];
|
|
19
|
-
};
|
|
20
6
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
7
|
+
* Sends a Jito bundle to every Jito-capable RPC and returns as soon as one of
|
|
8
|
+
* them confirms it.
|
|
9
|
+
*
|
|
10
|
+
* The deadline receives the lifetime of *every* signed transaction, not just
|
|
11
|
+
* the first: a bundle is an array of independently built backend transactions
|
|
12
|
+
* and they may not share a blockhash.
|
|
13
|
+
*
|
|
14
|
+
* `sendBundle` is handed to `confirmBundle` rather than awaited here, so the
|
|
15
|
+
* deadline starts on the same clock as `BRANCH_TIMEOUT_MS` instead of after
|
|
16
|
+
* the submission returns.
|
|
27
17
|
*/
|
|
28
|
-
declare function sendAndConfirmBundle(client: SDKClient, signedTransactions: Transaction[]
|
|
18
|
+
declare function sendAndConfirmBundle(client: SDKClient, signedTransactions: Transaction[], options?: {
|
|
19
|
+
/** Runs once, when the first Jito RPC accepts the submission. */
|
|
20
|
+
onBroadcast?: () => void;
|
|
21
|
+
}): Promise<RaceResult<BundleConfirmation>>;
|
|
29
22
|
//#endregion
|
|
30
|
-
export {
|
|
23
|
+
export { sendAndConfirmBundle };
|
|
31
24
|
//# sourceMappingURL=sendAndConfirmBundle.d.ts.map
|
|
@@ -1,65 +1,44 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rpc_registry = require("../rpc/registry.js");
|
|
3
|
+
const require_confirmation_createConfirmationDeadline = require("../confirmation/createConfirmationDeadline.js");
|
|
4
|
+
const require_confirmation_confirmBundle = require("../confirmation/confirmBundle.js");
|
|
5
|
+
const require_confirmation_raceRpcs = require("../confirmation/raceRpcs.js");
|
|
6
|
+
const require_utils_getTransactionLifetime = require("../utils/getTransactionLifetime.js");
|
|
3
7
|
let _lifi_sdk = require("@lifi/sdk");
|
|
4
8
|
let _solana_kit = require("@solana/kit");
|
|
5
9
|
//#region src/actions/sendAndConfirmBundle.ts
|
|
6
|
-
const NULL_BUNDLE_RESULT = /* @__PURE__ */ new Error("Bundle was not confirmed by this RPC");
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Sends a Jito bundle to every Jito-capable RPC and returns as soon as one of
|
|
12
|
+
* them confirms it.
|
|
13
|
+
*
|
|
14
|
+
* The deadline receives the lifetime of *every* signed transaction, not just
|
|
15
|
+
* the first: a bundle is an array of independently built backend transactions
|
|
16
|
+
* and they may not share a blockhash.
|
|
17
|
+
*
|
|
18
|
+
* `sendBundle` is handed to `confirmBundle` rather than awaited here, so the
|
|
19
|
+
* deadline starts on the same clock as `BRANCH_TIMEOUT_MS` instead of after
|
|
20
|
+
* the submission returns.
|
|
14
21
|
*/
|
|
15
|
-
async function sendAndConfirmBundle(client, signedTransactions) {
|
|
16
|
-
const jitoRpcs = await require_rpc_registry.getJitoRpcs(client);
|
|
17
|
-
if (jitoRpcs.length === 0) throw new
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
22
|
+
async function sendAndConfirmBundle(client, signedTransactions, options) {
|
|
23
|
+
const { rpcs: jitoRpcs, unreachable } = await require_rpc_registry.getJitoRpcs(client);
|
|
24
|
+
if (jitoRpcs.length === 0) throw new _lifi_sdk.RPCError(_lifi_sdk.LiFiErrorCode.RpcUnavailable, unreachable > 0 ? `Jito bundle required, but the capability probe failed against ${unreachable} configured Solana RPC(s). This is usually temporary - retry. If it persists, the endpoint may refuse \`sendBundle\` for your plan.` : "Jito bundle required, but no configured Solana RPC supports `sendBundle`. Supply a Jito-capable URL via the `rpcUrls` client config option.");
|
|
25
|
+
let broadcastReported = false;
|
|
26
|
+
const reportBroadcast = () => {
|
|
27
|
+
if (broadcastReported) return;
|
|
21
28
|
try {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!sigResponse?.value || !Array.isArray(sigResponse.value)) {
|
|
36
|
-
await (0, _lifi_sdk.sleep)(400);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
abortController.abort();
|
|
40
|
-
return {
|
|
41
|
-
bundleId,
|
|
42
|
-
txSignatures,
|
|
43
|
-
signatureResults: sigResponse.value
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
await (0, _lifi_sdk.sleep)(400);
|
|
47
|
-
if (!abortController.signal.aborted) currentBlockHeight = await jitoRpc.getBlockHeight({ commitment: "confirmed" }).send();
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
} catch (error) {
|
|
51
|
-
if (abortController.signal.aborted) return null;
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const result = await Promise.any(confirmPromises.map(async (promise) => {
|
|
56
|
-
const bundleResult = await promise;
|
|
57
|
-
if (!bundleResult) throw NULL_BUNDLE_RESULT;
|
|
58
|
-
return bundleResult;
|
|
59
|
-
})).catch(() => null);
|
|
60
|
-
if (!abortController.signal.aborted) abortController.abort();
|
|
61
|
-
if (!result) throw new Error("Failed to send and confirm bundle");
|
|
62
|
-
return result;
|
|
29
|
+
options?.onBroadcast?.();
|
|
30
|
+
broadcastReported = true;
|
|
31
|
+
} catch (_) {}
|
|
32
|
+
};
|
|
33
|
+
const serializedTransactions = signedTransactions.map((transaction) => (0, _solana_kit.getBase64EncodedWireTransaction)(transaction));
|
|
34
|
+
const lifetimes = await Promise.all(signedTransactions.map((transaction) => require_utils_getTransactionLifetime.getTransactionLifetime(transaction)));
|
|
35
|
+
return require_confirmation_raceRpcs.raceRpcs(jitoRpcs, (rpc, signal) => require_confirmation_confirmBundle.confirmBundle({
|
|
36
|
+
rpc,
|
|
37
|
+
signal,
|
|
38
|
+
lifetimes,
|
|
39
|
+
send: () => rpc.sendBundle(serializedTransactions).send({ abortSignal: signal }),
|
|
40
|
+
onBroadcast: reportBroadcast
|
|
41
|
+
}), { timeoutMs: require_confirmation_createConfirmationDeadline.BRANCH_TIMEOUT_MS });
|
|
63
42
|
}
|
|
64
43
|
//#endregion
|
|
65
44
|
exports.sendAndConfirmBundle = sendAndConfirmBundle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendAndConfirmBundle.js","names":["getJitoRpcs","getBase64EncodedWireTransaction","
|
|
1
|
+
{"version":3,"file":"sendAndConfirmBundle.js","names":["getJitoRpcs","RPCError","LiFiErrorCode","getBase64EncodedWireTransaction","getTransactionLifetime","raceRpcs","confirmBundle","BRANCH_TIMEOUT_MS"],"sources":["../../../src/actions/sendAndConfirmBundle.ts"],"sourcesContent":["import { LiFiErrorCode, RPCError, type SDKClient } from '@lifi/sdk'\nimport { getBase64EncodedWireTransaction, type Transaction } from '@solana/kit'\nimport {\n type BundleConfirmation,\n confirmBundle,\n} from '../confirmation/confirmBundle.js'\nimport { BRANCH_TIMEOUT_MS } from '../confirmation/createConfirmationDeadline.js'\nimport { type RaceResult, raceRpcs } from '../confirmation/raceRpcs.js'\nimport { getJitoRpcs } from '../rpc/registry.js'\nimport { getTransactionLifetime } from '../utils/getTransactionLifetime.js'\n\n/**\n * Sends a Jito bundle to every Jito-capable RPC and returns as soon as one of\n * them confirms it.\n *\n * The deadline receives the lifetime of *every* signed transaction, not just\n * the first: a bundle is an array of independently built backend transactions\n * and they may not share a blockhash.\n *\n * `sendBundle` is handed to `confirmBundle` rather than awaited here, so the\n * deadline starts on the same clock as `BRANCH_TIMEOUT_MS` instead of after\n * the submission returns.\n */\nexport async function sendAndConfirmBundle(\n client: SDKClient,\n signedTransactions: Transaction[],\n options?: {\n /** Runs once, when the first Jito RPC accepts the submission. */\n onBroadcast?: () => void\n }\n): Promise<RaceResult<BundleConfirmation>> {\n const { rpcs: jitoRpcs, unreachable } = await getJitoRpcs(client)\n\n // Named here, where the emptiness is known: racing zero RPCs would surface\n // as a bare `rpc-unavailable`, indistinguishable from a total outage. The\n // two causes get different messages - a configuration gap the integrator can\n // close, or endpoints that never answered.\n //\n // The `unreachable` message names a plan gate as well as an outage: a bare\n // HTTP 401/403 never reaches the JSON-RPC layer, so `readProbeFailure`\n // cannot tell a gated endpoint from a provider mid-deploy and classifies\n // both as `unreachable`. \"Retry\" alone would loop an integrator forever on a\n // gate no retry can clear.\n if (jitoRpcs.length === 0) {\n throw new RPCError(\n LiFiErrorCode.RpcUnavailable,\n unreachable > 0\n ? `Jito bundle required, but the capability probe failed against ${unreachable} configured Solana RPC(s). This is usually temporary - retry. If it persists, the endpoint may refuse \\`sendBundle\\` for your plan.`\n : 'Jito bundle required, but no configured Solana RPC supports `sendBundle`. Supply a Jito-capable URL via the `rpcUrls` client config option.'\n )\n }\n\n let broadcastReported = false\n // No `sendAccepted` twin here: a bundle submits once, and a failed `send()`\n // throws out of `confirmBundle` before polling starts, so this action has no\n // not-confirmed-but-never-sent case to disambiguate. See\n // `sendAndConfirmTransaction` for the signature path's version.\n const reportBroadcast = (): void => {\n if (broadcastReported) {\n return\n }\n try {\n options?.onBroadcast?.()\n // Latched only after the callback returned. A callback that threw wrote\n // nothing, so the next successful send must be allowed to try again -\n // latching first made one failed `txLink` write permanent.\n broadcastReported = true\n } catch (_) {\n // This runs integrator code: the callback reaches `updateRouteHook` via\n // `StatusManager.updateAction`. Its failure must never reject the branch\n // that called it - the send has already been accepted by the network at\n // this point, so a throw here would report a landed transaction as an\n // RPC outage. Swallowed rather than surfaced because there is no verdict\n // it could honestly change.\n }\n }\n\n const serializedTransactions = signedTransactions.map((transaction) =>\n getBase64EncodedWireTransaction(transaction)\n )\n\n const lifetimes = await Promise.all(\n signedTransactions.map((transaction) => getTransactionLifetime(transaction))\n )\n\n return raceRpcs(\n jitoRpcs,\n (rpc, signal) =>\n confirmBundle({\n rpc,\n signal,\n lifetimes,\n send: () =>\n rpc.sendBundle(serializedTransactions).send({ abortSignal: signal }),\n onBroadcast: reportBroadcast,\n }),\n { timeoutMs: BRANCH_TIMEOUT_MS }\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,qBACpB,QACA,oBACA,SAIyC;CACzC,MAAM,EAAE,MAAM,UAAU,gBAAgB,MAAMA,qBAAAA,YAAY,MAAM;CAYhE,IAAI,SAAS,WAAW,GACtB,MAAM,IAAIC,UAAAA,SACRC,UAAAA,cAAc,gBACd,cAAc,IACV,iEAAiE,YAAY,uIAC7E,6IACN;CAGF,IAAI,oBAAoB;CAKxB,MAAM,wBAA8B;EAClC,IAAI,mBACF;EAEF,IAAI;GACF,SAAS,cAAc;GAIvB,oBAAoB;EACtB,SAAS,GAAG,CAOZ;CACF;CAEA,MAAM,yBAAyB,mBAAmB,KAAK,iBAAA,GACrDC,YAAAA,gCAAAA,CAAgC,WAAW,CAC7C;CAEA,MAAM,YAAY,MAAM,QAAQ,IAC9B,mBAAmB,KAAK,gBAAgBC,qCAAAA,uBAAuB,WAAW,CAAC,CAC7E;CAEA,OAAOC,8BAAAA,SACL,WACC,KAAK,WACJC,mCAAAA,cAAc;EACZ;EACA;EACA;EACA,YACE,IAAI,WAAW,sBAAsB,CAAC,CAAC,KAAK,EAAE,aAAa,OAAO,CAAC;EACrE,aAAa;CACf,CAAC,GACH,EAAE,WAAWC,gDAAAA,kBAAkB,CACjC;AACF"}
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
+
import { SignatureStatus } from "../confirmation/types.js";
|
|
2
|
+
import { RaceResult } from "../confirmation/raceRpcs.js";
|
|
1
3
|
import { SDKClient } from "@lifi/sdk";
|
|
2
|
-
import {
|
|
4
|
+
import { Transaction } from "@solana/kit";
|
|
3
5
|
//#region src/actions/sendAndConfirmTransaction.d.ts
|
|
4
|
-
type SignatureStatus = {
|
|
5
|
-
slot: bigint;
|
|
6
|
-
confirmations: bigint | null;
|
|
7
|
-
err: TransactionError | null;
|
|
8
|
-
confirmationStatus: Commitment | null;
|
|
9
|
-
status: Readonly<{
|
|
10
|
-
Err: TransactionError;
|
|
11
|
-
}> | Readonly<{
|
|
12
|
-
Ok: null;
|
|
13
|
-
}>;
|
|
14
|
-
};
|
|
15
|
-
type ConfirmedTransactionResult = {
|
|
16
|
-
signatureResult: SignatureStatus | null;
|
|
17
|
-
txSignature: string;
|
|
18
|
-
};
|
|
19
6
|
/**
|
|
20
|
-
* Sends a Solana transaction to
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
7
|
+
* Sends a Solana transaction to every configured RPC and returns as soon as
|
|
8
|
+
* one of them confirms it.
|
|
9
|
+
*
|
|
10
|
+
* The polling horizon comes from the signed transaction's own blockhash and a
|
|
11
|
+
* wall-clock ceiling. It deliberately never comes from `getBlockHeight`: at
|
|
12
|
+
* least one endpoint in the default LI.FI set answers that call with the slot
|
|
13
|
+
* number.
|
|
25
14
|
*/
|
|
26
|
-
declare function sendAndConfirmTransaction(client: SDKClient, signedTransaction: Transaction
|
|
15
|
+
declare function sendAndConfirmTransaction(client: SDKClient, signedTransaction: Transaction, options?: {
|
|
16
|
+
/** Runs once, when the first RPC accepts a send. */
|
|
17
|
+
onBroadcast?: () => void;
|
|
18
|
+
}): Promise<RaceResult<SignatureStatus>>;
|
|
27
19
|
//#endregion
|
|
28
20
|
export { sendAndConfirmTransaction };
|
|
29
21
|
//# sourceMappingURL=sendAndConfirmTransaction.d.ts.map
|
|
@@ -1,74 +1,57 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rpc_registry = require("../rpc/registry.js");
|
|
3
|
-
|
|
3
|
+
const require_confirmation_createConfirmationDeadline = require("../confirmation/createConfirmationDeadline.js");
|
|
4
|
+
const require_confirmation_raceRpcs = require("../confirmation/raceRpcs.js");
|
|
5
|
+
const require_utils_getTransactionLifetime = require("../utils/getTransactionLifetime.js");
|
|
6
|
+
const require_confirmation_confirmSignature = require("../confirmation/confirmSignature.js");
|
|
4
7
|
let _solana_kit = require("@solana/kit");
|
|
5
8
|
//#region src/actions/sendAndConfirmTransaction.ts
|
|
6
|
-
const NULL_CONFIRMATION_RESULT = /* @__PURE__ */ new Error("Transaction was not confirmed by this RPC");
|
|
7
9
|
/**
|
|
8
|
-
* Sends a Solana transaction to
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Sends a Solana transaction to every configured RPC and returns as soon as
|
|
11
|
+
* one of them confirms it.
|
|
12
|
+
*
|
|
13
|
+
* The polling horizon comes from the signed transaction's own blockhash and a
|
|
14
|
+
* wall-clock ceiling. It deliberately never comes from `getBlockHeight`: at
|
|
15
|
+
* least one endpoint in the default LI.FI set answers that call with the slot
|
|
16
|
+
* number.
|
|
13
17
|
*/
|
|
14
|
-
async function sendAndConfirmTransaction(client, signedTransaction) {
|
|
18
|
+
async function sendAndConfirmTransaction(client, signedTransaction, options) {
|
|
15
19
|
const solanaRpcs = await require_rpc_registry.getSolanaRpcs(client);
|
|
20
|
+
let broadcastReported = false;
|
|
21
|
+
let sendAccepted = false;
|
|
22
|
+
const reportBroadcast = () => {
|
|
23
|
+
sendAccepted = true;
|
|
24
|
+
if (broadcastReported) return;
|
|
25
|
+
try {
|
|
26
|
+
options?.onBroadcast?.();
|
|
27
|
+
broadcastReported = true;
|
|
28
|
+
} catch (_) {}
|
|
29
|
+
};
|
|
16
30
|
const signedTxSerialized = (0, _solana_kit.getBase64EncodedWireTransaction)(signedTransaction);
|
|
17
31
|
const txSignature = (0, _solana_kit.getSignatureFromTransaction)(signedTransaction);
|
|
18
|
-
|
|
32
|
+
const lifetime = await require_utils_getTransactionLifetime.getTransactionLifetime(signedTransaction);
|
|
19
33
|
const rawTransactionOptions = {
|
|
20
34
|
skipPreflight: true,
|
|
21
35
|
maxRetries: BigInt(0),
|
|
22
36
|
preflightCommitment: "confirmed",
|
|
23
37
|
encoding: "base64"
|
|
24
38
|
};
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
abortController.abort();
|
|
40
|
-
return status;
|
|
41
|
-
}
|
|
42
|
-
await (0, _lifi_sdk.sleep)(400);
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
})();
|
|
46
|
-
const sendingPromise = (async () => {
|
|
47
|
-
while (blockHeight < blockhashResult.lastValidBlockHeight && !abortController.signal.aborted && !signatureResult) {
|
|
48
|
-
try {
|
|
49
|
-
await rpc.sendTransaction(signedTxSerialized, rawTransactionOptions).send();
|
|
50
|
-
} catch (_) {}
|
|
51
|
-
await (0, _lifi_sdk.sleep)(1e3);
|
|
52
|
-
if (!abortController.signal.aborted) blockHeight = await rpc.getBlockHeight({ commitment: "confirmed" }).send();
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
})();
|
|
56
|
-
return await Promise.race([pollingPromise, sendingPromise]);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
if (abortController.signal.aborted) return null;
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
const signatureResult = await Promise.any(confirmPromises.map(async (promise) => {
|
|
63
|
-
const result = await promise;
|
|
64
|
-
if (!result) throw NULL_CONFIRMATION_RESULT;
|
|
65
|
-
return result;
|
|
66
|
-
})).catch(() => null);
|
|
67
|
-
if (!abortController.signal.aborted) abortController.abort();
|
|
68
|
-
return {
|
|
69
|
-
signatureResult,
|
|
70
|
-
txSignature
|
|
39
|
+
const resend = async (rpc, signal) => {
|
|
40
|
+
await rpc.sendTransaction(signedTxSerialized, rawTransactionOptions).send({ abortSignal: signal });
|
|
41
|
+
};
|
|
42
|
+
const result = await require_confirmation_raceRpcs.raceRpcs(solanaRpcs, (rpc, signal) => require_confirmation_confirmSignature.confirmSignature({
|
|
43
|
+
rpc,
|
|
44
|
+
signal,
|
|
45
|
+
signature: txSignature,
|
|
46
|
+
lifetimes: [lifetime],
|
|
47
|
+
resend,
|
|
48
|
+
onBroadcast: reportBroadcast
|
|
49
|
+
}), { timeoutMs: require_confirmation_createConfirmationDeadline.BRANCH_TIMEOUT_MS });
|
|
50
|
+
if (result.kind === "not-confirmed" && !sendAccepted) return {
|
|
51
|
+
kind: "rpc-unavailable",
|
|
52
|
+
errors: result.errors
|
|
71
53
|
};
|
|
54
|
+
return result;
|
|
72
55
|
}
|
|
73
56
|
//#endregion
|
|
74
57
|
exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendAndConfirmTransaction.js","names":["getSolanaRpcs","getBase64EncodedWireTransaction","getSignatureFromTransaction","
|
|
1
|
+
{"version":3,"file":"sendAndConfirmTransaction.js","names":["getSolanaRpcs","getBase64EncodedWireTransaction","getSignatureFromTransaction","getTransactionLifetime","raceRpcs","confirmSignature","BRANCH_TIMEOUT_MS"],"sources":["../../../src/actions/sendAndConfirmTransaction.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n type Commitment,\n getBase64EncodedWireTransaction,\n getSignatureFromTransaction,\n type Transaction,\n} from '@solana/kit'\nimport { confirmSignature } from '../confirmation/confirmSignature.js'\nimport { BRANCH_TIMEOUT_MS } from '../confirmation/createConfirmationDeadline.js'\nimport { type RaceResult, raceRpcs } from '../confirmation/raceRpcs.js'\nimport type { SignatureStatus } from '../confirmation/types.js'\nimport { getSolanaRpcs } from '../rpc/registry.js'\nimport type { SolanaRpcType } from '../rpc/types.js'\nimport { getTransactionLifetime } from '../utils/getTransactionLifetime.js'\n\n/**\n * Sends a Solana transaction to every configured RPC and returns as soon as\n * one of them confirms it.\n *\n * The polling horizon comes from the signed transaction's own blockhash and a\n * wall-clock ceiling. It deliberately never comes from `getBlockHeight`: at\n * least one endpoint in the default LI.FI set answers that call with the slot\n * number.\n */\nexport async function sendAndConfirmTransaction(\n client: SDKClient,\n signedTransaction: Transaction,\n options?: {\n /** Runs once, when the first RPC accepts a send. */\n onBroadcast?: () => void\n }\n): Promise<RaceResult<SignatureStatus>> {\n const solanaRpcs = await getSolanaRpcs(client)\n\n let broadcastReported = false\n // Distinct from `broadcastReported`, which records whether the integrator\n // callback has *succeeded*. This one answers \"did any RPC accept the send?\",\n // and only that question may steer the verdict below. Set before the callback\n // runs, so a hook that throws on every resend cannot make a real expiry look\n // like an outage.\n let sendAccepted = false\n const reportBroadcast = (): void => {\n sendAccepted = true\n if (broadcastReported) {\n return\n }\n try {\n options?.onBroadcast?.()\n // Latched only after the callback returned. A callback that threw wrote\n // nothing, so the next successful send must be allowed to try again -\n // latching first made one failed `txLink` write permanent.\n broadcastReported = true\n } catch (_) {\n // This runs integrator code: the callback reaches `updateRouteHook` via\n // `StatusManager.updateAction`. Its failure must never reject the branch\n // that called it - the send has already been accepted by the network at\n // this point, so a throw here would report a landed transaction as an\n // RPC outage. Swallowed rather than surfaced because there is no verdict\n // it could honestly change.\n }\n }\n\n const signedTxSerialized = getBase64EncodedWireTransaction(signedTransaction)\n const txSignature = getSignatureFromTransaction(signedTransaction)\n\n const lifetime = await getTransactionLifetime(signedTransaction)\n\n const rawTransactionOptions = {\n // We can skip preflight check after the first transaction has been sent\n // https://solana.com/docs/advanced/retry#the-cost-of-skipping-preflight\n skipPreflight: true,\n // Setting max retries to 0 as we are handling retries manually\n maxRetries: BigInt(0),\n // https://solana.com/docs/advanced/confirmation#use-an-appropriate-preflight-commitment-level\n preflightCommitment: 'confirmed' as Commitment,\n encoding: 'base64' as const,\n }\n\n const resend = async (\n rpc: SolanaRpcType,\n signal: AbortSignal\n ): Promise<void> => {\n await rpc\n .sendTransaction(signedTxSerialized, rawTransactionOptions)\n .send({ abortSignal: signal })\n }\n\n const result = await raceRpcs(\n solanaRpcs,\n (rpc, signal) =>\n confirmSignature({\n rpc,\n signal,\n signature: txSignature,\n lifetimes: [lifetime],\n resend,\n onBroadcast: reportBroadcast,\n }),\n { timeoutMs: BRANCH_TIMEOUT_MS }\n )\n\n // Only this scope knows whether ANY branch accepted the send. A branch that\n // polls to its deadline reports `not-confirmed` regardless - correct per\n // branch, but across the whole race it would claim a transaction expired\n // when nothing ever submitted it. That is an outage, not an expiry.\n //\n // Reads `sendAccepted`, never `broadcastReported`: the latter is false\n // whenever the integrator's callback threw, which says nothing about whether\n // the network took the transaction.\n if (result.kind === 'not-confirmed' && !sendAccepted) {\n return { kind: 'rpc-unavailable', errors: result.errors }\n }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,eAAsB,0BACpB,QACA,mBACA,SAIsC;CACtC,MAAM,aAAa,MAAMA,qBAAAA,cAAc,MAAM;CAE7C,IAAI,oBAAoB;CAMxB,IAAI,eAAe;CACnB,MAAM,wBAA8B;EAClC,eAAe;EACf,IAAI,mBACF;EAEF,IAAI;GACF,SAAS,cAAc;GAIvB,oBAAoB;EACtB,SAAS,GAAG,CAOZ;CACF;CAEA,MAAM,sBAAA,GAAqBC,YAAAA,gCAAAA,CAAgC,iBAAiB;CAC5E,MAAM,eAAA,GAAcC,YAAAA,4BAAAA,CAA4B,iBAAiB;CAEjE,MAAM,WAAW,MAAMC,qCAAAA,uBAAuB,iBAAiB;CAE/D,MAAM,wBAAwB;EAG5B,eAAe;EAEf,YAAY,OAAO,CAAC;EAEpB,qBAAqB;EACrB,UAAU;CACZ;CAEA,MAAM,SAAS,OACb,KACA,WACkB;EAClB,MAAM,IACH,gBAAgB,oBAAoB,qBAAqB,CAAC,CAC1D,KAAK,EAAE,aAAa,OAAO,CAAC;CACjC;CAEA,MAAM,SAAS,MAAMC,8BAAAA,SACnB,aACC,KAAK,WACJC,sCAAAA,iBAAiB;EACf;EACA;EACA,WAAW;EACX,WAAW,CAAC,QAAQ;EACpB;EACA,aAAa;CACf,CAAC,GACH,EAAE,WAAWC,gDAAAA,kBAAkB,CACjC;CAUA,IAAI,OAAO,SAAS,mBAAmB,CAAC,cACtC,OAAO;EAAE,MAAM;EAAmB,QAAQ,OAAO;CAAO;CAG1D,OAAO;AACT"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/confirmation/abortableSleep.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Sleeps for `ms`, or until `signal` aborts - whichever comes first.
|
|
4
|
+
*
|
|
5
|
+
* Not `@lifi/sdk`'s `sleep`: that one is publicly exported, so making its
|
|
6
|
+
* timer abortable or unref'd would change behaviour for every caller in the
|
|
7
|
+
* repo. The confirmation branches need the abort, because both detached loops
|
|
8
|
+
* here sleep between iterations and a plain timer stays alive for the whole
|
|
9
|
+
* interval after the branch has already returned - one live timer per RPC,
|
|
10
|
+
* holding the Node event loop open past the end of a race.
|
|
11
|
+
*
|
|
12
|
+
* Never rejects on abort. The callers re-check `signal.aborted` and exit
|
|
13
|
+
* through their own loop condition, so a rejection here would only add a
|
|
14
|
+
* catch to every call site.
|
|
15
|
+
*/
|
|
16
|
+
declare function abortableSleep(ms: number, signal: AbortSignal): Promise<void>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { abortableSleep };
|
|
19
|
+
//# sourceMappingURL=abortableSleep.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/confirmation/abortableSleep.ts
|
|
3
|
+
/**
|
|
4
|
+
* Sleeps for `ms`, or until `signal` aborts - whichever comes first.
|
|
5
|
+
*
|
|
6
|
+
* Not `@lifi/sdk`'s `sleep`: that one is publicly exported, so making its
|
|
7
|
+
* timer abortable or unref'd would change behaviour for every caller in the
|
|
8
|
+
* repo. The confirmation branches need the abort, because both detached loops
|
|
9
|
+
* here sleep between iterations and a plain timer stays alive for the whole
|
|
10
|
+
* interval after the branch has already returned - one live timer per RPC,
|
|
11
|
+
* holding the Node event loop open past the end of a race.
|
|
12
|
+
*
|
|
13
|
+
* Never rejects on abort. The callers re-check `signal.aborted` and exit
|
|
14
|
+
* through their own loop condition, so a rejection here would only add a
|
|
15
|
+
* catch to every call site.
|
|
16
|
+
*/
|
|
17
|
+
function abortableSleep(ms, signal) {
|
|
18
|
+
if (signal.aborted) return Promise.resolve();
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
const settle = () => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
signal.removeEventListener("abort", settle);
|
|
23
|
+
resolve();
|
|
24
|
+
};
|
|
25
|
+
const timer = setTimeout(settle, ms);
|
|
26
|
+
signal.addEventListener("abort", settle, { once: true });
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.abortableSleep = abortableSleep;
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=abortableSleep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abortableSleep.js","names":[],"sources":["../../../src/confirmation/abortableSleep.ts"],"sourcesContent":["/**\n * Sleeps for `ms`, or until `signal` aborts - whichever comes first.\n *\n * Not `@lifi/sdk`'s `sleep`: that one is publicly exported, so making its\n * timer abortable or unref'd would change behaviour for every caller in the\n * repo. The confirmation branches need the abort, because both detached loops\n * here sleep between iterations and a plain timer stays alive for the whole\n * interval after the branch has already returned - one live timer per RPC,\n * holding the Node event loop open past the end of a race.\n *\n * Never rejects on abort. The callers re-check `signal.aborted` and exit\n * through their own loop condition, so a rejection here would only add a\n * catch to every call site.\n */\nexport function abortableSleep(ms: number, signal: AbortSignal): Promise<void> {\n if (signal.aborted) {\n return Promise.resolve()\n }\n\n return new Promise<void>((resolve) => {\n const settle = (): void => {\n clearTimeout(timer)\n signal.removeEventListener('abort', settle)\n resolve()\n }\n\n const timer = setTimeout(settle, ms)\n signal.addEventListener('abort', settle, { once: true })\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,SAAgB,eAAe,IAAY,QAAoC;CAC7E,IAAI,OAAO,SACT,OAAO,QAAQ,QAAQ;CAGzB,OAAO,IAAI,SAAe,YAAY;EACpC,MAAM,eAAqB;GACzB,aAAa,KAAK;GAClB,OAAO,oBAAoB,SAAS,MAAM;GAC1C,QAAQ;EACV;EAEA,MAAM,QAAQ,WAAW,QAAQ,EAAE;EACnC,OAAO,iBAAiB,SAAS,QAAQ,EAAE,MAAM,KAAK,CAAC;CACzD,CAAC;AACH"}
|