@fuel-ts/account 0.0.0-rc-1764-20240404125616 → 0.0.0-rc-1832-20240404143349

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 (52) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +558 -772
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +511 -764
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +392 -644
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +305 -824
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +0 -3
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +24 -44
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/input.d.ts +2 -2
  31. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/transaction-request.d.ts +25 -8
  34. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/utils.d.ts +0 -3
  36. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  37. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  38. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/utils/gas.d.ts +2 -8
  44. package/dist/providers/utils/gas.d.ts.map +1 -1
  45. package/dist/test-utils.global.js +551 -729
  46. package/dist/test-utils.global.js.map +1 -1
  47. package/dist/test-utils.js +490 -705
  48. package/dist/test-utils.js.map +1 -1
  49. package/dist/test-utils.mjs +379 -594
  50. package/dist/test-utils.mjs.map +1 -1
  51. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  52. package/package.json +17 -17
package/dist/index.mjs CHANGED
@@ -32,9 +32,8 @@ import { Address as Address3 } from "@fuel-ts/address";
32
32
  import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
33
33
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
34
34
  import { AbstractAccount } from "@fuel-ts/interfaces";
35
- import { bn as bn18 } from "@fuel-ts/math";
35
+ import { bn as bn17 } from "@fuel-ts/math";
36
36
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
37
- import { clone as clone4 } from "ramda";
38
37
 
39
38
  // src/providers/coin-quantity.ts
40
39
  import { BaseAssetId } from "@fuel-ts/address/configs";
@@ -43,24 +42,24 @@ import { hexlify } from "@fuel-ts/utils";
43
42
  var coinQuantityfy = (coinQuantityLike) => {
44
43
  let assetId;
45
44
  let amount;
46
- let max;
45
+ let max2;
47
46
  if (Array.isArray(coinQuantityLike)) {
48
47
  amount = coinQuantityLike[0];
49
48
  assetId = coinQuantityLike[1] ?? BaseAssetId;
50
- max = coinQuantityLike[2] ?? void 0;
49
+ max2 = coinQuantityLike[2] ?? void 0;
51
50
  } else {
52
51
  amount = coinQuantityLike.amount;
53
52
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
54
- max = coinQuantityLike.max ?? void 0;
53
+ max2 = coinQuantityLike.max ?? void 0;
55
54
  }
56
55
  const bnAmount = bn(amount);
57
56
  return {
58
57
  assetId: hexlify(assetId),
59
58
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
60
- max: max ? bn(max) : void 0
59
+ max: max2 ? bn(max2) : void 0
61
60
  };
62
61
  };
