@fuel-ts/account 0.0.0-rc-2037-20240419083713 → 0.0.0-rc-2045-20240419094011

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 (35) hide show
  1. package/dist/index.global.js +39 -86
  2. package/dist/index.global.js.map +1 -1
  3. package/dist/index.js +141 -201
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +64 -118
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/predicate/predicate.d.ts +2 -17
  8. package/dist/predicate/predicate.d.ts.map +1 -1
  9. package/dist/providers/coin.d.ts +1 -2
  10. package/dist/providers/coin.d.ts.map +1 -1
  11. package/dist/providers/message.d.ts +0 -1
  12. package/dist/providers/message.d.ts.map +1 -1
  13. package/dist/providers/transaction-request/index.d.ts +0 -1
  14. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  15. package/dist/providers/transaction-request/transaction-request.d.ts +20 -4
  16. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  17. package/dist/test-utils/index.d.ts +0 -1
  18. package/dist/test-utils/index.d.ts.map +1 -1
  19. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  20. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  21. package/dist/test-utils.global.js +40 -64
  22. package/dist/test-utils.global.js.map +1 -1
  23. package/dist/test-utils.js +135 -173
  24. package/dist/test-utils.js.map +1 -1
  25. package/dist/test-utils.mjs +64 -99
  26. package/dist/test-utils.mjs.map +1 -1
  27. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  28. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  29. package/package.json +15 -15
  30. package/dist/providers/transaction-request/helpers.d.ts +0 -10
  31. package/dist/providers/transaction-request/helpers.d.ts.map +0 -1
  32. package/dist/test-utils/resources.d.ts +0 -4
  33. package/dist/test-utils/resources.d.ts.map +0 -1
  34. package/dist/test-utils/transactionRequest.d.ts +0 -5
  35. package/dist/test-utils/transactionRequest.d.ts.map +0 -1
