@fuel-ts/account 0.0.0-rc-1832-20240403171523 → 0.0.0-rc-1976-20240403225009

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.

@@ -32488,7 +32488,8 @@ This unreleased fuel-core build may include features and updates not yet support
32488
32488
  fee_params: {
32489
32489
  gas_price_factor: 92,
32490
32490
  gas_per_byte: 4
32491
- }
32491
+ },
32492
+ base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
32492
32493
  },
32493
32494
  gas_costs: {
32494
32495
  add: 1,
@@ -34757,10 +34758,6 @@ This unreleased fuel-core build may include features and updates not yet support
34757
34758
  }
34758
34759
  };
34759
34760
 
34760
- // ../address/dist/configs.mjs
34761
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
34762
- var BaseAssetId = ZeroBytes32;
34763
-
34764
34761
  // ../math/dist/index.mjs
34765
34762
  var import_bn = __toESM(require_bn(), 1);
34766
34763
  var DEFAULT_PRECISION = 9;
@@ -34991,11 +34988,11 @@ This unreleased fuel-core build may include features and updates not yet support
34991
34988
  let max2;
34992
34989
  if (Array.isArray(coinQuantityLike)) {
34993
34990
  amount = coinQuantityLike[0];
34994
- assetId = coinQuantityLike[1] ?? BaseAssetId;
34995
- max2 = coinQuantityLike[2] ?? void 0;
34991
+ assetId = coinQuantityLike[1];
34992
+ max2 = coinQuantityLike[2];
34996
34993
  } else {
34997
34994
  amount = coinQuantityLike.amount;
34998
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
34995
+ assetId = coinQuantityLike.assetId;
34999
34996
  max2 = coinQuantityLike.max ?? void 0;
35000
34997
  }
35001
34998
  const bnAmount = bn(amount);
@@ -35383,6 +35380,9 @@ This unreleased fuel-core build may include features and updates not yet support
35383
35380
  __privateAdd2(this, _getPaddedData);
35384
35381
  }
35385
35382
  encode(value) {
35383
+ if (!Array.isArray(value)) {
35384
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
35385
+ }
35386
35386
  const parts = [];
35387
35387
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
35388
35388
  const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
@@ -35409,7 +35409,7 @@ This unreleased fuel-core build may include features and updates not yet support
35409
35409
  };
35410
35410
  _getPaddedData = /* @__PURE__ */ new WeakSet();
35411
35411
  getPaddedData_fn = function(value) {
35412
- const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
35412
+ const data = [Uint8Array.from(value)];
35413
35413
  const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
35414
35414
  if (paddingLength) {
35415
35415
  data.push(new Uint8Array(paddingLength));
@@ -35432,7 +35432,7 @@ This unreleased fuel-core build may include features and updates not yet support
35432
35432
  (max2, coder) => Math.max(max2, coder.encodedLength),
35433
35433
  0
35434
35434
  );
35435
- super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
35435
+ super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
35436
35436
  this.name = name;
35437
35437
  this.coders = coders;
35438
35438
  this.#caseIndexCoder = caseIndexCoder;
@@ -35502,7 +35502,7 @@ This unreleased fuel-core build may include features and updates not yet support
35502
35502
  return { None: [] };
35503
35503
  }
35504
35504
  decode(data, offset) {
35505
- if (data.length < this.encodedLength) {
35505
+ if (data.length < this.encodedLength - 1) {
35506
35506
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
35507
35507
  }
35508
35508
  const [decoded, newOffset] = super.decode(data, offset);
@@ -36085,8 +36085,11 @@ This unreleased fuel-core build may include features and updates not yet support
36085
36085
  super("struct", "struct Bytes", WORD_SIZE);
36086
36086
  }
36087
36087
  encode(value) {
36088
- const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
36089
- const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
36088
+ if (!Array.isArray(value)) {
36089
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
36090
+ }
36091
+ const bytes3 = new Uint8Array(value);
36092
+ const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36090
36093
  return new Uint8Array([...lengthBytes, ...bytes3]);
36091
36094
  }
36092
36095
  decode(data, offset) {
@@ -36119,7 +36122,7 @@ This unreleased fuel-core build may include features and updates not yet support
36119
36122
  (max2, coder) => Math.max(max2, coder.encodedLength),
36120
36123
  0
36121
36124
  );
36122
- super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
36125
+ super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
36123
36126
  this.name = name;
36124
36127
  this.coders = coders;
36125
36128
  this.#caseIndexCoder = caseIndexCoder;
@@ -36217,28 +36220,6 @@ This unreleased fuel-core build may include features and updates not yet support
36217
36220
  return [toNumber2(bytes3), offset + this.length];
36218
36221
  }
