@lifi/sdk-provider-solana 4.2.3 → 4.3.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/actions/sendAndConfirmBundle.d.ts +5 -0
  3. package/dist/cjs/actions/sendAndConfirmBundle.js +38 -3
  4. package/dist/cjs/actions/sendAndConfirmBundle.js.map +1 -1
  5. package/dist/cjs/actions/sendAndConfirmTransaction.d.ts +3 -0
  6. package/dist/cjs/actions/sendAndConfirmTransaction.js +56 -10
  7. package/dist/cjs/actions/sendAndConfirmTransaction.js.map +1 -1
  8. package/dist/cjs/confirmation/confirmSignature.d.ts +2 -0
  9. package/dist/cjs/confirmation/confirmSignature.js +2 -0
  10. package/dist/cjs/confirmation/confirmSignature.js.map +1 -1
  11. package/dist/cjs/rpc/registry.d.ts +20 -0
  12. package/dist/cjs/rpc/registry.js +54 -11
  13. package/dist/cjs/rpc/registry.js.map +1 -1
  14. package/dist/cjs/version.d.ts +1 -1
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/cjs/version.js.map +1 -1
  17. package/dist/esm/actions/sendAndConfirmBundle.d.ts +5 -0
  18. package/dist/esm/actions/sendAndConfirmBundle.d.ts.map +1 -1
  19. package/dist/esm/actions/sendAndConfirmBundle.js +40 -5
  20. package/dist/esm/actions/sendAndConfirmBundle.js.map +1 -1
  21. package/dist/esm/actions/sendAndConfirmTransaction.d.ts +3 -0
  22. package/dist/esm/actions/sendAndConfirmTransaction.d.ts.map +1 -1
  23. package/dist/esm/actions/sendAndConfirmTransaction.js +58 -12
  24. package/dist/esm/actions/sendAndConfirmTransaction.js.map +1 -1
  25. package/dist/esm/confirmation/confirmSignature.d.ts +2 -0
  26. package/dist/esm/confirmation/confirmSignature.d.ts.map +1 -1
  27. package/dist/esm/confirmation/confirmSignature.js +2 -1
  28. package/dist/esm/confirmation/confirmSignature.js.map +1 -1
  29. package/dist/esm/rpc/registry.d.ts +20 -0
  30. package/dist/esm/rpc/registry.d.ts.map +1 -1
  31. package/dist/esm/rpc/registry.js +53 -12
  32. package/dist/esm/rpc/registry.js.map +1 -1
  33. package/dist/esm/version.d.ts +1 -1
  34. package/dist/esm/version.js +1 -1
  35. package/dist/esm/version.js.map +1 -1
  36. package/package.json +2 -2
  37. package/src/actions/sendAndConfirmBundle.ts +85 -5
  38. package/src/actions/sendAndConfirmTransaction.ts +108 -18
  39. package/src/confirmation/confirmSignature.ts +2 -1
  40. package/src/rpc/registry.ts +66 -21
  41. package/src/version.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { LiFiErrorCode, RPCError, type SDKClient } from '@lifi/sdk'
1
+ import { ChainId, LiFiErrorCode, RPCError, type SDKClient } from '@lifi/sdk'
2
2
  import { getBase64EncodedWireTransaction, type Transaction } from '@solana/kit'
