@fuel-ts/account 0.0.0-rc-1976-20240419054120 → 0.0.0-rc-2037-20240419083713

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 +125 -100
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +281 -241
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +160 -126
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts +17 -2
  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 +2 -1
  13. package/dist/providers/coin.d.ts.map +1 -1
  14. package/dist/providers/message.d.ts +1 -0
  15. package/dist/providers/message.d.ts.map +1 -1
  16. package/dist/providers/provider.d.ts +0 -7
  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/helpers.d.ts +10 -0
  21. package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
  22. package/dist/providers/transaction-request/index.d.ts +1 -0
  23. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  24. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
  25. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  26. package/dist/providers/transaction-request/transaction-request.d.ts +6 -25
  27. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  28. package/dist/test-utils/index.d.ts +1 -0
  29. package/dist/test-utils/index.d.ts.map +1 -1
  30. package/dist/test-utils/launchNode.d.ts.map +1 -1
  31. package/dist/test-utils/resources.d.ts +4 -0
  32. package/dist/test-utils/resources.d.ts.map +1 -0
  33. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  34. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  35. package/dist/test-utils/transactionRequest.d.ts +5 -0
  36. package/dist/test-utils/transactionRequest.d.ts.map +1 -0
  37. package/dist/test-utils.global.js +104 -105
  38. package/dist/test-utils.global.js.map +1 -1
  39. package/dist/test-utils.js +253 -238
  40. package/dist/test-utils.js.map +1 -1
  41. package/dist/test-utils.mjs +141 -129
  42. package/dist/test-utils.mjs.map +1 -1
  43. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  44. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  45. package/package.json +15 -15
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACR,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,4BAA4B,EAC5B,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,CACjE,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAQ,SAAQ,eAAe;IAC1C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,SAAS,CAAC,SAA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;IA6C/B;;;;;;;OAOG;IACG,mBAAmB;IACvB,iDAAiD;IACjD,SAAS,EAAE,MAAM,GAAG,eAAe;IACnC,2BAA2B;IAC3B,MAAM,EAAE,YAAY;IACpB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAyCzB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOnD;;;;;OAKG;IACG,eAAe,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUtF;;;;;OAKG;IACG,eAAe,CACnB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,cAAc,EAAE,GAAE,oBAAyB,GAC3E,OAAO,CAAC,mBAAmB,CAAC;IAgB/B;;;;;OAKG;IACG,mBAAmB,CACvB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,GAAE,yBAA8B,GAChE,OAAO,CAAC,UAAU,CAAC;IAQtB,OAAO,CAAC,WAAW;CAyBpB"}
@@ -31272,6 +31272,10 @@ This unreleased fuel-core build may include features and updates not yet support
31272
31272
  }
31273
31273
  };
31274
31274
 
31275
+ // ../address/dist/configs.mjs
31276
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
31277
+ var BaseAssetId = ZeroBytes32;
31278
+
31275
31279
  // ../math/dist/index.mjs
31276
31280
  var import_bn = __toESM(require_bn(), 1);
31277
31281
  var DEFAULT_PRECISION = 9;
@@ -31502,11 +31506,11 @@ This unreleased fuel-core build may include features and updates not yet support
31502
31506
  let max2;
31503
31507
  if (Array.isArray(coinQuantityLike)) {
31504
31508
  amount = coinQuantityLike[0];
31505
- assetId = coinQuantityLike[1];
31506
- max2 = coinQuantityLike[2];
31509
+ assetId = coinQuantityLike[1] ?? BaseAssetId;
31510
+ max2 = coinQuantityLike[2] ?? void 0;
31507
31511
  } else {
31508
31512
  amount = coinQuantityLike.amount;
31509
- assetId = coinQuantityLike.assetId;
31513
+ assetId = coinQuantityLike.assetId ?? BaseAssetId;
31510
31514
  max2 = coinQuantityLike.max ?? void 0;
31511
31515
  }
31512
31516
  const bnAmount = bn(amount);
@@ -38870,9 +38874,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38870
38874
  }
38871
38875
  };