36219
36222
  };
36220
- var OptionCoder2 = class extends EnumCoder2 {
36221
- encode(value) {
36222
- const result = super.encode(this.toSwayOption(value));
36223
- return result;
36224
- }
36225
- toSwayOption(input) {
36226
- if (input !== void 0) {
36227
- return { Some: input };
36228
- }
36229
- return { None: [] };
36230
- }
36231
- decode(data, offset) {
36232
- const [decoded, newOffset] = super.decode(data, offset);
36233
- return [this.toOption(decoded), newOffset];
36234
- }
36235
- toOption(output3) {
36236
- if (output3 && "Some" in output3) {
36237
- return output3.Some;
36238
- }
36239
- return void 0;
36240
- }
36241
- };
36242
36223
  var RawSliceCoder2 = class extends Coder {
36243
36224
  constructor() {
36244
36225
  super("raw untyped slice", "raw untyped slice", WORD_SIZE);
@@ -36292,30 +36273,6 @@ This unreleased fuel-core build may include features and updates not yet support
36292
36273
  }
36293
36274
  };
36294
36275
  __publicField4(StdStringCoder2, "memorySize", 1);
36295
- var StrSliceCoder = class extends Coder {
36296
- constructor() {
36297
- super("strSlice", "str", WORD_SIZE);
36298
- }
36299
- encode(value) {
36300
- const bytes3 = toUtf8Bytes(value);
36301
- const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36302
- return new Uint8Array([...lengthBytes, ...bytes3]);
36303
- }
36304
- decode(data, offset) {
36305
- if (data.length < this.encodedLength) {
36306
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
36307
- }
36308
- const offsetAndLength = offset + WORD_SIZE;
36309
- const lengthBytes = data.slice(offset, offsetAndLength);
36310
- const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
36311
- const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
36312
- if (bytes3.length !== length) {
36313
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
36314
- }
36315
- return [toUtf8String(bytes3), offsetAndLength + length];
36316
- }
36317
- };
36318
- __publicField4(StrSliceCoder, "memorySize", 1);
36319
36276
  var StringCoder2 = class extends Coder {
36320
36277
  constructor(length) {
36321
36278
  super("string", `str[${length}]`, length);
@@ -36354,7 +36311,7 @@ This unreleased fuel-core build may include features and updates not yet support
36354
36311
  Object.keys(this.coders).map((fieldName) => {
36355
36312
  const fieldCoder = this.coders[fieldName];
36356
36313
  const fieldValue = value[fieldName];
36357
- if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
36314
+ if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
36358
36315
  throw new FuelError(
36359
36316
  ErrorCode.ENCODE_ERROR,
36360
36317
  `Invalid ${this.type}. Field "${fieldName}" not present.`
@@ -36462,8 +36419,6 @@ This unreleased fuel-core build may include features and updates not yet support
36462
36419
  return new ByteCoder2();
36463
36420
  case STD_STRING_CODER_TYPE:
36464
36421
  return new StdStringCoder2();
36465
- case STR_SLICE_CODER_TYPE:
36466
- return new StrSliceCoder();
36467
36422
  default:
36468
36423
  break;
36469
36424
  }
@@ -36508,7 +36463,7 @@ This unreleased fuel-core build may include features and updates not yet support
36508
36463
  const coders = getCoders(components, { getCoder: getCoder2 });
36509
36464
  const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
36510
36465
  if (isOptionEnum) {
36511
- return new OptionCoder2(enumMatch.name, coders);
36466
+ return new OptionCoder(enumMatch.name, coders);
36512
36467
  }
36513
36468
  return new EnumCoder2(enumMatch.name, coders);
36514
36469
  }
@@ -36519,6 +36474,12 @@ This unreleased fuel-core build may include features and updates not yet support
36519
36474
  );
36520
36475
  return new TupleCoder2(coders);
36521
36476
  }
36477
+ if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
36478
+ throw new FuelError(
36479
+ ErrorCode.INVALID_DATA,
36480
+ "String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
36481
+ );
36482
+ }
36522
36483
  throw new FuelError(
36523
36484
  ErrorCode.CODER_NOT_FOUND,
36524
36485
  `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
@@ -36554,8 +36515,6 @@ This unreleased fuel-core build may include features and updates not yet support
36554
36515
  var FunctionFragment = class {
36555
36516
  signature;
36556
36517
  selector;
36557
- selectorBytes;
36558
- encoding;
36559
36518
  name;
36560
36519
  jsonFn;
36561
36520
  attributes;
@@ -36568,8 +36527,6 @@ This unreleased fuel-core build may include features and updates not yet support
36568
36527
  this.name = name;
36569
36528
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
36570
36529
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
36571
- this.selectorBytes = new StdStringCoder2().encode(name);
36572
- this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
36573
36530
  this.isInputDataPointer = this.#isInputDataPointer();
36574
36531
  this.outputMetadata = {
36575
36532
  isHeapType: this.#isOutputDataHeap(),
@@ -36623,14 +36580,11 @@ This unreleased fuel-core build may include features and updates not yet support
36623
36580
  }
36624
36581
  const coders = nonEmptyInputs.map(
36625
36582
  (t) => AbiCoder.getCoder(this.jsonAbi, t, {
36626
- isRightPadded: nonEmptyInputs.length > 1,
36627
- encoding: this.encoding
36583
+ isRightPadded: nonEmptyInputs.length > 1
36628
36584
  })
36629
36585
  );
36630
- if (this.encoding === ENCODING_V1) {
36631
- return new TupleCoder2(coders).encode(shallowCopyValues);
36632
- }
36633
- const results = new TupleCoder(coders).encode(shallowCopyValues);
36586
+ const coder = new TupleCoder(coders);
36587
+ const results = coder.encode(shallowCopyValues);
36634
36588
  return unpackDynamicData(results, offset, results.byteLength);
36635
36589
  }
36636
36590
  static verifyArgsAndInputsAlign(args, inputs, abi) {
@@ -36677,7 +36631,7 @@ This unreleased fuel-core build may include features and updates not yet support
36677
36631
  }
36678
36632
  const result = nonEmptyInputs.reduce(
36679
36633
  (obj, input) => {
36680
- const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
36634
+ const coder = AbiCoder.getCoder(this.jsonAbi, input);
36681
36635
  const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
36682
36636
  return {
36683
36637
  decoded: [...obj.decoded, decodedValue],
@@ -36697,9 +36651,7 @@ This unreleased fuel-core build may include features and updates not yet support
36697
36651
  return [void 0, 0];
36698
36652
  }
36699
36653
  const bytes3 = arrayify(data);
36700
- const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
36701
- encoding: this.encoding
36702
- });
36654
+ const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
36703
36655
  return coder.decode(bytes3, 0);
36704
36656
  }
36705
36657
  };
@@ -36767,8 +36719,7 @@ This unreleased fuel-core build may include features and updates not yet support
36767
36719
  }
36768
36720
  );
36769
36721
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
36770
- isRightPadded: true,
36771
- encoding: this.jsonAbi.encoding
36722
+ isRightPadded: true
36772
36723
  });
36773
36724
  }
36774
36725
  getTypeById(typeId) {
@@ -42339,6 +42290,9 @@ ${MessageCoinFragmentFragmentDoc}`;
42339
42290
  }
