starknet 4.6.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 +25 -0
- package/__tests__/account.test.ts +2 -5
- package/__tests__/contract.test.ts +0 -1
- package/__tests__/defaultProvider.test.ts +9 -1
- package/__tests__/sequencerProvider.test.ts +10 -8
- package/__tests__/utils/ellipticalCurve.test.ts +7 -8
- 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 +12 -10
- package/dist/provider/rpc.js +80 -72
- package/dist/provider/sequencer.d.ts +4 -3
- package/dist/provider/sequencer.js +14 -6
- 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 +17 -27
- package/dist/types/api/rpc.d.ts +4 -128
- 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 +2 -5
- package/dist/utils/responseParser/rpc.js +2 -38
- 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 +12 -10
- package/provider/rpc.js +80 -72
- package/provider/sequencer.d.ts +4 -3
- package/provider/sequencer.js +14 -6
- 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 +89 -73
- package/src/provider/sequencer.ts +16 -8
- package/src/signer/default.ts +8 -8
- package/src/signer/interface.ts +2 -2
- package/src/types/api/openrpc.ts +20 -25
- package/src/types/api/rpc.ts +4 -128
- 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 +7 -25
- package/types/api/openrpc.d.ts +17 -27
- package/types/api/rpc.d.ts +4 -128
- 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 +2 -5
- package/utils/responseParser/rpc.js +2 -38
- 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
|
@@ -8,26 +8,14 @@
|
|
|
8
8
|
* TypeScript Representation of OpenRpc protocol types
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* "type": "string",
|
|
13
|
-
* "title": "Field element",
|
|
14
|
-
* "$comment": "A field element, represented as a string of hex digits",
|
|
15
|
-
* "description": "A field element. Represented as up to 63 hex digits and leading 4 bits zeroed.",
|
|
16
|
-
* "pattern": "^0x0[a-fA-F0-9]{1,63}$"
|
|
17
|
-
*/
|
|
18
11
|
export type FELT = string;
|
|
19
12
|
export type ADDRESS = FELT;
|
|
20
|
-
/**
|
|
21
|
-
* "title": "An integer number in hex format (0x...)",
|
|
22
|
-
* "pattern": "^0x[a-fA-F0-9]+$"
|
|
23
|
-
*/
|
|
24
13
|
type NUM_AS_HEX = string;
|
|
25
14
|
type SIGNATURE = Array<FELT>;
|
|
26
15
|
type ETH_ADDRESS = string;
|
|
27
16
|
type BLOCK_NUMBER = number;
|
|
28
17
|
type BLOCK_HASH = FELT;
|
|
29
18
|
type TXN_HASH = FELT;
|
|
30
|
-
type CHAIN_ID = string;
|
|
31
19
|
type PROTOCOL_VERSION = string;
|
|
32
20
|
type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
33
21
|
type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'INVOKE' | 'L1_HANDLER';
|
|
@@ -68,7 +56,6 @@ type PENDING_COMMON_RECEIPT_PROPERTIES = {
|
|
|
68
56
|
actual_fee: FELT;
|
|
69
57
|
};
|
|
70
58
|
type INVOKE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
|
|
71
|
-
// type L1_HANDLER_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
|
|
72
59
|
type DECLARE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
|
|
73
60
|
type DEPLOY_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
|
|
74
61
|
type PENDING_INVOKE_TXN_RECEIPT = PENDING_COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
|
|
@@ -98,18 +85,19 @@ type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
|
|
|
98
85
|
sequencer_address: FELT;
|
|
99
86
|
parent_hash: BLOCK_HASH;
|
|
100
87
|
};
|
|
88
|
+
// transaction_hash, nonce, type optional because of pathfinder not implemented
|
|
101
89
|
type COMMON_TXN_PROPERTIES = {
|
|
102
|
-
transaction_hash
|
|
90
|
+
transaction_hash?: TXN_HASH;
|
|
103
91
|
max_fee: FELT;
|
|
104
92
|
version: NUM_AS_HEX;
|
|
105
93
|
signature: SIGNATURE;
|
|
106
|
-
nonce
|
|
107
|
-
type
|
|
94
|
+
nonce?: FELT;
|
|
95
|
+
type?: TXN_TYPE;
|
|
108
96
|
};
|
|
109
97
|
type FUNCTION_CALL = {
|
|
110
|
-
contract_address
|
|
111
|
-
entry_point_selector
|
|
112
|
-
calldata
|
|
98
|
+
contract_address?: ADDRESS;
|
|
99
|
+
entry_point_selector?: FELT;
|
|
100
|
+
calldata?: Array<FELT>;
|
|
113
101
|
};
|
|
114
102
|
type INVOKE_TXN = COMMON_TXN_PROPERTIES & FUNCTION_CALL;
|
|
115
103
|
type DECLARE_TXN = COMMON_TXN_PROPERTIES & {
|
|
@@ -138,6 +126,7 @@ type PENDING_BLOCK_WITH_TXS = BLOCK_BODY_WITH_TXS & {
|
|
|
138
126
|
sequencer_address: FELT;
|
|
139
127
|
parent_hash: BLOCK_HASH;
|
|
140
128
|
};
|
|
129
|
+
|
|
141
130
|
type CONTRACT_CLASS = {
|
|
142
131
|
program: string; // A base64 representation of the compressed program code
|
|
143
132
|
entry_points_by_type: {
|
|
@@ -234,6 +223,7 @@ type TRACE_ROOT = {
|
|
|
234
223
|
};
|
|
235
224
|
|
|
236
225
|
export namespace OPENRPC {
|
|
226
|
+
export type Nonce = FELT;
|
|
237
227
|
export type BlockWithTxHashes = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
|
|
238
228
|
export type BlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
|
|
239
229
|
export type StateUpdate = STATE_UPDATE;
|
|
@@ -248,7 +238,7 @@ export namespace OPENRPC {
|
|
|
248
238
|
block_hash: BLOCK_HASH;
|
|
249
239
|
block_number: BLOCK_NUMBER;
|
|
250
240
|
};
|
|
251
|
-
export type
|
|
241
|
+
export type CHAIN_ID = string;
|
|
252
242
|
export type PendingTransactions = Array<TXN>;
|
|
253
243
|
export type ProtocolVersion = PROTOCOL_VERSION;
|
|
254
244
|
export type SyncingStatus = false | SYNC_STATUS;
|
|
@@ -257,7 +247,6 @@ export namespace OPENRPC {
|
|
|
257
247
|
page_number: number;
|
|
258
248
|
is_last_page: boolean;
|
|
259
249
|
};
|
|
260
|
-
export type Nonce = FELT;
|
|
261
250
|
export type Trace = TRACE_ROOT;
|
|
262
251
|
export type Traces = Array<{
|
|
263
252
|
transaction_hash: FELT;
|
|
@@ -265,7 +254,7 @@ export namespace OPENRPC {
|
|
|
265
254
|
}>;
|
|
266
255
|
export type TransactionHash = TXN_HASH;
|
|
267
256
|
export type BlockHash = BLOCK_HASH;
|
|
268
|
-
export type EventFilter = EVENT_FILTER;
|
|
257
|
+
export type EventFilter = EVENT_FILTER & RESULT_PAGE_REQUEST;
|
|
269
258
|
export type InvokedTransaction = { transaction_hash: TXN_HASH };
|
|
270
259
|
export type DeclaredTransaction = { transaction_hash: TXN_HASH; class_hash: FELT };
|
|
271
260
|
export type DeployedTransaction = { transaction_hash: TXN_HASH; contract_address: FELT };
|
|
@@ -349,29 +338,35 @@ export namespace OPENRPC {
|
|
|
349
338
|
| Errors.INVALID_BLOCK_ID;
|
|
350
339
|
};
|
|
351
340
|
starknet_blockNumber: {
|
|
341
|
+
params: {};
|
|
352
342
|
result: BLOCK_NUMBER;
|
|
353
343
|
errors: Errors.NO_BLOCKS;
|
|
354
344
|
};
|
|
355
345
|
starknet_blockHashAndNumber: {
|
|
346
|
+
params: {};
|
|
356
347
|
result: BLOCK_HASH & BLOCK_NUMBER;
|
|
357
348
|
errors: Errors.NO_BLOCKS;
|
|
358
349
|
};
|
|
359
350
|
starknet_chainId: {
|
|
351
|
+
params: {};
|
|
360
352
|
result: CHAIN_ID;
|
|
361
353
|
};
|
|
362
354
|
starknet_pendingTransactions: {
|
|
355
|
+
params: {};
|
|
363
356
|
result: PendingTransactions;
|
|
364
357
|
};
|
|
365
358
|
starknet_syncing: {
|
|
359
|
+
params: {};
|
|
366
360
|
result: SyncingStatus;
|
|
367
361
|
};
|
|
368
362
|
starknet_getEvents: {
|
|
369
363
|
params: { filter: EVENT_FILTER & RESULT_PAGE_REQUEST };
|
|
370
|
-
result:
|
|
364
|
+
result: Events;
|
|
371
365
|
errors: Errors.PAGE_SIZE_TOO_BIG;
|
|
372
366
|
};
|
|
367
|
+
// FROM RPC 0.2.0 Pathfinder exception
|
|
373
368
|
starknet_getNonce: {
|
|
374
|
-
params: { contract_address: ADDRESS };
|
|
369
|
+
params: { contract_address: ADDRESS; block_id: BLOCK_ID };
|
|
375
370
|
result: FELT;
|
|
376
371
|
errors: Errors.CONTRACT_NOT_FOUND;
|
|
377
372
|
};
|
|
@@ -397,7 +392,7 @@ export namespace OPENRPC {
|
|
|
397
392
|
starknet_addDeployTransaction: {
|
|
398
393
|
params: {
|
|
399
394
|
contract_address_salt: FELT;
|
|
400
|
-
constructor_calldata: FELT
|
|
395
|
+
constructor_calldata: Array<FELT>;
|
|
401
396
|
contract_definition: CONTRACT_CLASS;
|
|
402
397
|
};
|
|
403
398
|
result: DeployedTransaction;
|
package/src/types/api/rpc.ts
CHANGED
|
@@ -11,9 +11,11 @@ export namespace RPC {
|
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export type ChainId = OPENRPC.
|
|
14
|
+
export type ChainId = OPENRPC.CHAIN_ID;
|
|
15
|
+
export type CallResponse = OPENRPC.CallResponse;
|
|
15
16
|
export type ContractAddress = ADDRESS;
|
|
16
17
|
export type Felt = FELT;
|
|
18
|
+
export type Nonce = OPENRPC.Nonce;
|
|
17
19
|
export type ContractClass = OPENRPC.ContractClass;
|
|
18
20
|
export type StateUpdate = OPENRPC.StateUpdate;
|
|
19
21
|
export type Transaction = OPENRPC.Transaction;
|
|
@@ -40,131 +42,5 @@ export namespace RPC {
|
|
|
40
42
|
export type DeclaredTransaction = OPENRPC.DeclaredTransaction;
|
|
41
43
|
export type DeployedTransaction = OPENRPC.DeployedTransaction;
|
|
42
44
|
|
|
43
|
-
export type Methods =
|
|
44
|
-
starknet_pendingTransactions: {
|
|
45
|
-
QUERY: never;
|
|
46
|
-
REQUEST: any[];
|
|
47
|
-
RESPONSE: PendingTransactions;
|
|
48
|
-
};
|
|
49
|
-
starknet_blockHashAndNumber: {
|
|
50
|
-
QUERY: never;
|
|
51
|
-
REQUEST: any[];
|
|
52
|
-
RESPONSE: BlockHashAndNumber;
|
|
53
|
-
};
|
|
54
|
-
starknet_getClassHashAt: {
|
|
55
|
-
QUERY: never;
|
|
56
|
-
REQUEST: any[];
|
|
57
|
-
RESPONSE: Felt;
|
|
58
|
-
};
|
|
59
|
-
starknet_getStateUpdate: {
|
|
60
|
-
QUERY: never;
|
|
61
|
-
REQUEST: any[];
|
|
62
|
-
RESPONSE: OPENRPC.StateUpdate;
|
|
63
|
-
};
|
|
64
|
-
starknet_getClass: {
|
|
65
|
-
QUERY: never;
|
|
66
|
-
REQUEST: any[];
|
|
67
|
-
RESPONSE: OPENRPC.ContractClass;
|
|
68
|
-
};
|
|
69
|
-
starknet_getBlockWithTxHashes: {
|
|
70
|
-
QUERY: never;
|
|
71
|
-
REQUEST: any[];
|
|
72
|
-
RESPONSE: GetBlockWithTxHashesResponse;
|
|
73
|
-
};
|
|
74
|
-
starknet_getBlockWithTxs: {
|
|
75
|
-
QUERY: never;
|
|
76
|
-
REQUEST: any[];
|
|
77
|
-
RESPONSE: GetBlockWithTxs;
|
|
78
|
-
};
|
|
79
|
-
starknet_getNonce: {
|
|
80
|
-
QUERY: never;
|
|
81
|
-
REQUEST: any[];
|
|
82
|
-
RESPONSE: OPENRPC.Nonce;
|
|
83
|
-
};
|
|
84
|
-
starknet_getStorageAt: {
|
|
85
|
-
QUERY: never;
|
|
86
|
-
REQUEST: any[];
|
|
87
|
-
RESPONSE: GetStorageAtResponse;
|
|
88
|
-
};
|
|
89
|
-
starknet_getTransactionByHash: {
|
|
90
|
-
QUERY: never;
|
|
91
|
-
REQUEST: any[];
|
|
92
|
-
RESPONSE: GetTransactionByHashResponse;
|
|
93
|
-
};
|
|
94
|
-
starknet_getTransactionByBlockIdAndIndex: {
|
|
95
|
-
QUERY: never;
|
|
96
|
-
REQUEST: any[];
|
|
97
|
-
RESPONSE: GetTransactionByBlockIdAndIndex;
|
|
98
|
-
};
|
|
99
|
-
starknet_getTransactionReceipt: {
|
|
100
|
-
QUERY: never;
|
|
101
|
-
REQUEST: any[];
|
|
102
|
-
RESPONSE: TransactionReceipt;
|
|
103
|
-
};
|
|
104
|
-
starknet_getBlockTransactionCount: {
|
|
105
|
-
QUERY: never;
|
|
106
|
-
REQUEST: any[];
|
|
107
|
-
RESPONSE: GetTransactionCountResponse;
|
|
108
|
-
};
|
|
109
|
-
starknet_call: {
|
|
110
|
-
QUERY: never;
|
|
111
|
-
REQUEST: any[];
|
|
112
|
-
RESPONSE: string[];
|
|
113
|
-
};
|
|
114
|
-
starknet_estimateFee: {
|
|
115
|
-
QUERY: never;
|
|
116
|
-
REQUEST: any[];
|
|
117
|
-
RESPONSE: OPENRPC.EstimatedFee;
|
|
118
|
-
};
|
|
119
|
-
starknet_blockNumber: {
|
|
120
|
-
QUERY: never;
|
|
121
|
-
REQUEST: any[];
|
|
122
|
-
RESPONSE: GetBlockNumberResponse;
|
|
123
|
-
};
|
|
124
|
-
starknet_chainId: {
|
|
125
|
-
QUERY: never;
|
|
126
|
-
REQUEST: any[];
|
|
127
|
-
RESPONSE: OPENRPC.ChainId;
|
|
128
|
-
};
|
|
129
|
-
starknet_syncing: {
|
|
130
|
-
QUERY: never;
|
|
131
|
-
REQUEST: any[];
|
|
132
|
-
RESPONSE: GetSyncingStatsResponse;
|
|
133
|
-
};
|
|
134
|
-
starknet_getEvents: {
|
|
135
|
-
QUERY: never;
|
|
136
|
-
REQUEST: any[];
|
|
137
|
-
RESPONSE: GetEventsResponse;
|
|
138
|
-
};
|
|
139
|
-
starknet_addInvokeTransaction: {
|
|
140
|
-
QUERY: never;
|
|
141
|
-
REQUEST: any[];
|
|
142
|
-
RESPONSE: OPENRPC.InvokedTransaction;
|
|
143
|
-
};
|
|
144
|
-
starknet_addDeployTransaction: {
|
|
145
|
-
QUERY: never;
|
|
146
|
-
REQUEST: any[];
|
|
147
|
-
RESPONSE: OPENRPC.DeployedTransaction;
|
|
148
|
-
};
|
|
149
|
-
starknet_addDeclareTransaction: {
|
|
150
|
-
QUERY: never;
|
|
151
|
-
REQUEST: any[];
|
|
152
|
-
RESPONSE: OPENRPC.DeclaredTransaction;
|
|
153
|
-
};
|
|
154
|
-
starknet_getClassAt: {
|
|
155
|
-
QUERY: never;
|
|
156
|
-
REQUEST: any[];
|
|
157
|
-
RESPONSE: any;
|
|
158
|
-
};
|
|
159
|
-
starknet_traceTransaction: {
|
|
160
|
-
QUERY: never;
|
|
161
|
-
REQUEST: any[];
|
|
162
|
-
RESPONSE: any;
|
|
163
|
-
};
|
|
164
|
-
starknet_traceBlockTransactions: {
|
|
165
|
-
QUERY: never;
|
|
166
|
-
REQUEST: any[];
|
|
167
|
-
RESPONSE: any;
|
|
168
|
-
};
|
|
169
|
-
};
|
|
45
|
+
export type Methods = OPENRPC.Methods;
|
|
170
46
|
}
|
|
@@ -95,9 +95,8 @@ export namespace Sequencer {
|
|
|
95
95
|
contract_address: string;
|
|
96
96
|
signature?: Signature;
|
|
97
97
|
entry_point_type?: EntryPointType;
|
|
98
|
-
entry_point_selector: string;
|
|
99
98
|
calldata?: RawCalldata;
|
|
100
|
-
nonce
|
|
99
|
+
nonce: BigNumberish;
|
|
101
100
|
max_fee?: BigNumberish;
|
|
102
101
|
version?: BigNumberish;
|
|
103
102
|
};
|
|
@@ -118,6 +117,7 @@ export namespace Sequencer {
|
|
|
118
117
|
|
|
119
118
|
export interface InvokeFunctionTransactionResponse extends InvokeFunctionTransaction {
|
|
120
119
|
transaction_hash: string;
|
|
120
|
+
entry_point_selector: string;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export type TransactionResponse =
|
|
@@ -202,12 +202,17 @@ export namespace Sequencer {
|
|
|
202
202
|
export type CallContractTransaction = Omit<
|
|
203
203
|
InvokeFunctionTransaction,
|
|
204
204
|
'type' | 'entry_point_type' | 'nonce'
|
|
205
|
-
|
|
205
|
+
> & { entry_point_selector: string };
|
|
206
206
|
|
|
207
207
|
export type CallContractResponse = {
|
|
208
208
|
result: string[];
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
+
export type EstimateFeeTransaction = Omit<
|
|
212
|
+
InvokeFunctionTransaction,
|
|
213
|
+
'max_fee' | 'entry_point_type'
|
|
214
|
+
>;
|
|
215
|
+
|
|
211
216
|
// Support 0.9.1 changes in a backward-compatible way
|
|
212
217
|
export type EstimateFeeResponse =
|
|
213
218
|
| {
|
|
@@ -259,6 +264,14 @@ export namespace Sequencer {
|
|
|
259
264
|
REQUEST: never;
|
|
260
265
|
RESPONSE: TransactionReceiptResponse;
|
|
261
266
|
};
|
|
267
|
+
get_nonce: {
|
|
268
|
+
QUERY: {
|
|
269
|
+
contractAddress: string;
|
|
270
|
+
blockIdentifier: BlockIdentifier;
|
|
271
|
+
};
|
|
272
|
+
REQUEST: never;
|
|
273
|
+
RESPONSE: BigNumberish;
|
|
274
|
+
};
|
|
262
275
|
get_storage_at: {
|
|
263
276
|
QUERY: {
|
|
264
277
|
contractAddress: string;
|
|
@@ -294,7 +307,7 @@ export namespace Sequencer {
|
|
|
294
307
|
QUERY: {
|
|
295
308
|
blockIdentifier: BlockIdentifier;
|
|
296
309
|
};
|
|
297
|
-
REQUEST:
|
|
310
|
+
REQUEST: EstimateFeeTransaction;
|
|
298
311
|
RESPONSE: EstimateFeeResponse;
|
|
299
312
|
};
|
|
300
313
|
get_class_by_hash: {
|
package/src/types/lib.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type RawCalldata = BigNumberish[];
|
|
|
9
9
|
export type DeployContractPayload = {
|
|
10
10
|
contract: CompiledContract | string;
|
|
11
11
|
constructorCalldata?: RawCalldata;
|
|
12
|
-
addressSalt?:
|
|
12
|
+
addressSalt?: string;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export type DeclareContractPayload = {
|
|
@@ -17,14 +17,14 @@ export type DeclareContractPayload = {
|
|
|
17
17
|
version?: BigNumberish;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export type
|
|
20
|
+
export type CallDetails = {
|
|
21
21
|
contractAddress: string;
|
|
22
|
-
entrypoint: string;
|
|
23
22
|
calldata?: RawCalldata;
|
|
24
|
-
signature?: Signature;
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
export type
|
|
25
|
+
export type Invocation = CallDetails & { signature?: Signature };
|
|
26
|
+
|
|
27
|
+
export type Call = CallDetails & { entrypoint: string };
|
|
28
28
|
|
|
29
29
|
export type InvocationsDetails = {
|
|
30
30
|
nonce?: BigNumberish;
|
|
@@ -32,6 +32,8 @@ export type InvocationsDetails = {
|
|
|
32
32
|
version?: BigNumberish;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
export type InvocationsDetailsWithNonce = InvocationsDetails & { nonce: BigNumberish };
|
|
36
|
+
|
|
35
37
|
export type Status =
|
|
36
38
|
| 'NOT_RECEIVED'
|
|
37
39
|
| 'RECEIVED'
|
package/src/types/provider.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { RPC } from './api/rpc';
|
|
8
|
+
import { Abi, CompressedProgram, RawCalldata, Signature, Status } from './lib';
|
|
8
9
|
|
|
9
10
|
export interface GetBlockResponse {
|
|
10
11
|
timestamp: number;
|
|
@@ -44,7 +45,7 @@ export interface ContractEntryPoint {
|
|
|
44
45
|
|
|
45
46
|
export interface ContractClass {
|
|
46
47
|
program: CompressedProgram;
|
|
47
|
-
entry_points_by_type:
|
|
48
|
+
entry_points_by_type: RPC.ContractClass['entry_points_by_type'];
|
|
48
49
|
abi?: Abi;
|
|
49
50
|
}
|
|
50
51
|
|
package/src/utils/hash.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { ec } from './ellipticCurve';
|
|
|
17
17
|
import { addHexPrefix, buf2hex, removeHexPrefix, utf8ToArray } from './encode';
|
|
18
18
|
import { BigNumberish, toBN, toFelt, toHex } from './number';
|
|
19
19
|
|
|
20
|
-
export const transactionVersion =
|
|
20
|
+
export const transactionVersion = 1;
|
|
21
21
|
export const feeTransactionVersion = toBN(2).pow(toBN(128)).add(toBN(transactionVersion));
|
|
22
22
|
|
|
23
23
|
export function keccakBn(value: BigNumberish): string {
|
|
@@ -124,22 +124,23 @@ export function calculateDeployTransactionHash(
|
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
export function
|
|
127
|
+
export function calculateTransactionHash(
|
|
128
128
|
contractAddress: BigNumberish,
|
|
129
129
|
version: BigNumberish,
|
|
130
|
-
entryPointSelector: BigNumberish,
|
|
131
130
|
calldata: BigNumberish[],
|
|
132
131
|
maxFee: BigNumberish,
|
|
133
|
-
chainId: StarknetChainId
|
|
132
|
+
chainId: StarknetChainId,
|
|
133
|
+
nonce: BigNumberish
|
|
134
134
|
): string {
|
|
135
135
|
return calculateTransactionHashCommon(
|
|
136
136
|
TransactionHashPrefix.INVOKE,
|
|
137
137
|
version,
|
|
138
138
|
contractAddress,
|
|
139
|
-
|
|
139
|
+
0,
|
|
140
140
|
calldata,
|
|
141
141
|
maxFee,
|
|
142
|
-
chainId
|
|
142
|
+
chainId,
|
|
143
|
+
[nonce]
|
|
143
144
|
);
|
|
144
145
|
}
|
|
145
146
|
|
|
@@ -4,13 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import {
|
|
6
6
|
CallContractResponse,
|
|
7
|
-
DeclareContractResponse,
|
|
8
|
-
DeployContractResponse,
|
|
9
7
|
EstimateFeeResponse,
|
|
10
8
|
GetBlockResponse,
|
|
11
9
|
GetTransactionReceiptResponse,
|
|
12
10
|
GetTransactionResponse,
|
|
13
|
-
InvokeFunctionResponse,
|
|
14
11
|
} from '../../types';
|
|
15
12
|
import { RPC } from '../../types/api';
|
|
16
13
|
import { toBN } from '../number';
|
|
@@ -28,7 +25,13 @@ type TransactionReceipt = RPC.TransactionReceipt & {
|
|
|
28
25
|
[key: string]: any;
|
|
29
26
|
};
|
|
30
27
|
|
|
31
|
-
export class RPCResponseParser
|
|
28
|
+
export class RPCResponseParser
|
|
29
|
+
implements
|
|
30
|
+
Omit<
|
|
31
|
+
ResponseParser,
|
|
32
|
+
'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse'
|
|
33
|
+
>
|
|
34
|
+
{
|
|
32
35
|
public parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse {
|
|
33
36
|
return {
|
|
34
37
|
timestamp: res.timestamp,
|
|
@@ -45,7 +48,6 @@ export class RPCResponseParser extends ResponseParser {
|
|
|
45
48
|
return {
|
|
46
49
|
calldata: res.calldata || [],
|
|
47
50
|
contract_address: res.contract_address,
|
|
48
|
-
entry_point_selector: res.entry_point_selector,
|
|
49
51
|
max_fee: res.max_fee,
|
|
50
52
|
nonce: res.nonce,
|
|
51
53
|
signature: res.signature || [],
|
|
@@ -81,24 +83,4 @@ export class RPCResponseParser extends ResponseParser {
|
|
|
81
83
|
result: res,
|
|
82
84
|
};
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
public parseInvokeFunctionResponse(res: RPC.InvokedTransaction): InvokeFunctionResponse {
|
|
86
|
-
return {
|
|
87
|
-
transaction_hash: res.transaction_hash,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public parseDeployContractResponse(res: RPC.DeployedTransaction): DeployContractResponse {
|
|
92
|
-
return {
|
|
93
|
-
transaction_hash: res.transaction_hash,
|
|
94
|
-
contract_address: res.contract_address,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public parseDeclareContractResponse(res: RPC.DeclaredTransaction): DeclareContractResponse {
|
|
99
|
-
return {
|
|
100
|
-
transaction_hash: res.transaction_hash,
|
|
101
|
-
class_hash: res.class_hash,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
86
|
}
|
package/types/api/openrpc.d.ts
CHANGED
|
@@ -7,26 +7,14 @@
|
|
|
7
7
|
*
|
|
8
8
|
* TypeScript Representation of OpenRpc protocol types
|
|
9
9
|
*/
|
|
10
|
-
/**
|
|
11
|
-
* "type": "string",
|
|
12
|
-
* "title": "Field element",
|
|
13
|
-
* "$comment": "A field element, represented as a string of hex digits",
|
|
14
|
-
* "description": "A field element. Represented as up to 63 hex digits and leading 4 bits zeroed.",
|
|
15
|
-
* "pattern": "^0x0[a-fA-F0-9]{1,63}$"
|
|
16
|
-
*/
|
|
17
10
|
export declare type FELT = string;
|
|
18
11
|
export declare type ADDRESS = FELT;
|
|
19
|
-
/**
|
|
20
|
-
* "title": "An integer number in hex format (0x...)",
|
|
21
|
-
* "pattern": "^0x[a-fA-F0-9]+$"
|
|
22
|
-
*/
|
|
23
12
|
declare type NUM_AS_HEX = string;
|
|
24
13
|
declare type SIGNATURE = Array<FELT>;
|
|
25
14
|
declare type ETH_ADDRESS = string;
|
|
26
15
|
declare type BLOCK_NUMBER = number;
|
|
27
16
|
declare type BLOCK_HASH = FELT;
|
|
28
17
|
declare type TXN_HASH = FELT;
|
|
29
|
-
declare type CHAIN_ID = string;
|
|
30
18
|
declare type PROTOCOL_VERSION = string;
|
|
31
19
|
declare type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
32
20
|
declare type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'INVOKE' | 'L1_HANDLER';
|
|
@@ -96,17 +84,17 @@ declare type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
|
|
|
96
84
|
parent_hash: BLOCK_HASH;
|
|
97
85
|
};
|
|
98
86
|
declare type COMMON_TXN_PROPERTIES = {
|
|
99
|
-
transaction_hash
|
|
87
|
+
transaction_hash?: TXN_HASH;
|
|
100
88
|
max_fee: FELT;
|
|
101
89
|
version: NUM_AS_HEX;
|
|
102
90
|
signature: SIGNATURE;
|
|
103
|
-
nonce
|
|
104
|
-
type
|
|
91
|
+
nonce?: FELT;
|
|
92
|
+
type?: TXN_TYPE;
|
|
105
93
|
};
|
|
106
94
|
declare type FUNCTION_CALL = {
|
|
107
|
-
contract_address
|
|
108
|
-
entry_point_selector
|
|
109
|
-
calldata
|
|
95
|
+
contract_address?: ADDRESS;
|
|
96
|
+
entry_point_selector?: FELT;
|
|
97
|
+
calldata?: Array<FELT>;
|
|
110
98
|
};
|
|
111
99
|
declare type INVOKE_TXN = COMMON_TXN_PROPERTIES & FUNCTION_CALL;
|
|
112
100
|
declare type DECLARE_TXN = COMMON_TXN_PROPERTIES & {
|
|
@@ -228,6 +216,7 @@ declare type TRACE_ROOT = {
|
|
|
228
216
|
function_invocation: FUNCTION_INVOCATION;
|
|
229
217
|
};
|
|
230
218
|
export declare namespace OPENRPC {
|
|
219
|
+
type Nonce = FELT;
|
|
231
220
|
type BlockWithTxHashes = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
|
|
232
221
|
type BlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
|
|
233
222
|
type StateUpdate = STATE_UPDATE;
|
|
@@ -242,7 +231,7 @@ export declare namespace OPENRPC {
|
|
|
242
231
|
block_hash: BLOCK_HASH;
|
|
243
232
|
block_number: BLOCK_NUMBER;
|
|
244
233
|
};
|
|
245
|
-
type
|
|
234
|
+
type CHAIN_ID = string;
|
|
246
235
|
type PendingTransactions = Array<TXN>;
|
|
247
236
|
type ProtocolVersion = PROTOCOL_VERSION;
|
|
248
237
|
type SyncingStatus = false | SYNC_STATUS;
|
|
@@ -251,7 +240,6 @@ export declare namespace OPENRPC {
|
|
|
251
240
|
page_number: number;
|
|
252
241
|
is_last_page: boolean;
|
|
253
242
|
};
|
|
254
|
-
type Nonce = FELT;
|
|
255
243
|
type Trace = TRACE_ROOT;
|
|
256
244
|
type Traces = Array<{
|
|
257
245
|
transaction_hash: FELT;
|
|
@@ -259,7 +247,7 @@ export declare namespace OPENRPC {
|
|
|
259
247
|
}>;
|
|
260
248
|
type TransactionHash = TXN_HASH;
|
|
261
249
|
type BlockHash = BLOCK_HASH;
|
|
262
|
-
type EventFilter = EVENT_FILTER;
|
|
250
|
+
type EventFilter = EVENT_FILTER & RESULT_PAGE_REQUEST;
|
|
263
251
|
type InvokedTransaction = {
|
|
264
252
|
transaction_hash: TXN_HASH;
|
|
265
253
|
};
|
|
@@ -371,36 +359,38 @@ export declare namespace OPENRPC {
|
|
|
371
359
|
errors: Errors.CONTRACT_NOT_FOUND | Errors.INVALID_MESSAGE_SELECTOR | Errors.INVALID_CALL_DATA | Errors.CONTRACT_ERROR | Errors.INVALID_BLOCK_ID;
|
|
372
360
|
};
|
|
373
361
|
starknet_blockNumber: {
|
|
362
|
+
params: {};
|
|
374
363
|
result: BLOCK_NUMBER;
|
|
375
364
|
errors: Errors.NO_BLOCKS;
|
|
376
365
|
};
|
|
377
366
|
starknet_blockHashAndNumber: {
|
|
367
|
+
params: {};
|
|
378
368
|
result: BLOCK_HASH & BLOCK_NUMBER;
|
|
379
369
|
errors: Errors.NO_BLOCKS;
|
|
380
370
|
};
|
|
381
371
|
starknet_chainId: {
|
|
372
|
+
params: {};
|
|
382
373
|
result: CHAIN_ID;
|
|
383
374
|
};
|
|
384
375
|
starknet_pendingTransactions: {
|
|
376
|
+
params: {};
|
|
385
377
|
result: PendingTransactions;
|
|
386
378
|
};
|
|
387
379
|
starknet_syncing: {
|
|
380
|
+
params: {};
|
|
388
381
|
result: SyncingStatus;
|
|
389
382
|
};
|
|
390
383
|
starknet_getEvents: {
|
|
391
384
|
params: {
|
|
392
385
|
filter: EVENT_FILTER & RESULT_PAGE_REQUEST;
|
|
393
386
|
};
|
|
394
|
-
result:
|
|
395
|
-
events: EMITTED_EVENT;
|
|
396
|
-
page_number: number;
|
|
397
|
-
is_last_page: boolean;
|
|
398
|
-
};
|
|
387
|
+
result: Events;
|
|
399
388
|
errors: Errors.PAGE_SIZE_TOO_BIG;
|
|
400
389
|
};
|
|
401
390
|
starknet_getNonce: {
|
|
402
391
|
params: {
|
|
403
392
|
contract_address: ADDRESS;
|
|
393
|
+
block_id: BLOCK_ID;
|
|
404
394
|
};
|
|
405
395
|
result: FELT;
|
|
406
396
|
errors: Errors.CONTRACT_NOT_FOUND;
|
|
@@ -425,7 +415,7 @@ export declare namespace OPENRPC {
|
|
|
425
415
|
starknet_addDeployTransaction: {
|
|
426
416
|
params: {
|
|
427
417
|
contract_address_salt: FELT;
|
|
428
|
-
constructor_calldata: FELT
|
|
418
|
+
constructor_calldata: Array<FELT>;
|
|
429
419
|
contract_definition: CONTRACT_CLASS;
|
|
430
420
|
};
|
|
431
421
|
result: DeployedTransaction;
|