38872
38876
 
38873
- // ../address/dist/configs.mjs
38874
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38875
-
38876
38877
  // src/providers/transaction-request/input.ts
38877
38878
  var inputify = (value) => {
38878
38879
  const { type: type3 } = value;
@@ -39524,6 +39525,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39524
39525
  name = "NoWitnessByOwnerError";
39525
39526
  };
39526
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
+
39527
39549
  // src/providers/transaction-request/witness.ts
39528
39550
  var witnessify = (value) => {
39529
39551
  const data = arrayify(value);
@@ -39549,8 +39571,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39549
39571
  outputs = [];
39550
39572
  /** List of witnesses */
39551
39573
  witnesses = [];
39552
- /** Base asset ID - should be fetched from the chain */
39553
- baseAssetId;
39554
39574
  /**
39555
39575
  * Constructor for initializing a base transaction request.
39556
39576
  *
@@ -39563,9 +39583,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39563
39583
  witnessLimit,
39564
39584
  inputs,
39565
39585
  outputs,
39566
- witnesses,
39567
- baseAssetId
39568
- }) {
39586
+ witnesses
39587
+ } = {}) {
39569
39588
  this.gasPrice = bn(gasPrice);
39570
39589
  this.maturity = maturity ?? 0;
39571
39590
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
@@ -39573,7 +39592,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39573
39592
  this.inputs = inputs ?? [];
39574
39593
  this.outputs = outputs ?? [];
39575
39594
  this.witnesses = witnesses ?? [];
39576
- this.baseAssetId = baseAssetId;
39577
39595
  }
39578
39596
  static getPolicyMeta(req) {
39579
39597
  let policyTypes = 0;
@@ -39767,8 +39785,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39767
39785
  * @param predicate - Predicate bytes.
39768
39786
  * @param predicateData - Predicate data bytes.
39769
39787
  */
39770
- addCoinInput(coin, predicate) {
39771
- const { assetId, owner, amount } = coin;
39788
+ addCoinInput(coin) {
39789
+ const { assetId, owner, amount, id, predicate } = coin;
39772
39790
  let witnessIndex;
39773
39791
  if (predicate) {
39774
39792
  witnessIndex = 0;
@@ -39779,14 +39797,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39779
39797
  }
39780
39798
  }
39781
39799
  const input = {
39782
- ...coin,
39800
+ id,
39783
39801
  type: InputType.Coin,
39784
39802
  owner: owner.toB256(),
39785
39803
  amount,
39786
39804
  assetId,
39787
39805
  txPointer: "0x00000000000000000000000000000000",
39788
39806
  witnessIndex,
39789
- predicate: predicate?.bytes
39807
+ predicate
39790
39808
  };
39791
39809
  this.pushInput(input);
39792
39810
  this.addChangeOutput(owner, assetId);
@@ -39797,9 +39815,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39797
39815
  *
39798
39816
  * @param message - Message resource.
39799
39817
  * @param predicate - Predicate bytes.
39818
+ * @param predicateData - Predicate data bytes.
39800
39819
  */
39801
- addMessageInput(message, predicate) {
39802
- const { recipient, sender, amount } = message;
39820
+ addMessageInput(message) {
39821
+ const { recipient, sender, amount, predicate, nonce } = message;
39822
+ const assetId = BaseAssetId;
39803
39823
  let witnessIndex;
39804
39824
  if (predicate) {
39805
39825
  witnessIndex = 0;
@@ -39810,16 +39830,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39810
39830
  }
39811
39831
  }
39812
39832
  const input = {
39813
- ...message,
39833
+ nonce,
39814
39834
  type: InputType.Message,
39815
39835
  sender: sender.toB256(),
39816
39836
  recipient: recipient.toB256(),
39817
39837
  amount,
39818
39838
  witnessIndex,
39819
- predicate: predicate?.bytes
39839
+ predicate
39820
39840
  };
39821
39841
  this.pushInput(input);
39822
- this.addChangeOutput(recipient, this.baseAssetId);
39842
+ this.addChangeOutput(recipient, assetId);
39823
39843
  }
39824
39844
  /**
39825
39845
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39847,32 +39867,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39847
39867
  resources.forEach((resource) => this.addResource(resource));
39848
39868
  return this;
39849
39869
  }
39850
- /**
39851
- * Adds multiple resources to the transaction by adding coin/message inputs and change
39852
- * outputs from the related assetIds.
39853
- *
39854
- * @param resources - The resources to add.
39855
- * @returns This transaction.
39856
- */
39857
- addPredicateResource(resource, predicate) {
39858
- if (isCoin(resource)) {
39859
- this.addCoinInput(resource, predicate);
39860
- } else {
39861
- this.addMessageInput(resource, predicate);
39862
- }
39863
- return this;
39864
- }
39865
- /**
39866
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
39867
- * from the related assetIds.
39868
- *
39869
- * @param resources - The resources to add.
39870
- * @returns This transaction.
39871
- */
39872
- addPredicateResources(resources, predicate) {
39873
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
39874
- return this;
39875
- }
39876
39870
  /**
39877
39871
  * Adds a coin output to the transaction.
39878
39872
  *
@@ -39880,12 +39874,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39880
39874
  * @param amount - Amount of coin.
39881
39875
  * @param assetId - Asset ID of coin.
39882
39876
  */
39883
- addCoinOutput(to, amount, assetId) {
39877
+ addCoinOutput(to, amount, assetId = BaseAssetId) {
39884
39878
  this.pushOutput({
39885
39879
  type: OutputType.Coin,
39886
39880
  to: addressify(to).toB256(),
39887
39881
  amount,
39888
- assetId: assetId ?? this.baseAssetId
39882
+ assetId
39889
39883
  });
39890
39884
  return this;
39891
39885
  }
@@ -39912,7 +39906,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39912
39906
  * @param to - Address of the owner.
39913
39907
  * @param assetId - Asset ID of coin.
39914
39908
  */
39915
- addChangeOutput(to, assetId) {
39909
+ addChangeOutput(to, assetId = BaseAssetId) {
39916
39910
  const changeOutput = this.getChangeOutputs().find(
39917
39911
  (output3) => hexlify(output3.assetId) === assetId
39918
39912
  );
@@ -39920,7 +39914,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39920
39914
  this.pushOutput({
39921
39915
  type: OutputType.Change,
39922
39916
  to: addressify(to).toB256(),
39923
- assetId: assetId ?? this.baseAssetId
39917
+ assetId
39924
39918
  });
39925
39919
  }
39926
39920
  }
@@ -39996,7 +39990,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39996
39990
  ]);
39997
39991
  }
