@fuel-ts/account 0.0.0-rc-1832-20240415161726 → 0.0.0-rc-2034-20240415163000

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.

@@ -29015,6 +29015,7 @@ This unreleased fuel-core build may include features and updates not yet support
29015
29015
  ErrorCode2["INVALID_COMPONENT"] = "invalid-component";
29016
29016
  ErrorCode2["CONFIGURABLE_NOT_FOUND"] = "configurable-not-found";
29017
29017
  ErrorCode2["TYPE_NOT_FOUND"] = "type-not-found";
29018
+ ErrorCode2["LOG_TYPE_NOT_FOUND"] = "log-type-not-found";
29018
29019
  ErrorCode2["TYPE_NOT_SUPPORTED"] = "type-not-supported";
29019
29020
  ErrorCode2["INVALID_DECODE_VALUE"] = "invalid-decode-value";
29020
29021
  ErrorCode2["JSON_ABI_ERROR"] = "json-abi-error";
@@ -31279,7 +31280,7 @@ This unreleased fuel-core build may include features and updates not yet support
31279
31280
  var import_bn = __toESM(require_bn(), 1);
31280
31281
  var DEFAULT_PRECISION = 9;
31281
31282
  var DEFAULT_MIN_PRECISION = 3;
31282
- var DECIMAL_UNITS = 9;
31283
+ var DEFAULT_DECIMAL_UNITS = 9;
31283
31284
  function toFixed(value, options) {
31284
31285
  const { precision = DEFAULT_PRECISION, minPrecision = DEFAULT_MIN_PRECISION } = options || {};
31285
31286
  const [valueUnits = "0", valueDecimals = "0"] = String(value || "0.0").split(".");
@@ -31345,7 +31346,7 @@ This unreleased fuel-core build may include features and updates not yet support
31345
31346
  }
31346
31347
  format(options) {
31347
31348
  const {
31348
- units = DECIMAL_UNITS,
31349
+ units = DEFAULT_DECIMAL_UNITS,
31349
31350
  precision = DEFAULT_PRECISION,
31350
31351
  minPrecision = DEFAULT_MIN_PRECISION
31351
31352
  } = options || {};
@@ -31361,7 +31362,7 @@ This unreleased fuel-core build may include features and updates not yet support
31361
31362
  }
31362
31363
  return formattedFixed;
31363
31364
  }
31364
- formatUnits(units = DECIMAL_UNITS) {
31365
+ formatUnits(units = DEFAULT_DECIMAL_UNITS) {
31365
31366
  const valueUnits = this.toString().slice(0, units * -1);
31366
31367
  const valueDecimals = this.toString().slice(units * -1);
31367
31368
  const length = valueDecimals.length;
@@ -31470,7 +31471,7 @@ This unreleased fuel-core build may include features and updates not yet support
31470
31471
  // END ANCHOR: OVERRIDES to avoid losing references
31471
31472
  };
31472
31473
  var bn = (value, base, endian) => new BN(value, base, endian);
31473
- bn.parseUnits = (value, units = DECIMAL_UNITS) => {
31474
+ bn.parseUnits = (value, units = DEFAULT_DECIMAL_UNITS) => {
31474
31475
  const valueToParse = value === "." ? "0." : value;
31475
31476
  const [valueUnits = "0", valueDecimals = "0"] = valueToParse.split(".");
31476
31477
  const length = valueDecimals.length;
@@ -31604,6 +31605,7 @@ This unreleased fuel-core build may include features and updates not yet support
31604
31605
  var ENCODING_V1 = "1";
31605
31606
  var WORD_SIZE = 8;
31606
31607
  var BYTES_32 = 32;
31608
+ var UTXO_ID_LEN = BYTES_32 + 1;
31607
31609
  var ASSET_ID_LEN = BYTES_32;
31608
31610
  var ADDRESS_LEN = BYTES_32;
31609
31611
  var NONCE_LEN = BYTES_32;
@@ -31754,15 +31756,6 @@ This unreleased fuel-core build may include features and updates not yet support
31754
31756
  }
31755
31757
  };
31756
31758
  var isHeapType = (type3) => type3 === VEC_CODER_TYPE || type3 === BYTES_CODER_TYPE || type3 === STD_STRING_CODER_TYPE;
31757
- function findOrThrow(arr, predicate, throwFn = () => {
31758
- throw new FuelError(ErrorCode.ELEMENT_NOT_FOUND, "Element not found in the array.");
31759
- }) {
31760
- const found = arr.find(predicate);
31761
- if (found === void 0) {
31762
- throwFn();
31763
- }
31764
- return found;
31765
- }
31766
31759
  var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
31767
31760
  var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
31768
31761
  var rightPadToWordSize = (encoded) => {
@@ -31772,6 +31765,7 @@ This unreleased fuel-core build may include features and updates not yet support
31772
31765
  const padding = new Uint8Array(WORD_SIZE - encoded.length % WORD_SIZE);
31773
31766
  return concatBytes2([encoded, padding]);
31774
31767
  };
31768
+ var isUint8Array = (value) => value instanceof Uint8Array;
31775
31769
  var ArrayCoder = class extends Coder {
31776
31770
  coder;
31777
31771
  length;
@@ -32313,8 +32307,11 @@ This unreleased fuel-core build may include features and updates not yet support
32313
32307
  this.coder = coder;
32314
32308
  }
32315
32309
  encode(value) {
32316
- if (!Array.isArray(value)) {
32317
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
32310
+ if (!Array.isArray(value) && !isUint8Array(value)) {
32311
+ throw new FuelError(
32312
+ ErrorCode.ENCODE_ERROR,
32313
+ `Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.`
32314
+ );
32318
32315
  }
32319
32316
  const parts = [];
32320
32317
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
@@ -32345,6 +32342,38 @@ This unreleased fuel-core build may include features and updates not yet support
32345
32342
  ];
32346
32343
  }
32347
32344
  };
