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

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":"AAGA,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"}
@@ -29013,7 +29013,6 @@ This unreleased fuel-core build may include features and updates not yet support
29013
29013
  ErrorCode2["ABI_TYPES_AND_VALUES_MISMATCH"] = "abi-types-and-values-mismatch";
29014
29014
  ErrorCode2["ABI_MAIN_METHOD_MISSING"] = "abi-main-method-missing";
29015
29015
  ErrorCode2["INVALID_COMPONENT"] = "invalid-component";
29016
- ErrorCode2["FRAGMENT_NOT_FOUND"] = "fragment-not-found";
29017
29016
  ErrorCode2["CONFIGURABLE_NOT_FOUND"] = "configurable-not-found";
29018
29017
  ErrorCode2["TYPE_NOT_FOUND"] = "type-not-found";
29019
29018
  ErrorCode2["TYPE_NOT_SUPPORTED"] = "type-not-supported";
@@ -29028,14 +29027,12 @@ This unreleased fuel-core build may include features and updates not yet support
29028
29027
  ErrorCode2["INVALID_BECH32_ADDRESS"] = "invalid-bech32-address";
29029
29028
  ErrorCode2["INVALID_EVM_ADDRESS"] = "invalid-evm-address";
29030
29029
  ErrorCode2["INVALID_B256_ADDRESS"] = "invalid-b256-address";
29031
- ErrorCode2["INVALID_URL"] = "invalid-url";
29032
29030
  ErrorCode2["CHAIN_INFO_CACHE_EMPTY"] = "chain-info-cache-empty";
29033
29031
  ErrorCode2["NODE_INFO_CACHE_EMPTY"] = "node-info-cache-empty";
29034
29032
  ErrorCode2["MISSING_PROVIDER"] = "missing-provider";
29035
29033
  ErrorCode2["INVALID_PROVIDER"] = "invalid-provider";
29036
29034
  ErrorCode2["CONNECTION_REFUSED"] = "connection-refused";
29037
29035
  ErrorCode2["INVALID_PUBLIC_KEY"] = "invalid-public-key";
29038
- ErrorCode2["INSUFFICIENT_BALANCE"] = "insufficient-balance";
29039
29036
  ErrorCode2["WALLET_MANAGER_ERROR"] = "wallet-manager-error";
29040
29037
  ErrorCode2["HD_WALLET_ERROR"] = "hd-wallet-error";
29041
29038
  ErrorCode2["MISSING_CONNECTOR"] = "missing-connector";
@@ -29052,7 +29049,6 @@ This unreleased fuel-core build may include features and updates not yet support
29052
29049
  ErrorCode2["ELEMENT_NOT_FOUND"] = "element-not-found";
29053
29050
  ErrorCode2["MISSING_REQUIRED_PARAMETER"] = "missing-required-parameter";
29054
29051
  ErrorCode2["INVALID_REQUEST"] = "invalid-request";
29055
- ErrorCode2["UNEXPECTED_HEX_VALUE"] = "unexpected-hex-value";
29056
29052
  ErrorCode2["INVALID_TRANSFER_AMOUNT"] = "invalid-transfer-amount";
29057
29053
  ErrorCode2["GAS_PRICE_TOO_LOW"] = "gas-price-too-low";
29058
29054
  ErrorCode2["GAS_LIMIT_TOO_LOW"] = "gas-limit-too-low";
@@ -29076,7 +29072,6 @@ This unreleased fuel-core build may include features and updates not yet support
29076
29072
  ErrorCode2["INVALID_PASSWORD"] = "invalid-password";
29077
29073
  ErrorCode2["ACCOUNT_REQUIRED"] = "account-required";
29078
29074
  ErrorCode2["UNLOCKED_WALLET_REQUIRED"] = "unlocked-wallet-required";
29079
- ErrorCode2["LATEST_BLOCK_UNAVAILABLE"] = "latest-block-unavailable";
29080
29075
  ErrorCode2["ERROR_BUILDING_BLOCK_EXPLORER_URL"] = "error-building-block-explorer-url";