39998
39992
  };
39999
- updateAssetInput(this.baseAssetId, bn(1e11));
39993
+ updateAssetInput(BaseAssetId, bn(1e11));
40000
39994
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
40001
39995
  }
40002
39996
  /**
@@ -40021,6 +40015,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40021
40015
  toJSON() {
40022
40016
  return normalizeJSON(this);
40023
40017
  }
40018
+ removeWitness(index) {
40019
+ this.witnesses.splice(index, 1);
40020
+ this.adjustWitnessIndexes(index);
40021
+ }
40024
40022
  updatePredicateInputs(inputs) {
40025
40023
  this.inputs.forEach((i) => {
40026
40024
  let correspondingInput;
@@ -40043,6 +40041,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40043
40041
  }
40044
40042
  });
40045
40043
  }
40044
+ adjustWitnessIndexes(removedIndex) {
40045
+ this.inputs.filter(isRequestInputResource).forEach((input) => {
40046
+ if (input.witnessIndex > removedIndex) {
40047
+ input.witnessIndex -= 1;
40048
+ }
40049
+ });
40050
+ }
40046
40051
  };
40047
40052
 
40048
40053
  // src/providers/transaction-request/hash-transaction.ts
@@ -40153,7 +40158,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40153
40158
  *
40154
40159
  * @param createTransactionRequestLike - The initial values for the instance
40155
40160
  */
