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.
@@ -1,135 +1,71 @@
1
- import { StarknetChainId } from '../../constants';
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 AddTransactionResponse = {
18
- transaction_hash: string;
19
- };
20
-
21
- export type GetClassResponse = {
22
- program: string;
23
- entry_point_by_type: any;
24
- };
25
-
26
- export type DeclareResponse = {
27
- transaction_hash: string;
28
- class_hash: string;
29
- };
30
-
31
- export type EstimateFeeResponse = {
32
- overall_fee: number;
33
- gas_consumed: number;
34
- gas_price: number;
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 GetBlockNumberResponse = number;
76
-
77
- export type GetSyncingStatsResponse =
78
- | {
79
- starting_block_hash: string;
80
- starting_block_num: string;
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: string;
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: GetTransactionReceiptResponse;
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: EstimateFeeResponse;
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: StarknetChainId;
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: AddTransactionResponse;
142
+ RESPONSE: OPENRPC.InvokedTransaction;
207
143
  };
208
144
  starknet_addDeployTransaction: {
209
145
  QUERY: never;
210
146
  REQUEST: any[];
211
- RESPONSE: DeployContractResponse;
147
+ RESPONSE: OPENRPC.DeployedTransaction;
212
148
  };
213
149
  starknet_addDeclareTransaction: {
214
150
  QUERY: never;
215
151
  REQUEST: any[];
216
- RESPONSE: DeclareResponse;
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: RPC.GetTransactionReceiptResponse
58
+ res: TransactionReceipt
55
59
  ): GetTransactionReceiptResponse {
56
60
  return {
57
- transaction_hash: res.txn_hash,
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.AddTransactionResponse): InvokeFunctionResponse {
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.DeployContractResponse): DeployContractResponse {
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.DeclareResponse): DeclareContractResponse {
98
+ public parseDeclareContractResponse(res: RPC.DeclaredTransaction): DeclareContractResponse {
95
99
  return {
96
100
  transaction_hash: res.transaction_hash,
97
101
  class_hash: res.class_hash,