32345
+ var findFunctionByName = (abi, name) => {
32346
+ const fn = abi.functions.find((f2) => f2.name === name);
32347
+ if (!fn) {
32348
+ throw new FuelError(
32349
+ ErrorCode.FUNCTION_NOT_FOUND,
32350
+ `Function with name '${name}' doesn't exist in the ABI`
32351
+ );
32352
+ }
32353
+ return fn;
32354
+ };
32355
+ var findTypeById = (abi, typeId) => {
32356
+ const type3 = abi.types.find((t) => t.typeId === typeId);
32357
+ if (!type3) {
32358
+ throw new FuelError(
32359
+ ErrorCode.TYPE_NOT_FOUND,
32360
+ `Type with typeId '${typeId}' doesn't exist in the ABI.`
32361
+ );
32362
+ }
32363
+ return type3;
32364
+ };
32365
+ var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
32366
+ var findVectorBufferArgument = (components) => {
32367
+ const bufferComponent = components.find((c) => c.name === "buf");
32368
+ const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
32369
+ if (!bufferComponent || !bufferTypeArgument) {
32370
+ throw new FuelError(
32371
+ ErrorCode.INVALID_COMPONENT,
32372
+ `The Vec type provided is missing or has a malformed 'buf' component.`
32373
+ );
32374
+ }
32375
+ return bufferTypeArgument;
32376
+ };
32348
32377
  var ResolvedAbiType = class {
32349
32378
  abi;
32350
32379
  name;
@@ -32353,20 +32382,8 @@ This unreleased fuel-core build may include features and updates not yet support
32353
32382
  components;
32354
32383
  constructor(abi, argument) {
32355
32384
  this.abi = abi;
32356
- const type3 = findOrThrow(
32357
- abi.types,
32358
- (t) => t.typeId === argument.type,
32359
- () => {
32360
- throw new FuelError(
32361
- ErrorCode.TYPE_NOT_FOUND,
32362
- `Type does not exist in the provided abi: ${JSON.stringify({
32363
- argument,
32364
- abi: this.abi
32365
- })}`
32366
- );
32367
- }
32368
- );
32369
32385
  this.name = argument.name;
32386
+ const type3 = findTypeById(abi, argument.type);
32370
32387
  this.type = type3.type;
32371
32388
  this.originalTypeArguments = argument.typeArguments;
32372
32389
  this.components = ResolvedAbiType.getResolvedGenericComponents(
@@ -32418,7 +32435,7 @@ This unreleased fuel-core build may include features and updates not yet support
32418
32435
  )
32419
32436
  };
32420
32437
  }
