lampamazaza-new-internal-utils 0.24.3

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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +43 -0
  3. package/dist/_virtual/rolldown_runtime.js +18 -0
  4. package/dist/config.cjs +82 -0
  5. package/dist/config.d.cts +42 -0
  6. package/dist/config.d.ts +42 -0
  7. package/dist/config.js +72 -0
  8. package/dist/errors/assert.cjs +11 -0
  9. package/dist/errors/assert.d.cts +11 -0
  10. package/dist/errors/assert.d.ts +11 -0
  11. package/dist/errors/assert.js +11 -0
  12. package/dist/errors/base.cjs +34 -0
  13. package/dist/errors/base.d.cts +21 -0
  14. package/dist/errors/base.d.ts +21 -0
  15. package/dist/errors/base.js +33 -0
  16. package/dist/errors/index.cjs +23 -0
  17. package/dist/errors/index.d.cts +11 -0
  18. package/dist/errors/index.d.ts +11 -0
  19. package/dist/errors/index.js +18 -0
  20. package/dist/errors/request.cjs +48 -0
  21. package/dist/errors/request.d.cts +61 -0
  22. package/dist/errors/request.d.ts +61 -0
  23. package/dist/errors/request.js +46 -0
  24. package/dist/errors/utils/isNetworkError.cjs +23 -0
  25. package/dist/errors/utils/isNetworkError.js +22 -0
  26. package/dist/errors/utils/toError.cjs +8 -0
  27. package/dist/errors/utils/toError.d.cts +4 -0
  28. package/dist/errors/utils/toError.d.ts +4 -0
  29. package/dist/errors/utils/toError.js +7 -0
  30. package/dist/index.cjs +125 -0
  31. package/dist/index.d.cts +30 -0
  32. package/dist/index.d.ts +30 -0
  33. package/dist/index.js +30 -0
  34. package/dist/logger.d.cts +11 -0
  35. package/dist/logger.d.ts +11 -0
  36. package/dist/nearClient.cjs +18 -0
  37. package/dist/nearClient.d.cts +8 -0
  38. package/dist/nearClient.d.ts +8 -0
  39. package/dist/nearClient.js +18 -0
  40. package/dist/poaBridge/constants/blockchains.cjs +57 -0
  41. package/dist/poaBridge/constants/blockchains.d.cts +86 -0
  42. package/dist/poaBridge/constants/blockchains.d.ts +86 -0
  43. package/dist/poaBridge/constants/blockchains.js +54 -0
  44. package/dist/poaBridge/errors/withdrawal.cjs +52 -0
  45. package/dist/poaBridge/errors/withdrawal.d.cts +34 -0
  46. package/dist/poaBridge/errors/withdrawal.d.ts +34 -0
  47. package/dist/poaBridge/errors/withdrawal.js +50 -0
  48. package/dist/poaBridge/getPendingDeposits.cjs +9 -0
  49. package/dist/poaBridge/getPendingDeposits.d.cts +12 -0
  50. package/dist/poaBridge/getPendingDeposits.d.ts +13 -0
  51. package/dist/poaBridge/getPendingDeposits.js +9 -0
  52. package/dist/poaBridge/index.cjs +23 -0
  53. package/dist/poaBridge/index.d.cts +11 -0
  54. package/dist/poaBridge/index.d.ts +11 -0
  55. package/dist/poaBridge/index.js +18 -0
  56. package/dist/poaBridge/poaBridgeHttpClient/apis.cjs +38 -0
  57. package/dist/poaBridge/poaBridgeHttpClient/apis.d.cts +12 -0
  58. package/dist/poaBridge/poaBridgeHttpClient/apis.d.ts +12 -0
  59. package/dist/poaBridge/poaBridgeHttpClient/apis.js +32 -0
  60. package/dist/poaBridge/poaBridgeHttpClient/index.cjs +21 -0
  61. package/dist/poaBridge/poaBridgeHttpClient/index.d.cts +9 -0
  62. package/dist/poaBridge/poaBridgeHttpClient/index.d.ts +9 -0
  63. package/dist/poaBridge/poaBridgeHttpClient/index.js +16 -0
  64. package/dist/poaBridge/poaBridgeHttpClient/runtime.cjs +49 -0
  65. package/dist/poaBridge/poaBridgeHttpClient/runtime.js +47 -0
  66. package/dist/poaBridge/poaBridgeHttpClient/types.d.cts +161 -0
  67. package/dist/poaBridge/poaBridgeHttpClient/types.d.ts +161 -0
  68. package/dist/poaBridge/waitForWithdrawalCompletion.cjs +57 -0
  69. package/dist/poaBridge/waitForWithdrawalCompletion.d.cts +31 -0
  70. package/dist/poaBridge/waitForWithdrawalCompletion.d.ts +31 -0
  71. package/dist/poaBridge/waitForWithdrawalCompletion.js +56 -0
  72. package/dist/services/blockchainBalanceService.cjs +40 -0
  73. package/dist/services/blockchainBalanceService.d.cts +21 -0
  74. package/dist/services/blockchainBalanceService.d.ts +21 -0
  75. package/dist/services/blockchainBalanceService.js +37 -0
  76. package/dist/solverRelay/errors/intentSettlement.cjs +20 -0
  77. package/dist/solverRelay/errors/intentSettlement.d.cts +13 -0
  78. package/dist/solverRelay/errors/intentSettlement.d.ts +13 -0
  79. package/dist/solverRelay/errors/intentSettlement.js +20 -0
  80. package/dist/solverRelay/errors/quote.cjs +18 -0
  81. package/dist/solverRelay/errors/quote.d.cts +21 -0
  82. package/dist/solverRelay/errors/quote.d.ts +22 -0
  83. package/dist/solverRelay/errors/quote.js +18 -0
  84. package/dist/solverRelay/getQuote.cjs +49 -0
  85. package/dist/solverRelay/getQuote.d.cts +14 -0
  86. package/dist/solverRelay/getQuote.d.ts +14 -0
  87. package/dist/solverRelay/getQuote.js +49 -0
  88. package/dist/solverRelay/getStatus.cjs +26 -0
  89. package/dist/solverRelay/getStatus.d.cts +17 -0
  90. package/dist/solverRelay/getStatus.d.ts +18 -0
  91. package/dist/solverRelay/getStatus.js +26 -0
  92. package/dist/solverRelay/index.cjs +27 -0
  93. package/dist/solverRelay/index.d.cts +16 -0
  94. package/dist/solverRelay/index.d.ts +16 -0
  95. package/dist/solverRelay/index.js +22 -0
  96. package/dist/solverRelay/publishIntent.cjs +20 -0
  97. package/dist/solverRelay/publishIntent.d.cts +15 -0
  98. package/dist/solverRelay/publishIntent.d.ts +16 -0
  99. package/dist/solverRelay/publishIntent.js +20 -0
  100. package/dist/solverRelay/publishIntents.cjs +43 -0
  101. package/dist/solverRelay/publishIntents.d.cts +10 -0
  102. package/dist/solverRelay/publishIntents.d.ts +11 -0
  103. package/dist/solverRelay/publishIntents.js +42 -0
  104. package/dist/solverRelay/solverRelayHttpClient/apis.cjs +21 -0
  105. package/dist/solverRelay/solverRelayHttpClient/apis.d.cts +9 -0
  106. package/dist/solverRelay/solverRelayHttpClient/apis.d.ts +9 -0
  107. package/dist/solverRelay/solverRelayHttpClient/apis.js +18 -0
  108. package/dist/solverRelay/solverRelayHttpClient/index.cjs +18 -0
  109. package/dist/solverRelay/solverRelayHttpClient/index.d.cts +9 -0
  110. package/dist/solverRelay/solverRelayHttpClient/index.d.ts +9 -0
  111. package/dist/solverRelay/solverRelayHttpClient/index.js +13 -0
  112. package/dist/solverRelay/solverRelayHttpClient/runtime.cjs +60 -0
  113. package/dist/solverRelay/solverRelayHttpClient/runtime.js +58 -0
  114. package/dist/solverRelay/solverRelayHttpClient/types.d.cts +109 -0
  115. package/dist/solverRelay/solverRelayHttpClient/types.d.ts +109 -0
  116. package/dist/solverRelay/utils/parseFailedPublishError.cjs +40 -0
  117. package/dist/solverRelay/utils/parseFailedPublishError.d.cts +25 -0
  118. package/dist/solverRelay/utils/parseFailedPublishError.d.ts +26 -0
  119. package/dist/solverRelay/utils/parseFailedPublishError.js +39 -0
  120. package/dist/solverRelay/utils/quoteWithLog.cjs +21 -0
  121. package/dist/solverRelay/utils/quoteWithLog.d.cts +12 -0
  122. package/dist/solverRelay/utils/quoteWithLog.d.ts +14 -0
  123. package/dist/solverRelay/utils/quoteWithLog.js +21 -0
  124. package/dist/solverRelay/waitForIntentSettlement.cjs +52 -0
  125. package/dist/solverRelay/waitForIntentSettlement.d.cts +30 -0
  126. package/dist/solverRelay/waitForIntentSettlement.d.ts +30 -0
  127. package/dist/solverRelay/waitForIntentSettlement.js +52 -0
  128. package/dist/types/authHandle.cjs +22 -0
  129. package/dist/types/authHandle.d.cts +25 -0
  130. package/dist/types/authHandle.d.ts +25 -0
  131. package/dist/types/authHandle.js +16 -0
  132. package/dist/types/base.d.cts +45 -0
  133. package/dist/types/base.d.ts +45 -0
  134. package/dist/types/intentsUserId.d.cts +10 -0
  135. package/dist/types/intentsUserId.d.ts +10 -0
  136. package/dist/types/walletMessage.cjs +11 -0
  137. package/dist/types/walletMessage.d.cts +106 -0
  138. package/dist/types/walletMessage.d.ts +106 -0
  139. package/dist/types/walletMessage.js +5 -0
  140. package/dist/utils/abortSignal.cjs +19 -0
  141. package/dist/utils/abortSignal.js +18 -0
  142. package/dist/utils/appFee.cjs +20 -0
  143. package/dist/utils/appFee.d.cts +9 -0
  144. package/dist/utils/appFee.d.ts +9 -0
  145. package/dist/utils/appFee.js +15 -0
  146. package/dist/utils/assert.cjs +9 -0
  147. package/dist/utils/assert.d.cts +7 -0
  148. package/dist/utils/assert.d.ts +7 -0
  149. package/dist/utils/assert.js +9 -0
  150. package/dist/utils/authIdentity.cjs +56 -0
  151. package/dist/utils/authIdentity.d.cts +34 -0
  152. package/dist/utils/authIdentity.d.ts +34 -0
  153. package/dist/utils/authIdentity.js +50 -0
  154. package/dist/utils/failover.cjs +22 -0
  155. package/dist/utils/failover.d.cts +16 -0
  156. package/dist/utils/failover.d.ts +16 -0
  157. package/dist/utils/failover.js +20 -0
  158. package/dist/utils/handleRPCResponse.cjs +30 -0
  159. package/dist/utils/handleRPCResponse.js +28 -0
  160. package/dist/utils/index.cjs +55 -0
  161. package/dist/utils/index.d.cts +13 -0
  162. package/dist/utils/index.d.ts +13 -0
  163. package/dist/utils/index.js +50 -0
  164. package/dist/utils/messageFactory.cjs +137 -0
  165. package/dist/utils/messageFactory.d.cts +70 -0
  166. package/dist/utils/messageFactory.d.ts +70 -0
  167. package/dist/utils/messageFactory.js +132 -0
  168. package/dist/utils/multiPayload/webauthn.cjs +27 -0
  169. package/dist/utils/multiPayload/webauthn.js +26 -0
  170. package/dist/utils/near.cjs +58 -0
  171. package/dist/utils/near.d.cts +35 -0
  172. package/dist/utils/near.d.ts +35 -0
  173. package/dist/utils/near.js +53 -0
  174. package/dist/utils/poll.cjs +87 -0
  175. package/dist/utils/poll.d.cts +54 -0
  176. package/dist/utils/poll.d.ts +54 -0
  177. package/dist/utils/poll.js +85 -0
  178. package/dist/utils/prepareBroadcastRequest.cjs +98 -0
  179. package/dist/utils/prepareBroadcastRequest.d.cts +16 -0
  180. package/dist/utils/prepareBroadcastRequest.d.ts +16 -0
  181. package/dist/utils/prepareBroadcastRequest.js +90 -0
  182. package/dist/utils/promise/withTimeout.cjs +34 -0
  183. package/dist/utils/promise/withTimeout.d.cts +16 -0
  184. package/dist/utils/promise/withTimeout.d.ts +16 -0
  185. package/dist/utils/promise/withTimeout.js +34 -0
  186. package/dist/utils/request.cjs +100 -0
  187. package/dist/utils/request.d.cts +27 -0
  188. package/dist/utils/request.d.ts +27 -0
  189. package/dist/utils/request.js +99 -0
  190. package/dist/utils/requestShouldRetry.cjs +20 -0
  191. package/dist/utils/requestShouldRetry.js +20 -0
  192. package/dist/utils/retry.cjs +66 -0
  193. package/dist/utils/retry.d.cts +56 -0
  194. package/dist/utils/retry.d.ts +56 -0
  195. package/dist/utils/retry.js +64 -0
  196. package/dist/utils/serialize.cjs +82 -0
  197. package/dist/utils/serialize.d.cts +17 -0
  198. package/dist/utils/serialize.d.ts +17 -0
  199. package/dist/utils/serialize.js +81 -0
  200. package/dist/utils/stellarAddressToBytes.cjs +295 -0
  201. package/dist/utils/stellarAddressToBytes.js +294 -0
  202. package/dist/utils/token.cjs +8 -0
  203. package/dist/utils/token.js +7 -0
  204. package/dist/utils/tokenUtils.cjs +263 -0
  205. package/dist/utils/tokenUtils.d.cts +88 -0
  206. package/dist/utils/tokenUtils.d.ts +88 -0
  207. package/dist/utils/tokenUtils.js +238 -0
  208. package/dist/utils/tronAddressToHex.cjs +18 -0
  209. package/dist/utils/tronAddressToHex.js +17 -0
  210. package/dist/utils/uint8Array.cjs +15 -0
  211. package/dist/utils/uint8Array.d.cts +4 -0
  212. package/dist/utils/uint8Array.d.ts +4 -0
  213. package/dist/utils/uint8Array.js +14 -0
  214. package/dist/utils/webAuthn.cjs +91 -0
  215. package/dist/utils/webAuthn.js +89 -0
  216. package/package.json +56 -0
