starknet 4.3.0 → 4.3.1

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/__tests__/defaultProvider.test.ts +11 -24
  3. package/__tests__/rpcProvider.test.ts +3 -3
  4. package/__tests__/sequencerProvider.test.ts +9 -1
  5. package/dist/provider/default.d.ts +2 -2
  6. package/dist/provider/default.js +3 -3
  7. package/dist/provider/interface.d.ts +6 -3
  8. package/dist/provider/rpc.d.ts +9 -4
  9. package/dist/provider/rpc.js +67 -25
  10. package/dist/provider/sequencer.d.ts +2 -2
  11. package/dist/provider/sequencer.js +4 -4
  12. package/dist/provider/utils.d.ts +12 -0
  13. package/dist/provider/utils.js +17 -1
  14. package/dist/types/api/openrpc.d.ts +151 -0
  15. package/dist/types/api/openrpc.js +9 -0
  16. package/dist/types/api/rpc.d.ts +22 -43
  17. package/dist/types/provider.d.ts +5 -5
  18. package/dist/utils/ellipticCurve.d.ts +13 -0
  19. package/dist/utils/ellipticCurve.js +20 -16
  20. package/dist/utils/responseParser/rpc.d.ts +13 -3
  21. package/dist/utils/responseParser/rpc.js +2 -10
  22. package/dist/utils/responseParser/sequencer.d.ts +4 -1
  23. package/dist/utils/responseParser/sequencer.js +1 -7
  24. package/package.json +1 -1
  25. package/provider/default.d.ts +2 -2
  26. package/provider/default.js +3 -3
  27. package/provider/interface.d.ts +6 -3
  28. package/provider/rpc.d.ts +9 -4
  29. package/provider/rpc.js +67 -25
  30. package/provider/sequencer.d.ts +2 -2
  31. package/provider/sequencer.js +4 -4
  32. package/provider/utils.d.ts +12 -0
  33. package/provider/utils.js +17 -1
  34. package/src/provider/default.ts +2 -3
  35. package/src/provider/interface.ts +5 -3
  36. package/src/provider/rpc.ts +56 -34
  37. package/src/provider/sequencer.ts +3 -6
  38. package/src/provider/utils.ts +22 -1
  39. package/src/types/api/openrpc.ts +168 -0
  40. package/src/types/api/rpc.ts +22 -45
  41. package/src/types/provider.ts +5 -5
  42. package/src/utils/ellipticCurve.ts +20 -16
  43. package/src/utils/responseParser/rpc.ts +16 -13
  44. package/src/utils/responseParser/sequencer.ts +5 -8
  45. package/types/api/openrpc.d.ts +151 -0
  46. package/types/api/openrpc.js +9 -0
  47. package/types/api/rpc.d.ts +22 -43
  48. package/types/provider.d.ts +5 -5
  49. package/utils/ellipticCurve.d.ts +13 -0
  50. package/utils/ellipticCurve.js +20 -16
  51. package/utils/responseParser/rpc.d.ts +13 -3
  52. package/utils/responseParser/rpc.js +2 -10
  53. package/utils/responseParser/sequencer.d.ts +4 -1
  54. package/utils/responseParser/sequencer.js +1 -7
  55. package/www/docs/API/account.md +20 -18
  56. package/www/docs/API/contract.md +10 -10
  57. package/www/docs/API/contractFactory.md +14 -11
  58. package/www/docs/API/provider.md +29 -63
  59. package/www/docs/API/signer.md +8 -10
  60. package/www/docs/API/utils.md +151 -74
  61. package/www/guides/account.md +5 -5
  62. package/www/guides/erc20.md +20 -4
  63. package/www/guides/intro.md +3 -1
@@ -4,7 +4,7 @@ sidebar_position: 1
4
4
 
5
5
  # Provider
6
6
 
7
- The **Provider** API allows you to interface with the StarkNet network, without signing transactions or messages.
7
+ The **Provider** API allows you to interact with the StarkNet network, without signing transactions or messages.
8
8
 
9
9
  Typically, these are _read_ calls on the blockchain.
