@fuel-ts/account 0.0.0-rc-2037-20240423110545 → 0.0.0-rc-2045-20240423120113

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 +57 -88
  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 +58 -66
  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.55.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
  /**
@@ -32342,6 +32342,20 @@ This unreleased fuel-core build may include features and updates not yet support
32342
32342
  ];
32343
32343
  }
32344
32344
  };
32345
+ var getEncodingVersion = (encoding) => {
32346
+ switch (encoding) {
32347
+ case void 0:
32348
+ case ENCODING_V0:
32349
+ return ENCODING_V0;
32350
+ case ENCODING_V1:
32351
+ return ENCODING_V1;
32352
+ default:
32353
+ throw new FuelError(
32354
+ ErrorCode.UNSUPPORTED_ENCODING_VERSION,
32355
+ `Encoding version '${encoding}' is unsupported.`
32356
+ );
32357
+ }
32358
+ };
32345
32359
  var findFunctionByName = (abi, name) => {
32346
32360
  const fn = abi.functions.find((f2) => f2.name === name);
32347
32361
  if (!fn) {
@@ -33106,7 +33120,7 @@ This unreleased fuel-core build may include features and updates not yet support
33106
33120
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
33107
33121
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
33108
33122
  this.selectorBytes = new StdStringCoder2().encode(name);
33109
- this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
33123
+ this.encoding = getEncodingVersion(jsonAbi.encoding);
33110
33124
  this.isInputDataPointer = this.#isInputDataPointer();
33111
33125
  this.outputMetadata = {
33112
33126
  isHeapType: this.#isOutputDataHeap(),
@@ -33244,8 +33258,10 @@ This unreleased fuel-core build may include features and updates not yet support
33244
33258
  functions;
33245
33259
  configurables;
33246
33260
  jsonAbi;
33261
+ encoding;
33247
33262
  constructor(jsonAbi) {
33248
33263
  this.jsonAbi = jsonAbi;
33264
+ this.encoding = getEncodingVersion(jsonAbi.encoding);
33249
33265
  this.functions = Object.fromEntries(
33250
33266
  this.jsonAbi.functions.map((x) => [x.name, new FunctionFragment(this.jsonAbi, x.name)])
33251
33267
  );
@@ -33289,7 +33305,7 @@ This unreleased fuel-core build may include features and updates not yet support
33289
33305
  );
33290
33306
  }
33291
33307
  return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
33292
- encoding: this.jsonAbi.encoding
33308
+ encoding: this.encoding
33293
33309
  });
33294
33310
  }
33295
33311
  encodeConfigurable(name, value) {
@@ -39525,27 +39541,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39525
39541
  name = "NoWitnessByOwnerError";
39526
39542
  };
39527
39543
 
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
39544
  // src/providers/transaction-request/witness.ts
39550
39545
  var witnessify = (value) => {
39551
39546
  const data = arrayify(value);
@@ -39785,8 +39780,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39785
39780
  * @param predicate - Predicate bytes.
39786
39781
  * @param predicateData - Predicate data bytes.
39787
39782
  */
