starknet 4.12.0 → 4.13.0

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 (224) hide show
  1. package/.eslintrc +1 -0
  2. package/CHANGELOG.md +14 -0
  3. package/__tests__/account.test.ts +0 -2
  4. package/dist/index.d.ts +2683 -24
  5. package/dist/index.global.js +22994 -0
  6. package/dist/index.global.js.map +1 -0
  7. package/dist/index.js +4713 -53
  8. package/dist/index.js.map +1 -0
  9. package/dist/index.mjs +4655 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/index.d.ts +2683 -24
  12. package/index.global.js +22994 -0
  13. package/index.global.js.map +1 -0
  14. package/index.js +4713 -53
  15. package/index.js.map +1 -0
  16. package/index.mjs +4655 -0
  17. package/index.mjs.map +1 -0
  18. package/package.json +8 -2
  19. package/src/account/default.ts +43 -8
  20. package/src/account/interface.ts +25 -2
  21. package/src/constants.ts +0 -1
  22. package/src/provider/default.ts +3 -0
  23. package/src/provider/interface.ts +2 -0
  24. package/src/provider/rpc.ts +4 -4
  25. package/src/provider/sequencer.ts +4 -1
  26. package/src/types/lib.ts +1 -1
  27. package/src/types/provider.ts +5 -0
  28. package/src/utils/ellipticCurve.ts +3 -1
  29. package/src/utils/fetchPonyfill.ts +3 -2
  30. package/src/utils/hash.ts +3 -2
  31. package/src/utils/number.ts +2 -2
  32. package/tsup.config.ts +10 -0
  33. package/account/default.d.ts +0 -30
  34. package/account/default.js +0 -526
  35. package/account/index.d.ts +0 -2
  36. package/account/index.js +0 -18
  37. package/account/interface.d.ts +0 -161
  38. package/account/interface.js +0 -27
  39. package/constants.d.ts +0 -36
  40. package/constants.js +0 -2067
  41. package/contract/contractFactory.d.ts +0 -31
  42. package/contract/contractFactory.js +0 -102
  43. package/contract/default.d.ts +0 -108
  44. package/contract/default.js +0 -640
  45. package/contract/index.d.ts +0 -3
  46. package/contract/index.js +0 -19
  47. package/contract/interface.d.ts +0 -80
  48. package/contract/interface.js +0 -9
  49. package/dist/account/default.d.ts +0 -30
  50. package/dist/account/default.js +0 -526
  51. package/dist/account/index.d.ts +0 -2
  52. package/dist/account/index.js +0 -18
  53. package/dist/account/interface.d.ts +0 -161
  54. package/dist/account/interface.js +0 -27
  55. package/dist/constants.d.ts +0 -36
  56. package/dist/constants.js +0 -2067
  57. package/dist/contract/contractFactory.d.ts +0 -31
  58. package/dist/contract/contractFactory.js +0 -102
  59. package/dist/contract/default.d.ts +0 -108
  60. package/dist/contract/default.js +0 -640
  61. package/dist/contract/index.d.ts +0 -3
  62. package/dist/contract/index.js +0 -19
  63. package/dist/contract/interface.d.ts +0 -80
  64. package/dist/contract/interface.js +0 -9
  65. package/dist/provider/default.d.ts +0 -37
  66. package/dist/provider/default.js +0 -207
  67. package/dist/provider/errors.d.ts +0 -9
  68. package/dist/provider/errors.js +0 -40
  69. package/dist/provider/index.d.ts +0 -7
  70. package/dist/provider/index.js +0 -24
  71. package/dist/provider/interface.d.ts +0 -203
  72. package/dist/provider/interface.js +0 -9
  73. package/dist/provider/rpc.d.ts +0 -86
  74. package/dist/provider/rpc.js +0 -605
  75. package/dist/provider/sequencer.d.ts +0 -79
  76. package/dist/provider/sequencer.js +0 -575
  77. package/dist/provider/utils.d.ts +0 -30
  78. package/dist/provider/utils.js +0 -84
  79. package/dist/signer/default.d.ts +0 -13
  80. package/dist/signer/default.js +0 -102
  81. package/dist/signer/index.d.ts +0 -2
  82. package/dist/signer/index.js +0 -18
  83. package/dist/signer/interface.d.ts +0 -60
  84. package/dist/signer/interface.js +0 -9
  85. package/dist/types/account.d.ts +0 -11
  86. package/dist/types/account.js +0 -2
  87. package/dist/types/api/index.d.ts +0 -10
  88. package/dist/types/api/index.js +0 -18
  89. package/dist/types/api/openrpc.d.ts +0 -572
  90. package/dist/types/api/openrpc.js +0 -45
  91. package/dist/types/api/rpc.d.ts +0 -43
  92. package/dist/types/api/rpc.js +0 -2
  93. package/dist/types/api/sequencer.d.ts +0 -320
  94. package/dist/types/api/sequencer.js +0 -2
  95. package/dist/types/contract.d.ts +0 -5
  96. package/dist/types/contract.js +0 -2
  97. package/dist/types/index.d.ts +0 -7
  98. package/dist/types/index.js +0 -35
  99. package/dist/types/lib.d.ts +0 -120
  100. package/dist/types/lib.js +0 -8
  101. package/dist/types/provider.d.ts +0 -99
  102. package/dist/types/provider.js +0 -2
  103. package/dist/types/signer.d.ts +0 -19
  104. package/dist/types/signer.js +0 -2
  105. package/dist/utils/address.d.ts +0 -5
  106. package/dist/utils/address.js +0 -41
  107. package/dist/utils/ellipticCurve.d.ts +0 -29
  108. package/dist/utils/ellipticCurve.js +0 -132
  109. package/dist/utils/encode.d.ts +0 -15
  110. package/dist/utils/encode.js +0 -96
  111. package/dist/utils/fetchPonyfill.d.ts +0 -2
  112. package/dist/utils/fetchPonyfill.js +0 -6
  113. package/dist/utils/hash.d.ts +0 -37
  114. package/dist/utils/hash.js +0 -162
  115. package/dist/utils/json.d.ts +0 -16
  116. package/dist/utils/json.js +0 -19
  117. package/dist/utils/merkle.d.ts +0 -10
  118. package/dist/utils/merkle.js +0 -89
  119. package/dist/utils/number.d.ts +0 -16
  120. package/dist/utils/number.js +0 -112
  121. package/dist/utils/provider.d.ts +0 -4
  122. package/dist/utils/provider.js +0 -38
  123. package/dist/utils/responseParser/index.d.ts +0 -11
  124. package/dist/utils/responseParser/index.js +0 -9
  125. package/dist/utils/responseParser/rpc.d.ts +0 -20
  126. package/dist/utils/responseParser/rpc.js +0 -44
  127. package/dist/utils/responseParser/sequencer.d.ts +0 -17
  128. package/dist/utils/responseParser/sequencer.js +0 -99
  129. package/dist/utils/shortString.d.ts +0 -4
  130. package/dist/utils/shortString.js +0 -26
  131. package/dist/utils/stark.d.ts +0 -16
  132. package/dist/utils/stark.js +0 -91
  133. package/dist/utils/transaction.d.ts +0 -20
  134. package/dist/utils/transaction.js +0 -79
  135. package/dist/utils/typedData/index.d.ts +0 -72
  136. package/dist/utils/typedData/index.js +0 -239
  137. package/dist/utils/typedData/types.d.ts +0 -32
  138. package/dist/utils/typedData/types.js +0 -2
  139. package/dist/utils/typedData/utils.d.ts +0 -8
  140. package/dist/utils/typedData/utils.js +0 -16
  141. package/dist/utils/uint256.d.ts +0 -11
  142. package/dist/utils/uint256.js +0 -28
  143. package/dist/utils/url.d.ts +0 -7
  144. package/dist/utils/url.js +0 -49
  145. package/provider/default.d.ts +0 -37
  146. package/provider/default.js +0 -207
  147. package/provider/errors.d.ts +0 -9
  148. package/provider/errors.js +0 -40
  149. package/provider/index.d.ts +0 -7
  150. package/provider/index.js +0 -24
  151. package/provider/interface.d.ts +0 -203
  152. package/provider/interface.js +0 -9
  153. package/provider/rpc.d.ts +0 -86
  154. package/provider/rpc.js +0 -605
  155. package/provider/sequencer.d.ts +0 -79
  156. package/provider/sequencer.js +0 -575
  157. package/provider/utils.d.ts +0 -30
  158. package/provider/utils.js +0 -84
  159. package/signer/default.d.ts +0 -13
  160. package/signer/default.js +0 -102
  161. package/signer/index.d.ts +0 -2
  162. package/signer/index.js +0 -18
  163. package/signer/interface.d.ts +0 -60
  164. package/signer/interface.js +0 -9
  165. package/types/account.d.ts +0 -11
  166. package/types/account.js +0 -2
  167. package/types/api/index.d.ts +0 -10
  168. package/types/api/index.js +0 -18
  169. package/types/api/openrpc.d.ts +0 -572
  170. package/types/api/openrpc.js +0 -45
  171. package/types/api/rpc.d.ts +0 -43
  172. package/types/api/rpc.js +0 -2
  173. package/types/api/sequencer.d.ts +0 -320
  174. package/types/api/sequencer.js +0 -2
  175. package/types/contract.d.ts +0 -5
  176. package/types/contract.js +0 -2
  177. package/types/index.d.ts +0 -7
  178. package/types/index.js +0 -35
  179. package/types/lib.d.ts +0 -120
  180. package/types/lib.js +0 -8
  181. package/types/provider.d.ts +0 -99
  182. package/types/provider.js +0 -2
  183. package/types/signer.d.ts +0 -19
  184. package/types/signer.js +0 -2
  185. package/utils/address.d.ts +0 -5
  186. package/utils/address.js +0 -41
  187. package/utils/ellipticCurve.d.ts +0 -29
  188. package/utils/ellipticCurve.js +0 -132
  189. package/utils/encode.d.ts +0 -15
  190. package/utils/encode.js +0 -96
  191. package/utils/fetchPonyfill.d.ts +0 -2
  192. package/utils/fetchPonyfill.js +0 -6
  193. package/utils/hash.d.ts +0 -37
  194. package/utils/hash.js +0 -162
  195. package/utils/json.d.ts +0 -16
  196. package/utils/json.js +0 -19
  197. package/utils/merkle.d.ts +0 -10
  198. package/utils/merkle.js +0 -89
  199. package/utils/number.d.ts +0 -16
  200. package/utils/number.js +0 -112
  201. package/utils/provider.d.ts +0 -4
  202. package/utils/provider.js +0 -38
  203. package/utils/responseParser/index.d.ts +0 -11
  204. package/utils/responseParser/index.js +0 -9
  205. package/utils/responseParser/rpc.d.ts +0 -20
  206. package/utils/responseParser/rpc.js +0 -44
  207. package/utils/responseParser/sequencer.d.ts +0 -17
  208. package/utils/responseParser/sequencer.js +0 -99
  209. package/utils/shortString.d.ts +0 -4
  210. package/utils/shortString.js +0 -26
  211. package/utils/stark.d.ts +0 -16
  212. package/utils/stark.js +0 -91
  213. package/utils/transaction.d.ts +0 -20
  214. package/utils/transaction.js +0 -79
  215. package/utils/typedData/index.d.ts +0 -72
  216. package/utils/typedData/index.js +0 -239
  217. package/utils/typedData/types.d.ts +0 -32
  218. package/utils/typedData/types.js +0 -2
  219. package/utils/typedData/utils.d.ts +0 -8
  220. package/utils/typedData/utils.js +0 -16
  221. package/utils/uint256.d.ts +0 -11
  222. package/utils/uint256.js +0 -28
  223. package/utils/url.d.ts +0 -7
  224. package/utils/url.js +0 -49
