starknet 4.5.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 +40 -0
- package/README.md +3 -1
- package/__tests__/account.test.ts +2 -5
- package/__tests__/contract.test.ts +0 -1
- package/__tests__/defaultProvider.test.ts +16 -10
- package/__tests__/rpcProvider.test.ts +107 -12
- package/__tests__/sequencerProvider.test.ts +10 -8
- package/__tests__/utils/ellipticalCurve.test.ts +7 -8
- package/__tests__/utils/utils.test.ts +17 -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 +24 -12
- package/dist/provider/rpc.js +167 -105
- package/dist/provider/sequencer.d.ts +4 -3
- package/dist/provider/sequencer.js +16 -7
- package/dist/provider/utils.d.ts +11 -35
- package/dist/provider/utils.js +52 -63
- 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 +395 -45
- package/dist/types/api/openrpc.js +21 -3
- package/dist/types/api/rpc.d.ts +34 -191
- 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 +6 -6
- package/dist/utils/responseParser/rpc.js +3 -39
- 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 +24 -12
- package/provider/rpc.js +167 -105
- package/provider/sequencer.d.ts +4 -3
- package/provider/sequencer.js +16 -7
- package/provider/utils.d.ts +11 -35
- package/provider/utils.js +52 -63
- 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 +152 -102
- package/src/provider/sequencer.ts +19 -10
- package/src/provider/utils.ts +43 -56
- package/src/signer/default.ts +8 -8
- package/src/signer/interface.ts +2 -2
- package/src/types/api/openrpc.ts +378 -53
- package/src/types/api/rpc.ts +33 -211
- 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 +13 -27
- package/types/api/openrpc.d.ts +395 -45
- package/types/api/openrpc.js +21 -3
- package/types/api/rpc.d.ts +34 -191
- 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 +6 -6
- package/utils/responseParser/rpc.js +3 -39
- 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
package/src/types/api/rpc.ts
CHANGED
|
@@ -1,224 +1,46 @@
|
|
|
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
|
|
38
|
-
export type
|
|
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.CHAIN_ID;
|
|
15
|
+
export type CallResponse = OPENRPC.CallResponse;
|
|
16
|
+
export type ContractAddress = ADDRESS;
|
|
17
|
+
export type Felt = FELT;
|
|
18
|
+
export type Nonce = OPENRPC.Nonce;
|
|
19
|
+
export type ContractClass = OPENRPC.ContractClass;
|
|
20
|
+
export type StateUpdate = OPENRPC.StateUpdate;
|
|
21
|
+
export type Transaction = OPENRPC.Transaction;
|
|
22
|
+
export type PendingTransactions = OPENRPC.PendingTransactions;
|
|
23
|
+
export type TransactionHash = OPENRPC.TransactionHash;
|
|
24
|
+
export type Trace = OPENRPC.Trace;
|
|
25
|
+
export type Traces = OPENRPC.Traces;
|
|
26
|
+
export type BlockHash = OPENRPC.BlockHash;
|
|
27
|
+
export type BlockHashAndNumber = OPENRPC.BlockHashAndNumber;
|
|
28
|
+
export type GetClassResponse = OPENRPC.ContractClass;
|
|
29
|
+
export type EstimateFeeResponse = OPENRPC.EstimatedFee;
|
|
30
|
+
export type GetBlockWithTxHashesResponse = OPENRPC.BlockWithTxHashes;
|
|
31
|
+
export type GetBlockWithTxs = OPENRPC.BlockWithTxs;
|
|
32
|
+
export type GetStorageAtResponse = OPENRPC.Storage;
|
|
33
|
+
export type TransactionReceipt = OPENRPC.TransactionReceipt;
|
|
34
|
+
export type GetTransactionByHashResponse = OPENRPC.Transaction;
|
|
35
|
+
export type GetTransactionByBlockIdAndIndex = OPENRPC.Transaction;
|
|
73
36
|
export type GetTransactionCountResponse = number;
|
|
74
|
-
|
|
75
|
-
export type
|
|
76
|
-
|
|
77
|
-
export type
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
};
|
|
131
|
-
|
|
132
|
-
export type Methods = {
|
|
133
|
-
starknet_getBlockWithTxHashes: {
|
|
134
|
-
QUERY: never;
|
|
135
|
-
REQUEST: any[];
|
|
136
|
-
RESPONSE: GetBlockWithTxHashesResponse;
|
|
137
|
-
};
|
|
138
|
-
starknet_getBlockWithTxs: {
|
|
139
|
-
QUERY: never;
|
|
140
|
-
REQUEST: any[];
|
|
141
|
-
RESPONSE: GetBlockWithTxs;
|
|
142
|
-
};
|
|
143
|
-
starknet_getNonce: {
|
|
144
|
-
QUERY: never;
|
|
145
|
-
REQUEST: any[];
|
|
146
|
-
RESPONSE: string;
|
|
147
|
-
};
|
|
148
|
-
starknet_getStorageAt: {
|
|
149
|
-
QUERY: never;
|
|
150
|
-
REQUEST: any[];
|
|
151
|
-
RESPONSE: GetStorageAtResponse;
|
|
152
|
-
};
|
|
153
|
-
starknet_getTransactionByHash: {
|
|
154
|
-
QUERY: never;
|
|
155
|
-
REQUEST: any[];
|
|
156
|
-
RESPONSE: GetTransactionByHashResponse;
|
|
157
|
-
};
|
|
158
|
-
starknet_getTransactionByBlockIdAndIndex: {
|
|
159
|
-
QUERY: never;
|
|
160
|
-
REQUEST: any[];
|
|
161
|
-
RESPONSE: GetTransactionByBlockIdAndIndex;
|
|
162
|
-
};
|
|
163
|
-
starknet_getTransactionReceipt: {
|
|
164
|
-
QUERY: never;
|
|
165
|
-
REQUEST: any[];
|
|
166
|
-
RESPONSE: GetTransactionReceiptResponse;
|
|
167
|
-
};
|
|
168
|
-
starknet_getBlockTransactionCount: {
|
|
169
|
-
QUERY: never;
|
|
170
|
-
REQUEST: any[];
|
|
171
|
-
RESPONSE: GetTransactionCountResponse;
|
|
172
|
-
};
|
|
173
|
-
starknet_call: {
|
|
174
|
-
QUERY: never;
|
|
175
|
-
REQUEST: any[];
|
|
176
|
-
RESPONSE: string[];
|
|
177
|
-
};
|
|
178
|
-
starknet_estimateFee: {
|
|
179
|
-
QUERY: never;
|
|
180
|
-
REQUEST: any[];
|
|
181
|
-
RESPONSE: EstimateFeeResponse;
|
|
182
|
-
};
|
|
183
|
-
starknet_blockNumber: {
|
|
184
|
-
QUERY: never;
|
|
185
|
-
REQUEST: any[];
|
|
186
|
-
RESPONSE: GetBlockNumberResponse;
|
|
187
|
-
};
|
|
188
|
-
starknet_chainId: {
|
|
189
|
-
QUERY: never;
|
|
190
|
-
REQUEST: any[];
|
|
191
|
-
RESPONSE: StarknetChainId;
|
|
192
|
-
};
|
|
193
|
-
starknet_syncing: {
|
|
194
|
-
QUERY: never;
|
|
195
|
-
REQUEST: any[];
|
|
196
|
-
RESPONSE: GetSyncingStatsResponse;
|
|
197
|
-
};
|
|
198
|
-
starknet_getEvents: {
|
|
199
|
-
QUERY: never;
|
|
200
|
-
REQUEST: any[];
|
|
201
|
-
RESPONSE: GetEventsResponse;
|
|
202
|
-
};
|
|
203
|
-
starknet_addInvokeTransaction: {
|
|
204
|
-
QUERY: never;
|
|
205
|
-
REQUEST: any[];
|
|
206
|
-
RESPONSE: AddTransactionResponse;
|
|
207
|
-
};
|
|
208
|
-
starknet_addDeployTransaction: {
|
|
209
|
-
QUERY: never;
|
|
210
|
-
REQUEST: any[];
|
|
211
|
-
RESPONSE: DeployContractResponse;
|
|
212
|
-
};
|
|
213
|
-
starknet_addDeclareTransaction: {
|
|
214
|
-
QUERY: never;
|
|
215
|
-
REQUEST: any[];
|
|
216
|
-
RESPONSE: DeclareResponse;
|
|
217
|
-
};
|
|
218
|
-
starknet_getClassAt: {
|
|
219
|
-
QUERY: never;
|
|
220
|
-
REQUEST: any[];
|
|
221
|
-
RESPONSE: any;
|
|
222
|
-
};
|
|
223
|
-
};
|
|
37
|
+
export type GetBlockNumberResponse = OPENRPC.BlockNumber;
|
|
38
|
+
export type GetSyncingStatsResponse = OPENRPC.SyncingStatus;
|
|
39
|
+
export type EventFilter = OPENRPC.EventFilter;
|
|
40
|
+
export type GetEventsResponse = OPENRPC.Events;
|
|
41
|
+
export type InvokedTransaction = OPENRPC.InvokedTransaction;
|
|
42
|
+
export type DeclaredTransaction = OPENRPC.DeclaredTransaction;
|
|
43
|
+
export type DeployedTransaction = OPENRPC.DeployedTransaction;
|
|
44
|
+
|
|
45
|
+
export type Methods = OPENRPC.Methods;
|
|
224
46
|
}
|
|
@@ -95,9 +95,8 @@ export namespace Sequencer {
|
|
|
95
95
|
contract_address: string;
|
|
96
96
|
signature?: Signature;
|
|
97
97
|
entry_point_type?: EntryPointType;
|
|
98
|
-
entry_point_selector: string;
|
|
99
98
|
calldata?: RawCalldata;
|
|
100
|
-
nonce
|
|
99
|
+
nonce: BigNumberish;
|
|
101
100
|
max_fee?: BigNumberish;
|
|
102
101
|
version?: BigNumberish;
|
|
103
102
|
};
|
|
@@ -118,6 +117,7 @@ export namespace Sequencer {
|
|
|
118
117
|
|
|
119
118
|
export interface InvokeFunctionTransactionResponse extends InvokeFunctionTransaction {
|
|
120
119
|
transaction_hash: string;
|
|
120
|
+
entry_point_selector: string;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export type TransactionResponse =
|
|
@@ -202,12 +202,17 @@ export namespace Sequencer {
|
|
|
202
202
|
export type CallContractTransaction = Omit<
|
|
203
203
|
InvokeFunctionTransaction,
|
|
204
204
|
'type' | 'entry_point_type' | 'nonce'
|
|
205
|
-
|
|
205
|
+
> & { entry_point_selector: string };
|
|
206
206
|
|
|
207
207
|
export type CallContractResponse = {
|
|
208
208
|
result: string[];
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
+
export type EstimateFeeTransaction = Omit<
|
|
212
|
+
InvokeFunctionTransaction,
|
|
213
|
+
'max_fee' | 'entry_point_type'
|
|
214
|
+
>;
|
|
215
|
+
|
|
211
216
|
// Support 0.9.1 changes in a backward-compatible way
|
|
212
217
|
export type EstimateFeeResponse =
|
|
213
218
|
| {
|
|
@@ -259,6 +264,14 @@ export namespace Sequencer {
|
|
|
259
264
|
REQUEST: never;
|
|
260
265
|
RESPONSE: TransactionReceiptResponse;
|
|
261
266
|
};
|
|
267
|
+
get_nonce: {
|
|
268
|
+
QUERY: {
|
|
269
|
+
contractAddress: string;
|
|
270
|
+
blockIdentifier: BlockIdentifier;
|
|
271
|
+
};
|
|
272
|
+
REQUEST: never;
|
|
273
|
+
RESPONSE: BigNumberish;
|
|
274
|
+
};
|
|
262
275
|
get_storage_at: {
|
|
263
276
|
QUERY: {
|
|
264
277
|
contractAddress: string;
|
|
@@ -294,7 +307,7 @@ export namespace Sequencer {
|
|
|
294
307
|
QUERY: {
|
|
295
308
|
blockIdentifier: BlockIdentifier;
|
|
296
309
|
};
|
|
297
|
-
REQUEST:
|
|
310
|
+
REQUEST: EstimateFeeTransaction;
|
|
298
311
|
RESPONSE: EstimateFeeResponse;
|
|
299
312
|
};
|
|
300
313
|
get_class_by_hash: {
|
package/src/types/lib.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type RawCalldata = BigNumberish[];
|
|
|
9
9
|
export type DeployContractPayload = {
|
|
10
10
|
contract: CompiledContract | string;
|
|
11
11
|
constructorCalldata?: RawCalldata;
|
|
12
|
-
addressSalt?:
|
|
12
|
+
addressSalt?: string;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export type DeclareContractPayload = {
|
|
@@ -17,14 +17,14 @@ export type DeclareContractPayload = {
|
|
|
17
17
|
version?: BigNumberish;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export type
|
|
20
|
+
export type CallDetails = {
|
|
21
21
|
contractAddress: string;
|
|
22
|
-
entrypoint: string;
|
|
23
22
|
calldata?: RawCalldata;
|
|
24
|
-
signature?: Signature;
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
export type
|
|
25
|
+
export type Invocation = CallDetails & { signature?: Signature };
|
|
26
|
+
|
|
27
|
+
export type Call = CallDetails & { entrypoint: string };
|
|
28
28
|
|
|
29
29
|
export type InvocationsDetails = {
|
|
30
30
|
nonce?: BigNumberish;
|
|
@@ -32,6 +32,8 @@ export type InvocationsDetails = {
|
|
|
32
32
|
version?: BigNumberish;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
export type InvocationsDetailsWithNonce = InvocationsDetails & { nonce: BigNumberish };
|
|
36
|
+
|
|
35
37
|
export type Status =
|
|
36
38
|
| 'NOT_RECEIVED'
|
|
37
39
|
| 'RECEIVED'
|
package/src/types/provider.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { RPC } from './api/rpc';
|
|
8
|
+
import { Abi, CompressedProgram, RawCalldata, Signature, Status } from './lib';
|
|
8
9
|
|
|
9
10
|
export interface GetBlockResponse {
|
|
10
11
|
timestamp: number;
|
|
@@ -44,7 +45,7 @@ export interface ContractEntryPoint {
|
|
|
44
45
|
|
|
45
46
|
export interface ContractClass {
|
|
46
47
|
program: CompressedProgram;
|
|
47
|
-
entry_points_by_type:
|
|
48
|
+
entry_points_by_type: RPC.ContractClass['entry_points_by_type'];
|
|
48
49
|
abi?: Abi;
|
|
49
50
|
}
|
|
50
51
|
|
package/src/utils/hash.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { ec } from './ellipticCurve';
|
|
|
17
17
|
import { addHexPrefix, buf2hex, removeHexPrefix, utf8ToArray } from './encode';
|
|
18
18
|
import { BigNumberish, toBN, toFelt, toHex } from './number';
|
|
19
19
|
|
|
20
|
-
export const transactionVersion =
|
|
20
|
+
export const transactionVersion = 1;
|
|
21
21
|
export const feeTransactionVersion = toBN(2).pow(toBN(128)).add(toBN(transactionVersion));
|
|
22
22
|
|
|
23
23
|
export function keccakBn(value: BigNumberish): string {
|
|
@@ -124,22 +124,23 @@ export function calculateDeployTransactionHash(
|
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
export function
|
|
127
|
+
export function calculateTransactionHash(
|
|
128
128
|
contractAddress: BigNumberish,
|
|
129
129
|
version: BigNumberish,
|
|
130
|
-
entryPointSelector: BigNumberish,
|
|
131
130
|
calldata: BigNumberish[],
|
|
132
131
|
maxFee: BigNumberish,
|
|
133
|
-
chainId: StarknetChainId
|
|
132
|
+
chainId: StarknetChainId,
|
|
133
|
+
nonce: BigNumberish
|
|
134
134
|
): string {
|
|
135
135
|
return calculateTransactionHashCommon(
|
|
136
136
|
TransactionHashPrefix.INVOKE,
|
|
137
137
|
version,
|
|
138
138
|
contractAddress,
|
|
139
|
-
|
|
139
|
+
0,
|
|
140
140
|
calldata,
|
|
141
141
|
maxFee,
|
|
142
|
-
chainId
|
|
142
|
+
chainId,
|
|
143
|
+
[nonce]
|
|
143
144
|
);
|
|
144
145
|
}
|
|
145
146
|
|
|
@@ -4,13 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import {
|
|
6
6
|
CallContractResponse,
|
|
7
|
-
DeclareContractResponse,
|
|
8
|
-
DeployContractResponse,
|
|
9
7
|
EstimateFeeResponse,
|
|
10
8
|
GetBlockResponse,
|
|
11
9
|
GetTransactionReceiptResponse,
|
|
12
10
|
GetTransactionResponse,
|
|
13
|
-
InvokeFunctionResponse,
|
|
14
11
|
} from '../../types';
|
|
15
12
|
import { RPC } from '../../types/api';
|
|
16
13
|
import { toBN } from '../number';
|
|
@@ -24,7 +21,17 @@ type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
|
|
|
24
21
|
[key: string]: any;
|
|
25
22
|
};
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
type TransactionReceipt = RPC.TransactionReceipt & {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export class RPCResponseParser
|
|
29
|
+
implements
|
|
30
|
+
Omit<
|
|
31
|
+
ResponseParser,
|
|
32
|
+
'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse'
|
|
33
|
+
>
|
|
34
|
+
{
|
|
28
35
|
public parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse {
|
|
29
36
|
return {
|
|
30
37
|
timestamp: res.timestamp,
|
|
@@ -41,7 +48,6 @@ export class RPCResponseParser extends ResponseParser {
|
|
|
41
48
|
return {
|
|
42
49
|
calldata: res.calldata || [],
|
|
43
50
|
contract_address: res.contract_address,
|
|
44
|
-
entry_point_selector: res.entry_point_selector,
|
|
45
51
|
max_fee: res.max_fee,
|
|
46
52
|
nonce: res.nonce,
|
|
47
53
|
signature: res.signature || [],
|
|
@@ -51,10 +57,10 @@ export class RPCResponseParser extends ResponseParser {
|
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
public parseGetTransactionReceiptResponse(
|
|
54
|
-
res:
|
|
60
|
+
res: TransactionReceipt
|
|
55
61
|
): GetTransactionReceiptResponse {
|
|
56
62
|
return {
|
|
57
|
-
transaction_hash: res.
|
|
63
|
+
transaction_hash: res.transaction_hash,
|
|
58
64
|
actual_fee: res.actual_fee,
|
|
59
65
|
status: res.status,
|
|
60
66
|
status_data: res.status_data,
|
|
@@ -77,24 +83,4 @@ export class RPCResponseParser extends ResponseParser {
|
|
|
77
83
|
result: res,
|
|
78
84
|
};
|
|
79
85
|
}
|
|
80
|
-
|
|
81
|
-
public parseInvokeFunctionResponse(res: RPC.AddTransactionResponse): InvokeFunctionResponse {
|
|
82
|
-
return {
|
|
83
|
-
transaction_hash: res.transaction_hash,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public parseDeployContractResponse(res: RPC.DeployContractResponse): DeployContractResponse {
|
|
88
|
-
return {
|
|
89
|
-
transaction_hash: res.transaction_hash,
|
|
90
|
-
contract_address: res.contract_address,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public parseDeclareContractResponse(res: RPC.DeclareResponse): DeclareContractResponse {
|
|
95
|
-
return {
|
|
96
|
-
transaction_hash: res.transaction_hash,
|
|
97
|
-
class_hash: res.class_hash,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
86
|
}
|