@lifi/sdk-provider-solana 4.0.6 → 4.1.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 (145) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/dist/cjs/actions/sendAndConfirmBundle.d.ts +18 -25
  3. package/dist/cjs/actions/sendAndConfirmBundle.js +33 -54
  4. package/dist/cjs/actions/sendAndConfirmBundle.js.map +1 -1
  5. package/dist/cjs/actions/sendAndConfirmTransaction.d.ts +14 -22
  6. package/dist/cjs/actions/sendAndConfirmTransaction.js +38 -55
  7. package/dist/cjs/actions/sendAndConfirmTransaction.js.map +1 -1
  8. package/dist/cjs/confirmation/abortableSleep.d.ts +19 -0
  9. package/dist/cjs/confirmation/abortableSleep.js +32 -0
  10. package/dist/cjs/confirmation/abortableSleep.js.map +1 -0
  11. package/dist/cjs/confirmation/confirmBundle.d.ts +43 -0
  12. package/dist/cjs/confirmation/confirmBundle.js +57 -0
  13. package/dist/cjs/confirmation/confirmBundle.js.map +1 -0
  14. package/dist/cjs/confirmation/confirmSignature.d.ts +29 -0
  15. package/dist/cjs/confirmation/confirmSignature.js +66 -0
  16. package/dist/cjs/confirmation/confirmSignature.js.map +1 -0
  17. package/dist/cjs/confirmation/createConfirmationDeadline.d.ts +51 -0
  18. package/dist/cjs/confirmation/createConfirmationDeadline.js +101 -0
  19. package/dist/cjs/confirmation/createConfirmationDeadline.js.map +1 -0
  20. package/dist/cjs/confirmation/pollUntilDeadline.d.ts +58 -0
  21. package/dist/cjs/confirmation/pollUntilDeadline.js +97 -0
  22. package/dist/cjs/confirmation/pollUntilDeadline.js.map +1 -0
  23. package/dist/cjs/confirmation/raceRpcs.d.ts +26 -0
  24. package/dist/cjs/confirmation/raceRpcs.js +93 -0
  25. package/dist/cjs/confirmation/raceRpcs.js.map +1 -0
  26. package/dist/cjs/confirmation/types.d.ts +18 -0
  27. package/dist/cjs/confirmation/types.js +9 -0
  28. package/dist/cjs/confirmation/types.js.map +1 -0
  29. package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js +30 -9
  30. package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -1
  31. package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js +5 -1
  32. package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js.map +1 -1
  33. package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js +20 -7
  34. package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -1
  35. package/dist/cjs/core/tasks/readSignature.d.ts +17 -0
  36. package/dist/cjs/core/tasks/readSignature.js +26 -0
  37. package/dist/cjs/core/tasks/readSignature.js.map +1 -0
  38. package/dist/cjs/core/tasks/unwrapConfirmation.d.ts +25 -0
  39. package/dist/cjs/core/tasks/unwrapConfirmation.js +24 -0
  40. package/dist/cjs/core/tasks/unwrapConfirmation.js.map +1 -0
  41. package/dist/cjs/rpc/jito/api/getBundleStatuses.d.ts +4 -2
  42. package/dist/cjs/rpc/registry.d.ts +37 -11
  43. package/dist/cjs/rpc/registry.js +103 -18
  44. package/dist/cjs/rpc/registry.js.map +1 -1
  45. package/dist/cjs/rpc/utils.js +1 -1
  46. package/dist/cjs/rpc/utils.js.map +1 -1
  47. package/dist/cjs/utils/KeypairWalletAdapter.js +10 -4
  48. package/dist/cjs/utils/KeypairWalletAdapter.js.map +1 -1
  49. package/dist/cjs/utils/getTransactionLifetime.d.ts +21 -0
  50. package/dist/cjs/utils/getTransactionLifetime.js +28 -0
  51. package/dist/cjs/utils/getTransactionLifetime.js.map +1 -0
  52. package/dist/cjs/version.d.ts +1 -1
  53. package/dist/cjs/version.js +1 -1
  54. package/dist/cjs/version.js.map +1 -1
  55. package/dist/esm/actions/sendAndConfirmBundle.d.ts +18 -25
  56. package/dist/esm/actions/sendAndConfirmBundle.d.ts.map +1 -1
  57. package/dist/esm/actions/sendAndConfirmBundle.js +34 -55
  58. package/dist/esm/actions/sendAndConfirmBundle.js.map +1 -1
  59. package/dist/esm/actions/sendAndConfirmTransaction.d.ts +14 -22
  60. package/dist/esm/actions/sendAndConfirmTransaction.d.ts.map +1 -1
  61. package/dist/esm/actions/sendAndConfirmTransaction.js +38 -55
  62. package/dist/esm/actions/sendAndConfirmTransaction.js.map +1 -1
  63. package/dist/esm/confirmation/abortableSleep.d.ts +19 -0
  64. package/dist/esm/confirmation/abortableSleep.d.ts.map +1 -0
  65. package/dist/esm/confirmation/abortableSleep.js +31 -0
  66. package/dist/esm/confirmation/abortableSleep.js.map +1 -0
  67. package/dist/esm/confirmation/confirmBundle.d.ts +43 -0
  68. package/dist/esm/confirmation/confirmBundle.d.ts.map +1 -0
  69. package/dist/esm/confirmation/confirmBundle.js +55 -0
  70. package/dist/esm/confirmation/confirmBundle.js.map +1 -0
  71. package/dist/esm/confirmation/confirmSignature.d.ts +29 -0
  72. package/dist/esm/confirmation/confirmSignature.d.ts.map +1 -0
  73. package/dist/esm/confirmation/confirmSignature.js +64 -0
  74. package/dist/esm/confirmation/confirmSignature.js.map +1 -0
  75. package/dist/esm/confirmation/createConfirmationDeadline.d.ts +51 -0
  76. package/dist/esm/confirmation/createConfirmationDeadline.d.ts.map +1 -0
  77. package/dist/esm/confirmation/createConfirmationDeadline.js +93 -0
  78. package/dist/esm/confirmation/createConfirmationDeadline.js.map +1 -0
  79. package/dist/esm/confirmation/pollUntilDeadline.d.ts +58 -0
  80. package/dist/esm/confirmation/pollUntilDeadline.d.ts.map +1 -0
  81. package/dist/esm/confirmation/pollUntilDeadline.js +93 -0
  82. package/dist/esm/confirmation/pollUntilDeadline.js.map +1 -0
  83. package/dist/esm/confirmation/raceRpcs.d.ts +26 -0
  84. package/dist/esm/confirmation/raceRpcs.d.ts.map +1 -0
  85. package/dist/esm/confirmation/raceRpcs.js +92 -0
  86. package/dist/esm/confirmation/raceRpcs.js.map +1 -0
  87. package/dist/esm/confirmation/types.d.ts +18 -0
  88. package/dist/esm/confirmation/types.d.ts.map +1 -0
  89. package/dist/esm/confirmation/types.js +8 -0
  90. package/dist/esm/confirmation/types.js.map +1 -0
  91. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts.map +1 -1
  92. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js +30 -9
  93. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -1
  94. package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js +5 -1
  95. package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js.map +1 -1
  96. package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.d.ts.map +1 -1
  97. package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js +20 -7
  98. package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -1
  99. package/dist/esm/core/tasks/readSignature.d.ts +17 -0
  100. package/dist/esm/core/tasks/readSignature.d.ts.map +1 -0
  101. package/dist/esm/core/tasks/readSignature.js +25 -0
  102. package/dist/esm/core/tasks/readSignature.js.map +1 -0
  103. package/dist/esm/core/tasks/unwrapConfirmation.d.ts +25 -0
  104. package/dist/esm/core/tasks/unwrapConfirmation.d.ts.map +1 -0
  105. package/dist/esm/core/tasks/unwrapConfirmation.js +23 -0
  106. package/dist/esm/core/tasks/unwrapConfirmation.js.map +1 -0
  107. package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts +4 -2
  108. package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts.map +1 -1
  109. package/dist/esm/rpc/registry.d.ts +37 -11
  110. package/dist/esm/rpc/registry.d.ts.map +1 -1
  111. package/dist/esm/rpc/registry.js +102 -19
  112. package/dist/esm/rpc/registry.js.map +1 -1
  113. package/dist/esm/rpc/utils.js +1 -1
  114. package/dist/esm/rpc/utils.js.map +1 -1
  115. package/dist/esm/utils/KeypairWalletAdapter.d.ts.map +1 -1
  116. package/dist/esm/utils/KeypairWalletAdapter.js +11 -5
  117. package/dist/esm/utils/KeypairWalletAdapter.js.map +1 -1
  118. package/dist/esm/utils/getTransactionLifetime.d.ts +21 -0
  119. package/dist/esm/utils/getTransactionLifetime.d.ts.map +1 -0
  120. package/dist/esm/utils/getTransactionLifetime.js +27 -0
  121. package/dist/esm/utils/getTransactionLifetime.js.map +1 -0
  122. package/dist/esm/version.d.ts +1 -1
  123. package/dist/esm/version.js +1 -1
  124. package/dist/esm/version.js.map +1 -1
  125. package/package.json +4 -4
  126. package/src/actions/sendAndConfirmBundle.ts +82 -142
  127. package/src/actions/sendAndConfirmTransaction.ts +82 -134
  128. package/src/confirmation/abortableSleep.ts +30 -0
  129. package/src/confirmation/confirmBundle.ts +121 -0
  130. package/src/confirmation/confirmSignature.ts +113 -0
  131. package/src/confirmation/createConfirmationDeadline.ts +174 -0
  132. package/src/confirmation/pollUntilDeadline.ts +182 -0
  133. package/src/confirmation/raceRpcs.ts +135 -0
  134. package/src/confirmation/types.ts +23 -0
  135. package/src/core/tasks/SolanaJitoWaitForTransactionTask.ts +49 -16
  136. package/src/core/tasks/SolanaSignAndExecuteTask.ts +15 -0
  137. package/src/core/tasks/SolanaStandardWaitForTransactionTask.ts +28 -17
  138. package/src/core/tasks/readSignature.ts +29 -0
  139. package/src/core/tasks/unwrapConfirmation.ts +59 -0
  140. package/src/rpc/jito/api/getBundleStatuses.ts +4 -2
  141. package/src/rpc/registry.ts +183 -25
  142. package/src/rpc/utils.ts +5 -2
  143. package/src/utils/KeypairWalletAdapter.ts +34 -9
  144. package/src/utils/getTransactionLifetime.ts +38 -0
  145. package/src/version.ts +1 -1
@@ -16,18 +16,78 @@ const jitoRpcs = new _lifi_sdk.LruMap(12);
16
16
  * still accepts it and performs the lookup instead of rejecting the probe.
17
17
  */
18
18
  const PROBE_BUNDLE_ID = "1111111111111111111111111111111111111111111111111111111111111111";
