starknet 4.19.2 → 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 +18 -0
- package/dist/index.d.ts +228 -137
- package/dist/index.global.js +94 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +94 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
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
|
+
|
|
12
|
+
## [4.19.3](https://github.com/0xs34n/starknet.js/compare/v4.19.2...v4.19.3) (2023-01-12)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- remove any type in simulateTransaction ([a94db18](https://github.com/0xs34n/starknet.js/commit/a94db1887c9fee676ac9b313190453abd5ea2554))
|
|
17
|
+
- update account.simulateTransaction return type ([3c3d397](https://github.com/0xs34n/starknet.js/commit/3c3d397a4fb1042c7358f70f50df0a4ce2893220))
|
|
18
|
+
|
|
1
19
|
## [4.19.2](https://github.com/0xs34n/starknet.js/compare/v4.19.1...v4.19.2) (2023-01-11)
|
|
2
20
|
|
|
3
21
|
### 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;
|
|
@@ -1154,6 +1021,27 @@ declare type CallL1Handler = {
|
|
|
1154
1021
|
entry_point_selector: string;
|
|
1155
1022
|
payload: Array<string>;
|
|
1156
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
|
+
};
|
|
1157
1045
|
declare namespace Sequencer {
|
|
1158
1046
|
type DeclareTransaction = {
|
|
1159
1047
|
type: 'DECLARE';
|
|
@@ -1300,6 +1188,19 @@ declare namespace Sequencer {
|
|
|
1300
1188
|
unit: string;
|
|
1301
1189
|
};
|
|
1302
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
|
+
};
|
|
1303
1204
|
type Endpoints = {
|
|
1304
1205
|
get_contract_addresses: {
|
|
1305
1206
|
QUERY: never;
|
|
@@ -1402,10 +1303,11 @@ declare namespace Sequencer {
|
|
|
1402
1303
|
};
|
|
1403
1304
|
get_state_update: {
|
|
1404
1305
|
QUERY: {
|
|
1405
|
-
blockHash
|
|
1306
|
+
blockHash?: string;
|
|
1307
|
+
blockNumber?: BlockNumber;
|
|
1406
1308
|
};
|
|
1407
1309
|
REQUEST: never;
|
|
1408
|
-
RESPONSE:
|
|
1310
|
+
RESPONSE: StateUpdateResponse;
|
|
1409
1311
|
};
|
|
1410
1312
|
get_full_contract: {
|
|
1411
1313
|
QUERY: {
|
|
@@ -1437,6 +1339,157 @@ declare namespace Sequencer {
|
|
|
1437
1339
|
};
|
|
1438
1340
|
}
|
|
1439
1341
|
|
|
1342
|
+
/**
|
|
1343
|
+
* Common interface response
|
|
1344
|
+
* Intersection (sequencer response ∩ (∪ rpc responses))
|
|
1345
|
+
*/
|
|
1346
|
+
|
|
1347
|
+
interface GetBlockResponse {
|
|
1348
|
+
timestamp: number;
|
|
1349
|
+
block_hash: string;
|
|
1350
|
+
block_number: number;
|
|
1351
|
+
new_root: string;
|
|
1352
|
+
parent_hash: string;
|
|
1353
|
+
status: Status;
|
|
1354
|
+
transactions: Array<string>;
|
|
1355
|
+
gas_price?: string;
|
|
1356
|
+
sequencer_address?: string;
|
|
1357
|
+
starknet_version?: string;
|
|
1358
|
+
transaction_receipts?: any;
|
|
1359
|
+
}
|
|
1360
|
+
interface GetCodeResponse {
|
|
1361
|
+
bytecode: string[];
|
|
1362
|
+
}
|
|
1363
|
+
declare type GetTransactionResponse = InvokeTransactionResponse & DeclareTransactionResponse;
|
|
1364
|
+
interface CommonTransactionResponse {
|
|
1365
|
+
transaction_hash?: string;
|
|
1366
|
+
version?: string;
|
|
1367
|
+
signature?: Signature;
|
|
1368
|
+
max_fee?: string;
|
|
1369
|
+
nonce?: string;
|
|
1370
|
+
}
|
|
1371
|
+
interface InvokeTransactionResponse extends CommonTransactionResponse {
|
|
1372
|
+
contract_address?: string;
|
|
1373
|
+
entry_point_selector?: string;
|
|
1374
|
+
calldata: RawCalldata;
|
|
1375
|
+
}
|
|
1376
|
+
interface ContractEntryPoint {
|
|
1377
|
+
offset: string;
|
|
1378
|
+
selector: string;
|
|
1379
|
+
}
|
|
1380
|
+
interface DeclareTransactionResponse extends CommonTransactionResponse {
|
|
1381
|
+
contract_class?: any;
|
|
1382
|
+
sender_address?: string;
|
|
1383
|
+
}
|
|
1384
|
+
declare type GetTransactionReceiptResponse = InvokeTransactionReceiptResponse | DeclareTransactionReceiptResponse;
|
|
1385
|
+
interface CommonTransactionReceiptResponse {
|
|
1386
|
+
transaction_hash: string;
|
|
1387
|
+
status?: Status;
|
|
1388
|
+
actual_fee?: string;
|
|
1389
|
+
status_data?: string;
|
|
1390
|
+
}
|
|
1391
|
+
interface MessageToL1 {
|
|
1392
|
+
to_address: string;
|
|
1393
|
+
payload: Array<string>;
|
|
1394
|
+
}
|
|
1395
|
+
interface Event {
|
|
1396
|
+
from_address: string;
|
|
1397
|
+
keys: Array<string>;
|
|
1398
|
+
data: Array<string>;
|
|
1399
|
+
}
|
|
1400
|
+
interface MessageToL2 {
|
|
1401
|
+
from_address: string;
|
|
1402
|
+
payload: Array<string>;
|
|
1403
|
+
}
|
|
1404
|
+
interface InvokeTransactionReceiptResponse extends CommonTransactionReceiptResponse {
|
|
1405
|
+
/** @deprecated Use l2_to_l1_messages */
|
|
1406
|
+
messages_sent?: Array<MessageToL1>;
|
|
1407
|
+
events?: Array<Event>;
|
|
1408
|
+
l1_origin_message?: MessageToL2;
|
|
1409
|
+
}
|
|
1410
|
+
declare type DeclareTransactionReceiptResponse = CommonTransactionReceiptResponse;
|
|
1411
|
+
interface EstimateFeeResponse {
|
|
1412
|
+
overall_fee: BN__default;
|
|
1413
|
+
gas_consumed?: BN__default;
|
|
1414
|
+
gas_price?: BN__default;
|
|
1415
|
+
}
|
|
1416
|
+
interface InvokeFunctionResponse {
|
|
1417
|
+
transaction_hash: string;
|
|
1418
|
+
}
|
|
1419
|
+
interface DeclareContractResponse {
|
|
1420
|
+
transaction_hash: string;
|
|
1421
|
+
class_hash: string;
|
|
1422
|
+
}
|
|
1423
|
+
declare type CallContractResponse = {
|
|
1424
|
+
result: Array<string>;
|
|
1425
|
+
};
|
|
1426
|
+
declare type EstimateFeeAction = {
|
|
1427
|
+
type: 'INVOKE';
|
|
1428
|
+
payload: AllowArray<Call>;
|
|
1429
|
+
} | {
|
|
1430
|
+
type: 'DECLARE';
|
|
1431
|
+
payload: DeclareContractPayload;
|
|
1432
|
+
} | {
|
|
1433
|
+
type: 'DEPLOY_ACCOUNT';
|
|
1434
|
+
payload: DeployAccountContractPayload;
|
|
1435
|
+
} | {
|
|
1436
|
+
type: 'DEPLOY';
|
|
1437
|
+
payload: UniversalDeployerContractPayload;
|
|
1438
|
+
};
|
|
1439
|
+
declare type EstimateFeeResponseBulk = Array<EstimateFeeResponse>;
|
|
1440
|
+
interface TransactionSimulationResponse {
|
|
1441
|
+
trace: TransactionTraceResponse;
|
|
1442
|
+
fee_estimation: EstimateFeeResponse;
|
|
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
|
+
}
|
|
1455
|
+
|
|
1456
|
+
interface EstimateFee extends EstimateFeeResponse {
|
|
1457
|
+
suggestedMaxFee: BN__default;
|
|
1458
|
+
}
|
|
1459
|
+
declare type EstimateFeeBulk = Array<EstimateFee>;
|
|
1460
|
+
interface EstimateFeeDetails {
|
|
1461
|
+
nonce?: BigNumberish;
|
|
1462
|
+
blockIdentifier?: BlockIdentifier;
|
|
1463
|
+
}
|
|
1464
|
+
interface DeployContractResponse {
|
|
1465
|
+
contract_address: string;
|
|
1466
|
+
transaction_hash: string;
|
|
1467
|
+
}
|
|
1468
|
+
declare type MultiDeployContractResponse = {
|
|
1469
|
+
contract_address: Array<string>;
|
|
1470
|
+
transaction_hash: string;
|
|
1471
|
+
};
|
|
1472
|
+
declare type DeployContractUDCResponse = {
|
|
1473
|
+
contract_address: string;
|
|
1474
|
+
transaction_hash: string;
|
|
1475
|
+
address: string;
|
|
1476
|
+
deployer: string;
|
|
1477
|
+
unique: string;
|
|
1478
|
+
classHash: string;
|
|
1479
|
+
calldata_len: string;
|
|
1480
|
+
calldata: Array<string>;
|
|
1481
|
+
salt: string;
|
|
1482
|
+
};
|
|
1483
|
+
declare type DeclareDeployUDCResponse = {
|
|
1484
|
+
declare: {
|
|
1485
|
+
class_hash: BigNumberish;
|
|
1486
|
+
} & DeclareTransactionReceiptResponse;
|
|
1487
|
+
deploy: DeployContractUDCResponse;
|
|
1488
|
+
};
|
|
1489
|
+
interface TransactionSimulation extends TransactionSimulationResponse {
|
|
1490
|
+
fee_estimation: EstimateFee;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1440
1493
|
declare abstract class ProviderInterface {
|
|
1441
1494
|
abstract chainId: StarknetChainId;
|
|
1442
1495
|
/**
|
|
@@ -1638,6 +1691,28 @@ declare abstract class ProviderInterface {
|
|
|
1638
1691
|
* @return GetTransactionReceiptResponse
|
|
1639
1692
|
*/
|
|
1640
1693
|
abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number, successStates?: Array<Status>): Promise<GetTransactionReceiptResponse>;
|
|
1694
|
+
/**
|
|
1695
|
+
* Simulates the transaction and returns the transaction trace and estimated fee.
|
|
1696
|
+
*
|
|
1697
|
+
* @param invocation the invocation object containing:
|
|
1698
|
+
* - contractAddress - the address of the contract
|
|
1699
|
+
* - entrypoint - the entrypoint of the contract
|
|
1700
|
+
* - calldata - (defaults to []) the calldata
|
|
1701
|
+
* - signature - (defaults to []) the signature
|
|
1702
|
+
* @param details - optional details containing:
|
|
1703
|
+
* - nonce - optional nonce
|
|
1704
|
+
* - version - optional version
|
|
1705
|
+
* @param blockIdentifier - block identifier
|
|
1706
|
+
* @returns the transaction trace and estimated fee
|
|
1707
|
+
*/
|
|
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>;
|
|
1641
1716
|
}
|
|
1642
1717
|
|
|
1643
1718
|
declare type RpcProviderOptions = {
|
|
@@ -1717,6 +1792,7 @@ declare class RpcProvider implements ProviderInterface {
|
|
|
1717
1792
|
* @returns events and the pagination of the events
|
|
1718
1793
|
*/
|
|
1719
1794
|
getEvents(eventFilter: RPC.EventFilter): Promise<RPC.GetEventsResponse>;
|
|
1795
|
+
getSimulateTransaction(_invocation: Invocation, _invocationDetails: InvocationsDetailsWithNonce, _blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
|
|
1720
1796
|
}
|
|
1721
1797
|
|
|
1722
1798
|
declare type NetworkName = 'mainnet-alpha' | 'goerli-alpha' | 'goerli-alpha-2';
|
|
@@ -1792,7 +1868,8 @@ declare class SequencerProvider implements ProviderInterface {
|
|
|
1792
1868
|
*/
|
|
1793
1869
|
getTransactionTrace(txHash: BigNumberish): Promise<TransactionTraceResponse>;
|
|
1794
1870
|
estimateMessageFee({ from_address, to_address, entry_point_selector, payload }: CallL1Handler, blockIdentifier?: BlockIdentifier): Promise<Sequencer.EstimateFeeResponse>;
|
|
1795
|
-
|
|
1871
|
+
getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
|
|
1872
|
+
getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
|
|
1796
1873
|
}
|
|
1797
1874
|
|
|
1798
1875
|
interface ProviderOptions {
|
|
@@ -1823,6 +1900,8 @@ declare class Provider implements ProviderInterface {
|
|
|
1823
1900
|
getDeployAccountEstimateFee(transaction: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
1824
1901
|
getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
|
1825
1902
|
waitForTransaction(txHash: BigNumberish, retryInterval?: number, successStates?: Array<Status>): Promise<GetTransactionReceiptResponse>;
|
|
1903
|
+
getSimulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<TransactionSimulationResponse>;
|
|
1904
|
+
getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
|
|
1826
1905
|
}
|
|
1827
1906
|
|
|
1828
1907
|
declare class LibraryError extends CustomError {
|
|
@@ -2280,6 +2359,17 @@ declare abstract class AccountInterface extends ProviderInterface {
|
|
|
2280
2359
|
* @returns suggestedMaxFee
|
|
2281
2360
|
*/
|
|
2282
2361
|
abstract getSuggestedMaxFee(estimateFeeAction: EstimateFeeAction, details: EstimateFeeDetails): Promise<BigNumberish>;
|
|
2362
|
+
/**
|
|
2363
|
+
* Simulates the transaction and returns the transaction trace and estimated fee.
|
|
2364
|
+
*
|
|
2365
|
+
* @param calls the invocation object containing:
|
|
2366
|
+
* - contractAddress - the address of the contract
|
|
2367
|
+
* - entrypoint - the entrypoint of the contract
|
|
2368
|
+
* - calldata - (defaults to []) the calldata
|
|
2369
|
+
*
|
|
2370
|
+
* @returns response from estimate_fee
|
|
2371
|
+
*/
|
|
2372
|
+
abstract simulateTransaction(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails): Promise<TransactionSimulation>;
|
|
2283
2373
|
}
|
|
2284
2374
|
|
|
2285
2375
|
declare class Account extends Provider implements AccountInterface {
|
|
@@ -2310,6 +2400,7 @@ declare class Account extends Provider implements AccountInterface {
|
|
|
2310
2400
|
buildDeclarePayload({ classHash, contract }: DeclareContractPayload, { nonce, chainId, version, walletAddress, maxFee }: InvocationsSignerDetails): Promise<DeclareContractTransaction>;
|
|
2311
2401
|
buildAccountDeployPayload({ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress, }: DeployAccountContractPayload, { nonce, chainId, version, maxFee }: InvocationsSignerDetails): Promise<DeployAccountContractTransaction>;
|
|
2312
2402
|
buildUDCContractPayload(payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[]): Call[];
|
|
2403
|
+
simulateTransaction(calls: AllowArray<Call>, { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<TransactionSimulation>;
|
|
2313
2404
|
}
|
|
2314
2405
|
|
|
2315
2406
|
declare type CallOptions = {
|
|
@@ -2769,4 +2860,4 @@ declare function validateChecksumAddress(address: string): boolean;
|
|
|
2769
2860
|
declare function isUrl(s?: string): boolean;
|
|
2770
2861
|
declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
|
|
2771
2862
|
|
|
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 };
|
|
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
|
|
@@ -21058,6 +21061,9 @@ var starknet = (() => {
|
|
|
21058
21061
|
async getEvents(eventFilter) {
|
|
21059
21062
|
return this.fetchEndpoint("starknet_getEvents", { filter: eventFilter });
|
|
21060
21063
|
}
|
|
21064
|
+
async getSimulateTransaction(_invocation, _invocationDetails, _blockIdentifier) {
|
|
21065
|
+
throw new Error("RPC does not implement simulateTransaction function");
|
|
21066
|
+
}
|
|
21061
21067
|
};
|
|
21062
21068
|
|
|
21063
21069
|
// src/provider/sequencer.ts
|
|
@@ -21151,6 +21157,31 @@ var starknet = (() => {
|
|
|
21151
21157
|
};
|
|
21152
21158
|
});
|
|
21153
21159
|
}
|
|
21160
|
+
parseFeeSimulateTransactionResponse(res) {
|
|
21161
|
+
if ("overall_fee" in res.fee_estimation) {
|
|
21162
|
+
let gasInfo = {};
|
|
21163
|
+
try {
|
|
21164
|
+
gasInfo = {
|
|
21165
|
+
gas_consumed: toBN(res.fee_estimation.gas_usage),
|
|
21166
|
+
gas_price: toBN(res.fee_estimation.gas_price)
|
|
21167
|
+
};
|
|
21168
|
+
} catch {
|
|
21169
|
+
}
|
|
21170
|
+
return {
|
|
21171
|
+
trace: res.trace,
|
|
21172
|
+
fee_estimation: {
|
|
21173
|
+
...gasInfo,
|
|
21174
|
+
overall_fee: toBN(res.fee_estimation.overall_fee)
|
|
21175
|
+
}
|
|
21176
|
+
};
|
|
21177
|
+
}
|
|
21178
|
+
return {
|
|
21179
|
+
trace: res.trace,
|
|
21180
|
+
fee_estimation: {
|
|
21181
|
+
overall_fee: toBN(res.fee_estimation.amount)
|
|
21182
|
+
}
|
|
21183
|
+
};
|
|
21184
|
+
}
|
|
21154
21185
|
parseCallContractResponse(res) {
|
|
21155
21186
|
return {
|
|
21156
21187
|
result: res.result
|
|
@@ -21173,6 +21204,29 @@ var starknet = (() => {
|
|
|
21173
21204
|
class_hash: res.class_hash
|
|
21174
21205
|
};
|
|
21175
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
|
+
}
|
|
21176
21230
|
};
|
|
21177
21231
|
|
|
21178
21232
|
// src/utils/url.ts
|
|
@@ -21552,7 +21606,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
21552
21606
|
};
|
|
21553
21607
|
return this.fetchEndpoint("estimate_message_fee", { blockIdentifier }, validCallL1Handler);
|
|
21554
21608
|
}
|
|
21555
|
-
async
|
|
21609
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
21556
21610
|
return this.fetchEndpoint(
|
|
21557
21611
|
"simulate_transaction",
|
|
21558
21612
|
{ blockIdentifier },
|
|
@@ -21564,6 +21618,12 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
21564
21618
|
version: toHex(toBN((invocationDetails == null ? void 0 : invocationDetails.version) || 1)),
|
|
21565
21619
|
nonce: toHex(toBN(invocationDetails.nonce))
|
|
21566
21620
|
}
|
|
21621
|
+
).then(this.responseParser.parseFeeSimulateTransactionResponse);
|
|
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
|
|
21567
21627
|
);
|
|
21568
21628
|
}
|
|
21569
21629
|
};
|
|
@@ -21650,6 +21710,12 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
21650
21710
|
async waitForTransaction(txHash, retryInterval, successStates) {
|
|
21651
21711
|
return this.provider.waitForTransaction(txHash, retryInterval, successStates);
|
|
21652
21712
|
}
|
|
21713
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier) {
|
|
21714
|
+
return this.provider.getSimulateTransaction(invocation, invocationDetails, blockIdentifier);
|
|
21715
|
+
}
|
|
21716
|
+
async getStateUpdate(blockIdentifier) {
|
|
21717
|
+
return this.provider.getStateUpdate(blockIdentifier);
|
|
21718
|
+
}
|
|
21653
21719
|
};
|
|
21654
21720
|
|
|
21655
21721
|
// src/provider/interface.ts
|
|
@@ -23054,6 +23120,33 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
23054
23120
|
});
|
|
23055
23121
|
return calls;
|
|
23056
23122
|
}
|
|
23123
|
+
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier } = {}) {
|
|
23124
|
+
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
23125
|
+
const nonce = toBN(providedNonce ?? await this.getNonce());
|
|
23126
|
+
const version3 = toBN(feeTransactionVersion);
|
|
23127
|
+
const chainId = await this.getChainId();
|
|
23128
|
+
const signerDetails = {
|
|
23129
|
+
walletAddress: this.address,
|
|
23130
|
+
nonce,
|
|
23131
|
+
maxFee: ZERO,
|
|
23132
|
+
version: version3,
|
|
23133
|
+
chainId
|
|
23134
|
+
};
|
|
23135
|
+
const invocation = await this.buildInvocation(transactions, signerDetails);
|
|
23136
|
+
const response = await super.getSimulateTransaction(
|
|
23137
|
+
invocation,
|
|
23138
|
+
{ version: version3, nonce },
|
|
23139
|
+
blockIdentifier
|
|
23140
|
+
);
|
|
23141
|
+
const suggestedMaxFee = estimatedFeeToMaxFee(response.fee_estimation.overall_fee);
|
|
23142
|
+
return {
|
|
23143
|
+
...response,
|
|
23144
|
+
fee_estimation: {
|
|
23145
|
+
...response.fee_estimation,
|
|
23146
|
+
suggestedMaxFee
|
|
23147
|
+
}
|
|
23148
|
+
};
|
|
23149
|
+
}
|
|
23057
23150
|
};
|
|
23058
23151
|
|
|
23059
23152
|
// src/account/interface.ts
|