@fuel-ts/account 0.0.0-rc-1976-20240417161625 → 0.0.0-rc-2037-20240417202046

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 +124 -100
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +280 -241
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +159 -126
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts +11 -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,32 @@ ${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) => {
39533
+ if (isRequestInputCoin(input)) {
39534
+ return input.owner;
39535
+ }
39536
+ return input.recipient;
39537
+ };
39538
+ var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
39539
+ var cacheResources = (resources) => resources.reduce(
39540
+ (cache2, resource) => {
39541
+ if (isCoin(resource)) {
39542
+ cache2.utxos.push(resource.id);
39543
+ } else {
39544
+ cache2.messages.push(resource.nonce);
39545
+ }
39546
+ return cache2;
39547
+ },
39548
+ {
39549
+ utxos: [],
39550
+ messages: []
39551
+ }
39552
+ );
39553
+
39527
39554
  // src/providers/transaction-request/witness.ts
39528
39555
  var witnessify = (value) => {
39529
39556
  const data = arrayify(value);
@@ -39549,8 +39576,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39549
39576
  outputs = [];
39550
39577
  /** List of witnesses */
39551
39578
  witnesses = [];
39552
- /** Base asset ID - should be fetched from the chain */
39553
- baseAssetId;
39554
39579
  /**
39555
39580
  * Constructor for initializing a base transaction request.
39556
39581
  *
@@ -39563,9 +39588,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39563
39588
  witnessLimit,
39564
39589
  inputs,
39565
39590
  outputs,
39566
- witnesses,
39567
- baseAssetId
39568
- }) {
39591
+ witnesses
39592
+ } = {}) {
39569
39593
  this.gasPrice = bn(gasPrice);
39570
39594
  this.maturity = maturity ?? 0;
39571
39595
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
@@ -39573,7 +39597,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39573
39597
  this.inputs = inputs ?? [];
39574
39598
  this.outputs = outputs ?? [];
39575
39599
  this.witnesses = witnesses ?? [];
39576
- this.baseAssetId = baseAssetId;
39577
39600
  }
39578
39601
  static getPolicyMeta(req) {
39579
39602
  let policyTypes = 0;
@@ -39767,8 +39790,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39767
39790
  * @param predicate - Predicate bytes.
39768
39791
  * @param predicateData - Predicate data bytes.
39769
39792
  */
39770
- addCoinInput(coin, predicate) {
39771
- const { assetId, owner, amount } = coin;
39793
+ addCoinInput(coin) {
39794
+ const { assetId, owner, amount, id, predicate } = coin;
39772
39795
  let witnessIndex;
39773
39796
  if (predicate) {
39774
39797
  witnessIndex = 0;
@@ -39779,14 +39802,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39779
39802
  }
39780
39803
  }
39781
39804
  const input = {
39782
- ...coin,
39805
+ id,
39783
39806
  type: InputType.Coin,
39784
39807
  owner: owner.toB256(),
39785
39808
  amount,
39786
39809
  assetId,
39787
39810
  txPointer: "0x00000000000000000000000000000000",
39788
39811
  witnessIndex,
39789
- predicate: predicate?.bytes
39812
+ predicate
39790
39813
  };
39791
39814
  this.pushInput(input);
39792
39815
  this.addChangeOutput(owner, assetId);
@@ -39797,9 +39820,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39797
39820
  *
39798
39821
  * @param message - Message resource.
39799
39822
  * @param predicate - Predicate bytes.
39823
+ * @param predicateData - Predicate data bytes.
39800
39824
  */
39801
- addMessageInput(message, predicate) {
39802
- const { recipient, sender, amount } = message;
39825
+ addMessageInput(message) {
39826
+ const { recipient, sender, amount, predicate, nonce } = message;
39827
+ const assetId = BaseAssetId;
39803
39828
  let witnessIndex;
39804
39829
  if (predicate) {
39805
39830
  witnessIndex = 0;
@@ -39810,16 +39835,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39810
39835
  }
39811
39836
  }
39812
39837
  const input = {
39813
- ...message,
39838
+ nonce,
39814
39839
  type: InputType.Message,
39815
39840
  sender: sender.toB256(),
39816
39841
  recipient: recipient.toB256(),
39817
39842
  amount,
39818
39843
  witnessIndex,
39819
- predicate: predicate?.bytes
39844
+ predicate
39820
39845
  };
39821
39846
  this.pushInput(input);
39822
- this.addChangeOutput(recipient, this.baseAssetId);
39847
+ this.addChangeOutput(recipient, assetId);
39823
39848
  }
39824
39849
  /**
39825
39850
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39847,32 +39872,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39847
39872
  resources.forEach((resource) => this.addResource(resource));
39848
39873
  return this;
39849
39874
  }
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
39875
  /**
39877
39876
  * Adds a coin output to the transaction.
39878
39877
  *
@@ -39880,12 +39879,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39880
39879
  * @param amount - Amount of coin.
39881
39880
  * @param assetId - Asset ID of coin.
39882
39881
  */
39883
- addCoinOutput(to, amount, assetId) {
39882
+ addCoinOutput(to, amount, assetId = BaseAssetId) {
39884
39883
  this.pushOutput({
39885
39884
  type: OutputType.Coin,
39886
39885
  to: addressify(to).toB256(),
39887
39886
  amount,
39888
- assetId: assetId ?? this.baseAssetId
39887
+ assetId
39889
39888
  });
39890
39889
  return this;
39891
39890
  }
@@ -39912,7 +39911,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39912
39911
  * @param to - Address of the owner.
39913
39912
  * @param assetId - Asset ID of coin.
39914
39913
  */
39915
- addChangeOutput(to, assetId) {
39914
+ addChangeOutput(to, assetId = BaseAssetId) {
39916
39915
  const changeOutput = this.getChangeOutputs().find(
39917
39916
  (output3) => hexlify(output3.assetId) === assetId
39918
39917
  );
@@ -39920,7 +39919,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39920
39919
  this.pushOutput({
39921
39920
  type: OutputType.Change,
39922
39921
  to: addressify(to).toB256(),
39923
- assetId: assetId ?? this.baseAssetId
39922
+ assetId
39924
39923
  });
39925
39924
  }
39926
39925
  }
@@ -39996,7 +39995,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39996
39995
  ]);
39997
39996
  }
