@fuel-ts/account 0.0.0-rc-2045-20240415152456 → 0.0.0-rc-1832-20240415161726

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.

@@ -31914,7 +31914,7 @@ spurious results.`);
31914
31914
  // ../versions/dist/index.mjs
31915
31915
  function getBuiltinVersions() {
31916
31916
  return {
31917
- FORC: "0.53.0",
31917
+ FORC: "0.49.3",
31918
31918
  FUEL_CORE: "0.22.1",
31919
31919
  FUELS: "0.79.0"
31920
31920
  };
@@ -31977,7 +31977,6 @@ This unreleased fuel-core build may include features and updates not yet support
31977
31977
  ErrorCode2["INVALID_COMPONENT"] = "invalid-component";
31978
31978
  ErrorCode2["CONFIGURABLE_NOT_FOUND"] = "configurable-not-found";
31979
31979
  ErrorCode2["TYPE_NOT_FOUND"] = "type-not-found";
31980
- ErrorCode2["LOG_TYPE_NOT_FOUND"] = "log-type-not-found";
31981
31980
  ErrorCode2["TYPE_NOT_SUPPORTED"] = "type-not-supported";
31982
31981
  ErrorCode2["INVALID_DECODE_VALUE"] = "invalid-decode-value";
31983
31982
  ErrorCode2["JSON_ABI_ERROR"] = "json-abi-error";
@@ -34627,7 +34626,7 @@ This unreleased fuel-core build may include features and updates not yet support
34627
34626
  toEvmAddress() {
34628
34627
  const b256Address = toB256(this.bech32Address);
34629
34628
  return {
34630
- bits: clearFirst12BytesFromB256(b256Address)
34629
+ value: clearFirst12BytesFromB256(b256Address)
34631
34630
  };
34632
34631
  }
34633
34632
  /**
@@ -34637,7 +34636,7 @@ This unreleased fuel-core build may include features and updates not yet support
34637
34636
  */
34638
34637
  toAssetId() {
34639
34638
  return {
34640
- bits: this.toB256()
34639
+ value: this.toB256()
34641
34640
  };
34642
34641
  }
34643
34642
  /**
@@ -34763,7 +34762,7 @@ This unreleased fuel-core build may include features and updates not yet support
34763
34762
  var import_bn = __toESM(require_bn(), 1);
34764
34763
  var DEFAULT_PRECISION = 9;
34765
34764
  var DEFAULT_MIN_PRECISION = 3;
34766
- var DEFAULT_DECIMAL_UNITS = 9;
34765
+ var DECIMAL_UNITS = 9;
34767
34766
  function toFixed(value, options) {
34768
34767
  const { precision = DEFAULT_PRECISION, minPrecision = DEFAULT_MIN_PRECISION } = options || {};
34769
34768
  const [valueUnits = "0", valueDecimals = "0"] = String(value || "0.0").split(".");
@@ -34829,7 +34828,7 @@ This unreleased fuel-core build may include features and updates not yet support
34829
34828
  }
34830
34829
  format(options) {
34831
34830
  const {
34832
- units = DEFAULT_DECIMAL_UNITS,
34831
+ units = DECIMAL_UNITS,
34833
34832
  precision = DEFAULT_PRECISION,
34834
34833
  minPrecision = DEFAULT_MIN_PRECISION
34835
34834
  } = options || {};
@@ -34845,7 +34844,7 @@ This unreleased fuel-core build may include features and updates not yet support
34845
34844
  }
34846
34845
  return formattedFixed;
34847
34846
  }
34848
- formatUnits(units = DEFAULT_DECIMAL_UNITS) {
34847
+ formatUnits(units = DECIMAL_UNITS) {
34849
34848
  const valueUnits = this.toString().slice(0, units * -1);
34850
34849
  const valueDecimals = this.toString().slice(units * -1);
34851
34850
  const length = valueDecimals.length;
@@ -34954,7 +34953,7 @@ This unreleased fuel-core build may include features and updates not yet support
34954
34953
  // END ANCHOR: OVERRIDES to avoid losing references
34955
34954
  };
34956
34955
  var bn = (value, base, endian) => new BN(value, base, endian);
34957
- bn.parseUnits = (value, units = DEFAULT_DECIMAL_UNITS) => {
34956
+ bn.parseUnits = (value, units = DECIMAL_UNITS) => {
34958
34957
  const valueToParse = value === "." ? "0." : value;
34959
34958
  const [valueUnits = "0", valueDecimals = "0"] = valueToParse.split(".");
34960
34959
  const length = valueDecimals.length;
@@ -35070,7 +35069,6 @@ This unreleased fuel-core build may include features and updates not yet support
35070
35069
  var ENCODING_V1 = "1";
35071
35070
  var WORD_SIZE = 8;
35072
35071
  var BYTES_32 = 32;
35073
- var UTXO_ID_LEN = BYTES_32 + 1;
35074
35072
  var ASSET_ID_LEN = BYTES_32;
35075
35073
  var ADDRESS_LEN = BYTES_32;
35076
35074
  var NONCE_LEN = BYTES_32;
@@ -35221,6 +35219,15 @@ This unreleased fuel-core build may include features and updates not yet support
35221
35219
  }
35222
35220
  };
35223
35221
  var isHeapType = (type3) => type3 === VEC_CODER_TYPE || type3 === BYTES_CODER_TYPE || type3 === STD_STRING_CODER_TYPE;
35222
+ function findOrThrow(arr, predicate, throwFn = () => {
35223
+ throw new FuelError(ErrorCode.ELEMENT_NOT_FOUND, "Element not found in the array.");
35224
+ }) {
35225
+ const found = arr.find(predicate);
35226
+ if (found === void 0) {
35227
+ throwFn();
35228
+ }
35229
+ return found;
35230
+ }
35224
35231
  var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
35225
35232
  var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
35226
35233
  var rightPadToWordSize = (encoded) => {
@@ -35230,7 +35237,6 @@ This unreleased fuel-core build may include features and updates not yet support
35230
35237
  const padding = new Uint8Array(WORD_SIZE - encoded.length % WORD_SIZE);
35231
35238
  return concatBytes2([encoded, padding]);
35232
35239
  };
35233
- var isUint8Array = (value) => value instanceof Uint8Array;
35234
35240
  var ArrayCoder = class extends Coder {
35235
35241
  coder;
35236
35242
  length;
@@ -35772,11 +35778,8 @@ This unreleased fuel-core build may include features and updates not yet support
35772
35778
  this.coder = coder;
35773
35779
  }
35774
35780
  encode(value) {
35775
- if (!Array.isArray(value) && !isUint8Array(value)) {
35776
- throw new FuelError(
35777
- ErrorCode.ENCODE_ERROR,
35778
- `Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.`
35779
- );
35781
+ if (!Array.isArray(value)) {
35782
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
35780
35783
  }
35781
35784
  const parts = [];
35782
35785
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
@@ -35807,38 +35810,6 @@ This unreleased fuel-core build may include features and updates not yet support
35807
35810
  ];
35808
35811
  }
35809
35812
  };
35810
- var findFunctionByName = (abi, name) => {
35811
- const fn = abi.functions.find((f2) => f2.name === name);
35812
- if (!fn) {
35813
- throw new FuelError(
35814
- ErrorCode.FUNCTION_NOT_FOUND,
35815
- `Function with name '${name}' doesn't exist in the ABI`
35816
- );
35817
- }
35818
- return fn;
35819
- };
35820
- var findTypeById = (abi, typeId) => {
35821
- const type3 = abi.types.find((t) => t.typeId === typeId);
35822
- if (!type3) {
35823
- throw new FuelError(
35824
- ErrorCode.TYPE_NOT_FOUND,
35825
- `Type with typeId '${typeId}' doesn't exist in the ABI.`
35826
- );
35827
- }
35828
- return type3;
35829
- };
35830
- var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
35831
- var findVectorBufferArgument = (components) => {
35832
- const bufferComponent = components.find((c) => c.name === "buf");
35833
- const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
35834
- if (!bufferComponent || !bufferTypeArgument) {
35835
- throw new FuelError(
35836
- ErrorCode.INVALID_COMPONENT,
35837
- `The Vec type provided is missing or has a malformed 'buf' component.`
35838
- );
35839
- }
35840
- return bufferTypeArgument;
35841
- };
35842
35813
  var ResolvedAbiType = class {
35843
35814
  abi;
35844
35815
  name;
@@ -35847,8 +35818,20 @@ This unreleased fuel-core build may include features and updates not yet support
35847
35818
  components;
35848
35819
  constructor(abi, argument) {
35849
35820
  this.abi = abi;
35821
+ const type3 = findOrThrow(
35822
+ abi.types,
35823
+ (t) => t.typeId === argument.type,
35824
+ () => {
35825
+ throw new FuelError(
35826
+ ErrorCode.TYPE_NOT_FOUND,
35827
+ `Type does not exist in the provided abi: ${JSON.stringify({
35828
+ argument,
35829
+ abi: this.abi
35830
+ })}`
35831
+ );
35832
+ }
35833
+ );
35850
35834
  this.name = argument.name;
35851
- const type3 = findTypeById(abi, argument.type);
35852
35835
  this.type = type3.type;
35853
35836
  this.originalTypeArguments = argument.typeArguments;
35854
35837
  this.components = ResolvedAbiType.getResolvedGenericComponents(
@@ -35900,7 +35883,7 @@ This unreleased fuel-core build may include features and updates not yet support
35900
35883
  )
35901
35884
  };
35902
35885
  }
