@lifi/sdk 3.0.2-beta.0 → 3.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 (217) hide show
  1. package/package.json +3 -3
  2. package/src/_cjs/core/EVM/EVMStepExecutor.js +12 -11
  3. package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -1
  4. package/src/_cjs/core/EVM/checkAllowance.js +5 -10
  5. package/src/_cjs/core/EVM/checkAllowance.js.map +1 -1
  6. package/src/_cjs/core/EVM/multisig.js +4 -3
  7. package/src/_cjs/core/EVM/multisig.js.map +1 -1
  8. package/src/_cjs/core/EVM/parseEVMErrors.js +38 -0
  9. package/src/_cjs/core/EVM/parseEVMErrors.js.map +1 -0
  10. package/src/_cjs/core/EVM/publicClient.js +8 -3
  11. package/src/_cjs/core/EVM/publicClient.js.map +1 -1
  12. package/src/_cjs/core/EVM/setAllowance.js +2 -3
  13. package/src/_cjs/core/EVM/setAllowance.js.map +1 -1
  14. package/src/_cjs/core/EVM/switchChain.js +4 -3
  15. package/src/_cjs/core/EVM/switchChain.js.map +1 -1
  16. package/src/_cjs/core/Solana/SolanaStepExecutor.js +42 -24
  17. package/src/_cjs/core/Solana/SolanaStepExecutor.js.map +1 -1
  18. package/src/_cjs/core/Solana/connection.js.map +1 -1
  19. package/src/_cjs/core/Solana/parseSolanaErrors.js +33 -0
  20. package/src/_cjs/core/Solana/parseSolanaErrors.js.map +1 -0
  21. package/src/_cjs/core/checkBalance.js +2 -2
  22. package/src/_cjs/core/checkBalance.js.map +1 -1
  23. package/src/_cjs/core/stepComparison.js +3 -3
  24. package/src/_cjs/core/stepComparison.js.map +1 -1
  25. package/src/_cjs/core/waitForReceivingTransaction.js +1 -1
  26. package/src/_cjs/core/waitForReceivingTransaction.js.map +1 -1
  27. package/src/_cjs/errors/SDKError.js +48 -0
  28. package/src/_cjs/errors/SDKError.js.map +1 -0
  29. package/src/_cjs/errors/baseError.js +30 -0
  30. package/src/_cjs/errors/baseError.js.map +1 -0
  31. package/src/_cjs/errors/constants.js +48 -0
  32. package/src/_cjs/errors/constants.js.map +1 -0
  33. package/src/_cjs/errors/errors.js +48 -0
  34. package/src/_cjs/errors/errors.js.map +1 -0
  35. package/src/_cjs/errors/httpError.js +101 -0
  36. package/src/_cjs/errors/httpError.js.map +1 -0
  37. package/src/_cjs/errors/index.js +11 -0
  38. package/src/_cjs/errors/index.js.map +1 -0
  39. package/src/_cjs/errors/utils/baseErrorRootCause.js +21 -0
  40. package/src/_cjs/errors/utils/baseErrorRootCause.js.map +1 -0
  41. package/src/_cjs/errors/utils/rootCause.js +12 -0
  42. package/src/_cjs/errors/utils/rootCause.js.map +1 -0
  43. package/src/_cjs/helpers.js +13 -8
  44. package/src/_cjs/helpers.js.map +1 -1
  45. package/src/_cjs/index.js +2 -4
  46. package/src/_cjs/index.js.map +1 -1
  47. package/src/_cjs/request.js +37 -34
  48. package/src/_cjs/request.js.map +1 -1
  49. package/src/_cjs/services/api.js +61 -132
  50. package/src/_cjs/services/api.js.map +1 -1
  51. package/src/_cjs/services/balance.js +1 -1
  52. package/src/_cjs/services/balance.js.map +1 -1
  53. package/src/_cjs/types/request.js +3 -0
  54. package/src/_cjs/types/request.js.map +1 -0
  55. package/src/_cjs/utils/errors.js +0 -183
  56. package/src/_cjs/utils/errors.js.map +1 -1
  57. package/src/_cjs/utils/index.js +1 -2
  58. package/src/_cjs/utils/index.js.map +1 -1
  59. package/src/_cjs/version.js +1 -1
  60. package/src/_cjs/version.js.map +1 -1
  61. package/src/_esm/core/EVM/EVMStepExecutor.js +8 -7
  62. package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -1
  63. package/src/_esm/core/EVM/checkAllowance.js +5 -10
  64. package/src/_esm/core/EVM/checkAllowance.js.map +1 -1
  65. package/src/_esm/core/EVM/multisig.js +2 -1
  66. package/src/_esm/core/EVM/multisig.js.map +1 -1
  67. package/src/_esm/core/EVM/parseEVMErrors.js +35 -0
  68. package/src/_esm/core/EVM/parseEVMErrors.js.map +1 -0
  69. package/src/_esm/core/EVM/publicClient.js +9 -4
  70. package/src/_esm/core/EVM/publicClient.js.map +1 -1
  71. package/src/_esm/core/EVM/setAllowance.js +3 -5
  72. package/src/_esm/core/EVM/setAllowance.js.map +1 -1
  73. package/src/_esm/core/EVM/switchChain.js +2 -1
  74. package/src/_esm/core/EVM/switchChain.js.map +1 -1
  75. package/src/_esm/core/Solana/SolanaStepExecutor.js +52 -25
  76. package/src/_esm/core/Solana/SolanaStepExecutor.js.map +1 -1
  77. package/src/_esm/core/Solana/connection.js +2 -3
  78. package/src/_esm/core/Solana/connection.js.map +1 -1
  79. package/src/_esm/core/Solana/parseSolanaErrors.js +29 -0
  80. package/src/_esm/core/Solana/parseSolanaErrors.js.map +1 -0
  81. package/src/_esm/core/checkBalance.js +2 -2
  82. package/src/_esm/core/checkBalance.js.map +1 -1
  83. package/src/_esm/core/stepComparison.js +3 -3
  84. package/src/_esm/core/stepComparison.js.map +1 -1
  85. package/src/_esm/core/waitForReceivingTransaction.js +1 -1
  86. package/src/_esm/core/waitForReceivingTransaction.js.map +1 -1
  87. package/src/_esm/errors/SDKError.js +47 -0
  88. package/src/_esm/errors/SDKError.js.map +1 -0
  89. package/src/_esm/errors/baseError.js +28 -0
  90. package/src/_esm/errors/baseError.js.map +1 -0
  91. package/src/_esm/errors/constants.js +45 -0
  92. package/src/_esm/errors/constants.js.map +1 -0
  93. package/src/_esm/errors/errors.js +38 -0
  94. package/src/_esm/errors/errors.js.map +1 -0
  95. package/src/_esm/errors/httpError.js +97 -0
  96. package/src/_esm/errors/httpError.js.map +1 -0
  97. package/src/_esm/errors/index.js +8 -0
  98. package/src/_esm/errors/index.js.map +1 -0
  99. package/src/_esm/errors/utils/baseErrorRootCause.js +16 -0
  100. package/src/_esm/errors/utils/baseErrorRootCause.js.map +1 -0
  101. package/src/_esm/errors/utils/rootCause.js +8 -0
  102. package/src/_esm/errors/utils/rootCause.js.map +1 -0
  103. package/src/_esm/helpers.js +16 -9
  104. package/src/_esm/helpers.js.map +1 -1
  105. package/src/_esm/index.js +2 -2
  106. package/src/_esm/index.js.map +1 -1
  107. package/src/_esm/request.js +38 -35
  108. package/src/_esm/request.js.map +1 -1
  109. package/src/_esm/services/api.js +61 -133
  110. package/src/_esm/services/api.js.map +1 -1
  111. package/src/_esm/services/balance.js +4 -4
  112. package/src/_esm/services/balance.js.map +1 -1
  113. package/src/_esm/types/request.js +2 -0
  114. package/src/_esm/types/request.js.map +1 -0
  115. package/src/_esm/utils/errors.js +1 -173
  116. package/src/_esm/utils/errors.js.map +1 -1
  117. package/src/_esm/utils/index.js +1 -2
  118. package/src/_esm/utils/index.js.map +1 -1
  119. package/src/_esm/version.js +1 -1
  120. package/src/_esm/version.js.map +1 -1
  121. package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -1
  122. package/src/_types/core/EVM/checkAllowance.d.ts.map +1 -1
  123. package/src/_types/core/EVM/multisig.d.ts.map +1 -1
  124. package/src/_types/core/EVM/parseEVMErrors.d.ts +4 -0
  125. package/src/_types/core/EVM/parseEVMErrors.d.ts.map +1 -0
  126. package/src/_types/core/EVM/publicClient.d.ts.map +1 -1
  127. package/src/_types/core/EVM/setAllowance.d.ts +1 -2
  128. package/src/_types/core/EVM/setAllowance.d.ts.map +1 -1
  129. package/src/_types/core/EVM/switchChain.d.ts.map +1 -1
  130. package/src/_types/core/EVM/types.d.ts +3 -0
  131. package/src/_types/core/EVM/types.d.ts.map +1 -1
  132. package/src/_types/core/Solana/SolanaStepExecutor.d.ts.map +1 -1
  133. package/src/_types/core/Solana/connection.d.ts +2 -3
  134. package/src/_types/core/Solana/connection.d.ts.map +1 -1
  135. package/src/_types/core/Solana/parseSolanaErrors.d.ts +4 -0
  136. package/src/_types/core/Solana/parseSolanaErrors.d.ts.map +1 -0
  137. package/src/_types/core/stepComparison.d.ts.map +1 -1
  138. package/src/_types/core/types.d.ts +3 -0
  139. package/src/_types/core/types.d.ts.map +1 -1
  140. package/src/_types/errors/SDKError.d.ts +12 -0
  141. package/src/_types/errors/SDKError.d.ts.map +1 -0
  142. package/src/_types/errors/baseError.d.ts +7 -0
  143. package/src/_types/errors/baseError.d.ts.map +1 -0
  144. package/src/_types/errors/constants.d.ts +43 -0
  145. package/src/_types/errors/constants.d.ts.map +1 -0
  146. package/src/_types/errors/errors.d.ts +24 -0
  147. package/src/_types/errors/errors.d.ts.map +1 -0
  148. package/src/_types/errors/httpError.d.ts +21 -0
  149. package/src/_types/errors/httpError.d.ts.map +1 -0
  150. package/src/_types/errors/index.d.ts +8 -0
  151. package/src/_types/errors/index.d.ts.map +1 -0
  152. package/src/_types/errors/utils/baseErrorRootCause.d.ts +4 -0
  153. package/src/_types/errors/utils/baseErrorRootCause.d.ts.map +1 -0
  154. package/src/_types/errors/utils/rootCause.d.ts +2 -0
  155. package/src/_types/errors/utils/rootCause.d.ts.map +1 -0
  156. package/src/_types/helpers.d.ts +5 -4
  157. package/src/_types/helpers.d.ts.map +1 -1
  158. package/src/_types/index.d.ts +2 -2
  159. package/src/_types/index.d.ts.map +1 -1
  160. package/src/_types/request.d.ts +1 -5
  161. package/src/_types/request.d.ts.map +1 -1
  162. package/src/_types/services/api.d.ts.map +1 -1
  163. package/src/_types/services/balance.d.ts +3 -3
  164. package/src/_types/types/request.d.ts +4 -0
  165. package/src/_types/types/request.d.ts.map +1 -0
  166. package/src/_types/utils/errors.d.ts +0 -109
  167. package/src/_types/utils/errors.d.ts.map +1 -1
  168. package/src/_types/utils/index.d.ts +1 -2
  169. package/src/_types/utils/index.d.ts.map +1 -1
  170. package/src/_types/version.d.ts +1 -1
  171. package/src/_types/version.d.ts.map +1 -1
  172. package/src/core/EVM/EVMStepExecutor.ts +14 -12
  173. package/src/core/EVM/checkAllowance.ts +5 -10
  174. package/src/core/EVM/multisig.ts +2 -1
  175. package/src/core/EVM/parseEVMErrors.ts +60 -0
  176. package/src/core/EVM/publicClient.ts +9 -4
  177. package/src/core/EVM/setAllowance.ts +2 -6
  178. package/src/core/EVM/switchChain.ts +2 -1
  179. package/src/core/EVM/types.ts +3 -0
  180. package/src/core/Solana/SolanaStepExecutor.ts +67 -34
  181. package/src/core/Solana/connection.ts +2 -3
  182. package/src/core/Solana/parseSolanaErrors.ts +45 -0
  183. package/src/core/checkBalance.ts +2 -2
  184. package/src/core/stepComparison.ts +3 -4
  185. package/src/core/types.ts +3 -0
  186. package/src/core/waitForReceivingTransaction.ts +1 -1
  187. package/src/errors/SDKError.ts +25 -0
  188. package/src/errors/baseError.ts +22 -0
  189. package/src/errors/constants.ts +45 -0
  190. package/src/errors/errors.ts +44 -0
  191. package/src/errors/httpError.ts +93 -0
  192. package/src/errors/index.ts +7 -0
  193. package/src/errors/utils/baseErrorRootCause.ts +18 -0
  194. package/src/errors/utils/rootCause.ts +7 -0
  195. package/src/helpers.ts +23 -16
  196. package/src/index.ts +2 -2
  197. package/src/request.ts +52 -38
  198. package/src/services/api.ts +109 -157
  199. package/src/services/balance.ts +4 -4
  200. package/src/types/request.ts +3 -0
  201. package/src/utils/errors.ts +0 -233
  202. package/src/utils/index.ts +1 -2
  203. package/src/version.ts +1 -1
  204. package/src/_cjs/utils/parseBackendError.js +0 -27
  205. package/src/_cjs/utils/parseBackendError.js.map +0 -1
  206. package/src/_cjs/utils/parseError.js +0 -69
  207. package/src/_cjs/utils/parseError.js.map +0 -1
  208. package/src/_esm/utils/parseBackendError.js +0 -24
  209. package/src/_esm/utils/parseBackendError.js.map +0 -1
  210. package/src/_esm/utils/parseError.js +0 -100
  211. package/src/_esm/utils/parseError.js.map +0 -1
  212. package/src/_types/utils/parseBackendError.d.ts +0 -3
  213. package/src/_types/utils/parseBackendError.d.ts.map +0 -1
  214. package/src/_types/utils/parseError.d.ts +0 -35
  215. package/src/_types/utils/parseError.d.ts.map +0 -1
  216. package/src/utils/parseBackendError.ts +0 -50
  217. package/src/utils/parseError.ts +0 -210