@@ -0,0 +1,21 @@
1
+ const require_runtime = require('./runtime.cjs');
2
+
3
+ //#region src/solverRelay/solverRelayHttpClient/apis.ts
4
+ async function quote(params, config = {}) {
5
+ return await require_runtime.jsonRPCRequest("quote", params, config);
6
+ }
7
+ async function publishIntent(params, config = {}) {
8
+ return await require_runtime.jsonRPCRequest("publish_intent", params, config);
9
+ }
10
+ async function publishIntents(params, config = {}) {
11
+ return await require_runtime.jsonRPCRequest("publish_intents", params, config);
12
+ }
13
+ async function getStatus(params, config = {}) {
14
+ return await require_runtime.jsonRPCRequest("get_status", params, config);
15
+ }
16
+
17
+ //#endregion
18
+ exports.getStatus = getStatus;
19
+ exports.publishIntent = publishIntent;
20
+ exports.publishIntents = publishIntents;
21
+ exports.quote = quote;
@@ -0,0 +1,9 @@
1
+ import { GetStatusRequest, GetStatusResponse, PublishIntentRequest, PublishIntentResponse, PublishIntentsRequest, PublishIntentsResponse, QuoteRequest, QuoteResponse, RequestConfig } from "./types.cjs";
2
+
3
+ //#region src/solverRelay/solverRelayHttpClient/apis.d.ts
4
+ declare function quote(params: QuoteRequest["params"][0], config?: RequestConfig): Promise<QuoteResponse["result"]>;
5
+ declare function publishIntent(params: PublishIntentRequest["params"][0], config?: RequestConfig): Promise<PublishIntentResponse["result"]>;
6
+ declare function publishIntents(params: PublishIntentsRequest["params"][0], config?: RequestConfig): Promise<PublishIntentsResponse["result"]>;
7
+ declare function getStatus(params: GetStatusRequest["params"][0], config?: RequestConfig): Promise<GetStatusResponse["result"]>;
8
+ //#endregion
9
+ export { getStatus, publishIntent, publishIntents, quote };
@@ -0,0 +1,9 @@
1
+ import { GetStatusRequest, GetStatusResponse, PublishIntentRequest, PublishIntentResponse, PublishIntentsRequest, PublishIntentsResponse, QuoteRequest, QuoteResponse, RequestConfig } from "./types.js";
2
+
3
+ //#region src/solverRelay/solverRelayHttpClient/apis.d.ts
4
+ declare function quote(params: QuoteRequest["params"][0], config?: RequestConfig): Promise<QuoteResponse["result"]>;
5
+ declare function publishIntent(params: PublishIntentRequest["params"][0], config?: RequestConfig): Promise<PublishIntentResponse["result"]>;
6
+ declare function publishIntents(params: PublishIntentsRequest["params"][0], config?: RequestConfig): Promise<PublishIntentsResponse["result"]>;
7
+ declare function getStatus(params: GetStatusRequest["params"][0], config?: RequestConfig): Promise<GetStatusResponse["result"]>;
8
+ //#endregion
9
+ export { getStatus, publishIntent, publishIntents, quote };
@@ -0,0 +1,18 @@
1
+ import { jsonRPCRequest } from "./runtime.js";
2
+
3
+ //#region src/solverRelay/solverRelayHttpClient/apis.ts
4
+ async function quote(params, config = {}) {
5
+ return await jsonRPCRequest("quote", params, config);
6
+ }
7
+ async function publishIntent(params, config = {}) {
8
+ return await jsonRPCRequest("publish_intent", params, config);
9
+ }
10
+ async function publishIntents(params, config = {}) {
11
+ return await jsonRPCRequest("publish_intents", params, config);
12
+ }
13
+ async function getStatus(params, config = {}) {
14
+ return await jsonRPCRequest("get_status", params, config);
15
+ }
16
+
17
+ //#endregion
18
+ export { getStatus, publishIntent, publishIntents, quote };
@@ -0,0 +1,18 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_apis = require('./apis.cjs');
3
+
4
+ //#region src/solverRelay/solverRelayHttpClient/index.ts
5
+ var solverRelayHttpClient_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
6
+ getStatus: () => require_apis.getStatus,
7
+ publishIntent: () => require_apis.publishIntent,
8
+ publishIntents: () => require_apis.publishIntents,
9
+ quote: () => require_apis.quote
10
+ });
11
+
12
+ //#endregion
13
+ Object.defineProperty(exports, 'solverRelayHttpClient_exports', {
14
+ enumerable: true,
15
+ get: function () {
16
+ return solverRelayHttpClient_exports;
17
+ }
18
+ });
@@ -0,0 +1,9 @@
1
+ import { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig } from "./types.cjs";
2
+ import { getStatus, publishIntent, publishIntents, quote } from "./apis.cjs";
3
+
4
+ //#region src/solverRelay/solverRelayHttpClient/index.d.ts
5
+ declare namespace index_d_exports {
6
+ export { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig, getStatus, publishIntent, publishIntents, quote };
7
+ }
8
+ //#endregion
9
+ export { index_d_exports };
@@ -0,0 +1,9 @@
1
+ import { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig } from "./types.js";
2
+ import { getStatus, publishIntent, publishIntents, quote } from "./apis.js";
3
+
4
+ //#region src/solverRelay/solverRelayHttpClient/index.d.ts
5
+ declare namespace index_d_exports {
6
+ export { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig, getStatus, publishIntent, publishIntents, quote };
7
+ }
8
+ //#endregion
9
+ export { index_d_exports };
@@ -0,0 +1,13 @@
1
+ import { __exportAll } from "../../_virtual/rolldown_runtime.js";
2
+ import { getStatus, publishIntent, publishIntents, quote } from "./apis.js";
3
+
4
+ //#region src/solverRelay/solverRelayHttpClient/index.ts
5
+ var solverRelayHttpClient_exports = /* @__PURE__ */ __exportAll({
6
+ getStatus: () => getStatus,
7
+ publishIntent: () => publishIntent,
8
+ publishIntents: () => publishIntents,
9
+ quote: () => quote
10
+ });
11
+
12
+ //#endregion
13
+ export { solverRelayHttpClient_exports };
@@ -0,0 +1,60 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_config = require('../../config.cjs');
3
+ const require_request = require('../../utils/request.cjs');
4
+ const require_handleRPCResponse = require('../../utils/handleRPCResponse.cjs');
5
+ const require_retry = require('../../utils/retry.cjs');
6
+ let valibot = require("valibot");
7
+ valibot = require_rolldown_runtime.__toESM(valibot);
8
+
9
+ //#region src/solverRelay/solverRelayHttpClient/runtime.ts
10
+ const rpcResponseSchema = valibot.union([valibot.object({
11
+ jsonrpc: valibot.literal("2.0"),
12
+ id: valibot.string(),
13
+ result: valibot.unknown()
14
+ }), valibot.object({
15
+ jsonrpc: valibot.literal("2.0"),
16
+ id: valibot.string(),
17
+ error: valibot.pipe(valibot.union([valibot.string(), valibot.object({
18
+ code: valibot.number(),
19
+ message: valibot.string()
20
+ })]), valibot.transform((v) => {
21
+ if (typeof v === "string") return {
22
+ code: -1,
23
+ data: null,
24
+ message: v
25
+ };
26
+ return {
27
+ code: v.code,
28
+ data: null,
29
+ message: v.message
30
+ };
31
+ }))
32
+ })]);
33
+ async function jsonRPCRequest(method, params, config$1) {
34
+ const baseURL = config$1?.baseURL ?? require_config.config.env.solverRelayBaseURL;
35
+ const url = new URL("rpc", baseURL);
36
+ url.searchParams.set("method", String(method));
37
+ const body = {
38
+ id: config$1?.requestId ?? "dontcare",
39
+ jsonrpc: "2.0",
40
+ method,
41
+ params: params !== void 0 ? [params] : void 0
42
+ };
43
+ const fetchOptions = {
44
+ ...config$1?.fetchOptions,
45
+ method: "POST",
46
+ headers: new Headers(config$1?.fetchOptions?.headers)
47
+ };
48
+ if (config$1?.solverRelayApiKey) fetchOptions.headers.append("Authorization", `Bearer ${config$1.solverRelayApiKey}`);
49
+ return require_handleRPCResponse.handleRPCResponse(await require_request.request({
50
+ url,
51
+ body,
52
+ ...config$1,
53
+ fetchOptions,
54
+ retryOptions: config$1?.retryOptions ?? require_retry.RETRY_CONFIGS.THIRTY_SECS_AGGRESSIVE,
55
+ logger: config$1?.logger
56
+ }), body, rpcResponseSchema);
57
+ }
58
+
59
+ //#endregion
60
+ exports.jsonRPCRequest = jsonRPCRequest;
@@ -0,0 +1,58 @@
1
+ import { config } from "../../config.js";
2
+ import { request } from "../../utils/request.js";
3
+ import { handleRPCResponse } from "../../utils/handleRPCResponse.js";
4
+ import { RETRY_CONFIGS } from "../../utils/retry.js";
5
+ import * as v from "valibot";
6
+
7
+ //#region src/solverRelay/solverRelayHttpClient/runtime.ts
8
+ const rpcResponseSchema = v.union([v.object({
9
+ jsonrpc: v.literal("2.0"),
10
+ id: v.string(),
11
+ result: v.unknown()
12
+ }), v.object({
13
+ jsonrpc: v.literal("2.0"),
14
+ id: v.string(),
15
+ error: v.pipe(v.union([v.string(), v.object({
16
+ code: v.number(),
17
+ message: v.string()
18
+ })]), v.transform((v$1) => {
19
+ if (typeof v$1 === "string") return {
20
+ code: -1,
21
+ data: null,
22
+ message: v$1
23
+ };
24
+ return {
25
+ code: v$1.code,
26
+ data: null,
27
+ message: v$1.message
28
+ };
29
+ }))
30
+ })]);
31
+ async function jsonRPCRequest(method, params, config$1) {
32
+ const baseURL = config$1?.baseURL ?? config.env.solverRelayBaseURL;
33
+ const url = new URL("rpc", baseURL);
34
+ url.searchParams.set("method", String(method));
35
+ const body = {
36
+ id: config$1?.requestId ?? "dontcare",
37
+ jsonrpc: "2.0",
38
+ method,
39
+ params: params !== void 0 ? [params] : void 0
40
+ };
41
+ const fetchOptions = {
42
+ ...config$1?.fetchOptions,
43
+ method: "POST",
44
+ headers: new Headers(config$1?.fetchOptions?.headers)
45
+ };
46
+ if (config$1?.solverRelayApiKey) fetchOptions.headers.append("Authorization", `Bearer ${config$1.solverRelayApiKey}`);
47
+ return handleRPCResponse(await request({
48
+ url,
49
+ body,
50
+ ...config$1,
51
+ fetchOptions,
52
+ retryOptions: config$1?.retryOptions ?? RETRY_CONFIGS.THIRTY_SECS_AGGRESSIVE,
53
+ logger: config$1?.logger
54
+ }), body, rpcResponseSchema);
55
+ }
56
+
57
+ //#endregion
58
+ export { jsonRPCRequest };
@@ -0,0 +1,109 @@
1
+ import { RpcRequestError } from "../../errors/request.cjs";
2
+ import { ILogger } from "../../logger.cjs";
3
+ import { RetryOptions } from "../../utils/retry.cjs";
4
+ import { RequestErrorType } from "../../utils/request.cjs";
5
+ import { MultiPayload } from "lampamazaza-contract-types";
6
+
7
+ //#region src/solverRelay/solverRelayHttpClient/types.d.ts
8
+ type RequestConfig = {
9
+ requestId?: string | undefined;
10
+ timeout?: number | undefined;
11
+ fetchOptions?: Omit<RequestInit, "body"> | undefined;
12
+ baseURL?: string | undefined;
13
+ retryOptions?: RetryOptions;
14
+ logger?: ILogger;
15
+ solverRelayApiKey?: string;
16
+ };
17
+ type JSONRPCRequest<Method, Params$1> = {
18
+ id: string;
19
+ jsonrpc: "2.0";
20
+ method: Method;
21
+ params: Params$1[];
22
+ };
23
+ type JSONRPCResponse<Result> = {
24
+ id: string;
25
+ jsonrpc: "2.0";
26
+ result: Result;
27
+ };
28
+ type JSONRPCErrorType = RequestErrorType | RpcRequestError;
29
+ type QuoteRequest = JSONRPCRequest<"quote", {
30
+ defuse_asset_identifier_in: string;
31
+ defuse_asset_identifier_out: string;
32
+ exact_amount_in?: string;
33
+ exact_amount_out?: string;
34
+ min_deadline_ms?: number;
35
+ wait_ms?: number;
36
+ min_wait_ms?: number;
37
+ max_wait_ms?: number;
38
+ trusted_metadata?: unknown;
39
+ }>;
40
+ type Params<T extends JSONRPCRequest<unknown, unknown>> = T["params"][0];
41
+ type FailedQuote = {
42
+ type: "INSUFFICIENT_AMOUNT";
43
+ min_amount: string;
44
+ };
45
+ type Quote = {
46
+ quote_hash: string;
47
+ defuse_asset_identifier_in: string;
48
+ defuse_asset_identifier_out: string;
49
+ amount_in: string;
50
+ amount_out: string;
51
+ expiration_time: string;
52
+ };
53
+ type QuoteResponse = JSONRPCResponse<null | Array<Quote | FailedQuote>>;
54
+ type PublishIntentRequest = JSONRPCRequest<"publish_intent", {
55
+ quote_hashes: string[];
56
+ signed_data: MultiPayload;
57
+ }>;
58
+ type PublishIntentResponse = JSONRPCResponse<PublishIntentResponseSuccess | PublishIntentResponseFailure>;
59
+ type PublishIntentResponseSuccess = {
60
+ intent_hash: string;
61
+ status: "OK";
62
+ };
63
+ type PublishIntentResponseFailure = {
64
+ intent_hash: string;
65
+ status: "FAILED";
66
+ reason: string | "expired" | "internal";
67
+ };
68
+ type PublishIntentsRequest = JSONRPCRequest<"publish_intents", {
69
+ quote_hashes: string[];
70
+ signed_datas: MultiPayload[];
71
+ }>;
72
+ type PublishIntentsResponse = JSONRPCResponse<PublishIntentsResponseSuccess | PublishIntentsResponseFailure>;
73
+ type PublishIntentsResponseSuccess = {
74
+ intent_hashes: string[];
75
+ status: "OK";
76
+ };
77
+ type PublishIntentsResponseFailure = {
78
+ intent_hashes: string[];
79
+ status: "FAILED";
80
+ reason: string | "expired" | "internal";
81
+ };
82
+ type GetStatusRequest = JSONRPCRequest<"get_status", {
83
+ intent_hash: string;
84
+ }>;
85
+ type GetStatusResponse = JSONRPCResponse<{
86
+ status: "PENDING";
87
+ intent_hash: string;
88
+ } | {
89
+ status: "TX_BROADCASTED";
90
+ intent_hash: string;
91
+ data: {
92
+ hash: string;
93
+ };
94
+ } | {
95
+ status: "SETTLED";
96
+ intent_hash: string;
97
+ data: {
98
+ hash: string;
99
+ };
100
+ } | {
101
+ status: "NOT_FOUND_OR_NOT_VALID";
102
+ intent_hash: string;
103
+ status_details?: "FAILED";
104
+ data?: {
105
+ hash: string;
106
+ };
107
+ }>;
108
+ //#endregion
109
+ export { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig };
@@ -0,0 +1,109 @@
1
+ import { RpcRequestError } from "../../errors/request.js";
2
+ import { ILogger } from "../../logger.js";
3
+ import { RetryOptions } from "../../utils/retry.js";
4
+ import { RequestErrorType } from "../../utils/request.js";
5
+ import { MultiPayload } from "lampamazaza-contract-types";
6
+
7
+ //#region src/solverRelay/solverRelayHttpClient/types.d.ts
8
+ type RequestConfig = {
9
+ requestId?: string | undefined;
10
+ timeout?: number | undefined;
11
+ fetchOptions?: Omit<RequestInit, "body"> | undefined;
12
+ baseURL?: string | undefined;
13
+ retryOptions?: RetryOptions;
14
+ logger?: ILogger;
15
+ solverRelayApiKey?: string;
16
+ };
17
+ type JSONRPCRequest<Method, Params$1> = {
18
+ id: string;
19
+ jsonrpc: "2.0";
20
+ method: Method;
21
+ params: Params$1[];
22
+ };
23
+ type JSONRPCResponse<Result> = {
24
+ id: string;
25
+ jsonrpc: "2.0";
26
+ result: Result;
27
+ };
28
+ type JSONRPCErrorType = RequestErrorType | RpcRequestError;
29
+ type QuoteRequest = JSONRPCRequest<"quote", {
30
+ defuse_asset_identifier_in: string;
31
+ defuse_asset_identifier_out: string;
32
+ exact_amount_in?: string;
33
+ exact_amount_out?: string;
34
+ min_deadline_ms?: number;
35
+ wait_ms?: number;
36
+ min_wait_ms?: number;
37
+ max_wait_ms?: number;
38
+ trusted_metadata?: unknown;
39
+ }>;
40
+ type Params<T extends JSONRPCRequest<unknown, unknown>> = T["params"][0];
41
+ type FailedQuote = {
42
+ type: "INSUFFICIENT_AMOUNT";
43
+ min_amount: string;
44
+ };
45
+ type Quote = {
46
+ quote_hash: string;
47
+ defuse_asset_identifier_in: string;
48
+ defuse_asset_identifier_out: string;
49
+ amount_in: string;
50
+ amount_out: string;
51
+ expiration_time: string;
52
+ };
53
+ type QuoteResponse = JSONRPCResponse<null | Array<Quote | FailedQuote>>;
54
+ type PublishIntentRequest = JSONRPCRequest<"publish_intent", {
55
+ quote_hashes: string[];
56
+ signed_data: MultiPayload;
57
+ }>;
58
+ type PublishIntentResponse = JSONRPCResponse<PublishIntentResponseSuccess | PublishIntentResponseFailure>;
59
+ type PublishIntentResponseSuccess = {
60
+ intent_hash: string;
61
+ status: "OK";
62
+ };
63
+ type PublishIntentResponseFailure = {
64
+ intent_hash: string;
65
+ status: "FAILED";
66
+ reason: string | "expired" | "internal";
67
+ };
68
+ type PublishIntentsRequest = JSONRPCRequest<"publish_intents", {
69
+ quote_hashes: string[];
70
+ signed_datas: MultiPayload[];
71
+ }>;
72
+ type PublishIntentsResponse = JSONRPCResponse<PublishIntentsResponseSuccess | PublishIntentsResponseFailure>;
73
+ type PublishIntentsResponseSuccess = {
74
+ intent_hashes: string[];
75
+ status: "OK";
76
+ };
77
+ type PublishIntentsResponseFailure = {
78
+ intent_hashes: string[];
79
+ status: "FAILED";
80
+ reason: string | "expired" | "internal";
81
+ };
82
+ type GetStatusRequest = JSONRPCRequest<"get_status", {
83
+ intent_hash: string;
84
+ }>;
85
+ type GetStatusResponse = JSONRPCResponse<{
86
+ status: "PENDING";
87
+ intent_hash: string;
88
+ } | {
89
+ status: "TX_BROADCASTED";
90
+ intent_hash: string;
91
+ data: {
92
+ hash: string;
93
+ };
94
+ } | {
95
+ status: "SETTLED";
96
+ intent_hash: string;
97
+ data: {
98
+ hash: string;
99
+ };
100
+ } | {
101
+ status: "NOT_FOUND_OR_NOT_VALID";
102
+ intent_hash: string;
103
+ status_details?: "FAILED";
104
+ data?: {
105
+ hash: string;
106
+ };
107
+ }>;
108
+ //#endregion
109
+ export { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig };
@@ -0,0 +1,40 @@
1
+ const require_serialize = require('../../utils/serialize.cjs');
2
+ const require_base = require('../../errors/base.cjs');
3
+ const require_assert = require('../../utils/assert.cjs');
4
+
5
+ //#region src/solverRelay/utils/parseFailedPublishError.ts
6
+ var RelayPublishError = class extends require_base.BaseError {
7
+ constructor({ reason, code, publishParams, cause }) {
8
+ super("Failed to publish intent.", {
9
+ details: reason,
10
+ metaMessages: [`Code: ${code}`, `Publish params: ${require_serialize.serialize(publishParams)}`],
11
+ name: "RelayPublishError",
12
+ cause
13
+ });
14
+ this.name = "RelayPublishError";
15
+ this.code = code;
16
+ }
17
+ };
18
+ function toRelayPublishError(publishParams, response) {
19
+ require_assert.assert(response.status === "FAILED", "Expected response to be failed");
20
+ return new RelayPublishError({
21
+ reason: response.reason,
22
+ code: parseFailedPublishReason(response),
23
+ publishParams
24
+ });
25
+ }
26
+ function parseFailedPublishReason(response) {
27
+ require_assert.assert(response.status === "FAILED", "Expected response to be failed");
28
+ if (response.reason === "expired" || response.reason.includes("deadline has expired")) return "SIGNATURE_EXPIRED";
29
+ if (response.reason === "internal") return "INTERNAL_ERROR";
30
+ if (response.reason.includes("invalid signature")) return "SIGNATURE_INVALID";
31
+ if (response.reason.includes("nonce was already used")) return "NONCE_USED";
32
+ if (response.reason.includes("insufficient balance or overflow")) return "INSUFFICIENT_BALANCE";
33
+ if (response.reason.includes("public key doesn't exist")) return "PUBLIC_KEY_NOT_EXIST";
34
+ if (response.reason.includes("invalid salt")) return "INVALID_SALT";
35
+ return "UNKNOWN_ERROR";
36
+ }
37
+
38
+ //#endregion
39
+ exports.RelayPublishError = RelayPublishError;
40
+ exports.toRelayPublishError = toRelayPublishError;
@@ -0,0 +1,25 @@
1
+ import { BaseError } from "../../errors/base.cjs";
2
+ import { publishIntent, publishIntents } from "../solverRelayHttpClient/apis.cjs";
3
+
4
+ //#region src/solverRelay/utils/parseFailedPublishError.d.ts
5
+ type PublishErrorCode = "SIGNATURE_EXPIRED" | "INTERNAL_ERROR" | "SIGNATURE_INVALID" | "NONCE_USED" | "INSUFFICIENT_BALANCE" | "PUBLIC_KEY_NOT_EXIST" | "UNKNOWN_ERROR" | "NETWORK_ERROR" | "INVALID_SALT";
6
+ type RelayPublishErrorType = RelayPublishError & {
7
+ name: "RelayPublishError";
8
+ };
9
+ declare class RelayPublishError extends BaseError {
10
+ name: "RelayPublishError";
11
+ code: PublishErrorCode;
12
+ constructor({
13
+ reason,
14
+ code,
15
+ publishParams,
16
+ cause
17
+ }: {
18
+ reason: string;
19
+ code: PublishErrorCode;
20
+ publishParams: Parameters<typeof publishIntents>[0] | Parameters<typeof publishIntent>[0];
21
+ cause?: unknown;
22
+ });
23
+ }
24
+ //#endregion
25
+ export { RelayPublishError, RelayPublishErrorType };
@@ -0,0 +1,26 @@
1
+ import { BaseError } from "../../errors/base.js";
2
+ import { publishIntent, publishIntents } from "../solverRelayHttpClient/apis.js";
3
+ import "../solverRelayHttpClient/index.js";
4
+
5
+ //#region src/solverRelay/utils/parseFailedPublishError.d.ts
6
+ type PublishErrorCode = "SIGNATURE_EXPIRED" | "INTERNAL_ERROR" | "SIGNATURE_INVALID" | "NONCE_USED" | "INSUFFICIENT_BALANCE" | "PUBLIC_KEY_NOT_EXIST" | "UNKNOWN_ERROR" | "NETWORK_ERROR" | "INVALID_SALT";
7
+ type RelayPublishErrorType = RelayPublishError & {
8
+ name: "RelayPublishError";
9
+ };
10
+ declare class RelayPublishError extends BaseError {
11
+ name: "RelayPublishError";
12
+ code: PublishErrorCode;
13
+ constructor({
14
+ reason,
15
+ code,
16
+ publishParams,
17
+ cause
18
+ }: {
19
+ reason: string;
20
+ code: PublishErrorCode;
21
+ publishParams: Parameters<typeof publishIntents>[0] | Parameters<typeof publishIntent>[0];
22
+ cause?: unknown;
23
+ });
24
+ }
25
+ //#endregion
26
+ export { RelayPublishError, RelayPublishErrorType };
@@ -0,0 +1,39 @@
1
+ import { serialize } from "../../utils/serialize.js";
2
+ import { BaseError } from "../../errors/base.js";
3
+ import { assert } from "../../utils/assert.js";
4
+
5
+ //#region src/solverRelay/utils/parseFailedPublishError.ts
6
+ var RelayPublishError = class extends BaseError {
7
+ constructor({ reason, code, publishParams, cause }) {
8
+ super("Failed to publish intent.", {
9
+ details: reason,
10
+ metaMessages: [`Code: ${code}`, `Publish params: ${serialize(publishParams)}`],
11
+ name: "RelayPublishError",
12
+ cause
13
+ });
14
+ this.name = "RelayPublishError";
15
+ this.code = code;
16
+ }
17
+ };
18
+ function toRelayPublishError(publishParams, response) {
19
+ assert(response.status === "FAILED", "Expected response to be failed");
20
+ return new RelayPublishError({
21
+ reason: response.reason,
22
+ code: parseFailedPublishReason(response),
23
+ publishParams
24
+ });
25
+ }
26
+ function parseFailedPublishReason(response) {
27
+ assert(response.status === "FAILED", "Expected response to be failed");
28
+ if (response.reason === "expired" || response.reason.includes("deadline has expired")) return "SIGNATURE_EXPIRED";
29
+ if (response.reason === "internal") return "INTERNAL_ERROR";
30
+ if (response.reason.includes("invalid signature")) return "SIGNATURE_INVALID";
31
+ if (response.reason.includes("nonce was already used")) return "NONCE_USED";
32
+ if (response.reason.includes("insufficient balance or overflow")) return "INSUFFICIENT_BALANCE";
33
+ if (response.reason.includes("public key doesn't exist")) return "PUBLIC_KEY_NOT_EXIST";
34
+ if (response.reason.includes("invalid salt")) return "INVALID_SALT";
35
+ return "UNKNOWN_ERROR";
36
+ }
37
+
38
+ //#endregion
39
+ export { RelayPublishError, toRelayPublishError };
@@ -0,0 +1,21 @@
1
+ const require_apis = require('../solverRelayHttpClient/apis.cjs');
2
+
3
+ //#region src/solverRelay/utils/quoteWithLog.ts
4
+ async function quoteWithLog(params, { logBalanceSufficient, ...config }) {
5
+ const requestId = crypto.randomUUID();
6
+ const result = await require_apis.quote(params, {
7
+ ...config,
8
+ requestId
9
+ });
10
+ if (result == null) {
11
+ config.logger?.warn("quote: No liquidity available", { quoteParams: params });
12
+ if (logBalanceSufficient && (params.wait_ms == null || params.wait_ms > 2500)) config.logger?.warn("quote: No liquidity available for user with sufficient balance", {
13
+ quoteParams: params,
14
+ quoteRequestInfo: { requestId }
15
+ });
16
+ }
17
+ return result;
18
+ }
19
+
20
+ //#endregion
21
+ exports.quoteWithLog = quoteWithLog;
@@ -0,0 +1,12 @@
1
+ import { FailedQuote, Quote } from "../solverRelayHttpClient/types.cjs";
2
+ import { quote } from "../solverRelayHttpClient/apis.cjs";
3
+
4
+ //#region src/solverRelay/utils/quoteWithLog.d.ts
5
+ declare function quoteWithLog(params: Parameters<typeof quote>[0], {
6
+ logBalanceSufficient,
7
+ ...config
8
+ }: {
9
+ logBalanceSufficient: boolean;
10
+ } & Parameters<typeof quote>[1]): Promise<(Quote | FailedQuote)[] | null>;
11
+ //#endregion
12
+ export { quoteWithLog };
@@ -0,0 +1,14 @@
1
+ import { FailedQuote, Quote } from "../solverRelayHttpClient/types.js";
2
+ import { quote } from "../solverRelayHttpClient/apis.js";
3
+ import "../solverRelayHttpClient/index.js";
4
+ import "../index.js";
5
+
6
+ //#region src/solverRelay/utils/quoteWithLog.d.ts
7
+ declare function quoteWithLog(params: Parameters<typeof quote>[0], {
8
+ logBalanceSufficient,
9
+ ...config
10
+ }: {
11
+ logBalanceSufficient: boolean;
12
+ } & Parameters<typeof quote>[1]): Promise<(Quote | FailedQuote)[] | null>;
13
+ //#endregion
14
+ export { quoteWithLog };
@@ -0,0 +1,21 @@
1
+ import { quote } from "../solverRelayHttpClient/apis.js";
2
+
3
+ //#region src/solverRelay/utils/quoteWithLog.ts
4
+ async function quoteWithLog(params, { logBalanceSufficient, ...config }) {
5
+ const requestId = crypto.randomUUID();
6
+ const result = await quote(params, {
7
+ ...config,
8
+ requestId
9
+ });
10
+ if (result == null) {
11
+ config.logger?.warn("quote: No liquidity available", { quoteParams: params });
12
+ if (logBalanceSufficient && (params.wait_ms == null || params.wait_ms > 2500)) config.logger?.warn("quote: No liquidity available for user with sufficient balance", {
13
+ quoteParams: params,
14
+ quoteRequestInfo: { requestId }
15
+ });
16
+ }
17
+ return result;
18
+ }
19
+
20
+ //#endregion
21
+ export { quoteWithLog };