@lifi/sdk-provider-solana 0.0.0-preview-f5cf9f8

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 (223) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +201 -0
  3. package/README.md +79 -0
  4. package/dist/cjs/SolanaProvider.d.ts +7 -0
  5. package/dist/cjs/SolanaProvider.js +34 -0
  6. package/dist/cjs/SolanaProvider.js.map +1 -0
  7. package/dist/cjs/actions/getSNSAddress.d.ts +5 -0
  8. package/dist/cjs/actions/getSNSAddress.js +20 -0
  9. package/dist/cjs/actions/getSNSAddress.js.map +1 -0
  10. package/dist/cjs/actions/getSolanaBalance.d.ts +7 -0
  11. package/dist/cjs/actions/getSolanaBalance.js +75 -0
  12. package/dist/cjs/actions/getSolanaBalance.js.map +1 -0
  13. package/dist/cjs/actions/resolveSolanaAddress.d.ts +5 -0
  14. package/dist/cjs/actions/resolveSolanaAddress.js +10 -0
  15. package/dist/cjs/actions/resolveSolanaAddress.js.map +1 -0
  16. package/dist/cjs/actions/sendAndConfirmBundle.d.ts +32 -0
  17. package/dist/cjs/actions/sendAndConfirmBundle.js +67 -0
  18. package/dist/cjs/actions/sendAndConfirmBundle.js.map +1 -0
  19. package/dist/cjs/actions/sendAndConfirmTransaction.d.ts +30 -0
  20. package/dist/cjs/actions/sendAndConfirmTransaction.js +76 -0
  21. package/dist/cjs/actions/sendAndConfirmTransaction.js.map +1 -0
  22. package/dist/cjs/core/SolanaStepExecutor.d.ts +17 -0
  23. package/dist/cjs/core/SolanaStepExecutor.js +49 -0
  24. package/dist/cjs/core/SolanaStepExecutor.js.map +1 -0
  25. package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.d.ts +10 -0
  26. package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js +34 -0
  27. package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -0
  28. package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.d.ts +10 -0
  29. package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js +37 -0
  30. package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js.map +1 -0
  31. package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.d.ts +10 -0
  32. package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js +45 -0
  33. package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -0
  34. package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.d.ts +10 -0
  35. package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.js +18 -0
  36. package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.js.map +1 -0
  37. package/dist/cjs/errors/parseSolanaErrors.d.ts +7 -0
  38. package/dist/cjs/errors/parseSolanaErrors.js +23 -0
  39. package/dist/cjs/errors/parseSolanaErrors.js.map +1 -0
  40. package/dist/cjs/index.d.ts +5 -0
  41. package/dist/cjs/index.js +14 -0
  42. package/dist/cjs/package.json +1 -0
  43. package/dist/cjs/rpc/jito/api/getBundleStatuses.d.ts +27 -0
  44. package/dist/cjs/rpc/jito/api/getBundleStatuses.js +0 -0
  45. package/dist/cjs/rpc/jito/api/getTipAccounts.d.ts +16 -0
  46. package/dist/cjs/rpc/jito/api/getTipAccounts.js +0 -0
  47. package/dist/cjs/rpc/jito/api/sendBundle.d.ts +23 -0
  48. package/dist/cjs/rpc/jito/api/sendBundle.js +0 -0
  49. package/dist/cjs/rpc/jito/api/simulateBundle.d.ts +57 -0
  50. package/dist/cjs/rpc/jito/api/simulateBundle.js +0 -0
  51. package/dist/cjs/rpc/jito/createJitoRpc.d.ts +14 -0
  52. package/dist/cjs/rpc/jito/createJitoRpc.js +23 -0
  53. package/dist/cjs/rpc/jito/createJitoRpc.js.map +1 -0
  54. package/dist/cjs/rpc/jito/types.d.ts +8 -0
  55. package/dist/cjs/rpc/jito/types.js +0 -0
  56. package/dist/cjs/rpc/registry.d.ts +21 -0
  57. package/dist/cjs/rpc/registry.js +56 -0
  58. package/dist/cjs/rpc/registry.js.map +1 -0
  59. package/dist/cjs/rpc/types.d.ts +9 -0
  60. package/dist/cjs/rpc/types.js +0 -0
  61. package/dist/cjs/rpc/utils.d.ts +67 -0
  62. package/dist/cjs/rpc/utils.js +84 -0
  63. package/dist/cjs/rpc/utils.js.map +1 -0
  64. package/dist/cjs/types.d.ts +28 -0
  65. package/dist/cjs/types.js +10 -0
  66. package/dist/cjs/types.js.map +1 -0
  67. package/dist/cjs/utils/KeypairWallet.unit.helpers.d.ts +8 -0
  68. package/dist/cjs/utils/KeypairWallet.unit.helpers.js +20 -0
  69. package/dist/cjs/utils/KeypairWallet.unit.helpers.js.map +1 -0
  70. package/dist/cjs/utils/KeypairWalletAdapter.d.ts +30 -0
  71. package/dist/cjs/utils/KeypairWalletAdapter.js +82 -0
  72. package/dist/cjs/utils/KeypairWalletAdapter.js.map +1 -0
  73. package/dist/cjs/utils/base64ToUint8Array.d.ts +5 -0
  74. package/dist/cjs/utils/base64ToUint8Array.js +13 -0
  75. package/dist/cjs/utils/base64ToUint8Array.js.map +1 -0
  76. package/dist/cjs/utils/getWalletFeature.d.ts +30 -0
  77. package/dist/cjs/utils/getWalletFeature.js +26 -0
  78. package/dist/cjs/utils/getWalletFeature.js.map +1 -0
  79. package/dist/cjs/utils/shouldUseJitoBundle.d.ts +8 -0
  80. package/dist/cjs/utils/shouldUseJitoBundle.js +12 -0
  81. package/dist/cjs/utils/shouldUseJitoBundle.js.map +1 -0
  82. package/dist/cjs/version.d.ts +6 -0
  83. package/dist/cjs/version.js +9 -0
  84. package/dist/cjs/version.js.map +1 -0
  85. package/dist/esm/SolanaProvider.d.ts +7 -0
  86. package/dist/esm/SolanaProvider.d.ts.map +1 -0
  87. package/dist/esm/SolanaProvider.js +33 -0
  88. package/dist/esm/SolanaProvider.js.map +1 -0
  89. package/dist/esm/actions/getSNSAddress.d.ts +5 -0
  90. package/dist/esm/actions/getSNSAddress.d.ts.map +1 -0
  91. package/dist/esm/actions/getSNSAddress.js +19 -0
  92. package/dist/esm/actions/getSNSAddress.js.map +1 -0
  93. package/dist/esm/actions/getSolanaBalance.d.ts +7 -0
  94. package/dist/esm/actions/getSolanaBalance.d.ts.map +1 -0
  95. package/dist/esm/actions/getSolanaBalance.js +74 -0
  96. package/dist/esm/actions/getSolanaBalance.js.map +1 -0
  97. package/dist/esm/actions/resolveSolanaAddress.d.ts +5 -0
  98. package/dist/esm/actions/resolveSolanaAddress.d.ts.map +1 -0
  99. package/dist/esm/actions/resolveSolanaAddress.js +9 -0
  100. package/dist/esm/actions/resolveSolanaAddress.js.map +1 -0
  101. package/dist/esm/actions/sendAndConfirmBundle.d.ts +32 -0
  102. package/dist/esm/actions/sendAndConfirmBundle.d.ts.map +1 -0
  103. package/dist/esm/actions/sendAndConfirmBundle.js +66 -0
  104. package/dist/esm/actions/sendAndConfirmBundle.js.map +1 -0
  105. package/dist/esm/actions/sendAndConfirmTransaction.d.ts +30 -0
  106. package/dist/esm/actions/sendAndConfirmTransaction.d.ts.map +1 -0
  107. package/dist/esm/actions/sendAndConfirmTransaction.js +75 -0
  108. package/dist/esm/actions/sendAndConfirmTransaction.js.map +1 -0
  109. package/dist/esm/core/SolanaStepExecutor.d.ts +17 -0
  110. package/dist/esm/core/SolanaStepExecutor.d.ts.map +1 -0
  111. package/dist/esm/core/SolanaStepExecutor.js +48 -0
  112. package/dist/esm/core/SolanaStepExecutor.js.map +1 -0
  113. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts +10 -0
  114. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts.map +1 -0
  115. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js +33 -0
  116. package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -0
  117. package/dist/esm/core/tasks/SolanaSignAndExecuteTask.d.ts +10 -0
  118. package/dist/esm/core/tasks/SolanaSignAndExecuteTask.d.ts.map +1 -0
  119. package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js +36 -0
  120. package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js.map +1 -0
  121. package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.d.ts +10 -0
  122. package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.d.ts.map +1 -0
  123. package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js +44 -0
  124. package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -0
  125. package/dist/esm/core/tasks/SolanaWaitForTransactionTask.d.ts +10 -0
  126. package/dist/esm/core/tasks/SolanaWaitForTransactionTask.d.ts.map +1 -0
  127. package/dist/esm/core/tasks/SolanaWaitForTransactionTask.js +17 -0
  128. package/dist/esm/core/tasks/SolanaWaitForTransactionTask.js.map +1 -0
  129. package/dist/esm/errors/parseSolanaErrors.d.ts +7 -0
  130. package/dist/esm/errors/parseSolanaErrors.d.ts.map +1 -0
  131. package/dist/esm/errors/parseSolanaErrors.js +22 -0
  132. package/dist/esm/errors/parseSolanaErrors.js.map +1 -0
  133. package/dist/esm/index.d.ts +5 -0
  134. package/dist/esm/index.js +5 -0
  135. package/dist/esm/package.json +1 -0
  136. package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts +27 -0
  137. package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts.map +1 -0
  138. package/dist/esm/rpc/jito/api/getBundleStatuses.js +1 -0
  139. package/dist/esm/rpc/jito/api/getTipAccounts.d.ts +16 -0
  140. package/dist/esm/rpc/jito/api/getTipAccounts.d.ts.map +1 -0
  141. package/dist/esm/rpc/jito/api/getTipAccounts.js +1 -0
  142. package/dist/esm/rpc/jito/api/sendBundle.d.ts +23 -0
  143. package/dist/esm/rpc/jito/api/sendBundle.d.ts.map +1 -0
  144. package/dist/esm/rpc/jito/api/sendBundle.js +1 -0
  145. package/dist/esm/rpc/jito/api/simulateBundle.d.ts +57 -0
  146. package/dist/esm/rpc/jito/api/simulateBundle.d.ts.map +1 -0
  147. package/dist/esm/rpc/jito/api/simulateBundle.js +1 -0
  148. package/dist/esm/rpc/jito/createJitoRpc.d.ts +14 -0
  149. package/dist/esm/rpc/jito/createJitoRpc.d.ts.map +1 -0
  150. package/dist/esm/rpc/jito/createJitoRpc.js +21 -0
  151. package/dist/esm/rpc/jito/createJitoRpc.js.map +1 -0
  152. package/dist/esm/rpc/jito/types.d.ts +8 -0
  153. package/dist/esm/rpc/jito/types.d.ts.map +1 -0
  154. package/dist/esm/rpc/jito/types.js +1 -0
  155. package/dist/esm/rpc/registry.d.ts +21 -0
  156. package/dist/esm/rpc/registry.d.ts.map +1 -0
  157. package/dist/esm/rpc/registry.js +53 -0
  158. package/dist/esm/rpc/registry.js.map +1 -0
  159. package/dist/esm/rpc/types.d.ts +9 -0
  160. package/dist/esm/rpc/types.d.ts.map +1 -0
  161. package/dist/esm/rpc/types.js +1 -0
  162. package/dist/esm/rpc/utils.d.ts +67 -0
  163. package/dist/esm/rpc/utils.d.ts.map +1 -0
  164. package/dist/esm/rpc/utils.js +81 -0
  165. package/dist/esm/rpc/utils.js.map +1 -0
  166. package/dist/esm/types.d.ts +28 -0
  167. package/dist/esm/types.d.ts.map +1 -0
  168. package/dist/esm/types.js +9 -0
  169. package/dist/esm/types.js.map +1 -0
  170. package/dist/esm/utils/KeypairWallet.unit.helpers.d.ts +8 -0
  171. package/dist/esm/utils/KeypairWallet.unit.helpers.d.ts.map +1 -0
  172. package/dist/esm/utils/KeypairWallet.unit.helpers.js +19 -0
  173. package/dist/esm/utils/KeypairWallet.unit.helpers.js.map +1 -0
  174. package/dist/esm/utils/KeypairWalletAdapter.d.ts +30 -0
  175. package/dist/esm/utils/KeypairWalletAdapter.d.ts.map +1 -0
  176. package/dist/esm/utils/KeypairWalletAdapter.js +81 -0
  177. package/dist/esm/utils/KeypairWalletAdapter.js.map +1 -0
  178. package/dist/esm/utils/base64ToUint8Array.d.ts +5 -0
  179. package/dist/esm/utils/base64ToUint8Array.d.ts.map +1 -0
  180. package/dist/esm/utils/base64ToUint8Array.js +12 -0
  181. package/dist/esm/utils/base64ToUint8Array.js.map +1 -0
  182. package/dist/esm/utils/getWalletFeature.d.ts +30 -0
  183. package/dist/esm/utils/getWalletFeature.d.ts.map +1 -0
  184. package/dist/esm/utils/getWalletFeature.js +25 -0
  185. package/dist/esm/utils/getWalletFeature.js.map +1 -0
  186. package/dist/esm/utils/shouldUseJitoBundle.d.ts +8 -0
  187. package/dist/esm/utils/shouldUseJitoBundle.d.ts.map +1 -0
  188. package/dist/esm/utils/shouldUseJitoBundle.js +11 -0
  189. package/dist/esm/utils/shouldUseJitoBundle.js.map +1 -0
  190. package/dist/esm/version.d.ts +6 -0
  191. package/dist/esm/version.d.ts.map +1 -0
  192. package/dist/esm/version.js +7 -0
  193. package/dist/esm/version.js.map +1 -0
  194. package/package.json +78 -0
  195. package/src/SolanaProvider.ts +51 -0
  196. package/src/actions/getSNSAddress.ts +34 -0
  197. package/src/actions/getSolanaBalance.ts +149 -0
  198. package/src/actions/resolveSolanaAddress.ts +7 -0
  199. package/src/actions/sendAndConfirmBundle.ts +159 -0
  200. package/src/actions/sendAndConfirmTransaction.ts +167 -0
  201. package/src/core/SolanaStepExecutor.ts +102 -0
  202. package/src/core/tasks/SolanaJitoWaitForTransactionTask.ts +87 -0
  203. package/src/core/tasks/SolanaSignAndExecuteTask.ts +99 -0
  204. package/src/core/tasks/SolanaStandardWaitForTransactionTask.ts +115 -0
  205. package/src/core/tasks/SolanaWaitForTransactionTask.ts +23 -0
  206. package/src/errors/parseSolanaErrors.ts +54 -0
  207. package/src/index.ts +9 -0
  208. package/src/rpc/jito/api/getBundleStatuses.ts +31 -0
  209. package/src/rpc/jito/api/getTipAccounts.ts +16 -0
  210. package/src/rpc/jito/api/sendBundle.ts +26 -0
  211. package/src/rpc/jito/api/simulateBundle.ts +59 -0
  212. package/src/rpc/jito/createJitoRpc.ts +50 -0
  213. package/src/rpc/jito/types.ts +12 -0
  214. package/src/rpc/registry.ts +74 -0
  215. package/src/rpc/types.ts +5 -0
  216. package/src/rpc/utils.ts +101 -0
  217. package/src/types.ts +40 -0
  218. package/src/utils/KeypairWallet.unit.helpers.ts +34 -0
  219. package/src/utils/KeypairWalletAdapter.ts +133 -0
  220. package/src/utils/base64ToUint8Array.ts +9 -0
  221. package/src/utils/getWalletFeature.ts +48 -0
  222. package/src/utils/shouldUseJitoBundle.ts +18 -0
  223. package/src/version.ts +2 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # @lifi/sdk-provider-solana