32421
- const argType = findOrThrow(abi.types, (t) => t.typeId === arg.type);
32438
+ const argType = findTypeById(abi, arg.type);
32422
32439
  const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
32423
32440
  if (implicitTypeParameters && implicitTypeParameters.length > 0) {
32424
32441
  return {
@@ -32435,7 +32452,7 @@ This unreleased fuel-core build may include features and updates not yet support
32435
32452
  }
32436
32453
  const implicitGenericParameters = implicitGenericParametersParam ?? [];
32437
32454
  args.forEach((a) => {
32438
- const argType = findOrThrow(abi.types, (t) => t.typeId === a.type);
32455
+ const argType = findTypeById(abi, a.type);
32439
32456
  if (genericRegEx.test(argType.type)) {
32440
32457
  implicitGenericParameters.push(argType.typeId);
32441
32458
  return;
@@ -32544,13 +32561,7 @@ This unreleased fuel-core build may include features and updates not yet support
32544
32561
  return new ArrayCoder(arrayElementCoder, length);
32545
32562
  }
32546
32563
  if (resolvedAbiType.type === VEC_CODER_TYPE) {
32547
- const arg = findOrThrow(components, (c) => c.name === "buf").originalTypeArguments?.[0];
32548
- if (!arg) {
32549
- throw new FuelError(
32550
- ErrorCode.INVALID_COMPONENT,
32551
- `The provided Vec type is missing the 'type argument'.`
32552
- );
32553
- }
32564
+ const arg = findVectorBufferArgument(components);
32554
32565
  const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
32555
32566
  const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
32556
32567
  return new VecCoder(itemCoder);
@@ -33019,13 +33030,7 @@ This unreleased fuel-core build may include features and updates not yet support
33019
33030
  return new ArrayCoder(arrayElementCoder, length);
33020
33031
  }
33021
33032
  if (resolvedAbiType.type === VEC_CODER_TYPE) {
33022
- const arg = findOrThrow(components, (c) => c.name === "buf").originalTypeArguments?.[0];
33023
- if (!arg) {
33024
- throw new FuelError(
33025
- ErrorCode.INVALID_COMPONENT,
33026
- `The provided Vec type is missing the 'type argument'.`
33027
- );
33028
- }
33033
+ const arg = findVectorBufferArgument(components);
33029
33034
  const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
33030
33035
  const itemCoder = getCoder2(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
33031
33036
  return new VecCoder2(itemCoder);
@@ -33096,7 +33101,7 @@ This unreleased fuel-core build may include features and updates not yet support
33096
33101
  jsonAbi;
33097
33102
  constructor(jsonAbi, name) {
33098
33103
  this.jsonAbi = jsonAbi;
33099
- this.jsonFn = findOrThrow(this.jsonAbi.functions, (f2) => f2.name === name);
33104
+ this.jsonFn = findFunctionByName(this.jsonAbi, name);
33100
33105
  this.name = name;
33101
33106
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
33102
33107
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
@@ -33120,13 +33125,11 @@ This unreleased fuel-core build may include features and updates not yet support
33120
33125
  return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
33121
33126
  }
33122
33127
  #isInputDataPointer() {
33123
- const inputTypes = this.jsonFn.inputs.map(
33124
- (i) => this.jsonAbi.types.find((t) => t.typeId === i.type)
33125
- );
33128
+ const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type));
33126
33129
  return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
33127
33130
  }
33128
33131
  #isOutputDataHeap() {
33129
- const outputType = findOrThrow(this.jsonAbi.types, (t) => t.typeId === this.jsonFn.output.type);
33132
+ const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
33130
33133
  return isHeapType(outputType?.type || "");
33131
33134
  }
33132
33135
  #getOutputEncodedLength() {
@@ -33146,9 +33149,7 @@ This unreleased fuel-core build may include features and updates not yet support
33146
33149
  encodeArguments(values, offset = 0) {
33147
33150
  FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
33148
33151
  const shallowCopyValues = values.slice();
33149
- const nonEmptyInputs = this.jsonFn.inputs.filter(
33150
- (x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
33151
- );
33152
+ const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
33152
33153
  if (Array.isArray(values) && nonEmptyInputs.length !== values.length) {
33153
33154
  shallowCopyValues.length = this.jsonFn.inputs.length;
33154
33155
  shallowCopyValues.fill(void 0, values.length);
@@ -33169,7 +33170,7 @@ This unreleased fuel-core build may include features and updates not yet support
33169
33170
  if (args.length === inputs.length) {
33170
33171
  return;
33171
33172
  }
33172
- const inputTypes = inputs.map((i) => findOrThrow(abi.types, (t) => t.typeId === i.type));
33173
+ const inputTypes = inputs.map((input) => findTypeById(abi, input.type));
33173
33174
  const optionalInputs = inputTypes.filter(
33174
33175
  (x) => x.type === OPTION_CODER_TYPE || x.type === "()"
33175
33176
  );
@@ -33184,9 +33185,7 @@ This unreleased fuel-core build may include features and updates not yet support
33184
33185
  }
33185
33186
  decodeArguments(data) {
33186
33187
  const bytes3 = arrayify(data);
33187
- const nonEmptyInputs = this.jsonFn.inputs.filter(
33188
- (x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
33189
- );
33188
+ const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
33190
33189
  if (nonEmptyInputs.length === 0) {
33191
33190
  if (bytes3.length === 0) {
33192
33191
  return void 0;
@@ -33221,10 +33220,7 @@ This unreleased fuel-core build may include features and updates not yet support
33221
33220
  return result.decoded;
33222
33221
  }
33223
33222
  decodeOutput(data) {
33224
- const outputAbiType = findOrThrow(
33225
- this.jsonAbi.types,
33226
- (t) => t.typeId === this.jsonFn.output.type
33227
- );
33223
+ const outputAbiType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
33228
33224
  if (outputAbiType.type === "()") {
33229
33225
  return [void 0, 0];
33230
33226
  }
@@ -33234,6 +33230,15 @@ This unreleased fuel-core build may include features and updates not yet support
33234
33230
  });
33235
33231
  return coder.decode(bytes3, 0);
33236
33232
  }
33233
+ /**
33234
+ * Checks if the function is read-only i.e. it only reads from storage, does not write to it.
33235
+ *
33236
+ * @returns True if the function is read-only or pure, false otherwise.
33237
+ */
33238
+ isReadOnly() {
33239
+ const storageAttribute = this.attributes.find((attr) => attr.name === "storage");
33240
+ return !storageAttribute?.arguments.includes("write");
33241
+ }
33237
33242
  };
33238
33243
  var Interface = class {
33239
33244
  functions;
@@ -33276,38 +33281,33 @@ This unreleased fuel-core build may include features and updates not yet support
33276
33281
  return fragment.decodeOutput(data);
33277
33282
  }
33278
33283
  decodeLog(data, logId) {
33279
- const { loggedType } = findOrThrow(this.jsonAbi.loggedTypes, (type3) => type3.logId === logId);
33280
- return AbiCoder.decode(this.jsonAbi, loggedType, arrayify(data), 0, {
33284
+ const loggedType = this.jsonAbi.loggedTypes.find((type3) => type3.logId === logId);
33285
+ if (!loggedType) {
33286
+ throw new FuelError(
33287
+ ErrorCode.LOG_TYPE_NOT_FOUND,
33288
+ `Log type with logId '${logId}' doesn't exist in the ABI.`
33289
+ );
33290
+ }
33291
+ return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
33281
33292
  encoding: this.jsonAbi.encoding
33282
33293
  });
33283
33294
  }
33284
33295
  encodeConfigurable(name, value) {
33285
- const configurable = findOrThrow(
33286
- this.jsonAbi.configurables,
33287
- (c) => c.name === name,
33288
- () => {
33289
- throw new FuelError(
33290
- ErrorCode.CONFIGURABLE_NOT_FOUND,
33291
- `A configurable with the '${name}' was not found in the ABI.`
33292
- );
33293
- }
33294
- );
33296
+ const configurable = this.jsonAbi.configurables.find((c) => c.name === name);
33297
+ if (!configurable) {
33298
+ throw new FuelError(
33299
+ ErrorCode.CONFIGURABLE_NOT_FOUND,
33300
+ `A configurable with the '${name}' was not found in the ABI.`
33301
+ );
33302
+ }
33295
33303
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
33296
33304
  isRightPadded: true,
33297
- encoding: this.jsonAbi.encoding
33305
+ // TODO: Review support for configurables in v1 encoding when it becomes available
33306
+ encoding: ENCODING_V0
33298
33307
  });
33299
33308
  }
33300
33309
  getTypeById(typeId) {
33301
- return findOrThrow(
33302
- this.jsonAbi.types,
33303
- (t) => t.typeId === typeId,
33304
- () => {
33305
- throw new FuelError(
33306
- ErrorCode.TYPE_NOT_FOUND,
33307
- `Type with typeId '${typeId}' doesn't exist in the ABI.`
33308
- );
33309
- }
33310
- );
33310
+ return findTypeById(this.jsonAbi, typeId);
33311
33311
  }
33312
33312
  };
