starknet 4.19.3 → 4.21.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 CHANGED
@@ -1,3 +1,25 @@
1
+ # [4.21.0](https://github.com/0xs34n/starknet.js/compare/v4.20.0...v4.21.0) (2023-01-18)
2
+
3
+ ### Bug Fixes
4
+
5
+ - fix merge conflicts from develop ([a8b01e3](https://github.com/0xs34n/starknet.js/commit/a8b01e351bb2d62f98d874d836a3f4046d5e046f))
6
+
7
+ ### Features
8
+
9
+ - add get_block_traces support in sequencer ([b8dec62](https://github.com/0xs34n/starknet.js/commit/b8dec62c06dabcd3b917d6b53f318df2a0a8dfe4))
10
+ - update types get_block_traces in sequencer ([2a8d97a](https://github.com/0xs34n/starknet.js/commit/2a8d97a532bb2c9f84436daa2b88abc81a4efa41))
11
+
12
+ # [4.20.0](https://github.com/0xs34n/starknet.js/compare/v4.19.3...v4.20.0) (2023-01-17)
13
+
14
+ ### Bug Fixes
15
+
16
+ - add utility getter in Block class ([3a52292](https://github.com/0xs34n/starknet.js/commit/3a5229277978c3235eaf1f7003b39eeabecac53e))
17
+ - update responseParser & query parameters for sequencer ([a72db02](https://github.com/0xs34n/starknet.js/commit/a72db020aa1ac6924b2c047d067d553ac1b87248))
18
+
19
+ ### Features
20
+
21
+ - add support for get_state_update in provider ([76035a1](https://github.com/0xs34n/starknet.js/commit/76035a148e7863fa1dbe440920eca34498480aa9))
22
+
1
23
  ## [4.19.3](https://github.com/0xs34n/starknet.js/compare/v4.19.2...v4.19.3) (2023-01-12)
2
24
 
3
25
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -1021,6 +1021,27 @@ declare type CallL1Handler = {
1021
1021
  entry_point_selector: string;
1022
1022
  payload: Array<string>;
1023
1023
  };
1024
+ declare type StateDiffItem = {
1025
+ key: string;
1026
+ value: string;
1027
+ };
1028
+ declare type StorageDiffItem = {
1029
+ address: string;
1030
+ storage_entries: [key: string, value: string];
1031
+ };
1032
+ declare type DeployedContractItem = {
1033
+ address: string;
1034
+ class_hash: string;
1035
+ };
1036
+ declare type Nonces = {
1037
+ contract_address: string;
1038
+ nonce: string;
1039
+ };
1040
+ declare type SequencerIdentifier = {
1041
+ blockHash: string;
1042
+ } | {
1043
+ blockNumber: BlockNumber;
1044
+ };
1024
1045
  declare namespace Sequencer {
1025
1046
  type DeclareTransaction = {
1026
1047
  type: 'DECLARE';
@@ -1167,6 +1188,24 @@ declare namespace Sequencer {
1167
1188
  unit: string;
1168
1189
  };
1169
1190
  type EstimateFeeResponseBulk = AllowArray<EstimateFeeResponse>;
1191
+ type BlockTransactionTracesResponse = {
1192
+ traces: Array<TransactionTraceResponse & {
1193
+ transaction_hash: string;
1194
+ }>;
1195
+ };
1196
+ type StateUpdateResponse = {
1197
+ block_hash: string;
1198
+ new_root: string;
1199
+ old_root: string;
1200
+ state_diff: {
1201
+ storage_diffs: Array<{
1202
+ [address: string]: Array<StateDiffItem>;
1203
+ }>;
1204
+ declared_contract_hashes: Array<string>;
1205
+ deployed_contracts: Array<DeployedContractItem>;
1206
+ nonces: Array<Nonces>;
1207
+ };
1208
+ };
1170
1209
  type Endpoints = {
1171
1210
  get_contract_addresses: {
1172
1211
  QUERY: never;
@@ -1269,10 +1308,11 @@ declare namespace Sequencer {
1269
1308
  };
1270
1309
  get_state_update: {
1271
1310
  QUERY: {
1272
- blockHash: string;
1311
+ blockHash?: string;
1312
+ blockNumber?: BlockNumber;
1273
1313
  };
1274
1314
  REQUEST: never;
1275
- RESPONSE: any;
1315
+ RESPONSE: StateUpdateResponse;
1276
1316
  };
1277
1317
  get_full_contract: {
1278
1318
  QUERY: {
@@ -1301,6 +1341,14 @@ declare namespace Sequencer {
1301
1341
  REQUEST: EstimateFeeRequestBulk;
1302
1342
  RESPONSE: EstimateFeeResponseBulk;
1303
1343
  };
1344
+ get_block_traces: {
1345
+ QUERY: {
1346
+ blockHash?: string;
1347
+ blockNumber?: BlockNumber;
1348
+ };
1349
+ REQUEST: never;
1350
+ RESPONSE: BlockTransactionTracesResponse;
1351
+ };
1304
1352
  };
1305
1353
  }
1306
1354
 
@@ -1406,6 +1454,17 @@ interface TransactionSimulationResponse {
1406
1454
  trace: TransactionTraceResponse;
1407
1455
  fee_estimation: EstimateFeeResponse;
1408
1456
  }
1457
+ interface StateUpdateResponse {
1458
+ block_hash: string;
1459
+ new_root: string;
1460
+ old_root: string;
1461
+ state_diff: {
1462
+ storage_diffs: Array<StorageDiffItem>;
1463
+ declared_contract_hashes: Array<string>;
1464
+ deployed_contracts: Array<DeployedContractItem>;
1465
+ nonces: Array<Nonces>;
1466
+ };
1467
+ }
1409
1468
 
1410
1469
  interface EstimateFee extends EstimateFeeResponse {
1411
1470
  suggestedMaxFee: BN__default;
@@ -1660,6 +1719,13 @@ declare abstract class ProviderInterface {
1660
1719
  * @returns the transaction trace and estimated fee
1661
1720
  */
1662
1721
  abstract getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
1722
+ /**
1723
+ * Gets the state changes in a specific block
1724
+ *
1725
+ * @param blockIdentifier - block identifier
1726
+ * @returns StateUpdateResponse
1727
+ */
1728
+ abstract getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
1663
1729
  }
1664
1730
 
1665
1731
  declare type RpcProviderOptions = {
@@ -1816,6 +1882,8 @@ declare class SequencerProvider implements ProviderInterface {
1816
1882
  getTransactionTrace(txHash: BigNumberish): Promise<TransactionTraceResponse>;
1817
1883
  estimateMessageFee({ from_address, to_address, entry_point_selector, payload }: CallL1Handler, blockIdentifier?: BlockIdentifier): Promise<Sequencer.EstimateFeeResponse>;
1818
1884
  getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
1885
+ getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
1886
+ getBlockTraces(blockIdentifier?: BlockIdentifier): Promise<Sequencer.BlockTransactionTracesResponse>;
1819
1887
  }
1820
1888
 
1821
1889
  interface ProviderOptions {
@@ -1847,6 +1915,7 @@ declare class Provider implements ProviderInterface {
1847
1915
  getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
1848
1916
  waitForTransaction(txHash: BigNumberish, retryInterval?: number, successStates?: Array<Status>): Promise<GetTransactionReceiptResponse>;
1849
1917
  getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
1918
+ getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
1850
1919
  }
1851
1920
 
1852
1921
  declare class LibraryError extends CustomError {
@@ -2805,4 +2874,4 @@ declare function validateChecksumAddress(address: string): boolean;
2805
2874
  declare function isUrl(s?: string): boolean;
2806
2875
  declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
2807
2876
 
2808
- export { Abi, AbiEntry, Account, AccountInterface, AllowArray, Args, AsyncContractFunction, BlockNumber, BlockTag, Call, CallContractResponse, CallDetails, CallL1Handler, CallOptions, Calldata, CommonTransactionReceiptResponse, CommonTransactionResponse, CompiledContract, CompressedCompiledContract, CompressedProgram, Contract, ContractClass, ContractEntryPoint, ContractFactory, ContractFunction, ContractInterface, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareDeployContractPayload, DeclareDeployUDCResponse, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractPayload, DeployContractResponse, DeployContractUDCResponse, EntryPointType, EntryPointsByType, EstimateFee, EstimateFeeAction, EstimateFeeBulk, EstimateFeeDetails, EstimateFeeResponse, EstimateFeeResponseBulk, Event, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, HttpError, Invocation, InvocationBulk, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeTransactionReceiptResponse, InvokeTransactionResponse, KeyPair, LibraryError, MessageToL1, MessageToL2, MultiDeployContractResponse, Overrides, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, RPC, RawArgs, RawCalldata, Result, RpcProvider, RpcProviderOptions, Sequencer, SequencerProvider, SequencerProviderOptions, Signature, Signer, SignerInterface, Status, Struct, StructAbi, TransactionBulk, TransactionSimulation, TransactionSimulationResponse, TransactionStatus, TransactionTraceResponse, TransactionType, UniversalDeployerContractPayload, addAddressPadding, buildUrl, constants, defaultProvider, ellipticCurve as ec, encode, getChecksumAddress, hash, isUrl, json, merkle, number, shortString, stark, transaction, index as typedData, uint256, validateAndParseAddress, validateChecksumAddress };
2877
+ export { Abi, AbiEntry, Account, AccountInterface, AllowArray, Args, AsyncContractFunction, BlockNumber, BlockTag, Call, CallContractResponse, CallDetails, CallL1Handler, CallOptions, Calldata, CommonTransactionReceiptResponse, CommonTransactionResponse, CompiledContract, CompressedCompiledContract, CompressedProgram, Contract, ContractClass, ContractEntryPoint, ContractFactory, ContractFunction, ContractInterface, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareDeployContractPayload, DeclareDeployUDCResponse, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractPayload, DeployContractResponse, DeployContractUDCResponse, DeployedContractItem, EntryPointType, EntryPointsByType, EstimateFee, EstimateFeeAction, EstimateFeeBulk, EstimateFeeDetails, EstimateFeeResponse, EstimateFeeResponseBulk, Event, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, HttpError, Invocation, InvocationBulk, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeTransactionReceiptResponse, InvokeTransactionResponse, KeyPair, LibraryError, MessageToL1, MessageToL2, MultiDeployContractResponse, Nonces, Overrides, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, RPC, RawArgs, RawCalldata, Result, RpcProvider, RpcProviderOptions, Sequencer, SequencerIdentifier, SequencerProvider, SequencerProviderOptions, Signature, Signer, SignerInterface, StateDiffItem, StateUpdateResponse, Status, StorageDiffItem, Struct, StructAbi, TransactionBulk, TransactionSimulation, TransactionSimulationResponse, TransactionStatus, TransactionTraceResponse, TransactionType, UniversalDeployerContractPayload, addAddressPadding, buildUrl, constants, defaultProvider, ellipticCurve as ec, encode, getChecksumAddress, hash, isUrl, json, merkle, number, shortString, stark, transaction, index as typedData, uint256, validateAndParseAddress, validateChecksumAddress };
@@ -20766,6 +20766,9 @@ var starknet = (() => {
20766
20766
  set identifier(_identifier) {
20767
20767
  this.setIdentifier(_identifier);
20768
20768
  }
20769
+ get sequencerIdentifier() {
20770
+ return this.hash !== null ? { blockHash: this.hash } : { blockNumber: this.number ?? this.tag };
20771
+ }
20769
20772
  };
20770
20773
 
20771
20774
  // src/provider/rpc.ts
@@ -21201,6 +21204,29 @@ var starknet = (() => {
21201
21204
  class_hash: res.class_hash
21202
21205
  };
21203
21206
  }
21207
+ parseGetStateUpdateResponse(res) {
21208
+ const nonces = [].concat(res.state_diff.nonces).map(({ contract_address, nonce }) => {
21209
+ return {
21210
+ contract_address,
21211
+ nonce
21212
+ };
21213
+ });
21214
+ const storage_diffs = [].concat(res.state_diff.storage_diffs).map(({ address, storage_entries }) => {
21215
+ return {
21216
+ address,
21217
+ storage_entries
21218
+ };
21219
+ });
21220
+ return {
21221
+ ...res,
21222
+ state_diff: {
21223
+ storage_diffs,
21224
+ declared_contract_hashes: res.state_diff.declared_contract_hashes,
21225
+ deployed_contracts: res.state_diff.deployed_contracts,
21226
+ nonces
21227
+ }
21228
+ };
21229
+ }
21204
21230
  };
21205
21231
 
21206
21232
  // src/utils/url.ts
@@ -21594,6 +21620,16 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
21594
21620
  }
21595
21621
  ).then(this.responseParser.parseFeeSimulateTransactionResponse);
21596
21622
  }
21623
+ async getStateUpdate(blockIdentifier = this.blockIdentifier) {
21624
+ const args = new Block(blockIdentifier).sequencerIdentifier;
21625
+ return this.fetchEndpoint("get_state_update", { ...args }).then(
21626
+ this.responseParser.parseGetStateUpdateResponse
21627
+ );
21628
+ }
21629
+ async getBlockTraces(blockIdentifier = this.blockIdentifier) {
21630
+ const args = new Block(blockIdentifier).sequencerIdentifier;
21631
+ return this.fetchEndpoint("get_block_traces", { ...args });
21632
+ }
21597
21633
  };
21598
21634
 
21599
21635
  // src/provider/default.ts
@@ -21681,6 +21717,9 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
21681
21717
  async getSimulateTransaction(invocation, invocationDetails, blockIdentifier) {
21682
21718
  return this.provider.getSimulateTransaction(invocation, invocationDetails, blockIdentifier);
21683
21719
  }
21720
+ async getStateUpdate(blockIdentifier) {
21721
+ return this.provider.getStateUpdate(blockIdentifier);
21722
+ }
21684
21723
  };
21685
21724
 
21686
21725
  // src/provider/interface.ts