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