@@ -4,7 +4,7 @@ import type { Token, TokenAmount } from '@lifi/types';
4
4
  * @param walletAddress - A wallet address.
5
5
  * @param token - A Token object.
6
6
  * @returns An object containing the token and the amounts on different chains.
7
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
7
+ * @throws {BaseError} Throws a ValidationError if parameters are invalid.
8
8
  */
9
9
  export declare const getTokenBalance: (walletAddress: string, token: Token) => Promise<TokenAmount | null>;
10
10
  /**
@@ -12,7 +12,7 @@ export declare const getTokenBalance: (walletAddress: string, token: Token) => P
12
12
  * @param walletAddress - A wallet address.
13
13
  * @param tokens - A list of Token objects.
14
14
  * @returns A list of objects containing the tokens and the amounts on different chains.
15
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
15
+ * @throws {BaseError} Throws a ValidationError if parameters are invalid.
16
16
  */
17
17
  export declare const getTokenBalances: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
18
18
  /**
@@ -20,7 +20,7 @@ export declare const getTokenBalances: (walletAddress: string, tokens: Token[])
20
20
  * @param walletAddress - A walletaddress.
21
21
  * @param tokensByChain - A list of Token objects organized by chain ids.
22
22
  * @returns A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.
23
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
23
+ * @throws {BaseError} Throws a ValidationError if parameters are invalid.
24
24
  */
