@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.

@@ -58,18 +58,16 @@ module.exports = __toCommonJS(test_utils_exports);
58
58
 
59
59
  // src/wallet/base-wallet-unlocked.ts
60
60
  var import_hasher3 = require("@fuel-ts/hasher");
61
- var import_utils31 = require("@fuel-ts/utils");
61
+ var import_utils30 = require("@fuel-ts/utils");
62
62
 
63
63
  // src/account.ts
64
64
  var import_address4 = require("@fuel-ts/address");
65
- var import_configs12 = require("@fuel-ts/address/configs");
66
- var import_errors16 = require("@fuel-ts/errors");
65
+ var import_errors15 = require("@fuel-ts/errors");
67
66
  var import_interfaces = require("@fuel-ts/interfaces");
68
- var import_math18 = require("@fuel-ts/math");
69
- var import_utils28 = require("@fuel-ts/utils");
67
+ var import_math17 = require("@fuel-ts/math");
68
+ var import_utils27 = require("@fuel-ts/utils");
70
69
 
71
70
  // src/providers/coin-quantity.ts
72
- var import_configs = require("@fuel-ts/address/configs");
73
71
  var import_math = require("@fuel-ts/math");
74
72
  var import_utils = require("@fuel-ts/utils");
75
73
  var coinQuantityfy = (coinQuantityLike) => {
@@ -78,11 +76,11 @@ var coinQuantityfy = (coinQuantityLike) => {
78
76
  let max2;
79
77
  if (Array.isArray(coinQuantityLike)) {
80
78
  amount = coinQuantityLike[0];
81
- assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
82
- max2 = coinQuantityLike[2] ?? void 0;
79
+ assetId = coinQuantityLike[1];
80
+ max2 = coinQuantityLike[2];
83
81
  } else {
84
82
  amount = coinQuantityLike.amount;
85
- assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
83
+ assetId = coinQuantityLike.assetId;
86
84
  max2 = coinQuantityLike.max ?? void 0;
87
85
  }
88
86
  const bnAmount = (0, import_math.bn)(amount);
@@ -106,12 +104,12 @@ var addAmountToAsset = (params) => {
106
104
 
107
105
  // src/providers/provider.ts
108
106
  var import_address3 = require("@fuel-ts/address");
109
- var import_errors14 = require("@fuel-ts/errors");
110
- var import_math15 = require("@fuel-ts/math");
111
- var import_transactions18 = require("@fuel-ts/transactions");
112
- var import_utils23 = require("@fuel-ts/utils");
107
+ var import_errors13 = require("@fuel-ts/errors");
108
+ var import_math14 = require("@fuel-ts/math");
109
+ var import_transactions17 = require("@fuel-ts/transactions");
110
+ var import_utils22 = require("@fuel-ts/utils");
113
111
  var import_versions = require("@fuel-ts/versions");
114
- var import_utils24 = require("@noble/curves/abstract/utils");
112
+ var import_utils23 = require("@noble/curves/abstract/utils");
115
113
  var import_ethers = require("ethers");
116
114
  var import_graphql_request = require("graphql-request");
117
115
  var import_ramda3 = require("ramda");
@@ -1051,7 +1049,7 @@ var MemoryCache = class {
1051
1049
  };
1052
1050
 
1053
1051
  // src/providers/transaction-request/input.ts
1054
- var import_configs2 = require("@fuel-ts/address/configs");
1052
+ var import_configs = require("@fuel-ts/address/configs");
1055
1053
  var import_errors3 = require("@fuel-ts/errors");
1056
1054
  var import_math2 = require("@fuel-ts/math");
1057
1055
  var import_transactions = require("@fuel-ts/transactions");
@@ -1085,10 +1083,10 @@ var inputify = (value) => {
1085
1083
  case import_transactions.InputType.Contract: {
1086
1084
  return {
1087
1085
  type: import_transactions.InputType.Contract,
1088
- txID: import_configs2.ZeroBytes32,
1086
+ txID: import_configs.ZeroBytes32,
1089
1087
  outputIndex: 0,
1090
- balanceRoot: import_configs2.ZeroBytes32,
1091
- stateRoot: import_configs2.ZeroBytes32,
1088
+ balanceRoot: import_configs.ZeroBytes32,
1089
+ stateRoot: import_configs.ZeroBytes32,
1092
1090
  txPointer: {
1093
1091
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1094
1092
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1126,7 +1124,7 @@ var inputify = (value) => {
1126
1124
  };
1127
1125
 
1128
1126
  // src/providers/transaction-request/output.ts
1129
- var import_configs3 = require("@fuel-ts/address/configs");
1127
+ var import_configs2 = require("@fuel-ts/address/configs");
1130
1128
  var import_errors4 = require("@fuel-ts/errors");
1131
1129
  var import_math3 = require("@fuel-ts/math");
1132
1130
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1146,8 +1144,8 @@ var outputify = (value) => {
1146
1144
  return {
1147
1145
  type: import_transactions2.OutputType.Contract,
1148
1146
  inputIndex: value.inputIndex,
1149
- balanceRoot: import_configs3.ZeroBytes32,
1150
- stateRoot: import_configs3.ZeroBytes32
1147
+ balanceRoot: import_configs2.ZeroBytes32,
1148
+ stateRoot: import_configs2.ZeroBytes32
1151
1149
  };
1152
1150
  }
1153
1151
  case import_transactions2.OutputType.Change: {
@@ -1161,9 +1159,9 @@ var outputify = (value) => {
1161
1159
  case import_transactions2.OutputType.Variable: {
1162
1160
  return {
1163
1161
  type: import_transactions2.OutputType.Variable,
1164
- to: import_configs3.ZeroBytes32,
1162
+ to: import_configs2.ZeroBytes32,
1165
1163
  amount: (0, import_math3.bn)(0),
1166
- assetId: import_configs3.ZeroBytes32
1164
+ assetId: import_configs2.ZeroBytes32
1167
1165
  };
1168
1166
  }
1169
1167
  case import_transactions2.OutputType.ContractCreated: {
@@ -1184,22 +1182,22 @@ var outputify = (value) => {
1184
1182
 
1185
1183
  // src/providers/transaction-request/transaction-request.ts
1186
1184
  var import_address = require("@fuel-ts/address");
1187
- var import_configs7 = require("@fuel-ts/address/configs");
1188
- var import_math7 = require("@fuel-ts/math");
1189
- var import_transactions6 = require("@fuel-ts/transactions");
1185
+ var import_configs5 = require("@fuel-ts/address/configs");
1186
+ var import_math6 = require("@fuel-ts/math");
1187
+ var import_transactions5 = require("@fuel-ts/transactions");
1190
1188
  var import_utils9 = require("@fuel-ts/utils");
1191
1189
 
1192
1190
  // src/providers/resource.ts
1193
1191
  var isCoin = (resource) => "id" in resource;
1194
1192
 
1195
1193
  // src/providers/utils/receipts.ts
1196
- var import_configs4 = require("@fuel-ts/address/configs");
1194
+ var import_configs3 = require("@fuel-ts/address/configs");
1197
1195
  var import_errors5 = require("@fuel-ts/errors");
1198
1196
  var import_math4 = require("@fuel-ts/math");
1199
1197
  var import_transactions3 = require("@fuel-ts/transactions");
1200
- var import_configs5 = require("@fuel-ts/transactions/configs");
1198
+ var import_configs4 = require("@fuel-ts/transactions/configs");
1201
1199
  var import_utils5 = require("@fuel-ts/utils");
1202
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1200
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1203
1201
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1204
1202
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1205
1203
  (memo, receipt) => {
@@ -1216,7 +1214,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1216
1214
  missingOutputContractIds: []
1217
1215
  }
1218
1216
  );
1219
- var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1217
+ var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1220
1218
  function assembleReceiptByType(receipt) {
1221
1219
  const { receiptType } = receipt;
1222
1220
  switch (receiptType) {
@@ -1517,78 +1515,6 @@ function sleep(time) {
1517
1515
  });
1518
1516
  }
1519
1517
 
1520
- // src/providers/utils/extract-tx-error.ts
1521
- var import_errors7 = require("@fuel-ts/errors");
1522
- var import_math6 = require("@fuel-ts/math");
1523
- var import_transactions5 = require("@fuel-ts/transactions");
1524
- var import_configs6 = require("@fuel-ts/transactions/configs");
1525
- var assemblePanicError = (status) => {
1526
- let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1527
- const reason = status.reason;
1528
- if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1529
- errorMessage = `${errorMessage}
1530
-
1531
- You can read more about this error at:
1532
-
1533
- ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1534
- }
1535
- return { errorMessage, reason };
1536
- };
1537
- var stringify = (obj) => JSON.stringify(obj, null, 2);
1538
- var assembleRevertError = (receipts, logs) => {
1539
- let errorMessage = "The transaction reverted with an unknown reason.";
1540
- const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
1541
- let reason = "";
1542
- if (revertReceipt) {
1543
- const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1544
- switch (reasonHex) {
1545
- case import_configs6.FAILED_REQUIRE_SIGNAL: {
1546
- reason = "require";
1547
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1548
- break;
1549
- }
1550
- case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1551
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1552
- reason = "assert_eq";
1553
- errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1554
- break;
1555
- }
1556
- case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1557
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1558
- reason = "assert_ne";
1559
- errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1560
- break;
1561
- }
1562
- case import_configs6.FAILED_ASSERT_SIGNAL:
1563
- reason = "assert";
1564
- errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1565
- break;
1566
- case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1567
- reason = "MissingOutputChange";
1568
- errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1569
- break;
1570
- default:
1571
- reason = "unknown";
1572
- errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1573
- }
1574
- }
1575
- return { errorMessage, reason };
1576
- };
1577
- var extractTxError = (params) => {
1578
- const { receipts, status, logs } = params;
1579
- const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1580
- const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
1581
- const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1582
- const metadata = {
1583
- logs,
1584
- receipts,
1585
- panic: isPanic,
1586
- revert: isRevert,
1587
- reason
1588
- };
1589
- return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
1590
- };
1591
-
1592
1518
  // src/providers/transaction-request/errors.ts
1593
1519
  var NoWitnessAtIndexError = class extends Error {
1594
1520
  constructor(index) {
@@ -1625,6 +1551,8 @@ var BaseTransactionRequest = class {
1625
1551
  outputs = [];
1626
1552
  /** List of witnesses */
1627
1553
  witnesses = [];
1554
+ /** Base asset ID - should be fetched from the chain */
1555
+ baseAssetId = import_configs5.ZeroBytes32;
1628
1556
  /**
1629
1557
  * Constructor for initializing a base transaction request.
1630
1558
  *
@@ -1637,34 +1565,36 @@ var BaseTransactionRequest = class {
1637
1565
  witnessLimit,
1638
1566
  inputs,
1639
1567
  outputs,
1640
- witnesses
1568
+ witnesses,
1569
+ baseAssetId
1641
1570
  } = {}) {
1642
- this.gasPrice = (0, import_math7.bn)(gasPrice);
1571
+ this.gasPrice = (0, import_math6.bn)(gasPrice);
1643
1572
  this.maturity = maturity ?? 0;
1644
- this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1645
- this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1573
+ this.witnessLimit = witnessLimit ? (0, import_math6.bn)(witnessLimit) : void 0;
1574
+ this.maxFee = maxFee ? (0, import_math6.bn)(maxFee) : void 0;
1646
1575
  this.inputs = inputs ?? [];
1647
1576
  this.outputs = outputs ?? [];
1648
1577
  this.witnesses = witnesses ?? [];
1578
+ this.baseAssetId = baseAssetId ?? import_configs5.ZeroBytes32;
1649
1579
  }
1650
1580
  static getPolicyMeta(req) {
1651
1581
  let policyTypes = 0;
1652
1582
  const policies = [];
1653
1583
  if (req.gasPrice) {
1654
- policyTypes += import_transactions6.PolicyType.GasPrice;
1655
- policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1584
+ policyTypes += import_transactions5.PolicyType.GasPrice;
1585
+ policies.push({ data: req.gasPrice, type: import_transactions5.PolicyType.GasPrice });
1656
1586
  }
1657
1587
  if (req.witnessLimit) {
1658
- policyTypes += import_transactions6.PolicyType.WitnessLimit;
1659
- policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1588
+ policyTypes += import_transactions5.PolicyType.WitnessLimit;
1589
+ policies.push({ data: req.witnessLimit, type: import_transactions5.PolicyType.WitnessLimit });
1660
1590
  }
1661
1591
  if (req.maturity > 0) {
1662
- policyTypes += import_transactions6.PolicyType.Maturity;
1663
- policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1592
+ policyTypes += import_transactions5.PolicyType.Maturity;
1593
+ policies.push({ data: req.maturity, type: import_transactions5.PolicyType.Maturity });
1664
1594
  }
1665
1595
  if (req.maxFee) {
1666
- policyTypes += import_transactions6.PolicyType.MaxFee;
1667
- policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1596
+ policyTypes += import_transactions5.PolicyType.MaxFee;
1597
+ policies.push({ data: req.maxFee, type: import_transactions5.PolicyType.MaxFee });
1668
1598
  }
1669
1599
  return {
1670
1600
  policyTypes,
@@ -1698,7 +1628,7 @@ var BaseTransactionRequest = class {
1698
1628
  * @returns The transaction bytes.
1699
1629
  */
1700
1630
  toTransactionBytes() {
1701
- return new import_transactions6.TransactionCoder().encode(this.toTransaction());
1631
+ return new import_transactions5.TransactionCoder().encode(this.toTransaction());
1702
1632
  }
1703
1633
  /**
1704
1634
  * @hidden
@@ -1738,7 +1668,7 @@ var BaseTransactionRequest = class {
1738
1668
  * @returns The index of the created witness.
1739
1669
  */
1740
1670
  addEmptyWitness() {
1741
- this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1671
+ this.addWitness((0, import_utils9.concat)([import_configs5.ZeroBytes32, import_configs5.ZeroBytes32]));
1742
1672
  return this.witnesses.length - 1;
1743
1673
  }
1744
1674
  /**
@@ -1789,7 +1719,7 @@ var BaseTransactionRequest = class {
1789
1719
  */
1790
1720
  getCoinInputs() {
1791
1721
  return this.inputs.filter(
1792
- (input) => input.type === import_transactions6.InputType.Coin
1722
+ (input) => input.type === import_transactions5.InputType.Coin
1793
1723
  );
1794
1724
  }
1795
1725
  /**
@@ -1799,7 +1729,7 @@ var BaseTransactionRequest = class {
1799
1729
  */
1800
1730
  getCoinOutputs() {
1801
1731
  return this.outputs.filter(
1802
- (output) => output.type === import_transactions6.OutputType.Coin
1732
+ (output) => output.type === import_transactions5.OutputType.Coin
1803
1733
  );
1804
1734
  }
1805
1735
  /**
@@ -1809,7 +1739,7 @@ var BaseTransactionRequest = class {
1809
1739
  */
1810
1740
  getChangeOutputs() {
1811
1741
  return this.outputs.filter(
1812
- (output) => output.type === import_transactions6.OutputType.Change
1742
+ (output) => output.type === import_transactions5.OutputType.Change
1813
1743
  );
1814
1744
  }
1815
1745
  /**
@@ -1821,9 +1751,9 @@ var BaseTransactionRequest = class {
1821
1751
  const ownerAddress = (0, import_address.addressify)(owner);
1822
1752
  const found = this.inputs.find((input) => {
1823
1753
  switch (input.type) {
1824
- case import_transactions6.InputType.Coin:
1754
+ case import_transactions5.InputType.Coin:
1825
1755
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
1826
- case import_transactions6.InputType.Message:
1756
+ case import_transactions5.InputType.Message:
1827
1757
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
1828
1758
  default:
1829
1759
  return false;
@@ -1852,7 +1782,7 @@ var BaseTransactionRequest = class {
1852
1782
  }
1853
1783
  const input = {
1854
1784
  ...coin,
1855
- type: import_transactions6.InputType.Coin,
1785
+ type: import_transactions5.InputType.Coin,
1856
1786
  owner: owner.toB256(),
1857
1787
  amount,
1858
1788
  assetId,
@@ -1870,11 +1800,9 @@ var BaseTransactionRequest = class {
1870
1800
  *
1871
1801
  * @param message - Message resource.
1872
1802
  * @param predicate - Predicate bytes.
1873
- * @param predicateData - Predicate data bytes.
1874
1803
  */
1875
1804
  addMessageInput(message, predicate) {
1876
1805
  const { recipient, sender, amount } = message;
1877
- const assetId = import_configs7.BaseAssetId;
1878
1806
  let witnessIndex;
1879
1807
  if (predicate) {
1880
1808
  witnessIndex = 0;
@@ -1886,7 +1814,7 @@ var BaseTransactionRequest = class {
1886
1814
  }
1887
1815
  const input = {
1888
1816
  ...message,
1889
- type: import_transactions6.InputType.Message,
1817
+ type: import_transactions5.InputType.Message,
1890
1818
  sender: sender.toB256(),
1891
1819
  recipient: recipient.toB256(),
1892
1820
  amount,
@@ -1895,7 +1823,7 @@ var BaseTransactionRequest = class {
1895
1823
  predicateData: predicate?.predicateDataBytes
1896
1824
  };
1897
1825
  this.pushInput(input);
1898
- this.addChangeOutput(recipient, assetId);
1826
+ this.addChangeOutput(recipient, this.baseAssetId);
1899
1827
  }
1900
1828
  /**
1901
1829
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -1956,12 +1884,12 @@ var BaseTransactionRequest = class {
1956
1884
  * @param amount - Amount of coin.
1957
1885
  * @param assetId - Asset ID of coin.
1958
1886
  */
1959
- addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
1887
+ addCoinOutput(to, amount, assetId) {
1960
1888
  this.pushOutput({
1961
- type: import_transactions6.OutputType.Coin,
1889
+ type: import_transactions5.OutputType.Coin,
1962
1890
  to: (0, import_address.addressify)(to).toB256(),
1963
1891
  amount,
1964
- assetId
1892
+ assetId: assetId ?? this.baseAssetId
1965
1893
  });
1966
1894
  return this;
1967
1895
  }
@@ -1974,7 +1902,7 @@ var BaseTransactionRequest = class {
1974
1902
  addCoinOutputs(to, quantities) {
1975
1903
  quantities.map(coinQuantityfy).forEach((quantity) => {
1976
1904
  this.pushOutput({
1977
- type: import_transactions6.OutputType.Coin,
1905
+ type: import_transactions5.OutputType.Coin,
1978
1906
  to: (0, import_address.addressify)(to).toB256(),
1979
1907
  amount: quantity.amount,
1980
1908
  assetId: quantity.assetId
@@ -1988,15 +1916,15 @@ var BaseTransactionRequest = class {
1988
1916
  * @param to - Address of the owner.
1989
1917
  * @param assetId - Asset ID of coin.
1990
1918
  */
1991
- addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
1919
+ addChangeOutput(to, assetId) {
1992
1920
  const changeOutput = this.getChangeOutputs().find(
1993
1921
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
1994
1922
  );
1995
1923
  if (!changeOutput) {
1996
1924
  this.pushOutput({
1997
- type: import_transactions6.OutputType.Change,
1925
+ type: import_transactions5.OutputType.Change,
1998
1926
  to: (0, import_address.addressify)(to).toB256(),
1999
- assetId
1927
+ assetId: assetId ?? this.baseAssetId
2000
1928
  });
2001
1929
  }
2002
1930
  }
@@ -2050,7 +1978,7 @@ var BaseTransactionRequest = class {
2050
1978
  let idCounter = 0;
2051
1979
  const generateId = () => {
2052
1980
  const counterString = String(idCounter++);
2053
- const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
1981
+ const id = import_configs5.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2054
1982
  return id;
2055
1983
  };
2056
1984
  const findAssetInput = (assetId) => this.inputs.find((input) => {
@@ -2072,13 +2000,13 @@ var BaseTransactionRequest = class {
2072
2000
  assetId,
2073
2001
  owner: resourcesOwner || import_address.Address.fromRandom(),
2074
2002
  maturity: 0,
2075
- blockCreated: (0, import_math7.bn)(1),
2076
- txCreatedIdx: (0, import_math7.bn)(1)
2003
+ blockCreated: (0, import_math6.bn)(1),
2004
+ txCreatedIdx: (0, import_math6.bn)(1)
2077
2005
  }
2078
2006
  ]);
2079
2007
  }
2080
2008
  };
2081
- updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2009
+ updateAssetInput(this.baseAssetId, (0, import_math6.bn)(1e11));
2082
2010
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2083
2011
  }
2084
2012
  /**
@@ -2089,7 +2017,7 @@ var BaseTransactionRequest = class {
2089
2017
  */
2090
2018
  getCoinOutputsQuantities() {
2091
2019
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2092
- amount: (0, import_math7.bn)(amount),
2020
+ amount: (0, import_math6.bn)(amount),
2093
2021
  assetId: assetId.toString()
2094
2022
  }));
2095
2023
  return coinsQuantities;
@@ -2107,18 +2035,18 @@ var BaseTransactionRequest = class {
2107
2035
  this.inputs.forEach((i) => {
2108
2036
  let correspondingInput;
2109
2037
  switch (i.type) {
2110
- case import_transactions6.InputType.Coin:
2111
- correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2038
+ case import_transactions5.InputType.Coin:
2039
+ correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
2112
2040
  break;
2113
- case import_transactions6.InputType.Message:
2041
+ case import_transactions5.InputType.Message:
2114
2042
  correspondingInput = inputs.find(
2115
- (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2043
+ (x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
2116
2044
  );
2117
2045
  break;
2118
2046
  default:
2119
2047
  return;
2120
2048
  }
2121
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2049
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2122
2050
  i.predicate = correspondingInput.predicate;
2123
2051
  i.predicateData = correspondingInput.predicateData;
2124
2052
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2128,47 +2056,47 @@ var BaseTransactionRequest = class {
2128
2056
  };
2129
2057
 
2130
2058
  // src/providers/transaction-request/create-transaction-request.ts
2131
- var import_configs9 = require("@fuel-ts/address/configs");
2132
- var import_math9 = require("@fuel-ts/math");
2133
- var import_transactions8 = require("@fuel-ts/transactions");
2059
+ var import_configs7 = require("@fuel-ts/address/configs");
2060
+ var import_math8 = require("@fuel-ts/math");
2061
+ var import_transactions7 = require("@fuel-ts/transactions");
2134
2062
  var import_utils13 = require("@fuel-ts/utils");
2135
2063
 
2136
2064
  // src/providers/transaction-request/hash-transaction.ts
2137
- var import_configs8 = require("@fuel-ts/address/configs");
2065
+ var import_configs6 = require("@fuel-ts/address/configs");
2138
2066
  var import_hasher = require("@fuel-ts/hasher");
2139
- var import_math8 = require("@fuel-ts/math");
2140
- var import_transactions7 = require("@fuel-ts/transactions");
2067
+ var import_math7 = require("@fuel-ts/math");
2068
+ var import_transactions6 = require("@fuel-ts/transactions");
2141
2069
  var import_utils11 = require("@fuel-ts/utils");
2142
2070
  var import_ramda2 = require("ramda");
2143
2071
  function hashTransaction(transactionRequest, chainId) {
2144
2072
  const transaction = transactionRequest.toTransaction();
2145
- if (transaction.type === import_transactions7.TransactionType.Script) {
2146
- transaction.receiptsRoot = import_configs8.ZeroBytes32;
2073
+ if (transaction.type === import_transactions6.TransactionType.Script) {
2074
+ transaction.receiptsRoot = import_configs6.ZeroBytes32;
2147
2075
  }
2148
2076
  transaction.inputs = transaction.inputs.map((input) => {
2149
2077
  const inputClone = (0, import_ramda2.clone)(input);
2150
2078
  switch (inputClone.type) {
2151
- case import_transactions7.InputType.Coin: {
2079
+ case import_transactions6.InputType.Coin: {
2152
2080
  inputClone.txPointer = {
2153
2081
  blockHeight: 0,
2154
2082
  txIndex: 0
2155
2083
  };
2156
- inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2084
+ inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2157
2085
  return inputClone;
2158
2086
  }
2159
- case import_transactions7.InputType.Message: {
2160
- inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2087
+ case import_transactions6.InputType.Message: {
2088
+ inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2161
2089
  return inputClone;
2162
2090
  }
2163
- case import_transactions7.InputType.Contract: {
2091
+ case import_transactions6.InputType.Contract: {
2164
2092
  inputClone.txPointer = {
2165
2093
  blockHeight: 0,
2166
2094
  txIndex: 0
2167
2095
  };
2168
- inputClone.txID = import_configs8.ZeroBytes32;
2096
+ inputClone.txID = import_configs6.ZeroBytes32;
2169
2097
  inputClone.outputIndex = 0;
2170
- inputClone.balanceRoot = import_configs8.ZeroBytes32;
2171
- inputClone.stateRoot = import_configs8.ZeroBytes32;
2098
+ inputClone.balanceRoot = import_configs6.ZeroBytes32;
2099
+ inputClone.stateRoot = import_configs6.ZeroBytes32;
2172
2100
  return inputClone;
2173
2101
  }
2174
2102
  default:
@@ -2178,19 +2106,19 @@ function hashTransaction(transactionRequest, chainId) {
2178
2106
  transaction.outputs = transaction.outputs.map((output) => {
2179
2107
  const outputClone = (0, import_ramda2.clone)(output);
2180
2108
  switch (outputClone.type) {
2181
- case import_transactions7.OutputType.Contract: {
2182
- outputClone.balanceRoot = import_configs8.ZeroBytes32;
2183
- outputClone.stateRoot = import_configs8.ZeroBytes32;
2109
+ case import_transactions6.OutputType.Contract: {
2110
+ outputClone.balanceRoot = import_configs6.ZeroBytes32;
2111
+ outputClone.stateRoot = import_configs6.ZeroBytes32;
2184
2112
  return outputClone;
2185
2113
  }
2186
- case import_transactions7.OutputType.Change: {
2187
- outputClone.amount = (0, import_math8.bn)(0);
2114
+ case import_transactions6.OutputType.Change: {
2115
+ outputClone.amount = (0, import_math7.bn)(0);
2188
2116
  return outputClone;
2189
2117
  }
2190
- case import_transactions7.OutputType.Variable: {
2191
- outputClone.to = import_configs8.ZeroBytes32;
2192
- outputClone.amount = (0, import_math8.bn)(0);
2193
- outputClone.assetId = import_configs8.ZeroBytes32;
2118
+ case import_transactions6.OutputType.Variable: {
2119
+ outputClone.to = import_configs6.ZeroBytes32;
2120
+ outputClone.amount = (0, import_math7.bn)(0);
2121
+ outputClone.assetId = import_configs6.ZeroBytes32;
2194
2122
  return outputClone;
2195
2123
  }
2196
2124
  default:
@@ -2200,7 +2128,7 @@ function hashTransaction(transactionRequest, chainId) {
2200
2128
  transaction.witnessesCount = 0;
2201
2129
  transaction.witnesses = [];
2202
2130
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2203
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2131
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2204
2132
  return (0, import_hasher.sha256)(concatenatedData);
2205
2133
  }
2206
2134
 
@@ -2236,7 +2164,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2236
2164
  return new this(obj);
2237
2165
  }
2238
2166
  /** Type of the transaction */
2239
- type = import_transactions8.TransactionType.Create;
2167
+ type = import_transactions7.TransactionType.Create;
2240
2168
  /** Witness index of contract bytecode to create */
2241
2169
  bytecodeWitnessIndex;
2242
2170
  /** Salt */
@@ -2256,7 +2184,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2256
2184
  } = {}) {
2257
2185
  super(rest);
2258
2186
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2259
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2187
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs7.ZeroBytes32);
2260
2188
  this.storageSlots = [...storageSlots ?? []];
2261
2189
  }
2262
2190
  /**
@@ -2269,12 +2197,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2269
2197
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2270
2198
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2271
2199
  return {
2272
- type: import_transactions8.TransactionType.Create,
2200
+ type: import_transactions7.TransactionType.Create,
2273
2201
  ...baseTransaction,
2274
2202
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2275
2203
  bytecodeWitnessIndex,
2276
2204
  storageSlotsCount: storageSlots.length,
2277
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2205
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs7.ZeroBytes32,
2278
2206
  storageSlots
2279
2207
  };
2280
2208
  }
@@ -2285,7 +2213,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2285
2213
  */
2286
2214
  getContractCreatedOutputs() {
2287
2215
  return this.outputs.filter(
2288
- (output) => output.type === import_transactions8.OutputType.ContractCreated
2216
+ (output) => output.type === import_transactions7.OutputType.ContractCreated
2289
2217
  );
2290
2218
  }
2291
2219
  /**
@@ -2306,14 +2234,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2306
2234
  */
2307
2235
  addContractCreatedOutput(contractId, stateRoot) {
2308
2236
  this.pushOutput({
2309
- type: import_transactions8.OutputType.ContractCreated,
2237
+ type: import_transactions7.OutputType.ContractCreated,
2310
2238
  contractId,
2311
2239
  stateRoot
2312
2240
  });
2313
2241
  }
2314
2242
  metadataGas(gasCosts) {
2315
2243
  return calculateMetadataGasForTxCreate({
2316
- contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2244
+ contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2317
2245
  gasCosts,
2318
2246
  stateRootSize: this.storageSlots.length,
2319
2247
  txBytesSize: this.byteSize()
@@ -2324,9 +2252,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2324
2252
  // src/providers/transaction-request/script-transaction-request.ts
2325
2253
  var import_abi_coder = require("@fuel-ts/abi-coder");
2326
2254
  var import_address2 = require("@fuel-ts/address");
2327
- var import_configs10 = require("@fuel-ts/address/configs");
2328
- var import_math10 = require("@fuel-ts/math");
2329
- var import_transactions9 = require("@fuel-ts/transactions");
2255
+ var import_configs8 = require("@fuel-ts/address/configs");
2256
+ var import_math9 = require("@fuel-ts/math");
2257
+ var import_transactions8 = require("@fuel-ts/transactions");
2330
2258
  var import_utils15 = require("@fuel-ts/utils");
2331
2259
 
2332
2260
  // src/providers/transaction-request/scripts.ts
@@ -2364,7 +2292,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2364
2292
  return new this(obj);
2365
2293
  }
2366
2294
  /** Type of the transaction */
2367
- type = import_transactions9.TransactionType.Script;
2295
+ type = import_transactions8.TransactionType.Script;
2368
2296
  /** Gas limit for transaction */
2369
2297
  gasLimit;
2370
2298
  /** Script to execute */
@@ -2379,7 +2307,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2379
2307
  */
2380
2308
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2381
2309
  super(rest);
2382
- this.gasLimit = (0, import_math10.bn)(gasLimit);
2310
+ this.gasLimit = (0, import_math9.bn)(gasLimit);
2383
2311
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2384
2312
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2385
2313
  this.abis = rest.abis;
@@ -2393,12 +2321,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2393
2321
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2394
2322
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2395
2323
  return {
2396
- type: import_transactions9.TransactionType.Script,
2324
+ type: import_transactions8.TransactionType.Script,
2397
2325
  scriptGasLimit: this.gasLimit,
2398
2326
  ...super.getBaseTransaction(),
2399
2327
  scriptLength: script.length,
2400
2328
  scriptDataLength: scriptData.length,
2401
- receiptsRoot: import_configs10.ZeroBytes32,
2329
+ receiptsRoot: import_configs8.ZeroBytes32,
2402
2330
  script: (0, import_utils15.hexlify)(script),
2403
2331
  scriptData: (0, import_utils15.hexlify)(scriptData)
2404
2332
  };
@@ -2410,7 +2338,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2410
2338
  */
2411
2339
  getContractInputs() {
2412
2340
  return this.inputs.filter(
2413
- (input) => input.type === import_transactions9.InputType.Contract
2341
+ (input) => input.type === import_transactions8.InputType.Contract
2414
2342
  );
2415
2343
  }
2416
2344
  /**
@@ -2420,7 +2348,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2420
2348
  */
2421
2349
  getContractOutputs() {
2422
2350
  return this.outputs.filter(
2423
- (output) => output.type === import_transactions9.OutputType.Contract
2351
+ (output) => output.type === import_transactions8.OutputType.Contract
2424
2352
  );
2425
2353
  }
2426
2354
  /**
@@ -2430,7 +2358,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2430
2358
  */
2431
2359
  getVariableOutputs() {
2432
2360
  return this.outputs.filter(
2433
- (output) => output.type === import_transactions9.OutputType.Variable
2361
+ (output) => output.type === import_transactions8.OutputType.Variable
2434
2362
  );
2435
2363
  }
2436
2364
  /**
@@ -2453,7 +2381,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2453
2381
  let outputsNumber = numberOfVariables;
2454
2382
  while (outputsNumber) {
2455
2383
  this.pushOutput({
2456
- type: import_transactions9.OutputType.Variable
2384
+ type: import_transactions8.OutputType.Variable
2457
2385
  });
2458
2386
  outputsNumber -= 1;
2459
2387
  }
@@ -2486,12 +2414,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2486
2414
  return this;
2487
2415
  }
2488
2416
  const inputIndex = super.pushInput({
2489
- type: import_transactions9.InputType.Contract,
2417
+ type: import_transactions8.InputType.Contract,
2490
2418
  contractId: contractAddress.toB256(),
2491
2419
  txPointer: "0x00000000000000000000000000000000"
2492
2420
  });
2493
2421
  this.pushOutput({
2494
- type: import_transactions9.OutputType.Contract,
2422
+ type: import_transactions8.OutputType.Contract,
2495
2423
  inputIndex
2496
2424
  });
2497
2425
  return this;
@@ -2527,38 +2455,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2527
2455
  };
2528
2456
 
2529
2457
  // src/providers/transaction-request/utils.ts
2530
- var import_errors9 = require("@fuel-ts/errors");
2531
- var import_transactions10 = require("@fuel-ts/transactions");
2458
+ var import_errors8 = require("@fuel-ts/errors");
2459
+ var import_transactions9 = require("@fuel-ts/transactions");
2532
2460
  var transactionRequestify = (obj) => {
2533
2461
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2534
2462
  return obj;
2535
2463
  }
2536
2464
  const { type } = obj;
2537
2465
  switch (obj.type) {
2538
- case import_transactions10.TransactionType.Script: {
2466
+ case import_transactions9.TransactionType.Script: {
2539
2467
  return ScriptTransactionRequest.from(obj);
2540
2468
  }
2541
- case import_transactions10.TransactionType.Create: {
2469
+ case import_transactions9.TransactionType.Create: {
2542
2470
  return CreateTransactionRequest.from(obj);
2543
2471
  }
2544
2472
  default: {
2545
- throw new import_errors9.FuelError(import_errors9.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2473
+ throw new import_errors8.FuelError(import_errors8.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2546
2474
  }
2547
2475
  }
2548
2476
  };
2549
2477
 
2550
2478
  // src/providers/transaction-response/transaction-response.ts
2551
- var import_errors13 = require("@fuel-ts/errors");
2552
- var import_math14 = require("@fuel-ts/math");
2553
- var import_transactions17 = require("@fuel-ts/transactions");
2479
+ var import_errors12 = require("@fuel-ts/errors");
2480
+ var import_math13 = require("@fuel-ts/math");
2481
+ var import_transactions16 = require("@fuel-ts/transactions");
2554
2482
  var import_utils21 = require("@fuel-ts/utils");
2555
2483
 
2556
2484
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2557
2485
  var import_utils19 = require("@fuel-ts/utils");
2558
2486
 
2559
2487
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2560
- var import_math11 = require("@fuel-ts/math");
2561
- var import_transactions11 = require("@fuel-ts/transactions");
2488
+ var import_math10 = require("@fuel-ts/math");
2489
+ var import_transactions10 = require("@fuel-ts/transactions");
2562
2490
  var import_utils16 = require("@fuel-ts/utils");
2563
2491
  var calculateTransactionFee = (params) => {
2564
2492
  const {
@@ -2566,24 +2494,24 @@ var calculateTransactionFee = (params) => {
2566
2494
  rawPayload,
2567
2495
  consensusParameters: { gasCosts, feeParams }
2568
2496
  } = params;
2569
- const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2570
- const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2497
+ const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
2498
+ const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
2571
2499
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2572
- const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2573
- if (transaction.type === import_transactions11.TransactionType.Mint) {
2500
+ const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
2501
+ if (transaction.type === import_transactions10.TransactionType.Mint) {
2574
2502
  return {
2575
- fee: (0, import_math11.bn)(0),
2576
- minFee: (0, import_math11.bn)(0),
2577
- maxFee: (0, import_math11.bn)(0),
2578
- feeFromGasUsed: (0, import_math11.bn)(0)
2503
+ fee: (0, import_math10.bn)(0),
2504
+ minFee: (0, import_math10.bn)(0),
2505
+ maxFee: (0, import_math10.bn)(0),
2506
+ feeFromGasUsed: (0, import_math10.bn)(0)
2579
2507
  };
2580
2508
  }
2581
2509
  const { type, witnesses, inputs, policies } = transaction;
2582
- let metadataGas = (0, import_math11.bn)(0);
2583
- let gasLimit = (0, import_math11.bn)(0);
2584
- if (type === import_transactions11.TransactionType.Create) {
2510
+ let metadataGas = (0, import_math10.bn)(0);
2511
+ let gasLimit = (0, import_math10.bn)(0);
2512
+ if (type === import_transactions10.TransactionType.Create) {
2585
2513
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2586
- const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2514
+ const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2587
2515
  metadataGas = calculateMetadataGasForTxCreate({
2588
2516
  contractBytesSize,
2589
2517
  gasCosts,
@@ -2602,13 +2530,13 @@ var calculateTransactionFee = (params) => {
2602
2530
  }
2603
2531
  const minGas = getMinGas({
2604
2532
  gasCosts,
2605
- gasPerByte: (0, import_math11.bn)(gasPerByte),
2533
+ gasPerByte: (0, import_math10.bn)(gasPerByte),
2606
2534
  inputs,
2607
2535
  metadataGas,
2608
2536
  txBytesSize: transactionBytes.length
2609
2537
  });
2610
- const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2611
- const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2538
+ const gasPrice = (0, import_math10.bn)(policies.find((policy) => policy.type === import_transactions10.PolicyType.GasPrice)?.data);
2539
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions10.PolicyType.WitnessLimit)?.data;
2612
2540
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2613
2541
  const maxGas = getMaxGas({
2614
2542
  gasPerByte,
@@ -2630,14 +2558,14 @@ var calculateTransactionFee = (params) => {
2630
2558
  };
2631
2559
 
2632
2560
  // src/providers/transaction-summary/operations.ts
2633
- var import_configs11 = require("@fuel-ts/address/configs");
2634
- var import_errors11 = require("@fuel-ts/errors");
2635
- var import_math13 = require("@fuel-ts/math");
2636
- var import_transactions14 = require("@fuel-ts/transactions");
2561
+ var import_configs9 = require("@fuel-ts/address/configs");
2562
+ var import_errors10 = require("@fuel-ts/errors");
2563
+ var import_math12 = require("@fuel-ts/math");
2564
+ var import_transactions13 = require("@fuel-ts/transactions");
2637
2565
 
2638
2566
  // src/providers/transaction-summary/call.ts
2639
2567
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
2640
- var import_math12 = require("@fuel-ts/math");
2568
+ var import_math11 = require("@fuel-ts/math");
2641
2569
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2642
2570
  const abiInterface = new import_abi_coder2.Interface(abi);
2643
2571
  const callFunctionSelector = receipt.param1.toHex(8);
@@ -2646,7 +2574,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2646
2574
  let encodedArgs;
2647
2575
  if (functionFragment.isInputDataPointer) {
2648
2576
  if (rawPayload) {
2649
- const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2577
+ const argsOffset = (0, import_math11.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2650
2578
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2651
2579
  }
2652
2580
  } else {
@@ -2680,8 +2608,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2680
2608
  };
2681
2609
 
2682
2610
  // src/providers/transaction-summary/input.ts
2683
- var import_errors10 = require("@fuel-ts/errors");
2684
- var import_transactions12 = require("@fuel-ts/transactions");
2611
+ var import_errors9 = require("@fuel-ts/errors");
2612
+ var import_transactions11 = require("@fuel-ts/transactions");
2685
2613
  function getInputsByTypes(inputs, types) {
2686
2614
  return inputs.filter((i) => types.includes(i.type));
2687
2615
  }
@@ -2689,16 +2617,16 @@ function getInputsByType(inputs, type) {
2689
2617
  return inputs.filter((i) => i.type === type);
2690
2618
  }
2691
2619
  function getInputsCoin(inputs) {
2692
- return getInputsByType(inputs, import_transactions12.InputType.Coin);
2620
+ return getInputsByType(inputs, import_transactions11.InputType.Coin);
2693
2621
  }
2694
2622
  function getInputsMessage(inputs) {
2695
- return getInputsByType(inputs, import_transactions12.InputType.Message);
2623
+ return getInputsByType(inputs, import_transactions11.InputType.Message);
2696
2624
  }
2697
2625
  function getInputsCoinAndMessage(inputs) {
2698
- return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
2626
+ return getInputsByTypes(inputs, [import_transactions11.InputType.Coin, import_transactions11.InputType.Message]);
2699
2627
  }
2700
2628
  function getInputsContract(inputs) {
2701
- return getInputsByType(inputs, import_transactions12.InputType.Contract);
2629
+ return getInputsByType(inputs, import_transactions11.InputType.Contract);
2702
2630
  }
2703
2631
  function getInputFromAssetId(inputs, assetId) {
2704
2632
  const coinInputs = getInputsCoin(inputs);
@@ -2717,40 +2645,40 @@ function getInputContractFromIndex(inputs, inputIndex) {
2717
2645
  if (!contractInput) {
2718
2646
  return void 0;
2719
2647
  }
2720
- if (contractInput.type !== import_transactions12.InputType.Contract) {
2721
- throw new import_errors10.FuelError(
2722
- import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
2648
+ if (contractInput.type !== import_transactions11.InputType.Contract) {
2649
+ throw new import_errors9.FuelError(
2650
+ import_errors9.ErrorCode.INVALID_TRANSACTION_INPUT,
2723
2651
  `Contract input should be of type 'contract'.`
2724
2652
  );
2725
2653
  }
2726
2654
  return contractInput;
2727
2655
  }
2728
2656
  function getInputAccountAddress(input) {
2729
- if (input.type === import_transactions12.InputType.Coin) {
2657
+ if (input.type === import_transactions11.InputType.Coin) {
2730
2658
  return input.owner.toString();
2731
2659
  }
2732
- if (input.type === import_transactions12.InputType.Message) {
2660
+ if (input.type === import_transactions11.InputType.Message) {
2733
2661
  return input.recipient.toString();
2734
2662
  }
2735
2663
  return "";
2736
2664
  }
2737
2665
 
2738
2666
  // src/providers/transaction-summary/output.ts
2739
- var import_transactions13 = require("@fuel-ts/transactions");
2667
+ var import_transactions12 = require("@fuel-ts/transactions");
2740
2668
  function getOutputsByType(outputs, type) {
2741
2669
  return outputs.filter((o) => o.type === type);
2742
2670
  }
2743
2671
  function getOutputsContractCreated(outputs) {
2744
- return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
2672
+ return getOutputsByType(outputs, import_transactions12.OutputType.ContractCreated);
2745
2673
  }
2746
2674
  function getOutputsCoin(outputs) {
2747
- return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
2675
+ return getOutputsByType(outputs, import_transactions12.OutputType.Coin);
2748
2676
  }
2749
2677
  function getOutputsChange(outputs) {
2750
- return getOutputsByType(outputs, import_transactions13.OutputType.Change);
2678
+ return getOutputsByType(outputs, import_transactions12.OutputType.Change);
2751
2679
  }
2752
2680
  function getOutputsContract(outputs) {
2753
- return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
2681
+ return getOutputsByType(outputs, import_transactions12.OutputType.Contract);
2754
2682
  }
2755
2683
 
2756
2684
  // src/providers/transaction-summary/operations.ts
@@ -2759,15 +2687,15 @@ function getReceiptsByType(receipts, type) {
2759
2687
  }
2760
2688
  function getTransactionTypeName(transactionType) {
2761
2689
  switch (transactionType) {
2762
- case import_transactions14.TransactionType.Mint:
2690
+ case import_transactions13.TransactionType.Mint:
2763
2691
  return "Mint" /* Mint */;
2764
- case import_transactions14.TransactionType.Create:
2692
+ case import_transactions13.TransactionType.Create:
2765
2693
  return "Create" /* Create */;
2766
- case import_transactions14.TransactionType.Script:
2694
+ case import_transactions13.TransactionType.Script:
2767
2695
  return "Script" /* Script */;
2768
2696
  default:
2769
- throw new import_errors11.FuelError(
2770
- import_errors11.ErrorCode.INVALID_TRANSACTION_TYPE,
2697
+ throw new import_errors10.FuelError(
2698
+ import_errors10.ErrorCode.INVALID_TRANSACTION_TYPE,
2771
2699
  `Invalid transaction type: ${transactionType}.`
2772
2700
  );
2773
2701
  }
@@ -2786,10 +2714,10 @@ function isTypeScript(transactionType) {
2786
2714
  return isType(transactionType, "Script" /* Script */);
2787
2715
  }
2788
2716
  function getReceiptsCall(receipts) {
2789
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2717
+ return getReceiptsByType(receipts, import_transactions13.ReceiptType.Call);
2790
2718
  }
2791
2719
  function getReceiptsMessageOut(receipts) {
2792
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
2720
+ return getReceiptsByType(receipts, import_transactions13.ReceiptType.MessageOut);
2793
2721
  }
2794
2722
  var mergeAssets = (op1, op2) => {
2795
2723
  const assets1 = op1.assetsSent || [];
@@ -2802,7 +2730,7 @@ var mergeAssets = (op1, op2) => {
2802
2730
  if (!matchingAsset) {
2803
2731
  return asset1;
2804
2732
  }
2805
- const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
2733
+ const mergedAmount = (0, import_math12.bn)(asset1.amount).add(matchingAsset.amount);
2806
2734
  return { ...asset1, amount: mergedAmount };
2807
2735
  });
2808
2736
  return mergedAssets.concat(filteredAssets);
@@ -2928,7 +2856,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
2928
2856
  const { to: toAddress, assetId, amount } = receipt;
2929
2857
  let { from: fromAddress } = receipt;
2930
2858
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
2931
- if (import_configs11.ZeroBytes32 === fromAddress) {
2859
+ if (import_configs9.ZeroBytes32 === fromAddress) {
2932
2860
  const change = changeOutputs.find((output) => output.assetId === assetId);
2933
2861
  fromAddress = change?.to || fromAddress;
2934
2862
  }
@@ -2985,11 +2913,11 @@ function getTransferOperations({
2985
2913
  });
2986
2914
  const transferReceipts = getReceiptsByType(
2987
2915
  receipts,
2988
- import_transactions14.ReceiptType.Transfer
2916
+ import_transactions13.ReceiptType.Transfer
2989
2917
  );
2990
2918
  const transferOutReceipts = getReceiptsByType(
2991
2919
  receipts,
2992
- import_transactions14.ReceiptType.TransferOut
2920
+ import_transactions13.ReceiptType.TransferOut
2993
2921
  );
2994
2922
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
2995
2923
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3074,17 +3002,17 @@ function getOperations({
3074
3002
  }
3075
3003
 
3076
3004
  // src/providers/transaction-summary/receipt.ts
3077
- var import_transactions15 = require("@fuel-ts/transactions");
3005
+ var import_transactions14 = require("@fuel-ts/transactions");
3078
3006
  var processGqlReceipt = (gqlReceipt) => {
3079
3007
  const receipt = assembleReceiptByType(gqlReceipt);
3080
3008
  switch (receipt.type) {
3081
- case import_transactions15.ReceiptType.ReturnData: {
3009
+ case import_transactions14.ReceiptType.ReturnData: {
3082
3010
  return {
3083
3011
  ...receipt,
3084
3012
  data: gqlReceipt.data || "0x"
3085
3013
  };
3086
3014
  }
3087
- case import_transactions15.ReceiptType.LogData: {
3015
+ case import_transactions14.ReceiptType.LogData: {
3088
3016
  return {
3089
3017
  ...receipt,
3090
3018
  data: gqlReceipt.data || "0x"
@@ -3097,7 +3025,7 @@ var processGqlReceipt = (gqlReceipt) => {
3097
3025
  var extractMintedAssetsFromReceipts = (receipts) => {
3098
3026
  const mintedAssets = [];
3099
3027
  receipts.forEach((receipt) => {
3100
- if (receipt.type === import_transactions15.ReceiptType.Mint) {
3028
+ if (receipt.type === import_transactions14.ReceiptType.Mint) {
3101
3029
  mintedAssets.push({
3102
3030
  subId: receipt.subId,
3103
3031
  contractId: receipt.contractId,
@@ -3111,7 +3039,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3111
3039
  var extractBurnedAssetsFromReceipts = (receipts) => {
3112
3040
  const burnedAssets = [];
3113
3041
  receipts.forEach((receipt) => {
3114
- if (receipt.type === import_transactions15.ReceiptType.Burn) {
3042
+ if (receipt.type === import_transactions14.ReceiptType.Burn) {
3115
3043
  burnedAssets.push({
3116
3044
  subId: receipt.subId,
3117
3045
  contractId: receipt.contractId,
@@ -3124,7 +3052,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3124
3052
  };
3125
3053
 
3126
3054
  // src/providers/transaction-summary/status.ts
3127
- var import_errors12 = require("@fuel-ts/errors");
3055
+ var import_errors11 = require("@fuel-ts/errors");
3128
3056
  var getTransactionStatusName = (gqlStatus) => {
3129
3057
  switch (gqlStatus) {
3130
3058
  case "FailureStatus":
@@ -3136,8 +3064,8 @@ var getTransactionStatusName = (gqlStatus) => {
3136
3064
  case "SqueezedOutStatus":
3137
3065
  return "squeezedout" /* squeezedout */;
3138
3066
  default:
3139
- throw new import_errors12.FuelError(
3140
- import_errors12.ErrorCode.INVALID_TRANSACTION_STATUS,
3067
+ throw new import_errors11.FuelError(
3068
+ import_errors11.ErrorCode.INVALID_TRANSACTION_STATUS,
3141
3069
  `Invalid transaction status: ${gqlStatus}.`
3142
3070
  );
3143
3071
  }
@@ -3250,12 +3178,12 @@ function assembleTransactionSummary(params) {
3250
3178
 
3251
3179
  // src/providers/transaction-response/getDecodedLogs.ts
3252
3180
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
3253
- var import_transactions16 = require("@fuel-ts/transactions");
3181
+ var import_transactions15 = require("@fuel-ts/transactions");
3254
3182
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3255
3183
  return receipts.reduce((logs, receipt) => {
3256
- if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3184
+ if (receipt.type === import_transactions15.ReceiptType.LogData || receipt.type === import_transactions15.ReceiptType.Log) {
3257
3185
  const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3258
- const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3186
+ const data = receipt.type === import_transactions15.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3259
3187
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3260
3188
  logs.push(decodedLog);
3261
3189
  }
@@ -3270,7 +3198,7 @@ var TransactionResponse = class {
3270
3198
  /** Current provider */
3271
3199
  provider;
3272
3200
  /** Gas used on the transaction */
3273
- gasUsed = (0, import_math14.bn)(0);
3201
+ gasUsed = (0, import_math13.bn)(0);
3274
3202
  /** The graphql Transaction with receipts object. */
3275
3203
  gqlTransaction;
3276
3204
  abis;
@@ -3328,7 +3256,7 @@ var TransactionResponse = class {
3328
3256
  * @returns The decoded transaction.
3329
3257
  */
3330
3258
  decodeTransaction(transactionWithReceipts) {
3331
- return new import_transactions17.TransactionCoder().decode(
3259
+ return new import_transactions16.TransactionCoder().decode(
3332
3260
  (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3333
3261
  0
3334
3262
  )?.[0];
@@ -3375,8 +3303,8 @@ var TransactionResponse = class {
3375
3303
  });
3376
3304
  for await (const { statusChange } of subscription) {
3377
3305
  if (statusChange.type === "SqueezedOutStatus") {
3378
- throw new import_errors13.FuelError(
3379
- import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3306
+ throw new import_errors12.FuelError(
3307
+ import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3380
3308
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3381
3309
  );
3382
3310
  }
@@ -3398,26 +3326,14 @@ var TransactionResponse = class {
3398
3326
  gqlTransaction: this.gqlTransaction,
3399
3327
  ...transactionSummary
3400
3328
  };
3401
- let logs = [];
3402
3329
  if (this.abis) {
3403
- logs = getDecodedLogs(
3330
+ const logs = getDecodedLogs(
3404
3331
  transactionSummary.receipts,
3405
3332
  this.abis.main,
3406
3333
  this.abis.otherContractsAbis
3407
3334
  );
3408
3335
  transactionResult.logs = logs;
3409
3336
  }
3410
- if (transactionResult.isStatusFailure) {
3411
- const {
3412
- receipts,
3413
- gqlTransaction: { status }
3414
- } = transactionResult;
3415
- throw extractTxError({
3416
- receipts,
3417
- status,
3418
- logs
3419
- });
3420
- }
3421
3337
  return transactionResult;
3422
3338
  }
3423
3339
  /**
@@ -3426,7 +3342,14 @@ var TransactionResponse = class {
3426
3342
  * @param contractsAbiMap - The contracts ABI map.
3427
3343
  */
3428
3344
  async wait(contractsAbiMap) {
3429
- return this.waitForResult(contractsAbiMap);
3345
+ const result = await this.waitForResult(contractsAbiMap);
3346
+ if (result.isStatusFailure) {
3347
+ throw new import_errors12.FuelError(
3348
+ import_errors12.ErrorCode.TRANSACTION_FAILED,
3349
+ `Transaction failed: ${result.gqlTransaction.status.reason}`
3350
+ );
3351
+ }
3352
+ return result;
3430
3353
  }
3431
3354
  };
3432
3355
 
@@ -3488,29 +3411,30 @@ var processGqlChain = (chain) => {
3488
3411
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3489
3412
  return {
3490
3413
  name,
3491
- baseChainHeight: (0, import_math15.bn)(daHeight),
3414
+ baseChainHeight: (0, import_math14.bn)(daHeight),
3492
3415
  consensusParameters: {
3493
- contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3494
- maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3495
- maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3496
- maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3497
- maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3498
- maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3499
- maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3500
- maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3501
- maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3502
- maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3503
- maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3504
- gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3505
- gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3506
- maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3507
- chainId: (0, import_math15.bn)(consensusParameters.chainId),
3416
+ contractMaxSize: (0, import_math14.bn)(contractParams.contractMaxSize),
3417
+ maxInputs: (0, import_math14.bn)(txParams.maxInputs),
3418
+ maxOutputs: (0, import_math14.bn)(txParams.maxOutputs),
3419
+ maxWitnesses: (0, import_math14.bn)(txParams.maxWitnesses),
3420
+ maxGasPerTx: (0, import_math14.bn)(txParams.maxGasPerTx),
3421
+ maxScriptLength: (0, import_math14.bn)(scriptParams.maxScriptLength),
3422
+ maxScriptDataLength: (0, import_math14.bn)(scriptParams.maxScriptDataLength),
3423
+ maxStorageSlots: (0, import_math14.bn)(contractParams.maxStorageSlots),
3424
+ maxPredicateLength: (0, import_math14.bn)(predicateParams.maxPredicateLength),
3425
+ maxPredicateDataLength: (0, import_math14.bn)(predicateParams.maxPredicateDataLength),
3426
+ maxGasPerPredicate: (0, import_math14.bn)(predicateParams.maxGasPerPredicate),
3427
+ gasPriceFactor: (0, import_math14.bn)(feeParams.gasPriceFactor),
3428
+ gasPerByte: (0, import_math14.bn)(feeParams.gasPerByte),
3429
+ maxMessageDataLength: (0, import_math14.bn)(predicateParams.maxMessageDataLength),
3430
+ chainId: (0, import_math14.bn)(consensusParameters.chainId),
3431
+ baseAssetId: consensusParameters.baseAssetId,
3508
3432
  gasCosts
3509
3433
  },
3510
3434
  gasCosts,
3511
3435
  latestBlock: {
3512
3436
  id: latestBlock.id,
3513
- height: (0, import_math15.bn)(latestBlock.header.height),
3437
+ height: (0, import_math14.bn)(latestBlock.header.height),
3514
3438
  time: latestBlock.header.time,
3515
3439
  transactions: latestBlock.transactions.map((i) => ({
3516
3440
  id: i.id
@@ -3580,8 +3504,8 @@ var _Provider = class {
3580
3504
  getChain() {
3581
3505
  const chain = _Provider.chainInfoCache[this.url];
3582
3506
  if (!chain) {
3583
- throw new import_errors14.FuelError(
3584
- import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3507
+ throw new import_errors13.FuelError(
3508
+ import_errors13.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3585
3509
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3586
3510
  );
3587
3511
  }
@@ -3593,8 +3517,8 @@ var _Provider = class {
3593
3517
  getNode() {
3594
3518
  const node = _Provider.nodeInfoCache[this.url];
3595
3519
  if (!node) {
3596
- throw new import_errors14.FuelError(
3597
- import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
3520
+ throw new import_errors13.FuelError(
3521
+ import_errors13.ErrorCode.NODE_INFO_CACHE_EMPTY,
3598
3522
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3599
3523
  );
3600
3524
  }
@@ -3641,8 +3565,8 @@ var _Provider = class {
3641
3565
  static ensureClientVersionIsSupported(nodeInfo) {
3642
3566
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3643
3567
  if (!isMajorSupported || !isMinorSupported) {
3644
- throw new import_errors14.FuelError(
3645
- import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3568
+ throw new import_errors13.FuelError(
3569
+ import_errors13.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3646
3570
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3647
3571
  );
3648
3572
  }
@@ -3705,7 +3629,7 @@ var _Provider = class {
3705
3629
  */
3706
3630
  async getBlockNumber() {
3707
3631
  const { chain } = await this.operations.getChain();
3708
- return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3632
+ return (0, import_math14.bn)(chain.latestBlock.header.height, 10);
3709
3633
  }
3710
3634
  /**
3711
3635
  * Returns the chain information.
@@ -3715,9 +3639,9 @@ var _Provider = class {
3715
3639
  async fetchNode() {
3716
3640
  const { nodeInfo } = await this.operations.getNodeInfo();
3717
3641
  const processedNodeInfo = {
3718
- maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3719
- maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3720
- minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3642
+ maxDepth: (0, import_math14.bn)(nodeInfo.maxDepth),
3643
+ maxTx: (0, import_math14.bn)(nodeInfo.maxTx),
3644
+ minGasPrice: (0, import_math14.bn)(nodeInfo.minGasPrice),
3721
3645
  nodeVersion: nodeInfo.nodeVersion,
3722
3646
  utxoValidation: nodeInfo.utxoValidation,
3723
3647
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3747,6 +3671,17 @@ var _Provider = class {
3747
3671
  } = this.getChain();
3748
3672
  return chainId.toNumber();
3749
3673
  }
3674
+ /**
3675
+ * Returns the base asset ID
3676
+ *
3677
+ * @returns A promise that resolves to the base asset ID
3678
+ */
3679
+ getBaseAssetId() {
3680
+ const {
3681
+ consensusParameters: { baseAssetId }
3682
+ } = this.getChain();
3683
+ return baseAssetId;
3684
+ }
3750
3685
  /**
3751
3686
  * Submits a transaction to the chain to be executed.
3752
3687
  *
@@ -3763,17 +3698,17 @@ var _Provider = class {
3763
3698
  if (estimateTxDependencies) {
3764
3699
  await this.estimateTxDependencies(transactionRequest);
3765
3700
  }
3766
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3701
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3767
3702
  let abis;
3768
- if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3703
+ if (transactionRequest.type === import_transactions17.TransactionType.Script) {
3769
3704
  abis = transactionRequest.abis;
3770
3705
  }
3771
3706
  if (awaitExecution) {
3772
3707
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3773
3708
  for await (const { submitAndAwait } of subscription) {
3774
3709
  if (submitAndAwait.type === "SqueezedOutStatus") {
3775
- throw new import_errors14.FuelError(
3776
- import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3710
+ throw new import_errors13.FuelError(
3711
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3777
3712
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3778
3713
  );
3779
3714
  }
@@ -3806,7 +3741,7 @@ var _Provider = class {
3806
3741
  if (estimateTxDependencies) {
3807
3742
  return this.estimateTxDependencies(transactionRequest);
3808
3743
  }
3809
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3744
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3810
3745
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3811
3746
  encodedTransaction,
3812
3747
  utxoValidation: utxoValidation || false
@@ -3825,13 +3760,13 @@ var _Provider = class {
3825
3760
  async estimatePredicates(transactionRequest) {
3826
3761
  const shouldEstimatePredicates = Boolean(
3827
3762
  transactionRequest.inputs.find(
3828
- (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math15.BN(input.predicateGasUsed).isZero()
3763
+ (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
3829
3764
  )
3830
3765
  );
3831
3766
  if (!shouldEstimatePredicates) {
3832
3767
  return transactionRequest;
3833
3768
  }
3834
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3769
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3835
3770
  const response = await this.operations.estimatePredicates({
3836
3771
  encodedTransaction
3837
3772
  });
@@ -3840,7 +3775,7 @@ var _Provider = class {
3840
3775
  } = response;
3841
3776
  if (inputs) {
3842
3777
  inputs.forEach((input, index) => {
3843
- if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3778
+ if ("predicateGasUsed" in input && (0, import_math14.bn)(input.predicateGasUsed).gt(0)) {
3844
3779
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3845
3780
  }
3846
3781
  });
@@ -3861,7 +3796,7 @@ var _Provider = class {
3861
3796
  * @returns A promise.
3862
3797
  */
3863
3798
  async estimateTxDependencies(transactionRequest) {
3864
- if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3799
+ if (transactionRequest.type === import_transactions17.TransactionType.Create) {
3865
3800
  return {
3866
3801
  receipts: [],
3867
3802
  outputVariables: 0,
@@ -3874,7 +3809,7 @@ var _Provider = class {
3874
3809
  let outputVariables = 0;
3875
3810
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3876
3811
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3877
- encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
3812
+ encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
3878
3813
  utxoValidation: false
3879
3814
  });
3880
3815
  receipts = gqlReceipts.map(processGqlReceipt);
@@ -3912,7 +3847,7 @@ var _Provider = class {
3912
3847
  if (estimateTxDependencies) {
3913
3848
  return this.estimateTxDependencies(transactionRequest);
3914
3849
  }
3915
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3850
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3916
3851
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3917
3852
  encodedTransaction,
3918
3853
  utxoValidation: true
@@ -3946,14 +3881,14 @@ var _Provider = class {
3946
3881
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
3947
3882
  const chainInfo = this.getChain();
3948
3883
  const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3949
- const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3950
- const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
3884
+ const gasPrice = (0, import_math14.max)(txRequestClone.gasPrice, minGasPrice);
3885
+ const isScriptTransaction = txRequestClone.type === import_transactions17.TransactionType.Script;
3951
3886
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3952
3887
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3953
3888
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3954
3889
  if (estimatePredicates) {
3955
3890
  if (isScriptTransaction) {
3956
- txRequestClone.gasLimit = (0, import_math15.bn)(0);
3891
+ txRequestClone.gasLimit = (0, import_math14.bn)(0);
3957
3892
  }
3958
3893
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3959
3894
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -3969,8 +3904,8 @@ var _Provider = class {
3969
3904
  let missingContractIds = [];
3970
3905
  let outputVariables = 0;
3971
3906
  if (isScriptTransaction && estimateTxDependencies) {
3972
- txRequestClone.gasPrice = (0, import_math15.bn)(0);
3973
- txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3907
+ txRequestClone.gasPrice = (0, import_math14.bn)(0);
3908
+ txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3974
3909
  const result = await this.estimateTxDependencies(txRequestClone);
3975
3910
  receipts = result.receipts;
3976
3911
  outputVariables = result.outputVariables;
@@ -4026,17 +3961,17 @@ var _Provider = class {
4026
3961
  const result = await this.operations.getCoins({
4027
3962
  first: 10,
4028
3963
  ...paginationArgs,
4029
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
3964
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4030
3965
  });
4031
3966
  const coins = result.coins.edges.map((edge) => edge.node);
4032
3967
  return coins.map((coin) => ({
4033
3968
  id: coin.utxoId,
4034
3969
  assetId: coin.assetId,
4035
- amount: (0, import_math15.bn)(coin.amount),
3970
+ amount: (0, import_math14.bn)(coin.amount),
4036
3971
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4037
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4038
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4039
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
3972
+ maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
3973
+ blockCreated: (0, import_math14.bn)(coin.blockCreated),
3974
+ txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4040
3975
  }));
4041
3976
  }
4042
3977
  /**
@@ -4050,19 +3985,19 @@ var _Provider = class {
4050
3985
  async getResourcesToSpend(owner, quantities, excludedIds) {
4051
3986
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4052
3987
  const excludeInput = {
4053
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4054
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
3988
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
3989
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4055
3990
  };
4056
3991
  if (this.cache) {
4057
3992
  const uniqueUtxos = new Set(
4058
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
3993
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4059
3994
  );
4060
3995
  excludeInput.utxos = Array.from(uniqueUtxos);
4061
3996
  }
4062
3997
  const coinsQuery = {
4063
3998
  owner: ownerAddress.toB256(),
4064
3999
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4065
- assetId: (0, import_utils23.hexlify)(assetId),
4000
+ assetId: (0, import_utils22.hexlify)(assetId),
4066
4001
  amount: amount.toString(10),
4067
4002
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4068
4003
  })),
@@ -4073,9 +4008,9 @@ var _Provider = class {
4073
4008
  switch (coin.__typename) {
4074
4009
  case "MessageCoin":
4075
4010
  return {
4076
- amount: (0, import_math15.bn)(coin.amount),
4011
+ amount: (0, import_math14.bn)(coin.amount),
4077
4012
  assetId: coin.assetId,
4078
- daHeight: (0, import_math15.bn)(coin.daHeight),
4013
+ daHeight: (0, import_math14.bn)(coin.daHeight),
4079
4014
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4080
4015
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4081
4016
  nonce: coin.nonce
@@ -4083,12 +4018,12 @@ var _Provider = class {
4083
4018
  case "Coin":
4084
4019
  return {
4085
4020
  id: coin.utxoId,
4086
- amount: (0, import_math15.bn)(coin.amount),
4021
+ amount: (0, import_math14.bn)(coin.amount),
4087
4022
  assetId: coin.assetId,
4088
4023
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4089
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4090
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4091
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4024
+ maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
4025
+ blockCreated: (0, import_math14.bn)(coin.blockCreated),
4026
+ txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4092
4027
  };
4093
4028
  default:
4094
4029
  return null;
@@ -4105,13 +4040,13 @@ var _Provider = class {
4105
4040
  async getBlock(idOrHeight) {
4106
4041
  let variables;
4107
4042
  if (typeof idOrHeight === "number") {
4108
- variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4043
+ variables = { height: (0, import_math14.bn)(idOrHeight).toString(10) };
4109
4044
  } else if (idOrHeight === "latest") {
4110
4045
  variables = { height: (await this.getBlockNumber()).toString(10) };
4111
4046
  } else if (idOrHeight.length === 66) {
4112
4047
  variables = { blockId: idOrHeight };
4113
4048
  } else {
4114
- variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4049
+ variables = { blockId: (0, import_math14.bn)(idOrHeight).toString(10) };
4115
4050
  }
4116
4051
  const { block } = await this.operations.getBlock(variables);
4117
4052
  if (!block) {
@@ -4119,7 +4054,7 @@ var _Provider = class {
4119
4054
  }
4120
4055
  return {
4121
4056
  id: block.id,
4122
- height: (0, import_math15.bn)(block.header.height),
4057
+ height: (0, import_math14.bn)(block.header.height),
4123
4058
  time: block.header.time,
4124
4059
  transactionIds: block.transactions.map((tx) => tx.id)
4125
4060
  };
@@ -4134,7 +4069,7 @@ var _Provider = class {
4134
4069
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4135
4070
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4136
4071
  id: block.id,
4137
- height: (0, import_math15.bn)(block.header.height),
4072
+ height: (0, import_math14.bn)(block.header.height),
4138
4073
  time: block.header.time,
4139
4074
  transactionIds: block.transactions.map((tx) => tx.id)
4140
4075
  }));
@@ -4149,7 +4084,7 @@ var _Provider = class {
4149
4084
  async getBlockWithTransactions(idOrHeight) {
4150
4085
  let variables;
4151
4086
  if (typeof idOrHeight === "number") {
4152
- variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4087
+ variables = { blockHeight: (0, import_math14.bn)(idOrHeight).toString(10) };
4153
4088
  } else if (idOrHeight === "latest") {
4154
4089
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4155
4090
  } else {
@@ -4161,11 +4096,11 @@ var _Provider = class {
4161
4096
  }
4162
4097
  return {
4163
4098
  id: block.id,
4164
- height: (0, import_math15.bn)(block.header.height, 10),
4099
+ height: (0, import_math14.bn)(block.header.height, 10),
4165
4100
  time: block.header.time,
4166
4101
  transactionIds: block.transactions.map((tx) => tx.id),
4167
4102
  transactions: block.transactions.map(
4168
- (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4103
+ (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4169
4104
  )
4170
4105
  };
4171
4106
  }
@@ -4180,8 +4115,8 @@ var _Provider = class {
4180
4115
  if (!transaction) {
4181
4116
  return null;
4182
4117
  }
4183
- return new import_transactions18.TransactionCoder().decode(
4184
- (0, import_utils23.arrayify)(transaction.rawPayload),
4118
+ return new import_transactions17.TransactionCoder().decode(
4119
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4185
4120
  0
4186
4121
  )?.[0];
4187
4122
  }
@@ -4208,9 +4143,9 @@ var _Provider = class {
4208
4143
  async getContractBalance(contractId, assetId) {
4209
4144
  const { contractBalance } = await this.operations.getContractBalance({
4210
4145
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4211
- asset: (0, import_utils23.hexlify)(assetId)
4146
+ asset: (0, import_utils22.hexlify)(assetId)
4212
4147
  });
4213
- return (0, import_math15.bn)(contractBalance.amount, 10);
4148
+ return (0, import_math14.bn)(contractBalance.amount, 10);
4214
4149
  }
4215
4150
  /**
4216
4151
  * Returns the balance for the given owner for the given asset ID.
@@ -4222,9 +4157,9 @@ var _Provider = class {
4222
4157
  async getBalance(owner, assetId) {
4223
4158
  const { balance } = await this.operations.getBalance({
4224
4159
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4225
- assetId: (0, import_utils23.hexlify)(assetId)
4160
+ assetId: (0, import_utils22.hexlify)(assetId)
4226
4161
  });
4227
- return (0, import_math15.bn)(balance.amount, 10);
4162
+ return (0, import_math14.bn)(balance.amount, 10);
4228
4163
  }
4229
4164
  /**
4230
4165
  * Returns balances for the given owner.
@@ -4242,7 +4177,7 @@ var _Provider = class {
4242
4177
  const balances = result.balances.edges.map((edge) => edge.node);
4243
4178
  return balances.map((balance) => ({
4244
4179
  assetId: balance.assetId,
4245
- amount: (0, import_math15.bn)(balance.amount)
4180
+ amount: (0, import_math14.bn)(balance.amount)
4246
4181
  }));
4247
4182
  }
4248
4183
  /**
@@ -4260,19 +4195,19 @@ var _Provider = class {
4260
4195
  });
4261
4196
  const messages = result.messages.edges.map((edge) => edge.node);
4262
4197
  return messages.map((message) => ({
4263
- messageId: import_transactions18.InputMessageCoder.getMessageId({
4198
+ messageId: import_transactions17.InputMessageCoder.getMessageId({
4264
4199
  sender: message.sender,
4265
4200
  recipient: message.recipient,
4266
4201
  nonce: message.nonce,
4267
- amount: (0, import_math15.bn)(message.amount),
4202
+ amount: (0, import_math14.bn)(message.amount),
4268
4203
  data: message.data
4269
4204
  }),
4270
4205
  sender: import_address3.Address.fromAddressOrString(message.sender),
4271
4206
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4272
4207
  nonce: message.nonce,
4273
- amount: (0, import_math15.bn)(message.amount),
4274
- data: import_transactions18.InputMessageCoder.decodeData(message.data),
4275
- daHeight: (0, import_math15.bn)(message.daHeight)
4208
+ amount: (0, import_math14.bn)(message.amount),
4209
+ data: import_transactions17.InputMessageCoder.decodeData(message.data),
4210
+ daHeight: (0, import_math14.bn)(message.daHeight)
4276
4211
  }));
4277
4212
  }
4278
4213
  /**
@@ -4290,8 +4225,8 @@ var _Provider = class {
4290
4225
  nonce
4291
4226
  };
4292
4227
  if (commitBlockId && commitBlockHeight) {
4293
- throw new import_errors14.FuelError(
4294
- import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
4228
+ throw new import_errors13.FuelError(
4229
+ import_errors13.ErrorCode.INVALID_INPUT_PARAMETERS,
4295
4230
  "commitBlockId and commitBlockHeight cannot be used together"
4296
4231
  );
4297
4232
  }
@@ -4325,41 +4260,41 @@ var _Provider = class {
4325
4260
  } = result.messageProof;
4326
4261
  return {
4327
4262
  messageProof: {
4328
- proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4263
+ proofIndex: (0, import_math14.bn)(messageProof.proofIndex),
4329
4264
  proofSet: messageProof.proofSet
4330
4265
  },
4331
4266
  blockProof: {
4332
- proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4267
+ proofIndex: (0, import_math14.bn)(blockProof.proofIndex),
4333
4268
  proofSet: blockProof.proofSet
4334
4269
  },
4335
4270
  messageBlockHeader: {
4336
4271
  id: messageBlockHeader.id,
4337
- daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4338
- transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4272
+ daHeight: (0, import_math14.bn)(messageBlockHeader.daHeight),
4273
+ transactionsCount: (0, import_math14.bn)(messageBlockHeader.transactionsCount),
4339
4274
  transactionsRoot: messageBlockHeader.transactionsRoot,
4340
- height: (0, import_math15.bn)(messageBlockHeader.height),
4275
+ height: (0, import_math14.bn)(messageBlockHeader.height),
4341
4276
  prevRoot: messageBlockHeader.prevRoot,
4342
4277
  time: messageBlockHeader.time,
4343
4278
  applicationHash: messageBlockHeader.applicationHash,
4344
4279
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4345
- messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4280
+ messageReceiptCount: (0, import_math14.bn)(messageBlockHeader.messageReceiptCount)
4346
4281
  },
4347
4282
  commitBlockHeader: {
4348
4283
  id: commitBlockHeader.id,
4349
- daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4350
- transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4284
+ daHeight: (0, import_math14.bn)(commitBlockHeader.daHeight),
4285
+ transactionsCount: (0, import_math14.bn)(commitBlockHeader.transactionsCount),
4351
4286
  transactionsRoot: commitBlockHeader.transactionsRoot,
4352
- height: (0, import_math15.bn)(commitBlockHeader.height),
4287
+ height: (0, import_math14.bn)(commitBlockHeader.height),
4353
4288
  prevRoot: commitBlockHeader.prevRoot,
4354
4289
  time: commitBlockHeader.time,
4355
4290
  applicationHash: commitBlockHeader.applicationHash,
4356
4291
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4357
- messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4292
+ messageReceiptCount: (0, import_math14.bn)(commitBlockHeader.messageReceiptCount)
4358
4293
  },
4359
4294
  sender: import_address3.Address.fromAddressOrString(sender),
4360
4295
  recipient: import_address3.Address.fromAddressOrString(recipient),
4361
4296
  nonce,
4362
- amount: (0, import_math15.bn)(amount),
4297
+ amount: (0, import_math14.bn)(amount),
4363
4298
  data
4364
4299
  };
4365
4300
  }
@@ -4382,10 +4317,10 @@ var _Provider = class {
4382
4317
  */
4383
4318
  async produceBlocks(amount, startTime) {
4384
4319
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4385
- blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4386
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4320
+ blocksToProduce: (0, import_math14.bn)(amount).toString(10),
4321
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4387
4322
  });
4388
- return (0, import_math15.bn)(latestBlockHeight);
4323
+ return (0, import_math14.bn)(latestBlockHeight);
4389
4324
  }
4390
4325
  // eslint-disable-next-line @typescript-eslint/require-await
4391
4326
  async getTransactionResponse(transactionId) {
@@ -4399,7 +4334,7 @@ cacheInputs_fn = function(inputs) {
4399
4334
  return;
4400
4335
  }
4401
4336
  inputs.forEach((input) => {
4402
- if (input.type === import_transactions18.InputType.Coin) {
4337
+ if (input.type === import_transactions17.InputType.Coin) {
4403
4338
  this.cache?.set(input.id);
4404
4339
  }
4405
4340
  });
@@ -4408,10 +4343,10 @@ __publicField(Provider, "chainInfoCache", {});
4408
4343
  __publicField(Provider, "nodeInfoCache", {});
4409
4344
 
4410
4345
  // src/providers/transaction-summary/get-transaction-summary.ts
4411
- var import_errors15 = require("@fuel-ts/errors");
4412
- var import_math16 = require("@fuel-ts/math");
4413
- var import_transactions19 = require("@fuel-ts/transactions");
4414
- var import_utils26 = require("@fuel-ts/utils");
4346
+ var import_errors14 = require("@fuel-ts/errors");
4347
+ var import_math15 = require("@fuel-ts/math");
4348
+ var import_transactions18 = require("@fuel-ts/transactions");
4349
+ var import_utils25 = require("@fuel-ts/utils");
4415
4350
 
4416
4351
  // src/providers/chains.ts
4417
4352
  var CHAIN_IDS = {
@@ -4460,17 +4395,17 @@ var assets = [
4460
4395
 
4461
4396
  // src/utils/formatTransferToContractScriptData.ts
4462
4397
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
4463
- var import_math17 = require("@fuel-ts/math");
4464
- var import_utils27 = require("@fuel-ts/utils");
4398
+ var import_math16 = require("@fuel-ts/math");
4399
+ var import_utils26 = require("@fuel-ts/utils");
4465
4400
  var asm = __toESM(require("@fuels/vm-asm"));
4466
4401
  var formatTransferToContractScriptData = (params) => {
4467
4402
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4468
4403
  const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4469
- const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4404
+ const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4470
4405
  const scriptData = Uint8Array.from([
4471
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
4406
+ ...(0, import_utils26.arrayify)(hexlifiedContractId),
4472
4407
  ...encoded,
4473
- ...(0, import_utils27.arrayify)(assetId)
4408
+ ...(0, import_utils26.arrayify)(assetId)
4474
4409
  ]);
4475
4410
  return scriptData;
4476
4411
  };
@@ -4526,7 +4461,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4526
4461
  */
4527
4462
  get provider() {
4528
4463
  if (!this._provider) {
4529
- throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
4464
+ throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_PROVIDER, "Provider not set");
4530
4465
  }
4531
4466
  return this._provider;
4532
4467
  }
@@ -4578,8 +4513,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4578
4513
  if (!hasNextPage) {
4579
4514
  break;
4580
4515
  }
4581
- throw new import_errors16.FuelError(
4582
- import_errors16.ErrorCode.NOT_SUPPORTED,
4516
+ throw new import_errors15.FuelError(
4517
+ import_errors15.ErrorCode.NOT_SUPPORTED,
4583
4518
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4584
4519
  );
4585
4520
  }
@@ -4604,8 +4539,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4604
4539
  if (!hasNextPage) {
4605
4540
  break;
4606
4541
  }
4607
- throw new import_errors16.FuelError(
4608
- import_errors16.ErrorCode.NOT_SUPPORTED,
4542
+ throw new import_errors15.FuelError(
4543
+ import_errors15.ErrorCode.NOT_SUPPORTED,
4609
4544
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4610
4545
  );
4611
4546
  }
@@ -4617,8 +4552,9 @@ var Account = class extends import_interfaces.AbstractAccount {
4617
4552
  * @param assetId - The asset ID to check the balance for.
4618
4553
  * @returns A promise that resolves to the balance amount.
4619
4554
  */
4620
- async getBalance(assetId = import_configs12.BaseAssetId) {
4621
- const amount = await this.provider.getBalance(this.address, assetId);
4555
+ async getBalance(assetId) {
4556
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4557
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4622
4558
  return amount;
4623
4559
  }
4624
4560
  /**
@@ -4640,8 +4576,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4640
4576
  if (!hasNextPage) {
4641
4577
  break;
4642
4578
  }
4643
- throw new import_errors16.FuelError(
4644
- import_errors16.ErrorCode.NOT_SUPPORTED,
4579
+ throw new import_errors15.FuelError(
4580
+ import_errors15.ErrorCode.NOT_SUPPORTED,
4645
4581
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4646
4582
  );
4647
4583
  }
@@ -4656,16 +4592,17 @@ var Account = class extends import_interfaces.AbstractAccount {
4656
4592
  * @returns A promise that resolves when the resources are added to the transaction.
4657
4593
  */
4658
4594
  async fund(request, coinQuantities, fee) {
4595
+ const baseAssetId = this.provider.getBaseAssetId();
4659
4596
  const updatedQuantities = addAmountToAsset({
4660
- amount: (0, import_math18.bn)(fee),
4661
- assetId: import_configs12.BaseAssetId,
4597
+ amount: (0, import_math17.bn)(fee),
4598
+ assetId: baseAssetId,
4662
4599
  coinQuantities
4663
4600
  });
4664
4601
  const quantitiesDict = {};
4665
4602
  updatedQuantities.forEach(({ amount, assetId }) => {
4666
4603
  quantitiesDict[assetId] = {
4667
4604
  required: amount,
4668
- owned: (0, import_math18.bn)(0)
4605
+ owned: (0, import_math17.bn)(0)
4669
4606
  };
4670
4607
  });
4671
4608
  const cachedUtxos = [];
@@ -4678,12 +4615,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4678
4615
  if (isCoin2) {
4679
4616
  const assetId = String(input.assetId);
4680
4617
  if (input.owner === owner && quantitiesDict[assetId]) {
4681
- const amount = (0, import_math18.bn)(input.amount);
4618
+ const amount = (0, import_math17.bn)(input.amount);
4682
4619
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4683
4620
  cachedUtxos.push(input.id);
4684
4621
  }
4685
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4686
- quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4622
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4623
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4687
4624
  cachedMessages.push(input.nonce);
4688
4625
  }
4689
4626
  }
@@ -4715,17 +4652,18 @@ var Account = class extends import_interfaces.AbstractAccount {
4715
4652
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4716
4653
  * @returns A promise that resolves to the prepared transaction request.
4717
4654
  */
4718
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4655
+ async createTransfer(destination, amount, assetId, txParams = {}) {
4719
4656
  const { minGasPrice } = this.provider.getGasConfig();
4657
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4720
4658
  const params = { gasPrice: minGasPrice, ...txParams };
4721
4659
  const request = new ScriptTransactionRequest(params);
4722
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
4660
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
4723
4661
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4724
4662
  estimateTxDependencies: true,
4725
4663
  resourcesOwner: this
4726
4664
  });
4727
- request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
4728
- request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
4665
+ request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
4666
+ request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
4729
4667
  this.validateGas({
4730
4668
  gasUsed,
4731
4669
  gasPrice: request.gasPrice,
@@ -4745,14 +4683,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4745
4683
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4746
4684
  * @returns A promise that resolves to the transaction response.
4747
4685
  */
4748
- async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4749
- if ((0, import_math18.bn)(amount).lte(0)) {
4750
- throw new import_errors16.FuelError(
4751
- import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4686
+ async transfer(destination, amount, assetId, txParams = {}) {
4687
+ if ((0, import_math17.bn)(amount).lte(0)) {
4688
+ throw new import_errors15.FuelError(
4689
+ import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
4752
4690
  "Transfer amount must be a positive number."
4753
4691
  );
4754
4692
  }
4755
- const request = await this.createTransfer(destination, amount, assetId, txParams);
4693
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4694
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
4756
4695
  return this.sendTransaction(request, { estimateTxDependencies: false });
4757
4696
  }
4758
4697
  /**
@@ -4764,20 +4703,21 @@ var Account = class extends import_interfaces.AbstractAccount {
4764
4703
  * @param txParams - The optional transaction parameters.
4765
4704
  * @returns A promise that resolves to the transaction response.
4766
4705
  */
4767
- async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4768
- if ((0, import_math18.bn)(amount).lte(0)) {
4769
- throw new import_errors16.FuelError(
4770
- import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4706
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
4707
+ if ((0, import_math17.bn)(amount).lte(0)) {
4708
+ throw new import_errors15.FuelError(
4709
+ import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
4771
4710
  "Transfer amount must be a positive number."
4772
4711
  );
4773
4712
  }
4774
4713
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4775
4714
  const { minGasPrice } = this.provider.getGasConfig();
4715
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4776
4716
  const params = { gasPrice: minGasPrice, ...txParams };
4777
4717
  const { script, scriptData } = await assembleTransferToContractScript({
4778
4718
  hexlifiedContractId: contractAddress.toB256(),
4779
- amountToTransfer: (0, import_math18.bn)(amount),
4780
- assetId
4719
+ amountToTransfer: (0, import_math17.bn)(amount),
4720
+ assetId: assetIdToTransfer
4781
4721
  });
4782
4722
  const request = new ScriptTransactionRequest({
4783
4723
  ...params,
@@ -4787,9 +4727,9 @@ var Account = class extends import_interfaces.AbstractAccount {
4787
4727
  request.addContractInputAndOutput(contractAddress);
4788
4728
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4789
4729
  request,
4790
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
4730
+ [{ amount: (0, import_math17.bn)(amount), assetId: String(assetIdToTransfer) }]
4791
4731
  );
4792
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4732
+ request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
4793
4733
  this.validateGas({
4794
4734
  gasUsed,
4795
4735
  gasPrice: request.gasPrice,
@@ -4809,26 +4749,27 @@ var Account = class extends import_interfaces.AbstractAccount {
4809
4749
  */
4810
4750
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4811
4751
  const { minGasPrice } = this.provider.getGasConfig();
4752
+ const baseAssetId = this.provider.getBaseAssetId();
4812
4753
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
4813
- const recipientDataArray = (0, import_utils28.arrayify)(
4754
+ const recipientDataArray = (0, import_utils27.arrayify)(
4814
4755
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4815
4756
  );
4816
- const amountDataArray = (0, import_utils28.arrayify)(
4817
- "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
4757
+ const amountDataArray = (0, import_utils27.arrayify)(
4758
+ "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
4818
4759
  );
4819
4760
  const script = new Uint8Array([
4820
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
4761
+ ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4821
4762
  ...recipientDataArray,
4822
4763
  ...amountDataArray
4823
4764
  ]);
4824
4765
  const params = { script, gasPrice: minGasPrice, ...txParams };
4825
4766
  const request = new ScriptTransactionRequest(params);
4826
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
4767
+ const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: baseAssetId }];
4827
4768
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4828
4769
  request,
4829
4770
  forwardingQuantities
4830
4771
  );
4831
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4772
+ request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
4832
4773
  this.validateGas({
4833
4774
  gasUsed,
4834
4775
  gasPrice: request.gasPrice,
@@ -4840,7 +4781,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4840
4781
  }
4841
4782
  async signMessage(message) {
4842
4783
  if (!this._connector) {
4843
- throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
4784
+ throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
4844
4785
  }
4845
4786
  return this._connector.signMessage(this.address.toString(), message);
4846
4787
  }
@@ -4852,8 +4793,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4852
4793
  */
4853
4794
  async signTransaction(transactionRequestLike) {
4854
4795
  if (!this._connector) {
4855
- throw new import_errors16.FuelError(
4856
- import_errors16.ErrorCode.MISSING_CONNECTOR,
4796
+ throw new import_errors15.FuelError(
4797
+ import_errors15.ErrorCode.MISSING_CONNECTOR,
4857
4798
  "A connector is required to sign transactions."
4858
4799
  );
4859
4800
  }
@@ -4900,14 +4841,14 @@ var Account = class extends import_interfaces.AbstractAccount {
4900
4841
  minGasPrice
4901
4842
  }) {
4902
4843
  if (minGasPrice.gt(gasPrice)) {
4903
- throw new import_errors16.FuelError(
4904
- import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4844
+ throw new import_errors15.FuelError(
4845
+ import_errors15.ErrorCode.GAS_PRICE_TOO_LOW,
4905
4846
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4906
4847
  );
4907
4848
  }
4908
4849
  if (gasUsed.gt(gasLimit)) {
4909
- throw new import_errors16.FuelError(
4910
- import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
4850
+ throw new import_errors15.FuelError(
4851
+ import_errors15.ErrorCode.GAS_LIMIT_TOO_LOW,
4911
4852
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
4912
4853
  );
4913
4854
  }
@@ -4918,8 +4859,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4918
4859
  var import_address5 = require("@fuel-ts/address");
4919
4860
  var import_crypto = require("@fuel-ts/crypto");
4920
4861
  var import_hasher2 = require("@fuel-ts/hasher");
4921
- var import_math19 = require("@fuel-ts/math");
4922
- var import_utils29 = require("@fuel-ts/utils");
4862
+ var import_math18 = require("@fuel-ts/math");
4863
+ var import_utils28 = require("@fuel-ts/utils");
4923
4864
  var import_secp256k1 = require("@noble/curves/secp256k1");
4924
4865
  var Signer = class {
4925
4866
  address;
@@ -4938,10 +4879,10 @@ var Signer = class {
4938
4879
  privateKey = `0x${privateKey}`;
4939
4880
  }
4940
4881
  }
4941
- const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
4942
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4943
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4944
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4882
+ const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
4883
+ this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
4884
+ this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4885
+ this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4945
4886
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
4946
4887
  }
4947
4888
  /**
@@ -4955,11 +4896,11 @@ var Signer = class {
4955
4896
  * @returns hashed signature
4956
4897
  */
4957
4898
  sign(data) {
4958
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
4959
- const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
4960
- const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
4899
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
4900
+ const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
4901
+ const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
4961
4902
  s[0] |= (signature.recovery || 0) << 7;
4962
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
4903
+ return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4963
4904
  }
4964
4905
  /**
4965
4906
  * Add point on the current elliptic curve
@@ -4968,8 +4909,8 @@ var Signer = class {
4968
4909
  * @returns compressed point on the curve
4969
4910
  */
4970
4911
  addPoint(point) {
4971
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
4972
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
4912
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
4913
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
4973
4914
  const result = p0.add(p1);
4974
4915
  return `0x${result.toHex(true)}`;
4975
4916
  }
@@ -4981,16 +4922,16 @@ var Signer = class {
4981
4922
  * @returns public key from signature from the
4982
4923
  */
4983
4924
  static recoverPublicKey(data, signature) {
4984
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
4925
+ const signedMessageBytes = (0, import_utils28.arrayify)(signature);
4985
4926
  const r = signedMessageBytes.slice(0, 32);
4986
4927
  const s = signedMessageBytes.slice(32, 64);
4987
4928
  const recoveryParam = (s[0] & 128) >> 7;
4988
4929
  s[0] &= 127;
4989
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
4930
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
4990
4931
  recoveryParam
4991
4932
  );
4992
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
4993
- return (0, import_utils29.hexlify)(publicKey);
4933
+ const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
4934
+ return (0, import_utils28.hexlify)(publicKey);
4994
4935
  }
4995
4936
  /**
4996
4937
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5009,7 +4950,7 @@ var Signer = class {
5009
4950
  * @returns random 32-byte hashed
5010
4951
  */
5011
4952
  static generatePrivateKey(entropy) {
5012
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
4953
+ return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5013
4954
  }
5014
4955
  /**
5015
4956
  * Extended publicKey from a compact publicKey
@@ -5018,16 +4959,16 @@ var Signer = class {
5018
4959
  * @returns extended publicKey
5019
4960
  */
5020
4961
  static extendPublicKey(publicKey) {
5021
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5022
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
4962
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
4963
+ return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5023
4964
  }
5024
4965
  };
5025
4966
 
5026
4967
  // src/wallet/keystore-wallet.ts
5027
4968
  var import_address6 = require("@fuel-ts/address");
5028
4969
  var import_crypto2 = require("@fuel-ts/crypto");
5029
- var import_errors17 = require("@fuel-ts/errors");
5030
- var import_utils30 = require("@fuel-ts/utils");
4970
+ var import_errors16 = require("@fuel-ts/errors");
4971
+ var import_utils29 = require("@fuel-ts/utils");
5031
4972
  var import_uuid = require("uuid");
5032
4973
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5033
4974
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5104,13 +5045,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5104
5045
  const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5105
5046
  const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5106
5047
  if (mac !== macHash) {
5107
- throw new import_errors17.FuelError(
5108
- import_errors17.ErrorCode.INVALID_PASSWORD,
5048
+ throw new import_errors16.FuelError(
5049
+ import_errors16.ErrorCode.INVALID_PASSWORD,
5109
5050
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5110
5051
  );
5111
5052
  }
5112
5053
  const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5113
- const privateKey = (0, import_utils30.hexlify)(buffer);
5054
+ const privateKey = (0, import_utils29.hexlify)(buffer);
5114
5055
  return privateKey;
5115
5056
  }
5116
5057
 
@@ -5155,7 +5096,7 @@ var BaseWalletUnlocked = class extends Account {
5155
5096
  */
5156
5097
  async signMessage(message) {
5157
5098
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5158
- return (0, import_utils31.hexlify)(signedMessage);
5099
+ return (0, import_utils30.hexlify)(signedMessage);
5159
5100
  }
5160
5101
  /**
5161
5102
  * Signs a transaction with the wallet's private key.
@@ -5168,7 +5109,7 @@ var BaseWalletUnlocked = class extends Account {
5168
5109
  const chainId = this.provider.getChainId();
5169
5110
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5170
5111
  const signature = await this.signer().sign(hashedTransaction);
5171
- return (0, import_utils31.hexlify)(signature);
5112
+ return (0, import_utils30.hexlify)(signature);
5172
5113
  }
5173
5114
  /**
5174
5115
  * Populates a transaction with the witnesses signature.
@@ -5227,17 +5168,17 @@ var BaseWalletUnlocked = class extends Account {
5227
5168
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5228
5169
 
5229
5170
  // src/hdwallet/hdwallet.ts
5230
- var import_errors20 = require("@fuel-ts/errors");
5171
+ var import_errors19 = require("@fuel-ts/errors");
5231
5172
  var import_hasher6 = require("@fuel-ts/hasher");
5232
- var import_math20 = require("@fuel-ts/math");
5233
- var import_utils35 = require("@fuel-ts/utils");
5173
+ var import_math19 = require("@fuel-ts/math");
5174
+ var import_utils34 = require("@fuel-ts/utils");
5234
5175
  var import_ethers3 = require("ethers");
5235
5176
 
5236
5177
  // src/mnemonic/mnemonic.ts
5237
5178
  var import_crypto3 = require("@fuel-ts/crypto");
5238
- var import_errors19 = require("@fuel-ts/errors");
5179
+ var import_errors18 = require("@fuel-ts/errors");
5239
5180
  var import_hasher5 = require("@fuel-ts/hasher");
5240
- var import_utils33 = require("@fuel-ts/utils");
5181
+ var import_utils32 = require("@fuel-ts/utils");
5241
5182
  var import_ethers2 = require("ethers");
5242
5183
 
5243
5184
  // src/wordlists/words/english.ts
@@ -7293,9 +7234,9 @@ var english = [
7293
7234
  ];
7294
7235
 
7295
7236
  // src/mnemonic/utils.ts
7296
- var import_errors18 = require("@fuel-ts/errors");
7237
+ var import_errors17 = require("@fuel-ts/errors");
7297
7238
  var import_hasher4 = require("@fuel-ts/hasher");
7298
- var import_utils32 = require("@fuel-ts/utils");
7239
+ var import_utils31 = require("@fuel-ts/utils");
7299
7240
  function toUtf8Bytes(stri) {
7300
7241
  const str = stri.normalize("NFKD");
7301
7242
  const result = [];
@@ -7310,8 +7251,8 @@ function toUtf8Bytes(stri) {
7310
7251
  i += 1;
7311
7252
  const c2 = str.charCodeAt(i);
7312
7253
  if (i >= str.length || (c2 & 64512) !== 56320) {
7313
- throw new import_errors18.FuelError(
7314
- import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
7254
+ throw new import_errors17.FuelError(
7255
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
7315
7256
  "Invalid UTF-8 in the input string."
7316
7257
  );
7317
7258
  }
@@ -7362,20 +7303,20 @@ function entropyToMnemonicIndices(entropy) {
7362
7303
  }
7363
7304
  }
7364
7305
  const checksumBits = entropy.length / 4;
7365
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7306
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7366
7307
  indices[indices.length - 1] <<= checksumBits;
7367
7308
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7368
7309
  return indices;
7369
7310
  }
7370
7311
  function mnemonicWordsToEntropy(words, wordlist) {
7371
7312
  const size = Math.ceil(11 * words.length / 8);
7372
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7313
+ const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7373
7314
  let offset = 0;
7374
7315
  for (let i = 0; i < words.length; i += 1) {
7375
7316
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7376
7317
  if (index === -1) {
7377
- throw new import_errors18.FuelError(
7378
- import_errors18.ErrorCode.INVALID_MNEMONIC,
7318
+ throw new import_errors17.FuelError(
7319
+ import_errors17.ErrorCode.INVALID_MNEMONIC,
7379
7320
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7380
7321
  );
7381
7322
  }
@@ -7389,10 +7330,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
7389
7330
  const entropyBits = 32 * words.length / 3;
7390
7331
  const checksumBits = words.length / 3;
7391
7332
  const checksumMask = getUpperMask(checksumBits);
7392
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7333
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7393
7334
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7394
- throw new import_errors18.FuelError(
7395
- import_errors18.ErrorCode.INVALID_CHECKSUM,
7335
+ throw new import_errors17.FuelError(
7336
+ import_errors17.ErrorCode.INVALID_CHECKSUM,
7396
7337
  "Checksum validation failed for the provided mnemonic."
7397
7338
  );
7398
7339
  }
@@ -7406,16 +7347,16 @@ var TestnetPRV = "0x04358394";
7406
7347
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7407
7348
  function assertWordList(wordlist) {
7408
7349
  if (wordlist.length !== 2048) {
7409
- throw new import_errors19.FuelError(
7410
- import_errors19.ErrorCode.INVALID_WORD_LIST,
7350
+ throw new import_errors18.FuelError(
7351
+ import_errors18.ErrorCode.INVALID_WORD_LIST,
7411
7352
  `Expected word list length of 2048, but got ${wordlist.length}.`
7412
7353
  );
7413
7354
  }
7414
7355
  }
7415
7356
  function assertEntropy(entropy) {
7416
7357
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7417
- throw new import_errors19.FuelError(
7418
- import_errors19.ErrorCode.INVALID_ENTROPY,
7358
+ throw new import_errors18.FuelError(
7359
+ import_errors18.ErrorCode.INVALID_ENTROPY,
7419
7360
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7420
7361
  );
7421
7362
  }
@@ -7425,7 +7366,7 @@ function assertMnemonic(words) {
7425
7366
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7426
7367
  ", "
7427
7368
  )}] words, but got ${words.length}.`;
7428
- throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
7369
+ throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
7429
7370
  }
7430
7371
  }
7431
7372
  var Mnemonic = class {
@@ -7464,7 +7405,7 @@ var Mnemonic = class {
7464
7405
  static mnemonicToEntropy(phrase, wordlist = english) {
7465
7406
  const words = getWords(phrase);
7466
7407
  assertMnemonic(words);
7467
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7408
+ return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7468
7409
  }
7469
7410
  /**
7470
7411
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7472,7 +7413,7 @@ var Mnemonic = class {
7472
7413
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7473
7414
  */
7474
7415
  static entropyToMnemonic(entropy, wordlist = english) {
7475
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
7416
+ const entropyBytes = (0, import_utils32.arrayify)(entropy);
7476
7417
  assertWordList(wordlist);
7477
7418
  assertEntropy(entropyBytes);
7478
7419
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7541,14 +7482,14 @@ var Mnemonic = class {
7541
7482
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7542
7483
  */
7543
7484
  static masterKeysFromSeed(seed) {
7544
- const seedArray = (0, import_utils33.arrayify)(seed);
7485
+ const seedArray = (0, import_utils32.arrayify)(seed);
7545
7486
  if (seedArray.length < 16 || seedArray.length > 64) {
7546
- throw new import_errors19.FuelError(
7547
- import_errors19.ErrorCode.INVALID_SEED,
7487
+ throw new import_errors18.FuelError(
7488
+ import_errors18.ErrorCode.INVALID_SEED,
7548
7489
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7549
7490
  );
7550
7491
  }
7551
- return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7492
+ return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7552
7493
  }
7553
7494
  /**
7554
7495
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7559,22 +7500,22 @@ var Mnemonic = class {
7559
7500
  */
7560
7501
  static seedToExtendedKey(seed, testnet = false) {
7561
7502
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7562
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7503
+ const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7563
7504
  const depth = "0x00";
7564
7505
  const fingerprint = "0x00000000";
7565
7506
  const index = "0x00000000";
7566
7507
  const chainCode = masterKey.slice(32);
7567
7508
  const privateKey = masterKey.slice(0, 32);
7568
- const extendedKey = (0, import_utils33.concat)([
7509
+ const extendedKey = (0, import_utils32.concat)([
7569
7510
  prefix,
7570
7511
  depth,
7571
7512
  fingerprint,
7572
7513
  index,
7573
7514
  chainCode,
7574
- (0, import_utils33.concat)(["0x00", privateKey])
7515
+ (0, import_utils32.concat)(["0x00", privateKey])
7575
7516
  ]);
7576
7517
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7577
- return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7518
+ return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7578
7519
  }
7579
7520
  /**
7580
7521
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7589,7 +7530,7 @@ var Mnemonic = class {
7589
7530
  * @returns A randomly generated mnemonic
7590
7531
  */
7591
7532
  static generate(size = 32, extraEntropy = "") {
7592
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7533
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7593
7534
  return Mnemonic.entropyToMnemonic(entropy);
7594
7535
  }
7595
7536
  };
@@ -7597,12 +7538,12 @@ var mnemonic_default = Mnemonic;
7597
7538
 
7598
7539
  // src/hdwallet/hdwallet.ts
7599
7540
  var HARDENED_INDEX = 2147483648;
7600
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7601
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7602
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7603
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7541
+ var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7542
+ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7543
+ var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7544
+ var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7604
7545
  function base58check(data) {
7605
- return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7546
+ return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7606
7547
  }
7607
7548
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7608
7549
  if (isPublic) {
@@ -7611,17 +7552,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7611
7552
  return testnet ? TestnetPRV2 : MainnetPRV2;
7612
7553
  }
7613
7554
  function isPublicExtendedKey(extendedKey) {
7614
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7555
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7615
7556
  }
7616
7557
  function isValidExtendedKey(extendedKey) {
7617
7558
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7618
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7559
+ (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7619
7560
  );
7620
7561
  }
7621
7562
  function parsePath(path2, depth = 0) {
7622
7563
  const components = path2.split("/");
7623
7564
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7624
- throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
7565
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
7625
7566
  }
7626
7567
  if (components[0] === "m") {
7627
7568
  components.shift();
@@ -7633,8 +7574,8 @@ function parsePath(path2, depth = 0) {
7633
7574
  var HDWallet = class {
7634
7575
  depth = 0;
7635
7576
  index = 0;
7636
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
7637
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7577
+ fingerprint = (0, import_utils34.hexlify)("0x00000000");
7578
+ parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7638
7579
  privateKey;
7639
7580
  publicKey;
7640
7581
  chainCode;
@@ -7646,16 +7587,16 @@ var HDWallet = class {
7646
7587
  constructor(config) {
7647
7588
  if (config.privateKey) {
7648
7589
  const signer = new Signer(config.privateKey);
7649
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7650
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7590
+ this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7591
+ this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7651
7592
  } else {
7652
7593
  if (!config.publicKey) {
7653
- throw new import_errors20.FuelError(
7654
- import_errors20.ErrorCode.HD_WALLET_ERROR,
7594
+ throw new import_errors19.FuelError(
7595
+ import_errors19.ErrorCode.HD_WALLET_ERROR,
7655
7596
  "Both public and private Key cannot be missing. At least one should be provided."
7656
7597
  );
7657
7598
  }
7658
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7599
+ this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7659
7600
  }
7660
7601
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7661
7602
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7674,28 +7615,28 @@ var HDWallet = class {
7674
7615
  * @returns A new instance of HDWallet on the derived index
7675
7616
  */
7676
7617
  deriveIndex(index) {
7677
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7678
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7679
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7618
+ const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7619
+ const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7620
+ const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7680
7621
  const data = new Uint8Array(37);
7681
7622
  if (index & HARDENED_INDEX) {
7682
7623
  if (!privateKey) {
7683
- throw new import_errors20.FuelError(
7684
- import_errors20.ErrorCode.HD_WALLET_ERROR,
7624
+ throw new import_errors19.FuelError(
7625
+ import_errors19.ErrorCode.HD_WALLET_ERROR,
7685
7626
  "Cannot derive a hardened index without a private Key."
7686
7627
  );
7687
7628
  }
7688
7629
  data.set(privateKey, 1);
7689
7630
  } else {
7690
- data.set((0, import_utils35.arrayify)(this.publicKey));
7631
+ data.set((0, import_utils34.arrayify)(this.publicKey));
7691
7632
  }
7692
- data.set((0, import_math20.toBytes)(index, 4), 33);
7693
- const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7633
+ data.set((0, import_math19.toBytes)(index, 4), 33);
7634
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7694
7635
  const IL = bytes.slice(0, 32);
7695
7636
  const IR = bytes.slice(32);
7696
7637
  if (privateKey) {
7697
7638
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7698
- const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7639
+ const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
7699
7640
  return new HDWallet({
7700
7641
  privateKey: ki,
7701
7642
  chainCode: IR,
@@ -7704,7 +7645,7 @@ var HDWallet = class {
7704
7645
  parentFingerprint: this.fingerprint
7705
7646
  });
7706
7647
  }
7707
- const signer = new Signer((0, import_utils35.hexlify)(IL));
7648
+ const signer = new Signer((0, import_utils34.hexlify)(IL));
7708
7649
  const Ki = signer.addPoint(publicKey);
7709
7650
  return new HDWallet({
7710
7651
  publicKey: Ki,
@@ -7733,18 +7674,18 @@ var HDWallet = class {
7733
7674
  */
7734
7675
  toExtendedKey(isPublic = false, testnet = false) {
7735
7676
  if (this.depth >= 256) {
7736
- throw new import_errors20.FuelError(
7737
- import_errors20.ErrorCode.HD_WALLET_ERROR,
7677
+ throw new import_errors19.FuelError(
7678
+ import_errors19.ErrorCode.HD_WALLET_ERROR,
7738
7679
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
7739
7680
  );
7740
7681
  }
7741
7682
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7742
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
7683
+ const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7743
7684
  const parentFingerprint = this.parentFingerprint;
7744
- const index = (0, import_math20.toHex)(this.index, 4);
7685
+ const index = (0, import_math19.toHex)(this.index, 4);
7745
7686
  const chainCode = this.chainCode;
7746
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7747
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7687
+ const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
7688
+ const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7748
7689
  return base58check(extendedKey);
7749
7690
  }
7750
7691
  /**
@@ -7756,34 +7697,34 @@ var HDWallet = class {
7756
7697
  static fromSeed(seed) {
7757
7698
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7758
7699
  return new HDWallet({
7759
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7760
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
7700
+ chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
7701
+ privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7761
7702
  });
7762
7703
  }
7763
7704
  static fromExtendedKey(extendedKey) {
7764
7705
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
7765
- const bytes = (0, import_utils35.arrayify)(decoded);
7706
+ const bytes = (0, import_utils34.arrayify)(decoded);
7766
7707
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7767
7708
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7768
- throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7709
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7769
7710
  }
7770
7711
  if (!validChecksum) {
7771
- throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7712
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7772
7713
  }
7773
7714
  const depth = bytes[4];
7774
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7775
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7776
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
7715
+ const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
7716
+ const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7717
+ const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7777
7718
  const key = bytes.slice(45, 78);
7778
7719
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7779
- throw new import_errors20.FuelError(
7780
- import_errors20.ErrorCode.HD_WALLET_ERROR,
7720
+ throw new import_errors19.FuelError(
7721
+ import_errors19.ErrorCode.HD_WALLET_ERROR,
7781
7722
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
7782
7723
  );
7783
7724
  }
7784
7725
  if (isPublicExtendedKey(bytes)) {
7785
7726
  if (key[0] !== 3) {
7786
- throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
7727
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
7787
7728
  }
7788
7729
  return new HDWallet({
7789
7730
  publicKey: key,
@@ -7794,7 +7735,7 @@ var HDWallet = class {
7794
7735
  });
7795
7736
  }
7796
7737
  if (key[0] !== 0) {
7797
- throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
7738
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
7798
7739
  }
7799
7740
  return new HDWallet({
7800
7741
  privateKey: key.slice(1),
@@ -7987,9 +7928,9 @@ var generateTestWallet = async (provider, quantities) => {
7987
7928
  };
7988
7929
 
7989
7930
  // src/test-utils/launchNode.ts
7990
- var import_configs13 = require("@fuel-ts/address/configs");
7991
- var import_math21 = require("@fuel-ts/math");
7992
- var import_utils36 = require("@fuel-ts/utils");
7931
+ var import_configs10 = require("@fuel-ts/address/configs");
7932
+ var import_math20 = require("@fuel-ts/math");
7933
+ var import_utils35 = require("@fuel-ts/utils");
7993
7934
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
7994
7935
  var import_child_process = require("child_process");
7995
7936
  var import_crypto5 = require("crypto");
@@ -8047,7 +7988,7 @@ var launchNode = async ({
8047
7988
  "--poa-instant"
8048
7989
  ]);
8049
7990
  const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8050
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
7991
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8051
7992
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8052
7993
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8053
7994
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -8073,21 +8014,21 @@ var launchNode = async ({
8073
8014
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8074
8015
  }
8075
8016
  const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
8076
- let chainConfig = import_utils36.defaultChainConfig;
8017
+ let chainConfig = import_utils35.defaultChainConfig;
8077
8018
  if (!process.env.GENESIS_SECRET) {
8078
8019
  const pk = Signer.generatePrivateKey();
8079
8020
  const signer = new Signer(pk);
8080
- process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8021
+ process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8081
8022
  chainConfig = {
8082
- ...import_utils36.defaultChainConfig,
8023
+ ...import_utils35.defaultChainConfig,
8083
8024
  initial_state: {
8084
- ...import_utils36.defaultChainConfig.initial_state,
8025
+ ...import_utils35.defaultChainConfig.initial_state,
8085
8026
  coins: [
8086
- ...import_utils36.defaultChainConfig.initial_state.coins,
8027
+ ...import_utils35.defaultChainConfig.initial_state.coins,
8087
8028
  {
8088
8029
  owner: signer.address.toHexString(),
8089
- amount: (0, import_math21.toHex)(1e9),
8090
- asset_id: import_configs13.BaseAssetId
8030
+ amount: (0, import_math20.toHex)(1e9),
8031
+ asset_id: import_utils35.defaultChainConfig?.consensus_parameters?.base_asset_id ?? import_configs10.ZeroBytes32
8091
8032
  }
8092
8033
  ]
8093
8034
  }
@@ -8153,9 +8094,10 @@ var launchNode = async ({
8153
8094
  })
8154
8095
  );
8155
8096
  var generateWallets = async (count, provider) => {
8097
+ const baseAssetId = provider.getBaseAssetId();
8156
8098
  const wallets = [];
8157
8099
  for (let i = 0; i < count; i += 1) {
8158
- const wallet = await generateTestWallet(provider, [[1e3, import_configs13.BaseAssetId]]);
8100
+ const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8159
8101
  wallets.push(wallet);
8160
8102
  }
8161
8103
  return wallets;