39998
39997
  };
39999
- updateAssetInput(this.baseAssetId, bn(1e11));
39998
+ updateAssetInput(BaseAssetId, bn(1e11));
40000
39999
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
40001
40000
  }
40002
40001
  /**
@@ -40021,6 +40020,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40021
40020
  toJSON() {
40022
40021
  return normalizeJSON(this);
40023
40022
  }
40023
+ removeWitness(index) {
40024
+ this.witnesses.splice(index, 1);
40025
+ this.adjustWitnessIndexes(index);
40026
+ }
40024
40027
  updatePredicateInputs(inputs) {
40025
40028
  this.inputs.forEach((i) => {
40026
40029
  let correspondingInput;
@@ -40043,6 +40046,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40043
40046
  }
40044
40047
  });
40045
40048
  }
40049
+ adjustWitnessIndexes(removedIndex) {
40050
+ this.inputs.filter(isRequestInputResource).forEach((input) => {
40051
+ if (input.witnessIndex > removedIndex) {
40052
+ input.witnessIndex -= 1;
40053
+ }
40054
+ });
40055
+ }
40046
40056
  };
40047
40057
 
40048
40058
  // src/providers/transaction-request/hash-transaction.ts
@@ -40153,7 +40163,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40153
40163
  *
40154
40164
  * @param createTransactionRequestLike - The initial values for the instance
40155
40165
  */