@@ -28952,7 +28952,7 @@ spurious results.`);
28952
28952
  // ../versions/dist/index.mjs
28953
28953
  function getBuiltinVersions() {
28954
28954
  return {
28955
- FORC: "0.49.3",
28955
+ FORC: "0.53.0",
28956
28956
  FUEL_CORE: "0.22.1",
28957
28957
  FUELS: "0.81.0"
28958
28958
  };
@@ -31144,7 +31144,7 @@ This unreleased fuel-core build may include features and updates not yet support
31144
31144
  toEvmAddress() {
31145
31145
  const b256Address = toB256(this.bech32Address);
31146
31146
  return {
31147
- value: clearFirst12BytesFromB256(b256Address)
31147
+ bits: clearFirst12BytesFromB256(b256Address)
31148
31148
  };
31149
31149
  }
31150
31150
  /**
@@ -31154,7 +31154,7 @@ This unreleased fuel-core build may include features and updates not yet support
31154
31154
  */
31155
31155
  toAssetId() {
31156
31156
  return {
31157
- value: this.toB256()
31157
+ bits: this.toB256()
31158
31158
  };
31159
31159
  }
31160
31160
  /**
@@ -39525,27 +39525,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39525
39525
  name = "NoWitnessByOwnerError";
39526
39526
  };
39527
39527
 
39528
- // src/providers/transaction-request/helpers.ts
39529
- var isRequestInputCoin = (input) => input.type === InputType.Coin;
39530
- var isRequestInputMessage = (input) => input.type === InputType.Message;
39531
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
39532
- var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
39533
- var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
39534
- var cacheResources = (resources) => resources.reduce(
39535
- (cache2, resource) => {
39536
- if (isCoin(resource)) {
39537
- cache2.utxos.push(resource.id);
39538
- } else {
39539
- cache2.messages.push(resource.nonce);
39540
- }
39541
- return cache2;
39542
- },
39543
- {
39544
- utxos: [],
39545
- messages: []
39546
- }
39547
- );
39548
-
39549
39528
  // src/providers/transaction-request/witness.ts
39550
39529
  var witnessify = (value) => {
39551
39530
  const data = arrayify(value);
@@ -39785,8 +39764,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39785
39764
  * @param predicate - Predicate bytes.
39786
39765
  * @param predicateData - Predicate data bytes.
39787
39766
  */
39788
- addCoinInput(coin) {
39789
- const { assetId, owner, amount, id, predicate } = coin;
39767
+ addCoinInput(coin, predicate) {
39768
+ const { assetId, owner, amount } = coin;
39790
39769
  let witnessIndex;
39791
39770
  if (predicate) {
39792
39771
  witnessIndex = 0;
@@ -39797,14 +39776,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39797
39776
  }
39798
39777
  }
39799
39778
  const input = {
39800
- id,
39779
+ ...coin,
39801
39780
  type: InputType.Coin,
39802
39781
  owner: owner.toB256(),
39803
39782
  amount,
39804
39783
  assetId,
39805
39784
  txPointer: "0x00000000000000000000000000000000",
39806
39785
  witnessIndex,
39807
- predicate
39786
+ predicate: predicate?.bytes
39808
39787
  };
39809
39788
  this.pushInput(input);
39810
39789
  this.addChangeOutput(owner, assetId);
@@ -39817,8 +39796,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39817
39796
  * @param predicate - Predicate bytes.
39818
39797
  * @param predicateData - Predicate data bytes.
39819
39798
  */
39820
- addMessageInput(message) {
39821
- const { recipient, sender, amount, predicate, nonce } = message;
39799
+ addMessageInput(message, predicate) {
39800
+ const { recipient, sender, amount } = message;
39822
39801
  const assetId = BaseAssetId;
39823
39802
  let witnessIndex;
39824
39803
  if (predicate) {
@@ -39830,13 +39809,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39830
39809
  }
39831
39810
  }
39832
39811
  const input = {
39833
- nonce,
39812
+ ...message,
39834
39813
  type: InputType.Message,
39835
39814
  sender: sender.toB256(),
39836
39815
  recipient: recipient.toB256(),
39837
39816
  amount,
39838
39817
  witnessIndex,
39839
- predicate
39818
+ predicate: predicate?.bytes
39840
39819
  };
39841
39820
  this.pushInput(input);
39842
39821
  this.addChangeOutput(recipient, assetId);
@@ -39867,6 +39846,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39867
39846
  resources.forEach((resource) => this.addResource(resource));
39868
39847
  return this;
39869
39848
  }
39849
+ /**
39850
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
39851
+ * outputs from the related assetIds.
39852
+ *
39853
+ * @param resources - The resources to add.
39854
+ * @returns This transaction.
39855
+ */
39856
+ addPredicateResource(resource, predicate) {
39857
+ if (isCoin(resource)) {
39858
+ this.addCoinInput(resource, predicate);
39859
+ } else {
39860
+ this.addMessageInput(resource, predicate);
39861
+ }
39862
+ return this;
39863
+ }
39864
+ /**
39865
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
39866
+ * from the related assetIds.
39867
+ *
39868
+ * @param resources - The resources to add.
39869
+ * @returns This transaction.
39870
+ */
39871
+ addPredicateResources(resources, predicate) {
39872
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
39873
+ return this;
39874
+ }
39870
39875
  /**
39871
39876
  * Adds a coin output to the transaction.
39872
39877
  *
@@ -40015,10 +40020,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40015
40020
  toJSON() {
40016
40021
  return normalizeJSON(this);
40017
40022
  }
40018
- removeWitness(index) {
40019
- this.witnesses.splice(index, 1);
40020
- this.adjustWitnessIndexes(index);
40021
- }
40022
40023
  updatePredicateInputs(inputs) {
40023
40024
  this.inputs.forEach((i) => {
40024
40025
  let correspondingInput;
@@ -40041,13 +40042,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40041
40042
  }
40042
40043
  });
40043
40044
  }
40044
- adjustWitnessIndexes(removedIndex) {
40045
- this.inputs.filter(isRequestInputResource).forEach((input) => {
40046
- if (input.witnessIndex > removedIndex) {
40047
- input.witnessIndex -= 1;
40048
- }
40049
- });
40050
- }
40051
40045
  };
40052
40046
 
40053
40047
  // src/providers/transaction-request/hash-transaction.ts
@@ -47874,15 +47868,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47874
47868
  populateTransactionPredicateData(transactionRequestLike) {
47875
47869
  const request = transactionRequestify(transactionRequestLike);
47876
47870
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
47877
- const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
47878
- if (placeholderIndex !== -1) {
47879
- request.removeWitness(placeholderIndex);
47880
- }
47881
- request.inputs.filter(isRequestInputResource).forEach((input) => {
47882
- if (isRequestInputResourceFromOwner(input, this.address)) {
47871
+ request.inputs?.forEach((input) => {
47872
+ if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
47883
47873
  input.predicate = this.bytes;
47884
47874
  input.predicateData = this.getPredicateData(policies.length);
47885
- input.witnessIndex = 0;
47886
47875
  }
47887
47876
  });
47888
47877
  return request;
@@ -47920,20 +47909,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47920
47909
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47921
47910
  return super.simulateTransaction(transactionRequest);
47922
47911
  }
47923
- /**
47924
- * Retrieves resources satisfying the spend query for the account.
47925
- *
47926
- * @param quantities - Coins to retrieve.
47927
- * @param excludedIds - IDs of resources to be excluded from the query.
47928
- * @returns A promise that resolves to an array of Resources.
47929
- */
47930
- async getResourcesToSpend(quantities, excludedIds) {
47931
- const resources = await super.getResourcesToSpend(quantities, excludedIds);
47932
- return resources.map((resource) => ({
47933
- ...resource,
47934
- predicate: hexlify(this.bytes)
47935
- }));
47936
- }
47937
47912
  getPredicateData(policiesLength) {
47938
47913
  if (!this.predicateData.length) {
47939
47914
  return new Uint8Array();
@@ -48013,28 +47988,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48013
47988
  }
48014
47989
  return mutatedBytes;
48015
47990
  }
48016
- /**
48017
- * Returns the index of the witness placeholder that was added to this predicate.
48018
- * If no witness placeholder was added, it returns -1.
48019
- * @param request - The transaction request.
48020
- * @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
48021
- */
48022
- getIndexFromPlaceholderWitness(request) {
48023
- const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
48024
- let index = -1;
48025
- const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
48026
- if (hasEmptyPredicateInputs) {
48027
- index = hasEmptyPredicateInputs.witnessIndex;
48028
- const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
48029
- if (!allInputsAreEmpty) {
48030
- const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
48031
- if (wasFilledInputAddedFirst) {
48032
- index = -1;
48033
- }
48034
- }
48035
- }
48036
- return index;
48037
- }
48038
47991
  };
48039
47992
 
48040
47993
  // src/connectors/fuel-connector.ts