35903
- const argType = findTypeById(abi, arg.type);
35886
+ const argType = findOrThrow(abi.types, (t) => t.typeId === arg.type);
35904
35887
  const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
35905
35888
  if (implicitTypeParameters && implicitTypeParameters.length > 0) {
35906
35889
  return {
@@ -35917,7 +35900,7 @@ This unreleased fuel-core build may include features and updates not yet support
35917
35900
  }
35918
35901
  const implicitGenericParameters = implicitGenericParametersParam ?? [];
35919
35902
  args.forEach((a) => {
35920
- const argType = findTypeById(abi, a.type);
35903
+ const argType = findOrThrow(abi.types, (t) => t.typeId === a.type);
35921
35904
  if (genericRegEx.test(argType.type)) {
35922
35905
  implicitGenericParameters.push(argType.typeId);
35923
35906
  return;
@@ -36026,7 +36009,13 @@ This unreleased fuel-core build may include features and updates not yet support
36026
36009
  return new ArrayCoder(arrayElementCoder, length);
36027
36010
  }
36028
36011
  if (resolvedAbiType.type === VEC_CODER_TYPE) {
36029
- const arg = findVectorBufferArgument(components);
36012
+ const arg = findOrThrow(components, (c) => c.name === "buf").originalTypeArguments?.[0];
36013
+ if (!arg) {
36014
+ throw new FuelError(
36015
+ ErrorCode.INVALID_COMPONENT,
36016
+ `The provided Vec type is missing the 'type argument'.`
36017
+ );
36018
+ }
36030
36019
  const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
36031
36020
  const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
36032
36021
  return new VecCoder(itemCoder);
@@ -36495,7 +36484,13 @@ This unreleased fuel-core build may include features and updates not yet support
36495
36484
  return new ArrayCoder(arrayElementCoder, length);
36496
36485
  }
36497
36486
  if (resolvedAbiType.type === VEC_CODER_TYPE) {
36498
- const arg = findVectorBufferArgument(components);
36487
+ const arg = findOrThrow(components, (c) => c.name === "buf").originalTypeArguments?.[0];
36488
+ if (!arg) {
36489
+ throw new FuelError(
36490
+ ErrorCode.INVALID_COMPONENT,
36491
+ `The provided Vec type is missing the 'type argument'.`
36492
+ );
36493
+ }
36499
36494
  const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
36500
36495
  const itemCoder = getCoder2(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
36501
36496
  return new VecCoder2(itemCoder);
@@ -36566,7 +36561,7 @@ This unreleased fuel-core build may include features and updates not yet support
36566
36561
  jsonAbi;
36567
36562
  constructor(jsonAbi, name) {
36568
36563
  this.jsonAbi = jsonAbi;
36569
- this.jsonFn = findFunctionByName(this.jsonAbi, name);
36564
+ this.jsonFn = findOrThrow(this.jsonAbi.functions, (f2) => f2.name === name);
36570
36565
  this.name = name;
36571
36566
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
36572
36567
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
@@ -36590,11 +36585,13 @@ This unreleased fuel-core build may include features and updates not yet support
36590
36585
  return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
36591
36586
  }
36592
36587
  #isInputDataPointer() {
36593
- const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type));
36588
+ const inputTypes = this.jsonFn.inputs.map(
36589
+ (i) => this.jsonAbi.types.find((t) => t.typeId === i.type)
36590
+ );
36594
36591
  return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
36595
36592
  }
36596
36593
  #isOutputDataHeap() {
36597
- const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
36594
+ const outputType = findOrThrow(this.jsonAbi.types, (t) => t.typeId === this.jsonFn.output.type);
36598
36595
  return isHeapType(outputType?.type || "");
36599
36596
  }
36600
36597
  #getOutputEncodedLength() {
@@ -36614,7 +36611,9 @@ This unreleased fuel-core build may include features and updates not yet support
36614
36611
  encodeArguments(values, offset = 0) {
36615
36612
  FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
36616
36613
  const shallowCopyValues = values.slice();
36617
- const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
36614
+ const nonEmptyInputs = this.jsonFn.inputs.filter(
36615
+ (x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
36616
+ );
36618
36617
  if (Array.isArray(values) && nonEmptyInputs.length !== values.length) {
36619
36618
  shallowCopyValues.length = this.jsonFn.inputs.length;
36620
36619
  shallowCopyValues.fill(void 0, values.length);
@@ -36635,7 +36634,7 @@ This unreleased fuel-core build may include features and updates not yet support
36635
36634
  if (args.length === inputs.length) {
36636
36635
  return;
36637
36636
  }
36638
- const inputTypes = inputs.map((input) => findTypeById(abi, input.type));
36637
+ const inputTypes = inputs.map((i) => findOrThrow(abi.types, (t) => t.typeId === i.type));
36639
36638
  const optionalInputs = inputTypes.filter(
36640
36639
  (x) => x.type === OPTION_CODER_TYPE || x.type === "()"
36641
36640
  );
@@ -36650,7 +36649,9 @@ This unreleased fuel-core build may include features and updates not yet support
36650
36649
  }
36651
36650
  decodeArguments(data) {
36652
36651
  const bytes3 = arrayify(data);
36653
- const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
36652
+ const nonEmptyInputs = this.jsonFn.inputs.filter(
36653
+ (x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
36654
+ );
36654
36655
  if (nonEmptyInputs.length === 0) {
36655
36656
  if (bytes3.length === 0) {
36656
36657
  return void 0;
@@ -36685,7 +36686,10 @@ This unreleased fuel-core build may include features and updates not yet support
36685
36686
  return result.decoded;
36686
36687
  }
36687
36688
  decodeOutput(data) {
36688
- const outputAbiType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
36689
+ const outputAbiType = findOrThrow(
36690
+ this.jsonAbi.types,
36691
+ (t) => t.typeId === this.jsonFn.output.type
36692
+ );
36689
36693
  if (outputAbiType.type === "()") {
36690
36694
  return [void 0, 0];
36691
36695
  }
@@ -36695,15 +36699,6 @@ This unreleased fuel-core build may include features and updates not yet support
36695
36699
  });
36696
36700
  return coder.decode(bytes3, 0);
36697
36701
  }
36698
- /**
36699
- * Checks if the function is read-only i.e. it only reads from storage, does not write to it.
36700
- *
36701
- * @returns True if the function is read-only or pure, false otherwise.
36702
- */
36703
- isReadOnly() {
36704
- const storageAttribute = this.attributes.find((attr) => attr.name === "storage");
36705
- return !storageAttribute?.arguments.includes("write");
36706
- }
36707
36702
  };
36708
36703
  var Interface = class {
36709
36704
  functions;
@@ -36746,33 +36741,38 @@ This unreleased fuel-core build may include features and updates not yet support
36746
36741
  return fragment.decodeOutput(data);
36747
36742
  }
36748
36743
  decodeLog(data, logId) {
36749
- const loggedType = this.jsonAbi.loggedTypes.find((type3) => type3.logId === logId);
36750
- if (!loggedType) {
36751
- throw new FuelError(
36752
- ErrorCode.LOG_TYPE_NOT_FOUND,
36753
- `Log type with logId '${logId}' doesn't exist in the ABI.`
36754
- );
36755
- }
36756
- return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
36744
+ const { loggedType } = findOrThrow(this.jsonAbi.loggedTypes, (type3) => type3.logId === logId);
36745
+ return AbiCoder.decode(this.jsonAbi, loggedType, arrayify(data), 0, {
36757
36746
  encoding: this.jsonAbi.encoding
36758
36747
  });
36759
36748
  }
36760
36749
  encodeConfigurable(name, value) {
36761
- const configurable = this.jsonAbi.configurables.find((c) => c.name === name);
36762
- if (!configurable) {
36763
- throw new FuelError(
36764
- ErrorCode.CONFIGURABLE_NOT_FOUND,
36765
- `A configurable with the '${name}' was not found in the ABI.`
36766
- );
36767
- }
36750
+ const configurable = findOrThrow(
36751
+ this.jsonAbi.configurables,
36752
+ (c) => c.name === name,
36753
+ () => {
36754
+ throw new FuelError(
36755
+ ErrorCode.CONFIGURABLE_NOT_FOUND,
36756
+ `A configurable with the '${name}' was not found in the ABI.`
36757
+ );
36758
+ }
36759
+ );
36768
36760
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
36769
36761
  isRightPadded: true,
36770
- // TODO: Review support for configurables in v1 encoding when it becomes available
36771
- encoding: ENCODING_V0
36762
+ encoding: this.jsonAbi.encoding
36772
36763
  });
36773
36764
  }
36774
36765
  getTypeById(typeId) {
36775
- return findTypeById(this.jsonAbi, typeId);
36766
+ return findOrThrow(
36767
+ this.jsonAbi.types,
36768
+ (t) => t.typeId === typeId,
36769
+ () => {
36770
+ throw new FuelError(
36771
+ ErrorCode.TYPE_NOT_FOUND,
36772
+ `Type with typeId '${typeId}' doesn't exist in the ABI.`
36773
+ );
36774
+ }
36775
+ );
36776
36776
  }
36777
36777
  };
