@fuel-ts/account 0.0.0-rc-1976-20240417161625 → 0.0.0-rc-2037-20240417202046

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