package/dist/index.d.ts CHANGED
@@ -1,25 +1,2684 @@
1
+ import elliptic, { ec as ec$1 } from 'elliptic';
2
+ import * as BN from 'bn.js';
3
+ import BN__default from 'bn.js';
4
+ import { CustomError } from 'ts-custom-error';
5
+
6
+ declare type BigNumberish = string | number | BN__default;
7
+ declare function isHex(hex: string): boolean;
8
+ declare function toBN(number: BigNumberish, base?: number | 'hex'): BN__default;
9
+ declare function toHex(number: BN__default): string;
10
+ declare function hexToDecimalString(hex: string): string;
11
+ declare function toFelt(num: BigNumberish): string;
12
+ declare function assertInRange(input: BigNumberish, lowerBound: BigNumberish, upperBound: BigNumberish, inputName?: string): void;
13
+ declare function bigNumberishArrayToDecimalStringArray(rawCalldata: BigNumberish[]): string[];
14
+ declare function bigNumberishArrayToHexadecimalStringArray(rawCalldata: BigNumberish[]): string[];
15
+ declare const isStringWholeNumber: (value: string) => boolean;
16
+ declare const toHexString: (value: string) => string;
17
+ declare function getDecimalString(value: string): string;
18
+ declare function getHexString(value: string): string;
19
+ declare function getHexStringArray(value: Array<string>): string[];
20
+ declare const toCairoBool: (value: boolean) => string;
21
+
22
+ type number_BigNumberish = BigNumberish;
23
+ declare const number_isHex: typeof isHex;
24
+ declare const number_toBN: typeof toBN;
25
+ declare const number_toHex: typeof toHex;
26
+ declare const number_hexToDecimalString: typeof hexToDecimalString;
27
+ declare const number_toFelt: typeof toFelt;
28
+ declare const number_assertInRange: typeof assertInRange;
29
+ declare const number_bigNumberishArrayToDecimalStringArray: typeof bigNumberishArrayToDecimalStringArray;
30
+ declare const number_bigNumberishArrayToHexadecimalStringArray: typeof bigNumberishArrayToHexadecimalStringArray;
31
+ declare const number_isStringWholeNumber: typeof isStringWholeNumber;
32
+ declare const number_toHexString: typeof toHexString;
33
+ declare const number_getDecimalString: typeof getDecimalString;
34
+ declare const number_getHexString: typeof getHexString;
35
+ declare const number_getHexStringArray: typeof getHexStringArray;
36
+ declare const number_toCairoBool: typeof toCairoBool;
37
+ declare namespace number {
38
+ export {
39
+ number_BigNumberish as BigNumberish,
40
+ number_isHex as isHex,
41
+ number_toBN as toBN,
42
+ number_toHex as toHex,
43
+ number_hexToDecimalString as hexToDecimalString,
44
+ number_toFelt as toFelt,
45
+ number_assertInRange as assertInRange,
46
+ number_bigNumberishArrayToDecimalStringArray as bigNumberishArrayToDecimalStringArray,
47
+ number_bigNumberishArrayToHexadecimalStringArray as bigNumberishArrayToHexadecimalStringArray,
48
+ number_isStringWholeNumber as isStringWholeNumber,
49
+ number_toHexString as toHexString,
50
+ number_getDecimalString as getDecimalString,
51
+ number_getHexString as getHexString,
52
+ number_getHexStringArray as getHexStringArray,
53
+ number_toCairoBool as toCairoBool,
54
+ };
55
+ }
56
+
1
57
  /**
2
- * Main
3
- */
4
- export * from './contract';
5
- export * from './types';
6
- export * from './provider';
7
- export * from './account';
8
- export * from './signer';
9
- /**
10
- * Utils
11
- */
12
- export * as constants from './constants';
13
- export * as encode from './utils/encode';
14
- export * as hash from './utils/hash';
15
- export * as json from './utils/json';
16
- export * as number from './utils/number';
17
- export * as transaction from './utils/transaction';
18
- export * as stark from './utils/stark';
19
- export * as merkle from './utils/merkle';
20
- export * as ec from './utils/ellipticCurve';
21
- export * as uint256 from './utils/uint256';
22
- export * as shortString from './utils/shortString';
23
- export * as typedData from './utils/typedData';
24
- export * from './utils/address';
25
- export * from './utils/url';
58
+ * Starknet RPC version 0.2.0
59
+ *
60
+ * StarkNet Node API 0.45.0 - rpc 0.2.1
61
+ * StarkNet Node Write API 0.3.0 - rpc 0.2.1
62
+ * StarkNet Trace API 0.4.0 - rpc 0.2.1
63
+ *
64
+ * TypeScript Representation of OpenRpc protocol types
65
+ */
66
+ declare type FELT = string;
67
+ declare type ADDRESS = FELT;
68
+ declare type NUM_AS_HEX = string;
69
+ declare type SIGNATURE = Array<FELT>;
70
+ declare type BLOCK_NUMBER = number;
71
+ declare type BLOCK_HASH = FELT;
72
+ declare type TXN_HASH = FELT;
73
+ declare type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
74
+ declare type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'DEPLOY_ACCOUNT' | 'INVOKE' | 'L1_HANDLER';
75
+ declare type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
76
+ declare enum BLOCK_TAG {
77
+ 'latest' = 0,
78
+ 'pending' = 1
79
+ }
80
+ declare type BLOCK_ID = {
81
+ block_hash: BLOCK_HASH;
82
+ } | {
83
+ block_number: BLOCK_NUMBER;
84
+ } | BLOCK_TAG;
85
+ declare type MSG_TO_L1 = {
86
+ to_address: FELT;
87
+ payload: Array<FELT>;
88
+ };
89
+ declare type EVENT = {
90
+ from_address: FELT;
91
+ keys: Array<FELT>;
92
+ data: Array<FELT>;
93
+ };
94
+ declare type COMMON_RECEIPT_PROPERTIES = {
95
+ transaction_hash: TXN_HASH;
96
+ actual_fee: FELT;
97
+ status: TXN_STATUS;
98
+ block_hash?: BLOCK_HASH;
99
+ block_number?: BLOCK_NUMBER;
100
+ type: TXN_TYPE;
101
+ messages_sent: Array<MSG_TO_L1>;
102
+ events: Array<EVENT>;
103
+ };
104
+ declare type PENDING_COMMON_RECEIPT_PROPERTIES = {
105
+ transaction_hash: TXN_HASH;
106
+ actual_fee: FELT;
107
+ type?: TXN_TYPE;
108
+ messages_sent: Array<MSG_TO_L1>;
109
+ events: Array<EVENT>;
110
+ };
111
+ declare type INVOKE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
112
+ declare type DECLARE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
113
+ declare type DEPLOY_TXN_RECEIPT = {
114
+ contract_address: FELT;
115
+ } & COMMON_RECEIPT_PROPERTIES;
116
+ declare type L1_HANDLER_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
117
+ declare type PENDING_DEPLOY_TXN_RECEIPT = {
118
+ contract_address: FELT;
119
+ } & PENDING_COMMON_RECEIPT_PROPERTIES;
120
+ declare type PENDING_TXN_RECEIPT = PENDING_DEPLOY_TXN_RECEIPT | PENDING_COMMON_RECEIPT_PROPERTIES;
121
+ declare type TXN_RECEIPT = INVOKE_TXN_RECEIPT | L1_HANDLER_TXN_RECEIPT | DECLARE_TXN_RECEIPT | DEPLOY_TXN_RECEIPT | DEPLOY_ACCOUNT_TXN_RECEIPT | PENDING_TXN_RECEIPT;
122
+ declare type BLOCK_HEADER = {
123
+ block_hash: BLOCK_HASH;
124
+ parent_hash: BLOCK_HASH;
125
+ block_number: BLOCK_NUMBER;
126
+ new_root: FELT;
127
+ timestamp: number;
128
+ sequencer_address: FELT;
129
+ };
130
+ declare type BLOCK_BODY_WITH_TX_HASHES = {
131
+ transactions: Array<TXN_HASH>;
132
+ };
133
+ declare type BLOCK_WITH_TX_HASHES = {
134
+ status: BLOCK_STATUS;
135
+ } & BLOCK_HEADER & BLOCK_BODY_WITH_TX_HASHES;
136
+ declare type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
137
+ timestamp: number;
138
+ sequencer_address: FELT;
139
+ parent_hash: BLOCK_HASH;
140
+ };
141
+ declare type COMMON_TXN_PROPERTIES = {
142
+ transaction_hash?: TXN_HASH;
143
+ } & BROADCASTED_TXN_COMMON_PROPERTIES;
144
+ declare type FUNCTION_CALL = {
145
+ contract_address?: ADDRESS;
146
+ entry_point_selector?: FELT;
147
+ calldata?: Array<FELT>;
148
+ };
149
+ declare type INVOKE_TXN = COMMON_TXN_PROPERTIES & (INVOKE_TXN_V0 | INVOKE_TXN_V1);
150
+ declare type DECLARE_TXN = COMMON_TXN_PROPERTIES & {
151
+ class_hash: FELT;
152
+ sender_address: ADDRESS;
153
+ };
154
+ declare type DEPLOY_TXN = {
155
+ transaction_hash: TXN_HASH;
156
+ class_hash: FELT;
157
+ } & DEPLOY_TXN_PROPERTIES;
158
+ declare type DEPLOY_ACCOUNT_TXN = COMMON_TXN_PROPERTIES & DEPLOY_ACCOUNT_TXN_PROPERTIES;
159
+ declare type DEPLOY_ACCOUNT_TXN_PROPERTIES = {
160
+ contract_address_salt: FELT;
161
+ constructor_calldata: Array<FELT>;
162
+ class_hash: FELT;
163
+ };
164
+ declare type DEPLOY_ACCOUNT_TXN_RECEIPT = DEPLOY_TXN_RECEIPT;
165
+ declare type TXN = INVOKE_TXN | L1_HANDLER_TXN | DECLARE_TXN | DEPLOY_TXN | DEPLOY_ACCOUNT_TXN;
166
+ declare enum L1_HANDLER {
167
+ 'L1_HANDLER' = 0
168
+ }
169
+ declare type L1_HANDLER_TXN = {
170
+ transaction_hash: TXN_HASH;
171
+ version: NUM_AS_HEX;
172
+ type: L1_HANDLER;
173
+ nonce: NUM_AS_HEX;
174
+ } & FUNCTION_CALL;
175
+ declare type BROADCASTED_DEPLOY_ACCOUNT_TXN = BROADCASTED_TXN_COMMON_PROPERTIES & DEPLOY_ACCOUNT_TXN_PROPERTIES;
176
+ declare type BROADCASTED_TXN = BROADCASTED_INVOKE_TXN | BROADCASTED_DECLARE_TXN | BROADCASTED_DEPLOY_TXN | BROADCASTED_DEPLOY_ACCOUNT_TXN;
177
+ declare type BROADCASTED_INVOKE_TXN = BROADCASTED_TXN_COMMON_PROPERTIES & (INVOKE_TXN_V0 | INVOKE_TXN_V1);
178
+ declare type BROADCASTED_TXN_COMMON_PROPERTIES = {
179
+ type: TXN_TYPE;
180
+ max_fee: FELT;
181
+ version: NUM_AS_HEX;
182
+ signature: SIGNATURE;
183
+ nonce: FELT;
184
+ };
185
+ declare type BROADCASTED_DECLARE_TXN = {
186
+ contract_class: CONTRACT_CLASS;
187
+ sender_address: ADDRESS;
188
+ } & BROADCASTED_TXN_COMMON_PROPERTIES;
189
+ declare type BROADCASTED_DEPLOY_TXN = {
190
+ contract_class: CONTRACT_CLASS;
191
+ } & DEPLOY_TXN_PROPERTIES;
192
+ declare type DEPLOY_TXN_PROPERTIES = {
193
+ version: NUM_AS_HEX;
194
+ type: TXN_TYPE;
195
+ contract_address_salt: FELT;
196
+ constructor_calldata: Array<FELT>;
197
+ };
198
+ declare type INVOKE_TXN_V0 = FUNCTION_CALL;
199
+ declare type INVOKE_TXN_V1 = {
200
+ sender_address: ADDRESS;
201
+ calldata: Array<FELT>;
202
+ };
203
+ declare type BLOCK_BODY_WITH_TXS = {
204
+ transactions: Array<TXN>;
205
+ };
206
+ declare type BLOCK_WITH_TXS = {
207
+ status: BLOCK_STATUS;
208
+ } & BLOCK_HEADER & BLOCK_BODY_WITH_TXS;
209
+ declare type PENDING_BLOCK_WITH_TXS = BLOCK_BODY_WITH_TXS & {
210
+ timestamp: number;
211
+ sequencer_address: FELT;
212
+ parent_hash: BLOCK_HASH;
213
+ };
214
+ declare type CONTRACT_CLASS = {
215
+ program: string;
216
+ entry_points_by_type: {
217
+ CONSTRUCTOR: CONTRACT_ENTRY_POINT_LIST;
218
+ EXTERNAL: CONTRACT_ENTRY_POINT_LIST;
219
+ L1_HANDLER: CONTRACT_ENTRY_POINT_LIST;
220
+ };
221
+ abi?: CONTRACT_ABI;
222
+ };
223
+ declare type CONTRACT_ABI = Array<CONTRACT_ABI_ENTRY>;
224
+ declare type CONTRACT_ABI_ENTRY = FUNCTION_ABI_ENTRY | EVENT_ABI_ENTRY | STRUCT_ABI_ENTRY;
225
+ declare enum STRUCT_ABI_TYPE {
226
+ 'struct' = 0
227
+ }
228
+ declare enum EVENT_ABI_TYPE {
229
+ 'event' = 0
230
+ }
231
+ declare enum FUNCTION_ABI_TYPE {
232
+ 'function' = 0,
233
+ 'l1_handler' = 1,
234
+ 'constructor' = 2
235
+ }
236
+ declare type STRUCT_ABI_ENTRY = STRUCT_ABI_TYPE & {
237
+ name: string;
238
+ size: number;
239
+ members: Array<STRUCT_MEMBER>;
240
+ };
241
+ declare type STRUCT_MEMBER = {
242
+ offset: number;
243
+ } & TYPED_PARAMETER;
244
+ declare type EVENT_ABI_ENTRY = {
245
+ name: string;
246
+ keys: Array<TYPED_PARAMETER>;
247
+ data: Array<TYPED_PARAMETER>;
248
+ } & EVENT_ABI_TYPE;
249
+ declare type FUNCTION_ABI_ENTRY = {
250
+ type: FUNCTION_ABI_TYPE;
251
+ name: string;
252
+ inputs: Array<TYPED_PARAMETER>;
253
+ outputs: Array<TYPED_PARAMETER>;
254
+ };
255
+ declare type TYPED_PARAMETER = {
256
+ name: string;
257
+ type: string;
258
+ };
259
+ declare type CONTRACT_ENTRY_POINT_LIST = Array<CONTRACT_ENTRY_POINT>;
260
+ declare type CONTRACT_ENTRY_POINT = {
261
+ offset: NUM_AS_HEX;
262
+ selector: FELT;
263
+ };
264
+ declare type CONTRACT_STORAGE_DIFF_ITEM = {
265
+ address: FELT;
266
+ storage_entries: [key: FELT, value: FELT];
267
+ };
268
+ declare type DEPLOYED_CONTRACT_ITEM = {
269
+ address: FELT;
270
+ class_hash: FELT;
271
+ };
272
+ declare type STATE_UPDATE = {
273
+ block_hash: BLOCK_HASH;
274
+ new_root: FELT;
275
+ old_root: FELT;
276
+ state_diff: {
277
+ storage_diffs: Array<CONTRACT_STORAGE_DIFF_ITEM>;
278
+ declared_contract_hashes: Array<FELT>;
279
+ deployed_contracts: Array<DEPLOYED_CONTRACT_ITEM>;
280
+ nonces: Array<{
281
+ contract_address: ADDRESS;
282
+ nonce: FELT;
283
+ }>;
284
+ };
285
+ };
286
+ declare type STORAGE_KEY = string;
287
+ declare type EVENT_FILTER = {
288
+ from_block?: BLOCK_ID;
289
+ to_block?: BLOCK_ID;
290
+ address?: ADDRESS;
291
+ keys?: Array<FELT>;
292
+ };
293
+ declare type RESULT_PAGE_REQUEST = {
294
+ continuation_token?: string;
295
+ chunk_size: number;
296
+ };
297
+ declare type EMITTED_EVENT = EVENT & {
298
+ block_hash: BLOCK_HASH;
299
+ block_number: BLOCK_NUMBER;
300
+ transaction_hash: TXN_HASH;
301
+ };
302
+ declare type SYNC_STATUS = {
303
+ starting_block_hash: BLOCK_HASH;
304
+ starting_block_num: NUM_AS_HEX;
305
+ current_block_hash: BLOCK_HASH;
306
+ current_block_num: NUM_AS_HEX;
307
+ highest_block_hash: BLOCK_HASH;
308
+ highest_block_num: NUM_AS_HEX;
309
+ };
310
+ declare type FEE_ESTIMATE = {
311
+ gas_consumed: NUM_AS_HEX;
312
+ gas_price: NUM_AS_HEX;
313
+ overall_fee: NUM_AS_HEX;
314
+ };
315
+ declare enum CALL_TYPE {
316
+ 'DELEGATE' = 0,
317
+ 'CALL' = 1
318
+ }
319
+ declare enum ENTRY_POINT_TYPE {
320
+ 'EXTERNAL' = 0,
321
+ 'L1_HANDLER' = 1,
322
+ 'CONSTRUCTOR' = 2
323
+ }
324
+ declare type FUNCTION_INVOCATION = FUNCTION_CALL & {
325
+ caller_address: FELT;
326
+ code_address: FELT;
327
+ entry_point_type: ENTRY_POINT_TYPE;
328
+ call_type: CALL_TYPE;
329
+ result: FELT;
330
+ calls: NESTED_CALL;
331
+ events: Array<EVENT>;
332
+ messages: MSG_TO_L1;
333
+ };
334
+ declare type NESTED_CALL = FUNCTION_INVOCATION;
335
+ declare type TRACE_ROOT = {
336
+ nonce: FELT;
337
+ signature: FELT;
338
+ function_invocation: FUNCTION_INVOCATION;
339
+ };
340
+ declare namespace OPENRPC {
341
+ type Nonce = FELT;
342
+ type BlockWithTxHashes = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
343
+ type BlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
344
+ type StateUpdate = STATE_UPDATE;
345
+ type Storage = FELT;
346
+ type Transaction = TXN;
347
+ type TransactionReceipt = TXN_RECEIPT;
348
+ type ContractClass = CONTRACT_CLASS;
349
+ type CallResponse = Array<FELT>;
350
+ type EstimatedFee = FEE_ESTIMATE;
351
+ type BlockNumber = BLOCK_NUMBER;
352
+ type BlockHashAndNumber = {
353
+ block_hash: BLOCK_HASH;
354
+ block_number: BLOCK_NUMBER;
355
+ };
356
+ type CHAIN_ID = string;
357
+ type PendingTransactions = Array<TXN>;
358
+ type SyncingStatus = false | SYNC_STATUS;
359
+ type Events = {
360
+ events: Array<EMITTED_EVENT>;
361
+ continuation_token: string;
362
+ };
363
+ type Trace = TRACE_ROOT;
364
+ type Traces = Array<{
365
+ transaction_hash: FELT;
366
+ trace_root: TRACE_ROOT;
367
+ }>;
368
+ type TransactionHash = TXN_HASH;
369
+ type BlockHash = BLOCK_HASH;
370
+ type EventFilter = EVENT_FILTER & RESULT_PAGE_REQUEST;
371
+ type InvokedTransaction = {
372
+ transaction_hash: TXN_HASH;
373
+ };
374
+ type DeclaredTransaction = {
375
+ transaction_hash: TXN_HASH;
376
+ class_hash: FELT;
377
+ };
378
+ type DeployedTransaction = {
379
+ transaction_hash: TXN_HASH;
380
+ contract_address: FELT;
381
+ };
382
+ type Methods = {
383
+ starknet_getBlockWithTxHashes: {
384
+ params: {
385
+ block_id: BLOCK_ID;
386
+ };
387
+ result: BlockWithTxHashes;
388
+ errors: Errors.BLOCK_NOT_FOUND;
389
+ };
390
+ starknet_getBlockWithTxs: {
391
+ params: {
392
+ block_id: BLOCK_ID;
393
+ };
394
+ result: BlockWithTxs;
395
+ errors: Errors.BLOCK_NOT_FOUND;
396
+ };
397
+ starknet_getStateUpdate: {
398
+ params: {
399
+ block_id: BLOCK_ID;
400
+ };
401
+ result: StateUpdate;
402
+ errors: Errors.BLOCK_NOT_FOUND;
403
+ };
404
+ starknet_getStorageAt: {
405
+ params: {
406
+ contract_address: ADDRESS;
407
+ key: STORAGE_KEY;
408
+ block_id: BLOCK_ID;
409
+ };
410
+ result: Storage;
411
+ errors: Errors.CONTRACT_NOT_FOUND | Errors.BLOCK_NOT_FOUND;
412
+ };
413
+ starknet_getTransactionByHash: {
414
+ params: {
415
+ transaction_hash: TXN_HASH;
416
+ };
417
+ result: Transaction;
418
+ errors: Errors.TXN_HASH_NOT_FOUND;
419
+ };
420
+ starknet_getTransactionByBlockIdAndIndex: {
421
+ params: {
422
+ block_id: BLOCK_ID;
423
+ index: number;
424
+ };
425
+ result: Transaction;
426
+ errors: Errors.BLOCK_NOT_FOUND | Errors.INVALID_TXN_INDEX;
427
+ };
428
+ starknet_getTransactionReceipt: {
429
+ params: {
430
+ transaction_hash: TXN_HASH;
431
+ };
432
+ result: TransactionReceipt;
433
+ errors: Errors.TXN_HASH_NOT_FOUND;
434
+ };
435
+ starknet_getClass: {
436
+ params: {
437
+ block_id: BLOCK_ID;
438
+ class_hash: FELT;
439
+ };
440
+ result: ContractClass;
441
+ errors: Errors.BLOCK_NOT_FOUND | Errors.CLASS_HASH_NOT_FOUND;
442
+ };
443
+ starknet_getClassHashAt: {
444
+ params: {
445
+ block_id: BLOCK_ID;
446
+ contract_address: ADDRESS;
447
+ };
448
+ result: FELT;
449
+ errors: Errors.BLOCK_NOT_FOUND | Errors.CONTRACT_NOT_FOUND;
450
+ };
451
+ starknet_getClassAt: {
452
+ params: {
453
+ block_id: BLOCK_ID;
454
+ contract_address: ADDRESS;
455
+ };
456
+ result: ContractClass;
457
+ errors: Errors.BLOCK_NOT_FOUND | Errors.CONTRACT_NOT_FOUND;
458
+ };
459
+ starknet_getBlockTransactionCount: {
460
+ params: {
461
+ block_id: BLOCK_ID;
462
+ };
463
+ result: number;
464
+ errors: Errors.BLOCK_NOT_FOUND;
465
+ };
466
+ starknet_call: {
467
+ params: {
468
+ request: FUNCTION_CALL;
469
+ block_id: BLOCK_ID;
470
+ };
471
+ result: Array<FELT>;
472
+ errors: Errors.CONTRACT_NOT_FOUND | Errors.INVALID_MESSAGE_SELECTOR | Errors.INVALID_CALL_DATA | Errors.CONTRACT_ERROR | Errors.BLOCK_NOT_FOUND;
473
+ };
474
+ starknet_estimateFee: {
475
+ params: {
476
+ request: BROADCASTED_TXN;
477
+ block_id: BLOCK_ID;
478
+ };
479
+ result: FEE_ESTIMATE;
480
+ errors: Errors.CONTRACT_NOT_FOUND | Errors.INVALID_MESSAGE_SELECTOR | Errors.INVALID_CALL_DATA | Errors.CONTRACT_ERROR | Errors.BLOCK_NOT_FOUND;
481
+ };
482
+ starknet_blockNumber: {
483
+ params: {};
484
+ result: BLOCK_NUMBER;
485
+ errors: Errors.NO_BLOCKS;
486
+ };
487
+ starknet_blockHashAndNumber: {
488
+ params: {};
489
+ result: BLOCK_HASH & BLOCK_NUMBER;
490
+ errors: Errors.NO_BLOCKS;
491
+ };
492
+ starknet_chainId: {
493
+ params: {};
494
+ result: CHAIN_ID;
495
+ };
496
+ starknet_pendingTransactions: {
497
+ params: {};
498
+ result: PendingTransactions;
499
+ };
500
+ starknet_syncing: {
501
+ params: {};
502
+ result: SyncingStatus;
503
+ };
504
+ starknet_getEvents: {
505
+ params: {
506
+ filter: EVENT_FILTER & RESULT_PAGE_REQUEST;
507
+ };
508
+ result: Events;
509
+ errors: Errors.PAGE_SIZE_TOO_BIG | Errors.INVALID_CONTINUATION_TOKEN | Errors.BLOCK_NOT_FOUND;
510
+ };
511
+ starknet_getNonce: {
512
+ params: {
513
+ block_id: BLOCK_ID;
514
+ contract_address: ADDRESS;
515
+ };
516
+ result: FELT;
517
+ errors: Errors.BLOCK_NOT_FOUND | Errors.CONTRACT_NOT_FOUND;
518
+ };
519
+ starknet_addInvokeTransaction: {
520
+ params: {
521
+ invoke_transaction: BROADCASTED_INVOKE_TXN;
522
+ };
523
+ result: InvokedTransaction;
524
+ };
525
+ starknet_addDeclareTransaction: {
526
+ params: {
527
+ declare_transaction: BROADCASTED_DECLARE_TXN;
528
+ };
529
+ result: DeclaredTransaction;
530
+ errors: Errors.INVALID_CONTRACT_CLASS;
531
+ };
532
+ starknet_addDeployTransaction: {
533
+ params: {
534
+ deploy_transaction: BROADCASTED_DEPLOY_TXN;
535
+ };
536
+ result: DeployedTransaction;
537
+ errors: Errors.INVALID_CONTRACT_CLASS;
538
+ };
539
+ starknet_addDeployAccountTransaction: {
540
+ params: BROADCASTED_DEPLOY_ACCOUNT_TXN;
541
+ result: {
542
+ transaction_hash: TXN_HASH;
543
+ contract_address: FELT;
544
+ };
545
+ errors: Errors.CLASS_HASH_NOT_FOUND;
546
+ };
547
+ starknet_traceTransaction: {
548
+ params: {
549
+ transaction_hash: TXN_HASH;
550
+ };
551
+ result: Trace;
552
+ errors: Errors.TXN_HASH_NOT_FOUND | Errors.NO_TRACE_AVAILABLE | Errors.INVALID_BLOCK_HASH | Errors.TXN_HASH_NOT_FOUND;
553
+ };
554
+ starknet_traceBlockTransactions: {
555
+ params: {
556
+ block_hash: BLOCK_HASH;
557
+ };
558
+ result: Traces;
559
+ errors: Errors.INVALID_BLOCK_HASH;
560
+ };
561
+ };
562
+ }
563
+ declare namespace Errors {
564
+ interface FAILED_TO_RECEIVE_TXN {
565
+ code: 1;
566
+ message: 'Failed to write transaction';
567
+ }
568
+ interface CONTRACT_NOT_FOUND {
569
+ code: 20;
570
+ message: 'Contract not found';
571
+ }
572
+ interface INVALID_MESSAGE_SELECTOR {
573
+ code: 21;
574
+ message: 'Invalid message selector';
575
+ }
576
+ interface INVALID_CALL_DATA {
577
+ code: 22;
578
+ message: 'Invalid call data';
579
+ }
580
+ interface BLOCK_NOT_FOUND {
581
+ code: 24;
582
+ message: 'Block not found';
583
+ }
584
+ interface INVALID_TXN_INDEX {
585
+ code: 27;
586
+ message: 'Invalid transaction index in a block';
587
+ }
588
+ interface CLASS_HASH_NOT_FOUND {
589
+ code: 28;
590
+ message: 'Class hash not found';
591
+ }
592
+ interface PAGE_SIZE_TOO_BIG {
593
+ code: 31;
594
+ message: 'Requested page size is too big';
595
+ }
596
+ interface NO_BLOCKS {
597
+ code: 32;
598
+ message: 'There are no blocks';
599
+ }
600
+ interface INVALID_CONTINUATION_TOKEN {
601
+ code: 33;
602
+ message: 'The supplied continuation token is invalid or unknown';
603
+ }
604
+ interface CONTRACT_ERROR {
605
+ code: 40;
606
+ message: 'Contract error';
607
+ }
608
+ interface INVALID_CONTRACT_CLASS {
609
+ code: 50;
610
+ message: 'Invalid contract class';
611
+ }
612
+ interface NO_TRACE_AVAILABLE {
613
+ code: 10;
614
+ message: 'No trace available for transaction';
615
+ data: {
616
+ status: 'RECEIVED' | 'REJECTED';
617
+ };
618
+ }
619
+ interface INVALID_BLOCK_HASH {
620
+ code: 24;
621
+ message: 'Invalid block hash';
622
+ }
623
+ interface TXN_HASH_NOT_FOUND {
624
+ code: 25;
625
+ message: 'Transaction hash not found';
626
+ }
627
+ }
628
+
629
+ declare namespace RPC {
630
+ type Response = {
631
+ id: number;
632
+ jsonrpc: string;
633
+ result?: any;
634
+ error?: {
635
+ code: string;
636
+ message: string;
637
+ };
638
+ };
639
+ type ChainId = OPENRPC.CHAIN_ID;
640
+ type CallResponse = OPENRPC.CallResponse;
641
+ type ContractAddress = ADDRESS;
642
+ type Felt = FELT;
643
+ type Nonce = OPENRPC.Nonce;
644
+ type ContractClass = OPENRPC.ContractClass;
645
+ type StateUpdate = OPENRPC.StateUpdate;
646
+ type Transaction = OPENRPC.Transaction;
647
+ type PendingTransactions = OPENRPC.PendingTransactions;
648
+ type TransactionHash = OPENRPC.TransactionHash;
649
+ type Trace = OPENRPC.Trace;
650
+ type Traces = OPENRPC.Traces;
651
+ type BlockHash = OPENRPC.BlockHash;
652
+ type BlockHashAndNumber = OPENRPC.BlockHashAndNumber;
653
+ type GetClassResponse = OPENRPC.ContractClass;
654
+ type EstimateFeeResponse = OPENRPC.EstimatedFee;
655
+ type GetBlockWithTxHashesResponse = OPENRPC.BlockWithTxHashes;
656
+ type GetBlockWithTxs = OPENRPC.BlockWithTxs;
657
+ type GetStorageAtResponse = OPENRPC.Storage;
658
+ type TransactionReceipt = OPENRPC.TransactionReceipt;
659
+ type GetTransactionByHashResponse = OPENRPC.Transaction;
660
+ type GetTransactionByBlockIdAndIndex = OPENRPC.Transaction;
661
+ type GetTransactionCountResponse = number;
662
+ type GetBlockNumberResponse = OPENRPC.BlockNumber;
663
+ type GetSyncingStatsResponse = OPENRPC.SyncingStatus;
664
+ type EventFilter = OPENRPC.EventFilter;
665
+ type GetEventsResponse = OPENRPC.Events;
666
+ type InvokedTransaction = OPENRPC.InvokedTransaction;
667
+ type DeclaredTransaction = OPENRPC.DeclaredTransaction;
668
+ type DeployedTransaction = OPENRPC.DeployedTransaction;
669
+ type Methods = OPENRPC.Methods;
670
+ }
671
+
672
+ declare type KeyPair = ec$1.KeyPair;
673
+ declare type Signature = string[];
674
+ declare type RawCalldata = BigNumberish[];
675
+ declare type AllowArray<T> = T | T[];
676
+ declare type RawArgs$1 = {
677
+ [inputName: string]: string | string[] | {
678
+ type: 'struct';
679
+ [k: string]: BigNumberish;
680
+ };
681
+ } | string[];
682
+ interface ContractClass {
683
+ program: CompressedProgram;
684
+ entry_points_by_type: RPC.ContractClass['entry_points_by_type'];
685
+ abi?: Abi;
686
+ }
687
+ declare type UniversalDeployerContractPayload = {
688
+ classHash: BigNumberish;
689
+ salt: string;
690
+ unique: boolean;
691
+ constructorCalldata?: RawArgs$1;
692
+ additionalCalls?: AllowArray<Call>;
693
+ };
694
+ declare type DeployContractPayload = {
695
+ contract: CompiledContract | string;
696
+ constructorCalldata?: RawCalldata;
697
+ addressSalt?: string;
698
+ };
699
+ declare type DeployAccountContractPayload = {
700
+ classHash: BigNumberish;
701
+ constructorCalldata?: RawCalldata;
702
+ addressSalt?: BigNumberish;
703
+ contractAddress?: string;
704
+ };
705
+ declare type DeployAccountContractTransaction = Omit<DeployAccountContractPayload, 'contractAddress'> & {
706
+ signature?: Signature;
707
+ };
708
+ declare type DeclareContractPayload = {
709
+ contract: CompiledContract | string;
710
+ classHash: BigNumberish;
711
+ };
712
+ declare type DeclareContractTransaction = {
713
+ contractDefinition: ContractClass;
714
+ senderAddress: string;
715
+ signature?: Signature;
716
+ };
717
+ declare type CallDetails = {
718
+ contractAddress: string;
719
+ calldata?: RawCalldata;
720
+ };
721
+ declare type Invocation = CallDetails & {
722
+ signature?: Signature;
723
+ };
724
+ declare type Call = CallDetails & {
725
+ entrypoint: string;
726
+ };
727
+ declare type InvocationsDetails = {
728
+ nonce?: BigNumberish;
729
+ maxFee?: BigNumberish;
730
+ version?: BigNumberish;
731
+ };
732
+ declare type InvocationsDetailsWithNonce = InvocationsDetails & {
733
+ nonce: BigNumberish;
734
+ };
735
+ declare type Status = 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
736
+ declare type TransactionStatus = 'TRANSACTION_RECEIVED';
737
+ declare type TransactionType = 'DECLARE' | 'DEPLOY' | 'INVOKE_FUNCTION' | 'DEPLOY_ACCOUNT';
738
+ declare type EntryPointType = 'EXTERNAL';
739
+ declare type CompressedProgram = string;
740
+ declare type AbiEntry = {
741
+ name: string;
742
+ type: 'felt' | 'felt*' | string;
743
+ };
744
+ declare type FunctionAbi = {
745
+ inputs: AbiEntry[];
746
+ name: string;
747
+ outputs: AbiEntry[];
748
+ stateMutability?: 'view';
749
+ type: FunctionAbiType;
750
+ };
751
+ declare enum FunctionAbiType {
752
+ 'function' = 0,
753
+ 'l1_handler' = 1,
754
+ 'constructor' = 2
755
+ }
756
+ declare type StructAbi = {
757
+ members: (AbiEntry & {
758
+ offset: number;
759
+ })[];
760
+ name: string;
761
+ size: number;
762
+ type: 'struct';
763
+ };
764
+ declare type Abi = Array<FunctionAbi | EventAbi | StructAbi>;
765
+ declare type EventAbi = any;
766
+ declare type EntryPointsByType = object;
767
+ declare type Program = Record<any, any>;
768
+ declare type BlockTag = 'pending' | 'latest';
769
+ declare type BlockNumber = BlockTag | null | number;
770
+ declare type CompiledContract = {
771
+ abi: Abi;
772
+ entry_points_by_type: EntryPointsByType;
773
+ program: Program;
774
+ };
775
+ declare type CompressedCompiledContract = Omit<CompiledContract, 'program'> & {
776
+ program: CompressedProgram;
777
+ };
778
+ declare type Struct = {
779
+ type: 'struct';
780
+ [k: string]: BigNumberish;
781
+ };
782
+ declare type Args = {
783
+ [inputName: string]: BigNumberish | BigNumberish[] | ParsedStruct | ParsedStruct[];
784
+ };
785
+ declare type ParsedStruct = {
786
+ [key: string]: BigNumberish | ParsedStruct;
787
+ };
788
+
789
+ declare type BlockIdentifier = BlockNumber | BigNumberish;
790
+
791
+ declare type GetTransactionStatusResponse = {
792
+ tx_status: Status;
793
+ block_hash?: string;
794
+ tx_failure_reason?: {
795
+ code: string;
796
+ error_message: string;
797
+ };
798
+ };
799
+ declare type GetContractAddressesResponse = {
800
+ Starknet: string;
801
+ GpsStatementVerifier: string;
802
+ };
803
+ declare type FunctionInvocation = {
804
+ caller_address: string;
805
+ contract_address: string;
806
+ calldata: RawCalldata;
807
+ call_type?: string;
808
+ class_hash?: string;
809
+ selector?: string;
810
+ entry_point_type?: EntryPointType;
811
+ result: Array<any>;
812
+ execution_resources: ExecutionResources;
813
+ internal_calls: Array<FunctionInvocation>;
814
+ events: Array<any>;
815
+ messages: Array<any>;
816
+ };
817
+ declare type ExecutionResources = {
818
+ n_steps: number;
819
+ builtin_instance_counter: {
820
+ pedersen_builtin: number;
821
+ range_check_builtin: number;
822
+ bitwise_builtin: number;
823
+ output_builtin: number;
824
+ ecdsa_builtin: number;
825
+ ec_op_builtin?: number;
826
+ };
827
+ n_memory_holes: number;
828
+ };
829
+ declare type GetTransactionTraceResponse = {
830
+ validate_invocation?: FunctionInvocation;
831
+ function_invocation?: FunctionInvocation;
832
+ fee_transfer_invocation?: FunctionInvocation;
833
+ signature: Signature;
834
+ };
835
+ declare type RawArgs = {
836
+ [inputName: string]: string | string[] | {
837
+ type: 'struct';
838
+ [k: string]: BigNumberish;
839
+ };
840
+ };
841
+ declare type CallL1Handler = {
842
+ from_address: string;
843
+ to_address: string;
844
+ entry_point_selector: string;
845
+ payload: Array<string>;
846
+ };
847
+ declare namespace Sequencer {
848
+ type DeclareTransaction = {
849
+ type: 'DECLARE';
850
+ sender_address: string;
851
+ contract_class: ContractClass;
852
+ signature?: Signature;
853
+ nonce: BigNumberish;
854
+ max_fee?: BigNumberish;
855
+ version?: BigNumberish;
856
+ };
857
+ type DeployTransaction = {
858
+ type: 'DEPLOY';
859
+ contract_definition: ContractClass;
860
+ contract_address_salt: BigNumberish;
861
+ constructor_calldata: string[];
862
+ nonce?: BigNumberish;
863
+ };
864
+ type DeployAccountTransaction = {
865
+ type: 'DEPLOY_ACCOUNT';
866
+ class_hash: string;
867
+ contract_address_salt: BigNumberish;
868
+ constructor_calldata: string[];
869
+ signature?: Signature;
870
+ max_fee?: BigNumberish;
871
+ version?: BigNumberish;
872
+ nonce?: BigNumberish;
873
+ };
874
+ type InvokeFunctionTransaction = {
875
+ type: 'INVOKE_FUNCTION';
876
+ contract_address: string;
877
+ signature?: Signature;
878
+ entry_point_type?: EntryPointType;
879
+ calldata?: RawCalldata;
880
+ nonce: BigNumberish;
881
+ max_fee?: BigNumberish;
882
+ version?: BigNumberish;
883
+ };
884
+ type Transaction = DeclareTransaction | DeployTransaction | InvokeFunctionTransaction | DeployAccountTransaction;
885
+ type AddTransactionResponse = {
886
+ transaction_hash: string;
887
+ code?: TransactionStatus;
888
+ address?: string;
889
+ class_hash?: string;
890
+ };
891
+ type GetCodeResponse = {
892
+ bytecode: string[];
893
+ abi: Abi;
894
+ };
895
+ interface InvokeFunctionTransactionResponse extends InvokeFunctionTransaction {
896
+ transaction_hash: string;
897
+ entry_point_selector: string;
898
+ }
899
+ type TransactionResponse = DeclareTransaction | DeployTransaction | InvokeFunctionTransactionResponse;
900
+ type SuccessfulTransactionResponse = {
901
+ status: Status;
902
+ transaction: TransactionResponse;
903
+ block_hash: string;
904
+ block_number: BlockNumber;
905
+ transaction_index: number;
906
+ };
907
+ type FailedTransactionResponse = {
908
+ status: 'REJECTED';
909
+ transaction_failure_reason: {
910
+ code: string;
911
+ error_message: string;
912
+ };
913
+ transaction: TransactionResponse;
914
+ };
915
+ type GetTransactionResponse = SuccessfulTransactionResponse | FailedTransactionResponse;
916
+ type TransactionReceiptResponse = SuccessfulTransactionReceiptResponse | FailedTransactionReceiptResponse;
917
+ type SuccessfulTransactionReceiptResponse = {
918
+ status: Status;
919
+ transaction_hash: string;
920
+ transaction_index: number;
921
+ block_hash: string;
922
+ block_number: BlockNumber;
923
+ l2_to_l1_messages: string[];
924
+ events: string[];
925
+ actual_fee: string;
926
+ execution_resources: ExecutionResources;
927
+ };
928
+ type FailedTransactionReceiptResponse = {
929
+ status: 'REJECTED';
930
+ transaction_failure_reason: {
931
+ code: string;
932
+ error_message: string;
933
+ };
934
+ transaction_hash: string;
935
+ l2_to_l1_messages: string[];
936
+ events: string[];
937
+ };
938
+ type GetBlockResponse = {
939
+ block_number: number;
940
+ state_root: string;
941
+ block_hash: string;
942
+ transactions: {
943
+ [txHash: string]: TransactionResponse;
944
+ };
945
+ timestamp: number;
946
+ transaction_receipts: {
947
+ [txHash: string]: {
948
+ block_hash: string;
949
+ transaction_hash: string;
950
+ l2_to_l1_messages: {
951
+ to_address: string;
952
+ payload: string[];
953
+ from_address: string;
954
+ }[];
955
+ block_number: BlockNumber;
956
+ status: Status;
957
+ transaction_index: number;
958
+ };
959
+ };
960
+ parent_block_hash: string;
961
+ status: Status;
962
+ gas_price: string;
963
+ sequencer_address: string;
964
+ starknet_version: string;
965
+ };
966
+ type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'> & {
967
+ entry_point_selector: string;
968
+ };
969
+ type CallContractResponse = {
970
+ result: string[];
971
+ };
972
+ type InvokeEstimateFee = Omit<InvokeFunctionTransaction, 'max_fee' | 'entry_point_type'>;
973
+ type DeclareEstimateFee = Omit<DeclareTransaction, 'max_fee'>;
974
+ type DeployAccountEstimateFee = Omit<DeployAccountTransaction, 'max_fee'>;
975
+ type DeployEstimateFee = DeployTransaction;
976
+ type EstimateFeeRequest = InvokeEstimateFee | DeclareEstimateFee | DeployEstimateFee | DeployAccountEstimateFee;
977
+ type EstimateFeeResponse = {
978
+ overall_fee: number;
979
+ gas_price: number;
980
+ gas_usage: number;
981
+ } | {
982
+ amount: BN__default;
983
+ unit: string;
984
+ };
985
+ type Endpoints = {
986
+ get_contract_addresses: {
987
+ QUERY: never;
988
+ REQUEST: never;
989
+ RESPONSE: GetContractAddressesResponse;
990
+ };
991
+ add_transaction: {
992
+ QUERY: never;
993
+ REQUEST: Transaction;
994
+ RESPONSE: AddTransactionResponse;
995
+ };
996
+ get_transaction: {
997
+ QUERY: {
998
+ transactionHash: string;
999
+ };
1000
+ REQUEST: never;
1001
+ RESPONSE: GetTransactionResponse;
1002
+ };
1003
+ get_transaction_status: {
1004
+ QUERY: {
1005
+ transactionHash: string;
1006
+ };
1007
+ REQUEST: never;
1008
+ RESPONSE: GetTransactionStatusResponse;
1009
+ };
1010
+ get_transaction_trace: {
1011
+ QUERY: {
1012
+ transactionHash: string;
1013
+ };
1014
+ REQUEST: never;
1015
+ RESPONSE: GetTransactionTraceResponse;
1016
+ };
1017
+ get_transaction_receipt: {
1018
+ QUERY: {
1019
+ transactionHash: string;
1020
+ };
1021
+ REQUEST: never;
1022
+ RESPONSE: TransactionReceiptResponse;
1023
+ };
1024
+ get_nonce: {
1025
+ QUERY: {
1026
+ contractAddress: string;
1027
+ blockIdentifier: BlockIdentifier;
1028
+ };
1029
+ REQUEST: never;
1030
+ RESPONSE: BigNumberish;
1031
+ };
1032
+ get_storage_at: {
1033
+ QUERY: {
1034
+ contractAddress: string;
1035
+ key: BigNumberish;
1036
+ blockIdentifier: BlockIdentifier;
1037
+ };
1038
+ REQUEST: never;
1039
+ RESPONSE: string;
1040
+ };
1041
+ get_code: {
1042
+ QUERY: {
1043
+ contractAddress: string;
1044
+ blockIdentifier: BlockIdentifier;
1045
+ };
1046
+ REQUEST: never;
1047
+ RESPONSE: GetCodeResponse;
1048
+ };
1049
+ get_block: {
1050
+ QUERY: {
1051
+ blockIdentifier: BlockIdentifier;
1052
+ };
1053
+ REQUEST: never;
1054
+ RESPONSE: GetBlockResponse;
1055
+ };
1056
+ call_contract: {
1057
+ QUERY: {
1058
+ blockIdentifier: BlockIdentifier;
1059
+ };
1060
+ REQUEST: CallContractTransaction;
1061
+ RESPONSE: CallContractResponse;
1062
+ };
1063
+ estimate_fee: {
1064
+ QUERY: {
1065
+ blockIdentifier: BlockIdentifier;
1066
+ };
1067
+ REQUEST: EstimateFeeRequest;
1068
+ RESPONSE: EstimateFeeResponse;
1069
+ };
1070
+ get_class_by_hash: {
1071
+ QUERY: {
1072
+ classHash: string;
1073
+ };
1074
+ REQUEST: never;
1075
+ RESPONSE: any;
1076
+ };
1077
+ get_class_hash_at: {
1078
+ QUERY: {
1079
+ contractAddress: string;
1080
+ blockIdentifier?: BlockIdentifier;
1081
+ };
1082
+ REQUEST: never;
1083
+ RESPONSE: string;
1084
+ };
1085
+ get_state_update: {
1086
+ QUERY: {
1087
+ blockHash: string;
1088
+ };
1089
+ REQUEST: never;
1090
+ RESPONSE: any;
1091
+ };
1092
+ get_full_contract: {
1093
+ QUERY: {
1094
+ contractAddress: string;
1095
+ blockIdentifier?: BlockIdentifier;
1096
+ };
1097
+ REQUEST: never;
1098
+ RESPONSE: any;
1099
+ };
1100
+ estimate_message_fee: {
1101
+ QUERY: any;
1102
+ REQUEST: any;
1103
+ RESPONSE: EstimateFeeResponse;
1104
+ };
1105
+ };
1106
+ }
1107
+
1108
+ declare type Calldata = string[];
1109
+ declare type Overrides = {
1110
+ maxFee?: BigNumberish;
1111
+ nonce?: BigNumberish;
1112
+ signature?: Signature;
1113
+ };
1114
+
1115
+ type index$1_Calldata = Calldata;
1116
+ type index$1_Overrides = Overrides;
1117
+ type index$1_GetTransactionStatusResponse = GetTransactionStatusResponse;
1118
+ type index$1_GetContractAddressesResponse = GetContractAddressesResponse;
1119
+ type index$1_FunctionInvocation = FunctionInvocation;
1120
+ type index$1_ExecutionResources = ExecutionResources;
1121
+ type index$1_GetTransactionTraceResponse = GetTransactionTraceResponse;
1122
+ type index$1_RawArgs = RawArgs;
1123
+ type index$1_CallL1Handler = CallL1Handler;
1124
+ declare const index$1_Sequencer: typeof Sequencer;
1125
+ declare const index$1_RPC: typeof RPC;
1126
+ declare namespace index$1 {
1127
+ export {
1128
+ index$1_Calldata as Calldata,
1129
+ index$1_Overrides as Overrides,
1130
+ index$1_GetTransactionStatusResponse as GetTransactionStatusResponse,
1131
+ index$1_GetContractAddressesResponse as GetContractAddressesResponse,
1132
+ index$1_FunctionInvocation as FunctionInvocation,
1133
+ index$1_ExecutionResources as ExecutionResources,
1134
+ index$1_GetTransactionTraceResponse as GetTransactionTraceResponse,
1135
+ index$1_RawArgs as RawArgs,
1136
+ index$1_CallL1Handler as CallL1Handler,
1137
+ index$1_Sequencer as Sequencer,
1138
+ index$1_RPC as RPC,
1139
+ };
1140
+ }
1141
+
1142
+ declare const IS_BROWSER: boolean;
1143
+ declare function arrayBufferToString(array: ArrayBuffer): string;
1144
+ declare function btoaUniversal(b: ArrayBuffer): string;
1145
+ declare function buf2hex(buffer: Uint8Array): string;
1146
+ /**
1147
+ * Some function imported from https://github.com/pedrouid/enc-utils/blob/master/src/index.ts
1148
+ * enc-utils is no dependency to avoid using `Buffer` which just works in node and no browsers
1149
+ */
1150
+ declare function removeHexPrefix(hex: string): string;
1151
+ declare function addHexPrefix(hex: string): string;
1152
+ declare function padLeft(str: string, length: number, padding?: string): string;
1153
+ declare function calcByteLength(length: number, byteSize?: number): number;
1154
+ declare function sanitizeBytes(str: string, byteSize?: number, padding?: string): string;
1155
+ declare function sanitizeHex(hex: string): string;
1156
+ declare function utf8ToArray(str: string): Uint8Array;
1157
+
1158
+ declare const encode_IS_BROWSER: typeof IS_BROWSER;
1159
+ declare const encode_arrayBufferToString: typeof arrayBufferToString;
1160
+ declare const encode_btoaUniversal: typeof btoaUniversal;
1161
+ declare const encode_buf2hex: typeof buf2hex;
1162
+ declare const encode_removeHexPrefix: typeof removeHexPrefix;
1163
+ declare const encode_addHexPrefix: typeof addHexPrefix;
1164
+ declare const encode_padLeft: typeof padLeft;
1165
+ declare const encode_calcByteLength: typeof calcByteLength;
1166
+ declare const encode_sanitizeBytes: typeof sanitizeBytes;
1167
+ declare const encode_sanitizeHex: typeof sanitizeHex;
1168
+ declare const encode_utf8ToArray: typeof utf8ToArray;
1169
+ declare namespace encode {
1170
+ export {
1171
+ encode_IS_BROWSER as IS_BROWSER,
1172
+ encode_arrayBufferToString as arrayBufferToString,
1173
+ encode_btoaUniversal as btoaUniversal,
1174
+ encode_buf2hex as buf2hex,
1175
+ encode_removeHexPrefix as removeHexPrefix,
1176
+ encode_addHexPrefix as addHexPrefix,
1177
+ encode_padLeft as padLeft,
1178
+ encode_calcByteLength as calcByteLength,
1179
+ encode_sanitizeBytes as sanitizeBytes,
1180
+ encode_sanitizeHex as sanitizeHex,
1181
+ encode_utf8ToArray as utf8ToArray,
1182
+ };
1183
+ }
1184
+
1185
+ declare const ZERO: BN;
1186
+ declare const ONE: BN;
1187
+ declare const TWO: BN;
1188
+ declare const MASK_250: BN;
1189
+ declare const MASK_251: BN;
1190
+ declare enum StarknetChainId {
1191
+ MAINNET = "0x534e5f4d41494e",
1192
+ TESTNET = "0x534e5f474f45524c49",
1193
+ TESTNET2 = "0x534e5f474f45524c4932"
1194
+ }
1195
+ declare enum TransactionHashPrefix {
1196
+ DECLARE = "0x6465636c617265",
1197
+ DEPLOY = "0x6465706c6f79",
1198
+ DEPLOY_ACCOUNT = "0x6465706c6f795f6163636f756e74",
1199
+ INVOKE = "0x696e766f6b65",
1200
+ L1_HANDLER = "0x6c315f68616e646c6572"
1201
+ }
1202
+ declare const UDC: {
1203
+ ADDRESS: string;
1204
+ ENTRYPOINT: string;
1205
+ };
1206
+ /**
1207
+ * The following is taken from https://github.com/starkware-libs/starkex-resources/blob/master/crypto/starkware/crypto/signature/pedersen_params.json but converted to hex, because JS is very bad handling big integers by default
1208
+ * Please do not edit until the JSON changes.
1209
+ */
1210
+ declare const FIELD_PRIME = "800000000000011000000000000000000000000000000000000000000000001";
1211
+ declare const FIELD_GEN = "3";
1212
+ declare const FIELD_SIZE = 251;
1213
+ declare const EC_ORDER = "800000000000010FFFFFFFFFFFFFFFFB781126DCAE7B2321E66A241ADC64D2F";
1214
+ declare const ALPHA = "1";
1215
+ declare const BETA = "6F21413EFBE40DE150E596D72F7A8C5609AD26C15C915C1F4CDFCB99CEE9E89";
1216
+ declare const MAX_ECDSA_VAL = "800000000000000000000000000000000000000000000000000000000000000";
1217
+ declare const CONSTANT_POINTS: string[][];
1218
+
1219
+ declare const constants_ZERO: typeof ZERO;
1220
+ declare const constants_ONE: typeof ONE;
1221
+ declare const constants_TWO: typeof TWO;
1222
+ declare const constants_MASK_250: typeof MASK_250;
1223
+ declare const constants_MASK_251: typeof MASK_251;
1224
+ type constants_StarknetChainId = StarknetChainId;
1225
+ declare const constants_StarknetChainId: typeof StarknetChainId;
1226
+ type constants_TransactionHashPrefix = TransactionHashPrefix;
1227
+ declare const constants_TransactionHashPrefix: typeof TransactionHashPrefix;
1228
+ declare const constants_UDC: typeof UDC;
1229
+ declare const constants_FIELD_PRIME: typeof FIELD_PRIME;
1230
+ declare const constants_FIELD_GEN: typeof FIELD_GEN;
1231
+ declare const constants_FIELD_SIZE: typeof FIELD_SIZE;
1232
+ declare const constants_EC_ORDER: typeof EC_ORDER;
1233
+ declare const constants_ALPHA: typeof ALPHA;
1234
+ declare const constants_BETA: typeof BETA;
1235
+ declare const constants_MAX_ECDSA_VAL: typeof MAX_ECDSA_VAL;
1236
+ declare const constants_CONSTANT_POINTS: typeof CONSTANT_POINTS;
1237
+ declare const constants_IS_BROWSER: typeof IS_BROWSER;
1238
+ declare namespace constants {
1239
+ export {
1240
+ constants_ZERO as ZERO,
1241
+ constants_ONE as ONE,
1242
+ constants_TWO as TWO,
1243
+ constants_MASK_250 as MASK_250,
1244
+ constants_MASK_251 as MASK_251,
1245
+ constants_StarknetChainId as StarknetChainId,
1246
+ constants_TransactionHashPrefix as TransactionHashPrefix,
1247
+ constants_UDC as UDC,
1248
+ constants_FIELD_PRIME as FIELD_PRIME,
1249
+ constants_FIELD_GEN as FIELD_GEN,
1250
+ constants_FIELD_SIZE as FIELD_SIZE,
1251
+ constants_EC_ORDER as EC_ORDER,
1252
+ constants_ALPHA as ALPHA,
1253
+ constants_BETA as BETA,
1254
+ constants_MAX_ECDSA_VAL as MAX_ECDSA_VAL,
1255
+ constants_CONSTANT_POINTS as CONSTANT_POINTS,
1256
+ constants_IS_BROWSER as IS_BROWSER,
1257
+ };
1258
+ }
1259
+
1260
+ interface InvocationsSignerDetails extends Required<InvocationsDetails> {
1261
+ walletAddress: string;
1262
+ chainId: StarknetChainId;
1263
+ }
1264
+ interface DeclareSignerDetails {
1265
+ classHash: BigNumberish;
1266
+ senderAddress: BigNumberish;
1267
+ chainId: StarknetChainId;
1268
+ maxFee: BigNumberish;
1269
+ version: BigNumberish;
1270
+ nonce: BigNumberish;
1271
+ }
1272
+ declare type DeployAccountSignerDetails = Required<DeployAccountContractPayload> & Required<InvocationsDetails> & {
1273
+ contractAddress: BigNumberish;
1274
+ chainId: StarknetChainId;
1275
+ };
1276
+
1277
+ declare type AsyncContractFunction<T = any> = (...args: Array<any>) => Promise<T>;
1278
+ declare type ContractFunction = (...args: Array<any>) => any;
1279
+ interface Result extends Array<any> {
1280
+ [key: string]: any;
1281
+ }
1282
+
1283
+ /**
1284
+ * Common interface response
1285
+ * Intersection (sequencer response ∩ (∪ rpc responses))
1286
+ */
1287
+
1288
+ interface GetBlockResponse {
1289
+ timestamp: number;
1290
+ block_hash: string;
1291
+ block_number: number;
1292
+ new_root: string;
1293
+ parent_hash: string;
1294
+ status: Status;
1295
+ transactions: Array<string>;
1296
+ gas_price?: string;
1297
+ sequencer_address?: string;
1298
+ starknet_version?: string;
1299
+ transaction_receipts?: any;
1300
+ }
1301
+ interface GetCodeResponse {
1302
+ bytecode: string[];
1303
+ }
1304
+ declare type GetTransactionResponse = InvokeTransactionResponse & DeclareTransactionResponse;
1305
+ interface CommonTransactionResponse {
1306
+ transaction_hash?: string;
1307
+ version?: string;
1308
+ signature?: Signature;
1309
+ max_fee?: string;
1310
+ nonce?: string;
1311
+ }
1312
+ interface InvokeTransactionResponse extends CommonTransactionResponse {
1313
+ contract_address?: string;
1314
+ entry_point_selector?: string;
1315
+ calldata: RawCalldata;
1316
+ }
1317
+ interface ContractEntryPoint {
1318
+ offset: string;
1319
+ selector: string;
1320
+ }
1321
+ interface DeclareTransactionResponse extends CommonTransactionResponse {
1322
+ contract_class?: any;
1323
+ sender_address?: string;
1324
+ }
1325
+ declare type GetTransactionReceiptResponse = InvokeTransactionReceiptResponse | DeclareTransactionReceiptResponse;
1326
+ interface CommonTransactionReceiptResponse {
1327
+ transaction_hash: string;
1328
+ status?: Status;
1329
+ actual_fee?: string;
1330
+ status_data?: string;
1331
+ }
1332
+ interface MessageToL1 {
1333
+ to_address: string;
1334
+ payload: Array<string>;
1335
+ }
1336
+ interface Event {
1337
+ from_address: string;
1338
+ keys: Array<string>;
1339
+ data: Array<string>;
1340
+ }
1341
+ interface MessageToL2 {
1342
+ from_address: string;
1343
+ payload: Array<string>;
1344
+ }
1345
+ interface InvokeTransactionReceiptResponse extends CommonTransactionReceiptResponse {
1346
+ /** @deprecated Use l2_to_l1_messages */
1347
+ messages_sent?: Array<MessageToL1>;
1348
+ events?: Array<Event>;
1349
+ l1_origin_message?: MessageToL2;
1350
+ }
1351
+ declare type DeclareTransactionReceiptResponse = CommonTransactionReceiptResponse;
1352
+ interface EstimateFeeResponse {
1353
+ overall_fee: BN__default;
1354
+ gas_consumed?: BN__default;
1355
+ gas_price?: BN__default;
1356
+ }
1357
+ interface InvokeFunctionResponse {
1358
+ transaction_hash: string;
1359
+ }
1360
+ interface DeployContractResponse {
1361
+ contract_address: string;
1362
+ transaction_hash: string;
1363
+ }
1364
+ interface DeclareContractResponse {
1365
+ transaction_hash: string;
1366
+ class_hash: string;
1367
+ }
1368
+ declare type CallContractResponse = {
1369
+ result: Array<string>;
1370
+ };
1371
+ declare type EstimateFeeAction = {
1372
+ type: 'INVOKE';
1373
+ payload: AllowArray<Call>;
1374
+ } | {
1375
+ type: 'DECLARE';
1376
+ payload: DeclareContractPayload;
1377
+ } | {
1378
+ type: 'DEPLOY_ACCOUNT';
1379
+ payload: DeployAccountContractPayload;
1380
+ } | {
1381
+ type: 'DEPLOY';
1382
+ payload: UniversalDeployerContractPayload;
1383
+ };
1384
+
1385
+ interface EstimateFee extends EstimateFeeResponse {
1386
+ suggestedMaxFee: BN__default;
1387
+ }
1388
+ interface EstimateFeeDetails {
1389
+ nonce?: BigNumberish;
1390
+ blockIdentifier?: BlockIdentifier;
1391
+ }
1392
+
1393
+ declare abstract class ProviderInterface {
1394
+ abstract chainId: StarknetChainId;
1395
+ /**
1396
+ * Gets the Starknet chain Id
1397
+ *
1398
+ * @returns the chain Id
1399
+ */
1400
+ abstract getChainId(): Promise<StarknetChainId>;
1401
+ /**
1402
+ * Calls a function on the StarkNet contract.
1403
+ *
1404
+ * @param call transaction to be called
1405
+ * @param blockIdentifier block identifier
1406
+ * @returns the result of the function on the smart contract.
1407
+ */
1408
+ abstract callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
1409
+ /**
1410
+ * Gets the block information
1411
+ *
1412
+ * @param blockIdentifier block identifier
1413
+ * @returns the block object
1414
+ */
1415
+ abstract getBlock(blockIdentifier: BlockIdentifier): Promise<GetBlockResponse>;
1416
+ /**
1417
+ * @deprecated The method should not be used
1418
+ */
1419
+ abstract getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
1420
+ /**
1421
+ * Gets the contract class of the deployed contract.
1422
+ *
1423
+ * @param contractAddress - contract address
1424
+ * @param blockIdentifier - block identifier
1425
+ * @returns Contract class of compiled contract
1426
+ */
1427
+ abstract getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
1428
+ /**
1429
+ * Returns the class hash deployed under the given address.
1430
+ *
1431
+ * @param contractAddress - contract address
1432
+ * @param blockIdentifier - block identifier
1433
+ * @returns Class hash
1434
+ */
1435
+ abstract getClassHashAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<string>;
1436
+ /**
1437
+ * Returns the contract class deployed under the given class hash.
1438
+ *
1439
+ * @param classHash - class hash
1440
+ * @returns Contract class of compiled contract
1441
+ */
1442
+ abstract getClassByHash(classHash: string): Promise<ContractClass>;
1443
+ /**
1444
+ * Gets the nonce of a contract with respect to a specific block
1445
+ *
1446
+ * @param contractAddress - contract address
1447
+ * @returns the hex nonce
1448
+ */
1449
+ abstract getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1450
+ /**
1451
+ * Gets the contract's storage variable at a specific key.
1452
+ *
1453
+ * @param contractAddress
1454
+ * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
1455
+ * @param blockIdentifier - block identifier
1456
+ * @returns the value of the storage variable
1457
+ */
1458
+ abstract getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1459
+ /**
1460
+ * Gets the transaction information from a tx id.
1461
+ *
1462
+ * @param txHash
1463
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
1464
+ */
1465
+ abstract getTransaction(transactionHash: BigNumberish): Promise<GetTransactionResponse>;
1466
+ /**
1467
+ * Gets the transaction receipt from a tx hash.
1468
+ *
1469
+ * @param txHash
1470
+ * @returns the transaction receipt object
1471
+ */
1472
+ abstract getTransactionReceipt(transactionHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
1473
+ /**
1474
+ * Deploys a given compiled contract (json) to starknet
1475
+ *
1476
+ * @deprecated This method won't be supported, use Account.deploy instead
1477
+ *
1478
+ * @param payload payload to be deployed containing:
1479
+ * - compiled contract code
1480
+ * - constructor calldata
1481
+ * - address salt
1482
+ * @returns a confirmation of sending a transaction on the starknet contract
1483
+ */
1484
+ abstract deployContract(payload: DeployContractPayload, details?: InvocationsDetails): Promise<DeployContractResponse>;
1485
+ /**
1486
+ * Deploys a given compiled Account contract (json) to starknet
1487
+ *
1488
+ * @param payload payload to be deployed containing:
1489
+ * - compiled contract code
1490
+ * - constructor calldata
1491
+ * - address salt
1492
+ * @returns a confirmation of sending a transaction on the starknet contract
1493
+ */
1494
+ abstract deployAccountContract(payload: DeployAccountContractPayload, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
1495
+ /**
1496
+ * Invokes a function on starknet
1497
+ * @deprecated This method wont be supported as soon as fees are mandatory
1498
+ *
1499
+ * @param invocation the invocation object containing:
1500
+ * - contractAddress - the address of the contract
1501
+ * - entrypoint - the entrypoint of the contract
1502
+ * - calldata - (defaults to []) the calldata
1503
+ * - signature - (defaults to []) the signature
1504
+ * @param details - optional details containing:
1505
+ * - nonce - optional nonce
1506
+ * - version - optional version
1507
+ * - maxFee - optional maxFee
1508
+ * @returns response from addTransaction
1509
+ */
1510
+ abstract invokeFunction(invocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
1511
+ /**
1512
+ * Declares a given compiled contract (json) to starknet
1513
+ * @param transaction transaction payload to be deployed containing:
1514
+ * - compiled contract code
1515
+ * - sender address
1516
+ * - signature
1517
+ * @param details Invocation Details containing:
1518
+ * - nonce
1519
+ * - optional version
1520
+ * - optional maxFee
1521
+ * @returns a confirmation of sending a transaction on the starknet contract
1522
+ */
1523
+ abstract declareContract(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
1524
+ /**
1525
+ * Estimates the fee for a given INVOKE transaction
1526
+ * @deprecated Please use getInvokeEstimateFee or getDeclareEstimateFee instead
1527
+ *
1528
+ * @param invocation the invocation object containing:
1529
+ * - contractAddress - the address of the contract
1530
+ * - entrypoint - the entrypoint of the contract
1531
+ * - calldata - (defaults to []) the calldata
1532
+ * - signature - (defaults to []) the signature
1533
+ * @param blockIdentifier - block identifier
1534
+ * @param details - optional details containing:
1535
+ * - nonce - optional nonce
1536
+ * - version - optional version
1537
+ * @returns the estimated fee
1538
+ */
1539
+ abstract getEstimateFee(invocation: Invocation, details: InvocationsDetailsWithNonce, blockIdentifier: BlockIdentifier): Promise<EstimateFeeResponse>;
1540
+ /**
1541
+ * Estimates the fee for a given INVOKE transaction
1542
+ *
1543
+ * @param invocation the invocation object containing:
1544
+ * - contractAddress - the address of the contract
1545
+ * - entrypoint - the entrypoint of the contract
1546
+ * - calldata - (defaults to []) the calldata
1547
+ * - signature - (defaults to []) the signature
1548
+ * @param blockIdentifier - block identifier
1549
+ * @param details - optional details containing:
1550
+ * - nonce - optional nonce
1551
+ * - version - optional version
1552
+ * @returns the estimated fee
1553
+ */
1554
+ abstract getInvokeEstimateFee(invocation: Invocation, details: InvocationsDetailsWithNonce, blockIdentifier: BlockIdentifier): Promise<EstimateFeeResponse>;
1555
+ /**
1556
+ * Estimates the fee for a given DECLARE transaction
1557
+ *
1558
+ * @param transaction transaction payload to be declared containing:
1559
+ * - compiled contract code
1560
+ * - sender address
1561
+ * - signature - (defaults to []) the signature
1562
+ * @param details - optional details containing:
1563
+ * - nonce
1564
+ * - version - optional version
1565
+ * - optional maxFee
1566
+ * @param blockIdentifier - block identifier
1567
+ * @returns the estimated fee
1568
+ */
1569
+ abstract getDeclareEstimateFee(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier: BlockIdentifier): Promise<EstimateFeeResponse>;
1570
+ /**
1571
+ * Estimates the fee for a given DEPLOY_ACCOUNT transaction
1572
+ *
1573
+ * @param transaction transaction payload to be deployed containing:
1574
+ * - classHash
1575
+ * - constructorCalldata
1576
+ * - addressSalt
1577
+ * - signature - (defaults to []) the signature
1578
+ * @param details - optional details containing:
1579
+ * - nonce
1580
+ * - version - optional version
1581
+ * - optional maxFee
1582
+ * @param blockIdentifier - block identifier
1583
+ * @returns the estimated fee
1584
+ */
1585
+ abstract getDeployAccountEstimateFee(transaction: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier: BlockIdentifier): Promise<EstimateFeeResponse>;
1586
+ /**
1587
+ * Wait for the transaction to be accepted
1588
+ * @param txHash - transaction hash
1589
+ * @param retryInterval - retry interval
1590
+ */
1591
+ abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
1592
+ }
1593
+
1594
+ declare type RpcProviderOptions = {
1595
+ nodeUrl: string;
1596
+ retries?: number;
1597
+ headers?: object;
1598
+ };
1599
+ declare class RpcProvider implements ProviderInterface {
1600
+ nodeUrl: string;
1601
+ chainId: StarknetChainId;
1602
+ headers: object;
1603
+ private responseParser;
1604
+ private retries;
1605
+ constructor(optionsOrProvider: RpcProviderOptions);
1606
+ fetch(method: any, params: any): Promise<any>;
1607
+ protected errorHandler(error: any): void;
1608
+ protected fetchEndpoint<T extends keyof RPC.Methods>(method: T, params?: RPC.Methods[T]['params']): Promise<RPC.Methods[T]['result']>;
1609
+ getChainId(): Promise<any>;
1610
+ getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
1611
+ getBlockHashAndNumber(): Promise<RPC.BlockHashAndNumber>;
1612
+ getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxHashesResponse>;
1613
+ getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxs>;
1614
+ getClassHashAt(contractAddress: RPC.ContractAddress, blockIdentifier?: BlockIdentifier): Promise<RPC.Felt>;
1615
+ getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.Nonce>;
1616
+ getPendingTransactions(): Promise<RPC.PendingTransactions>;
1617
+ getProtocolVersion(): Promise<Error>;
1618
+ getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<RPC.StateUpdate>;
1619
+ getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1620
+ getTransaction(txHash: string): Promise<GetTransactionResponse>;
1621
+ getTransactionByHash(txHash: string): Promise<RPC.GetTransactionByHashResponse>;
1622
+ getTransactionByBlockIdAndIndex(blockIdentifier: BlockIdentifier, index: number): Promise<RPC.GetTransactionByBlockIdAndIndex>;
1623
+ getTransactionReceipt(txHash: string): Promise<RPC.TransactionReceipt>;
1624
+ getClassByHash(classHash: RPC.Felt): Promise<RPC.ContractClass>;
1625
+ getClass(classHash: RPC.Felt, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
1626
+ getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
1627
+ getCode(_contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
1628
+ getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1629
+ getInvokeEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1630
+ getDeclareEstimateFee({ senderAddress, contractDefinition, signature }: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1631
+ getDeployAccountEstimateFee({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1632
+ declareContract({ contractDefinition, signature, senderAddress }: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
1633
+ /**
1634
+ * @deprecated This method won't be supported, use Account.deploy instead
1635
+ */
1636
+ deployContract({ contract, constructorCalldata, addressSalt }: DeployContractPayload, details?: InvocationsDetails): Promise<DeployContractResponse>;
1637
+ deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
1638
+ invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
1639
+ callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
1640
+ traceTransaction(transactionHash: RPC.TransactionHash): Promise<RPC.Trace>;
1641
+ traceBlockTransactions(blockHash: RPC.BlockHash): Promise<RPC.Traces>;
1642
+ waitForTransaction(txHash: string, retryInterval?: number): Promise<void>;
1643
+ /**
1644
+ * Gets the transaction count from a block.
1645
+ *
1646
+ *
1647
+ * @param blockIdentifier
1648
+ * @returns Number of transactions
1649
+ */
1650
+ getTransactionCount(blockIdentifier?: BlockIdentifier): Promise<RPC.GetTransactionCountResponse>;
1651
+ /**
1652
+ * Gets the latest block number
1653
+ *
1654
+ *
1655
+ * @returns Number of the latest block
1656
+ */
1657
+ getBlockNumber(): Promise<RPC.GetBlockNumberResponse>;
1658
+ /**
1659
+ * Gets syncing status of the node
1660
+ *
1661
+ *
1662
+ * @returns Object with the stats data
1663
+ */
1664
+ getSyncingStats(): Promise<RPC.GetSyncingStatsResponse>;
1665
+ /**
1666
+ * Gets all the events filtered
1667
+ *
1668
+ *
1669
+ * @returns events and the pagination of the events
1670
+ */
1671
+ getEvents(eventFilter: RPC.EventFilter): Promise<RPC.GetEventsResponse>;
1672
+ }
1673
+
1674
+ declare type NetworkName = 'mainnet-alpha' | 'goerli-alpha' | 'goerli-alpha-2';
1675
+ declare type SequencerProviderOptions = {
1676
+ network: NetworkName;
1677
+ } | {
1678
+ baseUrl: string;
1679
+ feederGatewayUrl?: string;
1680
+ gatewayUrl?: string;
1681
+ chainId?: StarknetChainId;
1682
+ headers?: object;
1683
+ };
1684
+ declare class SequencerProvider implements ProviderInterface {
1685
+ baseUrl: string;
1686
+ feederGatewayUrl: string;
1687
+ gatewayUrl: string;
1688
+ chainId: StarknetChainId;
1689
+ headers: object | undefined;
1690
+ private responseParser;
1691
+ constructor(optionsOrProvider?: SequencerProviderOptions);
1692
+ protected static getNetworkFromName(name: NetworkName): "https://alpha-mainnet.starknet.io" | "https://alpha4.starknet.io" | "https://alpha4-2.starknet.io";
1693
+ protected static getChainIdFromBaseUrl(baseUrl: string): StarknetChainId;
1694
+ private getFetchUrl;
1695
+ private getFetchMethod;
1696
+ private getQueryString;
1697
+ private getHeaders;
1698
+ protected fetchEndpoint<T extends keyof Sequencer.Endpoints>(endpoint: T, ...[query, request]: Sequencer.Endpoints[T]['QUERY'] extends never ? Sequencer.Endpoints[T]['REQUEST'] extends never ? [] : [undefined, Sequencer.Endpoints[T]['REQUEST']] : Sequencer.Endpoints[T]['REQUEST'] extends never ? [Sequencer.Endpoints[T]['QUERY']] : [Sequencer.Endpoints[T]['QUERY'], Sequencer.Endpoints[T]['REQUEST']]): Promise<Sequencer.Endpoints[T]['RESPONSE']>;
1699
+ getChainId(): Promise<StarknetChainId>;
1700
+ callContract({ contractAddress, entrypoint: entryPointSelector, calldata }: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
1701
+ getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
1702
+ getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1703
+ getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1704
+ getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
1705
+ getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
1706
+ getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
1707
+ getClassHashAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<string>;
1708
+ getClassByHash(classHash: string): Promise<ContractClass>;
1709
+ invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
1710
+ /**
1711
+ * @deprecated This method won't be supported, use Account.deploy instead
1712
+ */
1713
+ deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
1714
+ deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
1715
+ declareContract({ senderAddress, contractDefinition, signature }: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
1716
+ getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1717
+ getInvokeEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1718
+ getDeclareEstimateFee({ senderAddress, contractDefinition, signature }: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1719
+ getDeployAccountEstimateFee({ classHash, addressSalt, constructorCalldata, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1720
+ getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<Sequencer.GetCodeResponse>;
1721
+ waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
1722
+ /**
1723
+ * Gets the status of a transaction.
1724
+ *
1725
+ * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
1726
+ *
1727
+ * @param txHash
1728
+ * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
1729
+ */
1730
+ getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
1731
+ /**
1732
+ * Gets the smart contract address on the goerli testnet.
1733
+ *
1734
+ * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L13-L15)
1735
+ * @returns starknet smart contract addresses
1736
+ */
1737
+ getContractAddresses(): Promise<GetContractAddressesResponse>;
1738
+ /**
1739
+ * Gets the transaction trace from a tx id.
1740
+ *
1741
+ *
1742
+ * @param txHash
1743
+ * @returns the transaction trace
1744
+ */
1745
+ getTransactionTrace(txHash: BigNumberish): Promise<GetTransactionTraceResponse>;
1746
+ estimateMessageFee({ from_address, to_address, entry_point_selector, payload }: CallL1Handler, blockIdentifier?: BlockIdentifier): Promise<Sequencer.EstimateFeeResponse>;
1747
+ }
1748
+
1749
+ interface ProviderOptions {
1750
+ sequencer?: SequencerProviderOptions;
1751
+ rpc?: RpcProviderOptions;
1752
+ }
1753
+ declare class Provider implements ProviderInterface {
1754
+ private provider;
1755
+ constructor(providerOrOptions?: ProviderOptions | ProviderInterface);
1756
+ get chainId(): StarknetChainId;
1757
+ getChainId(): Promise<StarknetChainId>;
1758
+ getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
1759
+ getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
1760
+ getClassHashAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<string>;
1761
+ getClassByHash(classHash: string): Promise<ContractClass>;
1762
+ getEstimateFee(invocationWithTxType: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1763
+ getInvokeEstimateFee(invocationWithTxType: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1764
+ getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1765
+ getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1766
+ getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
1767
+ getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
1768
+ callContract(request: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
1769
+ invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
1770
+ /**
1771
+ * @deprecated This method won't be supported, use Account.deploy instead
1772
+ */
1773
+ deployContract(payload: DeployContractPayload, details: InvocationsDetails): Promise<DeployContractResponse>;
1774
+ deployAccountContract(payload: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
1775
+ declareContract(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
1776
+ getDeclareEstimateFee(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1777
+ getDeployAccountEstimateFee(transaction: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1778
+ getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
1779
+ waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
1780
+ }
1781
+
1782
+ declare class GatewayError extends CustomError {
1783
+ errorCode: string;
1784
+ constructor(message: string, errorCode: string);
1785
+ }
1786
+ declare class HttpError extends CustomError {
1787
+ errorCode: number;
1788
+ constructor(message: string, errorCode: number);
1789
+ }
1790
+
1791
+ declare const defaultProvider: Provider;
1792
+
1793
+ declare type StarkNetMerkleType = {
1794
+ name: string;
1795
+ type: 'merkletree';
1796
+ contains: string;
1797
+ };
1798
+ /**
1799
+ * A single type, as part of a struct. The `type` field can be any of the EIP-712 supported types.
1800
+ *
1801
+ * Note that the `uint` and `int` aliases like in Solidity, and fixed point numbers are not supported by the EIP-712
1802
+ * standard.
1803
+ */
1804
+ declare type StarkNetType = {
1805
+ name: string;
1806
+ type: string;
1807
+ } | StarkNetMerkleType;
1808
+ /**
1809
+ * The EIP712 domain struct. Any of these fields are optional, but it must contain at least one field.
1810
+ */
1811
+ interface StarkNetDomain extends Record<string, unknown> {
1812
+ name?: string;
1813
+ version?: string;
1814
+ chainId?: string | number;
1815
+ }
1816
+ /**
1817
+ * The complete typed data, with all the structs, domain data, primary type of the message, and the message itself.
1818
+ */
1819
+ interface TypedData {
1820
+ types: Record<string, StarkNetType[]>;
1821
+ primaryType: string;
1822
+ domain: StarkNetDomain;
1823
+ message: Record<string, unknown>;
1824
+ }
1825
+
1826
+ declare function prepareSelector(selector: string): string;
1827
+ declare function isMerkleTreeType(type: StarkNetType): type is StarkNetMerkleType;
1828
+ interface Context {
1829
+ parent?: string;
1830
+ key?: string;
1831
+ }
1832
+ /**
1833
+ * Get the dependencies of a struct type. If a struct has the same dependency multiple times, it's only included once
1834
+ * in the resulting array.
1835
+ *
1836
+ * @param {TypedData} typedData
1837
+ * @param {string} type
1838
+ * @param {string[]} [dependencies]
1839
+ * @return {string[]}
1840
+ */
1841
+ declare const getDependencies: (types: TypedData['types'], type: string, dependencies?: string[]) => string[];
1842
+ /**
1843
+ * Encode a type to a string. All dependant types are alphabetically sorted.
1844
+ *
1845
+ * @param {TypedData} typedData
1846
+ * @param {string} type
1847
+ * @return {string}
1848
+ */
1849
+ declare const encodeType: (types: TypedData['types'], type: string) => string;
1850
+ /**
1851
+ * Get a type string as hash.
1852
+ *
1853
+ * @param {TypedData} typedData
1854
+ * @param {string} type
1855
+ * @return {string}
1856
+ */
1857
+ declare const getTypeHash: (types: TypedData['types'], type: string) => string;
1858
+ /**
1859
+ * Encodes a single value to an ABI serialisable string, number or Buffer. Returns the data as tuple, which consists of
1860
+ * an array of ABI compatible types, and an array of corresponding values.
1861
+ *
1862
+ * @param {TypedData} typedData
1863
+ * @param {string} type
1864
+ * @param {any} data
1865
+ * @returns {[string, string]}
1866
+ */
1867
+ declare const encodeValue: (types: TypedData['types'], type: string, data: unknown, ctx?: Context) => [string, string];
1868
+ /**
1869
+ * Encode the data to an ABI encoded Buffer. The data should be a key -> value object with all the required values. All
1870
+ * dependant types are automatically encoded.
1871
+ *
1872
+ * @param {TypedData} typedData
1873
+ * @param {string} type
1874
+ * @param {Record<string, any>} data
1875
+ */
1876
+ declare const encodeData: <T extends TypedData>(types: T["types"], type: string, data: T["message"]) => string[][];
1877
+ /**
1878
+ * Get encoded data as a hash. The data should be a key -> value object with all the required values. All dependant
1879
+ * types are automatically encoded.
1880
+ *
1881
+ * @param {TypedData} typedData
1882
+ * @param {string} type
1883
+ * @param {Record<string, any>} data
1884
+ * @return {Buffer}
1885
+ */
1886
+ declare const getStructHash: <T extends TypedData>(types: T["types"], type: string, data: T["message"]) => string;
1887
+ /**
1888
+ * Get the EIP-191 encoded message to sign, from the typedData object.
1889
+ *
1890
+ * @param {TypedData} typedData
1891
+ * @param {BigNumberish} account
1892
+ * @return {string}
1893
+ */
1894
+ declare const getMessageHash: (typedData: TypedData, account: BigNumberish) => string;
1895
+
1896
+ declare const index_prepareSelector: typeof prepareSelector;
1897
+ declare const index_isMerkleTreeType: typeof isMerkleTreeType;
1898
+ declare const index_getDependencies: typeof getDependencies;
1899
+ declare const index_encodeType: typeof encodeType;
1900
+ declare const index_getTypeHash: typeof getTypeHash;
1901
+ declare const index_encodeValue: typeof encodeValue;
1902
+ declare const index_encodeData: typeof encodeData;
1903
+ declare const index_getStructHash: typeof getStructHash;
1904
+ declare const index_getMessageHash: typeof getMessageHash;
1905
+ type index_StarkNetMerkleType = StarkNetMerkleType;
1906
+ type index_StarkNetType = StarkNetType;
1907
+ type index_StarkNetDomain = StarkNetDomain;
1908
+ type index_TypedData = TypedData;
1909
+ declare namespace index {
1910
+ export {
1911
+ index_prepareSelector as prepareSelector,
1912
+ index_isMerkleTreeType as isMerkleTreeType,
1913
+ index_getDependencies as getDependencies,
1914
+ index_encodeType as encodeType,
1915
+ index_getTypeHash as getTypeHash,
1916
+ index_encodeValue as encodeValue,
1917
+ index_encodeData as encodeData,
1918
+ index_getStructHash as getStructHash,
1919
+ index_getMessageHash as getMessageHash,
1920
+ index_StarkNetMerkleType as StarkNetMerkleType,
1921
+ index_StarkNetType as StarkNetType,
1922
+ index_StarkNetDomain as StarkNetDomain,
1923
+ index_TypedData as TypedData,
1924
+ };
1925
+ }
1926
+
1927
+ declare abstract class SignerInterface {
1928
+ /**
1929
+ * Method to get the public key of the signer
1930
+ *
1931
+ * @returns public key of signer as hex string with 0x prefix
1932
+ */
1933
+ abstract getPubKey(): Promise<string>;
1934
+ /**
1935
+ * Sign an JSON object for off-chain usage with the starknet private key and return the signature
1936
+ * This adds a message prefix so it cant be interchanged with transactions
1937
+ *
1938
+ * @param typedData - JSON object to be signed
1939
+ * @param accountAddress - account
1940
+ * @returns the signature of the JSON object
1941
+ * @throws {Error} if the JSON object is not a valid JSON
1942
+ */
1943
+ abstract signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
1944
+ /**
1945
+ * Signs a transaction with the starknet private key and returns the signature
1946
+ *
1947
+ * @param invocation the invocation object containing:
1948
+ * - contractAddress - the address of the contract
1949
+ * - entrypoint - the entrypoint of the contract
1950
+ * - calldata - (defaults to []) the calldata
1951
+ * @param abi (optional) the abi of the contract for better displaying
1952
+ *
1953
+ * @returns signature
1954
+ */
1955
+ abstract signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
1956
+ /**
1957
+ * Signs a DEPLOY_ACCOUNT transaction with the starknet private key and returns the signature
1958
+ *
1959
+ * @param transaction
1960
+ * - contractAddress - the computed address of the contract
1961
+ * - constructorCalldata - calldata to be passed in deploy constructor
1962
+ * - addressSalt - contract address salt
1963
+ * - chainId - the chainId to declare contract on
1964
+ * - maxFee - maxFee for the declare transaction
1965
+ * - version - transaction version
1966
+ * - nonce - Nonce of the declare transaction
1967
+ * @returns signature
1968
+ */
1969
+ abstract signDeployAccountTransaction(transaction: DeployAccountSignerDetails): Promise<Signature>;
1970
+ /**
1971
+ * Signs a DECLARE transaction with the starknet private key and returns the signature
1972
+ *
1973
+ * @param transaction
1974
+ * - classHash - computed class hash. Will be replaced by ContractClass in future once class hash is present in CompiledContract
1975
+ * - senderAddress - the address of the sender
1976
+ * - chainId - the chainId to declare contract on
1977
+ * - maxFee - maxFee for the declare transaction
1978
+ * - version - transaction version
1979
+ * - nonce - Nonce of the declare transaction
1980
+ * @returns signature
1981
+ */
1982
+ abstract signDeclareTransaction(transaction: DeclareSignerDetails): Promise<Signature>;
1983
+ }
1984
+
1985
+ declare class Signer implements SignerInterface {
1986
+ protected keyPair: KeyPair;
1987
+ constructor(keyPair?: KeyPair);
1988
+ getPubKey(): Promise<string>;
1989
+ signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
1990
+ signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
1991
+ signDeployAccountTransaction({ classHash, contractAddress, constructorCalldata, addressSalt, maxFee, version, chainId, nonce, }: DeployAccountSignerDetails): Promise<Signature>;
1992
+ signDeclareTransaction({ classHash, senderAddress, chainId, maxFee, version, nonce }: DeclareSignerDetails): Promise<Signature>;
1993
+ }
1994
+
1995
+ declare abstract class AccountInterface extends ProviderInterface {
1996
+ abstract address: string;
1997
+ abstract signer: SignerInterface;
1998
+ /**
1999
+ * @deprecated Use estimateInvokeFee or estimateDeclareFee instead
2000
+ * Estimate Fee for executing an INVOKE transaction on starknet
2001
+ *
2002
+ * @param calls the invocation object containing:
2003
+ * - contractAddress - the address of the contract
2004
+ * - entrypoint - the entrypoint of the contract
2005
+ * - calldata - (defaults to []) the calldata
2006
+ *
2007
+ * @returns response from estimate_fee
2008
+ */
2009
+ abstract estimateFee(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
2010
+ /**
2011
+ * Estimate Fee for executing an INVOKE transaction on starknet
2012
+ *
2013
+ * @param calls the invocation object containing:
2014
+ * - contractAddress - the address of the contract
2015
+ * - entrypoint - the entrypoint of the contract
2016
+ * - calldata - (defaults to []) the calldata
2017
+ *
2018
+ * @returns response from estimate_fee
2019
+ */
2020
+ abstract estimateInvokeFee(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
2021
+ /**
2022
+ * Estimate Fee for executing a DECLARE transaction on starknet
2023
+ *
2024
+ * @param contractPayload the payload object containing:
2025
+ * - contract - the compiled contract to be declared
2026
+ * - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli.
2027
+ *
2028
+ * @returns response from estimate_fee
2029
+ */
2030
+ abstract estimateDeclareFee(contractPayload: DeclareContractPayload, estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
2031
+ /**
2032
+ * Estimate Fee for executing a DEPLOY_ACCOUNT transaction on starknet
2033
+ *
2034
+ * @param contractPayload the payload object containing:
2035
+ * - contract - the compiled contract to be deployed
2036
+ * - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli.
2037
+ *
2038
+ * @returns response from estimate_fee
2039
+ */
2040
+ abstract estimateAccountDeployFee(contractPayload: DeployAccountContractPayload, estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
2041
+ /**
2042
+ * Estimate Fee for executing a UDC DEPLOY transaction on starknet
2043
+ * This is different from the normal DEPLOY transaction as it goes through the Universal Deployer Contract (UDC)
2044
+
2045
+ * @param deployContractPayload containing
2046
+ * - classHash: computed class hash of compiled contract
2047
+ * - salt: address salt
2048
+ * - unique: bool if true ensure unique salt
2049
+ * - calldata: constructor calldata
2050
+ * - additionalCalls - optional additional calls array to support multicall
2051
+ *
2052
+ * @param transactionsDetail Invocation Details containing:
2053
+ * - optional nonce
2054
+ * - optional version
2055
+ * - optional maxFee
2056
+ */
2057
+ abstract estimateDeployFee(deployContractPayload: UniversalDeployerContractPayload, transactionsDetail?: InvocationsDetails): Promise<EstimateFeeResponse>;
2058
+ /**
2059
+ * Invoke execute function in account contract
2060
+ *
2061
+ * @param transactions the invocation object or an array of them, containing:
2062
+ * - contractAddress - the address of the contract
2063
+ * - entrypoint - the entrypoint of the contract
2064
+ * - calldata - (defaults to []) the calldata
2065
+ * - signature - (defaults to []) the signature
2066
+ * @param abi (optional) the abi of the contract for better displaying
2067
+ *
2068
+ * @returns response from addTransaction
2069
+ */
2070
+ abstract execute(transactions: AllowArray<Call>, abis?: Abi[], transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
2071
+ /**
2072
+ * Declares a given compiled contract (json) to starknet
2073
+ *
2074
+ * @param contractPayload transaction payload to be deployed containing:
2075
+ - contract: compiled contract code
2076
+ - classHash: computed class hash of compiled contract
2077
+ - signature
2078
+ * @param transactionsDetail Invocation Details containing:
2079
+ - optional nonce
2080
+ - optional version
2081
+ - optional maxFee
2082
+ * @returns a confirmation of sending a transaction on the starknet contract
2083
+ */
2084
+ abstract declare(contractPayload: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
2085
+ /**
2086
+ * Deploys a given compiled contract (json) to starknet using Universal Deployer Contract (UDC)
2087
+ * This is different from the normal DEPLOY transaction as it goes through the Universal Deployer Contract (UDC)
2088
+ *
2089
+ * @param deployContractPayload containing
2090
+ * - classHash: computed class hash of compiled contract
2091
+ * - salt: address salt
2092
+ * - unique: bool if true ensure unique salt
2093
+ * - calldata: constructor calldata
2094
+ * - additionalCalls - optional additional calls array to support multicall
2095
+ * @param transactionsDetail Invocation Details containing:
2096
+ * - optional nonce
2097
+ * - optional version
2098
+ * - optional maxFee
2099
+ */
2100
+ abstract deploy(deployContractPayload: UniversalDeployerContractPayload, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
2101
+ /**
2102
+ * Deploy the account on Starknet
2103
+ *
2104
+ * @param contractPayload transaction payload to be deployed containing:
2105
+ - classHash: computed class hash of compiled contract
2106
+ - optional constructor calldata
2107
+ - optional address salt
2108
+ - optional contractAddress
2109
+ * @param transactionsDetail Invocation Details containing:
2110
+ - optional nonce
2111
+ - optional version
2112
+ - optional maxFee
2113
+ * @returns a confirmation of sending a transaction on the starknet contract
2114
+ */
2115
+ abstract deployAccount(contractPayload: DeployAccountContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeployContractResponse>;
2116
+ /**
2117
+ * Sign an JSON object for off-chain usage with the starknet private key and return the signature
2118
+ * This adds a message prefix so it cant be interchanged with transactions
2119
+ *
2120
+ * @param json - JSON object to be signed
2121
+ * @returns the signature of the JSON object
2122
+ * @throws {Error} if the JSON object is not a valid JSON
2123
+ */
2124
+ abstract signMessage(typedData: TypedData): Promise<Signature>;
2125
+ /**
2126
+ * Hash a JSON object with pederson hash and return the hash
2127
+ * This adds a message prefix so it cant be interchanged with transactions
2128
+ *
2129
+ * @param json - JSON object to be hashed
2130
+ * @returns the hash of the JSON object
2131
+ * @throws {Error} if the JSON object is not a valid JSON
2132
+ */
2133
+ abstract hashMessage(typedData: TypedData): Promise<string>;
2134
+ /**
2135
+ * Verify a signature of a JSON object
2136
+ *
2137
+ * @param typedData - JSON object to be verified
2138
+ * @param signature - signature of the JSON object
2139
+ * @returns true if the signature is valid, false otherwise
2140
+ * @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
2141
+ */
2142
+ abstract verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
2143
+ /**
2144
+ * Verify a signature of a given hash
2145
+ * @warning This method is not recommended, use verifyMessage instead
2146
+ *
2147
+ * @param hash - hash to be verified
2148
+ * @param signature - signature of the hash
2149
+ * @returns true if the signature is valid, false otherwise
2150
+ * @throws {Error} if the signature is not a valid signature
2151
+ */
2152
+ abstract verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
2153
+ /**
2154
+ * Gets the nonce of the account with respect to a specific block
2155
+ *
2156
+ * @param {BlockIdentifier} blockIdentifier - optional blockIdentifier. Defaults to 'pending'
2157
+ * @returns nonce of the account
2158
+ */
2159
+ abstract getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
2160
+ /**
2161
+ * Gets Suggested Max Fee based on the transaction type
2162
+ *
2163
+ * @param {EstimateFeeAction} estimateFeeAction
2164
+ * @param {EstimateFeeDetails} details
2165
+ * @returns suggestedMaxFee
2166
+ */
2167
+ abstract getSuggestedMaxFee(estimateFeeAction: EstimateFeeAction, details: EstimateFeeDetails): Promise<BigNumberish>;
2168
+ }
2169
+
2170
+ declare class Account extends Provider implements AccountInterface {
2171
+ signer: SignerInterface;
2172
+ address: string;
2173
+ constructor(providerOrOptions: ProviderOptions | ProviderInterface, address: string, keyPairOrSigner: KeyPair | SignerInterface);
2174
+ getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
2175
+ estimateFee(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails | undefined): Promise<EstimateFee>;
2176
+ estimateInvokeFee(calls: AllowArray<Call>, { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<EstimateFee>;
2177
+ estimateDeclareFee({ classHash, contract }: DeclareContractPayload, { blockIdentifier, nonce: providedNonce }?: EstimateFeeDetails): Promise<EstimateFee>;
2178
+ estimateAccountDeployFee({ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress, }: DeployAccountContractPayload, { blockIdentifier, nonce: providedNonce }?: EstimateFeeDetails): Promise<EstimateFee>;
2179
+ estimateDeployFee({ classHash, salt, unique, constructorCalldata, additionalCalls, }: UniversalDeployerContractPayload, transactionsDetail?: InvocationsDetails | undefined): Promise<EstimateFee>;
2180
+ execute(calls: AllowArray<Call>, abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
2181
+ declare({ classHash, contract }: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
2182
+ deploy({ classHash, salt, unique, constructorCalldata, additionalCalls, }: UniversalDeployerContractPayload, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
2183
+ deployAccount({ classHash, constructorCalldata, addressSalt, contractAddress: providedContractAddress, }: DeployAccountContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeployContractResponse>;
2184
+ signMessage(typedData: TypedData): Promise<Signature>;
2185
+ hashMessage(typedData: TypedData): Promise<string>;
2186
+ verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
2187
+ verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
2188
+ getSuggestedMaxFee({ type, payload }: EstimateFeeAction, details: EstimateFeeDetails): Promise<string>;
2189
+ }
2190
+
2191
+ declare abstract class ContractInterface {
2192
+ abstract abi: Abi;
2193
+ abstract address: string;
2194
+ abstract providerOrAccount: ProviderInterface | AccountInterface;
2195
+ abstract deployTransactionHash?: string;
2196
+ readonly functions: {
2197
+ [name: string]: AsyncContractFunction;
2198
+ };
2199
+ readonly callStatic: {
2200
+ [name: string]: AsyncContractFunction;
2201
+ };
2202
+ readonly populateTransaction: {
2203
+ [name: string]: ContractFunction;
2204
+ };
2205
+ readonly estimateFee: {
2206
+ [name: string]: ContractFunction;
2207
+ };
2208
+ readonly [key: string]: AsyncContractFunction | any;
2209
+ /**
2210
+ * Saves the address of the contract deployed on network that will be used for interaction
2211
+ *
2212
+ * @param address - address of the contract
2213
+ */
2214
+ abstract attach(address: string): void;
2215
+ /**
2216
+ * Attaches to new Provider or Account
2217
+ *
2218
+ * @param providerOrAccount - new Provider or Account to attach to
2219
+ */
2220
+ abstract connect(providerOrAccount: ProviderInterface | AccountInterface): void;
2221
+ /**
2222
+ * Resolves when contract is deployed on the network or when no deployment transaction is found
2223
+ *
2224
+ * @returns Promise that resolves when contract is deployed on the network or when no deployment transaction is found
2225
+ * @throws When deployment fails
2226
+ */
2227
+ abstract deployed(): Promise<ContractInterface>;
2228
+ /**
2229
+ * Calls a method on a contract
2230
+ *
2231
+ * @param method name of the method
2232
+ * @param args Array of the arguments for the call
2233
+ * @param options optional blockIdentifier
2234
+ * @returns Result of the call as an array with key value pars
2235
+ */
2236
+ abstract call(method: string, args?: Array<any>, options?: {
2237
+ blockIdentifier?: BlockIdentifier;
2238
+ }): Promise<Result>;
2239
+ /**
2240
+ * Invokes a method on a contract
2241
+ *
2242
+ * @param method name of the method
2243
+ * @param args Array of the arguments for the invoke
2244
+ * @param options
2245
+ * @returns Add Transaction Response
2246
+ */
2247
+ abstract invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
2248
+ /**
2249
+ * Estimates a method on a contract
2250
+ *
2251
+ * @param method name of the method
2252
+ * @param args Array of the arguments for the call
2253
+ * @param options optional blockIdentifier
2254
+ */
2255
+ abstract estimate(method: string, args?: Array<any>, options?: {
2256
+ blockIdentifier?: BlockIdentifier;
2257
+ }): Promise<any>;
2258
+ /**
2259
+ * Calls a method on a contract
2260
+ *
2261
+ * @param method name of the method
2262
+ * @param args Array of the arguments for the call
2263
+ * @returns Invocation object
2264
+ */
2265
+ abstract populate(method: string, args?: Array<any>): Invocation;
2266
+ }
2267
+
2268
+ declare class Contract implements ContractInterface {
2269
+ abi: Abi;
2270
+ address: string;
2271
+ providerOrAccount: ProviderInterface | AccountInterface;
2272
+ deployTransactionHash?: string;
2273
+ protected readonly structs: {
2274
+ [name: string]: StructAbi;
2275
+ };
2276
+ readonly functions: {
2277
+ [name: string]: AsyncContractFunction;
2278
+ };
2279
+ readonly callStatic: {
2280
+ [name: string]: AsyncContractFunction;
2281
+ };
2282
+ readonly populateTransaction: {
2283
+ [name: string]: ContractFunction;
2284
+ };
2285
+ readonly estimateFee: {
2286
+ [name: string]: ContractFunction;
2287
+ };
2288
+ readonly [key: string]: AsyncContractFunction | any;
2289
+ /**
2290
+ * Contract class to handle contract methods
2291
+ *
2292
+ * @param abi - Abi of the contract object
2293
+ * @param address (optional) - address to connect to
2294
+ * @param providerOrAccount (optional) - Provider or Account to attach to
2295
+ */
2296
+ constructor(abi: Abi, address: string, providerOrAccount?: ProviderInterface | AccountInterface);
2297
+ attach(address: string): void;
2298
+ connect(providerOrAccount: ProviderInterface | AccountInterface): void;
2299
+ deployed(): Promise<Contract>;
2300
+ call(method: string, args?: Array<any>, { blockIdentifier, }?: {
2301
+ blockIdentifier?: BlockIdentifier;
2302
+ }): Promise<Result>;
2303
+ invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
2304
+ estimate(method: string, args?: Array<any>): Promise<EstimateFeeResponse>;
2305
+ populate(method: string, args?: Array<any>): Call;
2306
+ /**
2307
+ * Deep parse of the object that has been passed to the method
2308
+ *
2309
+ * @param struct - struct that needs to be calculated
2310
+ * @return {number} - number of members for the given struct
2311
+ */
2312
+ private calculateStructMembers;
2313
+ /**
2314
+ * Validates if all arguments that are passed to the method are corresponding to the ones in the abi
2315
+ *
2316
+ * @param type - type of the method
2317
+ * @param method - name of the method
2318
+ * @param args - arguments that are passed to the method
2319
+ */
2320
+ protected validateMethodAndArgs(type: 'INVOKE' | 'CALL', method: string, args?: Array<any>): void;
2321
+ /**
2322
+ * Deep parse of the object that has been passed to the method
2323
+ *
2324
+ * @param element - element that needs to be parsed
2325
+ * @param type - name of the method
2326
+ * @return {string | string[]} - parsed arguments in format that contract is expecting
2327
+ */
2328
+ protected parseCalldataValue(element: ParsedStruct | BigNumberish | BigNumberish[], type: string): string | string[];
2329
+ /**
2330
+ * Parse of the response elements that are converted to Object (Struct) by using the abi
2331
+ *
2332
+ * @param responseIterator - iterator of the response
2333
+ * @param type - type of the struct
2334
+ * @return {BigNumberish | ParsedStruct} - parsed arguments in format that contract is expecting
2335
+ */
2336
+ protected parseResponseStruct(responseIterator: Iterator<string>, type: string): BigNumberish | ParsedStruct;
2337
+ /**
2338
+ * Parse one field of the calldata by using input field from the abi for that method
2339
+ *
2340
+ * @param args - value of the field
2341
+ * @param input - input(field) information from the abi that will be used to parse the data
2342
+ * @return {string | string[]} - parsed arguments in format that contract is expecting
2343
+ */
2344
+ protected parseCalldataField(argsIterator: Iterator<any>, input: AbiEntry): string | string[];
2345
+ /**
2346
+ * Parse the calldata by using input fields from the abi for that method
2347
+ *
2348
+ * @param args - arguments passed the the method
2349
+ * @param inputs - list of inputs(fields) that are in the abi
2350
+ * @return {Calldata} - parsed arguments in format that contract is expecting
2351
+ */
2352
+ protected compileCalldata(args: Array<any>, inputs: AbiEntry[]): Calldata;
2353
+ /**
2354
+ * Parse elements of the response and structuring them into one field by using output property from the abi for that method
2355
+ *
2356
+ * @param responseIterator - iterator of the response
2357
+ * @param output - output(field) information from the abi that will be used to parse the data
2358
+ * @return - parsed response corresponding to the abi structure of the field
2359
+ */
2360
+ protected parseResponseField(responseIterator: Iterator<string>, output: AbiEntry, parsedResult?: Args): any;
2361
+ /**
2362
+ * Parse elements of the response array and structuring them into response object
2363
+ *
2364
+ * @param method - method name
2365
+ * @param response - response from the method
2366
+ * @return - parsed response corresponding to the abi
2367
+ */
2368
+ protected parseResponse(method: string, response: string[]): Result;
2369
+ }
2370
+
2371
+ declare class ContractFactory {
2372
+ abi: Abi;
2373
+ compiledContract: CompiledContract;
2374
+ providerOrAccount: ProviderInterface | AccountInterface;
2375
+ constructor(compiledContract: CompiledContract, providerOrAccount?: ProviderInterface | AccountInterface, abi?: Abi);
2376
+ /**
2377
+ * Deploys contract and returns new instance of the Contract
2378
+ *
2379
+ * @param constructorCalldata - Constructor Calldata
2380
+ * @param addressSalt (optional) - Address Salt for deployment
2381
+ * @returns deployed Contract
2382
+ */
2383
+ deploy(constructorCalldata?: RawCalldata, addressSalt?: string | undefined): Promise<Contract>;
2384
+ /**
2385
+ * Attaches to new Provider or Account
2386
+ *
2387
+ * @param providerOrAccount - new Provider or Account to attach to
2388
+ */
2389
+ connect(providerOrAccount: ProviderInterface | AccountInterface): ContractFactory;
2390
+ /**
2391
+ * Attaches current abi and provider or account to the new address
2392
+ *
2393
+ * @param address - Contract address
2394
+ * @returns Contract
2395
+ */
2396
+ attach(address: string): Contract;
2397
+ }
2398
+
2399
+ declare const transactionVersion = 1;
2400
+ declare const feeTransactionVersion: BN__default;
2401
+ declare function keccakBn(value: BigNumberish): string;
2402
+ /**
2403
+ * Function to get the starknet keccak hash from a string
2404
+ *
2405
+ * [Reference](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/public/abi.py#L17-L22)
2406
+ * @param value - string you want to get the starknetKeccak hash from
2407
+ * @returns starknet keccak hash as BigNumber
2408
+ */
2409
+ declare function starknetKeccak(value: string): BN__default;
2410
+ /**
2411
+ * Function to get the hex selector from a given function name
2412
+ *
2413
+ * [Reference](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/public/abi.py#L25-L26)
2414
+ * @param funcName - selectors abi function name
2415
+ * @returns hex selector of given abi function name
2416
+ */
2417
+ declare function getSelectorFromName(funcName: string): string;
2418
+ /**
2419
+ * Function to get hex selector from function name, decimal string or hex string
2420
+ * @param value hex string | decimal string | string
2421
+ * @returns Hex selector
2422
+ */
2423
+ declare function getSelector(value: string): string;
2424
+ declare function pedersen(input: [BigNumberish, BigNumberish]): string;
2425
+ declare function computeHashOnElements(data: BigNumberish[]): string;
2426
+ declare function calculateTransactionHashCommon(txHashPrefix: TransactionHashPrefix, version: BigNumberish, contractAddress: BigNumberish, entryPointSelector: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, additionalData?: BigNumberish[]): string;
2427
+ declare function calculateDeployTransactionHash(contractAddress: BigNumberish, constructorCalldata: BigNumberish[], version: BigNumberish, chainId: StarknetChainId): string;
2428
+ declare function calculateDeclareTransactionHash(classHash: BigNumberish, senderAddress: BigNumberish, version: BigNumberish, maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
2429
+ declare function calculateDeployAccountTransactionHash(contractAddress: BigNumberish, classHash: BigNumberish, constructorCalldata: BigNumberish[], salt: BigNumberish, version: BigNumberish, maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
2430
+ declare function calculateTransactionHash(contractAddress: BigNumberish, version: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
2431
+ declare function calculateContractAddressFromHash(salt: BigNumberish, classHash: BigNumberish, constructorCalldata: RawCalldata, deployerAddress: BigNumberish): string;
2432
+
2433
+ declare const hash_transactionVersion: typeof transactionVersion;
2434
+ declare const hash_feeTransactionVersion: typeof feeTransactionVersion;
2435
+ declare const hash_keccakBn: typeof keccakBn;
2436
+ declare const hash_starknetKeccak: typeof starknetKeccak;
2437
+ declare const hash_getSelectorFromName: typeof getSelectorFromName;
2438
+ declare const hash_getSelector: typeof getSelector;
2439
+ declare const hash_pedersen: typeof pedersen;
2440
+ declare const hash_computeHashOnElements: typeof computeHashOnElements;
2441
+ declare const hash_calculateTransactionHashCommon: typeof calculateTransactionHashCommon;
2442
+ declare const hash_calculateDeployTransactionHash: typeof calculateDeployTransactionHash;
2443
+ declare const hash_calculateDeclareTransactionHash: typeof calculateDeclareTransactionHash;
2444
+ declare const hash_calculateDeployAccountTransactionHash: typeof calculateDeployAccountTransactionHash;
2445
+ declare const hash_calculateTransactionHash: typeof calculateTransactionHash;
2446
+ declare const hash_calculateContractAddressFromHash: typeof calculateContractAddressFromHash;
2447
+ declare namespace hash {
2448
+ export {
2449
+ hash_transactionVersion as transactionVersion,
2450
+ hash_feeTransactionVersion as feeTransactionVersion,
2451
+ hash_keccakBn as keccakBn,
2452
+ hash_starknetKeccak as starknetKeccak,
2453
+ hash_getSelectorFromName as getSelectorFromName,
2454
+ hash_getSelector as getSelector,
2455
+ hash_pedersen as pedersen,
2456
+ hash_computeHashOnElements as computeHashOnElements,
2457
+ hash_calculateTransactionHashCommon as calculateTransactionHashCommon,
2458
+ hash_calculateDeployTransactionHash as calculateDeployTransactionHash,
2459
+ hash_calculateDeclareTransactionHash as calculateDeclareTransactionHash,
2460
+ hash_calculateDeployAccountTransactionHash as calculateDeployAccountTransactionHash,
2461
+ hash_calculateTransactionHash as calculateTransactionHash,
2462
+ hash_calculateContractAddressFromHash as calculateContractAddressFromHash,
2463
+ };
2464
+ }
2465
+
2466
+ declare const parse: (text: string, reviver?: ((this: any, key: string, value: any) => any) | undefined) => any;
2467
+ declare const stringify: {
2468
+ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
2469
+ (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
2470
+ };
2471
+ declare const parseAlwaysAsBig: (text: string, reviver?: ((this: any, key: string, value: any) => any) | undefined) => any;
2472
+ declare const stringifyAlwaysAsBig: {
2473
+ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
2474
+ (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
2475
+ };
2476
+ declare const _default: {
2477
+ parse: (text: string, reviver?: ((this: any, key: string, value: any) => any) | undefined) => any;
2478
+ stringify: {
2479
+ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
2480
+ (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
2481
+ };
2482
+ };
2483
+
2484
+ declare const json_parse: typeof parse;
2485
+ declare const json_stringify: typeof stringify;
2486
+ declare const json_parseAlwaysAsBig: typeof parseAlwaysAsBig;
2487
+ declare const json_stringifyAlwaysAsBig: typeof stringifyAlwaysAsBig;
2488
+ declare namespace json {
2489
+ export {
2490
+ _default as default,
2491
+ json_parse as parse,
2492
+ json_stringify as stringify,
2493
+ json_parseAlwaysAsBig as parseAlwaysAsBig,
2494
+ json_stringifyAlwaysAsBig as stringifyAlwaysAsBig,
2495
+ };
2496
+ }
2497
+
2498
+ /**
2499
+ * Transforms a list of Calls, each with their own calldata, into
2500
+ * two arrays: one with the entrypoints, and one with the concatenated calldata.
2501
+ * @param calls
2502
+ * @returns
2503
+ */
2504
+ declare const transformCallsToMulticallArrays: (calls: Call[]) => {
2505
+ callArray: ParsedStruct[];
2506
+ calldata: string[];
2507
+ };
2508
+ /**
2509
+ * Transforms a list of calls in the full flattened calldata expected
2510
+ * by the __execute__ protocol.
2511
+ * @param calls
2512
+ * @returns
2513
+ */
2514
+ declare const fromCallsToExecuteCalldata: (calls: Call[]) => string[];
2515
+ declare const fromCallsToExecuteCalldataWithNonce: (calls: Call[], nonce: BigNumberish) => string[];
2516
+
2517
+ declare const transaction_transformCallsToMulticallArrays: typeof transformCallsToMulticallArrays;
2518
+ declare const transaction_fromCallsToExecuteCalldata: typeof fromCallsToExecuteCalldata;
2519
+ declare const transaction_fromCallsToExecuteCalldataWithNonce: typeof fromCallsToExecuteCalldataWithNonce;
2520
+ declare namespace transaction {
2521
+ export {
2522
+ transaction_transformCallsToMulticallArrays as transformCallsToMulticallArrays,
2523
+ transaction_fromCallsToExecuteCalldata as fromCallsToExecuteCalldata,
2524
+ transaction_fromCallsToExecuteCalldataWithNonce as fromCallsToExecuteCalldataWithNonce,
2525
+ };
2526
+ }
2527
+
2528
+ /**
2529
+ * Function to compress compiled cairo program
2530
+ *
2531
+ * [Reference](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/services/api/gateway/transaction.py#L54-L58)
2532
+ * @param jsonProgram - json file representing the compiled cairo program
2533
+ * @returns Compressed cairo program
2534
+ */
2535
+ declare function compressProgram(jsonProgram: Program | string): CompressedProgram;
2536
+ declare function randomAddress(): string;
2537
+ declare function makeAddress(input: string): string;
2538
+ declare function formatSignature(sig?: Signature): string[];
2539
+ declare function compileCalldata(args: RawArgs$1): Calldata;
2540
+ declare function estimatedFeeToMaxFee(estimatedFee: BigNumberish, overhead?: number): BN__default;
2541
+
2542
+ declare const stark_compressProgram: typeof compressProgram;
2543
+ declare const stark_randomAddress: typeof randomAddress;
2544
+ declare const stark_makeAddress: typeof makeAddress;
2545
+ declare const stark_formatSignature: typeof formatSignature;
2546
+ declare const stark_compileCalldata: typeof compileCalldata;
2547
+ declare const stark_estimatedFeeToMaxFee: typeof estimatedFeeToMaxFee;
2548
+ declare namespace stark {
2549
+ export {
2550
+ stark_compressProgram as compressProgram,
2551
+ stark_randomAddress as randomAddress,
2552
+ stark_makeAddress as makeAddress,
2553
+ stark_formatSignature as formatSignature,
2554
+ stark_compileCalldata as compileCalldata,
2555
+ stark_estimatedFeeToMaxFee as estimatedFeeToMaxFee,
2556
+ };
2557
+ }
2558
+
2559
+ declare class MerkleTree {
2560
+ leaves: string[];
2561
+ branches: string[][];
2562
+ root: string;
2563
+ constructor(leafHashes: string[]);
2564
+ private build;
2565
+ static hash(a: string, b: string): string;
2566
+ getProof(leaf: string, branch?: string[], hashPath?: string[]): string[];
2567
+ }
2568
+ declare function proofMerklePath(root: string, leaf: string, path: string[]): boolean;
2569
+
2570
+ type merkle_MerkleTree = MerkleTree;
2571
+ declare const merkle_MerkleTree: typeof MerkleTree;
2572
+ declare const merkle_proofMerklePath: typeof proofMerklePath;
2573
+ declare namespace merkle {
2574
+ export {
2575
+ merkle_MerkleTree as MerkleTree,
2576
+ merkle_proofMerklePath as proofMerklePath,
2577
+ };
2578
+ }
2579
+
2580
+ declare const ec: elliptic.ec;
2581
+ declare const genKeyPair: (options?: elliptic.ec.GenKeyPairOptions | undefined) => elliptic.ec.KeyPair;
2582
+ declare function getKeyPair(pk: BigNumberish): KeyPair;
2583
+ declare function getStarkKey(keyPair: KeyPair): string;
2584
+ /**
2585
+ * Takes a public key and casts it into `elliptic` KeyPair format.
2586
+ *
2587
+ * @param publicKey - public key which should get casted to a KeyPair
2588
+ * @returns keyPair with public key only, which can be used to verify signatures, but cant sign anything
2589
+ */
2590
+ declare function getKeyPairFromPublicKey(publicKey: BigNumberish): KeyPair;
2591
+ /**
2592
+ * Signs a message using the provided key.
2593
+ *
2594
+ * @param keyPair should be an KeyPair with a valid private key.
2595
+ * @returns an Signature.
2596
+ */
2597
+ declare function sign(keyPair: KeyPair, msgHash: string): Signature;
2598
+ /**
2599
+ * Verifies a message using the provided key.
2600
+ *
2601
+ * @param keyPair should be an KeyPair with a valid public key.
2602
+ * @param sig should be an Signature.
2603
+ * @returns true if the verification succeeds.
2604
+ */
2605
+ declare function verify(keyPair: KeyPair | KeyPair[], msgHash: string, sig: Signature): boolean;
2606
+
2607
+ declare const ellipticCurve_ec: typeof ec;
2608
+ declare const ellipticCurve_genKeyPair: typeof genKeyPair;
2609
+ declare const ellipticCurve_getKeyPair: typeof getKeyPair;
2610
+ declare const ellipticCurve_getStarkKey: typeof getStarkKey;
2611
+ declare const ellipticCurve_getKeyPairFromPublicKey: typeof getKeyPairFromPublicKey;
2612
+ declare const ellipticCurve_sign: typeof sign;
2613
+ declare const ellipticCurve_verify: typeof verify;
2614
+ declare namespace ellipticCurve {
2615
+ export {
2616
+ ellipticCurve_ec as ec,
2617
+ ellipticCurve_genKeyPair as genKeyPair,
2618
+ ellipticCurve_getKeyPair as getKeyPair,
2619
+ ellipticCurve_getStarkKey as getStarkKey,
2620
+ ellipticCurve_getKeyPairFromPublicKey as getKeyPairFromPublicKey,
2621
+ ellipticCurve_sign as sign,
2622
+ ellipticCurve_verify as verify,
2623
+ };
2624
+ }
2625
+
2626
+ interface Uint256 {
2627
+ low: BigNumberish;
2628
+ high: BigNumberish;
2629
+ }
2630
+ declare function uint256ToBN(uint256: Uint256): BN;
2631
+ declare const UINT_128_MAX: BN;
2632
+ declare const UINT_256_MAX: BN;
2633
+ declare function isUint256(bn: BigNumberish): boolean;
2634
+ declare function bnToUint256(bignumber: BigNumberish): Uint256;
2635
+
2636
+ type uint256_Uint256 = Uint256;
2637
+ declare const uint256_uint256ToBN: typeof uint256ToBN;
2638
+ declare const uint256_UINT_128_MAX: typeof UINT_128_MAX;
2639
+ declare const uint256_UINT_256_MAX: typeof UINT_256_MAX;
2640
+ declare const uint256_isUint256: typeof isUint256;
2641
+ declare const uint256_bnToUint256: typeof bnToUint256;
2642
+ declare namespace uint256 {
2643
+ export {
2644
+ uint256_Uint256 as Uint256,
2645
+ uint256_uint256ToBN as uint256ToBN,
2646
+ uint256_UINT_128_MAX as UINT_128_MAX,
2647
+ uint256_UINT_256_MAX as UINT_256_MAX,
2648
+ uint256_isUint256 as isUint256,
2649
+ uint256_bnToUint256 as bnToUint256,
2650
+ };
2651
+ }
2652
+
2653
+ declare function isASCII(str: string): boolean;
2654
+ declare function isShortString(str: string): boolean;
2655
+ declare function encodeShortString(str: string): string;
2656
+ declare function decodeShortString(str: string): string;
2657
+
2658
+ declare const shortString_isASCII: typeof isASCII;
2659
+ declare const shortString_isShortString: typeof isShortString;
2660
+ declare const shortString_encodeShortString: typeof encodeShortString;
2661
+ declare const shortString_decodeShortString: typeof decodeShortString;
2662
+ declare namespace shortString {
2663
+ export {
2664
+ shortString_isASCII as isASCII,
2665
+ shortString_isShortString as isShortString,
2666
+ shortString_encodeShortString as encodeShortString,
2667
+ shortString_decodeShortString as decodeShortString,
2668
+ };
2669
+ }
2670
+
2671
+ declare function addAddressPadding(address: BigNumberish): string;
2672
+ declare function validateAndParseAddress(address: BigNumberish): string;
2673
+ declare function getChecksumAddress(address: BigNumberish): string;
2674
+ declare function validateChecksumAddress(address: string): boolean;
2675
+
2676
+ /**
2677
+ * Loosely validate a URL `string`.
2678
+ * @param {String} s
2679
+ * @return {Boolean}
2680
+ */
2681
+ declare function isUrl(s?: string): boolean;
2682
+ declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
2683
+
2684
+ export { Abi, AbiEntry, Account, AccountInterface, AllowArray, Args, AsyncContractFunction, BlockNumber, BlockTag, Call, CallContractResponse, CallDetails, Calldata, CommonTransactionReceiptResponse, CommonTransactionResponse, CompiledContract, CompressedCompiledContract, CompressedProgram, Contract, ContractClass, ContractEntryPoint, ContractFactory, ContractFunction, ContractInterface, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractPayload, DeployContractResponse, EntryPointType, EntryPointsByType, EstimateFee, EstimateFeeAction, EstimateFeeDetails, EstimateFeeResponse, Event, FunctionAbi, GatewayError, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, HttpError, Invocation, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeTransactionReceiptResponse, InvokeTransactionResponse, KeyPair, MessageToL1, MessageToL2, Overrides, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, RawArgs$1 as RawArgs, RawCalldata, Result, RpcProvider, RpcProviderOptions, SequencerProvider, SequencerProviderOptions, Signature, Signer, SignerInterface, Status, Struct, StructAbi, TransactionStatus, TransactionType, UniversalDeployerContractPayload, addAddressPadding, index$1 as api, buildUrl, constants, defaultProvider, ellipticCurve as ec, encode, getChecksumAddress, hash, isUrl, json, merkle, number, shortString, stark, transaction, index as typedData, uint256, validateAndParseAddress, validateChecksumAddress };