starknet 6.9.0 → 6.10.1

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 (315) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +1 -1
  3. package/README.md +5 -9
  4. package/dist/account/default.cjs +655 -0
  5. package/dist/account/default.d.ts +67 -0
  6. package/dist/account/default.mjs +652 -0
  7. package/dist/account/index.cjs +27 -0
  8. package/dist/account/index.d.ts +2 -0
  9. package/dist/account/index.mjs +2 -0
  10. package/dist/account/interface.cjs +9 -0
  11. package/dist/account/interface.d.ts +301 -0
  12. package/dist/account/interface.mjs +3 -0
  13. package/dist/channel/index.cjs +27 -0
  14. package/dist/channel/index.d.ts +3 -0
  15. package/dist/channel/index.mjs +3 -0
  16. package/dist/channel/rpc_0_6.cjs +607 -0
  17. package/dist/channel/rpc_0_6.d.ts +78 -0
  18. package/dist/channel/rpc_0_6.mjs +543 -0
  19. package/dist/channel/rpc_0_7.cjs +619 -0
  20. package/dist/channel/rpc_0_7.d.ts +81 -0
  21. package/dist/channel/rpc_0_7.mjs +561 -0
  22. package/dist/constants.cjs +76 -0
  23. package/dist/constants.d.ts +70 -0
  24. package/dist/constants.mjs +60 -0
  25. package/dist/contract/contractFactory.cjs +93 -0
  26. package/dist/contract/contractFactory.d.ts +46 -0
  27. package/dist/contract/contractFactory.mjs +83 -0
  28. package/dist/contract/default.cjs +269 -0
  29. package/dist/contract/default.d.ts +58 -0
  30. package/dist/contract/default.mjs +254 -0
  31. package/dist/contract/index.cjs +38 -0
  32. package/dist/contract/index.d.ts +3 -0
  33. package/dist/contract/index.mjs +3 -0
  34. package/dist/contract/interface.cjs +13 -0
  35. package/dist/contract/interface.d.ts +128 -0
  36. package/dist/contract/interface.mjs +6 -0
  37. package/dist/index.cjs +267 -0
  38. package/dist/index.d.ts +45 -5991
  39. package/dist/index.global.js +728 -609
  40. package/dist/index.global.js.map +1 -1
  41. package/dist/index.mjs +39 -7320
  42. package/dist/provider/errors.cjs +50 -0
  43. package/dist/provider/errors.d.ts +16 -0
  44. package/dist/provider/errors.mjs +35 -0
  45. package/dist/provider/extensions/default.cjs +11 -0
  46. package/dist/provider/extensions/default.d.ts +6 -0
  47. package/dist/provider/extensions/default.mjs +5 -0
  48. package/dist/provider/extensions/starknetId.cjs +174 -0
  49. package/dist/provider/extensions/starknetId.d.ts +10 -0
  50. package/dist/provider/extensions/starknetId.mjs +230 -0
  51. package/dist/provider/index.cjs +56 -0
  52. package/dist/provider/index.d.ts +6 -0
  53. package/dist/provider/index.mjs +6 -0
  54. package/dist/provider/interface.cjs +8 -0
  55. package/dist/provider/interface.d.ts +261 -0
  56. package/dist/provider/interface.mjs +2 -0
  57. package/dist/provider/rpc.cjs +301 -0
  58. package/dist/provider/rpc.d.ts +115 -0
  59. package/dist/provider/rpc.mjs +302 -0
  60. package/dist/service/types.cjs +1 -0
  61. package/dist/service/types.d.ts +5 -0
  62. package/dist/service/types.mjs +0 -0
  63. package/dist/signer/default.cjs +105 -0
  64. package/dist/signer/default.d.ts +12 -0
  65. package/dist/signer/default.mjs +102 -0
  66. package/dist/signer/ethSigner.cjs +123 -0
  67. package/dist/signer/ethSigner.d.ts +25 -0
  68. package/dist/signer/ethSigner.mjs +140 -0
  69. package/dist/signer/index.cjs +38 -0
  70. package/dist/signer/index.d.ts +3 -0
  71. package/dist/signer/index.mjs +3 -0
  72. package/dist/signer/interface.cjs +8 -0
  73. package/dist/signer/interface.d.ts +115 -0
  74. package/dist/signer/interface.mjs +2 -0
  75. package/dist/types/account.cjs +1 -0
  76. package/dist/types/account.d.ts +79 -0
  77. package/dist/types/account.mjs +0 -0
  78. package/dist/types/api/index.cjs +30 -0
  79. package/dist/types/api/index.d.ts +4 -0
  80. package/dist/types/api/index.mjs +4 -0
  81. package/dist/types/api/jsonrpc/index.cjs +1 -0
  82. package/dist/types/api/jsonrpc/index.d.ts +21 -0
  83. package/dist/types/api/jsonrpc/index.mjs +0 -0
  84. package/dist/types/api/rpcspec_0_6/components.cjs +1 -0
  85. package/dist/types/api/rpcspec_0_6/components.d.ts +541 -0
  86. package/dist/types/api/rpcspec_0_6/components.mjs +0 -0
  87. package/dist/types/api/rpcspec_0_6/contract.cjs +1 -0
  88. package/dist/types/api/rpcspec_0_6/contract.d.ts +85 -0
  89. package/dist/types/api/rpcspec_0_6/contract.mjs +0 -0
  90. package/dist/types/api/rpcspec_0_6/errors.cjs +1 -0
  91. package/dist/types/api/rpcspec_0_6/errors.d.ts +128 -0
  92. package/dist/types/api/rpcspec_0_6/errors.mjs +0 -0
  93. package/dist/types/api/rpcspec_0_6/index.cjs +45 -0
  94. package/dist/types/api/rpcspec_0_6/index.d.ts +8 -0
  95. package/dist/types/api/rpcspec_0_6/index.mjs +5 -0
  96. package/dist/types/api/rpcspec_0_6/methods.cjs +1 -0
  97. package/dist/types/api/rpcspec_0_6/methods.d.ts +207 -0
  98. package/dist/types/api/rpcspec_0_6/methods.mjs +0 -0
  99. package/dist/types/api/rpcspec_0_6/nonspec.cjs +65 -0
  100. package/dist/types/api/rpcspec_0_6/nonspec.d.ts +147 -0
  101. package/dist/types/api/rpcspec_0_6/nonspec.mjs +59 -0
  102. package/dist/types/cairoEnum.cjs +1 -0
  103. package/dist/types/cairoEnum.d.ts +2 -0
  104. package/dist/types/cairoEnum.mjs +0 -0
  105. package/dist/types/calldata.cjs +27 -0
  106. package/dist/types/calldata.d.ts +23 -0
  107. package/dist/types/calldata.mjs +21 -0
  108. package/dist/types/contract.cjs +1 -0
  109. package/dist/types/contract.d.ts +27 -0
  110. package/dist/types/contract.mjs +0 -0
  111. package/dist/types/helpers/valuesType.cjs +1 -0
  112. package/dist/types/helpers/valuesType.d.ts +1 -0
  113. package/dist/types/helpers/valuesType.mjs +0 -0
  114. package/dist/types/index.cjs +121 -0
  115. package/dist/types/index.d.ts +10 -0
  116. package/dist/types/index.mjs +10 -0
  117. package/dist/types/lib/contract/abi.cjs +1 -0
  118. package/dist/types/lib/contract/abi.d.ts +71 -0
  119. package/dist/types/lib/contract/abi.mjs +0 -0
  120. package/dist/types/lib/contract/index.cjs +50 -0
  121. package/dist/types/lib/contract/index.d.ts +26 -0
  122. package/dist/types/lib/contract/index.mjs +8 -0
  123. package/dist/types/lib/contract/legacy.cjs +1 -0
  124. package/dist/types/lib/contract/legacy.d.ts +33 -0
  125. package/dist/types/lib/contract/legacy.mjs +0 -0
  126. package/dist/types/lib/contract/sierra.cjs +1 -0
  127. package/dist/types/lib/contract/sierra.d.ts +52 -0
  128. package/dist/types/lib/contract/sierra.mjs +0 -0
  129. package/dist/types/lib/index.cjs +61 -0
  130. package/dist/types/lib/index.d.ts +259 -0
  131. package/dist/types/lib/index.mjs +36 -0
  132. package/dist/types/provider/configuration.cjs +1 -0
  133. package/dist/types/provider/configuration.d.ts +20 -0
  134. package/dist/types/provider/configuration.mjs +0 -0
  135. package/dist/types/provider/index.cjs +27 -0
  136. package/dist/types/provider/index.d.ts +2 -0
  137. package/dist/types/provider/index.mjs +2 -0
  138. package/dist/types/provider/response.cjs +30 -0
  139. package/dist/types/provider/response.d.ts +98 -0
  140. package/dist/types/provider/response.mjs +1 -0
  141. package/dist/types/provider/spec.cjs +1 -0
  142. package/dist/types/provider/spec.d.ts +49 -0
  143. package/dist/types/provider/spec.mjs +0 -0
  144. package/dist/types/signer.cjs +1 -0
  145. package/dist/types/signer.d.ts +49 -0
  146. package/dist/types/signer.mjs +0 -0
  147. package/dist/types/transactionReceipt.cjs +1 -0
  148. package/dist/types/transactionReceipt.d.ts +23 -0
  149. package/dist/types/transactionReceipt.mjs +0 -0
  150. package/dist/types/typedData.cjs +12 -0
  151. package/dist/types/typedData.d.ts +1 -0
  152. package/dist/types/typedData.mjs +3 -0
  153. package/dist/utils/address.cjs +44 -0
  154. package/dist/utils/address.d.ts +55 -0
  155. package/dist/utils/address.mjs +35 -0
  156. package/dist/utils/assert.cjs +11 -0
  157. package/dist/utils/assert.d.ts +12 -0
  158. package/dist/utils/assert.mjs +5 -0
  159. package/dist/utils/cairoDataTypes/felt.cjs +31 -0
  160. package/dist/utils/cairoDataTypes/felt.d.ts +6 -0
  161. package/dist/utils/cairoDataTypes/felt.mjs +27 -0
  162. package/dist/utils/cairoDataTypes/uint256.cjs +113 -0
  163. package/dist/utils/cairoDataTypes/uint256.d.ts +72 -0
  164. package/dist/utils/cairoDataTypes/uint256.mjs +103 -0
  165. package/dist/utils/cairoDataTypes/uint512.cjs +125 -0
  166. package/dist/utils/cairoDataTypes/uint512.d.ts +76 -0
  167. package/dist/utils/cairoDataTypes/uint512.mjs +123 -0
  168. package/dist/utils/calldata/byteArray.cjs +27 -0
  169. package/dist/utils/calldata/byteArray.d.ts +32 -0
  170. package/dist/utils/calldata/byteArray.mjs +20 -0
  171. package/dist/utils/calldata/cairo.cjs +114 -0
  172. package/dist/utils/calldata/cairo.d.ts +196 -0
  173. package/dist/utils/calldata/cairo.mjs +68 -0
  174. package/dist/utils/calldata/enum/CairoCustomEnum.cjs +55 -0
  175. package/dist/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
  176. package/dist/utils/calldata/enum/CairoCustomEnum.mjs +50 -0
  177. package/dist/utils/calldata/enum/CairoOption.cjs +55 -0
  178. package/dist/utils/calldata/enum/CairoOption.d.ts +37 -0
  179. package/dist/utils/calldata/enum/CairoOption.mjs +50 -0
  180. package/dist/utils/calldata/enum/CairoResult.cjs +54 -0
  181. package/dist/utils/calldata/enum/CairoResult.d.ts +36 -0
  182. package/dist/utils/calldata/enum/CairoResult.mjs +47 -0
  183. package/dist/utils/calldata/enum/index.cjs +38 -0
  184. package/dist/utils/calldata/enum/index.d.ts +3 -0
  185. package/dist/utils/calldata/enum/index.mjs +3 -0
  186. package/dist/utils/calldata/formatter.cjs +55 -0
  187. package/dist/utils/calldata/formatter.d.ts +9 -0
  188. package/dist/utils/calldata/formatter.mjs +58 -0
  189. package/dist/utils/calldata/index.cjs +272 -0
  190. package/dist/utils/calldata/index.d.ts +90 -0
  191. package/dist/utils/calldata/index.mjs +276 -0
  192. package/dist/utils/calldata/parser/index.cjs +29 -0
  193. package/dist/utils/calldata/parser/index.d.ts +5 -0
  194. package/dist/utils/calldata/parser/index.mjs +21 -0
  195. package/dist/utils/calldata/parser/interface.cjs +8 -0
  196. package/dist/utils/calldata/parser/interface.d.ts +20 -0
  197. package/dist/utils/calldata/parser/interface.mjs +2 -0
  198. package/dist/utils/calldata/parser/parser-0-1.1.0.cjs +38 -0
  199. package/dist/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
  200. package/dist/utils/calldata/parser/parser-0-1.1.0.mjs +31 -0
  201. package/dist/utils/calldata/parser/parser-2.0.0.cjs +42 -0
  202. package/dist/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
  203. package/dist/utils/calldata/parser/parser-2.0.0.mjs +37 -0
  204. package/dist/utils/calldata/propertyOrder.cjs +159 -0
  205. package/dist/utils/calldata/propertyOrder.d.ts +2 -0
  206. package/dist/utils/calldata/propertyOrder.mjs +189 -0
  207. package/dist/utils/calldata/requestParser.cjs +204 -0
  208. package/dist/utils/calldata/requestParser.d.ts +11 -0
  209. package/dist/utils/calldata/requestParser.mjs +231 -0
  210. package/dist/utils/calldata/responseParser.cjs +200 -0
  211. package/dist/utils/calldata/responseParser.d.ts +11 -0
  212. package/dist/utils/calldata/responseParser.mjs +201 -0
  213. package/dist/utils/calldata/tuple.cjs +106 -0
  214. package/dist/utils/calldata/tuple.d.ts +6 -0
  215. package/dist/utils/calldata/tuple.mjs +88 -0
  216. package/dist/utils/calldata/validate.cjs +241 -0
  217. package/dist/utils/calldata/validate.d.ts +6 -0
  218. package/dist/utils/calldata/validate.mjs +315 -0
  219. package/dist/utils/contract.cjs +40 -0
  220. package/dist/utils/contract.d.ts +37 -0
  221. package/dist/utils/contract.mjs +31 -0
  222. package/dist/utils/ec.cjs +12 -0
  223. package/dist/utils/ec.d.ts +2 -0
  224. package/dist/utils/ec.mjs +2 -0
  225. package/dist/utils/encode.cjs +78 -0
  226. package/dist/utils/encode.d.ts +207 -0
  227. package/dist/utils/encode.mjs +56 -0
  228. package/dist/utils/eth.cjs +22 -0
  229. package/dist/utils/eth.d.ts +22 -0
  230. package/dist/utils/eth.mjs +14 -0
  231. package/dist/utils/events/index.cjs +144 -0
  232. package/dist/utils/events/index.d.ts +84 -0
  233. package/dist/utils/events/index.mjs +136 -0
  234. package/dist/utils/fetchPonyfill.cjs +14 -0
  235. package/dist/utils/fetchPonyfill.d.ts +2 -0
  236. package/dist/utils/fetchPonyfill.mjs +5 -0
  237. package/dist/utils/hash/classHash.cjs +151 -0
  238. package/dist/utils/hash/classHash.d.ts +120 -0
  239. package/dist/utils/hash/classHash.mjs +168 -0
  240. package/dist/utils/hash/index.cjs +49 -0
  241. package/dist/utils/hash/index.d.ts +7 -0
  242. package/dist/utils/hash/index.mjs +4 -0
  243. package/dist/utils/hash/selector.cjs +37 -0
  244. package/dist/utils/hash/selector.d.ts +57 -0
  245. package/dist/utils/hash/selector.mjs +28 -0
  246. package/dist/utils/hash/transactionHash/index.cjs +38 -0
  247. package/dist/utils/hash/transactionHash/index.d.ts +81 -0
  248. package/dist/utils/hash/transactionHash/index.mjs +102 -0
  249. package/dist/utils/hash/transactionHash/v2.cjs +31 -0
  250. package/dist/utils/hash/transactionHash/v2.d.ts +34 -0
  251. package/dist/utils/hash/transactionHash/v2.mjs +57 -0
  252. package/dist/utils/hash/transactionHash/v3.cjs +45 -0
  253. package/dist/utils/hash/transactionHash/v3.d.ts +24 -0
  254. package/dist/utils/hash/transactionHash/v3.mjs +80 -0
  255. package/dist/utils/json.cjs +21 -0
  256. package/dist/utils/json.d.ts +50 -0
  257. package/dist/utils/json.mjs +10 -0
  258. package/dist/utils/merkle.cjs +118 -0
  259. package/dist/utils/merkle.d.ts +87 -0
  260. package/dist/utils/merkle.mjs +114 -0
  261. package/dist/utils/num.cjs +109 -0
  262. package/dist/utils/num.d.ts +283 -0
  263. package/dist/utils/num.mjs +86 -0
  264. package/dist/utils/provider.cjs +182 -0
  265. package/dist/utils/provider.d.ts +217 -0
  266. package/dist/utils/provider.mjs +158 -0
  267. package/dist/utils/responseParser/index.cjs +27 -0
  268. package/dist/utils/responseParser/index.d.ts +2 -0
  269. package/dist/utils/responseParser/index.mjs +2 -0
  270. package/dist/utils/responseParser/interface.cjs +8 -0
  271. package/dist/utils/responseParser/interface.d.ts +13 -0
  272. package/dist/utils/responseParser/interface.mjs +2 -0
  273. package/dist/utils/responseParser/rpc.cjs +83 -0
  274. package/dist/utils/responseParser/rpc.d.ts +19 -0
  275. package/dist/utils/responseParser/rpc.mjs +77 -0
  276. package/dist/utils/shortString.cjs +56 -0
  277. package/dist/utils/shortString.d.ts +116 -0
  278. package/dist/utils/shortString.mjs +39 -0
  279. package/dist/utils/stark.cjs +137 -0
  280. package/dist/utils/stark.d.ts +224 -0
  281. package/dist/utils/stark.mjs +109 -0
  282. package/dist/utils/starknetId.cjs +196 -0
  283. package/dist/utils/starknetId.d.ts +182 -0
  284. package/dist/utils/starknetId.mjs +185 -0
  285. package/dist/utils/transaction.cjs +115 -0
  286. package/dist/utils/transaction.d.ts +185 -0
  287. package/dist/utils/transaction.mjs +98 -0
  288. package/dist/utils/transactionReceipt.cjs +54 -0
  289. package/dist/utils/transactionReceipt.d.ts +33 -0
  290. package/dist/utils/transactionReceipt.mjs +49 -0
  291. package/dist/utils/typedData.cjs +285 -0
  292. package/dist/utils/typedData.d.ts +54 -0
  293. package/dist/utils/typedData.mjs +286 -0
  294. package/dist/utils/uint256.cjs +30 -0
  295. package/dist/utils/uint256.d.ts +45 -0
  296. package/dist/utils/uint256.mjs +11 -0
  297. package/dist/utils/url.cjs +35 -0
  298. package/dist/utils/url.d.ts +29 -0
  299. package/dist/utils/url.mjs +27 -0
  300. package/dist/wallet/account.cjs +115 -0
  301. package/dist/wallet/account.d.ts +31 -0
  302. package/dist/wallet/account.mjs +112 -0
  303. package/dist/wallet/connect.cjs +90 -0
  304. package/dist/wallet/connect.d.ts +82 -0
  305. package/dist/wallet/connect.mjs +64 -0
  306. package/dist/wallet/index.cjs +16 -0
  307. package/dist/wallet/index.d.ts +1 -0
  308. package/dist/wallet/index.mjs +1 -0
  309. package/dist/wallet/types.cjs +1 -0
  310. package/dist/wallet/types.d.ts +4 -0
  311. package/dist/wallet/types.mjs +0 -0
  312. package/package.json +13 -13
  313. package/dist/index.js +0 -7426
  314. package/dist/index.js.map +0 -1
  315. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,207 @@
