@fuel-ts/account 0.0.0-rc-2037-20240429115810 → 0.0.0-rc-2152-20240429145747

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 (33) hide show
  1. package/dist/index.global.js +126 -1074
  2. package/dist/index.global.js.map +1 -1
  3. package/dist/index.js +128 -218
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +39 -123
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/predicate/predicate.d.ts +2 -9
  8. package/dist/predicate/predicate.d.ts.map +1 -1
  9. package/dist/providers/provider.d.ts +0 -9
  10. package/dist/providers/provider.d.ts.map +1 -1
  11. package/dist/providers/transaction-request/index.d.ts +0 -1
  12. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  13. package/dist/providers/transaction-request/transaction-request.d.ts +0 -2
  14. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  15. package/dist/test-utils/index.d.ts +0 -1
  16. package/dist/test-utils/index.d.ts.map +1 -1
  17. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  18. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  19. package/dist/test-utils.global.js +136 -1073
  20. package/dist/test-utils.global.js.map +1 -1
  21. package/dist/test-utils.js +125 -205
  22. package/dist/test-utils.js.map +1 -1
  23. package/dist/test-utils.mjs +42 -119
  24. package/dist/test-utils.mjs.map +1 -1
  25. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  26. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  27. package/package.json +15 -15
  28. package/dist/providers/transaction-request/helpers.d.ts +0 -10
  29. package/dist/providers/transaction-request/helpers.d.ts.map +0 -1
  30. package/dist/test-utils/resources.d.ts +0 -4
  31. package/dist/test-utils/resources.d.ts.map +0 -1
  32. package/dist/test-utils/transactionRequest.d.ts +0 -5
  33. package/dist/test-utils/transactionRequest.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -75,7 +75,7 @@ import { Address as Address2 } from "@fuel-ts/address";
75
75
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
76
76
  import { BN, bn as bn16 } from "@fuel-ts/math";