40156
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
40166
+ constructor({
40167
+ bytecodeWitnessIndex,
40168
+ salt,
40169
+ storageSlots,
40170
+ ...rest
40171
+ } = {}) {
40157
40172
  super(rest);
40158
40173
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
40159
40174
  this.salt = hexlify(salt ?? ZeroBytes32);
@@ -40268,7 +40283,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40268
40283
  *
40269
40284
  * @param scriptTransactionRequestLike - The initial values for the instance.
40270
40285
  */
40271
- constructor({ script, scriptData, gasLimit, ...rest }) {
40286
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
40272
40287
  super(rest);
40273
40288
  this.gasLimit = bn(gasLimit);
40274
40289
  this.script = arrayify(script ?? returnZeroScript.bytes);
@@ -41414,7 +41429,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41414
41429
  gasPerByte: bn(feeParams.gasPerByte),
41415
41430
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41416
41431
  chainId: bn(consensusParameters.chainId),
41417
- baseAssetId: consensusParameters.baseAssetId,
41418
41432
  gasCosts
41419
41433
  },
41420
41434
  gasCosts,
@@ -41657,17 +41671,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41657
41671
  } = this.getChain();
41658
41672
  return chainId.toNumber();
41659
41673
  }
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
41674
  /**
41672
41675
  * Submits a transaction to the chain to be executed.
41673
41676
  *
@@ -42724,9 +42727,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42724
42727
  * @param assetId - The asset ID to check the balance for.
42725
42728
  * @returns A promise that resolves to the balance amount.
42726
42729
  */
42727
- async getBalance(assetId) {
42728
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42729
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42730
+ async getBalance(assetId = BaseAssetId) {
42731
+ const amount = await this.provider.getBalance(this.address, assetId);
42730
42732
  return amount;
42731
42733
  }
42732
42734
  /**
@@ -42764,10 +42766,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42764
42766
  * @returns A promise that resolves when the resources are added to the transaction.
42765
42767
  */
42766
42768
  async fund(request, coinQuantities, fee) {
42767
- const baseAssetId = this.provider.getBaseAssetId();
42768
42769
  const updatedQuantities = addAmountToAsset({
42769
42770
  amount: bn(fee),
42770
- assetId: baseAssetId,
42771
+ assetId: BaseAssetId,
42771
42772
  coinQuantities
42772
42773
  });
42773
42774
  const quantitiesDict = {};
@@ -42791,8 +42792,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42791
42792
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42792
42793
  cachedUtxos.push(input.id);
42793
42794
  }
42794
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42795
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42795
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42796
+ quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42796
42797
  cachedMessages.push(input.nonce);
42797
42798
  }
42798
42799
  }
@@ -42824,13 +42825,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42824
42825
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42825
42826
  * @returns A promise that resolves to the prepared transaction request.
42826
42827
  */
42827
- async createTransfer(destination, amount, assetId, txParams = {}) {
42828
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42828
42829
  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 };
42830
+ const params = { gasPrice: minGasPrice, ...txParams };
42832
42831
  const request = new ScriptTransactionRequest(params);
42833
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42832
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42834
42833
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
42835
42834
  estimateTxDependencies: true,
42836
42835
  resourcesOwner: this
@@ -42856,15 +42855,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42856
42855
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42857
42856
  * @returns A promise that resolves to the transaction response.
42858
42857
  */
42859
- async transfer(destination, amount, assetId, txParams = {}) {
42858
+ async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42860
42859
  if (bn(amount).lte(0)) {
42861
42860
  throw new FuelError(
42862
42861
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42863
42862
  "Transfer amount must be a positive number."
42864
42863
  );
42865
42864
  }
42866
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42867
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42865
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
42868
42866
  return this.sendTransaction(request, { estimateTxDependencies: false });
42869
42867
  }
42870
42868
  /**
@@ -42876,7 +42874,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42876
42874
  * @param txParams - The optional transaction parameters.
42877
42875
  * @returns A promise that resolves to the transaction response.
42878
42876
  */
