@fuel-ts/account 0.0.0-rc-2037-20240418195040 → 0.0.0-rc-2021-20240418195117

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 +797 -596
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +825 -633
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +648 -451
  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 +906 -324
  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 +1547 -1085
  53. package/dist/test-utils.global.js.map +1 -1
  54. package/dist/test-utils.js +804 -608
  55. package/dist/test-utils.js.map +1 -1
  56. package/dist/test-utils.mjs +641 -442
  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
@@ -48,9 +48,6 @@ var __privateMethod = (obj, member, method) => {
48
48
  // src/test-utils/index.ts
49
49
  var test_utils_exports = {};
50
50
  __export(test_utils_exports, {
51
- generateFakeRequestInputCoin: () => generateFakeRequestInputCoin,
52
- generateFakeRequestInputContract: () => generateFakeRequestInputContract,
53
- generateFakeRequestInputMessage: () => generateFakeRequestInputMessage,
54
51
  generateTestWallet: () => generateTestWallet,
55
52
  killNode: () => killNode,
56
53
  launchNode: () => launchNode,
@@ -61,15 +58,16 @@ module.exports = __toCommonJS(test_utils_exports);
61
58
 
62
59
  // src/wallet/base-wallet-unlocked.ts
63
60
  var import_hasher3 = require("@fuel-ts/hasher");
64
- var import_utils31 = require("@fuel-ts/utils");
61
+ var import_utils30 = require("@fuel-ts/utils");
65
62
 
66
63
  // src/account.ts
67
64
  var import_address4 = require("@fuel-ts/address");
68
65
  var import_configs12 = require("@fuel-ts/address/configs");
69
66
  var import_errors16 = require("@fuel-ts/errors");
70
67
  var import_interfaces = require("@fuel-ts/interfaces");
71
- var import_math18 = require("@fuel-ts/math");
72
- var import_utils28 = require("@fuel-ts/utils");
68
+ var import_math19 = require("@fuel-ts/math");
69
+ var import_utils27 = require("@fuel-ts/utils");
70
+ var import_ramda4 = require("ramda");
73
71
 
74
72
  // src/providers/coin-quantity.ts
75
73
  var import_configs = require("@fuel-ts/address/configs");
@@ -78,24 +76,24 @@ var import_utils = require("@fuel-ts/utils");
78
76
  var coinQuantityfy = (coinQuantityLike) => {
79
77
  let assetId;
80
78
  let amount;
81
- let max2;
79
+ let max;
82
80
  if (Array.isArray(coinQuantityLike)) {
83
81
  amount = coinQuantityLike[0];
84
82
  assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
85
- max2 = coinQuantityLike[2] ?? void 0;
83
+ max = coinQuantityLike[2] ?? void 0;
86
84
  } else {
87
85
  amount = coinQuantityLike.amount;
88
86
  assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
89
- max2 = coinQuantityLike.max ?? void 0;
87
+ max = coinQuantityLike.max ?? void 0;
90
88
  }
91
89
  const bnAmount = (0, import_math.bn)(amount);
92
90
  return {
93
91
  assetId: (0, import_utils.hexlify)(assetId),
94
92
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
95
- max: max2 ? (0, import_math.bn)(max2) : void 0
93
+ max: max ? (0, import_math.bn)(max) : void 0
96
94
  };
97
95
  };
98
- var addAmountToAsset = (params) => {
96
+ var addAmountToCoinQuantities = (params) => {
99
97
  const { amount, assetId } = params;
100
98
  const coinQuantities = [...params.coinQuantities];
101
99
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -110,11 +108,11 @@ var addAmountToAsset = (params) => {
110
108
  // src/providers/provider.ts
111
109
  var import_address3 = require("@fuel-ts/address");
112
110
  var import_errors14 = require("@fuel-ts/errors");
113
- var import_math15 = require("@fuel-ts/math");
111
+ var import_math16 = require("@fuel-ts/math");
114
112
  var import_transactions19 = require("@fuel-ts/transactions");
115
- var import_utils23 = require("@fuel-ts/utils");
113
+ var import_utils22 = require("@fuel-ts/utils");
116
114
  var import_versions = require("@fuel-ts/versions");
117
- var import_utils24 = require("@noble/curves/abstract/utils");
115
+ var import_utils23 = require("@noble/curves/abstract/utils");
118
116
  var import_ethers = require("ethers");
119
117
  var import_graphql_request = require("graphql-request");
120
118
  var import_ramda3 = require("ramda");
@@ -123,14 +121,10 @@ var import_ramda3 = require("ramda");
123
121
  var import_graphql_tag = __toESM(require("graphql-tag"));
124
122
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
125
123
  fragment receiptFragment on Receipt {
126
- contract {
127
- id
128
- }
124
+ id
129
125
  pc
130
126
  is
131
- to {
132
- id
133
- }
127
+ to
134
128
  toAddress
135
129
  amount
136
130
  assetId
@@ -168,10 +162,16 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
168
162
  id
169
163
  }
170
164
  time
165
+ receipts {
166
+ ...receiptFragment
167
+ }
171
168
  programState {
172
169
  returnType
173
170
  data
174
171
  }
172
+ receipts {
173
+ ...receiptFragment
174
+ }
175
175
  }
176
176
  ... on FailureStatus {
177
177
  block {
@@ -179,26 +179,24 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
179
179
  }
180
180
  time
181
181
  reason
182
+ receipts {
183
+ ...receiptFragment
184
+ }
182
185
  }
183
186
  ... on SqueezedOutStatus {
184
187
  reason
185
188
  }
186
189
  }
187
- `;
190
+ ${ReceiptFragmentFragmentDoc}`;
188
191
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
189
192
  fragment transactionFragment on Transaction {
190
193
  id
191
194
  rawPayload
192
- gasPrice
193
- receipts {
194
- ...receiptFragment
195
- }
196
195
  status {
197
196
  ...transactionStatusFragment
198
197
  }
199
198
  }
200
- ${ReceiptFragmentFragmentDoc}
201
- ${TransactionStatusFragmentFragmentDoc}`;
199
+ ${TransactionStatusFragmentFragmentDoc}`;
202
200
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
203
201
  fragment inputEstimatePredicatesFragment on Input {
204
202
  ... on InputCoin {
@@ -216,6 +214,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
216
214
  }
217
215
  }
218
216
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
217
+ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
218
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
219
+ reason
220
+ programState {
221
+ returnType
222
+ data
223
+ }
224
+ }
225
+ `;
226
+ var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
227
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
228
+ programState {
229
+ returnType
230
+ data
231
+ }
232
+ }
233
+ `;
234
+ var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
235
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
236
+ ... on DryRunFailureStatus {
237
+ ...dryRunFailureStatusFragment
238
+ }
239
+ ... on DryRunSuccessStatus {
240
+ ...dryRunSuccessStatusFragment
241
+ }
242
+ }
243
+ ${DryRunFailureStatusFragmentFragmentDoc}
244
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
245
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
246
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
247
+ id
248
+ status {
249
+ ...dryRunTransactionStatusFragment
250
+ }
251
+ receipts {
252
+ ...receiptFragment
253
+ }
254
+ }
255
+ ${DryRunTransactionStatusFragmentFragmentDoc}
256
+ ${ReceiptFragmentFragmentDoc}`;
219
257
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
220
258
  fragment coinFragment on Coin {
221
259
  __typename
@@ -223,7 +261,6 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
223
261
  owner
224
262
  amount
225
263
  assetId
226
- maturity
227
264
  blockCreated
228
265
  txCreatedIdx
229
266
  }
@@ -262,26 +299,32 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
262
299
  messageBlockHeader {
263
300
  id
264
301
  daHeight
302
+ consensusParametersVersion
303
+ stateTransitionBytecodeVersion
265
304
  transactionsCount
305
+ messageReceiptCount
266
306
  transactionsRoot
307
+ messageOutboxRoot
308
+ eventInboxRoot
267
309
  height
268
310
  prevRoot
269
311
  time
270
312
  applicationHash
271
- messageReceiptRoot
272
- messageReceiptCount
273
313
  }
274
314
  commitBlockHeader {
275
315
  id
276
316
  daHeight
317
+ consensusParametersVersion
318
+ stateTransitionBytecodeVersion
277
319
  transactionsCount
320
+ messageReceiptCount
278
321
  transactionsRoot
322
+ messageOutboxRoot
323
+ eventInboxRoot
279
324
  height
280
325
  prevRoot
281
326
  time
282
327
  applicationHash
283
- messageReceiptRoot
284
- messageReceiptCount
285
328
  }
286
329
  sender
287
330
  recipient
@@ -300,8 +343,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
300
343
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
301
344
  fragment blockFragment on Block {
302
345
  id
346
+ height
303
347
  header {
304
- height
305
348
  time
306
349
  }
307
350
  transactions {
@@ -359,6 +402,11 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
359
402
  `;
360
403
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
361
404
  fragment GasCostsFragment on GasCosts {
405
+ version {
406
+ ... on Version {
407
+ value
408
+ }
409
+ }
362
410
  add
363
411
  addi
364
412
  aloc
@@ -371,7 +419,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
371
419
  cb
372
420
  cfei
373
421
  cfsi
374
- croo
375
422
  div
376
423
  divi
377
424
  ecr1
@@ -454,6 +501,9 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
454
501
  ccp {
455
502
  ...DependentCostFragment
456
503
  }
504
+ croo {
505
+ ...DependentCostFragment
506
+ }
457
507
  csiz {
458
508
  ...DependentCostFragment
459
509
  }
@@ -513,6 +563,11 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
513
563
  ${DependentCostFragmentFragmentDoc}`;
514
564
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
515
565
  fragment consensusParametersFragment on ConsensusParameters {
566
+ version {
567
+ ... on Version {
568
+ value
569
+ }
570
+ }
516
571
  txParams {
517
572
  ...TxParametersFragment
518
573
  }
@@ -572,18 +627,9 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
572
627
  fragment nodeInfoFragment on NodeInfo {
573
628
  utxoValidation
574
629
  vmBacktrace
575
- minGasPrice
576
630
  maxTx
577
631
  maxDepth
578
632
  nodeVersion
579
- peers {
580
- id
581
- addresses
582
- clientVersion
583
- blockHeight
584
- lastHeartbeatMs
585
- appScore
586
- }
587
633
  }
588
634
  `;
589
635
  var GetVersionDocument = import_graphql_tag.default`
@@ -618,13 +664,9 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
618
664
  query getTransactionWithReceipts($transactionId: TransactionId!) {
619
665
  transaction(id: $transactionId) {
620
666
  ...transactionFragment
621
- receipts {
622
- ...receiptFragment
623
- }
624
667
  }
625
668
  }
626
- ${TransactionFragmentFragmentDoc}
627
- ${ReceiptFragmentFragmentDoc}`;
669
+ ${TransactionFragmentFragmentDoc}`;
628
670
  var GetTransactionsDocument = import_graphql_tag.default`
629
671
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
630
672
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -752,6 +794,20 @@ var GetBalanceDocument = import_graphql_tag.default`
752
794
  }
753
795
  }
754
796
  ${BalanceFragmentFragmentDoc}`;
797
+ var GetLatestGasPriceDocument = import_graphql_tag.default`
798
+ query getLatestGasPrice {
799
+ latestGasPrice {
800
+ gasPrice
801
+ }
802
+ }
803
+ `;
804
+ var EstimateGasPriceDocument = import_graphql_tag.default`
805
+ query estimateGasPrice($blockHorizon: U32!) {
806
+ estimateGasPrice(blockHorizon: $blockHorizon) {
807
+ gasPrice
808
+ }
809
+ }
810
+ `;
755
811
  var GetBalancesDocument = import_graphql_tag.default`
756
812
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
757
813
  balances(
@@ -806,12 +862,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
806
862
  }
807
863
  `;
808
864
  var DryRunDocument = import_graphql_tag.default`
809
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
810
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
811
- ...receiptFragment
865
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
866
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
867
+ ...dryRunTransactionExecutionStatusFragment
812
868
  }
813
869
  }
814
- ${ReceiptFragmentFragmentDoc}`;
870
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
815
871
  var SubmitDocument = import_graphql_tag.default`
816
872
  mutation submit($encodedTransaction: HexString!) {
817
873
  submit(tx: $encodedTransaction) {
@@ -894,6 +950,12 @@ function getSdk(requester) {
894
950
  getBalance(variables, options) {
895
951
  return requester(GetBalanceDocument, variables, options);
896
952
  },
953
+ getLatestGasPrice(variables, options) {
954
+ return requester(GetLatestGasPriceDocument, variables, options);
955
+ },
956
+ estimateGasPrice(variables, options) {
957
+ return requester(EstimateGasPriceDocument, variables, options);
958
+ },
897
959
  getBalances(variables, options) {
898
960
  return requester(GetBalancesDocument, variables, options);
899
961
  },
@@ -1087,10 +1149,9 @@ var inputify = (value) => {
1087
1149
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1088
1150
  },
1089
1151
  witnessIndex: value.witnessIndex,
1090
- maturity: value.maturity ?? 0,
1091
1152
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1092
- predicateLength: predicate.length,
1093
- predicateDataLength: predicateData.length,
1153
+ predicateLength: (0, import_math2.bn)(predicate.length),
1154
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1094
1155
  predicate: (0, import_utils3.hexlify)(predicate),
1095
1156
  predicateData: (0, import_utils3.hexlify)(predicateData)
1096
1157
  };
@@ -1121,8 +1182,8 @@ var inputify = (value) => {
1121
1182
  nonce: (0, import_utils3.hexlify)(value.nonce),
1122
1183
  witnessIndex: value.witnessIndex,
1123
1184
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1124
- predicateLength: predicate.length,
1125
- predicateDataLength: predicateData.length,
1185
+ predicateLength: (0, import_math2.bn)(predicate.length),
1186
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1126
1187
  predicate: (0, import_utils3.hexlify)(predicate),
1127
1188
  predicateData: (0, import_utils3.hexlify)(predicateData),
1128
1189
  data: (0, import_utils3.hexlify)(data),
@@ -1201,7 +1262,7 @@ var import_address = require("@fuel-ts/address");
1201
1262
  var import_configs7 = require("@fuel-ts/address/configs");
1202
1263
  var import_crypto = require("@fuel-ts/crypto");
1203
1264
  var import_math7 = require("@fuel-ts/math");
1204
- var import_transactions7 = require("@fuel-ts/transactions");
1265
+ var import_transactions6 = require("@fuel-ts/transactions");
1205
1266
  var import_utils9 = require("@fuel-ts/utils");
1206
1267
 
1207
1268
  // src/providers/resource.ts
@@ -1238,8 +1299,8 @@ function assembleReceiptByType(receipt) {
1238
1299
  case "CALL" /* Call */: {
1239
1300
  const callReceipt = {
1240
1301
  type: import_transactions3.ReceiptType.Call,
1241
- from: hexOrZero(receipt.contract?.id),
1242
- to: hexOrZero(receipt?.to?.id),
1302
+ from: hexOrZero(receipt.id || receipt.contractId),
1303
+ to: hexOrZero(receipt?.to),
1243
1304
  amount: (0, import_math4.bn)(receipt.amount),
1244
1305
  assetId: hexOrZero(receipt.assetId),
1245
1306
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1253,7 +1314,7 @@ function assembleReceiptByType(receipt) {
1253
1314
  case "RETURN" /* Return */: {
1254
1315
  const returnReceipt = {
1255
1316
  type: import_transactions3.ReceiptType.Return,
1256
- id: hexOrZero(receipt.contract?.id),
1317
+ id: hexOrZero(receipt.id || receipt.contractId),
1257
1318
  val: (0, import_math4.bn)(receipt.val),
1258
1319
  pc: (0, import_math4.bn)(receipt.pc),
1259
1320
  is: (0, import_math4.bn)(receipt.is)
@@ -1263,7 +1324,7 @@ function assembleReceiptByType(receipt) {
1263
1324
  case "RETURN_DATA" /* ReturnData */: {
1264
1325
  const returnDataReceipt = {
1265
1326
  type: import_transactions3.ReceiptType.ReturnData,
1266
- id: hexOrZero(receipt.contract?.id),
1327
+ id: hexOrZero(receipt.id || receipt.contractId),
1267
1328
  ptr: (0, import_math4.bn)(receipt.ptr),
1268
1329
  len: (0, import_math4.bn)(receipt.len),
1269
1330
  digest: hexOrZero(receipt.digest),
@@ -1275,7 +1336,7 @@ function assembleReceiptByType(receipt) {
1275
1336
  case "PANIC" /* Panic */: {
1276
1337
  const panicReceipt = {
1277
1338
  type: import_transactions3.ReceiptType.Panic,
1278
- id: hexOrZero(receipt.contract?.id),
1339
+ id: hexOrZero(receipt.id),
1279
1340
  reason: (0, import_math4.bn)(receipt.reason),
1280
1341
  pc: (0, import_math4.bn)(receipt.pc),
1281
1342
  is: (0, import_math4.bn)(receipt.is),
@@ -1286,7 +1347,7 @@ function assembleReceiptByType(receipt) {
1286
1347
  case "REVERT" /* Revert */: {
1287
1348
  const revertReceipt = {
1288
1349
  type: import_transactions3.ReceiptType.Revert,
1289
- id: hexOrZero(receipt.contract?.id),
1350
+ id: hexOrZero(receipt.id || receipt.contractId),
1290
1351
  val: (0, import_math4.bn)(receipt.ra),
1291
1352
  pc: (0, import_math4.bn)(receipt.pc),
1292
1353
  is: (0, import_math4.bn)(receipt.is)
@@ -1296,7 +1357,7 @@ function assembleReceiptByType(receipt) {
1296
1357
  case "LOG" /* Log */: {
1297
1358
  const logReceipt = {
1298
1359
  type: import_transactions3.ReceiptType.Log,
1299
- id: hexOrZero(receipt.contract?.id),
1360
+ id: hexOrZero(receipt.id || receipt.contractId),
1300
1361
  val0: (0, import_math4.bn)(receipt.ra),
1301
1362
  val1: (0, import_math4.bn)(receipt.rb),
1302
1363
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1309,7 +1370,7 @@ function assembleReceiptByType(receipt) {
1309
1370
  case "LOG_DATA" /* LogData */: {
1310
1371
  const logDataReceipt = {
1311
1372
  type: import_transactions3.ReceiptType.LogData,
1312
- id: hexOrZero(receipt.contract?.id),
1373
+ id: hexOrZero(receipt.id || receipt.contractId),
1313
1374
  val0: (0, import_math4.bn)(receipt.ra),
1314
1375
  val1: (0, import_math4.bn)(receipt.rb),
1315
1376
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1323,8 +1384,8 @@ function assembleReceiptByType(receipt) {
1323
1384
  case "TRANSFER" /* Transfer */: {
1324
1385
  const transferReceipt = {
1325
1386
  type: import_transactions3.ReceiptType.Transfer,
1326
- from: hexOrZero(receipt.contract?.id),
1327
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1387
+ from: hexOrZero(receipt.id || receipt.contractId),
1388
+ to: hexOrZero(receipt.toAddress || receipt?.to),
1328
1389
  amount: (0, import_math4.bn)(receipt.amount),
1329
1390
  assetId: hexOrZero(receipt.assetId),
1330
1391
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1335,8 +1396,8 @@ function assembleReceiptByType(receipt) {
1335
1396
  case "TRANSFER_OUT" /* TransferOut */: {
1336
1397
  const transferOutReceipt = {
1337
1398
  type: import_transactions3.ReceiptType.TransferOut,
1338
- from: hexOrZero(receipt.contract?.id),
1339
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
1399
+ from: hexOrZero(receipt.id || receipt.contractId),
1400
+ to: hexOrZero(receipt.toAddress || receipt.to),
1340
1401
  amount: (0, import_math4.bn)(receipt.amount),
1341
1402
  assetId: hexOrZero(receipt.assetId),
1342
1403
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1379,7 +1440,7 @@ function assembleReceiptByType(receipt) {
1379
1440
  return receiptMessageOut;
1380
1441
  }
1381
1442
  case "MINT" /* Mint */: {
1382
- const contractId = hexOrZero(receipt.contract?.id);
1443
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1383
1444
  const subId = hexOrZero(receipt.subId);
1384
1445
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1385
1446
  const mintReceipt = {
@@ -1394,7 +1455,7 @@ function assembleReceiptByType(receipt) {
1394
1455
  return mintReceipt;
1395
1456
  }
1396
1457
  case "BURN" /* Burn */: {
1397
- const contractId = hexOrZero(receipt.contract?.id);
1458
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1398
1459
  const subId = hexOrZero(receipt.subId);
1399
1460
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1400
1461
  const burnReceipt = {
@@ -1420,7 +1481,6 @@ var import_errors6 = require("@fuel-ts/errors");
1420
1481
  var import_math5 = require("@fuel-ts/math");
1421
1482
  var import_transactions4 = require("@fuel-ts/transactions");
1422
1483
  var import_utils6 = require("@fuel-ts/utils");
1423
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1424
1484
  var getGasUsedFromReceipts = (receipts) => {
1425
1485
  const scriptResult = receipts.filter(
1426
1486
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1441,18 +1501,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1441
1501
  }
1442
1502
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1443
1503
  const witnessCache = [];
1444
- const totalGas = inputs.reduce((total, input) => {
1504
+ const chargeableInputs = inputs.filter((input) => {
1505
+ const isCoinOrMessage = "owner" in input || "sender" in input;
1506
+ if (isCoinOrMessage) {
1507
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1508
+ return true;
1509
+ }
1510
+ if (!witnessCache.includes(input.witnessIndex)) {
1511
+ witnessCache.push(input.witnessIndex);
1512
+ return true;
1513
+ }
1514
+ }
1515
+ return false;
1516
+ });
1517
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1518
+ const totalGas = chargeableInputs.reduce((total, input) => {
1445
1519
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1446
1520
  return total.add(
1447
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1521
+ vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1448
1522
  );
1449
1523
  }
1450
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1451
- witnessCache.push(input.witnessIndex);
1452
- return total.add(gasCosts.ecr1);
1453
- }
1454
- return total;
1455
- }, (0, import_math5.bn)());
1524
+ return total.add(gasCosts.ecr1);
1525
+ }, (0, import_math5.bn)(0));
1456
1526
  return totalGas;
1457
1527
  }
1458
1528
  function getMinGas(params) {
@@ -1464,12 +1534,20 @@ function getMinGas(params) {
1464
1534
  return minGas;
1465
1535
  }
1466
1536
  function getMaxGas(params) {
1467
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1537
+ const {
1538
+ gasPerByte,
1539
+ witnessesLength,
1540
+ witnessLimit,
1541
+ minGas,
1542
+ gasLimit = (0, import_math5.bn)(0),
1543
+ maxGasPerTx
1544
+ } = params;
1468
1545
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1469
1546
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1470
1547
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1471
1548
  }
1472
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1549
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1550
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1473
1551
  }
1474
1552
  function calculateMetadataGasForTxCreate({
1475
1553
  gasCosts,
@@ -1491,6 +1569,10 @@ function calculateMetadataGasForTxScript({
1491
1569
  }) {
1492
1570
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1493
1571
  }
1572
+ var calculateGasFee = (params) => {
1573
+ const { gas, gasPrice, priceFactor, tip } = params;
1574
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
1575
+ };
1494
1576
 
1495
1577
  // src/providers/utils/json.ts
1496
1578
  var import_utils7 = require("@fuel-ts/utils");
@@ -1614,12 +1696,6 @@ var NoWitnessAtIndexError = class extends Error {
1614
1696
  name = "NoWitnessAtIndexError";
1615
1697
  };
1616
1698
 
1617
- // src/providers/transaction-request/helpers.ts
1618
- var import_transactions6 = require("@fuel-ts/transactions");
1619
- var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
1620
- var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
1621
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1622
-
1623
1699
  // src/providers/transaction-request/witness.ts
1624
1700
  var import_utils8 = require("@fuel-ts/utils");
1625
1701
  var witnessify = (value) => {
@@ -1633,7 +1709,7 @@ var witnessify = (value) => {
1633
1709
  // src/providers/transaction-request/transaction-request.ts
1634
1710
  var BaseTransactionRequest = class {
1635
1711
  /** Gas price for transaction */
1636
- gasPrice;
1712
+ tip;
1637
1713
  /** Block until which tx cannot be included */
1638
1714
  maturity;
1639
1715
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1652,7 +1728,7 @@ var BaseTransactionRequest = class {
1652
1728
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1653
1729
  */
1654
1730
  constructor({
1655
- gasPrice,
1731
+ tip,
1656
1732
  maturity,
1657
1733
  maxFee,
1658
1734
  witnessLimit,
@@ -1660,7 +1736,7 @@ var BaseTransactionRequest = class {
1660
1736
  outputs,
1661
1737
  witnesses
1662
1738
  } = {}) {
1663
- this.gasPrice = (0, import_math7.bn)(gasPrice);
1739
+ this.tip = (0, import_math7.bn)(tip);
1664
1740
  this.maturity = maturity ?? 0;
1665
1741
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1666
1742
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1671,21 +1747,21 @@ var BaseTransactionRequest = class {
1671
1747
  static getPolicyMeta(req) {
1672
1748
  let policyTypes = 0;
1673
1749
  const policies = [];
1674
- if (req.gasPrice) {
1675
- policyTypes += import_transactions7.PolicyType.GasPrice;
1676
- policies.push({ data: req.gasPrice, type: import_transactions7.PolicyType.GasPrice });
1750
+ if (req.tip) {
1751
+ policyTypes += import_transactions6.PolicyType.Tip;
1752
+ policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1677
1753
  }
1678
1754
  if (req.witnessLimit) {
1679
- policyTypes += import_transactions7.PolicyType.WitnessLimit;
1680
- policies.push({ data: req.witnessLimit, type: import_transactions7.PolicyType.WitnessLimit });
1755
+ policyTypes += import_transactions6.PolicyType.WitnessLimit;
1756
+ policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1681
1757
  }
1682
1758
  if (req.maturity > 0) {
1683
- policyTypes += import_transactions7.PolicyType.Maturity;
1684
- policies.push({ data: req.maturity, type: import_transactions7.PolicyType.Maturity });
1759
+ policyTypes += import_transactions6.PolicyType.Maturity;
1760
+ policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1685
1761
  }
1686
1762
  if (req.maxFee) {
1687
- policyTypes += import_transactions7.PolicyType.MaxFee;
1688
- policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
1763
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1764
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1689
1765
  }
1690
1766
  return {
1691
1767
  policyTypes,
@@ -1719,7 +1795,7 @@ var BaseTransactionRequest = class {
1719
1795
  * @returns The transaction bytes.
1720
1796
  */
1721
1797
  toTransactionBytes() {
1722
- return new import_transactions7.TransactionCoder().encode(this.toTransaction());
1798
+ return new import_transactions6.TransactionCoder().encode(this.toTransaction());
1723
1799
  }
1724
1800
  /**
1725
1801
  * @hidden
@@ -1810,7 +1886,7 @@ var BaseTransactionRequest = class {
1810
1886
  */
1811
1887
  getCoinInputs() {
1812
1888
  return this.inputs.filter(
1813
- (input) => input.type === import_transactions7.InputType.Coin
1889
+ (input) => input.type === import_transactions6.InputType.Coin
1814
1890
  );
1815
1891
  }
1816
1892
  /**
@@ -1820,7 +1896,7 @@ var BaseTransactionRequest = class {
1820
1896
  */
1821
1897
  getCoinOutputs() {
1822
1898
  return this.outputs.filter(
1823
- (output) => output.type === import_transactions7.OutputType.Coin
1899
+ (output) => output.type === import_transactions6.OutputType.Coin
1824
1900
  );
1825
1901
  }
1826
1902
  /**
@@ -1830,7 +1906,7 @@ var BaseTransactionRequest = class {
1830
1906
  */
1831
1907
  getChangeOutputs() {
1832
1908
  return this.outputs.filter(
1833
- (output) => output.type === import_transactions7.OutputType.Change
1909
+ (output) => output.type === import_transactions6.OutputType.Change
1834
1910
  );
1835
1911
  }
1836
1912
  /**
@@ -1842,9 +1918,9 @@ var BaseTransactionRequest = class {
1842
1918
  const ownerAddress = (0, import_address.addressify)(owner);
1843
1919
  const found = this.inputs.find((input) => {
1844
1920
  switch (input.type) {
1845
- case import_transactions7.InputType.Coin:
1921
+ case import_transactions6.InputType.Coin:
1846
1922
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
1847
- case import_transactions7.InputType.Message:
1923
+ case import_transactions6.InputType.Message:
1848
1924
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
1849
1925
  default:
1850
1926
  return false;
@@ -1861,9 +1937,9 @@ var BaseTransactionRequest = class {
1861
1937
  * @param predicateData - Predicate data bytes.
1862
1938
  */
1863
1939
  addCoinInput(coin) {
1864
- const { assetId, owner, amount, id, predicate } = coin;
1940
+ const { assetId, owner, amount } = coin;
1865
1941
  let witnessIndex;
1866
- if (predicate) {
1942
+ if (coin.predicate) {
1867
1943
  witnessIndex = 0;
1868
1944
  } else {
1869
1945
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1872,14 +1948,13 @@ var BaseTransactionRequest = class {
1872
1948
  }
1873
1949
  }
1874
1950
  const input = {
1875
- id,
1876
- type: import_transactions7.InputType.Coin,
1951
+ ...coin,
1952
+ type: import_transactions6.InputType.Coin,
1877
1953
  owner: owner.toB256(),
1878
1954
  amount,
1879
1955
  assetId,
1880
1956
  txPointer: "0x00000000000000000000000000000000",
1881
- witnessIndex,
1882
- predicate
1957
+ witnessIndex
1883
1958
  };
1884
1959
  this.pushInput(input);
1885
1960
  this.addChangeOutput(owner, assetId);
@@ -1893,10 +1968,10 @@ var BaseTransactionRequest = class {
1893
1968
  * @param predicateData - Predicate data bytes.
1894
1969
  */
1895
1970
  addMessageInput(message) {
1896
- const { recipient, sender, amount, predicate, nonce } = message;
1971
+ const { recipient, sender, amount } = message;
1897
1972
  const assetId = import_configs7.BaseAssetId;
1898
1973
  let witnessIndex;
1899
- if (predicate) {
1974
+ if (message.predicate) {
1900
1975
  witnessIndex = 0;
1901
1976
  } else {
1902
1977
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1905,13 +1980,12 @@ var BaseTransactionRequest = class {
1905
1980
  }
1906
1981
  }
1907
1982
  const input = {
1908
- nonce,
1909
- type: import_transactions7.InputType.Message,
1983
+ ...message,
1984
+ type: import_transactions6.InputType.Message,
1910
1985
  sender: sender.toB256(),
1911
1986
  recipient: recipient.toB256(),
1912
1987
  amount,
1913
- witnessIndex,
1914
- predicate
1988
+ witnessIndex
1915
1989
  };
1916
1990
  this.pushInput(input);
1917
1991
  this.addChangeOutput(recipient, assetId);
@@ -1951,7 +2025,7 @@ var BaseTransactionRequest = class {
1951
2025
  */
1952
2026
  addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
1953
2027
  this.pushOutput({
1954
- type: import_transactions7.OutputType.Coin,
2028
+ type: import_transactions6.OutputType.Coin,
1955
2029
  to: (0, import_address.addressify)(to).toB256(),
1956
2030
  amount,
1957
2031
  assetId
@@ -1967,7 +2041,7 @@ var BaseTransactionRequest = class {
1967
2041
  addCoinOutputs(to, quantities) {
1968
2042
  quantities.map(coinQuantityfy).forEach((quantity) => {
1969
2043
  this.pushOutput({
1970
- type: import_transactions7.OutputType.Coin,
2044
+ type: import_transactions6.OutputType.Coin,
1971
2045
  to: (0, import_address.addressify)(to).toB256(),
1972
2046
  amount: quantity.amount,
1973
2047
  assetId: quantity.assetId
@@ -1987,7 +2061,7 @@ var BaseTransactionRequest = class {
1987
2061
  );
1988
2062
  if (!changeOutput) {
1989
2063
  this.pushOutput({
1990
- type: import_transactions7.OutputType.Change,
2064
+ type: import_transactions6.OutputType.Change,
1991
2065
  to: (0, import_address.addressify)(to).toB256(),
1992
2066
  assetId
1993
2067
  });
@@ -2021,7 +2095,7 @@ var BaseTransactionRequest = class {
2021
2095
  }
2022
2096
  calculateMaxGas(chainInfo, minGas) {
2023
2097
  const { consensusParameters } = chainInfo;
2024
- const { gasPerByte } = consensusParameters;
2098
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2025
2099
  const witnessesLength = this.toTransaction().witnesses.reduce(
2026
2100
  (acc, wit) => acc + wit.dataLength,
2027
2101
  0
@@ -2030,7 +2104,8 @@ var BaseTransactionRequest = class {
2030
2104
  gasPerByte,
2031
2105
  minGas,
2032
2106
  witnessesLength,
2033
- witnessLimit: this.witnessLimit
2107
+ witnessLimit: this.witnessLimit,
2108
+ maxGasPerTx
2034
2109
  });
2035
2110
  }
2036
2111
  /**
@@ -2048,17 +2123,20 @@ var BaseTransactionRequest = class {
2048
2123
  });
2049
2124
  const updateAssetInput = (assetId, quantity) => {
2050
2125
  const assetInput = findAssetInput(assetId);
2126
+ let usedQuantity = quantity;
2127
+ if (assetId === import_configs7.BaseAssetId) {
2128
+ usedQuantity = (0, import_math7.bn)("1000000000000000000");
2129
+ }
2051
2130
  if (assetInput && "assetId" in assetInput) {
2052
2131
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2053
- assetInput.amount = quantity;
2132
+ assetInput.amount = usedQuantity;
2054
2133
  } else {
2055
2134
  this.addResources([
2056
2135
  {
2057
2136
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2058
- amount: quantity,
2137
+ amount: usedQuantity,
2059
2138
  assetId,
2060
2139
  owner: resourcesOwner || import_address.Address.fromRandom(),
2061
- maturity: 0,
2062
2140
  blockCreated: (0, import_math7.bn)(1),
2063
2141
  txCreatedIdx: (0, import_math7.bn)(1)
2064
2142
  }
@@ -2090,20 +2168,16 @@ var BaseTransactionRequest = class {
2090
2168
  toJSON() {
2091
2169
  return normalizeJSON(this);
2092
2170
  }
2093
- removeWitness(index) {
2094
- this.witnesses.splice(index, 1);
2095
- this.adjustWitnessIndexes(index);
2096
- }
2097
- updatePredicateInputs(inputs) {
2171
+ updatePredicateGasUsed(inputs) {
2098
2172
  this.inputs.forEach((i) => {
2099
2173
  let correspondingInput;
2100
2174
  switch (i.type) {
2101
- case import_transactions7.InputType.Coin:
2102
- correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
2175
+ case import_transactions6.InputType.Coin:
2176
+ correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2103
2177
  break;
2104
- case import_transactions7.InputType.Message:
2178
+ case import_transactions6.InputType.Message:
2105
2179
  correspondingInput = inputs.find(
2106
- (x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
2180
+ (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2107
2181
  );
2108
2182
  break;
2109
2183
  default:
@@ -2116,10 +2190,12 @@ var BaseTransactionRequest = class {
2116
2190
  }
2117
2191
  });
2118
2192
  }
2119
- adjustWitnessIndexes(removedIndex) {
2120
- this.inputs.filter(isRequestInputResource).forEach((input) => {
2121
- if (input.witnessIndex > removedIndex) {
2122
- input.witnessIndex -= 1;
2193
+ shiftPredicateData() {
2194
+ this.inputs.forEach((input) => {
2195
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2196
+ input.predicateData = input.paddPredicateData(
2197
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2198
+ );
2123
2199
  }
2124
2200
  });
2125
2201
  }
@@ -2128,25 +2204,25 @@ var BaseTransactionRequest = class {
2128
2204
  // src/providers/transaction-request/create-transaction-request.ts
2129
2205
  var import_configs9 = require("@fuel-ts/address/configs");
2130
2206
  var import_math9 = require("@fuel-ts/math");
2131
- var import_transactions9 = require("@fuel-ts/transactions");
2207
+ var import_transactions8 = require("@fuel-ts/transactions");
2132
2208
  var import_utils13 = require("@fuel-ts/utils");
2133
2209
 
2134
2210
  // src/providers/transaction-request/hash-transaction.ts
2135
2211
  var import_configs8 = require("@fuel-ts/address/configs");
2136
2212
  var import_hasher = require("@fuel-ts/hasher");
2137
2213
  var import_math8 = require("@fuel-ts/math");
2138
- var import_transactions8 = require("@fuel-ts/transactions");
2214
+ var import_transactions7 = require("@fuel-ts/transactions");
2139
2215
  var import_utils11 = require("@fuel-ts/utils");
2140
2216
  var import_ramda2 = require("ramda");
2141
2217
  function hashTransaction(transactionRequest, chainId) {
2142
2218
  const transaction = transactionRequest.toTransaction();
2143
- if (transaction.type === import_transactions8.TransactionType.Script) {
2219
+ if (transaction.type === import_transactions7.TransactionType.Script) {
2144
2220
  transaction.receiptsRoot = import_configs8.ZeroBytes32;
2145
2221
  }
2146
2222
  transaction.inputs = transaction.inputs.map((input) => {
2147
2223
  const inputClone = (0, import_ramda2.clone)(input);
2148
2224
  switch (inputClone.type) {
2149
- case import_transactions8.InputType.Coin: {
2225
+ case import_transactions7.InputType.Coin: {
2150
2226
  inputClone.txPointer = {
2151
2227
  blockHeight: 0,
2152
2228
  txIndex: 0
@@ -2154,11 +2230,11 @@ function hashTransaction(transactionRequest, chainId) {
2154
2230
  inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2155
2231
  return inputClone;
2156
2232
  }
2157
- case import_transactions8.InputType.Message: {
2233
+ case import_transactions7.InputType.Message: {
2158
2234
  inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2159
2235
  return inputClone;
2160
2236
  }
2161
- case import_transactions8.InputType.Contract: {
2237
+ case import_transactions7.InputType.Contract: {
2162
2238
  inputClone.txPointer = {
2163
2239
  blockHeight: 0,
2164
2240
  txIndex: 0
@@ -2176,16 +2252,16 @@ function hashTransaction(transactionRequest, chainId) {
2176
2252
  transaction.outputs = transaction.outputs.map((output) => {
2177
2253
  const outputClone = (0, import_ramda2.clone)(output);
2178
2254
  switch (outputClone.type) {
2179
- case import_transactions8.OutputType.Contract: {
2255
+ case import_transactions7.OutputType.Contract: {
2180
2256
  outputClone.balanceRoot = import_configs8.ZeroBytes32;
2181
2257
  outputClone.stateRoot = import_configs8.ZeroBytes32;
2182
2258
  return outputClone;
2183
2259
  }
2184
- case import_transactions8.OutputType.Change: {
2260
+ case import_transactions7.OutputType.Change: {
2185
2261
  outputClone.amount = (0, import_math8.bn)(0);
2186
2262
  return outputClone;
2187
2263
  }
2188
- case import_transactions8.OutputType.Variable: {
2264
+ case import_transactions7.OutputType.Variable: {
2189
2265
  outputClone.to = import_configs8.ZeroBytes32;
2190
2266
  outputClone.amount = (0, import_math8.bn)(0);
2191
2267
  outputClone.assetId = import_configs8.ZeroBytes32;
@@ -2198,7 +2274,7 @@ function hashTransaction(transactionRequest, chainId) {
2198
2274
  transaction.witnessesCount = 0;
2199
2275
  transaction.witnesses = [];
2200
2276
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2201
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
2277
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2202
2278
  return (0, import_hasher.sha256)(concatenatedData);
2203
2279
  }
2204
2280
 
@@ -2234,7 +2310,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2234
2310
  return new this(obj);
2235
2311
  }
2236
2312
  /** Type of the transaction */
2237
- type = import_transactions9.TransactionType.Create;
2313
+ type = import_transactions8.TransactionType.Create;
2238
2314
  /** Witness index of contract bytecode to create */
2239
2315
  bytecodeWitnessIndex;
2240
2316
  /** Salt */
@@ -2267,11 +2343,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2267
2343
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2268
2344
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2269
2345
  return {
2270
- type: import_transactions9.TransactionType.Create,
2346
+ type: import_transactions8.TransactionType.Create,
2271
2347
  ...baseTransaction,
2272
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2273
2348
  bytecodeWitnessIndex,
2274
- storageSlotsCount: storageSlots.length,
2349
+ storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2275
2350
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2276
2351
  storageSlots
2277
2352
  };
@@ -2283,7 +2358,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2283
2358
  */
2284
2359
  getContractCreatedOutputs() {
2285
2360
  return this.outputs.filter(
2286
- (output) => output.type === import_transactions9.OutputType.ContractCreated
2361
+ (output) => output.type === import_transactions8.OutputType.ContractCreated
2287
2362
  );
2288
2363
  }
2289
2364
  /**
@@ -2304,7 +2379,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2304
2379
  */
2305
2380
  addContractCreatedOutput(contractId, stateRoot) {
2306
2381
  this.pushOutput({
2307
- type: import_transactions9.OutputType.ContractCreated,
2382
+ type: import_transactions8.OutputType.ContractCreated,
2308
2383
  contractId,
2309
2384
  stateRoot
2310
2385
  });
@@ -2324,7 +2399,7 @@ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2324
2399
  var import_address2 = require("@fuel-ts/address");
2325
2400
  var import_configs10 = require("@fuel-ts/address/configs");
2326
2401
  var import_math10 = require("@fuel-ts/math");
2327
- var import_transactions10 = require("@fuel-ts/transactions");
2402
+ var import_transactions9 = require("@fuel-ts/transactions");
2328
2403
  var import_utils15 = require("@fuel-ts/utils");
2329
2404
 
2330
2405
  // src/providers/transaction-request/scripts.ts
@@ -2362,7 +2437,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2362
2437
  return new this(obj);
2363
2438
  }
2364
2439
  /** Type of the transaction */
2365
- type = import_transactions10.TransactionType.Script;
2440
+ type = import_transactions9.TransactionType.Script;
2366
2441
  /** Gas limit for transaction */
2367
2442
  gasLimit;
2368
2443
  /** Script to execute */
@@ -2391,11 +2466,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2391
2466
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2392
2467
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2393
2468
  return {
2394
- type: import_transactions10.TransactionType.Script,
2469
+ type: import_transactions9.TransactionType.Script,
2395
2470
  scriptGasLimit: this.gasLimit,
2396
2471
  ...super.getBaseTransaction(),
2397
- scriptLength: script.length,
2398
- scriptDataLength: scriptData.length,
2472
+ scriptLength: (0, import_math10.bn)(script.length),
2473
+ scriptDataLength: (0, import_math10.bn)(scriptData.length),
2399
2474
  receiptsRoot: import_configs10.ZeroBytes32,
2400
2475
  script: (0, import_utils15.hexlify)(script),
2401
2476
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2408,7 +2483,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2408
2483
  */
2409
2484
  getContractInputs() {
2410
2485
  return this.inputs.filter(
2411
- (input) => input.type === import_transactions10.InputType.Contract
2486
+ (input) => input.type === import_transactions9.InputType.Contract
2412
2487
  );
2413
2488
  }
2414
2489
  /**
@@ -2418,7 +2493,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2418
2493
  */
2419
2494
  getContractOutputs() {
2420
2495
  return this.outputs.filter(
2421
- (output) => output.type === import_transactions10.OutputType.Contract
2496
+ (output) => output.type === import_transactions9.OutputType.Contract
2422
2497
  );
2423
2498
  }
2424
2499
  /**
@@ -2428,7 +2503,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2428
2503
  */
2429
2504
  getVariableOutputs() {
2430
2505
  return this.outputs.filter(
2431
- (output) => output.type === import_transactions10.OutputType.Variable
2506
+ (output) => output.type === import_transactions9.OutputType.Variable
2432
2507
  );
2433
2508
  }
2434
2509
  /**
@@ -2451,7 +2526,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2451
2526
  let outputsNumber = numberOfVariables;
2452
2527
  while (outputsNumber) {
2453
2528
  this.pushOutput({
2454
- type: import_transactions10.OutputType.Variable
2529
+ type: import_transactions9.OutputType.Variable
2455
2530
  });
2456
2531
  outputsNumber -= 1;
2457
2532
  }
@@ -2459,7 +2534,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2459
2534
  }
2460
2535
  calculateMaxGas(chainInfo, minGas) {
2461
2536
  const { consensusParameters } = chainInfo;
2462
- const { gasPerByte } = consensusParameters;
2537
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2463
2538
  const witnessesLength = this.toTransaction().witnesses.reduce(
2464
2539
  (acc, wit) => acc + wit.dataLength,
2465
2540
  0
@@ -2469,7 +2544,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2469
2544
  minGas,
2470
2545
  witnessesLength,
2471
2546
  witnessLimit: this.witnessLimit,
2472
- gasLimit: this.gasLimit
2547
+ gasLimit: this.gasLimit,
2548
+ maxGasPerTx
2473
2549
  });
2474
2550
  }
2475
2551
  /**
@@ -2484,12 +2560,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2484
2560
  return this;
2485
2561
  }
2486
2562
  const inputIndex = super.pushInput({
2487
- type: import_transactions10.InputType.Contract,
2563
+ type: import_transactions9.InputType.Contract,
2488
2564
  contractId: contractAddress.toB256(),
2489
2565
  txPointer: "0x00000000000000000000000000000000"
2490
2566
  });
2491
2567
  this.pushOutput({
2492
- type: import_transactions10.OutputType.Contract,
2568
+ type: import_transactions9.OutputType.Contract,
2493
2569
  inputIndex
2494
2570
  });
2495
2571
  return this;
@@ -2526,17 +2602,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2526
2602
 
2527
2603
  // src/providers/transaction-request/utils.ts
2528
2604
  var import_errors9 = require("@fuel-ts/errors");
2529
- var import_transactions11 = require("@fuel-ts/transactions");
2605
+ var import_transactions10 = require("@fuel-ts/transactions");
2530
2606
  var transactionRequestify = (obj) => {
2531
2607
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2532
2608
  return obj;
2533
2609
  }
2534
2610
  const { type } = obj;
2535
2611
  switch (obj.type) {
2536
- case import_transactions11.TransactionType.Script: {
2612
+ case import_transactions10.TransactionType.Script: {
2537
2613
  return ScriptTransactionRequest.from(obj);
2538
2614
  }
2539
- case import_transactions11.TransactionType.Create: {
2615
+ case import_transactions10.TransactionType.Create: {
2540
2616
  return CreateTransactionRequest.from(obj);
2541
2617
  }
2542
2618
  default: {
@@ -2544,42 +2620,59 @@ var transactionRequestify = (obj) => {
2544
2620
  }
2545
2621
  }
2546
2622
  };
2623
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2624
+ (acc, input) => {
2625
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2626
+ acc.utxos.push(input.id);
2627
+ }
2628
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2629
+ acc.messages.push(input.nonce);
2630
+ }
2631
+ return acc;
2632
+ },
2633
+ {
2634
+ utxos: [],
2635
+ messages: []
2636
+ }
2637
+ );
2547
2638
 
2548
2639
  // src/providers/transaction-response/transaction-response.ts
2549
2640
  var import_errors13 = require("@fuel-ts/errors");
2550
- var import_math14 = require("@fuel-ts/math");
2641
+ var import_math15 = require("@fuel-ts/math");
2551
2642
  var import_transactions18 = require("@fuel-ts/transactions");
2552
- var import_utils21 = require("@fuel-ts/utils");
2643
+ var import_utils20 = require("@fuel-ts/utils");
2553
2644
 
2554
2645
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2555
- var import_utils19 = require("@fuel-ts/utils");
2646
+ var import_math14 = require("@fuel-ts/math");
2647
+ var import_transactions16 = require("@fuel-ts/transactions");
2648
+ var import_utils18 = require("@fuel-ts/utils");
2556
2649
 
2557
2650
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2558
2651
  var import_math11 = require("@fuel-ts/math");
2559
- var import_transactions12 = require("@fuel-ts/transactions");
2652
+ var import_transactions11 = require("@fuel-ts/transactions");
2560
2653
  var import_utils16 = require("@fuel-ts/utils");
2561
2654
  var calculateTransactionFee = (params) => {
2562
2655
  const {
2563
- gasUsed,
2656
+ gasPrice,
2564
2657
  rawPayload,
2565
- consensusParameters: { gasCosts, feeParams }
2658
+ tip,
2659
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2566
2660
  } = params;
2567
2661
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2568
2662
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2569
2663
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2570
- const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
2571
- if (transaction.type === import_transactions12.TransactionType.Mint) {
2664
+ const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2665
+ if (transaction.type === import_transactions11.TransactionType.Mint) {
2572
2666
  return {
2573
2667
  fee: (0, import_math11.bn)(0),
2574
2668
  minFee: (0, import_math11.bn)(0),
2575
- maxFee: (0, import_math11.bn)(0),
2576
- feeFromGasUsed: (0, import_math11.bn)(0)
2669
+ maxFee: (0, import_math11.bn)(0)
2577
2670
  };
2578
2671
  }
2579
2672
  const { type, witnesses, inputs, policies } = transaction;
2580
2673
  let metadataGas = (0, import_math11.bn)(0);
2581
2674
  let gasLimit = (0, import_math11.bn)(0);
2582
- if (type === import_transactions12.TransactionType.Create) {
2675
+ if (type === import_transactions11.TransactionType.Create) {
2583
2676
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2584
2677
  const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2585
2678
  metadataGas = calculateMetadataGasForTxCreate({
@@ -2605,25 +2698,32 @@ var calculateTransactionFee = (params) => {
2605
2698
  metadataGas,
2606
2699
  txBytesSize: transactionBytes.length
2607
2700
  });
2608
- const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions12.PolicyType.GasPrice)?.data);
2609
- const witnessLimit = policies.find((policy) => policy.type === import_transactions12.PolicyType.WitnessLimit)?.data;
2701
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2610
2702
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2611
2703
  const maxGas = getMaxGas({
2612
2704
  gasPerByte,
2613
2705
  minGas,
2614
2706
  witnessesLength,
2615
2707
  gasLimit,
2616
- witnessLimit
2708
+ witnessLimit,
2709
+ maxGasPerTx
2710
+ });
2711
+ const minFee = calculateGasFee({
2712
+ gasPrice,
2713
+ gas: minGas,
2714
+ priceFactor: gasPriceFactor,
2715
+ tip
2716
+ });
2717
+ const maxFee = calculateGasFee({
2718
+ gasPrice,
2719
+ gas: maxGas,
2720
+ priceFactor: gasPriceFactor,
2721
+ tip
2617
2722
  });
2618
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2619
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2620
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2621
- const fee = minFee.add(feeFromGasUsed);
2622
2723
  return {
2623
- fee,
2624
2724
  minFee,
2625
2725
  maxFee,
2626
- feeFromGasUsed
2726
+ fee: maxFee
2627
2727
  };
2628
2728
  };
2629
2729
 
@@ -2631,7 +2731,7 @@ var calculateTransactionFee = (params) => {
2631
2731
  var import_configs11 = require("@fuel-ts/address/configs");
2632
2732
  var import_errors11 = require("@fuel-ts/errors");
2633
2733
  var import_math13 = require("@fuel-ts/math");
2634
- var import_transactions15 = require("@fuel-ts/transactions");
2734
+ var import_transactions14 = require("@fuel-ts/transactions");
2635
2735
 
2636
2736
  // src/providers/transaction-summary/call.ts
2637
2737
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
@@ -2679,7 +2779,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2679
2779
 
2680
2780
  // src/providers/transaction-summary/input.ts
2681
2781
  var import_errors10 = require("@fuel-ts/errors");
2682
- var import_transactions13 = require("@fuel-ts/transactions");
2782
+ var import_transactions12 = require("@fuel-ts/transactions");
2683
2783
  function getInputsByTypes(inputs, types) {
2684
2784
  return inputs.filter((i) => types.includes(i.type));
2685
2785
  }
@@ -2687,16 +2787,16 @@ function getInputsByType(inputs, type) {
2687
2787
  return inputs.filter((i) => i.type === type);
2688
2788
  }
2689
2789
  function getInputsCoin(inputs) {
2690
- return getInputsByType(inputs, import_transactions13.InputType.Coin);
2790
+ return getInputsByType(inputs, import_transactions12.InputType.Coin);
2691
2791
  }
2692
2792
  function getInputsMessage(inputs) {
2693
- return getInputsByType(inputs, import_transactions13.InputType.Message);
2793
+ return getInputsByType(inputs, import_transactions12.InputType.Message);
2694
2794
  }
2695
2795
  function getInputsCoinAndMessage(inputs) {
2696
- return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
2796
+ return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
2697
2797
  }
2698
2798
  function getInputsContract(inputs) {
2699
- return getInputsByType(inputs, import_transactions13.InputType.Contract);
2799
+ return getInputsByType(inputs, import_transactions12.InputType.Contract);
2700
2800
  }
2701
2801
  function getInputFromAssetId(inputs, assetId) {
2702
2802
  const coinInputs = getInputsCoin(inputs);
@@ -2715,7 +2815,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2715
2815
  if (!contractInput) {
2716
2816
  return void 0;
2717
2817
  }
2718
- if (contractInput.type !== import_transactions13.InputType.Contract) {
2818
+ if (contractInput.type !== import_transactions12.InputType.Contract) {
2719
2819
  throw new import_errors10.FuelError(
2720
2820
  import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
2721
2821
  `Contract input should be of type 'contract'.`
@@ -2724,31 +2824,31 @@ function getInputContractFromIndex(inputs, inputIndex) {
2724
2824
  return contractInput;
2725
2825
  }
2726
2826
  function getInputAccountAddress(input) {
2727
- if (input.type === import_transactions13.InputType.Coin) {
2827
+ if (input.type === import_transactions12.InputType.Coin) {
2728
2828
  return input.owner.toString();
2729
2829
  }
2730
- if (input.type === import_transactions13.InputType.Message) {
2830
+ if (input.type === import_transactions12.InputType.Message) {
2731
2831
  return input.recipient.toString();
2732
2832
  }
2733
2833
  return "";
2734
2834
  }
2735
2835
 
2736
2836
  // src/providers/transaction-summary/output.ts
2737
- var import_transactions14 = require("@fuel-ts/transactions");
2837
+ var import_transactions13 = require("@fuel-ts/transactions");
2738
2838
  function getOutputsByType(outputs, type) {
2739
2839
  return outputs.filter((o) => o.type === type);
2740
2840
  }
2741
2841
  function getOutputsContractCreated(outputs) {
2742
- return getOutputsByType(outputs, import_transactions14.OutputType.ContractCreated);
2842
+ return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
2743
2843
  }
2744
2844
  function getOutputsCoin(outputs) {
2745
- return getOutputsByType(outputs, import_transactions14.OutputType.Coin);
2845
+ return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
2746
2846
  }
2747
2847
  function getOutputsChange(outputs) {
2748
- return getOutputsByType(outputs, import_transactions14.OutputType.Change);
2848
+ return getOutputsByType(outputs, import_transactions13.OutputType.Change);
2749
2849
  }
2750
2850
  function getOutputsContract(outputs) {
2751
- return getOutputsByType(outputs, import_transactions14.OutputType.Contract);
2851
+ return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
2752
2852
  }
2753
2853
 
2754
2854
  // src/providers/transaction-summary/operations.ts
@@ -2757,11 +2857,11 @@ function getReceiptsByType(receipts, type) {
2757
2857
  }
2758
2858
  function getTransactionTypeName(transactionType) {
2759
2859
  switch (transactionType) {
2760
- case import_transactions15.TransactionType.Mint:
2860
+ case import_transactions14.TransactionType.Mint:
2761
2861
  return "Mint" /* Mint */;
2762
- case import_transactions15.TransactionType.Create:
2862
+ case import_transactions14.TransactionType.Create:
2763
2863
  return "Create" /* Create */;
2764
- case import_transactions15.TransactionType.Script:
2864
+ case import_transactions14.TransactionType.Script:
2765
2865
  return "Script" /* Script */;
2766
2866
  default:
2767
2867
  throw new import_errors11.FuelError(
@@ -2784,10 +2884,10 @@ function isTypeScript(transactionType) {
2784
2884
  return isType(transactionType, "Script" /* Script */);
2785
2885
  }
2786
2886
  function getReceiptsCall(receipts) {
2787
- return getReceiptsByType(receipts, import_transactions15.ReceiptType.Call);
2887
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2788
2888
  }
2789
2889
  function getReceiptsMessageOut(receipts) {
2790
- return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
2890
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
2791
2891
  }
2792
2892
  var mergeAssets = (op1, op2) => {
2793
2893
  const assets1 = op1.assetsSent || [];
@@ -2983,11 +3083,11 @@ function getTransferOperations({
2983
3083
  });
2984
3084
  const transferReceipts = getReceiptsByType(
2985
3085
  receipts,
2986
- import_transactions15.ReceiptType.Transfer
3086
+ import_transactions14.ReceiptType.Transfer
2987
3087
  );
2988
3088
  const transferOutReceipts = getReceiptsByType(
2989
3089
  receipts,
2990
- import_transactions15.ReceiptType.TransferOut
3090
+ import_transactions14.ReceiptType.TransferOut
2991
3091
  );
2992
3092
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
2993
3093
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3072,17 +3172,17 @@ function getOperations({
3072
3172
  }
3073
3173
 
3074
3174
  // src/providers/transaction-summary/receipt.ts
3075
- var import_transactions16 = require("@fuel-ts/transactions");
3175
+ var import_transactions15 = require("@fuel-ts/transactions");
3076
3176
  var processGqlReceipt = (gqlReceipt) => {
3077
3177
  const receipt = assembleReceiptByType(gqlReceipt);
3078
3178
  switch (receipt.type) {
3079
- case import_transactions16.ReceiptType.ReturnData: {
3179
+ case import_transactions15.ReceiptType.ReturnData: {
3080
3180
  return {
3081
3181
  ...receipt,
3082
3182
  data: gqlReceipt.data || "0x"
3083
3183
  };
3084
3184
  }
3085
- case import_transactions16.ReceiptType.LogData: {
3185
+ case import_transactions15.ReceiptType.LogData: {
3086
3186
  return {
3087
3187
  ...receipt,
3088
3188
  data: gqlReceipt.data || "0x"
@@ -3095,7 +3195,7 @@ var processGqlReceipt = (gqlReceipt) => {
3095
3195
  var extractMintedAssetsFromReceipts = (receipts) => {
3096
3196
  const mintedAssets = [];
3097
3197
  receipts.forEach((receipt) => {
3098
- if (receipt.type === import_transactions16.ReceiptType.Mint) {
3198
+ if (receipt.type === import_transactions15.ReceiptType.Mint) {
3099
3199
  mintedAssets.push({
3100
3200
  subId: receipt.subId,
3101
3201
  contractId: receipt.contractId,
@@ -3109,7 +3209,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3109
3209
  var extractBurnedAssetsFromReceipts = (receipts) => {
3110
3210
  const burnedAssets = [];
3111
3211
  receipts.forEach((receipt) => {
3112
- if (receipt.type === import_transactions16.ReceiptType.Burn) {
3212
+ if (receipt.type === import_transactions15.ReceiptType.Burn) {
3113
3213
  burnedAssets.push({
3114
3214
  subId: receipt.subId,
3115
3215
  contractId: receipt.contractId,
@@ -3190,10 +3290,12 @@ function assembleTransactionSummary(params) {
3190
3290
  gqlTransactionStatus,
3191
3291
  abiMap = {},
3192
3292
  maxInputs,
3193
- gasCosts
3293
+ gasCosts,
3294
+ maxGasPerTx,
3295
+ gasPrice
3194
3296
  } = params;
3195
3297
  const gasUsed = getGasUsedFromReceipts(receipts);
3196
- const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3298
+ const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3197
3299
  const operations = getOperations({
3198
3300
  transactionType: transaction.type,
3199
3301
  inputs: transaction.inputs || [],
@@ -3204,11 +3306,14 @@ function assembleTransactionSummary(params) {
3204
3306
  maxInputs
3205
3307
  });
3206
3308
  const typeName = getTransactionTypeName(transaction.type);
3309
+ const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3207
3310
  const { fee } = calculateTransactionFee({
3208
- gasUsed,
3311
+ gasPrice,
3209
3312
  rawPayload,
3313
+ tip,
3210
3314
  consensusParameters: {
3211
3315
  gasCosts,
3316
+ maxGasPerTx,
3212
3317
  feeParams: {
3213
3318
  gasPerByte,
3214
3319
  gasPriceFactor
@@ -3220,7 +3325,7 @@ function assembleTransactionSummary(params) {
3220
3325
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3221
3326
  let date;
3222
3327
  if (time) {
3223
- date = import_utils19.DateTime.fromTai64(time);
3328
+ date = import_utils18.DateTime.fromTai64(time);
3224
3329
  }
3225
3330
  const transactionSummary = {
3226
3331
  id,
@@ -3268,7 +3373,7 @@ var TransactionResponse = class {
3268
3373
  /** Current provider */
3269
3374
  provider;
3270
3375
  /** Gas used on the transaction */
3271
- gasUsed = (0, import_math14.bn)(0);
3376
+ gasUsed = (0, import_math15.bn)(0);
3272
3377
  /** The graphql Transaction with receipts object. */
3273
3378
  gqlTransaction;
3274
3379
  abis;
@@ -3327,7 +3432,7 @@ var TransactionResponse = class {
3327
3432
  */
3328
3433
  decodeTransaction(transactionWithReceipts) {
3329
3434
  return new import_transactions18.TransactionCoder().decode(
3330
- (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3435
+ (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3331
3436
  0
3332
3437
  )?.[0];
3333
3438
  }
@@ -3346,20 +3451,27 @@ var TransactionResponse = class {
3346
3451
  const decodedTransaction = this.decodeTransaction(
3347
3452
  transaction
3348
3453
  );
3349
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3350
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3454
+ let txReceipts = [];
3455
+ if (transaction?.status && "receipts" in transaction.status) {
3456
+ txReceipts = transaction.status.receipts;
3457
+ }
3458
+ const receipts = txReceipts.map(processGqlReceipt) || [];
3459
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3460
+ const gasPrice = await this.provider.getLatestGasPrice();
3351
3461
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3352
3462
  const transactionSummary = assembleTransactionSummary({
3353
3463
  id: this.id,
3354
3464
  receipts,
3355
3465
  transaction: decodedTransaction,
3356
- transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3466
+ transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3357
3467
  gqlTransactionStatus: transaction.status,
3358
3468
  gasPerByte,
3359
3469
  gasPriceFactor,
3360
3470
  abiMap: contractsAbiMap,
3361
3471
  maxInputs,
3362
- gasCosts
3472
+ gasCosts,
3473
+ maxGasPerTx,
3474
+ gasPrice
3363
3475
  });
3364
3476
  return transactionSummary;
3365
3477
  }
@@ -3486,29 +3598,29 @@ var processGqlChain = (chain) => {
3486
3598
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3487
3599
  return {
3488
3600
  name,
3489
- baseChainHeight: (0, import_math15.bn)(daHeight),
3601
+ baseChainHeight: (0, import_math16.bn)(daHeight),
3490
3602
  consensusParameters: {
3491
- contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3492
- maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3493
- maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3494
- maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3495
- maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3496
- maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3497
- maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3498
- maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3499
- maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3500
- maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3501
- maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3502
- gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3503
- gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3504
- maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3505
- chainId: (0, import_math15.bn)(consensusParameters.chainId),
3603
+ contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3604
+ maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3605
+ maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3606
+ maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3607
+ maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3608
+ maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3609
+ maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3610
+ maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3611
+ maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3612
+ maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3613
+ maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3614
+ gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3615
+ gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3616
+ maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3617
+ chainId: (0, import_math16.bn)(consensusParameters.chainId),
3506
3618
  gasCosts
3507
3619
  },
3508
3620
  gasCosts,
3509
3621
  latestBlock: {
3510
3622
  id: latestBlock.id,
3511
- height: (0, import_math15.bn)(latestBlock.header.height),
3623
+ height: (0, import_math16.bn)(latestBlock.height),
3512
3624
  time: latestBlock.header.time,
3513
3625
  transactions: latestBlock.transactions.map((i) => ({
3514
3626
  id: i.id
@@ -3602,10 +3714,8 @@ var _Provider = class {
3602
3714
  * Returns some helpful parameters related to gas fees.
3603
3715
  */
3604
3716
  getGasConfig() {
3605
- const { minGasPrice } = this.getNode();
3606
3717
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3607
3718
  return {
3608
- minGasPrice,
3609
3719
  maxGasPerTx,
3610
3720
  maxGasPerPredicate,
3611
3721
  gasPriceFactor,
@@ -3703,7 +3813,7 @@ var _Provider = class {
3703
3813
  */
3704
3814
  async getBlockNumber() {
3705
3815
  const { chain } = await this.operations.getChain();
3706
- return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3816
+ return (0, import_math16.bn)(chain.latestBlock.height, 10);
3707
3817
  }
3708
3818
  /**
3709
3819
  * Returns the chain information.
@@ -3713,13 +3823,11 @@ var _Provider = class {
3713
3823
  async fetchNode() {
3714
3824
  const { nodeInfo } = await this.operations.getNodeInfo();
3715
3825
  const processedNodeInfo = {
3716
- maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3717
- maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3718
- minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3826
+ maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3827
+ maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3719
3828
  nodeVersion: nodeInfo.nodeVersion,
3720
3829
  utxoValidation: nodeInfo.utxoValidation,
3721
- vmBacktrace: nodeInfo.vmBacktrace,
3722
- peers: nodeInfo.peers
3830
+ vmBacktrace: nodeInfo.vmBacktrace
3723
3831
  };
3724
3832
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3725
3833
  return processedNodeInfo;
@@ -3761,7 +3869,7 @@ var _Provider = class {
3761
3869
  if (estimateTxDependencies) {
3762
3870
  await this.estimateTxDependencies(transactionRequest);
3763
3871
  }
3764
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3872
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3765
3873
  let abis;
3766
3874
  if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3767
3875
  abis = transactionRequest.abis;
@@ -3804,15 +3912,14 @@ var _Provider = class {
3804
3912
  if (estimateTxDependencies) {
3805
3913
  return this.estimateTxDependencies(transactionRequest);
3806
3914
  }
3807
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3808
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3809
- encodedTransaction,
3915
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3916
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3917
+ encodedTransactions: encodedTransaction,
3810
3918
  utxoValidation: utxoValidation || false
3811
3919
  });
3812
- const receipts = gqlReceipts.map(processGqlReceipt);
3813
- return {
3814
- receipts
3815
- };
3920
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3921
+ const receipts = rawReceipts.map(processGqlReceipt);
3922
+ return { receipts, dryrunStatus: status };
3816
3923
  }
3817
3924
  /**
3818
3925
  * Verifies whether enough gas is available to complete transaction.
@@ -3823,13 +3930,13 @@ var _Provider = class {
3823
3930
  async estimatePredicates(transactionRequest) {
3824
3931
  const shouldEstimatePredicates = Boolean(
3825
3932
  transactionRequest.inputs.find(
3826
- (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math15.BN(input.predicateGasUsed).isZero()
3933
+ (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math16.BN(input.predicateGasUsed).isZero()
3827
3934
  )
3828
3935
  );
3829
3936
  if (!shouldEstimatePredicates) {
3830
3937
  return transactionRequest;
3831
3938
  }
3832
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3939
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3833
3940
  const response = await this.operations.estimatePredicates({
3834
3941
  encodedTransaction
3835
3942
  });
@@ -3838,7 +3945,7 @@ var _Provider = class {
3838
3945
  } = response;
3839
3946
  if (inputs) {
3840
3947
  inputs.forEach((input, index) => {
3841
- if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3948
+ if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
3842
3949
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3843
3950
  }
3844
3951
  });
@@ -3851,9 +3958,6 @@ var _Provider = class {
3851
3958
  * If there are missing variable outputs,
3852
3959
  * `addVariableOutputs` is called on the transaction.
3853
3960
  *
3854
- * @privateRemarks
3855
- * TODO: Investigate support for missing contract IDs
3856
- * TODO: Add support for missing output messages
3857
3961
  *
3858
3962
  * @param transactionRequest - The transaction request object.
3859
3963
  * @returns A promise.
@@ -3866,16 +3970,19 @@ var _Provider = class {
3866
3970
  missingContractIds: []
3867
3971
  };
3868
3972
  }
3869
- await this.estimatePredicates(transactionRequest);
3870
3973
  let receipts = [];
3871
3974
  const missingContractIds = [];
3872
3975
  let outputVariables = 0;
3976
+ let dryrunStatus;
3873
3977
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3874
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3875
- encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
3978
+ const {
3979
+ dryRun: [{ receipts: rawReceipts, status }]
3980
+ } = await this.operations.dryRun({
3981
+ encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
3876
3982
  utxoValidation: false
3877
3983
  });
3878
- receipts = gqlReceipts.map(processGqlReceipt);
3984
+ receipts = rawReceipts.map(processGqlReceipt);
3985
+ dryrunStatus = status;
3879
3986
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3880
3987
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3881
3988
  if (hasMissingOutputs) {
@@ -3885,6 +3992,10 @@ var _Provider = class {
3885
3992
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
3886
3993
  missingContractIds.push(contractId);
3887
3994
  });
3995
+ const { maxFee } = await this.estimateTxGasAndFee({
3996
+ transactionRequest
3997
+ });
3998
+ transactionRequest.maxFee = maxFee;
3888
3999
  } else {
3889
4000
  break;
3890
4001
  }
@@ -3892,37 +4003,139 @@ var _Provider = class {
3892
4003
  return {
3893
4004
  receipts,
3894
4005
  outputVariables,
3895
- missingContractIds
4006
+ missingContractIds,
4007
+ dryrunStatus
3896
4008
  };
3897
4009
  }
4010
+ /**
4011
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
4012
+ *
4013
+ * Transactions are dry run in batches. After each dry run, transactions requiring
4014
+ * further modifications are identified. The method iteratively updates these transactions
4015
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4016
+ *
4017
+ * @param transactionRequests - Array of transaction request objects.
4018
+ * @returns A promise that resolves to an array of results for each transaction.
4019
+ */
4020
+ async estimateMultipleTxDependencies(transactionRequests) {
4021
+ const results = transactionRequests.map(() => ({
4022
+ receipts: [],
4023
+ outputVariables: 0,
4024
+ missingContractIds: [],
4025
+ dryrunStatus: void 0
4026
+ }));
4027
+ const allRequests = (0, import_ramda3.clone)(transactionRequests);
4028
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
4029
+ allRequests.forEach((req, index) => {
4030
+ if (req.type === import_transactions19.TransactionType.Script) {
4031
+ serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4032
+ }
4033
+ });
4034
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4035
+ let attempt = 0;
4036
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4037
+ const encodedTransactions = transactionsToProcess.map(
4038
+ (index) => serializedTransactionsMap.get(index)
4039
+ );
4040
+ const dryRunResults = await this.operations.dryRun({
4041
+ encodedTransactions,
4042
+ utxoValidation: false
4043
+ });
4044
+ const nextRoundTransactions = [];
4045
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4046
+ const currentResultIndex = transactionsToProcess[i];
4047
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4048
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4049
+ results[currentResultIndex].dryrunStatus = status;
4050
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4051
+ results[currentResultIndex].receipts
4052
+ );
4053
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4054
+ const requestToProcess = allRequests[currentResultIndex];
4055
+ if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4056
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
4057
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
4058
+ missingOutputContractIds.forEach(({ contractId }) => {
4059
+ requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4060
+ results[currentResultIndex].missingContractIds.push(contractId);
4061
+ });
4062
+ const { maxFee } = await this.estimateTxGasAndFee({
4063
+ transactionRequest: requestToProcess
4064
+ });
4065
+ requestToProcess.maxFee = maxFee;
4066
+ serializedTransactionsMap.set(
4067
+ currentResultIndex,
4068
+ (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4069
+ );
4070
+ nextRoundTransactions.push(currentResultIndex);
4071
+ allRequests[currentResultIndex] = requestToProcess;
4072
+ }
4073
+ }
4074
+ transactionsToProcess = nextRoundTransactions;
4075
+ attempt += 1;
4076
+ }
4077
+ return results;
4078
+ }
4079
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4080
+ if (estimateTxDependencies) {
4081
+ return this.estimateMultipleTxDependencies(transactionRequests);
4082
+ }
4083
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4084
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4085
+ encodedTransactions,
4086
+ utxoValidation: utxoValidation || false
4087
+ });
4088
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4089
+ const receipts = rawReceipts.map(processGqlReceipt);
4090
+ return { receipts, dryrunStatus: status };
4091
+ });
4092
+ return results;
4093
+ }
3898
4094
  /**
3899
4095
  * Estimates the transaction gas and fee based on the provided transaction request.
3900
4096
  * @param transactionRequest - The transaction request object.
3901
4097
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3902
4098
  */
3903
- estimateTxGasAndFee(params) {
4099
+ async estimateTxGasAndFee(params) {
3904
4100
  const { transactionRequest } = params;
3905
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4101
+ let { gasPrice } = params;
3906
4102
  const chainInfo = this.getChain();
3907
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3908
- transactionRequest.gasPrice = gasPrice;
4103
+ const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3909
4104
  const minGas = transactionRequest.calculateMinGas(chainInfo);
3910
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4105
+ if (!gasPrice) {
4106
+ gasPrice = await this.estimateGasPrice(10);
4107
+ }
4108
+ const minFee = calculateGasFee({
4109
+ gasPrice: (0, import_math16.bn)(gasPrice),
4110
+ gas: minGas,
4111
+ priceFactor: gasPriceFactor,
4112
+ tip: transactionRequest.tip
4113
+ }).add(1);
4114
+ let gasLimit = (0, import_math16.bn)(0);
3911
4115
  if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4116
+ gasLimit = transactionRequest.gasLimit;
3912
4117
  if (transactionRequest.gasLimit.eq(0)) {
3913
4118
  transactionRequest.gasLimit = minGas;
3914
4119
  transactionRequest.gasLimit = maxGasPerTx.sub(
3915
4120
  transactionRequest.calculateMaxGas(chainInfo, minGas)
3916
4121
  );
4122
+ gasLimit = transactionRequest.gasLimit;
3917
4123
  }
3918
4124
  }
3919
4125
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3920
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4126
+ const maxFee = calculateGasFee({
4127
+ gasPrice: (0, import_math16.bn)(gasPrice),
4128
+ gas: maxGas,
4129
+ priceFactor: gasPriceFactor,
4130
+ tip: transactionRequest.tip
4131
+ }).add(1);
3921
4132
  return {
3922
4133
  minGas,
3923
4134
  minFee,
3924
4135
  maxGas,
3925
- maxFee
4136
+ maxFee,
4137
+ gasPrice,
4138
+ gasLimit
3926
4139
  };
3927
4140
  }
3928
4141
  /**
@@ -3940,15 +4153,17 @@ var _Provider = class {
3940
4153
  if (estimateTxDependencies) {
3941
4154
  return this.estimateTxDependencies(transactionRequest);
3942
4155
  }
3943
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3944
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3945
- encodedTransaction,
4156
+ const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4157
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4158
+ encodedTransactions,
3946
4159
  utxoValidation: true
3947
4160
  });
3948
- const receipts = gqlReceipts.map(processGqlReceipt);
3949
- return {
3950
- receipts
3951
- };
4161
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
4162
+ const { id, receipts, status } = dryRunStatus;
4163
+ const processedReceipts = receipts.map(processGqlReceipt);
4164
+ return { id, receipts: processedReceipts, status };
4165
+ });
4166
+ return { receipts: callResult[0].receipts };
3952
4167
  }
3953
4168
  /**
3954
4169
  * Returns a transaction cost to enable user
@@ -3965,77 +4180,79 @@ var _Provider = class {
3965
4180
  * @param tolerance - The tolerance to add on top of the gasUsed.
3966
4181
  * @returns A promise that resolves to the transaction cost object.
3967
4182
  */
3968
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3969
- estimateTxDependencies = true,
3970
- estimatePredicates = true,
3971
- resourcesOwner,
3972
- signatureCallback
3973
- } = {}) {
4183
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3974
4184
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
3975
- const { minGasPrice } = this.getGasConfig();
3976
- const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3977
4185
  const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
3978
4186
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3979
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4187
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3980
4188
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4189
+ txRequestClone.maxFee = (0, import_math16.bn)(0);
3981
4190
  if (isScriptTransaction) {
3982
- txRequestClone.gasLimit = (0, import_math15.bn)(0);
4191
+ txRequestClone.gasLimit = (0, import_math16.bn)(0);
3983
4192
  }
3984
- if (estimatePredicates) {
3985
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3986
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3987
- }
3988
- await this.estimatePredicates(txRequestClone);
4193
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4194
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3989
4195
  }
4196
+ const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4197
+ let addedSignatures = 0;
3990
4198
  if (signatureCallback && isScriptTransaction) {
3991
- await signatureCallback(txRequestClone);
4199
+ const lengthBefore = signedRequest.witnesses.length;
4200
+ await signatureCallback(signedRequest);
4201
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
3992
4202
  }
3993
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3994
- transactionRequest: txRequestClone
4203
+ await this.estimatePredicates(signedRequest);
4204
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4205
+ transactionRequest: signedRequest
3995
4206
  });
3996
4207
  let receipts = [];
3997
4208
  let missingContractIds = [];
3998
4209
  let outputVariables = 0;
3999
- let gasUsed = (0, import_math15.bn)(0);
4000
- if (isScriptTransaction && estimateTxDependencies) {
4001
- txRequestClone.gasPrice = (0, import_math15.bn)(0);
4210
+ let gasUsed = (0, import_math16.bn)(0);
4211
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4212
+ txRequestClone.maxFee = maxFee;
4213
+ if (isScriptTransaction) {
4214
+ txRequestClone.gasLimit = gasLimit;
4215
+ if (signatureCallback) {
4216
+ await signatureCallback(txRequestClone);
4217
+ }
4002
4218
  const result = await this.estimateTxDependencies(txRequestClone);
4003
4219
  receipts = result.receipts;
4004
4220
  outputVariables = result.outputVariables;
4005
4221
  missingContractIds = result.missingContractIds;
4006
4222
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4007
4223
  txRequestClone.gasLimit = gasUsed;
4008
- txRequestClone.gasPrice = setGasPrice;
4009
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4010
- transactionRequest: txRequestClone
4224
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4225
+ transactionRequest: txRequestClone,
4226
+ gasPrice
4011
4227
  }));
4012
4228
  }
4013
4229
  return {
4014
4230
  requiredQuantities: allQuantities,
4015
4231
  receipts,
4016
4232
  gasUsed,
4017
- minGasPrice,
4018
- gasPrice: setGasPrice,
4233
+ gasPrice,
4019
4234
  minGas,
4020
4235
  maxGas,
4021
4236
  minFee,
4022
4237
  maxFee,
4023
- estimatedInputs: txRequestClone.inputs,
4024
4238
  outputVariables,
4025
- missingContractIds
4239
+ missingContractIds,
4240
+ addedSignatures,
4241
+ estimatedPredicates: txRequestClone.inputs
4026
4242
  };
4027
4243
  }
4028
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4244
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4029
4245
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4030
4246
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4031
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4247
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
4248
+ quantitiesToContract
4249
+ });
4032
4250
  transactionRequest.addResources(
4033
4251
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4034
4252
  );
4035
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4036
- transactionRequest,
4037
- forwardingQuantities
4038
- );
4253
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4254
+ quantitiesToContract
4255
+ });
4039
4256
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4040
4257
  return {
4041
4258
  resources,
@@ -4051,17 +4268,16 @@ var _Provider = class {
4051
4268
  const result = await this.operations.getCoins({
4052
4269
  first: 10,
4053
4270
  ...paginationArgs,
4054
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4271
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4055
4272
  });
4056
4273
  const coins = result.coins.edges.map((edge) => edge.node);
4057
4274
  return coins.map((coin) => ({
4058
4275
  id: coin.utxoId,
4059
4276
  assetId: coin.assetId,
4060
- amount: (0, import_math15.bn)(coin.amount),
4277
+ amount: (0, import_math16.bn)(coin.amount),
4061
4278
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4062
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4063
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4064
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4279
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4280
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4065
4281
  }));
4066
4282
  }
4067
4283
  /**
@@ -4075,19 +4291,19 @@ var _Provider = class {
4075
4291
  async getResourcesToSpend(owner, quantities, excludedIds) {
4076
4292
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4077
4293
  const excludeInput = {
4078
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4079
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4294
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4295
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4080
4296
  };
4081
4297
  if (this.cache) {
4082
4298
  const uniqueUtxos = new Set(
4083
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4299
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4084
4300
  );
4085
4301
  excludeInput.utxos = Array.from(uniqueUtxos);
4086
4302
  }
4087
4303
  const coinsQuery = {
4088
4304
  owner: ownerAddress.toB256(),
4089
4305
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4090
- assetId: (0, import_utils23.hexlify)(assetId),
4306
+ assetId: (0, import_utils22.hexlify)(assetId),
4091
4307
  amount: amount.toString(10),
4092
4308
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4093
4309
  })),
@@ -4098,9 +4314,9 @@ var _Provider = class {
4098
4314
  switch (coin.__typename) {
4099
4315
  case "MessageCoin":
4100
4316
  return {
4101
- amount: (0, import_math15.bn)(coin.amount),
4317
+ amount: (0, import_math16.bn)(coin.amount),
4102
4318
  assetId: coin.assetId,
4103
- daHeight: (0, import_math15.bn)(coin.daHeight),
4319
+ daHeight: (0, import_math16.bn)(coin.daHeight),
4104
4320
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4105
4321
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4106
4322
  nonce: coin.nonce
@@ -4108,12 +4324,11 @@ var _Provider = class {
4108
4324
  case "Coin":
4109
4325
  return {
4110
4326
  id: coin.utxoId,
4111
- amount: (0, import_math15.bn)(coin.amount),
4327
+ amount: (0, import_math16.bn)(coin.amount),
4112
4328
  assetId: coin.assetId,
4113
4329
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4114
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4115
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4116
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4330
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4331
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4117
4332
  };
4118
4333
  default:
4119
4334
  return null;
@@ -4130,13 +4345,13 @@ var _Provider = class {
4130
4345
  async getBlock(idOrHeight) {
4131
4346
  let variables;
4132
4347
  if (typeof idOrHeight === "number") {
4133
- variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4348
+ variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4134
4349
  } else if (idOrHeight === "latest") {
4135
4350
  variables = { height: (await this.getBlockNumber()).toString(10) };
4136
4351
  } else if (idOrHeight.length === 66) {
4137
4352
  variables = { blockId: idOrHeight };
4138
4353
  } else {
4139
- variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4354
+ variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4140
4355
  }
4141
4356
  const { block } = await this.operations.getBlock(variables);
4142
4357
  if (!block) {
@@ -4144,7 +4359,7 @@ var _Provider = class {
4144
4359
  }
4145
4360
  return {
4146
4361
  id: block.id,
4147
- height: (0, import_math15.bn)(block.header.height),
4362
+ height: (0, import_math16.bn)(block.height),
4148
4363
  time: block.header.time,
4149
4364
  transactionIds: block.transactions.map((tx) => tx.id)
4150
4365
  };
@@ -4159,7 +4374,7 @@ var _Provider = class {
4159
4374
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4160
4375
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4161
4376
  id: block.id,
4162
- height: (0, import_math15.bn)(block.header.height),
4377
+ height: (0, import_math16.bn)(block.height),
4163
4378
  time: block.header.time,
4164
4379
  transactionIds: block.transactions.map((tx) => tx.id)
4165
4380
  }));
@@ -4174,7 +4389,7 @@ var _Provider = class {
4174
4389
  async getBlockWithTransactions(idOrHeight) {
4175
4390
  let variables;
4176
4391
  if (typeof idOrHeight === "number") {
4177
- variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4392
+ variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4178
4393
  } else if (idOrHeight === "latest") {
4179
4394
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4180
4395
  } else {
@@ -4186,11 +4401,11 @@ var _Provider = class {
4186
4401
  }
4187
4402
  return {
4188
4403
  id: block.id,
4189
- height: (0, import_math15.bn)(block.header.height, 10),
4404
+ height: (0, import_math16.bn)(block.height, 10),
4190
4405
  time: block.header.time,
4191
4406
  transactionIds: block.transactions.map((tx) => tx.id),
4192
4407
  transactions: block.transactions.map(
4193
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4408
+ (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4194
4409
  )
4195
4410
  };
4196
4411
  }
@@ -4206,7 +4421,7 @@ var _Provider = class {
4206
4421
  return null;
4207
4422
  }
4208
4423
  return new import_transactions19.TransactionCoder().decode(
4209
- (0, import_utils23.arrayify)(transaction.rawPayload),
4424
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4210
4425
  0
4211
4426
  )?.[0];
4212
4427
  }
@@ -4233,9 +4448,9 @@ var _Provider = class {
4233
4448
  async getContractBalance(contractId, assetId) {
4234
4449
  const { contractBalance } = await this.operations.getContractBalance({
4235
4450
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4236
- asset: (0, import_utils23.hexlify)(assetId)
4451
+ asset: (0, import_utils22.hexlify)(assetId)
4237
4452
  });
4238
- return (0, import_math15.bn)(contractBalance.amount, 10);
4453
+ return (0, import_math16.bn)(contractBalance.amount, 10);
4239
4454
  }
4240
4455
  /**
4241
4456
  * Returns the balance for the given owner for the given asset ID.
@@ -4247,9 +4462,9 @@ var _Provider = class {
4247
4462
  async getBalance(owner, assetId) {
4248
4463
  const { balance } = await this.operations.getBalance({
4249
4464
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4250
- assetId: (0, import_utils23.hexlify)(assetId)
4465
+ assetId: (0, import_utils22.hexlify)(assetId)
4251
4466
  });
4252
- return (0, import_math15.bn)(balance.amount, 10);
4467
+ return (0, import_math16.bn)(balance.amount, 10);
4253
4468
  }
4254
4469
  /**
4255
4470
  * Returns balances for the given owner.
@@ -4267,7 +4482,7 @@ var _Provider = class {
4267
4482
  const balances = result.balances.edges.map((edge) => edge.node);
4268
4483
  return balances.map((balance) => ({
4269
4484
  assetId: balance.assetId,
4270
- amount: (0, import_math15.bn)(balance.amount)
4485
+ amount: (0, import_math16.bn)(balance.amount)
4271
4486
  }));
4272
4487
  }
4273
4488
  /**
@@ -4289,15 +4504,15 @@ var _Provider = class {
4289
4504
  sender: message.sender,
4290
4505
  recipient: message.recipient,
4291
4506
  nonce: message.nonce,
4292
- amount: (0, import_math15.bn)(message.amount),
4507
+ amount: (0, import_math16.bn)(message.amount),
4293
4508
  data: message.data
4294
4509
  }),
4295
4510
  sender: import_address3.Address.fromAddressOrString(message.sender),
4296
4511
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4297
4512
  nonce: message.nonce,
4298
- amount: (0, import_math15.bn)(message.amount),
4513
+ amount: (0, import_math16.bn)(message.amount),
4299
4514
  data: import_transactions19.InputMessageCoder.decodeData(message.data),
4300
- daHeight: (0, import_math15.bn)(message.daHeight)
4515
+ daHeight: (0, import_math16.bn)(message.daHeight)
4301
4516
  }));
4302
4517
  }
4303
4518
  /**
@@ -4350,44 +4565,60 @@ var _Provider = class {
4350
4565
  } = result.messageProof;
4351
4566
  return {
4352
4567
  messageProof: {
4353
- proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4568
+ proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4354
4569
  proofSet: messageProof.proofSet
4355
4570
  },
4356
4571
  blockProof: {
4357
- proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4572
+ proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4358
4573
  proofSet: blockProof.proofSet
4359
4574
  },
4360
4575
  messageBlockHeader: {
4361
4576
  id: messageBlockHeader.id,
4362
- daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4363
- transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4577
+ daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4578
+ transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4364
4579
  transactionsRoot: messageBlockHeader.transactionsRoot,
4365
- height: (0, import_math15.bn)(messageBlockHeader.height),
4580
+ height: (0, import_math16.bn)(messageBlockHeader.height),
4366
4581
  prevRoot: messageBlockHeader.prevRoot,
4367
4582
  time: messageBlockHeader.time,
4368
4583
  applicationHash: messageBlockHeader.applicationHash,
4369
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4370
- messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4584
+ messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4585
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4586
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4587
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
4588
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4371
4589
  },
4372
4590
  commitBlockHeader: {
4373
4591
  id: commitBlockHeader.id,
4374
- daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4375
- transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4592
+ daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4593
+ transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4376
4594
  transactionsRoot: commitBlockHeader.transactionsRoot,
4377
- height: (0, import_math15.bn)(commitBlockHeader.height),
4595
+ height: (0, import_math16.bn)(commitBlockHeader.height),
4378
4596
  prevRoot: commitBlockHeader.prevRoot,
4379
4597
  time: commitBlockHeader.time,
4380
4598
  applicationHash: commitBlockHeader.applicationHash,
4381
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4382
- messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4599
+ messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4600
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4601
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4602
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
4603
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4383
4604
  },
4384
4605
  sender: import_address3.Address.fromAddressOrString(sender),
4385
4606
  recipient: import_address3.Address.fromAddressOrString(recipient),
4386
4607
  nonce,
4387
- amount: (0, import_math15.bn)(amount),
4608
+ amount: (0, import_math16.bn)(amount),
4388
4609
  data
4389
4610
  };
4390
4611
  }
4612
+ async getLatestGasPrice() {
4613
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
4614
+ return (0, import_math16.bn)(latestGasPrice.gasPrice);
4615
+ }
4616
+ async estimateGasPrice(blockHorizon) {
4617
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
4618
+ blockHorizon: String(blockHorizon)
4619
+ });
4620
+ return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4621
+ }
4391
4622
  /**
4392
4623
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4393
4624
  *
@@ -4407,10 +4638,10 @@ var _Provider = class {
4407
4638
  */
4408
4639
  async produceBlocks(amount, startTime) {
4409
4640
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4410
- blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4411
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4641
+ blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4642
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4412
4643
  });
4413
- return (0, import_math15.bn)(latestBlockHeight);
4644
+ return (0, import_math16.bn)(latestBlockHeight);
4414
4645
  }
4415
4646
  // eslint-disable-next-line @typescript-eslint/require-await
4416
4647
  async getTransactionResponse(transactionId) {
@@ -4434,9 +4665,9 @@ __publicField(Provider, "nodeInfoCache", {});
4434
4665
 
4435
4666
  // src/providers/transaction-summary/get-transaction-summary.ts
4436
4667
  var import_errors15 = require("@fuel-ts/errors");
4437
- var import_math16 = require("@fuel-ts/math");
4668
+ var import_math17 = require("@fuel-ts/math");
4438
4669
  var import_transactions20 = require("@fuel-ts/transactions");
4439
- var import_utils26 = require("@fuel-ts/utils");
4670
+ var import_utils25 = require("@fuel-ts/utils");
4440
4671
 
4441
4672
  // src/providers/chains.ts
4442
4673
  var CHAIN_IDS = {
@@ -4485,17 +4716,17 @@ var assets = [
4485
4716
 
4486
4717
  // src/utils/formatTransferToContractScriptData.ts
4487
4718
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4488
- var import_math17 = require("@fuel-ts/math");
4489
- var import_utils27 = require("@fuel-ts/utils");
4719
+ var import_math18 = require("@fuel-ts/math");
4720
+ var import_utils26 = require("@fuel-ts/utils");
4490
4721
  var asm = __toESM(require("@fuels/vm-asm"));
4491
4722
  var formatTransferToContractScriptData = (params) => {
4492
4723
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4493
4724
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4494
- const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4725
+ const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4495
4726
  const scriptData = Uint8Array.from([
4496
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
4727
+ ...(0, import_utils26.arrayify)(hexlifiedContractId),
4497
4728
  ...encoded,
4498
- ...(0, import_utils27.arrayify)(assetId)
4729
+ ...(0, import_utils26.arrayify)(assetId)
4499
4730
  ]);
4500
4731
  return scriptData;
4501
4732
  };
@@ -4680,36 +4911,33 @@ var Account = class extends import_interfaces.AbstractAccount {
4680
4911
  * @param fee - The estimated transaction fee.
4681
4912
  * @returns A promise that resolves when the resources are added to the transaction.
4682
4913
  */
4683
- async fund(request, coinQuantities, fee) {
4684
- const updatedQuantities = addAmountToAsset({
4685
- amount: (0, import_math18.bn)(fee),
4914
+ async fund(request, params) {
4915
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4916
+ const txRequest = request;
4917
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4918
+ amount: (0, import_math19.bn)(fee),
4686
4919
  assetId: import_configs12.BaseAssetId,
4687
- coinQuantities
4920
+ coinQuantities: requiredQuantities
4688
4921
  });
4689
4922
  const quantitiesDict = {};
4690
- updatedQuantities.forEach(({ amount, assetId }) => {
4923
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4691
4924
  quantitiesDict[assetId] = {
4692
4925
  required: amount,
4693
- owned: (0, import_math18.bn)(0)
4926
+ owned: (0, import_math19.bn)(0)
4694
4927
  };
4695
4928
  });
4696
- const cachedUtxos = [];
4697
- const cachedMessages = [];
4698
- const owner = this.address.toB256();
4699
- request.inputs.forEach((input) => {
4929
+ txRequest.inputs.forEach((input) => {
4700
4930
  const isResource = "amount" in input;
4701
4931
  if (isResource) {
4702
4932
  const isCoin2 = "owner" in input;
4703
4933
  if (isCoin2) {
4704
4934
  const assetId = String(input.assetId);
4705
- if (input.owner === owner && quantitiesDict[assetId]) {
4706
- const amount = (0, import_math18.bn)(input.amount);
4935
+ if (quantitiesDict[assetId]) {
4936
+ const amount = (0, import_math19.bn)(input.amount);
4707
4937
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4708
- cachedUtxos.push(input.id);
4709
4938
  }
4710
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4939
+ } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4711
4940
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4712
- cachedMessages.push(input.nonce);
4713
4941
  }
4714
4942
  }
4715
4943
  });
@@ -4724,12 +4952,23 @@ var Account = class extends import_interfaces.AbstractAccount {
4724
4952
  });
4725
4953
  const needsToBeFunded = missingQuantities.length;
4726
4954
  if (needsToBeFunded) {
4727
- const resources = await this.getResourcesToSpend(missingQuantities, {
4728
- messages: cachedMessages,
4729
- utxos: cachedUtxos
4730
- });
4731
- request.addResources(resources);
4955
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4956
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4957
+ txRequest.addResources(resources);
4958
+ }
4959
+ txRequest.shiftPredicateData();
4960
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
4961
+ const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
4962
+ if (addedSignatures) {
4963
+ Array.from({ length: addedSignatures }).forEach(
4964
+ () => requestToBeReEstimate.addEmptyWitness()
4965
+ );
4732
4966
  }
4967
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
4968
+ transactionRequest: requestToBeReEstimate
4969
+ });
4970
+ txRequest.maxFee = maxFee;
4971
+ return txRequest;
4733
4972
  }
4734
4973
  /**
4735
4974
  * A helper that creates a transfer transaction request and returns it.
@@ -4737,28 +4976,25 @@ var Account = class extends import_interfaces.AbstractAccount {
4737
4976
  * @param destination - The address of the destination.
4738
4977
  * @param amount - The amount of coins to transfer.
4739
4978
  * @param assetId - The asset ID of the coins to transfer.
4740
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4979
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4741
4980
  * @returns A promise that resolves to the prepared transaction request.
4742
4981
  */
4743
4982
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4744
- const { minGasPrice } = this.provider.getGasConfig();
4745
- const params = { gasPrice: minGasPrice, ...txParams };
4746
- const request = new ScriptTransactionRequest(params);
4983
+ const request = new ScriptTransactionRequest(txParams);
4747
4984
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
4748
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4985
+ const txCost = await this.provider.getTransactionCost(request, {
4749
4986
  estimateTxDependencies: true,
4750
4987
  resourcesOwner: this
4751
4988
  });
4752
- request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
4753
- request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
4754
- this.validateGas({
4755
- gasUsed,
4756
- gasPrice: request.gasPrice,
4757
- gasLimit: request.gasLimit,
4758
- minGasPrice
4759
- });
4760
- await this.fund(request, requiredQuantities, maxFee);
4761
- request.updatePredicateInputs(estimatedInputs);
4989
+ if ("gasLimit" in txParams) {
4990
+ this.validateGas({
4991
+ gasUsed: txCost.gasUsed,
4992
+ gasLimit: request.gasLimit
4993
+ });
4994
+ }
4995
+ request.gasLimit = txCost.gasUsed;
4996
+ request.maxFee = txCost.maxFee;
4997
+ await this.fund(request, txCost);
4762
4998
  return request;
4763
4999
  }
4764
5000
  /**
@@ -4771,7 +5007,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4771
5007
  * @returns A promise that resolves to the transaction response.
4772
5008
  */
4773
5009
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4774
- if ((0, import_math18.bn)(amount).lte(0)) {
5010
+ if ((0, import_math19.bn)(amount).lte(0)) {
4775
5011
  throw new import_errors16.FuelError(
4776
5012
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4777
5013
  "Transfer amount must be a positive number."
@@ -4790,38 +5026,37 @@ var Account = class extends import_interfaces.AbstractAccount {
4790
5026
  * @returns A promise that resolves to the transaction response.
4791
5027
  */
4792
5028
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4793
- if ((0, import_math18.bn)(amount).lte(0)) {
5029
+ if ((0, import_math19.bn)(amount).lte(0)) {
4794
5030
  throw new import_errors16.FuelError(
4795
5031
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4796
5032
  "Transfer amount must be a positive number."
4797
5033
  );
4798
5034
  }
4799
5035
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4800
- const { minGasPrice } = this.provider.getGasConfig();
4801
- const params = { gasPrice: minGasPrice, ...txParams };
4802
5036
  const { script, scriptData } = await assembleTransferToContractScript({
4803
5037
  hexlifiedContractId: contractAddress.toB256(),
4804
- amountToTransfer: (0, import_math18.bn)(amount),
5038
+ amountToTransfer: (0, import_math19.bn)(amount),
4805
5039
  assetId
4806
5040
  });
4807
5041
  const request = new ScriptTransactionRequest({
4808
- ...params,
5042
+ ...txParams,
4809
5043
  script,
4810
5044
  scriptData
4811
5045
  });
4812
5046
  request.addContractInputAndOutput(contractAddress);
4813
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4814
- request,
4815
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
4816
- );
4817
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4818
- this.validateGas({
4819
- gasUsed,
4820
- gasPrice: request.gasPrice,
4821
- gasLimit: request.gasLimit,
4822
- minGasPrice
5047
+ const txCost = await this.provider.getTransactionCost(request, {
5048
+ resourcesOwner: this,
5049
+ quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
4823
5050
  });
4824
- await this.fund(request, requiredQuantities, maxFee);
5051
+ if (txParams.gasLimit) {
5052
+ this.validateGas({
5053
+ gasUsed: txCost.gasUsed,
5054
+ gasLimit: request.gasLimit
5055
+ });
5056
+ }
5057
+ request.gasLimit = txCost.gasUsed;
5058
+ request.maxFee = txCost.maxFee;
5059
+ await this.fund(request, txCost);
4825
5060
  return this.sendTransaction(request);
4826
5061
  }
4827
5062
  /**
@@ -4833,34 +5068,31 @@ var Account = class extends import_interfaces.AbstractAccount {
4833
5068
  * @returns A promise that resolves to the transaction response.
4834
5069
  */
4835
5070
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4836
- const { minGasPrice } = this.provider.getGasConfig();
4837
5071
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
4838
- const recipientDataArray = (0, import_utils28.arrayify)(
5072
+ const recipientDataArray = (0, import_utils27.arrayify)(
4839
5073
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4840
5074
  );
4841
- const amountDataArray = (0, import_utils28.arrayify)(
4842
- "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5075
+ const amountDataArray = (0, import_utils27.arrayify)(
5076
+ "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
4843
5077
  );
4844
5078
  const script = new Uint8Array([
4845
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5079
+ ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4846
5080
  ...recipientDataArray,
4847
5081
  ...amountDataArray
4848
5082
  ]);
4849
- const params = { script, gasPrice: minGasPrice, ...txParams };
5083
+ const params = { script, ...txParams };
4850
5084
  const request = new ScriptTransactionRequest(params);
4851
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
4852
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4853
- request,
4854
- forwardingQuantities
4855
- );
4856
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4857
- this.validateGas({
4858
- gasUsed,
4859
- gasPrice: request.gasPrice,
4860
- gasLimit: request.gasLimit,
4861
- minGasPrice
4862
- });
4863
- await this.fund(request, requiredQuantities, maxFee);
5085
+ const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5086
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5087
+ if (txParams.gasLimit) {
5088
+ this.validateGas({
5089
+ gasUsed: txCost.gasUsed,
5090
+ gasLimit: request.gasLimit
5091
+ });
5092
+ }
5093
+ request.maxFee = txCost.maxFee;
5094
+ request.gasLimit = txCost.gasUsed;
5095
+ await this.fund(request, txCost);
4864
5096
  return this.sendTransaction(request);
4865
5097
  }
4866
5098
  async signMessage(message) {
@@ -4918,18 +5150,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4918
5150
  }
4919
5151
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4920
5152
  }
4921
- validateGas({
4922
- gasUsed,
4923
- gasPrice,
4924
- gasLimit,
4925
- minGasPrice
4926
- }) {
4927
- if (minGasPrice.gt(gasPrice)) {
4928
- throw new import_errors16.FuelError(
4929
- import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4930
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4931
- );
4932
- }
5153
+ validateGas({ gasUsed, gasLimit }) {
4933
5154
  if (gasUsed.gt(gasLimit)) {
4934
5155
  throw new import_errors16.FuelError(
4935
5156
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -4943,8 +5164,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4943
5164
  var import_address5 = require("@fuel-ts/address");
4944
5165
  var import_crypto2 = require("@fuel-ts/crypto");
4945
5166
  var import_hasher2 = require("@fuel-ts/hasher");
4946
- var import_math19 = require("@fuel-ts/math");
4947
- var import_utils29 = require("@fuel-ts/utils");
5167
+ var import_math20 = require("@fuel-ts/math");
5168
+ var import_utils28 = require("@fuel-ts/utils");
4948
5169
  var import_secp256k1 = require("@noble/curves/secp256k1");
4949
5170
  var Signer = class {
4950
5171
  address;
@@ -4963,10 +5184,10 @@ var Signer = class {
4963
5184
  privateKey = `0x${privateKey}`;
4964
5185
  }
4965
5186
  }
4966
- const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
4967
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4968
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4969
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5187
+ const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5188
+ this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5189
+ this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5190
+ this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4970
5191
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
4971
5192
  }
4972
5193
  /**
@@ -4980,11 +5201,11 @@ var Signer = class {
4980
5201
  * @returns hashed signature
4981
5202
  */
4982
5203
  sign(data) {
4983
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
4984
- const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
4985
- const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5204
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5205
+ const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5206
+ const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
4986
5207
  s[0] |= (signature.recovery || 0) << 7;
4987
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5208
+ return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4988
5209
  }
4989
5210
  /**
4990
5211
  * Add point on the current elliptic curve
@@ -4993,8 +5214,8 @@ var Signer = class {
4993
5214
  * @returns compressed point on the curve
4994
5215
  */
4995
5216
  addPoint(point) {
4996
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
4997
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5217
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5218
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
4998
5219
  const result = p0.add(p1);
4999
5220
  return `0x${result.toHex(true)}`;
5000
5221
  }
@@ -5006,16 +5227,16 @@ var Signer = class {
5006
5227
  * @returns public key from signature from the
5007
5228
  */
5008
5229
  static recoverPublicKey(data, signature) {
5009
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5230
+ const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5010
5231
  const r = signedMessageBytes.slice(0, 32);
5011
5232
  const s = signedMessageBytes.slice(32, 64);
5012
5233
  const recoveryParam = (s[0] & 128) >> 7;
5013
5234
  s[0] &= 127;
5014
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5235
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5015
5236
  recoveryParam
5016
5237
  );
5017
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5018
- return (0, import_utils29.hexlify)(publicKey);
5238
+ const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5239
+ return (0, import_utils28.hexlify)(publicKey);
5019
5240
  }
5020
5241
  /**
5021
5242
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5034,7 +5255,7 @@ var Signer = class {
5034
5255
  * @returns random 32-byte hashed
5035
5256
  */
5036
5257
  static generatePrivateKey(entropy) {
5037
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5258
+ return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5038
5259
  }
5039
5260
  /**
5040
5261
  * Extended publicKey from a compact publicKey
@@ -5043,8 +5264,8 @@ var Signer = class {
5043
5264
  * @returns extended publicKey
5044
5265
  */
5045
5266
  static extendPublicKey(publicKey) {
5046
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5047
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5267
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5268
+ return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5048
5269
  }
5049
5270
  };
5050
5271
 
@@ -5052,7 +5273,7 @@ var Signer = class {
5052
5273
  var import_address6 = require("@fuel-ts/address");
5053
5274
  var import_crypto3 = require("@fuel-ts/crypto");
5054
5275
  var import_errors17 = require("@fuel-ts/errors");
5055
- var import_utils30 = require("@fuel-ts/utils");
5276
+ var import_utils29 = require("@fuel-ts/utils");
5056
5277
  var import_uuid = require("uuid");
5057
5278
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5058
5279
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5135,7 +5356,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5135
5356
  );
5136
5357
  }
5137
5358
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5138
- const privateKey = (0, import_utils30.hexlify)(buffer);
5359
+ const privateKey = (0, import_utils29.hexlify)(buffer);
5139
5360
  return privateKey;
5140
5361
  }
5141
5362
 
@@ -5180,7 +5401,7 @@ var BaseWalletUnlocked = class extends Account {
5180
5401
  */
5181
5402
  async signMessage(message) {
5182
5403
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5183
- return (0, import_utils31.hexlify)(signedMessage);
5404
+ return (0, import_utils30.hexlify)(signedMessage);
5184
5405
  }
5185
5406
  /**
5186
5407
  * Signs a transaction with the wallet's private key.
@@ -5193,7 +5414,7 @@ var BaseWalletUnlocked = class extends Account {
5193
5414
  const chainId = this.provider.getChainId();
5194
5415
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5195
5416
  const signature = await this.signer().sign(hashedTransaction);
5196
- return (0, import_utils31.hexlify)(signature);
5417
+ return (0, import_utils30.hexlify)(signature);
5197
5418
  }
5198
5419
  /**
5199
5420
  * Populates a transaction with the witnesses signature.
@@ -5213,7 +5434,7 @@ var BaseWalletUnlocked = class extends Account {
5213
5434
  * @param transactionRequestLike - The transaction request to send.
5214
5435
  * @returns A promise that resolves to the TransactionResponse object.
5215
5436
  */
5216
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5437
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5217
5438
  const transactionRequest = transactionRequestify(transactionRequestLike);
5218
5439
  if (estimateTxDependencies) {
5219
5440
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5254,15 +5475,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5254
5475
  // src/hdwallet/hdwallet.ts
5255
5476
  var import_errors20 = require("@fuel-ts/errors");
5256
5477
  var import_hasher6 = require("@fuel-ts/hasher");
5257
- var import_math20 = require("@fuel-ts/math");
5258
- var import_utils35 = require("@fuel-ts/utils");
5478
+ var import_math21 = require("@fuel-ts/math");
5479
+ var import_utils34 = require("@fuel-ts/utils");
5259
5480
  var import_ethers3 = require("ethers");
5260
5481
 
5261
5482
  // src/mnemonic/mnemonic.ts
5262
5483
  var import_crypto4 = require("@fuel-ts/crypto");
5263
5484
  var import_errors19 = require("@fuel-ts/errors");
5264
5485
  var import_hasher5 = require("@fuel-ts/hasher");
5265
- var import_utils33 = require("@fuel-ts/utils");
5486
+ var import_utils32 = require("@fuel-ts/utils");
5266
5487
  var import_ethers2 = require("ethers");
5267
5488
 
5268
5489
  // src/wordlists/words/english.ts
@@ -7320,7 +7541,7 @@ var english = [
7320
7541
  // src/mnemonic/utils.ts
7321
7542
  var import_errors18 = require("@fuel-ts/errors");
7322
7543
  var import_hasher4 = require("@fuel-ts/hasher");
7323
- var import_utils32 = require("@fuel-ts/utils");
7544
+ var import_utils31 = require("@fuel-ts/utils");
7324
7545
  function toUtf8Bytes(stri) {
7325
7546
  const str = stri.normalize("NFKD");
7326
7547
  const result = [];
@@ -7387,14 +7608,14 @@ function entropyToMnemonicIndices(entropy) {
7387
7608
  }
7388
7609
  }
7389
7610
  const checksumBits = entropy.length / 4;
7390
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7611
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7391
7612
  indices[indices.length - 1] <<= checksumBits;
7392
7613
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7393
7614
  return indices;
7394
7615
  }
7395
7616
  function mnemonicWordsToEntropy(words, wordlist) {
7396
7617
  const size = Math.ceil(11 * words.length / 8);
7397
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7618
+ const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7398
7619
  let offset = 0;
7399
7620
  for (let i = 0; i < words.length; i += 1) {
7400
7621
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7414,7 +7635,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7414
7635
  const entropyBits = 32 * words.length / 3;
7415
7636
  const checksumBits = words.length / 3;
7416
7637
  const checksumMask = getUpperMask(checksumBits);
7417
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7638
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7418
7639
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7419
7640
  throw new import_errors18.FuelError(
7420
7641
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7489,7 +7710,7 @@ var Mnemonic = class {
7489
7710
  static mnemonicToEntropy(phrase, wordlist = english) {
7490
7711
  const words = getWords(phrase);
7491
7712
  assertMnemonic(words);
7492
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7713
+ return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7493
7714
  }
7494
7715
  /**
7495
7716
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7497,7 +7718,7 @@ var Mnemonic = class {
7497
7718
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7498
7719
  */
7499
7720
  static entropyToMnemonic(entropy, wordlist = english) {
7500
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
7721
+ const entropyBytes = (0, import_utils32.arrayify)(entropy);
7501
7722
  assertWordList(wordlist);
7502
7723
  assertEntropy(entropyBytes);
7503
7724
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7566,14 +7787,14 @@ var Mnemonic = class {
7566
7787
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7567
7788
  */
7568
7789
  static masterKeysFromSeed(seed) {
7569
- const seedArray = (0, import_utils33.arrayify)(seed);
7790
+ const seedArray = (0, import_utils32.arrayify)(seed);
7570
7791
  if (seedArray.length < 16 || seedArray.length > 64) {
7571
7792
  throw new import_errors19.FuelError(
7572
7793
  import_errors19.ErrorCode.INVALID_SEED,
7573
7794
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7574
7795
  );
7575
7796
  }
7576
- return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7797
+ return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7577
7798
  }
7578
7799
  /**
7579
7800
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7584,22 +7805,22 @@ var Mnemonic = class {
7584
7805
  */
7585
7806
  static seedToExtendedKey(seed, testnet = false) {
7586
7807
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7587
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7808
+ const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7588
7809
  const depth = "0x00";
7589
7810
  const fingerprint = "0x00000000";
7590
7811
  const index = "0x00000000";
7591
7812
  const chainCode = masterKey.slice(32);
7592
7813
  const privateKey = masterKey.slice(0, 32);
7593
- const extendedKey = (0, import_utils33.concat)([
7814
+ const extendedKey = (0, import_utils32.concat)([
7594
7815
  prefix,
7595
7816
  depth,
7596
7817
  fingerprint,
7597
7818
  index,
7598
7819
  chainCode,
7599
- (0, import_utils33.concat)(["0x00", privateKey])
7820
+ (0, import_utils32.concat)(["0x00", privateKey])
7600
7821
  ]);
7601
7822
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7602
- return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7823
+ return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7603
7824
  }
7604
7825
  /**
7605
7826
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7614,7 +7835,7 @@ var Mnemonic = class {
7614
7835
  * @returns A randomly generated mnemonic
7615
7836
  */
7616
7837
  static generate(size = 32, extraEntropy = "") {
7617
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
7838
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
7618
7839
  return Mnemonic.entropyToMnemonic(entropy);
7619
7840
  }
7620
7841
  };
@@ -7622,12 +7843,12 @@ var mnemonic_default = Mnemonic;
7622
7843
 
7623
7844
  // src/hdwallet/hdwallet.ts
7624
7845
  var HARDENED_INDEX = 2147483648;
7625
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7626
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7627
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7628
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7846
+ var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7847
+ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7848
+ var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7849
+ var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7629
7850
  function base58check(data) {
7630
- return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7851
+ return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7631
7852
  }
7632
7853
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7633
7854
  if (isPublic) {
@@ -7636,11 +7857,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7636
7857
  return testnet ? TestnetPRV2 : MainnetPRV2;
7637
7858
  }
7638
7859
  function isPublicExtendedKey(extendedKey) {
7639
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7860
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7640
7861
  }
7641
7862
  function isValidExtendedKey(extendedKey) {
7642
7863
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7643
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7864
+ (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7644
7865
  );
7645
7866
  }
7646
7867
  function parsePath(path2, depth = 0) {
@@ -7658,8 +7879,8 @@ function parsePath(path2, depth = 0) {
7658
7879
  var HDWallet = class {
7659
7880
  depth = 0;
7660
7881
  index = 0;
7661
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
7662
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7882
+ fingerprint = (0, import_utils34.hexlify)("0x00000000");
7883
+ parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7663
7884
  privateKey;
7664
7885
  publicKey;
7665
7886
  chainCode;
@@ -7671,8 +7892,8 @@ var HDWallet = class {
7671
7892
  constructor(config) {
7672
7893
  if (config.privateKey) {
7673
7894
  const signer = new Signer(config.privateKey);
7674
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7675
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7895
+ this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7896
+ this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7676
7897
  } else {
7677
7898
  if (!config.publicKey) {
7678
7899
  throw new import_errors20.FuelError(
@@ -7680,7 +7901,7 @@ var HDWallet = class {
7680
7901
  "Both public and private Key cannot be missing. At least one should be provided."
7681
7902
  );
7682
7903
  }
7683
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7904
+ this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7684
7905
  }
7685
7906
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7686
7907
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7699,9 +7920,9 @@ var HDWallet = class {
7699
7920
  * @returns A new instance of HDWallet on the derived index
7700
7921
  */
7701
7922
  deriveIndex(index) {
7702
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7703
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7704
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7923
+ const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7924
+ const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7925
+ const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7705
7926
  const data = new Uint8Array(37);
7706
7927
  if (index & HARDENED_INDEX) {
7707
7928
  if (!privateKey) {
@@ -7712,15 +7933,15 @@ var HDWallet = class {
7712
7933
  }
7713
7934
  data.set(privateKey, 1);
7714
7935
  } else {
7715
- data.set((0, import_utils35.arrayify)(this.publicKey));
7936
+ data.set((0, import_utils34.arrayify)(this.publicKey));
7716
7937
  }
7717
- data.set((0, import_math20.toBytes)(index, 4), 33);
7718
- const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7938
+ data.set((0, import_math21.toBytes)(index, 4), 33);
7939
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7719
7940
  const IL = bytes.slice(0, 32);
7720
7941
  const IR = bytes.slice(32);
7721
7942
  if (privateKey) {
7722
7943
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7723
- const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7944
+ const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
7724
7945
  return new HDWallet({
7725
7946
  privateKey: ki,
7726
7947
  chainCode: IR,
@@ -7729,7 +7950,7 @@ var HDWallet = class {
7729
7950
  parentFingerprint: this.fingerprint
7730
7951
  });
7731
7952
  }
7732
- const signer = new Signer((0, import_utils35.hexlify)(IL));
7953
+ const signer = new Signer((0, import_utils34.hexlify)(IL));
7733
7954
  const Ki = signer.addPoint(publicKey);
7734
7955
  return new HDWallet({
7735
7956
  publicKey: Ki,
@@ -7764,12 +7985,12 @@ var HDWallet = class {
7764
7985
  );
7765
7986
  }
7766
7987
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7767
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
7988
+ const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7768
7989
  const parentFingerprint = this.parentFingerprint;
7769
- const index = (0, import_math20.toHex)(this.index, 4);
7990
+ const index = (0, import_math21.toHex)(this.index, 4);
7770
7991
  const chainCode = this.chainCode;
7771
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7772
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7992
+ const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
7993
+ const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7773
7994
  return base58check(extendedKey);
7774
7995
  }
7775
7996
  /**
@@ -7781,13 +8002,13 @@ var HDWallet = class {
7781
8002
  static fromSeed(seed) {
7782
8003
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7783
8004
  return new HDWallet({
7784
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7785
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8005
+ chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8006
+ privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7786
8007
  });
7787
8008
  }
7788
8009
  static fromExtendedKey(extendedKey) {
7789
8010
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
7790
- const bytes = (0, import_utils35.arrayify)(decoded);
8011
+ const bytes = (0, import_utils34.arrayify)(decoded);
7791
8012
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7792
8013
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7793
8014
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -7796,9 +8017,9 @@ var HDWallet = class {
7796
8017
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7797
8018
  }
7798
8019
  const depth = bytes[4];
7799
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7800
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7801
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8020
+ const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8021
+ const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8022
+ const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7802
8023
  const key = bytes.slice(45, 78);
7803
8024
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7804
8025
  throw new import_errors20.FuelError(
@@ -7986,26 +8207,20 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7986
8207
 
7987
8208
  // src/test-utils/seedTestWallet.ts
7988
8209
  var import_crypto5 = require("@fuel-ts/crypto");
7989
- var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
7990
- const toFundAccounts = Array.isArray(wallet) ? wallet : [wallet];
8210
+ var seedTestWallet = async (wallet, quantities) => {
7991
8211
  const genesisWallet = new WalletUnlocked(
7992
8212
  process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
7993
- toFundAccounts[0].provider
8213
+ wallet.provider
7994
8214
  );
7995
- const resources = await genesisWallet.getResourcesToSpend(quantities);
7996
- const { minGasPrice } = genesisWallet.provider.getGasConfig();
7997
- const request = new ScriptTransactionRequest({
7998
- gasLimit: 1e4,
7999
- gasPrice: minGasPrice
8215
+ const request = new ScriptTransactionRequest();
8216
+ quantities.forEach((quantity) => {
8217
+ const { amount, assetId } = coinQuantityfy(quantity);
8218
+ request.addCoinOutput(wallet.address, amount, assetId);
8000
8219
  });
8001
- request.addResources(resources);
8002
- quantities.map(coinQuantityfy).forEach(
8003
- ({ amount, assetId }) => toFundAccounts.forEach(({ address }) => {
8004
- for (let i = 0; i < utxosAmount; i++) {
8005
- request.addCoinOutput(address, amount.div(utxosAmount), assetId);
8006
- }
8007
- })
8008
- );
8220
+ const txCost = await genesisWallet.provider.getTransactionCost(request);
8221
+ request.gasLimit = txCost.gasUsed;
8222
+ request.maxFee = txCost.maxFee;
8223
+ await genesisWallet.fund(request, txCost);
8009
8224
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8010
8225
  };
8011
8226
 
@@ -8020,11 +8235,11 @@ var generateTestWallet = async (provider, quantities) => {
8020
8235
 
8021
8236
  // src/test-utils/launchNode.ts
8022
8237
  var import_configs13 = require("@fuel-ts/address/configs");
8023
- var import_math21 = require("@fuel-ts/math");
8024
- var import_utils36 = require("@fuel-ts/utils");
8238
+ var import_utils35 = require("@fuel-ts/utils");
8025
8239
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8026
8240
  var import_child_process = require("child_process");
8027
8241
  var import_crypto6 = require("crypto");
8242
+ var import_ethers4 = require("ethers");
8028
8243
  var import_fs = require("fs");
8029
8244
  var import_os = __toESM(require("os"));
8030
8245
  var import_path = __toESM(require("path"));
@@ -8073,13 +8288,13 @@ var launchNode = async ({
8073
8288
  // eslint-disable-next-line no-async-promise-executor
8074
8289
  new Promise(async (resolve, reject) => {
8075
8290
  const remainingArgs = extractRemainingArgs(args, [
8076
- "--chain",
8291
+ "--snapshot",
8077
8292
  "--consensus-key",
8078
8293
  "--db-type",
8079
8294
  "--poa-instant"
8080
8295
  ]);
8081
- const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8082
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8296
+ const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8297
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8083
8298
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8084
8299
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8085
8300
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -8097,36 +8312,54 @@ var launchNode = async ({
8097
8312
  let chainConfigPathToUse;
8098
8313
  const prefix = basePath || import_os.default.tmpdir();
8099
8314
  const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
8100
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
8315
+ const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
8101
8316
  if (chainConfigPath) {
8102
8317
  chainConfigPathToUse = chainConfigPath;
8103
8318
  } else {
8104
8319
  if (!(0, import_fs.existsSync)(tempDirPath)) {
8105
8320
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8106
8321
  }
8107
- const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
8108
- let chainConfig = import_utils36.defaultChainConfig;
8322
+ let { stateConfigJson } = import_utils35.defaultChainConfigs;
8323
+ const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
8324
+ stateConfigJson = {
8325
+ ...stateConfigJson,
8326
+ coins: [
8327
+ ...stateConfigJson.coins.map((coin) => ({
8328
+ ...coin,
8329
+ amount: "18446744073709551615"
8330
+ }))
8331
+ ],
8332
+ messages: stateConfigJson.messages.map((message) => ({
8333
+ ...message,
8334
+ amount: "18446744073709551615"
8335
+ }))
8336
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8337
+ };
8109
8338
  if (!process.env.GENESIS_SECRET) {
8110
8339
  const pk = Signer.generatePrivateKey();
8111
8340
  const signer = new Signer(pk);
8112
- process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8113
- chainConfig = {
8114
- ...import_utils36.defaultChainConfig,
8115
- initial_state: {
8116
- ...import_utils36.defaultChainConfig.initial_state,
8117
- coins: [
8118
- ...import_utils36.defaultChainConfig.initial_state.coins,
8119
- {
8120
- owner: signer.address.toHexString(),
8121
- amount: (0, import_math21.toHex)(1e9),
8122
- asset_id: import_configs13.BaseAssetId
8123
- }
8124
- ]
8125
- }
8126
- };
8341
+ process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8342
+ stateConfigJson.coins.push({
8343
+ tx_id: (0, import_utils35.hexlify)((0, import_ethers4.randomBytes)(34)),
8344
+ owner: signer.address.toHexString(),
8345
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8346
+ amount: "18446744073709551615",
8347
+ asset_id: import_configs13.BaseAssetId,
8348
+ output_index: 0,
8349
+ tx_pointer_block_height: 0,
8350
+ tx_pointer_tx_idx: 0
8351
+ });
8127
8352
  }
8128
- (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8129
- chainConfigPathToUse = tempChainConfigFilePath;
8353
+ let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8354
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8355
+ fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8356
+ const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8357
+ const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8358
+ const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8359
+ (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8360
+ (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8361
+ (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8362
+ chainConfigPathToUse = tempDirPath;
8130
8363
  }
8131
8364
  const child = (0, import_child_process.spawn)(
8132
8365
  command,
@@ -8135,10 +8368,10 @@ var launchNode = async ({
8135
8368
  ["--ip", ipToUse],
8136
8369
  ["--port", portToUse],
8137
8370
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8138
- ["--min-gas-price", "0"],
8371
+ ["--min-gas-price", "1"],
8139
8372
  poaInstant ? ["--poa-instant", "true"] : [],
8140
8373
  ["--consensus-key", consensusKey],
8141
- ["--chain", chainConfigPathToUse],
8374
+ ["--snapshot", chainConfigPathToUse],
8142
8375
  "--vm-backtrace",
8143
8376
  "--utxo-validation",
8144
8377
  "--debug",
@@ -8197,52 +8430,15 @@ var launchNodeAndGetWallets = async ({
8197
8430
  walletCount = 10
8198
8431
  } = {}) => {
8199
8432
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8200
- const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8433
+ const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8201
8434
  const wallets = await generateWallets(walletCount, provider);
8202
8435
  const cleanup = () => {
8203
8436
  closeNode();
8204
8437
  };
8205
8438
  return { wallets, stop: cleanup, provider };
8206
8439
  };
8207
-
8208
- // src/test-utils/transactionRequest.ts
8209
- var import_abi_coder7 = require("@fuel-ts/abi-coder");
8210
- var import_address7 = require("@fuel-ts/address");
8211
- var import_configs14 = require("@fuel-ts/address/configs");
8212
- var import_crypto7 = require("@fuel-ts/crypto");
8213
- var import_math22 = require("@fuel-ts/math");
8214
- var import_transactions21 = require("@fuel-ts/transactions");
8215
- var import_utils37 = require("@fuel-ts/utils");
8216
- var generateFakeRequestInputCoin = (partial = {}) => ({
8217
- id: (0, import_utils37.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8218
- type: import_transactions21.InputType.Coin,
8219
- owner: (0, import_address7.getRandomB256)(),
8220
- amount: (0, import_math22.bn)(100),
8221
- assetId: import_configs14.ZeroBytes32,
8222
- txPointer: "0x00000000000000000000000000000000",
8223
- witnessIndex: 0,
8224
- ...partial
8225
- });
8226
- var generateFakeRequestInputMessage = (partial = {}) => ({
8227
- nonce: (0, import_address7.getRandomB256)(),
8228
- type: import_transactions21.InputType.Message,
8229
- sender: (0, import_address7.getRandomB256)(),
8230
- recipient: (0, import_address7.getRandomB256)(),
8231
- amount: (0, import_math22.bn)(100),
8232
- witnessIndex: 0,
8233
- ...partial
8234
- });
8235
- var generateFakeRequestInputContract = (partial = {}) => ({
8236
- contractId: (0, import_address7.getRandomB256)(),
8237
- type: import_transactions21.InputType.Contract,
8238
- txPointer: "0x00000000000000000000000000000000",
8239
- ...partial
8240
- });
8241
8440
  // Annotate the CommonJS export names for ESM import in node:
8242
8441
  0 && (module.exports = {
8243
- generateFakeRequestInputCoin,
8244
- generateFakeRequestInputContract,
8245
- generateFakeRequestInputMessage,
8246
8442
  generateTestWallet,
8247
8443
  killNode,
8248
8444
  launchNode,