25
25
  export declare const getTokenBalancesByChain: (walletAddress: string, tokensByChain: {
26
26
  [chainId: number]: Token[];
@@ -0,0 +1,4 @@
1
+ export interface ExtendedRequestInit extends RequestInit {
2
+ retries?: number;
3
+ }
4
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../types/request.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
@@ -1,110 +1 @@
1
- declare enum ErrorType {
2
- RPCError = "RPCError",
3
- ProviderError = "ProviderError",
4
- ServerError = "ServerError",
5
- TransactionError = "TransactionError",
6
- ValidationError = "ValidationError",
7
- NotFoundError = "NotFoundError",
8
- UnknownError = "UnknownError",
9
- SlippageError = "SlippageError"
10
- }
11
- export declare enum LiFiErrorCode {
12
- InternalError = 1000,
13
- ValidationError = 1001,
14
- TransactionUnderpriced = 1002,
15
- TransactionFailed = 1003,
16
- Timeout = 1004,
17
- ProviderUnavailable = 1005,
18
- NotFound = 1006,
19
- ChainSwitchError = 1007,
20
- TransactionUnprepared = 1008,
21
- GasLimitError = 1009,
22
- TransactionCanceled = 1010,
23
- SlippageError = 1011,
24
- SignatureRejected = 1012,
25
- BalanceError = 1013,
26
- AllowanceRequired = 1014,
27
- InsufficientFunds = 1015,
28
- ExchangeRateUpdateCanceled = 1016,
29
- WalletChangedDuringExecution = 1017,
30
- TransactionExpired = 1018
31
- }
32
- export declare enum EthersErrorType {
33
- ActionRejected = "ACTION_REJECTED",
34
- CallExecption = "CALL_EXCEPTION",
35
- InsufficientFunds = "INSUFFICIENT_FUNDS"
36
- }
37
- export declare enum EthersErrorMessage {
38
- ERC20Allowance = "ERC20: transfer amount exceeds allowance",
39
- LowGas = "intrinsic gas too low",
40
- OutOfGas = "out of gas",
41
- Underpriced = "underpriced",
42
- LowReplacementFee = "replacement fee too low"
43
- }
44
- export declare enum ErrorMessage {
45
- UnknownError = "Unknown error occurred.",
46
- SlippageError = "The slippage is larger than the defined threshold. Please request a new route to get a fresh quote.",
47
- GasLimitLow = "Gas limit is too low.",
48
- TransactionUnderpriced = "Transaction is underpriced.",
49
- Default = "Something went wrong."
50
- }
51
- export declare enum MetaMaskRPCErrorCode {
52
- invalidInput = -32000,
53
- resourceNotFound = -32001,
54
- resourceUnavailable = -32002,
55
- transactionRejected = -32003,
56
- methodNotSupported = -32004,
57
- limitExceeded = -32005,
58
- parse = -32700,
59
- invalidRequest = -32600,
60
- methodNotFound = -32601,
61
- invalidParams = -32602,
62
- internal = -32603
63
- }
64
- export declare enum MetaMaskProviderErrorCode {
65
- userRejectedRequest = 4001,
66
- unauthorized = 4100,
67
- unsupportedMethod = 4200,
68
- disconnected = 4900,
69
- chainDisconnected = 4901
70
- }
71
- export type ErrorCode = LiFiErrorCode | MetaMaskRPCErrorCode | MetaMaskProviderErrorCode;
72
- export declare class LiFiError extends Error {
73
- code: ErrorCode;
74
- htmlMessage?: string;
75
- constructor(type: ErrorType, code: number, message: string, htmlMessage?: string, stack?: string);
76
- }
77
- export declare class RPCError extends LiFiError {
78
- constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
79
- }
80
- export declare class ProviderError extends LiFiError {
81
- constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
82
- }
83
- export declare class ServerError extends LiFiError {
84
- constructor(message: string, htmlMessage?: string, stack?: string);
85
- }
86
- export declare class ValidationError extends LiFiError {
87
- constructor(message: string, htmlMessage?: string, stack?: string);
88
- }
89
- export declare class TransactionError extends LiFiError {
90
- constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
91
- }
92
- export declare class SlippageError extends LiFiError {
93
- constructor(message: string, htmlMessage?: string, stack?: string);
94
- }
95
- export declare class BalanceError extends LiFiError {
96
- constructor(message: string, htmlMessage?: string, stack?: string);
97
- }
98
- export declare class NotFoundError extends LiFiError {
99
- constructor(message: string, htmlMessage?: string, stack?: string);
100
- }
101
- export declare class UnknownError extends LiFiError {
102
- constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
103
- }
104
- export declare class HTTPError extends Error {
105
- response: Response;
106
- status: number;
107
- constructor(response: Response);
108
- }
109
- export {};
110
1
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../utils/errors.ts"],"names":[],"mappings":"AAAA,aAAK,SAAS;IACZ,QAAQ,aAAa;IACrB,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;CAChC;AAED,oBAAY,aAAa;IACvB,aAAa,OAAO;IACpB,eAAe,OAAO;IACtB,sBAAsB,OAAO;IAC7B,iBAAiB,OAAO;IACxB,OAAO,OAAO;IACd,mBAAmB,OAAO;IAC1B,QAAQ,OAAO;IACf,gBAAgB,OAAO;IACvB,qBAAqB,OAAO;IAC5B,aAAa,OAAO;IACpB,mBAAmB,OAAO;IAC1B,aAAa,OAAO;IACpB,iBAAiB,OAAO;IACxB,YAAY,OAAO;IACnB,iBAAiB,OAAO;IACxB,iBAAiB,OAAO;IACxB,0BAA0B,OAAO;IACjC,4BAA4B,OAAO;IACnC,kBAAkB,OAAO;CAC1B;AAED,oBAAY,eAAe;IACzB,cAAc,oBAAoB;IAClC,aAAa,mBAAmB;IAChC,iBAAiB,uBAAuB;CACzC;AAED,oBAAY,kBAAkB;IAC5B,cAAc,6CAA6C;IAC3D,MAAM,0BAA0B;IAChC,QAAQ,eAAe;IACvB,WAAW,gBAAgB;IAC3B,iBAAiB,4BAA4B;CAC9C;AAED,oBAAY,YAAY;IACtB,YAAY,4BAA4B;IACxC,aAAa,wGAAwG;IACrH,WAAW,0BAA0B;IACrC,sBAAsB,gCAAgC;IACtD,OAAO,0BAA0B;CAClC;AAED,oBAAY,oBAAoB;IAC9B,YAAY,SAAS;IACrB,gBAAgB,SAAS;IACzB,mBAAmB,SAAS;IAC5B,mBAAmB,SAAS;IAC5B,kBAAkB,SAAS;IAC3B,aAAa,SAAS;IACtB,KAAK,SAAS;IACd,cAAc,SAAS;IACvB,cAAc,SAAS;IACvB,aAAa,SAAS;IACtB,QAAQ,SAAS;CAClB;AAED,oBAAY,yBAAyB;IACnC,mBAAmB,OAAO;IAC1B,YAAY,OAAO;IACnB,iBAAiB,OAAO;IACxB,YAAY,OAAO;IACnB,iBAAiB,OAAO;CACzB;AAED,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,oBAAoB,GACpB,yBAAyB,CAAA;AAE7B,qBAAa,SAAU,SAAQ,KAAK;IAClC,IAAI,EAAE,SAAS,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;gBAGlB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM;CAmBjB;AAED,qBAAa,QAAS,SAAQ,SAAS;gBAEnC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM;CAIjB;AAED,qBAAa,aAAc,SAAQ,SAAS;gBAExC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM;CAIjB;AAED,qBAAa,WAAY,SAAQ,SAAS;gBAC5B,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CASlE;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CASlE;AAED,qBAAa,gBAAiB,SAAQ,SAAS;gBAE3C,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM;CAIjB;AAED,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CASlE;AAED,qBAAa,YAAa,SAAQ,SAAS;gBAC7B,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CASlE;AAED,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CASlE;AAED,qBAAa,YAAa,SAAQ,SAAS;gBAEvC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM;CAIjB;AAED,qBAAa,SAAU,SAAQ,KAAK;IAC3B,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;gBAET,QAAQ,EAAE,QAAQ;CAY/B"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../utils/errors.ts"],"names":[],"mappings":""}
@@ -1,6 +1,5 @@
1
- export * from './errors.js';
1
+ export * from '../errors/index.js';
2
2
  export * from './getTransactionMessage.js';
