@fuel-ts/account 0.0.0-rc-1976-20240411153008 → 0.0.0-rc-2021-20240411154255

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 (57) 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 +896 -629
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +874 -621
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +716 -464
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -2
  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 +3 -3
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +4 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +7 -1
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +45 -34
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  31. package/dist/providers/transaction-request/create-transaction-request.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 +1 -1
  35. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/transaction-request.d.ts +9 -29
  37. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  38. package/dist/providers/transaction-request/utils.d.ts +3 -0
  39. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  40. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
  42. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
  44. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  45. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  46. package/dist/providers/utils/gas.d.ts +8 -2
  47. package/dist/providers/utils/gas.d.ts.map +1 -1
  48. package/dist/test-utils/launchNode.d.ts.map +1 -1
  49. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  50. package/dist/test-utils.global.js +1613 -1132
  51. package/dist/test-utils.global.js.map +1 -1
  52. package/dist/test-utils.js +852 -620
  53. package/dist/test-utils.js.map +1 -1
  54. package/dist/test-utils.mjs +710 -478
  55. package/dist/test-utils.mjs.map +1 -1
  56. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  57. package/package.json +17 -17
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ __export(src_exports, {
95
95
  WalletLocked: () => WalletLocked,
96
96
  WalletManager: () => WalletManager,
97
97
  WalletUnlocked: () => WalletUnlocked,
98
- addAmountToAsset: () => addAmountToAsset,
98
+ addAmountToCoinQuantities: () => addAmountToCoinQuantities,
99
99
  addOperation: () => addOperation,
100
100
  assemblePanicError: () => assemblePanicError,
101
101
  assembleReceiptByType: () => assembleReceiptByType,
@@ -104,9 +104,10 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
+ cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
108
+ calculateGasFee: () => calculateGasFee,
107
109
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
108
110
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
109
- calculatePriceWithFactor: () => calculatePriceWithFactor,
110
111
  calculateTransactionFee: () => calculateTransactionFee,
111
112
  coinQuantityfy: () => coinQuantityfy,
112
113
  deferPromise: () => deferPromise,
@@ -184,35 +185,38 @@ module.exports = __toCommonJS(src_exports);
184
185
 
185
186
  // src/account.ts
186
187
  var import_address4 = require("@fuel-ts/address");
188
+ var import_configs12 = require("@fuel-ts/address/configs");
187
189
  var import_errors16 = require("@fuel-ts/errors");
188
190
  var import_interfaces = require("@fuel-ts/interfaces");
189
- var import_math18 = require("@fuel-ts/math");
190
- var import_utils28 = require("@fuel-ts/utils");
191
+ var import_math19 = require("@fuel-ts/math");
192
+ var import_utils27 = require("@fuel-ts/utils");
193
+ var import_ramda4 = require("ramda");
191
194
 
192
195
  // src/providers/coin-quantity.ts
196
+ var import_configs = require("@fuel-ts/address/configs");
193
197
  var import_math = require("@fuel-ts/math");
194
198
  var import_utils = require("@fuel-ts/utils");
195
199
  var coinQuantityfy = (coinQuantityLike) => {
196
200
  let assetId;
197
201
  let amount;
198
- let max2;
202
+ let max;
199
203
  if (Array.isArray(coinQuantityLike)) {
200
204
  amount = coinQuantityLike[0];
201
- assetId = coinQuantityLike[1];
202
- max2 = coinQuantityLike[2];
205
+ assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
206
+ max = coinQuantityLike[2] ?? void 0;
203
207
  } else {
204
208
  amount = coinQuantityLike.amount;
205
- assetId = coinQuantityLike.assetId;
206
- max2 = coinQuantityLike.max ?? void 0;
209
+ assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
210
+ max = coinQuantityLike.max ?? void 0;
207
211
  }
208
212
  const bnAmount = (0, import_math.bn)(amount);
209
213
  return {
210
214
  assetId: (0, import_utils.hexlify)(assetId),
211
215
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
212
- max: max2 ? (0, import_math.bn)(max2) : void 0
216
+ max: max ? (0, import_math.bn)(max) : void 0
213
217
  };
214
218
  };
215
- var addAmountToAsset = (params) => {
219
+ var addAmountToCoinQuantities = (params) => {
216
220
  const { amount, assetId } = params;
217
221
  const coinQuantities = [...params.coinQuantities];
218
222
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -227,12 +231,12 @@ var addAmountToAsset = (params) => {
227
231
  // src/providers/provider.ts
228
232
  var import_address3 = require("@fuel-ts/address");
229
233
  var import_errors14 = require("@fuel-ts/errors");
230
- var import_math15 = require("@fuel-ts/math");
231
- var import_transactions18 = require("@fuel-ts/transactions");
232
- var import_utils23 = require("@fuel-ts/utils");
234
+ var import_math16 = require("@fuel-ts/math");
235
+ var import_transactions19 = require("@fuel-ts/transactions");
236
+ var import_utils22 = require("@fuel-ts/utils");
233
237
  var import_versions = require("@fuel-ts/versions");
234
- var import_utils24 = require("@noble/curves/abstract/utils");
235
- var import_ethers = require("ethers");
238
+ var import_utils23 = require("@noble/curves/abstract/utils");
239
+ var import_ethers2 = require("ethers");
236
240
  var import_graphql_request = require("graphql-request");
237
241
  var import_ramda3 = require("ramda");
238
242
 
@@ -240,14 +244,10 @@ var import_ramda3 = require("ramda");
240
244
  var import_graphql_tag = __toESM(require("graphql-tag"));
241
245
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
242
246
  fragment receiptFragment on Receipt {
243
- contract {
244
- id
245
- }
247
+ id
246
248
  pc
247
249
  is
248
- to {
249
- id
250
- }
250
+ to
251
251
  toAddress
252
252
  amount
253
253
  assetId
@@ -285,10 +285,16 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
285
285
  id
286
286
  }
287
287
  time
288
+ receipts {
289
+ ...receiptFragment
290
+ }
288
291
  programState {
289
292
  returnType
290
293
  data
291
294
  }
295
+ receipts {
296
+ ...receiptFragment
297
+ }
292
298
  }
293
299
  ... on FailureStatus {
294
300
  block {
@@ -296,26 +302,24 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
296
302
  }
297
303
  time
298
304
  reason
305
+ receipts {
306
+ ...receiptFragment
307
+ }
299
308
  }
300
309
  ... on SqueezedOutStatus {
301
310
  reason
302
311
  }
303
312
  }
304
- `;
313
+ ${ReceiptFragmentFragmentDoc}`;
305
314
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
306
315
  fragment transactionFragment on Transaction {
307
316
  id
308
317
  rawPayload
309
- gasPrice
310
- receipts {
311
- ...receiptFragment
312
- }
313
318
  status {
314
319
  ...transactionStatusFragment
315
320
  }
316
321
  }
317
- ${ReceiptFragmentFragmentDoc}
318
- ${TransactionStatusFragmentFragmentDoc}`;
322
+ ${TransactionStatusFragmentFragmentDoc}`;
319
323
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
320
324
  fragment inputEstimatePredicatesFragment on Input {
321
325
  ... on InputCoin {
@@ -333,6 +337,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
333
337
  }
334
338
  }
335
339
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
340
+ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
341
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
342
+ reason
343
+ programState {
344
+ returnType
345
+ data
346
+ }
347
+ }
348
+ `;
349
+ var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
350
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
351
+ programState {
352
+ returnType
353
+ data
354
+ }
355
+ }
356
+ `;
357
+ var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
358
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
359
+ ... on DryRunFailureStatus {
360
+ ...dryRunFailureStatusFragment
361
+ }
362
+ ... on DryRunSuccessStatus {
363
+ ...dryRunSuccessStatusFragment
364
+ }
365
+ }
366
+ ${DryRunFailureStatusFragmentFragmentDoc}
367
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
368
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
369
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
370
+ id
371
+ status {
372
+ ...dryRunTransactionStatusFragment
373
+ }
374
+ receipts {
375
+ ...receiptFragment
376
+ }
377
+ }
378
+ ${DryRunTransactionStatusFragmentFragmentDoc}
379
+ ${ReceiptFragmentFragmentDoc}`;
336
380
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
337
381
  fragment coinFragment on Coin {
338
382
  __typename
@@ -340,7 +384,6 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
340
384
  owner
341
385
  amount
342
386
  assetId
343
- maturity
344
387
  blockCreated
345
388
  txCreatedIdx
346
389
  }
@@ -379,26 +422,32 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
379
422
  messageBlockHeader {
380
423
  id
381
424
  daHeight
425
+ consensusParametersVersion
426
+ stateTransitionBytecodeVersion
382
427
  transactionsCount
428
+ messageReceiptCount
383
429
  transactionsRoot
430
+ messageOutboxRoot
431
+ eventInboxRoot
384
432
  height
385
433
  prevRoot
386
434
  time
387
435
  applicationHash
388
- messageReceiptRoot
389
- messageReceiptCount
390
436
  }
391
437
  commitBlockHeader {
392
438
  id
393
439
  daHeight
440
+ consensusParametersVersion
441
+ stateTransitionBytecodeVersion
394
442
  transactionsCount
443
+ messageReceiptCount
395
444
  transactionsRoot
445
+ messageOutboxRoot
446
+ eventInboxRoot
396
447
  height
397
448
  prevRoot
398
449
  time
399
450
  applicationHash
400
- messageReceiptRoot
401
- messageReceiptCount
402
451
  }
403
452
  sender
404
453
  recipient
@@ -417,8 +466,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
417
466
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
418
467
  fragment blockFragment on Block {
419
468
  id
469
+ height
420
470
  header {
421
- height
422
471
  time
423
472
  }
424
473
  transactions {
@@ -476,6 +525,11 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
476
525
  `;
