@fuel-ts/account 0.0.0-rc-2021-20240423205052 → 0.0.0-rc-2045-20240424064755

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 (53) 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 +589 -861
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +517 -793
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +398 -673
  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 +327 -821
  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/message.d.ts +1 -7
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +27 -37
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.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 +29 -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/launchNode.d.ts.map +1 -1
  46. package/dist/test-utils.global.js +1090 -1579
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +515 -774
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +407 -666
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  53. package/package.json +16 -16
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
@@ -91,40 +90,16 @@ import { clone as clone3 } from "ramda";
91
90
 
92
91
  // src/providers/__generated__/operations.ts
93
92
  import gql from "graphql-tag";
94
- var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
95
- fragment transactionStatusSubscriptionFragment on TransactionStatus {
96
- type: __typename
97
- ... on SubmittedStatus {
98
- time
99
- }
100
- ... on SuccessStatus {
101
- block {
102
- id
103
- }
104
- time
105
- programState {
106
- returnType
107
- data
108
- }
109
- }
110
- ... on FailureStatus {
111
- block {
112
- id
113
- }
114
- time
115
- reason
116
- }
117
- ... on SqueezedOutStatus {
118
- reason
119
- }
120
- }
121
- `;
122
93
  var ReceiptFragmentFragmentDoc = gql`
123
94
  fragment receiptFragment on Receipt {
124
- id
95
+ contract {
96
+ id
97
+ }
125
98
  pc
126
99
  is
127
- to
100
+ to {
101
+ id
102
+ }
128
103
  toAddress
129
104
  amount
130
105
  assetId
@@ -162,16 +137,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
162
137
  id
163
138
  }
164
139
  time
165
- receipts {
166
- ...receiptFragment
167
- }
168
140
  programState {
169
141
  returnType
170
142
  data
171
143
  }
172
- receipts {
173
- ...receiptFragment
174
- }
175
144
  }
176
145
  ... on FailureStatus {
177
146
  block {
@@ -179,24 +148,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
179
148
  }
180
149
  time
181
150
  reason
182
- receipts {
183
- ...receiptFragment
184
- }
185
151
  }
186
152
  ... on SqueezedOutStatus {
187
153
  reason
188
154
  }
189
155
  }
190
- ${ReceiptFragmentFragmentDoc}`;
156
+ `;
191
157
  var TransactionFragmentFragmentDoc = gql`
192
158
  fragment transactionFragment on Transaction {
193
159
  id
194
160
  rawPayload
161
+ gasPrice
162
+ receipts {
163
+ ...receiptFragment
164
+ }
195
165
  status {
196
166
  ...transactionStatusFragment
197
167
  }
198
168
  }
199
- ${TransactionStatusFragmentFragmentDoc}`;
169
+ ${ReceiptFragmentFragmentDoc}
170
+ ${TransactionStatusFragmentFragmentDoc}`;
200
171
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
201
172
  fragment inputEstimatePredicatesFragment on Input {
202
173
  ... on InputCoin {
@@ -214,46 +185,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
214
185
  }
215
186
  }
216
187
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
217
- var DryRunFailureStatusFragmentFragmentDoc = gql`
218
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
219
- reason
220
- programState {
221
- returnType
222
- data
223
- }
224
- }
225
- `;
226
- var DryRunSuccessStatusFragmentFragmentDoc = gql`
227
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
228
- programState {
229
- returnType
230
- data
231
- }
232
- }
233
- `;
234
- var DryRunTransactionStatusFragmentFragmentDoc = gql`
235
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
236
- ... on DryRunFailureStatus {
237
- ...dryRunFailureStatusFragment
238
- }
239
- ... on DryRunSuccessStatus {
240
- ...dryRunSuccessStatusFragment
241
- }
242
- }
243
- ${DryRunFailureStatusFragmentFragmentDoc}
244
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
245
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
246
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
247
- id
248
- status {
249
- ...dryRunTransactionStatusFragment
250
- }
251
- receipts {
252
- ...receiptFragment
253
- }
254
- }
255
- ${DryRunTransactionStatusFragmentFragmentDoc}
256
- ${ReceiptFragmentFragmentDoc}`;
257
188
  var CoinFragmentFragmentDoc = gql`
