@fuel-ts/account 0.0.0-rc-2037-20240501105750 → 0.0.0-rc-2037-20240501152515

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.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

@@ -27,7 +27,7 @@ import { Address as Address3 } from "@fuel-ts/address";
27
27
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
28
28
  import { AbstractAccount } from "@fuel-ts/interfaces";
29
29
  import { bn as bn19 } from "@fuel-ts/math";
30
- import { arrayify as arrayify14, isDefined } from "@fuel-ts/utils";
30
+ import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
31
31
  import { clone as clone4 } from "ramda";
32
32
 
33
33
  // src/providers/coin-quantity.ts
@@ -1248,7 +1248,7 @@ import {
1248
1248
  OutputType as OutputType2,
1249
1249
  TransactionType
1250
1250
  } from "@fuel-ts/transactions";
1251
- import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1251
+ import { concat, hexlify as hexlify7, isDefined } from "@fuel-ts/utils";
1252
1252
 
1253
1253
  // src/providers/resource.ts
1254
1254
  var isCoin = (resource) => "id" in resource;
@@ -1561,7 +1561,7 @@ function calculateMetadataGasForTxScript({
1561
1561
  }
1562
1562
  var calculateGasFee = (params) => {
1563
1563
  const { gas, gasPrice, priceFactor, tip } = params;
1564
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1564
+ return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
1565
1565
  };
1566
1566
 
1567
1567
  // src/providers/utils/json.ts
@@ -1764,10 +1764,10 @@ var BaseTransactionRequest = class {
1764
1764
  outputs,
1765
1765
  witnesses
1766
1766
  } = {}) {
1767
- this.tip = bn8(tip);
1768
- this.maturity = maturity ?? 0;
1769
- this.witnessLimit = witnessLimit ? bn8(witnessLimit) : void 0;
1770
- this.maxFee = maxFee ? bn8(maxFee) : void 0;
1767
+ this.tip = tip ? bn8(tip) : void 0;
1768
+ this.maturity = maturity && maturity > 0 ? maturity : void 0;
1769
+ this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
1770
+ this.maxFee = bn8(maxFee);
1771
1771
  this.inputs = inputs ?? [];
1772
1772
  this.outputs = outputs ?? [];
1773
1773
  this.witnesses = witnesses ?? [];
@@ -1775,22 +1775,21 @@ var BaseTransactionRequest = class {
1775
1775
  static getPolicyMeta(req) {
1776
1776
  let policyTypes = 0;
1777
1777
  const policies = [];
1778
- if (req.tip) {
1778
+ const { tip, witnessLimit, maturity } = req;
1779
+ if (bn8(tip).gt(0)) {
1779
1780
  policyTypes += PolicyType.Tip;
1780
- policies.push({ data: req.tip, type: PolicyType.Tip });
1781
+ policies.push({ data: bn8(tip), type: PolicyType.Tip });
1781
1782
  }
1782
- if (req.witnessLimit) {
1783
+ if (isDefined(witnessLimit) && bn8(witnessLimit).gte(0)) {
1783
1784
  policyTypes += PolicyType.WitnessLimit;
1784
- policies.push({ data: req.witnessLimit, type: PolicyType.WitnessLimit });
1785
+ policies.push({ data: bn8(witnessLimit), type: PolicyType.WitnessLimit });
1785
1786
  }
1786
- if (req.maturity > 0) {
1787
+ if (maturity && maturity > 0) {
1787
1788
  policyTypes += PolicyType.Maturity;
1788
- policies.push({ data: req.maturity, type: PolicyType.Maturity });
1789
- }
1790
- if (req.maxFee) {
1791
- policyTypes += PolicyType.MaxFee;
1792
- policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
1789
+ policies.push({ data: maturity, type: PolicyType.Maturity });
1793
1790
  }
1791
+ policyTypes += PolicyType.MaxFee;
1792
+ policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
1794
1793
  return {
1795
1794
  policyTypes,
1796
1795
  policies
@@ -5216,13 +5215,13 @@ var Account = class extends AbstractAccount {
5216
5215
  gasUsed,
5217
5216
  maxFee
5218
5217
  }) {
5219
- if (isDefined(setGasLimit) && gasUsed.gt(setGasLimit)) {
5218
+ if (isDefined2(setGasLimit) && gasUsed.gt(setGasLimit)) {
5220
5219
  throw new FuelError15(
5221
5220
  ErrorCode15.GAS_LIMIT_TOO_LOW,
5222
5221
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5223
5222
  );
5224
5223
  }
5225
- if (isDefined(setMaxFee) && maxFee.gt(setMaxFee)) {
5224
+ if (isDefined2(setMaxFee) && maxFee.gt(setMaxFee)) {
5226
5225
  throw new FuelError15(
5227
5226
  ErrorCode15.MAX_FEE_TOO_LOW,
5228
5227
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`