starknet 4.17.1 → 4.18.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 +12 -0
  2. package/README.md +2 -10
  3. package/dist/index.d.ts +18 -4
  4. package/dist/index.global.js +17 -2
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +17 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +17 -2
  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,15 @@
1
+ # [4.18.0](https://github.com/0xs34n/starknet.js/compare/v4.17.1...v4.18.0) (2022-12-23)
2
+
3
+ ### Bug Fixes
4
+
5
+ - merge develop into branch ([21efcb1](https://github.com/0xs34n/starknet.js/commit/21efcb1cefd6ea70a9d49e060ff620e88002e3b6))
6
+
7
+ ### Features
8
+
9
+ - simulate_transaction support on sequencer ([304c3cc](https://github.com/0xs34n/starknet.js/commit/304c3cc1af81bc8810581546f043caca01db173b))
10
+ - update simulate tx ([8f3ea55](https://github.com/0xs34n/starknet.js/commit/8f3ea55eb1e23cefc0419902a2ebbe10ee373ccb))
11
+ - update simulate tx in sequencer ([d79a9fa](https://github.com/0xs34n/starknet.js/commit/d79a9faa307936561504c120f67f3fb2f18423b6))
12
+
1
13
  ## [4.17.1](https://github.com/0xs34n/starknet.js/compare/v4.17.0...v4.17.1) (2022-12-14)
2
14
 
3
15
  ### 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
@@ -1114,7 +1114,7 @@ declare type ExecutionResources = {
1114
1114
  };
1115
1115
  n_memory_holes: number;
1116
1116
  };
1117
- declare type GetTransactionTraceResponse = {
1117
+ declare type TransactionTraceResponse = {
1118
1118
  validate_invocation?: FunctionInvocation;
1119
1119
  function_invocation?: FunctionInvocation;
1120
1120
  fee_transfer_invocation?: FunctionInvocation;
@@ -1256,10 +1256,16 @@ declare namespace Sequencer {
1256
1256
  type DeployAccountEstimateFee = Omit<DeployAccountTransaction, 'max_fee'>;
1257
1257
  type DeployEstimateFee = DeployTransaction;
1258
1258
  type EstimateFeeRequest = InvokeEstimateFee | DeclareEstimateFee | DeployEstimateFee | DeployAccountEstimateFee;
1259
+ type TransactionSimulationResponse = {
1260
+ trace: TransactionTraceResponse;
1261
+ fee_estimation: Sequencer.EstimateFeeResponse;
1262
+ };
1263
+ type SimulateTransaction = Omit<InvokeFunctionTransaction, 'max_fee' | 'entry_point_type'>;
1259
1264
  type EstimateFeeResponse = {
1260
1265
  overall_fee: number;
1261
1266
  gas_price: number;
1262
1267
  gas_usage: number;
1268
+ uint: string;
1263
1269
  } | {
1264
1270
  amount: BN__default;
1265
1271
  unit: string;
@@ -1294,7 +1300,7 @@ declare namespace Sequencer {
1294
1300
  transactionHash: string;
1295
1301
  };
1296
1302
  REQUEST: never;
1297
- RESPONSE: GetTransactionTraceResponse;
1303
+ RESPONSE: TransactionTraceResponse;
1298
1304
  };
1299
1305
  get_transaction_receipt: {
1300
1306
  QUERY: {
@@ -1384,6 +1390,13 @@ declare namespace Sequencer {
1384
1390
  REQUEST: any;
1385
1391
  RESPONSE: EstimateFeeResponse;
1386
1392
  };
1393
+ simulate_transaction: {
1394
+ QUERY: {
1395
+ blockIdentifier: BlockIdentifier;
1396
+ };
1397
+ REQUEST: SimulateTransaction;
1398
+ RESPONSE: TransactionSimulationResponse;
1399
+ };
1387
1400
  };
1388
1401
  }
1389
1402
 
@@ -1725,8 +1738,9 @@ declare class SequencerProvider implements ProviderInterface {
1725
1738
  * @param txHash
1726
1739
  * @returns the transaction trace
1727
1740
  */
1728
- getTransactionTrace(txHash: BigNumberish): Promise<GetTransactionTraceResponse>;
1741
+ getTransactionTrace(txHash: BigNumberish): Promise<TransactionTraceResponse>;
1729
1742
  estimateMessageFee({ from_address, to_address, entry_point_selector, payload }: CallL1Handler, blockIdentifier?: BlockIdentifier): Promise<Sequencer.EstimateFeeResponse>;
1743
+ simulateTransaction(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<Sequencer.TransactionSimulationResponse>;
1730
1744
  }
1731
1745
 
1732
1746
  interface ProviderOptions {
@@ -2684,4 +2698,4 @@ declare function validateChecksumAddress(address: string): boolean;
2684
2698
  declare function isUrl(s?: string): boolean;
2685
2699
  declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
2686
2700
 
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 };
2701
+ 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, 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, 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 };
@@ -20792,7 +20792,7 @@ var starknet = (() => {
20792
20792
  calldata: parseCalldata(functionInvocation.calldata),
20793
20793
  type: "INVOKE",
20794
20794
  max_fee: toHex(toBN(details.maxFee || 0)),
20795
- version: toHex(toBN(details.version || 0)),
20795
+ version: toHex(toBN(details.version || 1)),
20796
20796
  signature: bigNumberishArrayToHexadecimalStringArray(functionInvocation.signature || []),
20797
20797
  nonce: toHex(toBN(details.nonce))
20798
20798
  }
@@ -21118,7 +21118,8 @@ var starknet = (() => {
21118
21118
  "add_transaction",
21119
21119
  "call_contract",
21120
21120
  "estimate_fee",
21121
- "estimate_message_fee"
21121
+ "estimate_message_fee",
21122
+ "simulate_transaction"
21122
21123
  ];
21123
21124
  return postMethodEndpoints.includes(endpoint) ? "POST" : "GET";
21124
21125
  }
@@ -21363,6 +21364,20 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
21363
21364
  };
21364
21365
  return this.fetchEndpoint("estimate_message_fee", { blockIdentifier }, validCallL1Handler);
21365
21366
  }
21367
+ async simulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
21368
+ return this.fetchEndpoint(
21369
+ "simulate_transaction",
21370
+ { blockIdentifier },
21371
+ {
21372
+ type: "INVOKE_FUNCTION",
21373
+ contract_address: invocation.contractAddress,
21374
+ calldata: invocation.calldata ?? [],
21375
+ signature: bigNumberishArrayToDecimalStringArray(invocation.signature || []),
21376
+ version: toHex(toBN((invocationDetails == null ? void 0 : invocationDetails.version) || 1)),
21377
+ nonce: toHex(toBN(invocationDetails.nonce))
21378
+ }
21379
+ );
21380
+ }
21366
21381
  };
21367
21382
 
21368
21383
  // src/provider/default.ts