@fuel-ts/account 0.0.0-rc-2037-20240423110545 → 0.0.0-rc-1976-20240423111125

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 -125
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +241 -281
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +126 -160
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts +2 -17
  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,28 +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) => isRequestInputCoin(input) ? input.owner : input.recipient;
1685
- var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1686
- var cacheResources = (resources) => resources.reduce(
1687
- (cache2, resource) => {
1688
- if (isCoin(resource)) {
1689
- cache2.utxos.push(resource.id);
1690
- } else {
1691
- cache2.messages.push(resource.nonce);
1692
- }
1693
- return cache2;
1694
- },
1695
- {
1696
- utxos: [],
1697
- messages: []
1698
- }
1699
- );
1700
-
1701
1677
  // src/providers/transaction-request/witness.ts
1702
1678
  import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
1703
1679
  var witnessify = (value) => {
@@ -1724,6 +1700,8 @@ var BaseTransactionRequest = class {
1724
1700
  outputs = [];
1725
1701
  /** List of witnesses */
1726
1702
  witnesses = [];
1703
+ /** Base asset ID - should be fetched from the chain */
1704
+ baseAssetId;
1727
1705
  /**
1728
1706
  * Constructor for initializing a base transaction request.
1729
1707
  *
@@ -1736,8 +1714,9 @@ var BaseTransactionRequest = class {
1736
1714
  witnessLimit,
1737
1715
  inputs,
1738
1716
  outputs,
1739
- witnesses
1740
- } = {}) {
1717
+ witnesses,
1718
+ baseAssetId
1719
+ }) {
1741
1720
  this.gasPrice = bn7(gasPrice);
1742
1721
  this.maturity = maturity ?? 0;
1743
1722
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
@@ -1745,6 +1724,7 @@ var BaseTransactionRequest = class {
1745
1724
  this.inputs = inputs ?? [];
1746
1725
  this.outputs = outputs ?? [];
1747
1726
  this.witnesses = witnesses ?? [];
1727
+ this.baseAssetId = baseAssetId;
1748
1728
  }
1749
1729
  static getPolicyMeta(req) {
1750
1730
  let policyTypes = 0;
@@ -1888,7 +1868,7 @@ var BaseTransactionRequest = class {
1888
1868
  */
1889
1869
  getCoinInputs() {
1890
1870
  return this.inputs.filter(
1891
- (input) => input.type === InputType3.Coin
1871
+ (input) => input.type === InputType2.Coin
1892
1872
  );
1893
1873
  }
1894
1874
  /**
@@ -1920,9 +1900,9 @@ var BaseTransactionRequest = class {
1920
1900
  const ownerAddress = addressify(owner);
1921
1901
  const found = this.inputs.find((input) => {
1922
1902
  switch (input.type) {
1923
- case InputType3.Coin:
1903
+ case InputType2.Coin:
1924
1904
  return hexlify7(input.owner) === ownerAddress.toB256();
1925
- case InputType3.Message:
1905
+ case InputType2.Message:
1926
1906
  return hexlify7(input.recipient) === ownerAddress.toB256();
1927
1907
  default:
1928
1908
  return false;
@@ -1938,8 +1918,8 @@ var BaseTransactionRequest = class {
1938
1918
  * @param predicate - Predicate bytes.
1939
1919
  * @param predicateData - Predicate data bytes.
1940
1920
  */
1941
- addCoinInput(coin) {
1942
- const { assetId, owner, amount, id, predicate } = coin;
1921
+ addCoinInput(coin, predicate) {
1922
+ const { assetId, owner, amount } = coin;
1943
1923
  let witnessIndex;
1944
1924
  if (predicate) {
1945
1925
  witnessIndex = 0;
@@ -1950,14 +1930,14 @@ var BaseTransactionRequest = class {
1950
1930
  }
1951
1931
  }
1952
1932
  const input = {
1953
- id,
1954
- type: InputType3.Coin,
1933
+ ...coin,
1934
+ type: InputType2.Coin,
1955
1935
  owner: owner.toB256(),
1956
1936
  amount,
1957
1937
  assetId,
1958
1938
  txPointer: "0x00000000000000000000000000000000",
1959
1939
  witnessIndex,
1960
- predicate
1940
+ predicate: predicate?.bytes
1961
1941
  };
1962
1942
  this.pushInput(input);
1963
1943
  this.addChangeOutput(owner, assetId);
@@ -1968,11 +1948,9 @@ var BaseTransactionRequest = class {
1968
1948
  *
1969
1949
  * @param message - Message resource.
1970
1950
  * @param predicate - Predicate bytes.
1971
- * @param predicateData - Predicate data bytes.
1972
1951
  */
1973
- addMessageInput(message) {
1974
- const { recipient, sender, amount, predicate, nonce } = message;
1975
- const assetId = BaseAssetId2;
1952
+ addMessageInput(message, predicate) {
1953
+ const { recipient, sender, amount } = message;
1976
1954
  let witnessIndex;
1977
1955
  if (predicate) {
1978
1956
  witnessIndex = 0;
@@ -1983,16 +1961,16 @@ var BaseTransactionRequest = class {
1983
1961
  }
1984
1962
  }
1985
1963
  const input = {
1986
- nonce,
1987
- type: InputType3.Message,
1964
+ ...message,
1965
+ type: InputType2.Message,
1988
1966
  sender: sender.toB256(),
1989
1967
  recipient: recipient.toB256(),
1990
1968
  amount,
1991
1969
  witnessIndex,
1992
- predicate
1970
+ predicate: predicate?.bytes
1993
1971
  };
1994
1972
  this.pushInput(input);
1995
- this.addChangeOutput(recipient, assetId);
1973
+ this.addChangeOutput(recipient, this.baseAssetId);
1996
1974
  }
1997
1975
  /**
1998
1976
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2020,6 +1998,32 @@ var BaseTransactionRequest = class {
2020
1998
  resources.forEach((resource) => this.addResource(resource));
2021
1999
  return this;
2022
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
+ }
2023
2027
  /**
2024
2028
  * Adds a coin output to the transaction.
2025
2029
  *
@@ -2027,12 +2031,12 @@ var BaseTransactionRequest = class {
2027
2031
  * @param amount - Amount of coin.
2028
2032
  * @param assetId - Asset ID of coin.
2029
2033
  */
2030
- addCoinOutput(to, amount, assetId = BaseAssetId2) {
2034
+ addCoinOutput(to, amount, assetId) {
2031
2035
  this.pushOutput({
2032
2036
  type: OutputType2.Coin,
2033
2037
  to: addressify(to).toB256(),
2034
2038
  amount,
2035
- assetId
2039
+ assetId: assetId ?? this.baseAssetId
2036
2040
  });
2037
2041
  return this;
2038
2042
  }
@@ -2059,7 +2063,7 @@ var BaseTransactionRequest = class {
2059
2063
  * @param to - Address of the owner.
2060
2064
  * @param assetId - Asset ID of coin.
2061
2065
  */
2062
- addChangeOutput(to, assetId = BaseAssetId2) {
2066
+ addChangeOutput(to, assetId) {
2063
2067
  const changeOutput = this.getChangeOutputs().find(
2064
2068
  (output) => hexlify7(output.assetId) === assetId
2065
2069
  );
@@ -2067,7 +2071,7 @@ var BaseTransactionRequest = class {
2067
2071
  this.pushOutput({
2068
2072
  type: OutputType2.Change,
2069
2073
  to: addressify(to).toB256(),
2070
- assetId
2074
+ assetId: assetId ?? this.baseAssetId
2071
2075
  });
2072
2076
  }
2073
2077
  }
@@ -2143,7 +2147,7 @@ var BaseTransactionRequest = class {
2143
2147
  ]);
2144
2148
  }
2145
2149
  };
2146
- updateAssetInput(BaseAssetId2, bn7(1e11));
2150
+ updateAssetInput(this.baseAssetId, bn7(1e11));
2147
2151
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2148
2152
  }
2149
2153
  /**
@@ -2168,20 +2172,16 @@ var BaseTransactionRequest = class {
2168
2172
  toJSON() {
2169
2173
  return normalizeJSON(this);
2170
2174
  }
2171
- removeWitness(index) {
2172
- this.witnesses.splice(index, 1);
2173
- this.adjustWitnessIndexes(index);
2174
- }
2175
2175
  updatePredicateInputs(inputs) {
2176
2176
  this.inputs.forEach((i) => {
2177
2177
  let correspondingInput;
2178
2178
  switch (i.type) {
2179
- case InputType3.Coin:
2180
- 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);
2181
2181
  break;
2182
- case InputType3.Message:
2182
+ case InputType2.Message:
2183
2183
  correspondingInput = inputs.find(
2184
- (x) => x.type === InputType3.Message && x.sender === i.sender
2184
+ (x) => x.type === InputType2.Message && x.sender === i.sender
2185
2185
  );
2186
2186
  break;
2187
2187
  default:
@@ -2194,13 +2194,6 @@ var BaseTransactionRequest = class {
2194
2194
  }
2195
2195
  });
2196
2196
  }
2197
- adjustWitnessIndexes(removedIndex) {
2198
- this.inputs.filter(isRequestInputResource).forEach((input) => {
2199
- if (input.witnessIndex > removedIndex) {
2200
- input.witnessIndex -= 1;
2201
- }
2202
- });
2203
- }
2204
2197
  };
2205
2198
 
2206
2199
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2213,7 +2206,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2213
2206
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2214
2207
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2215
2208
  import { bn as bn8 } from "@fuel-ts/math";
2216
- 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";
2217
2210
  import { concat as concat2 } from "@fuel-ts/utils";
2218
2211
  import { clone as clone2 } from "ramda";
2219
2212
  function hashTransaction(transactionRequest, chainId) {
@@ -2224,7 +2217,7 @@ function hashTransaction(transactionRequest, chainId) {
2224
2217
  transaction.inputs = transaction.inputs.map((input) => {
2225
2218
  const inputClone = clone2(input);
2226
2219
  switch (inputClone.type) {
2227
- case InputType4.Coin: {
2220
+ case InputType3.Coin: {
2228
2221
  inputClone.txPointer = {
2229
2222
  blockHeight: 0,
2230
2223
  txIndex: 0
@@ -2232,11 +2225,11 @@ function hashTransaction(transactionRequest, chainId) {
2232
2225
  inputClone.predicateGasUsed = bn8(0);
2233
2226
  return inputClone;
2234
2227
  }
2235
- case InputType4.Message: {
2228
+ case InputType3.Message: {
2236
2229
  inputClone.predicateGasUsed = bn8(0);
2237
2230
  return inputClone;
2238
2231
  }
2239
- case InputType4.Contract: {
2232
+ case InputType3.Contract: {
2240
2233
  inputClone.txPointer = {
2241
2234
  blockHeight: 0,
2242
2235
  txIndex: 0
@@ -2324,12 +2317,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2324
2317
  *
2325
2318
  * @param createTransactionRequestLike - The initial values for the instance
2326
2319
  */
2327
- constructor({
2328
- bytecodeWitnessIndex,
2329
- salt,
2330
- storageSlots,
2331
- ...rest
2332
- } = {}) {
2320
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2333
2321
  super(rest);
2334
2322
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2335
2323
  this.salt = hexlify9(salt ?? ZeroBytes326);
@@ -2402,7 +2390,7 @@ import { Interface } from "@fuel-ts/abi-coder";
2402
2390
  import { addressify as addressify2 } from "@fuel-ts/address";
2403
2391
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2404
2392
  import { bn as bn10 } from "@fuel-ts/math";
2405
- 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";
2406
2394
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2407
2395
 
2408
2396
  // src/providers/transaction-request/scripts.ts
@@ -2453,7 +2441,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2453
2441
  *
2454
2442
  * @param scriptTransactionRequestLike - The initial values for the instance.
2455
2443
  */
2456
- constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2444
+ constructor({ script, scriptData, gasLimit, ...rest }) {
2457
2445
  super(rest);
2458
2446
  this.gasLimit = bn10(gasLimit);
2459
2447
  this.script = arrayify8(script ?? returnZeroScript.bytes);
@@ -2486,7 +2474,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2486
2474
  */
2487
2475
  getContractInputs() {
2488
2476
  return this.inputs.filter(
2489
- (input) => input.type === InputType5.Contract
2477
+ (input) => input.type === InputType4.Contract
2490
2478
  );
2491
2479
  }
2492
2480
  /**
@@ -2562,7 +2550,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2562
2550
  return this;
2563
2551
  }
2564
2552
  const inputIndex = super.pushInput({
2565
- type: InputType5.Contract,
2553
+ type: InputType4.Contract,
2566
2554
  contractId: contractAddress.toB256(),
2567
2555
  txPointer: "0x00000000000000000000000000000000"
2568
2556
  });
@@ -2757,7 +2745,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2757
2745
 
2758
2746
  // src/providers/transaction-summary/input.ts
2759
2747
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2760
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2748
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2761
2749
  function getInputsByTypes(inputs, types) {
2762
2750
  return inputs.filter((i) => types.includes(i.type));
2763
2751
  }
@@ -2765,16 +2753,16 @@ function getInputsByType(inputs, type) {
2765
2753
  return inputs.filter((i) => i.type === type);
2766
2754
  }
2767
2755
  function getInputsCoin(inputs) {
2768
- return getInputsByType(inputs, InputType6.Coin);
2756
+ return getInputsByType(inputs, InputType5.Coin);
2769
2757
  }
2770
2758
  function getInputsMessage(inputs) {
2771
- return getInputsByType(inputs, InputType6.Message);
2759
+ return getInputsByType(inputs, InputType5.Message);
2772
2760
  }
2773
2761
  function getInputsCoinAndMessage(inputs) {
2774
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2762
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2775
2763
  }
2776
2764
  function getInputsContract(inputs) {
2777
- return getInputsByType(inputs, InputType6.Contract);
2765
+ return getInputsByType(inputs, InputType5.Contract);
2778
2766
  }
2779
2767
  function getInputFromAssetId(inputs, assetId) {
2780
2768
  const coinInputs = getInputsCoin(inputs);
@@ -2793,7 +2781,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2793
2781
  if (!contractInput) {
2794
2782
  return void 0;
2795
2783
  }
2796
- if (contractInput.type !== InputType6.Contract) {
2784
+ if (contractInput.type !== InputType5.Contract) {
2797
2785
  throw new FuelError9(
2798
2786
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2799
2787
  `Contract input should be of type 'contract'.`
@@ -2802,10 +2790,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2802
2790
  return contractInput;
2803
2791
  }
2804
2792
  function getInputAccountAddress(input) {
2805
- if (input.type === InputType6.Coin) {
2793
+ if (input.type === InputType5.Coin) {
2806
2794
  return input.owner.toString();
2807
2795
  }
2808
- if (input.type === InputType6.Message) {
2796
+ if (input.type === InputType5.Message) {
2809
2797
  return input.recipient.toString();
2810
2798
  }
2811
2799
  return "";
@@ -3628,6 +3616,7 @@ var processGqlChain = (chain) => {
3628
3616
  gasPerByte: bn15(feeParams.gasPerByte),
3629
3617
  maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3630
3618
  chainId: bn15(consensusParameters.chainId),
3619
+ baseAssetId: consensusParameters.baseAssetId,
3631
3620
  gasCosts
3632
3621
  },
3633
3622
  gasCosts,
@@ -3870,6 +3859,17 @@ var _Provider = class {
3870
3859
  } = this.getChain();
3871
3860
  return chainId.toNumber();
3872
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
+ }
3873
3873
  /**
3874
3874
  * Submits a transaction to the chain to be executed.
3875
3875
  *
@@ -4549,7 +4549,7 @@ cacheInputs_fn = function(inputs) {
4549
4549
  return;
4550
4550
  }
4551
4551
  inputs.forEach((input) => {
4552
- if (input.type === InputType7.Coin) {
4552
+ if (input.type === InputType6.Coin) {
4553
4553
  this.cache?.set(input.id);
4554
4554
  }
4555
4555
  });
@@ -4933,8 +4933,9 @@ var Account = class extends AbstractAccount {
4933
4933
  * @param assetId - The asset ID to check the balance for.
4934
4934
  * @returns A promise that resolves to the balance amount.
4935
4935
  */
4936
- async getBalance(assetId = BaseAssetId3) {
4937
- 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);
4938
4939
  return amount;
4939
4940
  }
4940
4941
  /**
@@ -4972,9 +4973,10 @@ var Account = class extends AbstractAccount {
4972
4973
  * @returns A promise that resolves when the resources are added to the transaction.
4973
4974
  */
4974
4975
  async fund(request, coinQuantities, fee) {
4976
+ const baseAssetId = this.provider.getBaseAssetId();
4975
4977
  const updatedQuantities = addAmountToAsset({
4976
4978
  amount: bn17(fee),
4977
- assetId: BaseAssetId3,
4979
+ assetId: baseAssetId,
4978
4980
  coinQuantities
4979
4981
  });
4980
4982
  const quantitiesDict = {};
@@ -4998,8 +5000,8 @@ var Account = class extends AbstractAccount {
4998
5000
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4999
5001
  cachedUtxos.push(input.id);
5000
5002
  }
5001
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
5002
- 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);
5003
5005
  cachedMessages.push(input.nonce);
5004
5006
  }
5005
5007
  }
@@ -5031,11 +5033,13 @@ var Account = class extends AbstractAccount {
5031
5033
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5032
5034
  * @returns A promise that resolves to the prepared transaction request.
5033
5035
  */
5034
- async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5036
+ async createTransfer(destination, amount, assetId, txParams = {}) {
5035
5037
  const { minGasPrice } = this.provider.getGasConfig();
5036
- 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 };
5037
5041
  const request = new ScriptTransactionRequest(params);
5038
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5042
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5039
5043
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5040
5044
  estimateTxDependencies: true,
5041
5045
  resourcesOwner: this
@@ -5061,14 +5065,15 @@ var Account = class extends AbstractAccount {
5061
5065
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5062
5066
  * @returns A promise that resolves to the transaction response.
5063
5067
  */
5064
- async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5068
+ async transfer(destination, amount, assetId, txParams = {}) {
5065
5069
  if (bn17(amount).lte(0)) {
5066
5070
  throw new FuelError15(
5067
5071
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5068
5072
  "Transfer amount must be a positive number."
5069
5073
  );
5070
5074
  }
5071
- 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);
5072
5077
  return this.sendTransaction(request, { estimateTxDependencies: false });
5073
5078
  }
5074
5079
  /**
@@ -5080,7 +5085,7 @@ var Account = class extends AbstractAccount {
5080
5085
  * @param txParams - The optional transaction parameters.
5081
5086
  * @returns A promise that resolves to the transaction response.
5082
5087
  */
5083
- async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5088
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
5084
5089
  if (bn17(amount).lte(0)) {
5085
5090
  throw new FuelError15(
5086
5091
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
@@ -5089,11 +5094,13 @@ var Account = class extends AbstractAccount {
5089
5094
  }
5090
5095
  const contractAddress = Address3.fromAddressOrString(contractId);
5091
5096
  const { minGasPrice } = this.provider.getGasConfig();
5092
- 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 };
5093
5100
  const { script, scriptData } = await assembleTransferToContractScript({
5094
5101
  hexlifiedContractId: contractAddress.toB256(),
5095
5102
  amountToTransfer: bn17(amount),
5096
- assetId
5103
+ assetId: assetIdToTransfer
5097
5104
  });
5098
5105
  const request = new ScriptTransactionRequest({
5099
5106
  ...params,
@@ -5103,7 +5110,7 @@ var Account = class extends AbstractAccount {
5103
5110
  request.addContractInputAndOutput(contractAddress);
5104
5111
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5105
5112
  request,
5106
- [{ amount: bn17(amount), assetId: String(assetId) }]
5113
+ [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
5107
5114
  );
5108
5115
  request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5109
5116
  this.validateGas({
@@ -5125,6 +5132,7 @@ var Account = class extends AbstractAccount {
5125
5132
  */
5126
5133
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5127
5134
  const { minGasPrice } = this.provider.getGasConfig();
5135
+ const baseAssetId = this.provider.getBaseAssetId();
5128
5136
  const recipientAddress = Address3.fromAddressOrString(recipient);
5129
5137
  const recipientDataArray = arrayify14(
5130
5138
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -5137,9 +5145,14 @@ var Account = class extends AbstractAccount {
5137
5145
  ...recipientDataArray,
5138
5146
  ...amountDataArray
5139
5147
  ]);
5140
- const params = { script, gasPrice: minGasPrice, ...txParams };
5148
+ const params = {
5149
+ script,
5150
+ gasPrice: minGasPrice,
5151
+ baseAssetId,
5152
+ ...txParams
5153
+ };
5141
5154
  const request = new ScriptTransactionRequest(params);
5142
- const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5155
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
5143
5156
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5144
5157
  request,
5145
5158
  forwardingQuantities
@@ -8716,9 +8729,8 @@ import {
8716
8729
  SCRIPT_FIXED_SIZE
8717
8730
  } from "@fuel-ts/abi-coder";
8718
8731
  import { Address as Address9 } from "@fuel-ts/address";
8719
- import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8720
8732
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8721
- import { ByteArrayCoder } from "@fuel-ts/transactions";
8733
+ import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8722
8734
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8723
8735
 
8724
8736
  // src/predicate/utils/getPredicateRoot.ts
@@ -8777,15 +8789,10 @@ var Predicate = class extends Account {
8777
8789
  populateTransactionPredicateData(transactionRequestLike) {
8778
8790
  const request = transactionRequestify(transactionRequestLike);
8779
8791
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8780
- const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
8781
- if (placeholderIndex !== -1) {
8782
- request.removeWitness(placeholderIndex);
8783
- }
8784
- request.inputs.filter(isRequestInputResource).forEach((input) => {
8785
- if (isRequestInputResourceFromOwner(input, this.address)) {
8792
+ request.inputs?.forEach((input) => {
8793
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8786
8794
  input.predicate = this.bytes;
8787
8795
  input.predicateData = this.getPredicateData(policies.length);
8788
- input.witnessIndex = 0;
8789
8796
  }
8790
8797
  });
8791
8798
  return request;
@@ -8799,8 +8806,9 @@ var Predicate = class extends Account {
8799
8806
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8800
8807
  * @returns A promise that resolves to the prepared transaction request.
8801
8808
  */
8802
- async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
8803
- 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);
8804
8812
  return this.populateTransactionPredicateData(request);
8805
8813
  }
8806
8814
  /**
@@ -8823,20 +8831,6 @@ var Predicate = class extends Account {
8823
8831
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8824
8832
  return super.simulateTransaction(transactionRequest);
8825
8833
  }
8826
- /**
8827
- * Retrieves resources satisfying the spend query for the account.
8828
- *
8829
- * @param quantities - Coins to retrieve.
8830
- * @param excludedIds - IDs of resources to be excluded from the query.
8831
- * @returns A promise that resolves to an array of Resources.
8832
- */
8833
- async getResourcesToSpend(quantities, excludedIds) {
8834
- const resources = await super.getResourcesToSpend(quantities, excludedIds);
8835
- return resources.map((resource) => ({
8836
- ...resource,
8837
- predicate: hexlify19(this.bytes)
8838
- }));
8839
- }
8840
8834
  getPredicateData(policiesLength) {
8841
8835
  if (!this.predicateData.length) {
8842
8836
  return new Uint8Array();
@@ -8916,28 +8910,6 @@ var Predicate = class extends Account {
8916
8910
  }
8917
8911
  return mutatedBytes;
8918
8912
  }
8919
- /**
8920
- * Returns the index of the witness placeholder that was added to this predicate.
8921
- * If no witness placeholder was added, it returns -1.
8922
- * @param request - The transaction request.
8923
- * @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
8924
- */
8925
- getIndexFromPlaceholderWitness(request) {
8926
- const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
8927
- let index = -1;
8928
- const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
8929
- if (hasEmptyPredicateInputs) {
8930
- index = hasEmptyPredicateInputs.witnessIndex;
8931
- const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
8932
- if (!allInputsAreEmpty) {
8933
- const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
8934
- if (wasFilledInputAddedFirst) {
8935
- index = -1;
8936
- }
8937
- }
8938
- }
8939
- return index;
8940
- }
8941
8913
  };
8942
8914
 
8943
8915
  // src/connectors/fuel.ts
@@ -9660,7 +9632,6 @@ export {
9660
9632
  assets,
9661
9633
  buildBlockExplorerUrl,
9662
9634
  cacheFor,
9663
- cacheResources,
9664
9635
  calculateMetadataGasForTxCreate,
9665
9636
  calculateMetadataGasForTxScript,
9666
9637
  calculatePriceWithFactor,
@@ -9707,7 +9678,6 @@ export {
9707
9678
  getReceiptsMessageOut,
9708
9679
  getReceiptsTransferOut,
9709
9680
  getReceiptsWithMissingData,
9710
- getRequestInputResourceOwner,
9711
9681
  getTransactionStatusName,
9712
9682
  getTransactionSummary,
9713
9683
  getTransactionSummaryFromRequest,
@@ -9721,10 +9691,6 @@ export {
9721
9691
  isMessage,
9722
9692
  isRawCoin,
9723
9693
  isRawMessage,
9724
- isRequestInputCoin,
9725
- isRequestInputMessage,
9726
- isRequestInputResource,
9727
- isRequestInputResourceFromOwner,
9728
9694
  isType,
9729
9695
  isTypeCreate,
9730
9696
  isTypeMint,