starknet 4.19.1 → 4.19.3

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,16 @@
1
+ ## [4.19.3](https://github.com/0xs34n/starknet.js/compare/v4.19.2...v4.19.3) (2023-01-12)
2
+
3
+ ### Bug Fixes
4
+
5
+ - remove any type in simulateTransaction ([a94db18](https://github.com/0xs34n/starknet.js/commit/a94db1887c9fee676ac9b313190453abd5ea2554))
6
+ - update account.simulateTransaction return type ([3c3d397](https://github.com/0xs34n/starknet.js/commit/3c3d397a4fb1042c7358f70f50df0a4ce2893220))
7
+
8
+ ## [4.19.2](https://github.com/0xs34n/starknet.js/compare/v4.19.1...v4.19.2) (2023-01-11)
9
+
10
+ ### Bug Fixes
11
+
12
+ - repair and unify transaction retrieval error ([ea5e646](https://github.com/0xs34n/starknet.js/commit/ea5e64651bf47824b254ae73ed8aa88998a5be44))
13
+
1
14
  ## [4.19.1](https://github.com/0xs34n/starknet.js/compare/v4.19.0...v4.19.1) (2023-01-10)
2
15
 
3
16
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -971,139 +971,6 @@ interface Result extends Array<any> {
971
971
 
972
972
  declare type BlockIdentifier = BlockNumber | BigNumberish;
973
973
 
974
- /**
975
- * Common interface response
976
- * Intersection (sequencer response ∩ (∪ rpc responses))
977
- */
978
-
979
- interface GetBlockResponse {
980
- timestamp: number;
981
- block_hash: string;
982
- block_number: number;
983
- new_root: string;
984
- parent_hash: string;
985
- status: Status;
986
- transactions: Array<string>;
987
- gas_price?: string;
988
- sequencer_address?: string;
989
- starknet_version?: string;
990
- transaction_receipts?: any;
991
- }
992
- interface GetCodeResponse {
993
- bytecode: string[];
994
- }
995
- declare type GetTransactionResponse = InvokeTransactionResponse & DeclareTransactionResponse;
996
- interface CommonTransactionResponse {
997
- transaction_hash?: string;
998
- version?: string;
999
- signature?: Signature;
1000
- max_fee?: string;
1001
- nonce?: string;
1002
- }
1003
- interface InvokeTransactionResponse extends CommonTransactionResponse {
1004
- contract_address?: string;
1005
- entry_point_selector?: string;
1006
- calldata: RawCalldata;
1007
- }
1008
- interface ContractEntryPoint {
1009
- offset: string;
1010
- selector: string;
1011
- }
1012
- interface DeclareTransactionResponse extends CommonTransactionResponse {
1013
- contract_class?: any;
1014
- sender_address?: string;
1015
- }
1016
- declare type GetTransactionReceiptResponse = InvokeTransactionReceiptResponse | DeclareTransactionReceiptResponse;
1017
- interface CommonTransactionReceiptResponse {
1018
- transaction_hash: string;
1019
- status?: Status;
1020
- actual_fee?: string;
1021
- status_data?: string;
1022
- }
1023
- interface MessageToL1 {
1024
- to_address: string;
1025
- payload: Array<string>;
1026
- }
1027
- interface Event {
1028
- from_address: string;
1029
- keys: Array<string>;
1030
- data: Array<string>;
1031
- }
1032
- interface MessageToL2 {
1033
- from_address: string;
1034
- payload: Array<string>;
1035
- }
1036
- interface InvokeTransactionReceiptResponse extends CommonTransactionReceiptResponse {
1037
- /** @deprecated Use l2_to_l1_messages */
1038
- messages_sent?: Array<MessageToL1>;
1039
- events?: Array<Event>;
1040
- l1_origin_message?: MessageToL2;
1041
- }
1042
- declare type DeclareTransactionReceiptResponse = CommonTransactionReceiptResponse;
1043
- interface EstimateFeeResponse {
1044
- overall_fee: BN__default;
1045
- gas_consumed?: BN__default;
1046
- gas_price?: BN__default;
1047
- }
1048
- interface InvokeFunctionResponse {
1049
- transaction_hash: string;
1050
- }
1051
- interface DeclareContractResponse {
1052
- transaction_hash: string;
1053
- class_hash: string;
1054
- }
1055
- declare type CallContractResponse = {
1056
- result: Array<string>;
1057
- };
1058
- declare type EstimateFeeAction = {
1059
- type: 'INVOKE';
1060
- payload: AllowArray<Call>;
1061
- } | {
1062
- type: 'DECLARE';
1063
- payload: DeclareContractPayload;
1064
- } | {
1065
- type: 'DEPLOY_ACCOUNT';
1066
- payload: DeployAccountContractPayload;
1067
- } | {
1068
- type: 'DEPLOY';
1069
- payload: UniversalDeployerContractPayload;
1070
- };
1071
- declare type EstimateFeeResponseBulk = Array<EstimateFeeResponse>;
1072
-
1073
- interface EstimateFee extends EstimateFeeResponse {
1074
- suggestedMaxFee: BN__default;
1075
- }
1076
- declare type EstimateFeeBulk = Array<EstimateFee>;
1077
- interface EstimateFeeDetails {
1078
- nonce?: BigNumberish;
1079
- blockIdentifier?: BlockIdentifier;
1080
- }
1081
- interface DeployContractResponse {
1082
- contract_address: string;
1083
- transaction_hash: string;
1084
- }
1085
- declare type MultiDeployContractResponse = {
1086
- contract_address: Array<string>;
1087
- transaction_hash: string;
1088
- };
1089
- declare type DeployContractUDCResponse = {
1090
- contract_address: string;
1091
- transaction_hash: string;
1092
- address: string;
1093
- deployer: string;
1094
- unique: string;
1095
- classHash: string;
1096
- calldata_len: string;
1097
- calldata: Array<string>;
1098
- salt: string;
1099
- };
1100
- declare type DeclareDeployUDCResponse = {
1101
- declare: {
1102
- class_hash: BigNumberish;
1103
- } & DeclareTransactionReceiptResponse;
1104
- deploy: DeployContractUDCResponse;
1105
- };
1106
-
1107
974
  declare type GetTransactionStatusResponse = {
1108
975
  tx_status: Status;
1109
976
  block_hash?: string;
@@ -1437,6 +1304,146 @@ declare namespace Sequencer {
1437
1304
  };
1438
1305
  }
1439
1306
 
1307
+ /**
1308
+ * Common interface response
1309
+ * Intersection (sequencer response ∩ (∪ rpc responses))
1310
+ */
1311
+
1312
+ interface GetBlockResponse {
1313
+ timestamp: number;
1314
+ block_hash: string;
1315
+ block_number: number;
1316
+ new_root: string;
1317
+ parent_hash: string;
1318
+ status: Status;
1319
+ transactions: Array<string>;
1320
+ gas_price?: string;
1321
+ sequencer_address?: string;
1322
+ starknet_version?: string;
1323
+ transaction_receipts?: any;
1324
+ }
1325
+ interface GetCodeResponse {
1326
+ bytecode: string[];
1327
+ }
1328
+ declare type GetTransactionResponse = InvokeTransactionResponse & DeclareTransactionResponse;
1329
+ interface CommonTransactionResponse {
1330
+ transaction_hash?: string;
1331
+ version?: string;
1332
+ signature?: Signature;
1333
+ max_fee?: string;
1334
+ nonce?: string;
1335
+ }
1336
+ interface InvokeTransactionResponse extends CommonTransactionResponse {
1337
+ contract_address?: string;
1338
+ entry_point_selector?: string;
1339
+ calldata: RawCalldata;
1340
+ }
1341
+ interface ContractEntryPoint {
1342
+ offset: string;
1343
+ selector: string;
1344
+ }
1345
+ interface DeclareTransactionResponse extends CommonTransactionResponse {
1346
+ contract_class?: any;
1347
+ sender_address?: string;
1348
+ }
1349
+ declare type GetTransactionReceiptResponse = InvokeTransactionReceiptResponse | DeclareTransactionReceiptResponse;
1350
+ interface CommonTransactionReceiptResponse {
1351
+ transaction_hash: string;
1352
+ status?: Status;
1353
+ actual_fee?: string;
1354
+ status_data?: string;
1355
+ }
1356
+ interface MessageToL1 {
1357
+ to_address: string;
1358
+ payload: Array<string>;
1359
+ }
1360
+ interface Event {
1361
+ from_address: string;
1362
+ keys: Array<string>;
1363
+ data: Array<string>;
1364
+ }
1365
+ interface MessageToL2 {
1366
+ from_address: string;
1367
+ payload: Array<string>;
1368
+ }
1369
+ interface InvokeTransactionReceiptResponse extends CommonTransactionReceiptResponse {
1370
+ /** @deprecated Use l2_to_l1_messages */
1371
+ messages_sent?: Array<MessageToL1>;
1372
+ events?: Array<Event>;
1373
+ l1_origin_message?: MessageToL2;
1374
+ }
1375
+ declare type DeclareTransactionReceiptResponse = CommonTransactionReceiptResponse;
1376
+ interface EstimateFeeResponse {
1377
+ overall_fee: BN__default;
1378
+ gas_consumed?: BN__default;
1379
+ gas_price?: BN__default;
1380
+ }
1381
+ interface InvokeFunctionResponse {
1382
+ transaction_hash: string;
1383
+ }
1384
+ interface DeclareContractResponse {
1385
+ transaction_hash: string;
1386
+ class_hash: string;
1387
+ }
1388
+ declare type CallContractResponse = {
1389
+ result: Array<string>;
1390
+ };
1391
+ declare type EstimateFeeAction = {
1392
+ type: 'INVOKE';
1393
+ payload: AllowArray<Call>;
1394
+ } | {
1395
+ type: 'DECLARE';
1396
+ payload: DeclareContractPayload;
1397
+ } | {
1398
+ type: 'DEPLOY_ACCOUNT';
1399
+ payload: DeployAccountContractPayload;
1400
+ } | {
1401
+ type: 'DEPLOY';
1402
+ payload: UniversalDeployerContractPayload;
1403
+ };
1404
+ declare type EstimateFeeResponseBulk = Array<EstimateFeeResponse>;
1405
+ interface TransactionSimulationResponse {
1406
+ trace: TransactionTraceResponse;
1407
+ fee_estimation: EstimateFeeResponse;
1408
+ }
1409
+
1410
+ interface EstimateFee extends EstimateFeeResponse {
1411
+ suggestedMaxFee: BN__default;
1412
+ }
1413
+ declare type EstimateFeeBulk = Array<EstimateFee>;
1414
+ interface EstimateFeeDetails {
1415
+ nonce?: BigNumberish;
1416
+ blockIdentifier?: BlockIdentifier;
1417
+ }
1418
+ interface DeployContractResponse {
1419
+ contract_address: string;
1420
+ transaction_hash: string;
1421
+ }
1422
+ declare type MultiDeployContractResponse = {
1423
+ contract_address: Array<string>;
1424
+ transaction_hash: string;
1425
+ };
1426
+ declare type DeployContractUDCResponse = {
1427
+ contract_address: string;
1428
+ transaction_hash: string;
1429
+ address: string;
1430
+ deployer: string;
1431
+ unique: string;
1432
+ classHash: string;
1433
+ calldata_len: string;
1434
+ calldata: Array<string>;
1435
+ salt: string;
1436
+ };
1437
+ declare type DeclareDeployUDCResponse = {
1438
+ declare: {
1439
+ class_hash: BigNumberish;
1440
+ } & DeclareTransactionReceiptResponse;
1441
+ deploy: DeployContractUDCResponse;
1442
+ };
1443
+ interface TransactionSimulation extends TransactionSimulationResponse {
1444
+ fee_estimation: EstimateFee;
1445
+ }
1446
+
1440
1447
  declare abstract class ProviderInterface {
1441
1448
  abstract chainId: StarknetChainId;
1442
1449
  /**
@@ -1638,6 +1645,21 @@ declare abstract class ProviderInterface {
1638
1645
  * @return GetTransactionReceiptResponse
1639
1646
  */
1640
1647
  abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number, successStates?: Array<Status>): Promise<GetTransactionReceiptResponse>;
1648
+ /**
1649
+ * Simulates the transaction and returns the transaction trace and estimated fee.
1650
+ *
1651
+ * @param invocation the invocation object containing:
1652
+ * - contractAddress - the address of the contract
1653
+ * - entrypoint - the entrypoint of the contract
1654
+ * - calldata - (defaults to []) the calldata
1655
+ * - signature - (defaults to []) the signature
1656
+ * @param details - optional details containing:
1657
+ * - nonce - optional nonce
1658
+ * - version - optional version
1659
+ * @param blockIdentifier - block identifier
1660
+ * @returns the transaction trace and estimated fee
1661
+ */
1662
+ abstract getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
1641
1663
  }
1642
1664
 
1643
1665
  declare type RpcProviderOptions = {
@@ -1717,6 +1739,7 @@ declare class RpcProvider implements ProviderInterface {
1717
1739
  * @returns events and the pagination of the events
1718
1740
  */
1719
1741
  getEvents(eventFilter: RPC.EventFilter): Promise<RPC.GetEventsResponse>;
1742
+ getSimulateTransaction(_invocation: Invocation, _invocationDetails: InvocationsDetailsWithNonce, _blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
1720
1743
  }
1721
1744
 
1722
1745
  declare type NetworkName = 'mainnet-alpha' | 'goerli-alpha' | 'goerli-alpha-2';
@@ -1792,7 +1815,7 @@ declare class SequencerProvider implements ProviderInterface {
1792
1815
  */
1793
1816
  getTransactionTrace(txHash: BigNumberish): Promise<TransactionTraceResponse>;
1794
1817
  estimateMessageFee({ from_address, to_address, entry_point_selector, payload }: CallL1Handler, blockIdentifier?: BlockIdentifier): Promise<Sequencer.EstimateFeeResponse>;
1795
- simulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<Sequencer.TransactionSimulationResponse>;
1818
+ getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
1796
1819
  }
1797
1820
 
1798
1821
  interface ProviderOptions {
@@ -1823,13 +1846,16 @@ declare class Provider implements ProviderInterface {
1823
1846
  getDeployAccountEstimateFee(transaction: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1824
1847
  getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
1825
1848
  waitForTransaction(txHash: BigNumberish, retryInterval?: number, successStates?: Array<Status>): Promise<GetTransactionReceiptResponse>;
1849
+ getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
1826
1850
  }
1827
1851
 
1828
- declare class GatewayError extends CustomError {
1852
+ declare class LibraryError extends CustomError {
1853
+ }
1854
+ declare class GatewayError extends LibraryError {
1829
1855
  errorCode: string;
1830
1856
  constructor(message: string, errorCode: string);
1831
1857
  }
1832
- declare class HttpError extends CustomError {
1858
+ declare class HttpError extends LibraryError {
1833
1859
  errorCode: number;
1834
1860
  constructor(message: string, errorCode: number);
1835
1861
  }
@@ -2278,6 +2304,17 @@ declare abstract class AccountInterface extends ProviderInterface {
2278
2304
  * @returns suggestedMaxFee
2279
2305
  */
2280
2306
  abstract getSuggestedMaxFee(estimateFeeAction: EstimateFeeAction, details: EstimateFeeDetails): Promise<BigNumberish>;
2307
+ /**
2308
+ * Simulates the transaction and returns the transaction trace and estimated fee.
2309
+ *
2310
+ * @param calls the invocation object containing:
2311
+ * - contractAddress - the address of the contract
2312
+ * - entrypoint - the entrypoint of the contract
2313
+ * - calldata - (defaults to []) the calldata
2314
+ *
2315
+ * @returns response from estimate_fee
2316
+ */
2317
+ abstract simulateTransaction(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails): Promise<TransactionSimulation>;
2281
2318
  }
2282
2319
 
2283
2320
  declare class Account extends Provider implements AccountInterface {
@@ -2308,6 +2345,7 @@ declare class Account extends Provider implements AccountInterface {
2308
2345
  buildDeclarePayload({ classHash, contract }: DeclareContractPayload, { nonce, chainId, version, walletAddress, maxFee }: InvocationsSignerDetails): Promise<DeclareContractTransaction>;
2309
2346
  buildAccountDeployPayload({ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress, }: DeployAccountContractPayload, { nonce, chainId, version, maxFee }: InvocationsSignerDetails): Promise<DeployAccountContractTransaction>;
2310
2347
  buildUDCContractPayload(payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[]): Call[];
2348
+ simulateTransaction(calls: AllowArray<Call>, { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<TransactionSimulation>;
2311
2349
  }
2312
2350
 
2313
2351
  declare type CallOptions = {
@@ -2767,4 +2805,4 @@ declare function validateChecksumAddress(address: string): boolean;
2767
2805
  declare function isUrl(s?: string): boolean;
2768
2806
  declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
2769
2807
 
2770
- 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, 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, 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 };
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 };