42879
- async transferToContract(contractId, amount, assetId, txParams = {}) {
42877
+ async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42880
42878
  if (bn(amount).lte(0)) {
42881
42879
  throw new FuelError(
42882
42880
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42885,13 +42883,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42885
42883
  }
42886
42884
  const contractAddress = Address.fromAddressOrString(contractId);
42887
42885
  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 };
42886
+ const params = { gasPrice: minGasPrice, ...txParams };
42891
42887
  const { script, scriptData } = await assembleTransferToContractScript({
42892
42888
  hexlifiedContractId: contractAddress.toB256(),
42893
42889
  amountToTransfer: bn(amount),
42894
- assetId: assetIdToTransfer
42890
+ assetId
42895
42891
  });
42896
42892
  const request = new ScriptTransactionRequest({
42897
42893
  ...params,
@@ -42901,7 +42897,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42901
42897
  request.addContractInputAndOutput(contractAddress);
42902
42898
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42903
42899
  request,
42904
- [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42900
+ [{ amount: bn(amount), assetId: String(assetId) }]
42905
42901
  );
42906
42902
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
42907
42903
  this.validateGas({
@@ -42923,7 +42919,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42923
42919
  */
42924
42920
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42925
42921
  const { minGasPrice } = this.provider.getGasConfig();
42926
- const baseAssetId = this.provider.getBaseAssetId();
42927
42922
  const recipientAddress = Address.fromAddressOrString(recipient);
42928
42923
  const recipientDataArray = arrayify(
42929
42924
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42936,14 +42931,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42936
42931
  ...recipientDataArray,
42937
42932
  ...amountDataArray
42938
42933
  ]);
42939
- const params = {
42940
- script,
42941
- gasPrice: minGasPrice,
42942
- baseAssetId,
42943
- ...txParams
42944
- };
42934
+ const params = { script, gasPrice: minGasPrice, ...txParams };
42945
42935
  const request = new ScriptTransactionRequest(params);
42946
- const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42936
+ const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42947
42937
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42948
42938
  request,
42949
42939
  forwardingQuantities
@@ -47889,10 +47879,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47889
47879
  populateTransactionPredicateData(transactionRequestLike) {
47890
47880
  const request = transactionRequestify(transactionRequestLike);
47891
47881
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
47892
- request.inputs?.forEach((input) => {
47893
- if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
47882
+ const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
47883
+ if (placeholderIndex !== -1) {
47884
+ request.removeWitness(placeholderIndex);
47885
+ }
47886
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
47887
+ if (isRequestInputResourceFromOwner(input, this.address)) {
47894
47888
  input.predicate = this.bytes;
47895
47889
  input.predicateData = this.getPredicateData(policies.length);
47890
+ input.witnessIndex = 0;
47896
47891
  }
47897
47892
  });
47898
47893
  return request;
@@ -47906,9 +47901,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47906
47901
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47907
47902
  * @returns A promise that resolves to the prepared transaction request.
47908
47903
  */
47909
- async createTransfer(destination, amount, assetId, txParams = {}) {
47910
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47911
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47904
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47905
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47912
47906
  return this.populateTransactionPredicateData(request);
47913
47907
  }
47914
47908
  /**
@@ -47931,6 +47925,20 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47931
47925
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47932
47926
  return super.simulateTransaction(transactionRequest);
47933
47927
  }
47928
+ /**
47929
+ * Retrieves resources satisfying the spend query for the account.
47930
+ *
47931
+ * @param quantities - IDs of coins to exclude.
47932
+ * @param excludedIds - IDs of resources to be excluded from the query.
47933
+ * @returns A promise that resolves to an array of Resources.
47934
+ */
47935
+ async getResourcesToSpend(quantities, excludedIds) {
47936
+ const resources = await super.getResourcesToSpend(quantities, excludedIds);
47937
+ return resources.map((resource) => ({
47938
+ ...resource,
47939
+ predicate: hexlify(this.bytes)
47940
+ }));
47941
+ }
47934
47942
  getPredicateData(policiesLength) {
47935
47943
  if (!this.predicateData.length) {
47936
47944
  return new Uint8Array();
@@ -48010,6 +48018,22 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48010
48018
  }
48011
48019
  return mutatedBytes;
48012
48020
  }
48021
+ getIndexFromPlaceholderWitness(request) {
48022
+ const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
48023
+ let index = -1;
48024
+ const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
48025
+ if (hasEmptyPredicateInputs) {
48026
+ index = hasEmptyPredicateInputs.witnessIndex;
48027
+ const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
48028
+ if (!allInputsAreEmpty) {
48029
+ const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
48030
+ if (wasFilledInputAddedFirst) {
48031
+ index = -1;
48032
+ }
48033
+ }
48034
+ }
48035
+ return index;
48036
+ }
48013
48037
  };
48014
48038
 
48015
48039
  // src/connectors/fuel-connector.ts