29081
29076
  ErrorCode2["UNSUPPORTED_FUEL_CLIENT_VERSION"] = "unsupported-fuel-client-version";
29082
29077
  ErrorCode2["VITEPRESS_PLUGIN_ERROR"] = "vitepress-plugin-error";
@@ -29088,7 +29083,6 @@ This unreleased fuel-core build may include features and updates not yet support
29088
29083
  })(ErrorCode || {});
29089
29084
  var _FuelError = class extends Error {
29090
29085
  VERSIONS = versions;
29091
- metadata;
29092
29086
  static parse(e) {
29093
29087
  const error = e;
29094
29088
  if (error.code === void 0) {
@@ -29108,15 +29102,14 @@ This unreleased fuel-core build may include features and updates not yet support
29108
29102
  return new _FuelError(error.code, error.message);
29109
29103
  }
29110
29104
  code;
29111
- constructor(code, message, metadata = {}) {
29105
+ constructor(code, message) {
29112
29106
  super(message);
29113
29107
  this.code = code;
29114
29108
  this.name = "FuelError";
29115
- this.metadata = metadata;
29116
29109
  }
29117
29110
  toObject() {
29118
- const { code, name, message, metadata, VERSIONS } = this;
29119
- return { code, name, message, metadata, VERSIONS };
29111
+ const { code, name, message, VERSIONS } = this;
29112
+ return { code, name, message, VERSIONS };
29120
29113
  }
29121
29114
  };
29122
29115
  var FuelError = _FuelError;
@@ -31276,10 +31269,6 @@ This unreleased fuel-core build may include features and updates not yet support
31276
31269
  }
31277
31270
  };
31278
31271
 
31279
- // ../address/dist/configs.mjs
31280
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
31281
- var BaseAssetId = ZeroBytes32;
31282
-
31283
31272
  // ../math/dist/index.mjs
31284
31273
  var import_bn = __toESM(require_bn(), 1);
31285
31274
  var DEFAULT_PRECISION = 9;
@@ -31510,11 +31499,11 @@ This unreleased fuel-core build may include features and updates not yet support
31510
31499
  let max2;
31511
31500
  if (Array.isArray(coinQuantityLike)) {
31512
31501
  amount = coinQuantityLike[0];
31513
- assetId = coinQuantityLike[1] ?? BaseAssetId;
31514
- max2 = coinQuantityLike[2] ?? void 0;
31502
+ assetId = coinQuantityLike[1];
31503
+ max2 = coinQuantityLike[2];
31515
31504
  } else {
31516
31505
  amount = coinQuantityLike.amount;
31517
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
31506
+ assetId = coinQuantityLike.assetId;
31518
31507
  max2 = coinQuantityLike.max ?? void 0;
31519
31508
  }
31520
31509
  const bnAmount = bn(amount);
@@ -33224,16 +33213,10 @@ This unreleased fuel-core build may include features and updates not yet support
33224
33213
  }
33225
33214
  decodeFunctionData(functionFragment, data) {
33226
33215
  const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
33227
- if (!fragment) {
33228
- throw new FuelError(ErrorCode.FRAGMENT_NOT_FOUND, "Fragment not found.");
33229
- }
33230
33216
  return fragment.decodeArguments(data);
33231
33217
  }
33232
33218
  encodeFunctionData(functionFragment, values, offset = 0) {
33233
33219
  const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
33234
- if (!fragment) {
33235
- throw new FuelError(ErrorCode.FRAGMENT_NOT_FOUND, "Fragment not found.");
33236
- }
33237
33220
  return fragment.encodeArguments(values, offset);
33238
33221
  }
33239
33222
  // Decode the result of a function call
@@ -38830,6 +38813,9 @@ ${MessageCoinFragmentFragmentDoc}`;
38830
38813
  }
38831
38814
  };
38832
38815
 
38816
+ // ../address/dist/configs.mjs
38817
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38818
+
38833
38819
  // src/providers/transaction-request/input.ts
38834
38820
  var inputify = (value) => {
38835
38821
  const { type: type3 } = value;
@@ -38964,60 +38950,7 @@ ${MessageCoinFragmentFragmentDoc}`;
38964
38950
  var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