3
3
  import {
4
4
  type BundleConfirmation,
@@ -6,7 +6,8 @@ import {
6
6
  } from '../confirmation/confirmBundle.js'
7
7
  import { BRANCH_TIMEOUT_MS } from '../confirmation/createConfirmationDeadline.js'
8
8
  import { type RaceResult, raceRpcs } from '../confirmation/raceRpcs.js'
9
- import { getJitoRpcs } from '../rpc/registry.js'
9
+ import { getJitoCapableRpcs, getJitoRpcs } from '../rpc/registry.js'
10
+ import type { JitoRpcType } from '../rpc/types.js'
10
11
  import { getTransactionLifetime } from '../utils/getTransactionLifetime.js'
11
12
 
12
13
  /**
@@ -20,6 +21,11 @@ import { getTransactionLifetime } from '../utils/getTransactionLifetime.js'
20
21
  * `sendBundle` is handed to `confirmBundle` rather than awaited here, so the
21
22
  * deadline starts on the same clock as `BRANCH_TIMEOUT_MS` instead of after
22
23
  * the submission returns.
24
+ *
25
+ * When the client has Solana bundle or write RPCs (`rpcUrls[ChainId.SOL]`),
26
+ * the bundle is submitted once through those that pass the Jito probe - the
27
+ * bundle list first, else the write list - and the read Jito RPCs only poll.
28
+ * With either list set, bundles never go to the read RPCs.
23
29
  */
24
30
  export async function sendAndConfirmBundle(
25
31
  client: SDKClient,
@@ -29,7 +35,58 @@ export async function sendAndConfirmBundle(
29
35
  onBroadcast?: () => void
30
36
  }
31
37
  ): Promise<RaceResult<BundleConfirmation>> {
32
- const { rpcs: jitoRpcs, unreachable } = await getJitoRpcs(client)
38
+ // With a bundle or write list set, bundles go only to those: the bundle
39
+ // RPCs that pass the Jito probe, else the write RPCs that do. The write list
40
+ // is probed only when it is needed. With neither list, each branch submits
41
+ // through its own read Jito RPC, as before.
42
+ const [bundleUrls = [], writeUrls = []] = await Promise.all([
43
+ client.getBundleRpcUrlsByChainId?.(ChainId.SOL),
44
+ client.getWriteRpcUrlsByChainId?.(ChainId.SOL),
45
+ ])
46
+ const noSubmitRpcs = { rpcs: [] as JitoRpcType[], unreachable: 0 }
47
+ const findSubmitRpcs = async (): Promise<typeof noSubmitRpcs> => {
48
+ const bundle = bundleUrls.length
49
+ ? await getJitoCapableRpcs(bundleUrls)
50
+ : noSubmitRpcs
51
+ if (bundle.rpcs.length || !writeUrls.length) {
52
+ return bundle
53
+ }
54
+ const write = await getJitoCapableRpcs(writeUrls)
55
+ return {
56
+ rpcs: write.rpcs,
57
+ unreachable: bundle.unreachable + write.unreachable,
58
+ }
59
+ }
60
+ const [
61
+ { rpcs: jitoRpcs, unreachable },
62
+ { rpcs: submitRpcs, unreachable: submitUnreachable },
63
+ ] = await Promise.all([getJitoRpcs(client), findSubmitRpcs()])
64
+
65
+ if ((bundleUrls.length || writeUrls.length) && !submitRpcs.length) {
66
+ const lists = [
67
+ bundleUrls.length && '`rpcUrls[ChainId.SOL].bundle`',
68
+ writeUrls.length && '`rpcUrls[ChainId.SOL].write`',
69
+ ]
70
+ .filter(Boolean)
71
+ .join(' or ')
72
+ throw new RPCError(
73
+ LiFiErrorCode.RpcUnavailable,
74
+ [
75
+ `Jito bundle required, but no URL in ${lists} passed the Jito capability probe.`,
76
+ submitUnreachable > 0
77
+ ? 'The probe got no answer from some of them. This is usually temporary - retry. If it persists, the endpoint may refuse `sendBundle` for your plan.'
78
+ : 'They do not support `sendBundle`: add a Jito-capable URL to `rpcUrls[ChainId.SOL].bundle`.',
79
+ 'Bundles never go to the read RPCs while `bundle` or `write` is set.',
80
+ // Only a definite gap: a read RPC that did not answer the probe may
81
+ // support bundles, and the next attempt reports that case itself.
82
+ jitoRpcs.length === 0 &&
83
+ unreachable === 0 &&
84
+ 'No read RPC supports `getBundleStatuses` to confirm a bundle either: also add a Jito-capable URL to `rpcUrls[ChainId.SOL].read`.',
85
+ ]
86
+ .filter(Boolean)
87
+ .join(' ')
88
+ )
89
+ }
33
90
 
34
91
  // Named here, where the emptiness is known: racing zero RPCs would surface
35
92
  // as a bare `rpc-unavailable`, indistinguishable from a total outage. The
@@ -46,7 +103,9 @@ export async function sendAndConfirmBundle(
46
103
  LiFiErrorCode.RpcUnavailable,
47
104
  unreachable > 0
48
105
  ? `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.`
49
- : 'Jito bundle required, but no configured Solana RPC supports `sendBundle`. Supply a Jito-capable URL via the `rpcUrls` client config option.'
106
+ : submitRpcs.length > 0
107
+ ? 'Jito bundle required. A bundle or write RPC can submit it, but no read RPC supports `getBundleStatuses` to confirm it. Add a Jito-capable URL to `rpcUrls[ChainId.SOL].read`.'
108
+ : 'Jito bundle required, but no configured Solana RPC supports `sendBundle`. Supply a Jito-capable URL via the `rpcUrls` client config option.'
50
109
  )
51
110
  }
52
111
 
@@ -83,6 +142,23 @@ export async function sendAndConfirmBundle(
83
142
  signedTransactions.map((transaction) => getTransactionLifetime(transaction))
84
143
  )
85
144
 
145
+ // One submission for every polling branch: the bundle id is derived from
146
+ // the transactions, so each branch polls the same bundle. Started by the
147
+ // first branch that asks, so its deadline already runs.
148
+ let submission: Promise<string> | undefined
149
+ const submitOnce = (signal: AbortSignal): Promise<string> => {
150
+ submission ??= Promise.any(
151
+ submitRpcs.map((rpc) =>
152
+ rpc.sendBundle(serializedTransactions).send({ abortSignal: signal })
153
+ )
154
+ ).catch((error: unknown) => {
155
+ // Surface a refusal the way a single configured RPC would, not as a
156
+ // nested AggregateError inside the race's own error list.
157
+ throw error instanceof AggregateError ? error.errors[0] : error
158
+ })
159
+ return submission
160
+ }
161
+
86
162
  return raceRpcs(
87
163
  jitoRpcs,
88
164
  (rpc, signal) =>
@@ -91,7 +167,11 @@ export async function sendAndConfirmBundle(
91
167
  signal,
92
168
  lifetimes,
93
169
  send: () =>
94
- rpc.sendBundle(serializedTransactions).send({ abortSignal: signal }),
170
+ submitRpcs.length
171
+ ? submitOnce(signal)
172
+ : rpc
173
+ .sendBundle(serializedTransactions)
174
+ .send({ abortSignal: signal }),
95
175
  onBroadcast: reportBroadcast,
96
176
  }),
97
177
  { timeoutMs: BRANCH_TIMEOUT_MS }
@@ -1,15 +1,18 @@
1
- import type { SDKClient } from '@lifi/sdk'
1
+ import { ChainId, type SDKClient } from '@lifi/sdk'
2
2
  import {
3
3
  type Commitment,
4
4
  getBase64EncodedWireTransaction,
5
5
  getSignatureFromTransaction,
6
6
  type Transaction,
7
7
  } from '@solana/kit'
8
- import { confirmSignature } from '../confirmation/confirmSignature.js'
8
+ import {
9
+ confirmSignature,
10
+ RESEND_INTERVAL_MS,
11
+ } from '../confirmation/confirmSignature.js'
9
12
  import { BRANCH_TIMEOUT_MS } from '../confirmation/createConfirmationDeadline.js'
10
13
  import { type RaceResult, raceRpcs } from '../confirmation/raceRpcs.js'
11
14
  import type { SignatureStatus } from '../confirmation/types.js'
12
- import { getSolanaRpcs } from '../rpc/registry.js'
15
+ import { getSolanaRpcs, getSolanaWriteRpcs } from '../rpc/registry.js'
13
16
  import type { SolanaRpcType } from '../rpc/types.js'
14
17
  import { getTransactionLifetime } from '../utils/getTransactionLifetime.js'
15
18
 
@@ -17,6 +20,9 @@ import { getTransactionLifetime } from '../utils/getTransactionLifetime.js'
17
20
  * Sends a Solana transaction to every configured RPC and returns as soon as
18
21
  * one of them confirms it.
19
22
  *
23
+ * When the client has Solana write RPCs (`rpcUrls[ChainId.SOL].write`), the
24
+ * transaction is sent only through those, and the read RPCs only confirm it.
25
+ *
20
26
  * The polling horizon comes from the signed transaction's own blockhash and a
21
27
  * wall-clock ceiling. It deliberately never comes from `getBlockHeight`: at
22
28
  * least one endpoint in the default LI.FI set answers that call with the slot
@@ -30,7 +36,10 @@ export async function sendAndConfirmTransaction(
30
36
  onBroadcast?: () => void
31
37
  }
32
38
  ): Promise<RaceResult<SignatureStatus>> {
33
- const solanaRpcs = await getSolanaRpcs(client)
39
+ const [solanaRpcs, writeRpcUrls = []] = await Promise.all([
40
+ getSolanaRpcs(client),
41
+ client.getWriteRpcUrlsByChainId?.(ChainId.SOL),
42
+ ])
34
43
 
35
44
  let broadcastReported = false
36
45
  // Distinct from `broadcastReported`, which records whether the integrator
@@ -76,7 +85,7 @@ export async function sendAndConfirmTransaction(
76
85
  encoding: 'base64' as const,
77
86
  }
78
87
 
79
- const resend = async (
88
+ const send = async (
80
89
  rpc: SolanaRpcType,
81
90
  signal: AbortSignal
82
91
  ): Promise<void> => {
@@ -85,19 +94,100 @@ export async function sendAndConfirmTransaction(
85
94
  .send({ abortSignal: signal })
86
95
  }
87
96
 
88
- const result = await raceRpcs(
89
- solanaRpcs,
90
- (rpc, signal) =>
91
- confirmSignature({
92
- rpc,
93
- signal,
94
- signature: txSignature,
95
- lifetimes: [lifetime],
96
- resend,
97
- onBroadcast: reportBroadcast,
98
- }),
99
- { timeoutMs: BRANCH_TIMEOUT_MS }
100
- )
97
+ const writeRpcs = writeRpcUrls.length
98
+ ? getSolanaWriteRpcs(writeRpcUrls)
99
+ : undefined
100
+
101
+ // Sends to the write RPCs belong to the whole call, not to one branch:
102
+ // other branches wait on the same send, so the branch that started it must
103
+ // not cancel it by ending. They end when the race does.
104
+ const writes = new AbortController()
105
+
106
+ // Every confirmation branch resends about once a second. Branches share one
107
+ // send to the write RPCs per interval, so each write RPC sees the same rate
108
+ // it would as a configured RPC, however many configured RPCs are polling.
109
+ let lastWrite: { at: number; sent: Promise<void> } | undefined
110
+ // A write RPC that has not answered its last send gets no new one, so a
111
+ // hung endpoint holds one open request, not one per interval.
112
+ const openSends = new Set<SolanaRpcType>()
113
+ const sendToWriteRpc = async (rpc: SolanaRpcType): Promise<void> => {
114
+ openSends.add(rpc)
115
+ try {
116
+ await send(rpc, writes.signal)
117
+ } finally {
118
+ openSends.delete(rpc)
119
+ }
120
+ }
121
+ const sendToWriteRpcs = (rpcs: SolanaRpcType[]): Promise<void> => {
122
+ const now = Date.now()
123
+ if (lastWrite && now - lastWrite.at < RESEND_INTERVAL_MS) {
124
+ return lastWrite.sent
125
+ }
126
+ // With every write RPC busy this rejects at once, and the branch polls.
127
+ const ready = rpcs.filter((rpc) => !openSends.has(rpc))
128
+ // Accepted as soon as one write RPC accepts it.
129
+ const sent = Promise.any(ready.map(sendToWriteRpc)).then(() => undefined)
130
+ // Recorded here, not only by the branches: a branch stops waiting after
131
+ // one interval (below), and an acceptance after that must still count.
132
+ // Skipped once the race is over, so a late acceptance cannot regress an
133
+ // action status the wait task already finalized.
134
+ sent.then(
135
+ () => {
136
+ if (!writes.signal.aborted) {
137
+ reportBroadcast()
138
+ }
139
+ },
140
+ () => {}
141
+ )
142
+ lastWrite = { at: now, sent }
143
+ return sent
144
+ }
145
+
146
+ // `confirmSignature` awaits its first send before it starts polling. Every
147
+ // branch waits on the same shared send, so a write RPC that hangs would hold
148
+ // up polling on all of them - even for a transaction that already landed.
149
+ // A branch waits at most one resend interval, then polls either way.
150
+ const waitForWrite = (sent: Promise<void>): Promise<void> =>
151
+ new Promise((resolve, reject) => {
152
+ const timer = setTimeout(
153
+ () =>
154
+ reject(new Error('No write RPC accepted the transaction in time.')),
155
+ RESEND_INTERVAL_MS
156
+ )
157
+ sent.then(
158
+ () => {
159
+ clearTimeout(timer)
160
+ resolve()
161
+ },
162
+ (error: unknown) => {
163
+ clearTimeout(timer)
164
+ reject(error)
165
+ }
166
+ )
167
+ })
168
+
169
+ const resend = writeRpcs
170
+ ? (): Promise<void> => waitForWrite(sendToWriteRpcs(writeRpcs))
171
+ : send
172
+
173
+ let result: RaceResult<SignatureStatus>
174
+ try {
175
+ result = await raceRpcs(
176
+ solanaRpcs,
177
+ (rpc, signal) =>
178
+ confirmSignature({
179
+ rpc,
180
+ signal,
181
+ signature: txSignature,
182
+ lifetimes: [lifetime],
183
+ resend,
184
+ onBroadcast: reportBroadcast,
185
+ }),
186
+ { timeoutMs: BRANCH_TIMEOUT_MS }
187
+ )
188
+ } finally {
189
+ writes.abort()
190
+ }
101
191
 
102
192
  // Only this scope knows whether ANY branch accepted the send. A branch that
103
193
  // polls to its deadline reports `not-confirmed` regardless - correct per
@@ -10,7 +10,8 @@ import {
10
10
  type SignatureStatus,
11
11
  } from './types.js'
12
12
 
13
- const RESEND_INTERVAL_MS = 1000
13
+ /** How often each confirmation branch resends the transaction. */
14
+ export const RESEND_INTERVAL_MS = 1000
14
15
  /**
15
16
  * How often this poller re-reads `getSignatureStatuses`. The default Solana
16
17
  * RPCs tolerate 2.5 req/s of status reads; the Jito bundle poller runs slower
@@ -3,8 +3,10 @@ import { createSolanaRpc } from '@solana/kit'
3
3
  import { createJitoRpc } from './jito/createJitoRpc.js'
4
4
  import type { JitoRpcType, SolanaRpcType } from './types.js'
5
5
 
6
- const solanaRpcs = new LruMap<SolanaRpcType>(12)
7
- const jitoRpcs = new LruMap<JitoRpcType>(12)
6
+ // Read, write and bundle URLs share these caches, so they hold more than one
7
+ // list's worth: an entry evicted mid-use is probed or built again.
8
+ const solanaRpcs = new LruMap<SolanaRpcType>(64)
9
+ const jitoRpcs = new LruMap<JitoRpcType>(64)
8
10
 
9
11
  /**
10
12
  * A well-formed but non-existent Jito bundle id used solely to probe RPC
@@ -52,7 +54,7 @@ type JitoProbeRecord = JitoProbeResult & { at: number }
52
54
  * set never shrinks, and every bundle submission re-probes every non-Jito
53
55
  * endpoint at up to `PROBE_TIMEOUT_MS` each, on the latency path before
54
56
  * submission can start. */
55
- const jitoProbes = new LruMap<JitoProbeRecord>(12)
57
+ const jitoProbes = new LruMap<JitoProbeRecord>(64)
56
58
 
57
59
  /** One rule for every outcome: a record is fresh until its own window closes.
58
60
  * `Infinity` covers the answers that cannot change. */
@@ -146,27 +148,36 @@ export const probeJitoRpc = async (
146
148
  */
147
149
  const ensureSolanaRpcs = async (client: SDKClient): Promise<string[]> => {
148
150
  const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SOL)
151
+ ensureSolanaRpcsFor(rpcUrls)
152
+ return rpcUrls
153
+ }
154
+
155
+ /** Creates and caches a client for each URL that has none yet. */
156
+ const ensureSolanaRpcsFor = (rpcUrls: string[]): void => {
149
157
  for (const rpcUrl of rpcUrls) {
150
158
  if (!solanaRpcs.has(rpcUrl)) {
151
159
  solanaRpcs.set(rpcUrl, createSolanaRpc(rpcUrl))
152
160
  }
153
161
  }
154
- return rpcUrls
155
162
  }
156
163
 
164
+ const cachedSolanaRpcs = (rpcUrls: string[]): SolanaRpcType[] =>
165
+ rpcUrls
166
+ .map((rpcUrl) => solanaRpcs.get(rpcUrl))
167
+ .filter((rpc): rpc is SolanaRpcType => Boolean(rpc))
168
+
157
169
  /**
158
- * Initializes and caches Jito RPCs for every configured Solana RPC URL.
170
+ * Probes each URL for Jito support and caches a client for every supported
171
+ * one. The configured RPCs and the write RPCs share this cache.
159
172
  *
160
173
  * Every probe outcome is cached, so a non-Jito endpoint is probed once rather
161
174
  * than once per bundle submission. Each record carries its own retry window:
162
175
  * see `JITO_PROBE_RETRY_MS` and `JITO_PROBE_GATEWAY_RETRY_MS` for the two that
163
176
  * expire.
164
- * @param client - The SDK client used to fetch RPC URLs.
177
+ * @param rpcUrls - The URLs to probe.
178
+ * @returns - How many of the URLs are currently unreachable.
165
179
  */
166
- const ensureJitoRpcs = async (
167
- client: SDKClient
168
- ): Promise<{ rpcUrls: string[]; unreachable: number }> => {
169
- const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SOL)
180
+ const ensureJitoRpcsFor = async (rpcUrls: string[]): Promise<number> => {
170
181
  // Probed in parallel: serially, one slow endpoint delayed every URL behind
171
182
  // it before submission could start.
172
183
  const unprobed = rpcUrls.filter(
@@ -210,13 +221,28 @@ const ensureJitoRpcs = async (
210
221
  // `unreachable` still has to reach `sendAndConfirmBundle`, which uses the
211
222
  // count to choose between "retry, likely temporary" and "supply a
212
223
  // Jito-capable URL".
213
- const unreachable = rpcUrls.filter(
224
+ return rpcUrls.filter(
214
225
  (rpcUrl) => jitoProbes.get(rpcUrl)?.outcome === 'unreachable'
215
226
  ).length
227
+ }
216
228
 
229
+ /**
230
+ * Initializes and caches Jito RPCs for every configured Solana RPC URL.
231
+ * @param client - The SDK client used to fetch RPC URLs.
232
+ */
233
+ const ensureJitoRpcs = async (
234
+ client: SDKClient
235
+ ): Promise<{ rpcUrls: string[]; unreachable: number }> => {
236
+ const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SOL)
237
+ const unreachable = await ensureJitoRpcsFor(rpcUrls)
217
238
  return { rpcUrls, unreachable }
218
239
  }
219
240
 
241
+ const cachedJitoRpcs = (rpcUrls: string[]): JitoRpcType[] =>
242
+ rpcUrls
243
+ .map((rpcUrl) => jitoRpcs.get(rpcUrl))
244
+ .filter((rpc): rpc is JitoRpcType => Boolean(rpc))
245
+
220
246
  /**
221
247
  * Wrapper around getting the Solana RPCs
222
248
  * @returns - Solana RPCs
@@ -224,10 +250,19 @@ const ensureJitoRpcs = async (
224
250
  export const getSolanaRpcs = async (
225
251
  client: SDKClient
226
252
  ): Promise<SolanaRpcType[]> => {
227
- const rpcUrls = await ensureSolanaRpcs(client)
228
- return rpcUrls
229
- .map((rpcUrl) => solanaRpcs.get(rpcUrl))
230
- .filter((rpc): rpc is SolanaRpcType => Boolean(rpc))
253
+ return cachedSolanaRpcs(await ensureSolanaRpcs(client))
254
+ }
255
+
256
+ /**
257
+ * Clients for the write RPCs (`rpcUrls[ChainId.SOL].write`). They only
258
+ * send transactions; the one read they get is the Jito probe in
259
+ * `getJitoCapableRpcs`.
260
+ * @param rpcUrls - The write RPC URLs.
261
+ * @returns - Solana RPCs to send transactions through.
262
+ */
263
+ export const getSolanaWriteRpcs = (rpcUrls: string[]): SolanaRpcType[] => {
264
+ ensureSolanaRpcsFor(rpcUrls)
265
+ return cachedSolanaRpcs(rpcUrls)
231
266
  }
232
267
 
233
268
  /** `unreachable` counts endpoints whose probe failed without naming the
@@ -239,10 +274,20 @@ export const getJitoRpcs = async (
239
274
  client: SDKClient
240
275
  ): Promise<{ rpcs: JitoRpcType[]; unreachable: number }> => {
241
276
  const { rpcUrls, unreachable } = await ensureJitoRpcs(client)
242
- return {
243
- rpcs: rpcUrls
244
- .map((rpcUrl) => jitoRpcs.get(rpcUrl))
245
- .filter((rpc): rpc is JitoRpcType => Boolean(rpc)),
246
- unreachable,
247
- }
277
+ return { rpcs: cachedJitoRpcs(rpcUrls), unreachable }
278
+ }
279
+
280
+ /**
281
+ * The given URLs that pass the Jito probe - the bundle or write RPCs of
282
+ * `rpcUrls[ChainId.SOL]`. They share the probe cache with the read RPCs.
283
+ * `unreachable` counts the URLs whose probe failed without an answer, as in
284
+ * `getJitoRpcs`.
285
+ * @param rpcUrls - The URLs to probe.
286
+ * @returns - Jito RPCs to submit bundles through, and the unreachable count.
287
+ */
288
+ export const getJitoCapableRpcs = async (
289
+ rpcUrls: string[]
290
+ ): Promise<{ rpcs: JitoRpcType[]; unreachable: number }> => {
291
+ const unreachable = await ensureJitoRpcsFor(rpcUrls)
292
+ return { rpcs: cachedJitoRpcs(rpcUrls), unreachable }
248
293
  }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk-provider-solana'
2
- export const version = '4.2.3'
2
+ export const version = '4.3.0'