36778
36778
 
@@ -42339,8 +42339,8 @@ ${MessageCoinFragmentFragmentDoc}`;
42339
42339
  const predicateData = arrayify(value.predicateData ?? "0x");
42340
42340
  return {
42341
42341
  type: InputType.Coin,
42342
- txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
42343
- outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
42342
+ txID: hexlify(arrayify(value.id).slice(0, 32)),
42343
+ outputIndex: arrayify(value.id)[32],
42344
42344
  owner: hexlify(value.owner),
42345
42345
  amount: bn(value.amount),
42346
42346
  assetId: hexlify(value.assetId),
@@ -43163,7 +43163,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43163
43163
  assetId,
43164
43164
  txPointer: "0x00000000000000000000000000000000",
43165
43165
  witnessIndex,
43166
- predicate: predicate?.bytes
43166
+ predicate: predicate?.bytes,
43167
+ predicateData: predicate?.predicateDataBytes
43167
43168
  };
43168
43169
  this.pushInput(input);
43169
43170
  this.addChangeOutput(owner, assetId);
@@ -43195,7 +43196,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43195
43196
  recipient: recipient.toB256(),
43196
43197
  amount,
43197
43198
  witnessIndex,
43198
- predicate: predicate?.bytes
43199
+ predicate: predicate?.bytes,
43200
+ predicateData: predicate?.predicateDataBytes
43199
43201
  };
43200
43202
  this.pushInput(input);
43201
43203
  this.addChangeOutput(recipient, assetId);
@@ -43350,6 +43352,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43350
43352
  * @param quantities - CoinQuantity Array.
43351
43353
  */
43352
43354
  fundWithFakeUtxos(quantities, resourcesOwner) {
43355
+ let idCounter = 0;
43356
+ const generateId = () => {
43357
+ const counterString = String(idCounter++);
43358
+ const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
43359
+ return id;
43360
+ };
43353
43361
  const findAssetInput = (assetId) => this.inputs.find((input) => {
43354
43362
  if ("assetId" in input) {
43355
43363
  return input.assetId === assetId;
@@ -43359,12 +43367,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43359
43367
  const updateAssetInput = (assetId, quantity) => {
43360
43368
  const assetInput = findAssetInput(assetId);
43361
43369
  if (assetInput && "assetId" in assetInput) {
43362
- assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
43370
+ assetInput.id = generateId();
43363
43371
  assetInput.amount = quantity;
43364
43372
  } else {
43365
43373
  this.addResources([
43366
43374
  {
43367
- id: hexlify(randomBytes22(UTXO_ID_LEN)),
43375
+ id: generateId(),
43368
43376
  amount: quantity,
43369
43377
  assetId,
43370
43378
  owner: resourcesOwner || Address.fromRandom(),
@@ -45143,36 +45151,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45143
45151
  missingContractIds
45144
45152
  };
45145
45153
  }
45146
- /**
45147
- * Estimates the transaction gas and fee based on the provided transaction request.
45148
- * @param transactionRequest - The transaction request object.
45149
- * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
45150
- */
45151
- estimateTxGasAndFee(params) {
45152
- const { transactionRequest } = params;
45153
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
45154
- const chainInfo = this.getChain();
45155
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
45156
- transactionRequest.gasPrice = gasPrice;
45157
- const minGas = transactionRequest.calculateMinGas(chainInfo);
45158
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
45159
- if (transactionRequest.type === TransactionType.Script) {
45160
- if (transactionRequest.gasLimit.eq(0)) {
45161
- transactionRequest.gasLimit = minGas;
45162
- transactionRequest.gasLimit = maxGasPerTx.sub(
45163
- transactionRequest.calculateMaxGas(chainInfo, minGas)
45164
- );
45165
- }
45166
- }
45167
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
45168
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
45169
- return {
45170
- minGas,
45171
- minFee,
45172
- maxGas,
45173
- maxFee
45174
- };
45175
- }
45176
45154
  /**
45177
45155
  * Executes a signed transaction without applying the states changes
45178
45156
  * on the chain.
@@ -45220,16 +45198,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45220
45198
  signatureCallback
45221
45199
  } = {}) {
45222
45200
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
45223
- const { minGasPrice } = this.getGasConfig();
45224
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
45201
+ const chainInfo = this.getChain();
45202
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
45203
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
45225
45204
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
45226
45205
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
45227
45206
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
45228
45207
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
45229
- if (isScriptTransaction) {
45230
- txRequestClone.gasLimit = bn(0);
45231
- }
45232
45208
  if (estimatePredicates) {
45209
+ if (isScriptTransaction) {
45210
+ txRequestClone.gasLimit = bn(0);
45211
+ }
45233
45212
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
45234
45213
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
45235
45214
  }
@@ -45238,34 +45217,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45238
45217
  if (signatureCallback && isScriptTransaction) {
45239
45218
  await signatureCallback(txRequestClone);
45240
45219
  }
45241
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
45242
- transactionRequest: txRequestClone
45243
- });
45220
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
45221
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
45244
45222
  let receipts = [];
45245
45223
  let missingContractIds = [];
45246
45224
  let outputVariables = 0;
45247
- let gasUsed = bn(0);
45248
45225
  if (isScriptTransaction && estimateTxDependencies) {
45249
45226
  txRequestClone.gasPrice = bn(0);
45227
+ txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
45250
45228
  const result = await this.estimateTxDependencies(txRequestClone);
45251
45229
  receipts = result.receipts;
45252
45230
  outputVariables = result.outputVariables;
45253
45231
  missingContractIds = result.missingContractIds;
45254
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
45255
- txRequestClone.gasLimit = gasUsed;
45256
- txRequestClone.gasPrice = setGasPrice;
45257
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
45258
- transactionRequest: txRequestClone
45259
- }));
45260
45232
  }
45233
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
45234
+ const usedFee = calculatePriceWithFactor(
45235
+ gasUsed,
45236
+ gasPrice,
45237
+ gasPriceFactor
45238
+ ).normalizeZeroToOne();
45239
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
45240
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
45261
45241
  return {
45262
45242
  requiredQuantities: allQuantities,
45263
45243
  receipts,
45264
45244
  gasUsed,
45265
45245
  minGasPrice,
45266
- gasPrice: setGasPrice,
45246
+ gasPrice,
45267
45247
  minGas,
45268
45248
  maxGas,
45249
+ usedFee,
45269
45250
  minFee,
45270
45251
  maxFee,
45271
45252
  estimatedInputs: txRequestClone.inputs,
@@ -47551,12 +47532,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47551
47532
  };
47552
47533
 
47553
47534
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
47554
- var import_crypto16 = __toESM(__require("crypto"));
47535
+ var import_crypto15 = __toESM(__require("crypto"));
47555
47536
  var rnds8Pool = new Uint8Array(256);
47556
47537
  var poolPtr = rnds8Pool.length;
47557
47538
  function rng() {
47558
47539
  if (poolPtr > rnds8Pool.length - 16) {
47559
- import_crypto16.default.randomFillSync(rnds8Pool);
47540
+ import_crypto15.default.randomFillSync(rnds8Pool);
47560
47541
  poolPtr = 0;
47561
47542
  }
47562
47543
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -47572,9 +47553,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47572
47553
  }
47573
47554
 
47574
47555
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
47575
- var import_crypto17 = __toESM(__require("crypto"));
47556
+ var import_crypto16 = __toESM(__require("crypto"));
47576
47557
  var native_default = {
47577
- randomUUID: import_crypto17.default.randomUUID
47558
+ randomUUID: import_crypto16.default.randomUUID
47578
47559
  };
47579
47560
 
47580
47561
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
@@ -50554,7 +50535,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
50554
50535
 
50555
50536
  // src/test-utils/launchNode.ts
50556
50537
  var import_child_process = __require("child_process");
50557
- var import_crypto21 = __require("crypto");
50538
+ var import_crypto20 = __require("crypto");
50558
50539
  var import_fs2 = __require("fs");
50559
50540
  var import_os = __toESM(__require("os"));
50560
50541
  var import_path8 = __toESM(__require("path"));
@@ -50626,7 +50607,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
50626
50607
  })).toString();
50627
50608
  let chainConfigPathToUse;
50628
50609
  const prefix = basePath || import_os.default.tmpdir();
50629
- const suffix = basePath ? "" : (0, import_crypto21.randomUUID)();
50610
+ const suffix = basePath ? "" : (0, import_crypto20.randomUUID)();
50630
50611
  const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix);
50631
50612
  if (chainConfigPath) {
50632
50613
  chainConfigPathToUse = chainConfigPath;