2
+
3
+ ## 0.0.0-preview-f5cf9f8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @lifi/sdk@0.0.0-preview-f5cf9f8
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright LI.FI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ <div align="center">
2
+
3
+ [![license](https://img.shields.io/github/license/lifinance/sdk)](/LICENSE)
4
+ [![npm latest package](https://img.shields.io/npm/v/@lifi/sdk/latest.svg)](https://www.npmjs.com/package/@lifi/sdk)
5
+ [![npm downloads](https://img.shields.io/npm/dm/@lifi/sdk.svg)](https://www.npmjs.com/package/@lifi/sdk)
6
+ [![Follow on Twitter](https://img.shields.io/twitter/follow/lifiprotocol.svg?label=follow+LI.FI)](https://twitter.com/lifiprotocol)
7
+
8
+ </div>
9
+
10
+ <h1 align="center">LI.FI SDK</h1>
11
+
12
+ [**LI.FI SDK**](https://docs.li.fi/sdk/overview) provides a powerful toolkit for developers to enable seamless cross-chain and on-chain swaps and bridging within their applications. Our JavaScript/TypeScript SDK can be implemented in front-end or back-end environments, allowing you to build robust UX/UI around our advanced bridge and swap functionalities. LI.FI SDK efficiently manages all communications between our smart routing API and smart contracts and ensures optimal performance, security, and scalability for your cross-chain and on-chain needs.
13
+
14
+ [**LI.FI SDK**](https://docs.li.fi/sdk/overview) features include:
15
+
16
+ - All ecosystems, chains, bridges, exchanges, and solvers that [LI.FI](https://docs.li.fi/introduction/chains) supports
17
+ - Complete functionality covering full-cycle from obtaining routes/quotes to executing transactions
18
+ - Easy tracking of the route and quote execution through the robust event and hooks handling
19
+ - Highly customizable settings to tailor the SDK to your specific needs including configuration of RPCs and options to allow or deny certain chains, tokens, bridges, exchanges, solvers
20
+ - Supports widely adopted industry standards, including [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792), [ERC-2612](https://eips.ethereum.org/EIPS/eip-2612), [EIP-712](https://eips.ethereum.org/EIPS/eip-712), and [Permit2](https://github.com/Uniswap/permit2)
21
+ - SDK ecosystem providers are based on industry-standard libraries ([Viem](https://viem.sh/), [Wallet Standard](https://github.com/wallet-standard/wallet-standard), [Bigmi](https://github.com/lifinance/bigmi))
22
+ - Support for arbitrary contract calls on the destination chain
23
+ - Designed for optimal performance with tree-shaking and dead-code elimination, ensuring minimal bundle sizes and faster page load times in front-end environments
24
+ - Compatibility tested with Node.js and popular front-end tools like Vite
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pnpm add @lifi/sdk
30
+ ```
31
+
32
+ or
33
+
34
+ ```bash
35
+ npm install --save @lifi/sdk
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ### Set up the SDK
41
+
42
+ Firstly, create SDK config with your integrator string.
43
+
44
+ ```ts
45
+ import { createConfig } from '@lifi/sdk'
46
+
47
+ createConfig({
48
+ integrator: 'Your dApp/company name',
49
+ })
50
+ ```
51
+
52
+ ### Request a Quote
53
+
54
+ Now you can interact with the SDK and for example request a quote.
55
+
56
+ ```ts
57
+ import { ChainId, getQuote } from '@lifi/sdk'
58
+
59
+ const quote = await getQuote({
60
+ fromAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
61
+ fromChain: ChainId.ARB,
62
+ toChain: ChainId.OPT,
63
+ fromToken: '0x0000000000000000000000000000000000000000',
64
+ toToken: '0x0000000000000000000000000000000000000000',
65
+ fromAmount: '1000000000000000000',
66
+ })
67
+ ```
68
+
69
+ ## Examples
70
+
71
+ See [examples](/examples) folder in this repository.
72
+
73
+ ## Documentation
74
+
75
+ Please checkout the [SDK documentation](https://docs.li.fi/sdk/overview) and our [API reference](https://docs.li.fi/api-reference/introduction) for further information.
76
+
77
+ ## Changelog
78
+
79
+ The [changelog](/CHANGELOG.md) is regularly updated to reflect what's changed in each new release.
@@ -0,0 +1,7 @@
1
+ import { SolanaProviderOptions, SolanaSDKProvider } from "./types.js";
2
+
3
+ //#region src/SolanaProvider.d.ts
4
+ declare function SolanaProvider(options?: SolanaProviderOptions): SolanaSDKProvider;
5
+ //#endregion
6
+ export { SolanaProvider };
7
+ //# sourceMappingURL=SolanaProvider.d.ts.map
@@ -0,0 +1,34 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_actions_getSolanaBalance = require("./actions/getSolanaBalance.js");
3
+ const require_actions_resolveSolanaAddress = require("./actions/resolveSolanaAddress.js");
4
+ const require_core_SolanaStepExecutor = require("./core/SolanaStepExecutor.js");
5
+ let _lifi_sdk = require("@lifi/sdk");
6
+ let _solana_kit = require("@solana/kit");
7
+ //#region src/SolanaProvider.ts
8
+ function SolanaProvider(options) {
9
+ const _options = options ?? {};
10
+ return {
11
+ get type() {
12
+ return _lifi_sdk.ChainType.SVM;
13
+ },
14
+ isAddress: _solana_kit.isAddress,
15
+ resolveAddress: require_actions_resolveSolanaAddress.resolveSolanaAddress,
16
+ getBalance: require_actions_getSolanaBalance.getSolanaBalance,
17
+ async getStepExecutor(options) {
18
+ if (!_options.getWallet) throw new _lifi_sdk.ProviderError(_lifi_sdk.LiFiErrorCode.ConfigError, "SolanaProvider requires a getWallet function");
19
+ return new require_core_SolanaStepExecutor.SolanaStepExecutor({
20
+ wallet: await _options.getWallet(),
21
+ routeId: options.routeId,
22
+ skipSimulation: _options.skipSimulation,
23
+ executionOptions: { ...options.executionOptions }
24
+ });
25
+ },
26
+ setOptions(options) {
27
+ Object.assign(_options, options);
28
+ }
29
+ };
30
+ }
31
+ //#endregion
32
+ exports.SolanaProvider = SolanaProvider;
33
+
34
+ //# sourceMappingURL=SolanaProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SolanaProvider.js","names":["ChainType","resolveSolanaAddress","getSolanaBalance","ProviderError","LiFiErrorCode","SolanaStepExecutor"],"sources":["../../src/SolanaProvider.ts"],"sourcesContent":["import {\n ChainType,\n LiFiErrorCode,\n ProviderError,\n type StepExecutorOptions,\n} from '@lifi/sdk'\nimport { isAddress } from '@solana/kit'\nimport { getSolanaBalance } from './actions/getSolanaBalance.js'\nimport { resolveSolanaAddress } from './actions/resolveSolanaAddress.js'\nimport { SolanaStepExecutor } from './core/SolanaStepExecutor.js'\nimport type { SolanaProviderOptions, SolanaSDKProvider } from './types.js'\n\nexport function SolanaProvider(\n options?: SolanaProviderOptions\n): SolanaSDKProvider {\n const _options: SolanaProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.SVM\n },\n isAddress,\n resolveAddress: resolveSolanaAddress,\n getBalance: getSolanaBalance,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<SolanaStepExecutor> {\n if (!_options.getWallet) {\n throw new ProviderError(\n LiFiErrorCode.ConfigError,\n 'SolanaProvider requires a getWallet function'\n )\n }\n\n const wallet = await _options.getWallet()\n\n const executor = new SolanaStepExecutor({\n wallet,\n routeId: options.routeId,\n skipSimulation: _options.skipSimulation,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: SolanaProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;;AAYA,SAAgB,eACd,SACmB;CACnB,MAAM,WAAkC,WAAW,CAAC;CACpD,OAAO;EACL,IAAI,OAAO;GACT,OAAOA,UAAAA,UAAU;EACnB;EACA,WAAA,YAAA;EACA,gBAAgBC,qCAAAA;EAChB,YAAYC,iCAAAA;EACZ,MAAM,gBACJ,SAC6B;GAC7B,IAAI,CAAC,SAAS,WACZ,MAAM,IAAIC,UAAAA,cACRC,UAAAA,cAAc,aACd,8CACF;GAcF,OAAO,IATcC,gCAAAA,mBAAmB;IACtC,QAAA,MAHmB,SAAS,UAAU;IAItC,SAAS,QAAQ;IACjB,gBAAgB,SAAS;IACzB,kBAAkB,EAChB,GAAG,QAAQ,iBACb;GACF,CAEc;EAChB;EACA,WAAW,SAAgC;GACzC,OAAO,OAAO,UAAU,OAAO;EACjC;CACF;AACF"}
@@ -0,0 +1,5 @@
1
+ //#region src/actions/getSNSAddress.d.ts
2
+ declare const getSNSAddress: (name: string) => Promise<string | undefined>;
3
+ //#endregion
4
+ export { getSNSAddress };
5
+ //# sourceMappingURL=getSNSAddress.d.ts.map
@@ -0,0 +1,20 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _solana_kit = require("@solana/kit");
3
+ //#region src/actions/getSNSAddress.ts
4
+ const getSNSAddress = async (name) => {
5
+ try {
6
+ if (!name.endsWith(".sol")) return;
7
+ const snsWorkerUrl = `https://sns-sdk-proxy.bonfida.workers.dev/resolve/${name}`;
8
+ const response = await fetch(snsWorkerUrl);
9
+ if (!response.ok) return;
10
+ const data = await response.json();
11
+ if (!(0, _solana_kit.isAddress)(data.result)) return;
12
+ return data.result;
13
+ } catch (_) {
14
+ return;
15
+ }
16
+ };
17
+ //#endregion
18
+ exports.getSNSAddress = getSNSAddress;
19
+
20
+ //# sourceMappingURL=getSNSAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSNSAddress.js","names":[],"sources":["../../../src/actions/getSNSAddress.ts"],"sourcesContent":["import { isAddress } from '@solana/kit'\n\ninterface SNSResult {\n s: 'ok' | 'error'\n result: string\n}\n\n// Subject to change\n// https://github.com/Bonfida/sns-sdk?tab=readme-ov-file#sdk-proxy\nexport const getSNSAddress = async (\n name: string\n): Promise<string | undefined> => {\n try {\n if (!name.endsWith('.sol')) {\n return\n }\n const snsWorkerUrl = `https://sns-sdk-proxy.bonfida.workers.dev/resolve/${name}`\n const response: Response = await fetch(snsWorkerUrl)\n if (!response.ok) {\n return\n }\n\n const data: SNSResult = await response.json()\n\n if (!isAddress(data.result)) {\n return\n }\n\n return data.result\n } catch (_) {\n // ignore\n return\n }\n}\n"],"mappings":";;;AASA,MAAa,gBAAgB,OAC3B,SACgC;CAChC,IAAI;EACF,IAAI,CAAC,KAAK,SAAS,MAAM,GACvB;EAEF,MAAM,eAAe,qDAAqD;EAC1E,MAAM,WAAqB,MAAM,MAAM,YAAY;EACnD,IAAI,CAAC,SAAS,IACZ;EAGF,MAAM,OAAkB,MAAM,SAAS,KAAK;EAE5C,IAAI,EAAA,GAAA,YAAA,WAAW,KAAK,MAAM,GACxB;EAGF,OAAO,KAAK;CACd,SAAS,GAAG;EAEV;CACF;AACF"}
@@ -0,0 +1,7 @@
1
+ import { SDKClient, Token, TokenAmount } from "@lifi/sdk";
2
+
3
+ //#region src/actions/getSolanaBalance.d.ts
4
+ declare const getSolanaBalance: (client: SDKClient, walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
5
+ //#endregion
6
+ export { getSolanaBalance };
7
+ //# sourceMappingURL=getSolanaBalance.d.ts.map
@@ -0,0 +1,75 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rpc_utils = require("../rpc/utils.js");
3
+ let _lifi_sdk = require("@lifi/sdk");
4
+ let _solana_kit = require("@solana/kit");
5
+ //#region src/actions/getSolanaBalance.ts
6
+ const SolSystemProgram = "11111111111111111111111111111111";
7
+ const TokenProgramId = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
8
+ const Token2022ProgramId = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
9
+ const getSolanaBalance = async (client, walletAddress, tokens) => {
10
+ if (tokens.length === 0) return [];
11
+ const { chainId } = tokens[0];
12
+ for (const token of tokens) if (token.chainId !== chainId) console.warn("Requested tokens have to be on the same chain.");
13
+ return getSolanaBalanceDefault(client, chainId, tokens, walletAddress);
14
+ };
15
+ const getSolanaBalanceDefault = async (client, _chainId, tokens, walletAddress) => {
16
+ const accountAddress = (0, _solana_kit.address)(walletAddress);
17
+ const tokenProgramAddress = (0, _solana_kit.address)(TokenProgramId);
18
+ const token2022ProgramAddress = (0, _solana_kit.address)(Token2022ProgramId);
19
+ const [slot, balance, tokenAccountsByOwner, token2022AccountsByOwner] = await Promise.allSettled([
20
+ (0, _lifi_sdk.withDedupe)(() => require_rpc_utils.callSolanaRpcsWithRetry(client, (rpc) => rpc.getSlot({ commitment: "confirmed" }).send()), { id: `${getSolanaBalanceDefault.name}.getSlot` }),
21
+ (0, _lifi_sdk.withDedupe)(() => require_rpc_utils.callSolanaRpcsWithRetry(client, (rpc) => rpc.getBalance(accountAddress, { commitment: "confirmed" }).send()), { id: `${getSolanaBalanceDefault.name}.getBalance` }),
22
+ (0, _lifi_sdk.withDedupe)(() => require_rpc_utils.callSolanaRpcsWithRetry(client, (rpc) => rpc.getTokenAccountsByOwner(accountAddress, { programId: tokenProgramAddress }, {
23
+ commitment: "confirmed",
24
+ encoding: "jsonParsed"
25
+ }).send()), { id: `${getSolanaBalanceDefault.name}.getTokenAccountsByOwner.${TokenProgramId}` }),
26
+ (0, _lifi_sdk.withDedupe)(() => require_rpc_utils.callSolanaRpcsWithRetry(client, (rpc) => rpc.getTokenAccountsByOwner(accountAddress, { programId: token2022ProgramAddress }, {
27
+ commitment: "confirmed",
28
+ encoding: "jsonParsed"
29
+ }).send()), { id: `${getSolanaBalanceDefault.name}.getTokenAccountsByOwner.${Token2022ProgramId}` })
30
+ ]);
31
+ const blockNumber = slot.status === "fulfilled" ? BigInt(slot.value) : 0n;
32
+ const nativeBalanceOk = balance.status === "fulfilled";
33
+ const solBalance = nativeBalanceOk ? BigInt(balance.value.value) : 0n;
34
+ const tokenProgramOk = tokenAccountsByOwner.status === "fulfilled";
35
+ const token2022ProgramOk = token2022AccountsByOwner.status === "fulfilled";
36
+ const walletTokenAmounts = [...tokenProgramOk ? tokenAccountsByOwner.value.value : [], ...token2022ProgramOk ? token2022AccountsByOwner.value.value : []].reduce((tokenAmounts, value) => {
37
+ const tokenAccount = value.account.data.parsed.info;
38
+ const amount = BigInt(tokenAccount.tokenAmount.amount);
39
+ if (amount > 0n) tokenAmounts[tokenAccount.mint] = (tokenAmounts[tokenAccount.mint] ?? 0n) + amount;
40
+ return tokenAmounts;
41
+ }, {});
42
+ const splZeroIsKnown = tokenProgramOk && token2022ProgramOk;
43
+ return tokens.map((token) => {
44
+ if (token.address === SolSystemProgram) {
45
+ if (!nativeBalanceOk) return {
46
+ ...token,
47
+ blockNumber
48
+ };
49
+ return {
50
+ ...token,
51
+ amount: solBalance,
52
+ blockNumber
53
+ };
54
+ }
55
+ const found = walletTokenAmounts[token.address];
56
+ if (found !== void 0) return {
57
+ ...token,
58
+ amount: found,
59
+ blockNumber
60
+ };
61
+ if (splZeroIsKnown) return {
62
+ ...token,
63
+ amount: 0n,
64
+ blockNumber
65
+ };
66
+ return {
67
+ ...token,
68
+ blockNumber
69
+ };
70
+ });
71
+ };
72
+ //#endregion
73
+ exports.getSolanaBalance = getSolanaBalance;
74
+
75
+ //# sourceMappingURL=getSolanaBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSolanaBalance.js","names":["callSolanaRpcsWithRetry"],"sources":["../../../src/actions/getSolanaBalance.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n type ChainId,\n type Token,\n type TokenAmount,\n withDedupe,\n} from '@lifi/sdk'\nimport { address, type JsonParsedTokenAccount } from '@solana/kit'\n\nimport { callSolanaRpcsWithRetry } from '../rpc/utils.js'\n\nconst SolSystemProgram = '11111111111111111111111111111111'\nconst TokenProgramId = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'\nconst Token2022ProgramId = 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'\n\nexport const getSolanaBalance = async (\n client: SDKClient,\n walletAddress: string,\n tokens: Token[]\n): Promise<TokenAmount[]> => {\n if (tokens.length === 0) {\n return []\n }\n const { chainId } = tokens[0]\n for (const token of tokens) {\n if (token.chainId !== chainId) {\n console.warn('Requested tokens have to be on the same chain.')\n }\n }\n\n return getSolanaBalanceDefault(client, chainId, tokens, walletAddress)\n}\n\nconst getSolanaBalanceDefault = async (\n client: SDKClient,\n _chainId: ChainId,\n tokens: Token[],\n walletAddress: string\n): Promise<TokenAmount[]> => {\n // Convert addresses to Solana Kit's address type\n const accountAddress = address(walletAddress)\n const tokenProgramAddress = address(TokenProgramId)\n const token2022ProgramAddress = address(Token2022ProgramId)\n\n // Use Solana Kit's RPC API with the retry wrapper\n const [slot, balance, tokenAccountsByOwner, token2022AccountsByOwner] =\n await Promise.allSettled([\n withDedupe(\n () =>\n callSolanaRpcsWithRetry(client, (rpc) =>\n rpc.getSlot({ commitment: 'confirmed' }).send()\n ),\n { id: `${getSolanaBalanceDefault.name}.getSlot` }\n ),\n withDedupe(\n () =>\n callSolanaRpcsWithRetry(client, (rpc) =>\n rpc.getBalance(accountAddress, { commitment: 'confirmed' }).send()\n ),\n { id: `${getSolanaBalanceDefault.name}.getBalance` }\n ),\n withDedupe(\n () =>\n callSolanaRpcsWithRetry(client, (rpc) =>\n rpc\n .getTokenAccountsByOwner(\n accountAddress,\n {\n programId: tokenProgramAddress,\n },\n {\n commitment: 'confirmed',\n encoding: 'jsonParsed',\n }\n )\n .send()\n ),\n {\n id: `${getSolanaBalanceDefault.name}.getTokenAccountsByOwner.${TokenProgramId}`,\n }\n ),\n withDedupe(\n () =>\n callSolanaRpcsWithRetry(client, (rpc) =>\n rpc\n .getTokenAccountsByOwner(\n accountAddress,\n {\n programId: token2022ProgramAddress,\n },\n {\n commitment: 'confirmed',\n encoding: 'jsonParsed',\n }\n )\n .send()\n ),\n {\n id: `${getSolanaBalanceDefault.name}.getTokenAccountsByOwner.${Token2022ProgramId}`,\n }\n ),\n ])\n const blockNumber = slot.status === 'fulfilled' ? BigInt(slot.value) : 0n\n const nativeBalanceOk = balance.status === 'fulfilled'\n const solBalance = nativeBalanceOk ? BigInt(balance.value.value) : 0n\n const tokenProgramOk = tokenAccountsByOwner.status === 'fulfilled'\n const token2022ProgramOk = token2022AccountsByOwner.status === 'fulfilled'\n\n const walletTokenAmounts = [\n ...(tokenProgramOk ? tokenAccountsByOwner.value.value : []),\n ...(token2022ProgramOk ? token2022AccountsByOwner.value.value : []),\n ].reduce(\n (tokenAmounts: Record<string, bigint>, value) => {\n const tokenAccount: JsonParsedTokenAccount =\n value.account.data.parsed.info\n const amount = BigInt(tokenAccount.tokenAmount.amount)\n if (amount > 0n) {\n tokenAmounts[tokenAccount.mint] =\n (tokenAmounts[tokenAccount.mint] ?? 0n) + amount\n }\n return tokenAmounts\n },\n {} as Record<string, bigint>\n )\n\n // We can only confidently report 0n for an SPL mint when both Token and\n // Token2022 program queries succeeded — otherwise the mint may live in the\n // program whose query failed (e.g. PYUSD on Token2022).\n const splZeroIsKnown = tokenProgramOk && token2022ProgramOk\n\n const tokenAmounts: TokenAmount[] = tokens.map((token) => {\n const isNative = token.address === SolSystemProgram\n if (isNative) {\n if (!nativeBalanceOk) {\n return { ...token, blockNumber }\n }\n return { ...token, amount: solBalance, blockNumber }\n }\n const found = walletTokenAmounts[token.address]\n if (found !== undefined) {\n return { ...token, amount: found, blockNumber }\n }\n if (splZeroIsKnown) {\n return { ...token, amount: 0n, blockNumber }\n }\n return { ...token, blockNumber }\n })\n return tokenAmounts\n}\n"],"mappings":";;;;;AAWA,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAE3B,MAAa,mBAAmB,OAC9B,QACA,eACA,WAC2B;CAC3B,IAAI,OAAO,WAAW,GACpB,OAAO,CAAC;CAEV,MAAM,EAAE,YAAY,OAAO;CAC3B,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,YAAY,SACpB,QAAQ,KAAK,gDAAgD;CAIjE,OAAO,wBAAwB,QAAQ,SAAS,QAAQ,aAAa;AACvE;AAEA,MAAM,0BAA0B,OAC9B,QACA,UACA,QACA,kBAC2B;CAE3B,MAAM,kBAAA,GAAA,YAAA,SAAyB,aAAa;CAC5C,MAAM,uBAAA,GAAA,YAAA,SAA8B,cAAc;CAClD,MAAM,2BAAA,GAAA,YAAA,SAAkC,kBAAkB;CAG1D,MAAM,CAAC,MAAM,SAAS,sBAAsB,4BAC1C,MAAM,QAAQ,WAAW;kCAGnBA,kBAAAA,wBAAwB,SAAS,QAC/B,IAAI,QAAQ,EAAE,YAAY,YAAY,CAAC,EAAE,KAAK,CAChD,GACF,EAAE,IAAI,GAAG,wBAAwB,KAAK,UAAU,CAClD;kCAGIA,kBAAAA,wBAAwB,SAAS,QAC/B,IAAI,WAAW,gBAAgB,EAAE,YAAY,YAAY,CAAC,EAAE,KAAK,CACnE,GACF,EAAE,IAAI,GAAG,wBAAwB,KAAK,aAAa,CACrD;kCAGIA,kBAAAA,wBAAwB,SAAS,QAC/B,IACG,wBACC,gBACA,EACE,WAAW,oBACb,GACA;GACE,YAAY;GACZ,UAAU;EACZ,CACF,EACC,KAAK,CACV,GACF,EACE,IAAI,GAAG,wBAAwB,KAAK,2BAA2B,iBACjE,CACF;kCAGIA,kBAAAA,wBAAwB,SAAS,QAC/B,IACG,wBACC,gBACA,EACE,WAAW,wBACb,GACA;GACE,YAAY;GACZ,UAAU;EACZ,CACF,EACC,KAAK,CACV,GACF,EACE,IAAI,GAAG,wBAAwB,KAAK,2BAA2B,qBACjE,CACF;CACF,CAAC;CACH,MAAM,cAAc,KAAK,WAAW,cAAc,OAAO,KAAK,KAAK,IAAI;CACvE,MAAM,kBAAkB,QAAQ,WAAW;CAC3C,MAAM,aAAa,kBAAkB,OAAO,QAAQ,MAAM,KAAK,IAAI;CACnE,MAAM,iBAAiB,qBAAqB,WAAW;CACvD,MAAM,qBAAqB,yBAAyB,WAAW;CAE/D,MAAM,qBAAqB,CACzB,GAAI,iBAAiB,qBAAqB,MAAM,QAAQ,CAAC,GACzD,GAAI,qBAAqB,yBAAyB,MAAM,QAAQ,CAAC,CACnE,EAAE,QACC,cAAsC,UAAU;EAC/C,MAAM,eACJ,MAAM,QAAQ,KAAK,OAAO;EAC5B,MAAM,SAAS,OAAO,aAAa,YAAY,MAAM;EACrD,IAAI,SAAS,IACX,aAAa,aAAa,SACvB,aAAa,aAAa,SAAS,MAAM;EAE9C,OAAO;CACT,GACA,CAAC,CACH;CAKA,MAAM,iBAAiB,kBAAkB;CAmBzC,OAjBoC,OAAO,KAAK,UAAU;EAExD,IADiB,MAAM,YAAY,kBACrB;GACZ,IAAI,CAAC,iBACH,OAAO;IAAE,GAAG;IAAO;GAAY;GAEjC,OAAO;IAAE,GAAG;IAAO,QAAQ;IAAY;GAAY;EACrD;EACA,MAAM,QAAQ,mBAAmB,MAAM;EACvC,IAAI,UAAU,KAAA,GACZ,OAAO;GAAE,GAAG;GAAO,QAAQ;GAAO;EAAY;EAEhD,IAAI,gBACF,OAAO;GAAE,GAAG;GAAO,QAAQ;GAAI;EAAY;EAE7C,OAAO;GAAE,GAAG;GAAO;EAAY;CACjC,CACkB;AACpB"}
@@ -0,0 +1,5 @@
1
+ //#region src/actions/resolveSolanaAddress.d.ts
2
+ declare function resolveSolanaAddress(name: string): Promise<string | undefined>;
3
+ //#endregion
4
+ export { resolveSolanaAddress };
5
+ //# sourceMappingURL=resolveSolanaAddress.d.ts.map
@@ -0,0 +1,10 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_actions_getSNSAddress = require("./getSNSAddress.js");
3
+ //#region src/actions/resolveSolanaAddress.ts
4
+ async function resolveSolanaAddress(name) {
5
+ return await require_actions_getSNSAddress.getSNSAddress(name);
6
+ }
7
+ //#endregion
8
+ exports.resolveSolanaAddress = resolveSolanaAddress;
9
+
10
+ //# sourceMappingURL=resolveSolanaAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveSolanaAddress.js","names":["getSNSAddress"],"sources":["../../../src/actions/resolveSolanaAddress.ts"],"sourcesContent":["import { getSNSAddress } from './getSNSAddress.js'\n\nexport async function resolveSolanaAddress(\n name: string\n): Promise<string | undefined> {\n return await getSNSAddress(name)\n}\n"],"mappings":";;;AAEA,eAAsB,qBACpB,MAC6B;CAC7B,OAAO,MAAMA,8BAAAA,cAAc,IAAI;AACjC"}
@@ -0,0 +1,32 @@
1
+ import { SDKClient } from "@lifi/sdk";
2
+ import { Commitment, Signature, Transaction, TransactionError } from "@solana/kit";
3
+
4
+ //#region src/actions/sendAndConfirmBundle.d.ts
5
+ type SignatureStatus = {
6
+ slot: bigint;
7
+ confirmations: bigint | null;
8
+ err: TransactionError | null;
9
+ confirmationStatus: Commitment | null;
10
+ status: Readonly<{
11
+ Err: TransactionError;
12
+ }> | Readonly<{
13
+ Ok: null;
14
+ }>;
15
+ };
16
+ type BundleResult = {
17
+ bundleId: string;
18
+ txSignatures: Signature[];
19
+ signatureResults: (SignatureStatus | null)[];
20
+ };
21
+ /**
22
+ * Send and confirm a bundle of transactions using Jito.
23
+ * Automatically selects a Jito-enabled RPC connection and polls for confirmation
24
+ * across multiple Jito RPCs in parallel.
25
+ * @param client - The SDK client.
26
+ * @param signedTransactions - Array of signed transactions to bundle.
27
+ * @returns BundleResult containing Bundle ID, transaction signatures, and confirmation results.
28
+ */
29
+ declare function sendAndConfirmBundle(client: SDKClient, signedTransactions: Transaction[]): Promise<BundleResult>;
30
+ //#endregion
31
+ export { BundleResult, sendAndConfirmBundle };
32
+ //# sourceMappingURL=sendAndConfirmBundle.d.ts.map
@@ -0,0 +1,67 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rpc_registry = require("../rpc/registry.js");
3
+ let _lifi_sdk = require("@lifi/sdk");
4
+ let _solana_kit = require("@solana/kit");
5
+ //#region src/actions/sendAndConfirmBundle.ts
6
+ const NULL_BUNDLE_RESULT = /* @__PURE__ */ new Error("Bundle was not confirmed by this RPC");
7
+ /**
8
+ * Send and confirm a bundle of transactions using Jito.
9
+ * Automatically selects a Jito-enabled RPC connection and polls for confirmation
10
+ * across multiple Jito RPCs in parallel.
11
+ * @param client - The SDK client.
12
+ * @param signedTransactions - Array of signed transactions to bundle.
13
+ * @returns BundleResult containing Bundle ID, transaction signatures, and confirmation results.
14
+ */
15
+ async function sendAndConfirmBundle(client, signedTransactions) {
16
+ const jitoRpcs = await require_rpc_registry.getJitoRpcs(client);
17
+ if (jitoRpcs.length === 0) throw new Error("No Jito-enabled RPC connection available for bundle submission");
18
+ const serializedTransactions = signedTransactions.map((tx) => (0, _solana_kit.getBase64EncodedWireTransaction)(tx));
19
+ const abortController = new AbortController();
20
+ const confirmPromises = jitoRpcs.map(async (jitoRpc) => {
21
+ try {
22
+ let bundleId;
23
+ try {
24
+ bundleId = await jitoRpc.sendBundle(serializedTransactions).send();
25
+ } catch (_) {
26
+ return null;
27
+ }
28
+ const [{ value: blockhashResult }, initialBlockHeight] = await Promise.all([jitoRpc.getLatestBlockhash({ commitment: "confirmed" }).send(), jitoRpc.getBlockHeight({ commitment: "confirmed" }).send()]);
29
+ let currentBlockHeight = initialBlockHeight;
30
+ while (currentBlockHeight < blockhashResult.lastValidBlockHeight && !abortController.signal.aborted) {
31
+ const bundleStatus = (await jitoRpc.getBundleStatuses([bundleId]).send()).value[0];
32
+ if (bundleStatus && (bundleStatus.confirmation_status === "confirmed" || bundleStatus.confirmation_status === "finalized")) {
33
+ const txSignatures = bundleStatus.transactions;
34
+ const sigResponse = await jitoRpc.getSignatureStatuses(txSignatures).send();
35
+ if (!sigResponse?.value || !Array.isArray(sigResponse.value)) {
36
+ await (0, _lifi_sdk.sleep)(400);
37
+ continue;
38
+ }
39
+ abortController.abort();
40
+ return {
41
+ bundleId,
42
+ txSignatures,
43
+ signatureResults: sigResponse.value
44
+ };
45
+ }
46
+ await (0, _lifi_sdk.sleep)(400);
47
+ if (!abortController.signal.aborted) currentBlockHeight = await jitoRpc.getBlockHeight({ commitment: "confirmed" }).send();
48
+ }
49
+ return null;
50
+ } catch (error) {
51
+ if (abortController.signal.aborted) return null;
52
+ throw error;
53
+ }
54
+ });
55
+ const result = await Promise.any(confirmPromises.map(async (promise) => {
56
+ const bundleResult = await promise;
57
+ if (!bundleResult) throw NULL_BUNDLE_RESULT;
58
+ return bundleResult;
59
+ })).catch(() => null);
60
+ if (!abortController.signal.aborted) abortController.abort();
61
+ if (!result) throw new Error("Failed to send and confirm bundle");
62
+ return result;
63
+ }
64
+ //#endregion
65
+ exports.sendAndConfirmBundle = sendAndConfirmBundle;
66
+
67
+ //# sourceMappingURL=sendAndConfirmBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendAndConfirmBundle.js","names":["getJitoRpcs"],"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,MAAMA,qBAAAA,YAAY,MAAM;CAEzC,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,MACR,gEACF;CAIF,MAAM,yBAAyB,mBAAmB,KAAK,QAAA,GAAA,YAAA,iCACrB,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,EAAE,KAAK;GACnE,SAAS,GAAG;IACV,OAAO;GACT;GAEA,MAAM,CAAC,EAAE,OAAO,mBAAmB,sBACjC,MAAM,QAAQ,IAAI,CAChB,QACG,mBAAmB,EAClB,YAAY,YACd,CAAC,EACA,KAAK,GACR,QACG,eAAe,EACd,YAAY,YACd,CAAC,EACA,KAAK,CACV,CAAC;GAEH,IAAI,qBAAqB;GAEzB,OACE,qBAAqB,gBAAgB,wBACrC,CAAC,gBAAgB,OAAO,SACxB;IAKA,MAAM,gBAAe,MAJQ,QAC1B,kBAAkB,CAAC,QAAQ,CAAC,EAC5B,KAAK,GAE4B,MAAM;IAG1C,IACE,iBACC,aAAa,wBAAwB,eACpC,aAAa,wBAAwB,cACvC;KAEA,MAAM,eAAe,aAAa;KAGlC,MAAM,cAAc,MAAM,QACvB,qBAAqB,YAAY,EACjC,KAAK;KAER,IAAI,CAAC,aAAa,SAAS,CAAC,MAAM,QAAQ,YAAY,KAAK,GAAG;MAE5D,OAAA,GAAA,UAAA,OAAY,GAAG;MACf;KACF;KAGA,gBAAgB,MAAM;KACtB,OAAO;MACL;MACA;MACA,kBAAkB,YAAY;KAChC;IACF;IAEA,OAAA,GAAA,UAAA,OAAY,GAAG;IACf,IAAI,CAAC,gBAAgB,OAAO,SAC1B,qBAAqB,MAAM,QACxB,eAAe,EACd,YAAY,YACd,CAAC,EACA,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,EAAE,YAAY,IAAI;CAElB,IAAI,CAAC,gBAAgB,OAAO,SAC1B,gBAAgB,MAAM;CAGxB,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,mCAAmC;CAGrD,OAAO;AACT"}
@@ -0,0 +1,30 @@
1
+ import { SDKClient } from "@lifi/sdk";
2
+ import { Commitment, Transaction, TransactionError } from "@solana/kit";
3
+
4
+ //#region src/actions/sendAndConfirmTransaction.d.ts
5
+ type SignatureStatus = {
6
+ slot: bigint;
7
+ confirmations: bigint | null;
8
+ err: TransactionError | null;
9
+ confirmationStatus: Commitment | null;
10
+ status: Readonly<{
11
+ Err: TransactionError;
12
+ }> | Readonly<{
13
+ Ok: null;
14
+ }>;
15
+ };
16
+ type ConfirmedTransactionResult = {
17
+ signatureResult: SignatureStatus | null;
18
+ txSignature: string;
19
+ };
20
+ /**
21
+ * Sends a Solana transaction to multiple RPC endpoints and returns the confirmation
22
+ * as soon as any of them confirm the transaction.
23
+ * @param client - The SDK client.
24
+ * @param signedTransaction - The signed transaction to send.
25
+ * @returns - The confirmation result of the transaction.
26
+ */
27
+ declare function sendAndConfirmTransaction(client: SDKClient, signedTransaction: Transaction): Promise<ConfirmedTransactionResult>;
28
+ //#endregion
29
+ export { sendAndConfirmTransaction };
30
+ //# sourceMappingURL=sendAndConfirmTransaction.d.ts.map