63
- var addAmountToCoinQuantities = (params) => {
62
+ var addAmountToAsset = (params) => {
64
63
  const { amount, assetId } = params;
65
64
  const coinQuantities = [...params.coinQuantities];
66
65
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -75,9 +74,9 @@ var addAmountToCoinQuantities = (params) => {
75
74
  // src/providers/provider.ts
76
75
  import { Address as Address2 } from "@fuel-ts/address";
77
76
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
78
- import { BN, bn as bn16 } from "@fuel-ts/math";
77
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
79
78
  import {
80
- InputType as InputType7,
79
+ InputType as InputType6,
81
80
  TransactionType as TransactionType8,
82
81
  InputMessageCoder,
83
82
  TransactionCoder as TransactionCoder5
@@ -93,10 +92,14 @@ import { clone as clone3 } from "ramda";
93
92
  import gql from "graphql-tag";
94
93
  var ReceiptFragmentFragmentDoc = gql`
95
94
  fragment receiptFragment on Receipt {
96
- id
95
+ contract {
96
+ id
97
+ }
97
98
  pc
98
99
  is
99
- to
100
+ to {
101
+ id
102
+ }
100
103
  toAddress
101
104
  amount
102
105
  assetId
@@ -134,16 +137,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
134
137
  id
135
138
  }
136
139
  time
137
- receipts {
138
- ...receiptFragment
139
- }
140
140
  programState {
141
141
  returnType
142
142
  data
143
143
  }
144
- receipts {
145
- ...receiptFragment
146
- }
147
144
  }
148
145
  ... on FailureStatus {
149
146
  block {
@@ -151,24 +148,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
151
148
  }
152
149
  time
153
150
  reason
154
- receipts {
155
- ...receiptFragment
156
- }
157
151
  }
158
152
  ... on SqueezedOutStatus {
159
153
  reason
160
154
  }
161
155
  }
162
- ${ReceiptFragmentFragmentDoc}`;
156
+ `;
163
157
  var TransactionFragmentFragmentDoc = gql`
164
158
  fragment transactionFragment on Transaction {
165
159
  id
166
160
  rawPayload
161
+ gasPrice
162
+ receipts {
163
+ ...receiptFragment
164
+ }
167
165
  status {
168
166
  ...transactionStatusFragment
169
167
  }
170
168
  }
171
- ${TransactionStatusFragmentFragmentDoc}`;
169
+ ${ReceiptFragmentFragmentDoc}
170
+ ${TransactionStatusFragmentFragmentDoc}`;
172
171
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
173
172
  fragment inputEstimatePredicatesFragment on Input {
174
173
  ... on InputCoin {
@@ -186,46 +185,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
186
185
  }
187
186
  }
188
187
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
189
- var DryRunFailureStatusFragmentFragmentDoc = gql`
190
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
191
- reason
192
- programState {
193
- returnType
194
- data
195
- }
196
- }
197
- `;
198
- var DryRunSuccessStatusFragmentFragmentDoc = gql`
199
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
200
- programState {
201
- returnType
202
- data
203
- }
204
- }
205
- `;
206
- var DryRunTransactionStatusFragmentFragmentDoc = gql`
207
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
208
- ... on DryRunFailureStatus {
209
- ...dryRunFailureStatusFragment
210
- }
211
- ... on DryRunSuccessStatus {
212
- ...dryRunSuccessStatusFragment
213
- }
214
- }
215
- ${DryRunFailureStatusFragmentFragmentDoc}
216
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
217
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
218
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
219
- id
220
- status {
221
- ...dryRunTransactionStatusFragment
222
- }
223
- receipts {
224
- ...receiptFragment
225
- }
226
- }
227
- ${DryRunTransactionStatusFragmentFragmentDoc}
228
- ${ReceiptFragmentFragmentDoc}`;
229
188
  var CoinFragmentFragmentDoc = gql`
230
189
  fragment coinFragment on Coin {
231
190
  __typename
@@ -233,6 +192,7 @@ var CoinFragmentFragmentDoc = gql`
233
192
  owner
234
193
  amount
235
194
  assetId
195
+ maturity
236
196
  blockCreated
237
197
  txCreatedIdx
238
198
  }
@@ -309,8 +269,8 @@ var BalanceFragmentFragmentDoc = gql`
309
269
  var BlockFragmentFragmentDoc = gql`
310
270
  fragment blockFragment on Block {
311
271
  id
312
- height
313
272
  header {
273
+ height
314
274
  time
315
275
  }
316
276
  transactions {
@@ -380,6 +340,7 @@ var GasCostsFragmentFragmentDoc = gql`
380
340
  cb
381
341
  cfei
382
342
  cfsi
343
+ croo
383
344
  div
384
345
  divi
385
346
  ecr1
@@ -462,9 +423,6 @@ var GasCostsFragmentFragmentDoc = gql`
462
423
  ccp {
463
424
  ...DependentCostFragment
464
425
  }
465
- croo {
466
- ...DependentCostFragment
467
- }
468
426
  csiz {
469
427
  ...DependentCostFragment
470
428
  }
@@ -587,6 +545,14 @@ var NodeInfoFragmentFragmentDoc = gql`
587
545
  maxTx
588
546
  maxDepth
589
547
  nodeVersion
548
+ peers {
549
+ id
550
+ addresses
551
+ clientVersion
552
+ blockHeight
553
+ lastHeartbeatMs
554
+ appScore
555
+ }
590
556
  }
591
557
  `;
592
558
  var GetVersionDocument = gql`
@@ -621,9 +587,13 @@ var GetTransactionWithReceiptsDocument = gql`
621
587
  query getTransactionWithReceipts($transactionId: TransactionId!) {
622
588
  transaction(id: $transactionId) {
623
589
  ...transactionFragment
590
+ receipts {
591
+ ...receiptFragment
592
+ }
624
593
  }
625
594
  }
626
- ${TransactionFragmentFragmentDoc}`;
595
+ ${TransactionFragmentFragmentDoc}
596
+ ${ReceiptFragmentFragmentDoc}`;
627
597
  var GetTransactionsDocument = gql`
628
598
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
629
599
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -751,20 +721,6 @@ var GetBalanceDocument = gql`
751
721
  }
752
722
  }
753
723
  ${BalanceFragmentFragmentDoc}`;
754
- var GetLatestGasPriceDocument = gql`
755
- query getLatestGasPrice {
756
- latestGasPrice {
757
- gasPrice
758
- }
759
- }
760
- `;
761
- var EstimateGasPriceDocument = gql`
762
- query estimateGasPrice($blockHorizon: U32!) {
763
- estimateGasPrice(blockHorizon: $blockHorizon) {
764
- gasPrice
765
- }
766
- }
767
- `;
768
724
  var GetBalancesDocument = gql`
769
725
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
770
726
  balances(
@@ -819,12 +775,12 @@ var GetMessageStatusDocument = gql`
819
775
  }
820
776
  `;
821
777
  var DryRunDocument = gql`
822
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
823
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
824
- ...dryRunTransactionExecutionStatusFragment
778
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
779
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
780
+ ...receiptFragment
825
781
  }
826
782
  }
827
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
783
+ ${ReceiptFragmentFragmentDoc}`;
828
784
  var SubmitDocument = gql`
829
785
  mutation submit($encodedTransaction: HexString!) {
830
786
  submit(tx: $encodedTransaction) {
@@ -907,12 +863,6 @@ function getSdk(requester) {
907
863
  getBalance(variables, options) {
908
864
  return requester(GetBalanceDocument, variables, options);
909
865
  },
910
- getLatestGasPrice(variables, options) {
911
- return requester(GetLatestGasPriceDocument, variables, options);
912
- },
913
- estimateGasPrice(variables, options) {
914
- return requester(EstimateGasPriceDocument, variables, options);
915
- },
916
866
  getBalances(variables, options) {
917
867
  return requester(GetBalancesDocument, variables, options);
918
868
  },
@@ -1096,6 +1046,7 @@ var inputify = (value) => {
1096
1046
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1097
1047
  },
1098
1048
  witnessIndex: value.witnessIndex,
1049
+ maturity: value.maturity ?? 0,
1099
1050
  predicateGasUsed: bn2(value.predicateGasUsed),
1100
1051
  predicateLength: predicate.length,
1101
1052
  predicateDataLength: predicateData.length,
@@ -1215,7 +1166,6 @@ import {
1215
1166
  TransactionType
1216
1167
  } from "@fuel-ts/transactions";
1217
1168
  import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1218
- import { randomBytes } from "ethers";
1219
1169
 
1220
1170
  // src/providers/resource.ts
1221
1171
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1259,8 +1209,8 @@ function assembleReceiptByType(receipt) {
1259
1209
  case "CALL" /* Call */: {
1260
1210
  const callReceipt = {
1261
1211
  type: ReceiptType.Call,
1262
- from: hexOrZero(receipt.id || receipt.contractId),
1263
- to: hexOrZero(receipt?.to),
1212
+ from: hexOrZero(receipt.contract?.id),
1213
+ to: hexOrZero(receipt?.to?.id),
1264
1214
  amount: bn4(receipt.amount),
1265
1215
  assetId: hexOrZero(receipt.assetId),
1266
1216
  gas: bn4(receipt.gas),
@@ -1274,7 +1224,7 @@ function assembleReceiptByType(receipt) {
1274
1224
  case "RETURN" /* Return */: {
1275
1225
  const returnReceipt = {
1276
1226
  type: ReceiptType.Return,
1277
- id: hexOrZero(receipt.id || receipt.contractId),
1227
+ id: hexOrZero(receipt.contract?.id),
1278
1228
  val: bn4(receipt.val),
1279
1229
  pc: bn4(receipt.pc),
1280
1230
  is: bn4(receipt.is)
@@ -1284,7 +1234,7 @@ function assembleReceiptByType(receipt) {
1284
1234
  case "RETURN_DATA" /* ReturnData */: {
1285
1235
  const returnDataReceipt = {
1286
1236
  type: ReceiptType.ReturnData,
1287
- id: hexOrZero(receipt.id || receipt.contractId),
1237
+ id: hexOrZero(receipt.contract?.id),
1288
1238
  ptr: bn4(receipt.ptr),
1289
1239
  len: bn4(receipt.len),
1290
1240
  digest: hexOrZero(receipt.digest),
@@ -1296,7 +1246,7 @@ function assembleReceiptByType(receipt) {
1296
1246
  case "PANIC" /* Panic */: {
1297
1247
  const panicReceipt = {
1298
1248
  type: ReceiptType.Panic,
1299
- id: hexOrZero(receipt.id),
1249
+ id: hexOrZero(receipt.contract?.id),
1300
1250
  reason: bn4(receipt.reason),
1301
1251
  pc: bn4(receipt.pc),
1302
1252
  is: bn4(receipt.is),
@@ -1307,7 +1257,7 @@ function assembleReceiptByType(receipt) {
1307
1257
  case "REVERT" /* Revert */: {
1308
1258
  const revertReceipt = {
1309
1259
  type: ReceiptType.Revert,
1310
- id: hexOrZero(receipt.id || receipt.contractId),
1260
+ id: hexOrZero(receipt.contract?.id),
1311
1261
  val: bn4(receipt.ra),
1312
1262
  pc: bn4(receipt.pc),
1313
1263
  is: bn4(receipt.is)
@@ -1317,7 +1267,7 @@ function assembleReceiptByType(receipt) {
1317
1267
  case "LOG" /* Log */: {
1318
1268
  const logReceipt = {
1319
1269
  type: ReceiptType.Log,
1320
- id: hexOrZero(receipt.id || receipt.contractId),
1270
+ id: hexOrZero(receipt.contract?.id),
1321
1271
  val0: bn4(receipt.ra),
1322
1272
  val1: bn4(receipt.rb),
1323
1273
  val2: bn4(receipt.rc),
@@ -1330,7 +1280,7 @@ function assembleReceiptByType(receipt) {
1330
1280
  case "LOG_DATA" /* LogData */: {
1331
1281
  const logDataReceipt = {
1332
1282
  type: ReceiptType.LogData,
1333
- id: hexOrZero(receipt.id || receipt.contractId),
1283
+ id: hexOrZero(receipt.contract?.id),
1334
1284
  val0: bn4(receipt.ra),
1335
1285
  val1: bn4(receipt.rb),
1336
1286
  ptr: bn4(receipt.ptr),
@@ -1344,8 +1294,8 @@ function assembleReceiptByType(receipt) {
1344
1294
  case "TRANSFER" /* Transfer */: {
1345
1295
  const transferReceipt = {
1346
1296
  type: ReceiptType.Transfer,
1347
- from: hexOrZero(receipt.id || receipt.contractId),
1348
- to: hexOrZero(receipt.toAddress || receipt?.to),
1297
+ from: hexOrZero(receipt.contract?.id),
1298
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1349
1299
  amount: bn4(receipt.amount),
1350
1300
  assetId: hexOrZero(receipt.assetId),
1351
1301
  pc: bn4(receipt.pc),
@@ -1356,8 +1306,8 @@ function assembleReceiptByType(receipt) {
1356
1306
  case "TRANSFER_OUT" /* TransferOut */: {
1357
1307
  const transferOutReceipt = {
1358
1308
  type: ReceiptType.TransferOut,
1359
- from: hexOrZero(receipt.id || receipt.contractId),
1360
- to: hexOrZero(receipt.toAddress || receipt.to),
1309
+ from: hexOrZero(receipt.contract?.id),
1310
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1361
1311
  amount: bn4(receipt.amount),
1362
1312
  assetId: hexOrZero(receipt.assetId),
1363
1313
  pc: bn4(receipt.pc),
@@ -1400,7 +1350,7 @@ function assembleReceiptByType(receipt) {
1400
1350
  return receiptMessageOut;
1401
1351
  }
1402
1352
  case "MINT" /* Mint */: {
1403
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1353
+ const contractId = hexOrZero(receipt.contract?.id);
1404
1354
  const subId = hexOrZero(receipt.subId);
1405
1355
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1406
1356
  const mintReceipt = {
@@ -1415,7 +1365,7 @@ function assembleReceiptByType(receipt) {
1415
1365
  return mintReceipt;
1416
1366
  }
1417
1367
  case "BURN" /* Burn */: {
1418
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1368
+ const contractId = hexOrZero(receipt.contract?.id);
1419
1369
  const subId = hexOrZero(receipt.subId);
1420
1370
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1421
1371
  const burnReceipt = {
@@ -1500,6 +1450,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1500
1450
  import { bn as bn5 } from "@fuel-ts/math";
1501
1451
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1502
1452
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1453
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1503
1454
  var getGasUsedFromReceipts = (receipts) => {
1504
1455
  const scriptResult = receipts.filter(
1505
1456
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1520,28 +1471,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1520
1471
  }
1521
1472
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1522
1473
  const witnessCache = [];
1523
- const chargeableInputs = inputs.filter((input) => {
1524
- const isCoinOrMessage = "owner" in input || "sender" in input;
1525
- if (isCoinOrMessage) {
1526
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1527
- return true;
1528
- }
1529
- if (!witnessCache.includes(input.witnessIndex)) {
1530
- witnessCache.push(input.witnessIndex);
1531
- return true;
1532
- }
1533
- }
1534
- return false;
1535
- });
1536
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1537
- const totalGas = chargeableInputs.reduce((total, input) => {
1474
+ const totalGas = inputs.reduce((total, input) => {
1538
1475
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1539
1476
  return total.add(
1540
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1477
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1541
1478
  );
1542
1479
  }
1543
- return total.add(gasCosts.ecr1);
1544
- }, bn5(0));
1480
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1481
+ witnessCache.push(input.witnessIndex);
1482
+ return total.add(gasCosts.ecr1);
1483
+ }
1484
+ return total;
1485
+ }, bn5());
1545
1486
  return totalGas;
1546
1487
  }
1547
1488
  function getMinGas(params) {
@@ -1553,20 +1494,12 @@ function getMinGas(params) {
1553
1494
  return minGas;
1554
1495
  }
1555
1496
  function getMaxGas(params) {
1556
- const {
1557
- gasPerByte,
1558
- witnessesLength,
1559
- witnessLimit,
1560
- minGas,
1561
- gasLimit = bn5(0),
1562
- maxGasPerTx
1563
- } = params;
1497
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1564
1498
  let remainingAllowedWitnessGas = bn5(0);
1565
1499
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1566
1500
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1567
1501
  }
1568
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1569
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1502
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1570
1503
  }
1571
1504
  function calculateMetadataGasForTxCreate({
1572
1505
  gasCosts,
@@ -1588,10 +1521,6 @@ function calculateMetadataGasForTxScript({
1588
1521
  }) {
1589
1522
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1590
1523
  }
1591
- var calculateGasFee = (params) => {
1592
- const { gas, gasPrice, priceFactor, tip } = params;
1593
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1594
- };
1595
1524
 
1596
1525
  // src/providers/utils/json.ts
1597
1526
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1748,7 +1677,7 @@ var witnessify = (value) => {
1748
1677
  // src/providers/transaction-request/transaction-request.ts
1749
1678
  var BaseTransactionRequest = class {
1750
1679
  /** Gas price for transaction */
1751
- tip;
1680
+ gasPrice;
1752
1681
  /** Block until which tx cannot be included */
1753
1682
  maturity;
1754
1683
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1767,7 +1696,7 @@ var BaseTransactionRequest = class {
1767
1696
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1768
1697
  */
1769
1698
  constructor({
1770
- tip,
1699
+ gasPrice,
1771
1700
  maturity,
1772
1701
  maxFee,
1773
1702
  witnessLimit,
@@ -1775,7 +1704,7 @@ var BaseTransactionRequest = class {
1775
1704
  outputs,
1776
1705
  witnesses
1777
1706
  } = {}) {
1778
- this.tip = bn7(tip);
1707
+ this.gasPrice = bn7(gasPrice);
1779
1708
  this.maturity = maturity ?? 0;
1780
1709
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1781
1710
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
@@ -1786,9 +1715,9 @@ var BaseTransactionRequest = class {
1786
1715
  static getPolicyMeta(req) {
1787
1716
  let policyTypes = 0;
1788
1717
  const policies = [];
1789
- if (req.tip) {
1790
- policyTypes += PolicyType.Tip;
1791
- policies.push({ data: req.tip, type: PolicyType.Tip });
1718
+ if (req.gasPrice) {
1719
+ policyTypes += PolicyType.GasPrice;
1720
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1792
1721
  }
1793
1722
  if (req.witnessLimit) {
1794
1723
  policyTypes += PolicyType.WitnessLimit;
@@ -1975,10 +1904,10 @@ var BaseTransactionRequest = class {
1975
1904
  * @param predicate - Predicate bytes.
1976
1905
  * @param predicateData - Predicate data bytes.
1977
1906
  */
1978
- addCoinInput(coin) {
1907
+ addCoinInput(coin, predicate) {
1979
1908
  const { assetId, owner, amount } = coin;
1980
1909
  let witnessIndex;
1981
- if (coin.predicate) {
1910
+ if (predicate) {
1982
1911
  witnessIndex = 0;
1983
1912
  } else {
1984
1913
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1993,7 +1922,9 @@ var BaseTransactionRequest = class {
1993
1922
  amount,
1994
1923
  assetId,
1995
1924
  txPointer: "0x00000000000000000000000000000000",
1996
- witnessIndex
1925
+ witnessIndex,
1926
+ predicate: predicate?.bytes,
1927
+ predicateData: predicate?.predicateDataBytes
1997
1928
  };
1998
1929
  this.pushInput(input);
1999
1930
  this.addChangeOutput(owner, assetId);
@@ -2006,11 +1937,11 @@ var BaseTransactionRequest = class {
2006
1937
  * @param predicate - Predicate bytes.
2007
1938
  * @param predicateData - Predicate data bytes.
2008
1939
  */
2009
- addMessageInput(message) {
1940
+ addMessageInput(message, predicate) {
2010
1941
  const { recipient, sender, amount } = message;
2011
1942
  const assetId = BaseAssetId2;
2012
1943
  let witnessIndex;
2013
- if (message.predicate) {
1944
+ if (predicate) {
2014
1945
  witnessIndex = 0;
2015
1946
  } else {
2016
1947
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2024,7 +1955,9 @@ var BaseTransactionRequest = class {
2024
1955
  sender: sender.toB256(),
2025
1956
  recipient: recipient.toB256(),
2026
1957
  amount,
2027
- witnessIndex
1958
+ witnessIndex,
1959
+ predicate: predicate?.bytes,
1960
+ predicateData: predicate?.predicateDataBytes
2028
1961
  };
2029
1962
  this.pushInput(input);
2030
1963
  this.addChangeOutput(recipient, assetId);
@@ -2055,6 +1988,32 @@ var BaseTransactionRequest = class {
2055
1988
  resources.forEach((resource) => this.addResource(resource));
2056
1989
  return this;
2057
1990
  }
1991
+ /**
1992
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1993
+ * outputs from the related assetIds.
1994
+ *
1995
+ * @param resources - The resources to add.
1996
+ * @returns This transaction.
1997
+ */
1998
+ addPredicateResource(resource, predicate) {
1999
+ if (isCoin(resource)) {
2000
+ this.addCoinInput(resource, predicate);
2001
+ } else {
2002
+ this.addMessageInput(resource, predicate);
2003
+ }
2004
+ return this;
2005
+ }
2006
+ /**
2007
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2008
+ * from the related assetIds.
2009
+ *
2010
+ * @param resources - The resources to add.
2011
+ * @returns This transaction.
2012
+ */
2013
+ addPredicateResources(resources, predicate) {
2014
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2015
+ return this;
2016
+ }
2058
2017
  /**
2059
2018
  * Adds a coin output to the transaction.
2060
2019
  *
@@ -2134,7 +2093,7 @@ var BaseTransactionRequest = class {
2134
2093
  }
2135
2094
  calculateMaxGas(chainInfo, minGas) {
2136
2095
  const { consensusParameters } = chainInfo;
2137
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2096
+ const { gasPerByte } = consensusParameters;
2138
2097
  const witnessesLength = this.toTransaction().witnesses.reduce(
2139
2098
  (acc, wit) => acc + wit.dataLength,
2140
2099
  0
@@ -2143,8 +2102,7 @@ var BaseTransactionRequest = class {
2143
2102
  gasPerByte,
2144
2103
  minGas,
2145
2104
  witnessesLength,
2146
- witnessLimit: this.witnessLimit,
2147
- maxGasPerTx
2105
+ witnessLimit: this.witnessLimit
2148
2106
  });
2149
2107
  }
2150
2108
  /**
@@ -2154,6 +2112,12 @@ var BaseTransactionRequest = class {
2154
2112
  * @param quantities - CoinQuantity Array.
2155
2113
  */
2156
2114
  fundWithFakeUtxos(quantities, resourcesOwner) {
2115
+ let idCounter = 0;
2116
+ const generateId = () => {
2117
+ const counterString = String(idCounter++);
2118
+ const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
2119
+ return id;
2120
+ };
2157
2121
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2158
2122
  if ("assetId" in input) {
2159
2123
  return input.assetId === assetId;
@@ -2162,20 +2126,17 @@ var BaseTransactionRequest = class {
2162
2126
  });
2163
2127
  const updateAssetInput = (assetId, quantity) => {
2164
2128
  const assetInput = findAssetInput(assetId);
2165
- let usedQuantity = quantity;
2166
- if (assetId === BaseAssetId2) {
2167
- usedQuantity = bn7("1000000000000000000");
2168
- }
2169
2129
  if (assetInput && "assetId" in assetInput) {
2170
- assetInput.id = hexlify7(randomBytes(33));
2171
- assetInput.amount = usedQuantity;
2130
+ assetInput.id = generateId();
2131
+ assetInput.amount = quantity;
2172
2132
  } else {
2173
2133
  this.addResources([
2174
2134
  {
2175
- id: hexlify7(randomBytes(33)),
2176
- amount: usedQuantity,
2135
+ id: generateId(),
2136
+ amount: quantity,
2177
2137
  assetId,
2178
2138
  owner: resourcesOwner || Address.fromRandom(),
2139
+ maturity: 0,
2179
2140
  blockCreated: bn7(1),
2180
2141
  txCreatedIdx: bn7(1)
2181
2142
  }
@@ -2207,7 +2168,7 @@ var BaseTransactionRequest = class {
2207
2168
  toJSON() {
2208
2169
  return normalizeJSON(this);
2209
2170
  }
2210
- updatePredicateGasUsed(inputs) {
2171
+ updatePredicateInputs(inputs) {
2211
2172
  this.inputs.forEach((i) => {
2212
2173
  let correspondingInput;
2213
2174
  switch (i.type) {
@@ -2229,15 +2190,6 @@ var BaseTransactionRequest = class {
2229
2190
  }
2230
2191
  });
2231
2192
  }
2232
- shiftPredicateData() {
2233
- this.inputs.forEach((input) => {
2234
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2235
- input.predicateData = input.paddPredicateData(
2236
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2237
- );
2238
- }
2239
- });
2240
- }
2241
2193
  };
2242
2194
 
2243
2195
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2574,7 +2526,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2574
2526
  }
2575
2527
  calculateMaxGas(chainInfo, minGas) {
2576
2528
  const { consensusParameters } = chainInfo;
2577
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2529
+ const { gasPerByte } = consensusParameters;
2578
2530
  const witnessesLength = this.toTransaction().witnesses.reduce(
2579
2531
  (acc, wit) => acc + wit.dataLength,
2580
2532
  0
@@ -2584,8 +2536,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2584
2536
  minGas,
2585
2537
  witnessesLength,
2586
2538
  witnessLimit: this.witnessLimit,
2587
- gasLimit: this.gasLimit,
2588
- maxGasPerTx
2539
+ gasLimit: this.gasLimit
2589
2540
  });
2590
2541
  }
2591
2542
  /**
@@ -2642,7 +2593,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2642
2593
 
2643
2594
  // src/providers/transaction-request/utils.ts
2644
2595
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2645
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2596
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2646
2597
  var transactionRequestify = (obj) => {
2647
2598
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2648
2599
  return obj;
@@ -2660,31 +2611,14 @@ var transactionRequestify = (obj) => {
2660
2611
  }
2661
2612
  }
2662
2613
  };
2663
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2664
- (acc, input) => {
2665
- if (input.type === InputType5.Coin && input.owner === owner) {
2666
- acc.utxos.push(input.id);
2667
- }
2668
- if (input.type === InputType5.Message && input.recipient === owner) {
2669
- acc.messages.push(input.nonce);
2670
- }
2671
- return acc;
2672
- },
2673
- {
2674
- utxos: [],
2675
- messages: []
2676
- }
2677
- );
2678
2614
 
2679
2615
  // src/providers/transaction-response/transaction-response.ts
2680
2616
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2681
- import { bn as bn15 } from "@fuel-ts/math";
2617
+ import { bn as bn14 } from "@fuel-ts/math";
2682
2618
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2683
2619
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2684
2620
 
2685
2621
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2686
- import { bn as bn14 } from "@fuel-ts/math";
2687
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2688
2622
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2689
2623
 
2690
2624
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2693,10 +2627,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2693
2627
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2694
2628
  var calculateTransactionFee = (params) => {
2695
2629
  const {
2696
- gasPrice,
2630
+ gasUsed,
2697
2631
  rawPayload,
2698
- tip,
2699
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2632
+ consensusParameters: { gasCosts, feeParams }
2700
2633
  } = params;
2701
2634
  const gasPerByte = bn11(feeParams.gasPerByte);
2702
2635
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2706,7 +2639,8 @@ var calculateTransactionFee = (params) => {
2706
2639
  return {
2707
2640
  fee: bn11(0),
2708
2641
  minFee: bn11(0),
2709
- maxFee: bn11(0)
2642
+ maxFee: bn11(0),
2643
+ feeFromGasUsed: bn11(0)
2710
2644
  };
2711
2645
  }
2712
2646
  const { type, witnesses, inputs, policies } = transaction;
@@ -2738,6 +2672,7 @@ var calculateTransactionFee = (params) => {
2738
2672
  metadataGas,
2739
2673
  txBytesSize: transactionBytes.length
2740
2674
  });
2675
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2741
2676
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2742
2677
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2743
2678
  const maxGas = getMaxGas({
@@ -2745,25 +2680,17 @@ var calculateTransactionFee = (params) => {
2745
2680
  minGas,
2746
2681
  witnessesLength,
2747
2682
  gasLimit,
2748
- witnessLimit,
2749
- maxGasPerTx
2750
- });
2751
- const minFee = calculateGasFee({
2752
- gasPrice,
2753
- gas: minGas,
2754
- priceFactor: gasPriceFactor,
2755
- tip
2756
- });
2757
- const maxFee = calculateGasFee({
2758
- gasPrice,
2759
- gas: maxGas,
2760
- priceFactor: gasPriceFactor,
2761
- tip
2683
+ witnessLimit
2762
2684
  });
2685
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2686
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2687
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2688
+ const fee = minFee.add(feeFromGasUsed);
2763
2689
  return {
2690
+ fee,
2764
2691
  minFee,
2765
2692
  maxFee,
2766
- fee: maxFee
2693
+ feeFromGasUsed
2767
2694
  };
2768
2695
  };
2769
2696
 
@@ -2819,7 +2746,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2819
2746
 
2820
2747
  // src/providers/transaction-summary/input.ts
2821
2748
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2822
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2749
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2823
2750
  function getInputsByTypes(inputs, types) {
2824
2751
  return inputs.filter((i) => types.includes(i.type));
2825
2752
  }
@@ -2827,16 +2754,16 @@ function getInputsByType(inputs, type) {
2827
2754
  return inputs.filter((i) => i.type === type);
2828
2755
  }
2829
2756
  function getInputsCoin(inputs) {
2830
- return getInputsByType(inputs, InputType6.Coin);
2757
+ return getInputsByType(inputs, InputType5.Coin);
2831
2758
  }
2832
2759
  function getInputsMessage(inputs) {
2833
- return getInputsByType(inputs, InputType6.Message);
2760
+ return getInputsByType(inputs, InputType5.Message);
2834
2761
  }
2835
2762
  function getInputsCoinAndMessage(inputs) {
2836
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2763
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2837
2764
  }
2838
2765
  function getInputsContract(inputs) {
2839
- return getInputsByType(inputs, InputType6.Contract);
2766
+ return getInputsByType(inputs, InputType5.Contract);
2840
2767
  }
2841
2768
  function getInputFromAssetId(inputs, assetId) {
2842
2769
  const coinInputs = getInputsCoin(inputs);
@@ -2855,7 +2782,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2855
2782
  if (!contractInput) {
2856
2783
  return void 0;
2857
2784
  }
2858
- if (contractInput.type !== InputType6.Contract) {
2785
+ if (contractInput.type !== InputType5.Contract) {
2859
2786
  throw new FuelError9(
2860
2787
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2861
2788
  `Contract input should be of type 'contract'.`
@@ -2864,10 +2791,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2864
2791
  return contractInput;
2865
2792
  }
2866
2793
  function getInputAccountAddress(input) {
2867
- if (input.type === InputType6.Coin) {
2794
+ if (input.type === InputType5.Coin) {
2868
2795
  return input.owner.toString();
2869
2796
  }
2870
- if (input.type === InputType6.Message) {
2797
+ if (input.type === InputType5.Message) {
2871
2798
  return input.recipient.toString();
2872
2799
  }
2873
2800
  return "";
@@ -3377,9 +3304,7 @@ function assembleTransactionSummary(params) {
3377
3304
  gqlTransactionStatus,
3378
3305
  abiMap = {},
3379
3306
  maxInputs,
3380
- gasCosts,
3381
- maxGasPerTx,
3382
- gasPrice
3307
+ gasCosts
3383
3308
  } = params;
3384
3309
  const gasUsed = getGasUsedFromReceipts(receipts);
3385
3310
  const rawPayload = hexlify11(transactionBytes);
@@ -3393,14 +3318,11 @@ function assembleTransactionSummary(params) {
3393
3318
  maxInputs
3394
3319
  });
3395
3320
  const typeName = getTransactionTypeName(transaction.type);
3396
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3397
3321
  const { fee } = calculateTransactionFee({
3398
- gasPrice,
3322
+ gasUsed,
3399
3323
  rawPayload,
3400
- tip,
3401
3324
  consensusParameters: {
3402
3325
  gasCosts,
3403
- maxGasPerTx,
3404
3326
  feeParams: {
3405
3327
  gasPerByte,
3406
3328
  gasPriceFactor
@@ -3460,7 +3382,7 @@ var TransactionResponse = class {
3460
3382
  /** Current provider */
3461
3383
  provider;
3462
3384
  /** Gas used on the transaction */
3463
- gasUsed = bn15(0);
3385
+ gasUsed = bn14(0);
3464
3386
  /** The graphql Transaction with receipts object. */
3465
3387
  gqlTransaction;
3466
3388
  abis;
@@ -3538,13 +3460,8 @@ var TransactionResponse = class {
3538
3460
  const decodedTransaction = this.decodeTransaction(
3539
3461
  transaction
3540
3462
  );
3541
- let txReceipts = [];
3542
- if (transaction?.status && "receipts" in transaction.status) {
3543
- txReceipts = transaction.status.receipts;
3544
- }
3545
- const receipts = txReceipts.map(processGqlReceipt) || [];
3546
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3547
- const gasPrice = await this.provider.getLatestGasPrice();
3463
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3464
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3548
3465
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3549
3466
  const transactionSummary = assembleTransactionSummary({
3550
3467
  id: this.id,
@@ -3556,9 +3473,7 @@ var TransactionResponse = class {
3556
3473
  gasPriceFactor,
3557
3474
  abiMap: contractsAbiMap,
3558
3475
  maxInputs,
3559
- gasCosts,
3560
- maxGasPerTx,
3561
- gasPrice
3476
+ gasCosts
3562
3477
  });
3563
3478
  return transactionSummary;
3564
3479
  }
@@ -3685,29 +3600,29 @@ var processGqlChain = (chain) => {
3685
3600
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3686
3601
  return {
3687
3602
  name,
3688
- baseChainHeight: bn16(daHeight),
3603
+ baseChainHeight: bn15(daHeight),
3689
3604
  consensusParameters: {
3690
- contractMaxSize: bn16(contractParams.contractMaxSize),
3691
- maxInputs: bn16(txParams.maxInputs),
3692
- maxOutputs: bn16(txParams.maxOutputs),
3693
- maxWitnesses: bn16(txParams.maxWitnesses),
3694
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3695
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3696
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3697
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3698
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3699
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3700
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3701
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3702
- gasPerByte: bn16(feeParams.gasPerByte),
3703
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3704
- chainId: bn16(consensusParameters.chainId),
3605
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3606
+ maxInputs: bn15(txParams.maxInputs),
3607
+ maxOutputs: bn15(txParams.maxOutputs),
3608
+ maxWitnesses: bn15(txParams.maxWitnesses),
3609
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3610
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3611
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3612
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3613
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3614
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3615
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3616
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3617
+ gasPerByte: bn15(feeParams.gasPerByte),
3618
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3619
+ chainId: bn15(consensusParameters.chainId),
3705
3620
  gasCosts
3706
3621
  },
3707
3622
  gasCosts,
3708
3623
  latestBlock: {
3709
3624
  id: latestBlock.id,
3710
- height: bn16(latestBlock.height),
3625
+ height: bn15(latestBlock.header.height),
3711
3626
  time: latestBlock.header.time,
3712
3627
  transactions: latestBlock.transactions.map((i) => ({
3713
3628
  id: i.id
@@ -3902,7 +3817,7 @@ var _Provider = class {
3902
3817
  */
3903
3818
  async getBlockNumber() {
3904
3819
  const { chain } = await this.operations.getChain();
3905
- return bn16(chain.latestBlock.height, 10);
3820
+ return bn15(chain.latestBlock.header.height, 10);
3906
3821
  }
3907
3822
  /**
3908
3823
  * Returns the chain information.
@@ -3912,12 +3827,13 @@ var _Provider = class {
3912
3827
  async fetchNode() {
3913
3828
  const { nodeInfo } = await this.operations.getNodeInfo();
3914
3829
  const processedNodeInfo = {
3915
- maxDepth: bn16(nodeInfo.maxDepth),
3916
- maxTx: bn16(nodeInfo.maxTx),
3917
- minGasPrice: bn16(nodeInfo.minGasPrice),
3830
+ maxDepth: bn15(nodeInfo.maxDepth),
3831
+ maxTx: bn15(nodeInfo.maxTx),
3832
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3918
3833
  nodeVersion: nodeInfo.nodeVersion,
3919
3834
  utxoValidation: nodeInfo.utxoValidation,
3920
- vmBacktrace: nodeInfo.vmBacktrace
3835
+ vmBacktrace: nodeInfo.vmBacktrace,
3836
+ peers: nodeInfo.peers
3921
3837
  };
3922
3838
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3923
3839
  return processedNodeInfo;
@@ -4003,13 +3919,14 @@ var _Provider = class {
4003
3919
  return this.estimateTxDependencies(transactionRequest);
4004
3920
  }
4005
3921
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4006
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4007
- encodedTransactions: encodedTransaction,
3922
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3923
+ encodedTransaction,
4008
3924
  utxoValidation: utxoValidation || false
4009
3925
  });
4010
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4011
- const receipts = rawReceipts.map(processGqlReceipt);
4012
- return { receipts, dryrunStatus: status };
3926
+ const receipts = gqlReceipts.map(processGqlReceipt);
3927
+ return {
3928
+ receipts
3929
+ };
4013
3930
  }
4014
3931
  /**
4015
3932
  * Verifies whether enough gas is available to complete transaction.
@@ -4035,7 +3952,7 @@ var _Provider = class {
4035
3952
  } = response;
4036
3953
  if (inputs) {
4037
3954
  inputs.forEach((input, index) => {
4038
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3955
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
4039
3956
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4040
3957
  }
4041
3958
  });
@@ -4048,6 +3965,9 @@ var _Provider = class {
4048
3965
  * If there are missing variable outputs,
4049
3966
  * `addVariableOutputs` is called on the transaction.
4050
3967
  *
3968
+ * @privateRemarks
3969
+ * TODO: Investigate support for missing contract IDs
3970
+ * TODO: Add support for missing output messages
4051
3971
  *
4052
3972
  * @param transactionRequest - The transaction request object.
4053
3973
  * @returns A promise.
@@ -4060,19 +3980,16 @@ var _Provider = class {
4060
3980
  missingContractIds: []
4061
3981
  };
4062
3982
  }
3983
+ await this.estimatePredicates(transactionRequest);
4063
3984
  let receipts = [];
4064
3985
  const missingContractIds = [];
4065
3986
  let outputVariables = 0;
4066
- let dryrunStatus;
4067
3987
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4068
- const {
4069
- dryRun: [{ receipts: rawReceipts, status }]
4070
- } = await this.operations.dryRun({
4071
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3988
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3989
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
4072
3990
  utxoValidation: false
4073
3991
  });
4074
- receipts = rawReceipts.map(processGqlReceipt);
4075
- dryrunStatus = status;
3992
+ receipts = gqlReceipts.map(processGqlReceipt);
4076
3993
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4077
3994
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4078
3995
  if (hasMissingOutputs) {
@@ -4082,11 +3999,6 @@ var _Provider = class {
4082
3999
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
4083
4000
  missingContractIds.push(contractId);
4084
4001
  });
4085
- const { maxFee } = await this.estimateTxGasAndFee({
4086
- transactionRequest,
4087
- optimizeGas: false
4088
- });
4089
- transactionRequest.maxFee = maxFee;
4090
4002
  } else {
4091
4003
  break;
4092
4004
  }
@@ -4094,133 +4006,7 @@ var _Provider = class {
4094
4006
  return {
4095
4007
  receipts,
4096
4008
  outputVariables,
4097
- missingContractIds,
4098
- dryrunStatus
4099
- };
4100
- }
4101
- /**
4102
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4103
- *
4104
- * Transactions are dry run in batches. After each dry run, transactions requiring
4105
- * further modifications are identified. The method iteratively updates these transactions
4106
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4107
- *
4108
- * @param transactionRequests - Array of transaction request objects.
4109
- * @returns A promise that resolves to an array of results for each transaction.
4110
- */
4111
- async estimateMultipleTxDependencies(transactionRequests) {
4112
- const results = transactionRequests.map(() => ({
4113
- receipts: [],
4114
- outputVariables: 0,
4115
- missingContractIds: [],
4116
- dryrunStatus: void 0
4117
- }));
4118
- const allRequests = clone3(transactionRequests);
4119
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4120
- allRequests.forEach((req, index) => {
4121
- if (req.type === TransactionType8.Script) {
4122
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4123
- }
4124
- });
4125
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4126
- let attempt = 0;
4127
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4128
- const encodedTransactions = transactionsToProcess.map(
4129
- (index) => serializedTransactionsMap.get(index)
4130
- );
4131
- const dryRunResults = await this.operations.dryRun({
4132
- encodedTransactions,
4133
- utxoValidation: false
4134
- });
4135
- const nextRoundTransactions = [];
4136
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4137
- const currentResultIndex = transactionsToProcess[i];
4138
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4139
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4140
- results[currentResultIndex].dryrunStatus = status;
4141
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4142
- results[currentResultIndex].receipts
4143
- );
4144
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4145
- const requestToProcess = allRequests[currentResultIndex];
4146
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4147
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4148
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4149
- missingOutputContractIds.forEach(({ contractId }) => {
4150
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4151
- results[currentResultIndex].missingContractIds.push(contractId);
4152
- });
4153
- const { maxFee } = await this.estimateTxGasAndFee({
4154
- transactionRequest: requestToProcess,
4155
- optimizeGas: false
4156
- });
4157
- requestToProcess.maxFee = maxFee;
4158
- serializedTransactionsMap.set(
4159
- currentResultIndex,
4160
- hexlify12(requestToProcess.toTransactionBytes())
4161
- );
4162
- nextRoundTransactions.push(currentResultIndex);
4163
- allRequests[currentResultIndex] = requestToProcess;
4164
- }
4165
- }
4166
- transactionsToProcess = nextRoundTransactions;
4167
- attempt += 1;
4168
- }
4169
- return results;
4170
- }
4171
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4172
- if (estimateTxDependencies) {
4173
- return this.estimateMultipleTxDependencies(transactionRequests);
4174
- }
4175
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4176
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4177
- encodedTransactions,
4178
- utxoValidation: utxoValidation || false
4179
- });
4180
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4181
- const receipts = rawReceipts.map(processGqlReceipt);
4182
- return { receipts, dryrunStatus: status };
4183
- });
4184
- return results;
4185
- }
4186
- async estimateTxGasAndFee(params) {
4187
- const { transactionRequest, totalGasUsedByPredicates = bn16(0), optimizeGas = true } = params;
4188
- let { gasPrice } = params;
4189
- const chainInfo = this.getChain();
4190
- const { gasPriceFactor } = this.getGasConfig();
4191
- const minGas = transactionRequest.calculateMinGas(chainInfo);
4192
- if (!gasPrice) {
4193
- gasPrice = await this.estimateGasPrice(10);
4194
- }
4195
- const shouldSetGaslimit = transactionRequest.type === TransactionType8.Script && !optimizeGas;
4196
- const minFee = calculateGasFee({
4197
- gasPrice: bn16(gasPrice),
4198
- gas: minGas,
4199
- priceFactor: gasPriceFactor,
4200
- tip: transactionRequest.tip
4201
- }).add(1);
4202
- if (shouldSetGaslimit) {
4203
- transactionRequest.gasLimit = chainInfo.consensusParameters.maxGasPerTx.sub(
4204
- minGas.add(totalGasUsedByPredicates)
4205
- );
4206
- }
4207
- let maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4208
- const maxFee = calculateGasFee({
4209
- gasPrice: bn16(gasPrice),
4210
- gas: maxGas,
4211
- priceFactor: gasPriceFactor,
4212
- tip: transactionRequest.tip
4213
- }).add(1);
4214
- if (shouldSetGaslimit) {
4215
- maxGas = chainInfo.consensusParameters.maxGasPerTx.sub(maxFee);
4216
- transactionRequest.gasLimit = maxGas;
4217
- }
4218
- return {
4219
- minGas,
4220
- minFee,
4221
- maxGas,
4222
- maxFee,
4223
- gasPrice
4009
+ missingContractIds
4224
4010
  };
4225
4011
  }
4226
4012
  /**
@@ -4238,17 +4024,15 @@ var _Provider = class {
4238
4024
  if (estimateTxDependencies) {
4239
4025
  return this.estimateTxDependencies(transactionRequest);
4240
4026
  }
4241
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4242
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4243
- encodedTransactions,
4027
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4028
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4029
+ encodedTransaction,
4244
4030
  utxoValidation: true
4245
4031
  });
4246
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4247
- const { id, receipts, status } = dryRunStatus;
4248
- const processedReceipts = receipts.map(processGqlReceipt);
4249
- return { id, receipts: processedReceipts, status };
4250
- });
4251
- return { receipts: callResult[0].receipts };
4032
+ const receipts = gqlReceipts.map(processGqlReceipt);
4033
+ return {
4034
+ receipts
4035
+ };
4252
4036
  }
4253
4037
  /**
4254
4038
  * Returns a transaction cost to enable user
@@ -4265,80 +4049,80 @@ var _Provider = class {
4265
4049
  * @param tolerance - The tolerance to add on top of the gasUsed.
4266
4050
  * @returns A promise that resolves to the transaction cost object.
4267
4051
  */
4268
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4052
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4053
+ estimateTxDependencies = true,
4054
+ estimatePredicates = true,
4055
+ resourcesOwner,
4056
+ signatureCallback
4057
+ } = {}) {
4269
4058
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4059
+ const chainInfo = this.getChain();
4060
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4061
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
4270
4062
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4271
4063
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4272
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4064
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4273
4065
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4274
- txRequestClone.maxFee = bn16(0);
4275
- if (isScriptTransaction) {
4276
- txRequestClone.gasLimit = bn16(0);
4277
- }
4278
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4279
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4066
+ if (estimatePredicates) {
4067
+ if (isScriptTransaction) {
4068
+ txRequestClone.gasLimit = bn15(0);
4069
+ }
4070
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4071
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4072
+ }
4073
+ await this.estimatePredicates(txRequestClone);
4280
4074
  }
4281
- const signedRequest = clone3(txRequestClone);
4282
- let addedSignatures = 0;
4283
4075
  if (signatureCallback && isScriptTransaction) {
4284
- const lengthBefore = signedRequest.witnesses.length;
4285
- await signatureCallback(signedRequest);
4286
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4287
- }
4288
- await this.estimatePredicates(signedRequest);
4289
- let { maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4290
- transactionRequest: signedRequest,
4291
- optimizeGas: false
4292
- });
4293
- txRequestClone.maxFee = maxFee;
4076
+ await signatureCallback(txRequestClone);
4077
+ }
4078
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
4079
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4294
4080
  let receipts = [];
4295
4081
  let missingContractIds = [];
4296
4082
  let outputVariables = 0;
4297
- let gasUsed = bn16(0);
4298
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4299
- if (isScriptTransaction) {
4300
- if (signatureCallback) {
4301
- await signatureCallback(txRequestClone);
4302
- }
4303
- txRequestClone.gasLimit = maxGas;
4083
+ if (isScriptTransaction && estimateTxDependencies) {
4084
+ txRequestClone.gasPrice = bn15(0);
4085
+ txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4304
4086
  const result = await this.estimateTxDependencies(txRequestClone);
4305
4087
  receipts = result.receipts;
4306
4088
  outputVariables = result.outputVariables;
4307
4089
  missingContractIds = result.missingContractIds;
4308
- gasUsed = getGasUsedFromReceipts(receipts);
4309
- txRequestClone.gasLimit = gasUsed;
4310
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4311
- transactionRequest: txRequestClone,
4312
- gasPrice
4313
- }));
4314
4090
  }
4091
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4092
+ const usedFee = calculatePriceWithFactor(
4093
+ gasUsed,
4094
+ gasPrice,
4095
+ gasPriceFactor
4096
+ ).normalizeZeroToOne();
4097
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4098
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4315
4099
  return {
4316
4100
  requiredQuantities: allQuantities,
4317
4101
  receipts,
4318
4102
  gasUsed,
4103
+ minGasPrice,
4319
4104
  gasPrice,
4320
4105
  minGas,
4321
4106
  maxGas,
4107
+ usedFee,
4322
4108
  minFee,
4323
4109
  maxFee,
4110
+ estimatedInputs: txRequestClone.inputs,
4324
4111
  outputVariables,
4325
- missingContractIds,
4326
- addedSignatures,
4327
- estimatedPredicates: txRequestClone.inputs
4112
+ missingContractIds
4328
4113
  };
4329
4114
  }
4330
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4115
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4331
4116
  const ownerAddress = Address2.fromAddressOrString(owner);
4332
4117
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4333
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4334
- quantitiesToContract
4335
- });
4118
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4336
4119
  transactionRequest.addResources(
4337
4120
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4338
4121
  );
4339
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4340
- quantitiesToContract
4341
- });
4122
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4123
+ transactionRequest,
4124
+ forwardingQuantities
4125
+ );
4342
4126
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4343
4127
  return {
4344
4128
  resources,
@@ -4360,10 +4144,11 @@ var _Provider = class {
4360
4144
  return coins.map((coin) => ({
4361
4145
  id: coin.utxoId,
4362
4146
  assetId: coin.assetId,
4363
- amount: bn16(coin.amount),
4147
+ amount: bn15(coin.amount),
4364
4148
  owner: Address2.fromAddressOrString(coin.owner),
4365
- blockCreated: bn16(coin.blockCreated),
4366
- txCreatedIdx: bn16(coin.txCreatedIdx)
4149
+ maturity: bn15(coin.maturity).toNumber(),
4150
+ blockCreated: bn15(coin.blockCreated),
4151
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4367
4152
  }));
4368
4153
  }
4369
4154
  /**
@@ -4400,9 +4185,9 @@ var _Provider = class {
4400
4185
  switch (coin.__typename) {
4401
4186
  case "MessageCoin":
4402
4187
  return {
4403
- amount: bn16(coin.amount),
4188
+ amount: bn15(coin.amount),
4404
4189
  assetId: coin.assetId,
4405
- daHeight: bn16(coin.daHeight),
4190
+ daHeight: bn15(coin.daHeight),
4406
4191
  sender: Address2.fromAddressOrString(coin.sender),
4407
4192
  recipient: Address2.fromAddressOrString(coin.recipient),
4408
4193
  nonce: coin.nonce
@@ -4410,11 +4195,12 @@ var _Provider = class {
4410
4195
  case "Coin":
4411
4196
  return {
4412
4197
  id: coin.utxoId,
4413
- amount: bn16(coin.amount),
4198
+ amount: bn15(coin.amount),
4414
4199
  assetId: coin.assetId,
4415
4200
  owner: Address2.fromAddressOrString(coin.owner),
4416
- blockCreated: bn16(coin.blockCreated),
4417
- txCreatedIdx: bn16(coin.txCreatedIdx)
4201
+ maturity: bn15(coin.maturity).toNumber(),
4202
+ blockCreated: bn15(coin.blockCreated),
4203
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4418
4204
  };
4419
4205
  default:
4420
4206
  return null;
@@ -4431,13 +4217,13 @@ var _Provider = class {
4431
4217
  async getBlock(idOrHeight) {
4432
4218
  let variables;
4433
4219
  if (typeof idOrHeight === "number") {
4434
- variables = { height: bn16(idOrHeight).toString(10) };
4220
+ variables = { height: bn15(idOrHeight).toString(10) };
4435
4221
  } else if (idOrHeight === "latest") {
4436
4222
  variables = { height: (await this.getBlockNumber()).toString(10) };
4437
4223
  } else if (idOrHeight.length === 66) {
4438
4224
  variables = { blockId: idOrHeight };
4439
4225
  } else {
4440
- variables = { blockId: bn16(idOrHeight).toString(10) };
4226
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4441
4227
  }
4442
4228
  const { block } = await this.operations.getBlock(variables);
4443
4229
  if (!block) {
@@ -4445,7 +4231,7 @@ var _Provider = class {
4445
4231
  }
4446
4232
  return {
4447
4233
  id: block.id,
4448
- height: bn16(block.height),
4234
+ height: bn15(block.header.height),
4449
4235
  time: block.header.time,
4450
4236
  transactionIds: block.transactions.map((tx) => tx.id)
4451
4237
  };
@@ -4460,7 +4246,7 @@ var _Provider = class {
4460
4246
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4461
4247
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4462
4248
  id: block.id,
4463
- height: bn16(block.height),
4249
+ height: bn15(block.header.height),
4464
4250
  time: block.header.time,
4465
4251
  transactionIds: block.transactions.map((tx) => tx.id)
4466
4252
  }));
@@ -4475,7 +4261,7 @@ var _Provider = class {
4475
4261
  async getBlockWithTransactions(idOrHeight) {
4476
4262
  let variables;
4477
4263
  if (typeof idOrHeight === "number") {
4478
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4264
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4479
4265
  } else if (idOrHeight === "latest") {
4480
4266
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4481
4267
  } else {
@@ -4487,7 +4273,7 @@ var _Provider = class {
4487
4273
  }
4488
4274
  return {
4489
4275
  id: block.id,
4490
- height: bn16(block.height, 10),
4276
+ height: bn15(block.header.height, 10),
4491
4277
  time: block.header.time,
4492
4278
  transactionIds: block.transactions.map((tx) => tx.id),
4493
4279
  transactions: block.transactions.map(
@@ -4536,7 +4322,7 @@ var _Provider = class {
4536
4322
  contract: Address2.fromAddressOrString(contractId).toB256(),
4537
4323
  asset: hexlify12(assetId)
4538
4324
  });
4539
- return bn16(contractBalance.amount, 10);
4325
+ return bn15(contractBalance.amount, 10);
4540
4326
  }
4541
4327
  /**
4542
4328
  * Returns the balance for the given owner for the given asset ID.
@@ -4550,7 +4336,7 @@ var _Provider = class {
4550
4336
  owner: Address2.fromAddressOrString(owner).toB256(),
4551
4337
  assetId: hexlify12(assetId)
4552
4338
  });
4553
- return bn16(balance.amount, 10);
4339
+ return bn15(balance.amount, 10);
4554
4340
  }
4555
4341
  /**
4556
4342
  * Returns balances for the given owner.
@@ -4568,7 +4354,7 @@ var _Provider = class {
4568
4354
  const balances = result.balances.edges.map((edge) => edge.node);
4569
4355
  return balances.map((balance) => ({
4570
4356
  assetId: balance.assetId,
4571
- amount: bn16(balance.amount)
4357
+ amount: bn15(balance.amount)
4572
4358
  }));
4573
4359
  }
4574
4360
  /**
@@ -4590,15 +4376,15 @@ var _Provider = class {
4590
4376
  sender: message.sender,
4591
4377
  recipient: message.recipient,
4592
4378
  nonce: message.nonce,
4593
- amount: bn16(message.amount),
4379
+ amount: bn15(message.amount),
4594
4380
  data: message.data
4595
4381
  }),
4596
4382
  sender: Address2.fromAddressOrString(message.sender),
4597
4383
  recipient: Address2.fromAddressOrString(message.recipient),
4598
4384
  nonce: message.nonce,
4599
- amount: bn16(message.amount),
4385
+ amount: bn15(message.amount),
4600
4386
  data: InputMessageCoder.decodeData(message.data),
4601
- daHeight: bn16(message.daHeight)
4387
+ daHeight: bn15(message.daHeight)
4602
4388
  }));
4603
4389
  }
4604
4390
  /**
@@ -4651,54 +4437,44 @@ var _Provider = class {
4651
4437
  } = result.messageProof;
4652
4438
  return {
4653
4439
  messageProof: {
4654
- proofIndex: bn16(messageProof.proofIndex),
4440
+ proofIndex: bn15(messageProof.proofIndex),
4655
4441
  proofSet: messageProof.proofSet
4656
4442
  },
4657
4443
  blockProof: {
4658
- proofIndex: bn16(blockProof.proofIndex),
4444
+ proofIndex: bn15(blockProof.proofIndex),
4659
4445
  proofSet: blockProof.proofSet
4660
4446
  },
4661
4447
  messageBlockHeader: {
4662
4448
  id: messageBlockHeader.id,
4663
- daHeight: bn16(messageBlockHeader.daHeight),
4664
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4449
+ daHeight: bn15(messageBlockHeader.daHeight),
4450
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4665
4451
  transactionsRoot: messageBlockHeader.transactionsRoot,
4666
- height: bn16(messageBlockHeader.height),
4452
+ height: bn15(messageBlockHeader.height),
4667
4453
  prevRoot: messageBlockHeader.prevRoot,
4668
4454
  time: messageBlockHeader.time,
4669
4455
  applicationHash: messageBlockHeader.applicationHash,
4670
4456
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4671
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount)
4457
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4672
4458
  },
4673
4459
  commitBlockHeader: {
4674
4460
  id: commitBlockHeader.id,
4675
- daHeight: bn16(commitBlockHeader.daHeight),
4676
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4461
+ daHeight: bn15(commitBlockHeader.daHeight),
4462
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4677
4463
  transactionsRoot: commitBlockHeader.transactionsRoot,
4678
- height: bn16(commitBlockHeader.height),
4464
+ height: bn15(commitBlockHeader.height),
4679
4465
  prevRoot: commitBlockHeader.prevRoot,
4680
4466
  time: commitBlockHeader.time,
4681
4467
  applicationHash: commitBlockHeader.applicationHash,
4682
4468
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4683
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount)
4469
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4684
4470
  },
4685
4471
  sender: Address2.fromAddressOrString(sender),
4686
4472
  recipient: Address2.fromAddressOrString(recipient),
4687
4473
  nonce,
4688
- amount: bn16(amount),
4474
+ amount: bn15(amount),
4689
4475
  data
4690
4476
  };
4691
4477
  }
4692
- async getLatestGasPrice() {
4693
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4694
- return bn16(latestGasPrice.gasPrice);
4695
- }
4696
- async estimateGasPrice(blockHorizon) {
4697
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4698
- blockHorizon: String(blockHorizon)
4699
- });
4700
- return bn16(estimateGasPrice.gasPrice);
4701
- }
4702
4478
  /**
4703
4479
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4704
4480
  *
@@ -4718,10 +4494,10 @@ var _Provider = class {
4718
4494
  */
4719
4495
  async produceBlocks(amount, startTime) {
4720
4496
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4721
- blocksToProduce: bn16(amount).toString(10),
4497
+ blocksToProduce: bn15(amount).toString(10),
4722
4498
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4723
4499
  });
4724
- return bn16(latestBlockHeight);
4500
+ return bn15(latestBlockHeight);
4725
4501
  }
4726
4502
  // eslint-disable-next-line @typescript-eslint/require-await
4727
4503
  async getTransactionResponse(transactionId) {
@@ -4735,7 +4511,7 @@ cacheInputs_fn = function(inputs) {
4735
4511
  return;
4736
4512
  }
4737
4513
  inputs.forEach((input) => {
4738
- if (input.type === InputType7.Coin) {
4514
+ if (input.type === InputType6.Coin) {
4739
4515
  this.cache?.set(input.id);
4740
4516
  }
4741
4517
  });
@@ -4745,7 +4521,7 @@ __publicField(Provider, "nodeInfoCache", {});
4745
4521
 
4746
4522
  // src/providers/transaction-summary/get-transaction-summary.ts
4747
4523
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4748
- import { bn as bn17 } from "@fuel-ts/math";
4524
+ import { bn as bn16 } from "@fuel-ts/math";
4749
4525
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4750
4526
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4751
4527
  async function getTransactionSummary(params) {
@@ -4763,28 +4539,21 @@ async function getTransactionSummary(params) {
4763
4539
  arrayify12(gqlTransaction.rawPayload),
4764
4540
  0
4765
4541
  );
4766
- let txReceipts = [];
4767
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4768
- txReceipts = gqlTransaction.status.receipts;
4769
- }
4770
- const receipts = txReceipts.map(processGqlReceipt);
4542
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4771
4543
  const {
4772
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4544
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4773
4545
  } = provider.getChain();
4774
- const gasPrice = await provider.getLatestGasPrice();
4775
4546
  const transactionInfo = assembleTransactionSummary({
4776
4547
  id: gqlTransaction.id,
4777
4548
  receipts,
4778
4549
  transaction: decodedTransaction,
4779
4550
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4780
4551
  gqlTransactionStatus: gqlTransaction.status,
4781
- gasPerByte: bn17(gasPerByte),
4782
- gasPriceFactor: bn17(gasPriceFactor),
4552
+ gasPerByte: bn16(gasPerByte),
4553
+ gasPriceFactor: bn16(gasPriceFactor),
4783
4554
  abiMap,
4784
4555
  maxInputs,
4785
- gasCosts,
4786
- maxGasPerTx,
4787
- gasPrice
4556
+ gasCosts
4788
4557
  });
4789
4558
  return {
4790
4559
  gqlTransaction,
@@ -4794,11 +4563,10 @@ async function getTransactionSummary(params) {
4794
4563
  async function getTransactionSummaryFromRequest(params) {
4795
4564
  const { provider, transactionRequest, abiMap } = params;
4796
4565
  const { receipts } = await provider.call(transactionRequest);
4797
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4566
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4798
4567
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4799
4568
  const transaction = transactionRequest.toTransaction();
4800
4569
  const transactionBytes = transactionRequest.toTransactionBytes();
4801
- const gasPrice = await provider.getLatestGasPrice();
4802
4570
  const transactionSummary = assembleTransactionSummary({
4803
4571
  receipts,
4804
4572
  transaction,
@@ -4807,9 +4575,7 @@ async function getTransactionSummaryFromRequest(params) {
4807
4575
  gasPerByte,
4808
4576
  gasPriceFactor,
4809
4577
  maxInputs,
4810
- gasCosts,
4811
- maxGasPerTx,
4812
- gasPrice
4578
+ gasCosts
4813
4579
  });
4814
4580
  return transactionSummary;
4815
4581
  }
@@ -4818,18 +4584,13 @@ async function getTransactionsSummaries(params) {
4818
4584
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4819
4585
  const { edges, pageInfo } = transactionsByOwner;
4820
4586
  const {
4821
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4587
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4822
4588
  } = provider.getChain();
4823
- const gasPrice = await provider.getLatestGasPrice();
4824
4589
  const transactions = edges.map((edge) => {
4825
4590
  const { node: gqlTransaction } = edge;
4826
- const { id, rawPayload, status } = gqlTransaction;
4591
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4827
4592
  const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
4828
- let txReceipts = [];
4829
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4830
- txReceipts = gqlTransaction.status.receipts;
4831
- }
4832
- const receipts = txReceipts.map(processGqlReceipt);
4593
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4833
4594
  const transactionSummary = assembleTransactionSummary({
4834
4595
  id,
4835
4596
  receipts,
@@ -4840,9 +4601,7 @@ async function getTransactionsSummaries(params) {
4840
4601
  gasPerByte,
4841
4602
  gasPriceFactor,
4842
4603
  maxInputs,
4843
- gasCosts,
4844
- maxGasPerTx,
4845
- gasPrice
4604
+ gasCosts
4846
4605
  });
4847
4606
  const output = {
4848
4607
  gqlTransaction,
@@ -5174,33 +4933,36 @@ var Account = class extends AbstractAccount {
5174
4933
  * @param fee - The estimated transaction fee.
5175
4934
  * @returns A promise that resolves when the resources are added to the transaction.
5176
4935
  */
5177
- async fund(request, params) {
5178
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5179
- const txRequest = request;
5180
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5181
- amount: bn18(fee),
4936
+ async fund(request, coinQuantities, fee) {
4937
+ const updatedQuantities = addAmountToAsset({
4938
+ amount: bn17(fee),
5182
4939
  assetId: BaseAssetId3,
5183
- coinQuantities: requiredQuantities
4940
+ coinQuantities
5184
4941
  });
5185
4942
  const quantitiesDict = {};
5186
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4943
+ updatedQuantities.forEach(({ amount, assetId }) => {
5187
4944
  quantitiesDict[assetId] = {
5188
4945
  required: amount,
5189
- owned: bn18(0)
4946
+ owned: bn17(0)
5190
4947
  };
5191
4948
  });
5192
- txRequest.inputs.forEach((input) => {
4949
+ const cachedUtxos = [];
4950
+ const cachedMessages = [];
4951
+ const owner = this.address.toB256();
4952
+ request.inputs.forEach((input) => {
5193
4953
  const isResource = "amount" in input;
5194
4954
  if (isResource) {
5195
4955
  const isCoin2 = "owner" in input;
5196
4956
  if (isCoin2) {
5197
4957
  const assetId = String(input.assetId);
5198
- if (quantitiesDict[assetId]) {
5199
- const amount = bn18(input.amount);
4958
+ if (input.owner === owner && quantitiesDict[assetId]) {
4959
+ const amount = bn17(input.amount);
5200
4960
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4961
+ cachedUtxos.push(input.id);
5201
4962
  }
5202
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4963
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
5203
4964
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4965
+ cachedMessages.push(input.nonce);
5204
4966
  }
5205
4967
  }
5206
4968
  });
@@ -5215,23 +4977,12 @@ var Account = class extends AbstractAccount {
5215
4977
  });
5216
4978
  const needsToBeFunded = missingQuantities.length;
5217
4979
  if (needsToBeFunded) {
5218
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toString());
5219
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5220
- txRequest.addResources(resources);
5221
- }
5222
- txRequest.shiftPredicateData();
5223
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5224
- const requestToBeReEstimate = clone4(txRequest);
5225
- if (addedSignatures) {
5226
- Array.from({ length: addedSignatures }).forEach(
5227
- () => requestToBeReEstimate.addEmptyWitness()
5228
- );
4980
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4981
+ messages: cachedMessages,
4982
+ utxos: cachedUtxos
4983
+ });
4984
+ request.addResources(resources);
5229
4985
  }
5230
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5231
- transactionRequest: requestToBeReEstimate
5232
- });
5233
- txRequest.maxFee = maxFee;
5234
- return txRequest;
5235
4986
  }
5236
4987
  /**
5237
4988
  * A helper that creates a transfer transaction request and returns it.
@@ -5239,25 +4990,28 @@ var Account = class extends AbstractAccount {
5239
4990
  * @param destination - The address of the destination.
5240
4991
  * @param amount - The amount of coins to transfer.
5241
4992
  * @param assetId - The asset ID of the coins to transfer.
5242
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4993
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5243
4994
  * @returns A promise that resolves to the prepared transaction request.
5244
4995
  */
5245
4996
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5246
- const request = new ScriptTransactionRequest(txParams);
4997
+ const { minGasPrice } = this.provider.getGasConfig();
4998
+ const params = { gasPrice: minGasPrice, ...txParams };
4999
+ const request = new ScriptTransactionRequest(params);
5247
5000
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5248
- const txCost = await this.provider.getTransactionCost(request, {
5001
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5249
5002
  estimateTxDependencies: true,
5250
5003
  resourcesOwner: this
5251
5004
  });
5252
- if ("gasLimit" in txParams) {
5253
- this.validateGas({
5254
- gasUsed: txCost.gasUsed,
5255
- gasLimit: request.gasLimit
5256
- });
5257
- }
5258
- request.gasLimit = txCost.gasUsed;
5259
- request.maxFee = txCost.maxFee;
5260
- await this.fund(request, txCost);
5005
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5006
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
5007
+ this.validateGas({
5008
+ gasUsed,
5009
+ gasPrice: request.gasPrice,
5010
+ gasLimit: request.gasLimit,
5011
+ minGasPrice
5012
+ });
5013
+ await this.fund(request, requiredQuantities, maxFee);
5014
+ request.updatePredicateInputs(estimatedInputs);
5261
5015
  return request;
5262
5016
  }
5263
5017
  /**
@@ -5270,7 +5024,7 @@ var Account = class extends AbstractAccount {
5270
5024
  * @returns A promise that resolves to the transaction response.
5271
5025
  */
5272
5026
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5273
- if (bn18(amount).lte(0)) {
5027
+ if (bn17(amount).lte(0)) {
5274
5028
  throw new FuelError15(
5275
5029
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5276
5030
  "Transfer amount must be a positive number."
@@ -5289,37 +5043,38 @@ var Account = class extends AbstractAccount {
5289
5043
  * @returns A promise that resolves to the transaction response.
5290
5044
  */
5291
5045
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5292
- if (bn18(amount).lte(0)) {
5046
+ if (bn17(amount).lte(0)) {
5293
5047
  throw new FuelError15(
5294
5048
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5295
5049
  "Transfer amount must be a positive number."
5296
5050
  );
5297
5051
  }
5298
5052
  const contractAddress = Address3.fromAddressOrString(contractId);
5053
+ const { minGasPrice } = this.provider.getGasConfig();
5054
+ const params = { gasPrice: minGasPrice, ...txParams };
5299
5055
  const { script, scriptData } = await assembleTransferToContractScript({
5300
5056
  hexlifiedContractId: contractAddress.toB256(),
5301
- amountToTransfer: bn18(amount),
5057
+ amountToTransfer: bn17(amount),
5302
5058
  assetId
5303
5059
  });
5304
5060
  const request = new ScriptTransactionRequest({
5305
- ...txParams,
5061
+ ...params,
5306
5062
  script,
5307
5063
  scriptData
5308
5064
  });
5309
5065
  request.addContractInputAndOutput(contractAddress);
5310
- const txCost = await this.provider.getTransactionCost(request, {
5311
- resourcesOwner: this,
5312
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
5066
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5067
+ request,
5068
+ [{ amount: bn17(amount), assetId: String(assetId) }]
5069
+ );
5070
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5071
+ this.validateGas({
5072
+ gasUsed,
5073
+ gasPrice: request.gasPrice,
5074
+ gasLimit: request.gasLimit,
5075
+ minGasPrice
5313
5076
  });
5314
- if (txParams.gasLimit) {
5315
- this.validateGas({
5316
- gasUsed: txCost.gasUsed,
5317
- gasLimit: request.gasLimit
5318
- });
5319
- }
5320
- request.gasLimit = txCost.gasUsed;
5321
- request.maxFee = txCost.maxFee;
5322
- await this.fund(request, txCost);
5077
+ await this.fund(request, requiredQuantities, maxFee);
5323
5078
  return this.sendTransaction(request);
5324
5079
  }
5325
5080
  /**
@@ -5331,31 +5086,34 @@ var Account = class extends AbstractAccount {
5331
5086
  * @returns A promise that resolves to the transaction response.
5332
5087
  */
5333
5088
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5089
+ const { minGasPrice } = this.provider.getGasConfig();
5334
5090
  const recipientAddress = Address3.fromAddressOrString(recipient);
5335
5091
  const recipientDataArray = arrayify14(
5336
5092
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5337
5093
  );
5338
5094
  const amountDataArray = arrayify14(
5339
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
5095
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5340
5096
  );
5341
5097
  const script = new Uint8Array([
5342
5098
  ...arrayify14(withdrawScript.bytes),
5343
5099
  ...recipientDataArray,
5344
5100
  ...amountDataArray
5345
5101
  ]);
5346
- const params = { script, ...txParams };
5102
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5347
5103
  const request = new ScriptTransactionRequest(params);
5348
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5349
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5350
- if (txParams.gasLimit) {
5351
- this.validateGas({
5352
- gasUsed: txCost.gasUsed,
5353
- gasLimit: request.gasLimit
5354
- });
5355
- }
5356
- request.maxFee = txCost.maxFee;
5357
- request.gasLimit = txCost.gasUsed;
5358
- await this.fund(request, txCost);
5104
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5105
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5106
+ request,
5107
+ forwardingQuantities
5108
+ );
5109
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5110
+ this.validateGas({
5111
+ gasUsed,
5112
+ gasPrice: request.gasPrice,
5113
+ gasLimit: request.gasLimit,
5114
+ minGasPrice
5115
+ });
5116
+ await this.fund(request, requiredQuantities, maxFee);
5359
5117
  return this.sendTransaction(request);
5360
5118
  }
5361
5119
  async signMessage(message) {
@@ -5413,7 +5171,18 @@ var Account = class extends AbstractAccount {
5413
5171
  }
5414
5172
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5415
5173
  }
5416
- validateGas({ gasUsed, gasLimit }) {
5174
+ validateGas({
5175
+ gasUsed,
5176
+ gasPrice,
5177
+ gasLimit,
5178
+ minGasPrice
5179
+ }) {
5180
+ if (minGasPrice.gt(gasPrice)) {
5181
+ throw new FuelError15(
5182
+ ErrorCode15.GAS_PRICE_TOO_LOW,
5183
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5184
+ );
5185
+ }
5417
5186
  if (gasUsed.gt(gasLimit)) {
5418
5187
  throw new FuelError15(
5419
5188
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5429,7 +5198,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
5429
5198
 
5430
5199
  // src/signer/signer.ts
5431
5200
  import { Address as Address4 } from "@fuel-ts/address";
5432
- import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
5201
+ import { randomBytes } from "@fuel-ts/crypto";
5433
5202
  import { hash } from "@fuel-ts/hasher";
5434
5203
  import { toBytes } from "@fuel-ts/math";
5435
5204
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5522,7 +5291,7 @@ var Signer = class {
5522
5291
  * @returns random 32-byte hashed
5523
5292
  */
5524
5293
  static generatePrivateKey(entropy) {
5525
- return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5294
+ return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5526
5295
  }
5527
5296
  /**
5528
5297
  * Extended publicKey from a compact publicKey
@@ -5541,7 +5310,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5541
5310
  import {
5542
5311
  bufferFromString,
5543
5312
  keccak256,
5544
- randomBytes as randomBytes3,
5313
+ randomBytes as randomBytes2,
5545
5314
  scrypt,
5546
5315
  stringFromBuffer,
5547
5316
  decryptJsonWalletData,
@@ -5564,7 +5333,7 @@ var removeHexPrefix = (hexString) => {
5564
5333
  async function encryptKeystoreWallet(privateKey, address, password) {
5565
5334
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5566
5335
  const ownerAddress = Address5.fromAddressOrString(address);
5567
- const salt = randomBytes3(DEFAULT_KEY_SIZE);
5336
+ const salt = randomBytes2(DEFAULT_KEY_SIZE);
5568
5337
  const key = scrypt({
5569
5338
  password: bufferFromString(password),
5570
5339
  salt,
@@ -5573,7 +5342,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5573
5342
  r: DEFAULT_KDF_PARAMS_R,
5574
5343
  p: DEFAULT_KDF_PARAMS_P
5575
5344
  });
5576
- const iv = randomBytes3(DEFAULT_IV_SIZE);
5345
+ const iv = randomBytes2(DEFAULT_IV_SIZE);
5577
5346
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5578
5347
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5579
5348
  const macHashUint8Array = keccak256(data);
@@ -5709,7 +5478,7 @@ var BaseWalletUnlocked = class extends Account {
5709
5478
  * @param transactionRequestLike - The transaction request to send.
5710
5479
  * @returns A promise that resolves to the TransactionResponse object.
5711
5480
  */
5712
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5481
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5713
5482
  const transactionRequest = transactionRequestify(transactionRequestLike);
5714
5483
  if (estimateTxDependencies) {
5715
5484
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5750,12 +5519,12 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5750
5519
  // src/hdwallet/hdwallet.ts
5751
5520
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5752
5521
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5753
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5522
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5754
5523
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5755
5524
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5756
5525
 
5757
5526
  // src/mnemonic/mnemonic.ts
5758
- import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5527
+ import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5759
5528
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5760
5529
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5761
5530
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -8116,7 +7885,7 @@ var Mnemonic = class {
8116
7885
  * @returns A randomly generated mnemonic
8117
7886
  */
8118
7887
  static generate(size = 32, extraEntropy = "") {
8119
- const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7888
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
8120
7889
  return Mnemonic.entropyToMnemonic(entropy);
8121
7890
  }
8122
7891
  };
@@ -8222,7 +7991,7 @@ var HDWallet = class {
8222
7991
  const IR = bytes.slice(32);
8223
7992
  if (privateKey) {
8224
7993
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8225
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
7994
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
8226
7995
  return new HDWallet({
8227
7996
  privateKey: ki,
8228
7997
  chainCode: IR,
@@ -8911,7 +8680,7 @@ import {
8911
8680
  import { Address as Address9 } from "@fuel-ts/address";
8912
8681
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8913
8682
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8914
- import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
8683
+ import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8915
8684
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8916
8685
 
8917
8686
  // src/predicate/utils/getPredicateRoot.ts
@@ -8960,7 +8729,6 @@ var Predicate = class extends Account {
8960
8729
  this.interface = predicateInterface;
8961
8730
  if (inputData !== void 0 && inputData.length > 0) {
8962
8731
  this.predicateData = inputData;
8963
- this.predicateDataBytes = this.getPredicateData(0);
8964
8732
  }
8965
8733
  }
8966
8734
  /**
@@ -8973,9 +8741,9 @@ var Predicate = class extends Account {
8973
8741
  const request = transactionRequestify(transactionRequestLike);
8974
8742
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8975
8743
  request.inputs?.forEach((input) => {
8976
- if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
8977
- input.predicate = hexlify19(this.bytes);
8978
- input.predicateData = hexlify19(this.getPredicateData(policies.length));
8744
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8745
+ input.predicate = this.bytes;
8746
+ input.predicateData = this.getPredicateData(policies.length);
8979
8747
  }
8980
8748
  });
8981
8749
  return request;
@@ -8990,7 +8758,8 @@ var Predicate = class extends Account {
8990
8758
  * @returns A promise that resolves to the prepared transaction request.
8991
8759
  */
8992
8760
  async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
8993
- return super.createTransfer(destination, amount, assetId, txParams);
8761
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8762
+ return this.populateTransactionPredicateData(request);
8994
8763
  }
8995
8764
  /**
8996
8765
  * Sends a transaction with the populated predicate data.
@@ -8998,9 +8767,9 @@ var Predicate = class extends Account {
8998
8767
  * @param transactionRequestLike - The transaction request-like object.
8999
8768
  * @returns A promise that resolves to the transaction response.
9000
8769
  */
9001
- sendTransaction(transactionRequestLike) {
9002
- const transactionRequest = transactionRequestify(transactionRequestLike);
9003
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8770
+ sendTransaction(transactionRequestLike, options) {
8771
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8772
+ return super.sendTransaction(transactionRequest, options);
9004
8773
  }
9005
8774
  /**
9006
8775
  * Simulates a transaction with the populated predicate data.
@@ -9009,8 +8778,8 @@ var Predicate = class extends Account {
9009
8778
  * @returns A promise that resolves to the call result.
9010
8779
  */
9011
8780
  simulateTransaction(transactionRequestLike) {
9012
- const transactionRequest = transactionRequestify(transactionRequestLike);
9013
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8781
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8782
+ return super.simulateTransaction(transactionRequest);
9014
8783
  }
9015
8784
  getPredicateData(policiesLength) {
9016
8785
  if (!this.predicateData.length) {
@@ -9056,26 +8825,6 @@ var Predicate = class extends Account {
9056
8825
  predicateInterface: abiInterface
9057
8826
  };
9058
8827
  }
9059
- /**
9060
- * Retrieves resources satisfying the spend query for the account.
9061
- *
9062
- * @param quantities - IDs of coins to exclude.
9063
- * @param excludedIds - IDs of resources to be excluded from the query.
9064
- * @returns A promise that resolves to an array of Resources.
9065
- */
9066
- async getResourcesToSpend(quantities, excludedIds) {
9067
- const resources = await this.provider.getResourcesToSpend(
9068
- this.address,
9069
- quantities,
9070
- excludedIds
9071
- );
9072
- return resources.map((resource) => ({
9073
- ...resource,
9074
- predicate: hexlify19(this.bytes),
9075
- predicateData: hexlify19(this.predicateDataBytes),
9076
- paddPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
9077
- }));
9078
- }
9079
8828
  /**
9080
8829
  * Sets the configurable constants for the predicate.
9081
8830
  *
@@ -9824,7 +9573,7 @@ export {
9824
9573
  WalletLocked,
9825
9574
  WalletManager,
9826
9575
  WalletUnlocked,
9827
- addAmountToCoinQuantities,
9576
+ addAmountToAsset,
9828
9577
  addOperation,
9829
9578
  assemblePanicError,
9830
9579
  assembleReceiptByType,
@@ -9833,10 +9582,9 @@ export {
9833
9582
  assets,
9834
9583
  buildBlockExplorerUrl,
9835
9584
  cacheFor,
9836
- cacheTxInputsFromOwner,
9837
- calculateGasFee,
9838
9585
  calculateMetadataGasForTxCreate,
9839
9586
  calculateMetadataGasForTxScript,
9587
+ calculatePriceWithFactor,
9840
9588
  calculateTransactionFee,
9841
9589
  coinQuantityfy,
9842
9590
  deferPromise,