starknet 4.5.0 → 4.6.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 +15 -0
- package/README.md +3 -1
- package/__tests__/defaultProvider.test.ts +7 -9
- package/__tests__/rpcProvider.test.ts +107 -12
- package/__tests__/utils/utils.test.ts +17 -0
- package/dist/provider/rpc.d.ts +12 -2
- package/dist/provider/rpc.js +124 -70
- package/dist/provider/sequencer.js +2 -1
- package/dist/provider/utils.d.ts +11 -35
- package/dist/provider/utils.js +52 -63
- package/dist/types/api/openrpc.d.ts +392 -32
- package/dist/types/api/openrpc.js +21 -3
- package/dist/types/api/rpc.d.ts +74 -107
- package/dist/utils/responseParser/rpc.d.ts +7 -4
- package/dist/utils/responseParser/rpc.js +1 -1
- package/package.json +1 -1
- package/provider/rpc.d.ts +12 -2
- package/provider/rpc.js +124 -70
- package/provider/sequencer.js +2 -1
- package/provider/utils.d.ts +11 -35
- package/provider/utils.js +52 -63
- package/src/provider/rpc.ts +88 -54
- package/src/provider/sequencer.ts +3 -2
- package/src/provider/utils.ts +43 -56
- package/src/types/api/openrpc.ts +371 -41
- package/src/types/api/rpc.ts +71 -125
- package/src/utils/responseParser/rpc.ts +9 -5
- package/types/api/openrpc.d.ts +392 -32
- package/types/api/openrpc.js +21 -3
- package/types/api/rpc.d.ts +74 -107
- package/utils/responseParser/rpc.d.ts +7 -4
- package/utils/responseParser/rpc.js +1 -1
package/src/types/api/rpc.ts
CHANGED
|
@@ -1,135 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BlockIdentifier } from '../../provider/utils';
|
|
3
|
-
import { Status } from '../lib';
|
|
4
|
-
import { OPENRPC } from './openrpc';
|
|
1
|
+
import { ADDRESS, FELT, OPENRPC } from './openrpc';
|
|
5
2
|
|
|
6
3
|
export namespace RPC {
|
|
7
4
|
export type Response = {
|
|
8
5
|
id: number;
|
|
9
|
-
result: any;
|
|
10
6
|
jsonrpc: string;
|
|
7
|
+
result?: any;
|
|
11
8
|
error?: {
|
|
12
9
|
code: string;
|
|
13
10
|
message: string;
|
|
14
11
|
};
|
|
15
12
|
};
|
|
16
13
|
|
|
17
|
-
export type
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export type
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export type
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export type
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export type GetBlockWithTxHashesResponse = OPENRPC.GetBlockWithTxHashesResponse;
|
|
38
|
-
export type GetBlockWithTxs = OPENRPC.GetBlockWithTxs;
|
|
39
|
-
export type GetStorageAtResponse = OPENRPC.GetStorageAtResponse;
|
|
40
|
-
|
|
41
|
-
export type GetTransactionReceiptResponse = {
|
|
42
|
-
txn_hash: string;
|
|
43
|
-
actual_fee: string;
|
|
44
|
-
status: Status;
|
|
45
|
-
status_data: string;
|
|
46
|
-
messages_sent: Array<MessageToL1>;
|
|
47
|
-
l1_origin_message: MessageToL2;
|
|
48
|
-
events: Array<StarknetEvent>;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
interface CommonTransactionProperties {
|
|
52
|
-
txn_hash: string;
|
|
53
|
-
max_fee: string;
|
|
54
|
-
version: string;
|
|
55
|
-
nonce: string;
|
|
56
|
-
signature: Array<string>;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface InvokeTransactionResponse extends CommonTransactionProperties {
|
|
60
|
-
contract_address?: string;
|
|
61
|
-
entry_point_selector?: string;
|
|
62
|
-
calldata?: Array<string>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface DeclareTransactionResponse extends CommonTransactionProperties {
|
|
66
|
-
contract_class?: GetClassResponse;
|
|
67
|
-
sender_address?: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export type GetTransactionByHashResponse = OPENRPC.GetTransactionByHashResponse;
|
|
71
|
-
export type GetTransactionByBlockIdAndIndex = OPENRPC.GetTransactionByBlockIdAndIndex;
|
|
72
|
-
|
|
14
|
+
export type ChainId = OPENRPC.ChainId;
|
|
15
|
+
export type ContractAddress = ADDRESS;
|
|
16
|
+
export type Felt = FELT;
|
|
17
|
+
export type ContractClass = OPENRPC.ContractClass;
|
|
18
|
+
export type StateUpdate = OPENRPC.StateUpdate;
|
|
19
|
+
export type Transaction = OPENRPC.Transaction;
|
|
20
|
+
export type PendingTransactions = OPENRPC.PendingTransactions;
|
|
21
|
+
export type TransactionHash = OPENRPC.TransactionHash;
|
|
22
|
+
export type Trace = OPENRPC.Trace;
|
|
23
|
+
export type Traces = OPENRPC.Traces;
|
|
24
|
+
export type BlockHash = OPENRPC.BlockHash;
|
|
25
|
+
export type BlockHashAndNumber = OPENRPC.BlockHashAndNumber;
|
|
26
|
+
export type GetClassResponse = OPENRPC.ContractClass;
|
|
27
|
+
export type EstimateFeeResponse = OPENRPC.EstimatedFee;
|
|
28
|
+
export type GetBlockWithTxHashesResponse = OPENRPC.BlockWithTxHashes;
|
|
29
|
+
export type GetBlockWithTxs = OPENRPC.BlockWithTxs;
|
|
30
|
+
export type GetStorageAtResponse = OPENRPC.Storage;
|
|
31
|
+
export type TransactionReceipt = OPENRPC.TransactionReceipt;
|
|
32
|
+
export type GetTransactionByHashResponse = OPENRPC.Transaction;
|
|
33
|
+
export type GetTransactionByBlockIdAndIndex = OPENRPC.Transaction;
|
|
73
34
|
export type GetTransactionCountResponse = number;
|
|
74
|
-
|
|
75
|
-
export type
|
|
76
|
-
|
|
77
|
-
export type
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
current_block_hash: string;
|
|
82
|
-
current_block_num: string;
|
|
83
|
-
highest_block_hash: string;
|
|
84
|
-
highest_block_num: string;
|
|
85
|
-
}
|
|
86
|
-
| boolean;
|
|
87
|
-
|
|
88
|
-
export type EventFilter = {
|
|
89
|
-
fromBlock: BlockIdentifier;
|
|
90
|
-
toBlock: BlockIdentifier;
|
|
91
|
-
address: string;
|
|
92
|
-
keys: string[];
|
|
93
|
-
page_size: number;
|
|
94
|
-
page_number: number;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export type GetEventsResponse = {
|
|
98
|
-
events: StarknetEmittedEvent[];
|
|
99
|
-
page_number: number;
|
|
100
|
-
is_last_page: number;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export type DeployContractResponse = {
|
|
104
|
-
transaction_hash: string;
|
|
105
|
-
contract_address: string;
|
|
106
|
-
};
|
|
107
|
-
// Other
|
|
108
|
-
|
|
109
|
-
export type StarknetEvent = {
|
|
110
|
-
from_address: string;
|
|
111
|
-
keys: string[];
|
|
112
|
-
data: string[];
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export type StarknetEmittedEvent = {
|
|
116
|
-
event: StarknetEvent;
|
|
117
|
-
block_hash: string;
|
|
118
|
-
block_number: number;
|
|
119
|
-
transaction_hash: string;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export type MessageToL1 = {
|
|
123
|
-
to_address: string;
|
|
124
|
-
payload: string[];
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export type MessageToL2 = {
|
|
128
|
-
from_address: string;
|
|
129
|
-
payload: string[];
|
|
130
|
-
};
|
|
35
|
+
export type GetBlockNumberResponse = OPENRPC.BlockNumber;
|
|
36
|
+
export type GetSyncingStatsResponse = OPENRPC.SyncingStatus;
|
|
37
|
+
export type EventFilter = OPENRPC.EventFilter;
|
|
38
|
+
export type GetEventsResponse = OPENRPC.Events;
|
|
39
|
+
export type InvokedTransaction = OPENRPC.InvokedTransaction;
|
|
40
|
+
export type DeclaredTransaction = OPENRPC.DeclaredTransaction;
|
|
41
|
+
export type DeployedTransaction = OPENRPC.DeployedTransaction;
|
|
131
42
|
|
|
132
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
|
+
};
|
|
133
69
|
starknet_getBlockWithTxHashes: {
|
|
134
70
|
QUERY: never;
|
|
135
71
|
REQUEST: any[];
|
|
@@ -143,7 +79,7 @@ export namespace RPC {
|
|
|
143
79
|
starknet_getNonce: {
|
|
144
80
|
QUERY: never;
|
|
145
81
|
REQUEST: any[];
|
|
146
|
-
RESPONSE:
|
|
82
|
+
RESPONSE: OPENRPC.Nonce;
|
|
147
83
|
};
|
|
148
84
|
starknet_getStorageAt: {
|
|
149
85
|
QUERY: never;
|
|
@@ -163,7 +99,7 @@ export namespace RPC {
|
|
|
163
99
|
starknet_getTransactionReceipt: {
|
|
164
100
|
QUERY: never;
|
|
165
101
|
REQUEST: any[];
|
|
166
|
-
RESPONSE:
|
|
102
|
+
RESPONSE: TransactionReceipt;
|
|
167
103
|
};
|
|
168
104
|
starknet_getBlockTransactionCount: {
|
|
169
105
|
QUERY: never;
|
|
@@ -178,7 +114,7 @@ export namespace RPC {
|
|
|
178
114
|
starknet_estimateFee: {
|
|
179
115
|
QUERY: never;
|
|
180
116
|
REQUEST: any[];
|
|
181
|
-
RESPONSE:
|
|
117
|
+
RESPONSE: OPENRPC.EstimatedFee;
|
|
182
118
|
};
|
|
183
119
|
starknet_blockNumber: {
|
|
184
120
|
QUERY: never;
|
|
@@ -188,7 +124,7 @@ export namespace RPC {
|
|
|
188
124
|
starknet_chainId: {
|
|
189
125
|
QUERY: never;
|
|
190
126
|
REQUEST: any[];
|
|
191
|
-
RESPONSE:
|
|
127
|
+
RESPONSE: OPENRPC.ChainId;
|
|
192
128
|
};
|
|
193
129
|
starknet_syncing: {
|
|
194
130
|
QUERY: never;
|
|
@@ -203,22 +139,32 @@ export namespace RPC {
|
|
|
203
139
|
starknet_addInvokeTransaction: {
|
|
204
140
|
QUERY: never;
|
|
205
141
|
REQUEST: any[];
|
|
206
|
-
RESPONSE:
|
|
142
|
+
RESPONSE: OPENRPC.InvokedTransaction;
|
|
207
143
|
};
|
|
208
144
|
starknet_addDeployTransaction: {
|
|
209
145
|
QUERY: never;
|
|
210
146
|
REQUEST: any[];
|
|
211
|
-
RESPONSE:
|
|
147
|
+
RESPONSE: OPENRPC.DeployedTransaction;
|
|
212
148
|
};
|
|
213
149
|
starknet_addDeclareTransaction: {
|
|
214
150
|
QUERY: never;
|
|
215
151
|
REQUEST: any[];
|
|
216
|
-
RESPONSE:
|
|
152
|
+
RESPONSE: OPENRPC.DeclaredTransaction;
|
|
217
153
|
};
|
|
218
154
|
starknet_getClassAt: {
|
|
219
155
|
QUERY: never;
|
|
220
156
|
REQUEST: any[];
|
|
221
157
|
RESPONSE: any;
|
|
222
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
|
+
};
|
|
223
169
|
};
|
|
224
170
|
}
|
|
@@ -24,6 +24,10 @@ type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
|
|
|
24
24
|
[key: string]: any;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
type TransactionReceipt = RPC.TransactionReceipt & {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
30
|
+
|
|
27
31
|
export class RPCResponseParser extends ResponseParser {
|
|
28
32
|
public parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse {
|
|
29
33
|
return {
|
|
@@ -51,10 +55,10 @@ export class RPCResponseParser extends ResponseParser {
|
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
public parseGetTransactionReceiptResponse(
|
|
54
|
-
res:
|
|
58
|
+
res: TransactionReceipt
|
|
55
59
|
): GetTransactionReceiptResponse {
|
|
56
60
|
return {
|
|
57
|
-
transaction_hash: res.
|
|
61
|
+
transaction_hash: res.transaction_hash,
|
|
58
62
|
actual_fee: res.actual_fee,
|
|
59
63
|
status: res.status,
|
|
60
64
|
status_data: res.status_data,
|
|
@@ -78,20 +82,20 @@ export class RPCResponseParser extends ResponseParser {
|
|
|
78
82
|
};
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
public parseInvokeFunctionResponse(res: RPC.
|
|
85
|
+
public parseInvokeFunctionResponse(res: RPC.InvokedTransaction): InvokeFunctionResponse {
|
|
82
86
|
return {
|
|
83
87
|
transaction_hash: res.transaction_hash,
|
|
84
88
|
};
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
public parseDeployContractResponse(res: RPC.
|
|
91
|
+
public parseDeployContractResponse(res: RPC.DeployedTransaction): DeployContractResponse {
|
|
88
92
|
return {
|
|
89
93
|
transaction_hash: res.transaction_hash,
|
|
90
94
|
contract_address: res.contract_address,
|
|
91
95
|
};
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
public parseDeclareContractResponse(res: RPC.
|
|
98
|
+
public parseDeclareContractResponse(res: RPC.DeclaredTransaction): DeclareContractResponse {
|
|
95
99
|
return {
|
|
96
100
|
transaction_hash: res.transaction_hash,
|
|
97
101
|
class_hash: res.class_hash,
|