19
+ /** Retry window for a probe that failed without naming the method unknown.
20
+ * An outage heals, so a permanent entry would keep a recovered endpoint out of
21
+ * the Jito list for the whole process. */
22
+ const JITO_PROBE_RETRY_MS = 3e4;
23
+ /** Retry window for a bare HTTP 401/403. Longer than an outage's, shorter than
24
+ * forever. The refusal never reached the JSON-RPC layer, so it proves nothing
25
+ * about capability: a plan gate, a provider deploy and an allowlist entry
26
+ * still propagating are indistinguishable here. Treating it as permanent meant
27
+ * one transient 403 removed a working endpoint for the process lifetime;
28
+ * treating it as a 30 s outage would re-probe a real plan gate on the
29
+ * pre-submission latency path twice a minute, forever. */
30
+ const JITO_PROBE_GATEWAY_RETRY_MS = 9e5;
31
+ /** Every answered probe, the negative ones included. Without them the unprobed
32
+ * set never shrinks, and every bundle submission re-probes every non-Jito
33
+ * endpoint at up to `PROBE_TIMEOUT_MS` each, on the latency path before
34
+ * submission can start. */
35
+ const jitoProbes = new _lifi_sdk.LruMap(12);
36
+ /** One rule for every outcome: a record is fresh until its own window closes.
37
+ * `Infinity` covers the answers that cannot change. */
38
+ const isProbeFresh = (record) => record !== void 0 && Date.now() - record.at < record.retryMs;
39
+ const CAPABILITY_CODES = [-32601, -32403];
40
+ /** A plan gate rejects before JSON-RPC, so no `-32601` arrives - Helius
41
+ * answers with a bare 403. Unlike a JSON-RPC code this never reached the RPC
42
+ * layer, so it is a gateway verdict rather than a capability answer, and it
43
+ * earns a window instead of permanence. 429 and 5xx are absent: those take the
44
+ * shorter outage window. */
45
+ const GATEWAY_REFUSAL_HTTP_STATUSES = [401, 403];
46
+ const readProbeFailure = (error) => {
47
+ const candidate = error;
48
+ const rpcCode = candidate?.code ?? candidate?.context?.__code;
49
+ if (typeof rpcCode === "number" && CAPABILITY_CODES.includes(rpcCode)) return {
50
+ outcome: "unsupported",
51
+ retryMs: Number.POSITIVE_INFINITY
52
+ };
53
+ const status = candidate?.context?.statusCode;
54
+ if (typeof status === "number" && GATEWAY_REFUSAL_HTTP_STATUSES.includes(status)) return {
55
+ outcome: "unreachable",
56
+ retryMs: JITO_PROBE_GATEWAY_RETRY_MS
57
+ };
58
+ const message = error instanceof Error ? error.message : String(error);
59
+ return /method not found|method does not exist|-32601|method .* not supported|unsupported method|only available for business plans/i.test(message) ? {
60
+ outcome: "unsupported",
61
+ retryMs: Number.POSITIVE_INFINITY
62
+ } : {
63
+ outcome: "unreachable",
64
+ retryMs: JITO_PROBE_RETRY_MS
65
+ };
66
+ };
67
+ /**
68
+ * Bounded because it runs upstream of `raceRpcs`, outside the confirmation
69
+ * budget the SDK documents: an endpoint that accepts the connection and never
70
+ * answers would otherwise stall bundle submission indefinitely.
71
+ */
72
+ const PROBE_TIMEOUT_MS = 5e3;
19
73
  /**
20
- * Checks if an RPC URL supports Jito methods by calling getBundleStatuses.
21
- * We probe with getBundleStatuses (rather than getTipAccounts) because it is the
22
- * method actually used during bundle confirmation, and providers such as Helius
23
- * support sendBundle/getBundleStatuses without exposing getTipAccounts.
74
+ * Probes with `getBundleStatuses` rather than `getTipAccounts`: it is the
75
+ * method bundle confirmation actually uses, and providers such as Helius
76
+ * support it without exposing `getTipAccounts`.
24
77
  */
