@fuel-ts/account 0.0.0-rc-2037-20240417131250 → 0.0.0-rc-1976-20240417144614

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 +100 -124
  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 +105 -104
  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
package/dist/index.mjs CHANGED
@@ -29,14 +29,12 @@ var __privateMethod = (obj, member, method) => {
29
29
 
30
30
  // src/account.ts
31
31
  import { Address as Address3 } from "@fuel-ts/address";
32
- import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
33
32
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
34
33
  import { AbstractAccount } from "@fuel-ts/interfaces";
35
34
  import { bn as bn17 } from "@fuel-ts/math";
36
35
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
37
36
 
38
37
  // src/providers/coin-quantity.ts
39
- import { BaseAssetId } from "@fuel-ts/address/configs";
40
38
  import { bn } from "@fuel-ts/math";
41
39
  import { hexlify } from "@fuel-ts/utils";
42
40
  var coinQuantityfy = (coinQuantityLike) => {
@@ -45,11 +43,11 @@ var coinQuantityfy = (coinQuantityLike) => {
45
43
  let max2;
46
44
  if (Array.isArray(coinQuantityLike)) {
47
45
  amount = coinQuantityLike[0];
48
- assetId = coinQuantityLike[1] ?? BaseAssetId;
49
- max2 = coinQuantityLike[2] ?? void 0;
46
+ assetId = coinQuantityLike[1];
47
+ max2 = coinQuantityLike[2];
50
48
  } else {
51
49
  amount = coinQuantityLike.amount;
52
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
50
+ assetId = coinQuantityLike.assetId;
53
51
  max2 = coinQuantityLike.max ?? void 0;
54
52
  }
55
53
  const bnAmount = bn(amount);
@@ -76,7 +74,7 @@ import { Address as Address2 } from "@fuel-ts/address";
76
74
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
77
75
  import { BN, bn as bn15, max } from "@fuel-ts/math";
78
76
  import {
79
- InputType as InputType7,
77
+ InputType as InputType6,
80
78
  TransactionType as TransactionType8,
81
79
  InputMessageCoder,
82
80
  TransactionCoder as TransactionCoder5
@@ -1167,13 +1165,13 @@ var outputify = (value) => {
1167
1165
  // src/providers/transaction-request/transaction-request.ts
1168
1166
  import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1169
1167
  import { Address, addressify } from "@fuel-ts/address";
1170
- import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1168
+ import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1171
1169
  import { randomBytes } from "@fuel-ts/crypto";
1172
1170
  import { bn as bn7 } from "@fuel-ts/math";
1173
1171
  import {
1174
1172
  PolicyType,
1175
1173
  TransactionCoder,
1176
- InputType as InputType3,
1174
+ InputType as InputType2,
1177
1175
  OutputType as OutputType2,
1178
1176
  TransactionType
1179
1177
  } from "@fuel-ts/transactions";
@@ -1676,33 +1674,6 @@ var NoWitnessByOwnerError = class extends Error {
1676
1674
  name = "NoWitnessByOwnerError";
1677
1675
  };
1678
1676
 
1679
- // src/providers/transaction-request/helpers.ts
1680
- import { InputType as InputType2 } from "@fuel-ts/transactions";
1681
- var isRequestInputCoin = (input) => input.type === InputType2.Coin;
1682
- var isRequestInputMessage = (input) => input.type === InputType2.Message;
1683
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1684
- var getRequestInputResourceOwner = (input) => {
1685
- if (isRequestInputCoin(input)) {
1686
- return input.owner;
1687
- }
1688
- return input.recipient;
1689
- };
1690
- var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1691
- var cacheResources = (resources) => resources.reduce(
1692
- (cache2, resource) => {
1693
- if (isCoin(resource)) {
1694
- cache2.utxos.push(resource.id);
1695
- } else {
1696
- cache2.messages.push(resource.nonce);
1697
- }
1698
- return cache2;
1699
- },
1700
- {
1701
- utxos: [],
1702
- messages: []
1703
- }
1704
- );
1705
-
1706
1677
  // src/providers/transaction-request/witness.ts
1707
1678
  import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
1708
1679
  var witnessify = (value) => {
@@ -1729,6 +1700,8 @@ var BaseTransactionRequest = class {
1729
1700
  outputs = [];
1730
1701
  /** List of witnesses */
1731
1702
  witnesses = [];
1703
+ /** Base asset ID - should be fetched from the chain */
1704
+ baseAssetId;
1732
1705
  /**
1733
1706
  * Constructor for initializing a base transaction request.
1734
1707
  *
@@ -1741,8 +1714,9 @@ var BaseTransactionRequest = class {
1741
1714
  witnessLimit,
1742
1715
  inputs,
1743
1716
  outputs,
1744
- witnesses
1745
- } = {}) {
1717
+ witnesses,
1718
+ baseAssetId
1719
+ }) {
1746
1720
  this.gasPrice = bn7(gasPrice);
1747
1721
  this.maturity = maturity ?? 0;
1748
1722
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
@@ -1750,6 +1724,7 @@ var BaseTransactionRequest = class {
1750
1724
  this.inputs = inputs ?? [];
1751
1725
  this.outputs = outputs ?? [];
1752
1726
  this.witnesses = witnesses ?? [];
1727
+ this.baseAssetId = baseAssetId;
1753
1728
  }
1754
1729
  static getPolicyMeta(req) {
1755
1730
  let policyTypes = 0;
@@ -1893,7 +1868,7 @@ var BaseTransactionRequest = class {
1893
1868
  */
1894
1869
  getCoinInputs() {
1895
1870
  return this.inputs.filter(
1896
- (input) => input.type === InputType3.Coin
1871
+ (input) => input.type === InputType2.Coin
1897
1872
  );
1898
1873
  }
1899
1874
  /**
@@ -1925,9 +1900,9 @@ var BaseTransactionRequest = class {
1925
1900
  const ownerAddress = addressify(owner);
1926
1901
  const found = this.inputs.find((input) => {
1927
1902
  switch (input.type) {
1928
- case InputType3.Coin:
1903
+ case InputType2.Coin:
1929
1904
  return hexlify7(input.owner) === ownerAddress.toB256();
1930
- case InputType3.Message:
1905
+ case InputType2.Message:
1931
1906
  return hexlify7(input.recipient) === ownerAddress.toB256();
1932
1907
  default:
1933
1908
  return false;
@@ -1943,8 +1918,8 @@ var BaseTransactionRequest = class {
1943
1918
  * @param predicate - Predicate bytes.
1944
1919
  * @param predicateData - Predicate data bytes.
1945
1920
  */
1946
- addCoinInput(coin) {
1947
- const { assetId, owner, amount, id, predicate } = coin;
1921
+ addCoinInput(coin, predicate) {
1922
+ const { assetId, owner, amount } = coin;
1948
1923
  let witnessIndex;
1949
1924
  if (predicate) {
1950
1925
  witnessIndex = 0;
@@ -1955,14 +1930,14 @@ var BaseTransactionRequest = class {
1955
1930
  }
1956
1931
  }
1957
1932
  const input = {
1958
- id,
1959
- type: InputType3.Coin,
1933
+ ...coin,
1934
+ type: InputType2.Coin,
1960
1935
  owner: owner.toB256(),
1961
1936
  amount,
1962
1937
  assetId,
1963
1938
  txPointer: "0x00000000000000000000000000000000",
1964
1939
  witnessIndex,
1965
- predicate
1940
+ predicate: predicate?.bytes
1966
1941
  };
1967
1942
  this.pushInput(input);
1968
1943
  this.addChangeOutput(owner, assetId);
@@ -1973,11 +1948,9 @@ var BaseTransactionRequest = class {
1973
1948
  *
1974
1949
  * @param message - Message resource.
1975
1950
  * @param predicate - Predicate bytes.
1976
- * @param predicateData - Predicate data bytes.
1977
1951
  */
1978
- addMessageInput(message) {
1979
- const { recipient, sender, amount, predicate, nonce } = message;
1980
- const assetId = BaseAssetId2;
1952
+ addMessageInput(message, predicate) {
1953
+ const { recipient, sender, amount } = message;
1981
1954
  let witnessIndex;
1982
1955
  if (predicate) {
1983
1956
  witnessIndex = 0;
@@ -1988,16 +1961,16 @@ var BaseTransactionRequest = class {
1988
1961
  }
1989
1962
  }
1990
1963
  const input = {
1991
- nonce,
1992
- type: InputType3.Message,
1964
+ ...message,
1965
+ type: InputType2.Message,
1993
1966
  sender: sender.toB256(),
1994
1967
  recipient: recipient.toB256(),
1995
1968
  amount,
1996
1969
  witnessIndex,
1997
- predicate
1970
+ predicate: predicate?.bytes
1998
1971
  };
1999
1972
  this.pushInput(input);
2000
- this.addChangeOutput(recipient, assetId);
1973
+ this.addChangeOutput(recipient, this.baseAssetId);
2001
1974
  }
2002
1975
  /**
2003
1976
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2025,6 +1998,32 @@ var BaseTransactionRequest = class {
2025
1998
  resources.forEach((resource) => this.addResource(resource));
2026
1999
  return this;
2027
2000
  }
2001
+ /**
2002
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2003
+ * outputs from the related assetIds.
2004
+ *
2005
+ * @param resources - The resources to add.
2006
+ * @returns This transaction.
2007
+ */
2008
+ addPredicateResource(resource, predicate) {
2009
+ if (isCoin(resource)) {
2010
+ this.addCoinInput(resource, predicate);
2011
+ } else {
2012
+ this.addMessageInput(resource, predicate);
2013
+ }
2014
+ return this;
2015
+ }
2016
+ /**
2017
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2018
+ * from the related assetIds.
2019
+ *
2020
+ * @param resources - The resources to add.
2021
+ * @returns This transaction.
2022
+ */
2023
+ addPredicateResources(resources, predicate) {
2024
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2025
+ return this;
2026
+ }
2028
2027
  /**
2029
2028
  * Adds a coin output to the transaction.
2030
2029
  *
@@ -2032,12 +2031,12 @@ var BaseTransactionRequest = class {
2032
2031
  * @param amount - Amount of coin.
2033
2032
  * @param assetId - Asset ID of coin.
2034
2033
  */
2035
- addCoinOutput(to, amount, assetId = BaseAssetId2) {
2034
+ addCoinOutput(to, amount, assetId) {
2036
2035
  this.pushOutput({
2037
2036
  type: OutputType2.Coin,
2038
2037
  to: addressify(to).toB256(),
2039
2038
  amount,
2040
- assetId
2039
+ assetId: assetId ?? this.baseAssetId
2041
2040
  });
2042
2041
  return this;
2043
2042
  }
@@ -2064,7 +2063,7 @@ var BaseTransactionRequest = class {
2064
2063
  * @param to - Address of the owner.
2065
2064
  * @param assetId - Asset ID of coin.
2066
2065
  */
2067
- addChangeOutput(to, assetId = BaseAssetId2) {
2066
+ addChangeOutput(to, assetId) {
2068
2067
  const changeOutput = this.getChangeOutputs().find(
2069
2068
  (output) => hexlify7(output.assetId) === assetId
2070
2069
  );
@@ -2072,7 +2071,7 @@ var BaseTransactionRequest = class {
2072
2071
  this.pushOutput({
2073
2072
  type: OutputType2.Change,
2074
2073
  to: addressify(to).toB256(),
2075
- assetId
2074
+ assetId: assetId ?? this.baseAssetId
2076
2075
  });
2077
2076
  }
2078
2077
  }
@@ -2148,7 +2147,7 @@ var BaseTransactionRequest = class {
2148
2147
  ]);
2149
2148
  }
2150
2149
  };
2151
- updateAssetInput(BaseAssetId2, bn7(1e11));
2150
+ updateAssetInput(this.baseAssetId, bn7(1e11));
2152
2151
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2153
2152
  }
2154
2153
  /**
@@ -2173,20 +2172,16 @@ var BaseTransactionRequest = class {
2173
2172
  toJSON() {
2174
2173
  return normalizeJSON(this);
2175
2174
  }
2176
- removeWitness(index) {
2177
- this.witnesses.splice(index, 1);
2178
- this.adjustWitnessIndexes(index);
2179
- }
2180
2175
  updatePredicateInputs(inputs) {
2181
2176
  this.inputs.forEach((i) => {
2182
2177
  let correspondingInput;
2183
2178
  switch (i.type) {
2184
- case InputType3.Coin:
2185
- correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
2179
+ case InputType2.Coin:
2180
+ correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
2186
2181
  break;
2187
- case InputType3.Message:
2182
+ case InputType2.Message:
2188
2183
  correspondingInput = inputs.find(
2189
- (x) => x.type === InputType3.Message && x.sender === i.sender
2184
+ (x) => x.type === InputType2.Message && x.sender === i.sender
2190
2185
  );
2191
2186
  break;
2192
2187
  default:
@@ -2199,13 +2194,6 @@ var BaseTransactionRequest = class {
2199
2194
  }
2200
2195
  });
2201
2196
  }
2202
- adjustWitnessIndexes(removedIndex) {
2203
- this.inputs.filter(isRequestInputResource).forEach((input) => {
2204
- if (input.witnessIndex > removedIndex) {
2205
- input.witnessIndex -= 1;
2206
- }
2207
- });
2208
- }
2209
2197
  };
2210
2198
 
2211
2199
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2218,7 +2206,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2218
2206
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2219
2207
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2220
2208
  import { bn as bn8 } from "@fuel-ts/math";
2221
- import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2209
+ import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2222
2210
  import { concat as concat2 } from "@fuel-ts/utils";
2223
2211
  import { clone as clone2 } from "ramda";
2224
2212
  function hashTransaction(transactionRequest, chainId) {
@@ -2229,7 +2217,7 @@ function hashTransaction(transactionRequest, chainId) {
2229
2217
  transaction.inputs = transaction.inputs.map((input) => {
2230
2218
  const inputClone = clone2(input);
2231
2219
  switch (inputClone.type) {
2232
- case InputType4.Coin: {
2220
+ case InputType3.Coin: {
2233
2221
  inputClone.txPointer = {
2234
2222
  blockHeight: 0,
2235
2223
  txIndex: 0
@@ -2237,11 +2225,11 @@ function hashTransaction(transactionRequest, chainId) {
2237
2225
  inputClone.predicateGasUsed = bn8(0);
2238
2226
  return inputClone;
2239
2227
  }
2240
- case InputType4.Message: {
2228
+ case InputType3.Message: {
2241
2229
  inputClone.predicateGasUsed = bn8(0);
2242
2230
  return inputClone;
2243
2231
  }
2244
- case InputType4.Contract: {
2232
+ case InputType3.Contract: {
2245
2233
  inputClone.txPointer = {
2246
2234
  blockHeight: 0,
2247
2235
  txIndex: 0
@@ -2329,12 +2317,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2329
2317
  *
2330
2318
  * @param createTransactionRequestLike - The initial values for the instance
2331
2319
  */
2332
- constructor({
2333
- bytecodeWitnessIndex,
2334
- salt,
2335
- storageSlots,
2336
- ...rest
2337
- } = {}) {
2320
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2338
2321
  super(rest);
2339
2322
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2340
2323
  this.salt = hexlify9(salt ?? ZeroBytes326);
@@ -2407,7 +2390,7 @@ import { Interface } from "@fuel-ts/abi-coder";
2407
2390
  import { addressify as addressify2 } from "@fuel-ts/address";
2408
2391
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2409
2392
  import { bn as bn10 } from "@fuel-ts/math";
2410
- import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2393
+ import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2411
2394
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2412
2395
 
2413
2396
  // src/providers/transaction-request/scripts.ts
@@ -2458,7 +2441,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2458
2441
  *
2459
2442
  * @param scriptTransactionRequestLike - The initial values for the instance.
2460
2443
  */
2461
- constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2444
+ constructor({ script, scriptData, gasLimit, ...rest }) {
2462
2445
  super(rest);
2463
2446
  this.gasLimit = bn10(gasLimit);
2464
2447
  this.script = arrayify8(script ?? returnZeroScript.bytes);
@@ -2491,7 +2474,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2491
2474
  */
2492
2475
  getContractInputs() {
2493
2476
  return this.inputs.filter(
2494
- (input) => input.type === InputType5.Contract
2477
+ (input) => input.type === InputType4.Contract
2495
2478
  );
2496
2479
  }
2497
2480
  /**
@@ -2567,7 +2550,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2567
2550
  return this;
2568
2551
  }
2569
2552
  const inputIndex = super.pushInput({
2570
- type: InputType5.Contract,
2553
+ type: InputType4.Contract,
2571
2554
  contractId: contractAddress.toB256(),
2572
2555
  txPointer: "0x00000000000000000000000000000000"
2573
2556
  });
@@ -2762,7 +2745,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2762
2745
 
2763
2746
  // src/providers/transaction-summary/input.ts
2764
2747
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2765
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2748
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2766
2749
  function getInputsByTypes(inputs, types) {
2767
2750
  return inputs.filter((i) => types.includes(i.type));
2768
2751
  }
@@ -2770,16 +2753,16 @@ function getInputsByType(inputs, type) {
2770
2753
  return inputs.filter((i) => i.type === type);
2771
2754
  }
2772
2755
  function getInputsCoin(inputs) {
2773
- return getInputsByType(inputs, InputType6.Coin);
2756
+ return getInputsByType(inputs, InputType5.Coin);
2774
2757
  }
2775
2758
  function getInputsMessage(inputs) {
2776
- return getInputsByType(inputs, InputType6.Message);
2759
+ return getInputsByType(inputs, InputType5.Message);
2777
2760
  }
2778
2761
  function getInputsCoinAndMessage(inputs) {
2779
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2762
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2780
2763
  }
2781
2764
  function getInputsContract(inputs) {
2782
- return getInputsByType(inputs, InputType6.Contract);
2765
+ return getInputsByType(inputs, InputType5.Contract);
2783
2766
  }
2784
2767
  function getInputFromAssetId(inputs, assetId) {
2785
2768
  const coinInputs = getInputsCoin(inputs);
@@ -2798,7 +2781,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2798
2781
  if (!contractInput) {
2799
2782
  return void 0;
2800
2783
  }
2801
- if (contractInput.type !== InputType6.Contract) {
2784
+ if (contractInput.type !== InputType5.Contract) {
2802
2785
  throw new FuelError9(
2803
2786
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2804
2787
  `Contract input should be of type 'contract'.`
@@ -2807,10 +2790,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2807
2790
  return contractInput;
2808
2791
  }
2809
2792
  function getInputAccountAddress(input) {
2810
- if (input.type === InputType6.Coin) {
2793
+ if (input.type === InputType5.Coin) {
2811
2794
  return input.owner.toString();
2812
2795
  }
2813
- if (input.type === InputType6.Message) {
2796
+ if (input.type === InputType5.Message) {
2814
2797
  return input.recipient.toString();
2815
2798
  }
2816
2799
  return "";
@@ -3633,6 +3616,7 @@ var processGqlChain = (chain) => {
3633
3616
  gasPerByte: bn15(feeParams.gasPerByte),
3634
3617
  maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3635
3618
  chainId: bn15(consensusParameters.chainId),
3619
+ baseAssetId: consensusParameters.baseAssetId,
3636
3620
  gasCosts
3637
3621
  },
3638
3622
  gasCosts,
@@ -3875,6 +3859,17 @@ var _Provider = class {
3875
3859
  } = this.getChain();
3876
3860
  return chainId.toNumber();
3877
3861
  }
3862
+ /**
3863
+ * Returns the base asset ID
3864
+ *
3865
+ * @returns A promise that resolves to the base asset ID
3866
+ */
3867
+ getBaseAssetId() {
3868
+ const {
3869
+ consensusParameters: { baseAssetId }
3870
+ } = this.getChain();
3871
+ return baseAssetId;
3872
+ }
3878
3873
  /**
3879
3874
  * Submits a transaction to the chain to be executed.
3880
3875
  *
@@ -4554,7 +4549,7 @@ cacheInputs_fn = function(inputs) {
4554
4549
  return;
4555
4550
  }
4556
4551
  inputs.forEach((input) => {
4557
- if (input.type === InputType7.Coin) {
4552
+ if (input.type === InputType6.Coin) {
4558
4553
  this.cache?.set(input.id);
4559
4554
  }
4560
4555
  });
@@ -4938,8 +4933,9 @@ var Account = class extends AbstractAccount {
4938
4933
  * @param assetId - The asset ID to check the balance for.
4939
4934
  * @returns A promise that resolves to the balance amount.
4940
4935
  */
4941
- async getBalance(assetId = BaseAssetId3) {
4942
- const amount = await this.provider.getBalance(this.address, assetId);
4936
+ async getBalance(assetId) {
4937
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4938
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4943
4939
  return amount;
4944
4940
  }
4945
4941
  /**
@@ -4977,9 +4973,10 @@ var Account = class extends AbstractAccount {
4977
4973
  * @returns A promise that resolves when the resources are added to the transaction.
4978
4974
  */
4979
4975
  async fund(request, coinQuantities, fee) {
4976
+ const baseAssetId = this.provider.getBaseAssetId();
4980
4977
  const updatedQuantities = addAmountToAsset({
4981
4978
  amount: bn17(fee),
4982
- assetId: BaseAssetId3,
4979
+ assetId: baseAssetId,
4983
4980
  coinQuantities
4984
4981
  });
4985
4982
  const quantitiesDict = {};
@@ -5003,8 +5000,8 @@ var Account = class extends AbstractAccount {
5003
5000
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5004
5001
  cachedUtxos.push(input.id);
5005
5002
  }
5006
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
5007
- quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
5003
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
5004
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
5008
5005
  cachedMessages.push(input.nonce);
5009
5006
  }
5010
5007
  }
@@ -5036,11 +5033,13 @@ var Account = class extends AbstractAccount {
5036
5033
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5037
5034
  * @returns A promise that resolves to the prepared transaction request.
5038
5035
  */
5039
- async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5036
+ async createTransfer(destination, amount, assetId, txParams = {}) {
5040
5037
  const { minGasPrice } = this.provider.getGasConfig();
5041
- const params = { gasPrice: minGasPrice, ...txParams };
5038
+ const baseAssetId = this.provider.getBaseAssetId();
5039
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5040
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5042
5041
  const request = new ScriptTransactionRequest(params);
5043
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5042
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5044
5043
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5045
5044
  estimateTxDependencies: true,
5046
5045
  resourcesOwner: this
@@ -5066,14 +5065,15 @@ var Account = class extends AbstractAccount {
5066
5065
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5067
5066
  * @returns A promise that resolves to the transaction response.
5068
5067
  */
5069
- async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5068
+ async transfer(destination, amount, assetId, txParams = {}) {
5070
5069
  if (bn17(amount).lte(0)) {
5071
5070
  throw new FuelError15(
5072
5071
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5073
5072
  "Transfer amount must be a positive number."
5074
5073
  );
5075
5074
  }
5076
- const request = await this.createTransfer(destination, amount, assetId, txParams);
5075
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5076
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5077
5077
  return this.sendTransaction(request, { estimateTxDependencies: false });
5078
5078
  }
5079
5079
  /**
@@ -5085,7 +5085,7 @@ var Account = class extends AbstractAccount {
5085
5085
  * @param txParams - The optional transaction parameters.
5086
5086
  * @returns A promise that resolves to the transaction response.
5087
5087
  */
5088
- async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5088
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
5089
5089
  if (bn17(amount).lte(0)) {
5090
5090
  throw new FuelError15(
5091
5091
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
@@ -5094,11 +5094,13 @@ var Account = class extends AbstractAccount {
5094
5094
  }
5095
5095
  const contractAddress = Address3.fromAddressOrString(contractId);
5096
5096
  const { minGasPrice } = this.provider.getGasConfig();
5097
- const params = { gasPrice: minGasPrice, ...txParams };
5097
+ const baseAssetId = this.provider.getBaseAssetId();
5098
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5099
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5098
5100
  const { script, scriptData } = await assembleTransferToContractScript({
5099
5101
  hexlifiedContractId: contractAddress.toB256(),
5100
5102
  amountToTransfer: bn17(amount),
5101
- assetId
5103
+ assetId: assetIdToTransfer
5102
5104
  });
5103
5105
  const request = new ScriptTransactionRequest({
5104
5106
  ...params,
@@ -5108,7 +5110,7 @@ var Account = class extends AbstractAccount {
5108
5110
  request.addContractInputAndOutput(contractAddress);
5109
5111
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5110
5112
  request,
5111
- [{ amount: bn17(amount), assetId: String(assetId) }]
5113
+ [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
5112
5114
  );
5113
5115
  request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5114
5116
  this.validateGas({
@@ -5130,6 +5132,7 @@ var Account = class extends AbstractAccount {
5130
5132
  */
5131
5133
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5132
5134
  const { minGasPrice } = this.provider.getGasConfig();
5135
+ const baseAssetId = this.provider.getBaseAssetId();
5133
5136
  const recipientAddress = Address3.fromAddressOrString(recipient);
5134
5137
  const recipientDataArray = arrayify14(
5135
5138
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -5142,9 +5145,14 @@ var Account = class extends AbstractAccount {
5142
5145
  ...recipientDataArray,
5143
5146
  ...amountDataArray
5144
5147
  ]);
5145
- const params = { script, gasPrice: minGasPrice, ...txParams };
5148
+ const params = {
5149
+ script,
5150
+ gasPrice: minGasPrice,
5151
+ baseAssetId,
5152
+ ...txParams
5153
+ };
5146
5154
  const request = new ScriptTransactionRequest(params);
5147
- const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5155
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
5148
5156
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5149
5157
  request,
5150
5158
  forwardingQuantities
@@ -8721,9 +8729,8 @@ import {
8721
8729
  SCRIPT_FIXED_SIZE
8722
8730
  } from "@fuel-ts/abi-coder";
8723
8731
  import { Address as Address9 } from "@fuel-ts/address";
8724
- import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8725
8732
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8726
- import { ByteArrayCoder } from "@fuel-ts/transactions";
8733
+ import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8727
8734
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8728
8735
 
8729
8736
  // src/predicate/utils/getPredicateRoot.ts
@@ -8782,15 +8789,10 @@ var Predicate = class extends Account {
8782
8789
  populateTransactionPredicateData(transactionRequestLike) {
8783
8790
  const request = transactionRequestify(transactionRequestLike);
8784
8791
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8785
- const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
8786
- if (placeholderIndex !== -1) {
8787
- request.removeWitness(placeholderIndex);
8788
- }
8789
- request.inputs.filter(isRequestInputResource).forEach((input) => {
8790
- if (isRequestInputResourceFromOwner(input, this.address)) {
8792
+ request.inputs?.forEach((input) => {
8793
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8791
8794
  input.predicate = this.bytes;
8792
8795
  input.predicateData = this.getPredicateData(policies.length);
8793
- input.witnessIndex = 0;
8794
8796
  }
8795
8797
  });
8796
8798
  return request;
@@ -8804,8 +8806,9 @@ var Predicate = class extends Account {
8804
8806
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8805
8807
  * @returns A promise that resolves to the prepared transaction request.
8806
8808
  */
8807
- async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
8808
- const request = await super.createTransfer(destination, amount, assetId, txParams);
8809
+ async createTransfer(destination, amount, assetId, txParams = {}) {
8810
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8811
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8809
8812
  return this.populateTransactionPredicateData(request);
8810
8813
  }
8811
8814
  /**
@@ -8828,20 +8831,6 @@ var Predicate = class extends Account {
8828
8831
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8829
8832
  return super.simulateTransaction(transactionRequest);
8830
8833
  }
8831
- /**
8832
- * Retrieves resources satisfying the spend query for the account.
8833
- *
8834
- * @param quantities - IDs of coins to exclude.
8835
- * @param excludedIds - IDs of resources to be excluded from the query.
8836
- * @returns A promise that resolves to an array of Resources.
8837
- */
8838
- async getResourcesToSpend(quantities, excludedIds) {
8839
- const resources = await super.getResourcesToSpend(quantities, excludedIds);
8840
- return resources.map((resource) => ({
8841
- ...resource,
8842
- predicate: hexlify19(this.bytes)
8843
- }));
8844
- }
8845
8834
  getPredicateData(policiesLength) {
8846
8835
  if (!this.predicateData.length) {
8847
8836
  return new Uint8Array();
@@ -8921,22 +8910,6 @@ var Predicate = class extends Account {
8921
8910
  }
8922
8911
  return mutatedBytes;
8923
8912
  }
8924
- getIndexFromPlaceholderWitness(request) {
8925
- const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
8926
- let index = -1;
8927
- const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
8928
- if (hasEmptyPredicateInputs) {
8929
- index = hasEmptyPredicateInputs.witnessIndex;
8930
- const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
8931
- if (!allInputsAreEmpty) {
8932
- const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
8933
- if (wasFilledInputAddedFirst) {
8934
- index = -1;
8935
- }
8936
- }
8937
- }
8938
- return index;
8939
- }
8940
8913
  };
8941
8914
 
8942
8915
  // src/connectors/fuel.ts
@@ -9659,7 +9632,6 @@ export {
9659
9632
  assets,
9660
9633
  buildBlockExplorerUrl,
9661
9634
  cacheFor,
9662
- cacheResources,
9663
9635
  calculateMetadataGasForTxCreate,
9664
9636
  calculateMetadataGasForTxScript,
9665
9637
  calculatePriceWithFactor,
@@ -9706,7 +9678,6 @@ export {
9706
9678
  getReceiptsMessageOut,
9707
9679
  getReceiptsTransferOut,
9708
9680
  getReceiptsWithMissingData,
9709
- getRequestInputResourceOwner,
9710
9681
  getTransactionStatusName,
9711
9682
  getTransactionSummary,
9712
9683
  getTransactionSummaryFromRequest,
@@ -9720,10 +9691,6 @@ export {
9720
9691
  isMessage,
9721
9692
  isRawCoin,
9722
9693
  isRawMessage,
9723
- isRequestInputCoin,
9724
- isRequestInputMessage,
9725
- isRequestInputResource,
9726
- isRequestInputResourceFromOwner,
9727
9694
  isType,
9728
9695
  isTypeCreate,
9729
9696
  isTypeMint,