77
77
  import {
78
- InputType as InputType8,
78
+ InputType as InputType7,
79
79
  TransactionType as TransactionType8,
80
80
  InputMessageCoder,
81
81
  TransactionCoder as TransactionCoder5
@@ -83,7 +83,6 @@ import {
83
83
  import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
84
84
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
85
85
  import { equalBytes } from "@noble/curves/abstract/utils";
86
- import { Network } from "ethers";
87
86
  import { GraphQLClient } from "graphql-request";
88
87
  import { clone as clone3 } from "ramda";
89
88
 
@@ -1240,7 +1239,7 @@ import { bn as bn7 } from "@fuel-ts/math";
1240
1239
  import {
1241
1240
  PolicyType,
1242
1241
  TransactionCoder,
1243
- InputType as InputType3,
1242
+ InputType as InputType2,
1244
1243
  OutputType as OutputType2,
1245
1244
  TransactionType
1246
1245
  } from "@fuel-ts/transactions";
@@ -1764,28 +1763,6 @@ var NoWitnessByOwnerError = class extends Error {
1764
1763
  name = "NoWitnessByOwnerError";
1765
1764
  };
1766
1765
 
1767
- // src/providers/transaction-request/helpers.ts
1768
- import { InputType as InputType2 } from "@fuel-ts/transactions";
1769
- var isRequestInputCoin = (input) => input.type === InputType2.Coin;
1770
- var isRequestInputMessage = (input) => input.type === InputType2.Message;
1771
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1772
- var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
1773
- var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1774
- var cacheResources = (resources) => resources.reduce(
1775
- (cache2, resource) => {
1776
- if (isCoin(resource)) {
1777
- cache2.utxos.push(resource.id);
1778
- } else {
1779
- cache2.messages.push(resource.nonce);
1780
- }
1781
- return cache2;
1782
- },
1783
- {
1784
- utxos: [],
1785
- messages: []
1786
- }
1787
- );
1788
-
1789
1766
  // src/providers/transaction-request/witness.ts
1790
1767
  import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
1791
1768
  var witnessify = (value) => {
@@ -1976,7 +1953,7 @@ var BaseTransactionRequest = class {
1976
1953
  */
1977
1954
  getCoinInputs() {
1978
1955
  return this.inputs.filter(
1979
- (input) => input.type === InputType3.Coin
1956
+ (input) => input.type === InputType2.Coin
1980
1957
  );
1981
1958
  }
1982
1959
  /**
@@ -2008,9 +1985,9 @@ var BaseTransactionRequest = class {
2008
1985
  const ownerAddress = addressify(owner);
2009
1986
  const found = this.inputs.find((input) => {
2010
1987
  switch (input.type) {
2011
- case InputType3.Coin:
1988
+ case InputType2.Coin:
2012
1989
  return hexlify7(input.owner) === ownerAddress.toB256();
2013
- case InputType3.Message:
1990
+ case InputType2.Message:
2014
1991
  return hexlify7(input.recipient) === ownerAddress.toB256();
2015
1992
  default:
2016
1993
  return false;
@@ -2025,7 +2002,7 @@ var BaseTransactionRequest = class {
2025
2002
  * @param coin - Coin resource.
2026
2003
  */
2027
2004
  addCoinInput(coin) {
2028
- const { assetId, owner, amount, id, predicate } = coin;
2005
+ const { assetId, owner, amount } = coin;
2029
2006
  let witnessIndex;
2030
2007
  if (coin.predicate) {
2031
2008
  witnessIndex = 0;
@@ -2036,14 +2013,13 @@ var BaseTransactionRequest = class {
2036
2013
  }
2037
2014
  }
2038
2015
  const input = {
2039
- id,
2040
- type: InputType3.Coin,
2016
+ ...coin,
2017
+ type: InputType2.Coin,
2041
2018
  owner: owner.toB256(),
2042
2019
  amount,
2043
2020
  assetId,
2044
2021
  txPointer: "0x00000000000000000000000000000000",
2045
- witnessIndex,
2046
- predicate
2022
+ witnessIndex
2047
2023
  };
2048
2024
  this.pushInput(input);
2049
2025
  this.addChangeOutput(owner, assetId);
@@ -2055,7 +2031,7 @@ var BaseTransactionRequest = class {
2055
2031
  * @param message - Message resource.
2056
2032
  */
2057
2033
  addMessageInput(message) {
2058
- const { recipient, sender, amount, predicate, nonce, assetId } = message;
2034
+ const { recipient, sender, amount, assetId } = message;
2059
2035
  let witnessIndex;
2060
2036
  if (message.predicate) {
2061
2037
  witnessIndex = 0;
@@ -2066,13 +2042,12 @@ var BaseTransactionRequest = class {
2066
2042
  }
2067
2043
  }
2068
2044
  const input = {
2069
- nonce,
2070
- type: InputType3.Message,
2045
+ ...message,
2046
+ type: InputType2.Message,
2071
2047
  sender: sender.toB256(),
2072
2048
  recipient: recipient.toB256(),
2073
2049
  amount,
2074
- witnessIndex,
2075
- predicate
2050
+ witnessIndex
2076
2051
  };
2077
2052
  this.pushInput(input);
2078
2053
  this.addChangeOutput(recipient, assetId);
@@ -2256,27 +2231,16 @@ var BaseTransactionRequest = class {
2256
2231
  toJSON() {
2257
2232
  return normalizeJSON(this);
2258
2233
  }
2259
- removeWitness(index) {
2260
- this.witnesses.splice(index, 1);
2261
- this.adjustWitnessIndexes(index);
2262
- }
2263
- adjustWitnessIndexes(removedIndex) {
2264
- this.inputs.filter(isRequestInputResource).forEach((input) => {
2265
- if (input.witnessIndex > removedIndex) {
2266
- input.witnessIndex -= 1;
2267
- }
2268
- });
2269
- }
2270
2234
  updatePredicateGasUsed(inputs) {
2271
2235
  this.inputs.forEach((i) => {
2272
2236
  let correspondingInput;
2273
2237
  switch (i.type) {
2274
- case InputType3.Coin:
2275
- correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
2238
+ case InputType2.Coin:
2239
+ correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
2276
2240
  break;
2277
- case InputType3.Message:
2241
+ case InputType2.Message:
2278
2242
  correspondingInput = inputs.find(
2279
- (x) => x.type === InputType3.Message && x.sender === i.sender
2243
+ (x) => x.type === InputType2.Message && x.sender === i.sender
2280
2244
  );
2281
2245
  break;
2282
2246
  default:
@@ -2310,7 +2274,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2310
2274
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2311
2275
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2312
2276
  import { bn as bn8 } from "@fuel-ts/math";
2313
- import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2277
+ import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2314
2278
  import { concat as concat2 } from "@fuel-ts/utils";
2315
2279
  import { clone as clone2 } from "ramda";
2316
2280
  function hashTransaction(transactionRequest, chainId) {
@@ -2321,7 +2285,7 @@ function hashTransaction(transactionRequest, chainId) {
2321
2285
  transaction.inputs = transaction.inputs.map((input) => {
2322
2286
  const inputClone = clone2(input);
2323
2287
  switch (inputClone.type) {
2324
- case InputType4.Coin: {
2288
+ case InputType3.Coin: {
2325
2289
  inputClone.txPointer = {
2326
2290
  blockHeight: 0,
2327
2291
  txIndex: 0
@@ -2329,11 +2293,11 @@ function hashTransaction(transactionRequest, chainId) {
2329
2293
  inputClone.predicateGasUsed = bn8(0);
2330
2294
  return inputClone;
2331
2295
  }
2332
- case InputType4.Message: {
2296
+ case InputType3.Message: {
2333
2297
  inputClone.predicateGasUsed = bn8(0);
2334
2298
  return inputClone;
2335
2299
  }
2336
- case InputType4.Contract: {
2300
+ case InputType3.Contract: {
2337
2301
  inputClone.txPointer = {
2338
2302
  blockHeight: 0,
2339
2303
  txIndex: 0
@@ -2493,7 +2457,7 @@ import { Interface } from "@fuel-ts/abi-coder";
2493
2457
  import { addressify as addressify2 } from "@fuel-ts/address";
2494
2458
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2495
2459
  import { bn as bn10 } from "@fuel-ts/math";
2496
- import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2460
+ import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2497
2461
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2498
2462
 
2499
2463
  // src/providers/transaction-request/scripts.ts
@@ -2577,7 +2541,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2577
2541
  */
2578
2542
  getContractInputs() {
2579
2543
  return this.inputs.filter(
2580
- (input) => input.type === InputType5.Contract
2544
+ (input) => input.type === InputType4.Contract
2581
2545
  );
2582
2546
  }
2583
2547
  /**
@@ -2654,7 +2618,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2654
2618
  return this;
2655
2619
  }
2656
2620
  const inputIndex = super.pushInput({
2657
- type: InputType5.Contract,
2621
+ type: InputType4.Contract,
2658
2622
  contractId: contractAddress.toB256(),
2659
2623
  txPointer: "0x00000000000000000000000000000000"
2660
2624
  });
@@ -2696,7 +2660,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2696
2660
 
2697
2661
  // src/providers/transaction-request/utils.ts
2698
2662
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2699
- import { TransactionType as TransactionType5, InputType as InputType6 } from "@fuel-ts/transactions";
2663
+ import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2700
2664
  var transactionRequestify = (obj) => {
2701
2665
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2702
2666
  return obj;
@@ -2716,10 +2680,10 @@ var transactionRequestify = (obj) => {
2716
2680
  };
2717
2681
  var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2718
2682
  (acc, input) => {
2719
- if (input.type === InputType6.Coin && input.owner === owner) {
2683
+ if (input.type === InputType5.Coin && input.owner === owner) {
2720
2684
  acc.utxos.push(input.id);
2721
2685
  }
2722
- if (input.type === InputType6.Message && input.recipient === owner) {
2686
+ if (input.type === InputType5.Message && input.recipient === owner) {
2723
2687
  acc.messages.push(input.nonce);
2724
2688
  }
2725
2689
  return acc;
@@ -2873,7 +2837,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2873
2837
 
2874
2838
  // src/providers/transaction-summary/input.ts
2875
2839
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2876
- import { InputType as InputType7 } from "@fuel-ts/transactions";
2840
+ import { InputType as InputType6 } from "@fuel-ts/transactions";
2877
2841
  function getInputsByTypes(inputs, types) {
2878
2842
  return inputs.filter((i) => types.includes(i.type));
2879
2843
  }
@@ -2881,16 +2845,16 @@ function getInputsByType(inputs, type) {
2881
2845
  return inputs.filter((i) => i.type === type);
2882
2846
  }
2883
2847
  function getInputsCoin(inputs) {
2884
- return getInputsByType(inputs, InputType7.Coin);
2848
+ return getInputsByType(inputs, InputType6.Coin);
2885
2849
  }
2886
2850
  function getInputsMessage(inputs) {
2887
- return getInputsByType(inputs, InputType7.Message);
2851
+ return getInputsByType(inputs, InputType6.Message);
2888
2852
  }
2889
2853
  function getInputsCoinAndMessage(inputs) {
2890
- return getInputsByTypes(inputs, [InputType7.Coin, InputType7.Message]);
2854
+ return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2891
2855
  }
2892
2856
  function getInputsContract(inputs) {
2893
- return getInputsByType(inputs, InputType7.Contract);
2857
+ return getInputsByType(inputs, InputType6.Contract);
2894
2858
  }
2895
2859
  function getInputFromAssetId(inputs, assetId) {
2896
2860
  const coinInputs = getInputsCoin(inputs);
@@ -2909,7 +2873,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2909
2873
  if (!contractInput) {
2910
2874
  return void 0;
2911
2875
  }
2912
- if (contractInput.type !== InputType7.Contract) {
2876
+ if (contractInput.type !== InputType6.Contract) {
2913
2877
  throw new FuelError9(
2914
2878
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2915
2879
  `Contract input should be of type 'contract'.`
@@ -2918,10 +2882,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2918
2882
  return contractInput;
2919
2883
  }
2920
2884
  function getInputAccountAddress(input) {
2921
- if (input.type === InputType7.Coin) {
2885
+ if (input.type === InputType6.Coin) {
2922
2886
  return input.owner.toString();
2923
2887
  }
2924
- if (input.type === InputType7.Message) {
2888
+ if (input.type === InputType6.Message) {
2925
2889
  return input.recipient.toString();
2926
2890
  }
2927
2891
  return "";
@@ -3932,21 +3896,6 @@ var _Provider = class {
3932
3896
  } = await this.operations.getVersion();
3933
3897
  return nodeVersion;
3934
3898
  }
3935
- /**
3936
- * @hidden
3937
- *
3938
- * Returns the network configuration of the connected Fuel node.
3939
- *
3940
- * @returns A promise that resolves to the network configuration object
3941
- */
3942
- async getNetwork() {
3943
- const {
3944
- name,
3945
- consensusParameters: { chainId }
3946
- } = await this.getChain();
3947
- const network = new Network(name, chainId.toNumber());
3948
- return Promise.resolve(network);
3949
- }
3950
3899
  /**
3951
3900
  * Returns the block number.
3952
3901
  *
@@ -4805,7 +4754,7 @@ cacheInputs_fn = function(inputs) {
4805
4754
  return;
4806
4755
  }
4807
4756
  inputs.forEach((input) => {
4808
- if (input.type === InputType8.Coin) {
4757
+ if (input.type === InputType7.Coin) {
4809
4758
  this.cache?.set(input.id);
4810
4759
  }
4811
4760
  });
@@ -8987,7 +8936,7 @@ import {
8987
8936
  } from "@fuel-ts/abi-coder";
8988
8937
  import { Address as Address9 } from "@fuel-ts/address";
8989
8938
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8990
- import { ByteArrayCoder } from "@fuel-ts/transactions";
8939
+ import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
8991
8940
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8992
8941
 
8993
8942
  // src/predicate/utils/getPredicateRoot.ts
@@ -9046,15 +8995,10 @@ var Predicate = class extends Account {
9046
8995
  populateTransactionPredicateData(transactionRequestLike) {
9047
8996
  const request = transactionRequestify(transactionRequestLike);
9048
8997
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9049
- const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
9050
- if (placeholderIndex !== -1) {
9051
- request.removeWitness(placeholderIndex);
9052
- }
9053
- request.inputs.filter(isRequestInputResource).forEach((input) => {
9054
- if (isRequestInputResourceFromOwner(input, this.address)) {
8998
+ request.inputs?.forEach((input) => {
8999
+ if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
9055
9000
  input.predicate = hexlify19(this.bytes);
9056
9001
  input.predicateData = hexlify19(this.getPredicateData(policies.length));
9057
- input.witnessIndex = 0;
9058
9002
  }
9059
9003
  });
9060
9004
  return request;
@@ -9177,28 +9121,6 @@ var Predicate = class extends Account {
9177
9121
  }
9178
9122
  return mutatedBytes;
9179
9123
  }
9180
- /**
9181
- * Returns the index of the witness placeholder that was added to this predicate.
9182
- * If no witness placeholder was added, it returns -1.
9183
- * @param request - The transaction request.
9184
- * @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
9185
- */
9186
- getIndexFromPlaceholderWitness(request) {
9187
- const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
9188
- let index = -1;
9189
- const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
9190
- if (hasEmptyPredicateInputs) {
9191
- index = hasEmptyPredicateInputs.witnessIndex;
9192
- const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
9193
- if (!allInputsAreEmpty) {
9194
- const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
9195
- if (wasFilledInputAddedFirst) {
9196
- index = -1;
9197
- }
9198
- }
9199
- }
9200
- return index;
9201
- }
9202
9124
  };
9203
9125
 
9204
9126
  // src/connectors/fuel.ts
@@ -9921,7 +9843,6 @@ export {
9921
9843
  assets,
9922
9844
  buildBlockExplorerUrl,
9923
9845
  cacheFor,
9924
- cacheResources,
9925
9846
  cacheTxInputsFromOwner,
9926
9847
  calculateGasFee,
9927
9848
  calculateMetadataGasForTxCreate,
@@ -9969,7 +9890,6 @@ export {
9969
9890
  getReceiptsMessageOut,
9970
9891
  getReceiptsTransferOut,
9971
9892
  getReceiptsWithMissingData,
9972
- getRequestInputResourceOwner,
9973
9893
  getTransactionStatusName,
9974
9894
  getTransactionSummary,
9975
9895
  getTransactionSummaryFromRequest,
@@ -9983,10 +9903,6 @@ export {
9983
9903
  isMessage,
9984
9904
  isRawCoin,
9985
9905
  isRawMessage,
9986
- isRequestInputCoin,
9987
- isRequestInputMessage,
9988
- isRequestInputResource,
9989
- isRequestInputResourceFromOwner,
9990
9906
  isType,
9991
9907
  isTypeCreate,
9992
9908
  isTypeMint,