33313
33313
 
@@ -38874,8 +38874,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38874
38874
  const predicateData = arrayify(value.predicateData ?? "0x");
38875
38875
  return {
38876
38876
  type: InputType.Coin,
38877
- txID: hexlify(arrayify(value.id).slice(0, 32)),
38878
- outputIndex: arrayify(value.id)[32],
38877
+ txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
38878
+ outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
38879
38879
  owner: hexlify(value.owner),
38880
38880
  amount: bn(value.amount),
38881
38881
  assetId: hexlify(value.assetId),
@@ -39774,8 +39774,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39774
39774
  assetId,
39775
39775
  txPointer: "0x00000000000000000000000000000000",
39776
39776
  witnessIndex,
39777
- predicate: predicate?.bytes,
39778
- predicateData: predicate?.predicateDataBytes
39777
+ predicate: predicate?.bytes
39779
39778
  };
39780
39779
  this.pushInput(input);
39781
39780
  this.addChangeOutput(owner, assetId);
@@ -39807,8 +39806,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39807
39806
  recipient: recipient.toB256(),
39808
39807
  amount,
39809
39808
  witnessIndex,
39810
- predicate: predicate?.bytes,
39811
- predicateData: predicate?.predicateDataBytes
39809
+ predicate: predicate?.bytes
39812
39810
  };