10
10
 
@@ -12,7 +12,7 @@ Typically, these are _read_ calls on the blockchain.
12
12
 
13
13
  `new starknet.Provider(optionsOrProvider)`
14
14
 
15
- The options for the provider depends from the network. The structure of the options object is:
15
+ The options for the provider depend on the network. The structure of the options object is:
16
16
 
17
17
  - options.**sequencer** - Options for sequencer provider
18
18
  - options.**rpc** - Options for RPC provider
@@ -32,25 +32,26 @@ const provider = new starknet.Provider({
32
32
  sequencer: {
33
33
  network: 'mainnet-alpha' // or 'goerli-alpha'
34
34
  }
35
- })
35
+ })
36
36
  ```
37
37
 
38
- If you want to more control:
38
+ If you want more control:
39
39
 
40
40
  ```typescript
41
41
  const provider = new starknet.Provider({
42
42
  sequencer: {
43
- baseUrl: 'https://alpha4.starknet.io',
44
- feederGatewayUrl: 'feeder_gateway',
45
- gatewayUrl: 'gateway',
43
+ baseUrl: 'https://alpha4.starknet.io',
44
+ feederGatewayUrl: 'feeder_gateway',
45
+ gatewayUrl: 'gateway',
46
46
  }
47
47
  })
48
-
49
48
  ```
50
49
 
51
- \*\*This is also default options for the Provider constructor with `network: 'goerli-alpha'`\*\*\*
50
+ These are also the default options for the Provider constructor with `network: 'goerli-alpha'`.
52
51
 
53
- \*\*Note: `network` arguement should work in most cases. If you want to use sequencer arguement with `baseUrl`, you will not be able to use `network` field in the object.\*\*\*
52
+ > **Note**
53
+ >
54
+ > `network` arguement should work in most cases. If you want to use the `sequencer` arguement with `baseUrl`, you will not be able to use the `network` field in the object.
54
55
 
55
56
  ## Methods
56
57
 
@@ -64,16 +65,14 @@ The call object structure:
64
65
 
65
66
  - call.**contractAddress** - Address of the contract
66
67
  - call.**entrypoint** - Entrypoint of the call (method name)
67
- - call.**calldata** - Payload for the invoking the method
68
+ - call.**calldata** - Payload for the invoking method
68
69
 
69
- ###### CallContractResponse
70
+ ###### _CallContractResponse_
70
71
 
71
72
  ```typescript
72
-
73
73
  {
74
74
  result: string[];
75
75
  }
76
-
77
76
  ```
78
77
 
79
78
  <hr/>
@@ -85,7 +84,6 @@ Gets the block information.
85
84
  ###### _GetBlockResponse_
86
85
 
87
86
  ```typescript
88
-
89
87
  {
90
88
  accepted_time: number;
91
89
  block_hash: string;
@@ -99,7 +97,6 @@ Gets the block information.
99
97
  transactions: Array<string>;
100
98
  starknet_version?: string;
101
99
  }
102
-
103
100
  ```
104
101
 
105
102
  <hr/>
@@ -111,20 +108,18 @@ Gets the contract class of the deployed contract.
111
108
  ###### _ContractClass_
112
109
 
113
110
  ```typescript
114
-
115
111
  {
116
112
  program: CompressedProgram;
117
113
  entry_points_by_type: EntryPointsByType;
118
114
  abi?: Abi;
119
115
  }
120
-
121
116
  ```
122
117
 
123
118
  <hr/>
124
119
 
125
- provider.**getStorageAt**(contractAddress, key, blockHashOrTag) => _Promise < string >_
120
+ provider.**getStorageAt**(contractAddress, key, blockIdentifier) => _Promise < string >_
126
121
 
127
- Gets the contract's storage variable at a specific key
122
+ Gets the contract's storage variable at a specific key.
128
123
 
129
124
  <hr/>
130
125
 
@@ -135,7 +130,6 @@ Gets the status of a transaction.
135
130
  ###### _GetTransactionReceiptResponse_
136
131
 
137
132
  ```typescript