38965
38951
  var MAX_PREDICATE_LENGTH = 1024 * 1024;
38966
38952
  var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
38967
- var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
38968
38953
  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";
39021
38954
 
39022
38955
  // src/providers/utils/receipts.ts
39023
38956
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
@@ -39391,74 +39324,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39391
39324
  });
39392
39325
  }
39393
39326
 
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
-
39462
39327
  // src/providers/transaction-request/errors.ts
39463
39328
  var ChangeOutputCollisionError = class extends Error {
39464
39329
  name = "ChangeOutputCollisionError";
@@ -39506,6 +39371,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39506
39371
  outputs = [];
39507
39372
  /** List of witnesses */
39508
39373
  witnesses = [];
39374
+ /** Base asset ID - should be fetched from the chain */
39375
+ baseAssetId = ZeroBytes32;
39509
39376
  /**
39510
39377
  * Constructor for initializing a base transaction request.
39511
39378
  *
@@ -39518,7 +39385,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39518
39385
  witnessLimit,
39519
39386
  inputs,
39520
39387
  outputs,
39521
- witnesses
39388
+ witnesses,
39389
+ baseAssetId
39522
39390
  } = {}) {
39523
39391
  this.gasPrice = bn(gasPrice);
39524
39392
  this.maturity = maturity ?? 0;
@@ -39527,6 +39395,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39527
39395
  this.inputs = inputs ?? [];
39528
39396
  this.outputs = outputs ?? [];
39529
39397
  this.witnesses = witnesses ?? [];
39398
+ this.baseAssetId = baseAssetId ?? ZeroBytes32;
39530
39399
  }
39531
39400
  static getPolicyMeta(req) {
39532
39401
  let policyTypes = 0;
@@ -39751,11 +39620,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39751
39620
  *
39752
39621
  * @param message - Message resource.
39753
39622
  * @param predicate - Predicate bytes.
39754
- * @param predicateData - Predicate data bytes.
39755
39623
  */
39756
39624
  addMessageInput(message, predicate) {
39757
39625
  const { recipient, sender, amount } = message;
39758
- const assetId = BaseAssetId;
39759
39626
  let witnessIndex;
39760
39627
  if (predicate) {
39761
39628
  witnessIndex = 0;
@@ -39776,7 +39643,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39776
39643
  predicateData: predicate?.predicateDataBytes
39777
39644
  };
39778
39645
  this.pushInput(input);
39779
- this.addChangeOutput(recipient, assetId);
39646
+ this.addChangeOutput(recipient, this.baseAssetId);
39780
39647
  }
39781
39648
  /**
39782
39649
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39837,12 +39704,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39837
39704
  * @param amount - Amount of coin.
39838
39705
  * @param assetId - Asset ID of coin.
39839
39706
  */
39840
- addCoinOutput(to, amount, assetId = BaseAssetId) {
39707
+ addCoinOutput(to, amount, assetId) {
39841
39708
  this.pushOutput({
39842
39709
  type: OutputType.Coin,
39843
39710
  to: addressify(to).toB256(),
39844
39711
  amount,
39845
- assetId
39712
+ assetId: assetId ?? this.baseAssetId
39846
39713
  });
39847
39714
  return this;
39848
39715
  }
@@ -39869,7 +39736,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39869
39736
  * @param to - Address of the owner.
39870
39737
  * @param assetId - Asset ID of coin.
39871
39738
  */
39872
- addChangeOutput(to, assetId = BaseAssetId) {
39739
+ addChangeOutput(to, assetId) {
39873
39740
  const changeOutput = this.getChangeOutputs().find(
39874
39741
  (output3) => hexlify(output3.assetId) === assetId
39875
39742
  );
@@ -39877,7 +39744,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39877
39744
  this.pushOutput({
39878
39745
  type: OutputType.Change,
39879
39746
  to: addressify(to).toB256(),
39880
- assetId
39747
+ assetId: assetId ?? this.baseAssetId
39881
39748
  });
39882
39749
  }
39883
39750
  }
@@ -39959,7 +39826,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39959
39826
  ]);
