starknet 8.8.0 → 8.9.1

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/dist/index.js CHANGED
@@ -225,6 +225,7 @@ __export(constants_exports, {
225
225
  RPC_DEFAULT_NODES: () => RPC_DEFAULT_NODES,
226
226
  SNIP9_V1_INTERFACE_ID: () => SNIP9_V1_INTERFACE_ID,
227
227
  SNIP9_V2_INTERFACE_ID: () => SNIP9_V2_INTERFACE_ID,
228
+ SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS: () => SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS,
228
229
  SYSTEM_MESSAGES: () => SYSTEM_MESSAGES,
229
230
  StarknetChainId: () => _StarknetChainId,
230
231
  SupportedRpcVersion: () => _SupportedRpcVersion,
@@ -494,7 +495,7 @@ var DEFAULT_GLOBAL_CONFIG = {
494
495
  blake: void 0
495
496
  };
496
497
  var RPC_DEFAULT_NODES = {
497
- SN_MAIN: [`https://starknet-mainnet.g.alchemy.com/starknet/version/rpc`],
498
+ SN_MAIN: [`https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/`],
498
499
  SN_SEPOLIA: [`https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/`]
499
500
  };
500
501
  var PAYMASTER_RPC_NODES = {
@@ -514,6 +515,7 @@ var SYSTEM_MESSAGES = {
514
515
  consensusFailed: "Consensus failed to finalize the block proposal",
515
516
  txFailsBlockBuildingValidation: "Transaction fails block building validation"
516
517
  };
518
+ var SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS = "0.14.1";
517
519
 
518
520
  // src/global/config.ts
519
521
  var Configuration = class _Configuration {
@@ -5408,8 +5410,8 @@ function computeContractClassHash(contract) {
5408
5410
  }
5409
5411
  return computeLegacyContractClassHash(compiledContract);
5410
5412
  }
5411
- function computeCompiledClassHash(casm, starknetVersion) {
5412
- if (starknetVersion && compareVersions(starknetVersion, "0.14.1") >= 0) {
5413
+ function computeCompiledClassHash(casm, starknetVersion = SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS) {
5414
+ if (compareVersions(starknetVersion, SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS) >= 0) {
5413
5415
  return computeCompiledClassHashBlake(casm);
5414
5416
  }
5415
5417
  return computeCompiledClassHashPoseidon(casm);
@@ -12439,7 +12441,7 @@ var Contract = class _Contract {
12439
12441
  });
12440
12442
  }
12441
12443
  async invoke(method, args = [], options = {}) {
12442
- const { parseRequest = true, signature, waitForTransaction, ...RestInvokeOptions } = options;
12444
+ const { parseRequest = true, signature, waitForTransaction, ...restInvokeOptions } = options;
12443
12445
  assert(this.address !== null, "contract is not connected to an address");
12444
12446
  const calldata = getCompiledCalldata(args, () => {
12445
12447
  if (parseRequest) {
@@ -12455,8 +12457,20 @@ var Contract = class _Contract {
12455
12457
  entrypoint: method
12456
12458
  };
12457
12459
  if (isAccount(this.providerOrAccount)) {
12460
+ if (restInvokeOptions.paymasterDetails) {
12461
+ const myCall = {
12462
+ contractAddress: this.address,
12463
+ entrypoint: method,
12464
+ calldata: args
12465
+ };
12466
+ return this.providerOrAccount.executePaymasterTransaction(
12467
+ [myCall],
12468
+ restInvokeOptions.paymasterDetails,
12469
+ restInvokeOptions.maxFeeInGasToken
12470
+ );
12471
+ }
12458
12472
  const result = await this.providerOrAccount.execute(invocation, {
12459
- ...RestInvokeOptions
12473
+ ...restInvokeOptions
12460
12474
  });
12461
12475
  if (waitForTransaction) {
12462
12476
  const result2 = await this.providerOrAccount.waitForTransaction(result.transaction_hash);
@@ -12467,7 +12481,7 @@ var Contract = class _Contract {
12467
12481
  }
12468
12482
  return result;
12469
12483
  }
12470
- if (!RestInvokeOptions.nonce)
12484
+ if (!restInvokeOptions.nonce)
12471
12485
  throw new Error(`Manual nonce is required when invoking a function without an account`);
12472
12486
  logger.warn(`Invoking ${method} without an account.`);
12473
12487
  return this.providerOrAccount.invokeFunction(
@@ -12476,8 +12490,8 @@ var Contract = class _Contract {
12476
12490
  signature
12477
12491
  },
12478
12492
  {
12479
- ...RestInvokeOptions,
12480
- nonce: RestInvokeOptions.nonce
12493
+ ...restInvokeOptions,
12494
+ nonce: restInvokeOptions.nonce
12481
12495
  }
12482
12496
  );
12483
12497
  }
@@ -12488,6 +12502,17 @@ var Contract = class _Contract {
12488
12502
  }
12489
12503
  const invocation = this.populate(method, args);
12490
12504
  if (isAccount(this.providerOrAccount)) {
12505
+ if (estimateDetails.paymasterDetails) {
12506
+ const myCall = {
12507
+ contractAddress: this.address,
12508
+ entrypoint: method,
12509
+ calldata: args
12510
+ };
12511
+ return this.providerOrAccount.estimatePaymasterTransactionFee(
12512
+ [myCall],
12513
+ estimateDetails.paymasterDetails
12514
+ );
12515
+ }
12491
12516
  return this.providerOrAccount.estimateInvokeFee(invocation, estimateDetails);
12492
12517
  }
12493
12518
  throw Error("Contract must be connected to the account contract to estimate");