starknet 8.1.1 → 8.1.2

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
@@ -3444,7 +3444,7 @@ __export(stark_exports, {
3444
3444
  intDAM: () => intDAM,
3445
3445
  randomAddress: () => randomAddress,
3446
3446
  resourceBoundsToBigInt: () => resourceBoundsToBigInt,
3447
- resourceBoundsToEstimateFee: () => resourceBoundsToEstimateFee,
3447
+ resourceBoundsToEstimateFeeResponse: () => resourceBoundsToEstimateFeeResponse,
3448
3448
  resourceBoundsToHexString: () => resourceBoundsToHexString,
3449
3449
  signatureToDecimalArray: () => signatureToDecimalArray,
3450
3450
  signatureToHexArray: () => signatureToHexArray,
@@ -3452,7 +3452,8 @@ __export(stark_exports, {
3452
3452
  toOverheadOverallFee: () => toOverheadOverallFee,
3453
3453
  toOverheadResourceBounds: () => toOverheadResourceBounds,
3454
3454
  toTransactionVersion: () => toTransactionVersion,
3455
- v3Details: () => v3Details
3455
+ v3Details: () => v3Details,
3456
+ zeroResourceBounds: () => zeroResourceBounds
3456
3457
  });
3457
3458
  import { getPublicKey, getStarkKey, utils } from "@scure/starknet";
3458
3459
  import { gzip, ungzip } from "pako";
@@ -3488,26 +3489,44 @@ function signatureToDecimalArray(sig) {
3488
3489
  function signatureToHexArray(sig) {
3489
3490
  return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
3490
3491
  }
3492
+ function zeroResourceBounds() {
3493
+ return toOverheadResourceBounds(ZeroFeeEstimate(), false);
3494
+ }
3491
3495
  function toOverheadResourceBounds(estimate, overhead = config.get("resourceBoundsOverhead")) {
3492
3496
  return {
3493
3497
  l2_gas: {
3494
- max_amount: addPercent(estimate.l2_gas_consumed, overhead.l2_gas.max_amount),
3495
- max_price_per_unit: addPercent(estimate.l2_gas_price, overhead.l2_gas.max_price_per_unit)
3498
+ max_amount: addPercent(
3499
+ estimate.l2_gas_consumed,
3500
+ overhead !== false ? overhead.l2_gas.max_amount : 0
3501
+ ),
3502
+ max_price_per_unit: addPercent(
3503
+ estimate.l2_gas_price,
3504
+ overhead !== false ? overhead.l2_gas.max_price_per_unit : 0
3505
+ )
3496
3506
  },
3497
3507
  l1_gas: {
3498
- max_amount: addPercent(estimate.l1_gas_consumed, overhead.l1_gas.max_amount),
3499
- max_price_per_unit: addPercent(estimate.l1_gas_price, overhead.l1_gas.max_price_per_unit)
3508
+ max_amount: addPercent(
3509
+ estimate.l1_gas_consumed,
3510
+ overhead !== false ? overhead.l1_gas.max_amount : 0
3511
+ ),
3512
+ max_price_per_unit: addPercent(
3513
+ estimate.l1_gas_price,
3514
+ overhead !== false ? overhead.l1_gas.max_price_per_unit : 0
3515
+ )
3500
3516
  },
3501
3517
  l1_data_gas: {
3502
- max_amount: addPercent(estimate.l1_data_gas_consumed, overhead.l1_data_gas.max_amount),
3518
+ max_amount: addPercent(
3519
+ estimate.l1_data_gas_consumed,
3520
+ overhead !== false ? overhead.l1_data_gas.max_amount : 0
3521
+ ),
3503
3522
  max_price_per_unit: addPercent(
3504
3523
  estimate.l1_data_gas_price,
3505
- overhead.l1_data_gas.max_price_per_unit
3524
+ overhead !== false ? overhead.l1_data_gas.max_price_per_unit : 0
3506
3525
  )
3507
3526
  }
3508
3527
  };
3509
3528
  }
3510
- function resourceBoundsToEstimateFee(resourceBounds) {
3529
+ function resourceBoundsToEstimateFeeResponse(resourceBounds) {
3511
3530
  return {
3512
3531
  resourceBounds,
3513
3532
  /**
@@ -3518,7 +3537,16 @@ function resourceBoundsToEstimateFee(resourceBounds) {
3518
3537
  };
3519
3538
  }
3520
3539
  function toOverheadOverallFee(estimate, overhead = config.get("resourceBoundsOverhead")) {
3521
- return addPercent(estimate.l1_gas_consumed, overhead.l1_gas.max_amount) * addPercent(estimate.l1_gas_price, overhead.l1_gas.max_price_per_unit) + addPercent(estimate.l1_data_gas_consumed, overhead.l1_data_gas.max_amount) * addPercent(estimate.l1_data_gas_price, overhead.l1_data_gas.max_price_per_unit) + addPercent(estimate.l2_gas_consumed, overhead.l2_gas.max_amount) * addPercent(estimate.l2_gas_price, overhead.l2_gas.max_price_per_unit);
3540
+ return addPercent(estimate.l1_gas_consumed, overhead !== false ? overhead.l1_gas.max_amount : 0) * addPercent(
3541
+ estimate.l1_gas_price,
3542
+ overhead !== false ? overhead.l1_gas.max_price_per_unit : 0
3543
+ ) + addPercent(
3544
+ estimate.l1_data_gas_consumed,
3545
+ overhead !== false ? overhead.l1_data_gas.max_amount : 0
3546
+ ) * addPercent(
3547
+ estimate.l1_data_gas_price,
3548
+ overhead !== false ? overhead.l1_data_gas.max_price_per_unit : 0
3549
+ ) + addPercent(estimate.l2_gas_consumed, overhead !== false ? overhead.l2_gas.max_amount : 0) * addPercent(estimate.l2_gas_price, overhead !== false ? overhead.l2_gas.max_price_per_unit : 0);
3522
3550
  }
3523
3551
  function ZeroFeeEstimate() {
3524
3552
  return {
@@ -3563,7 +3591,7 @@ function v3Details(details) {
3563
3591
  accountDeploymentData: details.accountDeploymentData || [],
3564
3592
  nonceDataAvailabilityMode: details.nonceDataAvailabilityMode || EDataAvailabilityMode.L1,
3565
3593
  feeDataAvailabilityMode: details.feeDataAvailabilityMode || EDataAvailabilityMode.L1,
3566
- resourceBounds: details.resourceBounds ?? toOverheadResourceBounds(ZeroFeeEstimate(), void 0)
3594
+ resourceBounds: details.resourceBounds ?? zeroResourceBounds()
3567
3595
  };
3568
3596
  }
3569
3597
  function getFullPublicKey(privateKey) {
@@ -9034,7 +9062,8 @@ var Account = class extends RpcProvider2 {
9034
9062
  }
9035
9063
  async estimateFeeBulk(invocations, details = {}) {
9036
9064
  if (!invocations.length) throw TypeError("Invocations should be non-empty array");
9037
- if (details.resourceBounds) return [resourceBoundsToEstimateFee(details.resourceBounds)];
9065
+ if (details.resourceBounds)
9066
+ return [resourceBoundsToEstimateFeeResponse(details.resourceBounds)];
9038
9067
  const { nonce, blockIdentifier, version, skipValidate } = details;
9039
9068
  const detailsWithTip = await this.resolveDetailsWithTip(details);
9040
9069
  const accountInvocations = await this.accountInvocationsFactory(invocations, {