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,70 @@
1
+ import { ETransactionVersion } from './types/api';
2
+ import { ValuesType } from './types/helpers/valuesType';
3
+ export { IS_BROWSER } from './utils/encode';
4
+ /**
5
+ * Cairo Felt support storing max 31 character
6
+ */
7
+ export declare const TEXT_TO_FELT_MAX_LEN = 31;
8
+ /**
9
+ * Alternatively use directly from api specification
10
+ * types.RPC.ETransactionVersion
11
+ * For BN do BigInt(TRANSACTION_VERSION.*)
12
+ */
13
+ export { ETransactionVersion as TRANSACTION_VERSION };
14
+ export declare const ZERO = 0n;
15
+ export declare const MASK_250: bigint;
16
+ export declare const API_VERSION = 0n;
17
+ export declare const PRIME: bigint;
18
+ export declare const MAX_STORAGE_ITEM_SIZE = 256n;
19
+ export declare const ADDR_BOUND: bigint;
20
+ export declare const RANGE_FELT: {
21
+ readonly min: bigint;
22
+ readonly max: bigint;
23
+ };
24
+ export declare const RANGE_I128: {
25
+ readonly min: bigint;
26
+ readonly max: bigint;
27
+ };
28
+ export declare const RANGE_U128: {
29
+ readonly min: bigint;
30
+ readonly max: bigint;
31
+ };
32
+ export declare const BaseUrl: {
33
+ readonly SN_MAIN: "https://alpha-mainnet.starknet.io";
34
+ readonly SN_SEPOLIA: "https://alpha-sepolia.starknet.io";
35
+ };
36
+ export type BaseUrl = ValuesType<typeof BaseUrl>;
37
+ export declare const NetworkName: {
38
+ readonly SN_MAIN: "SN_MAIN";
39
+ readonly SN_SEPOLIA: "SN_SEPOLIA";
40
+ };
41
+ export type NetworkName = ValuesType<typeof NetworkName>;
42
+ export declare const StarknetChainId: {
43
+ readonly SN_MAIN: "0x534e5f4d41494e";
44
+ readonly SN_SEPOLIA: "0x534e5f5345504f4c4941";
45
+ };
46
+ export type StarknetChainId = ValuesType<typeof StarknetChainId>;
47
+ export declare const TransactionHashPrefix: {
48
+ readonly DECLARE: "0x6465636c617265";
49
+ readonly DEPLOY: "0x6465706c6f79";
50
+ readonly DEPLOY_ACCOUNT: "0x6465706c6f795f6163636f756e74";
51
+ readonly INVOKE: "0x696e766f6b65";
52
+ readonly L1_HANDLER: "0x6c315f68616e646c6572";
53
+ };
54
+ export type TransactionHashPrefix = ValuesType<typeof TransactionHashPrefix>;
55
+ export declare const FeeMarginPercentage: {
56
+ readonly L1_BOUND_MAX_AMOUNT: 50;
57
+ readonly L1_BOUND_MAX_PRICE_PER_UNIT: 50;
58
+ readonly MAX_FEE: 50;
59
+ };
60
+ export type FeeMarginPercentage = ValuesType<typeof FeeMarginPercentage>;
61
+ export declare const UDC: {
62
+ readonly ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf";
63
+ readonly ENTRYPOINT: "deployContract";
64
+ };
65
+ export type UDC = ValuesType<typeof UDC>;
66
+ export declare const RPC_DEFAULT_VERSION = "v0_7";
67
+ export declare const RPC_NODES: {
68
+ readonly SN_MAIN: readonly ["https://starknet-mainnet.public.blastapi.io/rpc/v0_7", "https://free-rpc.nethermind.io/mainnet-juno/v0_7"];
69
+ readonly SN_SEPOLIA: readonly ["https://starknet-sepolia.public.blastapi.io/rpc/v0_7", "https://free-rpc.nethermind.io/sepolia-juno/v0_7"];
70
+ };
@@ -0,0 +1,60 @@
1
+ import { ETransactionVersion } from "./types/api/index.mjs";
2
+ export { IS_BROWSER } from "./utils/encode.mjs";
3
+ export const TEXT_TO_FELT_MAX_LEN = 31;
4
+ export { ETransactionVersion as TRANSACTION_VERSION };
5
+ export const ZERO = 0n;
6
+ export const MASK_250 = 2n ** 250n - 1n;
7
+ export const API_VERSION = ZERO;
8
+ export const PRIME = 2n ** 251n + 17n * 2n ** 192n + 1n;
9
+ export const MAX_STORAGE_ITEM_SIZE = 256n;
10
+ export const ADDR_BOUND = 2n ** 251n - MAX_STORAGE_ITEM_SIZE;
11
+ const range = (min, max) => ({ min, max });
12
+ export const RANGE_FELT = range(ZERO, PRIME - 1n);
13
+ export const RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
14
+ export const RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
15
+ export const BaseUrl = {
16
+ SN_MAIN: "https://alpha-mainnet.starknet.io",
17
+ SN_SEPOLIA: "https://alpha-sepolia.starknet.io"
18
+ };
19
+ export const NetworkName = {
20
+ SN_MAIN: "SN_MAIN",
21
+ SN_SEPOLIA: "SN_SEPOLIA"
22
+ };
23
+ export const StarknetChainId = {
24
+ SN_MAIN: "0x534e5f4d41494e",
25
+ // encodeShortString('SN_MAIN'),
26
+ SN_SEPOLIA: "0x534e5f5345504f4c4941"
27
+ // encodeShortString('SN_SEPOLIA')
28
+ };
29
+ export const TransactionHashPrefix = {
30
+ DECLARE: "0x6465636c617265",
31
+ // encodeShortString('declare'),
32
+ DEPLOY: "0x6465706c6f79",
33
+ // encodeShortString('deploy'),
34
+ DEPLOY_ACCOUNT: "0x6465706c6f795f6163636f756e74",
35
+ // encodeShortString('deploy_account'),
36
+ INVOKE: "0x696e766f6b65",
37
+ // encodeShortString('invoke'),
38
+ L1_HANDLER: "0x6c315f68616e646c6572"
39
+ // encodeShortString('l1_handler'),
40
+ };
41
+ export const FeeMarginPercentage = {
42
+ L1_BOUND_MAX_AMOUNT: 50,
43
+ L1_BOUND_MAX_PRICE_PER_UNIT: 50,
44
+ MAX_FEE: 50
45
+ };
46
+ export const UDC = {
47
+ ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
48
+ ENTRYPOINT: "deployContract"
49
+ };
50
+ export const RPC_DEFAULT_VERSION = "v0_7";
51
+ export const RPC_NODES = {
52
+ SN_MAIN: [
53
+ `https://starknet-mainnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
54
+ `https://free-rpc.nethermind.io/mainnet-juno/${RPC_DEFAULT_VERSION}`
55
+ ],
56
+ SN_SEPOLIA: [
57
+ `https://starknet-sepolia.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
58
+ `https://free-rpc.nethermind.io/sepolia-juno/${RPC_DEFAULT_VERSION}`
59
+ ]
60
+ };
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ContractFactory = void 0;
7
+ var _types = require("../types/index.cjs");
8
+ var _assert = _interopRequireDefault(require("../utils/assert.cjs"));
9
+ var _calldata = require("../utils/calldata/index.cjs");
10
+ var _default = require("./default.cjs");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ class ContractFactory {
13
+ compiledContract;
14
+ account;
15
+ abi;
16
+ classHash;
17
+ casm;
18
+ compiledClassHash;
19
+ CallData;
20
+ /**
21
+ * @param params CFParams
22
+ * - compiledContract: CompiledContract;
23
+ * - account: AccountInterface;
24
+ * - casm?: CairoAssembly;
25
+ * - classHash?: string;
26
+ * - compiledClassHash?: string;
27
+ * - abi?: Abi;
28
+ */
29
+ constructor(params) {
30
+ this.compiledContract = params.compiledContract;
31
+ this.account = params.account;
32
+ this.casm = params.casm;
33
+ this.abi = params.abi ?? params.compiledContract.abi;
34
+ this.classHash = params.classHash;
35
+ this.compiledClassHash = params.compiledClassHash;
36
+ this.CallData = new _calldata.CallData(this.abi);
37
+ }
38
+ /**
39
+ * Deploys contract and returns new instance of the Contract
40
+ *
41
+ * If contract is not declared it will first declare it, and then deploy
42
+ */
43
+ async deploy(...args) {
44
+ const {
45
+ args: param,
46
+ options = {
47
+ parseRequest: true
48
+ }
49
+ } = (0, _default.splitArgsAndOptions)(args);
50
+ const constructorCalldata = (0, _default.getCalldata)(param, () => {
51
+ if (options.parseRequest) {
52
+ this.CallData.validate(_types.ValidateType.DEPLOY, "constructor", param);
53
+ return this.CallData.compile("constructor", param);
54
+ }
55
+ console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
56
+ return param;
57
+ });
58
+ const {
59
+ deploy: {
60
+ contract_address,
61
+ transaction_hash
62
+ }
63
+ } = await this.account.declareAndDeploy({
64
+ contract: this.compiledContract,
65
+ casm: this.casm,
66
+ classHash: this.classHash,
67
+ compiledClassHash: this.compiledClassHash,
68
+ constructorCalldata,
69
+ salt: options.addressSalt
70
+ });
71
+ (0, _assert.default)(Boolean(contract_address), "Deployment of the contract failed");
72
+ const contractInstance = new _default.Contract(this.compiledContract.abi, contract_address, this.account);
73
+ contractInstance.deployTransactionHash = transaction_hash;
74
+ return contractInstance;
75
+ }
76
+ /**
77
+ * Attaches to new Account
78
+ *
79
+ * @param account - new Account to attach to
80
+ */
81
+ connect(account) {
82
+ this.account = account;
83
+ return this;
84
+ }
85
+ /**
86
+ * Attaches current abi and account to the new address
87
+ */
88
+ attach(address) {
89
+ return new _default.Contract(this.abi, address, this.account);
90
+ }
91
+ // ethers.js' getDeployTransaction can't be supported as it requires the account or signer to return a signed transaction which is not possible with the current implementation
92
+ }
93
+ exports.ContractFactory = ContractFactory;
@@ -0,0 +1,46 @@
1
+ import { AccountInterface } from '../account';
2
+ import { Abi, ArgsOrCalldataWithOptions, CairoAssembly, CompiledContract } from '../types';
3
+ import { Contract } from './default';
4
+ export type ContractFactoryParams = {
5
+ compiledContract: CompiledContract;
6
+ account: any;
7
+ casm?: CairoAssembly;
8
+ classHash?: string;
9
+ compiledClassHash?: string;
10
+ abi?: Abi;
11
+ };
12
+ export declare class ContractFactory {
13
+ compiledContract: CompiledContract;
14
+ account: AccountInterface;
15
+ abi: Abi;
16
+ classHash?: string;
17
+ casm?: CairoAssembly;
18
+ compiledClassHash?: string;
19
+ private CallData;
20
+ /**
21
+ * @param params CFParams
22
+ * - compiledContract: CompiledContract;
23
+ * - account: AccountInterface;
24
+ * - casm?: CairoAssembly;
25
+ * - classHash?: string;
26
+ * - compiledClassHash?: string;
27
+ * - abi?: Abi;
28
+ */
29
+ constructor(params: ContractFactoryParams);
30
+ /**
31
+ * Deploys contract and returns new instance of the Contract
32
+ *
33
+ * If contract is not declared it will first declare it, and then deploy
34
+ */
35
+ deploy(...args: ArgsOrCalldataWithOptions): Promise<Contract>;
36
+ /**
37
+ * Attaches to new Account
38
+ *
39
+ * @param account - new Account to attach to
40
+ */
41
+ connect(account: AccountInterface): ContractFactory;
42
+ /**
43
+ * Attaches current abi and account to the new address
44
+ */
45
+ attach(address: string): Contract;
46
+ }
@@ -0,0 +1,83 @@
1
+ import {
2
+ ValidateType
3
+ } from "../types/index.mjs";
4
+ import assert from "../utils/assert.mjs";
5
+ import { CallData } from "../utils/calldata/index.mjs";
6
+ import { Contract, getCalldata, splitArgsAndOptions } from "./default.mjs";
7
+ export class ContractFactory {
8
+ compiledContract;
9
+ account;
10
+ abi;
11
+ classHash;
12
+ casm;
13
+ compiledClassHash;
14
+ CallData;
15
+ /**
16
+ * @param params CFParams
17
+ * - compiledContract: CompiledContract;
18
+ * - account: AccountInterface;
19
+ * - casm?: CairoAssembly;
20
+ * - classHash?: string;
21
+ * - compiledClassHash?: string;
22
+ * - abi?: Abi;
23
+ */
24
+ constructor(params) {
25
+ this.compiledContract = params.compiledContract;
26
+ this.account = params.account;
27
+ this.casm = params.casm;
28
+ this.abi = params.abi ?? params.compiledContract.abi;
29
+ this.classHash = params.classHash;
30
+ this.compiledClassHash = params.compiledClassHash;
31
+ this.CallData = new CallData(this.abi);
32
+ }
33
+ /**
34
+ * Deploys contract and returns new instance of the Contract
35
+ *
36
+ * If contract is not declared it will first declare it, and then deploy
37
+ */
38
+ async deploy(...args) {
39
+ const { args: param, options = { parseRequest: true } } = splitArgsAndOptions(args);
40
+ const constructorCalldata = getCalldata(param, () => {
41
+ if (options.parseRequest) {
42
+ this.CallData.validate(ValidateType.DEPLOY, "constructor", param);
43
+ return this.CallData.compile("constructor", param);
44
+ }
45
+ console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
46
+ return param;
47
+ });
48
+ const {
49
+ deploy: { contract_address, transaction_hash }
50
+ } = await this.account.declareAndDeploy({
51
+ contract: this.compiledContract,
52
+ casm: this.casm,
53
+ classHash: this.classHash,
54
+ compiledClassHash: this.compiledClassHash,
55
+ constructorCalldata,
56
+ salt: options.addressSalt
57
+ });
58
+ assert(Boolean(contract_address), "Deployment of the contract failed");
59
+ const contractInstance = new Contract(
60
+ this.compiledContract.abi,
61
+ contract_address,
62
+ this.account
63
+ );
64
+ contractInstance.deployTransactionHash = transaction_hash;
65
+ return contractInstance;
66
+ }
67
+ /**
68
+ * Attaches to new Account
69
+ *
70
+ * @param account - new Account to attach to
71
+ */
72
+ connect(account) {
73
+ this.account = account;
74
+ return this;
75
+ }
76
+ /**
77
+ * Attaches current abi and account to the new address
78
+ */
79
+ attach(address) {
80
+ return new Contract(this.abi, address, this.account);
81
+ }
82
+ // ethers.js' getDeployTransaction can't be supported as it requires the account or signer to return a signed transaction which is not possible with the current implementation
83
+ }
@@ -0,0 +1,269 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Contract = void 0;
7
+ exports.getCalldata = getCalldata;
8
+ exports.splitArgsAndOptions = void 0;
9
+ var _provider = require("../provider/index.cjs");
10
+ var _types = require("../types/index.cjs");
11
+ var _assert = _interopRequireDefault(require("../utils/assert.cjs"));
12
+ var _calldata = require("../utils/calldata/index.cjs");
13
+ var _parser = require("../utils/calldata/parser/index.cjs");
14
+ var _index = require("../utils/events/index.cjs");
15
+ var _num = require("../utils/num.cjs");
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ const splitArgsAndOptions = args => {
18
+ const options = ["blockIdentifier", "parseRequest", "parseResponse", "formatResponse", "maxFee", "nonce", "signature", "addressSalt"];
19
+ const lastArg = args[args.length - 1];
20
+ if (typeof lastArg === "object" && options.some(x => x in lastArg)) {
21
+ return {
22
+ args,
23
+ options: args.pop()
24
+ };
25
+ }
26
+ return {
27
+ args
28
+ };
29
+ };
30
+ exports.splitArgsAndOptions = splitArgsAndOptions;
31
+ function buildCall(contract, functionAbi) {
32
+ return async function (...args) {
33
+ const params = splitArgsAndOptions(args);
34
+ return contract.call(functionAbi.name, params.args, {
35
+ parseRequest: true,
36
+ parseResponse: true,
37
+ ...params.options
38
+ });
39
+ };
40
+ }
41
+ function buildInvoke(contract, functionAbi) {
42
+ return async function (...args) {
43
+ const params = splitArgsAndOptions(args);
44
+ return contract.invoke(functionAbi.name, params.args, {
45
+ parseRequest: true,
46
+ ...params.options
47
+ });
48
+ };
49
+ }
50
+ function buildDefault(contract, functionAbi) {
51
+ if (functionAbi.stateMutability === "view" || functionAbi.state_mutability === "view") {
52
+ return buildCall(contract, functionAbi);
53
+ }
54
+ return buildInvoke(contract, functionAbi);
55
+ }
56
+ function buildPopulate(contract, functionAbi) {
57
+ return function (...args) {
58
+ return contract.populate(functionAbi.name, args);
59
+ };
60
+ }
61
+ function buildEstimate(contract, functionAbi) {
62
+ return function (...args) {
63
+ return contract.estimate(functionAbi.name, args);
64
+ };
65
+ }
66
+ function getCalldata(args, callback) {
67
+ if (Array.isArray(args) && "__compiled__" in args) return args;
68
+ if (Array.isArray(args) && Array.isArray(args[0]) && "__compiled__" in args[0]) return args[0];
69
+ return callback();
70
+ }
71
+ class Contract {
72
+ abi;
73
+ address;
74
+ providerOrAccount;
75
+ deployTransactionHash;
76
+ structs;
77
+ events;
78
+ functions;
79
+ callStatic;
80
+ populateTransaction;
81
+ estimateFee;
82
+ callData;
83
+ /**
84
+ * Contract class to handle contract methods
85
+ *
86
+ * @param abi - Abi of the contract object
87
+ * @param address (optional) - address to connect to
88
+ * @param providerOrAccount (optional) - Provider or Account to attach to
89
+ */
90
+ constructor(abi, address, providerOrAccount = _provider.defaultProvider) {
91
+ this.address = address && address.toLowerCase();
92
+ this.providerOrAccount = providerOrAccount;
93
+ this.callData = new _calldata.CallData(abi);
94
+ this.structs = _calldata.CallData.getAbiStruct(abi);
95
+ this.events = (0, _index.getAbiEvents)(abi);
96
+ const parser = (0, _parser.createAbiParser)(abi);
97
+ this.abi = parser.getLegacyFormat();
98
+ const options = {
99
+ enumerable: true,
100
+ value: {},
101
+ writable: false
102
+ };
103
+ Object.defineProperties(this, {
104
+ functions: {
105
+ enumerable: true,
106
+ value: {},
107
+ writable: false
108
+ },
109
+ callStatic: {
110
+ enumerable: true,
111
+ value: {},
112
+ writable: false
113
+ },
114
+ populateTransaction: {
115
+ enumerable: true,
116
+ value: {},
117
+ writable: false
118
+ },
119
+ estimateFee: {
120
+ enumerable: true,
121
+ value: {},
122
+ writable: false
123
+ }
124
+ });
125
+ this.abi.forEach(abiElement => {
126
+ if (abiElement.type !== "function") return;
127
+ const signature = abiElement.name;
128
+ if (!this[signature]) {
129
+ Object.defineProperty(this, signature, {
130
+ ...options,
131
+ value: buildDefault(this, abiElement)
132
+ });
133
+ }
134
+ if (!this.functions[signature]) {
135
+ Object.defineProperty(this.functions, signature, {
136
+ ...options,
137
+ value: buildDefault(this, abiElement)
138
+ });
139
+ }
140
+ if (!this.callStatic[signature]) {
141
+ Object.defineProperty(this.callStatic, signature, {
142
+ ...options,
143
+ value: buildCall(this, abiElement)
144
+ });
145
+ }
146
+ if (!this.populateTransaction[signature]) {
147
+ Object.defineProperty(this.populateTransaction, signature, {
148
+ ...options,
149
+ value: buildPopulate(this, abiElement)
150
+ });
151
+ }
152
+ if (!this.estimateFee[signature]) {
153
+ Object.defineProperty(this.estimateFee, signature, {
154
+ ...options,
155
+ value: buildEstimate(this, abiElement)
156
+ });
157
+ }
158
+ });
159
+ }
160
+ attach(address) {
161
+ this.address = address;
162
+ }
163
+ connect(providerOrAccount) {
164
+ this.providerOrAccount = providerOrAccount;
165
+ }
166
+ async deployed() {
167
+ if (this.deployTransactionHash) {
168
+ await this.providerOrAccount.waitForTransaction(this.deployTransactionHash);
169
+ this.deployTransactionHash = void 0;
170
+ }
171
+ return this;
172
+ }
173
+ async call(method, args = [], {
174
+ parseRequest = true,
175
+ parseResponse = true,
176
+ formatResponse = void 0,
177
+ blockIdentifier = void 0
178
+ } = {}) {
179
+ (0, _assert.default)(this.address !== null, "contract is not connected to an address");
180
+ const calldata = getCalldata(args, () => {
181
+ if (parseRequest) {
182
+ this.callData.validate(_types.ValidateType.CALL, method, args);
183
+ return this.callData.compile(method, args);
184
+ }
185
+ console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
186
+ return args;
187
+ });
188
+ return this.providerOrAccount.callContract({
189
+ contractAddress: this.address,
190
+ calldata,
191
+ entrypoint: method
192
+ }, blockIdentifier).then(it => {
193
+ if (!parseResponse) {
194
+ return it;
195
+ }
196
+ if (formatResponse) {
197
+ return this.callData.format(method, it, formatResponse);
198
+ }
199
+ return this.callData.parse(method, it);
200
+ });
201
+ }
202
+ invoke(method, args = [], {
203
+ parseRequest = true,
204
+ maxFee,
205
+ nonce,
206
+ signature
207
+ } = {}) {
208
+ (0, _assert.default)(this.address !== null, "contract is not connected to an address");
209
+ const calldata = getCalldata(args, () => {
210
+ if (parseRequest) {
211
+ this.callData.validate(_types.ValidateType.INVOKE, method, args);
212
+ return this.callData.compile(method, args);
213
+ }
214
+ console.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request");
215
+ return args;
216
+ });
217
+ const invocation = {
218
+ contractAddress: this.address,
219
+ calldata,
220
+ entrypoint: method
221
+ };
222
+ if ("execute" in this.providerOrAccount) {
223
+ return this.providerOrAccount.execute(invocation, void 0, {
224
+ maxFee,
225
+ nonce
226
+ });
227
+ }
228
+ if (!nonce) throw new Error(`Nonce is required when invoking a function without an account`);
229
+ console.warn(`Invoking ${method} without an account. This will not work on a public node.`);
230
+ return this.providerOrAccount.invokeFunction({
231
+ ...invocation,
232
+ signature
233
+ }, {
234
+ nonce
235
+ });
236
+ }
237
+ async estimate(method, args = []) {
238
+ (0, _assert.default)(this.address !== null, "contract is not connected to an address");
239
+ if (!getCalldata(args, () => false)) {
240
+ this.callData.validate(_types.ValidateType.INVOKE, method, args);
241
+ }
242
+ const invocation = this.populate(method, args);
243
+ if ("estimateInvokeFee" in this.providerOrAccount) {
244
+ return this.providerOrAccount.estimateInvokeFee(invocation);
245
+ }
246
+ throw Error("Contract must be connected to the account contract to estimate");
247
+ }
248
+ populate(method, args = []) {
249
+ const calldata = getCalldata(args, () => this.callData.compile(method, args));
250
+ return {
251
+ contractAddress: this.address,
252
+ entrypoint: method,
253
+ calldata
254
+ };
255
+ }
256
+ parseEvents(receipt) {
257
+ return (0, _index.parseEvents)(receipt.events?.filter(event => (0, _num.cleanHex)(event.from_address) === (0, _num.cleanHex)(this.address), []) || [], this.events, this.structs, _calldata.CallData.getAbiEnum(this.abi));
258
+ }
259
+ isCairo1() {
260
+ return _calldata.cairo.isCairo1Abi(this.abi);
261
+ }
262
+ async getVersion() {
263
+ return this.providerOrAccount.getContractVersion(this.address);
264
+ }
265
+ typedv2(tAbi) {
266
+ return this;
267
+ }
268
+ }
269
+ exports.Contract = Contract;
@@ -0,0 +1,58 @@
1
+ import type { Abi as AbiKanabi, TypedContract as AbiWanTypedContract } from 'abi-wan-kanabi';
2
+ import { AccountInterface } from '../account';
3
+ import { ProviderInterface } from '../provider';
4
+ import { Abi, AbiEvents, ArgsOrCalldata, ArgsOrCalldataWithOptions, AsyncContractFunction, Call, CallOptions, Calldata, ContractFunction, ContractOptions, EstimateFeeResponse, InvokeFunctionResponse, InvokeOptions, ParsedEvents, RawArgs, Result, AbiStruct } from '../types';
5
+ import { ContractInterface } from './interface';
6
+ import type { GetTransactionReceiptResponse } from '../utils/transactionReceipt';
7
+ export type TypedContractV2<TAbi extends AbiKanabi> = AbiWanTypedContract<TAbi> & Contract;
8
+ export declare const splitArgsAndOptions: (args: ArgsOrCalldataWithOptions) => {
9
+ args: ArgsOrCalldata;
10
+ options: ContractOptions;
11
+ } | {
12
+ args: ArgsOrCalldata;
13
+ options?: undefined;
14
+ };
15
+ export declare function getCalldata(args: RawArgs, callback: Function): Calldata;
16
+ export declare class Contract implements ContractInterface {
17
+ abi: Abi;
18
+ address: string;
19
+ providerOrAccount: ProviderInterface | AccountInterface;
20
+ deployTransactionHash?: string;
21
+ protected readonly structs: {
22
+ [name: string]: AbiStruct;
23
+ };
24
+ protected readonly events: AbiEvents;
25
+ readonly functions: {
26
+ [name: string]: AsyncContractFunction;
27
+ };
28
+ readonly callStatic: {
29
+ [name: string]: AsyncContractFunction;
30
+ };
31
+ readonly populateTransaction: {
32
+ [name: string]: ContractFunction;
33
+ };
34
+ readonly estimateFee: {
35
+ [name: string]: ContractFunction;
36
+ };
37
+ readonly [key: string]: AsyncContractFunction | any;
38
+ private callData;
39
+ /**
40
+ * Contract class to handle contract methods
41
+ *
42
+ * @param abi - Abi of the contract object
43
+ * @param address (optional) - address to connect to
44
+ * @param providerOrAccount (optional) - Provider or Account to attach to
45
+ */
46
+ constructor(abi: Abi, address: string, providerOrAccount?: ProviderInterface | AccountInterface);
47
+ attach(address: string): void;
48
+ connect(providerOrAccount: ProviderInterface | AccountInterface): void;
49
+ deployed(): Promise<Contract>;
50
+ call(method: string, args?: ArgsOrCalldata, { parseRequest, parseResponse, formatResponse, blockIdentifier, }?: CallOptions): Promise<Result>;
51
+ invoke(method: string, args?: ArgsOrCalldata, { parseRequest, maxFee, nonce, signature }?: InvokeOptions): Promise<InvokeFunctionResponse>;
52
+ estimate(method: string, args?: ArgsOrCalldata): Promise<EstimateFeeResponse>;
53
+ populate(method: string, args?: RawArgs): Call;
54
+ parseEvents(receipt: GetTransactionReceiptResponse): ParsedEvents;
55
+ isCairo1(): boolean;
56
+ getVersion(): Promise<import("../types").ContractVersion>;
57
+ typedv2<TAbi extends AbiKanabi>(tAbi: TAbi): TypedContractV2<TAbi>;
58
+ }