starknet 4.17.0 → 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 +20 -0
  2. package/README.md +2 -10
  3. package/dist/index.d.ts +27 -9
  4. package/dist/index.global.js +30 -13
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +30 -13
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +30 -13
  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 -2683
  52. package/index.global.js +0 -23192
  53. package/index.global.js.map +0 -1
  54. package/index.js +0 -4910
  55. package/index.js.map +0 -1
  56. package/index.mjs +0 -4852
  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 -309
  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 -482
  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 -607
  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/dist/index.js CHANGED
@@ -2897,14 +2897,16 @@ var RpcProvider = class {
2897
2897
  }
2898
2898
  async deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }, details) {
2899
2899
  return this.fetchEndpoint("starknet_addDeployAccountTransaction", {
2900
- constructor_calldata: bigNumberishArrayToHexadecimalStringArray(constructorCalldata || []),
2901
- class_hash: toHex(toBN(classHash)),
2902
- contract_address_salt: toHex(toBN(addressSalt || 0)),
2903
- type: "DEPLOY",
2904
- max_fee: toHex(toBN(details.maxFee || 0)),
2905
- version: toHex(toBN(details.version || 0)),
2906
- signature: bigNumberishArrayToHexadecimalStringArray(signature || []),
2907
- nonce: toHex(toBN(details.nonce))
2900
+ deploy_account_transaction: {
2901
+ constructor_calldata: bigNumberishArrayToHexadecimalStringArray(constructorCalldata || []),
2902
+ class_hash: toHex(toBN(classHash)),
2903
+ contract_address_salt: toHex(toBN(addressSalt || 0)),
2904
+ type: "DEPLOY_ACCOUNT",
2905
+ max_fee: toHex(toBN(details.maxFee || 0)),
2906
+ version: toHex(toBN(details.version || 0)),
2907
+ signature: bigNumberishArrayToHexadecimalStringArray(signature || []),
2908
+ nonce: toHex(toBN(details.nonce))
2909
+ }
2908
2910
  });
2909
2911
  }
2910
2912
  async invokeFunction(functionInvocation, details) {
@@ -2914,7 +2916,7 @@ var RpcProvider = class {
2914
2916
  calldata: parseCalldata(functionInvocation.calldata),
2915
2917
  type: "INVOKE",
2916
2918
  max_fee: toHex(toBN(details.maxFee || 0)),
2917
- version: toHex(toBN(details.version || 0)),
2919
+ version: toHex(toBN(details.version || 1)),
2918
2920
  signature: bigNumberishArrayToHexadecimalStringArray(functionInvocation.signature || []),
2919
2921
  nonce: toHex(toBN(details.nonce))
2920
2922
  }
@@ -3188,7 +3190,8 @@ var SequencerProvider = class {
3188
3190
  "add_transaction",
3189
3191
  "call_contract",
3190
3192
  "estimate_fee",
3191
- "estimate_message_fee"
3193
+ "estimate_message_fee",
3194
+ "simulate_transaction"
3192
3195
  ];
3193
3196
  return postMethodEndpoints.includes(endpoint) ? "POST" : "GET";
3194
3197
  }
@@ -3433,6 +3436,20 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
3433
3436
  };
3434
3437
  return this.fetchEndpoint("estimate_message_fee", { blockIdentifier }, validCallL1Handler);
3435
3438
  }
3439
+ async simulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
3440
+ return this.fetchEndpoint(
3441
+ "simulate_transaction",
3442
+ { blockIdentifier },
3443
+ {
3444
+ type: "INVOKE_FUNCTION",
3445
+ contract_address: invocation.contractAddress,
3446
+ calldata: invocation.calldata ?? [],
3447
+ signature: bigNumberishArrayToDecimalStringArray(invocation.signature || []),
3448
+ version: toHex(toBN((invocationDetails == null ? void 0 : invocationDetails.version) || 1)),
3449
+ nonce: toHex(toBN(invocationDetails.nonce))
3450
+ }
3451
+ );
3452
+ }
3436
3453
  };
3437
3454
 
3438
3455
  // src/provider/default.ts
@@ -4574,8 +4591,8 @@ var Account = class extends Provider {
4574
4591
  addressSalt = 0,
4575
4592
  constructorCalldata = [],
4576
4593
  contractAddress: providedContractAddress
4577
- }, { blockIdentifier, nonce: providedNonce } = {}) {
4578
- const nonce = toBN(providedNonce ?? await this.getNonce());
4594
+ }, { blockIdentifier } = {}) {
4595
+ const nonce = "0x0";
4579
4596
  const version = toBN(feeTransactionVersion);
4580
4597
  const chainId = await this.getChainId();
4581
4598
  const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, constructorCalldata, 0);
@@ -4734,7 +4751,7 @@ var Account = class extends Provider {
4734
4751
  addressSalt = 0,
4735
4752
  contractAddress: providedContractAddress
4736
4753
  }, transactionsDetail = {}) {
4737
- const nonce = toBN(transactionsDetail.nonce ?? await this.getNonce());
4754
+ const nonce = "0x0";
4738
4755
  const version = toBN(transactionVersion);
4739
4756
  const chainId = await this.getChainId();
4740
4757
  const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, constructorCalldata, 0);