starknet 4.17.1 → 4.19.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.
Files changed (150) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +2 -10
  3. package/dist/index.d.ts +86 -4
  4. package/dist/index.global.js +232 -45
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +232 -45
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +232 -45
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +5 -1
  11. package/.babelrc +0 -6
  12. package/.commitlintrc +0 -22
  13. package/.eslintignore +0 -2
  14. package/.eslintrc +0 -28
  15. package/.prettierrc +0 -6
  16. package/.releaserc +0 -28
  17. package/CODE_OF_CONDUCT.md +0 -128
  18. package/CONTRIBUTING.md +0 -52
  19. package/__mocks__/Account.json +0 -25486
  20. package/__mocks__/ERC20.json +0 -40027
  21. package/__mocks__/TestDapp.json +0 -12962
  22. package/__mocks__/contract.json +0 -33191
  23. package/__mocks__/l1l2_compiled.json +0 -10107
  24. package/__mocks__/multicall.json +0 -8139
  25. package/__mocks__/naming_compiled.json +0 -53283
  26. package/__mocks__/starknetId_compiled.json +0 -44703
  27. package/__mocks__/typedDataExample.json +0 -35
  28. package/__mocks__/typedDataSessionExample.json +0 -42
  29. package/__mocks__/typedDataStructArrayExample.json +0 -44
  30. package/__tests__/account.test.ts +0 -345
  31. package/__tests__/contract.test.ts +0 -249
  32. package/__tests__/defaultProvider.test.ts +0 -177
  33. package/__tests__/fixtures.ts +0 -84
  34. package/__tests__/jest.setup.ts +0 -30
  35. package/__tests__/rpcProvider.test.ts +0 -132
  36. package/__tests__/sequencerProvider.test.ts +0 -123
  37. package/__tests__/utils/__snapshots__/ellipticalCurve.test.ts.snap +0 -5
  38. package/__tests__/utils/__snapshots__/utils.browser.test.ts.snap +0 -5
  39. package/__tests__/utils/__snapshots__/utils.test.ts.snap +0 -5
  40. package/__tests__/utils/address.test.ts +0 -45
  41. package/__tests__/utils/ellipticalCurve.test.ts +0 -91
  42. package/__tests__/utils/merkle.test.ts +0 -256
  43. package/__tests__/utils/shortString.test.ts +0 -22
  44. package/__tests__/utils/starknetId.test.ts +0 -53
  45. package/__tests__/utils/transactionHash.test.ts +0 -17
  46. package/__tests__/utils/typedData.test.ts +0 -223
  47. package/__tests__/utils/uint256.test.ts +0 -32
  48. package/__tests__/utils/utils.browser.test.ts +0 -29
  49. package/__tests__/utils/utils.test.ts +0 -141
  50. package/img/logo.svg +0 -17
  51. package/index.d.ts +0 -2687
  52. package/index.global.js +0 -23194
  53. package/index.global.js.map +0 -1
  54. package/index.js +0 -4912
  55. package/index.js.map +0 -1
  56. package/index.mjs +0 -4854
  57. package/index.mjs.map +0 -1
  58. package/src/account/default.ts +0 -501
  59. package/src/account/index.ts +0 -2
  60. package/src/account/interface.ts +0 -311
  61. package/src/constants.ts +0 -2065
  62. package/src/contract/contractFactory.ts +0 -88
  63. package/src/contract/default.ts +0 -425
  64. package/src/contract/index.ts +0 -3
  65. package/src/contract/interface.ts +0 -106
  66. package/src/index.ts +0 -26
  67. package/src/provider/default.ts +0 -187
  68. package/src/provider/errors.ts +0 -14
  69. package/src/provider/index.ts +0 -9
  70. package/src/provider/interface.ts +0 -281
  71. package/src/provider/rpc.ts +0 -484
  72. package/src/provider/sequencer.ts +0 -523
  73. package/src/provider/utils.ts +0 -100
  74. package/src/signer/default.ts +0 -99
  75. package/src/signer/index.ts +0 -2
  76. package/src/signer/interface.ts +0 -77
  77. package/src/types/account.ts +0 -43
  78. package/src/types/api/index.ts +0 -10
  79. package/src/types/api/openrpc.ts +0 -609
  80. package/src/types/api/rpc.ts +0 -45
  81. package/src/types/api/sequencer.ts +0 -369
  82. package/src/types/contract.ts +0 -5
  83. package/src/types/index.ts +0 -8
  84. package/src/types/lib.ts +0 -143
  85. package/src/types/provider.ts +0 -134
  86. package/src/types/signer.ts +0 -24
  87. package/src/utils/address.ts +0 -44
  88. package/src/utils/calldata.ts +0 -250
  89. package/src/utils/ellipticCurve.ts +0 -120
  90. package/src/utils/encode.ts +0 -66
  91. package/src/utils/events.ts +0 -32
  92. package/src/utils/fetchPonyfill.ts +0 -5
  93. package/src/utils/hash.ts +0 -235
  94. package/src/utils/json.ts +0 -15
  95. package/src/utils/merkle.ts +0 -69
  96. package/src/utils/number.ts +0 -98
  97. package/src/utils/provider.ts +0 -28
  98. package/src/utils/responseParser/index.ts +0 -28
  99. package/src/utils/responseParser/rpc.ts +0 -70
  100. package/src/utils/responseParser/sequencer.ts +0 -135
  101. package/src/utils/shortString.ts +0 -21
  102. package/src/utils/stark.ts +0 -57
  103. package/src/utils/starknetId.ts +0 -116
  104. package/src/utils/transaction.ts +0 -56
  105. package/src/utils/typedData/index.ts +0 -247
  106. package/src/utils/typedData/types.ts +0 -37
  107. package/src/utils/typedData/utils.ts +0 -16
  108. package/src/utils/uint256.ts +0 -32
  109. package/src/utils/url.ts +0 -53
  110. package/tsconfig.eslint.json +0 -4
  111. package/tsup.config.ts +0 -9
  112. package/www/README.md +0 -41
  113. package/www/babel.config.js +0 -3
  114. package/www/code-examples/account.js +0 -65
  115. package/www/code-examples/amm.js +0 -44
  116. package/www/code-examples/erc20.js +0 -13
  117. package/www/code-examples/package-lock.json +0 -336
  118. package/www/code-examples/package.json +0 -15
  119. package/www/docs/API/_category_.json +0 -5
  120. package/www/docs/API/account.md +0 -463
  121. package/www/docs/API/changelog.md +0 -15
  122. package/www/docs/API/contract.md +0 -135
  123. package/www/docs/API/contractFactory.md +0 -45
  124. package/www/docs/API/index.md +0 -3
  125. package/www/docs/API/provider.md +0 -725
  126. package/www/docs/API/signer.md +0 -105
  127. package/www/docs/API/utils.md +0 -374
  128. package/www/docusaurus.config.js +0 -130
  129. package/www/guides/account.md +0 -140
  130. package/www/guides/cra.md +0 -3
  131. package/www/guides/erc20.md +0 -163
  132. package/www/guides/intro.md +0 -63
  133. package/www/package-lock.json +0 -20405
  134. package/www/package.json +0 -43
  135. package/www/sidebars.js +0 -31
  136. package/www/src/components/HomepageFeatures/index.tsx +0 -67
  137. package/www/src/components/HomepageFeatures/styles.module.css +0 -10
  138. package/www/src/css/custom.css +0 -39
  139. package/www/src/pages/index.module.css +0 -23
  140. package/www/src/pages/index.tsx +0 -40
  141. package/www/src/pages/markdown-page.md +0 -7
  142. package/www/static/.nojekyll +0 -0
  143. package/www/static/img/docusaurus.png +0 -0
  144. package/www/static/img/favicon.ico +0 -0
  145. package/www/static/img/logo.svg +0 -17
  146. package/www/static/img/starknet-1.png +0 -0
  147. package/www/static/img/starknet-2.png +0 -0
  148. package/www/static/img/starknet-3.png +0 -0
  149. package/www/static/img/tutorial/docsVersionDropdown.png +0 -0
  150. package/www/static/img/tutorial/localeDropdown.png +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ # [4.19.0](https://github.com/0xs34n/starknet.js/compare/v4.18.0...v4.19.0) (2023-01-09)