39960
39827
  }
39961
39828
  };
39962
- updateAssetInput(BaseAssetId, bn(1e11));
39829
+ updateAssetInput(this.baseAssetId, bn(1e11));
39963
39830
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
39964
39831
  }
39965
39832
  /**
@@ -41275,26 +41142,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41275
41142
  gqlTransaction: this.gqlTransaction,
41276
41143
  ...transactionSummary
41277
41144
  };
41278
- let logs = [];
41279
41145
  if (this.abis) {
41280
- logs = getDecodedLogs(
41146
+ const logs = getDecodedLogs(
41281
41147
  transactionSummary.receipts,
41282
41148
  this.abis.main,
41283
41149
  this.abis.otherContractsAbis
41284
41150
  );
41285
41151
  transactionResult.logs = logs;
41286
41152
  }
41287
- if (transactionResult.isStatusFailure) {
41288
- const {
41289
- receipts,
41290
- gqlTransaction: { status }
41291
- } = transactionResult;
41292
- throw extractTxError({
41293
- receipts,
41294
- status,
41295
- logs
41296
- });
41297
- }
41298
41153
  return transactionResult;
41299
41154
  }
41300
41155
  /**
@@ -41303,7 +41158,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41303
41158
  * @param contractsAbiMap - The contracts ABI map.
41304
41159
  */
41305
41160
  async wait(contractsAbiMap) {
41306
- return this.waitForResult(contractsAbiMap);
41161
+ const result = await this.waitForResult(contractsAbiMap);
41162
+ if (result.isStatusFailure) {
41163
+ throw new FuelError(
41164
+ ErrorCode.TRANSACTION_FAILED,
41165
+ `Transaction failed: ${result.gqlTransaction.status.reason}`
41166
+ );
41167
+ }
41168
+ return result;
41307
41169
  }
41308
41170
  };
41309
41171
 
@@ -41382,6 +41244,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41382
41244
  gasPerByte: bn(feeParams.gasPerByte),
41383
41245
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41384
41246
  chainId: bn(consensusParameters.chainId),
41247
+ baseAssetId: consensusParameters.baseAssetId,
41385
41248
  gasCosts
41386
41249
  },
41387
41250
  gasCosts,
@@ -41624,6 +41487,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41624
41487
  } = this.getChain();
41625
41488
  return chainId.toNumber();
41626
41489
  }
41490
+ /**
41491
+ * Returns the base asset ID
41492
+ *
41493
+ * @returns A promise that resolves to the base asset ID
41494
+ */
41495
+ getBaseAssetId() {
41496
+ const {
41497
+ consensusParameters: { baseAssetId }
41498
+ } = this.getChain();
41499
+ return baseAssetId;
41500
+ }
41627
41501
  /**
41628
41502
  * Submits a transaction to the chain to be executed.
41629
41503
  *
@@ -42653,8 +42527,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42653
42527
  * @param assetId - The asset ID to check the balance for.
42654
42528
  * @returns A promise that resolves to the balance amount.
42655
42529
  */
42656
- async getBalance(assetId = BaseAssetId) {
42657
- const amount = await this.provider.getBalance(this.address, assetId);
42530
+ async getBalance(assetId) {
42531
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42532
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42658
42533
  return amount;
42659
42534
  }
42660
42535
  /**
@@ -42692,9 +42567,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42692
42567
  * @returns A promise that resolves when the resources are added to the transaction.
42693
42568
  */
42694
42569
  async fund(request, coinQuantities, fee) {
42570
+ const baseAssetId = this.provider.getBaseAssetId();
42695
42571
  const updatedQuantities = addAmountToAsset({
42696
42572
  amount: bn(fee),
42697
- assetId: BaseAssetId,
42573
+ assetId: baseAssetId,
42698
42574
  coinQuantities
42699
42575
  });
42700
42576
  const quantitiesDict = {};
@@ -42718,8 +42594,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42718
42594
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42719
42595
  cachedUtxos.push(input.id);
42720
42596
  }
42721
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42722
- quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42597
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42598
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42723
42599
  cachedMessages.push(input.nonce);
42724
42600
  }
