@fuel-ts/account 0.0.0-rc-2037-20240417224607 → 0.0.0-rc-1976-20240418110250

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.

Files changed (45) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/index.global.js +101 -125
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +241 -280
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +126 -159
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts +2 -11
  9. package/dist/predicate/predicate.d.ts.map +1 -1
  10. package/dist/providers/coin-quantity.d.ts +2 -2
  11. package/dist/providers/coin-quantity.d.ts.map +1 -1
  12. package/dist/providers/coin.d.ts +1 -2
  13. package/dist/providers/coin.d.ts.map +1 -1
  14. package/dist/providers/message.d.ts +0 -1
  15. package/dist/providers/message.d.ts.map +1 -1
  16. package/dist/providers/provider.d.ts +7 -0
  17. package/dist/providers/provider.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  19. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/index.d.ts +0 -1
  21. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
  23. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  24. package/dist/providers/transaction-request/transaction-request.d.ts +25 -6
  25. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  26. package/dist/test-utils/index.d.ts +0 -1
  27. package/dist/test-utils/index.d.ts.map +1 -1
  28. package/dist/test-utils/launchNode.d.ts.map +1 -1
  29. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  30. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  31. package/dist/test-utils.global.js +106 -105
  32. package/dist/test-utils.global.js.map +1 -1
  33. package/dist/test-utils.js +238 -253
  34. package/dist/test-utils.js.map +1 -1
  35. package/dist/test-utils.mjs +129 -141
  36. package/dist/test-utils.mjs.map +1 -1
  37. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  38. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  39. package/package.json +15 -15
  40. package/dist/providers/transaction-request/helpers.d.ts +0 -10
  41. package/dist/providers/transaction-request/helpers.d.ts.map +0 -1
  42. package/dist/test-utils/resources.d.ts +0 -4
  43. package/dist/test-utils/resources.d.ts.map +0 -1
  44. package/dist/test-utils/transactionRequest.d.ts +0 -5
  45. package/dist/test-utils/transactionRequest.d.ts.map +0 -1
@@ -24,14 +24,12 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
24
24
 
25
25
  // src/account.ts
26
26
  import { Address as Address3 } from "@fuel-ts/address";
27
- import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
28
27
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
29
28
  import { AbstractAccount } from "@fuel-ts/interfaces";
30
29
  import { bn as bn17 } from "@fuel-ts/math";
31
30
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
32
31
 
33
32
  // src/providers/coin-quantity.ts
34
- import { BaseAssetId } from "@fuel-ts/address/configs";
35
33
  import { bn } from "@fuel-ts/math";
36
34
  import { hexlify } from "@fuel-ts/utils";