138
-
139
133
  {
140
134
  transaction_hash: string;
141
135
  status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
@@ -145,7 +139,6 @@ Gets the status of a transaction.
145
139
  events?: Array<Event>;
146
140
  l1_origin_message?: MessageToL2;
147
141
  }
148
-
149
142
  ```
150
143
 
151
144
  <hr/>
@@ -157,7 +150,6 @@ Gets the transaction information from a tx hash.
157
150
  ###### _GetTransactionResponse_
158
151
 
159
152
  ```typescript
160
-
161
153
  {
162
154
  transaction_hash: string;
163
155
  version?: string;
@@ -170,41 +162,36 @@ Gets the transaction information from a tx hash.
170
162
  contract_class?: ContractClass;
171
163
  sender_address?: string;
172
164
  }
173
-
174
165
  ```
175
166
 
176
167
  <hr/>
177
168
 
178
169
  provider.**declareContract**(payload) => _Promise < DeclareContractResponse >_
179
170
 
180
- Declares a contract on Starknet
171
+ Declares a contract on Starknet.
181
172
 
182
173
  ###### _DeclareContractResponse_
183
174
 
184
175
  ```typescript
185
-
186
176
  {
187
177
  transaction_hash: string;
188
178
  class_hash: string;
189
179
  };
180
+ ```
190
181
 
191
182
  <hr/>
192
183
 
193
- ```
194
-
195
184
  provider.**deployContract**(payload [ , abi ]) => _Promise < DeployContractResponse >_
196
185
 
197
- Deploys a contract on Starknet
186
+ Deploys a contract on Starknet.
198
187
 
199
188
  ###### _DeployContractResponse_
200
189
 
201
190
  ```typescript
202
-
203
191
  {
204
192
  transaction_hash: string;
205
193
  contract_address?: string;
206
194
  };
207
-
208
195
  ```
209
196
 
210
197
  <hr/>
@@ -219,7 +206,7 @@ Wait for the transaction to be accepted on L2 or L1.
219
206
 
220
207
  `new starknet.SequencerProvider(optionsOrProvider)`
221
208
 
222
- The options for the provider depends from the network. The structure of the options object is:
209
+ The options for the provider depend on the network. The structure of the options object is:
223
210
 
224
211
  - options.**baseUrl** - Base URL of the network
225
212
  - options.**feederGatewayUrl** - Feeder Gateway Endpoint of the network
@@ -227,33 +214,31 @@ The options for the provider depends from the network. The structure of the opti
227
214
 
228
215
  or
229
216
 
230
- - options.**network** - One of 'mainnet-alpha' or 'goerli-alpha'
217
+ - options.**network** - Either 'mainnet-alpha' or 'goerli-alpha'
231
218
 
232
219
  Example:
233
220
 
234
221
  ```typescript
235
-
236
222
  const provider = new starknet.Provider({
237
223
  baseUrl: 'https://alpha4.starknet.io',
238
224
  feederGatewayUrl: 'feeder_gateway',
239
225
  gatewayUrl: 'gateway',
240
226
  })
241
-
242
227
  ```
243
228
 
244
229
  ## Methods
245
230
 
246
- Gets the smart contract address on the network
231
+ Gets the smart contract address on the network.
247
232
 
248
233
  provider.**getContractAddresses**() => _Promise < GetContractAddressesResponse >_
249
234
 
250
- ```typescript
235
+ ###### _GetContractAddressesResponse_
251
236
 
237
+ ```typescript
252
238
  {
253
239
  Starknet: string;
254
240
  GpsStatementVerifier: string;
255
241
  }
256
-
257
242
  ```
258
243
 
259
244
  <hr/>
@@ -265,7 +250,6 @@ Gets the status of a transaction.
265
250
  ###### _GetTransactionStatusResponse_
266
251
 
267
252
  ```typescript
268
-
269
253
  {
270
254
  tx_status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
271
255
  block_hash: string;
@@ -275,7 +259,6 @@ Gets the status of a transaction.
275
259
  error_message: string;
276
260
  }
277
261
  }
