starknet 4.19.2 → 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 +7 -0
- package/dist/index.d.ts +171 -135
- package/dist/index.global.js +60 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +60 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
## [4.19.2](https://github.com/0xs34n/starknet.js/compare/v4.19.1...v4.19.2) (2023-01-11)
|
|
2
9
|
|
|
3
10
|
### 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
|
-
|
|
1818
|
+
getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
|
|
1796
1819
|
}
|
|
1797
1820
|
|
|
1798
1821
|
interface ProviderOptions {
|
|
@@ -1823,6 +1846,7 @@ 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
1852
|
declare class LibraryError extends CustomError {
|
|
@@ -2280,6 +2304,17 @@ declare abstract class AccountInterface extends ProviderInterface {
|
|
|
2280
2304
|
* @returns suggestedMaxFee
|
|
2281
2305
|
*/
|
|
2282
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>;
|
|
2283
2318
|
}
|
|
2284
2319
|
|
|
2285
2320
|
declare class Account extends Provider implements AccountInterface {
|
|
@@ -2310,6 +2345,7 @@ declare class Account extends Provider implements AccountInterface {
|
|
|
2310
2345
|
buildDeclarePayload({ classHash, contract }: DeclareContractPayload, { nonce, chainId, version, walletAddress, maxFee }: InvocationsSignerDetails): Promise<DeclareContractTransaction>;
|
|
2311
2346
|
buildAccountDeployPayload({ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress, }: DeployAccountContractPayload, { nonce, chainId, version, maxFee }: InvocationsSignerDetails): Promise<DeployAccountContractTransaction>;
|
|
2312
2347
|
buildUDCContractPayload(payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[]): Call[];
|
|
2348
|
+
simulateTransaction(calls: AllowArray<Call>, { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<TransactionSimulation>;
|
|
2313
2349
|
}
|
|
2314
2350
|
|
|
2315
2351
|
declare type CallOptions = {
|
|
@@ -2769,4 +2805,4 @@ declare function validateChecksumAddress(address: string): boolean;
|
|
|
2769
2805
|
declare function isUrl(s?: string): boolean;
|
|
2770
2806
|
declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
|
|
2771
2807
|
|
|
2772
|
-
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, 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 };
|
package/dist/index.global.js
CHANGED
|
@@ -21058,6 +21058,9 @@ var starknet = (() => {
|
|
|
21058
21058
|
async getEvents(eventFilter) {
|
|
21059
21059
|
return this.fetchEndpoint("starknet_getEvents", { filter: eventFilter });
|
|
21060
21060
|
}
|
|
21061
|
+
async getSimulateTransaction(_invocation, _invocationDetails, _blockIdentifier) {
|
|
21062
|
+
throw new Error("RPC does not implement simulateTransaction function");
|
|
21063
|
+
}
|
|
21061
21064
|
};
|
|
21062
21065
|
|
|
21063
21066
|
// src/provider/sequencer.ts
|
|
@@ -21151,6 +21154,31 @@ var starknet = (() => {
|
|
|
21151
21154
|
};
|
|
21152
21155
|
});
|
|
21153
21156
|
}
|
|
21157
|
+
parseFeeSimulateTransactionResponse(res) {
|
|
21158
|
+
if ("overall_fee" in res.fee_estimation) {
|
|
21159
|
+
let gasInfo = {};
|
|
21160
|
+
try {
|
|
21161
|
+
gasInfo = {
|
|
21162
|
+
gas_consumed: toBN(res.fee_estimation.gas_usage),
|
|
21163
|
+
gas_price: toBN(res.fee_estimation.gas_price)
|
|
21164
|
+
};
|
|
21165
|
+
} catch {
|
|
21166
|
+
}
|
|
21167
|
+
return {
|
|
21168
|
+
trace: res.trace,
|
|
21169
|
+
fee_estimation: {
|
|
21170
|
+
...gasInfo,
|
|
21171
|
+
overall_fee: toBN(res.fee_estimation.overall_fee)
|
|
21172
|
+
}
|
|
21173
|
+
};
|
|
21174
|
+
}
|
|
21175
|
+
return {
|
|
21176
|
+
trace: res.trace,
|
|
21177
|
+
fee_estimation: {
|
|
21178
|
+
overall_fee: toBN(res.fee_estimation.amount)
|
|
21179
|
+
}
|
|
21180
|
+
};
|
|
21181
|
+
}
|
|
21154
21182
|
parseCallContractResponse(res) {
|
|
21155
21183
|
return {
|
|
21156
21184
|
result: res.result
|
|
@@ -21552,7 +21580,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
21552
21580
|
};
|
|
21553
21581
|
return this.fetchEndpoint("estimate_message_fee", { blockIdentifier }, validCallL1Handler);
|
|
21554
21582
|
}
|
|
21555
|
-
async
|
|
21583
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
21556
21584
|
return this.fetchEndpoint(
|
|
21557
21585
|
"simulate_transaction",
|
|
21558
21586
|
{ blockIdentifier },
|
|
@@ -21564,7 +21592,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
21564
21592
|
version: toHex(toBN((invocationDetails == null ? void 0 : invocationDetails.version) || 1)),
|
|
21565
21593
|
nonce: toHex(toBN(invocationDetails.nonce))
|
|
21566
21594
|
}
|
|
21567
|
-
);
|
|
21595
|
+
).then(this.responseParser.parseFeeSimulateTransactionResponse);
|
|
21568
21596
|
}
|
|
21569
21597
|
};
|
|
21570
21598
|
|
|
@@ -21650,6 +21678,9 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
21650
21678
|
async waitForTransaction(txHash, retryInterval, successStates) {
|
|
21651
21679
|
return this.provider.waitForTransaction(txHash, retryInterval, successStates);
|
|
21652
21680
|
}
|
|
21681
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier) {
|
|
21682
|
+
return this.provider.getSimulateTransaction(invocation, invocationDetails, blockIdentifier);
|
|
21683
|
+
}
|
|
21653
21684
|
};
|
|
21654
21685
|
|
|
21655
21686
|
// src/provider/interface.ts
|
|
@@ -23054,6 +23085,33 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
23054
23085
|
});
|
|
23055
23086
|
return calls;
|
|
23056
23087
|
}
|
|
23088
|
+
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier } = {}) {
|
|
23089
|
+
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
23090
|
+
const nonce = toBN(providedNonce ?? await this.getNonce());
|
|
23091
|
+
const version3 = toBN(feeTransactionVersion);
|
|
23092
|
+
const chainId = await this.getChainId();
|
|
23093
|
+
const signerDetails = {
|
|
23094
|
+
walletAddress: this.address,
|
|
23095
|
+
nonce,
|
|
23096
|
+
maxFee: ZERO,
|
|
23097
|
+
version: version3,
|
|
23098
|
+
chainId
|
|
23099
|
+
};
|
|
23100
|
+
const invocation = await this.buildInvocation(transactions, signerDetails);
|
|
23101
|
+
const response = await super.getSimulateTransaction(
|
|
23102
|
+
invocation,
|
|
23103
|
+
{ version: version3, nonce },
|
|
23104
|
+
blockIdentifier
|
|
23105
|
+
);
|
|
23106
|
+
const suggestedMaxFee = estimatedFeeToMaxFee(response.fee_estimation.overall_fee);
|
|
23107
|
+
return {
|
|
23108
|
+
...response,
|
|
23109
|
+
fee_estimation: {
|
|
23110
|
+
...response.fee_estimation,
|
|
23111
|
+
suggestedMaxFee
|
|
23112
|
+
}
|
|
23113
|
+
};
|
|
23114
|
+
}
|
|
23057
23115
|
};
|
|
23058
23116
|
|
|
23059
23117
|
// src/account/interface.ts
|