@fuel-ts/account 0.0.0-rc-1976-20240403225009 → 0.0.0-rc-1895-20240404023124

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.

@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACR,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,4BAA4B,EAC5B,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,CACjE,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAQ,SAAQ,eAAe;IAC1C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC;IAE/B,SAAS,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IAErC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,aAAa;IAO7F;;;;;;OAMG;IACH,IAAI,QAAQ,IAAI,QAA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GAAG,OAAO,CAAC,MAAM,CAAC;IAOnD;;;;;OAKG;IACG,eAAe,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUtF;;;;;OAKG;IACG,eAAe,CACnB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,cAAc,EAAE,GAAE,oBAAyB,GAC3E,OAAO,CAAC,mBAAmB,CAAC;IAgB/B;;;;;OAKG;IACG,mBAAmB,CACvB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,GAAE,yBAA8B,GAChE,OAAO,CAAC,UAAU,CAAC;IAQtB,OAAO,CAAC,WAAW;CAyBpB"}
@@ -29088,6 +29088,7 @@ This unreleased fuel-core build may include features and updates not yet support
29088
29088
  })(ErrorCode || {});
29089
29089
  var _FuelError = class extends Error {
29090
29090
  VERSIONS = versions;
29091
+ metadata;
29091
29092
  static parse(e) {
29092
29093
  const error = e;
29093
29094
  if (error.code === void 0) {
@@ -29107,14 +29108,15 @@ This unreleased fuel-core build may include features and updates not yet support
29107
29108
  return new _FuelError(error.code, error.message);
29108
29109
  }
29109
29110
  code;
29110
- constructor(code, message) {
29111
+ constructor(code, message, metadata = {}) {
29111
29112
  super(message);
29112
29113
  this.code = code;
29113
29114
  this.name = "FuelError";
29115
+ this.metadata = metadata;
29114
29116
  }
29115
29117
  toObject() {
29116
- const { code, name, message, VERSIONS } = this;
29117
- return { code, name, message, VERSIONS };
29118
+ const { code, name, message, metadata, VERSIONS } = this;
29119
+ return { code, name, message, metadata, VERSIONS };
29118
29120
  }
29119
29121
  };
29120
29122
  var FuelError = _FuelError;
@@ -31274,6 +31276,10 @@ This unreleased fuel-core build may include features and updates not yet support
31274
31276
  }
31275
31277
  };
31276
31278
 
31279
+ // ../address/dist/configs.mjs
31280
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
31281
+ var BaseAssetId = ZeroBytes32;
31282
+
31277
31283
  // ../math/dist/index.mjs
31278
31284
  var import_bn = __toESM(require_bn(), 1);
31279
31285
  var DEFAULT_PRECISION = 9;
@@ -31504,11 +31510,11 @@ This unreleased fuel-core build may include features and updates not yet support
31504
31510
  let max2;
31505
31511
  if (Array.isArray(coinQuantityLike)) {
31506
31512
  amount = coinQuantityLike[0];
31507
- assetId = coinQuantityLike[1];
31508
- max2 = coinQuantityLike[2];
31513
+ assetId = coinQuantityLike[1] ?? BaseAssetId;
31514
+ max2 = coinQuantityLike[2] ?? void 0;
31509
31515
  } else {
31510
31516
  amount = coinQuantityLike.amount;
31511
- assetId = coinQuantityLike.assetId;
31517
+ assetId = coinQuantityLike.assetId ?? BaseAssetId;
31512
31518
  max2 = coinQuantityLike.max ?? void 0;
31513
31519
  }
31514
31520
  const bnAmount = bn(amount);
@@ -38824,9 +38830,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38824
38830
  }
38825
38831
  };
38826
38832
 
38827
- // ../address/dist/configs.mjs
38828
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38829
-
38830
38833
  // src/providers/transaction-request/input.ts
