@fuel-ts/account 0.0.0-rc-2037-20240423134048 → 0.0.0-rc-2021-20240423134551

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 (66) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +5 -4
  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 +829 -600
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +857 -637
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +680 -455
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +11 -18
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +822 -328
  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 -1
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +6 -1
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +37 -27
  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/index.d.ts +0 -1
  31. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/input.d.ts +2 -2
  33. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/transaction-request.d.ts +6 -7
  36. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  37. package/dist/providers/transaction-request/utils.d.ts +3 -0
  38. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  39. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
  41. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
  43. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  45. package/dist/providers/utils/gas.d.ts +8 -2
  46. package/dist/providers/utils/gas.d.ts.map +1 -1
  47. package/dist/test-utils/index.d.ts +0 -1
  48. package/dist/test-utils/index.d.ts.map +1 -1
  49. package/dist/test-utils/launchNode.d.ts.map +1 -1
  50. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  51. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  52. package/dist/test-utils.global.js +1545 -1076
  53. package/dist/test-utils.global.js.map +1 -1
  54. package/dist/test-utils.js +837 -612
  55. package/dist/test-utils.js.map +1 -1
  56. package/dist/test-utils.mjs +674 -446
  57. package/dist/test-utils.mjs.map +1 -1
  58. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  59. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  60. package/package.json +16 -16
  61. package/dist/providers/transaction-request/helpers.d.ts +0 -10
  62. package/dist/providers/transaction-request/helpers.d.ts.map +0 -1
  63. package/dist/test-utils/resources.d.ts +0 -4
  64. package/dist/test-utils/resources.d.ts.map +0 -1
  65. package/dist/test-utils/transactionRequest.d.ts +0 -5
  66. package/dist/test-utils/transactionRequest.d.ts.map +0 -1
@@ -27,8 +27,9 @@ import { Address as Address3 } from "@fuel-ts/address";
27
27
  import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
28
28
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
29
29
  import { AbstractAccount } from "@fuel-ts/interfaces";
30
- import { bn as bn17 } from "@fuel-ts/math";
30
+ import { bn as bn18 } from "@fuel-ts/math";
31
31
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
32
+ import { clone as clone4 } from "ramda";
32
33
 
33
34
  // src/providers/coin-quantity.ts
34
35
  import { BaseAssetId } from "@fuel-ts/address/configs";
@@ -37,24 +38,24 @@ import { hexlify } from "@fuel-ts/utils";
37
38
  var coinQuantityfy = (coinQuantityLike) => {
38
39
  let assetId;
39
40
  let amount;
40
- let max2;
41
+ let max;
41
42
  if (Array.isArray(coinQuantityLike)) {
42
43
  amount = coinQuantityLike[0];
43
44
  assetId = coinQuantityLike[1] ?? BaseAssetId;
44
- max2 = coinQuantityLike[2] ?? void 0;
45
+ max = coinQuantityLike[2] ?? void 0;
45
46
  } else {
46
47
  amount = coinQuantityLike.amount;
47
48
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
48
- max2 = coinQuantityLike.max ?? void 0;
49
+ max = coinQuantityLike.max ?? void 0;
49
50
  }
50
51
  const bnAmount = bn(amount);
51
52
  return {
52
53
  assetId: hexlify(assetId),
53
54
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
54
- max: max2 ? bn(max2) : void 0
55
+ max: max ? bn(max) : void 0
55
56
  };
56
57
  };
57
- var addAmountToAsset = (params) => {
58
+ var addAmountToCoinQuantities = (params) => {
58
59
  const { amount, assetId } = params;
59
60
  const coinQuantities = [...params.coinQuantities];
60
61
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -69,7 +70,7 @@ var addAmountToAsset = (params) => {
69
70
  // src/providers/provider.ts
70
71
  import { Address as Address2 } from "@fuel-ts/address";
71
72
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
72
- import { BN, bn as bn15, max } from "@fuel-ts/math";
73
+ import { BN, bn as bn16 } from "@fuel-ts/math";
73
74
  import {
74
75
  InputType as InputType7,
75
76
  TransactionType as TransactionType8,
@@ -85,16 +86,40 @@ import { clone as clone3 } from "ramda";
85
86
 
86
87
  // src/providers/__generated__/operations.ts
87
88
  import gql from "graphql-tag";
89
+ var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
90
+ fragment transactionStatusSubscriptionFragment on TransactionStatus {
91
+ type: __typename
92
+ ... on SubmittedStatus {
93
+ time
94
+ }
95
+ ... on SuccessStatus {
96
+ block {
97
+ id
98
+ }
99
+ time
100
+ programState {
101
+ returnType
102
+ data
103
+ }
104
+ }
105
+ ... on FailureStatus {
106
+ block {
107
+ id
108
+ }
109
+ time
110
+ reason
111
+ }
112
+ ... on SqueezedOutStatus {
113
+ reason
114
+ }
115
+ }
116
+ `;
88
117
  var ReceiptFragmentFragmentDoc = gql`
89
118
  fragment receiptFragment on Receipt {
90
- contract {
91
- id
92
- }
119
+ id
93
120
  pc
94
121
  is
95
- to {
96
- id
97
- }
122
+ to
98
123
  toAddress
99
124
  amount
100
125
  assetId
@@ -132,10 +157,16 @@ var TransactionStatusFragmentFragmentDoc = gql`
132
157
  id
133
158
  }
134
159
  time
160
+ receipts {
161
+ ...receiptFragment
162
+ }
135
163
  programState {
136
164
  returnType
137
165
  data
138
166
  }
167
+ receipts {
168
+ ...receiptFragment
169
+ }
139
170
  }
140
171
  ... on FailureStatus {
141
172
  block {
@@ -143,26 +174,24 @@ var TransactionStatusFragmentFragmentDoc = gql`
143
174
  }
144
175
  time
145
176
  reason
177
+ receipts {
178
+ ...receiptFragment
179
+ }
146
180
  }
147
181
  ... on SqueezedOutStatus {
148
182
  reason
149
183
  }
150
184
  }
151
- `;
185
+ ${ReceiptFragmentFragmentDoc}`;
152
186
  var TransactionFragmentFragmentDoc = gql`
153
187
  fragment transactionFragment on Transaction {
154
188
  id
155
189
  rawPayload
156
- gasPrice
157
- receipts {
158
- ...receiptFragment
159
- }
160
190
  status {
161
191
  ...transactionStatusFragment
162
192
  }
163
193
  }
164
- ${ReceiptFragmentFragmentDoc}
165
- ${TransactionStatusFragmentFragmentDoc}`;
194
+ ${TransactionStatusFragmentFragmentDoc}`;
166
195
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
167
196
  fragment inputEstimatePredicatesFragment on Input {
168
197
  ... on InputCoin {
@@ -180,6 +209,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
180
209
  }
181
210
  }
182
211
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
212
+ var DryRunFailureStatusFragmentFragmentDoc = gql`
213
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
214
+ reason
215
+ programState {
216
+ returnType
217
+ data
218
+ }
219
+ }
220
+ `;
221
+ var DryRunSuccessStatusFragmentFragmentDoc = gql`
222
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
223
+ programState {
224
+ returnType
225
+ data
226
+ }
227
+ }
228
+ `;
229
+ var DryRunTransactionStatusFragmentFragmentDoc = gql`
230
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
231
+ ... on DryRunFailureStatus {
232
+ ...dryRunFailureStatusFragment
233
+ }
234
+ ... on DryRunSuccessStatus {
235
+ ...dryRunSuccessStatusFragment
236
+ }
237
+ }
238
+ ${DryRunFailureStatusFragmentFragmentDoc}
239
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
240
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
241
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
242
+ id
243
+ status {
244
+ ...dryRunTransactionStatusFragment
245
+ }
246
+ receipts {
247
+ ...receiptFragment
248
+ }
249
+ }
250
+ ${DryRunTransactionStatusFragmentFragmentDoc}
251
+ ${ReceiptFragmentFragmentDoc}`;
183
252
  var CoinFragmentFragmentDoc = gql`
