starknet 4.19.3 → 4.20.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 +11 -0
- package/dist/index.d.ts +58 -3
- package/dist/index.global.js +35 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# [4.20.0](https://github.com/0xs34n/starknet.js/compare/v4.19.3...v4.20.0) (2023-01-17)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- add utility getter in Block class ([3a52292](https://github.com/0xs34n/starknet.js/commit/3a5229277978c3235eaf1f7003b39eeabecac53e))
|
|
6
|
+
- update responseParser & query parameters for sequencer ([a72db02](https://github.com/0xs34n/starknet.js/commit/a72db020aa1ac6924b2c047d067d553ac1b87248))
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add support for get_state_update in provider ([76035a1](https://github.com/0xs34n/starknet.js/commit/76035a148e7863fa1dbe440920eca34498480aa9))
|
|
11
|
+
|
|
1
12
|
## [4.19.3](https://github.com/0xs34n/starknet.js/compare/v4.19.2...v4.19.3) (2023-01-12)
|
|
2
13
|
|
|
3
14
|
### 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,19 @@ declare namespace Sequencer {
|
|
|
1167
1188
|
unit: string;
|
|
1168
1189
|
};
|
|
1169
1190
|
type EstimateFeeResponseBulk = AllowArray<EstimateFeeResponse>;
|
|
1191
|
+
type StateUpdateResponse = {
|
|
1192
|
+
block_hash: string;
|
|
1193
|
+
new_root: string;
|
|
1194
|
+
old_root: string;
|
|
1195
|
+
state_diff: {
|
|
1196
|
+
storage_diffs: Array<{
|
|
1197
|
+
[address: string]: Array<StateDiffItem>;
|
|
1198
|
+
}>;
|
|
1199
|
+
declared_contract_hashes: Array<string>;
|
|
1200
|
+
deployed_contracts: Array<DeployedContractItem>;
|
|
1201
|
+
nonces: Array<Nonces>;
|
|
1202
|
+
};
|
|
1203
|
+
};
|
|
1170
1204
|
type Endpoints = {
|
|
1171
1205
|
get_contract_addresses: {
|
|
1172
1206
|
QUERY: never;
|
|
@@ -1269,10 +1303,11 @@ declare namespace Sequencer {
|
|
|
1269
1303
|
};
|
|
1270
1304
|
get_state_update: {
|
|
1271
1305
|
QUERY: {
|
|
1272
|
-
blockHash
|
|
1306
|
+
blockHash?: string;
|
|
1307
|
+
blockNumber?: BlockNumber;
|
|
1273
1308
|
};
|
|
1274
1309
|
REQUEST: never;
|
|
1275
|
-
RESPONSE:
|
|
1310
|
+
RESPONSE: StateUpdateResponse;
|
|
1276
1311
|
};
|
|
1277
1312
|
get_full_contract: {
|
|
1278
1313
|
QUERY: {
|
|
@@ -1406,6 +1441,17 @@ interface TransactionSimulationResponse {
|
|
|
1406
1441
|
trace: TransactionTraceResponse;
|
|
1407
1442
|
fee_estimation: EstimateFeeResponse;
|
|
1408
1443
|
}
|
|
1444
|
+
interface StateUpdateResponse {
|
|
1445
|
+
block_hash: string;
|
|
1446
|
+
new_root: string;
|
|
1447
|
+
old_root: string;
|
|
1448
|
+
state_diff: {
|
|
1449
|
+
storage_diffs: Array<StorageDiffItem>;
|
|
1450
|
+
declared_contract_hashes: Array<string>;
|
|
1451
|
+
deployed_contracts: Array<DeployedContractItem>;
|
|
1452
|
+
nonces: Array<Nonces>;
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1409
1455
|
|
|
1410
1456
|
interface EstimateFee extends EstimateFeeResponse {
|
|
1411
1457
|
suggestedMaxFee: BN__default;
|
|
@@ -1660,6 +1706,13 @@ declare abstract class ProviderInterface {
|
|
|
1660
1706
|
* @returns the transaction trace and estimated fee
|
|
1661
1707
|
*/
|
|
1662
1708
|
abstract getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
|
|
1709
|
+
/**
|
|
1710
|
+
* Gets the state changes in a specific block
|
|
1711
|
+
*
|
|
1712
|
+
* @param blockIdentifier - block identifier
|
|
1713
|
+
* @returns StateUpdateResponse
|
|
1714
|
+
*/
|
|
1715
|
+
abstract getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
|
|
1663
1716
|
}
|
|
1664
1717
|
|
|
1665
1718
|
declare type RpcProviderOptions = {
|
|
@@ -1816,6 +1869,7 @@ declare class SequencerProvider implements ProviderInterface {
|
|
|
1816
1869
|
getTransactionTrace(txHash: BigNumberish): Promise<TransactionTraceResponse>;
|
|
1817
1870
|
estimateMessageFee({ from_address, to_address, entry_point_selector, payload }: CallL1Handler, blockIdentifier?: BlockIdentifier): Promise<Sequencer.EstimateFeeResponse>;
|
|
1818
1871
|
getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
|
|
1872
|
+
getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
|
|
1819
1873
|
}
|
|
1820
1874
|
|
|
1821
1875
|
interface ProviderOptions {
|
|
@@ -1847,6 +1901,7 @@ declare class Provider implements ProviderInterface {
|
|
|
1847
1901
|
getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
|
1848
1902
|
waitForTransaction(txHash: BigNumberish, retryInterval?: number, successStates?: Array<Status>): Promise<GetTransactionReceiptResponse>;
|
|
1849
1903
|
getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
|
|
1904
|
+
getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
|
|
1850
1905
|
}
|
|
1851
1906
|
|
|
1852
1907
|
declare class LibraryError extends CustomError {
|
|
@@ -2805,4 +2860,4 @@ declare function validateChecksumAddress(address: string): boolean;
|
|
|
2805
2860
|
declare function isUrl(s?: string): boolean;
|
|
2806
2861
|
declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
|
|
2807
2862
|
|
|
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 };
|
|
2863
|
+
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 };
|
package/dist/index.global.js
CHANGED
|
@@ -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,12 @@ ${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
|
+
}
|
|
21597
21629
|
};
|
|
21598
21630
|
|
|
21599
21631
|
// src/provider/default.ts
|
|
@@ -21681,6 +21713,9 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
21681
21713
|
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier) {
|
|
21682
21714
|
return this.provider.getSimulateTransaction(invocation, invocationDetails, blockIdentifier);
|
|
21683
21715
|
}
|
|
21716
|
+
async getStateUpdate(blockIdentifier) {
|
|
21717
|
+
return this.provider.getStateUpdate(blockIdentifier);
|
|
21718
|
+
}
|
|
21684
21719
|
};
|
|
21685
21720
|
|
|
21686
21721
|
// src/provider/interface.ts
|