25
- const isJitoRpc = async (rpcUrl) => {
78
+ const probeJitoRpc = async (rpcUrl) => {
79
+ const controller = new AbortController();
80
+ const timer = setTimeout(() => controller.abort(), PROBE_TIMEOUT_MS);
26
81
  try {
27
- await require_rpc_jito_createJitoRpc.createJitoRpc(rpcUrl).getBundleStatuses([PROBE_BUNDLE_ID]).send();
28
- return true;
29
- } catch {
30
- return false;
82
+ await require_rpc_jito_createJitoRpc.createJitoRpc(rpcUrl).getBundleStatuses([PROBE_BUNDLE_ID]).send({ abortSignal: controller.signal });
83
+ return {
84
+ outcome: "supported",
85
+ retryMs: Number.POSITIVE_INFINITY
86
+ };
87
+ } catch (error) {
88
+ return readProbeFailure(error);
89
+ } finally {
90
+ clearTimeout(timer);
31
91
  }
32
92
  };
33
93
  /**
@@ -40,13 +100,31 @@ const ensureSolanaRpcs = async (client) => {
40
100
  return rpcUrls;
41
101
  };
42
102
  /**
43
- * Detects and caches Jito-capable RPCs by checking if they support the getTipAccounts method.
103
+ * Initializes and caches Jito RPCs for every configured Solana RPC URL.
104
+ *
105
+ * Every probe outcome is cached, so a non-Jito endpoint is probed once rather
106
+ * than once per bundle submission. Each record carries its own retry window:
107
+ * see `JITO_PROBE_RETRY_MS` and `JITO_PROBE_GATEWAY_RETRY_MS` for the two that
108
+ * expire.
44
109
  * @param client - The SDK client used to fetch RPC URLs.
45
110
  */
46
111
  const ensureJitoRpcs = async (client) => {
47
112
  const rpcUrls = await client.getRpcUrlsByChainId(_lifi_sdk.ChainId.SOL);
48
- for (const rpcUrl of rpcUrls) if (!jitoRpcs.has(rpcUrl) && await isJitoRpc(rpcUrl)) jitoRpcs.set(rpcUrl, require_rpc_jito_createJitoRpc.createJitoRpc(rpcUrl));
49
- return rpcUrls;
113
+ const unprobed = rpcUrls.filter((rpcUrl) => !isProbeFresh(jitoProbes.get(rpcUrl)));
114
+ (await Promise.all(unprobed.map((rpcUrl) => (0, _lifi_sdk.withDedupe)(() => probeJitoRpc(rpcUrl), { id: `jito-probe:${rpcUrl}` })))).forEach(({ outcome, retryMs }, index) => {
115
+ const rpcUrl = unprobed[index];
116
+ jitoProbes.set(rpcUrl, {
117
+ outcome,
118
+ retryMs,
119
+ at: Date.now()
120
+ });
121
+ if (outcome === "supported") jitoRpcs.set(rpcUrl, require_rpc_jito_createJitoRpc.createJitoRpc(rpcUrl));
122
+ else jitoRpcs.delete(rpcUrl);
123
+ });
124
+ return {
125
+ rpcUrls,
126
+ unreachable: rpcUrls.filter((rpcUrl) => jitoProbes.get(rpcUrl)?.outcome === "unreachable").length
127
+ };
50
128
  };
51
129
  /**
52
130
  * Wrapper around getting the Solana RPCs
@@ -55,16 +133,23 @@ const ensureJitoRpcs = async (client) => {
55
133
  const getSolanaRpcs = async (client) => {
56
134
  return (await ensureSolanaRpcs(client)).map((rpcUrl) => solanaRpcs.get(rpcUrl)).filter((rpc) => Boolean(rpc));
57
135
  };
58
- /**
59
- * Wrapper around getting the Jito RPCs
60
- * @returns - Jito RPCs
61
- */
136
+ /** `unreachable` counts endpoints whose probe failed without naming the
137
+ * method unknown. Empty `rpcs` with a non-zero count is usually an outage, but
138
+ * not always: a bare 401/403 lands here too, and that can be a plan gate the
139
+ * integrator has to fix. `sendAndConfirmBundle`'s message names both, because
140
+ * this count cannot tell them apart. */
62
141
  const getJitoRpcs = async (client) => {
63
- return (await ensureJitoRpcs(client)).map((rpcUrl) => jitoRpcs.get(rpcUrl)).filter((rpc) => Boolean(rpc));
142
+ const { rpcUrls, unreachable } = await ensureJitoRpcs(client);
143
+ return {
144
+ rpcs: rpcUrls.map((rpcUrl) => jitoRpcs.get(rpcUrl)).filter((rpc) => Boolean(rpc)),
145
+ unreachable
146
+ };
64
147
  };
65
148
  //#endregion
149
+ exports.JITO_PROBE_GATEWAY_RETRY_MS = JITO_PROBE_GATEWAY_RETRY_MS;
150
+ exports.JITO_PROBE_RETRY_MS = JITO_PROBE_RETRY_MS;
66
151
  exports.getJitoRpcs = getJitoRpcs;
67
152
  exports.getSolanaRpcs = getSolanaRpcs;
68
- exports.isJitoRpc = isJitoRpc;
153
+ exports.probeJitoRpc = probeJitoRpc;
69
154
 
70
155
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","names":["LruMap","createJitoRpc","ChainId","createSolanaRpc"],"sources":["../../../src/rpc/registry.ts"],"sourcesContent":["import { ChainId, LruMap, type SDKClient } from '@lifi/sdk'\nimport { createSolanaRpc } from '@solana/kit'\nimport { createJitoRpc } from './jito/createJitoRpc.js'\nimport type { JitoRpcType, SolanaRpcType } from './types.js'\n\nconst solanaRpcs = new LruMap<SolanaRpcType>(12)\nconst jitoRpcs = new LruMap<JitoRpcType>(12)\n\n/**\n * A well-formed but non-existent Jito bundle id used solely to probe RPC\n * capability. It forces `getBundleStatuses` to actually execute, so we can tell\n * a Jito-capable RPC (resolves with `{ value: [null] }` — bundle not found)\n * apart from a standard Solana RPC (throws \"Method not found\").\n *\n * Uses all `1`s: 64 chars, valid as both hex and base-58 (base-58 excludes\n * `0`/`O`/`I`/`l`), so a provider that validates the id in either encoding\n * still accepts it and performs the lookup instead of rejecting the probe.\n */\nconst PROBE_BUNDLE_ID =\n '1111111111111111111111111111111111111111111111111111111111111111'\n\n/**\n * Checks if an RPC URL supports Jito methods by calling getBundleStatuses.\n * We probe with getBundleStatuses (rather than getTipAccounts) because it is the\n * method actually used during bundle confirmation, and providers such as Helius\n * support sendBundle/getBundleStatuses without exposing getTipAccounts.\n */\nexport const isJitoRpc = async (rpcUrl: string): Promise<boolean> => {\n try {\n const rpc = createJitoRpc(rpcUrl)\n await rpc.getBundleStatuses([PROBE_BUNDLE_ID]).send()\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Initializes Solana RPCs for all available RPC URLs if they haven't been cached yet.\n * @param client - The SDK client used to fetch RPC URLs.\n */\nconst ensureSolanaRpcs = async (client: SDKClient): Promise<string[]> => {\n const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SOL)\n for (const rpcUrl of rpcUrls) {\n if (!solanaRpcs.has(rpcUrl)) {\n solanaRpcs.set(rpcUrl, createSolanaRpc(rpcUrl))\n }\n }\n return rpcUrls\n}\n\n/**\n * Detects and caches Jito-capable RPCs by checking if they support the getTipAccounts method.\n * @param client - The SDK client used to fetch RPC URLs.\n */\nconst ensureJitoRpcs = async (client: SDKClient): Promise<string[]> => {\n const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SOL)\n for (const rpcUrl of rpcUrls) {\n if (!jitoRpcs.has(rpcUrl) && (await isJitoRpc(rpcUrl))) {\n jitoRpcs.set(rpcUrl, createJitoRpc(rpcUrl))\n }\n }\n return rpcUrls\n}\n\n/**\n * Wrapper around getting the Solana RPCs\n * @returns - Solana RPCs\n */\nexport const getSolanaRpcs = async (\n client: SDKClient\n): Promise<SolanaRpcType[]> => {\n const rpcUrls = await ensureSolanaRpcs(client)\n return rpcUrls\n .map((rpcUrl) => solanaRpcs.get(rpcUrl))\n .filter((rpc): rpc is SolanaRpcType => Boolean(rpc))\n}\n\n/**\n * Wrapper around getting the Jito RPCs\n * @returns - Jito RPCs\n */\nexport const getJitoRpcs = async (\n client: SDKClient\n): Promise<JitoRpcType[]> => {\n const rpcUrls = await ensureJitoRpcs(client)\n return rpcUrls\n .map((rpcUrl) => jitoRpcs.get(rpcUrl))\n .filter((rpc): rpc is JitoRpcType => Boolean(rpc))\n}\n"],"mappings":";;;;;AAKA,MAAM,aAAa,IAAIA,UAAAA,OAAsB,EAAE;AAC/C,MAAM,WAAW,IAAIA,UAAAA,OAAoB,EAAE;;;;;;;;;;;AAY3C,MAAM,kBACJ;;;;;;;AAQF,MAAa,YAAY,OAAO,WAAqC;CACnE,IAAI;EAEF,MADYC,+BAAAA,cAAc,MAClB,CAAC,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK;EACpD,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,MAAM,mBAAmB,OAAO,WAAyC;CACvE,MAAM,UAAU,MAAM,OAAO,oBAAoBC,UAAAA,QAAQ,GAAG;CAC5D,KAAK,MAAM,UAAU,SACnB,IAAI,CAAC,WAAW,IAAI,MAAM,GACxB,WAAW,IAAI,SAAA,GAAQC,YAAAA,gBAAAA,CAAgB,MAAM,CAAC;CAGlD,OAAO;AACT;;;;;AAMA,MAAM,iBAAiB,OAAO,WAAyC;CACrE,MAAM,UAAU,MAAM,OAAO,oBAAoBD,UAAAA,QAAQ,GAAG;CAC5D,KAAK,MAAM,UAAU,SACnB,IAAI,CAAC,SAAS,IAAI,MAAM,KAAM,MAAM,UAAU,MAAM,GAClD,SAAS,IAAI,QAAQD,+BAAAA,cAAc,MAAM,CAAC;CAG9C,OAAO;AACT;;;;;AAMA,MAAa,gBAAgB,OAC3B,WAC6B;CAE7B,QAAO,MADe,iBAAiB,MAAM,EAAA,CAE1C,KAAK,WAAW,WAAW,IAAI,MAAM,CAAC,CAAC,CACvC,QAAQ,QAA8B,QAAQ,GAAG,CAAC;AACvD;;;;;AAMA,MAAa,cAAc,OACzB,WAC2B;CAE3B,QAAO,MADe,eAAe,MAAM,EAAA,CAExC,KAAK,WAAW,SAAS,IAAI,MAAM,CAAC,CAAC,CACrC,QAAQ,QAA4B,QAAQ,GAAG,CAAC;AACrD"}
1
+ {"version":3,"file":"registry.js","names":["LruMap","createJitoRpc","ChainId","createSolanaRpc","withDedupe"],"sources":["../../../src/rpc/registry.ts"],"sourcesContent":["import { ChainId, LruMap, type SDKClient, withDedupe } from '@lifi/sdk'\nimport { createSolanaRpc } from '@solana/kit'\nimport { createJitoRpc } from './jito/createJitoRpc.js'\nimport type { JitoRpcType, SolanaRpcType } from './types.js'\n\nconst solanaRpcs = new LruMap<SolanaRpcType>(12)\nconst jitoRpcs = new LruMap<JitoRpcType>(12)\n\n/**\n * A well-formed but non-existent Jito bundle id used solely to probe RPC\n * capability. It forces `getBundleStatuses` to actually execute, so we can tell\n * a Jito-capable RPC (resolves with `{ value: [null] }` — bundle not found)\n * apart from a standard Solana RPC (throws \"Method not found\").\n *\n * Uses all `1`s: 64 chars, valid as both hex and base-58 (base-58 excludes\n * `0`/`O`/`I`/`l`), so a provider that validates the id in either encoding\n * still accepts it and performs the lookup instead of rejecting the probe.\n */\nconst PROBE_BUNDLE_ID =\n '1111111111111111111111111111111111111111111111111111111111111111'\n\n/** Both leave the endpoint out of the Jito list, but only `unsupported` is a\n * configuration gap the integrator can act on. */\nexport type JitoProbeOutcome = 'supported' | 'unsupported' | 'unreachable'\n\n/** An outcome plus how long it may be trusted. The classifier decides both,\n * because how long an answer is worth is a property of the evidence that\n * produced it, not of the outcome alone. */\nexport type JitoProbeResult = {\n outcome: JitoProbeOutcome\n /** `Infinity` for an answer that cannot change. */\n retryMs: number\n}\n\n/** Retry window for a probe that failed without naming the method unknown.\n * An outage heals, so a permanent entry would keep a recovered endpoint out of\n * the Jito list for the whole process. */\nexport const JITO_PROBE_RETRY_MS = 30_000\n\n/** Retry window for a bare HTTP 401/403. Longer than an outage's, shorter than\n * forever. The refusal never reached the JSON-RPC layer, so it proves nothing\n * about capability: a plan gate, a provider deploy and an allowlist entry\n * still propagating are indistinguishable here. Treating it as permanent meant\n * one transient 403 removed a working endpoint for the process lifetime;\n * treating it as a 30 s outage would re-probe a real plan gate on the\n * pre-submission latency path twice a minute, forever. */\nexport const JITO_PROBE_GATEWAY_RETRY_MS: number = 15 * 60_000\n\ntype JitoProbeRecord = JitoProbeResult & { at: number }\n\n/** Every answered probe, the negative ones included. Without them the unprobed\n * set never shrinks, and every bundle submission re-probes every non-Jito\n * endpoint at up to `PROBE_TIMEOUT_MS` each, on the latency path before\n * submission can start. */\nconst jitoProbes = new LruMap<JitoProbeRecord>(12)\n\n/** One rule for every outcome: a record is fresh until its own window closes.\n * `Infinity` covers the answers that cannot change. */\nconst isProbeFresh = (record: JitoProbeRecord | undefined): boolean =>\n record !== undefined && Date.now() - record.at < record.retryMs\n\n/** `@solana/kit` puts the JSON-RPC code on `context.__code`, not `error.code`.\n * The message is a last resort - a provider can reword it. An unrecognized\n * failure counts as `unreachable`, so a misread blames an outage. */\nconst JSON_RPC_METHOD_NOT_FOUND = -32601\n/** Non-standard; providers use it for \"your plan lacks this method\". */\nconst PROVIDER_PLAN_RESTRICTED = -32403\n\nconst CAPABILITY_CODES: number[] = [\n JSON_RPC_METHOD_NOT_FOUND,\n PROVIDER_PLAN_RESTRICTED,\n]\n\n/** A plan gate rejects before JSON-RPC, so no `-32601` arrives - Helius\n * answers with a bare 403. Unlike a JSON-RPC code this never reached the RPC\n * layer, so it is a gateway verdict rather than a capability answer, and it\n * earns a window instead of permanence. 429 and 5xx are absent: those take the\n * shorter outage window. */\nconst GATEWAY_REFUSAL_HTTP_STATUSES: number[] = [401, 403]\n\nconst readProbeFailure = (error: unknown): JitoProbeResult => {\n const candidate = error as\n | {\n code?: unknown\n context?: { __code?: unknown; statusCode?: unknown }\n }\n | undefined\n\n // kit's `__code` is 8100002 for every HTTP failure, so only a JSON-RPC code\n // that reached the body is meaningful.\n const rpcCode = candidate?.code ?? candidate?.context?.__code\n if (typeof rpcCode === 'number' && CAPABILITY_CODES.includes(rpcCode)) {\n // The server parsed the request and said it has no such method. Definitive.\n return { outcome: 'unsupported', retryMs: Number.POSITIVE_INFINITY }\n }\n\n const status = candidate?.context?.statusCode\n if (\n typeof status === 'number' &&\n GATEWAY_REFUSAL_HTTP_STATUSES.includes(status)\n ) {\n return { outcome: 'unreachable', retryMs: JITO_PROBE_GATEWAY_RETRY_MS }\n }\n\n const message = error instanceof Error ? error.message : String(error)\n return /method not found|method does not exist|-32601|method .* not supported|unsupported method|only available for business plans/i.test(\n message\n )\n ? { outcome: 'unsupported', retryMs: Number.POSITIVE_INFINITY }\n : { outcome: 'unreachable', retryMs: JITO_PROBE_RETRY_MS }\n}\n\n/**\n * Bounded because it runs upstream of `raceRpcs`, outside the confirmation\n * budget the SDK documents: an endpoint that accepts the connection and never\n * answers would otherwise stall bundle submission indefinitely.\n */\nconst PROBE_TIMEOUT_MS = 5_000\n\n/**\n * Probes with `getBundleStatuses` rather than `getTipAccounts`: it is the\n * method bundle confirmation actually uses, and providers such as Helius\n * support it without exposing `getTipAccounts`.\n */\nexport const probeJitoRpc = async (\n rpcUrl: string\n): Promise<JitoProbeResult> => {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), PROBE_TIMEOUT_MS)\n try {\n const rpc = createJitoRpc(rpcUrl)\n await rpc\n .getBundleStatuses([PROBE_BUNDLE_ID])\n .send({ abortSignal: controller.signal })\n return { outcome: 'supported', retryMs: Number.POSITIVE_INFINITY }\n } catch (error) {\n return readProbeFailure(error)\n } finally {\n clearTimeout(timer)\n }\n}\n\n/**\n * Initializes Solana RPCs for all available RPC URLs if they haven't been cached yet.\n * @param client - The SDK client used to fetch RPC URLs.\n */\nconst ensureSolanaRpcs = async (client: SDKClient): Promise<string[]> => {\n const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SOL)\n for (const rpcUrl of rpcUrls) {\n if (!solanaRpcs.has(rpcUrl)) {\n solanaRpcs.set(rpcUrl, createSolanaRpc(rpcUrl))\n }\n }\n return rpcUrls\n}\n\n/**\n * Initializes and caches Jito RPCs for every configured Solana RPC URL.\n *\n * Every probe outcome is cached, so a non-Jito endpoint is probed once rather\n * than once per bundle submission. Each record carries its own retry window:\n * see `JITO_PROBE_RETRY_MS` and `JITO_PROBE_GATEWAY_RETRY_MS` for the two that\n * expire.\n * @param client - The SDK client used to fetch RPC URLs.\n */\nconst ensureJitoRpcs = async (\n client: SDKClient\n): Promise<{ rpcUrls: string[]; unreachable: number }> => {\n const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SOL)\n // Probed in parallel: serially, one slow endpoint delayed every URL behind\n // it before submission could start.\n const unprobed = rpcUrls.filter(\n (rpcUrl) => !isProbeFresh(jitoProbes.get(rpcUrl))\n )\n // Deduplicated per URL: without it two concurrent submissions each probe\n // every unprobed endpoint, and the slower probe writes last - a 5 s timeout\n // resolving `unreachable` used to overwrite a `supported` answer that landed\n // at 300 ms, evicting a verified-healthy endpoint.\n //\n // `withDedupe` drops its entry in a `.finally`, so this guarantees at most\n // one probe *in flight* per URL, not one probe per URL. The write below waits\n // for the whole batch, so a fast URL's record is unwritten while a slow\n // sibling is still running - up to `PROBE_TIMEOUT_MS` - and every caller\n // arriving in that window re-probes the fast URL. Repeats are therefore\n // bounded by arrivals, not by one.\n //\n // What this does rule out is the clobber: a second probe can only begin\n // after the first has settled, so it always carries the newer answer and\n // always writes second. Write order matches result recency, which is why no\n // timestamp comparison is needed here.\n const results = await Promise.all(\n unprobed.map((rpcUrl) =>\n withDedupe(() => probeJitoRpc(rpcUrl), { id: `jito-probe:${rpcUrl}` })\n )\n )\n\n results.forEach(({ outcome, retryMs }, index) => {\n const rpcUrl = unprobed[index]\n jitoProbes.set(rpcUrl, { outcome, retryMs, at: Date.now() })\n if (outcome === 'supported') {\n jitoRpcs.set(rpcUrl, createJitoRpc(rpcUrl))\n } else {\n // An endpoint that used to answer and now does not must leave the list,\n // or `getJitoRpcs` keeps handing out a client for it.\n jitoRpcs.delete(rpcUrl)\n }\n })\n\n // Counted over every URL, not only the freshly probed ones: a cached\n // `unreachable` still has to reach `sendAndConfirmBundle`, which uses the\n // count to choose between \"retry, likely temporary\" and \"supply a\n // Jito-capable URL\".\n const unreachable = rpcUrls.filter(\n (rpcUrl) => jitoProbes.get(rpcUrl)?.outcome === 'unreachable'\n ).length\n\n return { rpcUrls, unreachable }\n}\n\n/**\n * Wrapper around getting the Solana RPCs\n * @returns - Solana RPCs\n */\nexport const getSolanaRpcs = async (\n client: SDKClient\n): Promise<SolanaRpcType[]> => {\n const rpcUrls = await ensureSolanaRpcs(client)\n return rpcUrls\n .map((rpcUrl) => solanaRpcs.get(rpcUrl))\n .filter((rpc): rpc is SolanaRpcType => Boolean(rpc))\n}\n\n/** `unreachable` counts endpoints whose probe failed without naming the\n * method unknown. Empty `rpcs` with a non-zero count is usually an outage, but\n * not always: a bare 401/403 lands here too, and that can be a plan gate the\n * integrator has to fix. `sendAndConfirmBundle`'s message names both, because\n * this count cannot tell them apart. */\nexport const getJitoRpcs = async (\n client: SDKClient\n): Promise<{ rpcs: JitoRpcType[]; unreachable: number }> => {\n const { rpcUrls, unreachable } = await ensureJitoRpcs(client)\n return {\n rpcs: rpcUrls\n .map((rpcUrl) => jitoRpcs.get(rpcUrl))\n .filter((rpc): rpc is JitoRpcType => Boolean(rpc)),\n unreachable,\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,aAAa,IAAIA,UAAAA,OAAsB,EAAE;AAC/C,MAAM,WAAW,IAAIA,UAAAA,OAAoB,EAAE;;;;;;;;;;;AAY3C,MAAM,kBACJ;;;;AAkBF,MAAa,sBAAsB;;;;;;;;AASnC,MAAa,8BAAsC;;;;;AAQnD,MAAM,aAAa,IAAIA,UAAAA,OAAwB,EAAE;;;AAIjD,MAAM,gBAAgB,WACpB,WAAW,KAAA,KAAa,KAAK,IAAI,IAAI,OAAO,KAAK,OAAO;AAS1D,MAAM,mBAA6B,CACjC,QACA,MACF;;;;;;AAOA,MAAM,gCAA0C,CAAC,KAAK,GAAG;AAEzD,MAAM,oBAAoB,UAAoC;CAC5D,MAAM,YAAY;CASlB,MAAM,UAAU,WAAW,QAAQ,WAAW,SAAS;CACvD,IAAI,OAAO,YAAY,YAAY,iBAAiB,SAAS,OAAO,GAElE,OAAO;EAAE,SAAS;EAAe,SAAS,OAAO;CAAkB;CAGrE,MAAM,SAAS,WAAW,SAAS;CACnC,IACE,OAAO,WAAW,YAClB,8BAA8B,SAAS,MAAM,GAE7C,OAAO;EAAE,SAAS;EAAe,SAAS;CAA4B;CAGxE,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACrE,OAAO,8HAA8H,KACnI,OACF,IACI;EAAE,SAAS;EAAe,SAAS,OAAO;CAAkB,IAC5D;EAAE,SAAS;EAAe,SAAS;CAAoB;AAC7D;;;;;;AAOA,MAAM,mBAAmB;;;;;;AAOzB,MAAa,eAAe,OAC1B,WAC6B;CAC7B,MAAM,aAAa,IAAI,gBAAgB;CACvC,MAAM,QAAQ,iBAAiB,WAAW,MAAM,GAAG,gBAAgB;CACnE,IAAI;EAEF,MADYC,+BAAAA,cAAc,MAClB,CAAC,CACN,kBAAkB,CAAC,eAAe,CAAC,CAAC,CACpC,KAAK,EAAE,aAAa,WAAW,OAAO,CAAC;EAC1C,OAAO;GAAE,SAAS;GAAa,SAAS,OAAO;EAAkB;CACnE,SAAS,OAAO;EACd,OAAO,iBAAiB,KAAK;CAC/B,UAAU;EACR,aAAa,KAAK;CACpB;AACF;;;;;AAMA,MAAM,mBAAmB,OAAO,WAAyC;CACvE,MAAM,UAAU,MAAM,OAAO,oBAAoBC,UAAAA,QAAQ,GAAG;CAC5D,KAAK,MAAM,UAAU,SACnB,IAAI,CAAC,WAAW,IAAI,MAAM,GACxB,WAAW,IAAI,SAAA,GAAQC,YAAAA,gBAAAA,CAAgB,MAAM,CAAC;CAGlD,OAAO;AACT;;;;;;;;;;AAWA,MAAM,iBAAiB,OACrB,WACwD;CACxD,MAAM,UAAU,MAAM,OAAO,oBAAoBD,UAAAA,QAAQ,GAAG;CAG5D,MAAM,WAAW,QAAQ,QACtB,WAAW,CAAC,aAAa,WAAW,IAAI,MAAM,CAAC,CAClD;CAuBA,CAAA,MANsB,QAAQ,IAC5B,SAAS,KAAK,YAAA,GACZE,UAAAA,WAAAA,OAAiB,aAAa,MAAM,GAAG,EAAE,IAAI,cAAc,SAAS,CAAC,CACvE,CACF,EAAA,CAEQ,SAAS,EAAE,SAAS,WAAW,UAAU;EAC/C,MAAM,SAAS,SAAS;EACxB,WAAW,IAAI,QAAQ;GAAE;GAAS;GAAS,IAAI,KAAK,IAAI;EAAE,CAAC;EAC3D,IAAI,YAAY,aACd,SAAS,IAAI,QAAQH,+BAAAA,cAAc,MAAM,CAAC;OAI1C,SAAS,OAAO,MAAM;CAE1B,CAAC;CAUD,OAAO;EAAE;EAAS,aAJE,QAAQ,QACzB,WAAW,WAAW,IAAI,MAAM,CAAC,EAAE,YAAY,aAClD,CAAC,CAAC;CAE4B;AAChC;;;;;AAMA,MAAa,gBAAgB,OAC3B,WAC6B;CAE7B,QAAO,MADe,iBAAiB,MAAM,EAAA,CAE1C,KAAK,WAAW,WAAW,IAAI,MAAM,CAAC,CAAC,CACvC,QAAQ,QAA8B,QAAQ,GAAG,CAAC;AACvD;;;;;;AAOA,MAAa,cAAc,OACzB,WAC0D;CAC1D,MAAM,EAAE,SAAS,gBAAgB,MAAM,eAAe,MAAM;CAC5D,OAAO;EACL,MAAM,QACH,KAAK,WAAW,SAAS,IAAI,MAAM,CAAC,CAAC,CACrC,QAAQ,QAA4B,QAAQ,GAAG,CAAC;EACnD;CACF;AACF"}
@@ -75,7 +75,7 @@ const callSolanaRpcsWithRetry = createRetryFn(require_rpc_registry.getSolanaRpcs
75
75
  * )
76
76
  * ```
77
77
  */
78
- const callJitoRpcsWithRetry = createRetryFn(require_rpc_registry.getJitoRpcs);
78
+ const callJitoRpcsWithRetry = createRetryFn(async (client) => (await require_rpc_registry.getJitoRpcs(client)).rpcs);
79
79
  //#endregion
80
80
  exports.callJitoRpcsWithRetry = callJitoRpcsWithRetry;
81
81
  exports.callSolanaRpcsWithRetry = callSolanaRpcsWithRetry;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["getSolanaRpcs","getJitoRpcs"],"sources":["../../../src/rpc/utils.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport { getJitoRpcs, getSolanaRpcs } from './registry.js'\nimport type { JitoRpcType, SolanaRpcType } from './types.js'\n\ntype RetryFn<Rpc> = <R>(\n client: SDKClient,\n fn: (rpc: Rpc) => Promise<R>\n) => Promise<R>\n\n/**\n * Calls a function on RPC instances with retry logic.\n * Tries each RPC in sequence until one succeeds.\n *\n * @typeParam T - The type of the RPC instance.\n * @typeParam R - The return type of the function.\n * @param rpcs - An array of RPC instances to try.\n * @param fn - The async function to execute on each RPC until one succeeds.\n * @returns The result from the first successful RPC call.\n * @throws {Error} If no RPCs are available.\n * @throws {AggregateError} If all RPCs fail, containing all individual errors.\n *\n * @example\n * ```ts\n * const rpcs = await getSolanaRpcs(client)\n * const result = await callWithRetry(rpcs, (rpc) =>\n * rpc.getBalance(address).send()\n * )\n * ```\n */\nexport async function callWithRetry<T, R>(\n rpcs: T[],\n fn: (rpc: T) => Promise<R>\n): Promise<R> {\n if (rpcs.length === 0) {\n throw new Error('No RPCs available')\n }\n\n const errors: Error[] = []\n for (const rpc of rpcs) {\n try {\n return await fn(rpc)\n } catch (error) {\n errors.push(error instanceof Error ? error : new Error(String(error)))\n }\n }\n\n throw new AggregateError(errors, `All ${rpcs.length} RPCs failed`)\n}\n\n/**\n * Creates a retry function for a specific RPC type.\n * @internal\n */\nconst createRetryFn =\n <T>(getRpcs: (client: SDKClient) => Promise<T[]>) =>\n async <R>(client: SDKClient, fn: (rpc: T) => Promise<R>): Promise<R> => {\n const rpcs = await getRpcs(client)\n return callWithRetry(rpcs, fn)\n }\n\n/**\n * Calls a function on Solana RPC instances with retry logic.\n * Automatically fetches available Solana RPCs and tries each in sequence.\n *\n * @typeParam R - The return type of the function.\n * @param client - The SDK client used to fetch RPC URLs.\n * @param fn - The async function to execute on each RPC until one succeeds.\n * @returns The result from the first successful RPC call.\n * @throws {Error} If no Solana RPCs are available.\n * @throws {AggregateError} If all RPCs fail.\n *\n * @example\n * ```ts\n * const balance = await callSolanaRpcsWithRetry(client, (rpc) =>\n * rpc.getBalance(address).send()\n * )\n * ```\n */\nexport const callSolanaRpcsWithRetry: RetryFn<SolanaRpcType> =\n createRetryFn(getSolanaRpcs)\n\n/**\n * Calls a function on Jito RPC instances with retry logic.\n * Automatically fetches available Jito RPCs and tries each in sequence.\n *\n * @typeParam R - The return type of the function.\n * @param client - The SDK client used to fetch RPC URLs.\n * @param fn - The async function to execute on each RPC until one succeeds.\n * @returns The result from the first successful RPC call.\n * @throws {Error} If no Jito RPCs are available.\n * @throws {AggregateError} If all RPCs fail.\n *\n * @example\n * ```ts\n * const tipAccounts = await callJitoRpcsWithRetry(client, (rpc) =>\n * rpc.getTipAccounts().send()\n * )\n * ```\n */\nexport const callJitoRpcsWithRetry: RetryFn<JitoRpcType> =\n createRetryFn(getJitoRpcs)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,cACpB,MACA,IACY;CACZ,IAAI,KAAK,WAAW,GAClB,MAAM,IAAI,MAAM,mBAAmB;CAGrC,MAAM,SAAkB,CAAC;CACzB,KAAK,MAAM,OAAO,MAChB,IAAI;EACF,OAAO,MAAM,GAAG,GAAG;CACrB,SAAS,OAAO;EACd,OAAO,KAAK,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;CACvE;CAGF,MAAM,IAAI,eAAe,QAAQ,OAAO,KAAK,OAAO,aAAa;AACnE;;;;;AAMA,MAAM,iBACA,YACJ,OAAU,QAAmB,OAA2C;CAEtE,OAAO,cAAc,MADF,QAAQ,MAAM,GACN,EAAE;AAC/B;;;;;;;;;;;;;;;;;;;AAoBF,MAAa,0BACX,cAAcA,qBAAAA,aAAa;;;;;;;;;;;;;;;;;;;AAoB7B,MAAa,wBACX,cAAcC,qBAAAA,WAAW"}
1
+ {"version":3,"file":"utils.js","names":["getSolanaRpcs","getJitoRpcs"],"sources":["../../../src/rpc/utils.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport { getJitoRpcs, getSolanaRpcs } from './registry.js'\nimport type { JitoRpcType, SolanaRpcType } from './types.js'\n\ntype RetryFn<Rpc> = <R>(\n client: SDKClient,\n fn: (rpc: Rpc) => Promise<R>\n) => Promise<R>\n\n/**\n * Calls a function on RPC instances with retry logic.\n * Tries each RPC in sequence until one succeeds.\n *\n * @typeParam T - The type of the RPC instance.\n * @typeParam R - The return type of the function.\n * @param rpcs - An array of RPC instances to try.\n * @param fn - The async function to execute on each RPC until one succeeds.\n * @returns The result from the first successful RPC call.\n * @throws {Error} If no RPCs are available.\n * @throws {AggregateError} If all RPCs fail, containing all individual errors.\n *\n * @example\n * ```ts\n * const rpcs = await getSolanaRpcs(client)\n * const result = await callWithRetry(rpcs, (rpc) =>\n * rpc.getBalance(address).send()\n * )\n * ```\n */\nexport async function callWithRetry<T, R>(\n rpcs: T[],\n fn: (rpc: T) => Promise<R>\n): Promise<R> {\n if (rpcs.length === 0) {\n throw new Error('No RPCs available')\n }\n\n const errors: Error[] = []\n for (const rpc of rpcs) {\n try {\n return await fn(rpc)\n } catch (error) {\n errors.push(error instanceof Error ? error : new Error(String(error)))\n }\n }\n\n throw new AggregateError(errors, `All ${rpcs.length} RPCs failed`)\n}\n\n/**\n * Creates a retry function for a specific RPC type.\n * @internal\n */\nconst createRetryFn =\n <T>(getRpcs: (client: SDKClient) => Promise<T[]>) =>\n async <R>(client: SDKClient, fn: (rpc: T) => Promise<R>): Promise<R> => {\n const rpcs = await getRpcs(client)\n return callWithRetry(rpcs, fn)\n }\n\n/**\n * Calls a function on Solana RPC instances with retry logic.\n * Automatically fetches available Solana RPCs and tries each in sequence.\n *\n * @typeParam R - The return type of the function.\n * @param client - The SDK client used to fetch RPC URLs.\n * @param fn - The async function to execute on each RPC until one succeeds.\n * @returns The result from the first successful RPC call.\n * @throws {Error} If no Solana RPCs are available.\n * @throws {AggregateError} If all RPCs fail.\n *\n * @example\n * ```ts\n * const balance = await callSolanaRpcsWithRetry(client, (rpc) =>\n * rpc.getBalance(address).send()\n * )\n * ```\n */\nexport const callSolanaRpcsWithRetry: RetryFn<SolanaRpcType> =\n createRetryFn(getSolanaRpcs)\n\n/**\n * Calls a function on Jito RPC instances with retry logic.\n * Automatically fetches available Jito RPCs and tries each in sequence.\n *\n * @typeParam R - The return type of the function.\n * @param client - The SDK client used to fetch RPC URLs.\n * @param fn - The async function to execute on each RPC until one succeeds.\n * @returns The result from the first successful RPC call.\n * @throws {Error} If no Jito RPCs are available.\n * @throws {AggregateError} If all RPCs fail.\n *\n * @example\n * ```ts\n * const tipAccounts = await callJitoRpcsWithRetry(client, (rpc) =>\n * rpc.getTipAccounts().send()\n * )\n * ```\n */\nexport const callJitoRpcsWithRetry: RetryFn<JitoRpcType> = createRetryFn(\n // The probe diagnosis `getJitoRpcs` reports alongside the list is for the\n // bundle path's error message; a sequential retry only needs the list.\n async (client) => (await getJitoRpcs(client)).rpcs\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,cACpB,MACA,IACY;CACZ,IAAI,KAAK,WAAW,GAClB,MAAM,IAAI,MAAM,mBAAmB;CAGrC,MAAM,SAAkB,CAAC;CACzB,KAAK,MAAM,OAAO,MAChB,IAAI;EACF,OAAO,MAAM,GAAG,GAAG;CACrB,SAAS,OAAO;EACd,OAAO,KAAK,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;CACvE;CAGF,MAAM,IAAI,eAAe,QAAQ,OAAO,KAAK,OAAO,aAAa;AACnE;;;;;AAMA,MAAM,iBACA,YACJ,OAAU,QAAmB,OAA2C;CAEtE,OAAO,cAAc,MADF,QAAQ,MAAM,GACN,EAAE;AAC/B;;;;;;;;;;;;;;;;;;;AAoBF,MAAa,0BACX,cAAcA,qBAAAA,aAAa;;;;;;;;;;;;;;;;;;;AAoB7B,MAAa,wBAA8C,cAGzD,OAAO,YAAY,MAAMC,qBAAAA,YAAY,MAAM,EAAA,CAAG,IAChD"}
@@ -67,10 +67,16 @@ var KeypairWalletAdapter = class {
67
67
  for (const input of inputs) {
68
68
  const transaction = (0, _solana_kit.getTransactionCodec)().decode(input.transaction);
69
69
  (0, _solana_kit.assertIsTransactionWithinSizeLimit)(transaction);
70
- (0, _solana_kit.assertIsTransactionWithBlockhashLifetime)(transaction);
71
- const signatureDictionaries = await this._signer.signTransactions([transaction]);
72
- if (signatureDictionaries.length === 0 || !signatureDictionaries[0][this._signer.address]) throw new Error("Failed to sign transaction");
73
- const signedTransaction = (0, _solana_kit.getBase64EncodedWireTransaction)(transaction);
70
+ const [signatureDictionary] = await this._signer.signTransactions([transaction]);
71
+ const signature = signatureDictionary?.[this._signer.address];
72
+ if (!signature) throw new Error("Failed to sign transaction");
73
+ const signedTransaction = (0, _solana_kit.getBase64EncodedWireTransaction)({
74
+ ...transaction,
75
+ signatures: {
76
+ ...transaction.signatures,
77
+ [this._signer.address]: signature
78
+ }
79
+ });
74
80
  results.push({ signedTransaction: require_utils_base64ToUint8Array.base64ToUint8Array(signedTransaction) });
75
81
  }
76
82
  return results;
@@ -1 +1 @@
1
- {"version":3,"file":"KeypairWalletAdapter.js","names":["getBase58Codec","SolanaSignTransaction","createKeyPairSignerFromBytes","getTransactionCodec","getBase64EncodedWireTransaction","base64ToUint8Array"],"sources":["../../../src/utils/KeypairWalletAdapter.ts"],"sourcesContent":["import {\n assertIsTransactionWithBlockhashLifetime,\n assertIsTransactionWithinSizeLimit,\n createKeyPairSignerFromBytes,\n getBase58Codec,\n getBase64EncodedWireTransaction,\n getTransactionCodec,\n type KeyPairSigner,\n type ReadonlyUint8Array,\n} from '@solana/kit'\nimport {\n SolanaSignTransaction,\n type SolanaSignTransactionFeature,\n type SolanaSignTransactionInput,\n type SolanaSignTransactionOutput,\n} from '@solana/wallet-standard-features'\nimport type { Wallet, WalletAccount } from '@wallet-standard/base'\nimport { base64ToUint8Array } from './base64ToUint8Array.js'\n\n/**\n * This keypair wallet adapter is unsafe to use on the frontend and is only included to provide an easy way for applications to test\n * Wallet Adapter without using a third-party wallet.\n */\nexport class KeypairWalletAdapter implements Wallet {\n /**\n * Storing a keypair locally like this is not safe because any application using this adapter could retrieve the\n * secret key, and because the keypair will be lost any time the wallet is disconnected or the window is refreshed.\n */\n private _signer: KeyPairSigner | undefined\n private _account: WalletAccount | undefined\n private readonly _secretKeyBytes: ReadonlyUint8Array\n\n readonly version = '1.0.0' as const\n readonly name = 'Keypair Wallet' as const\n readonly icon =\n 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48L3N2Zz4=' as const\n\n constructor(secretKeyBase58: string) {\n if (!secretKeyBase58) {\n throw new Error('Private key is required')\n }\n\n const base58Codec = getBase58Codec()\n let encoded: ReadonlyUint8Array\n try {\n encoded = base58Codec.encode(secretKeyBase58)\n } catch {\n throw new Error('Invalid private key format')\n }\n\n if (encoded.length !== 64) {\n throw new Error('Invalid private key length. Expected 64 bytes.')\n }\n\n this._secretKeyBytes = encoded\n }\n\n // Wallet Standard interface properties\n get chains() {\n return ['solana:mainnet', 'solana:devnet', 'solana:testnet'] as const\n }\n\n get accounts(): readonly WalletAccount[] {\n return this._account ? [this._account] : []\n }\n\n get features(): SolanaSignTransactionFeature {\n return {\n [SolanaSignTransaction]: {\n version: '1.0.0' as const,\n supportedTransactionVersions: ['legacy', 0] as const,\n signTransaction: this._signTransactionFeature.bind(this),\n },\n }\n }\n\n async connect(): Promise<void> {\n this._signer = await createKeyPairSignerFromBytes(this._secretKeyBytes)\n\n const publicKeyBytes = new Uint8Array(\n await crypto.subtle.exportKey('raw', this._signer.keyPair.publicKey)\n )\n\n this._account = {\n address: this._signer.address,\n publicKey: publicKeyBytes,\n chains: this.chains,\n features: [SolanaSignTransaction],\n }\n }\n\n async disconnect(): Promise<void> {\n this._signer = undefined\n this._account = undefined\n }\n\n // Wallet Standard feature implementations\n private async _signTransactionFeature(\n ...inputs: readonly SolanaSignTransactionInput[]\n ): Promise<readonly SolanaSignTransactionOutput[]> {\n if (!this._signer) {\n throw new Error('Wallet is not connected')\n }\n\n const results: SolanaSignTransactionOutput[] = []\n\n for (const input of inputs) {\n const transaction = getTransactionCodec().decode(input.transaction)\n\n assertIsTransactionWithinSizeLimit(transaction)\n assertIsTransactionWithBlockhashLifetime(transaction)\n\n const signatureDictionaries = await this._signer.signTransactions([\n transaction,\n ])\n\n if (\n signatureDictionaries.length === 0 ||\n !signatureDictionaries[0][this._signer.address]\n ) {\n throw new Error('Failed to sign transaction')\n }\n\n const signedTransaction = getBase64EncodedWireTransaction(transaction)\n\n results.push({\n signedTransaction: base64ToUint8Array(signedTransaction),\n })\n }\n\n return results\n }\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAa,uBAAb,MAAoD;;;;;CAKlD;CACA;CACA;CAEA,UAAmB;CACnB,OAAgB;CAChB,OACE;CAEF,YAAY,iBAAyB;EACnC,IAAI,CAAC,iBACH,MAAM,IAAI,MAAM,yBAAyB;EAG3C,MAAM,eAAA,GAAcA,YAAAA,eAAAA,CAAe;EACnC,IAAI;EACJ,IAAI;GACF,UAAU,YAAY,OAAO,eAAe;EAC9C,QAAQ;GACN,MAAM,IAAI,MAAM,4BAA4B;EAC9C;EAEA,IAAI,QAAQ,WAAW,IACrB,MAAM,IAAI,MAAM,gDAAgD;EAGlE,KAAK,kBAAkB;CACzB;CAGA,IAAI,SAAS;EACX,OAAO;GAAC;GAAkB;GAAiB;EAAgB;CAC7D;CAEA,IAAI,WAAqC;EACvC,OAAO,KAAK,WAAW,CAAC,KAAK,QAAQ,IAAI,CAAC;CAC5C;CAEA,IAAI,WAAyC;EAC3C,OAAO,GACJC,iCAAAA,wBAAwB;GACvB,SAAS;GACT,8BAA8B,CAAC,UAAU,CAAC;GAC1C,iBAAiB,KAAK,wBAAwB,KAAK,IAAI;EACzD,EACF;CACF;CAEA,MAAM,UAAyB;EAC7B,KAAK,UAAU,OAAA,GAAMC,YAAAA,6BAAAA,CAA6B,KAAK,eAAe;EAEtE,MAAM,iBAAiB,IAAI,WACzB,MAAM,OAAO,OAAO,UAAU,OAAO,KAAK,QAAQ,QAAQ,SAAS,CACrE;EAEA,KAAK,WAAW;GACd,SAAS,KAAK,QAAQ;GACtB,WAAW;GACX,QAAQ,KAAK;GACb,UAAU,CAACD,iCAAAA,qBAAqB;EAClC;CACF;CAEA,MAAM,aAA4B;EAChC,KAAK,UAAU,KAAA;EACf,KAAK,WAAW,KAAA;CAClB;CAGA,MAAc,wBACZ,GAAG,QAC8C;EACjD,IAAI,CAAC,KAAK,SACR,MAAM,IAAI,MAAM,yBAAyB;EAG3C,MAAM,UAAyC,CAAC;EAEhD,KAAK,MAAM,SAAS,QAAQ;GAC1B,MAAM,eAAA,GAAcE,YAAAA,oBAAAA,CAAoB,CAAC,CAAC,OAAO,MAAM,WAAW;GAElE,CAAA,GAAA,YAAA,mCAAA,CAAmC,WAAW;GAC9C,CAAA,GAAA,YAAA,yCAAA,CAAyC,WAAW;GAEpD,MAAM,wBAAwB,MAAM,KAAK,QAAQ,iBAAiB,CAChE,WACF,CAAC;GAED,IACE,sBAAsB,WAAW,KACjC,CAAC,sBAAsB,EAAE,CAAC,KAAK,QAAQ,UAEvC,MAAM,IAAI,MAAM,4BAA4B;GAG9C,MAAM,qBAAA,GAAoBC,YAAAA,gCAAAA,CAAgC,WAAW;GAErE,QAAQ,KAAK,EACX,mBAAmBC,iCAAAA,mBAAmB,iBAAiB,EACzD,CAAC;EACH;EAEA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"KeypairWalletAdapter.js","names":["getBase58Codec","SolanaSignTransaction","createKeyPairSignerFromBytes","getTransactionCodec","getBase64EncodedWireTransaction","base64ToUint8Array"],"sources":["../../../src/utils/KeypairWalletAdapter.ts"],"sourcesContent":["import {\n assertIsTransactionWithinSizeLimit,\n createKeyPairSignerFromBytes,\n getBase58Codec,\n getBase64EncodedWireTransaction,\n getTransactionCodec,\n type KeyPairSigner,\n type ReadonlyUint8Array,\n} from '@solana/kit'\nimport {\n SolanaSignTransaction,\n type SolanaSignTransactionFeature,\n type SolanaSignTransactionInput,\n type SolanaSignTransactionOutput,\n} from '@solana/wallet-standard-features'\nimport type { Wallet, WalletAccount } from '@wallet-standard/base'\nimport { base64ToUint8Array } from './base64ToUint8Array.js'\n\n/**\n * This keypair wallet adapter is unsafe to use on the frontend and is only included to provide an easy way for applications to test\n * Wallet Adapter without using a third-party wallet.\n */\nexport class KeypairWalletAdapter implements Wallet {\n /**\n * Storing a keypair locally like this is not safe because any application using this adapter could retrieve the\n * secret key, and because the keypair will be lost any time the wallet is disconnected or the window is refreshed.\n */\n private _signer: KeyPairSigner | undefined\n private _account: WalletAccount | undefined\n private readonly _secretKeyBytes: ReadonlyUint8Array\n\n readonly version = '1.0.0' as const\n readonly name = 'Keypair Wallet' as const\n readonly icon =\n 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48L3N2Zz4=' as const\n\n constructor(secretKeyBase58: string) {\n if (!secretKeyBase58) {\n throw new Error('Private key is required')\n }\n\n const base58Codec = getBase58Codec()\n let encoded: ReadonlyUint8Array\n try {\n encoded = base58Codec.encode(secretKeyBase58)\n } catch {\n throw new Error('Invalid private key format')\n }\n\n if (encoded.length !== 64) {\n throw new Error('Invalid private key length. Expected 64 bytes.')\n }\n\n this._secretKeyBytes = encoded\n }\n\n // Wallet Standard interface properties\n get chains() {\n return ['solana:mainnet', 'solana:devnet', 'solana:testnet'] as const\n }\n\n get accounts(): readonly WalletAccount[] {\n return this._account ? [this._account] : []\n }\n\n get features(): SolanaSignTransactionFeature {\n return {\n [SolanaSignTransaction]: {\n version: '1.0.0' as const,\n supportedTransactionVersions: ['legacy', 0] as const,\n signTransaction: this._signTransactionFeature.bind(this),\n },\n }\n }\n\n async connect(): Promise<void> {\n this._signer = await createKeyPairSignerFromBytes(this._secretKeyBytes)\n\n const publicKeyBytes = new Uint8Array(\n await crypto.subtle.exportKey('raw', this._signer.keyPair.publicKey)\n )\n\n this._account = {\n address: this._signer.address,\n publicKey: publicKeyBytes,\n chains: this.chains,\n features: [SolanaSignTransaction],\n }\n }\n\n async disconnect(): Promise<void> {\n this._signer = undefined\n this._account = undefined\n }\n\n // Wallet Standard feature implementations\n private async _signTransactionFeature(\n ...inputs: readonly SolanaSignTransactionInput[]\n ): Promise<readonly SolanaSignTransactionOutput[]> {\n if (!this._signer) {\n throw new Error('Wallet is not connected')\n }\n\n const results: SolanaSignTransactionOutput[] = []\n\n for (const input of inputs) {\n const transaction = getTransactionCodec().decode(input.transaction)\n\n assertIsTransactionWithinSizeLimit(transaction)\n\n // `assertIsTransactionWithBlockhashLifetime` is deliberately NOT called\n // here. It tests `'lifetimeConstraint' in transaction`, and no kit\n // decoder reconstructs that property - decoding wire bytes yields\n // `{ messageBytes, signatures }` alone, so the assert rejected every\n // transaction a wallet is ever handed. Signing does not need it either:\n // `partiallySignTransaction` signs `messageBytes` and never reads the\n // lifetime. The blockhash still travels inside `messageBytes`, where\n // `getTransactionLifetime` reads it for the confirmation deadline.\n // Cast because `signTransactions` types its argument as carrying a\n // lifetime, while the runtime path - `partiallySignTransaction` - reads\n // only `messageBytes`. A decoded transaction never has the property, so\n // without this the type demands something no decoder can produce.\n const [signatureDictionary] = await this._signer.signTransactions([\n transaction as Parameters<\n typeof this._signer.signTransactions\n >[0][number],\n ])\n\n const signature = signatureDictionary?.[this._signer.address]\n if (!signature) {\n throw new Error('Failed to sign transaction')\n }\n\n // The signature has to be merged back in. `partiallySignTransaction`\n // returns a new frozen object rather than mutating its argument, so\n // encoding `transaction` here shipped the unsigned original and threw\n // the signature away - the transaction then failed on chain for a\n // missing signature, far from the code that dropped it.\n //\n // The cast mirrors the one above: the wire format is `messageBytes`\n // plus `signatures`, and the encoder reads nothing else - the lifetime\n // already travels inside `messageBytes`.\n const signedTransaction = getBase64EncodedWireTransaction({\n ...transaction,\n signatures: {\n ...transaction.signatures,\n [this._signer.address]: signature,\n },\n } as Parameters<typeof getBase64EncodedWireTransaction>[0])\n\n results.push({\n signedTransaction: base64ToUint8Array(signedTransaction),\n })\n }\n\n return results\n }\n}\n"],"mappings":";;;;;;;;;AAsBA,IAAa,uBAAb,MAAoD;;;;;CAKlD;CACA;CACA;CAEA,UAAmB;CACnB,OAAgB;CAChB,OACE;CAEF,YAAY,iBAAyB;EACnC,IAAI,CAAC,iBACH,MAAM,IAAI,MAAM,yBAAyB;EAG3C,MAAM,eAAA,GAAcA,YAAAA,eAAAA,CAAe;EACnC,IAAI;EACJ,IAAI;GACF,UAAU,YAAY,OAAO,eAAe;EAC9C,QAAQ;GACN,MAAM,IAAI,MAAM,4BAA4B;EAC9C;EAEA,IAAI,QAAQ,WAAW,IACrB,MAAM,IAAI,MAAM,gDAAgD;EAGlE,KAAK,kBAAkB;CACzB;CAGA,IAAI,SAAS;EACX,OAAO;GAAC;GAAkB;GAAiB;EAAgB;CAC7D;CAEA,IAAI,WAAqC;EACvC,OAAO,KAAK,WAAW,CAAC,KAAK,QAAQ,IAAI,CAAC;CAC5C;CAEA,IAAI,WAAyC;EAC3C,OAAO,GACJC,iCAAAA,wBAAwB;GACvB,SAAS;GACT,8BAA8B,CAAC,UAAU,CAAC;GAC1C,iBAAiB,KAAK,wBAAwB,KAAK,IAAI;EACzD,EACF;CACF;CAEA,MAAM,UAAyB;EAC7B,KAAK,UAAU,OAAA,GAAMC,YAAAA,6BAAAA,CAA6B,KAAK,eAAe;EAEtE,MAAM,iBAAiB,IAAI,WACzB,MAAM,OAAO,OAAO,UAAU,OAAO,KAAK,QAAQ,QAAQ,SAAS,CACrE;EAEA,KAAK,WAAW;GACd,SAAS,KAAK,QAAQ;GACtB,WAAW;GACX,QAAQ,KAAK;GACb,UAAU,CAACD,iCAAAA,qBAAqB;EAClC;CACF;CAEA,MAAM,aAA4B;EAChC,KAAK,UAAU,KAAA;EACf,KAAK,WAAW,KAAA;CAClB;CAGA,MAAc,wBACZ,GAAG,QAC8C;EACjD,IAAI,CAAC,KAAK,SACR,MAAM,IAAI,MAAM,yBAAyB;EAG3C,MAAM,UAAyC,CAAC;EAEhD,KAAK,MAAM,SAAS,QAAQ;GAC1B,MAAM,eAAA,GAAcE,YAAAA,oBAAAA,CAAoB,CAAC,CAAC,OAAO,MAAM,WAAW;GAElE,CAAA,GAAA,YAAA,mCAAA,CAAmC,WAAW;GAc9C,MAAM,CAAC,uBAAuB,MAAM,KAAK,QAAQ,iBAAiB,CAChE,WAGF,CAAC;GAED,MAAM,YAAY,sBAAsB,KAAK,QAAQ;GACrD,IAAI,CAAC,WACH,MAAM,IAAI,MAAM,4BAA4B;GAY9C,MAAM,qBAAA,GAAoBC,YAAAA,gCAAAA,CAAgC;IACxD,GAAG;IACH,YAAY;KACV,GAAG,YAAY;MACd,KAAK,QAAQ,UAAU;IAC1B;GACF,CAA0D;GAE1D,QAAQ,KAAK,EACX,mBAAmBC,iCAAAA,mBAAmB,iBAAiB,EACzD,CAAC;EACH;EAEA,OAAO;CACT;AACF"}
@@ -0,0 +1,21 @@
1
+ import { Blockhash, Transaction } from "@solana/kit";
2
+ //#region src/utils/getTransactionLifetime.d.ts
3
+ type TransactionLifetime = {
4
+ kind: "blockhash";
5
+ blockhash: Blockhash;
6
+ } | {
7
+ kind: "nonce";
8
+ } | {
9
+ kind: "unknown";
10
+ };
11
+ /**
12
+ * Decoding yields `{ messageBytes, signatures }` alone, so the lifetime is
13
+ * recovered from the compiled message.
14
+ *
15
+ * Never throws: anything undecodable yields `unknown`, degrading confirmation
16
+ * to the wall-clock ceiling rather than aborting the send.
17
+ */
18
+ declare function getTransactionLifetime(transaction: Transaction): Promise<TransactionLifetime>;
19
+ //#endregion
20
+ export { TransactionLifetime, getTransactionLifetime };
21
+ //# sourceMappingURL=getTransactionLifetime.d.ts.map
@@ -0,0 +1,28 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _solana_kit = require("@solana/kit");
3
+ //#region src/utils/getTransactionLifetime.ts
4
+ const decoder = (0, _solana_kit.getCompiledTransactionMessageDecoder)();
5
+ /**
6
+ * Decoding yields `{ messageBytes, signatures }` alone, so the lifetime is
7
+ * recovered from the compiled message.
8
+ *
9
+ * Never throws: anything undecodable yields `unknown`, degrading confirmation
10
+ * to the wall-clock ceiling rather than aborting the send.
11
+ */
12
+ async function getTransactionLifetime(transaction) {
13
+ try {
14
+ const compiledMessage = decoder.decode(transaction.messageBytes);
15
+ const constraint = await (0, _solana_kit.getTransactionLifetimeConstraintFromCompiledTransactionMessage)(compiledMessage);
16
+ if ("blockhash" in constraint) return {
17
+ kind: "blockhash",
18
+ blockhash: constraint.blockhash
19
+ };
20
+ return { kind: "nonce" };
21
+ } catch (_) {
22
+ return { kind: "unknown" };
23
+ }
24
+ }
25
+ //#endregion
26
+ exports.getTransactionLifetime = getTransactionLifetime;
27
+
28
+ //# sourceMappingURL=getTransactionLifetime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTransactionLifetime.js","names":["getCompiledTransactionMessageDecoder","getTransactionLifetimeConstraintFromCompiledTransactionMessage"],"sources":["../../../src/utils/getTransactionLifetime.ts"],"sourcesContent":["import {\n type Blockhash,\n getCompiledTransactionMessageDecoder,\n getTransactionLifetimeConstraintFromCompiledTransactionMessage,\n type Transaction,\n} from '@solana/kit'\n\nexport type TransactionLifetime =\n | { kind: 'blockhash'; blockhash: Blockhash }\n | { kind: 'nonce' }\n | { kind: 'unknown' }\n\nconst decoder = getCompiledTransactionMessageDecoder()\n\n/**\n * Decoding yields `{ messageBytes, signatures }` alone, so the lifetime is\n * recovered from the compiled message.\n *\n * Never throws: anything undecodable yields `unknown`, degrading confirmation\n * to the wall-clock ceiling rather than aborting the send.\n */\nexport async function getTransactionLifetime(\n transaction: Transaction\n): Promise<TransactionLifetime> {\n try {\n const compiledMessage = decoder.decode(transaction.messageBytes)\n const constraint =\n await getTransactionLifetimeConstraintFromCompiledTransactionMessage(\n compiledMessage\n )\n if ('blockhash' in constraint) {\n return { kind: 'blockhash', blockhash: constraint.blockhash }\n }\n return { kind: 'nonce' }\n } catch (_) {\n return { kind: 'unknown' }\n }\n}\n"],"mappings":";;;AAYA,MAAM,WAAA,GAAUA,YAAAA,qCAAAA,CAAqC;;;;;;;;AASrD,eAAsB,uBACpB,aAC8B;CAC9B,IAAI;EACF,MAAM,kBAAkB,QAAQ,OAAO,YAAY,YAAY;EAC/D,MAAM,aACJ,OAAA,GAAMC,YAAAA,+DAAAA,CACJ,eACF;EACF,IAAI,eAAe,YACjB,OAAO;GAAE,MAAM;GAAa,WAAW,WAAW;EAAU;EAE9D,OAAO,EAAE,MAAM,QAAQ;CACzB,SAAS,GAAG;EACV,OAAO,EAAE,MAAM,UAAU;CAC3B;AACF"}
@@ -1,6 +1,6 @@
1
1
  //#region src/version.d.ts
2
2
  declare const name = "@lifi/sdk-provider-solana";
3
- declare const version = "4.0.6";
3
+ declare const version = "4.1.0";
4
4
  //#endregion
5
5
  export { name, version };
6
6
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/version.ts
3
3
  const name = "@lifi/sdk-provider-solana";
4
- const version = "4.0.6";
4
+ const version = "4.1.0";
5
5
  //#endregion
6
6
  exports.name = name;
7
7
  exports.version = version;
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-solana'\nexport const version = '4.0.6'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-solana'\nexport const version = '4.1.0'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
@@ -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 { Commitment, Signature, Transaction, TransactionError as TransactionError$1 } from "@solana/kit";
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$1 | null;
8
- confirmationStatus: Commitment | null;
9
- status: Readonly<{
10
- Err: TransactionError$1;
11
- }> | Readonly<{
12
- Ok: null;
13
- }>;
14
- };
15
- type BundleResult = {
16
- bundleId: string;
17
- txSignatures: Signature[];
18
- signatureResults: (SignatureStatus | null)[];
19
- };
20
6
  /**
21
- * Send and confirm a bundle of transactions using Jito.
22
- * Automatically selects a Jito-enabled RPC connection and polls for confirmation
23
- * across multiple Jito RPCs in parallel.
24
- * @param client - The SDK client.
25
- * @param signedTransactions - Array of signed transactions to bundle.
26
- * @returns BundleResult containing Bundle ID, transaction signatures, and confirmation results.
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[]): Promise<BundleResult>;
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 { BundleResult, sendAndConfirmBundle };
23
+ export { sendAndConfirmBundle };
31
24
  //# sourceMappingURL=sendAndConfirmBundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendAndConfirmBundle.d.ts","names":[],"sources":["../../../src/actions/sendAndConfirmBundle.ts"],"mappings":";;;KAWK;EACH;EACA;EACA,KAAK;EACL,oBAAoB;EACpB,QAAQ;IAAW,KAAK;OAAsB;IAAW;;;KAG/C;EACV;EACA,cAAc;EACd,mBAAmB;;;;;;;;;;iBAaC,qBACpB,QAAQ,WACR,oBAAoB,gBACnB,QAAQ"}
1
+ {"version":3,"file":"sendAndConfirmBundle.d.ts","names":[],"sources":["../../../src/actions/sendAndConfirmBundle.ts"],"mappings":";;;;;;;;;;;;;;;;;iBAuBsB,qBACpB,QAAQ,WACR,oBAAoB,eACpB;;EAEE;IAED,QAAQ,WAAW"}
@@ -1,64 +1,43 @@
1
1
  import { getJitoRpcs } from "../rpc/registry.js";
2
- import { sleep } from "@lifi/sdk";
2
+ import { BRANCH_TIMEOUT_MS } from "../confirmation/createConfirmationDeadline.js";
3
+ import { confirmBundle } from "../confirmation/confirmBundle.js";
4
+ import { raceRpcs } from "../confirmation/raceRpcs.js";
5
+ import { getTransactionLifetime } from "../utils/getTransactionLifetime.js";
6
+ import { LiFiErrorCode, RPCError } from "@lifi/sdk";
3
7
  import { getBase64EncodedWireTransaction } from "@solana/kit";
4
8
  //#region src/actions/sendAndConfirmBundle.ts
5
- const NULL_BUNDLE_RESULT = /* @__PURE__ */ new Error("Bundle was not confirmed by this RPC");
6
9
  /**
7
- * Send and confirm a bundle of transactions using Jito.
8
- * Automatically selects a Jito-enabled RPC connection and polls for confirmation
9
- * across multiple Jito RPCs in parallel.
10
- * @param client - The SDK client.
11
- * @param signedTransactions - Array of signed transactions to bundle.
12
- * @returns BundleResult containing Bundle ID, transaction signatures, and confirmation results.
10
+ * Sends a Jito bundle to every Jito-capable RPC and returns as soon as one of
11
+ * them confirms it.
12
+ *
13
+ * The deadline receives the lifetime of *every* signed transaction, not just
14
+ * the first: a bundle is an array of independently built backend transactions
15
+ * and they may not share a blockhash.
16
+ *
17
+ * `sendBundle` is handed to `confirmBundle` rather than awaited here, so the
18
+ * deadline starts on the same clock as `BRANCH_TIMEOUT_MS` instead of after
19
+ * the submission returns.
13
20
  */
14
- async function sendAndConfirmBundle(client, signedTransactions) {
15
- const jitoRpcs = await getJitoRpcs(client);
16
- if (jitoRpcs.length === 0) throw new Error("No Jito-enabled RPC connection available for bundle submission");
17
- const serializedTransactions = signedTransactions.map((tx) => getBase64EncodedWireTransaction(tx));
18
- const abortController = new AbortController();
19
- const confirmPromises = jitoRpcs.map(async (jitoRpc) => {
21
+ async function sendAndConfirmBundle(client, signedTransactions, options) {
22
+ const { rpcs: jitoRpcs, unreachable } = await getJitoRpcs(client);
23
+ if (jitoRpcs.length === 0) throw new RPCError(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.");
24
+ let broadcastReported = false;
25
+ const reportBroadcast = () => {
26
+ if (broadcastReported) return;
20
27
  try {
21
- let bundleId;
22
- try {
23
- bundleId = await jitoRpc.sendBundle(serializedTransactions).send();
24
- } catch (_) {
25
- return null;
26
- }
27
- const [{ value: blockhashResult }, initialBlockHeight] = await Promise.all([jitoRpc.getLatestBlockhash({ commitment: "confirmed" }).send(), jitoRpc.getBlockHeight({ commitment: "confirmed" }).send()]);
28
- let currentBlockHeight = initialBlockHeight;
29
- while (currentBlockHeight < blockhashResult.lastValidBlockHeight && !abortController.signal.aborted) {
30
- const bundleStatus = (await jitoRpc.getBundleStatuses([bundleId]).send()).value[0];
31
- if (bundleStatus && (bundleStatus.confirmation_status === "confirmed" || bundleStatus.confirmation_status === "finalized")) {
32
- const txSignatures = bundleStatus.transactions;
33
- const sigResponse = await jitoRpc.getSignatureStatuses(txSignatures).send();
34
- if (!sigResponse?.value || !Array.isArray(sigResponse.value)) {
35
- await sleep(400);
36
- continue;
37
- }
38
- abortController.abort();
39
- return {
40
- bundleId,
41
- txSignatures,
42
- signatureResults: sigResponse.value
43
- };
44
- }
45
- await sleep(400);
46
- if (!abortController.signal.aborted) currentBlockHeight = await jitoRpc.getBlockHeight({ commitment: "confirmed" }).send();
47
- }
48
- return null;
49
- } catch (error) {
50
- if (abortController.signal.aborted) return null;
51
- throw error;
52
- }
53
- });
54
- const result = await Promise.any(confirmPromises.map(async (promise) => {
55
- const bundleResult = await promise;
56
- if (!bundleResult) throw NULL_BUNDLE_RESULT;
57
- return bundleResult;
58
- })).catch(() => null);
59
- if (!abortController.signal.aborted) abortController.abort();
60
- if (!result) throw new Error("Failed to send and confirm bundle");
61
- return result;
28
+ options?.onBroadcast?.();
29
+ broadcastReported = true;
30
+ } catch (_) {}
31
+ };
32
+ const serializedTransactions = signedTransactions.map((transaction) => getBase64EncodedWireTransaction(transaction));
33
+ const lifetimes = await Promise.all(signedTransactions.map((transaction) => getTransactionLifetime(transaction)));
34
+ return raceRpcs(jitoRpcs, (rpc, signal) => confirmBundle({
35
+ rpc,
36
+ signal,
37
+ lifetimes,
38
+ send: () => rpc.sendBundle(serializedTransactions).send({ abortSignal: signal }),
39
+ onBroadcast: reportBroadcast
40
+ }), { timeoutMs: BRANCH_TIMEOUT_MS });
62
41
  }
63
42
  //#endregion
64
43
  export { sendAndConfirmBundle };
@@ -1 +1 @@
1
- {"version":3,"file":"sendAndConfirmBundle.js","names":[],"sources":["../../../src/actions/sendAndConfirmBundle.ts"],"sourcesContent":["import { type SDKClient, sleep } from '@lifi/sdk'\nimport {\n type Commitment,\n getBase64EncodedWireTransaction,\n type Signature,\n type Transaction,\n type TransactionError,\n} from '@solana/kit'\n\nimport { getJitoRpcs } from '../rpc/registry.js'\n\ntype SignatureStatus = {\n slot: bigint\n confirmations: bigint | null\n err: TransactionError | null\n confirmationStatus: Commitment | null\n status: Readonly<{ Err: TransactionError }> | Readonly<{ Ok: null }>\n}\n\nexport type BundleResult = {\n bundleId: string\n txSignatures: Signature[]\n signatureResults: (SignatureStatus | null)[]\n}\n\nconst NULL_BUNDLE_RESULT = new Error('Bundle was not confirmed by this RPC')\n\n/**\n * Send and confirm a bundle of transactions using Jito.\n * Automatically selects a Jito-enabled RPC connection and polls for confirmation\n * across multiple Jito RPCs in parallel.\n * @param client - The SDK client.\n * @param signedTransactions - Array of signed transactions to bundle.\n * @returns BundleResult containing Bundle ID, transaction signatures, and confirmation results.\n */\nexport async function sendAndConfirmBundle(\n client: SDKClient,\n signedTransactions: Transaction[]\n): Promise<BundleResult> {\n const jitoRpcs = await getJitoRpcs(client)\n\n if (jitoRpcs.length === 0) {\n throw new Error(\n 'No Jito-enabled RPC connection available for bundle submission'\n )\n }\n\n // Serialize transactions to base64\n const serializedTransactions = signedTransactions.map((tx) =>\n getBase64EncodedWireTransaction(tx)\n )\n\n const abortController = new AbortController()\n\n const confirmPromises = jitoRpcs.map(async (jitoRpc) => {\n try {\n // Send bundle to Jito\n let bundleId: string\n try {\n bundleId = await jitoRpc.sendBundle(serializedTransactions).send()\n } catch (_) {\n return null\n }\n\n const [{ value: blockhashResult }, initialBlockHeight] =\n await Promise.all([\n jitoRpc\n .getLatestBlockhash({\n commitment: 'confirmed',\n })\n .send(),\n jitoRpc\n .getBlockHeight({\n commitment: 'confirmed',\n })\n .send(),\n ])\n\n let currentBlockHeight = initialBlockHeight\n\n while (\n currentBlockHeight < blockhashResult.lastValidBlockHeight &&\n !abortController.signal.aborted\n ) {\n const statusResponse = await jitoRpc\n .getBundleStatuses([bundleId])\n .send()\n\n const bundleStatus = statusResponse.value[0]\n\n // Check if bundle is confirmed or finalized\n if (\n bundleStatus &&\n (bundleStatus.confirmation_status === 'confirmed' ||\n bundleStatus.confirmation_status === 'finalized')\n ) {\n // Bundle confirmed! Extract transaction signatures from bundle status\n const txSignatures = bundleStatus.transactions\n\n // Fetch individual signature results from Jito RPC\n const sigResponse = await jitoRpc\n .getSignatureStatuses(txSignatures)\n .send()\n\n if (!sigResponse?.value || !Array.isArray(sigResponse.value)) {\n // Keep polling if can't find signature results\n await sleep(400)\n continue\n }\n\n // Immediately abort all other connections when we find a result\n abortController.abort()\n return {\n bundleId,\n txSignatures,\n signatureResults: sigResponse.value,\n }\n }\n\n await sleep(400)\n if (!abortController.signal.aborted) {\n currentBlockHeight = await jitoRpc\n .getBlockHeight({\n commitment: 'confirmed',\n })\n .send()\n }\n }\n\n return null\n } catch (error) {\n if (abortController.signal.aborted) {\n return null // Don't treat abortion as an error\n }\n throw error\n }\n })\n\n // Wait for first successful confirmation\n const result = await Promise.any(\n confirmPromises.map(async (promise) => {\n const bundleResult = await promise\n if (!bundleResult) {\n throw NULL_BUNDLE_RESULT\n }\n return bundleResult\n })\n ).catch(() => null)\n\n if (!abortController.signal.aborted) {\n abortController.abort()\n }\n\n if (!result) {\n throw new Error('Failed to send and confirm bundle')\n }\n\n return result\n}\n"],"mappings":";;;;AAyBA,MAAM,qCAAqB,IAAI,MAAM,sCAAsC;;;;;;;;;AAU3E,eAAsB,qBACpB,QACA,oBACuB;CACvB,MAAM,WAAW,MAAM,YAAY,MAAM;CAEzC,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,MACR,gEACF;CAIF,MAAM,yBAAyB,mBAAmB,KAAK,OACrD,gCAAgC,EAAE,CACpC;CAEA,MAAM,kBAAkB,IAAI,gBAAgB;CAE5C,MAAM,kBAAkB,SAAS,IAAI,OAAO,YAAY;EACtD,IAAI;GAEF,IAAI;GACJ,IAAI;IACF,WAAW,MAAM,QAAQ,WAAW,sBAAsB,CAAC,CAAC,KAAK;GACnE,SAAS,GAAG;IACV,OAAO;GACT;GAEA,MAAM,CAAC,EAAE,OAAO,mBAAmB,sBACjC,MAAM,QAAQ,IAAI,CAChB,QACG,mBAAmB,EAClB,YAAY,YACd,CAAC,CAAC,CACD,KAAK,GACR,QACG,eAAe,EACd,YAAY,YACd,CAAC,CAAC,CACD,KAAK,CACV,CAAC;GAEH,IAAI,qBAAqB;GAEzB,OACE,qBAAqB,gBAAgB,wBACrC,CAAC,gBAAgB,OAAO,SACxB;IAKA,MAAM,gBAAe,MAJQ,QAC1B,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAC7B,KAAK,EAAA,CAE4B,MAAM;IAG1C,IACE,iBACC,aAAa,wBAAwB,eACpC,aAAa,wBAAwB,cACvC;KAEA,MAAM,eAAe,aAAa;KAGlC,MAAM,cAAc,MAAM,QACvB,qBAAqB,YAAY,CAAC,CAClC,KAAK;KAER,IAAI,CAAC,aAAa,SAAS,CAAC,MAAM,QAAQ,YAAY,KAAK,GAAG;MAE5D,MAAM,MAAM,GAAG;MACf;KACF;KAGA,gBAAgB,MAAM;KACtB,OAAO;MACL;MACA;MACA,kBAAkB,YAAY;KAChC;IACF;IAEA,MAAM,MAAM,GAAG;IACf,IAAI,CAAC,gBAAgB,OAAO,SAC1B,qBAAqB,MAAM,QACxB,eAAe,EACd,YAAY,YACd,CAAC,CAAC,CACD,KAAK;GAEZ;GAEA,OAAO;EACT,SAAS,OAAO;GACd,IAAI,gBAAgB,OAAO,SACzB,OAAO;GAET,MAAM;EACR;CACF,CAAC;CAGD,MAAM,SAAS,MAAM,QAAQ,IAC3B,gBAAgB,IAAI,OAAO,YAAY;EACrC,MAAM,eAAe,MAAM;EAC3B,IAAI,CAAC,cACH,MAAM;EAER,OAAO;CACT,CAAC,CACH,CAAC,CAAC,YAAY,IAAI;CAElB,IAAI,CAAC,gBAAgB,OAAO,SAC1B,gBAAgB,MAAM;CAGxB,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,mCAAmC;CAGrD,OAAO;AACT"}
1
+ {"version":3,"file":"sendAndConfirmBundle.js","names":[],"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,MAAM,YAAY,MAAM;CAYhE,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,SACR,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,gBACrD,gCAAgC,WAAW,CAC7C;CAEA,MAAM,YAAY,MAAM,QAAQ,IAC9B,mBAAmB,KAAK,gBAAgB,uBAAuB,WAAW,CAAC,CAC7E;CAEA,OAAO,SACL,WACC,KAAK,WACJ,cAAc;EACZ;EACA;EACA;EACA,YACE,IAAI,WAAW,sBAAsB,CAAC,CAAC,KAAK,EAAE,aAAa,OAAO,CAAC;EACrE,aAAa;CACf,CAAC,GACH,EAAE,WAAW,kBAAkB,CACjC;AACF"}