42725
42601
  }
@@ -42751,11 +42627,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42751
42627
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42752
42628
  * @returns A promise that resolves to the prepared transaction request.
42753
42629
  */
42754
- async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42630
+ async createTransfer(destination, amount, assetId, txParams = {}) {
42755
42631
  const { minGasPrice } = this.provider.getGasConfig();
42632
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42756
42633
  const params = { gasPrice: minGasPrice, ...txParams };
42757
42634
  const request = new ScriptTransactionRequest(params);
42758
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42635
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42759
42636
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
42760
42637
  estimateTxDependencies: true,
42761
42638
  resourcesOwner: this
@@ -42781,14 +42658,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42781
42658
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42782
42659
  * @returns A promise that resolves to the transaction response.
42783
42660
  */
42784
- async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42661
+ async transfer(destination, amount, assetId, txParams = {}) {
42785
42662
  if (bn(amount).lte(0)) {
42786
42663
  throw new FuelError(
42787
42664
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42788
42665
  "Transfer amount must be a positive number."
42789
42666
  );
42790
42667
  }
42791
- const request = await this.createTransfer(destination, amount, assetId, txParams);
42668
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42669
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42792
42670
  return this.sendTransaction(request, { estimateTxDependencies: false });
42793
42671
  }
42794
42672
  /**
@@ -42800,7 +42678,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42800
42678
  * @param txParams - The optional transaction parameters.
42801
42679
  * @returns A promise that resolves to the transaction response.
42802
42680
  */
42803
- async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42681
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
42804
42682
  if (bn(amount).lte(0)) {
42805
42683
  throw new FuelError(
42806
42684
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42809,11 +42687,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42809
42687
  }
42810
42688
  const contractAddress = Address.fromAddressOrString(contractId);
42811
42689
  const { minGasPrice } = this.provider.getGasConfig();
42690
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42812
42691
  const params = { gasPrice: minGasPrice, ...txParams };
42813
42692
  const { script, scriptData } = await assembleTransferToContractScript({
42814
42693
  hexlifiedContractId: contractAddress.toB256(),
42815
42694
  amountToTransfer: bn(amount),
42816
- assetId
42695
+ assetId: assetIdToTransfer
42817
42696
  });
42818
42697
  const request = new ScriptTransactionRequest({
42819
42698
  ...params,
@@ -42823,7 +42702,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42823
42702
  request.addContractInputAndOutput(contractAddress);
42824
42703
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42825
42704
  request,
42826
- [{ amount: bn(amount), assetId: String(assetId) }]
42705
+ [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42827
42706
  );
42828
42707
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
42829
42708
  this.validateGas({
@@ -42845,6 +42724,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42845
42724
  */
42846
42725
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42847
42726
  const { minGasPrice } = this.provider.getGasConfig();
42727
+ const baseAssetId = this.provider.getBaseAssetId();
42848
42728
  const recipientAddress = Address.fromAddressOrString(recipient);
42849
42729
  const recipientDataArray = arrayify(
42850
42730
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42859,7 +42739,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42859
42739
  ]);
42860
42740
  const params = { script, gasPrice: minGasPrice, ...txParams };
42861
42741
  const request = new ScriptTransactionRequest(params);
42862
- const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42742
+ const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42863
42743
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42864
42744
  request,
42865
42745
  forwardingQuantities
@@ -47823,8 +47703,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47823
47703
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47824
47704
  * @returns A promise that resolves to the prepared transaction request.
47825
47705
  */
47826
- async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47827
- const request = await super.createTransfer(destination, amount, assetId, txParams);
47706
+ async createTransfer(destination, amount, assetId, txParams = {}) {
47707
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47708
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47828
47709
  return this.populateTransactionPredicateData(request);
47829
47710
  }
47830
47711
  /**