38831
38834
  var inputify = (value) => {
38832
38835
  const { type: type3 } = value;
@@ -38961,7 +38964,60 @@ ${MessageCoinFragmentFragmentDoc}`;
38961
38964
  var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
38962
38965
  var MAX_PREDICATE_LENGTH = 1024 * 1024;
38963
38966
  var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
38967
+ var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
38964
38968
  var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
38969
+ var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
38970
+ var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
38971
+ var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
38972
+ var PANIC_REASONS = [
38973
+ "UnknownPanicReason",
38974
+ "Revert",
38975
+ "OutOfGas",
38976
+ "TransactionValidity",
38977
+ "MemoryOverflow",
38978
+ "ArithmeticOverflow",
38979
+ "ContractNotFound",
38980
+ "MemoryOwnership",
38981
+ "NotEnoughBalance",
38982
+ "ExpectedInternalContext",
38983
+ "AssetIdNotFound",
38984
+ "InputNotFound",
38985
+ "OutputNotFound",
38986
+ "WitnessNotFound",
38987
+ "TransactionMaturity",
38988
+ "InvalidMetadataIdentifier",
38989
+ "MalformedCallStructure",
38990
+ "ReservedRegisterNotWritable",
38991
+ "InvalidFlags",
38992
+ "InvalidImmediateValue",
38993
+ "ExpectedCoinInput",
38994
+ "EcalError",
38995
+ "MemoryWriteOverlap",
38996
+ "ContractNotInInputs",
38997
+ "InternalBalanceOverflow",
38998
+ "ContractMaxSize",
38999
+ "ExpectedUnallocatedStack",
39000
+ "MaxStaticContractsReached",
39001
+ "TransferAmountCannotBeZero",
39002
+ "ExpectedOutputVariable",
39003
+ "ExpectedParentInternalContext",
39004
+ "PredicateReturnedNonOne",
39005
+ "ContractIdAlreadyDeployed",
39006
+ "ContractMismatch",
39007
+ "MessageDataTooLong",
39008
+ "ArithmeticError",
39009
+ "ContractInstructionNotAllowed",
39010
+ "TransferZeroCoins",
39011
+ "InvalidInstruction",
39012
+ "MemoryNotExecutable",
39013
+ "PolicyIsNotSet",
39014
+ "PolicyNotFound",
39015
+ "TooManyReceipts",
39016
+ "BalanceOverflow",
39017
+ "InvalidBlockHeight",
39018
+ "TooManySlots"
39019
+ ];
39020
+ var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
38965
39021
 
38966
39022
  // src/providers/utils/receipts.ts
38967
39023
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
@@ -39335,6 +39391,74 @@ ${MessageCoinFragmentFragmentDoc}`;
39335
39391
  });
39336
39392
  }
39337
39393
 
39394
+ // src/providers/utils/extract-tx-error.ts
39395
+ var assemblePanicError = (status) => {
39396
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
39397
+ const reason = status.reason;
39398
+ if (PANIC_REASONS.includes(status.reason)) {
39399
+ errorMessage = `${errorMessage}
39400
+
39401
+ You can read more about this error at:
39402
+
39403
+ ${PANIC_DOC_URL}#variant.${status.reason}`;
39404
+ }
39405
+ return { errorMessage, reason };
39406
+ };
39407
+ var stringify2 = (obj) => JSON.stringify(obj, null, 2);
39408
+ var assembleRevertError = (receipts, logs) => {
39409
+ let errorMessage = "The transaction reverted with an unknown reason.";
39410
+ const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
39411
+ let reason = "";
39412
+ if (revertReceipt) {
39413
+ const reasonHex = bn(revertReceipt.val).toHex();
39414
+ switch (reasonHex) {
39415
+ case FAILED_REQUIRE_SIGNAL: {
39416
+ reason = "require";
39417
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
39418
+ break;
39419
+ }
39420
+ case FAILED_ASSERT_EQ_SIGNAL: {
39421
+ const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
39422
+ reason = "assert_eq";
39423
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
39424
+ break;
39425
+ }
39426
+ case FAILED_ASSERT_NE_SIGNAL: {
39427
+ const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
39428
+ reason = "assert_ne";
39429
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
39430
+ break;
39431
+ }
39432
+ case FAILED_ASSERT_SIGNAL:
39433
+ reason = "assert";
39434
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
39435
+ break;
39436
+ case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
39437
+ reason = "MissingOutputChange";
39438
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
39439
+ break;
39440
+ default:
39441
+ reason = "unknown";
39442
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
39443
+ }
39444
+ }
39445
+ return { errorMessage, reason };
39446
+ };
39447
+ var extractTxError = (params) => {
39448
+ const { receipts, status, logs } = params;
39449
+ const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
39450
+ const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
39451
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
39452
+ const metadata = {
39453
+ logs,
39454
+ receipts,
39455
+ panic: isPanic,
39456
+ revert: isRevert,
39457
+ reason
39458
+ };
39459
+ return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
39460
+ };
39461
+
39338
39462
  // src/providers/transaction-request/errors.ts