3
3
  export * from './median.js';
4
- export * from './parseError.js';
5
4
  export * from './utils.js';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
@@ -1,3 +1,3 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "3.0.2-beta.0";
2
+ export declare const version = "3.1.0";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,iBAAiB,CAAA"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,UAAU,CAAA"}
@@ -13,13 +13,12 @@ import { publicActions } from 'viem'
13
13
  import { config } from '../../config.js'
14
14
  import { getStepTransaction } from '../../services/api.js'
15
15
  import {
16
- LiFiErrorCode,
17
- TransactionError,
18
- ValidationError,
19
16
  getTransactionFailedMessage,
20
17
  isZeroAddress,
21
- parseError,
22
18
  } from '../../utils/index.js'
19
+ import { ValidationError, TransactionError } from '../../errors/errors.js'
20
+ import { LiFiErrorCode } from '../../errors/constants.js'
21
+ import { parseEVMErrors } from './parseEVMErrors.js'
23
22
  import { BaseStepExecutor } from '../BaseStepExecutor.js'
24
23
  import { checkBalance } from '../checkBalance.js'
25
24
  import { getSubstatusMessage } from '../processMessages.js'
@@ -87,9 +86,13 @@ export class EVMStepExecutor extends BaseStepExecutor {
87
86
  },
