@fuel-ts/account 0.0.0-pr-1699-20240210143234 → 0.0.0-pr-1699-20240214162234

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 (34) hide show
  1. package/dist/account.d.ts +1 -0
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel.d.ts +9 -4
  4. package/dist/connectors/fuel.d.ts.map +1 -1
  5. package/dist/connectors/index.d.ts +0 -4
  6. package/dist/connectors/index.d.ts.map +1 -1
  7. package/dist/connectors/types/index.d.ts +1 -1
  8. package/dist/connectors/types/index.d.ts.map +1 -1
  9. package/dist/connectors/types/local-storage.d.ts +11 -0
  10. package/dist/connectors/types/local-storage.d.ts.map +1 -0
  11. package/dist/index.global.js +73 -1271
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +74 -302
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +73 -298
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/providers/provider.d.ts.map +1 -1
  18. package/dist/test-utils.global.js +44 -25
  19. package/dist/test-utils.global.js.map +1 -1
  20. package/dist/test-utils.js +43 -24
  21. package/dist/test-utils.js.map +1 -1
  22. package/dist/test-utils.mjs +43 -24
  23. package/dist/test-utils.mjs.map +1 -1
  24. package/package.json +16 -16
  25. package/dist/connectors/default-connector.d.ts +0 -7
  26. package/dist/connectors/default-connector.d.ts.map +0 -1
  27. package/dist/connectors/fuel-wallet-connector.d.ts +0 -54
  28. package/dist/connectors/fuel-wallet-connector.d.ts.map +0 -1
  29. package/dist/connectors/fuel-wallet-development-connector.d.ts +0 -7
  30. package/dist/connectors/fuel-wallet-development-connector.d.ts.map +0 -1
  31. package/dist/connectors/fuelet-wallet-connector.d.ts +0 -8
  32. package/dist/connectors/fuelet-wallet-connector.d.ts.map +0 -1
  33. package/dist/connectors/types/fuel-storage.d.ts +0 -11
  34. package/dist/connectors/types/fuel-storage.d.ts.map +0 -1
@@ -3621,23 +3621,6 @@ var _Provider = class {
3621
3621
  if (estimateTxDependencies) {
3622
3622
  await this.estimateTxDependencies(transactionRequest);
3623
3623
  }
3624
- const { gasUsed, minGasPrice } = await this.getTransactionCost(transactionRequest, [], {
3625
- estimateTxDependencies: false,
3626
- estimatePredicates: false
3627
- });
3628
- if (bn14(minGasPrice).gt(bn14(transactionRequest.gasPrice))) {
3629
- throw new FuelError12(
3630
- ErrorCode11.GAS_PRICE_TOO_LOW,
3631
- `Gas price '${transactionRequest.gasPrice}' is lower than the required: '${minGasPrice}'.`
3632
- );
3633
- }
3634
- const isScriptTransaction = transactionRequest.type === TransactionType8.Script;
3635
- if (isScriptTransaction && bn14(gasUsed).gt(bn14(transactionRequest.gasLimit))) {
3636
- throw new FuelError12(
3637
- ErrorCode11.GAS_LIMIT_TOO_LOW,
3638
- `Gas limit '${transactionRequest.gasLimit}' is lower than the required: '${gasUsed}'.`
3639
- );
3640
- }
3641
3624
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3642
3625
  if (awaitExecution) {
3643
3626
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
@@ -4507,10 +4490,14 @@ var Account = class extends AbstractAccount {
4507
4490
  const request = new ScriptTransactionRequest(params);
4508
4491
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4509
4492
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request);
4510
- const gasPriceToUse = bn16(txParams.gasPrice ?? minGasPrice);
4511
- const gasLimitToUse = bn16(txParams.gasLimit ?? gasUsed);
4512
- request.gasPrice = gasPriceToUse;
4513
- request.gasLimit = gasLimitToUse;
4493
+ request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
4494
+ request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
4495
+ this.validateGas({
4496
+ gasUsed,
4497
+ gasPrice: request.gasPrice,
4498
+ gasLimit: request.gasLimit,
4499
+ minGasPrice
4500
+ });
4514
4501
  await this.fund(request, requiredQuantities, maxFee);
4515
4502
  return request;
4516
4503
  }
@@ -4555,7 +4542,13 @@ var Account = class extends AbstractAccount {
4555
4542
  request,
4556
4543
  [{ amount: bn16(amount), assetId: String(assetId) }]
4557
4544
  );
4558
- request.gasLimit = bn16(params.gasLimit || gasUsed);
4545
+ request.gasLimit = bn16(params.gasLimit ?? gasUsed);
4546
+ this.validateGas({
4547
+ gasUsed,
4548
+ gasPrice: request.gasPrice,
4549
+ gasLimit: request.gasLimit,
4550
+ minGasPrice
4551
+ });
4559
4552
  await this.fund(request, requiredQuantities, maxFee);
4560
4553
  return this.sendTransaction(request);
4561
4554
  }
@@ -4568,6 +4561,7 @@ var Account = class extends AbstractAccount {
4568
4561
  * @returns A promise that resolves to the transaction response.
4569
4562
  */
4570
4563
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4564
+ const { minGasPrice } = this.provider.getGasConfig();
4571
4565
  const recipientAddress = Address3.fromAddressOrString(recipient);
4572
4566
  const recipientDataArray = getBytesCopy15(
4573
4567
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -4580,14 +4574,20 @@ var Account = class extends AbstractAccount {
4580
4574
  ...recipientDataArray,
4581
4575
  ...amountDataArray
4582
4576
  ]);
4583
- const params = { script, ...txParams };
4577
+ const params = { script, gasPrice: minGasPrice, ...txParams };
4584
4578
  const request = new ScriptTransactionRequest(params);
4585
4579
  const forwardingQuantities = [{ amount: bn16(amount), assetId: BaseAssetId3 }];
4586
4580
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4587
4581
  request,
4588
4582
  forwardingQuantities
4589
4583
  );
4590
- request.gasLimit = params.gasLimit ? bn16(params.gasLimit) : gasUsed;
4584
+ request.gasLimit = bn16(params.gasLimit ?? gasUsed);
4585
+ this.validateGas({
4586
+ gasUsed,
4587
+ gasPrice: request.gasPrice,
4588
+ gasLimit: request.gasLimit,
4589
+ minGasPrice
4590
+ });
4591
4591
  await this.fund(request, requiredQuantities, maxFee);
4592
4592
  return this.sendTransaction(request);
4593
4593
  }
@@ -4616,6 +4616,25 @@ var Account = class extends AbstractAccount {
4616
4616
  await this.provider.estimateTxDependencies(transactionRequest);
4617
4617
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4618
4618
  }
4619
+ validateGas({
4620
+ gasUsed,
4621
+ gasPrice,
4622
+ gasLimit,
4623
+ minGasPrice
4624
+ }) {
4625
+ if (minGasPrice.gt(gasPrice)) {
4626
+ throw new FuelError14(
4627
+ ErrorCode13.GAS_PRICE_TOO_LOW,
4628
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4629
+ );
4630
+ }
4631
+ if (gasUsed.gt(gasLimit)) {
4632
+ throw new FuelError14(
4633
+ ErrorCode13.GAS_LIMIT_TOO_LOW,
4634
+ `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
4635
+ );
4636
+ }
4637
+ }
4619
4638
  };
4620
4639
 
4621
4640
  // src/signer/signer.ts