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/dist/types/api/rpc.d.ts
CHANGED
|
@@ -1,200 +1,43 @@
|
|
|
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
|
-
version: string;
|
|
47
|
-
nonce: string;
|
|
48
|
-
signature: Array<string>;
|
|
49
|
-
}
|
|
50
|
-
export interface InvokeTransactionResponse extends CommonTransactionProperties {
|
|
51
|
-
contract_address?: string;
|
|
52
|
-
entry_point_selector?: string;
|
|
53
|
-
calldata?: Array<string>;
|
|
54
|
-
}
|
|
55
|
-
export interface DeclareTransactionResponse extends CommonTransactionProperties {
|
|
56
|
-
contract_class?: GetClassResponse;
|
|
57
|
-
sender_address?: string;
|
|
58
|
-
}
|
|
59
|
-
export type GetTransactionByHashResponse = OPENRPC.GetTransactionByHashResponse;
|
|
60
|
-
export type GetTransactionByBlockIdAndIndex = OPENRPC.GetTransactionByBlockIdAndIndex;
|
|
61
|
-
export type GetTransactionCountResponse = number;
|
|
62
|
-
export type GetBlockNumberResponse = number;
|
|
63
|
-
export type GetSyncingStatsResponse = {
|
|
64
|
-
starting_block_hash: string;
|
|
65
|
-
starting_block_num: string;
|
|
66
|
-
current_block_hash: string;
|
|
67
|
-
current_block_num: string;
|
|
68
|
-
highest_block_hash: string;
|
|
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 = {
|
|
108
|
-
starknet_getBlockWithTxHashes: {
|
|
109
|
-
QUERY: never;
|
|
110
|
-
REQUEST: any[];
|
|
111
|
-
RESPONSE: GetBlockWithTxHashesResponse;
|
|
112
|
-
};
|
|
113
|
-
starknet_getBlockWithTxs: {
|
|
114
|
-
QUERY: never;
|
|
115
|
-
REQUEST: any[];
|
|
116
|
-
RESPONSE: GetBlockWithTxs;
|
|
117
|
-
};
|
|
118
|
-
starknet_getNonce: {
|
|
119
|
-
QUERY: never;
|
|
120
|
-
REQUEST: any[];
|
|
121
|
-
RESPONSE: string;
|
|
122
|
-
};
|
|
123
|
-
starknet_getStorageAt: {
|
|
124
|
-
QUERY: never;
|
|
125
|
-
REQUEST: any[];
|
|
126
|
-
RESPONSE: GetStorageAtResponse;
|
|
127
|
-
};
|
|
128
|
-
starknet_getTransactionByHash: {
|
|
129
|
-
QUERY: never;
|
|
130
|
-
REQUEST: any[];
|
|
131
|
-
RESPONSE: GetTransactionByHashResponse;
|
|
132
|
-
};
|
|
133
|
-
starknet_getTransactionByBlockIdAndIndex: {
|
|
134
|
-
QUERY: never;
|
|
135
|
-
REQUEST: any[];
|
|
136
|
-
RESPONSE: GetTransactionByBlockIdAndIndex;
|
|
137
|
-
};
|
|
138
|
-
starknet_getTransactionReceipt: {
|
|
139
|
-
QUERY: never;
|
|
140
|
-
REQUEST: any[];
|
|
141
|
-
RESPONSE: GetTransactionReceiptResponse;
|
|
142
|
-
};
|
|
143
|
-
starknet_getBlockTransactionCount: {
|
|
144
|
-
QUERY: never;
|
|
145
|
-
REQUEST: any[];
|
|
146
|
-
RESPONSE: GetTransactionCountResponse;
|
|
147
|
-
};
|
|
148
|
-
starknet_call: {
|
|
149
|
-
QUERY: never;
|
|
150
|
-
REQUEST: any[];
|
|
151
|
-
RESPONSE: string[];
|
|
152
|
-
};
|
|
153
|
-
starknet_estimateFee: {
|
|
154
|
-
QUERY: never;
|
|
155
|
-
REQUEST: any[];
|
|
156
|
-
RESPONSE: EstimateFeeResponse;
|
|
157
|
-
};
|
|
158
|
-
starknet_blockNumber: {
|
|
159
|
-
QUERY: never;
|
|
160
|
-
REQUEST: any[];
|
|
161
|
-
RESPONSE: GetBlockNumberResponse;
|
|
162
|
-
};
|
|
163
|
-
starknet_chainId: {
|
|
164
|
-
QUERY: never;
|
|
165
|
-
REQUEST: any[];
|
|
166
|
-
RESPONSE: StarknetChainId;
|
|
167
|
-
};
|
|
168
|
-
starknet_syncing: {
|
|
169
|
-
QUERY: never;
|
|
170
|
-
REQUEST: any[];
|
|
171
|
-
RESPONSE: GetSyncingStatsResponse;
|
|
172
|
-
};
|
|
173
|
-
starknet_getEvents: {
|
|
174
|
-
QUERY: never;
|
|
175
|
-
REQUEST: any[];
|
|
176
|
-
RESPONSE: GetEventsResponse;
|
|
177
|
-
};
|
|
178
|
-
starknet_addInvokeTransaction: {
|
|
179
|
-
QUERY: never;
|
|
180
|
-
REQUEST: any[];
|
|
181
|
-
RESPONSE: AddTransactionResponse;
|
|
182
|
-
};
|
|
183
|
-
starknet_addDeployTransaction: {
|
|
184
|
-
QUERY: never;
|
|
185
|
-
REQUEST: any[];
|
|
186
|
-
RESPONSE: DeployContractResponse;
|
|
187
|
-
};
|
|
188
|
-
starknet_addDeclareTransaction: {
|
|
189
|
-
QUERY: never;
|
|
190
|
-
REQUEST: any[];
|
|
191
|
-
RESPONSE: DeclareResponse;
|
|
192
|
-
};
|
|
193
|
-
starknet_getClassAt: {
|
|
194
|
-
QUERY: never;
|
|
195
|
-
REQUEST: any[];
|
|
196
|
-
RESPONSE: any;
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
export {};
|
|
12
|
+
type ChainId = OPENRPC.CHAIN_ID;
|
|
13
|
+
type CallResponse = OPENRPC.CallResponse;
|
|
14
|
+
type ContractAddress = ADDRESS;
|
|
15
|
+
type Felt = FELT;
|
|
16
|
+
type Nonce = OPENRPC.Nonce;
|
|
17
|
+
type ContractClass = OPENRPC.ContractClass;
|
|
18
|
+
type StateUpdate = OPENRPC.StateUpdate;
|
|
19
|
+
type Transaction = OPENRPC.Transaction;
|
|
20
|
+
type PendingTransactions = OPENRPC.PendingTransactions;
|
|
21
|
+
type TransactionHash = OPENRPC.TransactionHash;
|
|
22
|
+
type Trace = OPENRPC.Trace;
|
|
23
|
+
type Traces = OPENRPC.Traces;
|
|
24
|
+
type BlockHash = OPENRPC.BlockHash;
|
|
25
|
+
type BlockHashAndNumber = OPENRPC.BlockHashAndNumber;
|
|
26
|
+
type GetClassResponse = OPENRPC.ContractClass;
|
|
27
|
+
type EstimateFeeResponse = OPENRPC.EstimatedFee;
|
|
28
|
+
type GetBlockWithTxHashesResponse = OPENRPC.BlockWithTxHashes;
|
|
29
|
+
type GetBlockWithTxs = OPENRPC.BlockWithTxs;
|
|
30
|
+
type GetStorageAtResponse = OPENRPC.Storage;
|
|
31
|
+
type TransactionReceipt = OPENRPC.TransactionReceipt;
|
|
32
|
+
type GetTransactionByHashResponse = OPENRPC.Transaction;
|
|
33
|
+
type GetTransactionByBlockIdAndIndex = OPENRPC.Transaction;
|
|
34
|
+
type GetTransactionCountResponse = number;
|
|
35
|
+
type GetBlockNumberResponse = OPENRPC.BlockNumber;
|
|
36
|
+
type GetSyncingStatsResponse = OPENRPC.SyncingStatus;
|
|
37
|
+
type EventFilter = OPENRPC.EventFilter;
|
|
38
|
+
type GetEventsResponse = OPENRPC.Events;
|
|
39
|
+
type InvokedTransaction = OPENRPC.InvokedTransaction;
|
|
40
|
+
type DeclaredTransaction = OPENRPC.DeclaredTransaction;
|
|
41
|
+
type DeployedTransaction = OPENRPC.DeployedTransaction;
|
|
42
|
+
type Methods = OPENRPC.Methods;
|
|
200
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 & {
|
|
@@ -11,14 +11,14 @@ declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
|
|
|
11
11
|
declare type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
declare type TransactionReceipt = RPC.TransactionReceipt & {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
export declare class RPCResponseParser implements Omit<ResponseParser, 'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse'> {
|
|
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.AddTransactionResponse): InvokeFunctionResponse;
|
|
21
|
-
parseDeployContractResponse(res: RPC.DeployContractResponse): DeployContractResponse;
|
|
22
|
-
parseDeclareContractResponse(res: RPC.DeclareResponse): DeclareContractResponse;
|
|
23
23
|
}
|
|
24
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 || [],
|
|
@@ -48,7 +29,7 @@ var RPCResponseParser = /** @class */ (function (_super) {
|
|
|
48
29
|
};
|
|
49
30
|
RPCResponseParser.prototype.parseGetTransactionReceiptResponse = function (res) {
|
|
50
31
|
return {
|
|
51
|
-
transaction_hash: res.
|
|
32
|
+
transaction_hash: res.transaction_hash,
|
|
52
33
|
actual_fee: res.actual_fee,
|
|
53
34
|
status: res.status,
|
|
54
35
|
status_data: res.status_data,
|
|
@@ -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
|
package/provider/rpc.d.ts
CHANGED
|
@@ -1,36 +1,48 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import { Call, CallContractResponse, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation,
|
|
2
|
+
import { Call, CallContractResponse, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
|
|
3
3
|
import { RPC } from '../types/api';
|
|
4
4
|
import { BigNumberish } from '../utils/number';
|
|
5
5
|
import { ProviderInterface } from './interface';
|
|
6
6
|
import { BlockIdentifier } from './utils';
|
|
7
7
|
export declare type RpcProviderOptions = {
|
|
8
8
|
nodeUrl: string;
|
|
9
|
+
retries?: number;
|
|
9
10
|
};
|
|
10
11
|
export declare class RpcProvider implements ProviderInterface {
|
|
11
12
|
nodeUrl: string;
|
|
12
13
|
chainId: StarknetChainId;
|
|
13
14
|
private responseParser;
|
|
15
|
+
private retries;
|
|
14
16
|
constructor(optionsOrProvider: RpcProviderOptions);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
fetch(method: any, params: any): Promise<any>;
|
|
18
|
+
protected errorHandler(error: any): void;
|
|
19
|
+
protected fetchEndpoint<T extends keyof RPC.Methods>(method: T, params?: RPC.Methods[T]['params']): Promise<RPC.Methods[T]['result']>;
|
|
20
|
+
getChainId(): Promise<any>;
|
|
17
21
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
22
|
+
getBlockHashAndNumber(): Promise<RPC.BlockHashAndNumber>;
|
|
18
23
|
getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxHashesResponse>;
|
|
19
24
|
getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxs>;
|
|
20
|
-
|
|
25
|
+
getClassHashAt(blockIdentifier: BlockIdentifier, contractAddress: RPC.ContractAddress): Promise<RPC.Felt>;
|
|
26
|
+
getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.Nonce>;
|
|
27
|
+
getPendingTransactions(): Promise<RPC.PendingTransactions>;
|
|
28
|
+
getProtocolVersion(): Promise<Error>;
|
|
29
|
+
getStateUpdate(blockIdentifier: BlockIdentifier): Promise<RPC.StateUpdate>;
|
|
21
30
|
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
22
|
-
getTransaction(txHash:
|
|
23
|
-
getTransactionByHash(txHash:
|
|
31
|
+
getTransaction(txHash: string): Promise<GetTransactionResponse>;
|
|
32
|
+
getTransactionByHash(txHash: string): Promise<RPC.GetTransactionByHashResponse>;
|
|
24
33
|
getTransactionByBlockIdAndIndex(blockIdentifier: BlockIdentifier, index: number): Promise<RPC.GetTransactionByBlockIdAndIndex>;
|
|
25
|
-
getTransactionReceipt(txHash:
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
getTransactionReceipt(txHash: string): Promise<GetTransactionReceiptResponse>;
|
|
35
|
+
getClass(classHash: RPC.Felt): Promise<RPC.ContractClass>;
|
|
36
|
+
getClassAt(contractAddress: string, blockIdentifier: BlockIdentifier): Promise<RPC.ContractClass>;
|
|
37
|
+
getCode(_contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
|
38
|
+
getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
28
39
|
declareContract({ contract, version, }: DeclareContractPayload): Promise<DeclareContractResponse>;
|
|
29
40
|
deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
|
|
30
|
-
invokeFunction(functionInvocation: Invocation, details:
|
|
41
|
+
invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
31
42
|
callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
traceTransaction(transactionHash: RPC.TransactionHash): Promise<RPC.Trace>;
|
|
44
|
+
traceBlockTransactions(blockHash: RPC.BlockHash): Promise<RPC.Traces>;
|
|
45
|
+
waitForTransaction(txHash: string, retryInterval?: number): Promise<void>;
|
|
34
46
|
/**
|
|
35
47
|
* Gets the transaction count from a block.
|
|
36
48
|
*
|