39339
39463
  var ChangeOutputCollisionError = class extends Error {
39340
39464
  name = "ChangeOutputCollisionError";
@@ -39382,8 +39506,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39382
39506
  outputs = [];
39383
39507
  /** List of witnesses */
39384
39508
  witnesses = [];
39385
- /** Base asset ID - should be fetched from the chain */
39386
- baseAssetId = ZeroBytes32;
39387
39509
  /**
39388
39510
  * Constructor for initializing a base transaction request.
39389
39511
  *
@@ -39396,8 +39518,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39396
39518
  witnessLimit,
39397
39519
  inputs,
39398
39520
  outputs,
39399
- witnesses,
39400
- baseAssetId
39521
+ witnesses
39401
39522
  } = {}) {
39402
39523
  this.gasPrice = bn(gasPrice);
39403
39524
  this.maturity = maturity ?? 0;
@@ -39406,7 +39527,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39406
39527
  this.inputs = inputs ?? [];
39407
39528
  this.outputs = outputs ?? [];
39408
39529
  this.witnesses = witnesses ?? [];
39409
- this.baseAssetId = baseAssetId ?? ZeroBytes32;
39410
39530
  }
39411
39531
  static getPolicyMeta(req) {
39412
39532
  let policyTypes = 0;
@@ -39631,9 +39751,11 @@ ${MessageCoinFragmentFragmentDoc}`;
39631
39751
  *
39632
39752
  * @param message - Message resource.
39633
39753
  * @param predicate - Predicate bytes.
39754
+ * @param predicateData - Predicate data bytes.
39634
39755
  */
39635
39756
  addMessageInput(message, predicate) {
39636
39757
  const { recipient, sender, amount } = message;
39758
+ const assetId = BaseAssetId;
39637
39759
  let witnessIndex;
39638
39760
  if (predicate) {
39639
39761
  witnessIndex = 0;
@@ -39654,7 +39776,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39654
39776
  predicateData: predicate?.predicateDataBytes
39655
39777
  };
39656
39778
  this.pushInput(input);
39657
- this.addChangeOutput(recipient, this.baseAssetId);
39779
+ this.addChangeOutput(recipient, assetId);
39658
39780
  }
39659
39781
  /**
39660
39782
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39715,12 +39837,12 @@ ${MessageCoinFragmentFragmentDoc}`;
39715
39837
  * @param amount - Amount of coin.
39716
39838
  * @param assetId - Asset ID of coin.
39717
39839
  */
39718
- addCoinOutput(to, amount, assetId) {
39840
+ addCoinOutput(to, amount, assetId = BaseAssetId) {
39719
39841
  this.pushOutput({
39720
39842
  type: OutputType.Coin,
39721
39843
  to: addressify(to).toB256(),
39722
39844
  amount,
39723
- assetId: assetId ?? this.baseAssetId
39845
+ assetId
39724
39846
  });
39725
39847
  return this;
39726
39848
  }
@@ -39747,7 +39869,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39747
39869
  * @param to - Address of the owner.
39748
39870
  * @param assetId - Asset ID of coin.
39749
39871
  */
39750
- addChangeOutput(to, assetId) {
39872
+ addChangeOutput(to, assetId = BaseAssetId) {
39751
39873
  const changeOutput = this.getChangeOutputs().find(
39752
39874
  (output3) => hexlify(output3.assetId) === assetId
39753
39875
  );
@@ -39755,7 +39877,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39755
39877
  this.pushOutput({
39756
39878
  type: OutputType.Change,
39757
39879
  to: addressify(to).toB256(),
39758
- assetId: assetId ?? this.baseAssetId
39880
+ assetId
39759
39881
  });
39760
39882
  }
39761
39883
  }
@@ -39837,7 +39959,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39837
39959
  ]);
39838
39960
  }
39839
39961
  };
39840
- updateAssetInput(this.baseAssetId, bn(1e11));
39962
+ updateAssetInput(BaseAssetId, bn(1e11));
39841
39963
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
39842
39964
  }
