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/types/api/rpc.d.ts
CHANGED
|
@@ -1,110 +1,68 @@
|
|
|
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
|
export declare namespace RPC {
|
|
6
|
-
|
|
3
|
+
type Response = {
|
|
7
4
|
id: number;
|
|
8
|
-
result: any;
|
|
9
5
|
jsonrpc: string;
|
|
6
|
+
result?: any;
|
|
10
7
|
error?: {
|
|
11
8
|
code: string;
|
|
12
9
|
message: string;
|
|
13
10
|
};
|
|
14
11
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
highest_block_num: string;
|
|
70
|
-
} | boolean;
|
|
71
|
-
export type EventFilter = {
|
|
72
|
-
fromBlock: BlockIdentifier;
|
|
73
|
-
toBlock: BlockIdentifier;
|
|
74
|
-
address: string;
|
|
75
|
-
keys: string[];
|
|
76
|
-
page_size: number;
|
|
77
|
-
page_number: number;
|
|
78
|
-
};
|
|
79
|
-
export type GetEventsResponse = {
|
|
80
|
-
events: StarknetEmittedEvent[];
|
|
81
|
-
page_number: number;
|
|
82
|
-
is_last_page: number;
|
|
83
|
-
};
|
|
84
|
-
export type DeployContractResponse = {
|
|
85
|
-
transaction_hash: string;
|
|
86
|
-
contract_address: string;
|
|
87
|
-
};
|
|
88
|
-
export type StarknetEvent = {
|
|
89
|
-
from_address: string;
|
|
90
|
-
keys: string[];
|
|
91
|
-
data: string[];
|
|
92
|
-
};
|
|
93
|
-
export type StarknetEmittedEvent = {
|
|
94
|
-
event: StarknetEvent;
|
|
95
|
-
block_hash: string;
|
|
96
|
-
block_number: number;
|
|
97
|
-
transaction_hash: string;
|
|
98
|
-
};
|
|
99
|
-
export type MessageToL1 = {
|
|
100
|
-
to_address: string;
|
|
101
|
-
payload: string[];
|
|
102
|
-
};
|
|
103
|
-
export type MessageToL2 = {
|
|
104
|
-
from_address: string;
|
|
105
|
-
payload: string[];
|
|
106
|
-
};
|
|
107
|
-
export type Methods = {
|
|
12
|
+
type ChainId = OPENRPC.ChainId;
|
|
13
|
+
type ContractAddress = ADDRESS;
|
|
14
|
+
type Felt = FELT;
|
|
15
|
+
type ContractClass = OPENRPC.ContractClass;
|
|
16
|
+
type StateUpdate = OPENRPC.StateUpdate;
|
|
17
|
+
type Transaction = OPENRPC.Transaction;
|
|
18
|
+
type PendingTransactions = OPENRPC.PendingTransactions;
|
|
19
|
+
type TransactionHash = OPENRPC.TransactionHash;
|
|
20
|
+
type Trace = OPENRPC.Trace;
|
|
21
|
+
type Traces = OPENRPC.Traces;
|
|
22
|
+
type BlockHash = OPENRPC.BlockHash;
|
|
23
|
+
type BlockHashAndNumber = OPENRPC.BlockHashAndNumber;
|
|
24
|
+
type GetClassResponse = OPENRPC.ContractClass;
|
|
25
|
+
type EstimateFeeResponse = OPENRPC.EstimatedFee;
|
|
26
|
+
type GetBlockWithTxHashesResponse = OPENRPC.BlockWithTxHashes;
|
|
27
|
+
type GetBlockWithTxs = OPENRPC.BlockWithTxs;
|
|
28
|
+
type GetStorageAtResponse = OPENRPC.Storage;
|
|
29
|
+
type TransactionReceipt = OPENRPC.TransactionReceipt;
|
|
30
|
+
type GetTransactionByHashResponse = OPENRPC.Transaction;
|
|
31
|
+
type GetTransactionByBlockIdAndIndex = OPENRPC.Transaction;
|
|
32
|
+
type GetTransactionCountResponse = number;
|
|
33
|
+
type GetBlockNumberResponse = OPENRPC.BlockNumber;
|
|
34
|
+
type GetSyncingStatsResponse = OPENRPC.SyncingStatus;
|
|
35
|
+
type EventFilter = OPENRPC.EventFilter;
|
|
36
|
+
type GetEventsResponse = OPENRPC.Events;
|
|
37
|
+
type InvokedTransaction = OPENRPC.InvokedTransaction;
|
|
38
|
+
type DeclaredTransaction = OPENRPC.DeclaredTransaction;
|
|
39
|
+
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
|
+
};
|
|
108
66
|
starknet_getBlockWithTxHashes: {
|
|
109
67
|
QUERY: never;
|
|
110
68
|
REQUEST: any[];
|
|
@@ -118,7 +76,7 @@ export declare namespace RPC {
|
|
|
118
76
|
starknet_getNonce: {
|
|
119
77
|
QUERY: never;
|
|
120
78
|
REQUEST: any[];
|
|
121
|
-
RESPONSE:
|
|
79
|
+
RESPONSE: OPENRPC.Nonce;
|
|
122
80
|
};
|
|
123
81
|
starknet_getStorageAt: {
|
|
124
82
|
QUERY: never;
|
|
@@ -138,7 +96,7 @@ export declare namespace RPC {
|
|
|
138
96
|
starknet_getTransactionReceipt: {
|
|
139
97
|
QUERY: never;
|
|
140
98
|
REQUEST: any[];
|
|
141
|
-
RESPONSE:
|
|
99
|
+
RESPONSE: TransactionReceipt;
|
|
142
100
|
};
|
|
143
101
|
starknet_getBlockTransactionCount: {
|
|
144
102
|
QUERY: never;
|
|
@@ -153,7 +111,7 @@ export declare namespace RPC {
|
|
|
153
111
|
starknet_estimateFee: {
|
|
154
112
|
QUERY: never;
|
|
155
113
|
REQUEST: any[];
|
|
156
|
-
RESPONSE:
|
|
114
|
+
RESPONSE: OPENRPC.EstimatedFee;
|
|
157
115
|
};
|
|
158
116
|
starknet_blockNumber: {
|
|
159
117
|
QUERY: never;
|
|
@@ -163,7 +121,7 @@ export declare namespace RPC {
|
|
|
163
121
|
starknet_chainId: {
|
|
164
122
|
QUERY: never;
|
|
165
123
|
REQUEST: any[];
|
|
166
|
-
RESPONSE:
|
|
124
|
+
RESPONSE: OPENRPC.ChainId;
|
|
167
125
|
};
|
|
168
126
|
starknet_syncing: {
|
|
169
127
|
QUERY: never;
|
|
@@ -178,23 +136,32 @@ export declare namespace RPC {
|
|
|
178
136
|
starknet_addInvokeTransaction: {
|
|
179
137
|
QUERY: never;
|
|
180
138
|
REQUEST: any[];
|
|
181
|
-
RESPONSE:
|
|
139
|
+
RESPONSE: OPENRPC.InvokedTransaction;
|
|
182
140
|
};
|
|
183
141
|
starknet_addDeployTransaction: {
|
|
184
142
|
QUERY: never;
|
|
185
143
|
REQUEST: any[];
|
|
186
|
-
RESPONSE:
|
|
144
|
+
RESPONSE: OPENRPC.DeployedTransaction;
|
|
187
145
|
};
|
|
188
146
|
starknet_addDeclareTransaction: {
|
|
189
147
|
QUERY: never;
|
|
190
148
|
REQUEST: any[];
|
|
191
|
-
RESPONSE:
|
|
149
|
+
RESPONSE: OPENRPC.DeclaredTransaction;
|
|
192
150
|
};
|
|
193
151
|
starknet_getClassAt: {
|
|
194
152
|
QUERY: never;
|
|
195
153
|
REQUEST: any[];
|
|
196
154
|
RESPONSE: any;
|
|
197
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
|
+
};
|
|
198
166
|
};
|
|
199
|
-
export {};
|
|
200
167
|
}
|
|
@@ -11,14 +11,17 @@ declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
|
|
|
11
11
|
declare type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
};
|
|
14
|
+
declare type TransactionReceipt = RPC.TransactionReceipt & {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
14
17
|
export declare class RPCResponseParser extends ResponseParser {
|
|
15
18
|
parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse;
|
|
16
19
|
parseGetTransactionResponse(res: GetTransactionByHashResponse): GetTransactionResponse;
|
|
17
|
-
parseGetTransactionReceiptResponse(res:
|
|
20
|
+
parseGetTransactionReceiptResponse(res: TransactionReceipt): GetTransactionReceiptResponse;
|
|
18
21
|
parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse;
|
|
19
22
|
parseCallContractResponse(res: Array<string>): CallContractResponse;
|
|
20
|
-
parseInvokeFunctionResponse(res: RPC.
|
|
21
|
-
parseDeployContractResponse(res: RPC.
|
|
22
|
-
parseDeclareContractResponse(res: RPC.
|
|
23
|
+
parseInvokeFunctionResponse(res: RPC.InvokedTransaction): InvokeFunctionResponse;
|
|
24
|
+
parseDeployContractResponse(res: RPC.DeployedTransaction): DeployContractResponse;
|
|
25
|
+
parseDeclareContractResponse(res: RPC.DeclaredTransaction): DeclareContractResponse;
|
|
23
26
|
}
|
|
24
27
|
export {};
|
|
@@ -48,7 +48,7 @@ var RPCResponseParser = /** @class */ (function (_super) {
|
|
|
48
48
|
};
|
|
49
49
|
RPCResponseParser.prototype.parseGetTransactionReceiptResponse = function (res) {
|
|
50
50
|
return {
|
|
51
|
-
transaction_hash: res.
|
|
51
|
+
transaction_hash: res.transaction_hash,
|
|
52
52
|
actual_fee: res.actual_fee,
|
|
53
53
|
status: res.status,
|
|
54
54
|
status_data: res.status_data,
|