88
87
  })
89
88
  this.statusManager.updateExecution(step, 'FAILED')
90
- throw new TransactionError(
91
- LiFiErrorCode.WalletChangedDuringExecution,
92
- errorMessage
89
+ throw await parseEVMErrors(
90
+ new TransactionError(
91
+ LiFiErrorCode.WalletChangedDuringExecution,
92
+ errorMessage
93
+ ),
94
+ step,
95
+ process
93
96
  )
94
97
  }
95
98
  return updatedWalletClient
@@ -397,20 +400,20 @@ export class EVMStepExecutor extends BaseStepExecutor {
397
400
  process = this.statusManager.updateProcess(step, process.type, 'DONE')
398
401
  }
399
402
  } catch (e: any) {
400
- const error = await parseError(e, step, process)
403
+ const error = await parseEVMErrors(e, step, process)
401
404
  process = this.statusManager.updateProcess(
402
405
  step,
403
406
  process.type,
404
407
  'FAILED',
405
408
  {
406
409
  error: {
407
- message: error.message,
408
- htmlMessage: error.htmlMessage,
410
+ message: error.cause.message,
409
411
  code: error.code,
410
412
  },
411
413
  }
412
414
  )
413
415
  this.statusManager.updateExecution(step, 'FAILED')
416
+
414
417
  throw error
415
418
  }
416
419
  }
@@ -479,8 +482,7 @@ export class EVMStepExecutor extends BaseStepExecutor {
479
482
  },
480
483
  })
481
484
  this.statusManager.updateExecution(step, 'FAILED')
482
- console.warn(e)
483
- throw e
485
+ throw await parseEVMErrors(e as Error, step, process)
484
486
  }
485
487
 
486
488
  // DONE
@@ -1,10 +1,9 @@
1
1
  import type { Chain, LiFiStep, Process, ProcessType } from '@lifi/types'
2
2
  import type { Address, Hash, WalletClient } from 'viem'
3
- import { maxUint256 } from 'viem'
4
- import { parseError } from '../../utils/parseError.js'
5
3
  import type { StatusManager } from '../StatusManager.js'
6
4
  import type { ExecutionOptions } from '../types.js'
7
5
  import { getAllowance } from './getAllowance.js'
6
+ import { parseEVMErrors } from './parseEVMErrors.js'
8
7
  import { setAllowance } from './setAllowance.js'
9
8
  import { waitForTransactionReceipt } from './waitForTransactionReceipt.js'
10
9
 