39843
39965
  /**
@@ -41153,14 +41275,26 @@ ${MessageCoinFragmentFragmentDoc}`;
41153
41275
  gqlTransaction: this.gqlTransaction,
41154
41276
  ...transactionSummary
41155
41277
  };
41278
+ let logs = [];
41156
41279
  if (this.abis) {
41157
- const logs = getDecodedLogs(
41280
+ logs = getDecodedLogs(
41158
41281
  transactionSummary.receipts,
41159
41282
  this.abis.main,
41160
41283
  this.abis.otherContractsAbis
41161
41284
  );
41162
41285
  transactionResult.logs = logs;
41163
41286
  }
41287
+ if (transactionResult.isStatusFailure) {
41288
+ const {
41289
+ receipts,
41290
+ gqlTransaction: { status }
41291
+ } = transactionResult;
41292
+ throw extractTxError({
41293
+ receipts,
41294
+ status,
41295
+ logs
41296
+ });
41297
+ }
41164
41298
  return transactionResult;
41165
41299
  }
41166
41300
  /**
@@ -41169,14 +41303,7 @@ ${MessageCoinFragmentFragmentDoc}`;
41169
41303
  * @param contractsAbiMap - The contracts ABI map.
41170
41304
  */
41171
41305
  async wait(contractsAbiMap) {
41172
- const result = await this.waitForResult(contractsAbiMap);
41173
- if (result.isStatusFailure) {
41174
- throw new FuelError(
41175
- ErrorCode.TRANSACTION_FAILED,
41176
- `Transaction failed: ${result.gqlTransaction.status.reason}`
41177
- );
41178
- }
41179
- return result;
41306
+ return this.waitForResult(contractsAbiMap);
41180
41307
  }
41181
41308
  };
41182
41309
 
@@ -41255,7 +41382,6 @@ ${MessageCoinFragmentFragmentDoc}`;
41255
41382
  gasPerByte: bn(feeParams.gasPerByte),
41256
41383
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41257
41384
  chainId: bn(consensusParameters.chainId),
41258
- baseAssetId: consensusParameters.baseAssetId,
41259
41385
  gasCosts
41260
41386
  },
41261
41387
  gasCosts,
@@ -41498,17 +41624,6 @@ ${MessageCoinFragmentFragmentDoc}`;
41498
41624
  } = this.getChain();
41499
41625
  return chainId.toNumber();
41500
41626
  }
41501
- /**
41502
- * Returns the base asset ID
41503
- *
41504
- * @returns A promise that resolves to the base asset ID
41505
- */
41506
- getBaseAssetId() {
41507
- const {
41508
- consensusParameters: { baseAssetId }
41509
- } = this.getChain();
41510
- return baseAssetId;
41511
- }
41512
41627
  /**
41513
41628
  * Submits a transaction to the chain to be executed.
41514
41629
  *
@@ -42538,9 +42653,8 @@ ${MessageCoinFragmentFragmentDoc}`;
42538
42653
  * @param assetId - The asset ID to check the balance for.
42539
42654
  * @returns A promise that resolves to the balance amount.
42540
42655
  */
