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.mjs CHANGED
@@ -49,6 +49,7 @@ __export(constants_exports, {
49
49
  RPC_DEFAULT_NODES: () => RPC_DEFAULT_NODES,
50
50
  SNIP9_V1_INTERFACE_ID: () => SNIP9_V1_INTERFACE_ID,
51
51
  SNIP9_V2_INTERFACE_ID: () => SNIP9_V2_INTERFACE_ID,
52
+ SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS: () => SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS,
52
53
  SYSTEM_MESSAGES: () => SYSTEM_MESSAGES,
53
54
  StarknetChainId: () => _StarknetChainId,
54
55
  SupportedRpcVersion: () => _SupportedRpcVersion,
@@ -319,7 +320,7 @@ var DEFAULT_GLOBAL_CONFIG = {
319
320
  blake: void 0
320
321
  };
321
322
  var RPC_DEFAULT_NODES = {
322
- SN_MAIN: [`https://starknet-mainnet.g.alchemy.com/starknet/version/rpc`],
323
+ SN_MAIN: [`https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/`],
323
324
  SN_SEPOLIA: [`https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/`]
324
325
  };
325
326
  var PAYMASTER_RPC_NODES = {
@@ -339,6 +340,7 @@ var SYSTEM_MESSAGES = {
339
340
  consensusFailed: "Consensus failed to finalize the block proposal",
340
341
  txFailsBlockBuildingValidation: "Transaction fails block building validation"
341
342
  };
343
+ var SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS = "0.14.1";
342
344
 
343
345
  // src/global/config.ts
344
346
  var Configuration = class _Configuration {
@@ -5233,8 +5235,8 @@ function computeContractClassHash(contract) {
5233
5235
  }
5234
5236
  return computeLegacyContractClassHash(compiledContract);
5235
5237
  }
5236
- function computeCompiledClassHash(casm, starknetVersion) {
5237
- if (starknetVersion && compareVersions(starknetVersion, "0.14.1") >= 0) {
5238
+ function computeCompiledClassHash(casm, starknetVersion = SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS) {
5239
+ if (compareVersions(starknetVersion, SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS) >= 0) {
5238
5240
  return computeCompiledClassHashBlake(casm);
5239
5241
  }
5240
5242
  return computeCompiledClassHashPoseidon(casm);
@@ -12264,7 +12266,7 @@ var Contract = class _Contract {
12264
12266
  });
12265
12267
  }
12266
12268
  async invoke(method, args = [], options = {}) {
12267
- const { parseRequest = true, signature, waitForTransaction, ...RestInvokeOptions } = options;
12269
+ const { parseRequest = true, signature, waitForTransaction, ...restInvokeOptions } = options;
12268
12270
  assert(this.address !== null, "contract is not connected to an address");
12269
12271
  const calldata = getCompiledCalldata(args, () => {
12270
12272
  if (parseRequest) {
@@ -12280,8 +12282,20 @@ var Contract = class _Contract {
12280
12282
  entrypoint: method
12281
12283
  };
12282
12284
  if (isAccount(this.providerOrAccount)) {
12285
+ if (restInvokeOptions.paymasterDetails) {
12286
+ const myCall = {
12287
+ contractAddress: this.address,
12288
+ entrypoint: method,
12289
+ calldata: args
12290
+ };
12291
+ return this.providerOrAccount.executePaymasterTransaction(
12292
+ [myCall],
12293
+ restInvokeOptions.paymasterDetails,
12294
+ restInvokeOptions.maxFeeInGasToken
12295
+ );
12296
+ }
12283
12297
  const result = await this.providerOrAccount.execute(invocation, {
12284
- ...RestInvokeOptions
12298
+ ...restInvokeOptions
12285
12299
  });
12286
12300
  if (waitForTransaction) {
12287
12301
  const result2 = await this.providerOrAccount.waitForTransaction(result.transaction_hash);
@@ -12292,7 +12306,7 @@ var Contract = class _Contract {
12292
12306
  }
12293
12307
  return result;
12294
12308
  }
12295
- if (!RestInvokeOptions.nonce)
12309
+ if (!restInvokeOptions.nonce)
12296
12310
  throw new Error(`Manual nonce is required when invoking a function without an account`);
12297
12311
  logger.warn(`Invoking ${method} without an account.`);
12298
12312
  return this.providerOrAccount.invokeFunction(
@@ -12301,8 +12315,8 @@ var Contract = class _Contract {
12301
12315
  signature
12302
12316
  },
12303
12317
  {
12304
- ...RestInvokeOptions,
12305
- nonce: RestInvokeOptions.nonce
12318
+ ...restInvokeOptions,
12319
+ nonce: restInvokeOptions.nonce
12306
12320
  }
12307
12321
  );
12308
12322
  }
@@ -12313,6 +12327,17 @@ var Contract = class _Contract {
12313
12327
  }
12314
12328
  const invocation = this.populate(method, args);
12315
12329
  if (isAccount(this.providerOrAccount)) {
12330
+ if (estimateDetails.paymasterDetails) {
12331
+ const myCall = {
12332
+ contractAddress: this.address,
12333
+ entrypoint: method,
12334
+ calldata: args
12335
+ };
12336
+ return this.providerOrAccount.estimatePaymasterTransactionFee(
12337
+ [myCall],
12338
+ estimateDetails.paymasterDetails
12339
+ );
12340
+ }
12316
12341
  return this.providerOrAccount.estimateInvokeFee(invocation, estimateDetails);
12317
12342
  }
12318
12343
  throw Error("Contract must be connected to the account contract to estimate");