starknet 4.5.0 → 4.7.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.
- package/CHANGELOG.md +40 -0
- package/README.md +3 -1
- package/__tests__/account.test.ts +2 -5
- package/__tests__/contract.test.ts +0 -1
- package/__tests__/defaultProvider.test.ts +16 -10
- package/__tests__/rpcProvider.test.ts +107 -12
- package/__tests__/sequencerProvider.test.ts +10 -8
- package/__tests__/utils/ellipticalCurve.test.ts +7 -8
- package/__tests__/utils/utils.test.ts +17 -0
- package/account/default.d.ts +3 -2
- package/account/default.js +22 -29
- package/account/interface.d.ts +2 -1
- package/contract/contractFactory.d.ts +1 -2
- package/contract/default.d.ts +2 -2
- package/contract/default.js +7 -3
- package/dist/account/default.d.ts +3 -2
- package/dist/account/default.js +22 -29
- package/dist/account/interface.d.ts +2 -1
- package/dist/contract/contractFactory.d.ts +1 -2
- package/dist/contract/default.d.ts +2 -2
- package/dist/contract/default.js +7 -3
- package/dist/provider/default.d.ts +4 -3
- package/dist/provider/default.js +9 -3
- package/dist/provider/interface.d.ts +10 -3
- package/dist/provider/rpc.d.ts +24 -12
- package/dist/provider/rpc.js +167 -105
- package/dist/provider/sequencer.d.ts +4 -3
- package/dist/provider/sequencer.js +16 -7
- package/dist/provider/utils.d.ts +11 -35
- package/dist/provider/utils.js +52 -63
- package/dist/signer/default.d.ts +2 -2
- package/dist/signer/default.js +2 -2
- package/dist/signer/interface.d.ts +2 -2
- package/dist/types/api/openrpc.d.ts +395 -45
- package/dist/types/api/openrpc.js +21 -3
- package/dist/types/api/rpc.d.ts +34 -191
- package/dist/types/api/sequencer.d.ts +15 -4
- package/dist/types/lib.d.ts +10 -4
- package/dist/types/provider.d.ts +3 -2
- package/dist/utils/hash.d.ts +2 -2
- package/dist/utils/hash.js +5 -5
- package/dist/utils/responseParser/rpc.d.ts +6 -6
- package/dist/utils/responseParser/rpc.js +3 -39
- package/package.json +1 -1
- package/provider/default.d.ts +4 -3
- package/provider/default.js +9 -3
- package/provider/interface.d.ts +10 -3
- package/provider/rpc.d.ts +24 -12
- package/provider/rpc.js +167 -105
- package/provider/sequencer.d.ts +4 -3
- package/provider/sequencer.js +16 -7
- package/provider/utils.d.ts +11 -35
- package/provider/utils.js +52 -63
- package/signer/default.d.ts +2 -2
- package/signer/default.js +2 -2
- package/signer/interface.d.ts +2 -2
- package/src/account/default.ts +21 -20
- package/src/account/interface.ts +2 -1
- package/src/contract/contractFactory.ts +1 -2
- package/src/contract/default.ts +16 -8
- package/src/provider/default.ts +12 -5
- package/src/provider/interface.ts +15 -4
- package/src/provider/rpc.ts +152 -102
- package/src/provider/sequencer.ts +19 -10
- package/src/provider/utils.ts +43 -56
- package/src/signer/default.ts +8 -8
- package/src/signer/interface.ts +2 -2
- package/src/types/api/openrpc.ts +378 -53
- package/src/types/api/rpc.ts +33 -211
- package/src/types/api/sequencer.ts +17 -4
- package/src/types/lib.ts +7 -5
- package/src/types/provider.ts +3 -2
- package/src/utils/hash.ts +7 -6
- package/src/utils/responseParser/rpc.ts +13 -27
- package/types/api/openrpc.d.ts +395 -45
- package/types/api/openrpc.js +21 -3
- package/types/api/rpc.d.ts +34 -191
- package/types/api/sequencer.d.ts +15 -4
- package/types/lib.d.ts +10 -4
- package/types/provider.d.ts +3 -2
- package/utils/hash.d.ts +2 -2
- package/utils/hash.js +5 -5
- package/utils/responseParser/rpc.d.ts +6 -6
- package/utils/responseParser/rpc.js +3 -39
- package/www/docs/API/account.md +3 -3
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/provider.md +6 -0
- package/www/docs/API/utils.md +2 -2
package/src/types/api/openrpc.ts
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Starknet RPC version 0.1.0
|
|
3
|
-
* starknet_api_openrpc version 0.31.0
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* StarkNet Node API 0.31.0
|
|
5
|
+
* StarkNet Node Write API 0.3.0
|
|
6
|
+
* StarkNet Trace API 0.3.0
|
|
7
|
+
*
|
|
8
|
+
* TypeScript Representation of OpenRpc protocol types
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* "pattern": "^0x0[a-fA-F0-9]{1,63}$"
|
|
15
|
-
*/
|
|
16
|
-
type FELT = string;
|
|
11
|
+
export type FELT = string;
|
|
12
|
+
export type ADDRESS = FELT;
|
|
13
|
+
type NUM_AS_HEX = string;
|
|
14
|
+
type SIGNATURE = Array<FELT>;
|
|
15
|
+
type ETH_ADDRESS = string;
|
|
17
16
|
type BLOCK_NUMBER = number;
|
|
18
17
|
type BLOCK_HASH = FELT;
|
|
19
18
|
type TXN_HASH = FELT;
|
|
19
|
+
type PROTOCOL_VERSION = string;
|
|
20
20
|
type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
21
21
|
type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'INVOKE' | 'L1_HANDLER';
|
|
22
|
+
type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
23
|
+
enum BLOCK_TAG {
|
|
24
|
+
'latest',
|
|
25
|
+
'pending',
|
|
26
|
+
}
|
|
27
|
+
type BLOCK_ID = { block_hash: BLOCK_HASH } | { block_number: BLOCK_NUMBER } | BLOCK_TAG;
|
|
22
28
|
type MSG_TO_L1 = {
|
|
23
29
|
to_address: FELT;
|
|
24
30
|
payload: Array<FELT>;
|
|
@@ -32,45 +38,33 @@ type COMMON_RECEIPT_PROPERTIES = {
|
|
|
32
38
|
transaction_hash: TXN_HASH;
|
|
33
39
|
actual_fee: FELT;
|
|
34
40
|
status: TXN_STATUS;
|
|
41
|
+
status_data?: string;
|
|
35
42
|
block_hash: BLOCK_HASH;
|
|
36
43
|
block_number: BLOCK_NUMBER;
|
|
37
|
-
|
|
44
|
+
};
|
|
45
|
+
type MSG_TO_L2 = {
|
|
46
|
+
from_address: ETH_ADDRESS;
|
|
47
|
+
payload: FELT;
|
|
38
48
|
};
|
|
39
49
|
type INVOKE_TXN_RECEIPT_PROPERTIES = {
|
|
40
50
|
messages_sent: MSG_TO_L1;
|
|
51
|
+
l1_origin_message?: MSG_TO_L2;
|
|
41
52
|
events: EVENT;
|
|
42
53
|
};
|
|
43
54
|
type PENDING_COMMON_RECEIPT_PROPERTIES = {
|
|
44
55
|
transaction_hash: TXN_HASH;
|
|
45
56
|
actual_fee: FELT;
|
|
46
|
-
type?: TXN_TYPE;
|
|
47
57
|
};
|
|
48
58
|
type INVOKE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
|
|
49
|
-
type L1_HANDLER_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
|
|
50
59
|
type DECLARE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
|
|
51
60
|
type DEPLOY_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
|
|
52
61
|
type PENDING_INVOKE_TXN_RECEIPT = PENDING_COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
|
|
53
62
|
type PENDING_TXN_RECEIPT = PENDING_INVOKE_TXN_RECEIPT | PENDING_COMMON_RECEIPT_PROPERTIES;
|
|
54
63
|
type TXN_RECEIPT =
|
|
55
64
|
| INVOKE_TXN_RECEIPT
|
|
56
|
-
| L1_HANDLER_TXN_RECEIPT
|
|
57
65
|
| DECLARE_TXN_RECEIPT
|
|
58
66
|
| DEPLOY_TXN_RECEIPT
|
|
59
67
|
| PENDING_TXN_RECEIPT;
|
|
60
|
-
|
|
61
|
-
export namespace RPC_1 {
|
|
62
|
-
export type GetTransactionReceiptResponse = TXN_RECEIPT;
|
|
63
|
-
|
|
64
|
-
export type Methods = {
|
|
65
|
-
starknet_getTransactionReceipt: {
|
|
66
|
-
QUERY: never;
|
|
67
|
-
REQUEST: any[];
|
|
68
|
-
RESPONSE: GetTransactionReceiptResponse;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// starknet_getBlockWithTxHashes
|
|
74
68
|
type BLOCK_HEADER = {
|
|
75
69
|
block_hash: BLOCK_HASH;
|
|
76
70
|
parent_hash: BLOCK_HASH;
|
|
@@ -91,28 +85,19 @@ type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
|
|
|
91
85
|
sequencer_address: FELT;
|
|
92
86
|
parent_hash: BLOCK_HASH;
|
|
93
87
|
};
|
|
94
|
-
|
|
95
|
-
// starknet_getBlockWithTx
|
|
96
|
-
type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
97
|
-
/**
|
|
98
|
-
* "title": "An integer number in hex format (0x...)",
|
|
99
|
-
* "pattern": "^0x[a-fA-F0-9]+$"
|
|
100
|
-
*/
|
|
101
|
-
type NUM_AS_HEX = string;
|
|
102
|
-
type SIGNATURE = Array<FELT>;
|
|
88
|
+
// transaction_hash, nonce, type optional because of pathfinder not implemented
|
|
103
89
|
type COMMON_TXN_PROPERTIES = {
|
|
104
|
-
transaction_hash
|
|
90
|
+
transaction_hash?: TXN_HASH;
|
|
105
91
|
max_fee: FELT;
|
|
106
92
|
version: NUM_AS_HEX;
|
|
107
93
|
signature: SIGNATURE;
|
|
108
|
-
nonce
|
|
109
|
-
type
|
|
94
|
+
nonce?: FELT;
|
|
95
|
+
type?: TXN_TYPE;
|
|
110
96
|
};
|
|
111
|
-
type ADDRESS = FELT;
|
|
112
97
|
type FUNCTION_CALL = {
|
|
113
|
-
contract_address
|
|
114
|
-
entry_point_selector
|
|
115
|
-
calldata
|
|
98
|
+
contract_address?: ADDRESS;
|
|
99
|
+
entry_point_selector?: FELT;
|
|
100
|
+
calldata?: Array<FELT>;
|
|
116
101
|
};
|
|
117
102
|
type INVOKE_TXN = COMMON_TXN_PROPERTIES & FUNCTION_CALL;
|
|
118
103
|
type DECLARE_TXN = COMMON_TXN_PROPERTIES & {
|
|
@@ -136,7 +121,6 @@ type BLOCK_WITH_TXS = {
|
|
|
136
121
|
status: BLOCK_STATUS;
|
|
137
122
|
} & BLOCK_HEADER &
|
|
138
123
|
BLOCK_BODY_WITH_TXS;
|
|
139
|
-
|
|
140
124
|
type PENDING_BLOCK_WITH_TXS = BLOCK_BODY_WITH_TXS & {
|
|
141
125
|
timestamp: number;
|
|
142
126
|
sequencer_address: FELT;
|
|
@@ -150,19 +134,360 @@ type CONTRACT_CLASS = {
|
|
|
150
134
|
EXTERNAL: CONTRACT_ENTRY_POINT_LIST;
|
|
151
135
|
L1_HANDLER: CONTRACT_ENTRY_POINT_LIST;
|
|
152
136
|
};
|
|
137
|
+
abi?: any; // Pathfinder exception from rpc 0.1.0
|
|
153
138
|
};
|
|
154
|
-
|
|
155
139
|
type CONTRACT_ENTRY_POINT_LIST = Array<CONTRACT_ENTRY_POINT>;
|
|
156
140
|
type CONTRACT_ENTRY_POINT = {
|
|
157
141
|
offset: NUM_AS_HEX;
|
|
158
142
|
selector: FELT;
|
|
159
143
|
};
|
|
144
|
+
type STORAGE_DIFF_ITEM = {
|
|
145
|
+
address: FELT;
|
|
146
|
+
key: FELT;
|
|
147
|
+
value: FELT;
|
|
148
|
+
};
|
|
149
|
+
type DECLARED_CONTRACT_ITEM = {
|
|
150
|
+
class_hash: FELT;
|
|
151
|
+
};
|
|
152
|
+
type DEPLOYED_CONTRACT_ITEM = {
|
|
153
|
+
address: FELT;
|
|
154
|
+
class_hash: FELT;
|
|
155
|
+
};
|
|
156
|
+
type STATE_UPDATE = {
|
|
157
|
+
block_hash: BLOCK_HASH;
|
|
158
|
+
new_root: FELT;
|
|
159
|
+
old_root: FELT;
|
|
160
|
+
state_diff: {
|
|
161
|
+
storage_diffs: Array<STORAGE_DIFF_ITEM>;
|
|
162
|
+
declared_contracts: Array<DECLARED_CONTRACT_ITEM>;
|
|
163
|
+
deployed_contracts: Array<DEPLOYED_CONTRACT_ITEM>;
|
|
164
|
+
nonces: Array<{
|
|
165
|
+
contract_address: ADDRESS;
|
|
166
|
+
nonce: FELT;
|
|
167
|
+
}>;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
type STORAGE_KEY = string;
|
|
171
|
+
type EVENT_FILTER = {
|
|
172
|
+
from_block?: BLOCK_ID;
|
|
173
|
+
to_block?: BLOCK_ID;
|
|
174
|
+
address?: ADDRESS;
|
|
175
|
+
keys?: Array<FELT>;
|
|
176
|
+
};
|
|
177
|
+
type RESULT_PAGE_REQUEST = {
|
|
178
|
+
page_size: number;
|
|
179
|
+
page_number: number;
|
|
180
|
+
};
|
|
181
|
+
type EMITTED_EVENT = EVENT & {
|
|
182
|
+
block_hash: BLOCK_HASH;
|
|
183
|
+
block_number: BLOCK_NUMBER;
|
|
184
|
+
transaction_hash: TXN_HASH;
|
|
185
|
+
};
|
|
186
|
+
type SYNC_STATUS = {
|
|
187
|
+
starting_block_hash: BLOCK_HASH;
|
|
188
|
+
starting_block_num: NUM_AS_HEX;
|
|
189
|
+
current_block_hash: BLOCK_HASH;
|
|
190
|
+
current_block_num: NUM_AS_HEX;
|
|
191
|
+
highest_block_hash: BLOCK_HASH;
|
|
192
|
+
highest_block_num: NUM_AS_HEX;
|
|
193
|
+
};
|
|
194
|
+
type FEE_ESTIMATE = {
|
|
195
|
+
gas_consumed: NUM_AS_HEX;
|
|
196
|
+
gas_price: NUM_AS_HEX;
|
|
197
|
+
overall_fee: NUM_AS_HEX;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
enum CALL_TYPE {
|
|
201
|
+
'DELEGATE',
|
|
202
|
+
'CALL',
|
|
203
|
+
}
|
|
204
|
+
enum ENTRY_POINT_TYPE {
|
|
205
|
+
'EXTERNAL',
|
|
206
|
+
'L1_HANDLER',
|
|
207
|
+
'CONSTRUCTOR',
|
|
208
|
+
}
|
|
209
|
+
type FUNCTION_INVOCATION = FUNCTION_CALL & {
|
|
210
|
+
caller_address: FELT;
|
|
211
|
+
code_address: FELT;
|
|
212
|
+
entry_point_type: ENTRY_POINT_TYPE;
|
|
213
|
+
call_type: CALL_TYPE;
|
|
214
|
+
result: FELT;
|
|
215
|
+
calls: FUNCTION_INVOCATION;
|
|
216
|
+
events: EVENT;
|
|
217
|
+
messages: MSG_TO_L1;
|
|
218
|
+
};
|
|
219
|
+
type TRACE_ROOT = {
|
|
220
|
+
nonce: FELT;
|
|
221
|
+
signature: FELT;
|
|
222
|
+
function_invocation: FUNCTION_INVOCATION;
|
|
223
|
+
};
|
|
160
224
|
|
|
161
225
|
export namespace OPENRPC {
|
|
162
|
-
export type
|
|
163
|
-
export type
|
|
164
|
-
export type
|
|
165
|
-
export type
|
|
166
|
-
export type
|
|
167
|
-
export type
|
|
226
|
+
export type Nonce = FELT;
|
|
227
|
+
export type BlockWithTxHashes = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
|
|
228
|
+
export type BlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
|
|
229
|
+
export type StateUpdate = STATE_UPDATE;
|
|
230
|
+
export type Storage = FELT;
|
|
231
|
+
export type Transaction = TXN;
|
|
232
|
+
export type TransactionReceipt = TXN_RECEIPT;
|
|
233
|
+
export type ContractClass = CONTRACT_CLASS;
|
|
234
|
+
export type CallResponse = Array<FELT>;
|
|
235
|
+
export type EstimatedFee = FEE_ESTIMATE;
|
|
236
|
+
export type BlockNumber = BLOCK_NUMBER;
|
|
237
|
+
export type BlockHashAndNumber = {
|
|
238
|
+
block_hash: BLOCK_HASH;
|
|
239
|
+
block_number: BLOCK_NUMBER;
|
|
240
|
+
};
|
|
241
|
+
export type CHAIN_ID = string;
|
|
242
|
+
export type PendingTransactions = Array<TXN>;
|
|
243
|
+
export type ProtocolVersion = PROTOCOL_VERSION;
|
|
244
|
+
export type SyncingStatus = false | SYNC_STATUS;
|
|
245
|
+
export type Events = {
|
|
246
|
+
events: Array<EMITTED_EVENT>;
|
|
247
|
+
page_number: number;
|
|
248
|
+
is_last_page: boolean;
|
|
249
|
+
};
|
|
250
|
+
export type Trace = TRACE_ROOT;
|
|
251
|
+
export type Traces = Array<{
|
|
252
|
+
transaction_hash: FELT;
|
|
253
|
+
trace_root: TRACE_ROOT;
|
|
254
|
+
}>;
|
|
255
|
+
export type TransactionHash = TXN_HASH;
|
|
256
|
+
export type BlockHash = BLOCK_HASH;
|
|
257
|
+
export type EventFilter = EVENT_FILTER & RESULT_PAGE_REQUEST;
|
|
258
|
+
export type InvokedTransaction = { transaction_hash: TXN_HASH };
|
|
259
|
+
export type DeclaredTransaction = { transaction_hash: TXN_HASH; class_hash: FELT };
|
|
260
|
+
export type DeployedTransaction = { transaction_hash: TXN_HASH; contract_address: FELT };
|
|
261
|
+
|
|
262
|
+
// Final Methods
|
|
263
|
+
export type Methods = {
|
|
264
|
+
// Read API
|
|
265
|
+
starknet_getBlockWithTxHashes: {
|
|
266
|
+
params: { block_id: BLOCK_ID };
|
|
267
|
+
result: BlockWithTxHashes;
|
|
268
|
+
errors: Errors.INVALID_BLOCK_ID;
|
|
269
|
+
};
|
|
270
|
+
starknet_getBlockWithTxs: {
|
|
271
|
+
params: { block_id: BLOCK_ID };
|
|
272
|
+
result: BlockWithTxs;
|
|
273
|
+
errors: Errors.INVALID_BLOCK_ID;
|
|
274
|
+
};
|
|
275
|
+
starknet_getStateUpdate: {
|
|
276
|
+
params: { block_id: BLOCK_ID };
|
|
277
|
+
result: StateUpdate;
|
|
278
|
+
errors: Errors.INVALID_BLOCK_ID;
|
|
279
|
+
};
|
|
280
|
+
starknet_getStorageAt: {
|
|
281
|
+
params: { contract_address: ADDRESS; key: STORAGE_KEY; block_id: BLOCK_ID };
|
|
282
|
+
result: Storage;
|
|
283
|
+
errors: Errors.CONTRACT_NOT_FOUND | Errors.INVALID_BLOCK_ID;
|
|
284
|
+
};
|
|
285
|
+
starknet_getTransactionByHash: {
|
|
286
|
+
params: { transaction_hash: TXN_HASH };
|
|
287
|
+
result: Transaction;
|
|
288
|
+
errors: Errors.INVALID_TXN_HASH;
|
|
289
|
+
};
|
|
290
|
+
starknet_getTransactionByBlockIdAndIndex: {
|
|
291
|
+
params: { block_id: BLOCK_ID; index: number };
|
|
292
|
+
result: Transaction;
|
|
293
|
+
errors: Errors.INVALID_BLOCK_ID | Errors.INVALID_TXN_INDEX;
|
|
294
|
+
};
|
|
295
|
+
starknet_getTransactionReceipt: {
|
|
296
|
+
params: { transaction_hash: TXN_HASH };
|
|
297
|
+
result: TransactionReceipt;
|
|
298
|
+
errors: Errors.INVALID_TXN_HASH;
|
|
299
|
+
};
|
|
300
|
+
starknet_getClass: {
|
|
301
|
+
params: { class_hash: FELT };
|
|
302
|
+
result: ContractClass;
|
|
303
|
+
errors: Errors.INVALID_CONTRACT_CLASS_HASH;
|
|
304
|
+
};
|
|
305
|
+
starknet_getClassHashAt: {
|
|
306
|
+
params: { block_id: BLOCK_ID; contract_address: ADDRESS };
|
|
307
|
+
result: FELT;
|
|
308
|
+
errors: Errors.INVALID_BLOCK_ID | Errors.CONTRACT_NOT_FOUND;
|
|
309
|
+
};
|
|
310
|
+
starknet_getClassAt: {
|
|
311
|
+
params: { block_id: BLOCK_ID; contract_address: ADDRESS };
|
|
312
|
+
result: ContractClass;
|
|
313
|
+
errors: Errors.INVALID_BLOCK_ID | Errors.CONTRACT_NOT_FOUND;
|
|
314
|
+
};
|
|
315
|
+
starknet_getBlockTransactionCount: {
|
|
316
|
+
params: { block_id: BLOCK_ID };
|
|
317
|
+
result: number;
|
|
318
|
+
errors: Errors.INVALID_BLOCK_ID;
|
|
319
|
+
};
|
|
320
|
+
starknet_call: {
|
|
321
|
+
params: { request: FUNCTION_CALL; block_id: BLOCK_ID };
|
|
322
|
+
result: Array<FELT>;
|
|
323
|
+
errors:
|
|
324
|
+
| Errors.CONTRACT_NOT_FOUND
|
|
325
|
+
| Errors.INVALID_MESSAGE_SELECTOR
|
|
326
|
+
| Errors.INVALID_CALL_DATA
|
|
327
|
+
| Errors.CONTRACT_ERROR
|
|
328
|
+
| Errors.INVALID_BLOCK_ID;
|
|
329
|
+
};
|
|
330
|
+
starknet_estimateFee: {
|
|
331
|
+
params: { request: INVOKE_TXN; block_id: BLOCK_ID };
|
|
332
|
+
result: FEE_ESTIMATE;
|
|
333
|
+
errors:
|
|
334
|
+
| Errors.CONTRACT_NOT_FOUND
|
|
335
|
+
| Errors.INVALID_MESSAGE_SELECTOR
|
|
336
|
+
| Errors.INVALID_CALL_DATA
|
|
337
|
+
| Errors.CONTRACT_ERROR
|
|
338
|
+
| Errors.INVALID_BLOCK_ID;
|
|
339
|
+
};
|
|
340
|
+
starknet_blockNumber: {
|
|
341
|
+
params: {};
|
|
342
|
+
result: BLOCK_NUMBER;
|
|
343
|
+
errors: Errors.NO_BLOCKS;
|
|
344
|
+
};
|
|
345
|
+
starknet_blockHashAndNumber: {
|
|
346
|
+
params: {};
|
|
347
|
+
result: BLOCK_HASH & BLOCK_NUMBER;
|
|
348
|
+
errors: Errors.NO_BLOCKS;
|
|
349
|
+
};
|
|
350
|
+
starknet_chainId: {
|
|
351
|
+
params: {};
|
|
352
|
+
result: CHAIN_ID;
|
|
353
|
+
};
|
|
354
|
+
starknet_pendingTransactions: {
|
|
355
|
+
params: {};
|
|
356
|
+
result: PendingTransactions;
|
|
357
|
+
};
|
|
358
|
+
starknet_syncing: {
|
|
359
|
+
params: {};
|
|
360
|
+
result: SyncingStatus;
|
|
361
|
+
};
|
|
362
|
+
starknet_getEvents: {
|
|
363
|
+
params: { filter: EVENT_FILTER & RESULT_PAGE_REQUEST };
|
|
364
|
+
result: Events;
|
|
365
|
+
errors: Errors.PAGE_SIZE_TOO_BIG;
|
|
366
|
+
};
|
|
367
|
+
// FROM RPC 0.2.0 Pathfinder exception
|
|
368
|
+
starknet_getNonce: {
|
|
369
|
+
params: { contract_address: ADDRESS; block_id: BLOCK_ID };
|
|
370
|
+
result: FELT;
|
|
371
|
+
errors: Errors.CONTRACT_NOT_FOUND;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// Write API
|
|
375
|
+
starknet_addInvokeTransaction: {
|
|
376
|
+
params: {
|
|
377
|
+
function_invocation: FUNCTION_CALL;
|
|
378
|
+
signature: SIGNATURE;
|
|
379
|
+
max_fee: NUM_AS_HEX;
|
|
380
|
+
version: NUM_AS_HEX;
|
|
381
|
+
};
|
|
382
|
+
result: InvokedTransaction;
|
|
383
|
+
};
|
|
384
|
+
starknet_addDeclareTransaction: {
|
|
385
|
+
params: {
|
|
386
|
+
contract_class: CONTRACT_CLASS;
|
|
387
|
+
version: NUM_AS_HEX;
|
|
388
|
+
};
|
|
389
|
+
result: DeclaredTransaction;
|
|
390
|
+
errors: Errors.INVALID_CONTRACT_CLASS;
|
|
391
|
+
};
|
|
392
|
+
starknet_addDeployTransaction: {
|
|
393
|
+
params: {
|
|
394
|
+
contract_address_salt: FELT;
|
|
395
|
+
constructor_calldata: Array<FELT>;
|
|
396
|
+
contract_definition: CONTRACT_CLASS;
|
|
397
|
+
};
|
|
398
|
+
result: DeployedTransaction;
|
|
399
|
+
errors: Errors.INVALID_CONTRACT_CLASS;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// Trace API
|
|
403
|
+
starknet_traceTransaction: {
|
|
404
|
+
params: { transaction_hash: TXN_HASH };
|
|
405
|
+
result: Trace;
|
|
406
|
+
errors:
|
|
407
|
+
| Errors.INVALID_TXN_HASH
|
|
408
|
+
| Errors.NO_TRACE_AVAILABLE
|
|
409
|
+
| Errors.INVALID_BLOCK_HASH
|
|
410
|
+
| Errors.INVALID_TXN_HASH;
|
|
411
|
+
};
|
|
412
|
+
starknet_traceBlockTransactions: {
|
|
413
|
+
params: { block_hash: BLOCK_HASH };
|
|
414
|
+
result: Traces;
|
|
415
|
+
errors: Errors.INVALID_BLOCK_HASH;
|
|
416
|
+
};
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export namespace Errors {
|
|
421
|
+
export interface FAILED_TO_RECEIVE_TXN {
|
|
422
|
+
code: 1;
|
|
423
|
+
message: 'Failed to write transaction';
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface CONTRACT_NOT_FOUND {
|
|
427
|
+
code: 20;
|
|
428
|
+
message: 'Contract not found';
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export interface INVALID_MESSAGE_SELECTOR {
|
|
432
|
+
code: 21;
|
|
433
|
+
message: 'Invalid message selector';
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface INVALID_CALL_DATA {
|
|
437
|
+
code: 22;
|
|
438
|
+
message: 'Invalid call data';
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export interface INVALID_BLOCK_ID {
|
|
442
|
+
code: 24;
|
|
443
|
+
message: 'Invalid block id';
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export interface INVALID_TXN_INDEX {
|
|
447
|
+
code: 27;
|
|
448
|
+
message: 'Invalid transaction index in a block';
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export interface INVALID_CONTRACT_CLASS_HASH {
|
|
452
|
+
code: 28;
|
|
453
|
+
message: 'The supplied contract class hash is invalid or unknown';
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export interface PAGE_SIZE_TOO_BIG {
|
|
457
|
+
code: 31;
|
|
458
|
+
message: 'Requested page size is too big';
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export interface NO_BLOCKS {
|
|
462
|
+
code: 32;
|
|
463
|
+
message: 'There are no blocks';
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export interface CONTRACT_ERROR {
|
|
467
|
+
code: 40;
|
|
468
|
+
message: 'Contract error';
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export interface INVALID_CONTRACT_CLASS {
|
|
472
|
+
code: 50;
|
|
473
|
+
message: 'Invalid contract class';
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export interface NO_TRACE_AVAILABLE {
|
|
477
|
+
code: 10;
|
|
478
|
+
message: 'No trace available for transaction';
|
|
479
|
+
data: {
|
|
480
|
+
status: 'RECEIVED' | 'REJECTED';
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export interface INVALID_BLOCK_HASH {
|
|
485
|
+
code: 24;
|
|
486
|
+
message: 'Invalid block hash';
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export interface INVALID_TXN_HASH {
|
|
490
|
+
code: 25;
|
|
491
|
+
message: 'Invalid transaction hash';
|
|
492
|
+
}
|
|
168
493
|
}
|