477
526
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
478
527
  fragment GasCostsFragment on GasCosts {
528
+ version {
529
+ ... on Version {
530
+ value
531
+ }
532
+ }
479
533
  add
480
534
  addi
481
535
  aloc
@@ -488,7 +542,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
488
542
  cb
489
543
  cfei
490
544
  cfsi
491
- croo
492
545
  div
493
546
  divi
494
547
  ecr1
@@ -571,6 +624,9 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
571
624
  ccp {
572
625
  ...DependentCostFragment
573
626
  }
627
+ croo {
628
+ ...DependentCostFragment
629
+ }
574
630
  csiz {
575
631
  ...DependentCostFragment
576
632
  }
@@ -630,6 +686,11 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
630
686
  ${DependentCostFragmentFragmentDoc}`;
631
687
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
632
688
  fragment consensusParametersFragment on ConsensusParameters {
689
+ version {
690
+ ... on Version {
691
+ value
692
+ }
693
+ }
633
694
  txParams {
634
695
  ...TxParametersFragment
635
696
  }
@@ -689,18 +750,9 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
689
750
  fragment nodeInfoFragment on NodeInfo {
690
751
  utxoValidation
691
752
  vmBacktrace
692
- minGasPrice
693
753
  maxTx
694
754
  maxDepth
695
755
  nodeVersion
696
- peers {
697
- id
698
- addresses
699
- clientVersion
700
- blockHeight
701
- lastHeartbeatMs
702
- appScore
703
- }
704
756
  }
705
757
  `;
706
758
  var GetVersionDocument = import_graphql_tag.default`
@@ -735,13 +787,9 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
735
787
  query getTransactionWithReceipts($transactionId: TransactionId!) {
736
788
  transaction(id: $transactionId) {
737
789
  ...transactionFragment
738
- receipts {
739
- ...receiptFragment
740
- }
741
790
  }
742
791
  }
743
- ${TransactionFragmentFragmentDoc}
744
- ${ReceiptFragmentFragmentDoc}`;
792
+ ${TransactionFragmentFragmentDoc}`;
745
793
  var GetTransactionsDocument = import_graphql_tag.default`
746
794
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
747
795
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -869,6 +917,20 @@ var GetBalanceDocument = import_graphql_tag.default`
869
917
  }
870
918
  }
871
919
  ${BalanceFragmentFragmentDoc}`;
920
+ var GetLatestGasPriceDocument = import_graphql_tag.default`
921
+ query getLatestGasPrice {
922
+ latestGasPrice {
923
+ gasPrice
924
+ }
925
+ }
926
+ `;
927
+ var EstimateGasPriceDocument = import_graphql_tag.default`
928
+ query estimateGasPrice($blockHorizon: U32!) {
929
+ estimateGasPrice(blockHorizon: $blockHorizon) {
930
+ gasPrice
931
+ }
932
+ }
933
+ `;
872
934
  var GetBalancesDocument = import_graphql_tag.default`
873
935
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
874
936
  balances(
@@ -923,12 +985,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
923
985
  }
924
986
  `;
925
987
  var DryRunDocument = import_graphql_tag.default`
926
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
927
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
928
- ...receiptFragment
988
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
989
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
990
+ ...dryRunTransactionExecutionStatusFragment
929
991
  }
930
992
  }
931
- ${ReceiptFragmentFragmentDoc}`;
993
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
932
994
  var SubmitDocument = import_graphql_tag.default`
933
995
  mutation submit($encodedTransaction: HexString!) {
934
996
  submit(tx: $encodedTransaction) {
@@ -1011,6 +1073,12 @@ function getSdk(requester) {
1011
1073
  getBalance(variables, options) {
1012
1074
  return requester(GetBalanceDocument, variables, options);
1013
1075
  },
1076
+ getLatestGasPrice(variables, options) {
1077
+ return requester(GetLatestGasPriceDocument, variables, options);
1078
+ },
1079
+ estimateGasPrice(variables, options) {
1080
+ return requester(EstimateGasPriceDocument, variables, options);
1081
+ },
1014
1082
  getBalances(variables, options) {
1015
1083
  return requester(GetBalancesDocument, variables, options);
1016
1084
  },
@@ -1080,11 +1148,14 @@ var _FuelGraphqlSubscriber = class {
1080
1148
  let data;
1081
1149
  let errors;
1082
1150
  try {
1083
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1151
+ const sanitizedText = text.replace(/\s/g, "");
1152
+ ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
1084
1153
  } catch (e) {
1085
1154
  throw new import_errors.FuelError(
1086
1155
  import_errors.ErrorCode.STREAM_PARSING_ERROR,
1087
- `Error while parsing stream data response: ${text}`
1156
+ `Error while parsing stream data response: ${text}
1157
+
1158
+ Thrown error: ${e}`
1088
1159
  );
1089
1160
  }
1090
1161
  if (Array.isArray(errors)) {
@@ -1171,7 +1242,7 @@ var MemoryCache = class {
1171
1242
  };
1172
1243
 
1173
1244
  // src/providers/transaction-request/input.ts
1174
- var import_configs = require("@fuel-ts/address/configs");
1245
+ var import_configs2 = require("@fuel-ts/address/configs");
1175
1246
  var import_errors3 = require("@fuel-ts/errors");
1176
1247
  var import_math2 = require("@fuel-ts/math");
1177
1248
  var import_transactions = require("@fuel-ts/transactions");
@@ -1185,7 +1256,7 @@ var inputify = (value) => {
1185
1256
  return {
1186
1257
  type: import_transactions.InputType.Coin,
1187
1258
  txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1188
- outputIndex: (0, import_utils3.arrayify)(value.id)[32],
1259
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 34)),
1189
1260
  owner: (0, import_utils3.hexlify)(value.owner),
1190
1261
  amount: (0, import_math2.bn)(value.amount),
1191
1262
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1194,10 +1265,9 @@ var inputify = (value) => {
1194
1265
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1195
1266
  },
1196
1267
  witnessIndex: value.witnessIndex,
1197
- maturity: value.maturity ?? 0,
1198
1268
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1199
- predicateLength: predicate.length,
1200
- predicateDataLength: predicateData.length,
1269
+ predicateLength: (0, import_math2.bn)(predicate.length),
1270
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1201
1271
  predicate: (0, import_utils3.hexlify)(predicate),
1202
1272
  predicateData: (0, import_utils3.hexlify)(predicateData)
1203
1273
  };
@@ -1205,10 +1275,10 @@ var inputify = (value) => {
1205
1275
  case import_transactions.InputType.Contract: {
1206
1276
  return {
1207
1277
  type: import_transactions.InputType.Contract,
1208
- txID: import_configs.ZeroBytes32,
1278
+ txID: import_configs2.ZeroBytes32,
1209
1279
  outputIndex: 0,
1210
- balanceRoot: import_configs.ZeroBytes32,
1211
- stateRoot: import_configs.ZeroBytes32,
1280
+ balanceRoot: import_configs2.ZeroBytes32,
1281
+ stateRoot: import_configs2.ZeroBytes32,
1212
1282
  txPointer: {
1213
1283
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1214
1284
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1228,8 +1298,8 @@ var inputify = (value) => {
1228
1298
  nonce: (0, import_utils3.hexlify)(value.nonce),
1229
1299
  witnessIndex: value.witnessIndex,
1230
1300
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1231
- predicateLength: predicate.length,
1232
- predicateDataLength: predicateData.length,
1301
+ predicateLength: (0, import_math2.bn)(predicate.length),
1302
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1233
1303
  predicate: (0, import_utils3.hexlify)(predicate),
1234
1304
  predicateData: (0, import_utils3.hexlify)(predicateData),
1235
1305
  data: (0, import_utils3.hexlify)(data),
@@ -1246,7 +1316,7 @@ var inputify = (value) => {
1246
1316
  };
1247
1317
 
1248
1318
  // src/providers/transaction-request/output.ts
1249
- var import_configs2 = require("@fuel-ts/address/configs");
1319
+ var import_configs3 = require("@fuel-ts/address/configs");
1250
1320
  var import_errors4 = require("@fuel-ts/errors");
1251
1321
  var import_math3 = require("@fuel-ts/math");
1252
1322
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1266,8 +1336,8 @@ var outputify = (value) => {
1266
1336
  return {
1267
1337
  type: import_transactions2.OutputType.Contract,
1268
1338
  inputIndex: value.inputIndex,
1269
- balanceRoot: import_configs2.ZeroBytes32,
1270
- stateRoot: import_configs2.ZeroBytes32
1339
+ balanceRoot: import_configs3.ZeroBytes32,
1340
+ stateRoot: import_configs3.ZeroBytes32
1271
1341
  };
1272
1342
  }
1273
1343
  case import_transactions2.OutputType.Change: {
@@ -1281,9 +1351,9 @@ var outputify = (value) => {
1281
1351
  case import_transactions2.OutputType.Variable: {
1282
1352
  return {
1283
1353
  type: import_transactions2.OutputType.Variable,
1284
- to: import_configs2.ZeroBytes32,
1354
+ to: import_configs3.ZeroBytes32,
1285
1355
  amount: (0, import_math3.bn)(0),
1286
- assetId: import_configs2.ZeroBytes32
1356
+ assetId: import_configs3.ZeroBytes32
1287
1357
  };
1288
1358
  }
1289
1359
  case import_transactions2.OutputType.ContractCreated: {
@@ -1304,10 +1374,11 @@ var outputify = (value) => {
1304
1374
 
1305
1375
  // src/providers/transaction-request/transaction-request.ts
1306
1376
  var import_address = require("@fuel-ts/address");
1307
- var import_configs6 = require("@fuel-ts/address/configs");
1377
+ var import_configs7 = require("@fuel-ts/address/configs");
1308
1378
  var import_math7 = require("@fuel-ts/math");
1309
1379
  var import_transactions6 = require("@fuel-ts/transactions");
1310
1380
  var import_utils9 = require("@fuel-ts/utils");
1381
+ var import_ethers = require("ethers");
1311
1382
 
1312
1383
  // src/providers/resource.ts
1313
1384
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1316,13 +1387,13 @@ var isCoin = (resource) => "id" in resource;
1316
1387
  var isMessage = (resource) => "recipient" in resource;
1317
1388
 
1318
1389
  // src/providers/utils/receipts.ts
1319
- var import_configs3 = require("@fuel-ts/address/configs");
1390
+ var import_configs4 = require("@fuel-ts/address/configs");
1320
1391
  var import_errors5 = require("@fuel-ts/errors");
1321
1392
  var import_math4 = require("@fuel-ts/math");
1322
1393
  var import_transactions3 = require("@fuel-ts/transactions");
1323
- var import_configs4 = require("@fuel-ts/transactions/configs");
1394
+ var import_configs5 = require("@fuel-ts/transactions/configs");
1324
1395
  var import_utils5 = require("@fuel-ts/utils");
1325
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1396
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1326
1397
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1327
1398
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1328
1399
  (memo, receipt) => {
@@ -1339,15 +1410,15 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1339
1410
  missingOutputContractIds: []
1340
1411
  }
1341
1412
  );
1342
- var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1413
+ var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1343
1414
  function assembleReceiptByType(receipt) {
1344
1415
  const { receiptType } = receipt;
1345
1416
  switch (receiptType) {
1346
1417
  case "CALL" /* Call */: {
1347
1418
  const callReceipt = {
1348
1419
  type: import_transactions3.ReceiptType.Call,
1349
- from: hexOrZero(receipt.contract?.id),
1350
- to: hexOrZero(receipt?.to?.id),
1420
+ from: hexOrZero(receipt.id || receipt.contractId),
1421
+ to: hexOrZero(receipt?.to),
1351
1422
  amount: (0, import_math4.bn)(receipt.amount),
1352
1423
  assetId: hexOrZero(receipt.assetId),
1353
1424
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1361,7 +1432,7 @@ function assembleReceiptByType(receipt) {
1361
1432
  case "RETURN" /* Return */: {
1362
1433
  const returnReceipt = {
1363
1434
  type: import_transactions3.ReceiptType.Return,
1364
- id: hexOrZero(receipt.contract?.id),
1435
+ id: hexOrZero(receipt.id || receipt.contractId),
1365
1436
  val: (0, import_math4.bn)(receipt.val),
1366
1437
  pc: (0, import_math4.bn)(receipt.pc),
1367
1438
  is: (0, import_math4.bn)(receipt.is)
@@ -1371,7 +1442,7 @@ function assembleReceiptByType(receipt) {
1371
1442
  case "RETURN_DATA" /* ReturnData */: {
1372
1443
  const returnDataReceipt = {
1373
1444
  type: import_transactions3.ReceiptType.ReturnData,
1374
- id: hexOrZero(receipt.contract?.id),
1445
+ id: hexOrZero(receipt.id || receipt.contractId),
1375
1446
  ptr: (0, import_math4.bn)(receipt.ptr),
1376
1447
  len: (0, import_math4.bn)(receipt.len),
1377
1448
  digest: hexOrZero(receipt.digest),
@@ -1383,7 +1454,7 @@ function assembleReceiptByType(receipt) {
1383
1454
  case "PANIC" /* Panic */: {
1384
1455
  const panicReceipt = {
1385
1456
  type: import_transactions3.ReceiptType.Panic,
1386
- id: hexOrZero(receipt.contract?.id),
1457
+ id: hexOrZero(receipt.id),
1387
1458
  reason: (0, import_math4.bn)(receipt.reason),
1388
1459
  pc: (0, import_math4.bn)(receipt.pc),
1389
1460
  is: (0, import_math4.bn)(receipt.is),
@@ -1394,7 +1465,7 @@ function assembleReceiptByType(receipt) {
1394
1465
  case "REVERT" /* Revert */: {
1395
1466
  const revertReceipt = {
1396
1467
  type: import_transactions3.ReceiptType.Revert,
1397
- id: hexOrZero(receipt.contract?.id),
1468
+ id: hexOrZero(receipt.id || receipt.contractId),
1398
1469
  val: (0, import_math4.bn)(receipt.ra),
1399
1470
  pc: (0, import_math4.bn)(receipt.pc),
1400
1471
  is: (0, import_math4.bn)(receipt.is)
@@ -1404,7 +1475,7 @@ function assembleReceiptByType(receipt) {
1404
1475
  case "LOG" /* Log */: {
1405
1476
  const logReceipt = {
1406
1477
  type: import_transactions3.ReceiptType.Log,
1407
- id: hexOrZero(receipt.contract?.id),
1478
+ id: hexOrZero(receipt.id || receipt.contractId),
1408
1479
  val0: (0, import_math4.bn)(receipt.ra),
1409
1480
  val1: (0, import_math4.bn)(receipt.rb),
1410
1481
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1417,7 +1488,7 @@ function assembleReceiptByType(receipt) {
1417
1488
  case "LOG_DATA" /* LogData */: {
1418
1489
  const logDataReceipt = {
1419
1490
  type: import_transactions3.ReceiptType.LogData,
1420
- id: hexOrZero(receipt.contract?.id),
1491
+ id: hexOrZero(receipt.id || receipt.contractId),
1421
1492
  val0: (0, import_math4.bn)(receipt.ra),
1422
1493
  val1: (0, import_math4.bn)(receipt.rb),
1423
1494
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1431,8 +1502,8 @@ function assembleReceiptByType(receipt) {
1431
1502
  case "TRANSFER" /* Transfer */: {
1432
1503
  const transferReceipt = {
1433
1504
  type: import_transactions3.ReceiptType.Transfer,
1434
- from: hexOrZero(receipt.contract?.id),
1435
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1505
+ from: hexOrZero(receipt.id || receipt.contractId),
1506
+ to: hexOrZero(receipt.toAddress || receipt?.to),
1436
1507
  amount: (0, import_math4.bn)(receipt.amount),
1437
1508
  assetId: hexOrZero(receipt.assetId),
1438
1509
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1443,8 +1514,8 @@ function assembleReceiptByType(receipt) {
1443
1514
  case "TRANSFER_OUT" /* TransferOut */: {
1444
1515
  const transferOutReceipt = {
1445
1516
  type: import_transactions3.ReceiptType.TransferOut,
1446
- from: hexOrZero(receipt.contract?.id),
1447
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
1517
+ from: hexOrZero(receipt.id || receipt.contractId),
1518
+ to: hexOrZero(receipt.toAddress || receipt.to),
1448
1519
  amount: (0, import_math4.bn)(receipt.amount),
1449
1520
  assetId: hexOrZero(receipt.assetId),
1450
1521
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1487,7 +1558,7 @@ function assembleReceiptByType(receipt) {
1487
1558
  return receiptMessageOut;
1488
1559
  }
1489
1560
  case "MINT" /* Mint */: {
1490
- const contractId = hexOrZero(receipt.contract?.id);
1561
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1491
1562
  const subId = hexOrZero(receipt.subId);
1492
1563
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1493
1564
  const mintReceipt = {
@@ -1502,7 +1573,7 @@ function assembleReceiptByType(receipt) {
1502
1573
  return mintReceipt;
1503
1574
  }
1504
1575
  case "BURN" /* Burn */: {
1505
- const contractId = hexOrZero(receipt.contract?.id);
1576
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1506
1577
  const subId = hexOrZero(receipt.subId);
1507
1578
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1508
1579
  const burnReceipt = {
@@ -1587,7 +1658,6 @@ var buildBlockExplorerUrl = (options = {}) => {
1587
1658
  var import_math5 = require("@fuel-ts/math");
1588
1659
  var import_transactions4 = require("@fuel-ts/transactions");
1589
1660
  var import_utils6 = require("@fuel-ts/utils");
1590
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1591
1661
  var getGasUsedFromReceipts = (receipts) => {
1592
1662
  const scriptResult = receipts.filter(
1593
1663
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1608,18 +1678,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1608
1678
  }
1609
1679
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1610
1680
  const witnessCache = [];
1611
- const totalGas = inputs.reduce((total, input) => {
1681
+ const chargeableInputs = inputs.filter((input) => {
1682
+ const isCoinOrMessage = "owner" in input || "sender" in input;
1683
+ if (isCoinOrMessage) {
1684
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1685
+ return true;
1686
+ }
1687
+ if (!witnessCache.includes(input.witnessIndex)) {
1688
+ witnessCache.push(input.witnessIndex);
1689
+ return true;
1690
+ }
1691
+ }
1692
+ return false;
1693
+ });
1694
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1695
+ const totalGas = chargeableInputs.reduce((total, input) => {
1612
1696
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1613
1697
  return total.add(
1614
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1698
+ vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1615
1699
  );
1616
1700
  }
1617
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1618
- witnessCache.push(input.witnessIndex);
1619
- return total.add(gasCosts.ecr1);
1620
- }
1621
- return total;
1622
- }, (0, import_math5.bn)());
1701
+ return total.add(gasCosts.ecr1);
1702
+ }, (0, import_math5.bn)(0));
1623
1703
  return totalGas;
1624
1704
  }
1625
1705
  function getMinGas(params) {
@@ -1631,12 +1711,20 @@ function getMinGas(params) {
1631
1711
  return minGas;
1632
1712
  }
1633
1713
  function getMaxGas(params) {
1634
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1714
+ const {
1715
+ gasPerByte,
1716
+ witnessesLength,
1717
+ witnessLimit,
1718
+ minGas,
1719
+ gasLimit = (0, import_math5.bn)(0),
1720
+ maxGasPerTx
1721
+ } = params;
1635
1722
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1636
1723
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1637
1724
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1638
1725
  }
1639
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1726
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1727
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1640
1728
  }
1641
1729
  function calculateMetadataGasForTxCreate({
1642
1730
  gasCosts,
@@ -1658,6 +1746,10 @@ function calculateMetadataGasForTxScript({
1658
1746
  }) {
1659
1747
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1660
1748
  }
1749
+ var calculateGasFee = (params) => {
1750
+ const { gas, gasPrice, priceFactor, tip } = params;
1751
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
1752
+ };
1661
1753
 
1662
1754
  // src/providers/utils/json.ts
1663
1755
  var import_utils7 = require("@fuel-ts/utils");
@@ -1703,16 +1795,16 @@ function sleep(time) {
1703
1795
  var import_errors7 = require("@fuel-ts/errors");
1704
1796
  var import_math6 = require("@fuel-ts/math");
1705
1797
  var import_transactions5 = require("@fuel-ts/transactions");
1706
- var import_configs5 = require("@fuel-ts/transactions/configs");
1798
+ var import_configs6 = require("@fuel-ts/transactions/configs");
1707
1799
  var assemblePanicError = (status) => {
1708
1800
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1709
1801
  const reason = status.reason;
1710
- if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1802
+ if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1711
1803
  errorMessage = `${errorMessage}
1712
1804
 
1713
1805
  You can read more about this error at:
1714
1806
 
1715
- ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1807
+ ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1716
1808
  }
1717
1809
  return { errorMessage, reason };
1718
1810
  };
