@lifi/sdk-provider-solana 4.3.4 → 4.3.6

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/actions/sendAndConfirmBundle.d.ts +8 -7
  3. package/dist/cjs/actions/sendAndConfirmBundle.js +22 -16
  4. package/dist/cjs/actions/sendAndConfirmBundle.js.map +1 -1
  5. package/dist/cjs/confirmation/confirmBundle.d.ts +18 -19
  6. package/dist/cjs/confirmation/confirmBundle.js +10 -23
  7. package/dist/cjs/confirmation/confirmBundle.js.map +1 -1
  8. package/dist/cjs/confirmation/confirmSignature.d.ts +2 -2
  9. package/dist/cjs/confirmation/confirmSignature.js +2 -2
  10. package/dist/cjs/confirmation/confirmSignature.js.map +1 -1
  11. package/dist/cjs/confirmation/createConfirmationDeadline.d.ts +1 -1
  12. package/dist/cjs/confirmation/createConfirmationDeadline.js.map +1 -1
  13. package/dist/cjs/confirmation/types.d.ts +1 -1
  14. package/dist/cjs/confirmation/types.js.map +1 -1
  15. package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js +9 -18
  16. package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -1
  17. package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js.map +1 -1
  18. package/dist/cjs/rpc/registry.d.ts +4 -3
  19. package/dist/cjs/rpc/registry.js +4 -3
  20. package/dist/cjs/rpc/registry.js.map +1 -1
  21. package/dist/cjs/version.d.ts +1 -1
  22. package/dist/cjs/version.js +1 -1
  23. package/dist/cjs/version.js.map +1 -1
  24. package/dist/esm/actions/sendAndConfirmBundle.d.ts +8 -7
  25. package/dist/esm/actions/sendAndConfirmBundle.d.ts.map +1 -1
  26. package/dist/esm/actions/sendAndConfirmBundle.js +24 -18
  27. package/dist/esm/actions/sendAndConfirmBundle.js.map +1 -1
  28. package/dist/esm/confirmation/confirmBundle.d.ts +18 -19
  29. package/dist/esm/confirmation/confirmBundle.d.ts.map +1 -1
  30. package/dist/esm/confirmation/confirmBundle.js +10 -23
  31. package/dist/esm/confirmation/confirmBundle.js.map +1 -1
  32. package/dist/esm/confirmation/confirmSignature.d.ts +2 -2
  33. package/dist/esm/confirmation/confirmSignature.js +2 -2
  34. package/dist/esm/confirmation/confirmSignature.js.map +1 -1
  35. package/dist/esm/confirmation/createConfirmationDeadline.d.ts +1 -1
  36. package/dist/esm/confirmation/createConfirmationDeadline.js.map +1 -1
  37. package/dist/esm/confirmation/types.d.ts +1 -1
  38. package/dist/esm/confirmation/types.js.map +1 -1
  39. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts.map +1 -1
  40. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js +10 -19
  41. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -1
  42. package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js.map +1 -1
  43. package/dist/esm/rpc/registry.d.ts +4 -3
  44. package/dist/esm/rpc/registry.d.ts.map +1 -1
  45. package/dist/esm/rpc/registry.js +4 -3
  46. package/dist/esm/rpc/registry.js.map +1 -1
  47. package/dist/esm/version.d.ts +1 -1
  48. package/dist/esm/version.js +1 -1
  49. package/dist/esm/version.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/actions/sendAndConfirmBundle.ts +48 -48
  52. package/src/confirmation/confirmBundle.ts +34 -69
  53. package/src/confirmation/confirmSignature.ts +2 -2
  54. package/src/confirmation/createConfirmationDeadline.ts +1 -1
  55. package/src/confirmation/types.ts +1 -1
  56. package/src/core/tasks/SolanaJitoWaitForTransactionTask.ts +13 -27
  57. package/src/core/tasks/SolanaSignAndExecuteTask.ts +5 -6
  58. package/src/rpc/registry.ts +4 -3
  59. package/src/version.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  import type { Signature } from '@solana/kit'
2
- import type { JitoRpcType } from '../rpc/types.js'
2
+ import type { SolanaRpcType } from '../rpc/types.js'
3
3
  import type { TransactionLifetime } from '../utils/getTransactionLifetime.js'
4
4
  import { createConfirmationDeadline } from './createConfirmationDeadline.js'
5
5
  import { pollUntilDeadline } from './pollUntilDeadline.js'
@@ -9,47 +9,46 @@ import {
9
9
  type SignatureStatus,
10
10
  } from './types.js'
11
11
 