39813
39811
  this.pushInput(input);
39814
39812
  this.addChangeOutput(recipient, assetId);
@@ -39963,12 +39961,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39963
39961
  * @param quantities - CoinQuantity Array.
39964
39962
  */
39965
39963
  fundWithFakeUtxos(quantities, resourcesOwner) {
39966
- let idCounter = 0;
39967
- const generateId = () => {
39968
- const counterString = String(idCounter++);
39969
- const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
39970
- return id;
39971
- };
39972
39964
  const findAssetInput = (assetId) => this.inputs.find((input) => {
39973
39965
  if ("assetId" in input) {
39974
39966
  return input.assetId === assetId;
@@ -39978,12 +39970,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39978
39970
  const updateAssetInput = (assetId, quantity) => {
39979
39971
  const assetInput = findAssetInput(assetId);
39980
39972
  if (assetInput && "assetId" in assetInput) {
39981
- assetInput.id = generateId();
39973
+ assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39982
39974
  assetInput.amount = quantity;
39983
39975
  } else {
39984
39976
  this.addResources([
39985
39977
  {
39986
- id: generateId(),
39978
+ id: hexlify(randomBytes22(UTXO_ID_LEN)),
39987
39979
  amount: quantity,
39988
39980
  assetId,
39989
39981
  owner: resourcesOwner || Address.fromRandom(),
@@ -41809,6 +41801,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41809
41801
  missingContractIds
41810
41802
  };
41811
41803
  }
41804
+ /**
41805
+ * Estimates the transaction gas and fee based on the provided transaction request.
41806
+ * @param transactionRequest - The transaction request object.
41807
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41808
+ */
41809
+ estimateTxGasAndFee(params) {
41810
+ const { transactionRequest } = params;
41811
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41812
+ const chainInfo = this.getChain();
41813
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41814
+ transactionRequest.gasPrice = gasPrice;
41815
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
41816
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41817
+ if (transactionRequest.type === TransactionType.Script) {
41818
+ if (transactionRequest.gasLimit.eq(0)) {
41819
+ transactionRequest.gasLimit = minGas;
41820
+ transactionRequest.gasLimit = maxGasPerTx.sub(
41821
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
41822
+ );
41823
+ }
41824
+ }
41825
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41826
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41827
+ return {
41828
+ minGas,
41829
+ minFee,
41830
+ maxGas,
41831
+ maxFee
41832
+ };
41833
+ }
41812
41834
  /**
41813
41835
  * Executes a signed transaction without applying the states changes
41814
41836
  * on the chain.
@@ -41856,17 +41878,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41856
41878
  signatureCallback
41857
41879
  } = {}) {
41858
41880
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41859
- const chainInfo = this.getChain();
41860
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41861
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
41881
+ const { minGasPrice } = this.getGasConfig();
41882
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41862
41883
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41863
41884
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41864
41885
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
41865
41886
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
41887
+ if (isScriptTransaction) {
41888
+ txRequestClone.gasLimit = bn(0);
41889
+ }
41866
41890
  if (estimatePredicates) {
41867
- if (isScriptTransaction) {
41868
- txRequestClone.gasLimit = bn(0);
41869
- }
41870
41891
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41871
41892
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
41872
41893
  }
@@ -41875,36 +41896,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41875
41896
  if (signatureCallback && isScriptTransaction) {
41876
41897
  await signatureCallback(txRequestClone);
41877
41898
  }
41878
- const minGas = txRequestClone.calculateMinGas(chainInfo);
41879
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
41899
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41900
+ transactionRequest: txRequestClone
41901
+ });
41880
41902
  let receipts = [];
41881
41903
  let missingContractIds = [];
41882
41904
  let outputVariables = 0;
41905
+ let gasUsed = bn(0);
41883
41906
  if (isScriptTransaction && estimateTxDependencies) {
41884
41907
  txRequestClone.gasPrice = bn(0);
41885
- txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
41886
41908
  const result = await this.estimateTxDependencies(txRequestClone);
41887
41909
  receipts = result.receipts;
41888
41910
  outputVariables = result.outputVariables;
41889
41911
  missingContractIds = result.missingContractIds;
41912
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41913
+ txRequestClone.gasLimit = gasUsed;
41914
+ txRequestClone.gasPrice = setGasPrice;
41915
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41916
+ transactionRequest: txRequestClone
41917
+ }));
41890
41918
  }
41891
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
41892
- const usedFee = calculatePriceWithFactor(
41893
- gasUsed,
41894
- gasPrice,
41895
- gasPriceFactor
41896
- ).normalizeZeroToOne();
41897
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41898
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41899
41919
  return {
41900
41920
  requiredQuantities: allQuantities,
41901
41921
  receipts,
41902
41922
  gasUsed,
41903
41923
  minGasPrice,
41904
- gasPrice,
41924
+ gasPrice: setGasPrice,
41905
41925
  minGas,
41906
41926
  maxGas,
41907
- usedFee,
41908
41927
  minFee,
41909
41928
  maxFee,
41910
41929
  estimatedInputs: txRequestClone.inputs,
@@ -44358,12 +44377,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44358
44377
  };
44359
44378
 
44360
44379
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
44361
- var import_crypto15 = __toESM(__require("crypto"));
44380
+ var import_crypto16 = __toESM(__require("crypto"));
44362
44381
  var rnds8Pool = new Uint8Array(256);
44363
44382
  var poolPtr = rnds8Pool.length;
44364
44383
  function rng() {
44365
44384
  if (poolPtr > rnds8Pool.length - 16) {
44366
- import_crypto15.default.randomFillSync(rnds8Pool);
44385
+ import_crypto16.default.randomFillSync(rnds8Pool);
44367
44386
  poolPtr = 0;
44368
44387
  }
44369
44388
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -44379,9 +44398,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44379
44398
  }
44380
44399
 
44381
44400
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
44382
- var import_crypto16 = __toESM(__require("crypto"));
44401
+ var import_crypto17 = __toESM(__require("crypto"));
44383
44402
  var native_default = {
44384
- randomUUID: import_crypto16.default.randomUUID
44403
+ randomUUID: import_crypto17.default.randomUUID
44385
44404
  };
44386
44405
 
44387
44406
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
@@ -47800,7 +47819,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47800
47819
  // src/predicate/predicate.ts
47801
47820
  var Predicate = class extends Account {
47802
47821
  bytes;
47803
- predicateDataBytes = Uint8Array.from([]);
47804
47822
  predicateData = [];
47805
47823
  interface;
47806
47824
  /**