@@ -54,16 +53,13 @@ export const checkAllowance = async (
54
53
  if (!allowUserInteraction) {
55
54
  return
56
55
  }
57
- const approvalAmount = settings?.infiniteApproval
58
- ? maxUint256
59
- : fromAmount
60
56
 
61
57
  if (shouldBatchTransactions) {
62
58
  const approveTxHash = await setAllowance(
63
59
  walletClient,
64
60
  step.action.fromToken.address,
65
61
  step.estimate.approvalAddress,
66
- approvalAmount,
62
+ fromAmount,
67
63
  settings,
68
64
  true
69
65
  )
@@ -81,7 +77,7 @@ export const checkAllowance = async (
81
77
  walletClient,
82
78
  step.action.fromToken.address,
83
79
  step.estimate.approvalAddress,
84
- approvalAmount
80
+ fromAmount
85
81
  )
86
82
  await waitForApprovalTransaction(
87
83
  walletClient,
@@ -100,15 +96,14 @@ export const checkAllowance = async (
100
96
  }
101
97
  }
102
98
  } catch (e: any) {
103
- const error = await parseError(e, step, allowanceProcess)
99
+ const error = await parseEVMErrors(e, step, allowanceProcess)
104
100
  allowanceProcess = statusManager.updateProcess(
105
101
  step,
106
102
  allowanceProcess.type,
107
103
  'FAILED',
108
104
  {
109
105
  error: {
110
- message: error.message,
111
- htmlMessage: error.htmlMessage,
106
+ message: error.cause.message,
112
107
  code: error.code,
113
108
  },
114
109
  }
@@ -1,6 +1,7 @@
1
1
  import type { ExtendedChain, LiFiStep, ProcessType } from '@lifi/types'
2
2
  import type { Hash } from 'viem'
3
- import { LiFiErrorCode, TransactionError } from '../../utils/errors.js'
3
+ import { LiFiErrorCode } from '../../errors/constants.js'
4
+ import { TransactionError } from '../../errors/errors.js'
4
5
  import type { StatusManager } from '../StatusManager.js'
5
6
  import type { MultisigConfig, MultisigTxDetails } from './types.js'
6
7
 
@@ -0,0 +1,60 @@
1
+ import { type LiFiStep, type Process } from '@lifi/types'
2
+ import { TransactionError, UnknownError } from '../../errors/errors.js'
3
+ import { SDKError } from '../../errors/SDKError.js'
4
+ import { ErrorMessage, LiFiErrorCode } from '../../errors/constants.js'
5
+ import { BaseError } from '../../utils/index.js'
6
+ import { fetchTxErrorDetails } from '../../helpers.js'
7
+
8
+ export const parseEVMErrors = async (
9
+ e: Error,
10
+ step?: LiFiStep,
11
+ process?: Process
12
+ ): Promise<SDKError> => {
13
+ if (e instanceof SDKError) {
14
+ e.step = e.step ?? step
15
+ e.process = e.process ?? process
16
+ return e
17
+ }
18
+
19
+ const baseError = await handleSpecificErrors(e, step, process)
20
+
21
+ return new SDKError(baseError, step, process)
22
+ }
23
+
24
+ const handleSpecificErrors = async (
25
+ e: any,
26
+ step?: LiFiStep,
27
+ process?: Process
28
+ ) => {
29
+ if (e.cause?.name === 'UserRejectedRequestError') {
30
+ return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)
31
+ }
32
+
33
+ if (
34
+ step &&
35
+ process?.txHash &&
36
+ e.code === LiFiErrorCode.TransactionFailed &&
37
+ e.message === ErrorMessage.TransactionReverted
38
+ ) {
39
+ const response = await fetchTxErrorDetails(
40
+ process.txHash,
41
+ step.action.fromChainId
42
+ )
43
+
44
+ const errorMessage = response?.error_message
45
+
46
+ if (errorMessage?.toLowerCase().includes('out of gas')) {
47
+ return new TransactionError(
48
+ LiFiErrorCode.GasLimitError,
49
+ ErrorMessage.GasLimitLow,
50
+ e
51
+ )
52
+ }
53
+ }
54
+
55
+ if (e instanceof BaseError) {
56
+ return e
57
+ }
58
+
59
+ return new UnknownError(e.message || ErrorMessage.UnknownError, e)
60
+ }
@@ -1,6 +1,6 @@
1
1
  import { ChainId } from '@lifi/types'
2
2
  import type { PublicClient } from 'viem'
3
- import { createPublicClient, fallback, http } from 'viem'
3
+ import { createPublicClient, fallback, http, webSocket } from 'viem'
4
4
  import { mainnet, type Chain } from 'viem/chains'
5
5
  import { config } from '../../config.js'
6
6
  import { getRpcUrls } from '../rpc.js'
@@ -19,9 +19,11 @@ export const getPublicClient = async (
19
19
  if (!publicClients[chainId]) {
20
20
  const urls = await getRpcUrls(chainId)
21
21
  const fallbackTransports = urls.map((url) =>
22
- http(url, {
23
- batch: true,
24
- })
22
+ url.startsWith('wss')
23
+ ? webSocket(url)
24
+ : http(url, {
25
+ batch: true,
26
+ })
25
27
  )
26
28
  const _chain = await config.getChainById(chainId)
27
29
  const chain: Chain = {
@@ -43,6 +45,9 @@ export const getPublicClient = async (
43
45
  publicClients[chainId] = createPublicClient({
44
46
  chain: chain,
45
47
  transport: fallback(fallbackTransports),
48
+ batch: {
49
+ multicall: true,
50
+ },
46
51
  })
47
52
  }
48
53
 
@@ -4,7 +4,7 @@ import type {
4
4
  SendTransactionParameters,
5
5
  WalletClient,
6
6
  } from 'viem'
7
- import { encodeFunctionData, maxUint256, publicActions } from 'viem'
7
+ import { encodeFunctionData, publicActions } from 'viem'
8
8
  import { isNativeTokenAddress } from '../../utils/utils.js'
9
9
  import type { ExecutionOptions, TransactionParameters } from '../types.js'
10
10
  import { approveAbi } from './abi.js'
@@ -72,7 +72,6 @@ export const setAllowance = async (
72
72
  * @param request.token - The token for which to set the allowance
73
73
  * @param request.spenderAddress - The address of the spender
74
74
  * @param request.amount - The amount of tokens to approve
75
- * @param request.infiniteApproval - If true, sets the approval to the maximum uint256 value
76
75
  * @returns Returns Hash or nothing
77
76
  */
78
77
  export const setTokenAllowance = async ({
@@ -80,7 +79,6 @@ export const setTokenAllowance = async ({
80
79
  token,
81
80
  spenderAddress,
82
81
  amount,
83
- infiniteApproval = false,
84
82
  }: ApproveTokenRequest): Promise<Hash | void> => {
85
83
  // native token don't need approval
86
84
  if (isNativeTokenAddress(token.address)) {
@@ -94,13 +92,11 @@ export const setTokenAllowance = async ({
94
92
  )
95
93
 
96
94
  if (amount > approvedAmount) {
97
- const approvalAmount = infiniteApproval ? maxUint256 : amount
98
-
99
95
  const approveTx = await setAllowance(
100
96
  walletClient,
101
97
  token.address,
102
98
  spenderAddress,
103
- approvalAmount
99
+ amount
104
100
  )
105
101
 
106
102
  return approveTx
@@ -1,5 +1,6 @@
1
1
  import type { WalletClient } from 'viem'
2
- import { LiFiErrorCode, ProviderError } from '../../utils/errors.js'
2
+ import { LiFiErrorCode } from '../../errors/constants.js'
3
+ import { ProviderError } from '../../errors/errors.js'
3
4
  import type { StatusManager } from '../StatusManager.js'
4
5
  import type { LiFiStepExtended, SwitchChainHook } from '../types.js'
5
6
 
@@ -39,6 +39,9 @@ export interface ApproveTokenRequest {
39
39
  token: BaseToken
40
40
  spenderAddress: string
41
41
  amount: bigint
42
+ /**
43
+ * @deprecated
44
+ */
42
45
  infiniteApproval?: boolean
43
46
  }
44
47
 
@@ -6,15 +6,13 @@ import {
6
6
  type SendOptions,
7
7
  type SignatureResult,
8
8
  } from '@solana/web3.js'
9
+ import bs58 from 'bs58'
9
10
  import { config } from '../../config.js'
11
+ import { LiFiErrorCode } from '../../errors/constants.js'
12
+ import { TransactionError } from '../../errors/errors.js'
10
13
  import { getStepTransaction } from '../../services/api.js'
11
14
  import { base64ToUint8Array } from '../../utils/base64ToUint8Array.js'
12
- import {
13
- LiFiErrorCode,
14
- TransactionError,
15
- getTransactionFailedMessage,
16
- parseError,
17
- } from '../../utils/index.js'
15
+ import { getTransactionFailedMessage } from '../../utils/index.js'
18
16
  import { BaseStepExecutor } from '../BaseStepExecutor.js'
19
17
  import { checkBalance } from '../checkBalance.js'
20
18
  import { getSubstatusMessage } from '../processMessages.js'
@@ -27,15 +25,12 @@ import type {
27
25
  import { sleep } from '../utils.js'
28
26
  import { waitForReceivingTransaction } from '../waitForReceivingTransaction.js'
29
27
  import { getSolanaConnection } from './connection.js'
28
+ import { parseSolanaErrors } from './parseSolanaErrors.js'
30
29
 
31
30
  export interface SolanaStepExecutorOptions extends StepExecutorOptions {
32
31
  walletAdapter: SignerWalletAdapter
33
32
  }
34
33
 
35
- const TX_RETRY_INTERVAL = 1000
36
- // https://solana.com/docs/advanced/confirmation
37
- const TIMEOUT_PERIOD = 60_000
38
-
39
34
  export class SolanaStepExecutor extends BaseStepExecutor {
40
35
  private walletAdapter: SignerWalletAdapter
41
36
 
@@ -149,8 +144,23 @@ export class SolanaStepExecutor extends BaseStepExecutor {
149
144
 
150
145
  this.checkWalletAdapter(step)
151
146
 
152
- const signedTx =
153
- await this.walletAdapter.signTransaction(versionedTransaction)
147
+ const signedTxPromise =
148
+ this.walletAdapter.signTransaction(versionedTransaction)
149
+
150
+ // We give users 2 minutes to sign the transaction or it should be considered expired
151
+ const signedTx = await Promise.race([
152
+ signedTxPromise,
153
+ // https://solana.com/docs/advanced/confirmation#transaction-expiration
154
+ // Use 2 minutes to account for fluctuations
155
+ sleep(120_000),
156
+ ])
157
+
158
+ if (!signedTx) {
159
+ throw new TransactionError(
160
+ LiFiErrorCode.TransactionExpired,
161
+ 'Transaction has expired: blockhash is no longer recent enough.'
162
+ )
163
+ }
154
164
 
155
165
  process = this.statusManager.updateProcess(
156
166
  step,
@@ -158,21 +168,31 @@ export class SolanaStepExecutor extends BaseStepExecutor {
158
168
  'PENDING'
159
169
  )
160
170
 
161
- const rawTransactionOptions: SendOptions = {
162
- // Skipping preflight i.e. tx simulation by RPC as we simulated the tx above
163
- skipPreflight: true,
164
- // Setting max retries to 0 as we are handling retries manually
165
- // Set this manually so that the default is skipped
166
- maxRetries: 0,
167
- // https://solana.com/docs/advanced/confirmation#use-an-appropriate-preflight-commitment-level
168
- preflightCommitment: 'confirmed',
169
- // minContextSlot: blockhashResult.context.slot,
171
+ const simulationResult = await connection.simulateTransaction(
172
+ signedTx,
173
+ {
174
+ commitment: 'processed',
175
+ replaceRecentBlockhash: true,
176
+ }
177
+ )
178
+
179
+ if (simulationResult.value.err) {
180
+ throw new TransactionError(
181
+ LiFiErrorCode.TransactionSimulationFailed,
182
+ 'Transaction simulation failed'
183
+ )
170
184
  }
171
185
 
172
- const txSignature = await connection.sendRawTransaction(
173
- signedTx.serialize(),
174
- rawTransactionOptions
175
- )
186
+ // Create transaction hash (signature)
187
+ const txSignature = bs58.encode(signedTx.signatures[0])
188
+
189
+ // A known weirdness - MAX_RECENT_BLOCKHASHES is 300
190
+ // https://github.com/solana-labs/solana/blob/master/sdk/program/src/clock.rs#L123
191
+ // but MAX_PROCESSING_AGE is 150
192
+ // https://github.com/solana-labs/solana/blob/master/sdk/program/src/clock.rs#L129
193
+ // the blockhash queue in the bank tells you 300 + current slot, but it won't be accepted 150 blocks later.
194
+ // https://solana.com/docs/advanced/confirmation#transaction-expiration
195
+ const lastValidBlockHeight = blockhashResult.lastValidBlockHeight - 150
176
196
 
177
197
  // In the following section, we wait and constantly check for the transaction to be confirmed
178
198
  // and resend the transaction if it is not confirmed within a certain time interval
@@ -183,7 +203,7 @@ export class SolanaStepExecutor extends BaseStepExecutor {
183
203
  {
184
204
  signature: txSignature,
185
205
  blockhash: blockhashResult.blockhash,
186
- lastValidBlockHeight: blockhashResult.lastValidBlockHeight,
206
+ lastValidBlockHeight: lastValidBlockHeight,
187
207
  abortSignal: abortController.signal,
188
208
  },
189
209
  'confirmed'
@@ -191,20 +211,34 @@ export class SolanaStepExecutor extends BaseStepExecutor {
191
211
  .then((result) => result.value)
192
212
 
193
213
  let confirmedTx: SignatureResult | null = null
194
- const startTime = Date.now()
214
+ let blockHeight = await connection.getBlockHeight()
215
+
216
+ const rawTransactionOptions: SendOptions = {
217
+ // We can skip preflight check after the first transaction has been sent
218
+ // https://solana.com/docs/advanced/retry#the-cost-of-skipping-preflight
219
+ skipPreflight: true,
220
+ // Setting max retries to 0 as we are handling retries manually
221
+ maxRetries: 0,
222
+ // https://solana.com/docs/advanced/confirmation#use-an-appropriate-preflight-commitment-level
223
+ preflightCommitment: 'confirmed',
224
+ }
225
+
226
+ const signedTxSerialized = signedTx.serialize()
195
227
 
196
- while (!confirmedTx && Date.now() - startTime <= TIMEOUT_PERIOD) {
228
+ // https://solana.com/docs/advanced/retry#customizing-rebroadcast-logic
229
+ while (!confirmedTx && blockHeight < lastValidBlockHeight) {
197
230
  await connection.sendRawTransaction(
198
- signedTx.serialize(),
231
+ signedTxSerialized,
199
232
  rawTransactionOptions
200
233
  )
201
234
  confirmedTx = await Promise.race([
202
235
  confirmTransactionPromise,
203
- sleep(TX_RETRY_INTERVAL),
236
+ sleep(1000),
204
237
  ])
205
238
  if (confirmedTx) {
206
239
  break
207
240
  }
241
+ blockHeight = await connection.getBlockHeight()
208
242
  }
209
243
 
210
244
  // Stop waiting for tx confirmation
@@ -233,7 +267,7 @@ export class SolanaStepExecutor extends BaseStepExecutor {
233
267
  if (!confirmedTx) {
234
268
  throw new TransactionError(
235
269
  LiFiErrorCode.TransactionExpired,
236
- 'Failed to land the transaction'
270
+ 'Transaction has expired: The block height has exceeded the maximum allowed limit.'
237
271
  )
238
272
  }
239
273
 
@@ -252,15 +286,14 @@ export class SolanaStepExecutor extends BaseStepExecutor {
252
286
  process = this.statusManager.updateProcess(step, process.type, 'DONE')
253
287
  }
254
288
  } catch (e: any) {
255
- const error = await parseError(e, step, process)
289
+ const error = await parseSolanaErrors(e, step, process)
256
290
  process = this.statusManager.updateProcess(
257
291
  step,
258
292
  process.type,
259
293
  'FAILED',
260
294
  {
261
295
  error: {
262
- message: error.message,
263
- htmlMessage: error.htmlMessage,
296
+ message: error.cause.message,
264
297
  code: error.code,
265
298
  },
266
299
  }
@@ -5,9 +5,8 @@ import { getRpcUrl } from '../rpc.js'
5
5
  let connection: Connection | undefined = undefined
6
6
 
7
7
  /**
8
- * getSolanaConnection is just a thin wrapper around getting the
9
- * connection (rpc provider) for Solana
10
- * @returns - Solana rpc connection
8
+ * getSolanaConnection is just a thin wrapper around getting the connection (RPC provider) for Solana
9
+ * @returns - Solana RPC connection
11
10
  */
12
11
  export const getSolanaConnection = async (): Promise<Connection> => {
13
12
  if (!connection) {