@fuel-ts/account 0.0.0-rc-2021-20240425184301 → 0.0.0-rc-2152-20240425194419

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 +6 -7
  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 +696 -1818
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +545 -796
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +421 -671
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +24 -12
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +359 -810
  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 -46
  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 +28 -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 +1189 -2540
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +532 -778
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +419 -665
  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
@@ -31,9 +31,8 @@ var __privateMethod = (obj, member, method) => {
31
31
  import { Address as Address3 } from "@fuel-ts/address";
32
32
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
33
33
  import { AbstractAccount } from "@fuel-ts/interfaces";
34
- import { bn as bn18 } from "@fuel-ts/math";
35
- import { arrayify as arrayify14, isDefined } from "@fuel-ts/utils";
36
- import { clone as clone4 } from "ramda";
34
+ import { bn as bn17 } from "@fuel-ts/math";
35
+ import { arrayify as arrayify14 } from "@fuel-ts/utils";
37
36
 
38
37
  // src/providers/coin-quantity.ts
39
38
  import { bn } from "@fuel-ts/math";
@@ -41,24 +40,24 @@ import { hexlify } from "@fuel-ts/utils";
41
40
  var coinQuantityfy = (coinQuantityLike) => {
42
41
  let assetId;
43
42
  let amount;
44
- let max;
43
+ let max2;
45
44
  if (Array.isArray(coinQuantityLike)) {
46
45
  amount = coinQuantityLike[0];
47
46
  assetId = coinQuantityLike[1];
48
- max = coinQuantityLike[2] ?? void 0;
47
+ max2 = coinQuantityLike[2] ?? void 0;
49
48
  } else {
50
49
  amount = coinQuantityLike.amount;
51
50
  assetId = coinQuantityLike.assetId;
52
- max = coinQuantityLike.max ?? void 0;
51
+ max2 = coinQuantityLike.max ?? void 0;
53
52
  }
54
53
  const bnAmount = bn(amount);
55
54
  return {
56
55
  assetId: hexlify(assetId),
57
56
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
58
- max: max ? bn(max) : void 0
57
+ max: max2 ? bn(max2) : void 0
59
58
  };
60
59
  };
61
- var addAmountToCoinQuantities = (params) => {
60
+ var addAmountToAsset = (params) => {
62
61
  const { amount, assetId } = params;
63
62
  const coinQuantities = [...params.coinQuantities];
64
63
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -73,9 +72,9 @@ var addAmountToCoinQuantities = (params) => {
73
72
  // src/providers/provider.ts
74
73
  import { Address as Address2 } from "@fuel-ts/address";
75
74
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
76
- import { BN, bn as bn16 } from "@fuel-ts/math";
75
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
77
76
  import {
78
- InputType as InputType7,
77
+ InputType as InputType6,
79
78
  TransactionType as TransactionType8,
80
79
  InputMessageCoder,
81
80
  TransactionCoder as TransactionCoder5
@@ -83,26 +82,21 @@ import {
83
82
  import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
84
83
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
85
84
  import { equalBytes } from "@noble/curves/abstract/utils";
86
- import { Network } from "ethers";
87
85
  import { GraphQLClient } from "graphql-request";
88
86
  import { clone as clone3 } from "ramda";
89
87
 
90
88
  // src/providers/__generated__/operations.ts
91
89
  import gql from "graphql-tag";
92
- var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
93
- fragment transactionStatusSubscriptionFragment on TransactionStatus {
94
- type: __typename
95
- ... on SqueezedOutStatus {
96
- reason
97
- }
98
- }
99
- `;
100
90
  var ReceiptFragmentFragmentDoc = gql`
101
91
  fragment receiptFragment on Receipt {
102
- id
92
+ contract {
93
+ id
94
+ }
103
95
  pc
104
96
  is
105
- to
97
+ to {
98
+ id
99
+ }
106
100
  toAddress
107
101
  amount
108
102
  assetId
@@ -140,16 +134,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
140
134
  id
141
135
  }
142
136
  time
143
- receipts {
144
- ...receiptFragment
145
- }
146
137
  programState {
147
138
  returnType
148
139
  data
149
140
  }
150
- receipts {
151
- ...receiptFragment
152
- }
153
141
  }
154
142
  ... on FailureStatus {
155
143
  block {
@@ -157,24 +145,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
157
145
  }
158
146
  time
159
147
  reason
160
- receipts {
161
- ...receiptFragment
162
- }
163
148
  }
164
149
  ... on SqueezedOutStatus {
165
150
  reason
166
151
  }
167
152
  }
168
- ${ReceiptFragmentFragmentDoc}`;
153
+ `;
169
154
  var TransactionFragmentFragmentDoc = gql`
170
155
  fragment transactionFragment on Transaction {
171
156
  id
172
157
  rawPayload
158
+ gasPrice
159
+ receipts {
160
+ ...receiptFragment
161
+ }
173
162
  status {
174
163
  ...transactionStatusFragment
175
164
  }
176
165
  }
177
- ${TransactionStatusFragmentFragmentDoc}`;
166
+ ${ReceiptFragmentFragmentDoc}
167
+ ${TransactionStatusFragmentFragmentDoc}`;
178
168
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
179
169
  fragment inputEstimatePredicatesFragment on Input {
180
170
  ... on InputCoin {
@@ -192,46 +182,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
192
182
  }
193
183
  }
194
184
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
195
- var DryRunFailureStatusFragmentFragmentDoc = gql`
196
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
197
- reason
198
- programState {
199
- returnType
200
- data
201
- }
202
- }
203
- `;
204
- var DryRunSuccessStatusFragmentFragmentDoc = gql`
205
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
206
- programState {
207
- returnType
208
- data
209
- }
210
- }
211
- `;
212
- var DryRunTransactionStatusFragmentFragmentDoc = gql`
213
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
214
- ... on DryRunFailureStatus {
215
- ...dryRunFailureStatusFragment
216
- }
217
- ... on DryRunSuccessStatus {
218
- ...dryRunSuccessStatusFragment
219
- }
220
- }
221
- ${DryRunFailureStatusFragmentFragmentDoc}
222
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
223
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
224
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
225
- id
226
- status {
227
- ...dryRunTransactionStatusFragment
228
- }
229
- receipts {
230
- ...receiptFragment
231
- }
232
- }
233
- ${DryRunTransactionStatusFragmentFragmentDoc}
234
- ${ReceiptFragmentFragmentDoc}`;
235
185
  var CoinFragmentFragmentDoc = gql`