40156
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
40161
+ constructor({
40162
+ bytecodeWitnessIndex,
40163
+ salt,
40164
+ storageSlots,
40165
+ ...rest
40166
+ } = {}) {
40157
40167
  super(rest);
40158
40168
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
40159
40169
  this.salt = hexlify(salt ?? ZeroBytes32);
@@ -40268,7 +40278,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40268
40278
  *
40269
40279
  * @param scriptTransactionRequestLike - The initial values for the instance.
40270
40280
  */
40271
- constructor({ script, scriptData, gasLimit, ...rest }) {
40281
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
40272
40282
  super(rest);
40273
40283
  this.gasLimit = bn(gasLimit);
40274
40284
  this.script = arrayify(script ?? returnZeroScript.bytes);
@@ -41414,7 +41424,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41414
41424
  gasPerByte: bn(feeParams.gasPerByte),
41415
41425
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41416
41426
  chainId: bn(consensusParameters.chainId),
41417
- baseAssetId: consensusParameters.baseAssetId,
41418
41427
  gasCosts
41419
41428
  },
41420
41429
  gasCosts,
@@ -41657,17 +41666,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41657
41666
  } = this.getChain();
41658
41667
  return chainId.toNumber();
41659
41668
  }
41660
- /**
41661
- * Returns the base asset ID
41662
- *
41663
- * @returns A promise that resolves to the base asset ID
41664
- */
41665
- getBaseAssetId() {
41666
- const {
41667
- consensusParameters: { baseAssetId }
41668
- } = this.getChain();
41669
- return baseAssetId;
41670
- }
41671
41669
  /**
41672
41670
  * Submits a transaction to the chain to be executed.
41673
41671
  *
@@ -42724,9 +42722,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42724
42722
  * @param assetId - The asset ID to check the balance for.
42725
42723
  * @returns A promise that resolves to the balance amount.
42726
42724
  */
42727
- async getBalance(assetId) {
42728
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42729
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42725
+ async getBalance(assetId = BaseAssetId) {
42726
+ const amount = await this.provider.getBalance(this.address, assetId);
42730
42727
  return amount;
42731
42728
  }
42732
42729
  /**
@@ -42764,10 +42761,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42764
42761
  * @returns A promise that resolves when the resources are added to the transaction.
42765
42762
  */
42766
42763
  async fund(request, coinQuantities, fee) {
42767
- const baseAssetId = this.provider.getBaseAssetId();
42768
42764
  const updatedQuantities = addAmountToAsset({
42769
42765
  amount: bn(fee),
42770
- assetId: baseAssetId,
42766
+ assetId: BaseAssetId,
42771
42767
  coinQuantities
42772
42768
  });
42773
42769
  const quantitiesDict = {};
@@ -42791,8 +42787,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42791
42787
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42792
42788
  cachedUtxos.push(input.id);
42793
42789
  }
42794
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42795
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42790
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42791
+ quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42796
42792
  cachedMessages.push(input.nonce);
42797
42793
  }
42798
42794
  }
@@ -42824,13 +42820,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42824
42820
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42825
42821
  * @returns A promise that resolves to the prepared transaction request.
42826
42822
  */