42340
42291
  };
42341
42292
 
42293
+ // ../address/dist/configs.mjs
42294
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
42295
+
42342
42296
  // src/providers/transaction-request/input.ts
42343
42297
  var inputify = (value) => {
42344
42298
  const { type: type3 } = value;
@@ -42818,6 +42772,8 @@ ${MessageCoinFragmentFragmentDoc}`;
42818
42772
  outputs = [];
42819
42773
  /** List of witnesses */
42820
42774
  witnesses = [];
42775
+ /** Base asset ID - should be fetched from the chain */
42776
+ baseAssetId = ZeroBytes32;
42821
42777
  /**
42822
42778
  * Constructor for initializing a base transaction request.
42823
42779
  *
@@ -42830,7 +42786,8 @@ ${MessageCoinFragmentFragmentDoc}`;
42830
42786
  witnessLimit,
42831
42787
  inputs,
42832
42788
  outputs,
42833
- witnesses
42789
+ witnesses,
42790
+ baseAssetId
42834
42791
  } = {}) {
42835
42792
  this.gasPrice = bn(gasPrice);
42836
42793
  this.maturity = maturity ?? 0;
@@ -42839,6 +42796,7 @@ ${MessageCoinFragmentFragmentDoc}`;
42839
42796
  this.inputs = inputs ?? [];
42840
42797
  this.outputs = outputs ?? [];
42841
42798
  this.witnesses = witnesses ?? [];
42799
+ this.baseAssetId = baseAssetId ?? ZeroBytes32;
42842
42800
  }
42843
42801
  static getPolicyMeta(req) {
42844
42802
  let policyTypes = 0;
@@ -43063,11 +43021,9 @@ ${MessageCoinFragmentFragmentDoc}`;
43063
43021
  *
43064
43022
  * @param message - Message resource.
43065
43023
  * @param predicate - Predicate bytes.
43066
- * @param predicateData - Predicate data bytes.
43067
43024
  */
43068
43025
  addMessageInput(message, predicate) {
43069
43026
  const { recipient, sender, amount } = message;
43070
- const assetId = BaseAssetId;
43071
43027
  let witnessIndex;
43072
43028
  if (predicate) {
43073
43029
  witnessIndex = 0;
@@ -43088,7 +43044,7 @@ ${MessageCoinFragmentFragmentDoc}`;
43088
43044
  predicateData: predicate?.predicateDataBytes
43089
43045
  };
43090
43046
  this.pushInput(input);
43091
- this.addChangeOutput(recipient, assetId);
43047
+ this.addChangeOutput(recipient, this.baseAssetId);
43092
43048
  }
43093
43049
  /**
43094
43050
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -43149,12 +43105,12 @@ ${MessageCoinFragmentFragmentDoc}`;
43149
43105
  * @param amount - Amount of coin.
43150
43106
  * @param assetId - Asset ID of coin.
43151
43107
  */
43152
- addCoinOutput(to, amount, assetId = BaseAssetId) {
43108
+ addCoinOutput(to, amount, assetId) {
43153
43109
  this.pushOutput({
43154
43110
  type: OutputType.Coin,
43155
43111
  to: addressify(to).toB256(),
43156
43112
  amount,
43157
- assetId
43113
+ assetId: assetId ?? this.baseAssetId
43158
43114
  });
43159
43115
  return this;
43160
43116
  }
@@ -43181,7 +43137,7 @@ ${MessageCoinFragmentFragmentDoc}`;
43181
43137
  * @param to - Address of the owner.
43182
43138
  * @param assetId - Asset ID of coin.
43183
43139
  */
43184
- addChangeOutput(to, assetId = BaseAssetId) {
43140
+ addChangeOutput(to, assetId) {
43185
43141
  const changeOutput = this.getChangeOutputs().find(
43186
43142
  (output3) => hexlify(output3.assetId) === assetId
43187
43143
  );
@@ -43189,7 +43145,7 @@ ${MessageCoinFragmentFragmentDoc}`;
43189
43145
  this.pushOutput({
43190
43146
  type: OutputType.Change,
43191
43147
  to: addressify(to).toB256(),
43192
- assetId
43148
+ assetId: assetId ?? this.baseAssetId
43193
43149
  });
43194
43150
  }
43195
43151
  }
@@ -43271,7 +43227,7 @@ ${MessageCoinFragmentFragmentDoc}`;
43271
43227
  ]);
43272
43228
  }
43273
43229
  };
43274
- updateAssetInput(BaseAssetId, bn(1e11));
43230
+ updateAssetInput(this.baseAssetId, bn(1e11));
43275
43231
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
43276
43232
  }
43277
43233
  /**
@@ -44642,6 +44598,7 @@ ${MessageCoinFragmentFragmentDoc}`;
44642
44598
  gasPerByte: bn(feeParams.gasPerByte),
44643
44599
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
44644
44600
  chainId: bn(consensusParameters.chainId),
44601
+ baseAssetId: consensusParameters.baseAssetId,
44645
44602
  gasCosts
44646
44603
  },
44647
44604
  gasCosts,
@@ -44884,6 +44841,17 @@ ${MessageCoinFragmentFragmentDoc}`;
44884
44841
  } = this.getChain();
44885
44842
  return chainId.toNumber();
44886
44843
  }
44844
+ /**
44845
+ * Returns the base asset ID
44846
+ *
44847
+ * @returns A promise that resolves to the base asset ID
44848
+ */
44849
+ getBaseAssetId() {
44850
+ const {
44851
+ consensusParameters: { baseAssetId }
44852
+ } = this.getChain();
44853
+ return baseAssetId;
44854
+ }
44887
44855
  /**
44888
44856
  * Submits a transaction to the chain to be executed.
44889
44857
  *
@@ -45745,8 +45713,9 @@ ${MessageCoinFragmentFragmentDoc}`;
45745
45713
  * @param assetId - The asset ID to check the balance for.
45746
45714
  * @returns A promise that resolves to the balance amount.
45747
45715
  */
45748
- async getBalance(assetId = BaseAssetId) {
45749
- const amount = await this.provider.getBalance(this.address, assetId);
45716
+ async getBalance(assetId) {
45717
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
45718
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
45750
45719
  return amount;
45751
45720
  }
45752
45721
  /**
@@ -45784,9 +45753,10 @@ ${MessageCoinFragmentFragmentDoc}`;
45784
45753
  * @returns A promise that resolves when the resources are added to the transaction.
45785
45754
  */
45786
45755
  async fund(request, coinQuantities, fee) {
45756
+ const baseAssetId = this.provider.getBaseAssetId();
45787
45757
  const updatedQuantities = addAmountToAsset({
45788
45758
  amount: bn(fee),
45789
- assetId: BaseAssetId,
45759
+ assetId: baseAssetId,
45790
45760
  coinQuantities
45791
45761
  });
45792
45762
  const quantitiesDict = {};
@@ -45810,8 +45780,8 @@ ${MessageCoinFragmentFragmentDoc}`;
45810
45780
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
45811
45781
  cachedUtxos.push(input.id);
45812
45782
  }
45813
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
45814
- quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
45783
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
45784
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
45815
45785
  cachedMessages.push(input.nonce);
45816
45786
  }
45817
45787
  }
@@ -45843,11 +45813,12 @@ ${MessageCoinFragmentFragmentDoc}`;
45843
45813
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
45844
45814
  * @returns A promise that resolves to the prepared transaction request.
45845
45815
  */
45846
- async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
45816
+ async createTransfer(destination, amount, assetId, txParams = {}) {
45847
45817
  const { minGasPrice } = this.provider.getGasConfig();
45818
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
45848
45819
  const params = { gasPrice: minGasPrice, ...txParams };
45849
45820
  const request = new ScriptTransactionRequest(params);
45850
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
45821
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
45851
45822
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
45852
45823
  estimateTxDependencies: true,
45853
45824
  resourcesOwner: this
@@ -45873,14 +45844,15 @@ ${MessageCoinFragmentFragmentDoc}`;
45873
45844
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
45874
45845
  * @returns A promise that resolves to the transaction response.
45875
45846
  */
45876
- async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
45847
+ async transfer(destination, amount, assetId, txParams = {}) {
45877
45848
  if (bn(amount).lte(0)) {
45878
45849
  throw new FuelError(
45879
45850
  ErrorCode.INVALID_TRANSFER_AMOUNT,
45880
45851
  "Transfer amount must be a positive number."
45881
45852
  );
45882
45853
  }
45883
- const request = await this.createTransfer(destination, amount, assetId, txParams);
45854
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
45855
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
45884
45856
  return this.sendTransaction(request, { estimateTxDependencies: false });
45885
45857
  }
45886
45858
  /**
@@ -45892,7 +45864,7 @@ ${MessageCoinFragmentFragmentDoc}`;
45892
45864
  * @param txParams - The optional transaction parameters.
45893
45865
  * @returns A promise that resolves to the transaction response.
45894
45866
  */
45895
- async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
45867
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
45896
45868
  if (bn(amount).lte(0)) {
45897
45869
  throw new FuelError(
45898
45870
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -45901,11 +45873,12 @@ ${MessageCoinFragmentFragmentDoc}`;
45901
45873
  }
45902
45874
  const contractAddress = Address.fromAddressOrString(contractId);
45903
45875
  const { minGasPrice } = this.provider.getGasConfig();
45876
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
45904
45877
  const params = { gasPrice: minGasPrice, ...txParams };
45905
45878
  const { script, scriptData } = await assembleTransferToContractScript({
45906
45879
  hexlifiedContractId: contractAddress.toB256(),
45907
45880
  amountToTransfer: bn(amount),
45908
- assetId
45881
+ assetId: assetIdToTransfer
45909
45882
  });
45910
45883
  const request = new ScriptTransactionRequest({
45911
45884
  ...params,
@@ -45915,7 +45888,7 @@ ${MessageCoinFragmentFragmentDoc}`;
45915
45888
  request.addContractInputAndOutput(contractAddress);
45916
45889
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
45917
45890
  request,
45918
- [{ amount: bn(amount), assetId: String(assetId) }]
45891
+ [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
45919
45892
  );
45920
45893
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
45921
45894
  this.validateGas({
@@ -45937,6 +45910,7 @@ ${MessageCoinFragmentFragmentDoc}`;
45937
45910
  */
45938
45911
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
45939
45912
  const { minGasPrice } = this.provider.getGasConfig();
45913
+ const baseAssetId = this.provider.getBaseAssetId();
45940
45914
  const recipientAddress = Address.fromAddressOrString(recipient);
45941
45915
  const recipientDataArray = arrayify(
45942
45916
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -45951,7 +45925,7 @@ ${MessageCoinFragmentFragmentDoc}`;
45951
45925
  ]);
45952
45926
  const params = { script, gasPrice: minGasPrice, ...txParams };
45953
45927
  const request = new ScriptTransactionRequest(params);
45954
- const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
45928
+ const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
45955
45929
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
45956
45930
  request,
45957
45931
  forwardingQuantities
@@ -50513,7 +50487,7 @@ ${MessageCoinFragmentFragmentDoc}`;
50513
50487
  {
50514
50488
  owner: signer.address.toHexString(),
50515
50489
  amount: toHex(1e9),
50516
- asset_id: BaseAssetId
50490
+ asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes32
50517
50491
  }
50518
50492
  ]
50519
50493
  }
@@ -50579,9 +50553,10 @@ ${MessageCoinFragmentFragmentDoc}`;
50579
50553
  })
50580
50554
  );
50581
50555
  var generateWallets = async (count, provider) => {
50556
+ const baseAssetId = provider.getBaseAssetId();
50582
50557
  const wallets = [];
50583
50558
  for (let i = 0; i < count; i += 1) {
50584
- const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
50559
+ const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
50585
50560
  wallets.push(wallet);
50586
50561
  }
50587
50562
  return wallets;