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
|
@@ -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/dist/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
|
}
|
|
@@ -80,9 +80,8 @@ export declare namespace Sequencer {
|
|
|
80
80
|
contract_address: string;
|
|
81
81
|
signature?: Signature;
|
|
82
82
|
entry_point_type?: EntryPointType;
|
|
83
|
-
entry_point_selector: string;
|
|
84
83
|
calldata?: RawCalldata;
|
|
85
|
-
nonce
|
|
84
|
+
nonce: BigNumberish;
|
|
86
85
|
max_fee?: BigNumberish;
|
|
87
86
|
version?: BigNumberish;
|
|
88
87
|
};
|
|
@@ -99,6 +98,7 @@ export declare namespace Sequencer {
|
|
|
99
98
|
};
|
|
100
99
|
interface InvokeFunctionTransactionResponse extends InvokeFunctionTransaction {
|
|
101
100
|
transaction_hash: string;
|
|
101
|
+
entry_point_selector: string;
|
|
102
102
|
}
|
|
103
103
|
type TransactionResponse = DeclareTransaction | DeployTransaction | InvokeFunctionTransactionResponse;
|
|
104
104
|
type SuccessfulTransactionResponse = {
|
|
@@ -166,10 +166,13 @@ export declare namespace Sequencer {
|
|
|
166
166
|
gas_price: string;
|
|
167
167
|
sequencer_address: string;
|
|
168
168
|
};
|
|
169
|
-
type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'
|
|
169
|
+
type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'> & {
|
|
170
|
+
entry_point_selector: string;
|
|
171
|
+
};
|
|
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: {
|
package/dist/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/dist/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;
|
|
@@ -35,7 +36,7 @@ export interface ContractEntryPoint {
|
|
|
35
36
|
}
|
|
36
37
|
export interface ContractClass {
|
|
37
38
|
program: CompressedProgram;
|
|
38
|
-
entry_points_by_type:
|
|
39
|
+
entry_points_by_type: RPC.ContractClass['entry_points_by_type'];
|
|
39
40
|
abi?: Abi;
|
|
40
41
|
}
|
|
41
42
|
export interface DeclareTransactionResponse extends CommonTransactionResponse {
|
package/dist/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
|
/**
|
|
@@ -25,5 +25,5 @@ export declare function pedersen(input: [BigNumberish, BigNumberish]): string;
|
|
|
25
25
|
export declare function computeHashOnElements(data: BigNumberish[]): string;
|
|
26
26
|
export declare function calculateTransactionHashCommon(txHashPrefix: TransactionHashPrefix, version: BigNumberish, contractAddress: BigNumberish, entryPointSelector: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, additionalData?: BigNumberish[]): string;
|
|
27
27
|
export declare function calculateDeployTransactionHash(contractAddress: BigNumberish, constructorCalldata: BigNumberish[], version: BigNumberish, chainId: StarknetChainId): string;
|
|
28
|
-
export declare function
|
|
28
|
+
export declare function calculateTransactionHash(contractAddress: BigNumberish, version: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
|
|
29
29
|
export declare function calculateContractAddressFromHash(salt: BigNumberish, classHash: BigNumberish, constructorCalldata: RawCalldata, deployerAddress: BigNumberish): string;
|
package/dist/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.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)));
|
|
@@ -117,10 +117,10 @@ function calculateDeployTransactionHash(contractAddress, constructorCalldata, ve
|
|
|
117
117
|
return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.DEPLOY, version, contractAddress, getSelectorFromName('constructor'), constructorCalldata, constants_1.ZERO, chainId);
|
|
118
118
|
}
|
|
119
119
|
exports.calculateDeployTransactionHash = calculateDeployTransactionHash;
|
|
120
|
-
function
|
|
121
|
-
return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.INVOKE, version, contractAddress,
|
|
120
|
+
function calculateTransactionHash(contractAddress, version, calldata, maxFee, chainId, nonce) {
|
|
121
|
+
return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.INVOKE, version, contractAddress, 0, calldata, maxFee, chainId, [nonce]);
|
|
122
122
|
}
|
|
123
|
-
exports.
|
|
123
|
+
exports.calculateTransactionHash = calculateTransactionHash;
|
|
124
124
|
function calculateContractAddressFromHash(salt, classHash, constructorCalldata, deployerAddress) {
|
|
125
125
|
var constructorCalldataHash = computeHashOnElements(constructorCalldata);
|
|
126
126
|
var CONTRACT_ADDRESS_PREFIX = (0, number_1.toFelt)('0x535441524b4e45545f434f4e54524143545f41444452455353'); // Equivalent to 'STARKNET_CONTRACT_ADDRESS'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Map RPC Response to common interface response
|
|
3
3
|
* Intersection (sequencer response ∩ (∪ rpc responses))
|
|
4
4
|
*/
|
|
5
|
-
import { CallContractResponse,
|
|
5
|
+
import { CallContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse } from '../../types';
|
|
6
6
|
import { RPC } from '../../types/api';
|
|
7
7
|
import { ResponseParser } from '.';
|
|
8
8
|
declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
|
|
@@ -14,14 +14,11 @@ declare type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
|
|
|
14
14
|
declare type TransactionReceipt = RPC.TransactionReceipt & {
|
|
15
15
|
[key: string]: any;
|
|
16
16
|
};
|
|
17
|
-
export declare class RPCResponseParser
|
|
17
|
+
export declare class RPCResponseParser implements Omit<ResponseParser, 'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse'> {
|
|
18
18
|
parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse;
|
|
19
19
|
parseGetTransactionResponse(res: GetTransactionByHashResponse): GetTransactionResponse;
|
|
20
20
|
parseGetTransactionReceiptResponse(res: TransactionReceipt): GetTransactionReceiptResponse;
|
|
21
21
|
parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse;
|
|
22
22
|
parseCallContractResponse(res: Array<string>): CallContractResponse;
|
|
23
|
-
parseInvokeFunctionResponse(res: RPC.InvokedTransaction): InvokeFunctionResponse;
|
|
24
|
-
parseDeployContractResponse(res: RPC.DeployedTransaction): DeployContractResponse;
|
|
25
|
-
parseDeclareContractResponse(res: RPC.DeclaredTransaction): DeclareContractResponse;
|
|
26
23
|
}
|
|
27
24
|
export {};
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.RPCResponseParser = void 0;
|
|
19
4
|
var number_1 = require("../number");
|
|
20
|
-
var
|
|
21
|
-
var RPCResponseParser = /** @class */ (function (_super) {
|
|
22
|
-
__extends(RPCResponseParser, _super);
|
|
5
|
+
var RPCResponseParser = /** @class */ (function () {
|
|
23
6
|
function RPCResponseParser() {
|
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
7
|
}
|
|
26
8
|
RPCResponseParser.prototype.parseGetBlockResponse = function (res) {
|
|
27
9
|
return {
|
|
@@ -38,7 +20,6 @@ var RPCResponseParser = /** @class */ (function (_super) {
|
|
|
38
20
|
return {
|
|
39
21
|
calldata: res.calldata || [],
|
|
40
22
|
contract_address: res.contract_address,
|
|
41
|
-
entry_point_selector: res.entry_point_selector,
|
|
42
23
|
max_fee: res.max_fee,
|
|
43
24
|
nonce: res.nonce,
|
|
44
25
|
signature: res.signature || [],
|
|
@@ -69,23 +50,6 @@ var RPCResponseParser = /** @class */ (function (_super) {
|
|
|
69
50
|
result: res,
|
|
70
51
|
};
|
|
71
52
|
};
|
|
72
|
-
RPCResponseParser.prototype.parseInvokeFunctionResponse = function (res) {
|
|
73
|
-
return {
|
|
74
|
-
transaction_hash: res.transaction_hash,
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
RPCResponseParser.prototype.parseDeployContractResponse = function (res) {
|
|
78
|
-
return {
|
|
79
|
-
transaction_hash: res.transaction_hash,
|
|
80
|
-
contract_address: res.contract_address,
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
RPCResponseParser.prototype.parseDeclareContractResponse = function (res) {
|
|
84
|
-
return {
|
|
85
|
-
transaction_hash: res.transaction_hash,
|
|
86
|
-
class_hash: res.class_hash,
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
53
|
return RPCResponseParser;
|
|
90
|
-
}(
|
|
54
|
+
}());
|
|
91
55
|
exports.RPCResponseParser = RPCResponseParser;
|
package/package.json
CHANGED
package/provider/default.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import { Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation,
|
|
2
|
+
import { Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
|
|
3
3
|
import { BigNumberish } from '../utils/number';
|
|
4
4
|
import { ProviderInterface } from './interface';
|
|
5
5
|
import { RpcProviderOptions } from './rpc';
|
|
@@ -16,12 +16,13 @@ export declare class Provider implements ProviderInterface {
|
|
|
16
16
|
getChainId(): Promise<StarknetChainId>;
|
|
17
17
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
18
18
|
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
19
|
-
getEstimateFee(invocation: Invocation,
|
|
19
|
+
getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
20
|
+
getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
20
21
|
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
21
22
|
getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
22
23
|
getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
23
24
|
callContract(request: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
24
|
-
invokeFunction(functionInvocation: Invocation, details:
|
|
25
|
+
invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
25
26
|
deployContract(payload: DeployContractPayload): Promise<DeployContractResponse>;
|
|
26
27
|
declareContract(payload: DeclareContractPayload): Promise<DeclareContractResponse>;
|
|
27
28
|
getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
package/provider/default.js
CHANGED
|
@@ -84,12 +84,18 @@ var Provider = /** @class */ (function () {
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
|
-
Provider.prototype.getEstimateFee = function (invocation,
|
|
87
|
+
Provider.prototype.getEstimateFee = function (invocation, invocationDetails, blockIdentifier) {
|
|
88
88
|
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
89
|
-
if (invocationDetails === void 0) { invocationDetails = {}; }
|
|
90
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
91
90
|
return __generator(this, function (_a) {
|
|
92
|
-
return [2 /*return*/, this.provider.getEstimateFee(invocation,
|
|
91
|
+
return [2 /*return*/, this.provider.getEstimateFee(invocation, invocationDetails, blockIdentifier)];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
Provider.prototype.getNonce = function (contractAddress, blockIdentifier) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
return [2 /*return*/, this.provider.getNonce(contractAddress, blockIdentifier)];
|
|
93
99
|
});
|
|
94
100
|
});
|
|
95
101
|
};
|
package/provider/interface.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import type { Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation,
|
|
2
|
+
import type { Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
|
|
3
3
|
import type { BigNumberish } from '../utils/number';
|
|
4
4
|
import { BlockIdentifier } from './utils';
|
|
5
5
|
export declare abstract class ProviderInterface {
|
|
@@ -37,6 +37,13 @@ export declare abstract class ProviderInterface {
|
|
|
37
37
|
* @returns Contract class of compiled contract
|
|
38
38
|
*/
|
|
39
39
|
abstract getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the nonce of a contract with respect to a specific block
|
|
42
|
+
*
|
|
43
|
+
* @param contractAddress - contract address
|
|
44
|
+
* @returns the hex nonce
|
|
45
|
+
*/
|
|
46
|
+
abstract getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
40
47
|
/**
|
|
41
48
|
* Gets the contract's storage variable at a specific key.
|
|
42
49
|
*
|
|
@@ -94,7 +101,7 @@ export declare abstract class ProviderInterface {
|
|
|
94
101
|
* - maxFee - optional maxFee
|
|
95
102
|
* @returns response from addTransaction
|
|
96
103
|
*/
|
|
97
|
-
abstract invokeFunction(invocation: Invocation, details
|
|
104
|
+
abstract invokeFunction(invocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
98
105
|
/**
|
|
99
106
|
* Estimates the fee for a given transaction
|
|
100
107
|
*
|
|
@@ -109,7 +116,7 @@ export declare abstract class ProviderInterface {
|
|
|
109
116
|
* - version - optional version
|
|
110
117
|
* @returns the estimated fee
|
|
111
118
|
*/
|
|
112
|
-
abstract getEstimateFee(invocation: Invocation,
|
|
119
|
+
abstract getEstimateFee(invocation: Invocation, details: InvocationsDetailsWithNonce, blockIdentifier: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
113
120
|
/**
|
|
114
121
|
* Wait for the transaction to be accepted
|
|
115
122
|
* @param txHash - transaction hash
|