12
- /** Slower than the signature poller's 400 ms: Jito documents 1 req/s per IP
13
- * per region. At 2 s this holds 0.5 req/s, leaving room for the deadline's
14
- * blockhash probes on the same endpoint. */
12
+ /** Slower than the signature poller's 400 ms, to spend fewer requests: the
13
+ * bundle is never resent, so a slower read delays only the verdict, by 2 s at
14
+ * most. `STATUS_RETRY_BACKOFF_CAP_MS` is set against this value. */
15
15
  export const BUNDLE_POLL_INTERVAL_MS = 2_000
16
16
 
17
17
  export type BundleConfirmation = {
18
- /** The submission's own id, carried for diagnostics. */
19
- bundleId: string
20
- /** Never read for a `txHash` - its order is Jito's to choose. Kept so the
21
- * reversed-list regression stays expressible in the wait-task spec. */
22
- txSignatures: Signature[]
23
- signatureResults: readonly (SignatureStatus | null)[]
24
- /** Bundle-level `err`, verbatim. Jito encodes it as a Rust `Result`, so a
25
- * landed bundle carries `{ Ok: null }` - never truthiness-check it. */
26
- bundleErr: unknown
18
+ /** One confirmed status per bundle transaction, in bundle order. */
19
+ signatureResults: readonly SignatureStatus[]
27
20
  }
28
21
 
29
22
  /**
30
- * Confirms one Jito bundle against one Jito RPC.
23
+ * Confirms one Jito bundle against one RPC, by the signatures of its
24
+ * transactions. Every Solana RPC can read them, and a bundle lands whole in
25
+ * one slot, so one read shows all of them confirmed.
31
26
  *
32
27
  * Bundles submit once, so there is no resend loop. `send` is owned here so the
33
28
  * deadline starts before submission rather than after it. A `send` failure
34
29
  * throws, which `raceRpcs` buckets as `rpc-unavailable`.
35
30
  */
