amogus-sdk-internal-utils 0.35.2

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 (261) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +43 -0
  2. package/dist/_virtual/rolldown_runtime.js +18 -0
  3. package/dist/bridgeIndexer/bridgeIndexerHttpClient/apis.cjs +10 -0
  4. package/dist/bridgeIndexer/bridgeIndexerHttpClient/apis.d.cts +6 -0
  5. package/dist/bridgeIndexer/bridgeIndexerHttpClient/apis.d.ts +6 -0
  6. package/dist/bridgeIndexer/bridgeIndexerHttpClient/apis.js +10 -0
  7. package/dist/bridgeIndexer/bridgeIndexerHttpClient/index.cjs +17 -0
  8. package/dist/bridgeIndexer/bridgeIndexerHttpClient/index.d.cts +9 -0
  9. package/dist/bridgeIndexer/bridgeIndexerHttpClient/index.d.ts +9 -0
  10. package/dist/bridgeIndexer/bridgeIndexerHttpClient/index.js +12 -0
  11. package/dist/bridgeIndexer/bridgeIndexerHttpClient/runtime.cjs +20 -0
  12. package/dist/bridgeIndexer/bridgeIndexerHttpClient/runtime.js +20 -0
  13. package/dist/bridgeIndexer/bridgeIndexerHttpClient/types.cjs +25 -0
  14. package/dist/bridgeIndexer/bridgeIndexerHttpClient/types.d.cts +31 -0
  15. package/dist/bridgeIndexer/bridgeIndexerHttpClient/types.d.ts +31 -0
  16. package/dist/bridgeIndexer/bridgeIndexerHttpClient/types.js +23 -0
  17. package/dist/bridgeIndexer/index.cjs +13 -0
  18. package/dist/bridgeIndexer/index.d.cts +8 -0
  19. package/dist/bridgeIndexer/index.d.ts +8 -0
  20. package/dist/bridgeIndexer/index.js +8 -0
  21. package/dist/config.cjs +86 -0
  22. package/dist/config.d.cts +50 -0
  23. package/dist/config.d.ts +50 -0
  24. package/dist/config.js +76 -0
  25. package/dist/errors/assert.cjs +11 -0
  26. package/dist/errors/assert.d.cts +11 -0
  27. package/dist/errors/assert.d.ts +11 -0
  28. package/dist/errors/assert.js +11 -0
  29. package/dist/errors/base.cjs +34 -0
  30. package/dist/errors/base.d.cts +21 -0
  31. package/dist/errors/base.d.ts +21 -0
  32. package/dist/errors/base.js +33 -0
  33. package/dist/errors/index.cjs +23 -0
  34. package/dist/errors/index.d.cts +11 -0
  35. package/dist/errors/index.d.ts +11 -0
  36. package/dist/errors/index.js +18 -0
  37. package/dist/errors/request.cjs +48 -0
  38. package/dist/errors/request.d.cts +61 -0
  39. package/dist/errors/request.d.ts +61 -0
  40. package/dist/errors/request.js +46 -0
  41. package/dist/errors/utils/isNetworkError.cjs +23 -0
  42. package/dist/errors/utils/isNetworkError.js +22 -0
  43. package/dist/errors/utils/toError.cjs +8 -0
  44. package/dist/errors/utils/toError.d.cts +4 -0
  45. package/dist/errors/utils/toError.d.ts +4 -0
  46. package/dist/errors/utils/toError.js +7 -0
  47. package/dist/index.cjs +144 -0
  48. package/dist/index.d.cts +33 -0
  49. package/dist/index.d.ts +33 -0
  50. package/dist/index.js +33 -0
  51. package/dist/logger.d.cts +11 -0
  52. package/dist/logger.d.ts +11 -0
  53. package/dist/nearClient.cjs +18 -0
  54. package/dist/nearClient.d.cts +8 -0
  55. package/dist/nearClient.d.ts +8 -0
  56. package/dist/nearClient.js +18 -0
  57. package/dist/poaBridge/constants/blockchains.cjs +62 -0
  58. package/dist/poaBridge/constants/blockchains.d.cts +95 -0
  59. package/dist/poaBridge/constants/blockchains.d.ts +95 -0
  60. package/dist/poaBridge/constants/blockchains.js +59 -0
  61. package/dist/poaBridge/errors/withdrawal.cjs +52 -0
  62. package/dist/poaBridge/errors/withdrawal.d.cts +34 -0
  63. package/dist/poaBridge/errors/withdrawal.d.ts +34 -0
  64. package/dist/poaBridge/errors/withdrawal.js +50 -0
  65. package/dist/poaBridge/getPendingDeposits.cjs +31 -0
  66. package/dist/poaBridge/getPendingDeposits.d.cts +14 -0
  67. package/dist/poaBridge/getPendingDeposits.d.ts +15 -0
  68. package/dist/poaBridge/getPendingDeposits.js +31 -0
  69. package/dist/poaBridge/index.cjs +23 -0
  70. package/dist/poaBridge/index.d.cts +11 -0
  71. package/dist/poaBridge/index.d.ts +11 -0
  72. package/dist/poaBridge/index.js +18 -0
  73. package/dist/poaBridge/poaBridgeHttpClient/apis.cjs +38 -0
  74. package/dist/poaBridge/poaBridgeHttpClient/apis.d.cts +12 -0
  75. package/dist/poaBridge/poaBridgeHttpClient/apis.d.ts +12 -0
  76. package/dist/poaBridge/poaBridgeHttpClient/apis.js +32 -0
  77. package/dist/poaBridge/poaBridgeHttpClient/index.cjs +21 -0
  78. package/dist/poaBridge/poaBridgeHttpClient/index.d.cts +9 -0
  79. package/dist/poaBridge/poaBridgeHttpClient/index.d.ts +9 -0
  80. package/dist/poaBridge/poaBridgeHttpClient/index.js +16 -0
  81. package/dist/poaBridge/poaBridgeHttpClient/runtime.cjs +49 -0
  82. package/dist/poaBridge/poaBridgeHttpClient/runtime.js +47 -0
  83. package/dist/poaBridge/poaBridgeHttpClient/types.d.cts +172 -0
  84. package/dist/poaBridge/poaBridgeHttpClient/types.d.ts +172 -0
  85. package/dist/poaBridge/waitForWithdrawalCompletion.cjs +57 -0
  86. package/dist/poaBridge/waitForWithdrawalCompletion.d.cts +31 -0
  87. package/dist/poaBridge/waitForWithdrawalCompletion.d.ts +31 -0
  88. package/dist/poaBridge/waitForWithdrawalCompletion.js +56 -0
  89. package/dist/services/blockchainBalanceService.cjs +40 -0
  90. package/dist/services/blockchainBalanceService.d.cts +21 -0
  91. package/dist/services/blockchainBalanceService.d.ts +21 -0
  92. package/dist/services/blockchainBalanceService.js +37 -0
  93. package/dist/solverRelay/errors/intentSettlement.cjs +20 -0
  94. package/dist/solverRelay/errors/intentSettlement.d.cts +13 -0
  95. package/dist/solverRelay/errors/intentSettlement.d.ts +13 -0
  96. package/dist/solverRelay/errors/intentSettlement.js +20 -0
  97. package/dist/solverRelay/errors/quote.cjs +18 -0
  98. package/dist/solverRelay/errors/quote.d.cts +21 -0
  99. package/dist/solverRelay/errors/quote.d.ts +22 -0
  100. package/dist/solverRelay/errors/quote.js +18 -0
  101. package/dist/solverRelay/getQuote.cjs +70 -0
  102. package/dist/solverRelay/getQuote.d.cts +14 -0
  103. package/dist/solverRelay/getQuote.d.ts +14 -0
  104. package/dist/solverRelay/getQuote.js +70 -0
  105. package/dist/solverRelay/getStatus.cjs +26 -0
  106. package/dist/solverRelay/getStatus.d.cts +17 -0
  107. package/dist/solverRelay/getStatus.d.ts +18 -0
  108. package/dist/solverRelay/getStatus.js +26 -0
  109. package/dist/solverRelay/index.cjs +27 -0
  110. package/dist/solverRelay/index.d.cts +16 -0
  111. package/dist/solverRelay/index.d.ts +16 -0
  112. package/dist/solverRelay/index.js +22 -0
  113. package/dist/solverRelay/publishIntent.cjs +20 -0
  114. package/dist/solverRelay/publishIntent.d.cts +15 -0
  115. package/dist/solverRelay/publishIntent.d.ts +16 -0
  116. package/dist/solverRelay/publishIntent.js +20 -0
  117. package/dist/solverRelay/publishIntents.cjs +42 -0
  118. package/dist/solverRelay/publishIntents.d.cts +10 -0
  119. package/dist/solverRelay/publishIntents.d.ts +11 -0
  120. package/dist/solverRelay/publishIntents.js +41 -0
  121. package/dist/solverRelay/solverRelayHttpClient/apis.cjs +21 -0
  122. package/dist/solverRelay/solverRelayHttpClient/apis.d.cts +9 -0
  123. package/dist/solverRelay/solverRelayHttpClient/apis.d.ts +9 -0
  124. package/dist/solverRelay/solverRelayHttpClient/apis.js +18 -0
  125. package/dist/solverRelay/solverRelayHttpClient/index.cjs +18 -0
  126. package/dist/solverRelay/solverRelayHttpClient/index.d.cts +9 -0
  127. package/dist/solverRelay/solverRelayHttpClient/index.d.ts +9 -0
  128. package/dist/solverRelay/solverRelayHttpClient/index.js +13 -0
  129. package/dist/solverRelay/solverRelayHttpClient/runtime.cjs +60 -0
  130. package/dist/solverRelay/solverRelayHttpClient/runtime.js +58 -0
  131. package/dist/solverRelay/solverRelayHttpClient/types.d.cts +117 -0
  132. package/dist/solverRelay/solverRelayHttpClient/types.d.ts +117 -0
  133. package/dist/solverRelay/utils/parseFailedPublishError.cjs +64 -0
  134. package/dist/solverRelay/utils/parseFailedPublishError.d.cts +56 -0
  135. package/dist/solverRelay/utils/parseFailedPublishError.d.ts +57 -0
  136. package/dist/solverRelay/utils/parseFailedPublishError.js +61 -0
  137. package/dist/solverRelay/utils/quoteWithLog.cjs +21 -0
  138. package/dist/solverRelay/utils/quoteWithLog.d.cts +12 -0
  139. package/dist/solverRelay/utils/quoteWithLog.d.ts +14 -0
  140. package/dist/solverRelay/utils/quoteWithLog.js +21 -0
  141. package/dist/solverRelay/waitForIntentSettlement.cjs +52 -0
  142. package/dist/solverRelay/waitForIntentSettlement.d.cts +30 -0
  143. package/dist/solverRelay/waitForIntentSettlement.d.ts +30 -0
  144. package/dist/solverRelay/waitForIntentSettlement.js +52 -0
  145. package/dist/types/authHandle.cjs +22 -0
  146. package/dist/types/authHandle.d.cts +25 -0
  147. package/dist/types/authHandle.d.ts +25 -0
  148. package/dist/types/authHandle.js +16 -0
  149. package/dist/types/base.d.cts +45 -0
  150. package/dist/types/base.d.ts +45 -0
  151. package/dist/types/intentsUserId.d.cts +10 -0
  152. package/dist/types/intentsUserId.d.ts +10 -0
  153. package/dist/types/walletMessage.cjs +11 -0
  154. package/dist/types/walletMessage.d.cts +106 -0
  155. package/dist/types/walletMessage.d.ts +106 -0
  156. package/dist/types/walletMessage.js +5 -0
  157. package/dist/utils/abortSignal.cjs +19 -0
  158. package/dist/utils/abortSignal.js +18 -0
  159. package/dist/utils/appFee.cjs +20 -0
  160. package/dist/utils/appFee.d.cts +9 -0
  161. package/dist/utils/appFee.d.ts +9 -0
  162. package/dist/utils/appFee.js +15 -0
  163. package/dist/utils/assert.cjs +9 -0
  164. package/dist/utils/assert.d.cts +7 -0
  165. package/dist/utils/assert.d.ts +7 -0
  166. package/dist/utils/assert.js +9 -0
  167. package/dist/utils/authIdentity.cjs +56 -0
  168. package/dist/utils/authIdentity.d.cts +34 -0
  169. package/dist/utils/authIdentity.d.ts +34 -0
  170. package/dist/utils/authIdentity.js +50 -0
  171. package/dist/utils/failover.cjs +36 -0
  172. package/dist/utils/failover.d.cts +24 -0
  173. package/dist/utils/failover.d.ts +24 -0
  174. package/dist/utils/failover.js +34 -0
  175. package/dist/utils/handleRPCResponse.cjs +30 -0
  176. package/dist/utils/handleRPCResponse.js +28 -0
  177. package/dist/utils/handleResponse.cjs +31 -0
  178. package/dist/utils/handleResponse.js +29 -0
  179. package/dist/utils/index.cjs +55 -0
  180. package/dist/utils/index.d.cts +13 -0
  181. package/dist/utils/index.d.ts +13 -0
  182. package/dist/utils/index.js +50 -0
  183. package/dist/utils/messageFactory.cjs +137 -0
  184. package/dist/utils/messageFactory.d.cts +70 -0
  185. package/dist/utils/messageFactory.d.ts +70 -0
  186. package/dist/utils/messageFactory.js +132 -0
  187. package/dist/utils/multiPayload/webauthn.cjs +27 -0
  188. package/dist/utils/multiPayload/webauthn.js +26 -0
  189. package/dist/utils/near.cjs +58 -0
  190. package/dist/utils/near.d.cts +35 -0
  191. package/dist/utils/near.d.ts +35 -0
  192. package/dist/utils/near.js +53 -0
  193. package/dist/utils/poll.cjs +87 -0
  194. package/dist/utils/poll.d.cts +54 -0
  195. package/dist/utils/poll.d.ts +54 -0
  196. package/dist/utils/poll.js +85 -0
  197. package/dist/utils/prepareBroadcastRequest.cjs +98 -0
  198. package/dist/utils/prepareBroadcastRequest.d.cts +16 -0
  199. package/dist/utils/prepareBroadcastRequest.d.ts +16 -0
  200. package/dist/utils/prepareBroadcastRequest.js +90 -0
  201. package/dist/utils/promise/withTimeout.cjs +34 -0
  202. package/dist/utils/promise/withTimeout.d.cts +16 -0
  203. package/dist/utils/promise/withTimeout.d.ts +16 -0
  204. package/dist/utils/promise/withTimeout.js +34 -0
  205. package/dist/utils/request.cjs +100 -0
  206. package/dist/utils/request.d.cts +27 -0
  207. package/dist/utils/request.d.ts +27 -0
  208. package/dist/utils/request.js +99 -0
  209. package/dist/utils/requestShouldRetry.cjs +20 -0
  210. package/dist/utils/requestShouldRetry.js +20 -0
  211. package/dist/utils/retry.cjs +66 -0
  212. package/dist/utils/retry.d.cts +56 -0
  213. package/dist/utils/retry.d.ts +56 -0
  214. package/dist/utils/retry.js +64 -0
  215. package/dist/utils/rpc-endpoint.cjs +56 -0
  216. package/dist/utils/rpc-endpoint.d.cts +20 -0
  217. package/dist/utils/rpc-endpoint.d.ts +20 -0
  218. package/dist/utils/rpc-endpoint.js +54 -0
  219. package/dist/utils/serialize.cjs +82 -0
  220. package/dist/utils/serialize.d.cts +17 -0
  221. package/dist/utils/serialize.d.ts +17 -0
  222. package/dist/utils/serialize.js +81 -0
  223. package/dist/utils/stellarAddressToBytes.cjs +295 -0
  224. package/dist/utils/stellarAddressToBytes.js +294 -0
  225. package/dist/utils/token.cjs +8 -0
  226. package/dist/utils/token.js +7 -0
  227. package/dist/utils/tokenUtils.cjs +263 -0
  228. package/dist/utils/tokenUtils.d.cts +88 -0
  229. package/dist/utils/tokenUtils.d.ts +88 -0
  230. package/dist/utils/tokenUtils.js +238 -0
  231. package/dist/utils/tronAddressToHex.cjs +18 -0
  232. package/dist/utils/tronAddressToHex.js +17 -0
  233. package/dist/utils/uint8Array.cjs +15 -0
  234. package/dist/utils/uint8Array.d.cts +4 -0
  235. package/dist/utils/uint8Array.d.ts +4 -0
  236. package/dist/utils/uint8Array.js +14 -0
  237. package/dist/utils/webAuthn.cjs +58 -0
  238. package/dist/utils/webAuthn.js +56 -0
  239. package/dist/xrpl/index.cjs +13 -0
  240. package/dist/xrpl/index.d.cts +8 -0
  241. package/dist/xrpl/index.d.ts +8 -0
  242. package/dist/xrpl/index.js +8 -0
  243. package/dist/xrpl/xrplHttpClient/apis.cjs +28 -0
  244. package/dist/xrpl/xrplHttpClient/apis.d.cts +7 -0
  245. package/dist/xrpl/xrplHttpClient/apis.d.ts +7 -0
  246. package/dist/xrpl/xrplHttpClient/apis.js +27 -0
  247. package/dist/xrpl/xrplHttpClient/errors.cjs +27 -0
  248. package/dist/xrpl/xrplHttpClient/errors.d.cts +24 -0
  249. package/dist/xrpl/xrplHttpClient/errors.d.ts +24 -0
  250. package/dist/xrpl/xrplHttpClient/errors.js +26 -0
  251. package/dist/xrpl/xrplHttpClient/index.cjs +19 -0
  252. package/dist/xrpl/xrplHttpClient/index.d.cts +10 -0
  253. package/dist/xrpl/xrplHttpClient/index.d.ts +10 -0
  254. package/dist/xrpl/xrplHttpClient/index.js +14 -0
  255. package/dist/xrpl/xrplHttpClient/runtime.cjs +57 -0
  256. package/dist/xrpl/xrplHttpClient/runtime.js +55 -0
  257. package/dist/xrpl/xrplHttpClient/types.cjs +39 -0
  258. package/dist/xrpl/xrplHttpClient/types.d.cts +64 -0
  259. package/dist/xrpl/xrplHttpClient/types.d.ts +64 -0
  260. package/dist/xrpl/xrplHttpClient/types.js +35 -0
  261. package/package.json +59 -0