42827
- async createTransfer(destination, amount, assetId, txParams = {}) {
42823
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42828
42824
  const { minGasPrice } = this.provider.getGasConfig();
42829
- const baseAssetId = this.provider.getBaseAssetId();
42830
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42831
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42825
+ const params = { gasPrice: minGasPrice, ...txParams };
42832
42826
  const request = new ScriptTransactionRequest(params);
42833
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42827
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42834
42828
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
42835
42829
  estimateTxDependencies: true,
42836
42830
  resourcesOwner: this
@@ -42856,15 +42850,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42856
42850
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42857
42851
  * @returns A promise that resolves to the transaction response.
42858
42852
  */
42859
- async transfer(destination, amount, assetId, txParams = {}) {
42853
+ async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42860
42854
  if (bn(amount).lte(0)) {
42861
42855
  throw new FuelError(
42862
42856
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42863
42857
  "Transfer amount must be a positive number."
42864
42858
  );
42865
42859
  }
42866
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42867
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42860
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
42868
42861
  return this.sendTransaction(request, { estimateTxDependencies: false });
42869
42862
  }
42870
42863
  /**
@@ -42876,7 +42869,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42876
42869
  * @param txParams - The optional transaction parameters.
42877
42870
  * @returns A promise that resolves to the transaction response.
42878
42871
  */
42879
- async transferToContract(contractId, amount, assetId, txParams = {}) {
42872
+ async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42880
42873
  if (bn(amount).lte(0)) {
42881
42874
  throw new FuelError(
42882
42875
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42885,13 +42878,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42885
42878
  }
42886
42879
  const contractAddress = Address.fromAddressOrString(contractId);
42887
42880
  const { minGasPrice } = this.provider.getGasConfig();
42888
- const baseAssetId = this.provider.getBaseAssetId();
42889
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42890
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42881
+ const params = { gasPrice: minGasPrice, ...txParams };
42891
42882
  const { script, scriptData } = await assembleTransferToContractScript({
42892
42883
  hexlifiedContractId: contractAddress.toB256(),
42893
42884
  amountToTransfer: bn(amount),
42894
- assetId: assetIdToTransfer
42885
+ assetId
42895
42886
  });
42896
42887
  const request = new ScriptTransactionRequest({
42897
42888
  ...params,
@@ -42901,7 +42892,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42901
42892
  request.addContractInputAndOutput(contractAddress);
42902
42893
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42903
42894
  request,
42904
- [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42895
+ [{ amount: bn(amount), assetId: String(assetId) }]
42905
42896
  );
42906
42897
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
42907
42898
  this.validateGas({
@@ -42923,7 +42914,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42923
42914
  */
42924
42915
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42925
42916
  const { minGasPrice } = this.provider.getGasConfig();
42926
- const baseAssetId = this.provider.getBaseAssetId();
42927
42917
  const recipientAddress = Address.fromAddressOrString(recipient);
42928
42918
  const recipientDataArray = arrayify(
42929
42919
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42936,14 +42926,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42936
42926
  ...recipientDataArray,
42937
42927
  ...amountDataArray
42938
42928
  ]);
42939
- const params = {
42940
- script,
42941
- gasPrice: minGasPrice,
42942
- baseAssetId,
42943
- ...txParams
42944
- };
42929
+ const params = { script, gasPrice: minGasPrice, ...txParams };
42945
42930
  const request = new ScriptTransactionRequest(params);
42946
- const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42931
+ const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42947
42932
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42948
42933
  request,
42949
42934
  forwardingQuantities
@@ -47889,10 +47874,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47889
47874
  populateTransactionPredicateData(transactionRequestLike) {
47890
47875
  const request = transactionRequestify(transactionRequestLike);
47891
47876
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
47892
- request.inputs?.forEach((input) => {
47893
- if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
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)) {
47894
47883
  input.predicate = this.bytes;
47895
47884
  input.predicateData = this.getPredicateData(policies.length);
47885
+ input.witnessIndex = 0;
47896
47886
  }
47897
47887
  });
47898
47888
  return request;
@@ -47906,9 +47896,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47906
47896
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47907
47897
  * @returns A promise that resolves to the prepared transaction request.
47908
47898
  */
47909
- async createTransfer(destination, amount, assetId, txParams = {}) {
47910
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47911
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47899
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47900
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47912
47901
  return this.populateTransactionPredicateData(request);
47913
47902
  }
47914
47903
  /**
@@ -47931,6 +47920,20 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47931
47920
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47932
47921
  return super.simulateTransaction(transactionRequest);
47933
47922
  }
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
+ }
47934
47937
  getPredicateData(policiesLength) {
47935
47938
  if (!this.predicateData.length) {
47936
47939
  return new Uint8Array();
@@ -48010,6 +48013,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48010
48013
  }
48011
48014
  return mutatedBytes;
48012
48015
  }
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
+ }
48013
48038
  };
48014
48039
 
48015
48040
  // src/connectors/fuel-connector.ts