36
31
  export async function confirmBundle(options: {
37
- rpc: JitoRpcType
32
+ rpc: SolanaRpcType
38
33
  signal: AbortSignal
34
+ /** The signatures of the bundle's transactions, in bundle order. */
35
+ signatures: Signature[]
39
36
  lifetimes: TransactionLifetime[]
40
- send: () => Promise<string>
37
+ /** Its answer is not read: senders answer `sendBundle` in different
38
+ * shapes, and the signatures are known before the send. */
39
+ send: () => Promise<unknown>
41
40
  /**
42
- * Reports that this RPC accepted the bundle submission. Must not throw -
41
+ * Reports that the shared submission was accepted. Must not throw -
43
42
  * `sendAndConfirmBundle` contains any throw from the integrator callback it
44
- * wraps, because a throw here would reject a branch whose bundle Jito had
45
- * already accepted.
43
+ * wraps, because a throw here would reject a branch whose bundle a submit
44
+ * RPC had already accepted.
46
45
  */
47
46
  onBroadcast?: () => void
48
47
  }): Promise<ConfirmationOutcome<BundleConfirmation>> {
49
- const { rpc, signal, lifetimes, send } = options
48
+ const { rpc, signal, signatures, lifetimes, send } = options
50
49
  const deadline = createConfirmationDeadline({ lifetimes, rpc })
51
50
 
52
- const bundleId = await send()
51
+ await send()
53
52
  // Guarded like `confirmSignature`'s send sites: the caller's once-guard
54
53
  // latches only after the callback returns, so a throwing integrator hook
55
54
  // leaves it open and a late `sendBundle` fulfilment would re-write a
@@ -59,55 +58,21 @@ export async function confirmBundle(options: {
59
58
  }
60
59
 
61
60
  const readBundle = async (): Promise<BundleConfirmation | null> => {
62
- const statusResponse = await rpc
63
- .getBundleStatuses([bundleId])
61
+ const response = await rpc
62
+ .getSignatureStatuses(signatures)
64
63
  .send({ abortSignal: signal })
65
- // A `{ value: null }` answer responded but said nothing - poll again
66
- // rather than throw a `TypeError` into the read-failure budget.
67
- const bundleStatus = statusResponse?.value?.[0]
68
- if (
69
- !bundleStatus ||
70
- !isConfirmedCommitment(bundleStatus.confirmation_status)
71
- ) {
72
- return null
73
- }
74
-
75
- // Unvalidated wire data: without this guard a confirmed status carrying
76
- // no `transactions` makes every `.map` below a `TypeError`, and a landed
77
- // bundle would report as `rpc-unavailable`.
78
- // `Array.isArray`, not `??`: the wire data is unvalidated, and a truthy
79
- // non-array keeps the declared array type while throwing out of `.map`.
80
- const txSignatures = Array.isArray(bundleStatus.transactions)
81
- ? bundleStatus.transactions
82
- : []
83
-
84
- // The bundle status is the atomic fact: a bundle lands whole or not at
85
- // all. `getSignatureStatuses` only enriches it with per-transaction `err`
86
- // detail, so an unusable response degrades to all-`null` and must never
87
- // veto a confirmation the status already made.
88
- let signatureResults: BundleConfirmation['signatureResults']
89
- if (txSignatures.length === 0) {
90
- // Nothing to enrich; the status already confirmed the bundle.
91
- signatureResults = []
92
- } else {
93
- try {
94
- const sigResponse = await rpc
95
- .getSignatureStatuses(txSignatures)
96
- .send({ abortSignal: signal })
97
- signatureResults = Array.isArray(sigResponse?.value)
98
- ? sigResponse.value
99
- : txSignatures.map(() => null)
100
- } catch (_) {
101
- signatureResults = txSignatures.map(() => null)
102
- }
103
- }
104
-
105
- return {
106
- bundleId,
107
- txSignatures,
108
- signatureResults,
109
- bundleErr: bundleStatus.err,
110
- }
64
+ // A `{ value: null }`, non-array or short answer responded but said
65
+ // nothing - poll again rather than throw a `TypeError` into the
66
+ // read-failure budget.
67
+ const statuses = response?.value
68
+ return Array.isArray(statuses) &&
69
+ statuses.length === signatures.length &&
70
+ statuses.every(
71
+ (status: SignatureStatus | null): status is SignatureStatus =>
72
+ isConfirmedCommitment(status?.confirmationStatus)
73
+ )
74
+ ? { signatureResults: statuses }
75
+ : null
111
76
  }
112
77
 
113
78
  return pollUntilDeadline({
@@ -14,8 +14,8 @@ import {
14
14
  export const RESEND_INTERVAL_MS = 1000
15
15
  /**
16
16
  * How often this poller re-reads `getSignatureStatuses`. The default Solana
17
- * RPCs tolerate 2.5 req/s of status reads; the Jito bundle poller runs slower
18
- * because its endpoints do not (see `confirmBundle`).
17
+ * RPCs tolerate 2.5 req/s of status reads; the bundle poller runs slower
18
+ * (see `confirmBundle`).
19
19
  */
20
20
  export const SIGNATURE_POLL_INTERVAL_MS = 400
21
21
 
@@ -29,7 +29,7 @@ export const EXPIRY_CONFIRMATIONS: number =
29
29
  * Prober-only; the status pollers have `MAX_STATUS_READ_SILENCE_MS`. */
30
30
  export const MAX_PROBE_ERRORS = 5
31
31
 
32
- /** Structural, so one implementation serves both the Solana and Jito RPC. */
32
+ /** Structural: the deadline needs nothing but `isBlockhashValid`. */
33
33
  export type BlockhashProbeRpc = Pick<SolanaRpcType, 'isBlockhashValid'>
34
34
 
35
35
  export interface ConfirmationDeadline {
@@ -6,7 +6,7 @@ type SignatureStatusesResponse = Awaited<
6
6
  >
7
7
 
8
8
  /** Derived from the RPC type rather than hand-written, which removes every
9
- * `as SignatureStatus` cast. A `JitoRpcType` response assigns without one. */
9
+ * `as SignatureStatus` cast. */
10
10
  export type SignatureStatus = NonNullable<
11
11
  SignatureStatusesResponse['value'][number]
12
12
  >
@@ -20,45 +20,29 @@ import { resumeFromStore } from './resumeFromStore.js'
20
20
  import {
21
21
  canResendStored,
22
22
  clearStoredTransactions,
23
+ failureOf,
23
24
  getTxLink,
24
25
  sendAndSettle,
25
26
  } from './transactionOutcome.js'
26
27
 
27
28
  // The `rpc-unavailable` message is distinct from the empty-list throw inside
28
29
  // `sendAndConfirmBundle`: RPCs were configured and every one of them failed.
29
- // That is an outage, and the collected branch errors say what each endpoint
30
- // did.
30
+ // Every read RPC confirms and waits for the one shared submission, so a
31
+ // refused submission fails every branch with the same error.
31
32
  const MESSAGES: ConfirmationMessages = {
32
- rpcUnavailable: 'Unable to confirm bundle: every configured Jito RPC failed.',
33
+ rpcUnavailable:
34
+ 'Unable to confirm bundle: every configured Solana RPC failed.',
33
35
  notConfirmed: 'Bundle was not confirmed before the SDK stopped waiting.',
34
- allRpcsFailed: 'All Jito RPCs failed',
36
+ allRpcsFailed: 'All Solana RPCs failed',
35
37
  someRpcsFailed:
36
- 'Some Jito RPCs failed while the confirmation window was open',
38
+ 'Some Solana RPCs failed while the confirmation window was open',
37
39
  }
38
40
 
39
- /** Jito encodes `err` as a Rust `Result`: a landed bundle carries
40
- * `{ Ok: null }`, so only an explicit `{ Err: … }` counts as a failure. */
41
- function getBundleFailure(err: unknown): { failure: unknown } | undefined {
42
- if (typeof err !== 'object' || err === null || !('Err' in err)) {
43
- return undefined
44
- }
45
- return { failure: (err as { Err: unknown }).Err }
46
- }
47
-
48
- /** The failure of a landed bundle, if any. A `null` in `signatureResults` is
49
- * indexing lag, never failure. The bundle-level `err` is checked first: it
50
- * survives a failed `getSignatureStatuses` read. */
41
+ /** The failure of a landed bundle, if any: the first transaction `err`. */
51
42
  function bundleFailureOf(
52
43
  confirmation: BundleConfirmation
53
44
  ): { err: unknown } | undefined {
54
- const bundleFailure = getBundleFailure(confirmation.bundleErr)
55
- if (bundleFailure) {
56
- return { err: bundleFailure.failure }
57
- }
58
- const failedResult = confirmation.signatureResults.find(
59
- (signatureResult) => signatureResult?.err
60
- )
61
- return failedResult?.err ? { err: failedResult.err } : undefined
45
+ return confirmation.signatureResults.map(failureOf).find(Boolean)
62
46
  }
63
47
 
64
48
  export class SolanaJitoWaitForTransactionTask extends BaseStepExecutionTask {
@@ -126,8 +110,10 @@ export class SolanaJitoWaitForTransactionTask extends BaseStepExecutionTask {
126
110
 
127
111
  /**
128
112
  * Submits the signed bundle once, confirms it and applies the result rules
129
- * of `sendAndSettle`, on the first run and on a resume alike. A bundle lands
130
- * whole or not at all, so the first transaction's signature stands for it.
113
+ * of `sendAndSettle`, on the first run and on a resume alike. A Jito bundle
114
+ * lands whole or not at all, so the first transaction's signature stands for
115
+ * it. A sender that is not Jito can land the transactions one by one; a
116
+ * lookup by the first signature then misses a partial landing.
131
117
  */
132
118
  function sendSigned(
133
119
  context: SolanaStepExecutorContext,
@@ -115,12 +115,11 @@ export class SolanaSignAndExecuteTask extends BaseStepExecutionTask {
115
115
  // every send failure all sit between this task and the first broadcast.
116
116
  // The wait tasks write both on `onBroadcast`, when an RPC has accepted it.
117
117
  //
118
- // The previous transaction's fields (`CLEARED_TRANSACTION_FIELDS`:
119
- // `txHash`, `txLink`, `txHex`, `txFinal`, `taskId`) are cleared
120
- // explicitly. Only a final failure reaches this task with them set, and a
121
- // stale hash would look open again once its `txFinal` is gone. This write
122
- // runs BEFORE the decode below, which can throw on a malformed wallet
123
- // output and would otherwise strand the old fields.
118
+ // The previous transaction's fields (`CLEARED_TRANSACTION_FIELDS`) are
119
+ // cleared explicitly. Only a final failure reaches this task with them
120
+ // set, and a stale hash would look open again once its `txFinal` is gone.
121
+ // This write runs BEFORE the decode below, which can throw on a malformed
122
+ // wallet output and would otherwise strand the old fields.
124
123
  statusManager.updateAction(step, action.type, 'PENDING', {
125
124
  ...CLEARED_TRANSACTION_FIELDS,
126
125
  signedAt: Date.now(),
@@ -120,9 +120,10 @@ const readProbeFailure = (error: unknown): JitoProbeResult => {
120
120
  const PROBE_TIMEOUT_MS = 5_000
121
121
 
122
122
  /**
123
- * Probes with `getBundleStatuses` rather than `getTipAccounts`: it is the
124
- * method bundle confirmation actually uses, and providers such as Helius
125
- * support it without exposing `getTipAccounts`.
123
+ * Picks the RPCs that may submit a bundle; confirmation reads signatures on
124
+ * every read RPC. Probes with `getBundleStatuses` rather than
125
+ * `getTipAccounts`: providers such as Helius support it without exposing
126
+ * `getTipAccounts`.
126
127
  */
127
128
  export const probeJitoRpc = async (
128
129
  rpcUrl: string
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk-provider-solana'
2
- export const version = '4.3.4'
2
+ export const version = '4.3.6'