278
-
279
262
  ```
280
263
 
281
264
  <hr/>
@@ -301,10 +284,9 @@ Gets the transaction trace from a tx hash.
301
284
  internal_call: Array<any>;
302
285
  events: Array<any>;
303
286
  messages: Array<any>;
304
- };
287
+ };
305
288
  signature: Signature;
306
289
  }
307
-
308
290
  ```
309
291
 
310
292
  # RpcProvider
@@ -318,11 +300,9 @@ Gets the transaction trace from a tx hash.
318
300
  Example:
319
301
 
320
302
  ```typescript
321
-
322
303
  const provider = new starknet.RpcProvider({
323
304
  nodeUrl: 'URL_TO_STARKNET_RPC_NODE',
324
305
  })
325
-
326
306
  ```
327
307
 
328
308
  ## Methods
@@ -335,18 +315,17 @@ Gets the transaction count from a block.
335
315
 
336
316
  provider.**getBlockNumber**() => _Promise < number >_
337
317
 
338
- Gets the latest block number
318
+ Gets the latest block number.
339
319
 
340
320
  <hr/>
341
321
 
342
322
  provider.**getSyncingStats**() => _Promise < GetSyncingStatsResponse >_
343
323
 
344
- Gets syncing status of the node
324
+ Gets syncing status of the node.
345
325
 
346
- ###### GetSyncingStatsResponse
326
+ ###### _GetSyncingStatsResponse_
347
327
 
348
328
  ```typescript
349
-
350
329
  boolean |
351
330
  {
352
331
  starting_block_hash: string;
@@ -356,17 +335,15 @@ boolean |
356
335
  highest_block_hash: string;
357
336
  highest_block_num: string;
358
337
  }
359
-
360
338
  ```
361
339
 
362
340
  <hr/>
363
341
 
364
342
  provider.**getEvents**(eventFilter) => _Promise < GetEventsResponse >_
365
343
 
366
- ##### EventFilter
344
+ ##### _EventFilter_
367
345
 
368
346
  ```typescript
369
-
370
347
  type EventFilter = {
371
348
  fromBlock: string;
372
349
  toBlock: string;
@@ -375,25 +352,14 @@ type EventFilter = {
375
352
  page_size: number;
376
353
  page_number: number;
377
354
  };
378
-
379
355
  ```
380
356
 
381
- ###### GetSyncingStatsResponse
357
+ ###### _GetEventsResponse_
382
358
 
383
359
  ```typescript
384
-
385
360
  {
386
361
  events: StarknetEmittedEvent[];
387
362
  page_number: number;
388
363
  is_last_page: number;
389
364
  }
390
-
391
- ```
392
-
393
- ```
394
-
395
- ```
396
-
397
- ```
398
-
399
365
  ```
@@ -10,21 +10,21 @@ The **Signer** API allows you to sign transactions and messages, and also allows
10
10
 
11
11
  `new starknet.Signer(keyPair)`
12
12
 
13
- ## Signer Methods
13
+ ## Methods
14
14
 
15
15
  signer.**getPubKey**() => _Promise < string >_
16
16
 
17
- Returns public key of the signer
17
+ Returns the public key of the signer.
18
18
 
19
19
  <hr />
20
20
 
21
21
  signer.**signTransaction**(transactions, transactionsDetail [ , abi ]) => _Promise < Signature >_
22
22
 
23
- Returns signature of the transaction
23
+ Returns the signature of the transaction.
24
24
 
25
- ###### Signature
25
+ ###### _Signature_
26
26
 
27
- ```
27
+ ```typescript
28
28
  string[]
29
29
  ```
30
30
 
@@ -32,12 +32,10 @@ string[]
32
32
 
33
33
  signer.**signMessage**(typedData, accountAddress) => _Promise < Signature >_
34
34
 
35
- Returns signature of the transaction
35
+ Returns the signature of the transaction.
36
36
 
37
- ###### Signature
37
+ ###### _Signature_
38
38
 
39
- ```
39
+ ```typescript
40
40
  string[]
41
41
  ```
42
-
43
- <hr />