37
35
  var coinQuantityfy = (coinQuantityLike) => {
@@ -40,11 +38,11 @@ var coinQuantityfy = (coinQuantityLike) => {
40
38
  let max2;
41
39
  if (Array.isArray(coinQuantityLike)) {
42
40
  amount = coinQuantityLike[0];
43
- assetId = coinQuantityLike[1] ?? BaseAssetId;
44
- max2 = coinQuantityLike[2] ?? void 0;
41
+ assetId = coinQuantityLike[1];
42
+ max2 = coinQuantityLike[2];
45
43
  } else {
46
44
  amount = coinQuantityLike.amount;
47
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
45
+ assetId = coinQuantityLike.assetId;
48
46
  max2 = coinQuantityLike.max ?? void 0;
49
47
  }
50
48
  const bnAmount = bn(amount);
@@ -71,7 +69,7 @@ import { Address as Address2 } from "@fuel-ts/address";
71
69
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
72
70
  import { BN, bn as bn15, max } from "@fuel-ts/math";
73
71
  import {
74
- InputType as InputType7,
72
+ InputType as InputType6,
75
73
  TransactionType as TransactionType8,
76
74
  InputMessageCoder,
77
75
  TransactionCoder as TransactionCoder5
@@ -1162,13 +1160,13 @@ var outputify = (value) => {
1162
1160
  // src/providers/transaction-request/transaction-request.ts
1163
1161
  import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1164
1162
  import { Address, addressify } from "@fuel-ts/address";
1165
- import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1163
+ import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1166
1164
  import { randomBytes } from "@fuel-ts/crypto";
1167
1165
  import { bn as bn7 } from "@fuel-ts/math";
1168
1166
  import {
1169
1167
  PolicyType,
1170
1168
  TransactionCoder,
1171
- InputType as InputType3,
1169
+ InputType as InputType2,
1172
1170
  OutputType as OutputType2,
1173
1171
  TransactionType
1174
1172
  } from "@fuel-ts/transactions";
@@ -1597,12 +1595,6 @@ var NoWitnessAtIndexError = class extends Error {
1597
1595
  name = "NoWitnessAtIndexError";
1598
1596
  };
1599
1597
 
1600
- // src/providers/transaction-request/helpers.ts
1601
- import { InputType as InputType2 } from "@fuel-ts/transactions";
1602
- var isRequestInputCoin = (input) => input.type === InputType2.Coin;
1603
- var isRequestInputMessage = (input) => input.type === InputType2.Message;
1604
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1605
-
1606
1598
  // src/providers/transaction-request/witness.ts
1607
1599
  import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
1608
1600
  var witnessify = (value) => {
@@ -1629,6 +1621,8 @@ var BaseTransactionRequest = class {
1629
1621
  outputs = [];
1630
1622
  /** List of witnesses */
1631
1623
  witnesses = [];
1624
+ /** Base asset ID - should be fetched from the chain */
1625
+ baseAssetId;
1632
1626
  /**
1633
1627
  * Constructor for initializing a base transaction request.
1634
1628
  *
@@ -1641,8 +1635,9 @@ var BaseTransactionRequest = class {
1641
1635
  witnessLimit,
1642
1636
  inputs,
1643
1637
  outputs,
1644
- witnesses
1645
- } = {}) {
1638
+ witnesses,
1639
+ baseAssetId
1640
+ }) {
1646
1641
  this.gasPrice = bn7(gasPrice);
1647
1642
  this.maturity = maturity ?? 0;
1648
1643
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
@@ -1650,6 +1645,7 @@ var BaseTransactionRequest = class {
1650
1645
  this.inputs = inputs ?? [];
1651
1646
  this.outputs = outputs ?? [];
1652
1647
  this.witnesses = witnesses ?? [];
1648
+ this.baseAssetId = baseAssetId;
1653
1649
  }
1654
1650
  static getPolicyMeta(req) {
1655
1651
  let policyTypes = 0;
@@ -1793,7 +1789,7 @@ var BaseTransactionRequest = class {
1793
1789
  */
1794
1790
  getCoinInputs() {
1795
1791
  return this.inputs.filter(
1796
- (input) => input.type === InputType3.Coin
1792
+ (input) => input.type === InputType2.Coin
1797
1793
  );
1798
1794
  }
1799
1795
  /**
@@ -1825,9 +1821,9 @@ var BaseTransactionRequest = class {
1825
1821
  const ownerAddress = addressify(owner);
1826
1822
  const found = this.inputs.find((input) => {
1827
1823
  switch (input.type) {
1828
- case InputType3.Coin:
1824
+ case InputType2.Coin:
1829
1825
  return hexlify7(input.owner) === ownerAddress.toB256();
1830
- case InputType3.Message:
1826
+ case InputType2.Message:
1831
1827
  return hexlify7(input.recipient) === ownerAddress.toB256();
1832
1828
  default:
1833
1829
  return false;
@@ -1843,8 +1839,8 @@ var BaseTransactionRequest = class {
1843
1839
  * @param predicate - Predicate bytes.
1844
1840
  * @param predicateData - Predicate data bytes.
1845
1841
  */
1846
- addCoinInput(coin) {
1847
- const { assetId, owner, amount, id, predicate } = coin;
1842
+ addCoinInput(coin, predicate) {
1843
+ const { assetId, owner, amount } = coin;
1848
1844
  let witnessIndex;
1849
1845
  if (predicate) {
1850
1846
  witnessIndex = 0;
@@ -1855,14 +1851,14 @@ var BaseTransactionRequest = class {
1855
1851
  }
1856
1852
  }
1857
1853
  const input = {
1858
- id,
1859
- type: InputType3.Coin,
1854
+ ...coin,
1855
+ type: InputType2.Coin,
1860
1856
  owner: owner.toB256(),
1861
1857
  amount,
1862
1858
  assetId,
1863
1859
  txPointer: "0x00000000000000000000000000000000",
1864
1860
  witnessIndex,
1865
- predicate
1861
+ predicate: predicate?.bytes
1866
1862
  };
1867
1863
  this.pushInput(input);
1868
1864
  this.addChangeOutput(owner, assetId);
@@ -1873,11 +1869,9 @@ var BaseTransactionRequest = class {
1873
1869
  *
1874
1870
  * @param message - Message resource.
1875
1871
  * @param predicate - Predicate bytes.
1876
- * @param predicateData - Predicate data bytes.
1877
1872
  */
1878
- addMessageInput(message) {
1879
- const { recipient, sender, amount, predicate, nonce } = message;
1880
- const assetId = BaseAssetId2;
1873
+ addMessageInput(message, predicate) {
1874
+ const { recipient, sender, amount } = message;
1881
1875
  let witnessIndex;
1882
1876
  if (predicate) {
1883
1877
  witnessIndex = 0;
@@ -1888,16 +1882,16 @@ var BaseTransactionRequest = class {
1888
1882
  }
1889
1883
  }
1890
1884
  const input = {
1891
- nonce,
1892
- type: InputType3.Message,
1885
+ ...message,
1886
+ type: InputType2.Message,
1893
1887
  sender: sender.toB256(),
1894
1888
  recipient: recipient.toB256(),
1895
1889
  amount,
1896
1890
  witnessIndex,
1897
- predicate
1891
+ predicate: predicate?.bytes
1898
1892
  };
1899
1893
  this.pushInput(input);
1900
- this.addChangeOutput(recipient, assetId);
1894
+ this.addChangeOutput(recipient, this.baseAssetId);
1901
1895
  }
1902
1896
  /**
1903
1897
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -1925,6 +1919,32 @@ var BaseTransactionRequest = class {
1925
1919
  resources.forEach((resource) => this.addResource(resource));
1926
1920
  return this;
1927
1921
  }
1922
+ /**
1923
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1924
+ * outputs from the related assetIds.
1925
+ *
1926
+ * @param resources - The resources to add.
1927
+ * @returns This transaction.
1928
+ */
1929
+ addPredicateResource(resource, predicate) {
1930
+ if (isCoin(resource)) {
1931
+ this.addCoinInput(resource, predicate);
1932
+ } else {
1933
+ this.addMessageInput(resource, predicate);
1934
+ }
1935
+ return this;
1936
+ }
1937
+ /**
1938
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
1939
+ * from the related assetIds.
1940
+ *
1941
+ * @param resources - The resources to add.
1942
+ * @returns This transaction.
1943
+ */
1944
+ addPredicateResources(resources, predicate) {
1945
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1946
+ return this;
1947
+ }
1928
1948
  /**
1929
1949
  * Adds a coin output to the transaction.
1930
1950
  *
@@ -1932,12 +1952,12 @@ var BaseTransactionRequest = class {
1932
1952
  * @param amount - Amount of coin.
1933
1953
  * @param assetId - Asset ID of coin.
1934
1954
  */
1935
- addCoinOutput(to, amount, assetId = BaseAssetId2) {
1955
+ addCoinOutput(to, amount, assetId) {
1936
1956
  this.pushOutput({
1937
1957
  type: OutputType2.Coin,
1938
1958
  to: addressify(to).toB256(),
1939
1959
  amount,
1940
- assetId
1960
+ assetId: assetId ?? this.baseAssetId
1941
1961
  });
1942
1962
  return this;
1943
1963
  }
@@ -1964,7 +1984,7 @@ var BaseTransactionRequest = class {
1964
1984
  * @param to - Address of the owner.
1965
1985
  * @param assetId - Asset ID of coin.
1966
1986
  */
1967
- addChangeOutput(to, assetId = BaseAssetId2) {
1987
+ addChangeOutput(to, assetId) {
1968
1988
  const changeOutput = this.getChangeOutputs().find(
1969
1989
  (output) => hexlify7(output.assetId) === assetId
1970
1990
  );
@@ -1972,7 +1992,7 @@ var BaseTransactionRequest = class {
1972
1992
  this.pushOutput({
1973
1993
  type: OutputType2.Change,
1974
1994
  to: addressify(to).toB256(),
1975
- assetId
1995
+ assetId: assetId ?? this.baseAssetId
1976
1996
  });
1977
1997
  }
1978
1998
  }
@@ -2048,7 +2068,7 @@ var BaseTransactionRequest = class {
2048
2068
  ]);
2049
2069
  }
2050
2070
  };
2051
- updateAssetInput(BaseAssetId2, bn7(1e11));
2071
+ updateAssetInput(this.baseAssetId, bn7(1e11));
2052
2072
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2053
2073
  }
2054
2074
  /**
@@ -2073,20 +2093,16 @@ var BaseTransactionRequest = class {
2073
2093
  toJSON() {
2074
2094
  return normalizeJSON(this);
2075
2095
  }
2076
- removeWitness(index) {
2077
- this.witnesses.splice(index, 1);
2078
- this.adjustWitnessIndexes(index);
2079
- }
2080
2096
  updatePredicateInputs(inputs) {
2081
2097
  this.inputs.forEach((i) => {
2082
2098
  let correspondingInput;
2083
2099
  switch (i.type) {
2084
- case InputType3.Coin:
2085
- correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
2100
+ case InputType2.Coin:
2101
+ correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
2086
2102
  break;
2087
- case InputType3.Message:
2103
+ case InputType2.Message:
2088
2104
  correspondingInput = inputs.find(
2089
- (x) => x.type === InputType3.Message && x.sender === i.sender
2105
+ (x) => x.type === InputType2.Message && x.sender === i.sender
2090
2106
  );
2091
2107
  break;
2092
2108
  default:
@@ -2099,13 +2115,6 @@ var BaseTransactionRequest = class {
2099
2115
  }
2100
2116
  });
2101
2117
  }
2102
- adjustWitnessIndexes(removedIndex) {
2103
- this.inputs.filter(isRequestInputResource).forEach((input) => {
2104
- if (input.witnessIndex > removedIndex) {
2105
- input.witnessIndex -= 1;
2106
- }
2107
- });
2108
- }
2109
2118
  };
2110
2119
 
2111
2120
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2118,7 +2127,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2118
2127
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2119
2128
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2120
2129
  import { bn as bn8 } from "@fuel-ts/math";
2121
- import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2130
+ import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2122
2131
  import { concat as concat2 } from "@fuel-ts/utils";
2123
2132
  import { clone as clone2 } from "ramda";
2124
2133
  function hashTransaction(transactionRequest, chainId) {
@@ -2129,7 +2138,7 @@ function hashTransaction(transactionRequest, chainId) {
2129
2138
  transaction.inputs = transaction.inputs.map((input) => {
2130
2139
  const inputClone = clone2(input);
2131
2140
  switch (inputClone.type) {
2132
- case InputType4.Coin: {
2141
+ case InputType3.Coin: {
2133
2142
  inputClone.txPointer = {
2134
2143
  blockHeight: 0,
2135
2144
  txIndex: 0
@@ -2137,11 +2146,11 @@ function hashTransaction(transactionRequest, chainId) {
2137
2146
  inputClone.predicateGasUsed = bn8(0);
2138
2147
  return inputClone;
2139
2148
  }
2140
- case InputType4.Message: {
2149
+ case InputType3.Message: {
2141
2150
  inputClone.predicateGasUsed = bn8(0);
2142
2151
  return inputClone;
2143
2152
  }
2144
- case InputType4.Contract: {
2153
+ case InputType3.Contract: {
2145
2154
  inputClone.txPointer = {
2146
2155
  blockHeight: 0,
2147
2156
  txIndex: 0
@@ -2229,12 +2238,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2229
2238
  *
2230
2239
  * @param createTransactionRequestLike - The initial values for the instance
2231
2240
  */
2232
- constructor({
2233
- bytecodeWitnessIndex,
2234
- salt,
2235
- storageSlots,
2236
- ...rest
2237
- } = {}) {
2241
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2238
2242
  super(rest);
2239
2243
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2240
2244
  this.salt = hexlify9(salt ?? ZeroBytes326);
@@ -2307,7 +2311,7 @@ import { Interface } from "@fuel-ts/abi-coder";
2307
2311
  import { addressify as addressify2 } from "@fuel-ts/address";
2308
2312
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2309
2313
  import { bn as bn10 } from "@fuel-ts/math";
2310
- import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2314
+ import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2311
2315
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2312
2316
 
2313
2317
  // src/providers/transaction-request/scripts.ts
@@ -2358,7 +2362,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2358
2362
  *
2359
2363
  * @param scriptTransactionRequestLike - The initial values for the instance.
2360
2364
  */
2361
- constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2365
+ constructor({ script, scriptData, gasLimit, ...rest }) {
2362
2366
  super(rest);
2363
2367
  this.gasLimit = bn10(gasLimit);
2364
2368
  this.script = arrayify8(script ?? returnZeroScript.bytes);
@@ -2391,7 +2395,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2391
2395
  */
2392
2396
  getContractInputs() {
2393
2397
  return this.inputs.filter(
2394
- (input) => input.type === InputType5.Contract
2398
+ (input) => input.type === InputType4.Contract
2395
2399
  );
2396
2400
  }
2397
2401
  /**
@@ -2467,7 +2471,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2467
2471
  return this;
2468
2472
  }
2469
2473
  const inputIndex = super.pushInput({
2470
- type: InputType5.Contract,
2474
+ type: InputType4.Contract,
2471
2475
  contractId: contractAddress.toB256(),
2472
2476
  txPointer: "0x00000000000000000000000000000000"
2473
2477
  });
@@ -2662,7 +2666,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2662
2666
 
2663
2667
  // src/providers/transaction-summary/input.ts
2664
2668
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2665
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2669
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2666
2670
  function getInputsByTypes(inputs, types) {
2667
2671
  return inputs.filter((i) => types.includes(i.type));
2668
2672
  }
@@ -2670,16 +2674,16 @@ function getInputsByType(inputs, type) {
2670
2674
  return inputs.filter((i) => i.type === type);
2671
2675
  }
2672
2676
  function getInputsCoin(inputs) {
2673
- return getInputsByType(inputs, InputType6.Coin);
2677
+ return getInputsByType(inputs, InputType5.Coin);
2674
2678
  }
2675
2679
  function getInputsMessage(inputs) {
2676
- return getInputsByType(inputs, InputType6.Message);
2680
+ return getInputsByType(inputs, InputType5.Message);
2677
2681
  }
2678
2682
  function getInputsCoinAndMessage(inputs) {
2679
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2683
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2680
2684
  }
2681
2685
  function getInputsContract(inputs) {
2682
- return getInputsByType(inputs, InputType6.Contract);
2686
+ return getInputsByType(inputs, InputType5.Contract);
2683
2687
  }
2684
2688
  function getInputFromAssetId(inputs, assetId) {
2685
2689
  const coinInputs = getInputsCoin(inputs);
@@ -2698,7 +2702,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2698
2702
  if (!contractInput) {
2699
2703
  return void 0;
2700
2704
  }
2701
- if (contractInput.type !== InputType6.Contract) {
2705
+ if (contractInput.type !== InputType5.Contract) {
2702
2706
  throw new FuelError9(
2703
2707
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2704
2708
  `Contract input should be of type 'contract'.`
@@ -2707,10 +2711,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2707
2711
  return contractInput;
2708
2712
  }
2709
2713
  function getInputAccountAddress(input) {
2710
- if (input.type === InputType6.Coin) {
2714
+ if (input.type === InputType5.Coin) {
2711
2715
  return input.owner.toString();
2712
2716
  }
2713
- if (input.type === InputType6.Message) {
2717
+ if (input.type === InputType5.Message) {
2714
2718
  return input.recipient.toString();
2715
2719
  }
2716
2720
  return "";
@@ -3486,6 +3490,7 @@ var processGqlChain = (chain) => {
3486
3490
  gasPerByte: bn15(feeParams.gasPerByte),
3487
3491
  maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3488
3492
  chainId: bn15(consensusParameters.chainId),
3493
+ baseAssetId: consensusParameters.baseAssetId,
3489
3494
  gasCosts
3490
3495
  },
3491
3496
  gasCosts,
@@ -3728,6 +3733,17 @@ var _Provider = class {
3728
3733
  } = this.getChain();
3729
3734
  return chainId.toNumber();
3730
3735
  }
3736
+ /**
3737
+ * Returns the base asset ID
3738
+ *
3739
+ * @returns A promise that resolves to the base asset ID
3740
+ */
3741
+ getBaseAssetId() {
3742
+ const {
3743
+ consensusParameters: { baseAssetId }
3744
+ } = this.getChain();
3745
+ return baseAssetId;
3746
+ }
3731
3747
  /**
3732
3748
  * Submits a transaction to the chain to be executed.
3733
3749
  *
@@ -4407,7 +4423,7 @@ cacheInputs_fn = function(inputs) {
4407
4423
  return;
4408
4424
  }
4409
4425
  inputs.forEach((input) => {
4410
- if (input.type === InputType7.Coin) {
4426
+ if (input.type === InputType6.Coin) {
4411
4427
  this.cache?.set(input.id);
4412
4428
  }
4413
4429
  });
@@ -4625,8 +4641,9 @@ var Account = class extends AbstractAccount {
4625
4641
  * @param assetId - The asset ID to check the balance for.
4626
4642
  * @returns A promise that resolves to the balance amount.
4627
4643
  */
4628
- async getBalance(assetId = BaseAssetId3) {
4629
- const amount = await this.provider.getBalance(this.address, assetId);
4644
+ async getBalance(assetId) {
4645
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4646
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4630
4647
  return amount;
4631
4648
  }
4632
4649
  /**
@@ -4664,9 +4681,10 @@ var Account = class extends AbstractAccount {
4664
4681
  * @returns A promise that resolves when the resources are added to the transaction.
4665
4682
  */
4666
4683
  async fund(request, coinQuantities, fee) {
4684
+ const baseAssetId = this.provider.getBaseAssetId();
4667
4685
  const updatedQuantities = addAmountToAsset({
4668
4686
  amount: bn17(fee),
4669
- assetId: BaseAssetId3,
4687
+ assetId: baseAssetId,
4670
4688
  coinQuantities
4671
4689
  });
4672
4690
  const quantitiesDict = {};
@@ -4690,8 +4708,8 @@ var Account = class extends AbstractAccount {
4690
4708
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4691
4709
  cachedUtxos.push(input.id);
4692
4710
  }
4693
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4694
- quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4711
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4712
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4695
4713
  cachedMessages.push(input.nonce);
4696
4714
  }
4697
4715
  }
@@ -4723,11 +4741,13 @@ var Account = class extends AbstractAccount {
4723
4741
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4724
4742
  * @returns A promise that resolves to the prepared transaction request.
4725
4743
  */
4726
- async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4744
+ async createTransfer(destination, amount, assetId, txParams = {}) {
4727
4745
  const { minGasPrice } = this.provider.getGasConfig();
4728
- const params = { gasPrice: minGasPrice, ...txParams };
4746
+ const baseAssetId = this.provider.getBaseAssetId();
4747
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4748
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
4729
4749
  const request = new ScriptTransactionRequest(params);
4730
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4750
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
4731
4751
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4732
4752
  estimateTxDependencies: true,
4733
4753
  resourcesOwner: this
@@ -4753,14 +4773,15 @@ var Account = class extends AbstractAccount {
4753
4773
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4754
4774
  * @returns A promise that resolves to the transaction response.
4755
4775
  */
4756
- async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4776
+ async transfer(destination, amount, assetId, txParams = {}) {
4757
4777
  if (bn17(amount).lte(0)) {
4758
4778
  throw new FuelError15(
4759
4779
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4760
4780
  "Transfer amount must be a positive number."
4761
4781
  );
4762
4782
  }
4763
- const request = await this.createTransfer(destination, amount, assetId, txParams);
4783
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4784
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
4764
4785
  return this.sendTransaction(request, { estimateTxDependencies: false });
4765
4786
  }
4766
4787
  /**
@@ -4772,7 +4793,7 @@ var Account = class extends AbstractAccount {
4772
4793
  * @param txParams - The optional transaction parameters.
4773
4794
  * @returns A promise that resolves to the transaction response.
4774
4795
  */
4775
- async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4796
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
4776
4797
  if (bn17(amount).lte(0)) {
4777
4798
  throw new FuelError15(
4778
4799
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
@@ -4781,11 +4802,13 @@ var Account = class extends AbstractAccount {
4781
4802
  }
4782
4803
  const contractAddress = Address3.fromAddressOrString(contractId);
4783
4804
  const { minGasPrice } = this.provider.getGasConfig();
4784
- const params = { gasPrice: minGasPrice, ...txParams };
4805
+ const baseAssetId = this.provider.getBaseAssetId();
4806
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4807
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
4785
4808
  const { script, scriptData } = await assembleTransferToContractScript({
4786
4809
  hexlifiedContractId: contractAddress.toB256(),
4787
4810
  amountToTransfer: bn17(amount),
4788
- assetId
4811
+ assetId: assetIdToTransfer
4789
4812
  });
4790
4813
  const request = new ScriptTransactionRequest({
4791
4814
  ...params,
@@ -4795,7 +4818,7 @@ var Account = class extends AbstractAccount {
4795
4818
  request.addContractInputAndOutput(contractAddress);
4796
4819
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4797
4820
  request,
4798
- [{ amount: bn17(amount), assetId: String(assetId) }]
4821
+ [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
4799
4822
  );
4800
4823
  request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4801
4824
  this.validateGas({
@@ -4817,6 +4840,7 @@ var Account = class extends AbstractAccount {
4817
4840
  */
4818
4841
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4819
4842
  const { minGasPrice } = this.provider.getGasConfig();
4843
+ const baseAssetId = this.provider.getBaseAssetId();
4820
4844
  const recipientAddress = Address3.fromAddressOrString(recipient);
4821
4845
  const recipientDataArray = arrayify14(
4822
4846
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -4829,9 +4853,14 @@ var Account = class extends AbstractAccount {
4829
4853
  ...recipientDataArray,
4830
4854
  ...amountDataArray
4831
4855
  ]);
4832
- const params = { script, gasPrice: minGasPrice, ...txParams };
4856
+ const params = {
4857
+ script,
4858
+ gasPrice: minGasPrice,
4859
+ baseAssetId,
4860
+ ...txParams
4861
+ };
4833
4862
  const request = new ScriptTransactionRequest(params);
4834
- const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4863
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
4835
4864
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4836
4865
  request,
4837
4866
  forwardingQuantities
@@ -7977,26 +8006,21 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7977
8006
 
7978
8007
  // src/test-utils/seedTestWallet.ts
7979
8008
  import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
7980
- var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
7981
- const toFundAccounts = Array.isArray(wallet) ? wallet : [wallet];
8009
+ var seedTestWallet = async (wallet, quantities) => {
7982
8010
  const genesisWallet = new WalletUnlocked(
7983
8011
  process.env.GENESIS_SECRET || randomBytes5(32),
7984
- toFundAccounts[0].provider
8012
+ wallet.provider
7985
8013
  );
7986
8014
  const resources = await genesisWallet.getResourcesToSpend(quantities);
7987
8015
  const { minGasPrice } = genesisWallet.provider.getGasConfig();
8016
+ const baseAssetId = genesisWallet.provider.getBaseAssetId();
7988
8017
  const request = new ScriptTransactionRequest({
8018
+ baseAssetId,
7989
8019
  gasLimit: 1e4,
7990
8020
  gasPrice: minGasPrice
7991
8021
  });
7992
8022
  request.addResources(resources);
7993
- quantities.map(coinQuantityfy).forEach(
7994
- ({ amount, assetId }) => toFundAccounts.forEach(({ address }) => {
7995
- for (let i = 0; i < utxosAmount; i++) {
7996
- request.addCoinOutput(address, amount.div(utxosAmount), assetId);
7997
- }
7998
- })
7999
- );
8023
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8000
8024
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8001
8025
  };
8002
8026
 
@@ -8010,7 +8034,7 @@ var generateTestWallet = async (provider, quantities) => {
8010
8034
  };
8011
8035
 
8012
8036
  // src/test-utils/launchNode.ts
8013
- import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8037
+ import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
8014
8038
  import { toHex as toHex2 } from "@fuel-ts/math";
8015
8039
  import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8016
8040
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
@@ -8110,7 +8134,7 @@ var launchNode = async ({
8110
8134
  {
8111
8135
  owner: signer.address.toHexString(),
8112
8136
  amount: toHex2(1e9),
8113
- asset_id: BaseAssetId4
8137
+ asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes329
8114
8138
  }
8115
8139
  ]
8116
8140
  }
@@ -8176,9 +8200,10 @@ var launchNode = async ({
8176
8200
  })
8177
8201
  );
8178
8202
  var generateWallets = async (count, provider) => {
8203
+ const baseAssetId = provider.getBaseAssetId();
8179
8204
  const wallets = [];
8180
8205
  for (let i = 0; i < count; i += 1) {
8181
- const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId4]]);
8206
+ const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8182
8207
  wallets.push(wallet);
8183
8208
  }
8184
8209
  return wallets;
@@ -8195,44 +8220,7 @@ var launchNodeAndGetWallets = async ({
8195
8220
  };
8196
8221
  return { wallets, stop: cleanup, provider };
8197
8222
  };
8198
-
8199
- // src/test-utils/transactionRequest.ts
8200
- import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
8201
- import { getRandomB256 } from "@fuel-ts/address";
8202
- import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
8203
- import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
8204
- import { bn as bn19 } from "@fuel-ts/math";
8205
- import { InputType as InputType8 } from "@fuel-ts/transactions";
8206
- import { hexlify as hexlify19 } from "@fuel-ts/utils";
8207
- var generateFakeRequestInputCoin = (partial = {}) => ({
8208
- id: hexlify19(randomBytes6(UTXO_ID_LEN3)),
8209
- type: InputType8.Coin,
8210
- owner: getRandomB256(),
8211
- amount: bn19(100),
8212
- assetId: ZeroBytes329,
8213
- txPointer: "0x00000000000000000000000000000000",
8214
- witnessIndex: 0,
8215
- ...partial
8216
- });
8217
- var generateFakeRequestInputMessage = (partial = {}) => ({
8218
- nonce: getRandomB256(),
8219
- type: InputType8.Message,
8220
- sender: getRandomB256(),
8221
- recipient: getRandomB256(),
8222
- amount: bn19(100),
8223
- witnessIndex: 0,
8224
- ...partial
8225
- });
8226
- var generateFakeRequestInputContract = (partial = {}) => ({
8227
- contractId: getRandomB256(),
8228
- type: InputType8.Contract,
8229
- txPointer: "0x00000000000000000000000000000000",
8230
- ...partial
8231
- });
8232
8223
  export {
8233
- generateFakeRequestInputCoin,
8234
- generateFakeRequestInputContract,
8235
- generateFakeRequestInputMessage,
8236
8224
  generateTestWallet,
8237
8225
  killNode,
8238
8226
  launchNode,