236
186
  fragment coinFragment on Coin {
237
187
  __typename
@@ -239,6 +189,7 @@ var CoinFragmentFragmentDoc = gql`
239
189
  owner
240
190
  amount
241
191
  assetId
192
+ maturity
242
193
  blockCreated
243
194
  txCreatedIdx
244
195
  }
@@ -277,32 +228,26 @@ var MessageProofFragmentFragmentDoc = gql`
277
228
  messageBlockHeader {
278
229
  id
279
230
  daHeight
280
- consensusParametersVersion
281
- stateTransitionBytecodeVersion
282
231
  transactionsCount
283
- messageReceiptCount
284
232
  transactionsRoot
285
- messageOutboxRoot
286
- eventInboxRoot
287
233
  height
288
234
  prevRoot
289
235
  time
290
236
  applicationHash
237
+ messageReceiptRoot
238
+ messageReceiptCount
291
239
  }
292
240
  commitBlockHeader {
293
241
  id
294
242
  daHeight
295
- consensusParametersVersion
296
- stateTransitionBytecodeVersion
297
243
  transactionsCount
298
- messageReceiptCount
299
244
  transactionsRoot
300
- messageOutboxRoot
301
- eventInboxRoot
302
245
  height
303
246
  prevRoot
304
247
  time
305
248
  applicationHash
249
+ messageReceiptRoot
250
+ messageReceiptCount
306
251
  }
307
252
  sender
308
253
  recipient
@@ -321,8 +266,8 @@ var BalanceFragmentFragmentDoc = gql`
321
266
  var BlockFragmentFragmentDoc = gql`
322
267
  fragment blockFragment on Block {
323
268
  id
324
- height
325
269
  header {
270
+ height
326
271
  time
327
272
  }
328
273
  transactions {
@@ -332,7 +277,6 @@ var BlockFragmentFragmentDoc = gql`
332
277
  `;
333
278
  var TxParametersFragmentFragmentDoc = gql`
334
279
  fragment TxParametersFragment on TxParameters {
335
- version
336
280
  maxInputs
337
281
  maxOutputs
338
282
  maxWitnesses
@@ -342,7 +286,6 @@ var TxParametersFragmentFragmentDoc = gql`
342
286
  `;
343
287
  var PredicateParametersFragmentFragmentDoc = gql`
344
288
  fragment PredicateParametersFragment on PredicateParameters {
345
- version
346
289
  maxPredicateLength
347
290
  maxPredicateDataLength
348
291
  maxGasPerPredicate
@@ -351,21 +294,18 @@ var PredicateParametersFragmentFragmentDoc = gql`
351
294
  `;
352
295
  var ScriptParametersFragmentFragmentDoc = gql`
353
296
  fragment ScriptParametersFragment on ScriptParameters {
354
- version
355
297
  maxScriptLength
356
298
  maxScriptDataLength
357
299
  }
358
300
  `;
359
301
  var ContractParametersFragmentFragmentDoc = gql`
360
302
  fragment ContractParametersFragment on ContractParameters {
361
- version
362
303
  contractMaxSize
363
304
  maxStorageSlots
364
305
  }
365
306
  `;
366
307
  var FeeParametersFragmentFragmentDoc = gql`
367
308
  fragment FeeParametersFragment on FeeParameters {
368
- version
369
309
  gasPriceFactor
370
310
  gasPerByte
371
311
  }
@@ -385,7 +325,6 @@ var DependentCostFragmentFragmentDoc = gql`
385
325
  `;
386
326
  var GasCostsFragmentFragmentDoc = gql`
387
327
  fragment GasCostsFragment on GasCosts {
388
- version
389
328
  add
390
329
  addi
391
330
  aloc
@@ -398,6 +337,7 @@ var GasCostsFragmentFragmentDoc = gql`
398
337
  cb
399
338
  cfei
400
339
  cfsi
340
+ croo
401
341
  div
402
342
  divi
403
343
  ecr1
@@ -480,9 +420,6 @@ var GasCostsFragmentFragmentDoc = gql`
480
420
  ccp {
481
421
  ...DependentCostFragment
482
422
  }
483
- croo {
484
- ...DependentCostFragment
485
- }
486
423
  csiz {
487
424
  ...DependentCostFragment
488
425
  }
@@ -542,7 +479,6 @@ var GasCostsFragmentFragmentDoc = gql`
542
479
  ${DependentCostFragmentFragmentDoc}`;
543
480
  var ConsensusParametersFragmentFragmentDoc = gql`
544
481
  fragment consensusParametersFragment on ConsensusParameters {
545
- version
546
482
  txParams {
547
483
  ...TxParametersFragment
548
484
  }
@@ -602,9 +538,18 @@ var NodeInfoFragmentFragmentDoc = gql`
602
538
  fragment nodeInfoFragment on NodeInfo {
603
539
  utxoValidation
604
540
  vmBacktrace
541
+ minGasPrice
605
542
  maxTx
606
543
  maxDepth
607
544
  nodeVersion
545
+ peers {
546
+ id
547
+ addresses
548
+ clientVersion
549
+ blockHeight
550
+ lastHeartbeatMs
551
+ appScore
552
+ }
608
553
  }
609
554
  `;
610
555
  var GetVersionDocument = gql`
@@ -639,9 +584,13 @@ var GetTransactionWithReceiptsDocument = gql`
639
584
  query getTransactionWithReceipts($transactionId: TransactionId!) {
640
585
  transaction(id: $transactionId) {
641
586
  ...transactionFragment
587
+ receipts {
588
+ ...receiptFragment
589
+ }
642
590
  }
643
591
  }
644
- ${TransactionFragmentFragmentDoc}`;
592
+ ${TransactionFragmentFragmentDoc}
593
+ ${ReceiptFragmentFragmentDoc}`;
645
594
  var GetTransactionsDocument = gql`
646
595
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
647
596
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -769,20 +718,6 @@ var GetBalanceDocument = gql`
769
718
  }
770
719
  }
771
720
  ${BalanceFragmentFragmentDoc}`;
772
- var GetLatestGasPriceDocument = gql`
773
- query getLatestGasPrice {
774
- latestGasPrice {
775
- gasPrice
776
- }
777
- }
778
- `;
779
- var EstimateGasPriceDocument = gql`
780
- query estimateGasPrice($blockHorizon: U32!) {
781
- estimateGasPrice(blockHorizon: $blockHorizon) {
782
- gasPrice
783
- }
784
- }
785
- `;
786
721
  var GetBalancesDocument = gql`
787
722
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
788
723
  balances(
@@ -837,12 +772,12 @@ var GetMessageStatusDocument = gql`
837
772
  }
838
773
  `;
839
774
  var DryRunDocument = gql`
840
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
841
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
842
- ...dryRunTransactionExecutionStatusFragment
775
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
776
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
777
+ ...receiptFragment
843
778
  }
844
779
  }
845
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
780
+ ${ReceiptFragmentFragmentDoc}`;
846
781
  var SubmitDocument = gql`
847
782
  mutation submit($encodedTransaction: HexString!) {
848
783
  submit(tx: $encodedTransaction) {
@@ -861,17 +796,17 @@ var ProduceBlocksDocument = gql`
861
796
  var SubmitAndAwaitDocument = gql`
862
797
  subscription submitAndAwait($encodedTransaction: HexString!) {
863
798
  submitAndAwait(tx: $encodedTransaction) {
864
- ...transactionStatusSubscriptionFragment
799
+ ...transactionStatusFragment
865
800
  }
866
801
  }
867
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
802
+ ${TransactionStatusFragmentFragmentDoc}`;
868
803
  var StatusChangeDocument = gql`
869
804
  subscription statusChange($transactionId: TransactionId!) {
870
805
  statusChange(id: $transactionId) {
871
- ...transactionStatusSubscriptionFragment
806
+ ...transactionStatusFragment
872
807
  }
873
808
  }
874
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
809
+ ${TransactionStatusFragmentFragmentDoc}`;
875
810
  function getSdk(requester) {
876
811
  return {
877
812
  getVersion(variables, options) {
@@ -925,12 +860,6 @@ function getSdk(requester) {
925
860
  getBalance(variables, options) {
926
861
  return requester(GetBalanceDocument, variables, options);
927
862
  },
928
- getLatestGasPrice(variables, options) {
929
- return requester(GetLatestGasPriceDocument, variables, options);
930
- },
931
- estimateGasPrice(variables, options) {
932
- return requester(EstimateGasPriceDocument, variables, options);
933
- },
934
863
  getBalances(variables, options) {
935
864
  return requester(GetBalancesDocument, variables, options);
936
865
  },
@@ -1124,9 +1053,10 @@ var inputify = (value) => {
1124
1053
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1125
1054
  },
1126
1055
  witnessIndex: value.witnessIndex,
1056
+ maturity: value.maturity ?? 0,
1127
1057
  predicateGasUsed: bn2(value.predicateGasUsed),
1128
- predicateLength: bn2(predicate.length),
1129
- predicateDataLength: bn2(predicateData.length),
1058
+ predicateLength: predicate.length,
1059
+ predicateDataLength: predicateData.length,
1130
1060
  predicate: hexlify3(predicate),
1131
1061
  predicateData: hexlify3(predicateData)
1132
1062
  };
@@ -1157,8 +1087,8 @@ var inputify = (value) => {
1157
1087
  nonce: hexlify3(value.nonce),
1158
1088
  witnessIndex: value.witnessIndex,
1159
1089
  predicateGasUsed: bn2(value.predicateGasUsed),
1160
- predicateLength: bn2(predicate.length),
1161
- predicateDataLength: bn2(predicateData.length),
1090
+ predicateLength: predicate.length,
1091
+ predicateDataLength: predicateData.length,
1162
1092
  predicate: hexlify3(predicate),
1163
1093
  predicateData: hexlify3(predicateData),
1164
1094
  data: hexlify3(data),
@@ -1288,8 +1218,8 @@ function assembleReceiptByType(receipt) {
1288
1218
  case "CALL" /* Call */: {
1289
1219
  const callReceipt = {
1290
1220
  type: ReceiptType.Call,
1291
- from: hexOrZero(receipt.id || receipt.contractId),
1292
- to: hexOrZero(receipt?.to),
1221
+ from: hexOrZero(receipt.contract?.id),
1222
+ to: hexOrZero(receipt?.to?.id),
1293
1223
  amount: bn4(receipt.amount),
1294
1224
  assetId: hexOrZero(receipt.assetId),
1295
1225
  gas: bn4(receipt.gas),
@@ -1303,7 +1233,7 @@ function assembleReceiptByType(receipt) {
1303
1233
  case "RETURN" /* Return */: {
1304
1234
  const returnReceipt = {
1305
1235
  type: ReceiptType.Return,
1306
- id: hexOrZero(receipt.id || receipt.contractId),
1236
+ id: hexOrZero(receipt.contract?.id),
1307
1237
  val: bn4(receipt.val),
1308
1238
  pc: bn4(receipt.pc),
1309
1239
  is: bn4(receipt.is)
@@ -1313,7 +1243,7 @@ function assembleReceiptByType(receipt) {
1313
1243
  case "RETURN_DATA" /* ReturnData */: {
1314
1244
  const returnDataReceipt = {
1315
1245
  type: ReceiptType.ReturnData,
1316
- id: hexOrZero(receipt.id || receipt.contractId),
1246
+ id: hexOrZero(receipt.contract?.id),
1317
1247
  ptr: bn4(receipt.ptr),
1318
1248
  len: bn4(receipt.len),
1319
1249
  digest: hexOrZero(receipt.digest),
@@ -1325,7 +1255,7 @@ function assembleReceiptByType(receipt) {
1325
1255
  case "PANIC" /* Panic */: {
1326
1256
  const panicReceipt = {
1327
1257
  type: ReceiptType.Panic,
1328
- id: hexOrZero(receipt.id),
1258
+ id: hexOrZero(receipt.contract?.id),
1329
1259
  reason: bn4(receipt.reason),
1330
1260
  pc: bn4(receipt.pc),
1331
1261
  is: bn4(receipt.is),
@@ -1336,7 +1266,7 @@ function assembleReceiptByType(receipt) {
1336
1266
  case "REVERT" /* Revert */: {
1337
1267
  const revertReceipt = {
1338
1268
  type: ReceiptType.Revert,
1339
- id: hexOrZero(receipt.id || receipt.contractId),
1269
+ id: hexOrZero(receipt.contract?.id),
1340
1270
  val: bn4(receipt.ra),
1341
1271
  pc: bn4(receipt.pc),
1342
1272
  is: bn4(receipt.is)
@@ -1346,7 +1276,7 @@ function assembleReceiptByType(receipt) {
1346
1276
  case "LOG" /* Log */: {
1347
1277
  const logReceipt = {
1348
1278
  type: ReceiptType.Log,
1349
- id: hexOrZero(receipt.id || receipt.contractId),
1279
+ id: hexOrZero(receipt.contract?.id),
1350
1280
  val0: bn4(receipt.ra),
1351
1281
  val1: bn4(receipt.rb),
1352
1282
  val2: bn4(receipt.rc),
@@ -1359,7 +1289,7 @@ function assembleReceiptByType(receipt) {
1359
1289
  case "LOG_DATA" /* LogData */: {
1360
1290
  const logDataReceipt = {
1361
1291
  type: ReceiptType.LogData,
1362
- id: hexOrZero(receipt.id || receipt.contractId),
1292
+ id: hexOrZero(receipt.contract?.id),
1363
1293
  val0: bn4(receipt.ra),
1364
1294
  val1: bn4(receipt.rb),
1365
1295
  ptr: bn4(receipt.ptr),
@@ -1373,8 +1303,8 @@ function assembleReceiptByType(receipt) {
1373
1303
  case "TRANSFER" /* Transfer */: {
1374
1304
  const transferReceipt = {
1375
1305
  type: ReceiptType.Transfer,
1376
- from: hexOrZero(receipt.id || receipt.contractId),
1377
- to: hexOrZero(receipt.toAddress || receipt?.to),
1306
+ from: hexOrZero(receipt.contract?.id),
1307
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1378
1308
  amount: bn4(receipt.amount),
1379
1309
  assetId: hexOrZero(receipt.assetId),
1380
1310
  pc: bn4(receipt.pc),
@@ -1385,8 +1315,8 @@ function assembleReceiptByType(receipt) {
1385
1315
  case "TRANSFER_OUT" /* TransferOut */: {
1386
1316
  const transferOutReceipt = {
1387
1317
  type: ReceiptType.TransferOut,
1388
- from: hexOrZero(receipt.id || receipt.contractId),
1389
- to: hexOrZero(receipt.toAddress || receipt.to),
1318
+ from: hexOrZero(receipt.contract?.id),
1319
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1390
1320
  amount: bn4(receipt.amount),
1391
1321
  assetId: hexOrZero(receipt.assetId),
1392
1322
  pc: bn4(receipt.pc),
@@ -1429,7 +1359,7 @@ function assembleReceiptByType(receipt) {
1429
1359
  return receiptMessageOut;
1430
1360
  }
1431
1361
  case "MINT" /* Mint */: {
1432
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1362
+ const contractId = hexOrZero(receipt.contract?.id);
1433
1363
  const subId = hexOrZero(receipt.subId);
1434
1364
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1435
1365
  const mintReceipt = {
@@ -1444,7 +1374,7 @@ function assembleReceiptByType(receipt) {
1444
1374
  return mintReceipt;
1445
1375
  }
1446
1376
  case "BURN" /* Burn */: {
1447
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1377
+ const contractId = hexOrZero(receipt.contract?.id);
1448
1378
  const subId = hexOrZero(receipt.subId);
1449
1379
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1450
1380
  const burnReceipt = {
@@ -1529,6 +1459,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1529
1459
  import { bn as bn5 } from "@fuel-ts/math";
1530
1460
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1531
1461
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1462
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1532
1463
  var getGasUsedFromReceipts = (receipts) => {
1533
1464
  const scriptResult = receipts.filter(
1534
1465
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1549,28 +1480,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1549
1480
  }
1550
1481
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1551
1482
  const witnessCache = [];
1552
- const chargeableInputs = inputs.filter((input) => {
1553
- const isCoinOrMessage = "owner" in input || "sender" in input;
1554
- if (isCoinOrMessage) {
1555
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1556
- return true;
1557
- }
1558
- if (!witnessCache.includes(input.witnessIndex)) {
1559
- witnessCache.push(input.witnessIndex);
1560
- return true;
1561
- }
1562
- }
1563
- return false;
1564
- });
1565
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1566
- const totalGas = chargeableInputs.reduce((total, input) => {
1483
+ const totalGas = inputs.reduce((total, input) => {
1567
1484
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1568
1485
  return total.add(
1569
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1486
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1570
1487
  );
1571
1488
  }
1572
- return total.add(gasCosts.ecr1);
1573
- }, bn5(0));
1489
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1490
+ witnessCache.push(input.witnessIndex);
1491
+ return total.add(gasCosts.ecr1);
1492
+ }
1493
+ return total;
1494
+ }, bn5());
1574
1495
  return totalGas;
1575
1496
  }
1576
1497
  function getMinGas(params) {
@@ -1582,20 +1503,12 @@ function getMinGas(params) {
1582
1503
  return minGas;
1583
1504
  }
1584
1505
  function getMaxGas(params) {
1585
- const {
1586
- gasPerByte,
1587
- witnessesLength,
1588
- witnessLimit,
1589
- minGas,
1590
- gasLimit = bn5(0),
1591
- maxGasPerTx
1592
- } = params;
1506
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1593
1507
  let remainingAllowedWitnessGas = bn5(0);
1594
1508
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1595
1509
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1596
1510
  }
1597
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1598
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1511
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1599
1512
  }
1600
1513
  function calculateMetadataGasForTxCreate({
1601
1514
  gasCosts,
@@ -1617,10 +1530,6 @@ function calculateMetadataGasForTxScript({
1617
1530
  }) {
1618
1531
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1619
1532
  }
1620
- var calculateGasFee = (params) => {
1621
- const { gas, gasPrice, priceFactor, tip } = params;
1622
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1623
- };
1624
1533
 
1625
1534
  // src/providers/utils/json.ts
1626
1535
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1777,7 +1686,7 @@ var witnessify = (value) => {
1777
1686
  // src/providers/transaction-request/transaction-request.ts
1778
1687
  var BaseTransactionRequest = class {
1779
1688
  /** Gas price for transaction */
1780
- tip;
1689
+ gasPrice;
1781
1690
  /** Block until which tx cannot be included */
1782
1691
  maturity;
1783
1692
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1796,7 +1705,7 @@ var BaseTransactionRequest = class {
1796
1705
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1797
1706
  */
1798
1707
  constructor({
1799
- tip,
1708
+ gasPrice,
1800
1709
  maturity,
1801
1710
  maxFee,
1802
1711
  witnessLimit,
@@ -1804,7 +1713,7 @@ var BaseTransactionRequest = class {
1804
1713
  outputs,
1805
1714
  witnesses
1806
1715
  } = {}) {
1807
- this.tip = bn7(tip);
1716
+ this.gasPrice = bn7(gasPrice);
1808
1717
  this.maturity = maturity ?? 0;
1809
1718
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1810
1719
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
@@ -1815,9 +1724,9 @@ var BaseTransactionRequest = class {
1815
1724
  static getPolicyMeta(req) {
1816
1725
  let policyTypes = 0;
1817
1726
  const policies = [];
1818
- if (req.tip) {
1819
- policyTypes += PolicyType.Tip;
1820
- policies.push({ data: req.tip, type: PolicyType.Tip });
1727
+ if (req.gasPrice) {
1728
+ policyTypes += PolicyType.GasPrice;
1729
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1821
1730
  }
1822
1731
  if (req.witnessLimit) {
1823
1732
  policyTypes += PolicyType.WitnessLimit;
@@ -2001,11 +1910,13 @@ var BaseTransactionRequest = class {
2001
1910
  * assetId, if one it was not added yet.
2002
1911
  *
2003
1912
  * @param coin - Coin resource.
1913
+ * @param predicate - Predicate bytes.
1914
+ * @param predicateData - Predicate data bytes.
2004
1915
  */
2005
- addCoinInput(coin) {
1916
+ addCoinInput(coin, predicate) {
2006
1917
  const { assetId, owner, amount } = coin;
2007
1918
  let witnessIndex;
2008
- if (coin.predicate) {
1919
+ if (predicate) {
2009
1920
  witnessIndex = 0;
2010
1921
  } else {
2011
1922
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2020,7 +1931,8 @@ var BaseTransactionRequest = class {
2020
1931
  amount,
2021
1932
  assetId,
2022
1933
  txPointer: "0x00000000000000000000000000000000",
2023
- witnessIndex
1934
+ witnessIndex,
1935
+ predicate: predicate?.bytes
2024
1936
  };
2025
1937
  this.pushInput(input);
2026
1938
  this.addChangeOutput(owner, assetId);
@@ -2030,11 +1942,12 @@ var BaseTransactionRequest = class {
2030
1942
  * asset against the message
2031
1943
  *
2032
1944
  * @param message - Message resource.
1945
+ * @param predicate - Predicate bytes.
2033
1946
  */
2034
- addMessageInput(message) {
1947
+ addMessageInput(message, predicate) {
2035
1948
  const { recipient, sender, amount, assetId } = message;
2036
1949
  let witnessIndex;
2037
- if (message.predicate) {
1950
+ if (predicate) {
2038
1951
  witnessIndex = 0;
2039
1952
  } else {
2040
1953
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2048,7 +1961,8 @@ var BaseTransactionRequest = class {
2048
1961
  sender: sender.toB256(),
2049
1962
  recipient: recipient.toB256(),
2050
1963
  amount,
2051
- witnessIndex
1964
+ witnessIndex,
1965
+ predicate: predicate?.bytes
2052
1966
  };
2053
1967
  this.pushInput(input);
2054
1968
  this.addChangeOutput(recipient, assetId);
@@ -2079,6 +1993,32 @@ var BaseTransactionRequest = class {
2079
1993
  resources.forEach((resource) => this.addResource(resource));
2080
1994
  return this;
2081
1995
  }
1996
+ /**
1997
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1998
+ * outputs from the related assetIds.
1999
+ *
2000
+ * @param resources - The resources to add.
2001
+ * @returns This transaction.
2002
+ */
2003
+ addPredicateResource(resource, predicate) {
2004
+ if (isCoin(resource)) {
2005
+ this.addCoinInput(resource, predicate);
2006
+ } else {
2007
+ this.addMessageInput(resource, predicate);
2008
+ }
2009
+ return this;
2010
+ }
2011
+ /**
2012
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2013
+ * from the related assetIds.
2014
+ *
2015
+ * @param resources - The resources to add.
2016
+ * @returns This transaction.
2017
+ */
2018
+ addPredicateResources(resources, predicate) {
2019
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2020
+ return this;
2021
+ }
2082
2022
  /**
2083
2023
  * Adds a coin output to the transaction.
2084
2024
  *
@@ -2158,7 +2098,7 @@ var BaseTransactionRequest = class {
2158
2098
  }
2159
2099
  calculateMaxGas(chainInfo, minGas) {
2160
2100
  const { consensusParameters } = chainInfo;
2161
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2101
+ const { gasPerByte } = consensusParameters;
2162
2102
  const witnessesLength = this.toTransaction().witnesses.reduce(
2163
2103
  (acc, wit) => acc + wit.dataLength,
2164
2104
  0
@@ -2167,8 +2107,7 @@ var BaseTransactionRequest = class {
2167
2107
  gasPerByte,
2168
2108
  minGas,
2169
2109
  witnessesLength,
2170
- witnessLimit: this.witnessLimit,
2171
- maxGasPerTx
2110
+ witnessLimit: this.witnessLimit
2172
2111
  });
2173
2112
  }
2174
2113
  /**
@@ -2187,20 +2126,17 @@ var BaseTransactionRequest = class {
2187
2126
  });
2188
2127
  const updateAssetInput = (assetId, quantity) => {
2189
2128
  const assetInput = findAssetInput(assetId);
2190
- let usedQuantity = quantity;
2191
- if (assetId === baseAssetId) {
2192
- usedQuantity = bn7("1000000000000000000");
2193
- }
2194
2129
  if (assetInput && "assetId" in assetInput) {
2195
2130
  assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2196
- assetInput.amount = usedQuantity;
2131
+ assetInput.amount = quantity;
2197
2132
  } else {
2198
2133
  this.addResources([
2199
2134
  {
2200
2135
  id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2201
- amount: usedQuantity,
2136
+ amount: quantity,
2202
2137
  assetId,
2203
2138
  owner: resourcesOwner || Address.fromRandom(),
2139
+ maturity: 0,
2204
2140
  blockCreated: bn7(1),
2205
2141
  txCreatedIdx: bn7(1)
2206
2142
  }
@@ -2232,7 +2168,7 @@ var BaseTransactionRequest = class {
2232
2168
  toJSON() {
2233
2169
  return normalizeJSON(this);
2234
2170
  }
2235
- updatePredicateGasUsed(inputs) {
2171
+ updatePredicateInputs(inputs) {
2236
2172
  this.inputs.forEach((i) => {
2237
2173
  let correspondingInput;
2238
2174
  switch (i.type) {
@@ -2254,15 +2190,6 @@ var BaseTransactionRequest = class {
2254
2190
  }
2255
2191
  });
2256
2192
  }
2257
- shiftPredicateData() {
2258
- this.inputs.forEach((input) => {
2259
- if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
2260
- input.predicateData = input.padPredicateData(
2261
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2262
- );
2263
- }
2264
- });
2265
- }
2266
2193
  };
2267
2194
 
2268
2195
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2404,8 +2331,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2404
2331
  return {
2405
2332
  type: TransactionType3.Create,
2406
2333
  ...baseTransaction,
2334
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2407
2335
  bytecodeWitnessIndex,
2408
- storageSlotsCount: bn9(storageSlots.length),
2336
+ storageSlotsCount: storageSlots.length,
2409
2337
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2410
2338
  storageSlots
2411
2339
  };
@@ -2528,8 +2456,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2528
2456
  type: TransactionType4.Script,
2529
2457
  scriptGasLimit: this.gasLimit,
2530
2458
  ...super.getBaseTransaction(),
2531
- scriptLength: bn10(script.length),
2532
- scriptDataLength: bn10(scriptData.length),
2459
+ scriptLength: script.length,
2460
+ scriptDataLength: scriptData.length,
2533
2461
  receiptsRoot: ZeroBytes327,
2534
2462
  script: hexlify10(script),
2535
2463
  scriptData: hexlify10(scriptData)
@@ -2593,7 +2521,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2593
2521
  }
2594
2522
  calculateMaxGas(chainInfo, minGas) {
2595
2523
  const { consensusParameters } = chainInfo;
2596
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2524
+ const { gasPerByte } = consensusParameters;
2597
2525
  const witnessesLength = this.toTransaction().witnesses.reduce(
2598
2526
  (acc, wit) => acc + wit.dataLength,
2599
2527
  0
@@ -2603,8 +2531,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2603
2531
  minGas,
2604
2532
  witnessesLength,
2605
2533
  witnessLimit: this.witnessLimit,
2606
- gasLimit: this.gasLimit,
2607
- maxGasPerTx
2534
+ gasLimit: this.gasLimit
2608
2535
  });
2609
2536
  }
2610
2537
  /**
@@ -2661,7 +2588,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2661
2588
 
2662
2589
  // src/providers/transaction-request/utils.ts
2663
2590
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2664
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2591
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2665
2592
  var transactionRequestify = (obj) => {
2666
2593
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2667
2594
  return obj;
@@ -2679,31 +2606,14 @@ var transactionRequestify = (obj) => {
2679
2606
  }
2680
2607
  }
2681
2608
  };
2682
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2683
- (acc, input) => {
2684
- if (input.type === InputType5.Coin && input.owner === owner) {
2685
- acc.utxos.push(input.id);
2686
- }
2687
- if (input.type === InputType5.Message && input.recipient === owner) {
2688
- acc.messages.push(input.nonce);
2689
- }
2690
- return acc;
2691
- },
2692
- {
2693
- utxos: [],
2694
- messages: []
2695
- }
2696
- );
2697
2609
 
2698
2610
  // src/providers/transaction-response/transaction-response.ts
2699
2611
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2700
- import { bn as bn15 } from "@fuel-ts/math";
2612
+ import { bn as bn14 } from "@fuel-ts/math";
2701
2613
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2702
2614
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2703
2615
 
2704
2616
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2705
- import { bn as bn14 } from "@fuel-ts/math";
2706
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2707
2617
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2708
2618
 
2709
2619
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2712,10 +2622,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2712
2622
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2713
2623
  var calculateTransactionFee = (params) => {
2714
2624
  const {
2715
- gasPrice,
2625
+ gasUsed,
2716
2626
  rawPayload,
2717
- tip,
2718
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2627
+ consensusParameters: { gasCosts, feeParams }
2719
2628
  } = params;
2720
2629
  const gasPerByte = bn11(feeParams.gasPerByte);
2721
2630
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2725,7 +2634,8 @@ var calculateTransactionFee = (params) => {
2725
2634
  return {
2726
2635
  fee: bn11(0),
2727
2636
  minFee: bn11(0),
2728
- maxFee: bn11(0)
2637
+ maxFee: bn11(0),
2638
+ feeFromGasUsed: bn11(0)
2729
2639
  };
2730
2640
  }
2731
2641
  const { type, witnesses, inputs, policies } = transaction;
@@ -2757,6 +2667,7 @@ var calculateTransactionFee = (params) => {
2757
2667
  metadataGas,
2758
2668
  txBytesSize: transactionBytes.length
2759
2669
  });
2670
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2760
2671
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2761
2672
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2762
2673
  const maxGas = getMaxGas({
@@ -2764,25 +2675,17 @@ var calculateTransactionFee = (params) => {
2764
2675
  minGas,
2765
2676
  witnessesLength,
2766
2677
  gasLimit,
2767
- witnessLimit,
2768
- maxGasPerTx
2769
- });
2770
- const minFee = calculateGasFee({
2771
- gasPrice,
2772
- gas: minGas,
2773
- priceFactor: gasPriceFactor,
2774
- tip
2775
- });
2776
- const maxFee = calculateGasFee({
2777
- gasPrice,
2778
- gas: maxGas,
2779
- priceFactor: gasPriceFactor,
2780
- tip
2678
+ witnessLimit
2781
2679
  });
2680
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2681
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2682
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2683
+ const fee = minFee.add(feeFromGasUsed);
2782
2684
  return {
2685
+ fee,
2783
2686
  minFee,
2784
2687
  maxFee,
2785
- fee: maxFee
2688
+ feeFromGasUsed
2786
2689
  };
2787
2690
  };
2788
2691
 
@@ -2838,7 +2741,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2838
2741
 
2839
2742
  // src/providers/transaction-summary/input.ts
2840
2743
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2841
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2744
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2842
2745
  function getInputsByTypes(inputs, types) {
2843
2746
  return inputs.filter((i) => types.includes(i.type));
2844
2747
  }
@@ -2846,16 +2749,16 @@ function getInputsByType(inputs, type) {
2846
2749
  return inputs.filter((i) => i.type === type);
2847
2750
  }
2848
2751
  function getInputsCoin(inputs) {
2849
- return getInputsByType(inputs, InputType6.Coin);
2752
+ return getInputsByType(inputs, InputType5.Coin);
2850
2753
  }
2851
2754
  function getInputsMessage(inputs) {
2852
- return getInputsByType(inputs, InputType6.Message);
2755
+ return getInputsByType(inputs, InputType5.Message);
2853
2756
  }
2854
2757
  function getInputsCoinAndMessage(inputs) {
2855
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2758
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2856
2759
  }
2857
2760
  function getInputsContract(inputs) {
2858
- return getInputsByType(inputs, InputType6.Contract);
2761
+ return getInputsByType(inputs, InputType5.Contract);
2859
2762
  }
2860
2763
  function getInputFromAssetId(inputs, assetId) {
2861
2764
  const coinInputs = getInputsCoin(inputs);
@@ -2874,7 +2777,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2874
2777
  if (!contractInput) {
2875
2778
  return void 0;
2876
2779
  }
2877
- if (contractInput.type !== InputType6.Contract) {
2780
+ if (contractInput.type !== InputType5.Contract) {
2878
2781
  throw new FuelError9(
2879
2782
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2880
2783
  `Contract input should be of type 'contract'.`
@@ -2883,10 +2786,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2883
2786
  return contractInput;
2884
2787
  }
2885
2788
  function getInputAccountAddress(input) {
2886
- if (input.type === InputType6.Coin) {
2789
+ if (input.type === InputType5.Coin) {
2887
2790
  return input.owner.toString();
2888
2791
  }
2889
- if (input.type === InputType6.Message) {
2792
+ if (input.type === InputType5.Message) {
2890
2793
  return input.recipient.toString();
2891
2794
  }
2892
2795
  return "";
@@ -3396,9 +3299,7 @@ function assembleTransactionSummary(params) {
3396
3299
  gqlTransactionStatus,
3397
3300
  abiMap = {},
3398
3301
  maxInputs,
3399
- gasCosts,
3400
- maxGasPerTx,
3401
- gasPrice
3302
+ gasCosts
3402
3303
  } = params;
3403
3304
  const gasUsed = getGasUsedFromReceipts(receipts);
3404
3305
  const rawPayload = hexlify11(transactionBytes);
@@ -3412,14 +3313,11 @@ function assembleTransactionSummary(params) {
3412
3313
  maxInputs
3413
3314
  });
3414
3315
  const typeName = getTransactionTypeName(transaction.type);
3415
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3416
3316
  const { fee } = calculateTransactionFee({
3417
- gasPrice,
3317
+ gasUsed,
3418
3318
  rawPayload,
3419
- tip,
3420
3319
  consensusParameters: {
3421
3320
  gasCosts,
3422
- maxGasPerTx,
3423
3321
  feeParams: {
3424
3322
  gasPerByte,
3425
3323
  gasPriceFactor
@@ -3479,7 +3377,7 @@ var TransactionResponse = class {
3479
3377
  /** Current provider */
3480
3378
  provider;
3481
3379
  /** Gas used on the transaction */
3482
- gasUsed = bn15(0);
3380
+ gasUsed = bn14(0);
3483
3381
  /** The graphql Transaction with receipts object. */
3484
3382
  gqlTransaction;
3485
3383
  abis;
@@ -3557,13 +3455,8 @@ var TransactionResponse = class {
3557
3455
  const decodedTransaction = this.decodeTransaction(
3558
3456
  transaction
3559
3457
  );
3560
- let txReceipts = [];
3561
- if (transaction?.status && "receipts" in transaction.status) {
3562
- txReceipts = transaction.status.receipts;
3563
- }
3564
- const receipts = txReceipts.map(processGqlReceipt) || [];
3565
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3566
- const gasPrice = await this.provider.getLatestGasPrice();
3458
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3459
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3567
3460
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3568
3461
  const transactionSummary = assembleTransactionSummary({
3569
3462
  id: this.id,
@@ -3575,9 +3468,7 @@ var TransactionResponse = class {
3575
3468
  gasPriceFactor,
3576
3469
  abiMap: contractsAbiMap,
3577
3470
  maxInputs,
3578
- gasCosts,
3579
- maxGasPerTx,
3580
- gasPrice
3471
+ gasCosts
3581
3472
  });
3582
3473
  return transactionSummary;
3583
3474
  }
@@ -3703,30 +3594,30 @@ var processGqlChain = (chain) => {
3703
3594
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3704
3595
  return {
3705
3596
  name,
3706
- baseChainHeight: bn16(daHeight),
3597
+ baseChainHeight: bn15(daHeight),
3707
3598
  consensusParameters: {
3708
- contractMaxSize: bn16(contractParams.contractMaxSize),
3709
- maxInputs: bn16(txParams.maxInputs),
3710
- maxOutputs: bn16(txParams.maxOutputs),
3711
- maxWitnesses: bn16(txParams.maxWitnesses),
3712
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3713
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3714
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3715
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3716
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3717
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3718
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3719
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3720
- gasPerByte: bn16(feeParams.gasPerByte),
3721
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3722
- chainId: bn16(consensusParameters.chainId),
3599
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3600
+ maxInputs: bn15(txParams.maxInputs),
3601
+ maxOutputs: bn15(txParams.maxOutputs),
3602
+ maxWitnesses: bn15(txParams.maxWitnesses),
3603
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3604
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3605
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3606
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3607
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3608
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3609
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3610
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3611
+ gasPerByte: bn15(feeParams.gasPerByte),
3612
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3613
+ chainId: bn15(consensusParameters.chainId),
3723
3614
  baseAssetId: consensusParameters.baseAssetId,
3724
3615
  gasCosts
3725
3616
  },
3726
3617
  gasCosts,
3727
3618
  latestBlock: {
3728
3619
  id: latestBlock.id,
3729
- height: bn16(latestBlock.height),
3620
+ height: bn15(latestBlock.header.height),
3730
3621
  time: latestBlock.header.time,
3731
3622
  transactions: latestBlock.transactions.map((i) => ({
3732
3623
  id: i.id
@@ -3820,8 +3711,10 @@ var _Provider = class {
3820
3711
  * Returns some helpful parameters related to gas fees.
3821
3712
  */
3822
3713
  getGasConfig() {
3714
+ const { minGasPrice } = this.getNode();
3823
3715
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3824
3716
  return {
3717
+ minGasPrice,
3825
3718
  maxGasPerTx,
3826
3719
  maxGasPerPredicate,
3827
3720
  gasPriceFactor,
@@ -3897,21 +3790,6 @@ var _Provider = class {
3897
3790
  } = await this.operations.getVersion();
3898
3791
  return nodeVersion;
3899
3792
  }
3900
- /**
3901
- * @hidden
3902
- *
3903
- * Returns the network configuration of the connected Fuel node.
3904
- *
3905
- * @returns A promise that resolves to the network configuration object
3906
- */
3907
- async getNetwork() {
3908
- const {
3909
- name,
3910
- consensusParameters: { chainId }
3911
- } = await this.getChain();
3912
- const network = new Network(name, chainId.toNumber());
3913
- return Promise.resolve(network);
3914
- }
3915
3793
  /**
3916
3794
  * Returns the block number.
3917
3795
  *
@@ -3919,7 +3797,7 @@ var _Provider = class {
3919
3797
  */
3920
3798
  async getBlockNumber() {
3921
3799
  const { chain } = await this.operations.getChain();
3922
- return bn16(chain.latestBlock.height, 10);
3800
+ return bn15(chain.latestBlock.header.height, 10);
3923
3801
  }
3924
3802
  /**
3925
3803
  * Returns the chain information.
@@ -3929,11 +3807,13 @@ var _Provider = class {
3929
3807
  async fetchNode() {
3930
3808
  const { nodeInfo } = await this.operations.getNodeInfo();
3931
3809
  const processedNodeInfo = {
3932
- maxDepth: bn16(nodeInfo.maxDepth),
3933
- maxTx: bn16(nodeInfo.maxTx),
3810
+ maxDepth: bn15(nodeInfo.maxDepth),
3811
+ maxTx: bn15(nodeInfo.maxTx),
3812
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3934
3813
  nodeVersion: nodeInfo.nodeVersion,
3935
3814
  utxoValidation: nodeInfo.utxoValidation,
3936
- vmBacktrace: nodeInfo.vmBacktrace
3815
+ vmBacktrace: nodeInfo.vmBacktrace,
3816
+ peers: nodeInfo.peers
3937
3817
  };
3938
3818
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3939
3819
  return processedNodeInfo;
@@ -4030,13 +3910,14 @@ var _Provider = class {
4030
3910
  return this.estimateTxDependencies(transactionRequest);
4031
3911
  }
4032
3912
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4033
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4034
- encodedTransactions: encodedTransaction,
3913
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3914
+ encodedTransaction,
4035
3915
  utxoValidation: utxoValidation || false
4036
3916
  });
4037
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4038
- const receipts = rawReceipts.map(processGqlReceipt);
4039
- return { receipts, dryrunStatus: status };
3917
+ const receipts = gqlReceipts.map(processGqlReceipt);
3918
+ return {
3919
+ receipts
3920
+ };
4040
3921
  }
4041
3922
  /**
4042
3923
  * Verifies whether enough gas is available to complete transaction.
@@ -4062,7 +3943,7 @@ var _Provider = class {
4062
3943
  } = response;
4063
3944
  if (inputs) {
4064
3945
  inputs.forEach((input, index) => {
4065
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3946
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
4066
3947
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4067
3948
  }
4068
3949
  });
@@ -4075,6 +3956,9 @@ var _Provider = class {
4075
3956
  * If there are missing variable outputs,
4076
3957
  * `addVariableOutputs` is called on the transaction.
4077
3958
  *
3959
+ * @privateRemarks
3960
+ * TODO: Investigate support for missing contract IDs
3961
+ * TODO: Add support for missing output messages
4078
3962
  *
4079
3963
  * @param transactionRequest - The transaction request object.
4080
3964
  * @returns A promise.
@@ -4087,19 +3971,16 @@ var _Provider = class {
4087
3971
  missingContractIds: []
4088
3972
  };
4089
3973
  }
3974
+ await this.estimatePredicates(transactionRequest);
4090
3975
  let receipts = [];
4091
3976
  const missingContractIds = [];
4092
3977
  let outputVariables = 0;
4093
- let dryrunStatus;
4094
3978
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4095
- const {
4096
- dryRun: [{ receipts: rawReceipts, status }]
4097
- } = await this.operations.dryRun({
4098
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3979
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3980
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
4099
3981
  utxoValidation: false
4100
3982
  });
4101
- receipts = rawReceipts.map(processGqlReceipt);
4102
- dryrunStatus = status;
3983
+ receipts = gqlReceipts.map(processGqlReceipt);
4103
3984
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4104
3985
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4105
3986
  if (hasMissingOutputs) {
@@ -4109,10 +3990,6 @@ var _Provider = class {
4109
3990
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
4110
3991
  missingContractIds.push(contractId);
4111
3992
  });
4112
- const { maxFee } = await this.estimateTxGasAndFee({
4113
- transactionRequest
4114
- });
4115
- transactionRequest.maxFee = maxFee;
4116
3993
  } else {
4117
3994
  break;
4118
3995
  }
@@ -4120,136 +3997,37 @@ var _Provider = class {
4120
3997
  return {
4121
3998
  receipts,
4122
3999
  outputVariables,
4123
- missingContractIds,
4124
- dryrunStatus
4000
+ missingContractIds
4125
4001
  };
4126
4002
  }
4127
- /**
4128
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4129
- *
4130
- * Transactions are dry run in batches. After each dry run, transactions requiring
4131
- * further modifications are identified. The method iteratively updates these transactions
4132
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4133
- *
4134
- * @param transactionRequests - Array of transaction request objects.
4135
- * @returns A promise that resolves to an array of results for each transaction.
4136
- */
4137
- async estimateMultipleTxDependencies(transactionRequests) {
4138
- const results = transactionRequests.map(() => ({
4139
- receipts: [],
4140
- outputVariables: 0,
4141
- missingContractIds: [],
4142
- dryrunStatus: void 0
4143
- }));
4144
- const allRequests = clone3(transactionRequests);
4145
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4146
- allRequests.forEach((req, index) => {
4147
- if (req.type === TransactionType8.Script) {
4148
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4149
- }
4150
- });
4151
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4152
- let attempt = 0;
4153
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4154
- const encodedTransactions = transactionsToProcess.map(
4155
- (index) => serializedTransactionsMap.get(index)
4156
- );
4157
- const dryRunResults = await this.operations.dryRun({
4158
- encodedTransactions,
4159
- utxoValidation: false
4160
- });
4161
- const nextRoundTransactions = [];
4162
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4163
- const requestIdx = transactionsToProcess[i];
4164
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4165
- const result = results[requestIdx];
4166
- result.receipts = rawReceipts.map(processGqlReceipt);
4167
- result.dryrunStatus = status;
4168
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4169
- result.receipts
4170
- );
4171
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4172
- const request = allRequests[requestIdx];
4173
- if (hasMissingOutputs && request?.type === TransactionType8.Script) {
4174
- result.outputVariables += missingOutputVariables.length;
4175
- request.addVariableOutputs(missingOutputVariables.length);
4176
- missingOutputContractIds.forEach(({ contractId }) => {
4177
- request.addContractInputAndOutput(Address2.fromString(contractId));
4178
- result.missingContractIds.push(contractId);
4179
- });
4180
- const { maxFee } = await this.estimateTxGasAndFee({
4181
- transactionRequest: request
4182
- });
4183
- request.maxFee = maxFee;
4184
- serializedTransactionsMap.set(requestIdx, hexlify12(request.toTransactionBytes()));
4185
- nextRoundTransactions.push(requestIdx);
4186
- }
4187
- }
4188
- transactionsToProcess = nextRoundTransactions;
4189
- attempt += 1;
4190
- }
4191
- return results;
4192
- }
4193
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4194
- if (estimateTxDependencies) {
4195
- return this.estimateMultipleTxDependencies(transactionRequests);
4196
- }
4197
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4198
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4199
- encodedTransactions,
4200
- utxoValidation: utxoValidation || false
4201
- });
4202
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4203
- const receipts = rawReceipts.map(processGqlReceipt);
4204
- return { receipts, dryrunStatus: status };
4205
- });
4206
- return results;
4207
- }
4208
4003
  /**
4209
4004
  * Estimates the transaction gas and fee based on the provided transaction request.
4210
4005
  * @param transactionRequest - The transaction request object.
4211
4006
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4212
4007
  */
4213
- async estimateTxGasAndFee(params) {
4008
+ estimateTxGasAndFee(params) {
4214
4009
  const { transactionRequest } = params;
4215
- let { gasPrice } = params;
4010
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4216
4011
  const chainInfo = this.getChain();
4217
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4012
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4013
+ transactionRequest.gasPrice = gasPrice;
4218
4014
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4219
- if (!gasPrice) {
4220
- gasPrice = await this.estimateGasPrice(10);
4221
- }
4222
- const minFee = calculateGasFee({
4223
- gasPrice: bn16(gasPrice),
4224
- gas: minGas,
4225
- priceFactor: gasPriceFactor,
4226
- tip: transactionRequest.tip
4227
- }).add(1);
4228
- let gasLimit = bn16(0);
4015
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4229
4016
  if (transactionRequest.type === TransactionType8.Script) {
4230
- gasLimit = transactionRequest.gasLimit;
4231
4017
  if (transactionRequest.gasLimit.eq(0)) {
4232
4018
  transactionRequest.gasLimit = minGas;
4233
4019
  transactionRequest.gasLimit = maxGasPerTx.sub(
4234
4020
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4235
4021
  );
4236
- gasLimit = transactionRequest.gasLimit;
4237
4022
  }
4238
4023
  }
4239
4024
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4240
- const maxFee = calculateGasFee({
4241
- gasPrice: bn16(gasPrice),
4242
- gas: maxGas,
4243
- priceFactor: gasPriceFactor,
4244
- tip: transactionRequest.tip
4245
- }).add(1);
4025
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4246
4026
  return {
4247
4027
  minGas,
4248
4028
  minFee,
4249
4029
  maxGas,
4250
- maxFee,
4251
- gasPrice,
4252
- gasLimit
4030
+ maxFee
4253
4031
  };
4254
4032
  }
4255
4033
  /**
@@ -4267,17 +4045,15 @@ var _Provider = class {
4267
4045
  if (estimateTxDependencies) {
4268
4046
  return this.estimateTxDependencies(transactionRequest);
4269
4047
  }
4270
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4271
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4272
- encodedTransactions,
4048
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4049
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4050
+ encodedTransaction,
4273
4051
  utxoValidation: true
4274
4052
  });
4275
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4276
- const { id, receipts, status } = dryRunStatus;
4277
- const processedReceipts = receipts.map(processGqlReceipt);
4278
- return { id, receipts: processedReceipts, status };
4279
- });
4280
- return { receipts: callResult[0].receipts };
4053
+ const receipts = gqlReceipts.map(processGqlReceipt);
4054
+ return {
4055
+ receipts
4056
+ };
4281
4057
  }
4282
4058
  /**
4283
4059
  * Returns a transaction cost to enable user
@@ -4294,80 +4070,78 @@ var _Provider = class {
4294
4070
  * @param tolerance - The tolerance to add on top of the gasUsed.
4295
4071
  * @returns A promise that resolves to the transaction cost object.
4296
4072
  */
4297
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4073
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4074
+ estimateTxDependencies = true,
4075
+ estimatePredicates = true,
4076
+ resourcesOwner,
4077
+ signatureCallback
4078
+ } = {}) {
4298
4079
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4080
+ const { minGasPrice } = this.getGasConfig();
4081
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4299
4082
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4300
4083
  const baseAssetId = this.getBaseAssetId();
4301
4084
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4302
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4085
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4303
4086
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4304
- txRequestClone.maxFee = bn16(0);
4305
4087
  if (isScriptTransaction) {
4306
- txRequestClone.gasLimit = bn16(0);
4088
+ txRequestClone.gasLimit = bn15(0);
4307
4089
  }
4308
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4309
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4090
+ if (estimatePredicates) {
4091
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4092
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4093
+ }
4094
+ await this.estimatePredicates(txRequestClone);
4310
4095
  }
4311
- const signedRequest = clone3(txRequestClone);
4312
- let addedSignatures = 0;
4313
4096
  if (signatureCallback && isScriptTransaction) {
4314
- const lengthBefore = signedRequest.witnesses.length;
4315
- await signatureCallback(signedRequest);
4316
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4097
+ await signatureCallback(txRequestClone);
4317
4098
  }
4318
- await this.estimatePredicates(signedRequest);
4319
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4320
- transactionRequest: signedRequest
4099
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4100
+ transactionRequest: txRequestClone
4321
4101
  });
4322
4102
  let receipts = [];
4323
4103
  let missingContractIds = [];
4324
4104
  let outputVariables = 0;
4325
- let gasUsed = bn16(0);
4326
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4327
- txRequestClone.maxFee = maxFee;
4328
- if (isScriptTransaction) {
4329
- txRequestClone.gasLimit = gasLimit;
4330
- if (signatureCallback) {
4331
- await signatureCallback(txRequestClone);
4332
- }
4105
+ let gasUsed = bn15(0);
4106
+ if (isScriptTransaction && estimateTxDependencies) {
4107
+ txRequestClone.gasPrice = bn15(0);
4333
4108
  const result = await this.estimateTxDependencies(txRequestClone);
4334
4109
  receipts = result.receipts;
4335
4110
  outputVariables = result.outputVariables;
4336
4111
  missingContractIds = result.missingContractIds;
4337
4112
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4338
4113
  txRequestClone.gasLimit = gasUsed;
4339
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4340
- transactionRequest: txRequestClone,
4341
- gasPrice
4114
+ txRequestClone.gasPrice = setGasPrice;
4115
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4116
+ transactionRequest: txRequestClone
4342
4117
  }));
4343
4118
  }
4344
4119
  return {
4345
4120
  requiredQuantities: allQuantities,
4346
4121
  receipts,
4347
4122
  gasUsed,
4348
- gasPrice,
4123
+ minGasPrice,
4124
+ gasPrice: setGasPrice,
4349
4125
  minGas,
4350
4126
  maxGas,
4351
4127
  minFee,
4352
4128
  maxFee,
4129
+ estimatedInputs: txRequestClone.inputs,
4353
4130
  outputVariables,
4354
- missingContractIds,
4355
- addedSignatures,
4356
- estimatedPredicates: txRequestClone.inputs
4131
+ missingContractIds
4357
4132
  };
4358
4133
  }
4359
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4134
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4360
4135
  const ownerAddress = Address2.fromAddressOrString(owner);
4361
4136
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4362
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4363
- quantitiesToContract
4364
- });
4137
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4365
4138
  transactionRequest.addResources(
4366
4139
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4367
4140
  );
4368
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4369
- quantitiesToContract
4370
- });
4141
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4142
+ transactionRequest,
4143
+ forwardingQuantities
4144
+ );
4371
4145
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4372
4146
  return {
4373
4147
  resources,
@@ -4389,10 +4163,11 @@ var _Provider = class {
4389
4163
  return coins.map((coin) => ({
4390
4164
  id: coin.utxoId,
4391
4165
  assetId: coin.assetId,
4392
- amount: bn16(coin.amount),
4166
+ amount: bn15(coin.amount),
4393
4167
  owner: Address2.fromAddressOrString(coin.owner),
4394
- blockCreated: bn16(coin.blockCreated),
4395
- txCreatedIdx: bn16(coin.txCreatedIdx)
4168
+ maturity: bn15(coin.maturity).toNumber(),
4169
+ blockCreated: bn15(coin.blockCreated),
4170
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4396
4171
  }));
4397
4172
  }
4398
4173
  /**
@@ -4429,9 +4204,9 @@ var _Provider = class {
4429
4204
  switch (coin.__typename) {
4430
4205
  case "MessageCoin":
4431
4206
  return {
4432
- amount: bn16(coin.amount),
4207
+ amount: bn15(coin.amount),
4433
4208
  assetId: coin.assetId,
4434
- daHeight: bn16(coin.daHeight),
4209
+ daHeight: bn15(coin.daHeight),
4435
4210
  sender: Address2.fromAddressOrString(coin.sender),
4436
4211
  recipient: Address2.fromAddressOrString(coin.recipient),
4437
4212
  nonce: coin.nonce
@@ -4439,11 +4214,12 @@ var _Provider = class {
4439
4214
  case "Coin":
4440
4215
  return {
4441
4216
  id: coin.utxoId,
4442
- amount: bn16(coin.amount),
4217
+ amount: bn15(coin.amount),
4443
4218
  assetId: coin.assetId,
4444
4219
  owner: Address2.fromAddressOrString(coin.owner),
4445
- blockCreated: bn16(coin.blockCreated),
4446
- txCreatedIdx: bn16(coin.txCreatedIdx)
4220
+ maturity: bn15(coin.maturity).toNumber(),
4221
+ blockCreated: bn15(coin.blockCreated),
4222
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4447
4223
  };
4448
4224
  default:
4449
4225
  return null;
@@ -4460,13 +4236,13 @@ var _Provider = class {
4460
4236
  async getBlock(idOrHeight) {
4461
4237
  let variables;
4462
4238
  if (typeof idOrHeight === "number") {
4463
- variables = { height: bn16(idOrHeight).toString(10) };
4239
+ variables = { height: bn15(idOrHeight).toString(10) };
4464
4240
  } else if (idOrHeight === "latest") {
4465
4241
  variables = { height: (await this.getBlockNumber()).toString(10) };
4466
4242
  } else if (idOrHeight.length === 66) {
4467
4243
  variables = { blockId: idOrHeight };
4468
4244
  } else {
4469
- variables = { blockId: bn16(idOrHeight).toString(10) };
4245
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4470
4246
  }
4471
4247
  const { block } = await this.operations.getBlock(variables);
4472
4248
  if (!block) {
@@ -4474,7 +4250,7 @@ var _Provider = class {
4474
4250
  }
4475
4251
  return {
4476
4252
  id: block.id,
4477
- height: bn16(block.height),
4253
+ height: bn15(block.header.height),
4478
4254
  time: block.header.time,
4479
4255
  transactionIds: block.transactions.map((tx) => tx.id)
4480
4256
  };
@@ -4489,7 +4265,7 @@ var _Provider = class {
4489
4265
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4490
4266
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4491
4267
  id: block.id,
4492
- height: bn16(block.height),
4268
+ height: bn15(block.header.height),
4493
4269
  time: block.header.time,
4494
4270
  transactionIds: block.transactions.map((tx) => tx.id)
4495
4271
  }));
@@ -4504,7 +4280,7 @@ var _Provider = class {
4504
4280
  async getBlockWithTransactions(idOrHeight) {
4505
4281
  let variables;
4506
4282
  if (typeof idOrHeight === "number") {
4507
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4283
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4508
4284
  } else if (idOrHeight === "latest") {
4509
4285
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4510
4286
  } else {
@@ -4516,7 +4292,7 @@ var _Provider = class {
4516
4292
  }
4517
4293
  return {
4518
4294
  id: block.id,
4519
- height: bn16(block.height, 10),
4295
+ height: bn15(block.header.height, 10),
4520
4296
  time: block.header.time,
4521
4297
  transactionIds: block.transactions.map((tx) => tx.id),
4522
4298
  transactions: block.transactions.map(
@@ -4565,7 +4341,7 @@ var _Provider = class {
4565
4341
  contract: Address2.fromAddressOrString(contractId).toB256(),
4566
4342
  asset: hexlify12(assetId)
4567
4343
  });
4568
- return bn16(contractBalance.amount, 10);
4344
+ return bn15(contractBalance.amount, 10);
4569
4345
  }
4570
4346
  /**
4571
4347
  * Returns the balance for the given owner for the given asset ID.
@@ -4579,7 +4355,7 @@ var _Provider = class {
4579
4355
  owner: Address2.fromAddressOrString(owner).toB256(),
4580
4356
  assetId: hexlify12(assetId)
4581
4357
  });
4582
- return bn16(balance.amount, 10);
4358
+ return bn15(balance.amount, 10);
4583
4359
  }
4584
4360
  /**
4585
4361
  * Returns balances for the given owner.
@@ -4597,7 +4373,7 @@ var _Provider = class {
4597
4373
  const balances = result.balances.edges.map((edge) => edge.node);
4598
4374
  return balances.map((balance) => ({
4599
4375
  assetId: balance.assetId,
4600
- amount: bn16(balance.amount)
4376
+ amount: bn15(balance.amount)
4601
4377
  }));
4602
4378
  }
4603
4379
  /**
@@ -4619,15 +4395,15 @@ var _Provider = class {
4619
4395
  sender: message.sender,
4620
4396
  recipient: message.recipient,
4621
4397
  nonce: message.nonce,
4622
- amount: bn16(message.amount),
4398
+ amount: bn15(message.amount),
4623
4399
  data: message.data
4624
4400
  }),
4625
4401
  sender: Address2.fromAddressOrString(message.sender),
4626
4402
  recipient: Address2.fromAddressOrString(message.recipient),
4627
4403
  nonce: message.nonce,
4628
- amount: bn16(message.amount),
4404
+ amount: bn15(message.amount),
4629
4405
  data: InputMessageCoder.decodeData(message.data),
4630
- daHeight: bn16(message.daHeight)
4406
+ daHeight: bn15(message.daHeight)
4631
4407
  }));
4632
4408
  }
4633
4409
  /**
@@ -4680,60 +4456,44 @@ var _Provider = class {
4680
4456
  } = result.messageProof;
4681
4457
  return {
4682
4458
  messageProof: {
4683
- proofIndex: bn16(messageProof.proofIndex),
4459
+ proofIndex: bn15(messageProof.proofIndex),
4684
4460
  proofSet: messageProof.proofSet
4685
4461
  },
4686
4462
  blockProof: {
4687
- proofIndex: bn16(blockProof.proofIndex),
4463
+ proofIndex: bn15(blockProof.proofIndex),
4688
4464
  proofSet: blockProof.proofSet
4689
4465
  },
4690
4466
  messageBlockHeader: {
4691
4467
  id: messageBlockHeader.id,
4692
- daHeight: bn16(messageBlockHeader.daHeight),
4693
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4468
+ daHeight: bn15(messageBlockHeader.daHeight),
4469
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4694
4470
  transactionsRoot: messageBlockHeader.transactionsRoot,
4695
- height: bn16(messageBlockHeader.height),
4471
+ height: bn15(messageBlockHeader.height),
4696
4472
  prevRoot: messageBlockHeader.prevRoot,
4697
4473
  time: messageBlockHeader.time,
4698
4474
  applicationHash: messageBlockHeader.applicationHash,
4699
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4700
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4701
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4702
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4703
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4475
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4476
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4704
4477
  },
4705
4478
  commitBlockHeader: {
4706
4479
  id: commitBlockHeader.id,
4707
- daHeight: bn16(commitBlockHeader.daHeight),
4708
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4480
+ daHeight: bn15(commitBlockHeader.daHeight),
4481
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4709
4482
  transactionsRoot: commitBlockHeader.transactionsRoot,
4710
- height: bn16(commitBlockHeader.height),
4483
+ height: bn15(commitBlockHeader.height),
4711
4484
  prevRoot: commitBlockHeader.prevRoot,
4712
4485
  time: commitBlockHeader.time,
4713
4486
  applicationHash: commitBlockHeader.applicationHash,
4714
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4715
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4716
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4717
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4718
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4487
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4488
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4719
4489
  },
4720
4490
  sender: Address2.fromAddressOrString(sender),
4721
4491
  recipient: Address2.fromAddressOrString(recipient),
4722
4492
  nonce,
4723
- amount: bn16(amount),
4493
+ amount: bn15(amount),
4724
4494
  data
4725
4495
  };
4726
4496
  }
4727
- async getLatestGasPrice() {
4728
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4729
- return bn16(latestGasPrice.gasPrice);
4730
- }
4731
- async estimateGasPrice(blockHorizon) {
4732
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4733
- blockHorizon: String(blockHorizon)
4734
- });
4735
- return bn16(estimateGasPrice.gasPrice);
4736
- }
4737
4497
  /**
4738
4498
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4739
4499
  *
@@ -4753,10 +4513,10 @@ var _Provider = class {
4753
4513
  */
4754
4514
  async produceBlocks(amount, startTime) {
4755
4515
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4756
- blocksToProduce: bn16(amount).toString(10),
4516
+ blocksToProduce: bn15(amount).toString(10),
4757
4517
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4758
4518
  });
4759
- return bn16(latestBlockHeight);
4519
+ return bn15(latestBlockHeight);
4760
4520
  }
4761
4521
  // eslint-disable-next-line @typescript-eslint/require-await
4762
4522
  async getTransactionResponse(transactionId) {
@@ -4770,7 +4530,7 @@ cacheInputs_fn = function(inputs) {
4770
4530
  return;
4771
4531
  }
4772
4532
  inputs.forEach((input) => {
4773
- if (input.type === InputType7.Coin) {
4533
+ if (input.type === InputType6.Coin) {
4774
4534
  this.cache?.set(input.id);
4775
4535
  }
4776
4536
  });
@@ -4780,7 +4540,7 @@ __publicField(Provider, "nodeInfoCache", {});
4780
4540
 
4781
4541
  // src/providers/transaction-summary/get-transaction-summary.ts
4782
4542
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4783
- import { bn as bn17 } from "@fuel-ts/math";
4543
+ import { bn as bn16 } from "@fuel-ts/math";
4784
4544
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4785
4545
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4786
4546
  async function getTransactionSummary(params) {
@@ -4798,28 +4558,21 @@ async function getTransactionSummary(params) {
4798
4558
  arrayify12(gqlTransaction.rawPayload),
4799
4559
  0
4800
4560
  );
4801
- let txReceipts = [];
4802
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4803
- txReceipts = gqlTransaction.status.receipts;
4804
- }
4805
- const receipts = txReceipts.map(processGqlReceipt);
4561
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4806
4562
  const {
4807
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4563
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4808
4564
  } = provider.getChain();
4809
- const gasPrice = await provider.getLatestGasPrice();
4810
4565
  const transactionInfo = assembleTransactionSummary({
4811
4566
  id: gqlTransaction.id,
4812
4567
  receipts,
4813
4568
  transaction: decodedTransaction,
4814
4569
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4815
4570
  gqlTransactionStatus: gqlTransaction.status,
4816
- gasPerByte: bn17(gasPerByte),
4817
- gasPriceFactor: bn17(gasPriceFactor),
4571
+ gasPerByte: bn16(gasPerByte),
4572
+ gasPriceFactor: bn16(gasPriceFactor),
4818
4573
  abiMap,
4819
4574
  maxInputs,
4820
- gasCosts,
4821
- maxGasPerTx,
4822
- gasPrice
4575
+ gasCosts
4823
4576
  });
4824
4577
  return {
4825
4578
  gqlTransaction,
@@ -4829,11 +4582,10 @@ async function getTransactionSummary(params) {
4829
4582
  async function getTransactionSummaryFromRequest(params) {
4830
4583
  const { provider, transactionRequest, abiMap } = params;
4831
4584
  const { receipts } = await provider.call(transactionRequest);
4832
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4585
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4833
4586
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4834
4587
  const transaction = transactionRequest.toTransaction();
4835
4588
  const transactionBytes = transactionRequest.toTransactionBytes();
4836
- const gasPrice = await provider.getLatestGasPrice();
4837
4589
  const transactionSummary = assembleTransactionSummary({
4838
4590
  receipts,
4839
4591
  transaction,
@@ -4842,9 +4594,7 @@ async function getTransactionSummaryFromRequest(params) {
4842
4594
  gasPerByte,
4843
4595
  gasPriceFactor,
4844
4596
  maxInputs,
4845
- gasCosts,
4846
- maxGasPerTx,
4847
- gasPrice
4597
+ gasCosts
4848
4598
  });
4849
4599
  return transactionSummary;
4850
4600
  }
@@ -4853,18 +4603,13 @@ async function getTransactionsSummaries(params) {
4853
4603
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4854
4604
  const { edges, pageInfo } = transactionsByOwner;
4855
4605
  const {
4856
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4606
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4857
4607
  } = provider.getChain();
4858
- const gasPrice = await provider.getLatestGasPrice();
4859
4608
  const transactions = edges.map((edge) => {
4860
4609
  const { node: gqlTransaction } = edge;
4861
- const { id, rawPayload, status } = gqlTransaction;
4610
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4862
4611
  const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
4863
- let txReceipts = [];
4864
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4865
- txReceipts = gqlTransaction.status.receipts;
4866
- }
4867
- const receipts = txReceipts.map(processGqlReceipt);
4612
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4868
4613
  const transactionSummary = assembleTransactionSummary({
4869
4614
  id,
4870
4615
  receipts,
@@ -4875,9 +4620,7 @@ async function getTransactionsSummaries(params) {
4875
4620
  gasPerByte,
4876
4621
  gasPriceFactor,
4877
4622
  maxInputs,
4878
- gasCosts,
4879
- maxGasPerTx,
4880
- gasPrice
4623
+ gasCosts
4881
4624
  });
4882
4625
  const output = {
4883
4626
  gqlTransaction,
@@ -5210,31 +4953,38 @@ var Account = class extends AbstractAccount {
5210
4953
  * @param fee - The estimated transaction fee.
5211
4954
  * @returns A promise that resolves when the resources are added to the transaction.
5212
4955
  */
5213
- async fund(request, params) {
5214
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4956
+ async fund(request, coinQuantities, fee) {
5215
4957
  const baseAssetId = this.provider.getBaseAssetId();
5216
- const txRequest = request;
5217
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5218
- amount: bn18(fee),
4958
+ const updatedQuantities = addAmountToAsset({
4959
+ amount: bn17(fee),
5219
4960
  assetId: baseAssetId,
5220
- coinQuantities: requiredQuantities
4961
+ coinQuantities
5221
4962
  });
5222
4963
  const quantitiesDict = {};
5223
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4964
+ updatedQuantities.forEach(({ amount, assetId }) => {
5224
4965
  quantitiesDict[assetId] = {
5225
4966
  required: amount,
5226
- owned: bn18(0)
4967
+ owned: bn17(0)
5227
4968
  };
5228
4969
  });
5229
- txRequest.inputs.forEach((input) => {
4970
+ const cachedUtxos = [];
4971
+ const cachedMessages = [];
4972
+ const owner = this.address.toB256();
4973
+ request.inputs.forEach((input) => {
5230
4974
  const isResource = "amount" in input;
5231
- if (!isResource) {
5232
- return;
5233
- }
5234
- const isCoin2 = "owner" in input;
5235
- const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
5236
- if (quantitiesDict[assetId]) {
5237
- quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
4975
+ if (isResource) {
4976
+ const isCoin2 = "owner" in input;
4977
+ if (isCoin2) {
4978
+ const assetId = String(input.assetId);
4979
+ if (input.owner === owner && quantitiesDict[assetId]) {
4980
+ const amount = bn17(input.amount);
4981
+ quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4982
+ cachedUtxos.push(input.id);
4983
+ }
4984
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4985
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4986
+ cachedMessages.push(input.nonce);
4987
+ }
5238
4988
  }
5239
4989
  });
5240
4990
  const missingQuantities = [];
@@ -5248,21 +4998,12 @@ var Account = class extends AbstractAccount {
5248
4998
  });
5249
4999
  const needsToBeFunded = missingQuantities.length;
5250
5000
  if (needsToBeFunded) {
5251
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5252
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5253
- txRequest.addResources(resources);
5254
- }
5255
- txRequest.shiftPredicateData();
5256
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5257
- const requestToReestimate = clone4(txRequest);
5258
- if (addedSignatures) {
5259
- Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
5260
- }
5261
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5262
- transactionRequest: requestToReestimate
5263
- });
5264
- txRequest.maxFee = maxFee;
5265
- return txRequest;
5001
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5002
+ messages: cachedMessages,
5003
+ utxos: cachedUtxos
5004
+ });
5005
+ request.addResources(resources);
5006
+ }
5266
5007
  }
5267
5008
  /**
5268
5009
  * A helper that creates a transfer transaction request and returns it.
@@ -5270,25 +5011,29 @@ var Account = class extends AbstractAccount {
5270
5011
  * @param destination - The address of the destination.
5271
5012
  * @param amount - The amount of coins to transfer.
5272
5013
  * @param assetId - The asset ID of the coins to transfer.
5273
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5014
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5274
5015
  * @returns A promise that resolves to the prepared transaction request.
5275
5016
  */
5276
5017
  async createTransfer(destination, amount, assetId, txParams = {}) {
5277
- const request = new ScriptTransactionRequest(txParams);
5018
+ const { minGasPrice } = this.provider.getGasConfig();
5278
5019
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5020
+ const params = { gasPrice: minGasPrice, ...txParams };
5021
+ const request = new ScriptTransactionRequest(params);
5279
5022
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5280
- const txCost = await this.provider.getTransactionCost(request, {
5023
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5281
5024
  estimateTxDependencies: true,
5282
5025
  resourcesOwner: this
5283
5026
  });
5284
- this.validateGasLimitAndMaxFee({
5285
- gasUsed: txCost.gasUsed,
5286
- maxFee: txCost.maxFee,
5287
- txParams
5027
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5028
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
5029
+ this.validateGas({
5030
+ gasUsed,
5031
+ gasPrice: request.gasPrice,
5032
+ gasLimit: request.gasLimit,
5033
+ minGasPrice
5288
5034
  });
5289
- request.gasLimit = txCost.gasUsed;
5290
- request.maxFee = txCost.maxFee;
5291
- await this.fund(request, txCost);
5035
+ await this.fund(request, requiredQuantities, maxFee);
5036
+ request.updatePredicateInputs(estimatedInputs);
5292
5037
  return request;
5293
5038
  }
5294
5039
  /**
@@ -5297,11 +5042,11 @@ var Account = class extends AbstractAccount {
5297
5042
  * @param destination - The address of the destination.
5298
5043
  * @param amount - The amount of coins to transfer.
5299
5044
  * @param assetId - The asset ID of the coins to transfer.
5300
- * @param txParams - The transaction parameters (gasLimit, maturity).
5045
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5301
5046
  * @returns A promise that resolves to the transaction response.
5302
5047
  */
5303
5048
  async transfer(destination, amount, assetId, txParams = {}) {
5304
- if (bn18(amount).lte(0)) {
5049
+ if (bn17(amount).lte(0)) {
5305
5050
  throw new FuelError15(
5306
5051
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5307
5052
  "Transfer amount must be a positive number."
@@ -5321,37 +5066,39 @@ var Account = class extends AbstractAccount {
5321
5066
  * @returns A promise that resolves to the transaction response.
5322
5067
  */
5323
5068
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5324
- if (bn18(amount).lte(0)) {
5069
+ if (bn17(amount).lte(0)) {
5325
5070
  throw new FuelError15(
5326
5071
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5327
5072
  "Transfer amount must be a positive number."
5328
5073
  );
5329
5074
  }
5330
5075
  const contractAddress = Address3.fromAddressOrString(contractId);
5076
+ const { minGasPrice } = this.provider.getGasConfig();
5331
5077
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5078
+ const params = { gasPrice: minGasPrice, ...txParams };
5332
5079
  const { script, scriptData } = await assembleTransferToContractScript({
5333
5080
  hexlifiedContractId: contractAddress.toB256(),
5334
- amountToTransfer: bn18(amount),
5081
+ amountToTransfer: bn17(amount),
5335
5082
  assetId: assetIdToTransfer
5336
5083
  });
5337
5084
  const request = new ScriptTransactionRequest({
5338
- ...txParams,
5085
+ ...params,
5339
5086
  script,
5340
5087
  scriptData
5341
5088
  });
5342
5089
  request.addContractInputAndOutput(contractAddress);
5343
- const txCost = await this.provider.getTransactionCost(request, {
5344
- resourcesOwner: this,
5345
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetIdToTransfer) }]
5346
- });
5347
- this.validateGasLimitAndMaxFee({
5348
- gasUsed: txCost.gasUsed,
5349
- maxFee: txCost.maxFee,
5350
- txParams
5090
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5091
+ request,
5092
+ [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
5093
+ );
5094
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5095
+ this.validateGas({
5096
+ gasUsed,
5097
+ gasPrice: request.gasPrice,
5098
+ gasLimit: request.gasLimit,
5099
+ minGasPrice
5351
5100
  });
5352
- request.gasLimit = txCost.gasUsed;
5353
- request.maxFee = txCost.maxFee;
5354
- await this.fund(request, txCost);
5101
+ await this.fund(request, requiredQuantities, maxFee);
5355
5102
  return this.sendTransaction(request);
5356
5103
  }
5357
5104
  /**
@@ -5363,31 +5110,39 @@ var Account = class extends AbstractAccount {
5363
5110
  * @returns A promise that resolves to the transaction response.
5364
5111
  */
5365
5112
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5113
+ const { minGasPrice } = this.provider.getGasConfig();
5114
+ const baseAssetId = this.provider.getBaseAssetId();
5366
5115
  const recipientAddress = Address3.fromAddressOrString(recipient);
5367
5116
  const recipientDataArray = arrayify14(
5368
5117
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5369
5118
  );
5370
5119
  const amountDataArray = arrayify14(
5371
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
5120
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5372
5121
  );
5373
5122
  const script = new Uint8Array([
5374
5123
  ...arrayify14(withdrawScript.bytes),
5375
5124
  ...recipientDataArray,
5376
5125
  ...amountDataArray
5377
5126
  ]);
5378
- const params = { script, ...txParams };
5379
- const baseAssetId = this.provider.getBaseAssetId();
5127
+ const params = {
5128
+ script,
5129
+ gasPrice: minGasPrice,
5130
+ ...txParams
5131
+ };
5380
5132
  const request = new ScriptTransactionRequest(params);
5381
- const quantitiesToContract = [{ amount: bn18(amount), assetId: baseAssetId }];
5382
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5383
- this.validateGasLimitAndMaxFee({
5384
- gasUsed: txCost.gasUsed,
5385
- maxFee: txCost.maxFee,
5386
- txParams
5133
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
5134
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5135
+ request,
5136
+ forwardingQuantities
5137
+ );
5138
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5139
+ this.validateGas({
5140
+ gasUsed,
5141
+ gasPrice: request.gasPrice,
5142
+ gasLimit: request.gasLimit,
5143
+ minGasPrice
5387
5144
  });
5388
- request.maxFee = txCost.maxFee;
5389
- request.gasLimit = txCost.gasUsed;
5390
- await this.fund(request, txCost);
5145
+ await this.fund(request, requiredQuantities, maxFee);
5391
5146
  return this.sendTransaction(request);
5392
5147
  }
5393
5148
  async signMessage(message) {
@@ -5445,21 +5200,22 @@ var Account = class extends AbstractAccount {
5445
5200
  }
5446
5201
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5447
5202
  }
5448
- validateGasLimitAndMaxFee({
5449
- txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
5203
+ validateGas({
5450
5204
  gasUsed,
5451
- maxFee
5205
+ gasPrice,
5206
+ gasLimit,
5207
+ minGasPrice
5452
5208
  }) {
5453
- if (isDefined(setGasLimit) && gasUsed.gt(setGasLimit)) {
5209
+ if (minGasPrice.gt(gasPrice)) {
5454
5210
  throw new FuelError15(
5455
- ErrorCode15.GAS_LIMIT_TOO_LOW,
5456
- `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5211
+ ErrorCode15.GAS_PRICE_TOO_LOW,
5212
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5457
5213
  );
5458
5214
  }
5459
- if (isDefined(setMaxFee) && maxFee.gt(setMaxFee)) {
5215
+ if (gasUsed.gt(gasLimit)) {
5460
5216
  throw new FuelError15(
5461
- ErrorCode15.MAX_FEE_TOO_LOW,
5462
- `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
5217
+ ErrorCode15.GAS_LIMIT_TOO_LOW,
5218
+ `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5463
5219
  );
5464
5220
  }
5465
5221
  }
@@ -5751,7 +5507,7 @@ var BaseWalletUnlocked = class extends Account {
5751
5507
  * @param transactionRequestLike - The transaction request to send.
5752
5508
  * @returns A promise that resolves to the TransactionResponse object.
5753
5509
  */
5754
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5510
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5755
5511
  const transactionRequest = transactionRequestify(transactionRequestLike);
5756
5512
  if (estimateTxDependencies) {
5757
5513
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5792,7 +5548,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5792
5548
  // src/hdwallet/hdwallet.ts
5793
5549
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5794
5550
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5795
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5551
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5796
5552
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5797
5553
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5798
5554
 
@@ -8264,7 +8020,7 @@ var HDWallet = class {
8264
8020
  const IR = bytes.slice(32);
8265
8021
  if (privateKey) {
8266
8022
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8267
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
8023
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
8268
8024
  return new HDWallet({
8269
8025
  privateKey: ki,
8270
8026
  chainCode: IR,
@@ -8952,7 +8708,7 @@ import {
8952
8708
  } from "@fuel-ts/abi-coder";
8953
8709
  import { Address as Address9 } from "@fuel-ts/address";
8954
8710
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8955
- import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
8711
+ import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8956
8712
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8957
8713
 
8958
8714
  // src/predicate/utils/getPredicateRoot.ts
@@ -9012,22 +8768,36 @@ var Predicate = class extends Account {
9012
8768
  const request = transactionRequestify(transactionRequestLike);
9013
8769
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9014
8770
  request.inputs?.forEach((input) => {
9015
- if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
9016
- input.predicate = hexlify19(this.bytes);
9017
- input.predicateData = hexlify19(this.getPredicateData(policies.length));
8771
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8772
+ input.predicate = this.bytes;
8773
+ input.predicateData = this.getPredicateData(policies.length);
9018
8774
  }
9019
8775
  });
9020
8776
  return request;
9021
8777
  }
8778
+ /**
8779
+ * A helper that creates a transfer transaction request and returns it.
8780
+ *
8781
+ * @param destination - The address of the destination.
8782
+ * @param amount - The amount of coins to transfer.
8783
+ * @param assetId - The asset ID of the coins to transfer.
8784
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8785
+ * @returns A promise that resolves to the prepared transaction request.
8786
+ */
8787
+ async createTransfer(destination, amount, assetId, txParams = {}) {
8788
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8789
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8790
+ return this.populateTransactionPredicateData(request);
8791
+ }
9022
8792
  /**
9023
8793
  * Sends a transaction with the populated predicate data.
9024
8794
  *
9025
8795
  * @param transactionRequestLike - The transaction request-like object.
9026
8796
  * @returns A promise that resolves to the transaction response.
9027
8797
  */
9028
- sendTransaction(transactionRequestLike) {
9029
- const transactionRequest = transactionRequestify(transactionRequestLike);
9030
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8798
+ sendTransaction(transactionRequestLike, options) {
8799
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8800
+ return super.sendTransaction(transactionRequest, options);
9031
8801
  }
9032
8802
  /**
9033
8803
  * Simulates a transaction with the populated predicate data.
@@ -9036,8 +8806,8 @@ var Predicate = class extends Account {
9036
8806
  * @returns A promise that resolves to the call result.
9037
8807
  */
9038
8808
  simulateTransaction(transactionRequestLike) {
9039
- const transactionRequest = transactionRequestify(transactionRequestLike);
9040
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8809
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8810
+ return super.simulateTransaction(transactionRequest);
9041
8811
  }
9042
8812
  getPredicateData(policiesLength) {
9043
8813
  if (!this.predicateData.length) {
@@ -9083,25 +8853,6 @@ var Predicate = class extends Account {
9083
8853
  predicateInterface: abiInterface
9084
8854
  };
9085
8855
  }
9086
- /**
9087
- * Retrieves resources satisfying the spend query for the account.
9088
- *
9089
- * @param quantities - IDs of coins to exclude.
9090
- * @param excludedIds - IDs of resources to be excluded from the query.
9091
- * @returns A promise that resolves to an array of Resources.
9092
- */
9093
- async getResourcesToSpend(quantities, excludedIds) {
9094
- const resources = await this.provider.getResourcesToSpend(
9095
- this.address,
9096
- quantities,
9097
- excludedIds
9098
- );
9099
- return resources.map((resource) => ({
9100
- ...resource,
9101
- predicate: hexlify19(this.bytes),
9102
- padPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
9103
- }));
9104
- }
9105
8856
  /**
9106
8857
  * Sets the configurable constants for the predicate.
9107
8858
  *
@@ -9850,7 +9601,7 @@ export {
9850
9601
  WalletLocked,
9851
9602
  WalletManager,
9852
9603
  WalletUnlocked,
9853
- addAmountToCoinQuantities,
9604
+ addAmountToAsset,
9854
9605
  addOperation,
9855
9606
  assemblePanicError,
9856
9607
  assembleReceiptByType,
@@ -9859,10 +9610,9 @@ export {
9859
9610
  assets,
9860
9611
  buildBlockExplorerUrl,
9861
9612
  cacheFor,
9862
- cacheTxInputsFromOwner,
9863
- calculateGasFee,
9864
9613
  calculateMetadataGasForTxCreate,
9865
9614
  calculateMetadataGasForTxScript,
9615
+ calculatePriceWithFactor,
9866
9616
  calculateTransactionFee,
9867
9617
  coinQuantityfy,
9868
9618
  deferPromise,