2
+
3
+ ### Bug Fixes
4
+
5
+ - merge develop into feat/add_estimate_fee_bulk ([88e76af](https://github.com/0xs34n/starknet.js/commit/88e76af68dd711b3f277c0a6d4f1935710aba4d7))
6
+ - update getEstimateFeeBulk function ([4b22c82](https://github.com/0xs34n/starknet.js/commit/4b22c8212f4586b37dc7c8ddfad77955e44b1b12))
7
+ - update types & add separate responseParser for estimateFeeBulk ([52110b2](https://github.com/0xs34n/starknet.js/commit/52110b289e3dfbbe449cf195709b2714f295a70d))
8
+
9
+ ### Features
10
+
11
+ - add function estimateInvokeFeeBulk ([e716a18](https://github.com/0xs34n/starknet.js/commit/e716a1882f3ac37d17eae72a51cd3c4fc4649bcb))
12
+ - update estimateFeeBulk ([5ee94f7](https://github.com/0xs34n/starknet.js/commit/5ee94f78af681690905e1ead1de711e3a43c0774))
13
+ - update estimateFeeBulk function & doc ([ce20139](https://github.com/0xs34n/starknet.js/commit/ce201394142a19c4810a1e44cb3f601b815a11fe))
14
+ - update sequencer api ([a12f99e](https://github.com/0xs34n/starknet.js/commit/a12f99ea6e93fb5d44d4d07f7fa8cc2d997db91a))
15
+
16
+ # [4.18.0](https://github.com/0xs34n/starknet.js/compare/v4.17.1...v4.18.0) (2022-12-23)
17
+
18
+ ### Bug Fixes
19
+
20
+ - merge develop into branch ([21efcb1](https://github.com/0xs34n/starknet.js/commit/21efcb1cefd6ea70a9d49e060ff620e88002e3b6))
21
+
22
+ ### Features
23
+
24
+ - simulate_transaction support on sequencer ([304c3cc](https://github.com/0xs34n/starknet.js/commit/304c3cc1af81bc8810581546f043caca01db173b))
25
+ - update simulate tx ([8f3ea55](https://github.com/0xs34n/starknet.js/commit/8f3ea55eb1e23cefc0419902a2ebbe10ee373ccb))
26
+ - update simulate tx in sequencer ([d79a9fa](https://github.com/0xs34n/starknet.js/commit/d79a9faa307936561504c120f67f3fb2f18423b6))
27
+
1
28
  ## [4.17.1](https://github.com/0xs34n/starknet.js/compare/v4.17.0...v4.17.1) (2022-12-14)
2
29
 
3
30
  ### Bug Fixes
package/README.md CHANGED
@@ -56,14 +56,6 @@ Guides can be found [here](https://www.starknetjs.com/guides/intro)
56
56
 
57
57
  [Click Here](https://www.starknetjs.com/docs/API/)
58
58
 
59
- ## 🚀 Powered by Starknet.js
60
-
61
- - [Argent X - the first StarkNet wallet](https://github.com/argentlabs/argent-x)
62
- - [Braavos - your new wallet on top of StarkNet](https://chrome.google.com/webstore/detail/braavos-wallet/jnlgamecbpmbajjfhmmmlhejkemejdma)
63
- - [React + Starknet.js boilerplate](https://github.com/fracek/starknet-react-example)
64
- - [AMM Demo](https://www.starknetswap.com/)
65
- - [mySwap - the first DeFi app to launch on StarkNet](https://myswap.xyz)
66
-
67
59
  ## ✏️ Contributing
68
60
 
69
61
  If you consider to contribute to this project please read [CONTRIBUTING.md](https://github.com/0xs34n/starknet.js/blob/main/CONTRIBUTING.md) first.
@@ -72,9 +64,9 @@ If you consider to contribute to this project please read [CONTRIBUTING.md](http
72
64
 
73
65
  Special thanks to all the [contributors](https://github.com/0xs34n/starknet.js/graphs/contributors), especially to:
74
66
 
75
- Janek ([@janek26](https://github.com/janek26)), Axel ([@delaaxe](https://github.com/delaaxe)) and Dhruv ([@dhruvkelawala](https://github.com/dhruvkelawala)) from [Argent](https://github.com/argentlabs)
67
+ Janek ([@janek26](https://github.com/janek26)) and Dhruv ([@dhruvkelawala](https://github.com/dhruvkelawala)) from [Argent](https://github.com/argentlabs)
76
68
 
77
- Miljan ([@MilGard91](https://github.com/MilGard91)) from [Shard Labs](https://shardlabs.io/)
69
+ Toni ([@tabaktoni](https://github.com/tabaktoni)) and Ivan ([@ivpavici](https://github.com/ivpavici)) from [Shard Labs](https://shardlabs.io/)
78
70
 
79
71
  and of course the [StarkWare](https://starkware.co/) team for their dedicated support!
80
72
 
package/dist/index.d.ts CHANGED
@@ -741,6 +741,32 @@ declare type InvocationsDetails = {
741
741
  declare type InvocationsDetailsWithNonce = InvocationsDetails & {
742
742
  nonce: BigNumberish;
743
743
  };
744
+ declare type TransactionBulk = Array<({
745
+ type: 'DECLARE';
746
+ } & {
747
+ payload: DeclareContractPayload;
748
+ }) | ({
749
+ type: 'DEPLOY';
750
+ } & {
751
+ payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[];
752
+ }) | ({
753
+ type: 'DEPLOY_ACCOUNT';
754
+ } & {
755
+ payload: DeployAccountContractPayload;
756
+ }) | ({
757
+ type: 'INVOKE_FUNCTION';
758
+ } & {
759
+ payload: AllowArray<Call>;
760
+ })>;
761
+ declare type InvocationBulk = Array<(({
762
+ type: 'DECLARE';
763
+ } & DeclareContractTransaction) | ({
764
+ type: 'DEPLOY_ACCOUNT';
765
+ } & DeployAccountContractTransaction) | ({
766
+ type: 'INVOKE_FUNCTION';
767
+ } & Invocation)) & InvocationsDetailsWithNonce & {
768
+ blockIdentifier: BlockNumber | BigNumberish;
769
+ }>;
744
770
  declare type Status = 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
745
771
  declare type TransactionStatus = 'TRANSACTION_RECEIVED';
746
772
  declare type TransactionType = 'DECLARE' | 'DEPLOY' | 'INVOKE_FUNCTION' | 'DEPLOY_ACCOUNT';
@@ -1042,6 +1068,7 @@ declare type EstimateFeeAction = {
1042
1068
  type: 'DEPLOY';
1043
1069
  payload: UniversalDeployerContractPayload;
1044
1070
  };
1071
+ declare type EstimateFeeResponseBulk = Array<EstimateFeeResponse>;
1045
1072
 
1046
1073
  interface EstimateFee extends EstimateFeeResponse {
1047
1074
  suggestedMaxFee: BN__default;
@@ -1114,7 +1141,7 @@ declare type ExecutionResources = {
1114
1141
  };
1115
1142
  n_memory_holes: number;
1116
1143
  };
1117
- declare type GetTransactionTraceResponse = {
1144
+ declare type TransactionTraceResponse = {
1118
1145
  validate_invocation?: FunctionInvocation;
1119
1146
  function_invocation?: FunctionInvocation;
1120
1147
  fee_transfer_invocation?: FunctionInvocation;
@@ -1256,14 +1283,22 @@ declare namespace Sequencer {
1256
1283
  type DeployAccountEstimateFee = Omit<DeployAccountTransaction, 'max_fee'>;
1257
1284
  type DeployEstimateFee = DeployTransaction;
1258
1285
  type EstimateFeeRequest = InvokeEstimateFee | DeclareEstimateFee | DeployEstimateFee | DeployAccountEstimateFee;
1286
+ type TransactionSimulationResponse = {
1287
+ trace: TransactionTraceResponse;
1288
+ fee_estimation: Sequencer.EstimateFeeResponse;
1289
+ };
1290
+ type SimulateTransaction = Omit<InvokeFunctionTransaction, 'max_fee' | 'entry_point_type'>;
1291
+ type EstimateFeeRequestBulk = AllowArray<InvokeEstimateFee | DeclareEstimateFee | DeployEstimateFee | DeployAccountEstimateFee>;
1259
1292
  type EstimateFeeResponse = {
1260
1293
  overall_fee: number;
1261
1294
  gas_price: number;
1262
1295
  gas_usage: number;
1296
+ uint: string;
1263
1297
  } | {
1264
1298
  amount: BN__default;
1265
1299
  unit: string;
1266
1300
  };
1301
+ type EstimateFeeResponseBulk = AllowArray<EstimateFeeResponse>;
1267
1302
  type Endpoints = {
1268
1303
  get_contract_addresses: {
1269
1304
  QUERY: never;
@@ -1294,7 +1329,7 @@ declare namespace Sequencer {
1294
1329
  transactionHash: string;
1295
1330
  };
1296
1331
  REQUEST: never;
1297
- RESPONSE: GetTransactionTraceResponse;
1332
+ RESPONSE: TransactionTraceResponse;
1298
1333
  };
1299
1334
  get_transaction_receipt: {
1300
1335
  QUERY: {
@@ -1384,6 +1419,20 @@ declare namespace Sequencer {
1384
1419
  REQUEST: any;
1385
1420
  RESPONSE: EstimateFeeResponse;
1386
1421
  };
1422
+ simulate_transaction: {
1423
+ QUERY: {
1424
+ blockIdentifier: BlockIdentifier;
1425
+ };
1426
+ REQUEST: SimulateTransaction;
1427
+ RESPONSE: TransactionSimulationResponse;
1428
+ };
1429
+ estimate_fee_bulk: {
1430
+ QUERY: {
1431
+ blockIdentifier: BlockIdentifier;
1432
+ };
1433
+ REQUEST: EstimateFeeRequestBulk;
1434
+ RESPONSE: EstimateFeeResponseBulk;
1435
+ };
1387
1436
  };
1388
1437
  }
1389
1438
 
@@ -1568,6 +1617,19 @@ declare abstract class ProviderInterface {
1568
1617
  * @returns the estimated fee
1569
1618
  */
1570
1619
  abstract getDeployAccountEstimateFee(transaction: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1620
+ /**
1621
+ * Estimates the fee for a list of INVOKE transaction
1622
+ *
1623
+ * @param invocations the array of invocation and invocation details object containing:
1624
+ * - contractAddress - the address of the account
1625
+ * - calldata - (defaults to []) the calldata
1626
+ * - signature - (defaults to []) the signature
1627
+ * - nonce - optional nonce
1628
+ * - version - optional version
1629
+ * @param blockIdentifier - block identifier
1630
+ * @returns the estimated fee
1631
+ */
1632
+ abstract getEstimateFeeBulk(invocations: InvocationBulk, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponseBulk>;
1571
1633
  /**
1572
1634
  * Wait for the transaction to be accepted
1573
1635
  * @param txHash - transaction hash
@@ -1617,6 +1679,7 @@ declare class RpcProvider implements ProviderInterface {
1617
1679
  getInvokeEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1618
1680
  getDeclareEstimateFee({ senderAddress, contractDefinition, signature }: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1619
1681
  getDeployAccountEstimateFee({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1682
+ getEstimateFeeBulk(_invocations: InvocationBulk, _blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponseBulk>;
1620
1683
  declareContract({ contractDefinition, signature, senderAddress }: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
1621
1684
  deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
1622
1685
  invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
@@ -1701,6 +1764,7 @@ declare class SequencerProvider implements ProviderInterface {
1701
1764
  getInvokeEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1702
1765
  getDeclareEstimateFee({ senderAddress, contractDefinition, signature }: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1703
1766
  getDeployAccountEstimateFee({ classHash, addressSalt, constructorCalldata, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1767
+ getEstimateFeeBulk(invocations: InvocationBulk, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponseBulk>;
1704
1768
  getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<Sequencer.GetCodeResponse>;
1705
1769
  waitForTransaction(txHash: BigNumberish, retryInterval?: number, successStates?: string[]): Promise<GetTransactionReceiptResponse>;
1706
1770
  /**
@@ -1725,8 +1789,9 @@ declare class SequencerProvider implements ProviderInterface {
1725
1789
  * @param txHash
1726
1790
  * @returns the transaction trace
1727
1791
  */
1728
- getTransactionTrace(txHash: BigNumberish): Promise<GetTransactionTraceResponse>;
1792
+ getTransactionTrace(txHash: BigNumberish): Promise<TransactionTraceResponse>;
1729
1793
  estimateMessageFee({ from_address, to_address, entry_point_selector, payload }: CallL1Handler, blockIdentifier?: BlockIdentifier): Promise<Sequencer.EstimateFeeResponse>;
1794
+ simulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<Sequencer.TransactionSimulationResponse>;
1730
1795
  }
1731
1796
 
1732
1797
  interface ProviderOptions {
@@ -1744,6 +1809,7 @@ declare class Provider implements ProviderInterface {
1744
1809
  getClassByHash(classHash: string): Promise<ContractClass>;
1745
1810
  getEstimateFee(invocationWithTxType: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier: BlockIdentifier): Promise<EstimateFeeResponse>;
1746
1811
  getInvokeEstimateFee(invocationWithTxType: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1812
+ getEstimateFeeBulk(invocations: InvocationBulk, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponseBulk>;
1747
1813
  getNonceForAddress(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1748
1814
  getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1749
1815
  getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
@@ -2035,6 +2101,17 @@ declare abstract class AccountInterface extends ProviderInterface {
2035
2101
  * - optional maxFee
2036
2102
  */
2037
2103
  abstract estimateDeployFee(deployContractPayload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], transactionsDetail?: InvocationsDetails): Promise<EstimateFeeResponse>;
2104
+ /**
2105
+ * Estimate Fee for executing a list of transactions on starknet
2106
+ * Contract must be deployed for fee estimation to be possible
2107
+ *
2108
+ * @param transactions array of transaction object containing :
2109
+ * - type - the type of transaction : 'DECLARE' | 'DEPLOY' | 'INVOKE_FUNCTION' | 'DEPLOY_ACCOUNT'
2110
+ * - payload - the payload of the transaction
2111
+ *
2112
+ * @returns response from estimate_fee
2113
+ */
2114
+ abstract estimateFeeBulk(transactions: TransactionBulk, estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponseBulk>;
2038
2115
  /**
2039
2116
  * Invoke execute function in account contract
2040
2117
  *
@@ -2214,6 +2291,8 @@ declare class Account extends Provider implements AccountInterface {
2214
2291
  estimateDeclareFee({ classHash, contract }: DeclareContractPayload, { blockIdentifier, nonce: providedNonce }?: EstimateFeeDetails): Promise<EstimateFee>;
2215
2292
  estimateAccountDeployFee({ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress, }: DeployAccountContractPayload, { blockIdentifier }?: EstimateFeeDetails): Promise<EstimateFee>;
2216
2293
  estimateDeployFee(payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], transactionsDetail?: InvocationsDetails | undefined): Promise<EstimateFee>;
2294
+ estimateFeeBulk(transactions: TransactionBulk, { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<EstimateFeeResponseBulk>;
2295
+ buildInvocation(call: Array<Call>, signerDetails: InvocationsSignerDetails): Promise<Invocation>;
2217
2296
  execute(calls: AllowArray<Call>, abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
2218
2297
  declare({ classHash, contract }: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
2219
2298
  deploy(payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], details?: InvocationsDetails | undefined): Promise<MultiDeployContractResponse>;
@@ -2225,6 +2304,9 @@ declare class Account extends Provider implements AccountInterface {
2225
2304
  verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
2226
2305
  verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
2227
2306
  getSuggestedMaxFee({ type, payload }: EstimateFeeAction, details: EstimateFeeDetails): Promise<string>;
2307
+ buildDeclarePayload({ classHash, contract }: DeclareContractPayload, { nonce, chainId, version, walletAddress, maxFee }: InvocationsSignerDetails): Promise<DeclareContractTransaction>;
2308
+ buildAccountDeployPayload({ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress, }: DeployAccountContractPayload, { nonce, chainId, version, maxFee }: InvocationsSignerDetails): Promise<DeployAccountContractTransaction>;
2309
+ buildUDCContractPayload(payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[]): Call[];
2228
2310
  }
2229
2311
 
2230
2312
  declare type CallOptions = {
@@ -2684,4 +2766,4 @@ declare function validateChecksumAddress(address: string): boolean;
2684
2766
  declare function isUrl(s?: string): boolean;
2685
2767
  declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
2686
2768
 
2687
- 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, EstimateFeeDetails, EstimateFeeResponse, Event, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, GetTransactionTraceResponse, HttpError, Invocation, 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, TransactionStatus, 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 };
2769
+ 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, 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 };
@@ -20754,6 +20754,9 @@ var starknet = (() => {
20754
20754
  block_id
20755
20755
  }).then(this.responseParser.parseFeeEstimateResponse);
20756
20756
  }
20757
+ async getEstimateFeeBulk(_invocations, _blockIdentifier = this.blockIdentifier) {
20758
+ throw new Error("RPC does not implement getInvokeEstimateFeeBulk function");
20759
+ }
20757
20760
  async declareContract({ contractDefinition, signature, senderAddress }, details) {
20758
20761
  return this.fetchEndpoint("starknet_addDeclareTransaction", {
20759
20762
  declare_transaction: {
@@ -20792,7 +20795,7 @@ var starknet = (() => {
20792
20795
  calldata: parseCalldata(functionInvocation.calldata),
20793
20796
  type: "INVOKE",
20794
20797
  max_fee: toHex(toBN(details.maxFee || 0)),
20795
- version: toHex(toBN(details.version || 0)),
20798
+ version: toHex(toBN(details.version || 1)),
20796
20799
  signature: bigNumberishArrayToHexadecimalStringArray(functionInvocation.signature || []),
20797
20800
  nonce: toHex(toBN(details.nonce))
20798
20801
  }
@@ -20935,6 +20938,27 @@ var starknet = (() => {
20935
20938
  overall_fee: toBN(res.amount)
20936
20939
  };
20937
20940
  }
20941
+ parseFeeEstimateBulkResponse(res) {
20942
+ return [].concat(res).map((item) => {
20943
+ if ("overall_fee" in item) {
20944
+ let gasInfo = {};
20945
+ try {
20946
+ gasInfo = {
20947
+ gas_consumed: toBN(item.gas_usage),
20948
+ gas_price: toBN(item.gas_price)
20949
+ };
20950
+ } catch {
20951
+ }
20952
+ return {
20953
+ overall_fee: toBN(item.overall_fee),
20954
+ ...gasInfo
20955
+ };
20956
+ }
20957
+ return {
20958
+ overall_fee: toBN(item.amount)
20959
+ };
20960
+ });
20961
+ }
20938
20962
  parseCallContractResponse(res) {
20939
20963
  return {
20940
20964
  result: res.result
@@ -21118,7 +21142,9 @@ var starknet = (() => {
21118
21142
  "add_transaction",
21119
21143
  "call_contract",
21120
21144
  "estimate_fee",
21121
- "estimate_message_fee"
21145
+ "estimate_message_fee",
21146
+ "estimate_fee_bulk",
21147
+ "simulate_transaction"
21122
21148
  ];
21123
21149
  return postMethodEndpoints.includes(endpoint) ? "POST" : "GET";
21124
21150
  }
@@ -21320,6 +21346,42 @@ var starknet = (() => {
21320
21346
  }
21321
21347
  ).then(this.responseParser.parseFeeEstimateResponse);
21322
21348
  }
21349
+ async getEstimateFeeBulk(invocations, blockIdentifier = this.blockIdentifier) {
21350
+ const params = invocations.map((invocation) => {
21351
+ let res;
21352
+ if (invocation.type === "INVOKE_FUNCTION") {
21353
+ res = {
21354
+ type: invocation.type,
21355
+ contract_address: invocation.contractAddress,
21356
+ calldata: invocation.calldata ?? []
21357
+ };
21358
+ } else if (invocation.type === "DECLARE") {
21359
+ res = {
21360
+ type: invocation.type,
21361
+ sender_address: invocation.senderAddress,
21362
+ contract_class: invocation.contractDefinition
21363
+ };
21364
+ } else {
21365
+ res = {
21366
+ type: invocation.type,
21367
+ class_hash: toHex(toBN(invocation.classHash)),
21368
+ constructor_calldata: bigNumberishArrayToDecimalStringArray(
21369
+ invocation.constructorCalldata || []
21370
+ ),
21371
+ contract_address_salt: toHex(toBN(invocation.addressSalt || 0))
21372
+ };
21373
+ }
21374
+ return {
21375
+ ...res,
21376
+ signature: bigNumberishArrayToDecimalStringArray(invocation.signature || []),
21377
+ version: toHex(toBN((invocation == null ? void 0 : invocation.version) || 1)),
21378
+ nonce: toHex(toBN(invocation.nonce))
21379
+ };
21380
+ });
21381
+ return this.fetchEndpoint("estimate_fee_bulk", { blockIdentifier }, params).then(
21382
+ this.responseParser.parseFeeEstimateBulkResponse
21383
+ );
21384
+ }
21323
21385
  async getCode(contractAddress, blockIdentifier = this.blockIdentifier) {
21324
21386
  return this.fetchEndpoint("get_code", { contractAddress, blockIdentifier });
21325
21387
  }
@@ -21363,6 +21425,20 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
21363
21425
  };
21364
21426
  return this.fetchEndpoint("estimate_message_fee", { blockIdentifier }, validCallL1Handler);
21365
21427
  }
21428
+ async simulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
21429
+ return this.fetchEndpoint(
21430
+ "simulate_transaction",
21431
+ { blockIdentifier },
21432
+ {
21433
+ type: "INVOKE_FUNCTION",
21434
+ contract_address: invocation.contractAddress,
21435
+ calldata: invocation.calldata ?? [],
21436
+ signature: bigNumberishArrayToDecimalStringArray(invocation.signature || []),
21437
+ version: toHex(toBN((invocationDetails == null ? void 0 : invocationDetails.version) || 1)),
21438
+ nonce: toHex(toBN(invocationDetails.nonce))
21439
+ }
21440
+ );
21441
+ }
21366
21442
  };
21367
21443
 
21368
21444
  // src/provider/default.ts
@@ -21408,6 +21484,9 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
21408
21484
  blockIdentifier
21409
21485
  );
21410
21486
  }
21487
+ async getEstimateFeeBulk(invocations, blockIdentifier) {
21488
+ return this.provider.getEstimateFeeBulk(invocations, blockIdentifier);
21489
+ }
21411
21490
  async getNonceForAddress(contractAddress, blockIdentifier) {
21412
21491
  return this.provider.getNonceForAddress(contractAddress, blockIdentifier);
21413
21492
  }
@@ -22462,10 +22541,9 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
22462
22541
  version: version3,
22463
22542
  chainId
22464
22543
  };
22465
- const signature = await this.signer.signTransaction(transactions, signerDetails);
22466
- const calldata = fromCallsToExecuteCalldata(transactions);
22544
+ const invocation = await this.buildInvocation(transactions, signerDetails);
22467
22545
  const response = await super.getInvokeEstimateFee(
22468
- { contractAddress: this.address, calldata, signature },
22546
+ { ...invocation },
22469
22547
  { version: version3, nonce },
22470
22548
  blockIdentifier
22471
22549
  );
@@ -22479,17 +22557,12 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
22479
22557
  const nonce = toBN(providedNonce ?? await this.getNonce());
22480
22558
  const version3 = toBN(feeTransactionVersion);
22481
22559
  const chainId = await this.getChainId();
22482
- const contractDefinition = parseContract(contract);
22483
- const signature = await this.signer.signDeclareTransaction({
22484
- classHash,
22485
- senderAddress: this.address,
22486
- chainId,
22487
- maxFee: ZERO,
22488
- version: version3,
22489
- nonce
22490
- });
22560
+ const payload = await this.buildDeclarePayload(
22561
+ { classHash, contract },
22562
+ { nonce, chainId, version: version3, walletAddress: this.address, maxFee: ZERO }
22563
+ );
22491
22564
  const response = await super.getDeclareEstimateFee(
22492
- { senderAddress: this.address, signature, contractDefinition },
22565
+ { ...payload },
22493
22566
  { version: version3, nonce },
22494
22567
  blockIdentifier
22495
22568
  );
@@ -22508,19 +22581,12 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
22508
22581
  const nonce = "0x0";
22509
22582
  const version3 = toBN(feeTransactionVersion);
22510
22583
  const chainId = await this.getChainId();
22511
- const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, constructorCalldata, 0);
22512
- const signature = await this.signer.signDeployAccountTransaction({
22513
- classHash,
22514
- contractAddress,
22515
- chainId,
22516
- maxFee: ZERO,
22517
- version: version3,
22518
- nonce,
22519
- addressSalt,
22520
- constructorCalldata
22521
- });
22584
+ const payload = await this.buildAccountDeployPayload(
22585
+ { classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress },
22586
+ { nonce, chainId, version: version3, walletAddress: this.address, maxFee: ZERO }
22587
+ );
22522
22588
  const response = await super.getDeployAccountEstimateFee(
22523
- { classHash, addressSalt, constructorCalldata, signature },
22589
+ { ...payload },
22524
22590
  { version: version3, nonce },
22525
22591
  blockIdentifier
22526
22592
  );
@@ -22531,27 +22597,85 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
22531
22597
  };
22532
22598
  }
22533
22599
  async estimateDeployFee(payload, transactionsDetail) {
22534
- const calls = [].concat(payload).map((it) => {
22535
- const {
22536
- classHash,
22537
- salt = "0",
22538
- unique = true,
22539
- constructorCalldata = []
22540
- } = it;
22541
- const compiledConstructorCallData = compileCalldata(constructorCalldata);
22600
+ const calls = this.buildUDCContractPayload(payload);
22601
+ return this.estimateInvokeFee(calls, transactionsDetail);
22602
+ }
22603
+ async estimateFeeBulk(transactions, { nonce: providedNonce, blockIdentifier } = {}) {
22604
+ const nonce = toBN(providedNonce ?? await this.getNonce());
22605
+ const version3 = toBN(feeTransactionVersion);
22606
+ const chainId = await this.getChainId();
22607
+ const params = await Promise.all(
22608
+ [].concat(transactions).map(async (transaction, index) => {
22609
+ const signerDetails = {
22610
+ walletAddress: this.address,
22611
+ nonce: toBN(Number(nonce) + index),
22612
+ maxFee: ZERO,
22613
+ version: version3,
22614
+ chainId
22615
+ };
22616
+ const txPayload = transaction.payload;
22617
+ let res;
22618
+ if (typeof transaction === "object" && transaction.type === "INVOKE_FUNCTION") {
22619
+ const invocation = await this.buildInvocation(
22620
+ Array.isArray(txPayload) ? txPayload : [txPayload],
22621
+ signerDetails
22622
+ );
22623
+ res = {
22624
+ type: "INVOKE_FUNCTION",
22625
+ ...invocation,
22626
+ version: version3,
22627
+ nonce: toBN(Number(nonce) + index),
22628
+ blockIdentifier
22629
+ };
22630
+ } else if (typeof transaction === "object" && transaction.type === "DECLARE") {
22631
+ const declareContractPayload = await this.buildDeclarePayload(txPayload, signerDetails);
22632
+ res = {
22633
+ type: "DECLARE",
22634
+ ...declareContractPayload,
22635
+ version: version3,
22636
+ nonce: toBN(Number(nonce) + index),
22637
+ blockIdentifier
22638
+ };
22639
+ } else if (typeof transaction === "object" && transaction.type === "DEPLOY_ACCOUNT") {
22640
+ const payload = await this.buildAccountDeployPayload(txPayload, signerDetails);
22641
+ res = {
22642
+ type: "DEPLOY_ACCOUNT",
22643
+ ...payload,
22644
+ version: version3,
22645
+ nonce,
22646
+ blockIdentifier
22647
+ };
22648
+ } else if (typeof transaction === "object" && transaction.type === "DEPLOY") {
22649
+ const calls = this.buildUDCContractPayload(txPayload);
22650
+ const invocation = await this.buildInvocation(calls, signerDetails);
22651
+ res = {
22652
+ type: "INVOKE_FUNCTION",
22653
+ ...invocation,
22654
+ version: version3,
22655
+ nonce: toBN(Number(nonce) + index),
22656
+ blockIdentifier
22657
+ };
22658
+ }
22659
+ return res;
22660
+ })
22661
+ );
22662
+ const response = await super.getEstimateFeeBulk(params, blockIdentifier);
22663
+ return [].concat(response).map((elem) => {
22664
+ const suggestedMaxFee = estimatedFeeToMaxFee(elem.overall_fee);
22542
22665
  return {
22543
- contractAddress: UDC.ADDRESS,
22544
- entrypoint: UDC.ENTRYPOINT,
22545
- calldata: [
22546
- classHash,
22547
- salt,
22548
- toCairoBool(unique),
22549
- compiledConstructorCallData.length,
22550
- ...compiledConstructorCallData
22551
- ]
22666
+ ...elem,
22667
+ suggestedMaxFee
22552
22668
  };
22553
22669
  });
22554
- return this.estimateInvokeFee(calls, transactionsDetail);
22670
+ }
22671
+ async buildInvocation(call, signerDetails) {
22672
+ const calldata = fromCallsToExecuteCalldata(call);
22673
+ const signature = await this.signer.signTransaction(call, signerDetails);
22674
+ return {
22675
+ contractAddress: this.address,
22676
+ calldata,
22677
+ signature
22678
+ };
22555
22679
  }
22556
22680
  async execute(calls, abis = void 0, transactionsDetail = {}) {
22557
22681
  const transactions = Array.isArray(calls) ? calls : [calls];
@@ -22740,6 +22864,69 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
22740
22864
  }
22741
22865
  return feeEstimate.suggestedMaxFee.toString();
22742
22866
  }
22867
+ async buildDeclarePayload({ classHash, contract }, { nonce, chainId, version: version3, walletAddress, maxFee }) {
22868
+ const contractDefinition = parseContract(contract);
22869
+ const signature = await this.signer.signDeclareTransaction({
22870
+ classHash,
22871
+ senderAddress: walletAddress,
22872
+ chainId,
22873
+ maxFee,
22874
+ version: version3,
22875
+ nonce
22876
+ });
22877
+ return {
22878
+ senderAddress: walletAddress,
22879
+ signature,
22880
+ contractDefinition
22881
+ };
22882
+ }
22883
+ async buildAccountDeployPayload({
22884
+ classHash,
22885
+ addressSalt = 0,
22886
+ constructorCalldata = [],
22887
+ contractAddress: providedContractAddress
22888
+ }, { nonce, chainId, version: version3, maxFee }) {
22889
+ const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, constructorCalldata, 0);
22890
+ const signature = await this.signer.signDeployAccountTransaction({
22891
+ classHash,
22892
+ contractAddress,
22893
+ chainId,
22894
+ maxFee,
22895
+ version: version3,
22896
+ nonce,
22897
+ addressSalt,
22898
+ constructorCalldata
22899
+ });
22900
+ return {
22901
+ classHash,
22902
+ addressSalt,
22903
+ constructorCalldata,
22904
+ signature
22905
+ };
22906
+ }
22907
+ buildUDCContractPayload(payload) {
22908
+ const calls = [].concat(payload).map((it) => {
22909
+ const {
22910
+ classHash,
22911
+ salt = "0",
22912
+ unique = true,
22913
+ constructorCalldata = []
22914
+ } = it;
22915
+ const compiledConstructorCallData = compileCalldata(constructorCalldata);
22916
+ return {
22917
+ contractAddress: UDC.ADDRESS,
22918
+ entrypoint: UDC.ENTRYPOINT,
22919
+ calldata: [
22920
+ classHash,
22921
+ salt,
22922
+ toCairoBool(unique),
22923
+ compiledConstructorCallData.length,
22924
+ ...compiledConstructorCallData
22925
+ ]
22926
+ };
22927
+ });
22928
+ return calls;
22929
+ }
22743
22930
  };
22744
22931
 
22745
22932
  // src/account/interface.ts