starknet 4.6.0 → 4.8.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 +44 -0
- package/CONTRIBUTING.md +2 -2
- package/__mocks__/l1l2_compiled.json +10107 -0
- package/__tests__/account.test.ts +2 -5
- package/__tests__/contract.test.ts +0 -1
- package/__tests__/defaultProvider.test.ts +5 -3
- package/__tests__/fixtures.ts +2 -0
- package/__tests__/sequencerProvider.test.ts +50 -9
- package/__tests__/utils/ellipticalCurve.test.ts +7 -8
- package/__tests__/utils/merkle.test.ts +15 -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 +12 -10
- package/dist/provider/rpc.js +80 -72
- package/dist/provider/sequencer.d.ts +6 -4
- package/dist/provider/sequencer.js +36 -7
- 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 +36 -20
- package/dist/types/lib.d.ts +10 -4
- package/dist/types/provider.d.ts +7 -2
- package/dist/utils/hash.d.ts +8 -2
- package/dist/utils/hash.js +20 -5
- package/dist/utils/merkle.js +2 -1
- package/dist/utils/number.d.ts +5 -0
- package/dist/utils/number.js +29 -1
- package/dist/utils/responseParser/rpc.d.ts +2 -5
- package/dist/utils/responseParser/rpc.js +2 -38
- package/dist/utils/responseParser/sequencer.js +7 -19
- 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 +6 -4
- package/provider/sequencer.js +36 -7
- 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 +47 -11
- 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 +39 -20
- package/src/types/lib.ts +7 -5
- package/src/types/provider.ts +7 -2
- package/src/utils/hash.ts +32 -8
- package/src/utils/merkle.ts +2 -1
- package/src/utils/number.ts +27 -0
- package/src/utils/responseParser/rpc.ts +7 -25
- package/src/utils/responseParser/sequencer.ts +12 -7
- package/types/api/openrpc.d.ts +17 -27
- package/types/api/rpc.d.ts +4 -128
- package/types/api/sequencer.d.ts +36 -20
- package/types/lib.d.ts +10 -4
- package/types/provider.d.ts +7 -2
- package/utils/hash.d.ts +8 -2
- package/utils/hash.js +20 -5
- package/utils/merkle.js +2 -1
- package/utils/number.d.ts +5 -0
- package/utils/number.js +29 -1
- package/utils/responseParser/rpc.d.ts +2 -5
- package/utils/responseParser/rpc.js +2 -38
- package/utils/responseParser/sequencer.js +7 -19
- package/www/docs/API/account.md +3 -3
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/provider.md +20 -6
- package/www/docs/API/utils.md +2 -2
- package/www/guides/account.md +1 -1
|
@@ -19,12 +19,9 @@ import { ResponseParser } from '.';
|
|
|
19
19
|
export class SequencerAPIResponseParser extends ResponseParser {
|
|
20
20
|
public parseGetBlockResponse(res: Sequencer.GetBlockResponse): GetBlockResponse {
|
|
21
21
|
return {
|
|
22
|
-
|
|
23
|
-
block_hash: res.block_hash,
|
|
24
|
-
block_number: res.block_number,
|
|
22
|
+
...res,
|
|
25
23
|
new_root: res.state_root,
|
|
26
24
|
parent_hash: res.parent_block_hash,
|
|
27
|
-
status: res.status,
|
|
28
25
|
transactions: Object.values(res.transactions)
|
|
29
26
|
.map((value) => 'transaction_hash' in value && value.transaction_hash)
|
|
30
27
|
.filter(Boolean) as Array<string>,
|
|
@@ -62,12 +59,20 @@ export class SequencerAPIResponseParser extends ResponseParser {
|
|
|
62
59
|
): GetTransactionReceiptResponse {
|
|
63
60
|
return {
|
|
64
61
|
transaction_hash: res.transaction_hash,
|
|
65
|
-
actual_fee: 'actual_fee' in res ? res.actual_fee : undefined,
|
|
66
62
|
status: res.status,
|
|
67
|
-
status_data: undefined,
|
|
68
63
|
messages_sent: res.l2_to_l1_messages as any, // TODO: parse
|
|
69
64
|
events: res.events as any,
|
|
70
|
-
|
|
65
|
+
...('block_hash' in res && { block_hash: res.block_hash }),
|
|
66
|
+
...('block_number' in res && { block_number: res.block_number }),
|
|
67
|
+
...('actual_fee' in res && { actual_fee: res.actual_fee }),
|
|
68
|
+
...('transaction_index' in res && { transaction_index: res.transaction_index }),
|
|
69
|
+
...('execution_resources' in res && { execution_resources: res.execution_resources }),
|
|
70
|
+
...('l1_to_l2_consumed_message' in res && {
|
|
71
|
+
l1_to_l2_consumed_message: res['l1_to_l2_consumed_message'],
|
|
72
|
+
}),
|
|
73
|
+
...('transaction_failure_reason' in res && {
|
|
74
|
+
transaction_failure_reason: res.transaction_failure_reason,
|
|
75
|
+
}),
|
|
71
76
|
};
|
|
72
77
|
}
|
|
73
78
|
|
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;
|
package/types/api/rpc.d.ts
CHANGED
|
@@ -9,9 +9,11 @@ export declare namespace RPC {
|
|
|
9
9
|
message: string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
type ChainId = OPENRPC.
|
|
12
|
+
type ChainId = OPENRPC.CHAIN_ID;
|
|
13
|
+
type CallResponse = OPENRPC.CallResponse;
|
|
13
14
|
type ContractAddress = ADDRESS;
|
|
14
15
|
type Felt = FELT;
|
|
16
|
+
type Nonce = OPENRPC.Nonce;
|
|
15
17
|
type ContractClass = OPENRPC.ContractClass;
|
|
16
18
|
type StateUpdate = OPENRPC.StateUpdate;
|
|
17
19
|
type Transaction = OPENRPC.Transaction;
|
|
@@ -37,131 +39,5 @@ export declare namespace RPC {
|
|
|
37
39
|
type InvokedTransaction = OPENRPC.InvokedTransaction;
|
|
38
40
|
type DeclaredTransaction = OPENRPC.DeclaredTransaction;
|
|
39
41
|
type DeployedTransaction = OPENRPC.DeployedTransaction;
|
|
40
|
-
type Methods =
|
|
41
|
-
starknet_pendingTransactions: {
|
|
42
|
-
QUERY: never;
|
|
43
|
-
REQUEST: any[];
|
|
44
|
-
RESPONSE: PendingTransactions;
|
|
45
|
-
};
|
|
46
|
-
starknet_blockHashAndNumber: {
|
|
47
|
-
QUERY: never;
|
|
48
|
-
REQUEST: any[];
|
|
49
|
-
RESPONSE: BlockHashAndNumber;
|
|
50
|
-
};
|
|
51
|
-
starknet_getClassHashAt: {
|
|
52
|
-
QUERY: never;
|
|
53
|
-
REQUEST: any[];
|
|
54
|
-
RESPONSE: Felt;
|
|
55
|
-
};
|
|
56
|
-
starknet_getStateUpdate: {
|
|
57
|
-
QUERY: never;
|
|
58
|
-
REQUEST: any[];
|
|
59
|
-
RESPONSE: OPENRPC.StateUpdate;
|
|
60
|
-
};
|
|
61
|
-
starknet_getClass: {
|
|
62
|
-
QUERY: never;
|
|
63
|
-
REQUEST: any[];
|
|
64
|
-
RESPONSE: OPENRPC.ContractClass;
|
|
65
|
-
};
|
|
66
|
-
starknet_getBlockWithTxHashes: {
|
|
67
|
-
QUERY: never;
|
|
68
|
-
REQUEST: any[];
|
|
69
|
-
RESPONSE: GetBlockWithTxHashesResponse;
|
|
70
|
-
};
|
|
71
|
-
starknet_getBlockWithTxs: {
|
|
72
|
-
QUERY: never;
|
|
73
|
-
REQUEST: any[];
|
|
74
|
-
RESPONSE: GetBlockWithTxs;
|
|
75
|
-
};
|
|
76
|
-
starknet_getNonce: {
|
|
77
|
-
QUERY: never;
|
|
78
|
-
REQUEST: any[];
|
|
79
|
-
RESPONSE: OPENRPC.Nonce;
|
|
80
|
-
};
|
|
81
|
-
starknet_getStorageAt: {
|
|
82
|
-
QUERY: never;
|
|
83
|
-
REQUEST: any[];
|
|
84
|
-
RESPONSE: GetStorageAtResponse;
|
|
85
|
-
};
|
|
86
|
-
starknet_getTransactionByHash: {
|
|
87
|
-
QUERY: never;
|
|
88
|
-
REQUEST: any[];
|
|
89
|
-
RESPONSE: GetTransactionByHashResponse;
|
|
90
|
-
};
|
|
91
|
-
starknet_getTransactionByBlockIdAndIndex: {
|
|
92
|
-
QUERY: never;
|
|
93
|
-
REQUEST: any[];
|
|
94
|
-
RESPONSE: GetTransactionByBlockIdAndIndex;
|
|
95
|
-
};
|
|
96
|
-
starknet_getTransactionReceipt: {
|
|
97
|
-
QUERY: never;
|
|
98
|
-
REQUEST: any[];
|
|
99
|
-
RESPONSE: TransactionReceipt;
|
|
100
|
-
};
|
|
101
|
-
starknet_getBlockTransactionCount: {
|
|
102
|
-
QUERY: never;
|
|
103
|
-
REQUEST: any[];
|
|
104
|
-
RESPONSE: GetTransactionCountResponse;
|
|
105
|
-
};
|
|
106
|
-
starknet_call: {
|
|
107
|
-
QUERY: never;
|
|
108
|
-
REQUEST: any[];
|
|
109
|
-
RESPONSE: string[];
|
|
110
|
-
};
|
|
111
|
-
starknet_estimateFee: {
|
|
112
|
-
QUERY: never;
|
|
113
|
-
REQUEST: any[];
|
|
114
|
-
RESPONSE: OPENRPC.EstimatedFee;
|
|
115
|
-
};
|
|
116
|
-
starknet_blockNumber: {
|
|
117
|
-
QUERY: never;
|
|
118
|
-
REQUEST: any[];
|
|
119
|
-
RESPONSE: GetBlockNumberResponse;
|
|
120
|
-
};
|
|
121
|
-
starknet_chainId: {
|
|
122
|
-
QUERY: never;
|
|
123
|
-
REQUEST: any[];
|
|
124
|
-
RESPONSE: OPENRPC.ChainId;
|
|
125
|
-
};
|
|
126
|
-
starknet_syncing: {
|
|
127
|
-
QUERY: never;
|
|
128
|
-
REQUEST: any[];
|
|
129
|
-
RESPONSE: GetSyncingStatsResponse;
|
|
130
|
-
};
|
|
131
|
-
starknet_getEvents: {
|
|
132
|
-
QUERY: never;
|
|
133
|
-
REQUEST: any[];
|
|
134
|
-
RESPONSE: GetEventsResponse;
|
|
135
|
-
};
|
|
136
|
-
starknet_addInvokeTransaction: {
|
|
137
|
-
QUERY: never;
|
|
138
|
-
REQUEST: any[];
|
|
139
|
-
RESPONSE: OPENRPC.InvokedTransaction;
|
|
140
|
-
};
|
|
141
|
-
starknet_addDeployTransaction: {
|
|
142
|
-
QUERY: never;
|
|
143
|
-
REQUEST: any[];
|
|
144
|
-
RESPONSE: OPENRPC.DeployedTransaction;
|
|
145
|
-
};
|
|
146
|
-
starknet_addDeclareTransaction: {
|
|
147
|
-
QUERY: never;
|
|
148
|
-
REQUEST: any[];
|
|
149
|
-
RESPONSE: OPENRPC.DeclaredTransaction;
|
|
150
|
-
};
|
|
151
|
-
starknet_getClassAt: {
|
|
152
|
-
QUERY: never;
|
|
153
|
-
REQUEST: any[];
|
|
154
|
-
RESPONSE: any;
|
|
155
|
-
};
|
|
156
|
-
starknet_traceTransaction: {
|
|
157
|
-
QUERY: never;
|
|
158
|
-
REQUEST: any[];
|
|
159
|
-
RESPONSE: any;
|
|
160
|
-
};
|
|
161
|
-
starknet_traceBlockTransactions: {
|
|
162
|
-
QUERY: never;
|
|
163
|
-
REQUEST: any[];
|
|
164
|
-
RESPONSE: any;
|
|
165
|
-
};
|
|
166
|
-
};
|
|
42
|
+
type Methods = OPENRPC.Methods;
|
|
167
43
|
}
|
package/types/api/sequencer.d.ts
CHANGED
|
@@ -15,15 +15,17 @@ export declare type GetContractAddressesResponse = {
|
|
|
15
15
|
Starknet: string;
|
|
16
16
|
GpsStatementVerifier: string;
|
|
17
17
|
};
|
|
18
|
-
export declare type
|
|
18
|
+
export declare type FunctionInvocation = {
|
|
19
19
|
caller_address: string;
|
|
20
20
|
contract_address: string;
|
|
21
|
-
code_address: string;
|
|
22
|
-
selector: string;
|
|
23
21
|
calldata: RawCalldata;
|
|
22
|
+
call_type?: string;
|
|
23
|
+
class_hash?: string;
|
|
24
|
+
selector?: string;
|
|
25
|
+
entry_point_type?: EntryPointType;
|
|
24
26
|
result: Array<any>;
|
|
25
27
|
execution_resources: ExecutionResources;
|
|
26
|
-
|
|
28
|
+
internal_calls: Array<FunctionInvocation>;
|
|
27
29
|
events: Array<any>;
|
|
28
30
|
messages: Array<any>;
|
|
29
31
|
};
|
|
@@ -40,18 +42,9 @@ export declare type ExecutionResources = {
|
|
|
40
42
|
n_memory_holes: number;
|
|
41
43
|
};
|
|
42
44
|
export declare type GetTransactionTraceResponse = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
code_address: string;
|
|
47
|
-
selector: string;
|
|
48
|
-
calldata: RawArgs;
|
|
49
|
-
result: Array<any>;
|
|
50
|
-
execution_resources: ExecutionResources;
|
|
51
|
-
internal_call: Array<any>;
|
|
52
|
-
events: Array<any>;
|
|
53
|
-
messages: Array<any>;
|
|
54
|
-
};
|
|
45
|
+
validate_invocation?: FunctionInvocation;
|
|
46
|
+
function_invocation?: FunctionInvocation;
|
|
47
|
+
fee_transfer_invocation?: FunctionInvocation;
|
|
55
48
|
signature: Signature;
|
|
56
49
|
};
|
|
57
50
|
export declare type RawArgs = {
|
|
@@ -60,6 +53,12 @@ export declare type RawArgs = {
|
|
|
60
53
|
[k: string]: BigNumberish;
|
|
61
54
|
};
|
|
62
55
|
};
|
|
56
|
+
export declare type CallL1Handler = {
|
|
57
|
+
from_address: string;
|
|
58
|
+
to_address: string;
|
|
59
|
+
entry_point_selector: string;
|
|
60
|
+
payload: Array<string>;
|
|
61
|
+
};
|
|
63
62
|
export declare namespace Sequencer {
|
|
64
63
|
type DeclareTransaction = {
|
|
65
64
|
type: 'DECLARE';
|
|
@@ -80,9 +79,8 @@ export declare namespace Sequencer {
|
|
|
80
79
|
contract_address: string;
|
|
81
80
|
signature?: Signature;
|
|
82
81
|
entry_point_type?: EntryPointType;
|
|
83
|
-
entry_point_selector: string;
|
|
84
82
|
calldata?: RawCalldata;
|
|
85
|
-
nonce
|
|
83
|
+
nonce: BigNumberish;
|
|
86
84
|
max_fee?: BigNumberish;
|
|
87
85
|
version?: BigNumberish;
|
|
88
86
|
};
|
|
@@ -99,6 +97,7 @@ export declare namespace Sequencer {
|
|
|
99
97
|
};
|
|
100
98
|
interface InvokeFunctionTransactionResponse extends InvokeFunctionTransaction {
|
|
101
99
|
transaction_hash: string;
|
|
100
|
+
entry_point_selector: string;
|
|
102
101
|
}
|
|
103
102
|
type TransactionResponse = DeclareTransaction | DeployTransaction | InvokeFunctionTransactionResponse;
|
|
104
103
|
type SuccessfulTransactionResponse = {
|
|
@@ -165,11 +164,15 @@ export declare namespace Sequencer {
|
|
|
165
164
|
status: Status;
|
|
166
165
|
gas_price: string;
|
|
167
166
|
sequencer_address: string;
|
|
167
|
+
starknet_version: string;
|
|
168
|
+
};
|
|
169
|
+
type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'> & {
|
|
170
|
+
entry_point_selector: string;
|
|
168
171
|
};
|
|
169
|
-
type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'>;
|
|
170
172
|
type CallContractResponse = {
|
|
171
173
|
result: string[];
|
|
172
174
|
};
|
|
175
|
+
type EstimateFeeTransaction = Omit<InvokeFunctionTransaction, 'max_fee' | 'entry_point_type'>;
|
|
173
176
|
type EstimateFeeResponse = {
|
|
174
177
|
overall_fee: number;
|
|
175
178
|
gas_price: number;
|
|
@@ -217,6 +220,14 @@ export declare namespace Sequencer {
|
|
|
217
220
|
REQUEST: never;
|
|
218
221
|
RESPONSE: TransactionReceiptResponse;
|
|
219
222
|
};
|
|
223
|
+
get_nonce: {
|
|
224
|
+
QUERY: {
|
|
225
|
+
contractAddress: string;
|
|
226
|
+
blockIdentifier: BlockIdentifier;
|
|
227
|
+
};
|
|
228
|
+
REQUEST: never;
|
|
229
|
+
RESPONSE: BigNumberish;
|
|
230
|
+
};
|
|
220
231
|
get_storage_at: {
|
|
221
232
|
QUERY: {
|
|
222
233
|
contractAddress: string;
|
|
@@ -252,7 +263,7 @@ export declare namespace Sequencer {
|
|
|
252
263
|
QUERY: {
|
|
253
264
|
blockIdentifier: BlockIdentifier;
|
|
254
265
|
};
|
|
255
|
-
REQUEST:
|
|
266
|
+
REQUEST: EstimateFeeTransaction;
|
|
256
267
|
RESPONSE: EstimateFeeResponse;
|
|
257
268
|
};
|
|
258
269
|
get_class_by_hash: {
|
|
@@ -285,5 +296,10 @@ export declare namespace Sequencer {
|
|
|
285
296
|
REQUEST: never;
|
|
286
297
|
RESPONSE: any;
|
|
287
298
|
};
|
|
299
|
+
estimate_message_fee: {
|
|
300
|
+
QUERY: any;
|
|
301
|
+
REQUEST: any;
|
|
302
|
+
RESPONSE: EstimateFeeResponse;
|
|
303
|
+
};
|
|
288
304
|
};
|
|
289
305
|
}
|
package/types/lib.d.ts
CHANGED
|
@@ -6,24 +6,30 @@ export declare type RawCalldata = BigNumberish[];
|
|
|
6
6
|
export declare type DeployContractPayload = {
|
|
7
7
|
contract: CompiledContract | string;
|
|
8
8
|
constructorCalldata?: RawCalldata;
|
|
9
|
-
addressSalt?:
|
|
9
|
+
addressSalt?: string;
|
|
10
10
|
};
|
|
11
11
|
export declare type DeclareContractPayload = {
|
|
12
12
|
contract: CompiledContract | string;
|
|
13
13
|
version?: BigNumberish;
|
|
14
14
|
};
|
|
15
|
-
export declare type
|
|
15
|
+
export declare type CallDetails = {
|
|
16
16
|
contractAddress: string;
|
|
17
|
-
entrypoint: string;
|
|
18
17
|
calldata?: RawCalldata;
|
|
18
|
+
};
|
|
19
|
+
export declare type Invocation = CallDetails & {
|
|
19
20
|
signature?: Signature;
|
|
20
21
|
};
|
|
21
|
-
export declare type Call =
|
|
22
|
+
export declare type Call = CallDetails & {
|
|
23
|
+
entrypoint: string;
|
|
24
|
+
};
|
|
22
25
|
export declare type InvocationsDetails = {
|
|
23
26
|
nonce?: BigNumberish;
|
|
24
27
|
maxFee?: BigNumberish;
|
|
25
28
|
version?: BigNumberish;
|
|
26
29
|
};
|
|
30
|
+
export declare type InvocationsDetailsWithNonce = InvocationsDetails & {
|
|
31
|
+
nonce: BigNumberish;
|
|
32
|
+
};
|
|
27
33
|
export declare type Status = 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
28
34
|
export declare type TransactionStatus = 'TRANSACTION_RECEIVED';
|
|
29
35
|
export declare type Type = 'DECLARE' | 'DEPLOY' | 'INVOKE_FUNCTION';
|
package/types/provider.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Intersection (sequencer response ∩ (∪ rpc responses))
|
|
4
4
|
*/
|
|
5
5
|
import BN from 'bn.js';
|
|
6
|
-
import {
|
|
6
|
+
import { RPC } from './api/rpc';
|
|
7
|
+
import { Abi, CompressedProgram, RawCalldata, Signature, Status } from './lib';
|
|
7
8
|
export interface GetBlockResponse {
|
|
8
9
|
timestamp: number;
|
|
9
10
|
block_hash: string;
|
|
@@ -12,6 +13,10 @@ export interface GetBlockResponse {
|
|
|
12
13
|
parent_hash: string;
|
|
13
14
|
status: Status;
|
|
14
15
|
transactions: Array<string>;
|
|
16
|
+
gas_price?: string;
|
|
17
|
+
sequencer_address?: string;
|
|
18
|
+
starknet_version?: string;
|
|
19
|
+
transaction_receipts?: any;
|
|
15
20
|
}
|
|
16
21
|
export interface GetCodeResponse {
|
|
17
22
|
bytecode: string[];
|
|
@@ -35,7 +40,7 @@ export interface ContractEntryPoint {
|
|
|
35
40
|
}
|
|
36
41
|
export interface ContractClass {
|
|
37
42
|
program: CompressedProgram;
|
|
38
|
-
entry_points_by_type:
|
|
43
|
+
entry_points_by_type: RPC.ContractClass['entry_points_by_type'];
|
|
39
44
|
abi?: Abi;
|
|
40
45
|
}
|
|
41
46
|
export interface DeclareTransactionResponse extends CommonTransactionResponse {
|
package/utils/hash.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import BN from 'bn.js';
|
|
|
2
2
|
import { StarknetChainId, TransactionHashPrefix } from '../constants';
|
|
3
3
|
import { RawCalldata } from '../types/lib';
|
|
4
4
|
import { BigNumberish } from './number';
|
|
5
|
-
export declare const transactionVersion =
|
|
5
|
+
export declare const transactionVersion = 1;
|
|
6
6
|
export declare const feeTransactionVersion: BN;
|
|
7
7
|
export declare function keccakBn(value: BigNumberish): string;
|
|
8
8
|
/**
|
|
@@ -21,9 +21,15 @@ export declare function starknetKeccak(value: string): BN;
|
|
|
21
21
|
* @returns hex selector of given abi function name
|
|
22
22
|
*/
|
|
23
23
|
export declare function getSelectorFromName(funcName: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Function to get hex selector from function name, decimal string or hex string
|
|
26
|
+
* @param value hex string | decimal string | string
|
|
27
|
+
* @returns Hex selector
|
|
28
|
+
*/
|
|
29
|
+
export declare function getSelector(value: string): string;
|
|
24
30
|
export declare function pedersen(input: [BigNumberish, BigNumberish]): string;
|
|
25
31
|
export declare function computeHashOnElements(data: BigNumberish[]): string;
|
|
26
32
|
export declare function calculateTransactionHashCommon(txHashPrefix: TransactionHashPrefix, version: BigNumberish, contractAddress: BigNumberish, entryPointSelector: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, additionalData?: BigNumberish[]): string;
|
|
27
33
|
export declare function calculateDeployTransactionHash(contractAddress: BigNumberish, constructorCalldata: BigNumberish[], version: BigNumberish, chainId: StarknetChainId): string;
|
|
28
|
-
export declare function
|
|
34
|
+
export declare function calculateTransactionHash(contractAddress: BigNumberish, version: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
|
|
29
35
|
export declare function calculateContractAddressFromHash(salt: BigNumberish, classHash: BigNumberish, constructorCalldata: RawCalldata, deployerAddress: BigNumberish): string;
|
package/utils/hash.js
CHANGED
|
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
29
|
};
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.calculateContractAddressFromHash = exports.
|
|
31
|
+
exports.calculateContractAddressFromHash = exports.calculateTransactionHash = exports.calculateDeployTransactionHash = exports.calculateTransactionHashCommon = exports.computeHashOnElements = exports.pedersen = exports.getSelector = exports.getSelectorFromName = exports.starknetKeccak = exports.keccakBn = exports.feeTransactionVersion = exports.transactionVersion = void 0;
|
|
32
32
|
var keccak_1 = require("ethereum-cryptography/keccak");
|
|
33
33
|
var utils_1 = require("ethereum-cryptography/utils");
|
|
34
34
|
var minimalistic_assert_1 = __importDefault(require("minimalistic-assert"));
|
|
@@ -36,7 +36,7 @@ var constants_1 = require("../constants");
|
|
|
36
36
|
var ellipticCurve_1 = require("./ellipticCurve");
|
|
37
37
|
var encode_1 = require("./encode");
|
|
38
38
|
var number_1 = require("./number");
|
|
39
|
-
exports.transactionVersion =
|
|
39
|
+
exports.transactionVersion = 1;
|
|
40
40
|
exports.feeTransactionVersion = (0, number_1.toBN)(2).pow((0, number_1.toBN)(128)).add((0, number_1.toBN)(exports.transactionVersion));
|
|
41
41
|
function keccakBn(value) {
|
|
42
42
|
var hexWithoutPrefix = (0, encode_1.removeHexPrefix)((0, number_1.toHex)((0, number_1.toBN)(value)));
|
|
@@ -70,6 +70,21 @@ function getSelectorFromName(funcName) {
|
|
|
70
70
|
return (0, number_1.toHex)(starknetKeccak(funcName));
|
|
71
71
|
}
|
|
72
72
|
exports.getSelectorFromName = getSelectorFromName;
|
|
73
|
+
/**
|
|
74
|
+
* Function to get hex selector from function name, decimal string or hex string
|
|
75
|
+
* @param value hex string | decimal string | string
|
|
76
|
+
* @returns Hex selector
|
|
77
|
+
*/
|
|
78
|
+
function getSelector(value) {
|
|
79
|
+
if ((0, number_1.isHex)(value)) {
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
if ((0, number_1.isStringWholeNumber)(value)) {
|
|
83
|
+
return (0, number_1.toHexString)(value);
|
|
84
|
+
}
|
|
85
|
+
return getSelectorFromName(value);
|
|
86
|
+
}
|
|
87
|
+
exports.getSelector = getSelector;
|
|
73
88
|
var constantPoints = constants_1.CONSTANT_POINTS.map(function (coords) {
|
|
74
89
|
return ellipticCurve_1.ec.curve.point(coords[0], coords[1]);
|
|
75
90
|
});
|
|
@@ -117,10 +132,10 @@ function calculateDeployTransactionHash(contractAddress, constructorCalldata, ve
|
|
|
117
132
|
return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.DEPLOY, version, contractAddress, getSelectorFromName('constructor'), constructorCalldata, constants_1.ZERO, chainId);
|
|
118
133
|
}
|
|
119
134
|
exports.calculateDeployTransactionHash = calculateDeployTransactionHash;
|
|
120
|
-
function
|
|
121
|
-
return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.INVOKE, version, contractAddress,
|
|
135
|
+
function calculateTransactionHash(contractAddress, version, calldata, maxFee, chainId, nonce) {
|
|
136
|
+
return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.INVOKE, version, contractAddress, 0, calldata, maxFee, chainId, [nonce]);
|
|
122
137
|
}
|
|
123
|
-
exports.
|
|
138
|
+
exports.calculateTransactionHash = calculateTransactionHash;
|
|
124
139
|
function calculateContractAddressFromHash(salt, classHash, constructorCalldata, deployerAddress) {
|
|
125
140
|
var constructorCalldataHash = computeHashOnElements(constructorCalldata);
|
|
126
141
|
var CONTRACT_ADDRESS_PREFIX = (0, number_1.toFelt)('0x535441524b4e45545f434f4e54524143545f41444452455353'); // Equivalent to 'STARKNET_CONTRACT_ADDRESS'
|
package/utils/merkle.js
CHANGED
|
@@ -27,6 +27,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.proofMerklePath = exports.MerkleTree = void 0;
|
|
29
29
|
var hash_1 = require("./hash");
|
|
30
|
+
var number_1 = require("./number");
|
|
30
31
|
var MerkleTree = /** @class */ (function () {
|
|
31
32
|
function MerkleTree(leafHashes) {
|
|
32
33
|
this.branches = [];
|
|
@@ -52,7 +53,7 @@ var MerkleTree = /** @class */ (function () {
|
|
|
52
53
|
return this.build(newLeaves);
|
|
53
54
|
};
|
|
54
55
|
MerkleTree.hash = function (a, b) {
|
|
55
|
-
var _a = __read([a, b].sort(), 2), aSorted = _a[0], bSorted = _a[1];
|
|
56
|
+
var _a = __read([(0, number_1.toBN)(a), (0, number_1.toBN)(b)].sort(function (x, y) { return (x.gte(y) ? 1 : -1); }), 2), aSorted = _a[0], bSorted = _a[1];
|
|
56
57
|
return (0, hash_1.pedersen)([aSorted, bSorted]);
|
|
57
58
|
};
|
|
58
59
|
MerkleTree.prototype.getProof = function (leaf, branch, hashPath) {
|
package/utils/number.d.ts
CHANGED
|
@@ -8,3 +8,8 @@ export declare function toFelt(num: BigNumberish): string;
|
|
|
8
8
|
export declare function assertInRange(input: BigNumberish, lowerBound: BigNumberish, upperBound: BigNumberish, inputName?: string): void;
|
|
9
9
|
export declare function bigNumberishArrayToDecimalStringArray(rawCalldata: BigNumberish[]): string[];
|
|
10
10
|
export declare function bigNumberishArrayToHexadecimalStringArray(rawCalldata: BigNumberish[]): string[];
|
|
11
|
+
export declare const isStringWholeNumber: (value: string) => boolean;
|
|
12
|
+
export declare const toHexString: (value: string) => string;
|
|
13
|
+
export declare function getDecimalString(value: string): string;
|
|
14
|
+
export declare function getHexString(value: string): string;
|
|
15
|
+
export declare function getHexStringArray(value: Array<string>): string[];
|
package/utils/number.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.bigNumberishArrayToHexadecimalStringArray = exports.bigNumberishArrayToDecimalStringArray = exports.assertInRange = exports.toFelt = exports.hexToDecimalString = exports.toHex = exports.toBN = exports.isHex = void 0;
|
|
29
|
+
exports.getHexStringArray = exports.getHexString = exports.getDecimalString = exports.toHexString = exports.isStringWholeNumber = exports.bigNumberishArrayToHexadecimalStringArray = exports.bigNumberishArrayToDecimalStringArray = exports.assertInRange = exports.toFelt = exports.hexToDecimalString = exports.toHex = exports.toBN = exports.isHex = void 0;
|
|
30
30
|
var bn_js_1 = __importStar(require("bn.js"));
|
|
31
31
|
var minimalistic_assert_1 = __importDefault(require("minimalistic-assert"));
|
|
32
32
|
var encode_1 = require("./encode");
|
|
@@ -80,3 +80,31 @@ function bigNumberishArrayToHexadecimalStringArray(rawCalldata) {
|
|
|
80
80
|
return rawCalldata.map(function (x) { return toHex(toBN(x)); });
|
|
81
81
|
}
|
|
82
82
|
exports.bigNumberishArrayToHexadecimalStringArray = bigNumberishArrayToHexadecimalStringArray;
|
|
83
|
+
var isStringWholeNumber = function (value) { return /^\d+$/.test(value); };
|
|
84
|
+
exports.isStringWholeNumber = isStringWholeNumber;
|
|
85
|
+
var toHexString = function (value) { return toHex(toBN(value)); };
|
|
86
|
+
exports.toHexString = toHexString;
|
|
87
|
+
function getDecimalString(value) {
|
|
88
|
+
if (isHex(value)) {
|
|
89
|
+
return hexToDecimalString(value);
|
|
90
|
+
}
|
|
91
|
+
if ((0, exports.isStringWholeNumber)(value)) {
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
throw new Error("".concat(value, " need to be hex-string or whole-number-string"));
|
|
95
|
+
}
|
|
96
|
+
exports.getDecimalString = getDecimalString;
|
|
97
|
+
function getHexString(value) {
|
|
98
|
+
if (isHex(value)) {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
if ((0, exports.isStringWholeNumber)(value)) {
|
|
102
|
+
return (0, exports.toHexString)(value);
|
|
103
|
+
}
|
|
104
|
+
throw new Error("".concat(value, " need to be hex-string or whole-number-string"));
|
|
105
|
+
}
|
|
106
|
+
exports.getHexString = getHexString;
|
|
107
|
+
function getHexStringArray(value) {
|
|
108
|
+
return value.map(function (el) { return getHexString(el); });
|
|
109
|
+
}
|
|
110
|
+
exports.getHexStringArray = getHexStringArray;
|