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,82 @@
1
+
2
+ //#region src/utils/serialize.ts
3
+ /**
4
+ * Get the reference key for the circular value
5
+ *
6
+ * @param keys the keys to build the reference key from
7
+ * @param cutoff the maximum number of keys to include
8
+ * @returns the reference key
9
+ */
10
+ function getReferenceKey(keys, cutoff) {
11
+ return keys.slice(0, cutoff).join(".") || ".";
12
+ }
13
+ /**
14
+ * Faster `Array.prototype.indexOf` implementation build for slicing / splicing
15
+ *
16
+ * @param array the array to match the value in
17
+ * @param value the value to match
18
+ * @returns the matching index, or -1
19
+ */
20
+ function getCutoff(array, value) {
21
+ const { length } = array;
22
+ for (let index = 0; index < length; ++index) if (array[index] === value) return index + 1;
23
+ return 0;
24
+ }
25
+ /**
26
+ * Create a replacer method that handles circular values
27
+ *
28
+ * @param [replacer] a custom replacer to use for non-circular values
29
+ * @param [circularReplacer] a custom replacer to use for circular methods
30
+ * @returns the value to stringify
31
+ */
32
+ function createReplacer(replacer, circularReplacer) {
33
+ const hasReplacer = typeof replacer === "function";
34
+ const hasCircularReplacer = typeof circularReplacer === "function";
35
+ const cache = [];
36
+ const keys = [];
37
+ return function replace(key, value) {
38
+ if (typeof value === "object") if (cache.length) {
39
+ const thisCutoff = getCutoff(cache, this);
40
+ if (thisCutoff === 0) cache[cache.length] = this;
41
+ else {
42
+ cache.splice(thisCutoff);
43
+ keys.splice(thisCutoff);
44
+ }
45
+ keys[keys.length] = key;
46
+ const valueCutoff = getCutoff(cache, value);
47
+ if (valueCutoff !== 0) return hasCircularReplacer ? circularReplacer.call(this, key, value, getReferenceKey(keys, valueCutoff)) : `[ref=${getReferenceKey(keys, valueCutoff)}]`;
48
+ } else {
49
+ cache[0] = value;
50
+ keys[0] = key;
51
+ }
52
+ return hasReplacer ? replacer.call(this, key, value) : value;
53
+ };
54
+ }
55
+ /**
56
+ * Stringifier that handles circular values
57
+ *
58
+ * Forked from https://github.com/planttheidea/fast-stringify
59
+ *
60
+ * @param value to stringify
61
+ * @param [replacer] a custom replacer function for handling standard values
62
+ * @param [indent] the number of spaces to indent the output by
63
+ * @param [circularReplacer] a custom replacer function for handling circular values
64
+ * @returns the stringified output
65
+ */
66
+ function serialize(value, replacer, indent, circularReplacer) {
67
+ return JSON.stringify(value, createReplacer((key, value_) => {
68
+ let value$1 = value_;
69
+ if (typeof value$1 === "bigint") value$1 = {
70
+ __type: "bigint",
71
+ value: value_.toString()
72
+ };
73
+ if (value$1 instanceof Map) value$1 = {
74
+ __type: "Map",
75
+ value: Array.from(value_.entries())
76
+ };
77
+ return replacer?.(key, value$1) ?? value$1;
78
+ }, circularReplacer), indent ?? void 0);
79
+ }
80
+
81
+ //#endregion
82
+ exports.serialize = serialize;
@@ -0,0 +1,17 @@
1
+ //#region src/utils/serialize.d.ts
2
+ type StandardReplacer = (key: string, value: any) => any;
3
+ type CircularReplacer = (key: string, value: any, referenceKey: string) => any;
4
+ /**
5
+ * Stringifier that handles circular values
6
+ *
7
+ * Forked from https://github.com/planttheidea/fast-stringify
8
+ *
9
+ * @param value to stringify
10
+ * @param [replacer] a custom replacer function for handling standard values
11
+ * @param [indent] the number of spaces to indent the output by
12
+ * @param [circularReplacer] a custom replacer function for handling circular values
13
+ * @returns the stringified output
14
+ */
15
+ declare function serialize(value: any, replacer?: StandardReplacer | null | undefined, indent?: number | null | undefined, circularReplacer?: CircularReplacer | null | undefined): string;
16
+ //#endregion
17
+ export { serialize };
@@ -0,0 +1,17 @@
1
+ //#region src/utils/serialize.d.ts
2
+ type StandardReplacer = (key: string, value: any) => any;
3
+ type CircularReplacer = (key: string, value: any, referenceKey: string) => any;
4
+ /**
5
+ * Stringifier that handles circular values
6
+ *
7
+ * Forked from https://github.com/planttheidea/fast-stringify
8
+ *
9
+ * @param value to stringify
10
+ * @param [replacer] a custom replacer function for handling standard values
11
+ * @param [indent] the number of spaces to indent the output by
12
+ * @param [circularReplacer] a custom replacer function for handling circular values
13
+ * @returns the stringified output
14
+ */
15
+ declare function serialize(value: any, replacer?: StandardReplacer | null | undefined, indent?: number | null | undefined, circularReplacer?: CircularReplacer | null | undefined): string;
16
+ //#endregion
17
+ export { serialize };
@@ -0,0 +1,81 @@
1
+ //#region src/utils/serialize.ts
2
+ /**
3
+ * Get the reference key for the circular value
4
+ *
5
+ * @param keys the keys to build the reference key from
6
+ * @param cutoff the maximum number of keys to include
7
+ * @returns the reference key
8
+ */
9
+ function getReferenceKey(keys, cutoff) {
10
+ return keys.slice(0, cutoff).join(".") || ".";
11
+ }
12
+ /**
13
+ * Faster `Array.prototype.indexOf` implementation build for slicing / splicing
14
+ *
15
+ * @param array the array to match the value in
16
+ * @param value the value to match
17
+ * @returns the matching index, or -1
18
+ */
19
+ function getCutoff(array, value) {
20
+ const { length } = array;
21
+ for (let index = 0; index < length; ++index) if (array[index] === value) return index + 1;
22
+ return 0;
23
+ }
24
+ /**
25
+ * Create a replacer method that handles circular values
26
+ *
27
+ * @param [replacer] a custom replacer to use for non-circular values
28
+ * @param [circularReplacer] a custom replacer to use for circular methods
29
+ * @returns the value to stringify
30
+ */
31
+ function createReplacer(replacer, circularReplacer) {
32
+ const hasReplacer = typeof replacer === "function";
33
+ const hasCircularReplacer = typeof circularReplacer === "function";
34
+ const cache = [];
35
+ const keys = [];
36
+ return function replace(key, value) {
37
+ if (typeof value === "object") if (cache.length) {
38
+ const thisCutoff = getCutoff(cache, this);
39
+ if (thisCutoff === 0) cache[cache.length] = this;
40
+ else {
41
+ cache.splice(thisCutoff);
42
+ keys.splice(thisCutoff);
43
+ }
44
+ keys[keys.length] = key;
45
+ const valueCutoff = getCutoff(cache, value);
46
+ if (valueCutoff !== 0) return hasCircularReplacer ? circularReplacer.call(this, key, value, getReferenceKey(keys, valueCutoff)) : `[ref=${getReferenceKey(keys, valueCutoff)}]`;
47
+ } else {
48
+ cache[0] = value;
49
+ keys[0] = key;
50
+ }
51
+ return hasReplacer ? replacer.call(this, key, value) : value;
52
+ };
53
+ }
54
+ /**
55
+ * Stringifier that handles circular values
56
+ *
57
+ * Forked from https://github.com/planttheidea/fast-stringify
58
+ *
59
+ * @param value to stringify
60
+ * @param [replacer] a custom replacer function for handling standard values
61
+ * @param [indent] the number of spaces to indent the output by
62
+ * @param [circularReplacer] a custom replacer function for handling circular values
63
+ * @returns the stringified output
64
+ */
65
+ function serialize(value, replacer, indent, circularReplacer) {
66
+ return JSON.stringify(value, createReplacer((key, value_) => {
67
+ let value$1 = value_;
68
+ if (typeof value$1 === "bigint") value$1 = {
69
+ __type: "bigint",
70
+ value: value_.toString()
71
+ };
72
+ if (value$1 instanceof Map) value$1 = {
73
+ __type: "Map",
74
+ value: Array.from(value_.entries())
75
+ };
76
+ return replacer?.(key, value$1) ?? value$1;
77
+ }, circularReplacer), indent ?? void 0);
78
+ }
79
+
80
+ //#endregion
81
+ export { serialize };
@@ -0,0 +1,295 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let _scure_base = require("@scure/base");
3
+
4
+ //#region src/utils/stellarAddressToBytes.ts
5
+ function stellarAddressToBytes(encoded) {
6
+ if (typeof encoded !== "string") throw new TypeError("encoded argument must be of type String");
7
+ const decoded = _scure_base.base32.decode(encoded);
8
+ const payload = decoded.slice(0, -2);
9
+ const data = payload.slice(1);
10
+ const checksum = decoded.slice(-2);
11
+ if (encoded !== _scure_base.base32.encode(decoded)) throw new Error("invalid encoded string");
12
+ if (!verifyChecksum(calculateChecksum(payload), checksum)) throw new Error("invalid checksum");
13
+ return new Uint8Array(data);
14
+ }
15
+ function verifyChecksum(expected, actual) {
16
+ if (expected.length !== actual.length) return false;
17
+ for (let i = 0; i < expected.length; i++) if (expected[i] !== actual[i]) return false;
18
+ return true;
19
+ }
20
+ function calculateChecksum(payload) {
21
+ const crcTable = [
22
+ 0,
23
+ 4129,
24
+ 8258,
25
+ 12387,
26
+ 16516,
27
+ 20645,
28
+ 24774,
29
+ 28903,
30
+ 33032,
31
+ 37161,
32
+ 41290,
33
+ 45419,
34
+ 49548,
35
+ 53677,
36
+ 57806,
37
+ 61935,
38
+ 4657,
39
+ 528,
40
+ 12915,
41
+ 8786,
42
+ 21173,
43
+ 17044,
44
+ 29431,
45
+ 25302,
46
+ 37689,
47
+ 33560,
48
+ 45947,
49
+ 41818,
50
+ 54205,
51
+ 50076,
52
+ 62463,
53
+ 58334,
54
+ 9314,
55
+ 13379,
56
+ 1056,
57
+ 5121,
58
+ 25830,
59
+ 29895,
60
+ 17572,
61
+ 21637,
62
+ 42346,
63
+ 46411,
64
+ 34088,
65
+ 38153,
66
+ 58862,
67
+ 62927,
68
+ 50604,
69
+ 54669,
70
+ 13907,
71
+ 9842,
72
+ 5649,
73
+ 1584,
74
+ 30423,
75
+ 26358,
76
+ 22165,
77
+ 18100,
78
+ 46939,
79
+ 42874,
80
+ 38681,
81
+ 34616,
82
+ 63455,
83
+ 59390,
84
+ 55197,
85
+ 51132,
86
+ 18628,
87
+ 22757,
88
+ 26758,
89
+ 30887,
90
+ 2112,
91
+ 6241,
92
+ 10242,
93
+ 14371,
94
+ 51660,
95
+ 55789,
96
+ 59790,
97
+ 63919,
98
+ 35144,
99
+ 39273,
100
+ 43274,
101
+ 47403,
102
+ 23285,
103
+ 19156,
104
+ 31415,
105
+ 27286,
106
+ 6769,
107
+ 2640,
108
+ 14899,
109
+ 10770,
110
+ 56317,
111
+ 52188,
112
+ 64447,
113
+ 60318,
114
+ 39801,
115
+ 35672,
116
+ 47931,
117
+ 43802,
118
+ 27814,
119
+ 31879,
120
+ 19684,
121
+ 23749,
122
+ 11298,
123
+ 15363,
124
+ 3168,
125
+ 7233,
126
+ 60846,
127
+ 64911,
128
+ 52716,
129
+ 56781,
130
+ 44330,
131
+ 48395,
132
+ 36200,
133
+ 40265,
134
+ 32407,
135
+ 28342,
136
+ 24277,
137
+ 20212,
138
+ 15891,
139
+ 11826,
140
+ 7761,
141
+ 3696,
142
+ 65439,
143
+ 61374,
144
+ 57309,
145
+ 53244,
146
+ 48923,
147
+ 44858,
148
+ 40793,
149
+ 36728,
150
+ 37256,
151
+ 33193,
152
+ 45514,
153
+ 41451,
154
+ 53516,
155
+ 49453,
156
+ 61774,
157
+ 57711,
158
+ 4224,
159
+ 161,
160
+ 12482,
161
+ 8419,
162
+ 20484,
163
+ 16421,
164
+ 28742,
165
+ 24679,
166
+ 33721,
167
+ 37784,
168
+ 41979,
169
+ 46042,
170
+ 49981,
171
+ 54044,
172
+ 58239,
173
+ 62302,
174
+ 689,
175
+ 4752,
176
+ 8947,
177
+ 13010,
178
+ 16949,
179
+ 21012,
180
+ 25207,
181
+ 29270,
182
+ 46570,
183
+ 42443,
184
+ 38312,
185
+ 34185,
186
+ 62830,
187
+ 58703,
188
+ 54572,
189
+ 50445,
190
+ 13538,
191
+ 9411,
192
+ 5280,
193
+ 1153,
194
+ 29798,
195
+ 25671,
196
+ 21540,
197
+ 17413,
198
+ 42971,
199
+ 47098,
200
+ 34713,
201
+ 38840,
202
+ 59231,
203
+ 63358,
204
+ 50973,
205
+ 55100,
206
+ 9939,
207
+ 14066,
208
+ 1681,
209
+ 5808,
210
+ 26199,
211
+ 30326,
212
+ 17941,
213
+ 22068,
214
+ 55628,
215
+ 51565,
216
+ 63758,
217
+ 59695,
218
+ 39368,
219
+ 35305,
220
+ 47498,
221
+ 43435,
222
+ 22596,
223
+ 18533,
224
+ 30726,
225
+ 26663,
226
+ 6336,
227
+ 2273,
228
+ 14466,
229
+ 10403,
230
+ 52093,
231
+ 56156,
232
+ 60223,
233
+ 64286,
234
+ 35833,
235
+ 39896,
236
+ 43963,
237
+ 48026,
238
+ 19061,
239
+ 23124,
240
+ 27191,
241
+ 31254,
242
+ 2801,
243
+ 6864,
244
+ 10931,
245
+ 14994,
246
+ 64814,
247
+ 60687,
248
+ 56684,
249
+ 52557,
250
+ 48554,
251
+ 44427,
252
+ 40424,
253
+ 36297,
254
+ 31782,
255
+ 27655,
256
+ 23652,
257
+ 19525,
258
+ 15522,
259
+ 11395,
260
+ 7392,
261
+ 3265,
262
+ 61215,
263
+ 65342,
264
+ 53085,
265
+ 57212,
266
+ 44955,
267
+ 49082,
268
+ 36825,
269
+ 40952,
270
+ 28183,
271
+ 32310,
272
+ 20053,
273
+ 24180,
274
+ 11923,
275
+ 16050,
276
+ 3793,
277
+ 7920
278
+ ];
279
+ let crc16 = 0;
280
+ for (let i = 0; i < payload.length; i += 1) {
281
+ const byte = payload[i];
282
+ if (byte === void 0) throw new Error("Invalid payload byte");
283
+ const crcValue = crcTable[crc16 >> 8 ^ byte];
284
+ if (crcValue === void 0) throw new Error("Invalid CRC lookup index");
285
+ crc16 = crc16 << 8 ^ crcValue;
286
+ crc16 &= 65535;
287
+ }
288
+ const checksum = new Uint8Array(2);
289
+ checksum[0] = crc16 & 255;
290
+ checksum[1] = crc16 >> 8 & 255;
291
+ return checksum;
292
+ }
293
+
294
+ //#endregion
295
+ exports.stellarAddressToBytes = stellarAddressToBytes;