@fuel-ts/account 0.101.1 → 0.101.2

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.
package/dist/index.js CHANGED
@@ -88,6 +88,7 @@ __export(src_exports, {
88
88
  assemblePreConfirmationTransactionSummary: () => assemblePreConfirmationTransactionSummary,
89
89
  assembleReceiptByType: () => assembleReceiptByType,
90
90
  assembleRevertError: () => assembleRevertError,
91
+ assembleSignalErrorMessage: () => assembleSignalErrorMessage,
91
92
  assembleTransactionSummary: () => assembleTransactionSummary,
92
93
  assembleTransactionSummaryFromJson: () => assembleTransactionSummaryFromJson,
93
94
  assets: () => assets,
@@ -927,13 +928,13 @@ var getAssetsByOwner = /* @__PURE__ */ __name(async (opts) => {
927
928
  }, "getAssetsByOwner");
928
929
 
929
930
  // src/account.ts
930
- var import_abi_coder7 = require("@fuel-ts/abi-coder");
931
+ var import_abi_coder9 = require("@fuel-ts/abi-coder");
931
932
  var import_address5 = require("@fuel-ts/address");
932
933
  var import_crypto2 = require("@fuel-ts/crypto");
933
934
  var import_errors22 = require("@fuel-ts/errors");
934
935
  var import_math22 = require("@fuel-ts/math");
935
936
  var import_transactions28 = require("@fuel-ts/transactions");
936
- var import_utils36 = require("@fuel-ts/utils");
937
+ var import_utils37 = require("@fuel-ts/utils");
937
938
  var import_ramda9 = require("ramda");
938
939
 
939
940
  // src/providers/coin-quantity.ts
@@ -975,7 +976,7 @@ var import_address3 = require("@fuel-ts/address");
975
976
  var import_errors20 = require("@fuel-ts/errors");
976
977
  var import_math19 = require("@fuel-ts/math");
977
978
  var import_transactions25 = require("@fuel-ts/transactions");
978
- var import_utils31 = require("@fuel-ts/utils");
979
+ var import_utils32 = require("@fuel-ts/utils");
979
980
  var import_versions = require("@fuel-ts/versions");
980
981
  var import_graphql_request = require("graphql-request");
981
982
  var import_graphql_tag2 = __toESM(require("graphql-tag"));
@@ -3482,58 +3483,97 @@ ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
3482
3483
  });
3483
3484
  }, "assemblePanicError");
3484
3485
  var stringify = /* @__PURE__ */ __name((obj) => JSON.stringify(obj, null, 2), "stringify");