42541
- async getBalance(assetId) {
42542
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42543
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42656
+ async getBalance(assetId = BaseAssetId) {
42657
+ const amount = await this.provider.getBalance(this.address, assetId);
42544
42658
  return amount;
42545
42659
  }
42546
42660
  /**
@@ -42578,10 +42692,9 @@ ${MessageCoinFragmentFragmentDoc}`;
42578
42692
  * @returns A promise that resolves when the resources are added to the transaction.
42579
42693
  */
42580
42694
  async fund(request, coinQuantities, fee) {
42581
- const baseAssetId = this.provider.getBaseAssetId();
42582
42695
  const updatedQuantities = addAmountToAsset({
42583
42696
  amount: bn(fee),
42584
- assetId: baseAssetId,
42697
+ assetId: BaseAssetId,
42585
42698
  coinQuantities
42586
42699
  });
42587
42700
  const quantitiesDict = {};
@@ -42605,8 +42718,8 @@ ${MessageCoinFragmentFragmentDoc}`;
42605
42718
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42606
42719
  cachedUtxos.push(input.id);
42607
42720
  }
42608
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42609
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42721
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42722
+ quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42610
42723
  cachedMessages.push(input.nonce);
42611
42724
  }
42612
42725
  }
@@ -42638,12 +42751,11 @@ ${MessageCoinFragmentFragmentDoc}`;
42638
42751
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42639
42752
  * @returns A promise that resolves to the prepared transaction request.
42640
42753
  */
42641
- async createTransfer(destination, amount, assetId, txParams = {}) {
42754
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42642
42755
  const { minGasPrice } = this.provider.getGasConfig();
42643
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42644
42756
  const params = { gasPrice: minGasPrice, ...txParams };
42645
42757
  const request = new ScriptTransactionRequest(params);
42646
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42758
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42647
42759
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
42648
42760
  estimateTxDependencies: true,
42649
42761
  resourcesOwner: this
@@ -42669,15 +42781,14 @@ ${MessageCoinFragmentFragmentDoc}`;
42669
42781
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42670
42782
  * @returns A promise that resolves to the transaction response.
42671
42783
  */
42672
- async transfer(destination, amount, assetId, txParams = {}) {
42784
+ async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42673
42785
  if (bn(amount).lte(0)) {
42674
42786
  throw new FuelError(
42675
42787
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42676
42788
  "Transfer amount must be a positive number."
42677
42789
  );
42678
42790
  }
42679
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42680
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42791
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
42681
42792
  return this.sendTransaction(request, { estimateTxDependencies: false });
42682
42793
  }
42683
42794
  /**
@@ -42689,7 +42800,7 @@ ${MessageCoinFragmentFragmentDoc}`;
42689
42800
  * @param txParams - The optional transaction parameters.
42690
42801
  * @returns A promise that resolves to the transaction response.
42691
42802
  */
42692
- async transferToContract(contractId, amount, assetId, txParams = {}) {
42803
+ async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42693
42804
  if (bn(amount).lte(0)) {
42694
42805
  throw new FuelError(
42695
42806
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42698,12 +42809,11 @@ ${MessageCoinFragmentFragmentDoc}`;
42698
42809
  }
42699
42810
  const contractAddress = Address.fromAddressOrString(contractId);
42700
42811
  const { minGasPrice } = this.provider.getGasConfig();
42701
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42702
42812
  const params = { gasPrice: minGasPrice, ...txParams };
42703
42813
  const { script, scriptData } = await assembleTransferToContractScript({
42704
42814
  hexlifiedContractId: contractAddress.toB256(),
42705
42815
  amountToTransfer: bn(amount),
42706
- assetId: assetIdToTransfer
42816
+ assetId
42707
42817
  });
42708
42818
  const request = new ScriptTransactionRequest({
42709
42819
  ...params,
@@ -42713,7 +42823,7 @@ ${MessageCoinFragmentFragmentDoc}`;
42713
42823
  request.addContractInputAndOutput(contractAddress);
42714
42824
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42715
42825
  request,
42716
- [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42826
+ [{ amount: bn(amount), assetId: String(assetId) }]
42717
42827
  );
42718
42828
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
42719
42829
  this.validateGas({
@@ -42735,7 +42845,6 @@ ${MessageCoinFragmentFragmentDoc}`;
42735
42845
  */
42736
42846
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42737
42847
  const { minGasPrice } = this.provider.getGasConfig();
42738
- const baseAssetId = this.provider.getBaseAssetId();
42739
42848
  const recipientAddress = Address.fromAddressOrString(recipient);
42740
42849
  const recipientDataArray = arrayify(
42741
42850
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42750,7 +42859,7 @@ ${MessageCoinFragmentFragmentDoc}`;
42750
42859
  ]);
42751
42860
  const params = { script, gasPrice: minGasPrice, ...txParams };
42752
42861
  const request = new ScriptTransactionRequest(params);
42753
- const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42862
+ const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42754
42863
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42755
42864
  request,
42756
42865
  forwardingQuantities
@@ -47714,9 +47823,8 @@ ${MessageCoinFragmentFragmentDoc}`;
47714
47823
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47715
47824
  * @returns A promise that resolves to the prepared transaction request.
47716
47825
  */
47717
- async createTransfer(destination, amount, assetId, txParams = {}) {
47718
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47719
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47826
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47827
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47720
47828
  return this.populateTransactionPredicateData(request);
47721
47829
  }
47722
47830
  /**