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,185 @@
1
+ import { BigNumberish, CairoVersion, Call, CallStruct, Calldata, ParsedStruct, UniversalDeployerContractPayload } from '../types';
2
+ /**
3
+ * Transforms a list of Calls, each with their own calldata, into
4
+ * two arrays: one with the entry points, and one with the concatenated calldata
5
+ * @param {Call[]} calls the list of calls to transform.
6
+ * @returns {callArray: ParsedStruct[], calldata: BigNumberish[]} An object containing two arrays: callArray and calldata.
7
+ * @example
8
+ * ```typescript
9
+ * const calls: Call[] = [
10
+ * {
11
+ * contractAddress: "0x1234567890123456789012345678901234567890",
12
+ * entrypoint: "functionName",
13
+ * calldata: [1,2,3]
14
+ * },
15
+ * {
16
+ * contractAddress: "0x0987654321098765432109876543210987654321",
17
+ * entrypoint: "anotherFunction",
18
+ * calldata: [4,5,6]
19
+ * }
20
+ * ];
21
+ * const result = transaction.transformCallsToMulticallArrays(calls);
22
+ * // result = {
23
+ * // callArray: [
24
+ * // { to: "0x1234567890123456789012345678901234567890", selector: "1234567890",
25
+ * // data_offset: "0", data_len: "3" },
26
+ * // { to: "0x0987654321098765432109876543210987654321", selector: "1234567890",
27
+ * // data_offset: "0987654321", data_offset: "3", data_len: "3"}
28
+ * // ], calldata: [1, 2, 3, 4, 5, 6]
29
+ * // }
30
+ * ```
31
+ */
32
+ export declare const transformCallsToMulticallArrays: (calls: Call[]) => {
33
+ callArray: ParsedStruct[];
34
+ calldata: Calldata;
35
+ };
36
+ /**
37
+ * Transforms a list of calls into the Cairo 0 `__execute__` calldata.
38
+ * @param {Call[]} calls the list of calls to transform
39
+ * @returns {Calldata} the Cairo 0 `__execute__` calldata
40
+ * @example
41
+ * ```typescript
42
+ * const calls: Call[] = [
43
+ * {
44
+ * contractAddress: "0x1234567890123456789012345678901234567890",
45
+ * entrypoint: "functionName",
46
+ * calldata: [1, 2, 3]
47
+ * },
48
+ * {
49
+ * contractAddress: "0x0987654321098765432109876543210987654321",
50
+ * entrypoint: "anotherFunction",
51
+ * calldata: [4, 5, 6]
52
+ * }
53
+ * ];
54
+ * const result = transaction.fromCallsToExecuteCalldata(calls);
55
+ * // result = ['2', '103929005307130220006098923584552504982110632080',
56
+ * // '784552248838722632831848474045274978537388011177294206940059575485454596699', '0',
57
+ * // '3', '54400338722927882010739357306608455014511100705',
58
+ * // '836430224577382061379420368022192503799782058803937958828224424676927281484',
59
+ * // '3', '3', '6', '1', '2', '3', '4', '5', '6']
60
+ * ```
61
+ */
62
+ export declare const fromCallsToExecuteCalldata: (calls: Call[]) => Calldata;
63
+ /**
64
+ * Transforms a list of calls into the Cairo 0 `__execute__` calldata including nonce.
65
+ * @deprecated
66
+ */
67
+ export declare const fromCallsToExecuteCalldataWithNonce: (calls: Call[], nonce: BigNumberish) => Calldata;
68
+ /**
69
+ * Format Data inside Calls
70
+ * @deprecated Not required for getting execute Calldata
71
+ */
72
+ export declare const transformCallsToMulticallArrays_cairo1: (calls: Call[]) => CallStruct[];
73
+ /**
74
+ * Transforms a list of calls into the Cairo 1 `__execute__` calldata.
75
+ * @param {Call[]} calls the list of calls to transform.
76
+ * @returns {Calldata} the Cairo 1 `__execute__` calldata.
77
+ * @example
78
+ * ```typescript
79
+ * const calls: Call[] = [
80
+ * {
81
+ * contractAddress: "0x1234567890123456789012345678901234567890",
82
+ * entrypoint: "functionName",
83
+ * calldata: [1, 2, 3]
84
+ * },
85
+ * {
86
+ * contractAddress: "0x0987654321098765432109876543210987654321",
87
+ * entrypoint: "anotherFunction",
88
+ * calldata: [4, 5, 6]
89
+ * }
90
+ * ];
91
+ * const result = transaction.fromCallsToExecuteCalldata_cairo1(calls);
92
+ * // result = ['2', '103929005307130220006098923584552504982110632080',
93
+ * // '784552248838722632831848474045274978537388011177294206940059575485454596699',
94
+ * // '3', '1', '2', '3', '54400338722927882010739357306608455014511100705',
95
+ * // '836430224577382061379420368022192503799782058803937958828224424676927281484',
96
+ * // '3', '4', '5', '6']
97
+ * ```
98
+ */
99
+ export declare const fromCallsToExecuteCalldata_cairo1: (calls: Call[]) => Calldata;
100
+ /**
101
+ * Create `__execute__` Calldata from Calls based on Cairo versions.
102
+ * @param {Call[]} calls the list of calls to transform
103
+ * @param {CairoVersion} cairoVersion the Cairo version
104
+ * @returns {Calldata} the `__execute__` calldata.
105
+ * @example
106
+ * ```typescript
107
+ * const calls: Call[] = [
108
+ * {
109
+ * contractAddress: "0x1234567890123456789012345678901234567890",
110
+ * entrypoint: "functionName",
111
+ * calldata: [1, 2, 3]
112
+ * },
113
+ * {
114
+ * contractAddress: "0x0987654321098765432109876543210987654321",
115
+ * entrypoint: "anotherFunction",
116
+ * calldata: [4, 5, 6]
117
+ * }
118
+ * ];
119
+ * const result = transaction.getExecuteCalldata(calls, '1');
120
+ * // result = ['2', '103929005307130220006098923584552504982110632080',
121
+ * // '784552248838722632831848474045274978537388011177294206940059575485454596699',
122
+ * // '3', '1', '2', '3', '54400338722927882010739357306608455014511100705',
123
+ * // '836430224577382061379420368022192503799782058803937958828224424676927281484',
124
+ * // '3', '4', '5', '6']
125
+ * ```
126
+ */
127
+ export declare const getExecuteCalldata: (calls: Call[], cairoVersion?: CairoVersion) => Calldata;
128
+ /**
129
+ * Builds a UDCCall object.
130
+ *
131
+ * @param {UniversalDeployerContractPayload | UniversalDeployerContractPayload[]} payload the payload data for the UDCCall. Can be a single payload object or an array of payload objects.
132
+ * @param {string} address the address to be used in the UDCCall
133
+ * @returns { calls: Call[], addresses: string[] } the UDCCall object containing an array of calls and an array of addresses.
134
+ * @example
135
+ * ```typescript
136
+ * const payload: UniversalDeployerContractPayload = {
137
+ * classHash: "0x1234567890123456789012345678901234567890",
138
+ * salt: "0x0987654321098765432109876543210987654321",
139
+ * unique:true,
140
+ * constructorCalldata: [1, 2, 3]
141
+ * };
142
+ * const address = "0xABCDEF1234567890ABCDEF1234567890ABCDEF12";
143
+ * const result = transaction.buildUDCCall(payload, address);
144
+ * // result = {
145
+ * // calls: [
146
+ * // {
147
+ * // contractAddress: "0xABCDEF1234567890ABCDEF1234567890ABCDEF12",
148
+ * // entrypoint: "functionName",
149
+ * // calldata: [classHash, salt, true, 3, 1, 2, 3]
150
+ * // }],
151
+ * // addresses: ["0x6fD084B56a7EDc5C06B3eB40f97Ae5A0C707A865"]
152
+ * // }
153
+ * ```
154
+ */
155
+ export declare function buildUDCCall(payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], address: string): {
156
+ calls: {
157
+ contractAddress: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf";
158
+ entrypoint: "deployContract";
159
+ calldata: BigNumberish[];
160
+ }[];
161
+ addresses: string[];
162
+ };
163
+ /**
164
+ * Return transaction versions based on version type, default version type is 'transaction'.
165
+ * @param {'fee' | 'transaction'} [versionType] the type of version ("fee" or "transaction")
166
+ * @returns {v1: ETransactionVersion, v2: ETransactionVersion, v3: ETransactionVersion} an object containing the transaction versions.
167
+ * @example
168
+ * ```typescript
169
+ * const result = transaction.getVersionsByType('fee');
170
+ * // result = {
171
+ * // v1: '0x100000000000000000000000000000001',
172
+ * // v2: '0x100000000000000000000000000000002',
173
+ * // v3: '0x100000000000000000000000000000003'
174
+ * // }
175
+ * ```
176
+ */
177
+ export declare function getVersionsByType(versionType?: 'fee' | 'transaction'): {
178
+ v1: "0x100000000000000000000000000000001";
179
+ v2: "0x100000000000000000000000000000002";
180
+ v3: "0x100000000000000000000000000000003";
181
+ } | {
182
+ v1: "0x1";
183
+ v2: "0x2";
184
+ v3: "0x3";
185
+ };
@@ -0,0 +1,98 @@
1
+ import { UDC } from "../constants.mjs";
2
+ import { ETransactionVersion } from "../types/api/index.mjs";
3
+ import { CallData } from "./calldata/index.mjs";
4
+ import { starkCurve } from "./ec.mjs";
5
+ import { calculateContractAddressFromHash, getSelectorFromName } from "./hash/index.mjs";
6
+ import { toBigInt, toCairoBool } from "./num.mjs";
7
+ import { randomAddress } from "./stark.mjs";
8
+ export const transformCallsToMulticallArrays = (calls) => {
9
+ const callArray = [];
10
+ const calldata = [];
11
+ calls.forEach((call) => {
12
+ const data = CallData.compile(call.calldata || []);
13
+ callArray.push({
14
+ to: toBigInt(call.contractAddress).toString(10),
15
+ selector: toBigInt(getSelectorFromName(call.entrypoint)).toString(10),
16
+ data_offset: calldata.length.toString(),
17
+ data_len: data.length.toString()
18
+ });
19
+ calldata.push(...data);
20
+ });
21
+ return {
22
+ callArray,
23
+ calldata: CallData.compile({ calldata })
24
+ };
25
+ };
26
+ export const fromCallsToExecuteCalldata = (calls) => {
27
+ const { callArray, calldata } = transformCallsToMulticallArrays(calls);
28
+ const compiledCalls = CallData.compile({ callArray });
29
+ return [...compiledCalls, ...calldata];
30
+ };
31
+ export const fromCallsToExecuteCalldataWithNonce = (calls, nonce) => {
32
+ return [...fromCallsToExecuteCalldata(calls), toBigInt(nonce).toString()];
33
+ };
34
+ export const transformCallsToMulticallArrays_cairo1 = (calls) => {
35
+ const callArray = calls.map((call) => ({
36
+ to: toBigInt(call.contractAddress).toString(10),
37
+ selector: toBigInt(getSelectorFromName(call.entrypoint)).toString(10),
38
+ calldata: CallData.compile(call.calldata || [])
39
+ }));
40
+ return callArray;
41
+ };
42
+ export const fromCallsToExecuteCalldata_cairo1 = (calls) => {
43
+ const orderCalls = calls.map((call) => ({
44
+ contractAddress: call.contractAddress,
45
+ entrypoint: call.entrypoint,
46
+ calldata: Array.isArray(call.calldata) && "__compiled__" in call.calldata ? call.calldata : CallData.compile(call.calldata)
47
+ // RawArgsObject | RawArgsArray type
48
+ }));
49
+ return CallData.compile({ orderCalls });
50
+ };
51
+ export const getExecuteCalldata = (calls, cairoVersion = "0") => {
52
+ if (cairoVersion === "1") {
53
+ return fromCallsToExecuteCalldata_cairo1(calls);
54
+ }
55
+ return fromCallsToExecuteCalldata(calls);
56
+ };
57
+ export function buildUDCCall(payload, address) {
58
+ const params = [].concat(payload).map((it) => {
59
+ const {
60
+ classHash,
61
+ salt,
62
+ unique = true,
63
+ constructorCalldata = []
64
+ } = it;
65
+ const compiledConstructorCallData = CallData.compile(constructorCalldata);
66
+ const deploySalt = salt ?? randomAddress();
67
+ return {
68
+ call: {
69
+ contractAddress: UDC.ADDRESS,
70
+ entrypoint: UDC.ENTRYPOINT,
71
+ calldata: [
72
+ classHash,
73
+ deploySalt,
74
+ toCairoBool(unique),
75
+ compiledConstructorCallData.length,
76
+ ...compiledConstructorCallData
77
+ ]
78
+ },
79
+ address: calculateContractAddressFromHash(
80
+ unique ? starkCurve.pedersen(address, deploySalt) : deploySalt,
81
+ classHash,
82
+ compiledConstructorCallData,
83
+ unique ? UDC.ADDRESS : 0
84
+ )
85
+ };
86
+ });
87
+ return {
88
+ calls: params.map((it) => it.call),
89
+ addresses: params.map((it) => it.address)
90
+ };
91
+ }
92
+ export function getVersionsByType(versionType) {
93
+ return versionType === "fee" ? {
94
+ v1: ETransactionVersion.F1,
95
+ v2: ETransactionVersion.F2,
96
+ v3: ETransactionVersion.F3
97
+ } : { v1: ETransactionVersion.V1, v2: ETransactionVersion.V2, v3: ETransactionVersion.V3 };
98
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ReceiptTx = void 0;
7
+ var _types = require("../types/index.cjs");
8
+ class ReceiptTx {
9
+ statusReceipt;
10
+ value;
11
+ constructor(receipt) {
12
+ [this.statusReceipt, this.value] = ReceiptTx.isSuccess(receipt) ? ["success", receipt] : ReceiptTx.isReverted(receipt) ? ["reverted", receipt] : ReceiptTx.isRejected(receipt) ? ["rejected", receipt] : ["error", new Error("Unknown response type")];
13
+ for (const [key] of Object.entries(this)) {
14
+ Object.defineProperty(this, key, {
15
+ enumerable: false
16
+ });
17
+ }
18
+ for (const [key, value] of Object.entries(receipt)) {
19
+ Object.defineProperty(this, key, {
20
+ enumerable: true,
21
+ writable: false,
22
+ value
23
+ });
24
+ }
25
+ }
26
+ match(callbacks) {
27
+ if (this.statusReceipt in callbacks) {
28
+ return callbacks[this.statusReceipt](this.value);
29
+ }
30
+ return callbacks._();
31
+ }
32
+ isSuccess() {
33
+ return this.statusReceipt === "success";
34
+ }
35
+ isReverted() {
36
+ return this.statusReceipt === "reverted";
37
+ }
38
+ isRejected() {
39
+ return this.statusReceipt === "rejected";
40
+ }
41
+ isError() {
42
+ return this.statusReceipt === "error";
43
+ }
44
+ static isSuccess(transactionReceipt) {
45
+ return transactionReceipt.execution_status === _types.TransactionExecutionStatus.SUCCEEDED;
46
+ }
47
+ static isReverted(transactionReceipt) {
48
+ return transactionReceipt.execution_status === _types.TransactionExecutionStatus.REVERTED;
49
+ }
50
+ static isRejected(transactionReceipt) {
51
+ return transactionReceipt.status === _types.TransactionExecutionStatus.REJECTED;
52
+ }
53
+ }
54
+ exports.ReceiptTx = ReceiptTx;
@@ -0,0 +1,33 @@
1
+ import { GetTxReceiptResponseWithoutHelper, RejectedTransactionReceiptResponse, RevertedTransactionReceiptResponse, SuccessfulTransactionReceiptResponse } from '../types';
2
+ import type { TransactionReceiptCallbacks, TransactionReceiptStatus, TransactionReceiptUtilityInterface, TransactionReceiptValue } from '../types/transactionReceipt';
3
+ /**
4
+ * Utility that analyses transaction receipt response and provides helpers to process it
5
+ * @example
6
+ * ```typescript
7
+ * const responseTx = new ReceiptTx(receipt);
8
+ * responseTx.match({
9
+ * success: (txR: SuccessfulTransactionReceiptResponse) => { },
10
+ * rejected: (txR: RejectedTransactionReceiptResponse) => { },
11
+ * reverted: (txR: RevertedTransactionReceiptResponse) => { },
12
+ * error: (err: Error) => { },
13
+ * });
14
+ * responseTx.match({
15
+ * success: (txR: SuccessfulTransactionReceiptResponse) => { },
16
+ * _: () => { },
17
+ * }
18
+ * ```
19
+ */
20
+ export declare class ReceiptTx implements TransactionReceiptUtilityInterface {
21
+ readonly statusReceipt: TransactionReceiptStatus;
22
+ readonly value: TransactionReceiptValue;
23
+ constructor(receipt: GetTxReceiptResponseWithoutHelper);
24
+ match(callbacks: TransactionReceiptCallbacks): void;
25
+ isSuccess(): this is SuccessfulTransactionReceiptResponse;
26
+ isReverted(): this is RevertedTransactionReceiptResponse;
27
+ isRejected(): this is RejectedTransactionReceiptResponse;
28
+ isError(): boolean;
29
+ static isSuccess(transactionReceipt: GetTxReceiptResponseWithoutHelper): transactionReceipt is SuccessfulTransactionReceiptResponse;
30
+ static isReverted(transactionReceipt: GetTxReceiptResponseWithoutHelper): transactionReceipt is RevertedTransactionReceiptResponse;
31
+ static isRejected(transactionReceipt: GetTxReceiptResponseWithoutHelper): transactionReceipt is RejectedTransactionReceiptResponse;
32
+ }
33
+ export type GetTransactionReceiptResponse = GetTxReceiptResponseWithoutHelper & ReceiptTx;
@@ -0,0 +1,49 @@
1
+ import {
2
+ TransactionExecutionStatus
3
+ } from "../types/index.mjs";
4
+ export class ReceiptTx {
5
+ statusReceipt;
6
+ value;
7
+ constructor(receipt) {
8
+ [this.statusReceipt, this.value] = ReceiptTx.isSuccess(receipt) ? ["success", receipt] : ReceiptTx.isReverted(receipt) ? ["reverted", receipt] : ReceiptTx.isRejected(receipt) ? ["rejected", receipt] : ["error", new Error("Unknown response type")];
9
+ for (const [key] of Object.entries(this)) {
10
+ Object.defineProperty(this, key, {
11
+ enumerable: false
12
+ });
13
+ }
14
+ for (const [key, value] of Object.entries(receipt)) {
15
+ Object.defineProperty(this, key, {
16
+ enumerable: true,
17
+ writable: false,
18
+ value
19
+ });
20
+ }
21
+ }
22
+ match(callbacks) {
23
+ if (this.statusReceipt in callbacks) {
24
+ return callbacks[this.statusReceipt](this.value);
25
+ }
26
+ return callbacks._();
27
+ }
28
+ isSuccess() {
29
+ return this.statusReceipt === "success";
30
+ }
31
+ isReverted() {
32
+ return this.statusReceipt === "reverted";
33
+ }
34
+ isRejected() {
35
+ return this.statusReceipt === "rejected";
36
+ }
37
+ isError() {
38
+ return this.statusReceipt === "error";
39
+ }
40
+ static isSuccess(transactionReceipt) {
41
+ return transactionReceipt.execution_status === TransactionExecutionStatus.SUCCEEDED;
42
+ }
43
+ static isReverted(transactionReceipt) {
44
+ return transactionReceipt.execution_status === TransactionExecutionStatus.REVERTED;
45
+ }
46
+ static isRejected(transactionReceipt) {
47
+ return transactionReceipt.status === TransactionExecutionStatus.REJECTED;
48
+ }
49
+ }