1
+ export declare const IS_BROWSER: boolean;
2
+ /**
3
+ * Some functions recreated from https://github.com/pedrouid/enc-utils/blob/master/src/index.ts
4
+ * enc-utils is not a dependency to avoid using `Buffer` which only works in node and not browsers
5
+ */
6
+ /**
7
+ * Convert array buffer to string
8
+ *
9
+ * *[internal usage]*
10
+ *
11
+ * @param {ArrayBuffer} array The ArrayBuffer to convert to string.
12
+ * @returns {string} The converted string.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const buffer = new ArrayBuffer(5);
17
+ * const view = new Uint8Array(buffer);
18
+ * [72, 101, 108, 108, 111].forEach((x, idx) => view[idx] = x);
19
+ * const result = encode.arrayBufferToString(buffer);
20
+ * // result = "Hello"
21
+ * ```
22
+ */
23
+ export declare function arrayBufferToString(array: ArrayBuffer): string;
24
+ /**
25
+ * Convert utf8-string to Uint8Array
26
+ *
27
+ * *[internal usage]*
28
+ *
29
+ * @param {string} str The UTF-8 string to convert.
30
+ * @returns {Uint8Array} The encoded Uint8Array.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const myString = 'Hi';
35
+ * const result = encode.utf8ToArray(myString);
36
+ * // result = Uint8Array(2) [ 72, 105 ]
37
+ * ```
38
+ */
39
+ export declare function utf8ToArray(str: string): Uint8Array;
40
+ /**
41
+ * Convert utf8-string to Uint8Array
42
+ *
43
+ * @deprecated equivalent to 'utf8ToArray', alias will be removed
44
+ */
45
+ export declare function stringToArrayBuffer(str: string): Uint8Array;
46
+ /**
47
+ * Convert string to array buffer (browser and node compatible)
48
+ *
49
+ * @param {string} a The Base64 encoded string to convert.
50
+ * @returns {Uint8Array} The decoded Uint8Array.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const base64String = 'SGVsbG8='; // 'Hello' in Base64
55
+ * const result = encode.atobUniversal(base64String);
56
+ * // result = Uint8Array(5) [ 72, 101, 108, 108, 111 ]
57
+ * ```
58
+ */
59
+ export declare function atobUniversal(a: string): Uint8Array;
60
+ /**
61
+ * Convert array buffer to string (browser and node compatible)
62
+ *
63
+ * @param {ArrayBuffer} b The Array buffer.
64
+ * @returns {string} The Base64 encoded string.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const buffer = new Uint8Array([72, 101, 108, 108, 111]); // Array with ASCII values for 'Hello'
69
+ * const result = encode.btoaUniversal(buffer);
70
+ * // result = "SGVsbG8="
71
+ * ```
72
+ */
73
+ export declare function btoaUniversal(b: ArrayBuffer): string;
74
+ /**
75
+ * Convert array buffer to hex-string
76
+ *
77
+ * @param {Uint8Array} buffer The encoded Uint8Array.
78
+ * @returns {string} The hex-string
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const buffer = new Uint8Array([72, 101, 108, 108, 111]); // Array with ASCII values for 'Hello'
83
+ * const result = encode.buf2hex(buffer);
84
+ * // result = "48656c6c6f"
85
+ * ```
86
+ */
87
+ export declare function buf2hex(buffer: Uint8Array): string;
88
+ /**
89
+ * Remove hex prefix '0x' from hex-string
90
+ * @param hex hex-string
91
+ * @returns {string} The hex-string
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const hexStringWithPrefix = '0x48656c6c6f';
96
+ * const result = encode.removeHexPrefix(hexStringWithPrefix);
97
+ * // result: "48656c6c6f"
98
+ * ```
99
+ */
100
+ export declare function removeHexPrefix(hex: string): string;
101
+ /**
102
+ * Add hex prefix '0x' to base16-string
103
+ * @param hex base16-string
104
+ * @returns {string} The hex-string
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const plainHexString = '48656c6c6f';
109
+ * const result = encode.addHexPrefix(plainHexString);
110
+ * // result: "0x48656c6c6f"
111
+ * ```
112
+ */
113
+ export declare function addHexPrefix(hex: string): string;
114
+ /**
115
+ * Prepend string (default with '0')
116
+ *
117
+ * Pads a string to a certain length with a specific string.
118
+ * The padding can be applied only to the left of the input string.
119
+ *
120
+ * @param {string} str The string to pad.
121
+ * @param {number} length The target length for the padded string.
122
+ * @param {string} [padding='0'] The string to use for padding. Defaults to '0'.
123
+ * @returns {string} The padded string.
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const myString = '1A3F';
128
+ * const result = encode.padLeft(myString, 10);
129
+ * // result: '0000001A3F'
130
+ * ```
131
+ */
132
+ export declare function padLeft(str: string, length: number, padding?: string): string;
133
+ /**
134
+ * Calculate byte length of string
135
+ *
136
+ * *[no internal usage]*
137
+ *
138
+ * Calculates the byte length of a string based on a specified byte size.
139
+ * The function rounds up the byte count to the nearest multiple of the specified byte size.
140
+ *
141
+ * @param {string} str The string whose byte length is to be calculated.
142
+ * @param {number} [byteSize='8'] The size of the byte block to round up to. Defaults to 8.
143
+ * @returns {number} The calculated byte length, rounded to the nearest multiple of byteSize.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const myString = 'Hello';
148
+ * const result = encode.calcByteLength(myString, 4);
149
+ * // result = 8 (rounded up to the nearest multiple of 4)
150
+ *
151
+ * ```
152
+ */
153
+ export declare function calcByteLength(str: string, byteSize?: number): number;
154
+ /**
155
+ * Prepend '0' to string bytes
156
+ *
157
+ * *[no internal usage]*
158
+ *
159
+ *
160
+ * * Prepends padding to the left of a string to ensure it matches a specific byte length.
161
+ * The function uses a specified padding character and rounds up the string length to the nearest multiple of `byteSize`.
162
+ *
163
+ * @param {string} str The string to be padded.
164
+ * @param {number} [byteSize='8'] The byte block size to which the string length should be rounded up. Defaults to 8.
165
+ * @param {string} [padding='0'] The character to use for padding. Defaults to '0'.
166
+ * @returns {string} The padded string.
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * const myString = '123';
171
+ * const result = encode.sanitizeBytes(myString);
172
+ * // result: '00000123' (padded to 8 characters)
173
+ * ```
174
+ */
175
+ export declare function sanitizeBytes(str: string, byteSize?: number, padding?: string): string;
176
+ /**
177
+ * Sanitizes a hex-string by removing any existing '0x' prefix, padding the string with '0' to ensure it has even length,
178
+ * and then re-adding the '0x' prefix.
179
+ *
180
+ * *[no internal usage]*
181
+ * @param hex hex-string
182
+ * @returns format: hex-string
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * const unevenHex = '0x23abc';
187
+ * const result = encode.sanitizeHex(unevenHex);
188
+ * // result = '0x023abc' (padded to ensure even length)
189
+ * ```
190
+ */
191
+ export declare function sanitizeHex(hex: string): string;
192
+ /**
193
+ * String transformation util
194
+ *
195
+ * Pascal case to screaming snake case
196
+ *
197
+ * @param {string} text The PascalCase string to convert.
198
+ * @returns {string} The converted snake_case string in uppercase.
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const pascalString = 'PascalCaseExample';
203
+ * const result = encode.pascalToSnake(pascalString);
204
+ * // result: 'PASCAL_CASE_EXAMPLE'
205
+ * ```
206
+ */
207
+ export declare const pascalToSnake: (text: string) => string;
@@ -0,0 +1,56 @@
1
+ import { base64 } from "@scure/base";
2
+ export const IS_BROWSER = typeof window !== "undefined";
3
+ const STRING_ZERO = "0";
4
+ export function arrayBufferToString(array) {
5
+ return new Uint8Array(array).reduce((data, byte) => data + String.fromCharCode(byte), "");
6
+ }
7
+ export function utf8ToArray(str) {
8
+ return new TextEncoder().encode(str);
9
+ }
10
+ export function stringToArrayBuffer(str) {
11
+ return utf8ToArray(str);
12
+ }
13
+ export function atobUniversal(a) {
14
+ return base64.decode(a);
15
+ }
16
+ export function btoaUniversal(b) {
17
+ return base64.encode(new Uint8Array(b));
18
+ }
19
+ export function buf2hex(buffer) {
20
+ return buffer.reduce((r, x) => r + x.toString(16).padStart(2, "0"), "");
21
+ }
22
+ export function removeHexPrefix(hex) {
23
+ return hex.replace(/^0x/i, "");
24
+ }
25
+ export function addHexPrefix(hex) {
26
+ return `0x${removeHexPrefix(hex)}`;
27
+ }
28
+ function padString(str, length, left, padding = STRING_ZERO) {
29
+ const diff = length - str.length;
30
+ let result = str;
31
+ if (diff > 0) {
32
+ const pad = padding.repeat(diff);
33
+ result = left ? pad + str : str + pad;
34
+ }
35
+ return result;
36
+ }
37
+ export function padLeft(str, length, padding = STRING_ZERO) {
38
+ return padString(str, length, true, padding);
39
+ }
40
+ export function calcByteLength(str, byteSize = 8) {
41
+ const { length } = str;
42
+ const remainder = length % byteSize;
43
+ return remainder ? (length - remainder) / byteSize * byteSize + byteSize : length;
44
+ }
45
+ export function sanitizeBytes(str, byteSize = 8, padding = STRING_ZERO) {
46
+ return padLeft(str, calcByteLength(str, byteSize), padding);
47
+ }
48
+ export function sanitizeHex(hex) {
49
+ hex = removeHexPrefix(hex);
50
+ hex = sanitizeBytes(hex, 2);
51
+ if (hex) {
52
+ hex = addHexPrefix(hex);
53
+ }
54
+ return hex;
55
+ }
56
+ export const pascalToSnake = (text) => /[a-z]/.test(text) ? text.split(/(?=[A-Z])/).join("_").toUpperCase() : text;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ethRandomPrivateKey = ethRandomPrivateKey;
7
+ exports.validateAndParseEthAddress = validateAndParseEthAddress;
8
+ var _secp256k = require("@noble/curves/secp256k1");
9
+ var _encode = require("./encode.cjs");
10
+ var _num = require("./num.cjs");
11
+ var _constants = require("../constants.cjs");
12
+ var _assert = _interopRequireDefault(require("./assert.cjs"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function ethRandomPrivateKey() {
15
+ return (0, _encode.sanitizeHex)((0, _encode.buf2hex)(_secp256k.secp256k1.utils.randomPrivateKey()));
16
+ }
17
+ function validateAndParseEthAddress(address) {
18
+ (0, _num.assertInRange)(address, _constants.ZERO, 2n ** 160n - 1n, "Ethereum Address ");
19
+ const result = (0, _encode.addHexPrefix)((0, _encode.removeHexPrefix)((0, _num.toHex)(address)).padStart(40, "0"));
20
+ (0, _assert.default)(Boolean(result.match(/^(0x)?[0-9a-f]{40}$/)), "Invalid Ethereum Address Format");
21
+ return result;
22
+ }
@@ -0,0 +1,22 @@
1
+ import type { BigNumberish } from '../types';
2
+ /**
3
+ * Get random Ethereum private Key.
4
+ * @returns an Hex string
5
+ * @example
6
+ * ```typescript
7
+ * const myPK: string = randomAddress()
8
+ * // result = "0xf04e69ac152fba37c02929c2ae78c9a481461dda42dbc6c6e286be6eb2a8ab83"
9
+ * ```
10
+ */
11
+ export declare function ethRandomPrivateKey(): string;
12
+ /**
13
+ * Get a string formatted for an Ethereum address, without uppercase characters.
14
+ * @param {BigNumberish} address Address of an Ethereum account.
15
+ * @returns an Hex string coded on 20 bytes
16
+ * @example
17
+ * ```typescript
18
+ * const myEthAddress: string = validateAndParseEthAddress("0x8359E4B0152ed5A731162D3c7B0D8D56edB165")
19
+ * // result = "0x008359e4b0152ed5a731162d3c7b0d8d56edb165"
20
+ * ```
21
+ */
22
+ export declare function validateAndParseEthAddress(address: BigNumberish): string;
@@ -0,0 +1,14 @@
1
+ import { secp256k1 } from "@noble/curves/secp256k1";
2
+ import { addHexPrefix, buf2hex, removeHexPrefix, sanitizeHex } from "./encode.mjs";
3
+ import { assertInRange, toHex } from "./num.mjs";
4
+ import { ZERO } from "../constants.mjs";
5
+ import assert from "./assert.mjs";
6
+ export function ethRandomPrivateKey() {
7
+ return sanitizeHex(buf2hex(secp256k1.utils.randomPrivateKey()));
8
+ }
9
+ export function validateAndParseEthAddress(address) {
10
+ assertInRange(address, ZERO, 2n ** 160n - 1n, "Ethereum Address ");
11
+ const result = addHexPrefix(removeHexPrefix(toHex(address)).padStart(40, "0"));
12
+ assert(Boolean(result.match(/^(0x)?[0-9a-f]{40}$/)), "Invalid Ethereum Address Format");
13
+ return result;
14
+ }
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAbiEvents = getAbiEvents;
7
+ exports.isAbiEvent = isAbiEvent;
8
+ exports.isObject = isObject;
9
+ exports.parseEvents = parseEvents;
10
+ exports.parseUDCEvent = parseUDCEvent;
11
+ var _constants = require("../../constants.cjs");
12
+ var _assert = _interopRequireDefault(require("../assert.cjs"));
13
+ var _cairo = require("../calldata/cairo.cjs");
14
+ var _responseParser = _interopRequireDefault(require("../calldata/responseParser.cjs"));
15
+ var _ec = require("../ec.cjs");
16
+ var _encode = require("../encode.cjs");
17
+ var _num = require("../num.cjs");
18
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
+ function isAbiEvent(object) {
20
+ return object.type === "event";
21
+ }
22
+ function getCairo0AbiEvents(abi) {
23
+ return abi.filter(abiEntry => abiEntry.type === "event").reduce((acc, abiEntry) => {
24
+ const entryName = abiEntry.name;
25
+ const abiEntryMod = {
26
+ ...abiEntry
27
+ };
28
+ abiEntryMod.name = entryName;
29
+ return {
30
+ ...acc,
31
+ [(0, _encode.addHexPrefix)(_ec.starkCurve.keccak((0, _encode.utf8ToArray)(entryName)).toString(16))]: abiEntryMod
32
+ };
33
+ }, {});
34
+ }
35
+ function getCairo1AbiEvents(abi) {
36
+ const abiEventsStructs = abi.filter(obj => isAbiEvent(obj) && obj.kind === "struct");
37
+ const abiEventsEnums = abi.filter(obj => isAbiEvent(obj) && obj.kind === "enum");
38
+ const abiEventsData = abiEventsStructs.reduce((acc, event) => {
39
+ let nameList = [];
40
+ let {
41
+ name
42
+ } = event;
43
+ let flat = false;
44
+ const findName = variant => variant.type === name;
45
+ while (true) {
46
+ const eventEnum = abiEventsEnums.find(eventE => eventE.variants.some(findName));
47
+ if (typeof eventEnum === "undefined") break;
48
+ const variant = eventEnum.variants.find(findName);
49
+ nameList.unshift(variant.name);
50
+ if (variant.kind === "flat") flat = true;
51
+ name = eventEnum.name;
52
+ }
53
+ if (nameList.length === 0) {
54
+ throw new Error("inconsistency in ABI events definition.");
55
+ }
56
+ if (flat) nameList = [nameList[nameList.length - 1]];
57
+ const final = nameList.pop();
58
+ let result = {
59
+ [(0, _encode.addHexPrefix)(_ec.starkCurve.keccak((0, _encode.utf8ToArray)(final)).toString(16))]: event
60
+ };
61
+ while (nameList.length > 0) {
62
+ result = {
63
+ [(0, _encode.addHexPrefix)(_ec.starkCurve.keccak((0, _encode.utf8ToArray)(nameList.pop())).toString(16))]: result
64
+ };
65
+ }
66
+ result = {
67
+ ...result
68
+ };
69
+ return mergeAbiEvents(acc, result);
70
+ }, {});
71
+ return abiEventsData;
72
+ }
73
+ function getAbiEvents(abi) {
74
+ return (0, _cairo.isCairo1Abi)(abi) ? getCairo1AbiEvents(abi) : getCairo0AbiEvents(abi);
75
+ }
76
+ function isObject(item) {
77
+ return item && typeof item === "object" && !Array.isArray(item);
78
+ }
79
+ function mergeAbiEvents(target, source) {
80
+ const output = {
81
+ ...target
82
+ };
83
+ if (isObject(target) && isObject(source)) {
84
+ Object.keys(source).forEach(key => {
85
+ if (isObject(source[key])) {
86
+ if (!(key in target)) Object.assign(output, {
87
+ [key]: source[key]
88
+ });else output[key] = mergeAbiEvents(target[key], source[key]);
89
+ } else {
90
+ Object.assign(output, {
91
+ [key]: source[key]
92
+ });
93
+ }
94
+ });
95
+ }
96
+ return output;
97
+ }
98
+ function parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums) {
99
+ const ret = providerReceivedEvents.flat().reduce((acc, recEvent) => {
100
+ let abiEvent = abiEvents[recEvent.keys.shift() ?? 0];
101
+ if (!abiEvent) {
102
+ return acc;
103
+ }
104
+ while (!abiEvent.name) {
105
+ const hashName = recEvent.keys.shift();
106
+ (0, _assert.default)(!!hashName, 'Not enough data in "key" property of this event.');
107
+ abiEvent = abiEvent[hashName];
108
+ }
109
+ const parsedEvent = {};
110
+ parsedEvent[abiEvent.name] = {};
111
+ const keysIter = recEvent.keys[Symbol.iterator]();
112
+ const dataIter = recEvent.data[Symbol.iterator]();
113
+ const abiEventKeys = abiEvent.members?.filter(it => it.kind === "key") || abiEvent.keys;
114
+ const abiEventData = abiEvent.members?.filter(it => it.kind === "data") || abiEvent.data;
115
+ abiEventKeys.forEach(key => {
116
+ parsedEvent[abiEvent.name][key.name] = (0, _responseParser.default)(keysIter, key, abiStructs, abiEnums, parsedEvent[abiEvent.name]);
117
+ });
118
+ abiEventData.forEach(data => {
119
+ parsedEvent[abiEvent.name][data.name] = (0, _responseParser.default)(dataIter, data, abiStructs, abiEnums, parsedEvent[abiEvent.name]);
120
+ });
121
+ acc.push(parsedEvent);
122
+ return acc;
123
+ }, []);
124
+ return ret;
125
+ }
126
+ function parseUDCEvent(txReceipt) {
127
+ if (!txReceipt.events) {
128
+ throw new Error("UDC emitted event is empty");
129
+ }
130
+ const event = txReceipt.events.find(it => (0, _num.cleanHex)(it.from_address) === (0, _num.cleanHex)(_constants.UDC.ADDRESS)) || {
131
+ data: []
132
+ };
133
+ return {
134
+ transaction_hash: txReceipt.transaction_hash,
135
+ contract_address: event.data[0],
136
+ address: event.data[0],
137
+ deployer: event.data[1],
138
+ unique: event.data[2],
139
+ classHash: event.data[3],
140
+ calldata_len: event.data[4],
141
+ calldata: event.data.slice(5, 5 + parseInt(event.data[4], 16)),
142
+ salt: event.data[event.data.length - 1]
143
+ };
144
+ }
@@ -0,0 +1,84 @@
1
+ import { Abi, AbiEnums, AbiEvents, AbiStructs, ParsedEvents, RPC, type InvokeTransactionReceiptResponse, type AbiEntry } from '../../types';
2
+ /**
3
+ * Check if an ABI entry is related to events.
4
+ * @param {AbiEntry} object an Abi entry
5
+ * @returns {boolean} true if this Abi Entry is related to an event
6
+ * @example
7
+ * ```typescript
8
+ * // use of a transaction receipt
9
+ * ```
10
+ */
11
+ export declare function isAbiEvent(object: AbiEntry): boolean;
12
+ /**
13
+ * Retrieves the events from the given ABI (from Cairo 0 or Cairo 1 contract).
14
+ *
15
+ * Is able to handle Cairo 1 events nested in Cairo components.
16
+ * @param {Abi} abi - The ABI to extract events from.
17
+ * @return {AbiEvents} - An object containing the hashes and the definition of the events.
18
+ * @example
19
+ * ```typescript
20
+ * const result = events.getAbiEvents(abi);
21
+ * // result = {
22
+ * // '0x22ea134d4126804c60797e633195f8c9aa5fd6d1567e299f4961d0e96f373ee':
23
+ * // { '0x34e55c1cd55f1338241b50d352f0e91c7e4ffad0e4271d64eb347589ebdfd16': {
24
+ * // kind: 'struct', type: 'event',
25
+ * // name: 'ka::ExComponent::ex_logic_component::Mint',
26
+
27
+ * // members: [{
28
+ * // name: 'spender',
29
+ * // type: 'core::starknet::contract_address::ContractAddress',
30
+ * // kind: 'key'},
31
+ * // { name: 'value', type: 'core::integer::u256', kind: 'data' }]},
32
+ * // ...
33
+ * ```
34
+ */
35
+ export declare function getAbiEvents(abi: Abi): AbiEvents;
36
+ /**
37
+ * Checks if a given value is an object (Object or Array)
38
+ * @param {any} item the tested item
39
+ * @returns {boolean}
40
+ * @example
41
+ * ```typescript
42
+ * const result = events.isObject({event: "pending"});
43
+ * // result = true
44
+ * ```
45
+ */
46
+ export declare function isObject(item: any): boolean;
47
+ /**
48
+ * Parse raw events and structure them into response object based on a contract structs and defined events
49
+ * @param {RPC.Event[]} providerReceivedEvents Array of raw events
50
+ * @param {AbiEvents} abiEvents Events defined in the abi
51
+ * @param {AbiStructs} abiStructs Structs defined in the abi
52
+ * @param {AbiEnums} abiEnums Enums defined in the abi
53
+ * @returns {ParsedEvents} parsed events corresponding to the abi
54
+ * @example
55
+ * ```typescript
56
+ * const abiEvents = events.getAbiEvents(sierra.abi);
57
+ * const abiStructs = CallData.getAbiStruct(sierra.abi);
58
+ * const abiEnums = CallData.getAbiEnum(sierra.abi);
59
+ * const result = events.parseEvents(myEvents, abiEvents, abiStructs, abiEnums);
60
+ * // result = [{test::ExCh::ex_ch::Trade: {
61
+ maker: 7548613724711489396448209137n,
62
+ taker: 6435850562375218974960297344n,
63
+ router_maker: 0n,
64
+ }}]
65
+ * ```
66
+ */
67
+ export declare function parseEvents(providerReceivedEvents: RPC.Event[], abiEvents: AbiEvents, abiStructs: AbiStructs, abiEnums: AbiEnums): ParsedEvents;
68
+ /**
69
+ * Parse Transaction Receipt Event from UDC invoke transaction and
70
+ * create DeployContractResponse compatible response with addition of the UDC Event data
71
+ *
72
+ * @returns DeployContractResponse | UDC Event Response data
73
+ */
74
+ export declare function parseUDCEvent(txReceipt: InvokeTransactionReceiptResponse): {
75
+ transaction_hash: string;
76
+ contract_address: string;
77
+ address: string;
78
+ deployer: string;
79
+ unique: string;
80
+ classHash: string;
81
+ calldata_len: string;
82
+ calldata: string[];
83
+ salt: string;
84
+ };
@@ -0,0 +1,136 @@
1
+ import { UDC } from "../../constants.mjs";
2
+ import assert from "../assert.mjs";
3
+ import { isCairo1Abi } from "../calldata/cairo.mjs";
4
+ import responseParser from "../calldata/responseParser.mjs";
5
+ import { starkCurve } from "../ec.mjs";
6
+ import { addHexPrefix, utf8ToArray } from "../encode.mjs";
7
+ import { cleanHex } from "../num.mjs";
8
+ export function isAbiEvent(object) {
9
+ return object.type === "event";
10
+ }
11
+ function getCairo0AbiEvents(abi) {
12
+ return abi.filter((abiEntry) => abiEntry.type === "event").reduce((acc, abiEntry) => {
13
+ const entryName = abiEntry.name;
14
+ const abiEntryMod = { ...abiEntry };
15
+ abiEntryMod.name = entryName;
16
+ return {
17
+ ...acc,
18
+ [addHexPrefix(starkCurve.keccak(utf8ToArray(entryName)).toString(16))]: abiEntryMod
19
+ };
20
+ }, {});
21
+ }
22
+ function getCairo1AbiEvents(abi) {
23
+ const abiEventsStructs = abi.filter((obj) => isAbiEvent(obj) && obj.kind === "struct");
24
+ const abiEventsEnums = abi.filter((obj) => isAbiEvent(obj) && obj.kind === "enum");
25
+ const abiEventsData = abiEventsStructs.reduce((acc, event) => {
26
+ let nameList = [];
27
+ let { name } = event;
28
+ let flat = false;
29
+ const findName = (variant) => variant.type === name;
30
+ while (true) {
31
+ const eventEnum = abiEventsEnums.find((eventE) => eventE.variants.some(findName));
32
+ if (typeof eventEnum === "undefined") break;
33
+ const variant = eventEnum.variants.find(findName);
34
+ nameList.unshift(variant.name);
35
+ if (variant.kind === "flat") flat = true;
36
+ name = eventEnum.name;
37
+ }
38
+ if (nameList.length === 0) {
39
+ throw new Error("inconsistency in ABI events definition.");
40
+ }
41
+ if (flat) nameList = [nameList[nameList.length - 1]];
42
+ const final = nameList.pop();
43
+ let result = {
44
+ [addHexPrefix(starkCurve.keccak(utf8ToArray(final)).toString(16))]: event
45
+ };
46
+ while (nameList.length > 0) {
47
+ result = {
48
+ [addHexPrefix(starkCurve.keccak(utf8ToArray(nameList.pop())).toString(16))]: result
49
+ };
50
+ }
51
+ result = { ...result };
52
+ return mergeAbiEvents(acc, result);
53
+ }, {});
54
+ return abiEventsData;
55
+ }
56
+ export function getAbiEvents(abi) {
57
+ return isCairo1Abi(abi) ? getCairo1AbiEvents(abi) : getCairo0AbiEvents(abi);
58
+ }
59
+ export function isObject(item) {
60
+ return item && typeof item === "object" && !Array.isArray(item);
61
+ }
62
+ function mergeAbiEvents(target, source) {
63
+ const output = { ...target };
64
+ if (isObject(target) && isObject(source)) {
65
+ Object.keys(source).forEach((key) => {
66
+ if (isObject(source[key])) {
67
+ if (!(key in target)) Object.assign(output, { [key]: source[key] });
68
+ else output[key] = mergeAbiEvents(target[key], source[key]);
69
+ } else {
70
+ Object.assign(output, { [key]: source[key] });
71
+ }
72
+ });
73
+ }
74
+ return output;
75
+ }
76
+ export function parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums) {
77
+ const ret = providerReceivedEvents.flat().reduce((acc, recEvent) => {
78
+ let abiEvent = abiEvents[recEvent.keys.shift() ?? 0];
79
+ if (!abiEvent) {
80
+ return acc;
81
+ }
82
+ while (!abiEvent.name) {
83
+ const hashName = recEvent.keys.shift();
84
+ assert(!!hashName, 'Not enough data in "key" property of this event.');
85
+ abiEvent = abiEvent[hashName];
86
+ }
87
+ const parsedEvent = {};
88
+ parsedEvent[abiEvent.name] = {};
89
+ const keysIter = recEvent.keys[Symbol.iterator]();
90
+ const dataIter = recEvent.data[Symbol.iterator]();
91
+ const abiEventKeys = abiEvent.members?.filter((it) => it.kind === "key") || abiEvent.keys;
92
+ const abiEventData = abiEvent.members?.filter((it) => it.kind === "data") || abiEvent.data;
93
+ abiEventKeys.forEach((key) => {
94
+ parsedEvent[abiEvent.name][key.name] = responseParser(
95
+ keysIter,
96
+ key,
97
+ abiStructs,
98
+ abiEnums,
99
+ parsedEvent[abiEvent.name]
100
+ );
101
+ });
102
+ abiEventData.forEach((data) => {
103
+ parsedEvent[abiEvent.name][data.name] = responseParser(
104
+ dataIter,
105
+ data,
106
+ abiStructs,
107
+ abiEnums,
108
+ parsedEvent[abiEvent.name]
109
+ );
110
+ });
111
+ acc.push(parsedEvent);
112
+ return acc;
113
+ }, []);
114
+ return ret;
115
+ }
116
+ export function parseUDCEvent(txReceipt) {
117
+ if (!txReceipt.events) {
118
+ throw new Error("UDC emitted event is empty");
119
+ }
120
+ const event = txReceipt.events.find(
121
+ (it) => cleanHex(it.from_address) === cleanHex(UDC.ADDRESS)
122
+ ) || {
123
+ data: []
124
+ };
125
+ return {
126
+ transaction_hash: txReceipt.transaction_hash,
127
+ contract_address: event.data[0],
128
+ address: event.data[0],
129
+ deployer: event.data[1],
130
+ unique: event.data[2],
131
+ classHash: event.data[3],
132
+ calldata_len: event.data[4],
133
+ calldata: event.data.slice(5, 5 + parseInt(event.data[4], 16)),
134
+ salt: event.data[event.data.length - 1]
135
+ };
136
+ }