258
189
  fragment coinFragment on Coin {
259
190
  __typename
@@ -261,6 +192,7 @@ var CoinFragmentFragmentDoc = gql`
261
192
  owner
262
193
  amount
263
194
  assetId
195
+ maturity
264
196
  blockCreated
265
197
  txCreatedIdx
266
198
  }
@@ -299,32 +231,26 @@ var MessageProofFragmentFragmentDoc = gql`
299
231
  messageBlockHeader {
300
232
  id
301
233
  daHeight
302
- consensusParametersVersion
303
- stateTransitionBytecodeVersion
304
234
  transactionsCount
305
- messageReceiptCount
306
235
  transactionsRoot
307
- messageOutboxRoot
308
- eventInboxRoot
309
236
  height
310
237
  prevRoot
311
238
  time
312
239
  applicationHash
240
+ messageReceiptRoot
241
+ messageReceiptCount
313
242
  }
314
243
  commitBlockHeader {
315
244
  id
316
245
  daHeight
317
- consensusParametersVersion
318
- stateTransitionBytecodeVersion
319
246
  transactionsCount
320
- messageReceiptCount
321
247
  transactionsRoot
322
- messageOutboxRoot
323
- eventInboxRoot
324
248
  height
325
249
  prevRoot
326
250
  time
327
251
  applicationHash
252
+ messageReceiptRoot
253
+ messageReceiptCount
328
254
  }
329
255
  sender
330
256
  recipient
@@ -343,8 +269,8 @@ var BalanceFragmentFragmentDoc = gql`
343
269
  var BlockFragmentFragmentDoc = gql`
344
270
  fragment blockFragment on Block {
345
271
  id
346
- height
347
272
  header {
273
+ height
348
274
  time
349
275
  }
350
276
  transactions {
@@ -402,11 +328,6 @@ var DependentCostFragmentFragmentDoc = gql`
402
328
  `;
403
329
  var GasCostsFragmentFragmentDoc = gql`
404
330
  fragment GasCostsFragment on GasCosts {
405
- version {
406
- ... on Version {
407
- value
408
- }
409
- }
410
331
  add
411
332
  addi
412
333
  aloc
@@ -419,6 +340,7 @@ var GasCostsFragmentFragmentDoc = gql`
419
340
  cb
420
341
  cfei
421
342
  cfsi
343
+ croo
422
344
  div
423
345
  divi
424
346
  ecr1
@@ -501,9 +423,6 @@ var GasCostsFragmentFragmentDoc = gql`
501
423
  ccp {
502
424
  ...DependentCostFragment
503
425
  }
504
- croo {
505
- ...DependentCostFragment
506
- }
507
426
  csiz {
508
427
  ...DependentCostFragment
509
428
  }
@@ -563,11 +482,6 @@ var GasCostsFragmentFragmentDoc = gql`
563
482
  ${DependentCostFragmentFragmentDoc}`;
564
483
  var ConsensusParametersFragmentFragmentDoc = gql`
565
484
  fragment consensusParametersFragment on ConsensusParameters {
566
- version {
567
- ... on Version {
568
- value
569
- }
570
- }
571
485
  txParams {
572
486
  ...TxParametersFragment
573
487
  }
@@ -627,9 +541,18 @@ var NodeInfoFragmentFragmentDoc = gql`
627
541
  fragment nodeInfoFragment on NodeInfo {
628
542
  utxoValidation
629
543
  vmBacktrace
544
+ minGasPrice
630
545
  maxTx
631
546
  maxDepth
632
547
  nodeVersion
548
+ peers {
549
+ id
550
+ addresses
551
+ clientVersion
552
+ blockHeight
553
+ lastHeartbeatMs
554
+ appScore
555
+ }
633
556
  }
634
557
  `;
635
558
  var GetVersionDocument = gql`
@@ -664,9 +587,13 @@ var GetTransactionWithReceiptsDocument = gql`
664
587
  query getTransactionWithReceipts($transactionId: TransactionId!) {
665
588
  transaction(id: $transactionId) {
666
589
  ...transactionFragment
590
+ receipts {
591
+ ...receiptFragment
592
+ }
667
593
  }
668
594
  }
669
- ${TransactionFragmentFragmentDoc}`;
595
+ ${TransactionFragmentFragmentDoc}
596
+ ${ReceiptFragmentFragmentDoc}`;
670
597
  var GetTransactionsDocument = gql`
671
598
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
672
599
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -794,20 +721,6 @@ var GetBalanceDocument = gql`
794
721
  }
795
722
  }
796
723
  ${BalanceFragmentFragmentDoc}`;
797
- var GetLatestGasPriceDocument = gql`
798
- query getLatestGasPrice {
799
- latestGasPrice {
800
- gasPrice
801
- }
802
- }
803
- `;
804
- var EstimateGasPriceDocument = gql`
805
- query estimateGasPrice($blockHorizon: U32!) {
806
- estimateGasPrice(blockHorizon: $blockHorizon) {
807
- gasPrice
808
- }
809
- }
810
- `;
811
724
  var GetBalancesDocument = gql`
812
725
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
813
726
  balances(
@@ -862,12 +775,12 @@ var GetMessageStatusDocument = gql`
862
775
  }
863
776
  `;
864
777
  var DryRunDocument = gql`
865
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
866
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
867
- ...dryRunTransactionExecutionStatusFragment
778
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
779
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
780
+ ...receiptFragment
868
781
  }
869
782
  }
870
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
783
+ ${ReceiptFragmentFragmentDoc}`;
871
784
  var SubmitDocument = gql`
872
785
  mutation submit($encodedTransaction: HexString!) {
873
786
  submit(tx: $encodedTransaction) {
@@ -886,17 +799,17 @@ var ProduceBlocksDocument = gql`
886
799
  var SubmitAndAwaitDocument = gql`
887
800
  subscription submitAndAwait($encodedTransaction: HexString!) {
888
801
  submitAndAwait(tx: $encodedTransaction) {
889
- ...transactionStatusSubscriptionFragment
802
+ ...transactionStatusFragment
890
803
  }
891
804
  }
892
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
805
+ ${TransactionStatusFragmentFragmentDoc}`;
893
806
  var StatusChangeDocument = gql`
894
807
  subscription statusChange($transactionId: TransactionId!) {
895
808
  statusChange(id: $transactionId) {
896
- ...transactionStatusSubscriptionFragment
809
+ ...transactionStatusFragment
897
810
  }
898
811
  }
899
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
812
+ ${TransactionStatusFragmentFragmentDoc}`;
900
813
  function getSdk(requester) {
901
814
  return {
902
815
  getVersion(variables, options) {
@@ -950,12 +863,6 @@ function getSdk(requester) {
950
863
  getBalance(variables, options) {
951
864
  return requester(GetBalanceDocument, variables, options);
952
865
  },
953
- getLatestGasPrice(variables, options) {
954
- return requester(GetLatestGasPriceDocument, variables, options);
955
- },
956
- estimateGasPrice(variables, options) {
957
- return requester(EstimateGasPriceDocument, variables, options);
958
- },
959
866
  getBalances(variables, options) {
960
867
  return requester(GetBalancesDocument, variables, options);
961
868
  },
@@ -1149,9 +1056,10 @@ var inputify = (value) => {
1149
1056
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1150
1057
  },
1151
1058
  witnessIndex: value.witnessIndex,
1059
+ maturity: value.maturity ?? 0,
1152
1060
  predicateGasUsed: bn2(value.predicateGasUsed),
1153
- predicateLength: bn2(predicate.length),
1154
- predicateDataLength: bn2(predicateData.length),
1061
+ predicateLength: predicate.length,
1062
+ predicateDataLength: predicateData.length,
1155
1063
  predicate: hexlify3(predicate),
1156
1064
  predicateData: hexlify3(predicateData)
1157
1065
  };
@@ -1182,8 +1090,8 @@ var inputify = (value) => {
1182
1090
  nonce: hexlify3(value.nonce),
1183
1091
  witnessIndex: value.witnessIndex,
1184
1092
  predicateGasUsed: bn2(value.predicateGasUsed),
1185
- predicateLength: bn2(predicate.length),
1186
- predicateDataLength: bn2(predicateData.length),
1093
+ predicateLength: predicate.length,
1094
+ predicateDataLength: predicateData.length,
1187
1095
  predicate: hexlify3(predicate),
1188
1096
  predicateData: hexlify3(predicateData),
1189
1097
  data: hexlify3(data),
@@ -1313,8 +1221,8 @@ function assembleReceiptByType(receipt) {
1313
1221
  case "CALL" /* Call */: {
1314
1222
  const callReceipt = {
1315
1223
  type: ReceiptType.Call,
1316
- from: hexOrZero(receipt.id || receipt.contractId),
1317
- to: hexOrZero(receipt?.to),
1224
+ from: hexOrZero(receipt.contract?.id),
1225
+ to: hexOrZero(receipt?.to?.id),
1318
1226
  amount: bn4(receipt.amount),
1319
1227
  assetId: hexOrZero(receipt.assetId),
1320
1228
  gas: bn4(receipt.gas),
@@ -1328,7 +1236,7 @@ function assembleReceiptByType(receipt) {
1328
1236
  case "RETURN" /* Return */: {
1329
1237
  const returnReceipt = {
1330
1238
  type: ReceiptType.Return,
1331
- id: hexOrZero(receipt.id || receipt.contractId),
1239
+ id: hexOrZero(receipt.contract?.id),
1332
1240
  val: bn4(receipt.val),
1333
1241
  pc: bn4(receipt.pc),
1334
1242
  is: bn4(receipt.is)
@@ -1338,7 +1246,7 @@ function assembleReceiptByType(receipt) {
1338
1246
  case "RETURN_DATA" /* ReturnData */: {
1339
1247
  const returnDataReceipt = {
1340
1248
  type: ReceiptType.ReturnData,
1341
- id: hexOrZero(receipt.id || receipt.contractId),
1249
+ id: hexOrZero(receipt.contract?.id),
1342
1250
  ptr: bn4(receipt.ptr),
1343
1251
  len: bn4(receipt.len),
1344
1252
  digest: hexOrZero(receipt.digest),
@@ -1350,7 +1258,7 @@ function assembleReceiptByType(receipt) {
1350
1258
  case "PANIC" /* Panic */: {
1351
1259
  const panicReceipt = {
1352
1260
  type: ReceiptType.Panic,
1353
- id: hexOrZero(receipt.id),
1261
+ id: hexOrZero(receipt.contract?.id),
1354
1262
  reason: bn4(receipt.reason),
1355
1263
  pc: bn4(receipt.pc),
1356
1264
  is: bn4(receipt.is),
@@ -1361,7 +1269,7 @@ function assembleReceiptByType(receipt) {
1361
1269
  case "REVERT" /* Revert */: {
1362
1270
  const revertReceipt = {
1363
1271
  type: ReceiptType.Revert,
1364
- id: hexOrZero(receipt.id || receipt.contractId),
1272
+ id: hexOrZero(receipt.contract?.id),
1365
1273
  val: bn4(receipt.ra),
1366
1274
  pc: bn4(receipt.pc),
1367
1275
  is: bn4(receipt.is)
@@ -1371,7 +1279,7 @@ function assembleReceiptByType(receipt) {
1371
1279
  case "LOG" /* Log */: {
1372
1280
  const logReceipt = {
1373
1281
  type: ReceiptType.Log,
1374
- id: hexOrZero(receipt.id || receipt.contractId),
1282
+ id: hexOrZero(receipt.contract?.id),
1375
1283
  val0: bn4(receipt.ra),
1376
1284
  val1: bn4(receipt.rb),
1377
1285
  val2: bn4(receipt.rc),
@@ -1384,7 +1292,7 @@ function assembleReceiptByType(receipt) {
1384
1292
  case "LOG_DATA" /* LogData */: {
1385
1293
  const logDataReceipt = {
1386
1294
  type: ReceiptType.LogData,
1387
- id: hexOrZero(receipt.id || receipt.contractId),
1295
+ id: hexOrZero(receipt.contract?.id),
1388
1296
  val0: bn4(receipt.ra),
1389
1297
  val1: bn4(receipt.rb),
1390
1298
  ptr: bn4(receipt.ptr),
@@ -1398,8 +1306,8 @@ function assembleReceiptByType(receipt) {
1398
1306
  case "TRANSFER" /* Transfer */: {
1399
1307
  const transferReceipt = {
1400
1308
  type: ReceiptType.Transfer,
1401
- from: hexOrZero(receipt.id || receipt.contractId),
1402
- to: hexOrZero(receipt.toAddress || receipt?.to),
1309
+ from: hexOrZero(receipt.contract?.id),
1310
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1403
1311
  amount: bn4(receipt.amount),
1404
1312
  assetId: hexOrZero(receipt.assetId),
1405
1313
  pc: bn4(receipt.pc),
@@ -1410,8 +1318,8 @@ function assembleReceiptByType(receipt) {
1410
1318
  case "TRANSFER_OUT" /* TransferOut */: {
1411
1319
  const transferOutReceipt = {
1412
1320
  type: ReceiptType.TransferOut,
1413
- from: hexOrZero(receipt.id || receipt.contractId),
1414
- to: hexOrZero(receipt.toAddress || receipt.to),
1321
+ from: hexOrZero(receipt.contract?.id),
1322
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1415
1323
  amount: bn4(receipt.amount),
1416
1324
  assetId: hexOrZero(receipt.assetId),
1417
1325
  pc: bn4(receipt.pc),
@@ -1454,7 +1362,7 @@ function assembleReceiptByType(receipt) {
1454
1362
  return receiptMessageOut;
1455
1363
  }
1456
1364
  case "MINT" /* Mint */: {
1457
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1365
+ const contractId = hexOrZero(receipt.contract?.id);
1458
1366
  const subId = hexOrZero(receipt.subId);
1459
1367
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1460
1368
  const mintReceipt = {
@@ -1469,7 +1377,7 @@ function assembleReceiptByType(receipt) {
1469
1377
  return mintReceipt;
1470
1378
  }
1471
1379
  case "BURN" /* Burn */: {
1472
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1380
+ const contractId = hexOrZero(receipt.contract?.id);
1473
1381
  const subId = hexOrZero(receipt.subId);
1474
1382
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1475
1383
  const burnReceipt = {
@@ -1554,6 +1462,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1554
1462
  import { bn as bn5 } from "@fuel-ts/math";
1555
1463
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1556
1464
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1465
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1557
1466
  var getGasUsedFromReceipts = (receipts) => {
1558
1467
  const scriptResult = receipts.filter(
1559
1468
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1574,28 +1483,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1574
1483
  }
1575
1484
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1576
1485
  const witnessCache = [];
1577
- const chargeableInputs = inputs.filter((input) => {
1578
- const isCoinOrMessage = "owner" in input || "sender" in input;
1579
- if (isCoinOrMessage) {
1580
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1581
- return true;
1582
- }
1583
- if (!witnessCache.includes(input.witnessIndex)) {
1584
- witnessCache.push(input.witnessIndex);
1585
- return true;
1586
- }
1587
- }
1588
- return false;
1589
- });
1590
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1591
- const totalGas = chargeableInputs.reduce((total, input) => {
1486
+ const totalGas = inputs.reduce((total, input) => {
1592
1487
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1593
1488
  return total.add(
1594
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1489
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1595
1490
  );
1596
1491
  }
1597
- return total.add(gasCosts.ecr1);
1598
- }, bn5(0));
1492
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1493
+ witnessCache.push(input.witnessIndex);
1494
+ return total.add(gasCosts.ecr1);
1495
+ }
1496
+ return total;
1497
+ }, bn5());
1599
1498
  return totalGas;
1600
1499
  }
1601
1500
  function getMinGas(params) {
@@ -1607,20 +1506,12 @@ function getMinGas(params) {
1607
1506
  return minGas;
1608
1507
  }
1609
1508
  function getMaxGas(params) {
1610
- const {
1611
- gasPerByte,
1612
- witnessesLength,
1613
- witnessLimit,
1614
- minGas,
1615
- gasLimit = bn5(0),
1616
- maxGasPerTx
1617
- } = params;
1509
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1618
1510
  let remainingAllowedWitnessGas = bn5(0);
1619
1511
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1620
1512
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1621
1513
  }
1622
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1623
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1514
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1624
1515
  }
1625
1516
  function calculateMetadataGasForTxCreate({
1626
1517
  gasCosts,
@@ -1642,10 +1533,6 @@ function calculateMetadataGasForTxScript({
1642
1533
  }) {
1643
1534
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1644
1535
  }
1645
- var calculateGasFee = (params) => {
1646
- const { gas, gasPrice, priceFactor, tip } = params;
1647
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1648
- };
1649
1536
 
1650
1537
  // src/providers/utils/json.ts
1651
1538
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1802,7 +1689,7 @@ var witnessify = (value) => {
1802
1689
  // src/providers/transaction-request/transaction-request.ts
1803
1690
  var BaseTransactionRequest = class {
1804
1691
  /** Gas price for transaction */
1805
- tip;
1692
+ gasPrice;
1806
1693
  /** Block until which tx cannot be included */
1807
1694
  maturity;
1808
1695
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1821,7 +1708,7 @@ var BaseTransactionRequest = class {
1821
1708
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1822
1709
  */
1823
1710
  constructor({
1824
- tip,
1711
+ gasPrice,
1825
1712
  maturity,
1826
1713
  maxFee,
1827
1714
  witnessLimit,
@@ -1829,7 +1716,7 @@ var BaseTransactionRequest = class {
1829
1716
  outputs,
1830
1717
  witnesses
1831
1718
  } = {}) {
1832
- this.tip = bn7(tip);
1719
+ this.gasPrice = bn7(gasPrice);
1833
1720
  this.maturity = maturity ?? 0;
1834
1721
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1835
1722
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
@@ -1840,9 +1727,9 @@ var BaseTransactionRequest = class {
1840
1727
  static getPolicyMeta(req) {
1841
1728
  let policyTypes = 0;
1842
1729
  const policies = [];
1843
- if (req.tip) {
1844
- policyTypes += PolicyType.Tip;
1845
- policies.push({ data: req.tip, type: PolicyType.Tip });
1730
+ if (req.gasPrice) {
1731
+ policyTypes += PolicyType.GasPrice;
1732
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1846
1733
  }
1847
1734
  if (req.witnessLimit) {
1848
1735
  policyTypes += PolicyType.WitnessLimit;
@@ -2026,11 +1913,13 @@ var BaseTransactionRequest = class {
2026
1913
  * assetId, if one it was not added yet.
2027
1914
  *
2028
1915
  * @param coin - Coin resource.
1916
+ * @param predicate - Predicate bytes.
1917
+ * @param predicateData - Predicate data bytes.
2029
1918
  */
2030
- addCoinInput(coin) {
1919
+ addCoinInput(coin, predicate) {
2031
1920
  const { assetId, owner, amount } = coin;
2032
1921
  let witnessIndex;
2033
- if (coin.predicate) {
1922
+ if (predicate) {
2034
1923
  witnessIndex = 0;
2035
1924
  } else {
2036
1925
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2045,7 +1934,8 @@ var BaseTransactionRequest = class {
2045
1934
  amount,
2046
1935
  assetId,
2047
1936
  txPointer: "0x00000000000000000000000000000000",
2048
- witnessIndex
1937
+ witnessIndex,
1938
+ predicate: predicate?.bytes
2049
1939
  };
2050
1940
  this.pushInput(input);
2051
1941
  this.addChangeOutput(owner, assetId);
@@ -2055,12 +1945,14 @@ var BaseTransactionRequest = class {
2055
1945
  * baseAssetId, if one it was not added yet.
2056
1946
  *
2057
1947
  * @param message - Message resource.
1948
+ * @param predicate - Predicate bytes.
1949
+ * @param predicateData - Predicate data bytes.
2058
1950
  */
2059
- addMessageInput(message) {
1951
+ addMessageInput(message, predicate) {
2060
1952
  const { recipient, sender, amount } = message;
2061
1953
  const assetId = BaseAssetId2;
2062
1954
  let witnessIndex;
2063
- if (message.predicate) {
1955
+ if (predicate) {
2064
1956
  witnessIndex = 0;
2065
1957
  } else {
2066
1958
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2074,7 +1966,8 @@ var BaseTransactionRequest = class {
2074
1966
  sender: sender.toB256(),
2075
1967
  recipient: recipient.toB256(),
2076
1968
  amount,
2077
- witnessIndex
1969
+ witnessIndex,
1970
+ predicate: predicate?.bytes
2078
1971
  };
2079
1972
  this.pushInput(input);
2080
1973
  this.addChangeOutput(recipient, assetId);
@@ -2105,6 +1998,32 @@ var BaseTransactionRequest = class {
2105
1998
  resources.forEach((resource) => this.addResource(resource));
2106
1999
  return this;
2107
2000
  }
2001
+ /**
2002
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2003
+ * outputs from the related assetIds.
2004
+ *
2005
+ * @param resources - The resources to add.
2006
+ * @returns This transaction.
2007
+ */
2008
+ addPredicateResource(resource, predicate) {
2009
+ if (isCoin(resource)) {
2010
+ this.addCoinInput(resource, predicate);
2011
+ } else {
2012
+ this.addMessageInput(resource, predicate);
2013
+ }
2014
+ return this;
2015
+ }
2016
+ /**
2017
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2018
+ * from the related assetIds.
2019
+ *
2020
+ * @param resources - The resources to add.
2021
+ * @returns This transaction.
2022
+ */
2023
+ addPredicateResources(resources, predicate) {
2024
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2025
+ return this;
2026
+ }
2108
2027
  /**
2109
2028
  * Adds a coin output to the transaction.
2110
2029
  *
@@ -2184,7 +2103,7 @@ var BaseTransactionRequest = class {
2184
2103
  }
2185
2104
  calculateMaxGas(chainInfo, minGas) {
2186
2105
  const { consensusParameters } = chainInfo;
2187
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2106
+ const { gasPerByte } = consensusParameters;
2188
2107
  const witnessesLength = this.toTransaction().witnesses.reduce(
2189
2108
  (acc, wit) => acc + wit.dataLength,
2190
2109
  0
@@ -2193,8 +2112,7 @@ var BaseTransactionRequest = class {
2193
2112
  gasPerByte,
2194
2113
  minGas,
2195
2114
  witnessesLength,
2196
- witnessLimit: this.witnessLimit,
2197
- maxGasPerTx
2115
+ witnessLimit: this.witnessLimit
2198
2116
  });
2199
2117
  }
2200
2118
  /**
@@ -2212,20 +2130,17 @@ var BaseTransactionRequest = class {
2212
2130
  });
2213
2131
  const updateAssetInput = (assetId, quantity) => {
2214
2132
  const assetInput = findAssetInput(assetId);
2215
- let usedQuantity = quantity;
2216
- if (assetId === BaseAssetId2) {
2217
- usedQuantity = bn7("1000000000000000000");
2218
- }
2219
2133
  if (assetInput && "assetId" in assetInput) {
2220
2134
  assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2221
- assetInput.amount = usedQuantity;
2135
+ assetInput.amount = quantity;
2222
2136
  } else {
2223
2137
  this.addResources([
2224
2138
  {
2225
2139
  id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2226
- amount: usedQuantity,
2140
+ amount: quantity,
2227
2141
  assetId,
2228
2142
  owner: resourcesOwner || Address.fromRandom(),
2143
+ maturity: 0,
2229
2144
  blockCreated: bn7(1),
2230
2145
  txCreatedIdx: bn7(1)
2231
2146
  }
@@ -2257,7 +2172,7 @@ var BaseTransactionRequest = class {
2257
2172
  toJSON() {
2258
2173
  return normalizeJSON(this);
2259
2174
  }
2260
- updatePredicateGasUsed(inputs) {
2175
+ updatePredicateInputs(inputs) {
2261
2176
  this.inputs.forEach((i) => {
2262
2177
  let correspondingInput;
2263
2178
  switch (i.type) {
@@ -2279,15 +2194,6 @@ var BaseTransactionRequest = class {
2279
2194
  }
2280
2195
  });
2281
2196
  }
2282
- shiftPredicateData() {
2283
- this.inputs.forEach((input) => {
2284
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2285
- input.predicateData = input.paddPredicateData(
2286
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2287
- );
2288
- }
2289
- });
2290
- }
2291
2197
  };
2292
2198
 
2293
2199
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2434,8 +2340,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2434
2340
  return {
2435
2341
  type: TransactionType3.Create,
2436
2342
  ...baseTransaction,
2343
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2437
2344
  bytecodeWitnessIndex,
2438
- storageSlotsCount: bn9(storageSlots.length),
2345
+ storageSlotsCount: storageSlots.length,
2439
2346
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2440
2347
  storageSlots
2441
2348
  };
@@ -2558,8 +2465,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2558
2465
  type: TransactionType4.Script,
2559
2466
  scriptGasLimit: this.gasLimit,
2560
2467
  ...super.getBaseTransaction(),
2561
- scriptLength: bn10(script.length),
2562
- scriptDataLength: bn10(scriptData.length),
2468
+ scriptLength: script.length,
2469
+ scriptDataLength: scriptData.length,
2563
2470
  receiptsRoot: ZeroBytes327,
2564
2471
  script: hexlify10(script),
2565
2472
  scriptData: hexlify10(scriptData)
@@ -2623,7 +2530,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2623
2530
  }
2624
2531
  calculateMaxGas(chainInfo, minGas) {
2625
2532
  const { consensusParameters } = chainInfo;
2626
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2533
+ const { gasPerByte } = consensusParameters;
2627
2534
  const witnessesLength = this.toTransaction().witnesses.reduce(
2628
2535
  (acc, wit) => acc + wit.dataLength,
2629
2536
  0
@@ -2633,8 +2540,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2633
2540
  minGas,
2634
2541
  witnessesLength,
2635
2542
  witnessLimit: this.witnessLimit,
2636
- gasLimit: this.gasLimit,
2637
- maxGasPerTx
2543
+ gasLimit: this.gasLimit
2638
2544
  });
2639
2545
  }
2640
2546
  /**
@@ -2691,7 +2597,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2691
2597
 
2692
2598
  // src/providers/transaction-request/utils.ts
2693
2599
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2694
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2600
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2695
2601
  var transactionRequestify = (obj) => {
2696
2602
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2697
2603
  return obj;
@@ -2709,31 +2615,14 @@ var transactionRequestify = (obj) => {
2709
2615
  }
2710
2616
  }
2711
2617
  };
2712
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2713
- (acc, input) => {
2714
- if (input.type === InputType5.Coin && input.owner === owner) {
2715
- acc.utxos.push(input.id);
2716
- }
2717
- if (input.type === InputType5.Message && input.recipient === owner) {
2718
- acc.messages.push(input.nonce);
2719
- }
2720
- return acc;
2721
- },
2722
- {
2723
- utxos: [],
2724
- messages: []
2725
- }
2726
- );
2727
2618
 
2728
2619
  // src/providers/transaction-response/transaction-response.ts
2729
2620
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2730
- import { bn as bn15 } from "@fuel-ts/math";
2621
+ import { bn as bn14 } from "@fuel-ts/math";
2731
2622
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2732
2623
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2733
2624
 
2734
2625
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2735
- import { bn as bn14 } from "@fuel-ts/math";
2736
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2737
2626
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2738
2627
 
2739
2628
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2742,10 +2631,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2742
2631
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2743
2632
  var calculateTransactionFee = (params) => {
2744
2633
  const {
2745
- gasPrice,
2634
+ gasUsed,
2746
2635
  rawPayload,
2747
- tip,
2748
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2636
+ consensusParameters: { gasCosts, feeParams }
2749
2637
  } = params;
2750
2638
  const gasPerByte = bn11(feeParams.gasPerByte);
2751
2639
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2755,7 +2643,8 @@ var calculateTransactionFee = (params) => {
2755
2643
  return {
2756
2644
  fee: bn11(0),
2757
2645
  minFee: bn11(0),
2758
- maxFee: bn11(0)
2646
+ maxFee: bn11(0),
2647
+ feeFromGasUsed: bn11(0)
2759
2648
  };
2760
2649
  }
2761
2650
  const { type, witnesses, inputs, policies } = transaction;
@@ -2787,6 +2676,7 @@ var calculateTransactionFee = (params) => {
2787
2676
  metadataGas,
2788
2677
  txBytesSize: transactionBytes.length
2789
2678
  });
2679
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2790
2680
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2791
2681
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2792
2682
  const maxGas = getMaxGas({
@@ -2794,25 +2684,17 @@ var calculateTransactionFee = (params) => {
2794
2684
  minGas,
2795
2685
  witnessesLength,
2796
2686
  gasLimit,
2797
- witnessLimit,
2798
- maxGasPerTx
2799
- });
2800
- const minFee = calculateGasFee({
2801
- gasPrice,
2802
- gas: minGas,
2803
- priceFactor: gasPriceFactor,
2804
- tip
2805
- });
2806
- const maxFee = calculateGasFee({
2807
- gasPrice,
2808
- gas: maxGas,
2809
- priceFactor: gasPriceFactor,
2810
- tip
2687
+ witnessLimit
2811
2688
  });
2689
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2690
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2691
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2692
+ const fee = minFee.add(feeFromGasUsed);
2812
2693
  return {
2694
+ fee,
2813
2695
  minFee,
2814
2696
  maxFee,
2815
- fee: maxFee
2697
+ feeFromGasUsed
2816
2698
  };
2817
2699
  };
2818
2700
 
@@ -2868,7 +2750,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2868
2750
 
2869
2751
  // src/providers/transaction-summary/input.ts
2870
2752
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2871
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2753
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2872
2754
  function getInputsByTypes(inputs, types) {
2873
2755
  return inputs.filter((i) => types.includes(i.type));
2874
2756
  }
@@ -2876,16 +2758,16 @@ function getInputsByType(inputs, type) {
2876
2758
  return inputs.filter((i) => i.type === type);
2877
2759
  }
2878
2760
  function getInputsCoin(inputs) {
2879
- return getInputsByType(inputs, InputType6.Coin);
2761
+ return getInputsByType(inputs, InputType5.Coin);
2880
2762
  }
2881
2763
  function getInputsMessage(inputs) {
2882
- return getInputsByType(inputs, InputType6.Message);
2764
+ return getInputsByType(inputs, InputType5.Message);
2883
2765
  }
2884
2766
  function getInputsCoinAndMessage(inputs) {
2885
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2767
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2886
2768
  }
2887
2769
  function getInputsContract(inputs) {
2888
- return getInputsByType(inputs, InputType6.Contract);
2770
+ return getInputsByType(inputs, InputType5.Contract);
2889
2771
  }
2890
2772
  function getInputFromAssetId(inputs, assetId) {
2891
2773
  const coinInputs = getInputsCoin(inputs);
@@ -2904,7 +2786,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2904
2786
  if (!contractInput) {
2905
2787
  return void 0;
2906
2788
  }
2907
- if (contractInput.type !== InputType6.Contract) {
2789
+ if (contractInput.type !== InputType5.Contract) {
2908
2790
  throw new FuelError9(
2909
2791
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2910
2792
  `Contract input should be of type 'contract'.`
@@ -2913,10 +2795,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2913
2795
  return contractInput;
2914
2796
  }
2915
2797
  function getInputAccountAddress(input) {
2916
- if (input.type === InputType6.Coin) {
2798
+ if (input.type === InputType5.Coin) {
2917
2799
  return input.owner.toString();
2918
2800
  }
2919
- if (input.type === InputType6.Message) {
2801
+ if (input.type === InputType5.Message) {
2920
2802
  return input.recipient.toString();
2921
2803
  }
2922
2804
  return "";
@@ -3426,9 +3308,7 @@ function assembleTransactionSummary(params) {
3426
3308
  gqlTransactionStatus,
3427
3309
  abiMap = {},
3428
3310
  maxInputs,
3429
- gasCosts,
3430
- maxGasPerTx,
3431
- gasPrice
3311
+ gasCosts
3432
3312
  } = params;
3433
3313
  const gasUsed = getGasUsedFromReceipts(receipts);
3434
3314
  const rawPayload = hexlify11(transactionBytes);
@@ -3442,14 +3322,11 @@ function assembleTransactionSummary(params) {
3442
3322
  maxInputs
3443
3323
  });
3444
3324
  const typeName = getTransactionTypeName(transaction.type);
3445
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3446
3325
  const { fee } = calculateTransactionFee({
3447
- gasPrice,
3326
+ gasUsed,
3448
3327
  rawPayload,
3449
- tip,
3450
3328
  consensusParameters: {
3451
3329
  gasCosts,
3452
- maxGasPerTx,
3453
3330
  feeParams: {
3454
3331
  gasPerByte,
3455
3332
  gasPriceFactor
@@ -3509,7 +3386,7 @@ var TransactionResponse = class {
3509
3386
  /** Current provider */
3510
3387
  provider;
3511
3388
  /** Gas used on the transaction */
3512
- gasUsed = bn15(0);
3389
+ gasUsed = bn14(0);
3513
3390
  /** The graphql Transaction with receipts object. */
3514
3391
  gqlTransaction;
3515
3392
  abis;
@@ -3587,13 +3464,8 @@ var TransactionResponse = class {
3587
3464
  const decodedTransaction = this.decodeTransaction(
3588
3465
  transaction
3589
3466
  );
3590
- let txReceipts = [];
3591
- if (transaction?.status && "receipts" in transaction.status) {
3592
- txReceipts = transaction.status.receipts;
3593
- }
3594
- const receipts = txReceipts.map(processGqlReceipt) || [];
3595
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3596
- const gasPrice = await this.provider.getLatestGasPrice();
3467
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3468
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3597
3469
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3598
3470
  const transactionSummary = assembleTransactionSummary({
3599
3471
  id: this.id,
@@ -3605,9 +3477,7 @@ var TransactionResponse = class {
3605
3477
  gasPriceFactor,
3606
3478
  abiMap: contractsAbiMap,
3607
3479
  maxInputs,
3608
- gasCosts,
3609
- maxGasPerTx,
3610
- gasPrice
3480
+ gasCosts
3611
3481
  });
3612
3482
  return transactionSummary;
3613
3483
  }
@@ -3734,29 +3604,29 @@ var processGqlChain = (chain) => {
3734
3604
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3735
3605
  return {
3736
3606
  name,
3737
- baseChainHeight: bn16(daHeight),
3607
+ baseChainHeight: bn15(daHeight),
3738
3608
  consensusParameters: {
3739
- contractMaxSize: bn16(contractParams.contractMaxSize),
3740
- maxInputs: bn16(txParams.maxInputs),
3741
- maxOutputs: bn16(txParams.maxOutputs),
3742
- maxWitnesses: bn16(txParams.maxWitnesses),
3743
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3744
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3745
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3746
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3747
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3748
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3749
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3750
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3751
- gasPerByte: bn16(feeParams.gasPerByte),
3752
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3753
- chainId: bn16(consensusParameters.chainId),
3609
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3610
+ maxInputs: bn15(txParams.maxInputs),
3611
+ maxOutputs: bn15(txParams.maxOutputs),
3612
+ maxWitnesses: bn15(txParams.maxWitnesses),
3613
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3614
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3615
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3616
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3617
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3618
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3619
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3620
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3621
+ gasPerByte: bn15(feeParams.gasPerByte),
3622
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3623
+ chainId: bn15(consensusParameters.chainId),
3754
3624
  gasCosts
3755
3625
  },
3756
3626
  gasCosts,
3757
3627
  latestBlock: {
3758
3628
  id: latestBlock.id,
3759
- height: bn16(latestBlock.height),
3629
+ height: bn15(latestBlock.header.height),
3760
3630
  time: latestBlock.header.time,
3761
3631
  transactions: latestBlock.transactions.map((i) => ({
3762
3632
  id: i.id
@@ -3850,8 +3720,10 @@ var _Provider = class {
3850
3720
  * Returns some helpful parameters related to gas fees.
3851
3721
  */
3852
3722
  getGasConfig() {
3723
+ const { minGasPrice } = this.getNode();
3853
3724
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3854
3725
  return {
3726
+ minGasPrice,
3855
3727
  maxGasPerTx,
3856
3728
  maxGasPerPredicate,
3857
3729
  gasPriceFactor,
@@ -3949,7 +3821,7 @@ var _Provider = class {
3949
3821
  */
3950
3822
  async getBlockNumber() {
3951
3823
  const { chain } = await this.operations.getChain();
3952
- return bn16(chain.latestBlock.height, 10);
3824
+ return bn15(chain.latestBlock.header.height, 10);
3953
3825
  }
3954
3826
  /**
3955
3827
  * Returns the chain information.
@@ -3959,11 +3831,13 @@ var _Provider = class {
3959
3831
  async fetchNode() {
3960
3832
  const { nodeInfo } = await this.operations.getNodeInfo();
3961
3833
  const processedNodeInfo = {
3962
- maxDepth: bn16(nodeInfo.maxDepth),
3963
- maxTx: bn16(nodeInfo.maxTx),
3834
+ maxDepth: bn15(nodeInfo.maxDepth),
3835
+ maxTx: bn15(nodeInfo.maxTx),
3836
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3964
3837
  nodeVersion: nodeInfo.nodeVersion,
3965
3838
  utxoValidation: nodeInfo.utxoValidation,
3966
- vmBacktrace: nodeInfo.vmBacktrace
3839
+ vmBacktrace: nodeInfo.vmBacktrace,
3840
+ peers: nodeInfo.peers
3967
3841
  };
3968
3842
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3969
3843
  return processedNodeInfo;
@@ -4049,13 +3923,14 @@ var _Provider = class {
4049
3923
  return this.estimateTxDependencies(transactionRequest);
4050
3924
  }
4051
3925
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4052
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4053
- encodedTransactions: encodedTransaction,
3926
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3927
+ encodedTransaction,
4054
3928
  utxoValidation: utxoValidation || false
4055
3929
  });
4056
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4057
- const receipts = rawReceipts.map(processGqlReceipt);
4058
- return { receipts, dryrunStatus: status };
3930
+ const receipts = gqlReceipts.map(processGqlReceipt);
3931
+ return {
3932
+ receipts
3933
+ };
4059
3934
  }
4060
3935
  /**
4061
3936
  * Verifies whether enough gas is available to complete transaction.
@@ -4081,7 +3956,7 @@ var _Provider = class {
4081
3956
  } = response;
4082
3957
  if (inputs) {
4083
3958
  inputs.forEach((input, index) => {
4084
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3959
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
4085
3960
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4086
3961
  }
4087
3962
  });
@@ -4094,6 +3969,9 @@ var _Provider = class {
4094
3969
  * If there are missing variable outputs,
4095
3970
  * `addVariableOutputs` is called on the transaction.
4096
3971
  *
3972
+ * @privateRemarks
3973
+ * TODO: Investigate support for missing contract IDs
3974
+ * TODO: Add support for missing output messages
4097
3975
  *
4098
3976
  * @param transactionRequest - The transaction request object.
4099
3977
  * @returns A promise.
@@ -4106,19 +3984,16 @@ var _Provider = class {
4106
3984
  missingContractIds: []
4107
3985
  };
4108
3986
  }
3987
+ await this.estimatePredicates(transactionRequest);
4109
3988
  let receipts = [];
4110
3989
  const missingContractIds = [];
4111
3990
  let outputVariables = 0;
4112
- let dryrunStatus;
4113
3991
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4114
- const {
4115
- dryRun: [{ receipts: rawReceipts, status }]
4116
- } = await this.operations.dryRun({
4117
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3992
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3993
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
4118
3994
  utxoValidation: false
4119
3995
  });
4120
- receipts = rawReceipts.map(processGqlReceipt);
4121
- dryrunStatus = status;
3996
+ receipts = gqlReceipts.map(processGqlReceipt);
4122
3997
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4123
3998
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4124
3999
  if (hasMissingOutputs) {
@@ -4128,10 +4003,6 @@ var _Provider = class {
4128
4003
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
4129
4004
  missingContractIds.push(contractId);
4130
4005
  });
4131
- const { maxFee } = await this.estimateTxGasAndFee({
4132
- transactionRequest
4133
- });
4134
- transactionRequest.maxFee = maxFee;
4135
4006
  } else {
4136
4007
  break;
4137
4008
  }
@@ -4139,139 +4010,37 @@ var _Provider = class {
4139
4010
  return {
4140
4011
  receipts,
4141
4012
  outputVariables,
4142
- missingContractIds,
4143
- dryrunStatus
4013
+ missingContractIds
4144
4014
  };
4145
4015
  }
4146
- /**
4147
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4148
- *
4149
- * Transactions are dry run in batches. After each dry run, transactions requiring
4150
- * further modifications are identified. The method iteratively updates these transactions
4151
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4152
- *
4153
- * @param transactionRequests - Array of transaction request objects.
4154
- * @returns A promise that resolves to an array of results for each transaction.
4155
- */
4156
- async estimateMultipleTxDependencies(transactionRequests) {
4157
- const results = transactionRequests.map(() => ({
4158
- receipts: [],
4159
- outputVariables: 0,
4160
- missingContractIds: [],
4161
- dryrunStatus: void 0
4162
- }));
4163
- const allRequests = clone3(transactionRequests);
4164
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4165
- allRequests.forEach((req, index) => {
4166
- if (req.type === TransactionType8.Script) {
4167
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4168
- }
4169
- });
4170
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4171
- let attempt = 0;
4172
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4173
- const encodedTransactions = transactionsToProcess.map(
4174
- (index) => serializedTransactionsMap.get(index)
4175
- );
4176
- const dryRunResults = await this.operations.dryRun({
4177
- encodedTransactions,
4178
- utxoValidation: false
4179
- });
4180
- const nextRoundTransactions = [];
4181
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4182
- const currentResultIndex = transactionsToProcess[i];
4183
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4184
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4185
- results[currentResultIndex].dryrunStatus = status;
4186
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4187
- results[currentResultIndex].receipts
4188
- );
4189
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4190
- const requestToProcess = allRequests[currentResultIndex];
4191
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4192
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4193
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4194
- missingOutputContractIds.forEach(({ contractId }) => {
4195
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4196
- results[currentResultIndex].missingContractIds.push(contractId);
4197
- });
4198
- const { maxFee } = await this.estimateTxGasAndFee({
4199
- transactionRequest: requestToProcess
4200
- });
4201
- requestToProcess.maxFee = maxFee;
4202
- serializedTransactionsMap.set(
4203
- currentResultIndex,
4204
- hexlify12(requestToProcess.toTransactionBytes())
4205
- );
4206
- nextRoundTransactions.push(currentResultIndex);
4207
- allRequests[currentResultIndex] = requestToProcess;
4208
- }
4209
- }
4210
- transactionsToProcess = nextRoundTransactions;
4211
- attempt += 1;
4212
- }
4213
- return results;
4214
- }
4215
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4216
- if (estimateTxDependencies) {
4217
- return this.estimateMultipleTxDependencies(transactionRequests);
4218
- }
4219
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4220
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4221
- encodedTransactions,
4222
- utxoValidation: utxoValidation || false
4223
- });
4224
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4225
- const receipts = rawReceipts.map(processGqlReceipt);
4226
- return { receipts, dryrunStatus: status };
4227
- });
4228
- return results;
4229
- }
4230
4016
  /**
4231
4017
  * Estimates the transaction gas and fee based on the provided transaction request.
4232
4018
  * @param transactionRequest - The transaction request object.
4233
4019
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4234
4020
  */
4235
- async estimateTxGasAndFee(params) {
4021
+ estimateTxGasAndFee(params) {
4236
4022
  const { transactionRequest } = params;
4237
- let { gasPrice } = params;
4023
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4238
4024
  const chainInfo = this.getChain();
4239
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4025
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4026
+ transactionRequest.gasPrice = gasPrice;
4240
4027
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4241
- if (!gasPrice) {
4242
- gasPrice = await this.estimateGasPrice(10);
4243
- }
4244
- const minFee = calculateGasFee({
4245
- gasPrice: bn16(gasPrice),
4246
- gas: minGas,
4247
- priceFactor: gasPriceFactor,
4248
- tip: transactionRequest.tip
4249
- }).add(1);
4250
- let gasLimit = bn16(0);
4028
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4251
4029
  if (transactionRequest.type === TransactionType8.Script) {
4252
- gasLimit = transactionRequest.gasLimit;
4253
4030
  if (transactionRequest.gasLimit.eq(0)) {
4254
4031
  transactionRequest.gasLimit = minGas;
4255
4032
  transactionRequest.gasLimit = maxGasPerTx.sub(
4256
4033
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4257
4034
  );
4258
- gasLimit = transactionRequest.gasLimit;
4259
4035
  }
4260
4036
  }
4261
4037
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4262
- const maxFee = calculateGasFee({
4263
- gasPrice: bn16(gasPrice),
4264
- gas: maxGas,
4265
- priceFactor: gasPriceFactor,
4266
- tip: transactionRequest.tip
4267
- }).add(1);
4038
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4268
4039
  return {
4269
4040
  minGas,
4270
4041
  minFee,
4271
4042
  maxGas,
4272
- maxFee,
4273
- gasPrice,
4274
- gasLimit
4043
+ maxFee
4275
4044
  };
4276
4045
  }
4277
4046
  /**
@@ -4289,17 +4058,15 @@ var _Provider = class {
4289
4058
  if (estimateTxDependencies) {
4290
4059
  return this.estimateTxDependencies(transactionRequest);
4291
4060
  }
4292
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4293
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4294
- encodedTransactions,
4061
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4062
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4063
+ encodedTransaction,
4295
4064
  utxoValidation: true
4296
4065
  });
4297
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4298
- const { id, receipts, status } = dryRunStatus;
4299
- const processedReceipts = receipts.map(processGqlReceipt);
4300
- return { id, receipts: processedReceipts, status };
4301
- });
4302
- return { receipts: callResult[0].receipts };
4066
+ const receipts = gqlReceipts.map(processGqlReceipt);
4067
+ return {
4068
+ receipts
4069
+ };
4303
4070
  }
4304
4071
  /**
4305
4072
  * Returns a transaction cost to enable user
@@ -4316,79 +4083,77 @@ var _Provider = class {
4316
4083
  * @param tolerance - The tolerance to add on top of the gasUsed.
4317
4084
  * @returns A promise that resolves to the transaction cost object.
4318
4085
  */
4319
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4086
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4087
+ estimateTxDependencies = true,
4088
+ estimatePredicates = true,
4089
+ resourcesOwner,
4090
+ signatureCallback
4091
+ } = {}) {
4320
4092
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4093
+ const { minGasPrice } = this.getGasConfig();
4094
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4321
4095
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4322
4096
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4323
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4097
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4324
4098
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4325
- txRequestClone.maxFee = bn16(0);
4326
4099
  if (isScriptTransaction) {
4327
- txRequestClone.gasLimit = bn16(0);
4100
+ txRequestClone.gasLimit = bn15(0);
4328
4101
  }
4329
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4330
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4102
+ if (estimatePredicates) {
4103
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4104
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4105
+ }
4106
+ await this.estimatePredicates(txRequestClone);
4331
4107
  }
4332
- const signedRequest = clone3(txRequestClone);
4333
- let addedSignatures = 0;
4334
4108
  if (signatureCallback && isScriptTransaction) {
4335
- const lengthBefore = signedRequest.witnesses.length;
4336
- await signatureCallback(signedRequest);
4337
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4109
+ await signatureCallback(txRequestClone);
4338
4110
  }
4339
- await this.estimatePredicates(signedRequest);
4340
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4341
- transactionRequest: signedRequest
4111
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4112
+ transactionRequest: txRequestClone
4342
4113
  });
4343
4114
  let receipts = [];
4344
4115
  let missingContractIds = [];
4345
4116
  let outputVariables = 0;
4346
- let gasUsed = bn16(0);
4347
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4348
- txRequestClone.maxFee = maxFee;
4349
- if (isScriptTransaction) {
4350
- txRequestClone.gasLimit = gasLimit;
4351
- if (signatureCallback) {
4352
- await signatureCallback(txRequestClone);
4353
- }
4117
+ let gasUsed = bn15(0);
4118
+ if (isScriptTransaction && estimateTxDependencies) {
4119
+ txRequestClone.gasPrice = bn15(0);
4354
4120
  const result = await this.estimateTxDependencies(txRequestClone);
4355
4121
  receipts = result.receipts;
4356
4122
  outputVariables = result.outputVariables;
4357
4123
  missingContractIds = result.missingContractIds;
4358
4124
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4359
4125
  txRequestClone.gasLimit = gasUsed;
4360
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4361
- transactionRequest: txRequestClone,
4362
- gasPrice
4126
+ txRequestClone.gasPrice = setGasPrice;
4127
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4128
+ transactionRequest: txRequestClone
4363
4129
  }));
4364
4130
  }
4365
4131
  return {
4366
4132
  requiredQuantities: allQuantities,
4367
4133
  receipts,
4368
4134
  gasUsed,
4369
- gasPrice,
4135
+ minGasPrice,
4136
+ gasPrice: setGasPrice,
4370
4137
  minGas,
4371
4138
  maxGas,
4372
4139
  minFee,
4373
4140
  maxFee,
4141
+ estimatedInputs: txRequestClone.inputs,
4374
4142
  outputVariables,
4375
- missingContractIds,
4376
- addedSignatures,
4377
- estimatedPredicates: txRequestClone.inputs
4143
+ missingContractIds
4378
4144
  };
4379
4145
  }
4380
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4146
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4381
4147
  const ownerAddress = Address2.fromAddressOrString(owner);
4382
4148
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4383
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4384
- quantitiesToContract
4385
- });
4149
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4386
4150
  transactionRequest.addResources(
4387
4151
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4388
4152
  );
4389
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4390
- quantitiesToContract
4391
- });
4153
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4154
+ transactionRequest,
4155
+ forwardingQuantities
4156
+ );
4392
4157
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4393
4158
  return {
4394
4159
  resources,
@@ -4410,10 +4175,11 @@ var _Provider = class {
4410
4175
  return coins.map((coin) => ({
4411
4176
  id: coin.utxoId,
4412
4177
  assetId: coin.assetId,
4413
- amount: bn16(coin.amount),
4178
+ amount: bn15(coin.amount),
4414
4179
  owner: Address2.fromAddressOrString(coin.owner),
4415
- blockCreated: bn16(coin.blockCreated),
4416
- txCreatedIdx: bn16(coin.txCreatedIdx)
4180
+ maturity: bn15(coin.maturity).toNumber(),
4181
+ blockCreated: bn15(coin.blockCreated),
4182
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4417
4183
  }));
4418
4184
  }
4419
4185
  /**
@@ -4450,9 +4216,9 @@ var _Provider = class {
4450
4216
  switch (coin.__typename) {
4451
4217
  case "MessageCoin":
4452
4218
  return {
4453
- amount: bn16(coin.amount),
4219
+ amount: bn15(coin.amount),
4454
4220
  assetId: coin.assetId,
4455
- daHeight: bn16(coin.daHeight),
4221
+ daHeight: bn15(coin.daHeight),
4456
4222
  sender: Address2.fromAddressOrString(coin.sender),
4457
4223
  recipient: Address2.fromAddressOrString(coin.recipient),
4458
4224
  nonce: coin.nonce
@@ -4460,11 +4226,12 @@ var _Provider = class {
4460
4226
  case "Coin":
4461
4227
  return {
4462
4228
  id: coin.utxoId,
4463
- amount: bn16(coin.amount),
4229
+ amount: bn15(coin.amount),
4464
4230
  assetId: coin.assetId,
4465
4231
  owner: Address2.fromAddressOrString(coin.owner),
4466
- blockCreated: bn16(coin.blockCreated),
4467
- txCreatedIdx: bn16(coin.txCreatedIdx)
4232
+ maturity: bn15(coin.maturity).toNumber(),
4233
+ blockCreated: bn15(coin.blockCreated),
4234
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4468
4235
  };
4469
4236
  default:
4470
4237
  return null;
@@ -4481,13 +4248,13 @@ var _Provider = class {
4481
4248
  async getBlock(idOrHeight) {
4482
4249
  let variables;
4483
4250
  if (typeof idOrHeight === "number") {
4484
- variables = { height: bn16(idOrHeight).toString(10) };
4251
+ variables = { height: bn15(idOrHeight).toString(10) };
4485
4252
  } else if (idOrHeight === "latest") {
4486
4253
  variables = { height: (await this.getBlockNumber()).toString(10) };
4487
4254
  } else if (idOrHeight.length === 66) {
4488
4255
  variables = { blockId: idOrHeight };
4489
4256
  } else {
4490
- variables = { blockId: bn16(idOrHeight).toString(10) };
4257
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4491
4258
  }
4492
4259
  const { block } = await this.operations.getBlock(variables);
4493
4260
  if (!block) {
@@ -4495,7 +4262,7 @@ var _Provider = class {
4495
4262
  }
4496
4263
  return {
4497
4264
  id: block.id,
4498
- height: bn16(block.height),
4265
+ height: bn15(block.header.height),
4499
4266
  time: block.header.time,
4500
4267
  transactionIds: block.transactions.map((tx) => tx.id)
4501
4268
  };
@@ -4510,7 +4277,7 @@ var _Provider = class {
4510
4277
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4511
4278
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4512
4279
  id: block.id,
4513
- height: bn16(block.height),
4280
+ height: bn15(block.header.height),
4514
4281
  time: block.header.time,
4515
4282
  transactionIds: block.transactions.map((tx) => tx.id)
4516
4283
  }));
@@ -4525,7 +4292,7 @@ var _Provider = class {
4525
4292
  async getBlockWithTransactions(idOrHeight) {
4526
4293
  let variables;
4527
4294
  if (typeof idOrHeight === "number") {
4528
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4295
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4529
4296
  } else if (idOrHeight === "latest") {
4530
4297
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4531
4298
  } else {
@@ -4537,7 +4304,7 @@ var _Provider = class {
4537
4304
  }
4538
4305
  return {
4539
4306
  id: block.id,
4540
- height: bn16(block.height, 10),
4307
+ height: bn15(block.header.height, 10),
4541
4308
  time: block.header.time,
4542
4309
  transactionIds: block.transactions.map((tx) => tx.id),
4543
4310
  transactions: block.transactions.map(
@@ -4586,7 +4353,7 @@ var _Provider = class {
4586
4353
  contract: Address2.fromAddressOrString(contractId).toB256(),
4587
4354
  asset: hexlify12(assetId)
4588
4355
  });
4589
- return bn16(contractBalance.amount, 10);
4356
+ return bn15(contractBalance.amount, 10);
4590
4357
  }
4591
4358
  /**
4592
4359
  * Returns the balance for the given owner for the given asset ID.
@@ -4600,7 +4367,7 @@ var _Provider = class {
4600
4367
  owner: Address2.fromAddressOrString(owner).toB256(),
4601
4368
  assetId: hexlify12(assetId)
4602
4369
  });
4603
- return bn16(balance.amount, 10);
4370
+ return bn15(balance.amount, 10);
4604
4371
  }
4605
4372
  /**
4606
4373
  * Returns balances for the given owner.
@@ -4618,7 +4385,7 @@ var _Provider = class {
4618
4385
  const balances = result.balances.edges.map((edge) => edge.node);
4619
4386
  return balances.map((balance) => ({
4620
4387
  assetId: balance.assetId,
4621
- amount: bn16(balance.amount)
4388
+ amount: bn15(balance.amount)
4622
4389
  }));
4623
4390
  }
4624
4391
  /**
@@ -4640,15 +4407,15 @@ var _Provider = class {
4640
4407
  sender: message.sender,
4641
4408
  recipient: message.recipient,
4642
4409
  nonce: message.nonce,
4643
- amount: bn16(message.amount),
4410
+ amount: bn15(message.amount),
4644
4411
  data: message.data
4645
4412
  }),
4646
4413
  sender: Address2.fromAddressOrString(message.sender),
4647
4414
  recipient: Address2.fromAddressOrString(message.recipient),
4648
4415
  nonce: message.nonce,
4649
- amount: bn16(message.amount),
4416
+ amount: bn15(message.amount),
4650
4417
  data: InputMessageCoder.decodeData(message.data),
4651
- daHeight: bn16(message.daHeight)
4418
+ daHeight: bn15(message.daHeight)
4652
4419
  }));
4653
4420
  }
4654
4421
  /**
@@ -4701,60 +4468,44 @@ var _Provider = class {
4701
4468
  } = result.messageProof;
4702
4469
  return {
4703
4470
  messageProof: {
4704
- proofIndex: bn16(messageProof.proofIndex),
4471
+ proofIndex: bn15(messageProof.proofIndex),
4705
4472
  proofSet: messageProof.proofSet
4706
4473
  },
4707
4474
  blockProof: {
4708
- proofIndex: bn16(blockProof.proofIndex),
4475
+ proofIndex: bn15(blockProof.proofIndex),
4709
4476
  proofSet: blockProof.proofSet
4710
4477
  },
4711
4478
  messageBlockHeader: {
4712
4479
  id: messageBlockHeader.id,
4713
- daHeight: bn16(messageBlockHeader.daHeight),
4714
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4480
+ daHeight: bn15(messageBlockHeader.daHeight),
4481
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4715
4482
  transactionsRoot: messageBlockHeader.transactionsRoot,
4716
- height: bn16(messageBlockHeader.height),
4483
+ height: bn15(messageBlockHeader.height),
4717
4484
  prevRoot: messageBlockHeader.prevRoot,
4718
4485
  time: messageBlockHeader.time,
4719
4486
  applicationHash: messageBlockHeader.applicationHash,
4720
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4721
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4722
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4723
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4724
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4487
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4488
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4725
4489
  },
4726
4490
  commitBlockHeader: {
4727
4491
  id: commitBlockHeader.id,
4728
- daHeight: bn16(commitBlockHeader.daHeight),
4729
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4492
+ daHeight: bn15(commitBlockHeader.daHeight),
4493
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4730
4494
  transactionsRoot: commitBlockHeader.transactionsRoot,
4731
- height: bn16(commitBlockHeader.height),
4495
+ height: bn15(commitBlockHeader.height),
4732
4496
  prevRoot: commitBlockHeader.prevRoot,
4733
4497
  time: commitBlockHeader.time,
4734
4498
  applicationHash: commitBlockHeader.applicationHash,
4735
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4736
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4737
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4738
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4739
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4499
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4500
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4740
4501
  },
4741
4502
  sender: Address2.fromAddressOrString(sender),
4742
4503
  recipient: Address2.fromAddressOrString(recipient),
4743
4504
  nonce,
4744
- amount: bn16(amount),
4505
+ amount: bn15(amount),
4745
4506
  data
4746
4507
  };
4747
4508
  }
4748
- async getLatestGasPrice() {
4749
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4750
- return bn16(latestGasPrice.gasPrice);
4751
- }
4752
- async estimateGasPrice(blockHorizon) {
4753
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4754
- blockHorizon: String(blockHorizon)
4755
- });
4756
- return bn16(estimateGasPrice.gasPrice);
4757
- }
4758
4509
  /**
4759
4510
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4760
4511
  *
@@ -4774,10 +4525,10 @@ var _Provider = class {
4774
4525
  */
4775
4526
  async produceBlocks(amount, startTime) {
4776
4527
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4777
- blocksToProduce: bn16(amount).toString(10),
4528
+ blocksToProduce: bn15(amount).toString(10),
4778
4529
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4779
4530
  });
4780
- return bn16(latestBlockHeight);
4531
+ return bn15(latestBlockHeight);
4781
4532
  }
4782
4533
  // eslint-disable-next-line @typescript-eslint/require-await
4783
4534
  async getTransactionResponse(transactionId) {
@@ -4791,7 +4542,7 @@ cacheInputs_fn = function(inputs) {
4791
4542
  return;
4792
4543
  }
4793
4544
  inputs.forEach((input) => {
4794
- if (input.type === InputType7.Coin) {
4545
+ if (input.type === InputType6.Coin) {
4795
4546
  this.cache?.set(input.id);
4796
4547
  }
4797
4548
  });
@@ -4801,7 +4552,7 @@ __publicField(Provider, "nodeInfoCache", {});
4801
4552
 
4802
4553
  // src/providers/transaction-summary/get-transaction-summary.ts
4803
4554
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4804
- import { bn as bn17 } from "@fuel-ts/math";
4555
+ import { bn as bn16 } from "@fuel-ts/math";
4805
4556
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4806
4557
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4807
4558
  async function getTransactionSummary(params) {
@@ -4819,28 +4570,21 @@ async function getTransactionSummary(params) {
4819
4570
  arrayify12(gqlTransaction.rawPayload),
4820
4571
  0
4821
4572
  );
4822
- let txReceipts = [];
4823
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4824
- txReceipts = gqlTransaction.status.receipts;
4825
- }
4826
- const receipts = txReceipts.map(processGqlReceipt);
4573
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4827
4574
  const {
4828
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4575
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4829
4576
  } = provider.getChain();
4830
- const gasPrice = await provider.getLatestGasPrice();
4831
4577
  const transactionInfo = assembleTransactionSummary({
4832
4578
  id: gqlTransaction.id,
4833
4579
  receipts,
4834
4580
  transaction: decodedTransaction,
4835
4581
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4836
4582
  gqlTransactionStatus: gqlTransaction.status,
4837
- gasPerByte: bn17(gasPerByte),
4838
- gasPriceFactor: bn17(gasPriceFactor),
4583
+ gasPerByte: bn16(gasPerByte),
4584
+ gasPriceFactor: bn16(gasPriceFactor),
4839
4585
  abiMap,
4840
4586
  maxInputs,
4841
- gasCosts,
4842
- maxGasPerTx,
4843
- gasPrice
4587
+ gasCosts
4844
4588
  });
4845
4589
  return {
4846
4590
  gqlTransaction,
@@ -4850,11 +4594,10 @@ async function getTransactionSummary(params) {
4850
4594
  async function getTransactionSummaryFromRequest(params) {
4851
4595
  const { provider, transactionRequest, abiMap } = params;
4852
4596
  const { receipts } = await provider.call(transactionRequest);
4853
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4597
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4854
4598
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4855
4599
  const transaction = transactionRequest.toTransaction();
4856
4600
  const transactionBytes = transactionRequest.toTransactionBytes();
4857
- const gasPrice = await provider.getLatestGasPrice();
4858
4601
  const transactionSummary = assembleTransactionSummary({
4859
4602
  receipts,
4860
4603
  transaction,
@@ -4863,9 +4606,7 @@ async function getTransactionSummaryFromRequest(params) {
4863
4606
  gasPerByte,
4864
4607
  gasPriceFactor,
4865
4608
  maxInputs,
4866
- gasCosts,
4867
- maxGasPerTx,
4868
- gasPrice
4609
+ gasCosts
4869
4610
  });
4870
4611
  return transactionSummary;
4871
4612
  }
@@ -4874,18 +4615,13 @@ async function getTransactionsSummaries(params) {
4874
4615
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4875
4616
  const { edges, pageInfo } = transactionsByOwner;
4876
4617
  const {
4877
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4618
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4878
4619
  } = provider.getChain();
4879
- const gasPrice = await provider.getLatestGasPrice();
4880
4620
  const transactions = edges.map((edge) => {
4881
4621
  const { node: gqlTransaction } = edge;
4882
- const { id, rawPayload, status } = gqlTransaction;
4622
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4883
4623
  const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
4884
- let txReceipts = [];
4885
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4886
- txReceipts = gqlTransaction.status.receipts;
4887
- }
4888
- const receipts = txReceipts.map(processGqlReceipt);
4624
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4889
4625
  const transactionSummary = assembleTransactionSummary({
4890
4626
  id,
4891
4627
  receipts,
@@ -4896,9 +4632,7 @@ async function getTransactionsSummaries(params) {
4896
4632
  gasPerByte,
4897
4633
  gasPriceFactor,
4898
4634
  maxInputs,
4899
- gasCosts,
4900
- maxGasPerTx,
4901
- gasPrice
4635
+ gasCosts
4902
4636
  });
4903
4637
  const output = {
4904
4638
  gqlTransaction,
@@ -5230,33 +4964,36 @@ var Account = class extends AbstractAccount {
5230
4964
  * @param fee - The estimated transaction fee.
5231
4965
  * @returns A promise that resolves when the resources are added to the transaction.
5232
4966
  */
5233
- async fund(request, params) {
5234
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5235
- const txRequest = request;
5236
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5237
- amount: bn18(fee),
4967
+ async fund(request, coinQuantities, fee) {
4968
+ const updatedQuantities = addAmountToAsset({
4969
+ amount: bn17(fee),
5238
4970
  assetId: BaseAssetId3,
5239
- coinQuantities: requiredQuantities
4971
+ coinQuantities
5240
4972
  });
5241
4973
  const quantitiesDict = {};
5242
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4974
+ updatedQuantities.forEach(({ amount, assetId }) => {
5243
4975
  quantitiesDict[assetId] = {
5244
4976
  required: amount,
5245
- owned: bn18(0)
4977
+ owned: bn17(0)
5246
4978
  };
5247
4979
  });
5248
- txRequest.inputs.forEach((input) => {
4980
+ const cachedUtxos = [];
4981
+ const cachedMessages = [];
4982
+ const owner = this.address.toB256();
4983
+ request.inputs.forEach((input) => {
5249
4984
  const isResource = "amount" in input;
5250
4985
  if (isResource) {
5251
4986
  const isCoin2 = "owner" in input;
5252
4987
  if (isCoin2) {
5253
4988
  const assetId = String(input.assetId);
5254
- if (quantitiesDict[assetId]) {
5255
- const amount = bn18(input.amount);
4989
+ if (input.owner === owner && quantitiesDict[assetId]) {
4990
+ const amount = bn17(input.amount);
5256
4991
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4992
+ cachedUtxos.push(input.id);
5257
4993
  }
5258
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4994
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
5259
4995
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4996
+ cachedMessages.push(input.nonce);
5260
4997
  }
5261
4998
  }
5262
4999
  });
@@ -5271,23 +5008,12 @@ var Account = class extends AbstractAccount {
5271
5008
  });
5272
5009
  const needsToBeFunded = missingQuantities.length;
5273
5010
  if (needsToBeFunded) {
5274
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5275
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5276
- txRequest.addResources(resources);
5277
- }
5278
- txRequest.shiftPredicateData();
5279
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5280
- const requestToBeReEstimate = clone4(txRequest);
5281
- if (addedSignatures) {
5282
- Array.from({ length: addedSignatures }).forEach(
5283
- () => requestToBeReEstimate.addEmptyWitness()
5284
- );
5011
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5012
+ messages: cachedMessages,
5013
+ utxos: cachedUtxos
5014
+ });
5015
+ request.addResources(resources);
5285
5016
  }
5286
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5287
- transactionRequest: requestToBeReEstimate
5288
- });
5289
- txRequest.maxFee = maxFee;
5290
- return txRequest;
5291
5017
  }
5292
5018
  /**
5293
5019
  * A helper that creates a transfer transaction request and returns it.
@@ -5295,25 +5021,28 @@ var Account = class extends AbstractAccount {
5295
5021
  * @param destination - The address of the destination.
5296
5022
  * @param amount - The amount of coins to transfer.
5297
5023
  * @param assetId - The asset ID of the coins to transfer.
5298
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5024
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5299
5025
  * @returns A promise that resolves to the prepared transaction request.
5300
5026
  */
5301
5027
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5302
- const request = new ScriptTransactionRequest(txParams);
5028
+ const { minGasPrice } = this.provider.getGasConfig();
5029
+ const params = { gasPrice: minGasPrice, ...txParams };
5030
+ const request = new ScriptTransactionRequest(params);
5303
5031
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5304
- const txCost = await this.provider.getTransactionCost(request, {
5032
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5305
5033
  estimateTxDependencies: true,
5306
5034
  resourcesOwner: this
5307
5035
  });
5308
- if ("gasLimit" in txParams) {
5309
- this.validateGas({
5310
- gasUsed: txCost.gasUsed,
5311
- gasLimit: request.gasLimit
5312
- });
5313
- }
5314
- request.gasLimit = txCost.gasUsed;
5315
- request.maxFee = txCost.maxFee;
5316
- await this.fund(request, txCost);
5036
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5037
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
5038
+ this.validateGas({
5039
+ gasUsed,
5040
+ gasPrice: request.gasPrice,
5041
+ gasLimit: request.gasLimit,
5042
+ minGasPrice
5043
+ });
5044
+ await this.fund(request, requiredQuantities, maxFee);
5045
+ request.updatePredicateInputs(estimatedInputs);
5317
5046
  return request;
5318
5047
  }
5319
5048
  /**
@@ -5326,7 +5055,7 @@ var Account = class extends AbstractAccount {
5326
5055
  * @returns A promise that resolves to the transaction response.
5327
5056
  */
5328
5057
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5329
- if (bn18(amount).lte(0)) {
5058
+ if (bn17(amount).lte(0)) {
5330
5059
  throw new FuelError15(
5331
5060
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5332
5061
  "Transfer amount must be a positive number."
@@ -5345,37 +5074,38 @@ var Account = class extends AbstractAccount {
5345
5074
  * @returns A promise that resolves to the transaction response.
5346
5075
  */
5347
5076
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5348
- if (bn18(amount).lte(0)) {
5077
+ if (bn17(amount).lte(0)) {
5349
5078
  throw new FuelError15(
5350
5079
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5351
5080
  "Transfer amount must be a positive number."
5352
5081
  );
5353
5082
  }
5354
5083
  const contractAddress = Address3.fromAddressOrString(contractId);
5084
+ const { minGasPrice } = this.provider.getGasConfig();
5085
+ const params = { gasPrice: minGasPrice, ...txParams };
5355
5086
  const { script, scriptData } = await assembleTransferToContractScript({
5356
5087
  hexlifiedContractId: contractAddress.toB256(),
5357
- amountToTransfer: bn18(amount),
5088
+ amountToTransfer: bn17(amount),
5358
5089
  assetId
5359
5090
  });
5360
5091
  const request = new ScriptTransactionRequest({
5361
- ...txParams,
5092
+ ...params,
5362
5093
  script,
5363
5094
  scriptData
5364
5095
  });
5365
5096
  request.addContractInputAndOutput(contractAddress);
5366
- const txCost = await this.provider.getTransactionCost(request, {
5367
- resourcesOwner: this,
5368
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
5097
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5098
+ request,
5099
+ [{ amount: bn17(amount), assetId: String(assetId) }]
5100
+ );
5101
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5102
+ this.validateGas({
5103
+ gasUsed,
5104
+ gasPrice: request.gasPrice,
5105
+ gasLimit: request.gasLimit,
5106
+ minGasPrice
5369
5107
  });
5370
- if (txParams.gasLimit) {
5371
- this.validateGas({
5372
- gasUsed: txCost.gasUsed,
5373
- gasLimit: request.gasLimit
5374
- });
5375
- }
5376
- request.gasLimit = txCost.gasUsed;
5377
- request.maxFee = txCost.maxFee;
5378
- await this.fund(request, txCost);
5108
+ await this.fund(request, requiredQuantities, maxFee);
5379
5109
  return this.sendTransaction(request);
5380
5110
  }
5381
5111
  /**
@@ -5387,31 +5117,34 @@ var Account = class extends AbstractAccount {
5387
5117
  * @returns A promise that resolves to the transaction response.
5388
5118
  */
5389
5119
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5120
+ const { minGasPrice } = this.provider.getGasConfig();
5390
5121
  const recipientAddress = Address3.fromAddressOrString(recipient);
5391
5122
  const recipientDataArray = arrayify14(
5392
5123
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5393
5124
  );
5394
5125
  const amountDataArray = arrayify14(
5395
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
5126
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5396
5127
  );
5397
5128
  const script = new Uint8Array([
5398
5129
  ...arrayify14(withdrawScript.bytes),
5399
5130
  ...recipientDataArray,
5400
5131
  ...amountDataArray
5401
5132
  ]);
5402
- const params = { script, ...txParams };
5133
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5403
5134
  const request = new ScriptTransactionRequest(params);
5404
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5405
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5406
- if (txParams.gasLimit) {
5407
- this.validateGas({
5408
- gasUsed: txCost.gasUsed,
5409
- gasLimit: request.gasLimit
5410
- });
5411
- }
5412
- request.maxFee = txCost.maxFee;
5413
- request.gasLimit = txCost.gasUsed;
5414
- await this.fund(request, txCost);
5135
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5136
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5137
+ request,
5138
+ forwardingQuantities
5139
+ );
5140
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5141
+ this.validateGas({
5142
+ gasUsed,
5143
+ gasPrice: request.gasPrice,
5144
+ gasLimit: request.gasLimit,
5145
+ minGasPrice
5146
+ });
5147
+ await this.fund(request, requiredQuantities, maxFee);
5415
5148
  return this.sendTransaction(request);
5416
5149
  }
5417
5150
  async signMessage(message) {
@@ -5469,7 +5202,18 @@ var Account = class extends AbstractAccount {
5469
5202
  }
5470
5203
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5471
5204
  }
5472
- validateGas({ gasUsed, gasLimit }) {
5205
+ validateGas({
5206
+ gasUsed,
5207
+ gasPrice,
5208
+ gasLimit,
5209
+ minGasPrice
5210
+ }) {
5211
+ if (minGasPrice.gt(gasPrice)) {
5212
+ throw new FuelError15(
5213
+ ErrorCode15.GAS_PRICE_TOO_LOW,
5214
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5215
+ );
5216
+ }
5473
5217
  if (gasUsed.gt(gasLimit)) {
5474
5218
  throw new FuelError15(
5475
5219
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5765,7 +5509,7 @@ var BaseWalletUnlocked = class extends Account {
5765
5509
  * @param transactionRequestLike - The transaction request to send.
5766
5510
  * @returns A promise that resolves to the TransactionResponse object.
5767
5511
  */
5768
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5512
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5769
5513
  const transactionRequest = transactionRequestify(transactionRequestLike);
5770
5514
  if (estimateTxDependencies) {
5771
5515
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5806,7 +5550,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5806
5550
  // src/hdwallet/hdwallet.ts
5807
5551
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5808
5552
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5809
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5553
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5810
5554
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5811
5555
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5812
5556
 
@@ -8278,7 +8022,7 @@ var HDWallet = class {
8278
8022
  const IR = bytes.slice(32);
8279
8023
  if (privateKey) {
8280
8024
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8281
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
8025
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
8282
8026
  return new HDWallet({
8283
8027
  privateKey: ki,
8284
8028
  chainCode: IR,
@@ -8967,7 +8711,7 @@ import {
8967
8711
  import { Address as Address9 } from "@fuel-ts/address";
8968
8712
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8969
8713
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8970
- import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
8714
+ import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8971
8715
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8972
8716
 
8973
8717
  // src/predicate/utils/getPredicateRoot.ts
@@ -9027,9 +8771,9 @@ var Predicate = class extends Account {
9027
8771
  const request = transactionRequestify(transactionRequestLike);
9028
8772
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9029
8773
  request.inputs?.forEach((input) => {
9030
- if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
9031
- input.predicate = hexlify19(this.bytes);
9032
- input.predicateData = hexlify19(this.getPredicateData(policies.length));
8774
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8775
+ input.predicate = this.bytes;
8776
+ input.predicateData = this.getPredicateData(policies.length);
9033
8777
  }
9034
8778
  });
9035
8779
  return request;
@@ -9044,7 +8788,8 @@ var Predicate = class extends Account {
9044
8788
  * @returns A promise that resolves to the prepared transaction request.
9045
8789
  */
9046
8790
  async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
9047
- return super.createTransfer(destination, amount, assetId, txParams);
8791
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8792
+ return this.populateTransactionPredicateData(request);
9048
8793
  }
9049
8794
  /**
9050
8795
  * Sends a transaction with the populated predicate data.
@@ -9052,9 +8797,9 @@ var Predicate = class extends Account {
9052
8797
  * @param transactionRequestLike - The transaction request-like object.
9053
8798
  * @returns A promise that resolves to the transaction response.
9054
8799
  */
9055
- sendTransaction(transactionRequestLike) {
9056
- const transactionRequest = transactionRequestify(transactionRequestLike);
9057
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8800
+ sendTransaction(transactionRequestLike, options) {
8801
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8802
+ return super.sendTransaction(transactionRequest, options);
9058
8803
  }
9059
8804
  /**
9060
8805
  * Simulates a transaction with the populated predicate data.
@@ -9063,8 +8808,8 @@ var Predicate = class extends Account {
9063
8808
  * @returns A promise that resolves to the call result.
9064
8809
  */
9065
8810
  simulateTransaction(transactionRequestLike) {
9066
- const transactionRequest = transactionRequestify(transactionRequestLike);
9067
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8811
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8812
+ return super.simulateTransaction(transactionRequest);
9068
8813
  }
9069
8814
  getPredicateData(policiesLength) {
9070
8815
  if (!this.predicateData.length) {
@@ -9110,25 +8855,6 @@ var Predicate = class extends Account {
9110
8855
  predicateInterface: abiInterface
9111
8856
  };
9112
8857
  }
9113
- /**
9114
- * Retrieves resources satisfying the spend query for the account.
9115
- *
9116
- * @param quantities - IDs of coins to exclude.
9117
- * @param excludedIds - IDs of resources to be excluded from the query.
9118
- * @returns A promise that resolves to an array of Resources.
9119
- */
9120
- async getResourcesToSpend(quantities, excludedIds) {
9121
- const resources = await this.provider.getResourcesToSpend(
9122
- this.address,
9123
- quantities,
9124
- excludedIds
9125
- );
9126
- return resources.map((resource) => ({
9127
- ...resource,
9128
- predicate: hexlify19(this.bytes),
9129
- paddPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
9130
- }));
9131
- }
9132
8858
  /**
9133
8859
  * Sets the configurable constants for the predicate.
9134
8860
  *
@@ -9877,7 +9603,7 @@ export {
9877
9603
  WalletLocked,
9878
9604
  WalletManager,
9879
9605
  WalletUnlocked,
9880
- addAmountToCoinQuantities,
9606
+ addAmountToAsset,
9881
9607
  addOperation,
9882
9608
  assemblePanicError,
9883
9609
  assembleReceiptByType,
@@ -9886,10 +9612,9 @@ export {
9886
9612
  assets,
9887
9613
  buildBlockExplorerUrl,
9888
9614
  cacheFor,
9889
- cacheTxInputsFromOwner,
9890
- calculateGasFee,
9891
9615
  calculateMetadataGasForTxCreate,
9892
9616
  calculateMetadataGasForTxScript,
9617
+ calculatePriceWithFactor,
9893
9618
  calculateTransactionFee,
9894
9619
  coinQuantityfy,
9895
9620
  deferPromise,