@@ -1724,28 +1816,28 @@ var assembleRevertError = (receipts, logs) => {
1724
1816
  if (revertReceipt) {
1725
1817
  const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1726
1818
  switch (reasonHex) {
1727
- case import_configs5.FAILED_REQUIRE_SIGNAL: {
1819
+ case import_configs6.FAILED_REQUIRE_SIGNAL: {
1728
1820
  reason = "require";
1729
1821
  errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1730
1822
  break;
1731
1823
  }
1732
- case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
1824
+ case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1733
1825
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1734
1826
  reason = "assert_eq";
1735
1827
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1736
1828
  break;
1737
1829
  }
1738
- case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
1830
+ case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1739
1831
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1740
1832
  reason = "assert_ne";
1741
1833
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1742
1834
  break;
1743
1835
  }
1744
- case import_configs5.FAILED_ASSERT_SIGNAL:
1836
+ case import_configs6.FAILED_ASSERT_SIGNAL:
1745
1837
  reason = "assert";
1746
1838
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1747
1839
  break;
1748
- case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1840
+ case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1749
1841
  reason = "MissingOutputChange";
1750
1842
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1751
1843
  break;
@@ -1806,7 +1898,7 @@ var witnessify = (value) => {
1806
1898
  // src/providers/transaction-request/transaction-request.ts
1807
1899
  var BaseTransactionRequest = class {
1808
1900
  /** Gas price for transaction */
1809
- gasPrice;
1901
+ tip;
1810
1902
  /** Block until which tx cannot be included */
1811
1903
  maturity;
1812
1904
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1819,38 +1911,34 @@ var BaseTransactionRequest = class {
1819
1911
  outputs = [];
1820
1912
  /** List of witnesses */
1821
1913
  witnesses = [];
1822
- /** Base asset ID - should be fetched from the chain */
1823
- baseAssetId;
1824
1914
  /**
1825
1915
  * Constructor for initializing a base transaction request.
1826
1916
  *
1827
1917
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1828
1918
  */
1829
1919
  constructor({
1830
- gasPrice,
1920
+ tip,
1831
1921
  maturity,
1832
1922
  maxFee,
1833
1923
  witnessLimit,
1834
1924
  inputs,
1835
1925
  outputs,
1836
- witnesses,
1837
- baseAssetId
1838
- }) {
1839
- this.gasPrice = (0, import_math7.bn)(gasPrice);
1926
+ witnesses
1927
+ } = {}) {
1928
+ this.tip = (0, import_math7.bn)(tip);
1840
1929
  this.maturity = maturity ?? 0;
1841
1930
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1842
1931
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1843
1932
  this.inputs = inputs ?? [];
1844
1933
  this.outputs = outputs ?? [];
1845
1934
  this.witnesses = witnesses ?? [];
1846
- this.baseAssetId = baseAssetId;
1847
1935
  }
1848
1936
  static getPolicyMeta(req) {
1849
1937
  let policyTypes = 0;
1850
1938
  const policies = [];
1851
- if (req.gasPrice) {
1852
- policyTypes += import_transactions6.PolicyType.GasPrice;
1853
- policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1939
+ if (req.tip) {
1940
+ policyTypes += import_transactions6.PolicyType.Tip;
1941
+ policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1854
1942
  }
1855
1943
  if (req.witnessLimit) {
1856
1944
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -1936,7 +2024,7 @@ var BaseTransactionRequest = class {
1936
2024
  * @returns The index of the created witness.
1937
2025
  */
1938
2026
  addEmptyWitness() {
1939
- this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
2027
+ this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1940
2028
  return this.witnesses.length - 1;
1941
2029
  }
1942
2030
  /**
@@ -2037,10 +2125,10 @@ var BaseTransactionRequest = class {
2037
2125
  * @param predicate - Predicate bytes.
2038
2126
  * @param predicateData - Predicate data bytes.
2039
2127
  */
2040
- addCoinInput(coin, predicate) {
2128
+ addCoinInput(coin) {
2041
2129
  const { assetId, owner, amount } = coin;
2042
2130
  let witnessIndex;
2043
- if (predicate) {
2131
+ if (coin.predicate) {
2044
2132
  witnessIndex = 0;
2045
2133
  } else {
2046
2134
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2055,8 +2143,7 @@ var BaseTransactionRequest = class {
2055
2143
  amount,
2056
2144
  assetId,
2057
2145
  txPointer: "0x00000000000000000000000000000000",
2058
- witnessIndex,
2059
- predicate: predicate?.bytes
2146
+ witnessIndex
2060
2147
  };
2061
2148
  this.pushInput(input);
2062
2149
  this.addChangeOutput(owner, assetId);
@@ -2067,11 +2154,13 @@ var BaseTransactionRequest = class {
2067
2154
  *
2068
2155
  * @param message - Message resource.
2069
2156
  * @param predicate - Predicate bytes.
2157
+ * @param predicateData - Predicate data bytes.
2070
2158
  */
2071
- addMessageInput(message, predicate) {
2159
+ addMessageInput(message) {
2072
2160
  const { recipient, sender, amount } = message;
2161
+ const assetId = import_configs7.BaseAssetId;
2073
2162
  let witnessIndex;
2074
- if (predicate) {
2163
+ if (message.predicate) {
2075
2164
  witnessIndex = 0;
2076
2165
  } else {
2077
2166
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2085,11 +2174,10 @@ var BaseTransactionRequest = class {
2085
2174
  sender: sender.toB256(),
2086
2175
  recipient: recipient.toB256(),
2087
2176
  amount,
2088
- witnessIndex,
2089
- predicate: predicate?.bytes
2177
+ witnessIndex
2090
2178
  };
2091
2179
  this.pushInput(input);
2092
- this.addChangeOutput(recipient, this.baseAssetId);
2180
+ this.addChangeOutput(recipient, assetId);
2093
2181
  }
2094
2182
  /**
2095
2183
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2117,32 +2205,6 @@ var BaseTransactionRequest = class {
2117
2205
  resources.forEach((resource) => this.addResource(resource));
2118
2206
  return this;
2119
2207
  }
2120
- /**
2121
- * Adds multiple resources to the transaction by adding coin/message inputs and change
2122
- * outputs from the related assetIds.
2123
- *
2124
- * @param resources - The resources to add.
2125
- * @returns This transaction.
2126
- */
2127
- addPredicateResource(resource, predicate) {
2128
- if (isCoin(resource)) {
2129
- this.addCoinInput(resource, predicate);
2130
- } else {
2131
- this.addMessageInput(resource, predicate);
2132
- }
2133
- return this;
2134
- }
2135
- /**
2136
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
2137
- * from the related assetIds.
2138
- *
2139
- * @param resources - The resources to add.
2140
- * @returns This transaction.
2141
- */
2142
- addPredicateResources(resources, predicate) {
2143
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2144
- return this;
2145
- }
2146
2208
  /**
2147
2209
  * Adds a coin output to the transaction.
2148
2210
  *
@@ -2150,12 +2212,12 @@ var BaseTransactionRequest = class {
2150
2212
  * @param amount - Amount of coin.
2151
2213
  * @param assetId - Asset ID of coin.
2152
2214
  */
2153
- addCoinOutput(to, amount, assetId) {
2215
+ addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2154
2216
  this.pushOutput({
2155
2217
  type: import_transactions6.OutputType.Coin,
2156
2218
  to: (0, import_address.addressify)(to).toB256(),
2157
2219
  amount,
2158
- assetId: assetId ?? this.baseAssetId
2220
+ assetId
2159
2221
  });
2160
2222
  return this;
2161
2223
  }
@@ -2182,7 +2244,7 @@ var BaseTransactionRequest = class {
2182
2244
  * @param to - Address of the owner.
2183
2245
  * @param assetId - Asset ID of coin.
2184
2246
  */
2185
- addChangeOutput(to, assetId) {
2247
+ addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2186
2248
  const changeOutput = this.getChangeOutputs().find(
2187
2249
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2188
2250
  );
@@ -2190,7 +2252,7 @@ var BaseTransactionRequest = class {
2190
2252
  this.pushOutput({
2191
2253
  type: import_transactions6.OutputType.Change,
2192
2254
  to: (0, import_address.addressify)(to).toB256(),
2193
- assetId: assetId ?? this.baseAssetId
2255
+ assetId
2194
2256
  });
2195
2257
  }
2196
2258
  }
@@ -2222,7 +2284,7 @@ var BaseTransactionRequest = class {
2222
2284
  }
2223
2285
  calculateMaxGas(chainInfo, minGas) {
2224
2286
  const { consensusParameters } = chainInfo;
2225
- const { gasPerByte } = consensusParameters;
2287
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2226
2288
  const witnessesLength = this.toTransaction().witnesses.reduce(
2227
2289
  (acc, wit) => acc + wit.dataLength,
2228
2290
  0
@@ -2231,7 +2293,8 @@ var BaseTransactionRequest = class {
2231
2293
  gasPerByte,
2232
2294
  minGas,
2233
2295
  witnessesLength,
2234
- witnessLimit: this.witnessLimit
2296
+ witnessLimit: this.witnessLimit,
2297
+ maxGasPerTx
2235
2298
  });
2236
2299
  }
2237
2300
  /**
@@ -2241,12 +2304,6 @@ var BaseTransactionRequest = class {
2241
2304
  * @param quantities - CoinQuantity Array.
2242
2305
  */
2243
2306
  fundWithFakeUtxos(quantities, resourcesOwner) {
2244
- let idCounter = 0;
2245
- const generateId = () => {
2246
- const counterString = String(idCounter++);
2247
- const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2248
- return id;
2249
- };
2250
2307
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2251
2308
  if ("assetId" in input) {
2252
2309
  return input.assetId === assetId;
@@ -2255,24 +2312,27 @@ var BaseTransactionRequest = class {
2255
2312
  });
2256
2313
  const updateAssetInput = (assetId, quantity) => {
2257
2314
  const assetInput = findAssetInput(assetId);
2315
+ let usedQuantity = quantity;
2316
+ if (assetId === import_configs7.BaseAssetId) {
2317
+ usedQuantity = (0, import_math7.bn)("1000000000000000000");
2318
+ }
2258
2319
  if (assetInput && "assetId" in assetInput) {
2259
- assetInput.id = generateId();
2260
- assetInput.amount = quantity;
2320
+ assetInput.id = (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34));
2321
+ assetInput.amount = usedQuantity;
2261
2322
  } else {
2262
2323
  this.addResources([
2263
2324
  {
2264
- id: generateId(),
2265
- amount: quantity,
2325
+ id: (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34)),
2326
+ amount: usedQuantity,
2266
2327
  assetId,
2267
2328
  owner: resourcesOwner || import_address.Address.fromRandom(),
2268
- maturity: 0,
2269
2329
  blockCreated: (0, import_math7.bn)(1),
2270
2330
  txCreatedIdx: (0, import_math7.bn)(1)
2271
2331
  }
2272
2332
  ]);
2273
2333
  }
2274
2334
  };
2275
- updateAssetInput(this.baseAssetId, (0, import_math7.bn)(1e11));
2335
+ updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2276
2336
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2277
2337
  }
2278
2338
  /**
@@ -2297,7 +2357,7 @@ var BaseTransactionRequest = class {
2297
2357
  toJSON() {
2298
2358
  return normalizeJSON(this);
2299
2359
  }
2300
- updatePredicateInputs(inputs) {
2360
+ updatePredicateGasUsed(inputs) {
2301
2361
  this.inputs.forEach((i) => {
2302
2362
  let correspondingInput;
2303
2363
  switch (i.type) {
@@ -2319,16 +2379,25 @@ var BaseTransactionRequest = class {
2319
2379
  }
2320
2380
  });
2321
2381
  }
2382
+ shiftPredicateData() {
2383
+ this.inputs.forEach((input) => {
2384
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2385
+ input.predicateData = input.paddPredicateData(
2386
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2387
+ );
2388
+ }
2389
+ });
2390
+ }
2322
2391
  };
2323
2392
 
2324
2393
  // src/providers/transaction-request/create-transaction-request.ts
2325
- var import_configs8 = require("@fuel-ts/address/configs");
2394
+ var import_configs9 = require("@fuel-ts/address/configs");
2326
2395
  var import_math9 = require("@fuel-ts/math");
2327
2396
  var import_transactions8 = require("@fuel-ts/transactions");
2328
2397
  var import_utils13 = require("@fuel-ts/utils");
2329
2398
 
2330
2399
  // src/providers/transaction-request/hash-transaction.ts
2331
- var import_configs7 = require("@fuel-ts/address/configs");
2400
+ var import_configs8 = require("@fuel-ts/address/configs");
2332
2401
  var import_hasher = require("@fuel-ts/hasher");
2333
2402
  var import_math8 = require("@fuel-ts/math");
2334
2403
  var import_transactions7 = require("@fuel-ts/transactions");
@@ -2337,7 +2406,7 @@ var import_ramda2 = require("ramda");
2337
2406
  function hashTransaction(transactionRequest, chainId) {
2338
2407
  const transaction = transactionRequest.toTransaction();
2339
2408
  if (transaction.type === import_transactions7.TransactionType.Script) {
2340
- transaction.receiptsRoot = import_configs7.ZeroBytes32;
2409
+ transaction.receiptsRoot = import_configs8.ZeroBytes32;
2341
2410
  }
2342
2411
  transaction.inputs = transaction.inputs.map((input) => {
2343
2412
  const inputClone = (0, import_ramda2.clone)(input);
@@ -2359,10 +2428,10 @@ function hashTransaction(transactionRequest, chainId) {
2359
2428
  blockHeight: 0,
2360
2429
  txIndex: 0
2361
2430
  };
2362
- inputClone.txID = import_configs7.ZeroBytes32;
2431
+ inputClone.txID = import_configs8.ZeroBytes32;
2363
2432
  inputClone.outputIndex = 0;
2364
- inputClone.balanceRoot = import_configs7.ZeroBytes32;
2365
- inputClone.stateRoot = import_configs7.ZeroBytes32;
2433
+ inputClone.balanceRoot = import_configs8.ZeroBytes32;
2434
+ inputClone.stateRoot = import_configs8.ZeroBytes32;
2366
2435
  return inputClone;
2367
2436
  }
2368
2437
  default:
@@ -2373,8 +2442,8 @@ function hashTransaction(transactionRequest, chainId) {
2373
2442
  const outputClone = (0, import_ramda2.clone)(output);
2374
2443
  switch (outputClone.type) {
2375
2444
  case import_transactions7.OutputType.Contract: {
2376
- outputClone.balanceRoot = import_configs7.ZeroBytes32;
2377
- outputClone.stateRoot = import_configs7.ZeroBytes32;
2445
+ outputClone.balanceRoot = import_configs8.ZeroBytes32;
2446
+ outputClone.stateRoot = import_configs8.ZeroBytes32;
2378
2447
  return outputClone;
2379
2448
  }
2380
2449
  case import_transactions7.OutputType.Change: {
@@ -2382,9 +2451,9 @@ function hashTransaction(transactionRequest, chainId) {
2382
2451
  return outputClone;
2383
2452
  }
2384
2453
  case import_transactions7.OutputType.Variable: {
2385
- outputClone.to = import_configs7.ZeroBytes32;
2454
+ outputClone.to = import_configs8.ZeroBytes32;
2386
2455
  outputClone.amount = (0, import_math8.bn)(0);
2387
- outputClone.assetId = import_configs7.ZeroBytes32;
2456
+ outputClone.assetId = import_configs8.ZeroBytes32;
2388
2457
  return outputClone;
2389
2458
  }
2390
2459
  default:
@@ -2442,10 +2511,15 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2442
2511
  *
2443
2512
  * @param createTransactionRequestLike - The initial values for the instance
2444
2513
  */
2445
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2514
+ constructor({
2515
+ bytecodeWitnessIndex,
2516
+ salt,
2517
+ storageSlots,
2518
+ ...rest
2519
+ } = {}) {
2446
2520
  super(rest);
2447
2521
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2448
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2522
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2449
2523
  this.storageSlots = [...storageSlots ?? []];
2450
2524
  }
2451
2525
  /**
@@ -2460,10 +2534,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2460
2534
  return {
2461
2535
  type: import_transactions8.TransactionType.Create,
2462
2536
  ...baseTransaction,
2463
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2464
2537
  bytecodeWitnessIndex,
2465
- storageSlotsCount: storageSlots.length,
2466
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2538
+ storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2539
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2467
2540
  storageSlots
2468
2541
  };
2469
2542
  }
@@ -2513,7 +2586,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2513
2586
  // src/providers/transaction-request/script-transaction-request.ts
2514
2587
  var import_abi_coder = require("@fuel-ts/abi-coder");
2515
2588
  var import_address2 = require("@fuel-ts/address");
2516
- var import_configs9 = require("@fuel-ts/address/configs");
2589
+ var import_configs10 = require("@fuel-ts/address/configs");
2517
2590
  var import_math10 = require("@fuel-ts/math");
2518
2591
  var import_transactions9 = require("@fuel-ts/transactions");
2519
2592
  var import_utils15 = require("@fuel-ts/utils");
@@ -2566,7 +2639,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2566
2639
  *
2567
2640
  * @param scriptTransactionRequestLike - The initial values for the instance.
2568
2641
  */
2569
- constructor({ script, scriptData, gasLimit, ...rest }) {
2642
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2570
2643
  super(rest);
2571
2644
  this.gasLimit = (0, import_math10.bn)(gasLimit);
2572
2645
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
@@ -2585,9 +2658,9 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2585
2658
  type: import_transactions9.TransactionType.Script,
2586
2659
  scriptGasLimit: this.gasLimit,
2587
2660
  ...super.getBaseTransaction(),
2588
- scriptLength: script.length,
2589
- scriptDataLength: scriptData.length,
2590
- receiptsRoot: import_configs9.ZeroBytes32,
2661
+ scriptLength: (0, import_math10.bn)(script.length),
2662
+ scriptDataLength: (0, import_math10.bn)(scriptData.length),
2663
+ receiptsRoot: import_configs10.ZeroBytes32,
2591
2664
  script: (0, import_utils15.hexlify)(script),
2592
2665
  scriptData: (0, import_utils15.hexlify)(scriptData)
2593
2666
  };
@@ -2650,7 +2723,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2650
2723
  }
2651
2724
  calculateMaxGas(chainInfo, minGas) {
2652
2725
  const { consensusParameters } = chainInfo;
2653
- const { gasPerByte } = consensusParameters;
2726
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2654
2727
  const witnessesLength = this.toTransaction().witnesses.reduce(
2655
2728
  (acc, wit) => acc + wit.dataLength,
2656
2729
  0
@@ -2660,7 +2733,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2660
2733
  minGas,
2661
2734
  witnessesLength,
2662
2735
  witnessLimit: this.witnessLimit,
2663
- gasLimit: this.gasLimit
2736
+ gasLimit: this.gasLimit,
2737
+ maxGasPerTx
2664
2738
  });
2665
2739
  }
2666
2740
  /**
@@ -2735,15 +2809,32 @@ var transactionRequestify = (obj) => {
2735
2809
  }
2736
2810
  }
2737
2811
  };
2812
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2813
+ (acc, input) => {
2814
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2815
+ acc.utxos.push(input.id);
2816
+ }
2817
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2818
+ acc.messages.push(input.nonce);
2819
+ }
2820
+ return acc;
2821
+ },
2822
+ {
2823
+ utxos: [],
2824
+ messages: []
2825
+ }
2826
+ );
2738
2827
 
2739
2828
  // src/providers/transaction-response/transaction-response.ts
2740
2829
  var import_errors13 = require("@fuel-ts/errors");
2741
- var import_math14 = require("@fuel-ts/math");
2742
- var import_transactions17 = require("@fuel-ts/transactions");
2743
- var import_utils21 = require("@fuel-ts/utils");
2830
+ var import_math15 = require("@fuel-ts/math");
2831
+ var import_transactions18 = require("@fuel-ts/transactions");
2832
+ var import_utils20 = require("@fuel-ts/utils");
2744
2833
 
2745
2834
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2746
- var import_utils19 = require("@fuel-ts/utils");
2835
+ var import_math14 = require("@fuel-ts/math");
2836
+ var import_transactions16 = require("@fuel-ts/transactions");
2837
+ var import_utils18 = require("@fuel-ts/utils");
2747
2838
 
2748
2839
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2749
2840
  var import_math11 = require("@fuel-ts/math");
@@ -2751,9 +2842,10 @@ var import_transactions11 = require("@fuel-ts/transactions");
2751
2842
  var import_utils16 = require("@fuel-ts/utils");
2752
2843
  var calculateTransactionFee = (params) => {
2753
2844
  const {
2754
- gasUsed,
2845
+ gasPrice,
2755
2846
  rawPayload,
2756
- consensusParameters: { gasCosts, feeParams }
2847
+ tip,
2848
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2757
2849
  } = params;
2758
2850
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2759
2851
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2763,8 +2855,7 @@ var calculateTransactionFee = (params) => {
2763
2855
  return {
2764
2856
  fee: (0, import_math11.bn)(0),
2765
2857
  minFee: (0, import_math11.bn)(0),
2766
- maxFee: (0, import_math11.bn)(0),
2767
- feeFromGasUsed: (0, import_math11.bn)(0)
2858
+ maxFee: (0, import_math11.bn)(0)
2768
2859
  };
2769
2860
  }
2770
2861
  const { type, witnesses, inputs, policies } = transaction;
@@ -2796,7 +2887,6 @@ var calculateTransactionFee = (params) => {
2796
2887
  metadataGas,
2797
2888
  txBytesSize: transactionBytes.length
2798
2889
  });
2799
- const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2800
2890
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2801
2891
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2802
2892
  const maxGas = getMaxGas({
@@ -2804,22 +2894,30 @@ var calculateTransactionFee = (params) => {
2804
2894
  minGas,
2805
2895
  witnessesLength,
2806
2896
  gasLimit,
2807
- witnessLimit
2897
+ witnessLimit,
2898
+ maxGasPerTx
2899
+ });
2900
+ const minFee = calculateGasFee({
2901
+ gasPrice,
2902
+ gas: minGas,
2903
+ priceFactor: gasPriceFactor,
2904
+ tip
2905
+ });
2906
+ const maxFee = calculateGasFee({
2907
+ gasPrice,
2908
+ gas: maxGas,
2909
+ priceFactor: gasPriceFactor,
2910
+ tip
2808
2911
  });
2809
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2810
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2811
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2812
- const fee = minFee.add(feeFromGasUsed);
2813
2912
  return {
2814
- fee,
2815
2913
  minFee,
2816
2914
  maxFee,
2817
- feeFromGasUsed
2915
+ fee: maxFee
2818
2916
  };
2819
2917
  };
2820
2918
 
2821
2919
  // src/providers/transaction-summary/operations.ts
2822
- var import_configs10 = require("@fuel-ts/address/configs");
2920
+ var import_configs11 = require("@fuel-ts/address/configs");
2823
2921
  var import_errors11 = require("@fuel-ts/errors");
2824
2922
  var import_math13 = require("@fuel-ts/math");
2825
2923
  var import_transactions14 = require("@fuel-ts/transactions");
@@ -3164,7 +3262,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3164
3262
  const { to: toAddress, assetId, amount } = receipt;
3165
3263
  let { from: fromAddress } = receipt;
3166
3264
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3167
- if (import_configs10.ZeroBytes32 === fromAddress) {
3265
+ if (import_configs11.ZeroBytes32 === fromAddress) {
3168
3266
  const change = changeOutputs.find((output) => output.assetId === assetId);
3169
3267
  fromAddress = change?.to || fromAddress;
3170
3268
  }
@@ -3428,10 +3526,12 @@ function assembleTransactionSummary(params) {
3428
3526
  gqlTransactionStatus,
3429
3527
  abiMap = {},
3430
3528
  maxInputs,
3431
- gasCosts
3529
+ gasCosts,
3530
+ maxGasPerTx,
3531
+ gasPrice
3432
3532
  } = params;
3433
3533
  const gasUsed = getGasUsedFromReceipts(receipts);
3434
- const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3534
+ const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3435
3535
  const operations = getOperations({
3436
3536
  transactionType: transaction.type,
3437
3537
  inputs: transaction.inputs || [],
@@ -3442,11 +3542,14 @@ function assembleTransactionSummary(params) {
3442
3542
  maxInputs
3443
3543
  });
3444
3544
  const typeName = getTransactionTypeName(transaction.type);
3545
+ const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3445
3546
  const { fee } = calculateTransactionFee({
3446
- gasUsed,
3547
+ gasPrice,
3447
3548
  rawPayload,
3549
+ tip,
3448
3550
  consensusParameters: {
3449
3551
  gasCosts,
3552
+ maxGasPerTx,
3450
3553
  feeParams: {
3451
3554
  gasPerByte,
3452
3555
  gasPriceFactor
@@ -3458,7 +3561,7 @@ function assembleTransactionSummary(params) {
3458
3561
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3459
3562
  let date;
3460
3563
  if (time) {
3461
- date = import_utils19.DateTime.fromTai64(time);
3564
+ date = import_utils18.DateTime.fromTai64(time);
3462
3565
  }
3463
3566
  const transactionSummary = {
3464
3567
  id,
@@ -3486,12 +3589,12 @@ function assembleTransactionSummary(params) {
3486
3589
 
3487
3590
  // src/providers/transaction-response/getDecodedLogs.ts
3488
3591
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
3489
- var import_transactions16 = require("@fuel-ts/transactions");
3592
+ var import_transactions17 = require("@fuel-ts/transactions");
3490
3593
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3491
3594
  return receipts.reduce((logs, receipt) => {
3492
- if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3595
+ if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3493
3596
  const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3494
- const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3597
+ const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3495
3598
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3496
3599
  logs.push(decodedLog);
3497
3600
  }
@@ -3506,7 +3609,7 @@ var TransactionResponse = class {
3506
3609
  /** Current provider */
3507
3610
  provider;
3508
3611
  /** Gas used on the transaction */
3509
- gasUsed = (0, import_math14.bn)(0);
3612
+ gasUsed = (0, import_math15.bn)(0);
3510
3613
  /** The graphql Transaction with receipts object. */
3511
3614
  gqlTransaction;
3512
3615
  abis;
@@ -3564,8 +3667,8 @@ var TransactionResponse = class {
3564
3667
  * @returns The decoded transaction.
3565
3668
  */
3566
3669
  decodeTransaction(transactionWithReceipts) {
3567
- return new import_transactions17.TransactionCoder().decode(
3568
- (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3670
+ return new import_transactions18.TransactionCoder().decode(
3671
+ (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3569
3672
  0
3570
3673
  )?.[0];
3571
3674
  }
@@ -3584,20 +3687,27 @@ var TransactionResponse = class {
3584
3687
  const decodedTransaction = this.decodeTransaction(
3585
3688
  transaction
3586
3689
  );
3587
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3588
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3690
+ let txReceipts = [];
3691
+ if (transaction?.status && "receipts" in transaction.status) {
3692
+ txReceipts = transaction.status.receipts;
3693
+ }
3694
+ const receipts = txReceipts.map(processGqlReceipt) || [];
3695
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3696
+ const gasPrice = await this.provider.getLatestGasPrice();
3589
3697
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3590
3698
  const transactionSummary = assembleTransactionSummary({
3591
3699
  id: this.id,
3592
3700
  receipts,
3593
3701
  transaction: decodedTransaction,
3594
- transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3702
+ transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3595
3703
  gqlTransactionStatus: transaction.status,
3596
3704
  gasPerByte,
3597
3705
  gasPriceFactor,
3598
3706
  abiMap: contractsAbiMap,
3599
3707
  maxInputs,
3600
- gasCosts
3708
+ gasCosts,
3709
+ maxGasPerTx,
3710
+ gasPrice
3601
3711
  });
3602
3712
  return transactionSummary;
3603
3713
  }
@@ -3724,30 +3834,29 @@ var processGqlChain = (chain) => {
3724
3834
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3725
3835
  return {
3726
3836
  name,
3727
- baseChainHeight: (0, import_math15.bn)(daHeight),
3837
+ baseChainHeight: (0, import_math16.bn)(daHeight),
3728
3838
  consensusParameters: {
3729
- contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3730
- maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3731
- maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3732
- maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3733
- maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3734
- maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3735
- maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3736
- maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3737
- maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3738
- maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3739
- maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3740
- gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3741
- gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3742
- maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3743
- chainId: (0, import_math15.bn)(consensusParameters.chainId),
3744
- baseAssetId: consensusParameters.baseAssetId,
3839
+ contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3840
+ maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3841
+ maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3842
+ maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3843
+ maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3844
+ maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3845
+ maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3846
+ maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3847
+ maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3848
+ maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3849
+ maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3850
+ gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3851
+ gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3852
+ maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3853
+ chainId: (0, import_math16.bn)(consensusParameters.chainId),
3745
3854
  gasCosts
3746
3855
  },
3747
3856
  gasCosts,
3748
3857
  latestBlock: {
3749
3858
  id: latestBlock.id,
3750
- height: (0, import_math15.bn)(latestBlock.header.height),
3859
+ height: (0, import_math16.bn)(latestBlock.height),
3751
3860
  time: latestBlock.header.time,
3752
3861
  transactions: latestBlock.transactions.map((i) => ({
3753
3862
  id: i.id
@@ -3841,10 +3950,8 @@ var _Provider = class {
3841
3950
  * Returns some helpful parameters related to gas fees.
3842
3951
  */
3843
3952
  getGasConfig() {
3844
- const { minGasPrice } = this.getNode();
3845
3953
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3846
3954
  return {
3847
- minGasPrice,
3848
3955
  maxGasPerTx,
3849
3956
  maxGasPerPredicate,
3850
3957
  gasPriceFactor,
@@ -3932,7 +4039,7 @@ var _Provider = class {
3932
4039
  name,
3933
4040
  consensusParameters: { chainId }
3934
4041
  } = await this.getChain();
3935
- const network = new import_ethers.Network(name, chainId.toNumber());
4042
+ const network = new import_ethers2.Network(name, chainId.toNumber());
3936
4043
  return Promise.resolve(network);
3937
4044
  }
3938
4045
  /**
@@ -3942,7 +4049,7 @@ var _Provider = class {
3942
4049
  */
3943
4050
  async getBlockNumber() {
3944
4051
  const { chain } = await this.operations.getChain();
3945
- return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4052
+ return (0, import_math16.bn)(chain.latestBlock.height, 10);
3946
4053
  }
3947
4054
  /**
3948
4055
  * Returns the chain information.
@@ -3952,13 +4059,11 @@ var _Provider = class {
3952
4059
  async fetchNode() {
3953
4060
  const { nodeInfo } = await this.operations.getNodeInfo();
3954
4061
  const processedNodeInfo = {
3955
- maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3956
- maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3957
- minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4062
+ maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4063
+ maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3958
4064
  nodeVersion: nodeInfo.nodeVersion,
3959
4065
  utxoValidation: nodeInfo.utxoValidation,
3960
- vmBacktrace: nodeInfo.vmBacktrace,
3961
- peers: nodeInfo.peers
4066
+ vmBacktrace: nodeInfo.vmBacktrace
3962
4067
  };
3963
4068
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3964
4069
  return processedNodeInfo;
@@ -3984,17 +4089,6 @@ var _Provider = class {
3984
4089
  } = this.getChain();
3985
4090
  return chainId.toNumber();
3986
4091
  }
3987
- /**
3988
- * Returns the base asset ID
3989
- *
3990
- * @returns A promise that resolves to the base asset ID
3991
- */
3992
- getBaseAssetId() {
3993
- const {
3994
- consensusParameters: { baseAssetId }
3995
- } = this.getChain();
3996
- return baseAssetId;
3997
- }
3998
4092
  /**
3999
4093
  * Submits a transaction to the chain to be executed.
4000
4094
  *
@@ -4011,9 +4105,9 @@ var _Provider = class {
4011
4105
  if (estimateTxDependencies) {
4012
4106
  await this.estimateTxDependencies(transactionRequest);
4013
4107
  }
4014
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4108
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4015
4109
  let abis;
4016
- if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4110
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4017
4111
  abis = transactionRequest.abis;
4018
4112
  }
4019
4113
  if (awaitExecution) {
@@ -4054,15 +4148,14 @@ var _Provider = class {
4054
4148
  if (estimateTxDependencies) {
4055
4149
  return this.estimateTxDependencies(transactionRequest);
4056
4150
  }
4057
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4058
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4059
- encodedTransaction,
4151
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4152
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4153
+ encodedTransactions: encodedTransaction,
4060
4154
  utxoValidation: utxoValidation || false
4061
4155
  });
4062
- const receipts = gqlReceipts.map(processGqlReceipt);
4063
- return {
4064
- receipts
4065
- };
4156
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4157
+ const receipts = rawReceipts.map(processGqlReceipt);
4158
+ return { receipts, dryrunStatus: status };
4066
4159
  }
4067
4160
  /**
4068
4161
  * Verifies whether enough gas is available to complete transaction.
@@ -4073,13 +4166,13 @@ var _Provider = class {
4073
4166
  async estimatePredicates(transactionRequest) {
4074
4167
  const shouldEstimatePredicates = Boolean(
4075
4168
  transactionRequest.inputs.find(
4076
- (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()
4169
+ (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()
4077
4170
  )
4078
4171
  );
4079
4172
  if (!shouldEstimatePredicates) {
4080
4173
  return transactionRequest;
4081
4174
  }
4082
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4175
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4083
4176
  const response = await this.operations.estimatePredicates({
4084
4177
  encodedTransaction
4085
4178
  });
@@ -4088,7 +4181,7 @@ var _Provider = class {
4088
4181
  } = response;
4089
4182
  if (inputs) {
4090
4183
  inputs.forEach((input, index) => {
4091
- if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4184
+ if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4092
4185
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4093
4186
  }
4094
4187
  });
@@ -4101,31 +4194,31 @@ var _Provider = class {
4101
4194
  * If there are missing variable outputs,
4102
4195
  * `addVariableOutputs` is called on the transaction.
4103
4196
  *
4104
- * @privateRemarks
4105
- * TODO: Investigate support for missing contract IDs
4106
- * TODO: Add support for missing output messages
4107
4197
  *
4108
4198
  * @param transactionRequest - The transaction request object.
4109
4199
  * @returns A promise.
4110
4200
  */
4111
4201
  async estimateTxDependencies(transactionRequest) {
4112
- if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4202
+ if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4113
4203
  return {
4114
4204
  receipts: [],
4115
4205
  outputVariables: 0,
4116
4206
  missingContractIds: []
4117
4207
  };
4118
4208
  }
4119
- await this.estimatePredicates(transactionRequest);
4120
4209
  let receipts = [];
4121
4210
  const missingContractIds = [];
4122
4211
  let outputVariables = 0;
4212
+ let dryrunStatus;
4123
4213
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4124
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4125
- encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4214
+ const {
4215
+ dryRun: [{ receipts: rawReceipts, status }]
4216
+ } = await this.operations.dryRun({
4217
+ encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4126
4218
  utxoValidation: false
4127
4219
  });
4128
- receipts = gqlReceipts.map(processGqlReceipt);
4220
+ receipts = rawReceipts.map(processGqlReceipt);
4221
+ dryrunStatus = status;
4129
4222
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4130
4223
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4131
4224
  if (hasMissingOutputs) {
@@ -4135,6 +4228,11 @@ var _Provider = class {
4135
4228
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4136
4229
  missingContractIds.push(contractId);
4137
4230
  });
4231
+ const { maxFee } = await this.estimateTxGasAndFee({
4232
+ transactionRequest,
4233
+ optimizeGas: false
4234
+ });
4235
+ transactionRequest.maxFee = maxFee;
4138
4236
  } else {
4139
4237
  break;
4140
4238
  }
@@ -4142,7 +4240,133 @@ var _Provider = class {
4142
4240
  return {
4143
4241
  receipts,
4144
4242
  outputVariables,
4145
- missingContractIds
4243
+ missingContractIds,
4244
+ dryrunStatus
4245
+ };
4246
+ }
4247
+ /**
4248
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
4249
+ *
4250
+ * Transactions are dry run in batches. After each dry run, transactions requiring
4251
+ * further modifications are identified. The method iteratively updates these transactions
4252
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4253
+ *
4254
+ * @param transactionRequests - Array of transaction request objects.
4255
+ * @returns A promise that resolves to an array of results for each transaction.
4256
+ */
4257
+ async estimateMultipleTxDependencies(transactionRequests) {
4258
+ const results = transactionRequests.map(() => ({
4259
+ receipts: [],
4260
+ outputVariables: 0,
4261
+ missingContractIds: [],
4262
+ dryrunStatus: void 0
4263
+ }));
4264
+ const allRequests = (0, import_ramda3.clone)(transactionRequests);
4265
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
4266
+ allRequests.forEach((req, index) => {
4267
+ if (req.type === import_transactions19.TransactionType.Script) {
4268
+ serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4269
+ }
4270
+ });
4271
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4272
+ let attempt = 0;
4273
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4274
+ const encodedTransactions = transactionsToProcess.map(
4275
+ (index) => serializedTransactionsMap.get(index)
4276
+ );
4277
+ const dryRunResults = await this.operations.dryRun({
4278
+ encodedTransactions,
4279
+ utxoValidation: false
4280
+ });
4281
+ const nextRoundTransactions = [];
4282
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4283
+ const currentResultIndex = transactionsToProcess[i];
4284
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4285
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4286
+ results[currentResultIndex].dryrunStatus = status;
4287
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4288
+ results[currentResultIndex].receipts
4289
+ );
4290
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4291
+ const requestToProcess = allRequests[currentResultIndex];
4292
+ if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4293
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
4294
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
4295
+ missingOutputContractIds.forEach(({ contractId }) => {
4296
+ requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4297
+ results[currentResultIndex].missingContractIds.push(contractId);
4298
+ });
4299
+ const { maxFee } = await this.estimateTxGasAndFee({
4300
+ transactionRequest: requestToProcess,
4301
+ optimizeGas: false
4302
+ });
4303
+ requestToProcess.maxFee = maxFee;
4304
+ serializedTransactionsMap.set(
4305
+ currentResultIndex,
4306
+ (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4307
+ );
4308
+ nextRoundTransactions.push(currentResultIndex);
4309
+ allRequests[currentResultIndex] = requestToProcess;
4310
+ }
4311
+ }
4312
+ transactionsToProcess = nextRoundTransactions;
4313
+ attempt += 1;
4314
+ }
4315
+ return results;
4316
+ }
4317
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4318
+ if (estimateTxDependencies) {
4319
+ return this.estimateMultipleTxDependencies(transactionRequests);
4320
+ }
4321
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4322
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4323
+ encodedTransactions,
4324
+ utxoValidation: utxoValidation || false
4325
+ });
4326
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4327
+ const receipts = rawReceipts.map(processGqlReceipt);
4328
+ return { receipts, dryrunStatus: status };
4329
+ });
4330
+ return results;
4331
+ }
4332
+ async estimateTxGasAndFee(params) {
4333
+ const { transactionRequest, optimizeGas = true } = params;
4334
+ let { gasPrice } = params;
4335
+ const chainInfo = this.getChain();
4336
+ const { gasPriceFactor } = this.getGasConfig();
4337
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4338
+ if (!gasPrice) {
4339
+ gasPrice = await this.estimateGasPrice(10);
4340
+ }
4341
+ const minFee = calculateGasFee({
4342
+ gasPrice: (0, import_math16.bn)(gasPrice),
4343
+ gas: minGas,
4344
+ priceFactor: gasPriceFactor,
4345
+ tip: transactionRequest.tip
4346
+ }).add(1);
4347
+ let gasLimit = (0, import_math16.bn)(0);
4348
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4349
+ gasLimit = transactionRequest.gasLimit;
4350
+ if (!optimizeGas) {
4351
+ transactionRequest.gasLimit = minGas;
4352
+ gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4353
+ transactionRequest.gasLimit = gasLimit;
4354
+ }
4355
+ }
4356
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4357
+ const maxFee = calculateGasFee({
4358
+ gasPrice: (0, import_math16.bn)(gasPrice),
4359
+ gas: maxGas,
4360
+ priceFactor: gasPriceFactor,
4361
+ tip: transactionRequest.tip
4362
+ }).add(1);
4363
+ return {
4364
+ minGas,
4365
+ minFee,
4366
+ maxGas,
4367
+ maxFee,
4368
+ gasPrice,
4369
+ gasLimit
4146
4370
  };
4147
4371
  }
4148
4372
  /**
@@ -4160,15 +4384,17 @@ var _Provider = class {
4160
4384
  if (estimateTxDependencies) {
4161
4385
  return this.estimateTxDependencies(transactionRequest);
4162
4386
  }
4163
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4164
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4165
- encodedTransaction,
4387
+ const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4388
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4389
+ encodedTransactions,
4166
4390
  utxoValidation: true
4167
4391
  });
4168
- const receipts = gqlReceipts.map(processGqlReceipt);
4169
- return {
4170
- receipts
4171
- };
4392
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
4393
+ const { id, receipts, status } = dryRunStatus;
4394
+ const processedReceipts = receipts.map(processGqlReceipt);
4395
+ return { id, receipts: processedReceipts, status };
4396
+ });
4397
+ return { receipts: callResult[0].receipts };
4172
4398
  }
4173
4399
  /**
4174
4400
  * Returns a transaction cost to enable user
@@ -4185,80 +4411,80 @@ var _Provider = class {
4185
4411
  * @param tolerance - The tolerance to add on top of the gasUsed.
4186
4412
  * @returns A promise that resolves to the transaction cost object.
4187
4413
  */
4188
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4189
- estimateTxDependencies = true,
4190
- estimatePredicates = true,
4191
- resourcesOwner,
4192
- signatureCallback
4193
- } = {}) {
4414
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4194
4415
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4195
- const chainInfo = this.getChain();
4196
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4197
- const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4198
- const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4416
+ const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4199
4417
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4200
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4418
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4201
4419
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4202
- if (estimatePredicates) {
4203
- if (isScriptTransaction) {
4204
- txRequestClone.gasLimit = (0, import_math15.bn)(0);
4205
- }
4206
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4207
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4208
- }
4209
- await this.estimatePredicates(txRequestClone);
4420
+ txRequestClone.maxFee = (0, import_math16.bn)(0);
4421
+ if (isScriptTransaction) {
4422
+ txRequestClone.gasLimit = (0, import_math16.bn)(0);
4210
4423
  }
4211
- if (signatureCallback && isScriptTransaction) {
4212
- await signatureCallback(txRequestClone);
4424
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4425
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4213
4426
  }
4214
- const minGas = txRequestClone.calculateMinGas(chainInfo);
4215
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4427
+ const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4428
+ let addedSignatures = 0;
4429
+ if (signatureCallback && isScriptTransaction) {
4430
+ const lengthBefore = signedRequest.witnesses.length;
4431
+ await signatureCallback(signedRequest);
4432
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
4433
+ }
4434
+ await this.estimatePredicates(signedRequest);
4435
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4436
+ transactionRequest: signedRequest,
4437
+ optimizeGas: false
4438
+ });
4439
+ txRequestClone.maxFee = maxFee;
4216
4440
  let receipts = [];
4217
4441
  let missingContractIds = [];
4218
4442
  let outputVariables = 0;
4219
- if (isScriptTransaction && estimateTxDependencies) {
4220
- txRequestClone.gasPrice = (0, import_math15.bn)(0);
4221
- txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4443
+ let gasUsed = (0, import_math16.bn)(0);
4444
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4445
+ if (isScriptTransaction) {
4446
+ if (signatureCallback) {
4447
+ await signatureCallback(txRequestClone);
4448
+ }
4449
+ txRequestClone.gasLimit = gasLimit;
4222
4450
  const result = await this.estimateTxDependencies(txRequestClone);
4223
4451
  receipts = result.receipts;
4224
4452
  outputVariables = result.outputVariables;
4225
4453
  missingContractIds = result.missingContractIds;
4454
+ gasUsed = getGasUsedFromReceipts(receipts);
4455
+ txRequestClone.gasLimit = gasUsed;
4456
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4457
+ transactionRequest: txRequestClone,
4458
+ gasPrice
4459
+ }));
4226
4460
  }
4227
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4228
- const usedFee = calculatePriceWithFactor(
4229
- gasUsed,
4230
- gasPrice,
4231
- gasPriceFactor
4232
- ).normalizeZeroToOne();
4233
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4234
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4235
4461
  return {
4236
4462
  requiredQuantities: allQuantities,
4237
4463
  receipts,
4238
4464
  gasUsed,
4239
- minGasPrice,
4240
4465
  gasPrice,
4241
4466
  minGas,
4242
4467
  maxGas,
4243
- usedFee,
4244
4468
  minFee,
4245
4469
  maxFee,
4246
- estimatedInputs: txRequestClone.inputs,
4247
4470
  outputVariables,
4248
- missingContractIds
4471
+ missingContractIds,
4472
+ addedSignatures,
4473
+ estimatedPredicates: txRequestClone.inputs
4249
4474
  };
4250
4475
  }
4251
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4476
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4252
4477
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4253
4478
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4254
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4479
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
4480
+ quantitiesToContract
4481
+ });
4255
4482
  transactionRequest.addResources(
4256
4483
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4257
4484
  );
4258
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4259
- transactionRequest,
4260
- forwardingQuantities
4261
- );
4485
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4486
+ quantitiesToContract
4487
+ });
4262
4488
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4263
4489
  return {
4264
4490
  resources,
@@ -4274,17 +4500,16 @@ var _Provider = class {
4274
4500
  const result = await this.operations.getCoins({
4275
4501
  first: 10,
4276
4502
  ...paginationArgs,
4277
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4503
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4278
4504
  });
4279
4505
  const coins = result.coins.edges.map((edge) => edge.node);
4280
4506
  return coins.map((coin) => ({
4281
4507
  id: coin.utxoId,
4282
4508
  assetId: coin.assetId,
4283
- amount: (0, import_math15.bn)(coin.amount),
4509
+ amount: (0, import_math16.bn)(coin.amount),
4284
4510
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4285
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4286
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4287
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4511
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4512
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4288
4513
  }));
4289
4514
  }
4290
4515
  /**
@@ -4298,19 +4523,19 @@ var _Provider = class {
4298
4523
  async getResourcesToSpend(owner, quantities, excludedIds) {
4299
4524
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4300
4525
  const excludeInput = {
4301
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4302
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4526
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4527
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4303
4528
  };
4304
4529
  if (this.cache) {
4305
4530
  const uniqueUtxos = new Set(
4306
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4531
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4307
4532
  );
4308
4533
  excludeInput.utxos = Array.from(uniqueUtxos);
4309
4534
  }
4310
4535
  const coinsQuery = {
4311
4536
  owner: ownerAddress.toB256(),
4312
4537
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4313
- assetId: (0, import_utils23.hexlify)(assetId),
4538
+ assetId: (0, import_utils22.hexlify)(assetId),
4314
4539
  amount: amount.toString(10),
4315
4540
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4316
4541
  })),
@@ -4321,9 +4546,9 @@ var _Provider = class {
4321
4546
  switch (coin.__typename) {
4322
4547
  case "MessageCoin":
4323
4548
  return {
4324
- amount: (0, import_math15.bn)(coin.amount),
4549
+ amount: (0, import_math16.bn)(coin.amount),
4325
4550
  assetId: coin.assetId,
4326
- daHeight: (0, import_math15.bn)(coin.daHeight),
4551
+ daHeight: (0, import_math16.bn)(coin.daHeight),
4327
4552
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4328
4553
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4329
4554
  nonce: coin.nonce
@@ -4331,12 +4556,11 @@ var _Provider = class {
4331
4556
  case "Coin":
4332
4557
  return {
4333
4558
  id: coin.utxoId,
4334
- amount: (0, import_math15.bn)(coin.amount),
4559
+ amount: (0, import_math16.bn)(coin.amount),
4335
4560
  assetId: coin.assetId,
4336
4561
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4337
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4338
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4339
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4562
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4563
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4340
4564
  };
4341
4565
  default:
4342
4566
  return null;
@@ -4353,13 +4577,13 @@ var _Provider = class {
4353
4577
  async getBlock(idOrHeight) {
4354
4578
  let variables;
4355
4579
  if (typeof idOrHeight === "number") {
4356
- variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4580
+ variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4357
4581
  } else if (idOrHeight === "latest") {
4358
4582
  variables = { height: (await this.getBlockNumber()).toString(10) };
4359
4583
  } else if (idOrHeight.length === 66) {
4360
4584
  variables = { blockId: idOrHeight };
4361
4585
  } else {
4362
- variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4586
+ variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4363
4587
  }
4364
4588
  const { block } = await this.operations.getBlock(variables);
4365
4589
  if (!block) {
@@ -4367,7 +4591,7 @@ var _Provider = class {
4367
4591
  }
4368
4592
  return {
4369
4593
  id: block.id,
4370
- height: (0, import_math15.bn)(block.header.height),
4594
+ height: (0, import_math16.bn)(block.height),
4371
4595
  time: block.header.time,
4372
4596
  transactionIds: block.transactions.map((tx) => tx.id)
4373
4597
  };
@@ -4382,7 +4606,7 @@ var _Provider = class {
4382
4606
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4383
4607
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4384
4608
  id: block.id,
4385
- height: (0, import_math15.bn)(block.header.height),
4609
+ height: (0, import_math16.bn)(block.height),
4386
4610
  time: block.header.time,
4387
4611
  transactionIds: block.transactions.map((tx) => tx.id)
4388
4612
  }));
@@ -4397,7 +4621,7 @@ var _Provider = class {
4397
4621
  async getBlockWithTransactions(idOrHeight) {
4398
4622
  let variables;
4399
4623
  if (typeof idOrHeight === "number") {
4400
- variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4624
+ variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4401
4625
  } else if (idOrHeight === "latest") {
4402
4626
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4403
4627
  } else {
@@ -4409,11 +4633,11 @@ var _Provider = class {
4409
4633
  }
4410
4634
  return {
4411
4635
  id: block.id,
4412
- height: (0, import_math15.bn)(block.header.height, 10),
4636
+ height: (0, import_math16.bn)(block.height, 10),
4413
4637
  time: block.header.time,
4414
4638
  transactionIds: block.transactions.map((tx) => tx.id),
4415
4639
  transactions: block.transactions.map(
4416
- (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4640
+ (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4417
4641
  )
4418
4642
  };
4419
4643
  }
@@ -4428,8 +4652,8 @@ var _Provider = class {
4428
4652
  if (!transaction) {
4429
4653
  return null;
4430
4654
  }
4431
- return new import_transactions18.TransactionCoder().decode(
4432
- (0, import_utils23.arrayify)(transaction.rawPayload),
4655
+ return new import_transactions19.TransactionCoder().decode(
4656
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4433
4657
  0
4434
4658
  )?.[0];
4435
4659
  }
@@ -4456,9 +4680,9 @@ var _Provider = class {
4456
4680
  async getContractBalance(contractId, assetId) {
4457
4681
  const { contractBalance } = await this.operations.getContractBalance({
4458
4682
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4459
- asset: (0, import_utils23.hexlify)(assetId)
4683
+ asset: (0, import_utils22.hexlify)(assetId)
4460
4684
  });
4461
- return (0, import_math15.bn)(contractBalance.amount, 10);
4685
+ return (0, import_math16.bn)(contractBalance.amount, 10);
4462
4686
  }
4463
4687
  /**
4464
4688
  * Returns the balance for the given owner for the given asset ID.
@@ -4470,9 +4694,9 @@ var _Provider = class {
4470
4694
  async getBalance(owner, assetId) {
4471
4695
  const { balance } = await this.operations.getBalance({
4472
4696
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4473
- assetId: (0, import_utils23.hexlify)(assetId)
4697
+ assetId: (0, import_utils22.hexlify)(assetId)
4474
4698
  });
4475
- return (0, import_math15.bn)(balance.amount, 10);
4699
+ return (0, import_math16.bn)(balance.amount, 10);
4476
4700
  }
4477
4701
  /**
4478
4702
  * Returns balances for the given owner.
@@ -4490,7 +4714,7 @@ var _Provider = class {
4490
4714
  const balances = result.balances.edges.map((edge) => edge.node);
4491
4715
  return balances.map((balance) => ({
4492
4716
  assetId: balance.assetId,
4493
- amount: (0, import_math15.bn)(balance.amount)
4717
+ amount: (0, import_math16.bn)(balance.amount)
4494
4718
  }));
4495
4719
  }
4496
4720
  /**
@@ -4508,19 +4732,19 @@ var _Provider = class {
4508
4732
  });
4509
4733
  const messages = result.messages.edges.map((edge) => edge.node);
4510
4734
  return messages.map((message) => ({
4511
- messageId: import_transactions18.InputMessageCoder.getMessageId({
4735
+ messageId: import_transactions19.InputMessageCoder.getMessageId({
4512
4736
  sender: message.sender,
4513
4737
  recipient: message.recipient,
4514
4738
  nonce: message.nonce,
4515
- amount: (0, import_math15.bn)(message.amount),
4739
+ amount: (0, import_math16.bn)(message.amount),
4516
4740
  data: message.data
4517
4741
  }),
4518
4742
  sender: import_address3.Address.fromAddressOrString(message.sender),
4519
4743
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4520
4744
  nonce: message.nonce,
4521
- amount: (0, import_math15.bn)(message.amount),
4522
- data: import_transactions18.InputMessageCoder.decodeData(message.data),
4523
- daHeight: (0, import_math15.bn)(message.daHeight)
4745
+ amount: (0, import_math16.bn)(message.amount),
4746
+ data: import_transactions19.InputMessageCoder.decodeData(message.data),
4747
+ daHeight: (0, import_math16.bn)(message.daHeight)
4524
4748
  }));
4525
4749
  }
4526
4750
  /**
@@ -4573,44 +4797,60 @@ var _Provider = class {
4573
4797
  } = result.messageProof;
4574
4798
  return {
4575
4799
  messageProof: {
4576
- proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4800
+ proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4577
4801
  proofSet: messageProof.proofSet
4578
4802
  },
4579
4803
  blockProof: {
4580
- proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4804
+ proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4581
4805
  proofSet: blockProof.proofSet
4582
4806
  },
4583
4807
  messageBlockHeader: {
4584
4808
  id: messageBlockHeader.id,
4585
- daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4586
- transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4809
+ daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4810
+ transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4587
4811
  transactionsRoot: messageBlockHeader.transactionsRoot,
4588
- height: (0, import_math15.bn)(messageBlockHeader.height),
4812
+ height: (0, import_math16.bn)(messageBlockHeader.height),
4589
4813
  prevRoot: messageBlockHeader.prevRoot,
4590
4814
  time: messageBlockHeader.time,
4591
4815
  applicationHash: messageBlockHeader.applicationHash,
4592
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4593
- messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4816
+ messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4817
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4818
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4819
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
4820
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4594
4821
  },
4595
4822
  commitBlockHeader: {
4596
4823
  id: commitBlockHeader.id,
4597
- daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4598
- transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4824
+ daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4825
+ transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4599
4826
  transactionsRoot: commitBlockHeader.transactionsRoot,
4600
- height: (0, import_math15.bn)(commitBlockHeader.height),
4827
+ height: (0, import_math16.bn)(commitBlockHeader.height),
4601
4828
  prevRoot: commitBlockHeader.prevRoot,
4602
4829
  time: commitBlockHeader.time,
4603
4830
  applicationHash: commitBlockHeader.applicationHash,
4604
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4605
- messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4831
+ messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4832
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4833
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4834
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
4835
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4606
4836
  },
4607
4837
  sender: import_address3.Address.fromAddressOrString(sender),
4608
4838
  recipient: import_address3.Address.fromAddressOrString(recipient),
4609
4839
  nonce,
4610
- amount: (0, import_math15.bn)(amount),
4840
+ amount: (0, import_math16.bn)(amount),
4611
4841
  data
4612
4842
  };
4613
4843
  }
4844
+ async getLatestGasPrice() {
4845
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
4846
+ return (0, import_math16.bn)(latestGasPrice.gasPrice);
4847
+ }
4848
+ async estimateGasPrice(blockHorizon) {
4849
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
4850
+ blockHorizon: String(blockHorizon)
4851
+ });
4852
+ return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4853
+ }
4614
4854
  /**
4615
4855
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4616
4856
  *
@@ -4630,10 +4870,10 @@ var _Provider = class {
4630
4870
  */
4631
4871
  async produceBlocks(amount, startTime) {
4632
4872
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4633
- blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4634
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4873
+ blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4874
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4635
4875
  });
4636
- return (0, import_math15.bn)(latestBlockHeight);
4876
+ return (0, import_math16.bn)(latestBlockHeight);
4637
4877
  }
4638
4878
  // eslint-disable-next-line @typescript-eslint/require-await
4639
4879
  async getTransactionResponse(transactionId) {
@@ -4647,7 +4887,7 @@ cacheInputs_fn = function(inputs) {
4647
4887
  return;
4648
4888
  }
4649
4889
  inputs.forEach((input) => {
4650
- if (input.type === import_transactions18.InputType.Coin) {
4890
+ if (input.type === import_transactions19.InputType.Coin) {
4651
4891
  this.cache?.set(input.id);
4652
4892
  }
4653
4893
  });
@@ -4657,9 +4897,9 @@ __publicField(Provider, "nodeInfoCache", {});
4657
4897
 
4658
4898
  // src/providers/transaction-summary/get-transaction-summary.ts
4659
4899
  var import_errors15 = require("@fuel-ts/errors");
4660
- var import_math16 = require("@fuel-ts/math");
4661
- var import_transactions19 = require("@fuel-ts/transactions");
4662
- var import_utils26 = require("@fuel-ts/utils");
4900
+ var import_math17 = require("@fuel-ts/math");
4901
+ var import_transactions20 = require("@fuel-ts/transactions");
4902
+ var import_utils25 = require("@fuel-ts/utils");
4663
4903
  async function getTransactionSummary(params) {
4664
4904
  const { id, provider, abiMap } = params;
4665
4905
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4671,25 +4911,32 @@ async function getTransactionSummary(params) {
4671
4911
  `Transaction not found for given id: ${id}.`
4672
4912
  );
4673
4913
  }
4674
- const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4675
- (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4914
+ const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4915
+ (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4676
4916
  0
4677
4917
  );
4678
- const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4918
+ let txReceipts = [];
4919
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4920
+ txReceipts = gqlTransaction.status.receipts;
4921
+ }
4922
+ const receipts = txReceipts.map(processGqlReceipt);
4679
4923
  const {
4680
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4924
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4681
4925
  } = provider.getChain();
4926
+ const gasPrice = await provider.getLatestGasPrice();
4682
4927
  const transactionInfo = assembleTransactionSummary({
4683
4928
  id: gqlTransaction.id,
4684
4929
  receipts,
4685
4930
  transaction: decodedTransaction,
4686
- transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4931
+ transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4687
4932
  gqlTransactionStatus: gqlTransaction.status,
4688
- gasPerByte: (0, import_math16.bn)(gasPerByte),
4689
- gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4933
+ gasPerByte: (0, import_math17.bn)(gasPerByte),
4934
+ gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4690
4935
  abiMap,
4691
4936
  maxInputs,
4692
- gasCosts
4937
+ gasCosts,
4938
+ maxGasPerTx,
4939
+ gasPrice
4693
4940
  });
4694
4941
  return {
4695
4942
  gqlTransaction,
@@ -4699,10 +4946,11 @@ async function getTransactionSummary(params) {
4699
4946
  async function getTransactionSummaryFromRequest(params) {
4700
4947
  const { provider, transactionRequest, abiMap } = params;
4701
4948
  const { receipts } = await provider.call(transactionRequest);
4702
- const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4949
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4703
4950
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4704
4951
  const transaction = transactionRequest.toTransaction();
4705
4952
  const transactionBytes = transactionRequest.toTransactionBytes();
4953
+ const gasPrice = await provider.getLatestGasPrice();
4706
4954
  const transactionSummary = assembleTransactionSummary({
4707
4955
  receipts,
4708
4956
  transaction,
@@ -4711,7 +4959,9 @@ async function getTransactionSummaryFromRequest(params) {
4711
4959
  gasPerByte,
4712
4960
  gasPriceFactor,
4713
4961
  maxInputs,
4714
- gasCosts
4962
+ gasCosts,
4963
+ maxGasPerTx,
4964
+ gasPrice
4715
4965
  });
4716
4966
  return transactionSummary;
4717
4967
  }
@@ -4720,24 +4970,31 @@ async function getTransactionsSummaries(params) {
4720
4970
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4721
4971
  const { edges, pageInfo } = transactionsByOwner;
4722
4972
  const {
4723
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4973
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4724
4974
  } = provider.getChain();
4975
+ const gasPrice = await provider.getLatestGasPrice();
4725
4976
  const transactions = edges.map((edge) => {
4726
4977
  const { node: gqlTransaction } = edge;
4727
- const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4728
- const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4729
- const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4978
+ const { id, rawPayload, status } = gqlTransaction;
4979
+ const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4980
+ let txReceipts = [];
4981
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4982
+ txReceipts = gqlTransaction.status.receipts;
4983
+ }
4984
+ const receipts = txReceipts.map(processGqlReceipt);
4730
4985
  const transactionSummary = assembleTransactionSummary({
4731
4986
  id,
4732
4987
  receipts,
4733
4988
  transaction: decodedTransaction,
4734
- transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4989
+ transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4735
4990
  gqlTransactionStatus: status,
4736
4991
  abiMap,
4737
4992
  gasPerByte,
4738
4993
  gasPriceFactor,
4739
4994
  maxInputs,
4740
- gasCosts
4995
+ gasCosts,
4996
+ maxGasPerTx,
4997
+ gasPrice
4741
4998
  });
4742
4999
  const output = {
4743
5000
  gqlTransaction,
@@ -4874,17 +5131,17 @@ var assets = [
4874
5131
 
4875
5132
  // src/utils/formatTransferToContractScriptData.ts
4876
5133
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
4877
- var import_math17 = require("@fuel-ts/math");
4878
- var import_utils27 = require("@fuel-ts/utils");
5134
+ var import_math18 = require("@fuel-ts/math");
5135
+ var import_utils26 = require("@fuel-ts/utils");
4879
5136
  var asm = __toESM(require("@fuels/vm-asm"));
4880
5137
  var formatTransferToContractScriptData = (params) => {
4881
5138
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4882
5139
  const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4883
- const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5140
+ const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4884
5141
  const scriptData = Uint8Array.from([
4885
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
5142
+ ...(0, import_utils26.arrayify)(hexlifiedContractId),
4886
5143
  ...encoded,
4887
- ...(0, import_utils27.arrayify)(assetId)
5144
+ ...(0, import_utils26.arrayify)(assetId)
4888
5145
  ]);
4889
5146
  return scriptData;
4890
5147
  };
@@ -5031,9 +5288,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5031
5288
  * @param assetId - The asset ID to check the balance for.
5032
5289
  * @returns A promise that resolves to the balance amount.
5033
5290
  */
5034
- async getBalance(assetId) {
5035
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
5036
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
5291
+ async getBalance(assetId = import_configs12.BaseAssetId) {
5292
+ const amount = await this.provider.getBalance(this.address, assetId);
5037
5293
  return amount;
5038
5294
  }
5039
5295
  /**
@@ -5070,37 +5326,33 @@ var Account = class extends import_interfaces.AbstractAccount {
5070
5326
  * @param fee - The estimated transaction fee.
5071
5327
  * @returns A promise that resolves when the resources are added to the transaction.
5072
5328
  */
5073
- async fund(request, coinQuantities, fee) {
5074
- const baseAssetId = this.provider.getBaseAssetId();
5075
- const updatedQuantities = addAmountToAsset({
5076
- amount: (0, import_math18.bn)(fee),
5077
- assetId: baseAssetId,
5078
- coinQuantities
5329
+ async fund(request, params) {
5330
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5331
+ const txRequest = request;
5332
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5333
+ amount: (0, import_math19.bn)(fee),
5334
+ assetId: import_configs12.BaseAssetId,
5335
+ coinQuantities: requiredQuantities
5079
5336
  });
5080
5337
  const quantitiesDict = {};
5081
- updatedQuantities.forEach(({ amount, assetId }) => {
5338
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5082
5339
  quantitiesDict[assetId] = {
5083
5340
  required: amount,
5084
- owned: (0, import_math18.bn)(0)
5341
+ owned: (0, import_math19.bn)(0)
5085
5342
  };
5086
5343
  });
5087
- const cachedUtxos = [];
5088
- const cachedMessages = [];
5089
- const owner = this.address.toB256();
5090
- request.inputs.forEach((input) => {
5344
+ txRequest.inputs.forEach((input) => {
5091
5345
  const isResource = "amount" in input;
5092
5346
  if (isResource) {
5093
5347
  const isCoin2 = "owner" in input;
5094
5348
  if (isCoin2) {
5095
5349
  const assetId = String(input.assetId);
5096
- if (input.owner === owner && quantitiesDict[assetId]) {
5097
- const amount = (0, import_math18.bn)(input.amount);
5350
+ if (quantitiesDict[assetId]) {
5351
+ const amount = (0, import_math19.bn)(input.amount);
5098
5352
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5099
- cachedUtxos.push(input.id);
5100
5353
  }
5101
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
5102
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
5103
- cachedMessages.push(input.nonce);
5354
+ } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5355
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5104
5356
  }
5105
5357
  }
5106
5358
  });
@@ -5115,12 +5367,23 @@ var Account = class extends import_interfaces.AbstractAccount {
5115
5367
  });
5116
5368
  const needsToBeFunded = missingQuantities.length;
5117
5369
  if (needsToBeFunded) {
5118
- const resources = await this.getResourcesToSpend(missingQuantities, {
5119
- messages: cachedMessages,
5120
- utxos: cachedUtxos
5121
- });
5122
- request.addResources(resources);
5370
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5371
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5372
+ txRequest.addResources(resources);
5373
+ }
5374
+ txRequest.shiftPredicateData();
5375
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5376
+ const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
5377
+ if (addedSignatures) {
5378
+ Array.from({ length: addedSignatures }).forEach(
5379
+ () => requestToBeReEstimate.addEmptyWitness()
5380
+ );
5123
5381
  }
5382
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
5383
+ transactionRequest: requestToBeReEstimate
5384
+ });
5385
+ txRequest.maxFee = maxFee;
5386
+ return txRequest;
5124
5387
  }
5125
5388
  /**
5126
5389
  * A helper that creates a transfer transaction request and returns it.
@@ -5128,30 +5391,25 @@ var Account = class extends import_interfaces.AbstractAccount {
5128
5391
  * @param destination - The address of the destination.
5129
5392
  * @param amount - The amount of coins to transfer.
5130
5393
  * @param assetId - The asset ID of the coins to transfer.
5131
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5394
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5132
5395
  * @returns A promise that resolves to the prepared transaction request.
5133
5396
  */
5134
- async createTransfer(destination, amount, assetId, txParams = {}) {
5135
- const { minGasPrice } = this.provider.getGasConfig();
5136
- const baseAssetId = this.provider.getBaseAssetId();
5137
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5138
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5139
- const request = new ScriptTransactionRequest(params);
5140
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5141
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5397
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5398
+ const request = new ScriptTransactionRequest(txParams);
5399
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5400
+ const txCost = await this.provider.getTransactionCost(request, {
5142
5401
  estimateTxDependencies: true,
5143
5402
  resourcesOwner: this
5144
5403
  });
5145
- request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5146
- request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5147
- this.validateGas({
5148
- gasUsed,
5149
- gasPrice: request.gasPrice,
5150
- gasLimit: request.gasLimit,
5151
- minGasPrice
5152
- });
5153
- await this.fund(request, requiredQuantities, maxFee);
5154
- request.updatePredicateInputs(estimatedInputs);
5404
+ if ("gasLimit" in txParams) {
5405
+ this.validateGas({
5406
+ gasUsed: txCost.gasUsed,
5407
+ gasLimit: request.gasLimit
5408
+ });
5409
+ }
5410
+ request.gasLimit = txCost.gasUsed;
5411
+ request.maxFee = txCost.maxFee;
5412
+ await this.fund(request, txCost);
5155
5413
  return request;
5156
5414
  }
5157
5415
  /**
@@ -5163,15 +5421,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5163
5421
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5164
5422
  * @returns A promise that resolves to the transaction response.
5165
5423
  */
5166
- async transfer(destination, amount, assetId, txParams = {}) {
5167
- if ((0, import_math18.bn)(amount).lte(0)) {
5424
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5425
+ if ((0, import_math19.bn)(amount).lte(0)) {
5168
5426
  throw new import_errors16.FuelError(
5169
5427
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5170
5428
  "Transfer amount must be a positive number."
5171
5429
  );
5172
5430
  }
5173
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5174
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5431
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5175
5432
  return this.sendTransaction(request, { estimateTxDependencies: false });
5176
5433
  }
5177
5434
  /**
@@ -5183,41 +5440,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5183
5440
  * @param txParams - The optional transaction parameters.
5184
5441
  * @returns A promise that resolves to the transaction response.
5185
5442
  */
5186
- async transferToContract(contractId, amount, assetId, txParams = {}) {
5187
- if ((0, import_math18.bn)(amount).lte(0)) {
5443
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5444
+ if ((0, import_math19.bn)(amount).lte(0)) {
5188
5445
  throw new import_errors16.FuelError(
5189
5446
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5190
5447
  "Transfer amount must be a positive number."
5191
5448
  );
5192
5449
  }
5193
5450
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5194
- const { minGasPrice } = this.provider.getGasConfig();
5195
- const baseAssetId = this.provider.getBaseAssetId();
5196
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5197
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5198
5451
  const { script, scriptData } = await assembleTransferToContractScript({
5199
5452
  hexlifiedContractId: contractAddress.toB256(),
5200
- amountToTransfer: (0, import_math18.bn)(amount),
5201
- assetId: assetIdToTransfer
5453
+ amountToTransfer: (0, import_math19.bn)(amount),
5454
+ assetId
5202
5455
  });
5203
5456
  const request = new ScriptTransactionRequest({
5204
- ...params,
5457
+ ...txParams,
5205
5458
  script,
5206
5459
  scriptData
5207
5460
  });
5208
5461
  request.addContractInputAndOutput(contractAddress);
5209
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5210
- request,
5211
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
5212
- );
5213
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5214
- this.validateGas({
5215
- gasUsed,
5216
- gasPrice: request.gasPrice,
5217
- gasLimit: request.gasLimit,
5218
- minGasPrice
5462
+ const txCost = await this.provider.getTransactionCost(request, {
5463
+ resourcesOwner: this,
5464
+ quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5219
5465
  });
5220
- await this.fund(request, requiredQuantities, maxFee);
5466
+ if (txParams.gasLimit) {
5467
+ this.validateGas({
5468
+ gasUsed: txCost.gasUsed,
5469
+ gasLimit: request.gasLimit
5470
+ });
5471
+ }
5472
+ request.gasLimit = txCost.gasUsed;
5473
+ request.maxFee = txCost.maxFee;
5474
+ await this.fund(request, txCost);
5221
5475
  return this.sendTransaction(request);
5222
5476
  }
5223
5477
  /**
@@ -5229,40 +5483,31 @@ var Account = class extends import_interfaces.AbstractAccount {
5229
5483
  * @returns A promise that resolves to the transaction response.
5230
5484
  */
5231
5485
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5232
- const { minGasPrice } = this.provider.getGasConfig();
5233
- const baseAssetId = this.provider.getBaseAssetId();
5234
5486
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5235
- const recipientDataArray = (0, import_utils28.arrayify)(
5487
+ const recipientDataArray = (0, import_utils27.arrayify)(
5236
5488
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5237
5489
  );
5238
- const amountDataArray = (0, import_utils28.arrayify)(
5239
- "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5490
+ const amountDataArray = (0, import_utils27.arrayify)(
5491
+ "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5240
5492
  );
5241
5493
  const script = new Uint8Array([
5242
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5494
+ ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5243
5495
  ...recipientDataArray,
5244
5496
  ...amountDataArray
5245
5497
  ]);
5246
- const params = {
5247
- script,
5248
- gasPrice: minGasPrice,
5249
- baseAssetId,
5250
- ...txParams
5251
- };
5498
+ const params = { script, ...txParams };
5252
5499
  const request = new ScriptTransactionRequest(params);
5253
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
5254
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5255
- request,
5256
- forwardingQuantities
5257
- );
5258
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5259
- this.validateGas({
5260
- gasUsed,
5261
- gasPrice: request.gasPrice,
5262
- gasLimit: request.gasLimit,
5263
- minGasPrice
5264
- });
5265
- await this.fund(request, requiredQuantities, maxFee);
5500
+ const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5501
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5502
+ if (txParams.gasLimit) {
5503
+ this.validateGas({
5504
+ gasUsed: txCost.gasUsed,
5505
+ gasLimit: request.gasLimit
5506
+ });
5507
+ }
5508
+ request.maxFee = txCost.maxFee;
5509
+ request.gasLimit = txCost.gasUsed;
5510
+ await this.fund(request, txCost);
5266
5511
  return this.sendTransaction(request);
5267
5512
  }
5268
5513
  async signMessage(message) {
@@ -5320,18 +5565,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5320
5565
  }
5321
5566
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5322
5567
  }
5323
- validateGas({
5324
- gasUsed,
5325
- gasPrice,
5326
- gasLimit,
5327
- minGasPrice
5328
- }) {
5329
- if (minGasPrice.gt(gasPrice)) {
5330
- throw new import_errors16.FuelError(
5331
- import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5332
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5333
- );
5334
- }
5568
+ validateGas({ gasUsed, gasLimit }) {
5335
5569
  if (gasUsed.gt(gasLimit)) {
5336
5570
  throw new import_errors16.FuelError(
5337
5571
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5343,14 +5577,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5343
5577
 
5344
5578
  // src/wallet/base-wallet-unlocked.ts
5345
5579
  var import_hasher3 = require("@fuel-ts/hasher");
5346
- var import_utils31 = require("@fuel-ts/utils");
5580
+ var import_utils30 = require("@fuel-ts/utils");
5347
5581
 
5348
5582
  // src/signer/signer.ts
5349
5583
  var import_address5 = require("@fuel-ts/address");
5350
5584
  var import_crypto = require("@fuel-ts/crypto");
5351
5585
  var import_hasher2 = require("@fuel-ts/hasher");
5352
- var import_math19 = require("@fuel-ts/math");
5353
- var import_utils29 = require("@fuel-ts/utils");
5586
+ var import_math20 = require("@fuel-ts/math");
5587
+ var import_utils28 = require("@fuel-ts/utils");
5354
5588
  var import_secp256k1 = require("@noble/curves/secp256k1");
5355
5589
  var Signer = class {
5356
5590
  address;
@@ -5369,10 +5603,10 @@ var Signer = class {
5369
5603
  privateKey = `0x${privateKey}`;
5370
5604
  }
5371
5605
  }
5372
- const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5373
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5374
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5375
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5606
+ const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5607
+ this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5608
+ this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5609
+ this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5376
5610
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5377
5611
  }
5378
5612
  /**
@@ -5386,11 +5620,11 @@ var Signer = class {
5386
5620
  * @returns hashed signature
5387
5621
  */
5388
5622
  sign(data) {
5389
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5390
- const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5391
- const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5623
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5624
+ const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5625
+ const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5392
5626
  s[0] |= (signature.recovery || 0) << 7;
5393
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5627
+ return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5394
5628
  }
5395
5629
  /**
5396
5630
  * Add point on the current elliptic curve
@@ -5399,8 +5633,8 @@ var Signer = class {
5399
5633
  * @returns compressed point on the curve
5400
5634
  */
5401
5635
  addPoint(point) {
5402
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5403
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5636
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5637
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5404
5638
  const result = p0.add(p1);
5405
5639
  return `0x${result.toHex(true)}`;
5406
5640
  }
@@ -5412,16 +5646,16 @@ var Signer = class {
5412
5646
  * @returns public key from signature from the
5413
5647
  */
5414
5648
  static recoverPublicKey(data, signature) {
5415
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5649
+ const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5416
5650
  const r = signedMessageBytes.slice(0, 32);
5417
5651
  const s = signedMessageBytes.slice(32, 64);
5418
5652
  const recoveryParam = (s[0] & 128) >> 7;
5419
5653
  s[0] &= 127;
5420
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5654
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5421
5655
  recoveryParam
5422
5656
  );
5423
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5424
- return (0, import_utils29.hexlify)(publicKey);
5657
+ const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5658
+ return (0, import_utils28.hexlify)(publicKey);
5425
5659
  }
5426
5660
  /**
5427
5661
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5440,7 +5674,7 @@ var Signer = class {
5440
5674
  * @returns random 32-byte hashed
5441
5675
  */
5442
5676
  static generatePrivateKey(entropy) {
5443
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5677
+ return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5444
5678
  }
5445
5679
  /**
5446
5680
  * Extended publicKey from a compact publicKey
@@ -5449,8 +5683,8 @@ var Signer = class {
5449
5683
  * @returns extended publicKey
5450
5684
  */
5451
5685
  static extendPublicKey(publicKey) {
5452
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5453
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5686
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5687
+ return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5454
5688
  }
5455
5689
  };
5456
5690
 
@@ -5458,7 +5692,7 @@ var Signer = class {
5458
5692
  var import_address6 = require("@fuel-ts/address");
5459
5693
  var import_crypto2 = require("@fuel-ts/crypto");
5460
5694
  var import_errors17 = require("@fuel-ts/errors");
5461
- var import_utils30 = require("@fuel-ts/utils");
5695
+ var import_utils29 = require("@fuel-ts/utils");
5462
5696
  var import_uuid = require("uuid");
5463
5697
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5464
5698
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5541,7 +5775,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5541
5775
  );
5542
5776
  }
5543
5777
  const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5544
- const privateKey = (0, import_utils30.hexlify)(buffer);
5778
+ const privateKey = (0, import_utils29.hexlify)(buffer);
5545
5779
  return privateKey;
5546
5780
  }
5547
5781
 
@@ -5586,7 +5820,7 @@ var BaseWalletUnlocked = class extends Account {
5586
5820
  */
5587
5821
  async signMessage(message) {
5588
5822
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5589
- return (0, import_utils31.hexlify)(signedMessage);
5823
+ return (0, import_utils30.hexlify)(signedMessage);
5590
5824
  }
5591
5825
  /**
5592
5826
  * Signs a transaction with the wallet's private key.
@@ -5599,7 +5833,7 @@ var BaseWalletUnlocked = class extends Account {
5599
5833
  const chainId = this.provider.getChainId();
5600
5834
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5601
5835
  const signature = await this.signer().sign(hashedTransaction);
5602
- return (0, import_utils31.hexlify)(signature);
5836
+ return (0, import_utils30.hexlify)(signature);
5603
5837
  }
5604
5838
  /**
5605
5839
  * Populates a transaction with the witnesses signature.
@@ -5619,7 +5853,7 @@ var BaseWalletUnlocked = class extends Account {
5619
5853
  * @param transactionRequestLike - The transaction request to send.
5620
5854
  * @returns A promise that resolves to the TransactionResponse object.
5621
5855
  */
5622
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5856
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5623
5857
  const transactionRequest = transactionRequestify(transactionRequestLike);
5624
5858
  if (estimateTxDependencies) {
5625
5859
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5660,16 +5894,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5660
5894
  // src/hdwallet/hdwallet.ts
5661
5895
  var import_errors20 = require("@fuel-ts/errors");
5662
5896
  var import_hasher6 = require("@fuel-ts/hasher");
5663
- var import_math20 = require("@fuel-ts/math");
5664
- var import_utils35 = require("@fuel-ts/utils");
5665
- var import_ethers3 = require("ethers");
5897
+ var import_math21 = require("@fuel-ts/math");
5898
+ var import_utils34 = require("@fuel-ts/utils");
5899
+ var import_ethers4 = require("ethers");
5666
5900
 
5667
5901
  // src/mnemonic/mnemonic.ts
5668
5902
  var import_crypto3 = require("@fuel-ts/crypto");
5669
5903
  var import_errors19 = require("@fuel-ts/errors");
5670
5904
  var import_hasher5 = require("@fuel-ts/hasher");
5671
- var import_utils33 = require("@fuel-ts/utils");
5672
- var import_ethers2 = require("ethers");
5905
+ var import_utils32 = require("@fuel-ts/utils");
5906
+ var import_ethers3 = require("ethers");
5673
5907
 
5674
5908
  // src/wordlists/words/english.ts
5675
5909
  var english = [
@@ -7732,7 +7966,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7732
7966
  // src/mnemonic/utils.ts
7733
7967
  var import_errors18 = require("@fuel-ts/errors");
7734
7968
  var import_hasher4 = require("@fuel-ts/hasher");
7735
- var import_utils32 = require("@fuel-ts/utils");
7969
+ var import_utils31 = require("@fuel-ts/utils");
7736
7970
  function toUtf8Bytes(stri) {
7737
7971
  const str = stri.normalize("NFKD");
7738
7972
  const result = [];
@@ -7799,14 +8033,14 @@ function entropyToMnemonicIndices(entropy) {
7799
8033
  }
7800
8034
  }
7801
8035
  const checksumBits = entropy.length / 4;
7802
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8036
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7803
8037
  indices[indices.length - 1] <<= checksumBits;
7804
8038
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7805
8039
  return indices;
7806
8040
  }
7807
8041
  function mnemonicWordsToEntropy(words, wordlist) {
7808
8042
  const size = Math.ceil(11 * words.length / 8);
7809
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8043
+ const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7810
8044
  let offset = 0;
7811
8045
  for (let i = 0; i < words.length; i += 1) {
7812
8046
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7826,7 +8060,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7826
8060
  const entropyBits = 32 * words.length / 3;
7827
8061
  const checksumBits = words.length / 3;
7828
8062
  const checksumMask = getUpperMask(checksumBits);
7829
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8063
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7830
8064
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7831
8065
  throw new import_errors18.FuelError(
7832
8066
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7901,7 +8135,7 @@ var Mnemonic = class {
7901
8135
  static mnemonicToEntropy(phrase, wordlist = english) {
7902
8136
  const words = getWords(phrase);
7903
8137
  assertMnemonic(words);
7904
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8138
+ return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7905
8139
  }
7906
8140
  /**
7907
8141
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7909,7 +8143,7 @@ var Mnemonic = class {
7909
8143
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7910
8144
  */
7911
8145
  static entropyToMnemonic(entropy, wordlist = english) {
7912
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
8146
+ const entropyBytes = (0, import_utils32.arrayify)(entropy);
7913
8147
  assertWordList(wordlist);
7914
8148
  assertEntropy(entropyBytes);
7915
8149
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7923,7 +8157,7 @@ var Mnemonic = class {
7923
8157
  assertMnemonic(getWords(phrase));
7924
8158
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7925
8159
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7926
- return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8160
+ return (0, import_ethers3.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7927
8161
  }
7928
8162
  /**
7929
8163
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7978,14 +8212,14 @@ var Mnemonic = class {
7978
8212
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7979
8213
  */
7980
8214
  static masterKeysFromSeed(seed) {
7981
- const seedArray = (0, import_utils33.arrayify)(seed);
8215
+ const seedArray = (0, import_utils32.arrayify)(seed);
7982
8216
  if (seedArray.length < 16 || seedArray.length > 64) {
7983
8217
  throw new import_errors19.FuelError(
7984
8218
  import_errors19.ErrorCode.INVALID_SEED,
7985
8219
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7986
8220
  );
7987
8221
  }
7988
- return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8222
+ return (0, import_utils32.arrayify)((0, import_ethers3.computeHmac)("sha512", MasterSecret, seedArray));
7989
8223
  }
7990
8224
  /**
7991
8225
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7996,22 +8230,22 @@ var Mnemonic = class {
7996
8230
  */
7997
8231
  static seedToExtendedKey(seed, testnet = false) {
7998
8232
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7999
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8233
+ const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8000
8234
  const depth = "0x00";
8001
8235
  const fingerprint = "0x00000000";
8002
8236
  const index = "0x00000000";
8003
8237
  const chainCode = masterKey.slice(32);
8004
8238
  const privateKey = masterKey.slice(0, 32);
8005
- const extendedKey = (0, import_utils33.concat)([
8239
+ const extendedKey = (0, import_utils32.concat)([
8006
8240
  prefix,
8007
8241
  depth,
8008
8242
  fingerprint,
8009
8243
  index,
8010
8244
  chainCode,
8011
- (0, import_utils33.concat)(["0x00", privateKey])
8245
+ (0, import_utils32.concat)(["0x00", privateKey])
8012
8246
  ]);
8013
- const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8014
- return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8247
+ const checksum = (0, import_ethers3.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8248
+ return (0, import_ethers3.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8015
8249
  }
8016
8250
  /**
8017
8251
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8026,7 +8260,7 @@ var Mnemonic = class {
8026
8260
  * @returns A randomly generated mnemonic
8027
8261
  */
8028
8262
  static generate(size = 32, extraEntropy = "") {
8029
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
8263
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
8030
8264
  return Mnemonic.entropyToMnemonic(entropy);
8031
8265
  }
8032
8266
  };
@@ -8034,12 +8268,12 @@ var mnemonic_default = Mnemonic;
8034
8268
 
8035
8269
  // src/hdwallet/hdwallet.ts
8036
8270
  var HARDENED_INDEX = 2147483648;
8037
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8038
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8039
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8040
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8271
+ var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8272
+ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8273
+ var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8274
+ var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8041
8275
  function base58check(data) {
8042
- 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)]));
8276
+ return (0, import_ethers4.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers4.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8043
8277
  }
8044
8278
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8045
8279
  if (isPublic) {
@@ -8048,11 +8282,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8048
8282
  return testnet ? TestnetPRV2 : MainnetPRV2;
8049
8283
  }
8050
8284
  function isPublicExtendedKey(extendedKey) {
8051
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8285
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8052
8286
  }
8053
8287
  function isValidExtendedKey(extendedKey) {
8054
8288
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8055
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8289
+ (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8056
8290
  );
8057
8291
  }
8058
8292
  function parsePath(path, depth = 0) {
@@ -8070,8 +8304,8 @@ function parsePath(path, depth = 0) {
8070
8304
  var HDWallet = class {
8071
8305
  depth = 0;
8072
8306
  index = 0;
8073
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
8074
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8307
+ fingerprint = (0, import_utils34.hexlify)("0x00000000");
8308
+ parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8075
8309
  privateKey;
8076
8310
  publicKey;
8077
8311
  chainCode;
@@ -8083,8 +8317,8 @@ var HDWallet = class {
8083
8317
  constructor(config) {
8084
8318
  if (config.privateKey) {
8085
8319
  const signer = new Signer(config.privateKey);
8086
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8087
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8320
+ this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8321
+ this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8088
8322
  } else {
8089
8323
  if (!config.publicKey) {
8090
8324
  throw new import_errors20.FuelError(
@@ -8092,10 +8326,10 @@ var HDWallet = class {
8092
8326
  "Both public and private Key cannot be missing. At least one should be provided."
8093
8327
  );
8094
8328
  }
8095
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8329
+ this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8096
8330
  }
8097
8331
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8098
- this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8332
+ this.fingerprint = (0, import_ethers4.dataSlice)((0, import_ethers4.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8099
8333
  this.depth = config.depth || this.depth;
8100
8334
  this.index = config.index || this.index;
8101
8335
  this.chainCode = config.chainCode;
@@ -8111,9 +8345,9 @@ var HDWallet = class {
8111
8345
  * @returns A new instance of HDWallet on the derived index
8112
8346
  */
8113
8347
  deriveIndex(index) {
8114
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8115
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8116
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8348
+ const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8349
+ const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8350
+ const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8117
8351
  const data = new Uint8Array(37);
8118
8352
  if (index & HARDENED_INDEX) {
8119
8353
  if (!privateKey) {
@@ -8124,15 +8358,15 @@ var HDWallet = class {
8124
8358
  }
8125
8359
  data.set(privateKey, 1);
8126
8360
  } else {
8127
- data.set((0, import_utils35.arrayify)(this.publicKey));
8361
+ data.set((0, import_utils34.arrayify)(this.publicKey));
8128
8362
  }
8129
- data.set((0, import_math20.toBytes)(index, 4), 33);
8130
- const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8363
+ data.set((0, import_math21.toBytes)(index, 4), 33);
8364
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers4.computeHmac)("sha512", chainCode, data));
8131
8365
  const IL = bytes.slice(0, 32);
8132
8366
  const IR = bytes.slice(32);
8133
8367
  if (privateKey) {
8134
8368
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8135
- const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8369
+ const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8136
8370
  return new HDWallet({
8137
8371
  privateKey: ki,
8138
8372
  chainCode: IR,
@@ -8141,7 +8375,7 @@ var HDWallet = class {
8141
8375
  parentFingerprint: this.fingerprint
8142
8376
  });
8143
8377
  }
8144
- const signer = new Signer((0, import_utils35.hexlify)(IL));
8378
+ const signer = new Signer((0, import_utils34.hexlify)(IL));
8145
8379
  const Ki = signer.addPoint(publicKey);
8146
8380
  return new HDWallet({
8147
8381
  publicKey: Ki,
@@ -8176,12 +8410,12 @@ var HDWallet = class {
8176
8410
  );
8177
8411
  }
8178
8412
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8179
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8413
+ const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8180
8414
  const parentFingerprint = this.parentFingerprint;
8181
- const index = (0, import_math20.toHex)(this.index, 4);
8415
+ const index = (0, import_math21.toHex)(this.index, 4);
8182
8416
  const chainCode = this.chainCode;
8183
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8184
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8417
+ const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8418
+ const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8185
8419
  return base58check(extendedKey);
8186
8420
  }
8187
8421
  /**
@@ -8193,13 +8427,13 @@ var HDWallet = class {
8193
8427
  static fromSeed(seed) {
8194
8428
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8195
8429
  return new HDWallet({
8196
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8197
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8430
+ chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8431
+ privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8198
8432
  });
8199
8433
  }
8200
8434
  static fromExtendedKey(extendedKey) {
8201
- const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8202
- const bytes = (0, import_utils35.arrayify)(decoded);
8435
+ const decoded = (0, import_ethers4.toBeHex)((0, import_ethers4.decodeBase58)(extendedKey));
8436
+ const bytes = (0, import_utils34.arrayify)(decoded);
8203
8437
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8204
8438
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8205
8439
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8208,9 +8442,9 @@ var HDWallet = class {
8208
8442
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8209
8443
  }
8210
8444
  const depth = bytes[4];
8211
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8212
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8213
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8445
+ const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8446
+ const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8447
+ const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8214
8448
  const key = bytes.slice(45, 78);
8215
8449
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8216
8450
  throw new import_errors20.FuelError(
@@ -8813,20 +9047,21 @@ var StorageAbstract = class {
8813
9047
  // src/predicate/predicate.ts
8814
9048
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
8815
9049
  var import_address10 = require("@fuel-ts/address");
9050
+ var import_configs13 = require("@fuel-ts/address/configs");
8816
9051
  var import_errors25 = require("@fuel-ts/errors");
8817
- var import_transactions20 = require("@fuel-ts/transactions");
8818
- var import_utils37 = require("@fuel-ts/utils");
9052
+ var import_transactions21 = require("@fuel-ts/transactions");
9053
+ var import_utils36 = require("@fuel-ts/utils");
8819
9054
 
8820
9055
  // src/predicate/utils/getPredicateRoot.ts
8821
9056
  var import_hasher7 = require("@fuel-ts/hasher");
8822
9057
  var import_merkle = require("@fuel-ts/merkle");
8823
- var import_utils36 = require("@fuel-ts/utils");
9058
+ var import_utils35 = require("@fuel-ts/utils");
8824
9059
  var getPredicateRoot = (bytecode) => {
8825
9060
  const chunkSize = 16 * 1024;
8826
- const bytes = (0, import_utils36.arrayify)(bytecode);
8827
- const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8828
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8829
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9061
+ const bytes = (0, import_utils35.arrayify)(bytecode);
9062
+ const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9063
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9064
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8830
9065
  return predicateRoot;
8831
9066
  };
8832
9067
 
@@ -8874,9 +9109,9 @@ var Predicate = class extends Account {
8874
9109
  const request = transactionRequestify(transactionRequestLike);
8875
9110
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8876
9111
  request.inputs?.forEach((input) => {
8877
- if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8878
- input.predicate = this.bytes;
8879
- input.predicateData = this.getPredicateData(policies.length);
9112
+ if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9113
+ input.predicate = (0, import_utils36.hexlify)(this.bytes);
9114
+ input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8880
9115
  }
8881
9116
  });
8882
9117
  return request;
@@ -8890,10 +9125,8 @@ var Predicate = class extends Account {
8890
9125
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8891
9126
  * @returns A promise that resolves to the prepared transaction request.
8892
9127
  */
8893
- async createTransfer(destination, amount, assetId, txParams = {}) {
8894
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8895
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8896
- return this.populateTransactionPredicateData(request);
9128
+ async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
9129
+ return super.createTransfer(destination, amount, assetId, txParams);
8897
9130
  }
8898
9131
  /**
8899
9132
  * Sends a transaction with the populated predicate data.
@@ -8901,9 +9134,9 @@ var Predicate = class extends Account {
8901
9134
  * @param transactionRequestLike - The transaction request-like object.
8902
9135
  * @returns A promise that resolves to the transaction response.
8903
9136
  */
8904
- sendTransaction(transactionRequestLike, options) {
8905
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8906
- return super.sendTransaction(transactionRequest, options);
9137
+ sendTransaction(transactionRequestLike) {
9138
+ const transactionRequest = transactionRequestify(transactionRequestLike);
9139
+ return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8907
9140
  }
8908
9141
  /**
8909
9142
  * Simulates a transaction with the populated predicate data.
@@ -8912,15 +9145,15 @@ var Predicate = class extends Account {
8912
9145
  * @returns A promise that resolves to the call result.
8913
9146
  */
8914
9147
  simulateTransaction(transactionRequestLike) {
8915
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8916
- return super.simulateTransaction(transactionRequest);
9148
+ const transactionRequest = transactionRequestify(transactionRequestLike);
9149
+ return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8917
9150
  }
8918
9151
  getPredicateData(policiesLength) {
8919
9152
  if (!this.predicateData.length) {
8920
9153
  return new Uint8Array();
8921
9154
  }
8922
9155
  const mainFn = this.interface?.functions.main;
8923
- const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9156
+ const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8924
9157
  const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8925
9158
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8926
9159
  });
@@ -8936,7 +9169,7 @@ var Predicate = class extends Account {
8936
9169
  * @returns An object containing the new predicate bytes and interface.
8937
9170
  */
8938
9171
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8939
- let predicateBytes = (0, import_utils37.arrayify)(bytes);
9172
+ let predicateBytes = (0, import_utils36.arrayify)(bytes);
8940
9173
  let abiInterface;
8941
9174
  if (jsonAbi) {
8942
9175
  abiInterface = new import_abi_coder5.Interface(jsonAbi);
@@ -8959,6 +9192,25 @@ var Predicate = class extends Account {
8959
9192
  predicateInterface: abiInterface
8960
9193
  };
8961
9194
  }
9195
+ /**
9196
+ * Retrieves resources satisfying the spend query for the account.
9197
+ *
9198
+ * @param quantities - IDs of coins to exclude.
9199
+ * @param excludedIds - IDs of resources to be excluded from the query.
9200
+ * @returns A promise that resolves to an array of Resources.
9201
+ */
9202
+ async getResourcesToSpend(quantities, excludedIds) {
9203
+ const resources = await this.provider.getResourcesToSpend(
9204
+ this.address,
9205
+ quantities,
9206
+ excludedIds
9207
+ );
9208
+ return resources.map((resource) => ({
9209
+ ...resource,
9210
+ predicate: (0, import_utils36.hexlify)(this.bytes),
9211
+ paddPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9212
+ }));
9213
+ }
8962
9214
  /**
8963
9215
  * Sets the configurable constants for the predicate.
8964
9216
  *
@@ -9708,7 +9960,7 @@ __publicField(Fuel, "defaultConfig", {});
9708
9960
  WalletLocked,
9709
9961
  WalletManager,
9710
9962
  WalletUnlocked,
9711
- addAmountToAsset,
9963
+ addAmountToCoinQuantities,
9712
9964
  addOperation,
9713
9965
  assemblePanicError,
9714
9966
  assembleReceiptByType,
@@ -9717,9 +9969,10 @@ __publicField(Fuel, "defaultConfig", {});
9717
9969
  assets,
9718
9970
  buildBlockExplorerUrl,
9719
9971
  cacheFor,
9972
+ cacheTxInputsFromOwner,
9973
+ calculateGasFee,
9720
9974
  calculateMetadataGasForTxCreate,
9721
9975
  calculateMetadataGasForTxScript,
9722
- calculatePriceWithFactor,
9723
9976
  calculateTransactionFee,
9724
9977
  coinQuantityfy,
9725
9978
  deferPromise,