39788
- addCoinInput(coin) {
39789
- const { assetId, owner, amount, id, predicate } = coin;
39783
+ addCoinInput(coin, predicate) {
39784
+ const { assetId, owner, amount } = coin;
39790
39785
  let witnessIndex;
39791
39786
  if (predicate) {
39792
39787
  witnessIndex = 0;
@@ -39797,14 +39792,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39797
39792
  }
39798
39793
  }
39799
39794
  const input = {
39800
- id,
39795
+ ...coin,
39801
39796
  type: InputType.Coin,
39802
39797
  owner: owner.toB256(),
39803
39798
  amount,
39804
39799
  assetId,
39805
39800
  txPointer: "0x00000000000000000000000000000000",
39806
39801
  witnessIndex,
39807
- predicate
39802
+ predicate: predicate?.bytes
39808
39803
  };
39809
39804
  this.pushInput(input);
39810
39805
  this.addChangeOutput(owner, assetId);
@@ -39817,8 +39812,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39817
39812
  * @param predicate - Predicate bytes.
39818
39813
  * @param predicateData - Predicate data bytes.
39819
39814
  */
39820
- addMessageInput(message) {
39821
- const { recipient, sender, amount, predicate, nonce } = message;
39815
+ addMessageInput(message, predicate) {
39816
+ const { recipient, sender, amount } = message;
39822
39817
  const assetId = BaseAssetId;
39823
39818
  let witnessIndex;
39824
39819
  if (predicate) {
@@ -39830,13 +39825,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39830
39825
  }
39831
39826
  }
39832
39827
  const input = {
39833
- nonce,
39828
+ ...message,
39834
39829
  type: InputType.Message,
39835
39830
  sender: sender.toB256(),
39836
39831
  recipient: recipient.toB256(),
39837
39832
  amount,
39838
39833
  witnessIndex,
39839
- predicate
39834
+ predicate: predicate?.bytes
39840
39835
  };
39841
39836
  this.pushInput(input);
39842
39837
  this.addChangeOutput(recipient, assetId);
@@ -39867,6 +39862,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39867
39862
  resources.forEach((resource) => this.addResource(resource));
39868
39863
  return this;
39869
39864
  }
39865
+ /**
39866
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
39867
+ * outputs from the related assetIds.
39868
+ *
39869
+ * @param resources - The resources to add.
39870
+ * @returns This transaction.
39871
+ */
39872
+ addPredicateResource(resource, predicate) {
39873
+ if (isCoin(resource)) {
39874
+ this.addCoinInput(resource, predicate);
39875
+ } else {
39876
+ this.addMessageInput(resource, predicate);
39877
+ }
39878
+ return this;
39879
+ }
39880
+ /**
39881
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
39882
+ * from the related assetIds.
39883
+ *
39884
+ * @param resources - The resources to add.
39885
+ * @returns This transaction.
39886
+ */
39887
+ addPredicateResources(resources, predicate) {
39888
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
39889
+ return this;
39890
+ }
39870
39891
  /**
39871
39892
  * Adds a coin output to the transaction.
39872
39893
  *
@@ -40015,10 +40036,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40015
40036
  toJSON() {
40016
40037
  return normalizeJSON(this);
40017
40038
  }
40018
- removeWitness(index) {
40019
- this.witnesses.splice(index, 1);
40020
- this.adjustWitnessIndexes(index);
40021
- }
40022
40039
  updatePredicateInputs(inputs) {
40023
40040
  this.inputs.forEach((i) => {
40024
40041
  let correspondingInput;
@@ -40041,13 +40058,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40041
40058
  }
40042
40059
  });
40043
40060
  }
40044
- adjustWitnessIndexes(removedIndex) {
40045
- this.inputs.filter(isRequestInputResource).forEach((input) => {
40046
- if (input.witnessIndex > removedIndex) {
40047
- input.witnessIndex -= 1;
40048
- }
40049
- });
40050
- }
40051
40061
  };
40052
40062
 
40053
40063
  // src/providers/transaction-request/hash-transaction.ts
@@ -47874,15 +47884,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47874
47884
  populateTransactionPredicateData(transactionRequestLike) {
47875
47885
  const request = transactionRequestify(transactionRequestLike);
47876
47886
  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)) {
47887
+ request.inputs?.forEach((input) => {
47888
+ if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
47883
47889
  input.predicate = this.bytes;
47884
47890
  input.predicateData = this.getPredicateData(policies.length);
47885
- input.witnessIndex = 0;
47886
47891
  }
47887
47892
  });
47888
47893
  return request;
@@ -47920,20 +47925,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47920
47925
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47921
47926
  return super.simulateTransaction(transactionRequest);
47922
47927
  }
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
47928
  getPredicateData(policiesLength) {
47938
47929
  if (!this.predicateData.length) {
47939
47930
  return new Uint8Array();
@@ -48013,28 +48004,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48013
48004
  }
48014
48005
  return mutatedBytes;
48015
48006
  }
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
48007
  };
48039
48008
 
48040
48009
  // src/connectors/fuel-connector.ts