184
253
  fragment coinFragment on Coin {
185
254
  __typename
@@ -187,7 +256,6 @@ var CoinFragmentFragmentDoc = gql`
187
256
  owner
188
257
  amount
189
258
  assetId
190
- maturity
191
259
  blockCreated
192
260
  txCreatedIdx
193
261
  }
@@ -226,26 +294,32 @@ var MessageProofFragmentFragmentDoc = gql`
226
294
  messageBlockHeader {
227
295
  id
228
296
  daHeight
297
+ consensusParametersVersion
298
+ stateTransitionBytecodeVersion
229
299
  transactionsCount
300
+ messageReceiptCount
230
301
  transactionsRoot
302
+ messageOutboxRoot
303
+ eventInboxRoot
231
304
  height
232
305
  prevRoot
233
306
  time
234
307
  applicationHash
235
- messageReceiptRoot
236
- messageReceiptCount
237
308
  }
238
309
  commitBlockHeader {
239
310
  id
240
311
  daHeight
312
+ consensusParametersVersion
313
+ stateTransitionBytecodeVersion
241
314
  transactionsCount
315
+ messageReceiptCount
242
316
  transactionsRoot
317
+ messageOutboxRoot
318
+ eventInboxRoot
243
319
  height
244
320
  prevRoot
245
321
  time
246
322
  applicationHash
247
- messageReceiptRoot
248
- messageReceiptCount
249
323
  }
250
324
  sender
251
325
  recipient
@@ -264,8 +338,8 @@ var BalanceFragmentFragmentDoc = gql`
264
338
  var BlockFragmentFragmentDoc = gql`
265
339
  fragment blockFragment on Block {
266
340
  id
341
+ height
267
342
  header {
268
- height
269
343
  time
270
344
  }
271
345
  transactions {
@@ -323,6 +397,11 @@ var DependentCostFragmentFragmentDoc = gql`
323
397
  `;
324
398
  var GasCostsFragmentFragmentDoc = gql`
325
399
  fragment GasCostsFragment on GasCosts {
400
+ version {
401
+ ... on Version {
402
+ value
403
+ }
404
+ }
326
405
  add
327
406
  addi
328
407
  aloc
@@ -335,7 +414,6 @@ var GasCostsFragmentFragmentDoc = gql`
335
414
  cb
336
415
  cfei
337
416
  cfsi
338
- croo
339
417
  div
340
418
  divi
341
419
  ecr1
@@ -418,6 +496,9 @@ var GasCostsFragmentFragmentDoc = gql`
418
496
  ccp {
419
497
  ...DependentCostFragment
420
498
  }
499
+ croo {
500
+ ...DependentCostFragment
501
+ }
421
502
  csiz {
422
503
  ...DependentCostFragment
423
504
  }
@@ -477,6 +558,11 @@ var GasCostsFragmentFragmentDoc = gql`
477
558
  ${DependentCostFragmentFragmentDoc}`;
478
559
  var ConsensusParametersFragmentFragmentDoc = gql`
479
560
  fragment consensusParametersFragment on ConsensusParameters {
561
+ version {
562
+ ... on Version {
563
+ value
564
+ }
565
+ }
480
566
  txParams {
481
567
  ...TxParametersFragment
482
568
  }
@@ -536,18 +622,9 @@ var NodeInfoFragmentFragmentDoc = gql`
536
622
  fragment nodeInfoFragment on NodeInfo {
537
623
  utxoValidation
538
624
  vmBacktrace
539
- minGasPrice
540
625
  maxTx
541
626
  maxDepth
542
627
  nodeVersion
543
- peers {
544
- id
545
- addresses
546
- clientVersion
547
- blockHeight
548
- lastHeartbeatMs
549
- appScore
550
- }
551
628
  }
552
629
  `;
553
630
  var GetVersionDocument = gql`
@@ -582,13 +659,9 @@ var GetTransactionWithReceiptsDocument = gql`
582
659
  query getTransactionWithReceipts($transactionId: TransactionId!) {
583
660
  transaction(id: $transactionId) {
584
661
  ...transactionFragment
585
- receipts {
586
- ...receiptFragment
587
- }
588
662
  }
589
663
  }
590
- ${TransactionFragmentFragmentDoc}
591
- ${ReceiptFragmentFragmentDoc}`;
664
+ ${TransactionFragmentFragmentDoc}`;
592
665
  var GetTransactionsDocument = gql`
593
666
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
594
667
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -716,6 +789,20 @@ var GetBalanceDocument = gql`
716
789
  }
717
790
  }
718
791
  ${BalanceFragmentFragmentDoc}`;
792
+ var GetLatestGasPriceDocument = gql`
793
+ query getLatestGasPrice {
794
+ latestGasPrice {
795
+ gasPrice
796
+ }
797
+ }
798
+ `;
799
+ var EstimateGasPriceDocument = gql`
800
+ query estimateGasPrice($blockHorizon: U32!) {
801
+ estimateGasPrice(blockHorizon: $blockHorizon) {
802
+ gasPrice
803
+ }
804
+ }
805
+ `;
719
806
  var GetBalancesDocument = gql`
720
807
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
721
808
  balances(
@@ -770,12 +857,12 @@ var GetMessageStatusDocument = gql`
770
857
  }
771
858
  `;
772
859
  var DryRunDocument = gql`
773
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
774
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
775
- ...receiptFragment
860
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
861
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
862
+ ...dryRunTransactionExecutionStatusFragment
776
863
  }
777
864
  }
778
- ${ReceiptFragmentFragmentDoc}`;
865
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
779
866
  var SubmitDocument = gql`
780
867
  mutation submit($encodedTransaction: HexString!) {
781
868
  submit(tx: $encodedTransaction) {
@@ -794,17 +881,17 @@ var ProduceBlocksDocument = gql`
794
881
  var SubmitAndAwaitDocument = gql`
795
882
  subscription submitAndAwait($encodedTransaction: HexString!) {
796
883
  submitAndAwait(tx: $encodedTransaction) {
797
- ...transactionStatusFragment
884
+ ...transactionStatusSubscriptionFragment
798
885
  }
799
886
  }
800
- ${TransactionStatusFragmentFragmentDoc}`;
887
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
801
888
  var StatusChangeDocument = gql`
802
889
  subscription statusChange($transactionId: TransactionId!) {
803
890
  statusChange(id: $transactionId) {
804
- ...transactionStatusFragment
891
+ ...transactionStatusSubscriptionFragment
805
892
  }
806
893
  }
807
- ${TransactionStatusFragmentFragmentDoc}`;
894
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
808
895
  function getSdk(requester) {
809
896
  return {
810
897
  getVersion(variables, options) {
@@ -858,6 +945,12 @@ function getSdk(requester) {
858
945
  getBalance(variables, options) {
859
946
  return requester(GetBalanceDocument, variables, options);
860
947
  },
948
+ getLatestGasPrice(variables, options) {
949
+ return requester(GetLatestGasPriceDocument, variables, options);
950
+ },
951
+ estimateGasPrice(variables, options) {
952
+ return requester(EstimateGasPriceDocument, variables, options);
953
+ },
861
954
  getBalances(variables, options) {
862
955
  return requester(GetBalancesDocument, variables, options);
863
956
  },
@@ -1051,10 +1144,9 @@ var inputify = (value) => {
1051
1144
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1052
1145
  },
1053
1146
  witnessIndex: value.witnessIndex,
1054
- maturity: value.maturity ?? 0,
1055
1147
  predicateGasUsed: bn2(value.predicateGasUsed),
1056
- predicateLength: predicate.length,
1057
- predicateDataLength: predicateData.length,
1148
+ predicateLength: bn2(predicate.length),
1149
+ predicateDataLength: bn2(predicateData.length),
1058
1150
  predicate: hexlify3(predicate),
1059
1151
  predicateData: hexlify3(predicateData)
1060
1152
  };
@@ -1085,8 +1177,8 @@ var inputify = (value) => {
1085
1177
  nonce: hexlify3(value.nonce),
1086
1178
  witnessIndex: value.witnessIndex,
1087
1179
  predicateGasUsed: bn2(value.predicateGasUsed),
1088
- predicateLength: predicate.length,
1089
- predicateDataLength: predicateData.length,
1180
+ predicateLength: bn2(predicate.length),
1181
+ predicateDataLength: bn2(predicateData.length),
1090
1182
  predicate: hexlify3(predicate),
1091
1183
  predicateData: hexlify3(predicateData),
1092
1184
  data: hexlify3(data),
@@ -1168,7 +1260,7 @@ import { bn as bn7 } from "@fuel-ts/math";
1168
1260
  import {
1169
1261
  PolicyType,
1170
1262
  TransactionCoder,
1171
- InputType as InputType3,
1263
+ InputType as InputType2,
1172
1264
  OutputType as OutputType2,
1173
1265
  TransactionType
1174
1266
  } from "@fuel-ts/transactions";
@@ -1213,8 +1305,8 @@ function assembleReceiptByType(receipt) {
1213
1305
  case "CALL" /* Call */: {
1214
1306
  const callReceipt = {
1215
1307
  type: ReceiptType.Call,
1216
- from: hexOrZero(receipt.contract?.id),
1217
- to: hexOrZero(receipt?.to?.id),
1308
+ from: hexOrZero(receipt.id || receipt.contractId),
1309
+ to: hexOrZero(receipt?.to),
1218
1310
  amount: bn4(receipt.amount),
1219
1311
  assetId: hexOrZero(receipt.assetId),
1220
1312
  gas: bn4(receipt.gas),
@@ -1228,7 +1320,7 @@ function assembleReceiptByType(receipt) {
1228
1320
  case "RETURN" /* Return */: {
1229
1321
  const returnReceipt = {
1230
1322
  type: ReceiptType.Return,
1231
- id: hexOrZero(receipt.contract?.id),
1323
+ id: hexOrZero(receipt.id || receipt.contractId),
1232
1324
  val: bn4(receipt.val),
1233
1325
  pc: bn4(receipt.pc),
1234
1326
  is: bn4(receipt.is)
@@ -1238,7 +1330,7 @@ function assembleReceiptByType(receipt) {
1238
1330
  case "RETURN_DATA" /* ReturnData */: {
1239
1331
  const returnDataReceipt = {
1240
1332
  type: ReceiptType.ReturnData,
1241
- id: hexOrZero(receipt.contract?.id),
1333
+ id: hexOrZero(receipt.id || receipt.contractId),
1242
1334
  ptr: bn4(receipt.ptr),
1243
1335
  len: bn4(receipt.len),
1244
1336
  digest: hexOrZero(receipt.digest),
@@ -1250,7 +1342,7 @@ function assembleReceiptByType(receipt) {
1250
1342
  case "PANIC" /* Panic */: {
1251
1343
  const panicReceipt = {
1252
1344
  type: ReceiptType.Panic,
1253
- id: hexOrZero(receipt.contract?.id),
1345
+ id: hexOrZero(receipt.id),
1254
1346
  reason: bn4(receipt.reason),
1255
1347
  pc: bn4(receipt.pc),
1256
1348
  is: bn4(receipt.is),
@@ -1261,7 +1353,7 @@ function assembleReceiptByType(receipt) {
1261
1353
  case "REVERT" /* Revert */: {
1262
1354
  const revertReceipt = {
1263
1355
  type: ReceiptType.Revert,
1264
- id: hexOrZero(receipt.contract?.id),
1356
+ id: hexOrZero(receipt.id || receipt.contractId),
1265
1357
  val: bn4(receipt.ra),
1266
1358
  pc: bn4(receipt.pc),
1267
1359
  is: bn4(receipt.is)
@@ -1271,7 +1363,7 @@ function assembleReceiptByType(receipt) {
1271
1363
  case "LOG" /* Log */: {
1272
1364
  const logReceipt = {
1273
1365
  type: ReceiptType.Log,
1274
- id: hexOrZero(receipt.contract?.id),
1366
+ id: hexOrZero(receipt.id || receipt.contractId),
1275
1367
  val0: bn4(receipt.ra),
1276
1368
  val1: bn4(receipt.rb),
1277
1369
  val2: bn4(receipt.rc),
@@ -1284,7 +1376,7 @@ function assembleReceiptByType(receipt) {
1284
1376
  case "LOG_DATA" /* LogData */: {
1285
1377
  const logDataReceipt = {
1286
1378
  type: ReceiptType.LogData,
1287
- id: hexOrZero(receipt.contract?.id),
1379
+ id: hexOrZero(receipt.id || receipt.contractId),
1288
1380
  val0: bn4(receipt.ra),
1289
1381
  val1: bn4(receipt.rb),
1290
1382
  ptr: bn4(receipt.ptr),
@@ -1298,8 +1390,8 @@ function assembleReceiptByType(receipt) {
1298
1390
  case "TRANSFER" /* Transfer */: {
1299
1391
  const transferReceipt = {
1300
1392
  type: ReceiptType.Transfer,
1301
- from: hexOrZero(receipt.contract?.id),
1302
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1393
+ from: hexOrZero(receipt.id || receipt.contractId),
1394
+ to: hexOrZero(receipt.toAddress || receipt?.to),
1303
1395
  amount: bn4(receipt.amount),
1304
1396
  assetId: hexOrZero(receipt.assetId),
1305
1397
  pc: bn4(receipt.pc),
@@ -1310,8 +1402,8 @@ function assembleReceiptByType(receipt) {
1310
1402
  case "TRANSFER_OUT" /* TransferOut */: {
1311
1403
  const transferOutReceipt = {
1312
1404
  type: ReceiptType.TransferOut,
1313
- from: hexOrZero(receipt.contract?.id),
1314
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
1405
+ from: hexOrZero(receipt.id || receipt.contractId),
1406
+ to: hexOrZero(receipt.toAddress || receipt.to),
1315
1407
  amount: bn4(receipt.amount),
1316
1408
  assetId: hexOrZero(receipt.assetId),
1317
1409
  pc: bn4(receipt.pc),
@@ -1354,7 +1446,7 @@ function assembleReceiptByType(receipt) {
1354
1446
  return receiptMessageOut;
1355
1447
  }
1356
1448
  case "MINT" /* Mint */: {
1357
- const contractId = hexOrZero(receipt.contract?.id);
1449
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1358
1450
  const subId = hexOrZero(receipt.subId);
1359
1451
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1360
1452
  const mintReceipt = {
@@ -1369,7 +1461,7 @@ function assembleReceiptByType(receipt) {
1369
1461
  return mintReceipt;
1370
1462
  }
1371
1463
  case "BURN" /* Burn */: {
1372
- const contractId = hexOrZero(receipt.contract?.id);
1464
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1373
1465
  const subId = hexOrZero(receipt.subId);
1374
1466
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1375
1467
  const burnReceipt = {
@@ -1395,7 +1487,6 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
1395
1487
  import { bn as bn5 } from "@fuel-ts/math";
1396
1488
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1397
1489
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1398
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1399
1490
  var getGasUsedFromReceipts = (receipts) => {
1400
1491
  const scriptResult = receipts.filter(
1401
1492
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1416,18 +1507,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1416
1507
  }
1417
1508
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1418
1509
  const witnessCache = [];
1419
- const totalGas = inputs.reduce((total, input) => {
1510
+ const chargeableInputs = inputs.filter((input) => {
1511
+ const isCoinOrMessage = "owner" in input || "sender" in input;
1512
+ if (isCoinOrMessage) {
1513
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1514
+ return true;
1515
+ }
1516
+ if (!witnessCache.includes(input.witnessIndex)) {
1517
+ witnessCache.push(input.witnessIndex);
1518
+ return true;
1519
+ }
1520
+ }
1521
+ return false;
1522
+ });
1523
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1524
+ const totalGas = chargeableInputs.reduce((total, input) => {
1420
1525
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1421
1526
  return total.add(
1422
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1527
+ vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1423
1528
  );
1424
1529
  }
1425
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1426
- witnessCache.push(input.witnessIndex);
1427
- return total.add(gasCosts.ecr1);
1428
- }
1429
- return total;
1430
- }, bn5());
1530
+ return total.add(gasCosts.ecr1);
1531
+ }, bn5(0));
1431
1532
  return totalGas;
1432
1533
  }
1433
1534
  function getMinGas(params) {
@@ -1439,12 +1540,20 @@ function getMinGas(params) {
1439
1540
  return minGas;
1440
1541
  }
1441
1542
  function getMaxGas(params) {
1442
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1543
+ const {
1544
+ gasPerByte,
1545
+ witnessesLength,
1546
+ witnessLimit,
1547
+ minGas,
1548
+ gasLimit = bn5(0),
1549
+ maxGasPerTx
1550
+ } = params;
1443
1551
  let remainingAllowedWitnessGas = bn5(0);
1444
1552
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1445
1553
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1446
1554
  }
1447
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1555
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1556
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1448
1557
  }
1449
1558
  function calculateMetadataGasForTxCreate({
1450
1559
  gasCosts,
@@ -1466,6 +1575,10 @@ function calculateMetadataGasForTxScript({
1466
1575
  }) {
1467
1576
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1468
1577
  }
1578
+ var calculateGasFee = (params) => {
1579
+ const { gas, gasPrice, priceFactor, tip } = params;
1580
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
1581
+ };
1469
1582
 
1470
1583
  // src/providers/utils/json.ts
1471
1584
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1597,12 +1710,6 @@ var NoWitnessAtIndexError = class extends Error {
1597
1710
  name = "NoWitnessAtIndexError";
1598
1711
  };
1599
1712
 
1600
- // src/providers/transaction-request/helpers.ts
1601
- import { InputType as InputType2 } from "@fuel-ts/transactions";
1602
- var isRequestInputCoin = (input) => input.type === InputType2.Coin;
1603
- var isRequestInputMessage = (input) => input.type === InputType2.Message;
1604
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1605
-
1606
1713
  // src/providers/transaction-request/witness.ts
1607
1714
  import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
1608
1715
  var witnessify = (value) => {
@@ -1616,7 +1723,7 @@ var witnessify = (value) => {
1616
1723
  // src/providers/transaction-request/transaction-request.ts
1617
1724
  var BaseTransactionRequest = class {
1618
1725
  /** Gas price for transaction */
1619
- gasPrice;
1726
+ tip;
1620
1727
  /** Block until which tx cannot be included */
1621
1728
  maturity;
1622
1729
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1635,7 +1742,7 @@ var BaseTransactionRequest = class {
1635
1742
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1636
1743
  */
1637
1744
  constructor({
1638
- gasPrice,
1745
+ tip,
1639
1746
  maturity,
1640
1747
  maxFee,
1641
1748
  witnessLimit,
@@ -1643,7 +1750,7 @@ var BaseTransactionRequest = class {
1643
1750
  outputs,
1644
1751
  witnesses
1645
1752
  } = {}) {
1646
- this.gasPrice = bn7(gasPrice);
1753
+ this.tip = bn7(tip);
1647
1754
  this.maturity = maturity ?? 0;
1648
1755
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1649
1756
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
@@ -1654,9 +1761,9 @@ var BaseTransactionRequest = class {
1654
1761
  static getPolicyMeta(req) {
1655
1762
  let policyTypes = 0;
1656
1763
  const policies = [];
1657
- if (req.gasPrice) {
1658
- policyTypes += PolicyType.GasPrice;
1659
- policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1764
+ if (req.tip) {
1765
+ policyTypes += PolicyType.Tip;
1766
+ policies.push({ data: req.tip, type: PolicyType.Tip });
1660
1767
  }
1661
1768
  if (req.witnessLimit) {
1662
1769
  policyTypes += PolicyType.WitnessLimit;
@@ -1793,7 +1900,7 @@ var BaseTransactionRequest = class {
1793
1900
  */
1794
1901
  getCoinInputs() {
1795
1902
  return this.inputs.filter(
1796
- (input) => input.type === InputType3.Coin
1903
+ (input) => input.type === InputType2.Coin
1797
1904
  );
1798
1905
  }
1799
1906
  /**
@@ -1825,9 +1932,9 @@ var BaseTransactionRequest = class {
1825
1932
  const ownerAddress = addressify(owner);
1826
1933
  const found = this.inputs.find((input) => {
1827
1934
  switch (input.type) {
1828
- case InputType3.Coin:
1935
+ case InputType2.Coin:
1829
1936
  return hexlify7(input.owner) === ownerAddress.toB256();
1830
- case InputType3.Message:
1937
+ case InputType2.Message:
1831
1938
  return hexlify7(input.recipient) === ownerAddress.toB256();
1832
1939
  default:
1833
1940
  return false;
@@ -1844,9 +1951,9 @@ var BaseTransactionRequest = class {
1844
1951
  * @param predicateData - Predicate data bytes.
1845
1952
  */
1846
1953
  addCoinInput(coin) {
1847
- const { assetId, owner, amount, id, predicate } = coin;
1954
+ const { assetId, owner, amount } = coin;
1848
1955
  let witnessIndex;
1849
- if (predicate) {
1956
+ if (coin.predicate) {
1850
1957
  witnessIndex = 0;
1851
1958
  } else {
1852
1959
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1855,14 +1962,13 @@ var BaseTransactionRequest = class {
1855
1962
  }
1856
1963
  }
1857
1964
  const input = {
1858
- id,
1859
- type: InputType3.Coin,
1965
+ ...coin,
1966
+ type: InputType2.Coin,
1860
1967
  owner: owner.toB256(),
1861
1968
  amount,
1862
1969
  assetId,
1863
1970
  txPointer: "0x00000000000000000000000000000000",
1864
- witnessIndex,
1865
- predicate
1971
+ witnessIndex
1866
1972
  };
1867
1973
  this.pushInput(input);
1868
1974
  this.addChangeOutput(owner, assetId);
@@ -1876,10 +1982,10 @@ var BaseTransactionRequest = class {
1876
1982
  * @param predicateData - Predicate data bytes.
1877
1983
  */
1878
1984
  addMessageInput(message) {
1879
- const { recipient, sender, amount, predicate, nonce } = message;
1985
+ const { recipient, sender, amount } = message;
1880
1986
  const assetId = BaseAssetId2;
1881
1987
  let witnessIndex;
1882
- if (predicate) {
1988
+ if (message.predicate) {
1883
1989
  witnessIndex = 0;
1884
1990
  } else {
1885
1991
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1888,13 +1994,12 @@ var BaseTransactionRequest = class {
1888
1994
  }
1889
1995
  }
1890
1996
  const input = {
1891
- nonce,
1892
- type: InputType3.Message,
1997
+ ...message,
1998
+ type: InputType2.Message,
1893
1999
  sender: sender.toB256(),
1894
2000
  recipient: recipient.toB256(),
1895
2001
  amount,
1896
- witnessIndex,
1897
- predicate
2002
+ witnessIndex
1898
2003
  };
1899
2004
  this.pushInput(input);
1900
2005
  this.addChangeOutput(recipient, assetId);
@@ -2004,7 +2109,7 @@ var BaseTransactionRequest = class {
2004
2109
  }
2005
2110
  calculateMaxGas(chainInfo, minGas) {
2006
2111
  const { consensusParameters } = chainInfo;
2007
- const { gasPerByte } = consensusParameters;
2112
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2008
2113
  const witnessesLength = this.toTransaction().witnesses.reduce(
2009
2114
  (acc, wit) => acc + wit.dataLength,
2010
2115
  0
@@ -2013,7 +2118,8 @@ var BaseTransactionRequest = class {
2013
2118
  gasPerByte,
2014
2119
  minGas,
2015
2120
  witnessesLength,
2016
- witnessLimit: this.witnessLimit
2121
+ witnessLimit: this.witnessLimit,
2122
+ maxGasPerTx
2017
2123
  });
2018
2124
  }
2019
2125
  /**
@@ -2031,17 +2137,20 @@ var BaseTransactionRequest = class {
2031
2137
  });
2032
2138
  const updateAssetInput = (assetId, quantity) => {
2033
2139
  const assetInput = findAssetInput(assetId);
2140
+ let usedQuantity = quantity;
2141
+ if (assetId === BaseAssetId2) {
2142
+ usedQuantity = bn7("1000000000000000000");
2143
+ }
2034
2144
  if (assetInput && "assetId" in assetInput) {
2035
2145
  assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2036
- assetInput.amount = quantity;
2146
+ assetInput.amount = usedQuantity;
2037
2147
  } else {
2038
2148
  this.addResources([
2039
2149
  {
2040
2150
  id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2041
- amount: quantity,
2151
+ amount: usedQuantity,
2042
2152
  assetId,
2043
2153
  owner: resourcesOwner || Address.fromRandom(),
2044
- maturity: 0,
2045
2154
  blockCreated: bn7(1),
2046
2155
  txCreatedIdx: bn7(1)
2047
2156
  }
@@ -2073,20 +2182,16 @@ var BaseTransactionRequest = class {
2073
2182
  toJSON() {
2074
2183
  return normalizeJSON(this);
2075
2184
  }
2076
- removeWitness(index) {
2077
- this.witnesses.splice(index, 1);
2078
- this.adjustWitnessIndexes(index);
2079
- }
2080
- updatePredicateInputs(inputs) {
2185
+ updatePredicateGasUsed(inputs) {
2081
2186
  this.inputs.forEach((i) => {
2082
2187
  let correspondingInput;
2083
2188
  switch (i.type) {
2084
- case InputType3.Coin:
2085
- correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
2189
+ case InputType2.Coin:
2190
+ correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
2086
2191
  break;
2087
- case InputType3.Message:
2192
+ case InputType2.Message:
2088
2193
  correspondingInput = inputs.find(
2089
- (x) => x.type === InputType3.Message && x.sender === i.sender
2194
+ (x) => x.type === InputType2.Message && x.sender === i.sender
2090
2195
  );
2091
2196
  break;
2092
2197
  default:
@@ -2099,10 +2204,12 @@ var BaseTransactionRequest = class {
2099
2204
  }
2100
2205
  });
2101
2206
  }
2102
- adjustWitnessIndexes(removedIndex) {
2103
- this.inputs.filter(isRequestInputResource).forEach((input) => {
2104
- if (input.witnessIndex > removedIndex) {
2105
- input.witnessIndex -= 1;
2207
+ shiftPredicateData() {
2208
+ this.inputs.forEach((input) => {
2209
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2210
+ input.predicateData = input.paddPredicateData(
2211
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2212
+ );
2106
2213
  }
2107
2214
  });
2108
2215
  }
@@ -2118,7 +2225,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2118
2225
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2119
2226
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2120
2227
  import { bn as bn8 } from "@fuel-ts/math";
2121
- import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2228
+ import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2122
2229
  import { concat as concat2 } from "@fuel-ts/utils";
2123
2230
  import { clone as clone2 } from "ramda";
2124
2231
  function hashTransaction(transactionRequest, chainId) {
@@ -2129,7 +2236,7 @@ function hashTransaction(transactionRequest, chainId) {
2129
2236
  transaction.inputs = transaction.inputs.map((input) => {
2130
2237
  const inputClone = clone2(input);
2131
2238
  switch (inputClone.type) {
2132
- case InputType4.Coin: {
2239
+ case InputType3.Coin: {
2133
2240
  inputClone.txPointer = {
2134
2241
  blockHeight: 0,
2135
2242
  txIndex: 0
@@ -2137,11 +2244,11 @@ function hashTransaction(transactionRequest, chainId) {
2137
2244
  inputClone.predicateGasUsed = bn8(0);
2138
2245
  return inputClone;
2139
2246
  }
2140
- case InputType4.Message: {
2247
+ case InputType3.Message: {
2141
2248
  inputClone.predicateGasUsed = bn8(0);
2142
2249
  return inputClone;
2143
2250
  }
2144
- case InputType4.Contract: {
2251
+ case InputType3.Contract: {
2145
2252
  inputClone.txPointer = {
2146
2253
  blockHeight: 0,
2147
2254
  txIndex: 0
@@ -2252,9 +2359,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2252
2359
  return {
2253
2360
  type: TransactionType3.Create,
2254
2361
  ...baseTransaction,
2255
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2256
2362
  bytecodeWitnessIndex,
2257
- storageSlotsCount: storageSlots.length,
2363
+ storageSlotsCount: bn9(storageSlots.length),
2258
2364
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2259
2365
  storageSlots
2260
2366
  };
@@ -2307,7 +2413,7 @@ import { Interface } from "@fuel-ts/abi-coder";
2307
2413
  import { addressify as addressify2 } from "@fuel-ts/address";
2308
2414
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2309
2415
  import { bn as bn10 } from "@fuel-ts/math";
2310
- import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2416
+ import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2311
2417
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2312
2418
 
2313
2419
  // src/providers/transaction-request/scripts.ts
@@ -2377,8 +2483,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2377
2483
  type: TransactionType4.Script,
2378
2484
  scriptGasLimit: this.gasLimit,
2379
2485
  ...super.getBaseTransaction(),
2380
- scriptLength: script.length,
2381
- scriptDataLength: scriptData.length,
2486
+ scriptLength: bn10(script.length),
2487
+ scriptDataLength: bn10(scriptData.length),
2382
2488
  receiptsRoot: ZeroBytes327,
2383
2489
  script: hexlify10(script),
2384
2490
  scriptData: hexlify10(scriptData)
@@ -2391,7 +2497,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2391
2497
  */
2392
2498
  getContractInputs() {
2393
2499
  return this.inputs.filter(
2394
- (input) => input.type === InputType5.Contract
2500
+ (input) => input.type === InputType4.Contract
2395
2501
  );
2396
2502
  }
2397
2503
  /**
@@ -2442,7 +2548,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2442
2548
  }
2443
2549
  calculateMaxGas(chainInfo, minGas) {
2444
2550
  const { consensusParameters } = chainInfo;
2445
- const { gasPerByte } = consensusParameters;
2551
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2446
2552
  const witnessesLength = this.toTransaction().witnesses.reduce(
2447
2553
  (acc, wit) => acc + wit.dataLength,
2448
2554
  0
@@ -2452,7 +2558,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2452
2558
  minGas,
2453
2559
  witnessesLength,
2454
2560
  witnessLimit: this.witnessLimit,
2455
- gasLimit: this.gasLimit
2561
+ gasLimit: this.gasLimit,
2562
+ maxGasPerTx
2456
2563
  });
2457
2564
  }
2458
2565
  /**
@@ -2467,7 +2574,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2467
2574
  return this;
2468
2575
  }
2469
2576
  const inputIndex = super.pushInput({
2470
- type: InputType5.Contract,
2577
+ type: InputType4.Contract,
2471
2578
  contractId: contractAddress.toB256(),
2472
2579
  txPointer: "0x00000000000000000000000000000000"
2473
2580
  });
@@ -2509,7 +2616,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2509
2616
 
2510
2617
  // src/providers/transaction-request/utils.ts
2511
2618
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2512
- import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2619
+ import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2513
2620
  var transactionRequestify = (obj) => {
2514
2621
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2515
2622
  return obj;
@@ -2527,14 +2634,31 @@ var transactionRequestify = (obj) => {
2527
2634
  }
2528
2635
  }
2529
2636
  };
2637
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2638
+ (acc, input) => {
2639
+ if (input.type === InputType5.Coin && input.owner === owner) {
2640
+ acc.utxos.push(input.id);
2641
+ }
2642
+ if (input.type === InputType5.Message && input.recipient === owner) {
2643
+ acc.messages.push(input.nonce);
2644
+ }
2645
+ return acc;
2646
+ },
2647
+ {
2648
+ utxos: [],
2649
+ messages: []
2650
+ }
2651
+ );
2530
2652
 
2531
2653
  // src/providers/transaction-response/transaction-response.ts
2532
2654
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2533
- import { bn as bn14 } from "@fuel-ts/math";
2655
+ import { bn as bn15 } from "@fuel-ts/math";
2534
2656
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2535
2657
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2536
2658
 
2537
2659
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2660
+ import { bn as bn14 } from "@fuel-ts/math";
2661
+ import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2538
2662
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2539
2663
 
2540
2664
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2543,9 +2667,10 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2543
2667
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2544
2668
  var calculateTransactionFee = (params) => {
2545
2669
  const {
2546
- gasUsed,
2670
+ gasPrice,
2547
2671
  rawPayload,
2548
- consensusParameters: { gasCosts, feeParams }
2672
+ tip,
2673
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2549
2674
  } = params;
2550
2675
  const gasPerByte = bn11(feeParams.gasPerByte);
2551
2676
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2555,8 +2680,7 @@ var calculateTransactionFee = (params) => {
2555
2680
  return {
2556
2681
  fee: bn11(0),
2557
2682
  minFee: bn11(0),
2558
- maxFee: bn11(0),
2559
- feeFromGasUsed: bn11(0)
2683
+ maxFee: bn11(0)
2560
2684
  };
2561
2685
  }
2562
2686
  const { type, witnesses, inputs, policies } = transaction;
@@ -2588,7 +2712,6 @@ var calculateTransactionFee = (params) => {
2588
2712
  metadataGas,
2589
2713
  txBytesSize: transactionBytes.length
2590
2714
  });
2591
- const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2592
2715
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2593
2716
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2594
2717
  const maxGas = getMaxGas({
@@ -2596,17 +2719,25 @@ var calculateTransactionFee = (params) => {
2596
2719
  minGas,
2597
2720
  witnessesLength,
2598
2721
  gasLimit,
2599
- witnessLimit
2722
+ witnessLimit,
2723
+ maxGasPerTx
2724
+ });
2725
+ const minFee = calculateGasFee({
2726
+ gasPrice,
2727
+ gas: minGas,
2728
+ priceFactor: gasPriceFactor,
2729
+ tip
2730
+ });
2731
+ const maxFee = calculateGasFee({
2732
+ gasPrice,
2733
+ gas: maxGas,
2734
+ priceFactor: gasPriceFactor,
2735
+ tip
2600
2736
  });
2601
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2602
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2603
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2604
- const fee = minFee.add(feeFromGasUsed);
2605
2737
  return {
2606
- fee,
2607
2738
  minFee,
2608
2739
  maxFee,
2609
- feeFromGasUsed
2740
+ fee: maxFee
2610
2741
  };
2611
2742
  };
2612
2743
 
@@ -3173,7 +3304,9 @@ function assembleTransactionSummary(params) {
3173
3304
  gqlTransactionStatus,
3174
3305
  abiMap = {},
3175
3306
  maxInputs,
3176
- gasCosts
3307
+ gasCosts,
3308
+ maxGasPerTx,
3309
+ gasPrice
3177
3310
  } = params;
3178
3311
  const gasUsed = getGasUsedFromReceipts(receipts);
3179
3312
  const rawPayload = hexlify11(transactionBytes);
@@ -3187,11 +3320,14 @@ function assembleTransactionSummary(params) {
3187
3320
  maxInputs
3188
3321
  });
3189
3322
  const typeName = getTransactionTypeName(transaction.type);
3323
+ const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3190
3324
  const { fee } = calculateTransactionFee({
3191
- gasUsed,
3325
+ gasPrice,
3192
3326
  rawPayload,
3327
+ tip,
3193
3328
  consensusParameters: {
3194
3329
  gasCosts,
3330
+ maxGasPerTx,
3195
3331
  feeParams: {
3196
3332
  gasPerByte,
3197
3333
  gasPriceFactor
@@ -3251,7 +3387,7 @@ var TransactionResponse = class {
3251
3387
  /** Current provider */
3252
3388
  provider;
3253
3389
  /** Gas used on the transaction */
3254
- gasUsed = bn14(0);
3390
+ gasUsed = bn15(0);
3255
3391
  /** The graphql Transaction with receipts object. */
3256
3392
  gqlTransaction;
3257
3393
  abis;
@@ -3329,8 +3465,13 @@ var TransactionResponse = class {
3329
3465
  const decodedTransaction = this.decodeTransaction(
3330
3466
  transaction
3331
3467
  );
3332
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3333
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3468
+ let txReceipts = [];
3469
+ if (transaction?.status && "receipts" in transaction.status) {
3470
+ txReceipts = transaction.status.receipts;
3471
+ }
3472
+ const receipts = txReceipts.map(processGqlReceipt) || [];
3473
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3474
+ const gasPrice = await this.provider.getLatestGasPrice();
3334
3475
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3335
3476
  const transactionSummary = assembleTransactionSummary({
3336
3477
  id: this.id,
@@ -3342,7 +3483,9 @@ var TransactionResponse = class {
3342
3483
  gasPriceFactor,
3343
3484
  abiMap: contractsAbiMap,
3344
3485
  maxInputs,
3345
- gasCosts
3486
+ gasCosts,
3487
+ maxGasPerTx,
3488
+ gasPrice
3346
3489
  });
3347
3490
  return transactionSummary;
3348
3491
  }
@@ -3469,29 +3612,29 @@ var processGqlChain = (chain) => {
3469
3612
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3470
3613
  return {
3471
3614
  name,
3472
- baseChainHeight: bn15(daHeight),
3615
+ baseChainHeight: bn16(daHeight),
3473
3616
  consensusParameters: {
3474
- contractMaxSize: bn15(contractParams.contractMaxSize),
3475
- maxInputs: bn15(txParams.maxInputs),
3476
- maxOutputs: bn15(txParams.maxOutputs),
3477
- maxWitnesses: bn15(txParams.maxWitnesses),
3478
- maxGasPerTx: bn15(txParams.maxGasPerTx),
3479
- maxScriptLength: bn15(scriptParams.maxScriptLength),
3480
- maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3481
- maxStorageSlots: bn15(contractParams.maxStorageSlots),
3482
- maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3483
- maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3484
- maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3485
- gasPriceFactor: bn15(feeParams.gasPriceFactor),
3486
- gasPerByte: bn15(feeParams.gasPerByte),
3487
- maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3488
- chainId: bn15(consensusParameters.chainId),
3617
+ contractMaxSize: bn16(contractParams.contractMaxSize),
3618
+ maxInputs: bn16(txParams.maxInputs),
3619
+ maxOutputs: bn16(txParams.maxOutputs),
3620
+ maxWitnesses: bn16(txParams.maxWitnesses),
3621
+ maxGasPerTx: bn16(txParams.maxGasPerTx),
3622
+ maxScriptLength: bn16(scriptParams.maxScriptLength),
3623
+ maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3624
+ maxStorageSlots: bn16(contractParams.maxStorageSlots),
3625
+ maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3626
+ maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3627
+ maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3628
+ gasPriceFactor: bn16(feeParams.gasPriceFactor),
3629
+ gasPerByte: bn16(feeParams.gasPerByte),
3630
+ maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3631
+ chainId: bn16(consensusParameters.chainId),
3489
3632
  gasCosts
3490
3633
  },
3491
3634
  gasCosts,
3492
3635
  latestBlock: {
3493
3636
  id: latestBlock.id,
3494
- height: bn15(latestBlock.header.height),
3637
+ height: bn16(latestBlock.height),
3495
3638
  time: latestBlock.header.time,
3496
3639
  transactions: latestBlock.transactions.map((i) => ({
3497
3640
  id: i.id
@@ -3585,10 +3728,8 @@ var _Provider = class {
3585
3728
  * Returns some helpful parameters related to gas fees.
3586
3729
  */
3587
3730
  getGasConfig() {
3588
- const { minGasPrice } = this.getNode();
3589
3731
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3590
3732
  return {
3591
- minGasPrice,
3592
3733
  maxGasPerTx,
3593
3734
  maxGasPerPredicate,
3594
3735
  gasPriceFactor,
@@ -3686,7 +3827,7 @@ var _Provider = class {
3686
3827
  */
3687
3828
  async getBlockNumber() {
3688
3829
  const { chain } = await this.operations.getChain();
3689
- return bn15(chain.latestBlock.header.height, 10);
3830
+ return bn16(chain.latestBlock.height, 10);
3690
3831
  }
3691
3832
  /**
3692
3833
  * Returns the chain information.
@@ -3696,13 +3837,11 @@ var _Provider = class {
3696
3837
  async fetchNode() {
3697
3838
  const { nodeInfo } = await this.operations.getNodeInfo();
3698
3839
  const processedNodeInfo = {
3699
- maxDepth: bn15(nodeInfo.maxDepth),
3700
- maxTx: bn15(nodeInfo.maxTx),
3701
- minGasPrice: bn15(nodeInfo.minGasPrice),
3840
+ maxDepth: bn16(nodeInfo.maxDepth),
3841
+ maxTx: bn16(nodeInfo.maxTx),
3702
3842
  nodeVersion: nodeInfo.nodeVersion,
3703
3843
  utxoValidation: nodeInfo.utxoValidation,
3704
- vmBacktrace: nodeInfo.vmBacktrace,
3705
- peers: nodeInfo.peers
3844
+ vmBacktrace: nodeInfo.vmBacktrace
3706
3845
  };
3707
3846
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3708
3847
  return processedNodeInfo;
@@ -3788,14 +3927,13 @@ var _Provider = class {
3788
3927
  return this.estimateTxDependencies(transactionRequest);
3789
3928
  }
3790
3929
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3791
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3792
- encodedTransaction,
3930
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3931
+ encodedTransactions: encodedTransaction,
3793
3932
  utxoValidation: utxoValidation || false
3794
3933
  });
3795
- const receipts = gqlReceipts.map(processGqlReceipt);
3796
- return {
3797
- receipts
3798
- };
3934
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3935
+ const receipts = rawReceipts.map(processGqlReceipt);
3936
+ return { receipts, dryrunStatus: status };
3799
3937
  }
3800
3938
  /**
3801
3939
  * Verifies whether enough gas is available to complete transaction.
@@ -3821,7 +3959,7 @@ var _Provider = class {
3821
3959
  } = response;
3822
3960
  if (inputs) {
3823
3961
  inputs.forEach((input, index) => {
3824
- if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3962
+ if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3825
3963
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3826
3964
  }
3827
3965
  });
@@ -3834,9 +3972,6 @@ var _Provider = class {
3834
3972
  * If there are missing variable outputs,
3835
3973
  * `addVariableOutputs` is called on the transaction.
3836
3974
  *
3837
- * @privateRemarks
3838
- * TODO: Investigate support for missing contract IDs
3839
- * TODO: Add support for missing output messages
3840
3975
  *
3841
3976
  * @param transactionRequest - The transaction request object.
3842
3977
  * @returns A promise.
@@ -3849,16 +3984,19 @@ var _Provider = class {
3849
3984
  missingContractIds: []
3850
3985
  };
3851
3986
  }
3852
- await this.estimatePredicates(transactionRequest);
3853
3987
  let receipts = [];
3854
3988
  const missingContractIds = [];
3855
3989
  let outputVariables = 0;
3990
+ let dryrunStatus;
3856
3991
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3857
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3858
- encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3992
+ const {
3993
+ dryRun: [{ receipts: rawReceipts, status }]
3994
+ } = await this.operations.dryRun({
3995
+ encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3859
3996
  utxoValidation: false
3860
3997
  });
3861
- receipts = gqlReceipts.map(processGqlReceipt);
3998
+ receipts = rawReceipts.map(processGqlReceipt);
3999
+ dryrunStatus = status;
3862
4000
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3863
4001
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3864
4002
  if (hasMissingOutputs) {
@@ -3868,6 +4006,10 @@ var _Provider = class {
3868
4006
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3869
4007
  missingContractIds.push(contractId);
3870
4008
  });
4009
+ const { maxFee } = await this.estimateTxGasAndFee({
4010
+ transactionRequest
4011
+ });
4012
+ transactionRequest.maxFee = maxFee;
3871
4013
  } else {
3872
4014
  break;
3873
4015
  }
@@ -3875,37 +4017,139 @@ var _Provider = class {
3875
4017
  return {
3876
4018
  receipts,
3877
4019
  outputVariables,
3878
- missingContractIds
4020
+ missingContractIds,
4021
+ dryrunStatus
3879
4022
  };
3880
4023
  }
4024
+ /**
4025
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
4026
+ *
4027
+ * Transactions are dry run in batches. After each dry run, transactions requiring
4028
+ * further modifications are identified. The method iteratively updates these transactions
4029
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4030
+ *
4031
+ * @param transactionRequests - Array of transaction request objects.
4032
+ * @returns A promise that resolves to an array of results for each transaction.
4033
+ */
4034
+ async estimateMultipleTxDependencies(transactionRequests) {
4035
+ const results = transactionRequests.map(() => ({
4036
+ receipts: [],
4037
+ outputVariables: 0,
4038
+ missingContractIds: [],
4039
+ dryrunStatus: void 0
4040
+ }));
4041
+ const allRequests = clone3(transactionRequests);
4042
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
4043
+ allRequests.forEach((req, index) => {
4044
+ if (req.type === TransactionType8.Script) {
4045
+ serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4046
+ }
4047
+ });
4048
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4049
+ let attempt = 0;
4050
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4051
+ const encodedTransactions = transactionsToProcess.map(
4052
+ (index) => serializedTransactionsMap.get(index)
4053
+ );
4054
+ const dryRunResults = await this.operations.dryRun({
4055
+ encodedTransactions,
4056
+ utxoValidation: false
4057
+ });
4058
+ const nextRoundTransactions = [];
4059
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4060
+ const currentResultIndex = transactionsToProcess[i];
4061
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4062
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4063
+ results[currentResultIndex].dryrunStatus = status;
4064
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4065
+ results[currentResultIndex].receipts
4066
+ );
4067
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4068
+ const requestToProcess = allRequests[currentResultIndex];
4069
+ if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4070
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
4071
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
4072
+ missingOutputContractIds.forEach(({ contractId }) => {
4073
+ requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4074
+ results[currentResultIndex].missingContractIds.push(contractId);
4075
+ });
4076
+ const { maxFee } = await this.estimateTxGasAndFee({
4077
+ transactionRequest: requestToProcess
4078
+ });
4079
+ requestToProcess.maxFee = maxFee;
4080
+ serializedTransactionsMap.set(
4081
+ currentResultIndex,
4082
+ hexlify12(requestToProcess.toTransactionBytes())
4083
+ );
4084
+ nextRoundTransactions.push(currentResultIndex);
4085
+ allRequests[currentResultIndex] = requestToProcess;
4086
+ }
4087
+ }
4088
+ transactionsToProcess = nextRoundTransactions;
4089
+ attempt += 1;
4090
+ }
4091
+ return results;
4092
+ }
4093
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4094
+ if (estimateTxDependencies) {
4095
+ return this.estimateMultipleTxDependencies(transactionRequests);
4096
+ }
4097
+ const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4098
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4099
+ encodedTransactions,
4100
+ utxoValidation: utxoValidation || false
4101
+ });
4102
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4103
+ const receipts = rawReceipts.map(processGqlReceipt);
4104
+ return { receipts, dryrunStatus: status };
4105
+ });
4106
+ return results;
4107
+ }
3881
4108
  /**
3882
4109
  * Estimates the transaction gas and fee based on the provided transaction request.
3883
4110
  * @param transactionRequest - The transaction request object.
3884
4111
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3885
4112
  */
3886
- estimateTxGasAndFee(params) {
4113
+ async estimateTxGasAndFee(params) {
3887
4114
  const { transactionRequest } = params;
3888
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4115
+ let { gasPrice } = params;
3889
4116
  const chainInfo = this.getChain();
3890
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3891
- transactionRequest.gasPrice = gasPrice;
4117
+ const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3892
4118
  const minGas = transactionRequest.calculateMinGas(chainInfo);
3893
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4119
+ if (!gasPrice) {
4120
+ gasPrice = await this.estimateGasPrice(10);
4121
+ }
4122
+ const minFee = calculateGasFee({
4123
+ gasPrice: bn16(gasPrice),
4124
+ gas: minGas,
4125
+ priceFactor: gasPriceFactor,
4126
+ tip: transactionRequest.tip
4127
+ }).add(1);
4128
+ let gasLimit = bn16(0);
3894
4129
  if (transactionRequest.type === TransactionType8.Script) {
4130
+ gasLimit = transactionRequest.gasLimit;
3895
4131
  if (transactionRequest.gasLimit.eq(0)) {
3896
4132
  transactionRequest.gasLimit = minGas;
3897
4133
  transactionRequest.gasLimit = maxGasPerTx.sub(
3898
4134
  transactionRequest.calculateMaxGas(chainInfo, minGas)
3899
4135
  );
4136
+ gasLimit = transactionRequest.gasLimit;
3900
4137
  }
3901
4138
  }
3902
4139
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3903
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4140
+ const maxFee = calculateGasFee({
4141
+ gasPrice: bn16(gasPrice),
4142
+ gas: maxGas,
4143
+ priceFactor: gasPriceFactor,
4144
+ tip: transactionRequest.tip
4145
+ }).add(1);
3904
4146
  return {
3905
4147
  minGas,
3906
4148
  minFee,
3907
4149
  maxGas,
3908
- maxFee
4150
+ maxFee,
4151
+ gasPrice,
4152
+ gasLimit
3909
4153
  };
3910
4154
  }
3911
4155
  /**
@@ -3923,15 +4167,17 @@ var _Provider = class {
3923
4167
  if (estimateTxDependencies) {
3924
4168
  return this.estimateTxDependencies(transactionRequest);
3925
4169
  }
3926
- const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3927
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3928
- encodedTransaction,
4170
+ const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4171
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4172
+ encodedTransactions,
3929
4173
  utxoValidation: true
3930
4174
  });
3931
- const receipts = gqlReceipts.map(processGqlReceipt);
3932
- return {
3933
- receipts
3934
- };
4175
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
4176
+ const { id, receipts, status } = dryRunStatus;
4177
+ const processedReceipts = receipts.map(processGqlReceipt);
4178
+ return { id, receipts: processedReceipts, status };
4179
+ });
4180
+ return { receipts: callResult[0].receipts };
3935
4181
  }
3936
4182
  /**
3937
4183
  * Returns a transaction cost to enable user
@@ -3948,77 +4194,79 @@ var _Provider = class {
3948
4194
  * @param tolerance - The tolerance to add on top of the gasUsed.
3949
4195
  * @returns A promise that resolves to the transaction cost object.
3950
4196
  */
3951
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3952
- estimateTxDependencies = true,
3953
- estimatePredicates = true,
3954
- resourcesOwner,
3955
- signatureCallback
3956
- } = {}) {
4197
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3957
4198
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3958
- const { minGasPrice } = this.getGasConfig();
3959
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
3960
4199
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3961
4200
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3962
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4201
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3963
4202
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4203
+ txRequestClone.maxFee = bn16(0);
3964
4204
  if (isScriptTransaction) {
3965
- txRequestClone.gasLimit = bn15(0);
4205
+ txRequestClone.gasLimit = bn16(0);
3966
4206
  }
3967
- if (estimatePredicates) {
3968
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3969
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3970
- }
3971
- await this.estimatePredicates(txRequestClone);
4207
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4208
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3972
4209
  }
4210
+ const signedRequest = clone3(txRequestClone);
4211
+ let addedSignatures = 0;
3973
4212
  if (signatureCallback && isScriptTransaction) {
3974
- await signatureCallback(txRequestClone);
4213
+ const lengthBefore = signedRequest.witnesses.length;
4214
+ await signatureCallback(signedRequest);
4215
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
3975
4216
  }
3976
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3977
- transactionRequest: txRequestClone
4217
+ await this.estimatePredicates(signedRequest);
4218
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4219
+ transactionRequest: signedRequest
3978
4220
  });
3979
4221
  let receipts = [];
3980
4222
  let missingContractIds = [];
3981
4223
  let outputVariables = 0;
3982
- let gasUsed = bn15(0);
3983
- if (isScriptTransaction && estimateTxDependencies) {
3984
- txRequestClone.gasPrice = bn15(0);
4224
+ let gasUsed = bn16(0);
4225
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4226
+ txRequestClone.maxFee = maxFee;
4227
+ if (isScriptTransaction) {
4228
+ txRequestClone.gasLimit = gasLimit;
4229
+ if (signatureCallback) {
4230
+ await signatureCallback(txRequestClone);
4231
+ }
3985
4232
  const result = await this.estimateTxDependencies(txRequestClone);
3986
4233
  receipts = result.receipts;
3987
4234
  outputVariables = result.outputVariables;
3988
4235
  missingContractIds = result.missingContractIds;
3989
4236
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
3990
4237
  txRequestClone.gasLimit = gasUsed;
3991
- txRequestClone.gasPrice = setGasPrice;
3992
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3993
- transactionRequest: txRequestClone
4238
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4239
+ transactionRequest: txRequestClone,
4240
+ gasPrice
3994
4241
  }));
3995
4242
  }
3996
4243
  return {
3997
4244
  requiredQuantities: allQuantities,
3998
4245
  receipts,
3999
4246
  gasUsed,
4000
- minGasPrice,
4001
- gasPrice: setGasPrice,
4247
+ gasPrice,
4002
4248
  minGas,
4003
4249
  maxGas,
4004
4250
  minFee,
4005
4251
  maxFee,
4006
- estimatedInputs: txRequestClone.inputs,
4007
4252
  outputVariables,
4008
- missingContractIds
4253
+ missingContractIds,
4254
+ addedSignatures,
4255
+ estimatedPredicates: txRequestClone.inputs
4009
4256
  };
4010
4257
  }
4011
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4258
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4012
4259
  const ownerAddress = Address2.fromAddressOrString(owner);
4013
4260
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4014
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4261
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
4262
+ quantitiesToContract
4263
+ });
4015
4264
  transactionRequest.addResources(
4016
4265
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4017
4266
  );
4018
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4019
- transactionRequest,
4020
- forwardingQuantities
4021
- );
4267
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4268
+ quantitiesToContract
4269
+ });
4022
4270
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4023
4271
  return {
4024
4272
  resources,
@@ -4040,11 +4288,10 @@ var _Provider = class {
4040
4288
  return coins.map((coin) => ({
4041
4289
  id: coin.utxoId,
4042
4290
  assetId: coin.assetId,
4043
- amount: bn15(coin.amount),
4291
+ amount: bn16(coin.amount),
4044
4292
  owner: Address2.fromAddressOrString(coin.owner),
4045
- maturity: bn15(coin.maturity).toNumber(),
4046
- blockCreated: bn15(coin.blockCreated),
4047
- txCreatedIdx: bn15(coin.txCreatedIdx)
4293
+ blockCreated: bn16(coin.blockCreated),
4294
+ txCreatedIdx: bn16(coin.txCreatedIdx)
4048
4295
  }));
4049
4296
  }
4050
4297
  /**
@@ -4081,9 +4328,9 @@ var _Provider = class {
4081
4328
  switch (coin.__typename) {
4082
4329
  case "MessageCoin":
4083
4330
  return {
4084
- amount: bn15(coin.amount),
4331
+ amount: bn16(coin.amount),
4085
4332
  assetId: coin.assetId,
4086
- daHeight: bn15(coin.daHeight),
4333
+ daHeight: bn16(coin.daHeight),
4087
4334
  sender: Address2.fromAddressOrString(coin.sender),
4088
4335
  recipient: Address2.fromAddressOrString(coin.recipient),
4089
4336
  nonce: coin.nonce
@@ -4091,12 +4338,11 @@ var _Provider = class {
4091
4338
  case "Coin":
4092
4339
  return {
4093
4340
  id: coin.utxoId,
4094
- amount: bn15(coin.amount),
4341
+ amount: bn16(coin.amount),
4095
4342
  assetId: coin.assetId,
4096
4343
  owner: Address2.fromAddressOrString(coin.owner),
4097
- maturity: bn15(coin.maturity).toNumber(),
4098
- blockCreated: bn15(coin.blockCreated),
4099
- txCreatedIdx: bn15(coin.txCreatedIdx)
4344
+ blockCreated: bn16(coin.blockCreated),
4345
+ txCreatedIdx: bn16(coin.txCreatedIdx)
4100
4346
  };
4101
4347
  default:
4102
4348
  return null;
@@ -4113,13 +4359,13 @@ var _Provider = class {
4113
4359
  async getBlock(idOrHeight) {
4114
4360
  let variables;
4115
4361
  if (typeof idOrHeight === "number") {
4116
- variables = { height: bn15(idOrHeight).toString(10) };
4362
+ variables = { height: bn16(idOrHeight).toString(10) };
4117
4363
  } else if (idOrHeight === "latest") {
4118
4364
  variables = { height: (await this.getBlockNumber()).toString(10) };
4119
4365
  } else if (idOrHeight.length === 66) {
4120
4366
  variables = { blockId: idOrHeight };
4121
4367
  } else {
4122
- variables = { blockId: bn15(idOrHeight).toString(10) };
4368
+ variables = { blockId: bn16(idOrHeight).toString(10) };
4123
4369
  }
4124
4370
  const { block } = await this.operations.getBlock(variables);
4125
4371
  if (!block) {
@@ -4127,7 +4373,7 @@ var _Provider = class {
4127
4373
  }
4128
4374
  return {
4129
4375
  id: block.id,
4130
- height: bn15(block.header.height),
4376
+ height: bn16(block.height),
4131
4377
  time: block.header.time,
4132
4378
  transactionIds: block.transactions.map((tx) => tx.id)
4133
4379
  };
@@ -4142,7 +4388,7 @@ var _Provider = class {
4142
4388
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4143
4389
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4144
4390
  id: block.id,
4145
- height: bn15(block.header.height),
4391
+ height: bn16(block.height),
4146
4392
  time: block.header.time,
4147
4393
  transactionIds: block.transactions.map((tx) => tx.id)
4148
4394
  }));
@@ -4157,7 +4403,7 @@ var _Provider = class {
4157
4403
  async getBlockWithTransactions(idOrHeight) {
4158
4404
  let variables;
4159
4405
  if (typeof idOrHeight === "number") {
4160
- variables = { blockHeight: bn15(idOrHeight).toString(10) };
4406
+ variables = { blockHeight: bn16(idOrHeight).toString(10) };
4161
4407
  } else if (idOrHeight === "latest") {
4162
4408
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4163
4409
  } else {
@@ -4169,7 +4415,7 @@ var _Provider = class {
4169
4415
  }
4170
4416
  return {
4171
4417
  id: block.id,
4172
- height: bn15(block.header.height, 10),
4418
+ height: bn16(block.height, 10),
4173
4419
  time: block.header.time,
4174
4420
  transactionIds: block.transactions.map((tx) => tx.id),
4175
4421
  transactions: block.transactions.map(
@@ -4218,7 +4464,7 @@ var _Provider = class {
4218
4464
  contract: Address2.fromAddressOrString(contractId).toB256(),
4219
4465
  asset: hexlify12(assetId)
4220
4466
  });
4221
- return bn15(contractBalance.amount, 10);
4467
+ return bn16(contractBalance.amount, 10);
4222
4468
  }
4223
4469
  /**
4224
4470
  * Returns the balance for the given owner for the given asset ID.
@@ -4232,7 +4478,7 @@ var _Provider = class {
4232
4478
  owner: Address2.fromAddressOrString(owner).toB256(),
4233
4479
  assetId: hexlify12(assetId)
4234
4480
  });
4235
- return bn15(balance.amount, 10);
4481
+ return bn16(balance.amount, 10);
4236
4482
  }
4237
4483
  /**
4238
4484
  * Returns balances for the given owner.
@@ -4250,7 +4496,7 @@ var _Provider = class {
4250
4496
  const balances = result.balances.edges.map((edge) => edge.node);
4251
4497
  return balances.map((balance) => ({
4252
4498
  assetId: balance.assetId,
4253
- amount: bn15(balance.amount)
4499
+ amount: bn16(balance.amount)
4254
4500
  }));
4255
4501
  }
4256
4502
  /**
@@ -4272,15 +4518,15 @@ var _Provider = class {
4272
4518
  sender: message.sender,
4273
4519
  recipient: message.recipient,
4274
4520
  nonce: message.nonce,
4275
- amount: bn15(message.amount),
4521
+ amount: bn16(message.amount),
4276
4522
  data: message.data
4277
4523
  }),
4278
4524
  sender: Address2.fromAddressOrString(message.sender),
4279
4525
  recipient: Address2.fromAddressOrString(message.recipient),
4280
4526
  nonce: message.nonce,
4281
- amount: bn15(message.amount),
4527
+ amount: bn16(message.amount),
4282
4528
  data: InputMessageCoder.decodeData(message.data),
4283
- daHeight: bn15(message.daHeight)
4529
+ daHeight: bn16(message.daHeight)
4284
4530
  }));
4285
4531
  }
4286
4532
  /**
@@ -4333,44 +4579,60 @@ var _Provider = class {
4333
4579
  } = result.messageProof;
4334
4580
  return {
4335
4581
  messageProof: {
4336
- proofIndex: bn15(messageProof.proofIndex),
4582
+ proofIndex: bn16(messageProof.proofIndex),
4337
4583
  proofSet: messageProof.proofSet
4338
4584
  },
4339
4585
  blockProof: {
4340
- proofIndex: bn15(blockProof.proofIndex),
4586
+ proofIndex: bn16(blockProof.proofIndex),
4341
4587
  proofSet: blockProof.proofSet
4342
4588
  },
4343
4589
  messageBlockHeader: {
4344
4590
  id: messageBlockHeader.id,
4345
- daHeight: bn15(messageBlockHeader.daHeight),
4346
- transactionsCount: bn15(messageBlockHeader.transactionsCount),
4591
+ daHeight: bn16(messageBlockHeader.daHeight),
4592
+ transactionsCount: bn16(messageBlockHeader.transactionsCount),
4347
4593
  transactionsRoot: messageBlockHeader.transactionsRoot,
4348
- height: bn15(messageBlockHeader.height),
4594
+ height: bn16(messageBlockHeader.height),
4349
4595
  prevRoot: messageBlockHeader.prevRoot,
4350
4596
  time: messageBlockHeader.time,
4351
4597
  applicationHash: messageBlockHeader.applicationHash,
4352
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4353
- messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4598
+ messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4599
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4600
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4601
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
4602
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4354
4603
  },
4355
4604
  commitBlockHeader: {
4356
4605
  id: commitBlockHeader.id,
4357
- daHeight: bn15(commitBlockHeader.daHeight),
4358
- transactionsCount: bn15(commitBlockHeader.transactionsCount),
4606
+ daHeight: bn16(commitBlockHeader.daHeight),
4607
+ transactionsCount: bn16(commitBlockHeader.transactionsCount),
4359
4608
  transactionsRoot: commitBlockHeader.transactionsRoot,
4360
- height: bn15(commitBlockHeader.height),
4609
+ height: bn16(commitBlockHeader.height),
4361
4610
  prevRoot: commitBlockHeader.prevRoot,
4362
4611
  time: commitBlockHeader.time,
4363
4612
  applicationHash: commitBlockHeader.applicationHash,
4364
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4365
- messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4613
+ messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4614
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4615
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4616
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
4617
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4366
4618
  },
4367
4619
  sender: Address2.fromAddressOrString(sender),
4368
4620
  recipient: Address2.fromAddressOrString(recipient),
4369
4621
  nonce,
4370
- amount: bn15(amount),
4622
+ amount: bn16(amount),
4371
4623
  data
4372
4624
  };
4373
4625
  }
4626
+ async getLatestGasPrice() {
4627
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
4628
+ return bn16(latestGasPrice.gasPrice);
4629
+ }
4630
+ async estimateGasPrice(blockHorizon) {
4631
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
4632
+ blockHorizon: String(blockHorizon)
4633
+ });
4634
+ return bn16(estimateGasPrice.gasPrice);
4635
+ }
4374
4636
  /**
4375
4637
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4376
4638
  *
@@ -4390,10 +4652,10 @@ var _Provider = class {
4390
4652
  */
4391
4653
  async produceBlocks(amount, startTime) {
4392
4654
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4393
- blocksToProduce: bn15(amount).toString(10),
4655
+ blocksToProduce: bn16(amount).toString(10),
4394
4656
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4395
4657
  });
4396
- return bn15(latestBlockHeight);
4658
+ return bn16(latestBlockHeight);
4397
4659
  }
4398
4660
  // eslint-disable-next-line @typescript-eslint/require-await
4399
4661
  async getTransactionResponse(transactionId) {
@@ -4417,7 +4679,7 @@ __publicField(Provider, "nodeInfoCache", {});
4417
4679
 
4418
4680
  // src/providers/transaction-summary/get-transaction-summary.ts
4419
4681
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4420
- import { bn as bn16 } from "@fuel-ts/math";
4682
+ import { bn as bn17 } from "@fuel-ts/math";
4421
4683
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4422
4684
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4423
4685
 
@@ -4663,36 +4925,33 @@ var Account = class extends AbstractAccount {
4663
4925
  * @param fee - The estimated transaction fee.
4664
4926
  * @returns A promise that resolves when the resources are added to the transaction.
4665
4927
  */
4666
- async fund(request, coinQuantities, fee) {
4667
- const updatedQuantities = addAmountToAsset({
4668
- amount: bn17(fee),
4928
+ async fund(request, params) {
4929
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4930
+ const txRequest = request;
4931
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4932
+ amount: bn18(fee),
4669
4933
  assetId: BaseAssetId3,
4670
- coinQuantities
4934
+ coinQuantities: requiredQuantities
4671
4935
  });
4672
4936
  const quantitiesDict = {};
4673
- updatedQuantities.forEach(({ amount, assetId }) => {
4937
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4674
4938
  quantitiesDict[assetId] = {
4675
4939
  required: amount,
4676
- owned: bn17(0)
4940
+ owned: bn18(0)
4677
4941
  };
4678
4942
  });
4679
- const cachedUtxos = [];
4680
- const cachedMessages = [];
4681
- const owner = this.address.toB256();
4682
- request.inputs.forEach((input) => {
4943
+ txRequest.inputs.forEach((input) => {
4683
4944
  const isResource = "amount" in input;
4684
4945
  if (isResource) {
4685
4946
  const isCoin2 = "owner" in input;
4686
4947
  if (isCoin2) {
4687
4948
  const assetId = String(input.assetId);
4688
- if (input.owner === owner && quantitiesDict[assetId]) {
4689
- const amount = bn17(input.amount);
4949
+ if (quantitiesDict[assetId]) {
4950
+ const amount = bn18(input.amount);
4690
4951
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4691
- cachedUtxos.push(input.id);
4692
4952
  }
4693
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4953
+ } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4694
4954
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4695
- cachedMessages.push(input.nonce);
4696
4955
  }
4697
4956
  }
4698
4957
  });
@@ -4707,12 +4966,23 @@ var Account = class extends AbstractAccount {
4707
4966
  });
4708
4967
  const needsToBeFunded = missingQuantities.length;
4709
4968
  if (needsToBeFunded) {
4710
- const resources = await this.getResourcesToSpend(missingQuantities, {
4711
- messages: cachedMessages,
4712
- utxos: cachedUtxos
4713
- });
4714
- request.addResources(resources);
4969
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4970
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4971
+ txRequest.addResources(resources);
4972
+ }
4973
+ txRequest.shiftPredicateData();
4974
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
4975
+ const requestToBeReEstimate = clone4(txRequest);
4976
+ if (addedSignatures) {
4977
+ Array.from({ length: addedSignatures }).forEach(
4978
+ () => requestToBeReEstimate.addEmptyWitness()
4979
+ );
4715
4980
  }
4981
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
4982
+ transactionRequest: requestToBeReEstimate
4983
+ });
4984
+ txRequest.maxFee = maxFee;
4985
+ return txRequest;
4716
4986
  }
4717
4987
  /**
4718
4988
  * A helper that creates a transfer transaction request and returns it.
@@ -4720,28 +4990,25 @@ var Account = class extends AbstractAccount {
4720
4990
  * @param destination - The address of the destination.
4721
4991
  * @param amount - The amount of coins to transfer.
4722
4992
  * @param assetId - The asset ID of the coins to transfer.
4723
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4993
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4724
4994
  * @returns A promise that resolves to the prepared transaction request.
4725
4995
  */
4726
4996
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4727
- const { minGasPrice } = this.provider.getGasConfig();
4728
- const params = { gasPrice: minGasPrice, ...txParams };
4729
- const request = new ScriptTransactionRequest(params);
4997
+ const request = new ScriptTransactionRequest(txParams);
4730
4998
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4731
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4999
+ const txCost = await this.provider.getTransactionCost(request, {
4732
5000
  estimateTxDependencies: true,
4733
5001
  resourcesOwner: this
4734
5002
  });
4735
- request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4736
- request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4737
- this.validateGas({
4738
- gasUsed,
4739
- gasPrice: request.gasPrice,
4740
- gasLimit: request.gasLimit,
4741
- minGasPrice
4742
- });
4743
- await this.fund(request, requiredQuantities, maxFee);
4744
- request.updatePredicateInputs(estimatedInputs);
5003
+ if ("gasLimit" in txParams) {
5004
+ this.validateGas({
5005
+ gasUsed: txCost.gasUsed,
5006
+ gasLimit: request.gasLimit
5007
+ });
5008
+ }
5009
+ request.gasLimit = txCost.gasUsed;
5010
+ request.maxFee = txCost.maxFee;
5011
+ await this.fund(request, txCost);
4745
5012
  return request;
4746
5013
  }
4747
5014
  /**
@@ -4754,7 +5021,7 @@ var Account = class extends AbstractAccount {
4754
5021
  * @returns A promise that resolves to the transaction response.
4755
5022
  */
4756
5023
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4757
- if (bn17(amount).lte(0)) {
5024
+ if (bn18(amount).lte(0)) {
4758
5025
  throw new FuelError15(
4759
5026
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4760
5027
  "Transfer amount must be a positive number."
@@ -4773,38 +5040,37 @@ var Account = class extends AbstractAccount {
4773
5040
  * @returns A promise that resolves to the transaction response.
4774
5041
  */
4775
5042
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4776
- if (bn17(amount).lte(0)) {
5043
+ if (bn18(amount).lte(0)) {
4777
5044
  throw new FuelError15(
4778
5045
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4779
5046
  "Transfer amount must be a positive number."
4780
5047
  );
4781
5048
  }
4782
5049
  const contractAddress = Address3.fromAddressOrString(contractId);
4783
- const { minGasPrice } = this.provider.getGasConfig();
4784
- const params = { gasPrice: minGasPrice, ...txParams };
4785
5050
  const { script, scriptData } = await assembleTransferToContractScript({
4786
5051
  hexlifiedContractId: contractAddress.toB256(),
4787
- amountToTransfer: bn17(amount),
5052
+ amountToTransfer: bn18(amount),
4788
5053
  assetId
4789
5054
  });
4790
5055
  const request = new ScriptTransactionRequest({
4791
- ...params,
5056
+ ...txParams,
4792
5057
  script,
4793
5058
  scriptData
4794
5059
  });
4795
5060
  request.addContractInputAndOutput(contractAddress);
4796
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4797
- request,
4798
- [{ amount: bn17(amount), assetId: String(assetId) }]
4799
- );
4800
- request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4801
- this.validateGas({
4802
- gasUsed,
4803
- gasPrice: request.gasPrice,
4804
- gasLimit: request.gasLimit,
4805
- minGasPrice
5061
+ const txCost = await this.provider.getTransactionCost(request, {
5062
+ resourcesOwner: this,
5063
+ quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
4806
5064
  });
4807
- await this.fund(request, requiredQuantities, maxFee);
5065
+ if (txParams.gasLimit) {
5066
+ this.validateGas({
5067
+ gasUsed: txCost.gasUsed,
5068
+ gasLimit: request.gasLimit
5069
+ });
5070
+ }
5071
+ request.gasLimit = txCost.gasUsed;
5072
+ request.maxFee = txCost.maxFee;
5073
+ await this.fund(request, txCost);
4808
5074
  return this.sendTransaction(request);
4809
5075
  }
4810
5076
  /**
@@ -4816,34 +5082,31 @@ var Account = class extends AbstractAccount {
4816
5082
  * @returns A promise that resolves to the transaction response.
4817
5083
  */
4818
5084
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4819
- const { minGasPrice } = this.provider.getGasConfig();
4820
5085
  const recipientAddress = Address3.fromAddressOrString(recipient);
4821
5086
  const recipientDataArray = arrayify14(
4822
5087
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4823
5088
  );
4824
5089
  const amountDataArray = arrayify14(
4825
- "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5090
+ "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
4826
5091
  );
4827
5092
  const script = new Uint8Array([
4828
5093
  ...arrayify14(withdrawScript.bytes),
4829
5094
  ...recipientDataArray,
4830
5095
  ...amountDataArray
4831
5096
  ]);
4832
- const params = { script, gasPrice: minGasPrice, ...txParams };
5097
+ const params = { script, ...txParams };
4833
5098
  const request = new ScriptTransactionRequest(params);
4834
- const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4835
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4836
- request,
4837
- forwardingQuantities
4838
- );
4839
- request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4840
- this.validateGas({
4841
- gasUsed,
4842
- gasPrice: request.gasPrice,
4843
- gasLimit: request.gasLimit,
4844
- minGasPrice
4845
- });
4846
- await this.fund(request, requiredQuantities, maxFee);
5099
+ const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5100
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5101
+ if (txParams.gasLimit) {
5102
+ this.validateGas({
5103
+ gasUsed: txCost.gasUsed,
5104
+ gasLimit: request.gasLimit
5105
+ });
5106
+ }
5107
+ request.maxFee = txCost.maxFee;
5108
+ request.gasLimit = txCost.gasUsed;
5109
+ await this.fund(request, txCost);
4847
5110
  return this.sendTransaction(request);
4848
5111
  }
4849
5112
  async signMessage(message) {
@@ -4901,18 +5164,7 @@ var Account = class extends AbstractAccount {
4901
5164
  }
4902
5165
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4903
5166
  }
4904
- validateGas({
4905
- gasUsed,
4906
- gasPrice,
4907
- gasLimit,
4908
- minGasPrice
4909
- }) {
4910
- if (minGasPrice.gt(gasPrice)) {
4911
- throw new FuelError15(
4912
- ErrorCode15.GAS_PRICE_TOO_LOW,
4913
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4914
- );
4915
- }
5167
+ validateGas({ gasUsed, gasLimit }) {
4916
5168
  if (gasUsed.gt(gasLimit)) {
4917
5169
  throw new FuelError15(
4918
5170
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5204,7 +5456,7 @@ var BaseWalletUnlocked = class extends Account {
5204
5456
  * @param transactionRequestLike - The transaction request to send.
5205
5457
  * @returns A promise that resolves to the TransactionResponse object.
5206
5458
  */
5207
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5459
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5208
5460
  const transactionRequest = transactionRequestify(transactionRequestLike);
5209
5461
  if (estimateTxDependencies) {
5210
5462
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5245,7 +5497,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5245
5497
  // src/hdwallet/hdwallet.ts
5246
5498
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5247
5499
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5248
- import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5500
+ import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5249
5501
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5250
5502
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5251
5503
 
@@ -7711,7 +7963,7 @@ var HDWallet = class {
7711
7963
  const IR = bytes.slice(32);
7712
7964
  if (privateKey) {
7713
7965
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7714
- const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7966
+ const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
7715
7967
  return new HDWallet({
7716
7968
  privateKey: ki,
7717
7969
  chainCode: IR,
@@ -7977,26 +8229,20 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7977
8229
 
7978
8230
  // src/test-utils/seedTestWallet.ts
7979
8231
  import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
7980
- var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
7981
- const toFundAccounts = Array.isArray(wallet) ? wallet : [wallet];
8232
+ var seedTestWallet = async (wallet, quantities) => {
7982
8233
  const genesisWallet = new WalletUnlocked(
7983
8234
  process.env.GENESIS_SECRET || randomBytes5(32),
7984
- toFundAccounts[0].provider
8235
+ wallet.provider
7985
8236
  );
7986
- const resources = await genesisWallet.getResourcesToSpend(quantities);
7987
- const { minGasPrice } = genesisWallet.provider.getGasConfig();
7988
- const request = new ScriptTransactionRequest({
7989
- gasLimit: 1e4,
7990
- gasPrice: minGasPrice
8237
+ const request = new ScriptTransactionRequest();
8238
+ quantities.forEach((quantity) => {
8239
+ const { amount, assetId } = coinQuantityfy(quantity);
8240
+ request.addCoinOutput(wallet.address, amount, assetId);
7991
8241
  });
7992
- request.addResources(resources);
7993
- quantities.map(coinQuantityfy).forEach(
7994
- ({ amount, assetId }) => toFundAccounts.forEach(({ address }) => {
7995
- for (let i = 0; i < utxosAmount; i++) {
7996
- request.addCoinOutput(address, amount.div(utxosAmount), assetId);
7997
- }
7998
- })
7999
- );
8242
+ const txCost = await genesisWallet.provider.getTransactionCost(request);
8243
+ request.gasLimit = txCost.gasUsed;
8244
+ request.maxFee = txCost.maxFee;
8245
+ await genesisWallet.fund(request, txCost);
8000
8246
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8001
8247
  };
8002
8248
 
@@ -8011,8 +8257,7 @@ var generateTestWallet = async (provider, quantities) => {
8011
8257
 
8012
8258
  // src/test-utils/launchNode.ts
8013
8259
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8014
- import { toHex as toHex2 } from "@fuel-ts/math";
8015
- import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8260
+ import { defaultChainConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8016
8261
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
8017
8262
  import { spawn } from "child_process";
8018
8263
  import { randomUUID } from "crypto";
@@ -8021,6 +8266,8 @@ import os from "os";
8021
8266
  import path from "path";
8022
8267
  import { getPortPromise } from "portfinder";
8023
8268
  import treeKill from "tree-kill";
8269
+ import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
8270
+ import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
8024
8271
  var getFlagValueFromArgs = (args, flag) => {
8025
8272
  const flagIndex = args.indexOf(flag);
8026
8273
  if (flagIndex === -1) {
@@ -8064,12 +8311,12 @@ var launchNode = async ({
8064
8311
  // eslint-disable-next-line no-async-promise-executor
8065
8312
  new Promise(async (resolve, reject) => {
8066
8313
  const remainingArgs = extractRemainingArgs(args, [
8067
- "--chain",
8314
+ "--snapshot",
8068
8315
  "--consensus-key",
8069
8316
  "--db-type",
8070
8317
  "--poa-instant"
8071
8318
  ]);
8072
- const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8319
+ const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8073
8320
  const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
8074
8321
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8075
8322
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
@@ -8088,36 +8335,54 @@ var launchNode = async ({
8088
8335
  let chainConfigPathToUse;
8089
8336
  const prefix = basePath || os.tmpdir();
8090
8337
  const suffix = basePath ? "" : randomUUID();
8091
- const tempDirPath = path.join(prefix, ".fuels", suffix);
8338
+ const tempDirPath = path.join(prefix, ".fuels", suffix, "chainConfigs");
8092
8339
  if (chainConfigPath) {
8093
8340
  chainConfigPathToUse = chainConfigPath;
8094
8341
  } else {
8095
8342
  if (!existsSync(tempDirPath)) {
8096
8343
  mkdirSync(tempDirPath, { recursive: true });
8097
8344
  }
8098
- const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
8099
- let chainConfig = defaultChainConfig;
8345
+ let { stateConfigJson } = defaultChainConfigs;
8346
+ const { chainConfigJson, metadataJson } = defaultChainConfigs;
8347
+ stateConfigJson = {
8348
+ ...stateConfigJson,
8349
+ coins: [
8350
+ ...stateConfigJson.coins.map((coin) => ({
8351
+ ...coin,
8352
+ amount: "18446744073709551615"
8353
+ }))
8354
+ ],
8355
+ messages: stateConfigJson.messages.map((message) => ({
8356
+ ...message,
8357
+ amount: "18446744073709551615"
8358
+ }))
8359
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8360
+ };
8100
8361
  if (!process.env.GENESIS_SECRET) {
8101
8362
  const pk = Signer.generatePrivateKey();
8102
8363
  const signer = new Signer(pk);
8103
8364
  process.env.GENESIS_SECRET = hexlify18(pk);
8104
- chainConfig = {
8105
- ...defaultChainConfig,
8106
- initial_state: {
8107
- ...defaultChainConfig.initial_state,
8108
- coins: [
8109
- ...defaultChainConfig.initial_state.coins,
8110
- {
8111
- owner: signer.address.toHexString(),
8112
- amount: toHex2(1e9),
8113
- asset_id: BaseAssetId4
8114
- }
8115
- ]
8116
- }
8117
- };
8365
+ stateConfigJson.coins.push({
8366
+ tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
8367
+ owner: signer.address.toHexString(),
8368
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8369
+ amount: "18446744073709551615",
8370
+ asset_id: BaseAssetId4,
8371
+ output_index: 0,
8372
+ tx_pointer_block_height: 0,
8373
+ tx_pointer_tx_idx: 0
8374
+ });
8118
8375
  }
8119
- writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8120
- chainConfigPathToUse = tempChainConfigFilePath;
8376
+ let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8377
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8378
+ fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8379
+ const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8380
+ const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8381
+ const metadataWritePath = path.join(tempDirPath, "metadata.json");
8382
+ writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8383
+ writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8384
+ writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8385
+ chainConfigPathToUse = tempDirPath;
8121
8386
  }
8122
8387
  const child = spawn(
8123
8388
  command,
@@ -8126,10 +8391,10 @@ var launchNode = async ({
8126
8391
  ["--ip", ipToUse],
8127
8392
  ["--port", portToUse],
8128
8393
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8129
- ["--min-gas-price", "0"],
8394
+ ["--min-gas-price", "1"],
8130
8395
  poaInstant ? ["--poa-instant", "true"] : [],
8131
8396
  ["--consensus-key", consensusKey],
8132
- ["--chain", chainConfigPathToUse],
8397
+ ["--snapshot", chainConfigPathToUse],
8133
8398
  "--vm-backtrace",
8134
8399
  "--utxo-validation",
8135
8400
  "--debug",
@@ -8188,51 +8453,14 @@ var launchNodeAndGetWallets = async ({
8188
8453
  walletCount = 10
8189
8454
  } = {}) => {
8190
8455
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8191
- const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8456
+ const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8192
8457
  const wallets = await generateWallets(walletCount, provider);
8193
8458
  const cleanup = () => {
8194
8459
  closeNode();
8195
8460
  };
8196
8461
  return { wallets, stop: cleanup, provider };
8197
8462
  };
8198
-
8199
- // src/test-utils/transactionRequest.ts
8200
- import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
8201
- import { getRandomB256 } from "@fuel-ts/address";
8202
- import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
8203
- import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
8204
- import { bn as bn19 } from "@fuel-ts/math";
8205
- import { InputType as InputType8 } from "@fuel-ts/transactions";
8206
- import { hexlify as hexlify19 } from "@fuel-ts/utils";
8207
- var generateFakeRequestInputCoin = (partial = {}) => ({
8208
- id: hexlify19(randomBytes6(UTXO_ID_LEN3)),
8209
- type: InputType8.Coin,
8210
- owner: getRandomB256(),
8211
- amount: bn19(100),
8212
- assetId: ZeroBytes329,
8213
- txPointer: "0x00000000000000000000000000000000",
8214
- witnessIndex: 0,
8215
- ...partial
8216
- });
8217
- var generateFakeRequestInputMessage = (partial = {}) => ({
8218
- nonce: getRandomB256(),
8219
- type: InputType8.Message,
8220
- sender: getRandomB256(),
8221
- recipient: getRandomB256(),
8222
- amount: bn19(100),
8223
- witnessIndex: 0,
8224
- ...partial
8225
- });
8226
- var generateFakeRequestInputContract = (partial = {}) => ({
8227
- contractId: getRandomB256(),
8228
- type: InputType8.Contract,
8229
- txPointer: "0x00000000000000000000000000000000",
8230
- ...partial
8231
- });
8232
8463
  export {
8233
- generateFakeRequestInputCoin,
8234
- generateFakeRequestInputContract,
8235
- generateFakeRequestInputMessage,
8236
8464
  generateTestWallet,
8237
8465
  killNode,
8238
8466
  launchNode,