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,607 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RpcChannel = void 0;
7
+ var _constants = require("../constants.cjs");
8
+ var _errors = require("../provider/errors.cjs");
9
+ var _types = require("../types/index.cjs");
10
+ var _api = require("../types/api/index.cjs");
11
+ var _calldata = require("../utils/calldata/index.cjs");
12
+ var _contract = require("../utils/contract.cjs");
13
+ var _eth = require("../utils/eth.cjs");
14
+ var _fetchPonyfill = _interopRequireDefault(require("../utils/fetchPonyfill.cjs"));
15
+ var _hash = require("../utils/hash/index.cjs");
16
+ var _json = require("../utils/json.cjs");
17
+ var _num = require("../utils/num.cjs");
18
+ var _provider = require("../utils/provider.cjs");
19
+ var _stark = require("../utils/stark.cjs");
20
+ var _transaction = require("../utils/transaction.cjs");
21
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
+ const defaultOptions = {
23
+ headers: {
24
+ "Content-Type": "application/json"
25
+ },
26
+ blockIdentifier: _types.BlockTag.PENDING,
27
+ retries: 200
28
+ };
29
+ class RpcChannel {
30
+ nodeUrl;
31
+ headers;
32
+ retries;
33
+ requestId;
34
+ blockIdentifier;
35
+ chainId;
36
+ specVersion;
37
+ waitMode;
38
+ // behave like web2 rpc and return when tx is processed
39
+ constructor(optionsOrProvider) {
40
+ const {
41
+ nodeUrl,
42
+ retries,
43
+ headers,
44
+ blockIdentifier,
45
+ chainId,
46
+ specVersion,
47
+ waitMode
48
+ } = optionsOrProvider || {};
49
+ if (Object.values(_constants.NetworkName).includes(nodeUrl)) {
50
+ this.nodeUrl = (0, _provider.getDefaultNodeUrl)(nodeUrl, optionsOrProvider?.default);
51
+ } else if (nodeUrl) {
52
+ this.nodeUrl = nodeUrl;
53
+ } else {
54
+ this.nodeUrl = (0, _provider.getDefaultNodeUrl)(void 0, optionsOrProvider?.default);
55
+ }
56
+ this.retries = retries || defaultOptions.retries;
57
+ this.headers = {
58
+ ...defaultOptions.headers,
59
+ ...headers
60
+ };
61
+ this.blockIdentifier = blockIdentifier || defaultOptions.blockIdentifier;
62
+ this.chainId = chainId;
63
+ this.specVersion = specVersion;
64
+ this.waitMode = waitMode || false;
65
+ this.requestId = 0;
66
+ }
67
+ setChainId(chainId) {
68
+ this.chainId = chainId;
69
+ }
70
+ fetch(method, params, id = 0) {
71
+ const rpcRequestBody = {
72
+ id,
73
+ jsonrpc: "2.0",
74
+ method,
75
+ ...(params && {
76
+ params
77
+ })
78
+ };
79
+ return (0, _fetchPonyfill.default)(this.nodeUrl, {
80
+ method: "POST",
81
+ body: (0, _json.stringify)(rpcRequestBody),
82
+ headers: this.headers
83
+ });
84
+ }
85
+ errorHandler(method, params, rpcError, otherError) {
86
+ if (rpcError) {
87
+ const {
88
+ code,
89
+ message,
90
+ data
91
+ } = rpcError;
92
+ throw new _errors.LibraryError(`RPC: ${method} with params ${(0, _json.stringify)(params, null, 2)}
93
+
94
+ ${code}: ${message}: ${(0, _json.stringify)(data)}`);
95
+ }
96
+ if (otherError instanceof _errors.LibraryError) {
97
+ throw otherError;
98
+ }
99
+ if (otherError) {
100
+ throw Error(otherError.message);
101
+ }
102
+ }
103
+ async fetchEndpoint(method, params) {
104
+ try {
105
+ const rawResult = await this.fetch(method, params, this.requestId += 1);
106
+ const {
107
+ error,
108
+ result
109
+ } = await rawResult.json();
110
+ this.errorHandler(method, params, error);
111
+ return result;
112
+ } catch (error) {
113
+ this.errorHandler(method, params, error?.response?.data, error);
114
+ throw error;
115
+ }
116
+ }
117
+ async getChainId() {
118
+ this.chainId ??= await this.fetchEndpoint("starknet_chainId");
119
+ return this.chainId;
120
+ }
121
+ async getSpecVersion() {
122
+ this.specVersion ??= await this.fetchEndpoint("starknet_specVersion");
123
+ return this.specVersion;
124
+ }
125
+ getNonceForAddress(contractAddress, blockIdentifier = this.blockIdentifier) {
126
+ const contract_address = (0, _num.toHex)(contractAddress);
127
+ const block_id = new _provider.Block(blockIdentifier).identifier;
128
+ return this.fetchEndpoint("starknet_getNonce", {
129
+ contract_address,
130
+ block_id
131
+ });
132
+ }
133
+ /**
134
+ * Get the most recent accepted block hash and number
135
+ */
136
+ getBlockLatestAccepted() {
137
+ return this.fetchEndpoint("starknet_blockHashAndNumber");
138
+ }
139
+ /**
140
+ * Get the most recent accepted block number
141
+ * redundant use getBlockLatestAccepted();
142
+ * @returns Number of the latest block
143
+ */
144
+ getBlockNumber() {
145
+ return this.fetchEndpoint("starknet_blockNumber");
146
+ }
147
+ getBlockWithTxHashes(blockIdentifier = this.blockIdentifier) {
148
+ const block_id = new _provider.Block(blockIdentifier).identifier;
149
+ return this.fetchEndpoint("starknet_getBlockWithTxHashes", {
150
+ block_id
151
+ });
152
+ }
153
+ getBlockWithTxs(blockIdentifier = this.blockIdentifier) {
154
+ const block_id = new _provider.Block(blockIdentifier).identifier;
155
+ return this.fetchEndpoint("starknet_getBlockWithTxs", {
156
+ block_id
157
+ });
158
+ }
159
+ getBlockStateUpdate(blockIdentifier = this.blockIdentifier) {
160
+ const block_id = new _provider.Block(blockIdentifier).identifier;
161
+ return this.fetchEndpoint("starknet_getStateUpdate", {
162
+ block_id
163
+ });
164
+ }
165
+ getBlockTransactionsTraces(blockIdentifier = this.blockIdentifier) {
166
+ const block_id = new _provider.Block(blockIdentifier).identifier;
167
+ return this.fetchEndpoint("starknet_traceBlockTransactions", {
168
+ block_id
169
+ });
170
+ }
171
+ getBlockTransactionCount(blockIdentifier = this.blockIdentifier) {
172
+ const block_id = new _provider.Block(blockIdentifier).identifier;
173
+ return this.fetchEndpoint("starknet_getBlockTransactionCount", {
174
+ block_id
175
+ });
176
+ }
177
+ getTransactionByHash(txHash) {
178
+ const transaction_hash = (0, _num.toHex)(txHash);
179
+ return this.fetchEndpoint("starknet_getTransactionByHash", {
180
+ transaction_hash
181
+ });
182
+ }
183
+ getTransactionByBlockIdAndIndex(blockIdentifier, index) {
184
+ const block_id = new _provider.Block(blockIdentifier).identifier;
185
+ return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex", {
186
+ block_id,
187
+ index
188
+ });
189
+ }
190
+ getTransactionReceipt(txHash) {
191
+ const transaction_hash = (0, _num.toHex)(txHash);
192
+ return this.fetchEndpoint("starknet_getTransactionReceipt", {
193
+ transaction_hash
194
+ });
195
+ }
196
+ getTransactionTrace(txHash) {
197
+ const transaction_hash = (0, _num.toHex)(txHash);
198
+ return this.fetchEndpoint("starknet_traceTransaction", {
199
+ transaction_hash
200
+ });
201
+ }
202
+ /**
203
+ * Get the status of a transaction
204
+ */
205
+ getTransactionStatus(transactionHash) {
206
+ const transaction_hash = (0, _num.toHex)(transactionHash);
207
+ return this.fetchEndpoint("starknet_getTransactionStatus", {
208
+ transaction_hash
209
+ });
210
+ }
211
+ /**
212
+ * @param invocations AccountInvocations
213
+ * @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
214
+ * - blockIdentifier<br/>
215
+ * - skipValidate (default false)<br/>
216
+ * - skipFeeCharge (default true)<br/>
217
+ */
218
+ simulateTransaction(invocations, simulateTransactionOptions = {}) {
219
+ const {
220
+ blockIdentifier = this.blockIdentifier,
221
+ skipValidate = true,
222
+ skipFeeCharge = true
223
+ } = simulateTransactionOptions;
224
+ const block_id = new _provider.Block(blockIdentifier).identifier;
225
+ const simulationFlags = [];
226
+ if (skipValidate) simulationFlags.push(_api.RPCSPEC06.ESimulationFlag.SKIP_VALIDATE);
227
+ if (skipFeeCharge) simulationFlags.push(_api.RPCSPEC06.ESimulationFlag.SKIP_FEE_CHARGE);
228
+ return this.fetchEndpoint("starknet_simulateTransactions", {
229
+ block_id,
230
+ transactions: invocations.map(it => this.buildTransaction(it)),
231
+ simulation_flags: simulationFlags
232
+ });
233
+ }
234
+ async waitForTransaction(txHash, options) {
235
+ const transactionHash = (0, _num.toHex)(txHash);
236
+ let {
237
+ retries
238
+ } = this;
239
+ let onchain = false;
240
+ let isErrorState = false;
241
+ const retryInterval = options?.retryInterval ?? 5e3;
242
+ const errorStates = options?.errorStates ?? [_api.RPCSPEC06.ETransactionStatus.REJECTED
243
+ // TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
244
+ // should decide which behavior to keep in the future
245
+ // RPC.ETransactionExecutionStatus.REVERTED,
246
+ ];
247
+ const successStates = options?.successStates ?? [_api.RPCSPEC06.ETransactionExecutionStatus.SUCCEEDED, _api.RPCSPEC06.ETransactionStatus.ACCEPTED_ON_L2, _api.RPCSPEC06.ETransactionStatus.ACCEPTED_ON_L1];
248
+ let txStatus;
249
+ while (!onchain) {
250
+ await (0, _provider.wait)(retryInterval);
251
+ try {
252
+ txStatus = await this.getTransactionStatus(transactionHash);
253
+ const executionStatus = txStatus.execution_status;
254
+ const finalityStatus = txStatus.finality_status;
255
+ if (!finalityStatus) {
256
+ const error = new Error("waiting for transaction status");
257
+ throw error;
258
+ }
259
+ if (errorStates.includes(executionStatus) || errorStates.includes(finalityStatus)) {
260
+ const message = `${executionStatus}: ${finalityStatus}`;
261
+ const error = new Error(message);
262
+ error.response = txStatus;
263
+ isErrorState = true;
264
+ throw error;
265
+ } else if (successStates.includes(executionStatus) || successStates.includes(finalityStatus)) {
266
+ onchain = true;
267
+ }
268
+ } catch (error) {
269
+ if (error instanceof Error && isErrorState) {
270
+ throw error;
271
+ }
272
+ if (retries <= 0) {
273
+ throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
274
+ }
275
+ }
276
+ retries -= 1;
277
+ }
278
+ let txReceipt = null;
279
+ while (txReceipt === null) {
280
+ try {
281
+ txReceipt = await this.getTransactionReceipt(transactionHash);
282
+ } catch (error) {
283
+ if (retries <= 0) {
284
+ throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
285
+ }
286
+ }
287
+ retries -= 1;
288
+ await (0, _provider.wait)(retryInterval);
289
+ }
290
+ return txReceipt;
291
+ }
292
+ getStorageAt(contractAddress, key, blockIdentifier = this.blockIdentifier) {
293
+ const contract_address = (0, _num.toHex)(contractAddress);
294
+ const parsedKey = (0, _num.toStorageKey)(key);
295
+ const block_id = new _provider.Block(blockIdentifier).identifier;
296
+ return this.fetchEndpoint("starknet_getStorageAt", {
297
+ contract_address,
298
+ key: parsedKey,
299
+ block_id
300
+ });
301
+ }
302
+ getClassHashAt(contractAddress, blockIdentifier = this.blockIdentifier) {
303
+ const contract_address = (0, _num.toHex)(contractAddress);
304
+ const block_id = new _provider.Block(blockIdentifier).identifier;
305
+ return this.fetchEndpoint("starknet_getClassHashAt", {
306
+ block_id,
307
+ contract_address
308
+ });
309
+ }
310
+ getClass(classHash, blockIdentifier = this.blockIdentifier) {
311
+ const class_hash = (0, _num.toHex)(classHash);
312
+ const block_id = new _provider.Block(blockIdentifier).identifier;
313
+ return this.fetchEndpoint("starknet_getClass", {
314
+ class_hash,
315
+ block_id
316
+ });
317
+ }
318
+ getClassAt(contractAddress, blockIdentifier = this.blockIdentifier) {
319
+ const contract_address = (0, _num.toHex)(contractAddress);
320
+ const block_id = new _provider.Block(blockIdentifier).identifier;
321
+ return this.fetchEndpoint("starknet_getClassAt", {
322
+ block_id,
323
+ contract_address
324
+ });
325
+ }
326
+ async getEstimateFee(invocations, {
327
+ blockIdentifier = this.blockIdentifier,
328
+ skipValidate = true
329
+ }) {
330
+ const block_id = new _provider.Block(blockIdentifier).identifier;
331
+ let flags = {};
332
+ if (!(0, _provider.isVersion)("0.5", await this.getSpecVersion())) {
333
+ flags = {
334
+ simulation_flags: skipValidate ? [_api.RPCSPEC06.ESimulationFlag.SKIP_VALIDATE] : []
335
+ };
336
+ }
337
+ return this.fetchEndpoint("starknet_estimateFee", {
338
+ request: invocations.map(it => this.buildTransaction(it, "fee")),
339
+ block_id,
340
+ ...flags
341
+ });
342
+ }
343
+ async invoke(functionInvocation, details) {
344
+ let promise;
345
+ if (!(0, _provider.isV3Tx)(details)) {
346
+ promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
347
+ invoke_transaction: {
348
+ sender_address: functionInvocation.contractAddress,
349
+ calldata: _calldata.CallData.toHex(functionInvocation.calldata),
350
+ type: _api.RPCSPEC06.ETransactionType.INVOKE,
351
+ max_fee: (0, _num.toHex)(details.maxFee || 0),
352
+ version: _api.RPCSPEC06.ETransactionVersion.V1,
353
+ signature: (0, _stark.signatureToHexArray)(functionInvocation.signature),
354
+ nonce: (0, _num.toHex)(details.nonce)
355
+ }
356
+ });
357
+ } else {
358
+ promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
359
+ invoke_transaction: {
360
+ type: _api.RPCSPEC06.ETransactionType.INVOKE,
361
+ sender_address: functionInvocation.contractAddress,
362
+ calldata: _calldata.CallData.toHex(functionInvocation.calldata),
363
+ version: _api.RPCSPEC06.ETransactionVersion.V3,
364
+ signature: (0, _stark.signatureToHexArray)(functionInvocation.signature),
365
+ nonce: (0, _num.toHex)(details.nonce),
366
+ resource_bounds: details.resourceBounds,
367
+ tip: (0, _num.toHex)(details.tip),
368
+ paymaster_data: details.paymasterData.map(it => (0, _num.toHex)(it)),
369
+ account_deployment_data: details.accountDeploymentData.map(it => (0, _num.toHex)(it)),
370
+ nonce_data_availability_mode: details.nonceDataAvailabilityMode,
371
+ fee_data_availability_mode: details.feeDataAvailabilityMode
372
+ }
373
+ });
374
+ }
375
+ return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
376
+ }
377
+ async declare({
378
+ contract,
379
+ signature,
380
+ senderAddress,
381
+ compiledClassHash
382
+ }, details) {
383
+ let promise;
384
+ if (!(0, _contract.isSierra)(contract) && !(0, _provider.isV3Tx)(details)) {
385
+ promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
386
+ declare_transaction: {
387
+ type: _api.RPCSPEC06.ETransactionType.DECLARE,
388
+ contract_class: {
389
+ program: contract.program,
390
+ entry_points_by_type: contract.entry_points_by_type,
391
+ abi: contract.abi
392
+ },
393
+ version: _api.RPCSPEC06.ETransactionVersion.V1,
394
+ max_fee: (0, _num.toHex)(details.maxFee || 0),
395
+ signature: (0, _stark.signatureToHexArray)(signature),
396
+ sender_address: senderAddress,
397
+ nonce: (0, _num.toHex)(details.nonce)
398
+ }
399
+ });
400
+ } else if ((0, _contract.isSierra)(contract) && !(0, _provider.isV3Tx)(details)) {
401
+ promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
402
+ declare_transaction: {
403
+ type: _api.RPCSPEC06.ETransactionType.DECLARE,
404
+ contract_class: {
405
+ sierra_program: (0, _stark.decompressProgram)(contract.sierra_program),
406
+ contract_class_version: contract.contract_class_version,
407
+ entry_points_by_type: contract.entry_points_by_type,
408
+ abi: contract.abi
409
+ },
410
+ compiled_class_hash: compiledClassHash || "",
411
+ version: _api.RPCSPEC06.ETransactionVersion.V2,
412
+ max_fee: (0, _num.toHex)(details.maxFee || 0),
413
+ signature: (0, _stark.signatureToHexArray)(signature),
414
+ sender_address: senderAddress,
415
+ nonce: (0, _num.toHex)(details.nonce)
416
+ }
417
+ });
418
+ } else if ((0, _contract.isSierra)(contract) && (0, _provider.isV3Tx)(details)) {
419
+ promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
420
+ declare_transaction: {
421
+ type: _api.RPCSPEC06.ETransactionType.DECLARE,
422
+ sender_address: senderAddress,
423
+ compiled_class_hash: compiledClassHash || "",
424
+ version: _api.RPCSPEC06.ETransactionVersion.V3,
425
+ signature: (0, _stark.signatureToHexArray)(signature),
426
+ nonce: (0, _num.toHex)(details.nonce),
427
+ contract_class: {
428
+ sierra_program: (0, _stark.decompressProgram)(contract.sierra_program),
429
+ contract_class_version: contract.contract_class_version,
430
+ entry_points_by_type: contract.entry_points_by_type,
431
+ abi: contract.abi
432
+ },
433
+ resource_bounds: details.resourceBounds,
434
+ tip: (0, _num.toHex)(details.tip),
435
+ paymaster_data: details.paymasterData.map(it => (0, _num.toHex)(it)),
436
+ account_deployment_data: details.accountDeploymentData.map(it => (0, _num.toHex)(it)),
437
+ nonce_data_availability_mode: details.nonceDataAvailabilityMode,
438
+ fee_data_availability_mode: details.feeDataAvailabilityMode
439
+ }
440
+ });
441
+ } else {
442
+ throw Error("declare unspotted parameters");
443
+ }
444
+ return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
445
+ }
446
+ async deployAccount({
447
+ classHash,
448
+ constructorCalldata,
449
+ addressSalt,
450
+ signature
451
+ }, details) {
452
+ let promise;
453
+ if (!(0, _provider.isV3Tx)(details)) {
454
+ promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
455
+ deploy_account_transaction: {
456
+ constructor_calldata: _calldata.CallData.toHex(constructorCalldata || []),
457
+ class_hash: (0, _num.toHex)(classHash),
458
+ contract_address_salt: (0, _num.toHex)(addressSalt || 0),
459
+ type: _api.RPCSPEC06.ETransactionType.DEPLOY_ACCOUNT,
460
+ max_fee: (0, _num.toHex)(details.maxFee || 0),
461
+ version: _api.RPCSPEC06.ETransactionVersion.V1,
462
+ signature: (0, _stark.signatureToHexArray)(signature),
463
+ nonce: (0, _num.toHex)(details.nonce)
464
+ }
465
+ });
466
+ } else {
467
+ promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
468
+ deploy_account_transaction: {
469
+ type: _api.RPCSPEC06.ETransactionType.DEPLOY_ACCOUNT,
470
+ version: _api.RPCSPEC06.ETransactionVersion.V3,
471
+ signature: (0, _stark.signatureToHexArray)(signature),
472
+ nonce: (0, _num.toHex)(details.nonce),
473
+ contract_address_salt: (0, _num.toHex)(addressSalt || 0),
474
+ constructor_calldata: _calldata.CallData.toHex(constructorCalldata || []),
475
+ class_hash: (0, _num.toHex)(classHash),
476
+ resource_bounds: details.resourceBounds,
477
+ tip: (0, _num.toHex)(details.tip),
478
+ paymaster_data: details.paymasterData.map(it => (0, _num.toHex)(it)),
479
+ nonce_data_availability_mode: details.nonceDataAvailabilityMode,
480
+ fee_data_availability_mode: details.feeDataAvailabilityMode
481
+ }
482
+ });
483
+ }
484
+ return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
485
+ }
486
+ callContract(call, blockIdentifier = this.blockIdentifier) {
487
+ const block_id = new _provider.Block(blockIdentifier).identifier;
488
+ return this.fetchEndpoint("starknet_call", {
489
+ request: {
490
+ contract_address: call.contractAddress,
491
+ entry_point_selector: (0, _hash.getSelectorFromName)(call.entrypoint),
492
+ calldata: _calldata.CallData.toHex(call.calldata)
493
+ },
494
+ block_id
495
+ });
496
+ }
497
+ /**
498
+ * NEW: Estimate the fee for a message from L1
499
+ * @param message Message From L1
500
+ */
501
+ estimateMessageFee(message, blockIdentifier = this.blockIdentifier) {
502
+ const {
503
+ from_address,
504
+ to_address,
505
+ entry_point_selector,
506
+ payload
507
+ } = message;
508
+ const formattedMessage = {
509
+ from_address: (0, _eth.validateAndParseEthAddress)(from_address),
510
+ to_address: (0, _num.toHex)(to_address),
511
+ entry_point_selector: (0, _hash.getSelector)(entry_point_selector),
512
+ payload: (0, _num.getHexStringArray)(payload)
513
+ };
514
+ const block_id = new _provider.Block(blockIdentifier).identifier;
515
+ return this.fetchEndpoint("starknet_estimateMessageFee", {
516
+ message: formattedMessage,
517
+ block_id
518
+ });
519
+ }
520
+ /**
521
+ * Returns an object about the sync status, or false if the node is not synching
522
+ * @returns Object with the stats data
523
+ */
524
+ getSyncingStats() {
525
+ return this.fetchEndpoint("starknet_syncing");
526
+ }
527
+ /**
528
+ * Returns all events matching the given filter
529
+ * @returns events and the pagination of the events
530
+ */
531
+ getEvents(eventFilter) {
532
+ return this.fetchEndpoint("starknet_getEvents", {
533
+ filter: eventFilter
534
+ });
535
+ }
536
+ buildTransaction(invocation, versionType) {
537
+ const defaultVersions = (0, _transaction.getVersionsByType)(versionType);
538
+ let details;
539
+ if (!(0, _provider.isV3Tx)(invocation)) {
540
+ details = {
541
+ signature: (0, _stark.signatureToHexArray)(invocation.signature),
542
+ nonce: (0, _num.toHex)(invocation.nonce),
543
+ max_fee: (0, _num.toHex)(invocation.maxFee || 0)
544
+ };
545
+ } else {
546
+ details = {
547
+ signature: (0, _stark.signatureToHexArray)(invocation.signature),
548
+ nonce: (0, _num.toHex)(invocation.nonce),
549
+ resource_bounds: invocation.resourceBounds,
550
+ tip: (0, _num.toHex)(invocation.tip),
551
+ paymaster_data: invocation.paymasterData.map(it => (0, _num.toHex)(it)),
552
+ nonce_data_availability_mode: invocation.nonceDataAvailabilityMode,
553
+ fee_data_availability_mode: invocation.feeDataAvailabilityMode,
554
+ account_deployment_data: invocation.accountDeploymentData.map(it => (0, _num.toHex)(it))
555
+ };
556
+ }
557
+ if (invocation.type === _types.TransactionType.INVOKE) {
558
+ return {
559
+ // v0 v1 v3
560
+ type: _api.RPCSPEC06.ETransactionType.INVOKE,
561
+ sender_address: invocation.contractAddress,
562
+ calldata: _calldata.CallData.toHex(invocation.calldata),
563
+ version: (0, _num.toHex)(invocation.version || defaultVersions.v3),
564
+ ...details
565
+ };
566
+ }
567
+ if (invocation.type === _types.TransactionType.DECLARE) {
568
+ if (!(0, _contract.isSierra)(invocation.contract)) {
569
+ return {
570
+ type: invocation.type,
571
+ contract_class: invocation.contract,
572
+ sender_address: invocation.senderAddress,
573
+ version: (0, _num.toHex)(invocation.version || defaultVersions.v1),
574
+ ...details
575
+ };
576
+ }
577
+ return {
578
+ // Cairo 1 - v2 v3
579
+ type: invocation.type,
580
+ contract_class: {
581
+ ...invocation.contract,
582
+ sierra_program: (0, _stark.decompressProgram)(invocation.contract.sierra_program)
583
+ },
584
+ compiled_class_hash: invocation.compiledClassHash || "",
585
+ sender_address: invocation.senderAddress,
586
+ version: (0, _num.toHex)(invocation.version || defaultVersions.v3),
587
+ ...details
588
+ };
589
+ }
590
+ if (invocation.type === _types.TransactionType.DEPLOY_ACCOUNT) {
591
+ const {
592
+ account_deployment_data,
593
+ ...restDetails
594
+ } = details;
595
+ return {
596
+ type: invocation.type,
597
+ constructor_calldata: _calldata.CallData.toHex(invocation.constructorCalldata || []),
598
+ class_hash: (0, _num.toHex)(invocation.classHash),
599
+ contract_address_salt: (0, _num.toHex)(invocation.addressSalt || 0),
600
+ version: (0, _num.toHex)(invocation.version || defaultVersions.v3),
601
+ ...restDetails
602
+ };
603
+ }
604
+ throw Error("RPC buildTransaction received unknown TransactionType");
605
+ }
606
+ }
607
+ exports.RpcChannel = RpcChannel;
@@ -0,0 +1,78 @@
1
+ import { StarknetChainId } from '../constants';
2
+ import { AccountInvocationItem, AccountInvocations, BigNumberish, BlockIdentifier, Call, DeclareContractTransaction, DeployAccountContractTransaction, Invocation, InvocationsDetailsWithNonce, RpcProviderOptions, getEstimateFeeBulkOptions, getSimulateTransactionOptions, waitForTransactionOptions } from '../types';
3
+ import { JRPC, RPCSPEC06 as RPC } from '../types/api';
4
+ export declare class RpcChannel {
5
+ nodeUrl: string;
6
+ headers: object;
7
+ readonly retries: number;
8
+ requestId: number;
9
+ readonly blockIdentifier: BlockIdentifier;
10
+ private chainId?;
11
+ private specVersion?;
12
+ readonly waitMode: Boolean;
13
+ constructor(optionsOrProvider?: RpcProviderOptions);
14
+ setChainId(chainId: StarknetChainId): void;
15
+ fetch(method: string, params?: object, id?: string | number): any;
16
+ protected errorHandler(method: string, params: any, rpcError?: JRPC.Error, otherError?: any): void;
17
+ protected fetchEndpoint<T extends keyof RPC.Methods>(method: T, params?: RPC.Methods[T]['params']): Promise<RPC.Methods[T]['result']>;
18
+ getChainId(): Promise<"0x534e5f4d41494e" | "0x534e5f5345504f4c4941">;
19
+ getSpecVersion(): Promise<string>;
20
+ getNonceForAddress(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
21
+ /**
22
+ * Get the most recent accepted block hash and number
23
+ */
24
+ getBlockLatestAccepted(): Promise<RPC.BlockHashAndNumber>;
25
+ /**
26
+ * Get the most recent accepted block number
27
+ * redundant use getBlockLatestAccepted();
28
+ * @returns Number of the latest block
29
+ */
30
+ getBlockNumber(): Promise<number>;
31
+ getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.BlockWithTxHashes>;
32
+ getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.BlockWithTxs>;
33
+ getBlockStateUpdate(blockIdentifier?: BlockIdentifier): Promise<RPC.StateUpdate>;
34
+ getBlockTransactionsTraces(blockIdentifier?: BlockIdentifier): Promise<RPC.BlockTransactionsTraces>;
35
+ getBlockTransactionCount(blockIdentifier?: BlockIdentifier): Promise<number>;
36
+ getTransactionByHash(txHash: BigNumberish): Promise<RPC.TransactionWithHash>;
37
+ getTransactionByBlockIdAndIndex(blockIdentifier: BlockIdentifier, index: number): Promise<RPC.TransactionWithHash>;
38
+ getTransactionReceipt(txHash: BigNumberish): Promise<RPC.TransactionReceipt>;
39
+ getTransactionTrace(txHash: BigNumberish): Promise<RPC.SPEC.TRANSACTION_TRACE>;
40
+ /**
41
+ * Get the status of a transaction
42
+ */
43
+ getTransactionStatus(transactionHash: BigNumberish): Promise<RPC.TransactionStatus>;
44
+ /**
45
+ * @param invocations AccountInvocations
46
+ * @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
47
+ * - blockIdentifier<br/>
48
+ * - skipValidate (default false)<br/>
49
+ * - skipFeeCharge (default true)<br/>
50
+ */
51
+ simulateTransaction(invocations: AccountInvocations, simulateTransactionOptions?: getSimulateTransactionOptions): Promise<RPC.SimulateTransactionResponse>;
52
+ waitForTransaction(txHash: BigNumberish, options?: waitForTransactionOptions): Promise<RPC.SPEC.TXN_RECEIPT>;
53
+ getStorageAt(contractAddress: BigNumberish, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
54
+ getClassHashAt(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
55
+ getClass(classHash: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
56
+ getClassAt(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
57
+ getEstimateFee(invocations: AccountInvocations, { blockIdentifier, skipValidate }: getEstimateFeeBulkOptions): Promise<RPC.SPEC.FEE_ESTIMATE[]>;
58
+ invoke(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<any>;
59
+ declare({ contract, signature, senderAddress, compiledClassHash }: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<any>;
60
+ deployAccount({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<any>;
61
+ callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<string[]>;
62
+ /**
63
+ * NEW: Estimate the fee for a message from L1
64
+ * @param message Message From L1
65
+ */
66
+ estimateMessageFee(message: RPC.L1Message, blockIdentifier?: BlockIdentifier): Promise<RPC.SPEC.FEE_ESTIMATE>;
67
+ /**
68
+ * Returns an object about the sync status, or false if the node is not synching
69
+ * @returns Object with the stats data
70
+ */
71
+ getSyncingStats(): Promise<RPC.Syncing>;
72
+ /**
73
+ * Returns all events matching the given filter
74
+ * @returns events and the pagination of the events
75
+ */
76
+ getEvents(eventFilter: RPC.EventFilter): Promise<RPC.SPEC.EVENTS_CHUNK>;
77
+ buildTransaction(invocation: AccountInvocationItem, versionType?: 'fee' | 'transaction'): RPC.BaseTransaction;
78
+ }