3485
- var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
3486
+ var assembleSignalErrorMessage = /* @__PURE__ */ __name((reasonHex, logs, metadata) => {
3486
3487
  let errorMessage = "The transaction reverted with an unknown reason.";
3487
- const revertReceipt = receipts.find(({ type }) => type === import_transactions7.ReceiptType.Revert);
3488
3488
  let reason = "";
3489
- if (revertReceipt) {
3490
- const reasonHex = (0, import_math7.bn)(revertReceipt.val).toHex();
3491
- const lastLog = logs[logs.length - 1];
3492
- const lastButOneLog = logs[logs.length - 2];
3493
- switch (reasonHex) {
3494
- case import_configs5.FAILED_REQUIRE_SIGNAL: {
3495
- reason = "require";
3496
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
3497
- break;
3498
- }
3499
- case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
3500
- const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
3501
- reason = "assert_eq";
3502
- errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
3503
- break;
3504
- }
3505
- case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
3506
- const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
3507
- reason = "assert_ne";
3508
- errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
3509
- break;
3510
- }
3511
- case import_configs5.FAILED_ASSERT_SIGNAL:
3512
- reason = "assert";
3513
- errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
3514
- break;
3515
- case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
3516
- reason = "MissingOutputVariable";
3517
- errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
3518
- break;
3519
- default:
3520
- throw new import_errors8.FuelError(
3521
- import_errors8.ErrorCode.UNKNOWN,
3522
- `The transaction reverted with an unknown reason: ${revertReceipt.val}`,
3523
- {
3524
- ...metadata,
3525
- reason: "unknown"
3526
- }
3527
- );
3489
+ const lastLog = logs[logs.length - 1];
3490
+ const lastButOneLog = logs[logs.length - 2];
3491
+ switch (reasonHex) {
3492
+ case import_configs5.FAILED_REQUIRE_SIGNAL: {
3493
+ reason = "require";
3494
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
3495
+ break;
3496
+ }
3497
+ case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
3498
+ const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
3499
+ reason = "assert_eq";
3500
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
3501
+ break;
3502
+ }
3503
+ case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
3504
+ const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
3505
+ reason = "assert_ne";
3506
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
3507
+ break;
3508
+ }
3509
+ case import_configs5.FAILED_ASSERT_SIGNAL:
3510
+ reason = "assert";
3511
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
3512
+ break;
3513
+ case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
3514
+ reason = "MissingOutputVariable";
3515
+ errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
3516
+ break;
3517
+ default:
3518
+ reason = `revert_with_log`;
3519
+ errorMessage = `The transaction reverted because a "revert_with_log" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
3520
+ break;
3521
+ }
3522
+ return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
3523
+ ...metadata,
3524
+ reason
3525
+ });
3526
+ }, "assembleSignalErrorMessage");
3527
+ function buildAbiErrorMessage(abiError, logs, metadata, reason) {
3528
+ const { pos, msg } = abiError;
3529
+ let errorMessage = "";
3530
+ const positionMessage = pos ? `
3531
+
3532
+ This error originated at ${JSON.stringify(pos, null, 2)}` : "";
3533
+ if (msg) {
3534
+ errorMessage = `A sway "panic" expression was invoked with the message: "${msg}".${positionMessage}`;
3535
+ } else {
3536
+ const value = logs[logs.length - 1];
3537
+ errorMessage = `A sway "panic" expression was invoked with the value: ${JSON.stringify(value)}.${positionMessage}`;
3538
+ }
3539
+ return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
3540
+ ...metadata,
3541
+ reason
3542
+ });
3543
+ }
3544
+ __name(buildAbiErrorMessage, "buildAbiErrorMessage");
3545
+ function findErrorInAbis(statusReason, abis = []) {
3546
+ for (const abi of abis) {
3547
+ if (abi.errorCodes?.[statusReason]) {
3548
+ return abi.errorCodes[statusReason];
3528
3549
  }
3529
3550
  }
3551
+ return void 0;
3552
+ }
3553
+ __name(findErrorInAbis, "findErrorInAbis");
3554
+ var assembleRevertError = /* @__PURE__ */ __name((_receipts, logs, metadata, statusReason, abis) => {
3555
+ const match = statusReason.match(/Revert\((\d+)\)/);
3556
+ const reason = match?.[1] ?? statusReason;
3557
+ const reasonHex = (0, import_math7.bn)(reason).toHex();
3558
+ if (Object.values(import_configs5.SwaySignalErrors).includes(reasonHex)) {
3559
+ return assembleSignalErrorMessage(reasonHex, logs, metadata);
3560
+ }
3561
+ let abiError;
3562
+ if (abis) {
3563
+ const abisArr = [abis.main, ...Object.values(abis.otherContractsAbis)];
3564
+ abiError = findErrorInAbis(reason, abisArr);
3565
+ }
3566
+ if (abiError) {
3567
+ return buildAbiErrorMessage(abiError, logs, metadata, reason);
3568
+ }
3569
+ const errorMessage = `The transaction reverted with reason: ${reason}.`;
3530
3570
  return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
3531
3571
  ...metadata,
3532
3572
  reason
3533
3573
  });
3534
3574
  }, "assembleRevertError");
3535
3575
  var extractTxError = /* @__PURE__ */ __name((params) => {
3536
- const { receipts, statusReason, logs, groupedLogs } = params;
3576
+ const { receipts, statusReason, logs, groupedLogs, abis } = params;
3537
3577
  const isPanic = receipts.some(({ type }) => type === import_transactions7.ReceiptType.Panic);
3538
3578
  const isRevert = receipts.some(({ type }) => type === import_transactions7.ReceiptType.Revert);
3539
3579
  const metadata = {
@@ -3547,7 +3587,7 @@ var extractTxError = /* @__PURE__ */ __name((params) => {
3547
3587
  if (isPanic) {
3548
3588
  return assemblePanicError(statusReason, metadata);
3549
3589
  }
3550
- return assembleRevertError(receipts, logs, metadata);
3590
+ return assembleRevertError(receipts, logs, metadata, statusReason, abis);
3551
3591
  }, "extractTxError");
3552
3592
 
3553
3593
  // src/providers/utils/merge-quantities.ts
@@ -5133,12 +5173,12 @@ var ResourceCache = class {
5133
5173
  var import_errors18 = require("@fuel-ts/errors");
5134
5174
  var import_math18 = require("@fuel-ts/math");
5135
5175
  var import_transactions23 = require("@fuel-ts/transactions");
5136
- var import_utils28 = require("@fuel-ts/utils");
5176
+ var import_utils29 = require("@fuel-ts/utils");
5137
5177
 
5138
5178
  // src/providers/transaction-summary/assemble-transaction-summary.ts
5139
5179
  var import_math17 = require("@fuel-ts/math");
5140
5180
  var import_transactions21 = require("@fuel-ts/transactions");
5141
- var import_utils26 = require("@fuel-ts/utils");
5181
+ var import_utils27 = require("@fuel-ts/utils");
5142
5182
 
5143
5183
  // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
5144
5184
  var import_math13 = require("@fuel-ts/math");
@@ -5211,6 +5251,45 @@ var import_configs11 = require("@fuel-ts/address/configs");
5211
5251
  var import_errors16 = require("@fuel-ts/errors");
5212
5252
  var import_math15 = require("@fuel-ts/math");
5213
5253
  var import_transactions19 = require("@fuel-ts/transactions");
5254
+ var import_utils25 = require("@fuel-ts/utils");
5255
+
5256
+ // src/providers/transaction-summary/call.ts
5257
+ var import_abi_coder4 = require("@fuel-ts/abi-coder");
5258
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
5259
+ var getFunctionCall = /* @__PURE__ */ __name(({
5260
+ abi,
5261
+ receipt,
5262
+ offset,
5263
+ scriptData
5264
+ }) => {
5265
+ const [functionSelector, argumentsOffset] = new import_abi_coder4.StdStringCoder().decode(scriptData, offset);
5266
+ const abiInterface = new import_abi_coder5.Interface(abi);
5267
+ const functionFragment = abiInterface.getFunction(functionSelector);
5268
+ const inputs = functionFragment.jsonFn.inputs;
5269
+ let argumentsProvided;
5270
+ if (inputs.length) {
5271
+ const functionArgsBytes = scriptData.slice(argumentsOffset);
5272
+ const decodedArguments = functionFragment.decodeArguments(functionArgsBytes);
5273
+ argumentsProvided = inputs.reduce((prev, input, index) => {
5274
+ const value = decodedArguments?.[index];
5275
+ const name = input.name;
5276
+ if (name) {
5277
+ return {
5278
+ ...prev,
5279
+ // reparse to remove bn
5280
+ [name]: JSON.parse(JSON.stringify(value))
5281
+ };
5282
+ }
5283
+ return prev;
5284
+ }, {});
5285
+ }
5286
+ return {
5287
+ functionSignature: functionFragment.signature,
5288
+ functionName: functionFragment.name,
5289
+ argumentsProvided,
5290
+ ...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
5291
+ };
5292
+ }, "getFunctionCall");
5214
5293
 
5215
5294
  // src/providers/transaction-summary/input.ts
5216
5295
  var import_errors15 = require("@fuel-ts/errors");
@@ -5545,12 +5624,45 @@ function getWithdrawFromFuelOperations({
5545
5624
  return withdrawFromFuelOperations;
5546
5625
  }
5547
5626
  __name(getWithdrawFromFuelOperations, "getWithdrawFromFuelOperations");
5548
- function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
5549
- const abi = abiMap?.[contractInput.contractID];
5550
- if (!abi) {
5551
- return [];
5627
+ function findBytesSegmentIndex(whole, segment) {
5628
+ for (let i = 0; i <= whole.length - segment.length; i++) {
5629
+ let match = true;
5630
+ for (let j = 0; j < segment.length; j++) {
5631
+ if (whole[i + j] !== segment[j]) {
5632
+ match = false;
5633
+ break;
5634
+ }
5635
+ }
5636
+ if (match) {
5637
+ return i;
5638
+ }
5552
5639
  }
5553
- return [];
5640
+ return -1;
5641
+ }
5642
+ __name(findBytesSegmentIndex, "findBytesSegmentIndex");
5643
+ function getContractCalls(contractInput, abiMap, receipt, scriptData) {
5644
+ const calls = [];
5645
+ const abi = abiMap?.[contractInput.contractID];
5646
+ if (!abi || !scriptData) {
5647
+ return calls;
5648
+ }
5649
+ const bytesSegment = (0, import_utils25.concat)([
5650
+ (0, import_utils25.arrayify)(receipt.to),
5651
+ // Contract ID (32 bytes)
5652
+ (0, import_math15.toBytes)(receipt.param1.toHex(), 8),
5653
+ // Function selector offset (8 bytes)
5654
+ (0, import_math15.toBytes)(receipt.param2.toHex(), 8)
5655
+ // Function args offset (8 bytes)
5656
+ ]);
5657
+ const segmentIndex = findBytesSegmentIndex(scriptData, bytesSegment);
5658
+ const canDecodeFunctionCall = segmentIndex !== -1;
5659
+ if (!canDecodeFunctionCall) {
5660
+ return calls;
5661
+ }
5662
+ const offset = segmentIndex + bytesSegment.length;
5663
+ const call = getFunctionCall({ abi, receipt, offset, scriptData });
5664
+ calls.push(call);
5665
+ return calls;
5554
5666
  }
5555
5667
  __name(getContractCalls, "getContractCalls");
5556
5668
  function getAssetsSent(receipt) {
@@ -5562,14 +5674,14 @@ function getAssetsSent(receipt) {
5562
5674
  ];
5563
5675
  }
5564
5676
  __name(getAssetsSent, "getAssetsSent");
5565
- function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
5677
+ function processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId) {
5566
5678
  const assetId = receipt.assetId === import_configs11.ZeroBytes32 ? baseAssetId : receipt.assetId;
5567
5679
  const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
5568
5680
  if (!input) {
5569
5681
  return [];
5570
5682
  }
5571
5683
  const inputAddress = getInputAccountAddress(input);
5572
- const calls = getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs);
5684
+ const calls = getContractCalls(contractInput, abiMap, receipt, scriptData);
5573
5685
  return [
5574
5686
  {
5575
5687
  name: "Contract call" /* contractCall */,
@@ -5594,7 +5706,6 @@ function getContractCallOperations({
5594
5706
  receipts,
5595
5707
  abiMap,
5596
5708
  rawPayload,
5597
- maxInputs,
5598
5709
  baseAssetId
5599
5710
  }) {
5600
5711
  const contractCallReceipts = getReceiptsCall(receipts);
@@ -5604,16 +5715,15 @@ function getContractCallOperations({
5604
5715
  if (!contractInput) {
5605
5716
  return [];
5606
5717
  }
5718
+ let scriptData;
5719
+ if (rawPayload) {
5720
+ const [transaction] = new import_transactions19.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5721
+ if (transaction.type === import_transactions19.TransactionType.Script) {
5722
+ scriptData = (0, import_utils25.arrayify)(transaction.scriptData);
5723
+ }
5724
+ }
5607
5725
  return contractCallReceipts.filter((receipt) => receipt.to === contractInput.contractID).flatMap(
5608
- (receipt) => processCallReceipt(
5609
- receipt,
5610
- contractInput,
5611
- inputs,
5612
- abiMap,
5613
- rawPayload,
5614
- maxInputs,
5615
- baseAssetId
5616
- )
5726
+ (receipt) => processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId)
5617
5727
  );
5618
5728
  });
5619
5729
  }
@@ -5938,7 +6048,7 @@ function assembleTransactionSummary(params) {
5938
6048
  baseAssetId
5939
6049
  } = params;
5940
6050
  const gasUsed = getGasUsedFromReceipts(receipts);
5941
- const rawPayload = (0, import_utils26.hexlify)(transactionBytes);
6051
+ const rawPayload = (0, import_utils27.hexlify)(transactionBytes);
5942
6052
  const operations = getOperations({
5943
6053
  transactionType: transaction.type,
5944
6054
  inputs: transaction.inputs || [],
@@ -5969,7 +6079,7 @@ function assembleTransactionSummary(params) {
5969
6079
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
5970
6080
  let date;
5971
6081
  if (time) {
5972
- date = import_utils26.DateTime.fromTai64(time);
6082
+ date = import_utils27.DateTime.fromTai64(time);
5973
6083
  }
5974
6084
  const transactionSummary = {
5975
6085
  id,
@@ -6030,7 +6140,7 @@ function assemblePreConfirmationTransactionSummary(params) {
6030
6140
  type = getTransactionTypeName(transaction.type);
6031
6141
  tip = (0, import_math17.bn)(transaction.policies?.find((policy) => policy.type === import_transactions21.PolicyType.Tip)?.data);
6032
6142
  if (receipts) {
6033
- const rawPayload = (0, import_utils26.hexlify)(new import_transactions21.TransactionCoder().encode(transaction));
6143
+ const rawPayload = (0, import_utils27.hexlify)(new import_transactions21.TransactionCoder().encode(transaction));
6034
6144
  operations = getOperations({
6035
6145
  transactionType: transaction.type,
6036
6146
  inputs: transaction.inputs || [],
@@ -6076,7 +6186,7 @@ function assemblePreConfirmationTransactionSummary(params) {
6076
6186
  __name(assemblePreConfirmationTransactionSummary, "assemblePreConfirmationTransactionSummary");
6077
6187
 
6078
6188
  // src/providers/transaction-response/getAllDecodedLogs.ts
6079
- var import_abi_coder4 = require("@fuel-ts/abi-coder");
6189
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
6080
6190
  var import_configs12 = require("@fuel-ts/address/configs");
6081
6191
  var import_transactions22 = require("@fuel-ts/transactions");
6082
6192
  function getAllDecodedLogs(opts) {
@@ -6096,8 +6206,8 @@ function getAllDecodedLogs(opts) {
6096
6206
  const isLogFromMainAbi = receipt.id === import_configs12.ZeroBytes32 || mainContract === receipt.id;
6097
6207
  const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
6098
6208
  if (isDecodable) {
6099
- const interfaceToUse = isLogFromMainAbi ? new import_abi_coder4.Interface(mainAbi) : new import_abi_coder4.Interface(externalAbis[receipt.id]);
6100
- const data = receipt.type === import_transactions22.ReceiptType.Log ? new import_abi_coder4.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
6209
+ const interfaceToUse = isLogFromMainAbi ? new import_abi_coder6.Interface(mainAbi) : new import_abi_coder6.Interface(externalAbis[receipt.id]);
6210
+ const data = receipt.type === import_transactions22.ReceiptType.Log ? new import_abi_coder6.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
6101
6211
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
6102
6212
  logs.push(decodedLog);
6103
6213
  groupedLogs[receipt.id] = [...groupedLogs[receipt.id] || [], decodedLog];
@@ -6196,7 +6306,7 @@ var TransactionResponse = class _TransactionResponse {
6196
6306
  }
6197
6307
  const gqlTransaction = this.gqlTransaction ?? await this.fetch();
6198
6308
  const { rawPayload } = gqlTransaction;
6199
- const bytes = (0, import_utils28.arrayify)(rawPayload);
6309
+ const bytes = (0, import_utils29.arrayify)(rawPayload);
6200
6310
  const [tx] = new import_transactions23.TransactionCoder().decode(bytes, 0);
6201
6311
  return {
6202
6312
  tx,
@@ -6384,6 +6494,7 @@ var TransactionResponse = class _TransactionResponse {
6384
6494
  ...transactionSummary
6385
6495
  };
6386
6496
  let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
6497
+ let abis;
6387
6498
  if (this.abis) {
6388
6499
  ({ logs, groupedLogs } = getAllDecodedLogs({
6389
6500
  receipts: transactionSummary.receipts,
@@ -6392,6 +6503,7 @@ var TransactionResponse = class _TransactionResponse {
6392
6503
  }));
6393
6504
  transactionResult.logs = logs;
6394
6505
  transactionResult.groupedLogs = groupedLogs;
6506
+ abis = this.abis;
6395
6507
  }
6396
6508
  const { receipts } = transactionResult;
6397
6509
  const status = this.getTransactionStatus();
@@ -6401,7 +6513,8 @@ var TransactionResponse = class _TransactionResponse {
6401
6513
  receipts,
6402
6514
  statusReason: reason,
6403
6515
  logs,
6404
- groupedLogs
6516
+ groupedLogs,
6517
+ abis
6405
6518
  });
6406
6519
  }
6407
6520
  return transactionResult;
@@ -6463,7 +6576,7 @@ var TransactionResponse = class _TransactionResponse {
6463
6576
  };
6464
6577
 
6465
6578
  // src/providers/transaction-response/getDecodedLogs.ts
6466
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
6579
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
6467
6580
  var import_configs13 = require("@fuel-ts/address/configs");
6468
6581
  var import_transactions24 = require("@fuel-ts/transactions");
6469
6582
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
@@ -6479,8 +6592,8 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
6479
6592
  const isLogFromMainAbi = receipt.id === import_configs13.ZeroBytes32 || mainContract === receipt.id;
6480
6593
  const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
6481
6594
  if (isDecodable) {
6482
- const interfaceToUse = isLogFromMainAbi ? new import_abi_coder5.Interface(mainAbi) : new import_abi_coder5.Interface(externalAbis[receipt.id]);
6483
- const data = receipt.type === import_transactions24.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
6595
+ const interfaceToUse = isLogFromMainAbi ? new import_abi_coder7.Interface(mainAbi) : new import_abi_coder7.Interface(externalAbis[receipt.id]);
6596
+ const data = receipt.type === import_transactions24.ReceiptType.Log ? new import_abi_coder7.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
6484
6597
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
6485
6598
  logs.push(decodedLog);
6486
6599
  }
@@ -6491,7 +6604,7 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
6491
6604
  __name(getDecodedLogs, "getDecodedLogs");
6492
6605
 
6493
6606
  // src/providers/utils/auto-retry-fetch.ts
6494
- var import_utils30 = require("@fuel-ts/utils");
6607
+ var import_utils31 = require("@fuel-ts/utils");
6495
6608
  function getWaitDelay(options, retryAttemptNum) {
6496
6609
  const duration = options.baseDelay ?? 150;
6497
6610
  switch (options.backoff) {
@@ -6522,7 +6635,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
6522
6635
  throw error;
6523
6636
  }
6524
6637
  const delay = getWaitDelay(options, retryNum);
6525
- await (0, import_utils30.sleep)(delay);
6638
+ await (0, import_utils31.sleep)(delay);
6526
6639
  return autoRetryFetch(fetchFn, options, retryNum)(...args);
6527
6640
  }
6528
6641
  };
@@ -6662,7 +6775,7 @@ var Provider = class _Provider {
6662
6775
  return url.replace(/-sub$/, "");
6663
6776
  }
6664
6777
  static hasWriteOperationHappened(url) {
6665
- return (0, import_utils31.isDefined)(_Provider.currentBlockHeightCache[this.normalizeUrl(url)]);
6778
+ return (0, import_utils32.isDefined)(_Provider.currentBlockHeightCache[this.normalizeUrl(url)]);
6666
6779
  }
6667
6780
  /**
6668
6781
  * @hidden
@@ -6717,14 +6830,14 @@ var Provider = class _Provider {
6717
6830
  }
6718
6831
  const retryAttempt = retryOptions.maxRetries - retriesLeft + 1;
6719
6832
  const sleepTime = getWaitDelay(retryOptions, retryAttempt);
6720
- await (0, import_utils31.sleep)(sleepTime);
6833
+ await (0, import_utils32.sleep)(sleepTime);
6721
6834
  response = await fetchFn();
6722
6835
  }
6723
6836
  return response;
6724
6837
  }
6725
6838
  static setCurrentBlockHeight(url, height) {
6726
6839
  const writeOperationHappened = _Provider.hasWriteOperationHappened(url);
6727
- if (!(0, import_utils31.isDefined)(height) || !writeOperationHappened) {
6840
+ if (!(0, import_utils32.isDefined)(height) || !writeOperationHappened) {
6728
6841
  return;
6729
6842
  }
6730
6843
  const normalizedUrl = _Provider.normalizeUrl(url);
@@ -6759,7 +6872,7 @@ var Provider = class _Provider {
6759
6872
  _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
6760
6873
  _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
6761
6874
  }
6762
- if ((0, import_utils31.isDefined)(resourceCacheTTL)) {
6875
+ if ((0, import_utils32.isDefined)(resourceCacheTTL)) {
6763
6876
  if (resourceCacheTTL !== -1) {
6764
6877
  this.cache = new ResourceCache(resourceCacheTTL);
6765
6878
  } else {
@@ -7122,7 +7235,7 @@ var Provider = class _Provider {
7122
7235
  await this.estimateTxDependencies(transactionRequest);
7123
7236
  }
7124
7237
  await this.validateTransaction(transactionRequest);
7125
- const encodedTransaction = (0, import_utils31.hexlify)(transactionRequest.toTransactionBytes());
7238
+ const encodedTransaction = (0, import_utils32.hexlify)(transactionRequest.toTransactionBytes());
7126
7239
  let abis;
7127
7240
  if (isTransactionTypeScript(transactionRequest)) {
7128
7241
  abis = transactionRequest.abis;
@@ -7153,7 +7266,7 @@ var Provider = class _Provider {
7153
7266
  if (estimateTxDependencies) {
7154
7267
  return this.estimateTxDependencies(transactionRequest);
7155
7268
  }
7156
- const encodedTransaction = (0, import_utils31.hexlify)(transactionRequest.toTransactionBytes());
7269
+ const encodedTransaction = (0, import_utils32.hexlify)(transactionRequest.toTransactionBytes());
7157
7270
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
7158
7271
  encodedTransactions: encodedTransaction,
7159
7272
  utxoValidation: utxoValidation || false
@@ -7177,7 +7290,7 @@ var Provider = class _Provider {
7177
7290
  if (!shouldEstimatePredicates) {
7178
7291
  return transactionRequest;
7179
7292
  }
7180
- const encodedTransaction = (0, import_utils31.hexlify)(transactionRequest.toTransactionBytes());
7293
+ const encodedTransaction = (0, import_utils32.hexlify)(transactionRequest.toTransactionBytes());
7181
7294
  const response = await this.operations.estimatePredicates({
7182
7295
  encodedTransaction
7183
7296
  });
@@ -7209,7 +7322,7 @@ var Provider = class _Provider {
7209
7322
  estimatePredicates
7210
7323
  } = await this.operations.estimatePredicatesAndGasPrice({
7211
7324
  blockHorizon: String(blockHorizon),
7212
- encodedTransaction: (0, import_utils31.hexlify)(transactionRequest.toTransactionBytes())
7325
+ encodedTransaction: (0, import_utils32.hexlify)(transactionRequest.toTransactionBytes())
7213
7326
  });
7214
7327
  transactionRequest = this.parseEstimatePredicatesResponse(
7215
7328
  transactionRequest,
@@ -7247,7 +7360,7 @@ var Provider = class _Provider {
7247
7360
  const {
7248
7361
  dryRun: [{ receipts: serializedReceipts, status }]
7249
7362
  } = await this.operations.dryRun({
7250
- encodedTransactions: [(0, import_utils31.hexlify)(transactionRequest.toTransactionBytes())],
7363
+ encodedTransactions: [(0, import_utils32.hexlify)(transactionRequest.toTransactionBytes())],
7251
7364
  utxoValidation: false,
7252
7365
  gasPrice: gasPrice.toString()
7253
7366
  });
@@ -7302,7 +7415,7 @@ var Provider = class _Provider {
7302
7415
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
7303
7416
  allRequests.forEach((req, index) => {
7304
7417
  if (isTransactionTypeScript(req)) {
7305
- serializedTransactionsMap.set(index, (0, import_utils31.hexlify)(req.toTransactionBytes()));
7418
+ serializedTransactionsMap.set(index, (0, import_utils32.hexlify)(req.toTransactionBytes()));
7306
7419
  }
7307
7420
  });
7308
7421
  let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
@@ -7338,7 +7451,7 @@ var Provider = class _Provider {
7338
7451
  transactionRequest: request2
7339
7452
  });
7340
7453
  request2.maxFee = maxFee;
7341
- serializedTransactionsMap.set(requestIdx, (0, import_utils31.hexlify)(request2.toTransactionBytes()));
7454
+ serializedTransactionsMap.set(requestIdx, (0, import_utils32.hexlify)(request2.toTransactionBytes()));
7342
7455
  nextRoundTransactions.push(requestIdx);
7343
7456
  }
7344
7457
  }
@@ -7359,7 +7472,7 @@ var Provider = class _Provider {
7359
7472
  if (estimateTxDependencies) {
7360
7473
  return this.estimateMultipleTxDependencies(transactionRequests);
7361
7474
  }
7362
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils31.hexlify)(tx.toTransactionBytes()));
7475
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils32.hexlify)(tx.toTransactionBytes()));
7363
7476
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
7364
7477
  encodedTransactions,
7365
7478
  utxoValidation: utxoValidation || false
@@ -7409,7 +7522,7 @@ var Provider = class _Provider {
7409
7522
  const chainInfo = await this.getChain();
7410
7523
  const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
7411
7524
  const minGas = transactionRequest.calculateMinGas(chainInfo);
7412
- if (!(0, import_utils31.isDefined)(gasPrice)) {
7525
+ if (!(0, import_utils32.isDefined)(gasPrice)) {
7413
7526
  gasPrice = await this.estimateGasPrice(10);
7414
7527
  }
7415
7528
  const minFee = calculateGasFee({
@@ -7461,7 +7574,7 @@ var Provider = class _Provider {
7461
7574
  if (estimateTxDependencies) {
7462
7575
  return this.estimateTxDependencies(transactionRequest);
7463
7576
  }
7464
- const encodedTransactions = [(0, import_utils31.hexlify)(transactionRequest.toTransactionBytes())];
7577
+ const encodedTransactions = [(0, import_utils32.hexlify)(transactionRequest.toTransactionBytes())];
7465
7578
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
7466
7579
  encodedTransactions,
7467
7580
  utxoValidation: true
@@ -7624,7 +7737,7 @@ var Provider = class _Provider {
7624
7737
  const {
7625
7738
  assembleTx: { status, transaction: gqlTransaction, gasPrice }
7626
7739
  } = await this.operations.assembleTx({
7627
- tx: (0, import_utils31.hexlify)(request2.toTransactionBytes()),
7740
+ tx: (0, import_utils32.hexlify)(request2.toTransactionBytes()),
7628
7741
  blockHorizon: String(blockHorizon),
7629
7742
  feeAddressIndex: String(feePayerIndex),
7630
7743
  requiredBalances,
@@ -7676,7 +7789,7 @@ var Provider = class _Provider {
7676
7789
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
7677
7790
  inputArgs: paginationArgs
7678
7791
  }),
7679
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils31.hexlify)(assetId) }
7792
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils32.hexlify)(assetId) }
7680
7793
  });
7681
7794
  const coins = edges.map(({ node }) => ({
7682
7795
  id: node.utxoId,
@@ -7708,7 +7821,7 @@ var Provider = class _Provider {
7708
7821
  const coinsQuery = {
7709
7822
  owner: ownerAddress.toB256(),
7710
7823
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
7711
- assetId: (0, import_utils31.hexlify)(assetId),
7824
+ assetId: (0, import_utils32.hexlify)(assetId),
7712
7825
  amount: (amount.eqn(0) ? (0, import_math19.bn)(1) : amount).toString(10),
7713
7826
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
7714
7827
  })),
@@ -7866,7 +7979,7 @@ var Provider = class _Provider {
7866
7979
  },
7867
7980
  transactionIds: block.transactions.map((tx) => tx.id),
7868
7981
  transactions: block.transactions.map(
7869
- (tx) => new import_transactions25.TransactionCoder().decode((0, import_utils31.arrayify)(tx.rawPayload), 0)?.[0]
7982
+ (tx) => new import_transactions25.TransactionCoder().decode((0, import_utils32.arrayify)(tx.rawPayload), 0)?.[0]
7870
7983
  )
7871
7984
  };
7872
7985
  }
@@ -7883,7 +7996,7 @@ var Provider = class _Provider {
7883
7996
  }
7884
7997
  try {
7885
7998
  return new import_transactions25.TransactionCoder().decode(
7886
- (0, import_utils31.arrayify)(transaction.rawPayload),
7999
+ (0, import_utils32.arrayify)(transaction.rawPayload),
7887
8000
  0
7888
8001
  )?.[0];
7889
8002
  } catch (error) {
@@ -7911,7 +8024,7 @@ var Provider = class _Provider {
7911
8024
  const coder = new import_transactions25.TransactionCoder();
7912
8025
  const transactions = edges.map(({ node: { rawPayload } }) => {
7913
8026
  try {
7914
- return coder.decode((0, import_utils31.arrayify)(rawPayload), 0)[0];
8027
+ return coder.decode((0, import_utils32.arrayify)(rawPayload), 0)[0];
7915
8028
  } catch (error) {
7916
8029
  if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
7917
8030
  console.warn("Unsupported transaction type encountered");
@@ -7960,7 +8073,7 @@ var Provider = class _Provider {
7960
8073
  async getContractBalance(contractId, assetId) {
7961
8074
  const { contractBalance } = await this.operations.getContractBalance({
7962
8075
  contract: new import_address3.Address(contractId).toB256(),
7963
- asset: (0, import_utils31.hexlify)(assetId)
8076
+ asset: (0, import_utils32.hexlify)(assetId)
7964
8077
  });
7965
8078
  return (0, import_math19.bn)(contractBalance.amount, 10);
7966
8079
  }
@@ -7974,7 +8087,7 @@ var Provider = class _Provider {
7974
8087
  async getBalance(owner, assetId) {
7975
8088
  const { balance } = await this.operations.getBalanceV2({
7976
8089
  owner: new import_address3.Address(owner).toB256(),
7977
- assetId: (0, import_utils31.hexlify)(assetId)
8090
+ assetId: (0, import_utils32.hexlify)(assetId)
7978
8091
  });
7979
8092
  return (0, import_math19.bn)(balance.amountU128, 10);
7980
8093
  }
@@ -8179,7 +8292,7 @@ var Provider = class _Provider {
8179
8292
  async produceBlocks(amount, startTime) {
8180
8293
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
8181
8294
  blocksToProduce: (0, import_math19.bn)(amount).toString(10),
8182
- startTimestamp: startTime ? import_utils31.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
8295
+ startTimestamp: startTime ? import_utils32.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
8183
8296
  });
8184
8297
  return (0, import_math19.bn)(latestBlockHeight);
8185
8298
  }
@@ -8282,18 +8395,21 @@ var Provider = class _Provider {
8282
8395
  extractDryRunError(transactionRequest, receipts, reason) {
8283
8396
  let logs = [];
8284
8397
  let groupedLogs = {};
8398
+ let abis;
8285
8399
  if (transactionRequest.type === import_transactions25.TransactionType.Script && transactionRequest.abis) {
8286
8400
  ({ logs, groupedLogs } = getAllDecodedLogs({
8287
8401
  receipts,
8288
8402
  mainAbi: transactionRequest.abis.main,
8289
8403
  externalAbis: transactionRequest.abis.otherContractsAbis
8290
8404
  }));
8405
+ abis = transactionRequest.abis;
8291
8406
  }
8292
8407
  return extractTxError({
8293
8408
  logs,
8294
8409
  groupedLogs,
8295
8410
  receipts,
8296
- statusReason: reason
8411
+ statusReason: reason,
8412
+ abis
8297
8413
  });
8298
8414
  }
8299
8415
  /**
@@ -8332,8 +8448,8 @@ var Provider = class _Provider {
8332
8448
  */
8333
8449
  async adjustResourcesToIgnoreForAddresses(addresses, resourcesIdsToIgnore) {
8334
8450
  const final = {
8335
- messages: resourcesIdsToIgnore?.messages?.map((nonce) => (0, import_utils31.hexlify)(nonce)) || [],
8336
- utxos: resourcesIdsToIgnore?.utxos?.map((id) => (0, import_utils31.hexlify)(id)) || []
8451
+ messages: resourcesIdsToIgnore?.messages?.map((nonce) => (0, import_utils32.hexlify)(nonce)) || [],
8452
+ utxos: resourcesIdsToIgnore?.utxos?.map((id) => (0, import_utils32.hexlify)(id)) || []
8337
8453
  };
8338
8454
  if (this.cache) {
8339
8455
  const cache2 = this.cache;
@@ -8365,7 +8481,7 @@ var Provider = class _Provider {
8365
8481
  var import_errors21 = require("@fuel-ts/errors");
8366
8482
  var import_math20 = require("@fuel-ts/math");
8367
8483
  var import_transactions26 = require("@fuel-ts/transactions");
8368
- var import_utils33 = require("@fuel-ts/utils");
8484
+ var import_utils34 = require("@fuel-ts/utils");
8369
8485
  async function getTransactionSummary(params) {
8370
8486
  const { id, provider, abiMap } = params;
8371
8487
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -8378,7 +8494,7 @@ async function getTransactionSummary(params) {
8378
8494
  );
8379
8495
  }
8380
8496
  const [decodedTransaction] = new import_transactions26.TransactionCoder().decode(
8381
- (0, import_utils33.arrayify)(gqlTransaction.rawPayload),
8497
+ (0, import_utils34.arrayify)(gqlTransaction.rawPayload),
8382
8498
  0
8383
8499
  );
8384
8500
  let txReceipts = [];
@@ -8400,7 +8516,7 @@ async function getTransactionSummary(params) {
8400
8516
  id: gqlTransaction.id,
8401
8517
  receipts,
8402
8518
  transaction: decodedTransaction,
8403
- transactionBytes: (0, import_utils33.arrayify)(gqlTransaction.rawPayload),
8519
+ transactionBytes: (0, import_utils34.arrayify)(gqlTransaction.rawPayload),
8404
8520
  gqlTransactionStatus: gqlTransaction.status,
8405
8521
  gasPerByte: (0, import_math20.bn)(gasPerByte),
8406
8522
  gasPriceFactor: (0, import_math20.bn)(gasPriceFactor),
@@ -8466,7 +8582,7 @@ async function getTransactionsSummaries(params) {
8466
8582
  const transactions = edges.map((edge) => {
8467
8583
  const { node: gqlTransaction } = edge;
8468
8584
  const { id, rawPayload, status } = gqlTransaction;
8469
- const [decodedTransaction] = new import_transactions26.TransactionCoder().decode((0, import_utils33.arrayify)(rawPayload), 0);
8585
+ const [decodedTransaction] = new import_transactions26.TransactionCoder().decode((0, import_utils34.arrayify)(rawPayload), 0);
8470
8586
  let txReceipts = [];
8471
8587
  if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
8472
8588
  txReceipts = gqlTransaction.status.receipts;
@@ -8476,7 +8592,7 @@ async function getTransactionsSummaries(params) {
8476
8592
  id,
8477
8593
  receipts,
8478
8594
  transaction: decodedTransaction,
8479
- transactionBytes: (0, import_utils33.arrayify)(rawPayload),
8595
+ transactionBytes: (0, import_utils34.arrayify)(rawPayload),
8480
8596
  gqlTransactionStatus: status,
8481
8597
  abiMap,
8482
8598
  gasPerByte,
@@ -8502,7 +8618,7 @@ __name(getTransactionsSummaries, "getTransactionsSummaries");
8502
8618
  // src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
8503
8619
  var import_math21 = require("@fuel-ts/math");
8504
8620
  var import_transactions27 = require("@fuel-ts/transactions");
8505
- var import_utils34 = require("@fuel-ts/utils");
8621
+ var import_utils35 = require("@fuel-ts/utils");
8506
8622
  var assembleTransactionSummaryFromJson = /* @__PURE__ */ __name(async (opts) => {
8507
8623
  const { provider, transactionSummary } = opts;
8508
8624
  const { id, transactionBytes, gasPrice, receipts } = transactionSummary;
@@ -8514,7 +8630,7 @@ var assembleTransactionSummaryFromJson = /* @__PURE__ */ __name(async (opts) =>
8514
8630
  gasCosts
8515
8631
  }
8516
8632
  } = await provider.getChain();
8517
- const deserializedTransactionBytes = (0, import_utils34.arrayify)(transactionBytes);
8633
+ const deserializedTransactionBytes = (0, import_utils35.arrayify)(transactionBytes);
8518
8634
  const [transaction] = new import_transactions27.TransactionCoder().decode(deserializedTransactionBytes, 0);
8519
8635
  return assembleTransactionSummary({
8520
8636
  id,
@@ -8577,17 +8693,17 @@ var AbstractAccount = class {
8577
8693
  };
8578
8694
 
8579
8695
  // src/utils/formatTransferToContractScriptData.ts
8580
- var import_abi_coder6 = require("@fuel-ts/abi-coder");
8696
+ var import_abi_coder8 = require("@fuel-ts/abi-coder");
8581
8697
  var import_address4 = require("@fuel-ts/address");
8582
- var import_utils35 = require("@fuel-ts/utils");
8698
+ var import_utils36 = require("@fuel-ts/utils");
8583
8699
  var asm = __toESM(require("@fuels/vm-asm"));
8584
8700
  var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
8585
- const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
8701
+ const numberCoder = new import_abi_coder8.BigNumberCoder("u64");
8586
8702
  return transferParams.reduce((acc, transferParam) => {
8587
8703
  const { assetId, amount, contractId } = transferParam;
8588
8704
  const encoded = numberCoder.encode(amount);
8589
- const scriptData = (0, import_utils35.concat)([new import_address4.Address(contractId).toBytes(), encoded, (0, import_utils35.arrayify)(assetId)]);
8590
- return (0, import_utils35.concat)([acc, scriptData]);
8705
+ const scriptData = (0, import_utils36.concat)([new import_address4.Address(contractId).toBytes(), encoded, (0, import_utils36.arrayify)(assetId)]);
8706
+ return (0, import_utils36.concat)([acc, scriptData]);
8591
8707
  }, new Uint8Array());
8592
8708
  }, "formatTransferToContractScriptData");
8593
8709
  var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferParams) => {
@@ -8595,24 +8711,24 @@ var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferPar
8595
8711
  await asm.initWasm();
8596
8712
  let script = new Uint8Array();
8597
8713
  transferParams.forEach((_, i) => {
8598
- const offset = (import_abi_coder6.CONTRACT_ID_LEN + import_abi_coder6.WORD_SIZE + import_abi_coder6.ASSET_ID_LEN) * i;
8599
- script = (0, import_utils35.concat)([
8714
+ const offset = (import_abi_coder8.CONTRACT_ID_LEN + import_abi_coder8.WORD_SIZE + import_abi_coder8.ASSET_ID_LEN) * i;
8715
+ script = (0, import_utils36.concat)([
8600
8716
  script,
8601
8717
  // Load ScriptData into register 0x10.
8602
8718
  asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
8603
8719
  // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
8604
8720
  asm.addi(17, 16, offset).to_bytes(),
8605
8721
  // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
8606
- asm.addi(18, 17, import_abi_coder6.CONTRACT_ID_LEN).to_bytes(),
8722
+ asm.addi(18, 17, import_abi_coder8.CONTRACT_ID_LEN).to_bytes(),
8607
8723
  // Load word to the amount at 0x12 into register 0x13.
8608
8724
  asm.lw(19, 18, 0).to_bytes(),
8609
8725
  // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
8610
- asm.addi(20, 18, import_abi_coder6.WORD_SIZE).to_bytes(),
8726
+ asm.addi(20, 18, import_abi_coder8.WORD_SIZE).to_bytes(),
8611
8727
  // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
8612
8728
  asm.tr(17, 19, 20).to_bytes()
8613
8729
  ]);
8614
8730
  });
8615
- script = (0, import_utils35.concat)([script, asm.ret(1).to_bytes()]);
8731
+ script = (0, import_utils36.concat)([script, asm.ret(1).to_bytes()]);
8616
8732
  return { script, scriptData };
8617
8733
  }, "assembleTransferToContractScript");
8618
8734
 
@@ -8962,7 +9078,7 @@ var Account = class extends AbstractAccount {
8962
9078
  const transferParams = contractTransferParams.map((transferParam) => {
8963
9079
  const amount = (0, import_math22.bn)(transferParam.amount);
8964
9080
  const contractAddress = new import_address5.Address(transferParam.contractId);
8965
- const assetId = transferParam.assetId ? (0, import_utils36.hexlify)(transferParam.assetId) : defaultAssetId;
9081
+ const assetId = transferParam.assetId ? (0, import_utils37.hexlify)(transferParam.assetId) : defaultAssetId;
8966
9082
  if (amount.lte(0)) {
8967
9083
  throw new import_errors22.FuelError(
8968
9084
  import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -9000,14 +9116,14 @@ var Account = class extends AbstractAccount {
9000
9116
  */
9001
9117
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
9002
9118
  const recipientAddress = new import_address5.Address(recipient);
9003
- const recipientDataArray = (0, import_utils36.arrayify)(
9119
+ const recipientDataArray = (0, import_utils37.arrayify)(
9004
9120
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
9005
9121
  );
9006
- const amountDataArray = (0, import_utils36.arrayify)(
9122
+ const amountDataArray = (0, import_utils37.arrayify)(
9007
9123
  "0x".concat((0, import_math22.bn)(amount).toHex().substring(2).padStart(16, "0"))
9008
9124
  );
9009
9125
  const script = new Uint8Array([
9010
- ...(0, import_utils36.arrayify)(withdrawScript.bytes),
9126
+ ...(0, import_utils37.arrayify)(withdrawScript.bytes),
9011
9127
  ...recipientDataArray,
9012
9128
  ...amountDataArray
9013
9129
  ]);
@@ -9297,7 +9413,7 @@ var Account = class extends AbstractAccount {
9297
9413
  */
9298
9414
  generateFakeResources(coins) {
9299
9415
  return coins.map((coin) => ({
9300
- id: (0, import_utils36.hexlify)((0, import_crypto2.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
9416
+ id: (0, import_utils37.hexlify)((0, import_crypto2.randomBytes)(import_abi_coder9.UTXO_ID_LEN)),
9301
9417
  owner: this.address,
9302
9418
  blockCreated: (0, import_math22.bn)(1),
9303
9419
  txCreatedIdx: (0, import_math22.bn)(1),
@@ -9307,7 +9423,7 @@ var Account = class extends AbstractAccount {
9307
9423
  /** @hidden */
9308
9424
  async prepareTransactionForSend(request2) {
9309
9425
  const { transactionId } = request2.flag;
9310
- if (!(0, import_utils36.isDefined)(transactionId)) {
9426
+ if (!(0, import_utils37.isDefined)(transactionId)) {
9311
9427
  return request2;
9312
9428
  }
9313
9429
  const chainId = await this.provider.getChainId();
@@ -9320,10 +9436,10 @@ var Account = class extends AbstractAccount {
9320
9436
  /** @hidden */
9321
9437
  async prepareTransactionSummary(request2) {
9322
9438
  const chainId = await this.provider.getChainId();
9323
- return (0, import_utils36.isDefined)(request2.flag.summary) ? {
9439
+ return (0, import_utils37.isDefined)(request2.flag.summary) ? {
9324
9440
  ...request2.flag.summary,
9325
9441
  id: request2.getTransactionId(chainId),
9326
- transactionBytes: (0, import_utils36.hexlify)(request2.toTransactionBytes())
9442
+ transactionBytes: (0, import_utils37.hexlify)(request2.toTransactionBytes())
9327
9443
  } : void 0;
9328
9444
  }
9329
9445
  /** @hidden * */
@@ -9368,7 +9484,7 @@ var Account = class extends AbstractAccount {
9368
9484
  txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
9369
9485
  }) {
9370
9486
  const request2 = transactionRequestify(transactionRequest);
9371
- if (!(0, import_utils36.isDefined)(setGasLimit)) {
9487
+ if (!(0, import_utils37.isDefined)(setGasLimit)) {
9372
9488
  request2.gasLimit = gasUsed;
9373
9489
  } else if (gasUsed.gt(setGasLimit)) {
9374
9490
  throw new import_errors22.FuelError(
@@ -9376,7 +9492,7 @@ var Account = class extends AbstractAccount {
9376
9492
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
9377
9493
  );
9378
9494
  }
9379
- if (!(0, import_utils36.isDefined)(setMaxFee)) {
9495
+ if (!(0, import_utils37.isDefined)(setMaxFee)) {
9380
9496
  request2.maxFee = maxFee;
9381
9497
  } else if (maxFee.gt(setMaxFee)) {
9382
9498
  throw new import_errors22.FuelError(
@@ -9419,14 +9535,14 @@ var Account = class extends AbstractAccount {
9419
9535
 
9420
9536
  // src/wallet/base-wallet-unlocked.ts
9421
9537
  var import_hasher4 = require("@fuel-ts/hasher");
9422
- var import_utils39 = require("@fuel-ts/utils");
9538
+ var import_utils40 = require("@fuel-ts/utils");
9423
9539
 
9424
9540
  // src/signer/signer.ts
9425
9541
  var import_address6 = require("@fuel-ts/address");
9426
9542
  var import_crypto3 = require("@fuel-ts/crypto");
9427
9543
  var import_hasher3 = require("@fuel-ts/hasher");
9428
9544
  var import_math23 = require("@fuel-ts/math");
9429
- var import_utils37 = require("@fuel-ts/utils");
9545
+ var import_utils38 = require("@fuel-ts/utils");
9430
9546
  var import_secp256k1 = require("@noble/curves/secp256k1");
9431
9547
  var Signer = class _Signer {
9432
9548
  static {
@@ -9449,9 +9565,9 @@ var Signer = class _Signer {
9449
9565
  }
9450
9566
  }
9451
9567
  const privateKeyBytes = (0, import_math23.toBytes)(privateKey, 32);
9452
- this.privateKey = (0, import_utils37.hexlify)(privateKeyBytes);
9453
- this.publicKey = (0, import_utils37.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
9454
- this.compressedPublicKey = (0, import_utils37.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
9568
+ this.privateKey = (0, import_utils38.hexlify)(privateKeyBytes);
9569
+ this.publicKey = (0, import_utils38.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
9570
+ this.compressedPublicKey = (0, import_utils38.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
9455
9571
  this.address = new import_address6.Address(this.publicKey);
9456
9572
  }
9457
9573
  /**
@@ -9465,11 +9581,11 @@ var Signer = class _Signer {
9465
9581
  * @returns hashed signature
9466
9582
  */
9467
9583
  sign(data) {
9468
- const signature = import_secp256k1.secp256k1.sign((0, import_utils37.arrayify)(data), (0, import_utils37.arrayify)(this.privateKey));
9584
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils38.arrayify)(data), (0, import_utils38.arrayify)(this.privateKey));
9469
9585
  const r = (0, import_math23.toBytes)(`0x${signature.r.toString(16)}`, 32);
9470
9586
  const s = (0, import_math23.toBytes)(`0x${signature.s.toString(16)}`, 32);
9471
9587
  s[0] |= (signature.recovery || 0) << 7;
9472
- return (0, import_utils37.hexlify)((0, import_utils37.concat)([r, s]));
9588
+ return (0, import_utils38.hexlify)((0, import_utils38.concat)([r, s]));
9473
9589
  }
9474
9590
  /**
9475
9591
  * Add point on the current elliptic curve
@@ -9478,8 +9594,8 @@ var Signer = class _Signer {
9478
9594
  * @returns compressed point on the curve
9479
9595
  */
9480
9596
  addPoint(point) {
9481
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils37.arrayify)(this.compressedPublicKey));
9482
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils37.arrayify)(point));
9597
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils38.arrayify)(this.compressedPublicKey));
9598
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils38.arrayify)(point));
9483
9599
  const result = p0.add(p1);
9484
9600
  return `0x${result.toHex(true)}`;
9485
9601
  }
@@ -9491,16 +9607,16 @@ var Signer = class _Signer {
9491
9607
  * @returns public key from signature from the
9492
9608
  */
9493
9609
  static recoverPublicKey(data, signature) {
9494
- const signedMessageBytes = (0, import_utils37.arrayify)(signature);
9610
+ const signedMessageBytes = (0, import_utils38.arrayify)(signature);
9495
9611
  const r = signedMessageBytes.slice(0, 32);
9496
9612
  const s = signedMessageBytes.slice(32, 64);
9497
9613
  const recoveryParam = (s[0] & 128) >> 7;
9498
9614
  s[0] &= 127;
9499
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils37.hexlify)(r)), BigInt((0, import_utils37.hexlify)(s))).addRecoveryBit(
9615
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils38.hexlify)(r)), BigInt((0, import_utils38.hexlify)(s))).addRecoveryBit(
9500
9616
  recoveryParam
9501
9617
  );
9502
- const publicKey = sig.recoverPublicKey((0, import_utils37.arrayify)(data)).toRawBytes(false).slice(1);
9503
- return (0, import_utils37.hexlify)(publicKey);
9618
+ const publicKey = sig.recoverPublicKey((0, import_utils38.arrayify)(data)).toRawBytes(false).slice(1);
9619
+ return (0, import_utils38.hexlify)(publicKey);
9504
9620
  }
9505
9621
  /**
9506
9622
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -9519,7 +9635,7 @@ var Signer = class _Signer {
9519
9635
  * @returns random 32-byte hashed
9520
9636
  */
9521
9637
  static generatePrivateKey(entropy) {
9522
- return entropy ? (0, import_hasher3.hash)((0, import_utils37.concat)([(0, import_crypto3.randomBytes)(32), (0, import_utils37.arrayify)(entropy)])) : (0, import_crypto3.randomBytes)(32);
9638
+ return entropy ? (0, import_hasher3.hash)((0, import_utils38.concat)([(0, import_crypto3.randomBytes)(32), (0, import_utils38.arrayify)(entropy)])) : (0, import_crypto3.randomBytes)(32);
9523
9639
  }
9524
9640
  /**
9525
9641
  * Extended publicKey from a compact publicKey
@@ -9528,8 +9644,8 @@ var Signer = class _Signer {
9528
9644
  * @returns extended publicKey
9529
9645
  */
9530
9646
  static extendPublicKey(publicKey) {
9531
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils37.arrayify)(publicKey));
9532
- return (0, import_utils37.hexlify)(point.toRawBytes(false).slice(1));
9647
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils38.arrayify)(publicKey));
9648
+ return (0, import_utils38.hexlify)(point.toRawBytes(false).slice(1));
9533
9649
  }
9534
9650
  };
9535
9651
 
@@ -9537,7 +9653,7 @@ var Signer = class _Signer {
9537
9653
  var import_address7 = require("@fuel-ts/address");
9538
9654
  var import_crypto4 = require("@fuel-ts/crypto");
9539
9655
  var import_errors23 = require("@fuel-ts/errors");
9540
- var import_utils38 = require("@fuel-ts/utils");
9656
+ var import_utils39 = require("@fuel-ts/utils");
9541
9657
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
9542
9658
  var DEFAULT_KDF_PARAMS_R = 8;
9543
9659
  var DEFAULT_KDF_PARAMS_P = 1;
@@ -9620,7 +9736,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
9620
9736
  );
9621
9737
  }
9622
9738
  const buffer = await (0, import_crypto4.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
9623
- const privateKey = (0, import_utils38.hexlify)(buffer);
9739
+ const privateKey = (0, import_utils39.hexlify)(buffer);
9624
9740
  return privateKey;
9625
9741
  }
9626
9742
  __name(decryptKeystoreWallet, "decryptKeystoreWallet");
@@ -9673,7 +9789,7 @@ var BaseWalletUnlocked = class extends Account {
9673
9789
  */
9674
9790
  async signMessage(message) {
9675
9791
  const signedMessage = await this.signer().sign((0, import_hasher4.hashMessage)(message));
9676
- return (0, import_utils39.hexlify)(signedMessage);
9792
+ return (0, import_utils40.hexlify)(signedMessage);
9677
9793
  }
9678
9794
  /**
9679
9795
  * Signs a transaction with the wallet's private key.
@@ -9686,7 +9802,7 @@ var BaseWalletUnlocked = class extends Account {
9686
9802
  const chainId = await this.provider.getChainId();
9687
9803
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
9688
9804
  const signature = await this.signer().sign(hashedTransaction);
9689
- return (0, import_utils39.hexlify)(signature);
9805
+ return (0, import_utils40.hexlify)(signature);
9690
9806
  }
9691
9807
  /**
9692
9808
  * Populates a transaction with the witnesses signature.
@@ -9757,13 +9873,13 @@ var import_crypto6 = require("@fuel-ts/crypto");
9757
9873
  var import_errors26 = require("@fuel-ts/errors");
9758
9874
  var import_hasher7 = require("@fuel-ts/hasher");
9759
9875
  var import_math24 = require("@fuel-ts/math");
9760
- var import_utils43 = require("@fuel-ts/utils");
9876
+ var import_utils44 = require("@fuel-ts/utils");
9761
9877
 
9762
9878
  // src/mnemonic/mnemonic.ts
9763
9879
  var import_crypto5 = require("@fuel-ts/crypto");
9764
9880
  var import_errors25 = require("@fuel-ts/errors");
9765
9881
  var import_hasher6 = require("@fuel-ts/hasher");
9766
- var import_utils41 = require("@fuel-ts/utils");
9882
+ var import_utils42 = require("@fuel-ts/utils");
9767
9883
 
9768
9884
  // src/wordlists/words/english.ts
9769
9885
  var english = [
@@ -11826,7 +11942,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
11826
11942
  // src/mnemonic/utils.ts
11827
11943
  var import_errors24 = require("@fuel-ts/errors");
11828
11944
  var import_hasher5 = require("@fuel-ts/hasher");
11829
- var import_utils40 = require("@fuel-ts/utils");
11945
+ var import_utils41 = require("@fuel-ts/utils");
11830
11946
  function getLowerMask(bits) {
11831
11947
  return (1 << bits) - 1;
11832
11948
  }
@@ -11865,7 +11981,7 @@ function entropyToMnemonicIndices(entropy) {
11865
11981
  }
11866
11982
  }
11867
11983
  const checksumBits = entropy.length / 4;
11868
- const checksum = (0, import_utils40.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
11984
+ const checksum = (0, import_utils41.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
11869
11985
  indices[indices.length - 1] <<= checksumBits;
11870
11986
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
11871
11987
  return indices;
@@ -11873,7 +11989,7 @@ function entropyToMnemonicIndices(entropy) {
11873
11989
  __name(entropyToMnemonicIndices, "entropyToMnemonicIndices");
11874
11990
  function mnemonicWordsToEntropy(words, wordlist) {
11875
11991
  const size = Math.ceil(11 * words.length / 8);
11876
- const entropy = (0, import_utils40.arrayify)(new Uint8Array(size));
11992
+ const entropy = (0, import_utils41.arrayify)(new Uint8Array(size));
11877
11993
  let offset = 0;
11878
11994
  for (let i = 0; i < words.length; i += 1) {
11879
11995
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -11893,7 +12009,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
11893
12009
  const entropyBits = 32 * words.length / 3;
11894
12010
  const checksumBits = words.length / 3;
11895
12011
  const checksumMask = getUpperMask(checksumBits);
11896
- const checksum = (0, import_utils40.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
12012
+ const checksum = (0, import_utils41.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
11897
12013
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
11898
12014
  throw new import_errors24.FuelError(
11899
12015
  import_errors24.ErrorCode.INVALID_CHECKSUM,
@@ -11905,7 +12021,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
11905
12021
  __name(mnemonicWordsToEntropy, "mnemonicWordsToEntropy");
11906
12022
 
11907
12023
  // src/mnemonic/mnemonic.ts
11908
- var MasterSecret = (0, import_utils41.toUtf8Bytes)("Bitcoin seed");
12024
+ var MasterSecret = (0, import_utils42.toUtf8Bytes)("Bitcoin seed");
11909
12025
  var MainnetPRV = "0x0488ade4";
11910
12026
  var TestnetPRV = "0x04358394";
11911
12027
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
@@ -11975,7 +12091,7 @@ var Mnemonic = class _Mnemonic {
11975
12091
  static mnemonicToEntropy(phrase, wordlist = english) {
11976
12092
  const words = getWords(phrase);
11977
12093
  assertMnemonic(words);
11978
- return (0, import_utils41.hexlify)(mnemonicWordsToEntropy(words, wordlist));
12094
+ return (0, import_utils42.hexlify)(mnemonicWordsToEntropy(words, wordlist));
11979
12095
  }
11980
12096
  /**
11981
12097
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -11983,7 +12099,7 @@ var Mnemonic = class _Mnemonic {
11983
12099
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
11984
12100
  */
11985
12101
  static entropyToMnemonic(entropy, wordlist = english) {
11986
- const entropyBytes = (0, import_utils41.arrayify)(entropy);
12102
+ const entropyBytes = (0, import_utils42.arrayify)(entropy);
11987
12103
  assertWordList(wordlist);
11988
12104
  assertEntropy(entropyBytes);
11989
12105
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -11995,8 +12111,8 @@ var Mnemonic = class _Mnemonic {
11995
12111
  */
11996
12112
  static mnemonicToSeed(phrase, passphrase = "") {
11997
12113
  assertMnemonic(getWords(phrase));
11998
- const phraseBytes = (0, import_utils41.toUtf8Bytes)(getPhrase(phrase));
11999
- const salt = (0, import_utils41.toUtf8Bytes)(`mnemonic${passphrase}`);
12114
+ const phraseBytes = (0, import_utils42.toUtf8Bytes)(getPhrase(phrase));
12115
+ const salt = (0, import_utils42.toUtf8Bytes)(`mnemonic${passphrase}`);
12000
12116
  return (0, import_crypto5.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
12001
12117
  }
12002
12118
  /**
@@ -12052,14 +12168,14 @@ var Mnemonic = class _Mnemonic {
12052
12168
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
12053
12169
  */
12054
12170
  static masterKeysFromSeed(seed) {
12055
- const seedArray = (0, import_utils41.arrayify)(seed);
12171
+ const seedArray = (0, import_utils42.arrayify)(seed);
12056
12172
  if (seedArray.length < 16 || seedArray.length > 64) {
12057
12173
  throw new import_errors25.FuelError(
12058
12174
  import_errors25.ErrorCode.INVALID_SEED,
12059
12175
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
12060
12176
  );
12061
12177
  }
12062
- return (0, import_utils41.arrayify)((0, import_crypto5.computeHmac)("sha512", MasterSecret, seedArray));
12178
+ return (0, import_utils42.arrayify)((0, import_crypto5.computeHmac)("sha512", MasterSecret, seedArray));
12063
12179
  }
12064
12180
  /**
12065
12181
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -12070,22 +12186,22 @@ var Mnemonic = class _Mnemonic {
12070
12186
  */
12071
12187
  static seedToExtendedKey(seed, testnet = false) {
12072
12188
  const masterKey = _Mnemonic.masterKeysFromSeed(seed);
12073
- const prefix = (0, import_utils41.arrayify)(testnet ? TestnetPRV : MainnetPRV);
12189
+ const prefix = (0, import_utils42.arrayify)(testnet ? TestnetPRV : MainnetPRV);
12074
12190
  const depth = "0x00";
12075
12191
  const fingerprint = "0x00000000";
12076
12192
  const index = "0x00000000";
12077
12193
  const chainCode = masterKey.slice(32);
12078
12194
  const privateKey = masterKey.slice(0, 32);
12079
- const extendedKey = (0, import_utils41.concat)([
12195
+ const extendedKey = (0, import_utils42.concat)([
12080
12196
  prefix,
12081
12197
  depth,
12082
12198
  fingerprint,
12083
12199
  index,
12084
12200
  chainCode,
12085
- (0, import_utils41.concat)(["0x00", privateKey])
12201
+ (0, import_utils42.concat)(["0x00", privateKey])
12086
12202
  ]);
12087
- const checksum = (0, import_utils41.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
12088
- return (0, import_utils41.encodeBase58)((0, import_utils41.concat)([extendedKey, checksum]));
12203
+ const checksum = (0, import_utils42.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
12204
+ return (0, import_utils42.encodeBase58)((0, import_utils42.concat)([extendedKey, checksum]));
12089
12205
  }
12090
12206
  /**
12091
12207
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -12100,7 +12216,7 @@ var Mnemonic = class _Mnemonic {
12100
12216
  * @returns A randomly generated mnemonic
12101
12217
  */
12102
12218
  static generate(size = 32, extraEntropy = "") {
12103
- const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils41.concat)([(0, import_crypto5.randomBytes)(size), (0, import_utils41.arrayify)(extraEntropy)])) : (0, import_crypto5.randomBytes)(size);
12219
+ const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils42.concat)([(0, import_crypto5.randomBytes)(size), (0, import_utils42.arrayify)(extraEntropy)])) : (0, import_crypto5.randomBytes)(size);
12104
12220
  return _Mnemonic.entropyToMnemonic(entropy);
12105
12221
  }
12106
12222
  };
@@ -12108,12 +12224,12 @@ var mnemonic_default = Mnemonic;
12108
12224
 
12109
12225
  // src/hdwallet/hdwallet.ts
12110
12226
  var HARDENED_INDEX = 2147483648;
12111
- var MainnetPRV2 = (0, import_utils43.hexlify)("0x0488ade4");
12112
- var MainnetPUB = (0, import_utils43.hexlify)("0x0488b21e");
12113
- var TestnetPRV2 = (0, import_utils43.hexlify)("0x04358394");
12114
- var TestnetPUB = (0, import_utils43.hexlify)("0x043587cf");
12227
+ var MainnetPRV2 = (0, import_utils44.hexlify)("0x0488ade4");
12228
+ var MainnetPUB = (0, import_utils44.hexlify)("0x0488b21e");
12229
+ var TestnetPRV2 = (0, import_utils44.hexlify)("0x04358394");
12230
+ var TestnetPUB = (0, import_utils44.hexlify)("0x043587cf");
12115
12231
  function base58check(data) {
12116
- return (0, import_utils43.encodeBase58)((0, import_utils43.concat)([data, (0, import_utils43.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
12232
+ return (0, import_utils44.encodeBase58)((0, import_utils44.concat)([data, (0, import_utils44.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
12117
12233
  }
12118
12234
  __name(base58check, "base58check");
12119
12235
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
@@ -12124,12 +12240,12 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
12124
12240
  }
12125
12241
  __name(getExtendedKeyPrefix, "getExtendedKeyPrefix");
12126
12242
  function isPublicExtendedKey(extendedKey) {
12127
- return [MainnetPUB, TestnetPUB].includes((0, import_utils43.hexlify)(extendedKey.slice(0, 4)));
12243
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils44.hexlify)(extendedKey.slice(0, 4)));
12128
12244
  }
12129
12245
  __name(isPublicExtendedKey, "isPublicExtendedKey");
12130
12246
  function isValidExtendedKey(extendedKey) {
12131
12247
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
12132
- (0, import_utils43.hexlify)(extendedKey.slice(0, 4))
12248
+ (0, import_utils44.hexlify)(extendedKey.slice(0, 4))
12133
12249
  );
12134
12250
  }
12135
12251
  __name(isValidExtendedKey, "isValidExtendedKey");
@@ -12152,8 +12268,8 @@ var HDWallet = class _HDWallet {
12152
12268
  }
12153
12269
  depth = 0;
12154
12270
  index = 0;
12155
- fingerprint = (0, import_utils43.hexlify)("0x00000000");
12156
- parentFingerprint = (0, import_utils43.hexlify)("0x00000000");
12271
+ fingerprint = (0, import_utils44.hexlify)("0x00000000");
12272
+ parentFingerprint = (0, import_utils44.hexlify)("0x00000000");
12157
12273
  privateKey;
12158
12274
  publicKey;
12159
12275
  chainCode;
@@ -12165,8 +12281,8 @@ var HDWallet = class _HDWallet {
12165
12281
  constructor(config) {
12166
12282
  if (config.privateKey) {
12167
12283
  const signer = new Signer(config.privateKey);
12168
- this.publicKey = (0, import_utils43.hexlify)(signer.compressedPublicKey);
12169
- this.privateKey = (0, import_utils43.hexlify)(config.privateKey);
12284
+ this.publicKey = (0, import_utils44.hexlify)(signer.compressedPublicKey);
12285
+ this.privateKey = (0, import_utils44.hexlify)(config.privateKey);
12170
12286
  } else {
12171
12287
  if (!config.publicKey) {
12172
12288
  throw new import_errors26.FuelError(
@@ -12174,10 +12290,10 @@ var HDWallet = class _HDWallet {
12174
12290
  "Both public and private Key cannot be missing. At least one should be provided."
12175
12291
  );
12176
12292
  }
12177
- this.publicKey = (0, import_utils43.hexlify)(config.publicKey);
12293
+ this.publicKey = (0, import_utils44.hexlify)(config.publicKey);
12178
12294
  }
12179
12295
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
12180
- this.fingerprint = (0, import_utils43.dataSlice)((0, import_crypto6.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
12296
+ this.fingerprint = (0, import_utils44.dataSlice)((0, import_crypto6.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
12181
12297
  this.depth = config.depth || this.depth;
12182
12298
  this.index = config.index || this.index;
12183
12299
  this.chainCode = config.chainCode;
@@ -12193,9 +12309,9 @@ var HDWallet = class _HDWallet {
12193
12309
  * @returns A new instance of HDWallet on the derived index
12194
12310
  */
12195
12311
  deriveIndex(index) {
12196
- const privateKey = this.privateKey && (0, import_utils43.arrayify)(this.privateKey);
12197
- const publicKey = (0, import_utils43.arrayify)(this.publicKey);
12198
- const chainCode = (0, import_utils43.arrayify)(this.chainCode);
12312
+ const privateKey = this.privateKey && (0, import_utils44.arrayify)(this.privateKey);
12313
+ const publicKey = (0, import_utils44.arrayify)(this.publicKey);
12314
+ const chainCode = (0, import_utils44.arrayify)(this.chainCode);
12199
12315
  const data = new Uint8Array(37);
12200
12316
  if (index & HARDENED_INDEX) {
12201
12317
  if (!privateKey) {
@@ -12206,10 +12322,10 @@ var HDWallet = class _HDWallet {
12206
12322
  }
12207
12323
  data.set(privateKey, 1);
12208
12324
  } else {
12209
- data.set((0, import_utils43.arrayify)(this.publicKey));
12325
+ data.set((0, import_utils44.arrayify)(this.publicKey));
12210
12326
  }
12211
12327
  data.set((0, import_math24.toBytes)(index, 4), 33);
12212
- const bytes = (0, import_utils43.arrayify)((0, import_crypto6.computeHmac)("sha512", chainCode, data));
12328
+ const bytes = (0, import_utils44.arrayify)((0, import_crypto6.computeHmac)("sha512", chainCode, data));
12213
12329
  const IL = bytes.slice(0, 32);
12214
12330
  const IR = bytes.slice(32);
12215
12331
  if (privateKey) {
@@ -12223,7 +12339,7 @@ var HDWallet = class _HDWallet {
12223
12339
  parentFingerprint: this.fingerprint
12224
12340
  });
12225
12341
  }
12226
- const signer = new Signer((0, import_utils43.hexlify)(IL));
12342
+ const signer = new Signer((0, import_utils44.hexlify)(IL));
12227
12343
  const Ki = signer.addPoint(publicKey);
12228
12344
  return new _HDWallet({
12229
12345
  publicKey: Ki,
@@ -12258,12 +12374,12 @@ var HDWallet = class _HDWallet {
12258
12374
  );
12259
12375
  }
12260
12376
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
12261
- const depth = (0, import_utils43.hexlify)(Uint8Array.from([this.depth]));
12377
+ const depth = (0, import_utils44.hexlify)(Uint8Array.from([this.depth]));
12262
12378
  const parentFingerprint = this.parentFingerprint;
12263
12379
  const index = (0, import_math24.toHex)(this.index, 4);
12264
12380
  const chainCode = this.chainCode;
12265
- const key = this.privateKey != null && !isPublic ? (0, import_utils43.concat)(["0x00", this.privateKey]) : this.publicKey;
12266
- const extendedKey = (0, import_utils43.arrayify)((0, import_utils43.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
12381
+ const key = this.privateKey != null && !isPublic ? (0, import_utils44.concat)(["0x00", this.privateKey]) : this.publicKey;
12382
+ const extendedKey = (0, import_utils44.arrayify)((0, import_utils44.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
12267
12383
  return base58check(extendedKey);
12268
12384
  }
12269
12385
  /**
@@ -12275,13 +12391,13 @@ var HDWallet = class _HDWallet {
12275
12391
  static fromSeed(seed) {
12276
12392
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
12277
12393
  return new _HDWallet({
12278
- chainCode: (0, import_utils43.arrayify)(masterKey.slice(32)),
12279
- privateKey: (0, import_utils43.arrayify)(masterKey.slice(0, 32))
12394
+ chainCode: (0, import_utils44.arrayify)(masterKey.slice(32)),
12395
+ privateKey: (0, import_utils44.arrayify)(masterKey.slice(0, 32))
12280
12396
  });
12281
12397
  }
12282
12398
  static fromExtendedKey(extendedKey) {
12283
- const decoded = (0, import_utils43.hexlify)((0, import_math24.toBytes)((0, import_utils43.decodeBase58)(extendedKey)));
12284
- const bytes = (0, import_utils43.arrayify)(decoded);
12399
+ const decoded = (0, import_utils44.hexlify)((0, import_math24.toBytes)((0, import_utils44.decodeBase58)(extendedKey)));
12400
+ const bytes = (0, import_utils44.arrayify)(decoded);
12285
12401
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
12286
12402
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
12287
12403
  throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -12290,9 +12406,9 @@ var HDWallet = class _HDWallet {
12290
12406
  throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
12291
12407
  }
12292
12408
  const depth = bytes[4];
12293
- const parentFingerprint = (0, import_utils43.hexlify)(bytes.slice(5, 9));
12294
- const index = parseInt((0, import_utils43.hexlify)(bytes.slice(9, 13)).substring(2), 16);
12295
- const chainCode = (0, import_utils43.hexlify)(bytes.slice(13, 45));
12409
+ const parentFingerprint = (0, import_utils44.hexlify)(bytes.slice(5, 9));
12410
+ const index = parseInt((0, import_utils44.hexlify)(bytes.slice(9, 13)).substring(2), 16);
12411
+ const chainCode = (0, import_utils44.hexlify)(bytes.slice(13, 45));
12296
12412
  const key = bytes.slice(45, 78);
12297
12413
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
12298
12414
  throw new import_errors26.FuelError(
@@ -12908,19 +13024,19 @@ var StorageAbstract = class {
12908
13024
  };
12909
13025
 
12910
13026
  // src/predicate/predicate.ts
12911
- var import_abi_coder9 = require("@fuel-ts/abi-coder");
13027
+ var import_abi_coder11 = require("@fuel-ts/abi-coder");
12912
13028
  var import_address11 = require("@fuel-ts/address");
12913
13029
  var import_errors32 = require("@fuel-ts/errors");
12914
- var import_utils47 = require("@fuel-ts/utils");
13030
+ var import_utils48 = require("@fuel-ts/utils");
12915
13031
 
12916
13032
  // src/utils/deployScriptOrPredicate.ts
12917
13033
  var import_errors31 = require("@fuel-ts/errors");
12918
- var import_utils45 = require("@fuel-ts/utils");
13034
+ var import_utils46 = require("@fuel-ts/utils");
12919
13035
 
12920
13036
  // src/utils/predicate-script-loader-instructions.ts
12921
- var import_abi_coder8 = require("@fuel-ts/abi-coder");
13037
+ var import_abi_coder10 = require("@fuel-ts/abi-coder");
12922
13038
  var import_hasher8 = require("@fuel-ts/hasher");
12923
- var import_utils44 = require("@fuel-ts/utils");
13039
+ var import_utils45 = require("@fuel-ts/utils");
12924
13040
  var asm2 = __toESM(require("@fuels/vm-asm"));
12925
13041
  var BLOB_ID_SIZE = 32;
12926
13042
  var REG_ADDRESS_OF_DATA_AFTER_CODE = 16;
@@ -12930,12 +13046,12 @@ var WORD_SIZE2 = 8;
12930
13046
  var DATA_OFFSET_INDEX = 8;
12931
13047
  var CONFIGURABLE_OFFSET_INDEX = 16;
12932
13048
  function getBytecodeDataOffset(bytecode) {
12933
- const [offset] = new import_abi_coder8.BigNumberCoder("u64").decode(bytecode, DATA_OFFSET_INDEX);
13049
+ const [offset] = new import_abi_coder10.BigNumberCoder("u64").decode(bytecode, DATA_OFFSET_INDEX);
12934
13050
  return offset.toNumber();
12935
13051
  }
12936
13052
  __name(getBytecodeDataOffset, "getBytecodeDataOffset");
12937
13053
  function getBytecodeConfigurableOffset(bytecode) {
12938
- const [offset] = new import_abi_coder8.BigNumberCoder("u64").decode(bytecode, CONFIGURABLE_OFFSET_INDEX);
13054
+ const [offset] = new import_abi_coder10.BigNumberCoder("u64").decode(bytecode, CONFIGURABLE_OFFSET_INDEX);
12939
13055
  return offset.toNumber();
12940
13056
  }
12941
13057
  __name(getBytecodeConfigurableOffset, "getBytecodeConfigurableOffset");
@@ -13046,7 +13162,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
13046
13162
  ...dataSectionLenBytes
13047
13163
  ]);
13048
13164
  return {
13049
- loaderBytecode: (0, import_utils44.concat)([loaderBytecode2, configurableSection]),
13165
+ loaderBytecode: (0, import_utils45.concat)([loaderBytecode2, configurableSection]),
13050
13166
  blobOffset: loaderBytecode2.length
13051
13167
  };
13052
13168
  }
@@ -13090,8 +13206,8 @@ async function deployScriptOrPredicate({
13090
13206
  abi,
13091
13207
  loaderInstanceCallback
13092
13208
  }) {
13093
- const blobId = getBytecodeId((0, import_utils45.arrayify)(bytecode));
13094
- const configurableOffset = getBytecodeConfigurableOffset((0, import_utils45.arrayify)(bytecode));
13209
+ const blobId = getBytecodeId((0, import_utils46.arrayify)(bytecode));
13210
+ const configurableOffset = getBytecodeConfigurableOffset((0, import_utils46.arrayify)(bytecode));
13095
13211
  const byteCodeWithoutConfigurableSection = bytecode.slice(0, configurableOffset);
13096
13212
  const blobTxRequest = new BlobTransactionRequest({
13097
13213
  blobId,
@@ -13099,8 +13215,8 @@ async function deployScriptOrPredicate({
13099
13215
  witnesses: [byteCodeWithoutConfigurableSection]
13100
13216
  });
13101
13217
  const { loaderBytecode, blobOffset } = getPredicateScriptLoaderInstructions(
13102
- (0, import_utils45.arrayify)(bytecode),
13103
- (0, import_utils45.arrayify)(blobId)
13218
+ (0, import_utils46.arrayify)(bytecode),
13219
+ (0, import_utils46.arrayify)(blobId)
13104
13220
  );
13105
13221
  const newConfigurableOffsetDiff = byteCodeWithoutConfigurableSection.length - (blobOffset || 0);
13106
13222
  const newAbi = adjustConfigurableOffsets(abi, newConfigurableOffsetDiff);
@@ -13135,13 +13251,13 @@ __name(deployScriptOrPredicate, "deployScriptOrPredicate");
13135
13251
  // src/predicate/utils/getPredicateRoot.ts
13136
13252
  var import_hasher9 = require("@fuel-ts/hasher");
13137
13253
  var import_merkle = require("@fuel-ts/merkle");
13138
- var import_utils46 = require("@fuel-ts/utils");
13254
+ var import_utils47 = require("@fuel-ts/utils");
13139
13255
  var getPredicateRoot = /* @__PURE__ */ __name((bytecode) => {
13140
13256
  const chunkSize = 16 * 1024;
13141
- const bytes = (0, import_utils46.arrayify)(bytecode);
13142
- const chunks = (0, import_utils46.chunkAndPadBytes)(bytes, chunkSize);
13143
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils46.hexlify)(c)));
13144
- const predicateRoot = (0, import_hasher9.hash)((0, import_utils46.concat)(["0x4655454C", codeRoot]));
13257
+ const bytes = (0, import_utils47.arrayify)(bytecode);
13258
+ const chunks = (0, import_utils47.chunkAndPadBytes)(bytes, chunkSize);
13259
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils47.hexlify)(c)));
13260
+ const predicateRoot = (0, import_hasher9.hash)((0, import_utils47.concat)(["0x4655454C", codeRoot]));
13145
13261
  return predicateRoot;
13146
13262
  }, "getPredicateRoot");
13147
13263
 
@@ -13178,7 +13294,7 @@ var Predicate = class _Predicate extends Account {
13178
13294
  );
13179
13295
  const address = new import_address11.Address(getPredicateRoot(predicateBytes));
13180
13296
  super(address, provider);
13181
- this.initialBytecode = (0, import_utils47.arrayify)(bytecode);
13297
+ this.initialBytecode = (0, import_utils48.arrayify)(bytecode);
13182
13298
  this.bytes = predicateBytes;
13183
13299
  this.interface = predicateInterface;
13184
13300
  this.configurableConstants = configurableConstants;
@@ -13200,8 +13316,8 @@ var Predicate = class _Predicate extends Account {
13200
13316
  }
13201
13317
  request2.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
13202
13318
  if (isRequestInputResourceFromOwner(input, this.address)) {
13203
- input.predicate = (0, import_utils47.hexlify)(this.bytes);
13204
- input.predicateData = (0, import_utils47.hexlify)(this.getPredicateData());
13319
+ input.predicate = (0, import_utils48.hexlify)(this.bytes);
13320
+ input.predicateData = (0, import_utils48.hexlify)(this.getPredicateData());
13205
13321
  input.witnessIndex = 0;
13206
13322
  }
13207
13323
  });
@@ -13270,8 +13386,8 @@ var Predicate = class _Predicate extends Account {
13270
13386
  * @returns An object containing the new predicate bytes and interface.
13271
13387
  */
13272
13388
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
13273
- let predicateBytes = (0, import_utils47.arrayify)(bytes);
13274
- const abiInterface = new import_abi_coder9.Interface(jsonAbi);
13389
+ let predicateBytes = (0, import_utils48.arrayify)(bytes);
13390
+ const abiInterface = new import_abi_coder11.Interface(jsonAbi);
13275
13391
  if (abiInterface.functions.main === void 0) {
13276
13392
  throw new import_errors32.FuelError(
13277
13393
  import_errors32.ErrorCode.ABI_MAIN_METHOD_MISSING,
@@ -13305,8 +13421,8 @@ var Predicate = class _Predicate extends Account {
13305
13421
  );
13306
13422
  return resources.map((resource) => ({
13307
13423
  ...resource,
13308
- predicate: (0, import_utils47.hexlify)(this.bytes),
13309
- predicateData: (0, import_utils47.hexlify)(this.getPredicateData())
13424
+ predicate: (0, import_utils48.hexlify)(this.bytes),
13425
+ predicateData: (0, import_utils48.hexlify)(this.getPredicateData())
13310
13426
  }));
13311
13427
  }
13312
13428
  /**
@@ -13318,8 +13434,8 @@ var Predicate = class _Predicate extends Account {
13318
13434
  generateFakeResources(coins) {
13319
13435
  return super.generateFakeResources(coins).map((coin) => ({
13320
13436
  ...coin,
13321
- predicate: (0, import_utils47.hexlify)(this.bytes),
13322
- predicateData: (0, import_utils47.hexlify)(this.getPredicateData())
13437
+ predicate: (0, import_utils48.hexlify)(this.bytes),
13438
+ predicateData: (0, import_utils48.hexlify)(this.getPredicateData())
13323
13439
  }));
13324
13440
  }
13325
13441
  /**
@@ -14166,6 +14282,7 @@ var Fuel = class _Fuel extends FuelConnector {
14166
14282
  assemblePreConfirmationTransactionSummary,
14167
14283
  assembleReceiptByType,
14168
14284
  assembleRevertError,
14285
+ assembleSignalErrorMessage,
14169
14286
  assembleTransactionSummary,
14170
14287
  assembleTransactionSummaryFromJson,
14171
14288
  assets,