@@ -0,0 +1,24 @@
1
+ import { BaseError } from "../../errors/base.cjs";
2
+
3
+ //#region src/xrpl/xrplHttpClient/errors.d.ts
4
+ type XrplApiErrorOutput = {
5
+ error: string;
6
+ error_code: number;
7
+ error_message: string;
8
+ };
9
+ type XrplApiErrorType = XrplApiError & {
10
+ name: "XrplApiError";
11
+ };
12
+ declare class XrplApiError extends BaseError {
13
+ output: XrplApiErrorOutput;
14
+ constructor(output: XrplApiErrorOutput);
15
+ }
16
+ type XrplAccountNotFundedErrorType = XrplAccountNotFundedError & {
17
+ name: "XrplAccountNotFundedError";
18
+ };
19
+ declare class XrplAccountNotFundedError extends BaseError {
20
+ account?: string | undefined;
21
+ constructor(account?: string | undefined);
22
+ }
23
+ //#endregion
24
+ export { XrplAccountNotFundedError, XrplAccountNotFundedErrorType, XrplApiError, XrplApiErrorType };
@@ -0,0 +1,24 @@
1
+ import { BaseError } from "../../errors/base.js";
2
+
3
+ //#region src/xrpl/xrplHttpClient/errors.d.ts
4
+ type XrplApiErrorOutput = {
5
+ error: string;
6
+ error_code: number;
7
+ error_message: string;
8
+ };
9
+ type XrplApiErrorType = XrplApiError & {
10
+ name: "XrplApiError";
11
+ };
12
+ declare class XrplApiError extends BaseError {
13
+ output: XrplApiErrorOutput;
14
+ constructor(output: XrplApiErrorOutput);
15
+ }
16
+ type XrplAccountNotFundedErrorType = XrplAccountNotFundedError & {
17
+ name: "XrplAccountNotFundedError";
18
+ };
19
+ declare class XrplAccountNotFundedError extends BaseError {
20
+ account?: string | undefined;
21
+ constructor(account?: string | undefined);
22
+ }
23
+ //#endregion
24
+ export { XrplAccountNotFundedError, XrplAccountNotFundedErrorType, XrplApiError, XrplApiErrorType };
@@ -0,0 +1,26 @@
1
+ import { BaseError } from "../../errors/base.js";
2
+
3
+ //#region src/xrpl/xrplHttpClient/errors.ts
4
+ var XrplApiError = class extends BaseError {
5
+ constructor(output) {
6
+ super("XRPL API request failed.", {
7
+ metaMessages: [`Error: ${output.error}`, `Error code: ${output.error_code}`],
8
+ name: "XrplApiError",
9
+ details: output.error_message
10
+ });
11
+ this.output = output;
12
+ }
13
+ };
14
+ var XrplAccountNotFundedError = class extends BaseError {
15
+ constructor(account) {
16
+ super("XRPL account is not funded.", {
17
+ metaMessages: account ? [`Account: ${account}`] : void 0,
18
+ name: "XrplAccountNotFundedError",
19
+ details: account ? `Account ${account} was not found on the XRPL ledger. The account must be funded with the minimum reserve before it can receive tokens.` : "Account was not found on the XRPL ledger. The account must be funded with the minimum reserve before it can receive tokens."
20
+ });
21
+ this.account = account;
22
+ }
23
+ };
24
+
25
+ //#endregion
26
+ export { XrplAccountNotFundedError, XrplApiError };
@@ -0,0 +1,19 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_errors = require('./errors.cjs');
3
+ const require_apis = require('./apis.cjs');
4
+
5
+ //#region src/xrpl/xrplHttpClient/index.ts
6
+ var xrplHttpClient_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
7
+ XrplAccountNotFundedError: () => require_errors.XrplAccountNotFundedError,
8
+ XrplApiError: () => require_errors.XrplApiError,
9
+ getAccountInfo: () => require_apis.getAccountInfo,
10
+ getAccountLines: () => require_apis.getAccountLines
11
+ });
12
+
13
+ //#endregion
14
+ Object.defineProperty(exports, 'xrplHttpClient_exports', {
15
+ enumerable: true,
16
+ get: function () {
17
+ return xrplHttpClient_exports;
18
+ }
19
+ });
@@ -0,0 +1,10 @@
1
+ import { AccountInfoResponse, AccountLinesResponse, RequestConfig, TrustLine } from "./types.cjs";
2
+ import { getAccountInfo, getAccountLines } from "./apis.cjs";
3
+ import { XrplAccountNotFundedError, XrplAccountNotFundedErrorType, XrplApiError, XrplApiErrorType } from "./errors.cjs";
4
+
5
+ //#region src/xrpl/xrplHttpClient/index.d.ts
6
+ declare namespace index_d_exports {
7
+ export { AccountInfoResponse, AccountLinesResponse, RequestConfig, TrustLine, XrplAccountNotFundedError, XrplAccountNotFundedErrorType, XrplApiError, XrplApiErrorType, getAccountInfo, getAccountLines };
8
+ }
9
+ //#endregion
10
+ export { index_d_exports };
@@ -0,0 +1,10 @@
1
+ import { AccountInfoResponse, AccountLinesResponse, RequestConfig, TrustLine } from "./types.js";
2
+ import { getAccountInfo, getAccountLines } from "./apis.js";
3
+ import { XrplAccountNotFundedError, XrplAccountNotFundedErrorType, XrplApiError, XrplApiErrorType } from "./errors.js";
4
+
5
+ //#region src/xrpl/xrplHttpClient/index.d.ts
6
+ declare namespace index_d_exports {
7
+ export { AccountInfoResponse, AccountLinesResponse, RequestConfig, TrustLine, XrplAccountNotFundedError, XrplAccountNotFundedErrorType, XrplApiError, XrplApiErrorType, getAccountInfo, getAccountLines };
8
+ }
9
+ //#endregion
10
+ export { index_d_exports };
@@ -0,0 +1,14 @@
1
+ import { __exportAll } from "../../_virtual/rolldown_runtime.js";
2
+ import { XrplAccountNotFundedError, XrplApiError } from "./errors.js";
3
+ import { getAccountInfo, getAccountLines } from "./apis.js";
4
+
5
+ //#region src/xrpl/xrplHttpClient/index.ts
6
+ var xrplHttpClient_exports = /* @__PURE__ */ __exportAll({
7
+ XrplAccountNotFundedError: () => XrplAccountNotFundedError,
8
+ XrplApiError: () => XrplApiError,
9
+ getAccountInfo: () => getAccountInfo,
10
+ getAccountLines: () => getAccountLines
11
+ });
12
+
13
+ //#endregion
14
+ export { xrplHttpClient_exports };
@@ -0,0 +1,57 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_serialize = require('../../utils/serialize.cjs');
3
+ const require_request = require('../../errors/request.cjs');
4
+ const require_request$1 = require('../../utils/request.cjs');
5
+ const require_retry = require('../../utils/retry.cjs');
6
+ const require_types = require('./types.cjs');
7
+ const require_errors = require('./errors.cjs');
8
+ let valibot = require("valibot");
9
+ valibot = require_rolldown_runtime.__toESM(valibot);
10
+
11
+ //#region src/xrpl/xrplHttpClient/runtime.ts
12
+ async function xrplRequest(method, params, config, schema) {
13
+ params.api_version = 2;
14
+ const body = {
15
+ method,
16
+ params: [params]
17
+ };
18
+ const response = await require_request$1.request({
19
+ url: config.baseURL,
20
+ body,
21
+ timeout: config.timeout,
22
+ retryOptions: config.retryOptions ?? require_retry.RETRY_CONFIGS.THIRTY_SECS_AGGRESSIVE,
23
+ logger: config.logger,
24
+ fetchOptions: {
25
+ ...config.fetchOptions,
26
+ method: "POST"
27
+ }
28
+ });
29
+ let json;
30
+ try {
31
+ json = await response.json();
32
+ } catch (error) {
33
+ throw new require_request.HttpRequestError({
34
+ body,
35
+ details: "Failed to deserialize JSON",
36
+ cause: error instanceof Error ? error : new Error(String(error)),
37
+ url: response.url
38
+ });
39
+ }
40
+ const parsedError = valibot.safeParse(require_types.XrplErrorResponseSchema, json);
41
+ if (parsedError.success) {
42
+ const output = parsedError.output.result;
43
+ if (output.error_code === 19 || output.error === "actNotFound") throw new require_errors.XrplAccountNotFundedError(output.account);
44
+ throw new require_errors.XrplApiError(output);
45
+ }
46
+ const parsed = valibot.safeParse(schema, json);
47
+ if (parsed.success) return parsed.output;
48
+ throw new require_request.HttpRequestError({
49
+ body,
50
+ details: "Failed to parse response JSON",
51
+ cause: new Error(require_serialize.serialize(parsed.issues)),
52
+ url: response.url
53
+ });
54
+ }
55
+
56
+ //#endregion
57
+ exports.xrplRequest = xrplRequest;
@@ -0,0 +1,55 @@
1
+ import { serialize } from "../../utils/serialize.js";
2
+ import { HttpRequestError } from "../../errors/request.js";
3
+ import { request } from "../../utils/request.js";
4
+ import { RETRY_CONFIGS } from "../../utils/retry.js";
5
+ import { XrplErrorResponseSchema } from "./types.js";
6
+ import { XrplAccountNotFundedError, XrplApiError } from "./errors.js";
7
+ import * as v from "valibot";
8
+
9
+ //#region src/xrpl/xrplHttpClient/runtime.ts
10
+ async function xrplRequest(method, params, config, schema) {
11
+ params.api_version = 2;
12
+ const body = {
13
+ method,
14
+ params: [params]
15
+ };
16
+ const response = await request({
17
+ url: config.baseURL,
18
+ body,
19
+ timeout: config.timeout,
20
+ retryOptions: config.retryOptions ?? RETRY_CONFIGS.THIRTY_SECS_AGGRESSIVE,
21
+ logger: config.logger,
22
+ fetchOptions: {
23
+ ...config.fetchOptions,
24
+ method: "POST"
25
+ }
26
+ });
27
+ let json;
28
+ try {
29
+ json = await response.json();
30
+ } catch (error) {
31
+ throw new HttpRequestError({
32
+ body,
33
+ details: "Failed to deserialize JSON",
34
+ cause: error instanceof Error ? error : new Error(String(error)),
35
+ url: response.url
36
+ });
37
+ }
38
+ const parsedError = v.safeParse(XrplErrorResponseSchema, json);
39
+ if (parsedError.success) {
40
+ const output = parsedError.output.result;
41
+ if (output.error_code === 19 || output.error === "actNotFound") throw new XrplAccountNotFundedError(output.account);
42
+ throw new XrplApiError(output);
43
+ }
44
+ const parsed = v.safeParse(schema, json);
45
+ if (parsed.success) return parsed.output;
46
+ throw new HttpRequestError({
47
+ body,
48
+ details: "Failed to parse response JSON",
49
+ cause: new Error(serialize(parsed.issues)),
50
+ url: response.url
51
+ });
52
+ }
53
+
54
+ //#endregion
55
+ export { xrplRequest };
@@ -0,0 +1,39 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ let valibot = require("valibot");
3
+ valibot = require_rolldown_runtime.__toESM(valibot);
4
+
5
+ //#region src/xrpl/xrplHttpClient/types.ts
6
+ const AccountFlagsSchema = valibot.object({
7
+ depositAuth: valibot.boolean(),
8
+ requireDestinationTag: valibot.boolean()
9
+ });
10
+ const AccountInfoResponseSchema = valibot.object({ result: valibot.object({
11
+ account_data: valibot.object({ Account: valibot.string() }),
12
+ account_flags: AccountFlagsSchema,
13
+ validated: valibot.optional(valibot.boolean())
14
+ }) });
15
+ const TrustLineSchema = valibot.object({
16
+ account: valibot.string(),
17
+ currency: valibot.string(),
18
+ limit: valibot.string(),
19
+ limit_peer: valibot.string(),
20
+ balance: valibot.string()
21
+ });
22
+ const AccountLinesResponseSchema = valibot.object({ result: valibot.object({
23
+ lines: valibot.array(TrustLineSchema),
24
+ marker: valibot.optional(valibot.unknown())
25
+ }) });
26
+ const XrplErrorResponseSchema = valibot.object({ result: valibot.object({
27
+ status: valibot.literal("error"),
28
+ account: valibot.optional(valibot.string()),
29
+ error: valibot.string(),
30
+ error_code: valibot.number(),
31
+ error_message: valibot.string(),
32
+ request: valibot.optional(valibot.record(valibot.string(), valibot.unknown())),
33
+ validated: valibot.optional(valibot.boolean())
34
+ }) });
35
+
36
+ //#endregion
37
+ exports.AccountInfoResponseSchema = AccountInfoResponseSchema;
38
+ exports.AccountLinesResponseSchema = AccountLinesResponseSchema;
39
+ exports.XrplErrorResponseSchema = XrplErrorResponseSchema;
@@ -0,0 +1,64 @@
1
+ import { ILogger } from "../../logger.cjs";
2
+ import { RetryOptions } from "../../utils/retry.cjs";
3
+ import * as v from "valibot";
4
+
5
+ //#region src/xrpl/xrplHttpClient/types.d.ts
6
+ type RequestConfig = {
7
+ baseURL: string;
8
+ timeout?: number | undefined;
9
+ fetchOptions?: Omit<RequestInit, "body"> | undefined;
10
+ retryOptions?: RetryOptions;
11
+ logger?: ILogger;
12
+ };
13
+ declare const AccountInfoResponseSchema: v.ObjectSchema<{
14
+ readonly result: v.ObjectSchema<{
15
+ readonly account_data: v.ObjectSchema<{
16
+ readonly Account: v.StringSchema<undefined>;
17
+ }, undefined>;
18
+ /**
19
+ * A map of account flags parsed out.
20
+ * Only available for rippled nodes 1.11.0 and higher.
21
+ */
22
+ readonly account_flags: v.ObjectSchema<{
23
+ /** Requires deposit authorization for incoming payments. */
24
+ readonly depositAuth: v.BooleanSchema<undefined>;
25
+ /** Requires incoming payments to specify a Destination Tag. */
26
+ readonly requireDestinationTag: v.BooleanSchema<undefined>;
27
+ }, undefined>;
28
+ readonly validated: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
29
+ }, undefined>;
30
+ }, undefined>;
31
+ type AccountInfoResponse = v.InferOutput<typeof AccountInfoResponseSchema>;
32
+ declare const TrustLineSchema: v.ObjectSchema<{
33
+ /** The unique Address of the counterparty to this trust line. */
34
+ readonly account: v.StringSchema<undefined>;
35
+ /** A Currency Code identifying what currency this trust line can hold. */
36
+ readonly currency: v.StringSchema<undefined>;
37
+ /** The maximum amount of currency this account is willing to owe the peer. The limit field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
38
+ readonly limit: v.StringSchema<undefined>;
39
+ /** The maximum amount of currency the peer is willing to owe this account. The limit_peer field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
40
+ readonly limit_peer: v.StringSchema<undefined>;
41
+ /** Current balance held against this line. Positive = account holds value, negative = account owes value. The balance field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
42
+ readonly balance: v.StringSchema<undefined>;
43
+ }, undefined>;
44
+ declare const AccountLinesResponseSchema: v.ObjectSchema<{
45
+ readonly result: v.ObjectSchema<{
46
+ readonly lines: v.ArraySchema<v.ObjectSchema<{
47
+ /** The unique Address of the counterparty to this trust line. */
48
+ readonly account: v.StringSchema<undefined>;
49
+ /** A Currency Code identifying what currency this trust line can hold. */
50
+ readonly currency: v.StringSchema<undefined>;
51
+ /** The maximum amount of currency this account is willing to owe the peer. The limit field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
52
+ readonly limit: v.StringSchema<undefined>;
53
+ /** The maximum amount of currency the peer is willing to owe this account. The limit_peer field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
54
+ readonly limit_peer: v.StringSchema<undefined>;
55
+ /** Current balance held against this line. Positive = account holds value, negative = account owes value. The balance field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
56
+ readonly balance: v.StringSchema<undefined>;
57
+ }, undefined>, undefined>;
58
+ readonly marker: v.OptionalSchema<v.UnknownSchema, undefined>;
59
+ }, undefined>;
60
+ }, undefined>;
61
+ type TrustLine = v.InferOutput<typeof TrustLineSchema>;
62
+ type AccountLinesResponse = v.InferOutput<typeof AccountLinesResponseSchema>;
63
+ //#endregion
64
+ export { AccountInfoResponse, AccountLinesResponse, RequestConfig, TrustLine };
@@ -0,0 +1,64 @@
1
+ import { ILogger } from "../../logger.js";
2
+ import { RetryOptions } from "../../utils/retry.js";
3
+ import * as v from "valibot";
4
+
5
+ //#region src/xrpl/xrplHttpClient/types.d.ts
6
+ type RequestConfig = {
7
+ baseURL: string;
8
+ timeout?: number | undefined;
9
+ fetchOptions?: Omit<RequestInit, "body"> | undefined;
10
+ retryOptions?: RetryOptions;
11
+ logger?: ILogger;
12
+ };
13
+ declare const AccountInfoResponseSchema: v.ObjectSchema<{
14
+ readonly result: v.ObjectSchema<{
15
+ readonly account_data: v.ObjectSchema<{
16
+ readonly Account: v.StringSchema<undefined>;
17
+ }, undefined>;
18
+ /**
19
+ * A map of account flags parsed out.
20
+ * Only available for rippled nodes 1.11.0 and higher.
21
+ */
22
+ readonly account_flags: v.ObjectSchema<{
23
+ /** Requires deposit authorization for incoming payments. */
24
+ readonly depositAuth: v.BooleanSchema<undefined>;
25
+ /** Requires incoming payments to specify a Destination Tag. */
26
+ readonly requireDestinationTag: v.BooleanSchema<undefined>;
27
+ }, undefined>;
28
+ readonly validated: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
29
+ }, undefined>;
30
+ }, undefined>;
31
+ type AccountInfoResponse = v.InferOutput<typeof AccountInfoResponseSchema>;
32
+ declare const TrustLineSchema: v.ObjectSchema<{
33
+ /** The unique Address of the counterparty to this trust line. */
34
+ readonly account: v.StringSchema<undefined>;
35
+ /** A Currency Code identifying what currency this trust line can hold. */
36
+ readonly currency: v.StringSchema<undefined>;
37
+ /** The maximum amount of currency this account is willing to owe the peer. The limit field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
38
+ readonly limit: v.StringSchema<undefined>;
39
+ /** The maximum amount of currency the peer is willing to owe this account. The limit_peer field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
40
+ readonly limit_peer: v.StringSchema<undefined>;
41
+ /** Current balance held against this line. Positive = account holds value, negative = account owes value. The balance field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
42
+ readonly balance: v.StringSchema<undefined>;
43
+ }, undefined>;
44
+ declare const AccountLinesResponseSchema: v.ObjectSchema<{
45
+ readonly result: v.ObjectSchema<{
46
+ readonly lines: v.ArraySchema<v.ObjectSchema<{
47
+ /** The unique Address of the counterparty to this trust line. */
48
+ readonly account: v.StringSchema<undefined>;
49
+ /** A Currency Code identifying what currency this trust line can hold. */
50
+ readonly currency: v.StringSchema<undefined>;
51
+ /** The maximum amount of currency this account is willing to owe the peer. The limit field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
52
+ readonly limit: v.StringSchema<undefined>;
53
+ /** The maximum amount of currency the peer is willing to owe this account. The limit_peer field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
54
+ readonly limit_peer: v.StringSchema<undefined>;
55
+ /** Current balance held against this line. Positive = account holds value, negative = account owes value. The balance field is a string-encoded decimal number in human-readable units (not drops/smallest units). */
56
+ readonly balance: v.StringSchema<undefined>;
57
+ }, undefined>, undefined>;
58
+ readonly marker: v.OptionalSchema<v.UnknownSchema, undefined>;
59
+ }, undefined>;
60
+ }, undefined>;
61
+ type TrustLine = v.InferOutput<typeof TrustLineSchema>;
62
+ type AccountLinesResponse = v.InferOutput<typeof AccountLinesResponseSchema>;
63
+ //#endregion
64
+ export { AccountInfoResponse, AccountLinesResponse, RequestConfig, TrustLine };
@@ -0,0 +1,35 @@
1
+ import * as v from "valibot";
2
+
3
+ //#region src/xrpl/xrplHttpClient/types.ts
4
+ const AccountFlagsSchema = v.object({
5
+ depositAuth: v.boolean(),
6
+ requireDestinationTag: v.boolean()
7
+ });
8
+ const AccountInfoResponseSchema = v.object({ result: v.object({
9
+ account_data: v.object({ Account: v.string() }),
10
+ account_flags: AccountFlagsSchema,
11
+ validated: v.optional(v.boolean())
12
+ }) });
13
+ const TrustLineSchema = v.object({
14
+ account: v.string(),
15
+ currency: v.string(),
16
+ limit: v.string(),
17
+ limit_peer: v.string(),
18
+ balance: v.string()
19
+ });
20
+ const AccountLinesResponseSchema = v.object({ result: v.object({
21
+ lines: v.array(TrustLineSchema),
22
+ marker: v.optional(v.unknown())
23
+ }) });
24
+ const XrplErrorResponseSchema = v.object({ result: v.object({
25
+ status: v.literal("error"),
26
+ account: v.optional(v.string()),
27
+ error: v.string(),
28
+ error_code: v.number(),
29
+ error_message: v.string(),
30
+ request: v.optional(v.record(v.string(), v.unknown())),
31
+ validated: v.optional(v.boolean())
32
+ }) });
33
+
34
+ //#endregion
35
+ export { AccountInfoResponseSchema, AccountLinesResponseSchema, XrplErrorResponseSchema };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "amogus-sdk-internal-utils",
3
+ "version": "0.35.2",
4
+ "private": false,
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/defuse-protocol/sdk-monorepo.git",
9
+ "directory": "packages/internal-utils"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/defuse-protocol/sdk-monorepo/issues"
13
+ },
14
+ "homepage": "https://github.com/defuse-protocol/sdk-monorepo/tree/main/packages/internal-utils#readme",
15
+ "sideEffects": false,
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "import": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.cts",
27
+ "default": "./dist/index.cjs"
28
+ }
29
+ }
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "scripts": {
35
+ "build": "tsdown",
36
+ "dev": "tsdown --watch",
37
+ "lint": "biome check .",
38
+ "lint:fix": "biome check --write .",
39
+ "format": "biome format --write .",
40
+ "typecheck": "tsc --noEmit"
41
+ },
42
+ "dependencies": {
43
+ "amogus-sdk-contract-types": "0.6.4",
44
+ "@lifeomic/attempt": "^3.0.0",
45
+ "@noble/curves": "^1.4.0",
46
+ "@noble/hashes": "^1.7.1",
47
+ "@scure/base": "^1.0.0",
48
+ "@thames/monads": "^0.7.0",
49
+ "near-api-js": "^4.0.0 || ^5.0.0",
50
+ "tweetnacl": "^1.0.0",
51
+ "valibot": "^1.0.0",
52
+ "viem": "^2.0.0"
53
+ },
54
+ "devDependencies": {
55
+ "msw": "^2.11.3",
56
+ "tsdown": "0.19.0",
57
+ "typescript": "^5.4.2"
58
+ }
59
+ }