@fuel-ts/account 0.0.0-rc-2021-20240411154255 → 0.0.0-rc-2045-20240411190910

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +574 -841
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +574 -823
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +409 -657
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +329 -911
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -7
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +30 -37
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +25 -8
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1073 -1557
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +567 -798
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +418 -649
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. 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
- addAmountToCoinQuantities: () => addAmountToCoinQuantities,
98
+ addAmountToAsset: () => addAmountToAsset,
99
99
  addOperation: () => addOperation,
100
100
  assemblePanicError: () => assemblePanicError,
101
101
  assembleReceiptByType: () => assembleReceiptByType,
@@ -104,10 +104,9 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
- cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
108
- calculateGasFee: () => calculateGasFee,
109
107
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
110
108
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
109
+ calculatePriceWithFactor: () => calculatePriceWithFactor,
111
110
  calculateTransactionFee: () => calculateTransactionFee,
112
111
  coinQuantityfy: () => coinQuantityfy,
113
112
  deferPromise: () => deferPromise,
@@ -188,9 +187,8 @@ var import_address4 = require("@fuel-ts/address");
188
187
  var import_configs12 = require("@fuel-ts/address/configs");
189
188
  var import_errors16 = require("@fuel-ts/errors");
190
189
  var import_interfaces = require("@fuel-ts/interfaces");
191
- var import_math19 = require("@fuel-ts/math");
192
- var import_utils27 = require("@fuel-ts/utils");
193
- var import_ramda4 = require("ramda");
190
+ var import_math18 = require("@fuel-ts/math");
191
+ var import_utils28 = require("@fuel-ts/utils");
194
192
 
195
193
  // src/providers/coin-quantity.ts
196
194
  var import_configs = require("@fuel-ts/address/configs");
@@ -199,24 +197,24 @@ var import_utils = require("@fuel-ts/utils");
199
197
  var coinQuantityfy = (coinQuantityLike) => {
200
198
  let assetId;
201
199
  let amount;
202
- let max;
200
+ let max2;
203
201
  if (Array.isArray(coinQuantityLike)) {
204
202
  amount = coinQuantityLike[0];
205
203
  assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
206
- max = coinQuantityLike[2] ?? void 0;
204
+ max2 = coinQuantityLike[2] ?? void 0;
207
205
  } else {
208
206
  amount = coinQuantityLike.amount;
209
207
  assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
210
- max = coinQuantityLike.max ?? void 0;
208
+ max2 = coinQuantityLike.max ?? void 0;
211
209
  }
212
210
  const bnAmount = (0, import_math.bn)(amount);
213
211
  return {
214
212
  assetId: (0, import_utils.hexlify)(assetId),
215
213
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
216
- max: max ? (0, import_math.bn)(max) : void 0
214
+ max: max2 ? (0, import_math.bn)(max2) : void 0
217
215
  };
218
216
  };
219
- var addAmountToCoinQuantities = (params) => {
217
+ var addAmountToAsset = (params) => {
220
218
  const { amount, assetId } = params;
221
219
  const coinQuantities = [...params.coinQuantities];
222
220
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -231,12 +229,12 @@ var addAmountToCoinQuantities = (params) => {
231
229
  // src/providers/provider.ts
232
230
  var import_address3 = require("@fuel-ts/address");
233
231
  var import_errors14 = require("@fuel-ts/errors");
234
- var import_math16 = require("@fuel-ts/math");
235
- var import_transactions19 = require("@fuel-ts/transactions");
236
- var import_utils22 = require("@fuel-ts/utils");
232
+ var import_math15 = require("@fuel-ts/math");
233
+ var import_transactions18 = require("@fuel-ts/transactions");
234
+ var import_utils23 = require("@fuel-ts/utils");
237
235
  var import_versions = require("@fuel-ts/versions");
238
- var import_utils23 = require("@noble/curves/abstract/utils");
239
- var import_ethers2 = require("ethers");
236
+ var import_utils24 = require("@noble/curves/abstract/utils");
237
+ var import_ethers = require("ethers");
240
238
  var import_graphql_request = require("graphql-request");
241
239
  var import_ramda3 = require("ramda");
242
240
 
@@ -244,10 +242,14 @@ var import_ramda3 = require("ramda");
244
242
  var import_graphql_tag = __toESM(require("graphql-tag"));
245
243
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
246
244
  fragment receiptFragment on Receipt {
247
- id
245
+ contract {
246
+ id
247
+ }
248
248
  pc
249
249
  is
250
- to
250
+ to {
251
+ id
252
+ }
251
253
  toAddress
252
254
  amount
253
255
  assetId
@@ -285,16 +287,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
285
287
  id
286
288
  }
287
289
  time
288
- receipts {
289
- ...receiptFragment
290
- }
291
290
  programState {
292
291
  returnType
293
292
  data
294
293
  }
295
- receipts {
296
- ...receiptFragment
297
- }
298
294
  }
299
295
  ... on FailureStatus {
300
296
  block {
@@ -302,24 +298,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
302
298
  }
303
299
  time
304
300
  reason
305
- receipts {
306
- ...receiptFragment
307
- }
308
301
  }
309
302
  ... on SqueezedOutStatus {
310
303
  reason
311
304
  }
312
305
  }
313
- ${ReceiptFragmentFragmentDoc}`;
306
+ `;
314
307
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
315
308
  fragment transactionFragment on Transaction {
316
309
  id
317
310
  rawPayload
311
+ gasPrice
312
+ receipts {
313
+ ...receiptFragment
314
+ }
318
315
  status {
319
316
  ...transactionStatusFragment
320
317
  }
321
318
  }
322
- ${TransactionStatusFragmentFragmentDoc}`;
319
+ ${ReceiptFragmentFragmentDoc}
320
+ ${TransactionStatusFragmentFragmentDoc}`;
323
321
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
324
322
  fragment inputEstimatePredicatesFragment on Input {
325
323
  ... on InputCoin {
@@ -337,46 +335,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
337
335
  }
338
336
  }
339
337
  ${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}`;
380
338
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
381
339
  fragment coinFragment on Coin {
382
340
  __typename
@@ -384,6 +342,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
384
342
  owner
385
343
  amount
386
344
  assetId
345
+ maturity
387
346
  blockCreated
388
347
  txCreatedIdx
389
348
  }
@@ -422,32 +381,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
422
381
  messageBlockHeader {
423
382
  id
424
383
  daHeight
425
- consensusParametersVersion
426
- stateTransitionBytecodeVersion
427
384
  transactionsCount
428
- messageReceiptCount
429
385
  transactionsRoot
430
- messageOutboxRoot
431
- eventInboxRoot
432
386
  height
433
387
  prevRoot
434
388
  time
435
389
  applicationHash
390
+ messageReceiptRoot
391
+ messageReceiptCount
436
392
  }
437
393
  commitBlockHeader {
438
394
  id
439
395
  daHeight
440
- consensusParametersVersion
441
- stateTransitionBytecodeVersion
442
396
  transactionsCount
443
- messageReceiptCount
444
397
  transactionsRoot
445
- messageOutboxRoot
446
- eventInboxRoot
447
398
  height
448
399
  prevRoot
449
400
  time
450
401
  applicationHash
402
+ messageReceiptRoot
403
+ messageReceiptCount
451
404
  }
452
405
  sender
453
406
  recipient
@@ -466,8 +419,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
466
419
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
467
420
  fragment blockFragment on Block {
468
421
  id
469
- height
470
422
  header {
423
+ height
471
424
  time
472
425
  }
473
426
  transactions {
@@ -525,11 +478,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
525
478
  `;
526
479
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
527
480
  fragment GasCostsFragment on GasCosts {
528
- version {
529
- ... on Version {
530
- value
531
- }
532
- }
533
481
  add
534
482
  addi
535
483
  aloc
@@ -542,6 +490,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
542
490
  cb
543
491
  cfei
544
492
  cfsi
493
+ croo
545
494
  div
546
495
  divi
547
496
  ecr1
@@ -624,9 +573,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
624
573
  ccp {
625
574
  ...DependentCostFragment
626
575
  }
627
- croo {
628
- ...DependentCostFragment
629
- }
630
576
  csiz {
631
577
  ...DependentCostFragment
632
578
  }
@@ -686,11 +632,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
686
632
  ${DependentCostFragmentFragmentDoc}`;
687
633
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
688
634
  fragment consensusParametersFragment on ConsensusParameters {
689
- version {
690
- ... on Version {
691
- value
692
- }
693
- }
694
635
  txParams {
695
636
  ...TxParametersFragment
696
637
  }
@@ -750,9 +691,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
750
691
  fragment nodeInfoFragment on NodeInfo {
751
692
  utxoValidation
752
693
  vmBacktrace
694
+ minGasPrice
753
695
  maxTx
754
696
  maxDepth
755
697
  nodeVersion
698
+ peers {
699
+ id
700
+ addresses
701
+ clientVersion
702
+ blockHeight
703
+ lastHeartbeatMs
704
+ appScore
705
+ }
756
706
  }
757
707
  `;
758
708
  var GetVersionDocument = import_graphql_tag.default`
@@ -787,9 +737,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
787
737
  query getTransactionWithReceipts($transactionId: TransactionId!) {
788
738
  transaction(id: $transactionId) {
789
739
  ...transactionFragment
740
+ receipts {
741
+ ...receiptFragment
742
+ }
790
743
  }
791
744
  }
792
- ${TransactionFragmentFragmentDoc}`;
745
+ ${TransactionFragmentFragmentDoc}
746
+ ${ReceiptFragmentFragmentDoc}`;
793
747
  var GetTransactionsDocument = import_graphql_tag.default`
794
748
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
795
749
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -917,20 +871,6 @@ var GetBalanceDocument = import_graphql_tag.default`
917
871
  }
918
872
  }
919
873
  ${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
- `;
934
874
  var GetBalancesDocument = import_graphql_tag.default`
935
875
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
936
876
  balances(
@@ -985,12 +925,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
985
925
  }
986
926
  `;
987
927
  var DryRunDocument = import_graphql_tag.default`
988
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
989
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
990
- ...dryRunTransactionExecutionStatusFragment
928
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
929
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
930
+ ...receiptFragment
991
931
  }
992
932
  }
993
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
933
+ ${ReceiptFragmentFragmentDoc}`;
994
934
  var SubmitDocument = import_graphql_tag.default`
995
935
  mutation submit($encodedTransaction: HexString!) {
996
936
  submit(tx: $encodedTransaction) {
@@ -1073,12 +1013,6 @@ function getSdk(requester) {
1073
1013
  getBalance(variables, options) {
1074
1014
  return requester(GetBalanceDocument, variables, options);
1075
1015
  },
1076
- getLatestGasPrice(variables, options) {
1077
- return requester(GetLatestGasPriceDocument, variables, options);
1078
- },
1079
- estimateGasPrice(variables, options) {
1080
- return requester(EstimateGasPriceDocument, variables, options);
1081
- },
1082
1016
  getBalances(variables, options) {
1083
1017
  return requester(GetBalancesDocument, variables, options);
1084
1018
  },
@@ -1148,14 +1082,11 @@ var _FuelGraphqlSubscriber = class {
1148
1082
  let data;
1149
1083
  let errors;
1150
1084
  try {
1151
- const sanitizedText = text.replace(/\s/g, "");
1152
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
1085
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1153
1086
  } catch (e) {
1154
1087
  throw new import_errors.FuelError(
1155
1088
  import_errors.ErrorCode.STREAM_PARSING_ERROR,
1156
- `Error while parsing stream data response: ${text}
1157
-
1158
- Thrown error: ${e}`
1089
+ `Error while parsing stream data response: ${text}`
1159
1090
  );
1160
1091
  }
1161
1092
  if (Array.isArray(errors)) {
@@ -1242,6 +1173,7 @@ var MemoryCache = class {
1242
1173
  };
1243
1174
 
1244
1175
  // src/providers/transaction-request/input.ts
1176
+ var import_abi_coder = require("@fuel-ts/abi-coder");
1245
1177
  var import_configs2 = require("@fuel-ts/address/configs");
1246
1178
  var import_errors3 = require("@fuel-ts/errors");
1247
1179
  var import_math2 = require("@fuel-ts/math");
@@ -1255,8 +1187,8 @@ var inputify = (value) => {
1255
1187
  const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1256
1188
  return {
1257
1189
  type: import_transactions.InputType.Coin,
1258
- txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1259
- outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 34)),
1190
+ txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
1191
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
1260
1192
  owner: (0, import_utils3.hexlify)(value.owner),
1261
1193
  amount: (0, import_math2.bn)(value.amount),
1262
1194
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1265,9 +1197,10 @@ var inputify = (value) => {
1265
1197
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1266
1198
  },
1267
1199
  witnessIndex: value.witnessIndex,
1200
+ maturity: value.maturity ?? 0,
1268
1201
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1269
- predicateLength: (0, import_math2.bn)(predicate.length),
1270
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1202
+ predicateLength: predicate.length,
1203
+ predicateDataLength: predicateData.length,
1271
1204
  predicate: (0, import_utils3.hexlify)(predicate),
1272
1205
  predicateData: (0, import_utils3.hexlify)(predicateData)
1273
1206
  };
@@ -1298,8 +1231,8 @@ var inputify = (value) => {
1298
1231
  nonce: (0, import_utils3.hexlify)(value.nonce),
1299
1232
  witnessIndex: value.witnessIndex,
1300
1233
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1301
- predicateLength: (0, import_math2.bn)(predicate.length),
1302
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1234
+ predicateLength: predicate.length,
1235
+ predicateDataLength: predicateData.length,
1303
1236
  predicate: (0, import_utils3.hexlify)(predicate),
1304
1237
  predicateData: (0, import_utils3.hexlify)(predicateData),
1305
1238
  data: (0, import_utils3.hexlify)(data),
@@ -1373,12 +1306,13 @@ var outputify = (value) => {
1373
1306
  };
1374
1307
 
1375
1308
  // src/providers/transaction-request/transaction-request.ts
1309
+ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1376
1310
  var import_address = require("@fuel-ts/address");
1377
1311
  var import_configs7 = require("@fuel-ts/address/configs");
1312
+ var import_crypto = require("@fuel-ts/crypto");
1378
1313
  var import_math7 = require("@fuel-ts/math");
1379
1314
  var import_transactions6 = require("@fuel-ts/transactions");
1380
1315
  var import_utils9 = require("@fuel-ts/utils");
1381
- var import_ethers = require("ethers");
1382
1316
 
1383
1317
  // src/providers/resource.ts
1384
1318
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1417,8 +1351,8 @@ function assembleReceiptByType(receipt) {
1417
1351
  case "CALL" /* Call */: {
1418
1352
  const callReceipt = {
1419
1353
  type: import_transactions3.ReceiptType.Call,
1420
- from: hexOrZero(receipt.id || receipt.contractId),
1421
- to: hexOrZero(receipt?.to),
1354
+ from: hexOrZero(receipt.contract?.id),
1355
+ to: hexOrZero(receipt?.to?.id),
1422
1356
  amount: (0, import_math4.bn)(receipt.amount),
1423
1357
  assetId: hexOrZero(receipt.assetId),
1424
1358
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1432,7 +1366,7 @@ function assembleReceiptByType(receipt) {
1432
1366
  case "RETURN" /* Return */: {
1433
1367
  const returnReceipt = {
1434
1368
  type: import_transactions3.ReceiptType.Return,
1435
- id: hexOrZero(receipt.id || receipt.contractId),
1369
+ id: hexOrZero(receipt.contract?.id),
1436
1370
  val: (0, import_math4.bn)(receipt.val),
1437
1371
  pc: (0, import_math4.bn)(receipt.pc),
1438
1372
  is: (0, import_math4.bn)(receipt.is)
@@ -1442,7 +1376,7 @@ function assembleReceiptByType(receipt) {
1442
1376
  case "RETURN_DATA" /* ReturnData */: {
1443
1377
  const returnDataReceipt = {
1444
1378
  type: import_transactions3.ReceiptType.ReturnData,
1445
- id: hexOrZero(receipt.id || receipt.contractId),
1379
+ id: hexOrZero(receipt.contract?.id),
1446
1380
  ptr: (0, import_math4.bn)(receipt.ptr),
1447
1381
  len: (0, import_math4.bn)(receipt.len),
1448
1382
  digest: hexOrZero(receipt.digest),
@@ -1454,7 +1388,7 @@ function assembleReceiptByType(receipt) {
1454
1388
  case "PANIC" /* Panic */: {
1455
1389
  const panicReceipt = {
1456
1390
  type: import_transactions3.ReceiptType.Panic,
1457
- id: hexOrZero(receipt.id),
1391
+ id: hexOrZero(receipt.contract?.id),
1458
1392
  reason: (0, import_math4.bn)(receipt.reason),
1459
1393
  pc: (0, import_math4.bn)(receipt.pc),
1460
1394
  is: (0, import_math4.bn)(receipt.is),
@@ -1465,7 +1399,7 @@ function assembleReceiptByType(receipt) {
1465
1399
  case "REVERT" /* Revert */: {
1466
1400
  const revertReceipt = {
1467
1401
  type: import_transactions3.ReceiptType.Revert,
1468
- id: hexOrZero(receipt.id || receipt.contractId),
1402
+ id: hexOrZero(receipt.contract?.id),
1469
1403
  val: (0, import_math4.bn)(receipt.ra),
1470
1404
  pc: (0, import_math4.bn)(receipt.pc),
1471
1405
  is: (0, import_math4.bn)(receipt.is)
@@ -1475,7 +1409,7 @@ function assembleReceiptByType(receipt) {
1475
1409
  case "LOG" /* Log */: {
1476
1410
  const logReceipt = {
1477
1411
  type: import_transactions3.ReceiptType.Log,
1478
- id: hexOrZero(receipt.id || receipt.contractId),
1412
+ id: hexOrZero(receipt.contract?.id),
1479
1413
  val0: (0, import_math4.bn)(receipt.ra),
1480
1414
  val1: (0, import_math4.bn)(receipt.rb),
1481
1415
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1488,7 +1422,7 @@ function assembleReceiptByType(receipt) {
1488
1422
  case "LOG_DATA" /* LogData */: {
1489
1423
  const logDataReceipt = {
1490
1424
  type: import_transactions3.ReceiptType.LogData,
1491
- id: hexOrZero(receipt.id || receipt.contractId),
1425
+ id: hexOrZero(receipt.contract?.id),
1492
1426
  val0: (0, import_math4.bn)(receipt.ra),
1493
1427
  val1: (0, import_math4.bn)(receipt.rb),
1494
1428
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1502,8 +1436,8 @@ function assembleReceiptByType(receipt) {
1502
1436
  case "TRANSFER" /* Transfer */: {
1503
1437
  const transferReceipt = {
1504
1438
  type: import_transactions3.ReceiptType.Transfer,
1505
- from: hexOrZero(receipt.id || receipt.contractId),
1506
- to: hexOrZero(receipt.toAddress || receipt?.to),
1439
+ from: hexOrZero(receipt.contract?.id),
1440
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1507
1441
  amount: (0, import_math4.bn)(receipt.amount),
1508
1442
  assetId: hexOrZero(receipt.assetId),
1509
1443
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1514,8 +1448,8 @@ function assembleReceiptByType(receipt) {
1514
1448
  case "TRANSFER_OUT" /* TransferOut */: {
1515
1449
  const transferOutReceipt = {
1516
1450
  type: import_transactions3.ReceiptType.TransferOut,
1517
- from: hexOrZero(receipt.id || receipt.contractId),
1518
- to: hexOrZero(receipt.toAddress || receipt.to),
1451
+ from: hexOrZero(receipt.contract?.id),
1452
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1519
1453
  amount: (0, import_math4.bn)(receipt.amount),
1520
1454
  assetId: hexOrZero(receipt.assetId),
1521
1455
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1558,7 +1492,7 @@ function assembleReceiptByType(receipt) {
1558
1492
  return receiptMessageOut;
1559
1493
  }
1560
1494
  case "MINT" /* Mint */: {
1561
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1495
+ const contractId = hexOrZero(receipt.contract?.id);
1562
1496
  const subId = hexOrZero(receipt.subId);
1563
1497
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1564
1498
  const mintReceipt = {
@@ -1573,7 +1507,7 @@ function assembleReceiptByType(receipt) {
1573
1507
  return mintReceipt;
1574
1508
  }
1575
1509
  case "BURN" /* Burn */: {
1576
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1510
+ const contractId = hexOrZero(receipt.contract?.id);
1577
1511
  const subId = hexOrZero(receipt.subId);
1578
1512
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1579
1513
  const burnReceipt = {
@@ -1658,6 +1592,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1658
1592
  var import_math5 = require("@fuel-ts/math");
1659
1593
  var import_transactions4 = require("@fuel-ts/transactions");
1660
1594
  var import_utils6 = require("@fuel-ts/utils");
1595
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1661
1596
  var getGasUsedFromReceipts = (receipts) => {
1662
1597
  const scriptResult = receipts.filter(
1663
1598
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1678,28 +1613,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1678
1613
  }
1679
1614
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1680
1615
  const witnessCache = [];
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) => {
1616
+ const totalGas = inputs.reduce((total, input) => {
1696
1617
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1697
1618
  return total.add(
1698
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1619
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1699
1620
  );
1700
1621
  }
1701
- return total.add(gasCosts.ecr1);
1702
- }, (0, import_math5.bn)(0));
1622
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1623
+ witnessCache.push(input.witnessIndex);
1624
+ return total.add(gasCosts.ecr1);
1625
+ }
1626
+ return total;
1627
+ }, (0, import_math5.bn)());
1703
1628
  return totalGas;
1704
1629
  }
1705
1630
  function getMinGas(params) {
@@ -1711,20 +1636,12 @@ function getMinGas(params) {
1711
1636
  return minGas;
1712
1637
  }
1713
1638
  function getMaxGas(params) {
1714
- const {
1715
- gasPerByte,
1716
- witnessesLength,
1717
- witnessLimit,
1718
- minGas,
1719
- gasLimit = (0, import_math5.bn)(0),
1720
- maxGasPerTx
1721
- } = params;
1639
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1722
1640
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1723
1641
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1724
1642
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1725
1643
  }
1726
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1727
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1644
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1728
1645
  }
1729
1646
  function calculateMetadataGasForTxCreate({
1730
1647
  gasCosts,
@@ -1746,10 +1663,6 @@ function calculateMetadataGasForTxScript({
1746
1663
  }) {
1747
1664
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1748
1665
  }
1749
- var calculateGasFee = (params) => {
1750
- const { gas, gasPrice, priceFactor, tip } = params;
1751
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1752
- };
1753
1666
 
1754
1667
  // src/providers/utils/json.ts
1755
1668
  var import_utils7 = require("@fuel-ts/utils");
@@ -1898,7 +1811,7 @@ var witnessify = (value) => {
1898
1811
  // src/providers/transaction-request/transaction-request.ts
1899
1812
  var BaseTransactionRequest = class {
1900
1813
  /** Gas price for transaction */
1901
- tip;
1814
+ gasPrice;
1902
1815
  /** Block until which tx cannot be included */
1903
1816
  maturity;
1904
1817
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1917,7 +1830,7 @@ var BaseTransactionRequest = class {
1917
1830
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1918
1831
  */
1919
1832
  constructor({
1920
- tip,
1833
+ gasPrice,
1921
1834
  maturity,
1922
1835
  maxFee,
1923
1836
  witnessLimit,
@@ -1925,7 +1838,7 @@ var BaseTransactionRequest = class {
1925
1838
  outputs,
1926
1839
  witnesses
1927
1840
  } = {}) {
1928
- this.tip = (0, import_math7.bn)(tip);
1841
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1929
1842
  this.maturity = maturity ?? 0;
1930
1843
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1931
1844
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1936,9 +1849,9 @@ var BaseTransactionRequest = class {
1936
1849
  static getPolicyMeta(req) {
1937
1850
  let policyTypes = 0;
1938
1851
  const policies = [];
1939
- if (req.tip) {
1940
- policyTypes += import_transactions6.PolicyType.Tip;
1941
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1852
+ if (req.gasPrice) {
1853
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1854
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1942
1855
  }
1943
1856
  if (req.witnessLimit) {
1944
1857
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -2125,10 +2038,10 @@ var BaseTransactionRequest = class {
2125
2038
  * @param predicate - Predicate bytes.
2126
2039
  * @param predicateData - Predicate data bytes.
2127
2040
  */
2128
- addCoinInput(coin) {
2041
+ addCoinInput(coin, predicate) {
2129
2042
  const { assetId, owner, amount } = coin;
2130
2043
  let witnessIndex;
2131
- if (coin.predicate) {
2044
+ if (predicate) {
2132
2045
  witnessIndex = 0;
2133
2046
  } else {
2134
2047
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2143,7 +2056,8 @@ var BaseTransactionRequest = class {
2143
2056
  amount,
2144
2057
  assetId,
2145
2058
  txPointer: "0x00000000000000000000000000000000",
2146
- witnessIndex
2059
+ witnessIndex,
2060
+ predicate: predicate?.bytes
2147
2061
  };
2148
2062
  this.pushInput(input);
2149
2063
  this.addChangeOutput(owner, assetId);
@@ -2156,11 +2070,11 @@ var BaseTransactionRequest = class {
2156
2070
  * @param predicate - Predicate bytes.
2157
2071
  * @param predicateData - Predicate data bytes.
2158
2072
  */
2159
- addMessageInput(message) {
2073
+ addMessageInput(message, predicate) {
2160
2074
  const { recipient, sender, amount } = message;
2161
2075
  const assetId = import_configs7.BaseAssetId;
2162
2076
  let witnessIndex;
2163
- if (message.predicate) {
2077
+ if (predicate) {
2164
2078
  witnessIndex = 0;
2165
2079
  } else {
2166
2080
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2174,7 +2088,8 @@ var BaseTransactionRequest = class {
2174
2088
  sender: sender.toB256(),
2175
2089
  recipient: recipient.toB256(),
2176
2090
  amount,
2177
- witnessIndex
2091
+ witnessIndex,
2092
+ predicate: predicate?.bytes
2178
2093
  };
2179
2094
  this.pushInput(input);
2180
2095
  this.addChangeOutput(recipient, assetId);
@@ -2205,6 +2120,32 @@ var BaseTransactionRequest = class {
2205
2120
  resources.forEach((resource) => this.addResource(resource));
2206
2121
  return this;
2207
2122
  }
2123
+ /**
2124
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2125
+ * outputs from the related assetIds.
2126
+ *
2127
+ * @param resources - The resources to add.
2128
+ * @returns This transaction.
2129
+ */
2130
+ addPredicateResource(resource, predicate) {
2131
+ if (isCoin(resource)) {
2132
+ this.addCoinInput(resource, predicate);
2133
+ } else {
2134
+ this.addMessageInput(resource, predicate);
2135
+ }
2136
+ return this;
2137
+ }
2138
+ /**
2139
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2140
+ * from the related assetIds.
2141
+ *
2142
+ * @param resources - The resources to add.
2143
+ * @returns This transaction.
2144
+ */
2145
+ addPredicateResources(resources, predicate) {
2146
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2147
+ return this;
2148
+ }
2208
2149
  /**
2209
2150
  * Adds a coin output to the transaction.
2210
2151
  *
@@ -2284,7 +2225,7 @@ var BaseTransactionRequest = class {
2284
2225
  }
2285
2226
  calculateMaxGas(chainInfo, minGas) {
2286
2227
  const { consensusParameters } = chainInfo;
2287
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2228
+ const { gasPerByte } = consensusParameters;
2288
2229
  const witnessesLength = this.toTransaction().witnesses.reduce(
2289
2230
  (acc, wit) => acc + wit.dataLength,
2290
2231
  0
@@ -2293,8 +2234,7 @@ var BaseTransactionRequest = class {
2293
2234
  gasPerByte,
2294
2235
  minGas,
2295
2236
  witnessesLength,
2296
- witnessLimit: this.witnessLimit,
2297
- maxGasPerTx
2237
+ witnessLimit: this.witnessLimit
2298
2238
  });
2299
2239
  }
2300
2240
  /**
@@ -2312,20 +2252,17 @@ var BaseTransactionRequest = class {
2312
2252
  });
2313
2253
  const updateAssetInput = (assetId, quantity) => {
2314
2254
  const assetInput = findAssetInput(assetId);
2315
- let usedQuantity = quantity;
2316
- if (assetId === import_configs7.BaseAssetId) {
2317
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2318
- }
2319
2255
  if (assetInput && "assetId" in assetInput) {
2320
- assetInput.id = (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34));
2321
- assetInput.amount = usedQuantity;
2256
+ assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2257
+ assetInput.amount = quantity;
2322
2258
  } else {
2323
2259
  this.addResources([
2324
2260
  {
2325
- id: (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34)),
2326
- amount: usedQuantity,
2261
+ id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2262
+ amount: quantity,
2327
2263
  assetId,
2328
2264
  owner: resourcesOwner || import_address.Address.fromRandom(),
2265
+ maturity: 0,
2329
2266
  blockCreated: (0, import_math7.bn)(1),
2330
2267
  txCreatedIdx: (0, import_math7.bn)(1)
2331
2268
  }
@@ -2357,7 +2294,7 @@ var BaseTransactionRequest = class {
2357
2294
  toJSON() {
2358
2295
  return normalizeJSON(this);
2359
2296
  }
2360
- updatePredicateGasUsed(inputs) {
2297
+ updatePredicateInputs(inputs) {
2361
2298
  this.inputs.forEach((i) => {
2362
2299
  let correspondingInput;
2363
2300
  switch (i.type) {
@@ -2379,15 +2316,6 @@ var BaseTransactionRequest = class {
2379
2316
  }
2380
2317
  });
2381
2318
  }
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
- }
2391
2319
  };
2392
2320
 
2393
2321
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2534,8 +2462,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2534
2462
  return {
2535
2463
  type: import_transactions8.TransactionType.Create,
2536
2464
  ...baseTransaction,
2465
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2537
2466
  bytecodeWitnessIndex,
2538
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2467
+ storageSlotsCount: storageSlots.length,
2539
2468
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2540
2469
  storageSlots
2541
2470
  };
@@ -2584,7 +2513,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2584
2513
  };
2585
2514
 
2586
2515
  // src/providers/transaction-request/script-transaction-request.ts
2587
- var import_abi_coder = require("@fuel-ts/abi-coder");
2516
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2588
2517
  var import_address2 = require("@fuel-ts/address");
2589
2518
  var import_configs10 = require("@fuel-ts/address/configs");
2590
2519
  var import_math10 = require("@fuel-ts/math");
@@ -2658,8 +2587,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2658
2587
  type: import_transactions9.TransactionType.Script,
2659
2588
  scriptGasLimit: this.gasLimit,
2660
2589
  ...super.getBaseTransaction(),
2661
- scriptLength: (0, import_math10.bn)(script.length),
2662
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2590
+ scriptLength: script.length,
2591
+ scriptDataLength: scriptData.length,
2663
2592
  receiptsRoot: import_configs10.ZeroBytes32,
2664
2593
  script: (0, import_utils15.hexlify)(script),
2665
2594
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2723,7 +2652,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2723
2652
  }
2724
2653
  calculateMaxGas(chainInfo, minGas) {
2725
2654
  const { consensusParameters } = chainInfo;
2726
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2655
+ const { gasPerByte } = consensusParameters;
2727
2656
  const witnessesLength = this.toTransaction().witnesses.reduce(
2728
2657
  (acc, wit) => acc + wit.dataLength,
2729
2658
  0
@@ -2733,8 +2662,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2733
2662
  minGas,
2734
2663
  witnessesLength,
2735
2664
  witnessLimit: this.witnessLimit,
2736
- gasLimit: this.gasLimit,
2737
- maxGasPerTx
2665
+ gasLimit: this.gasLimit
2738
2666
  });
2739
2667
  }
2740
2668
  /**
@@ -2777,7 +2705,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2777
2705
  * @returns The current instance of the `ScriptTransactionRequest`.
2778
2706
  */
2779
2707
  setData(abi, args) {
2780
- const abiInterface = new import_abi_coder.Interface(abi);
2708
+ const abiInterface = new import_abi_coder3.Interface(abi);
2781
2709
  this.scriptData = abiInterface.functions.main.encodeArguments(args);
2782
2710
  return this;
2783
2711
  }
@@ -2809,32 +2737,15 @@ var transactionRequestify = (obj) => {
2809
2737
  }
2810
2738
  }
2811
2739
  };
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
- );
2827
2740
 
2828
2741
  // src/providers/transaction-response/transaction-response.ts
2829
2742
  var import_errors13 = require("@fuel-ts/errors");
2830
- var import_math15 = require("@fuel-ts/math");
2831
- var import_transactions18 = require("@fuel-ts/transactions");
2832
- var import_utils20 = require("@fuel-ts/utils");
2743
+ var import_math14 = require("@fuel-ts/math");
2744
+ var import_transactions17 = require("@fuel-ts/transactions");
2745
+ var import_utils21 = require("@fuel-ts/utils");
2833
2746
 
2834
2747
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2835
- var import_math14 = require("@fuel-ts/math");
2836
- var import_transactions16 = require("@fuel-ts/transactions");
2837
- var import_utils18 = require("@fuel-ts/utils");
2748
+ var import_utils19 = require("@fuel-ts/utils");
2838
2749
 
2839
2750
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2840
2751
  var import_math11 = require("@fuel-ts/math");
@@ -2842,10 +2753,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2842
2753
  var import_utils16 = require("@fuel-ts/utils");
2843
2754
  var calculateTransactionFee = (params) => {
2844
2755
  const {
2845
- gasPrice,
2756
+ gasUsed,
2846
2757
  rawPayload,
2847
- tip,
2848
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2758
+ consensusParameters: { gasCosts, feeParams }
2849
2759
  } = params;
2850
2760
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2851
2761
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2855,7 +2765,8 @@ var calculateTransactionFee = (params) => {
2855
2765
  return {
2856
2766
  fee: (0, import_math11.bn)(0),
2857
2767
  minFee: (0, import_math11.bn)(0),
2858
- maxFee: (0, import_math11.bn)(0)
2768
+ maxFee: (0, import_math11.bn)(0),
2769
+ feeFromGasUsed: (0, import_math11.bn)(0)
2859
2770
  };
2860
2771
  }
2861
2772
  const { type, witnesses, inputs, policies } = transaction;
@@ -2887,6 +2798,7 @@ var calculateTransactionFee = (params) => {
2887
2798
  metadataGas,
2888
2799
  txBytesSize: transactionBytes.length
2889
2800
  });
2801
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2890
2802
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2891
2803
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2892
2804
  const maxGas = getMaxGas({
@@ -2894,25 +2806,17 @@ var calculateTransactionFee = (params) => {
2894
2806
  minGas,
2895
2807
  witnessesLength,
2896
2808
  gasLimit,
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
2809
+ witnessLimit
2911
2810
  });
2811
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2812
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2813
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2814
+ const fee = minFee.add(feeFromGasUsed);
2912
2815
  return {
2816
+ fee,
2913
2817
  minFee,
2914
2818
  maxFee,
2915
- fee: maxFee
2819
+ feeFromGasUsed
2916
2820
  };
2917
2821
  };
2918
2822
 
@@ -2923,17 +2827,17 @@ var import_math13 = require("@fuel-ts/math");
2923
2827
  var import_transactions14 = require("@fuel-ts/transactions");
2924
2828
 
2925
2829
  // src/providers/transaction-summary/call.ts
2926
- var import_abi_coder2 = require("@fuel-ts/abi-coder");
2830
+ var import_abi_coder4 = require("@fuel-ts/abi-coder");
2927
2831
  var import_math12 = require("@fuel-ts/math");
2928
2832
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2929
- const abiInterface = new import_abi_coder2.Interface(abi);
2833
+ const abiInterface = new import_abi_coder4.Interface(abi);
2930
2834
  const callFunctionSelector = receipt.param1.toHex(8);
2931
2835
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2932
2836
  const inputs = functionFragment.jsonFn.inputs;
2933
2837
  let encodedArgs;
2934
2838
  if (functionFragment.isInputDataPointer) {
2935
2839
  if (rawPayload) {
2936
- const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2840
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2937
2841
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2938
2842
  }
2939
2843
  } else {
@@ -3526,12 +3430,10 @@ function assembleTransactionSummary(params) {
3526
3430
  gqlTransactionStatus,
3527
3431
  abiMap = {},
3528
3432
  maxInputs,
3529
- gasCosts,
3530
- maxGasPerTx,
3531
- gasPrice
3433
+ gasCosts
3532
3434
  } = params;
3533
3435
  const gasUsed = getGasUsedFromReceipts(receipts);
3534
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3436
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3535
3437
  const operations = getOperations({
3536
3438
  transactionType: transaction.type,
3537
3439
  inputs: transaction.inputs || [],
@@ -3542,14 +3444,11 @@ function assembleTransactionSummary(params) {
3542
3444
  maxInputs
3543
3445
  });
3544
3446
  const typeName = getTransactionTypeName(transaction.type);
3545
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3546
3447
  const { fee } = calculateTransactionFee({
3547
- gasPrice,
3448
+ gasUsed,
3548
3449
  rawPayload,
3549
- tip,
3550
3450
  consensusParameters: {
3551
3451
  gasCosts,
3552
- maxGasPerTx,
3553
3452
  feeParams: {
3554
3453
  gasPerByte,
3555
3454
  gasPriceFactor
@@ -3561,7 +3460,7 @@ function assembleTransactionSummary(params) {
3561
3460
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3562
3461
  let date;
3563
3462
  if (time) {
3564
- date = import_utils18.DateTime.fromTai64(time);
3463
+ date = import_utils19.DateTime.fromTai64(time);
3565
3464
  }
3566
3465
  const transactionSummary = {
3567
3466
  id,
@@ -3588,13 +3487,13 @@ function assembleTransactionSummary(params) {
3588
3487
  }
3589
3488
 
3590
3489
  // src/providers/transaction-response/getDecodedLogs.ts
3591
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3592
- var import_transactions17 = require("@fuel-ts/transactions");
3490
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
3491
+ var import_transactions16 = require("@fuel-ts/transactions");
3593
3492
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3594
3493
  return receipts.reduce((logs, receipt) => {
3595
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3596
- const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3597
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3494
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3495
+ const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3496
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3598
3497
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3599
3498
  logs.push(decodedLog);
3600
3499
  }
@@ -3609,7 +3508,7 @@ var TransactionResponse = class {
3609
3508
  /** Current provider */
3610
3509
  provider;
3611
3510
  /** Gas used on the transaction */
3612
- gasUsed = (0, import_math15.bn)(0);
3511
+ gasUsed = (0, import_math14.bn)(0);
3613
3512
  /** The graphql Transaction with receipts object. */
3614
3513
  gqlTransaction;
3615
3514
  abis;
@@ -3667,8 +3566,8 @@ var TransactionResponse = class {
3667
3566
  * @returns The decoded transaction.
3668
3567
  */
3669
3568
  decodeTransaction(transactionWithReceipts) {
3670
- return new import_transactions18.TransactionCoder().decode(
3671
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3569
+ return new import_transactions17.TransactionCoder().decode(
3570
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3672
3571
  0
3673
3572
  )?.[0];
3674
3573
  }
@@ -3687,27 +3586,20 @@ var TransactionResponse = class {
3687
3586
  const decodedTransaction = this.decodeTransaction(
3688
3587
  transaction
3689
3588
  );
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
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3590
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3697
3591
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3698
3592
  const transactionSummary = assembleTransactionSummary({
3699
3593
  id: this.id,
3700
3594
  receipts,
3701
3595
  transaction: decodedTransaction,
3702
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3596
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3703
3597
  gqlTransactionStatus: transaction.status,
3704
3598
  gasPerByte,
3705
3599
  gasPriceFactor,
3706
3600
  abiMap: contractsAbiMap,
3707
3601
  maxInputs,
3708
- gasCosts,
3709
- maxGasPerTx,
3710
- gasPrice
3602
+ gasCosts
3711
3603
  });
3712
3604
  return transactionSummary;
3713
3605
  }
@@ -3834,29 +3726,29 @@ var processGqlChain = (chain) => {
3834
3726
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3835
3727
  return {
3836
3728
  name,
3837
- baseChainHeight: (0, import_math16.bn)(daHeight),
3729
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3838
3730
  consensusParameters: {
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),
3731
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3732
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3733
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3734
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3735
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3736
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3737
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3738
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3739
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3740
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3741
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3742
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3743
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3744
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3745
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3854
3746
  gasCosts
3855
3747
  },
3856
3748
  gasCosts,
3857
3749
  latestBlock: {
3858
3750
  id: latestBlock.id,
3859
- height: (0, import_math16.bn)(latestBlock.height),
3751
+ height: (0, import_math15.bn)(latestBlock.header.height),
3860
3752
  time: latestBlock.header.time,
3861
3753
  transactions: latestBlock.transactions.map((i) => ({
3862
3754
  id: i.id
@@ -3950,8 +3842,10 @@ var _Provider = class {
3950
3842
  * Returns some helpful parameters related to gas fees.
3951
3843
  */
3952
3844
  getGasConfig() {
3845
+ const { minGasPrice } = this.getNode();
3953
3846
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3954
3847
  return {
3848
+ minGasPrice,
3955
3849
  maxGasPerTx,
3956
3850
  maxGasPerPredicate,
3957
3851
  gasPriceFactor,
@@ -4039,7 +3933,7 @@ var _Provider = class {
4039
3933
  name,
4040
3934
  consensusParameters: { chainId }
4041
3935
  } = await this.getChain();
4042
- const network = new import_ethers2.Network(name, chainId.toNumber());
3936
+ const network = new import_ethers.Network(name, chainId.toNumber());
4043
3937
  return Promise.resolve(network);
4044
3938
  }
4045
3939
  /**
@@ -4049,7 +3943,7 @@ var _Provider = class {
4049
3943
  */
4050
3944
  async getBlockNumber() {
4051
3945
  const { chain } = await this.operations.getChain();
4052
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3946
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4053
3947
  }
4054
3948
  /**
4055
3949
  * Returns the chain information.
@@ -4059,11 +3953,13 @@ var _Provider = class {
4059
3953
  async fetchNode() {
4060
3954
  const { nodeInfo } = await this.operations.getNodeInfo();
4061
3955
  const processedNodeInfo = {
4062
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4063
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3956
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3957
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3958
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4064
3959
  nodeVersion: nodeInfo.nodeVersion,
4065
3960
  utxoValidation: nodeInfo.utxoValidation,
4066
- vmBacktrace: nodeInfo.vmBacktrace
3961
+ vmBacktrace: nodeInfo.vmBacktrace,
3962
+ peers: nodeInfo.peers
4067
3963
  };
4068
3964
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
4069
3965
  return processedNodeInfo;
@@ -4105,9 +4001,9 @@ var _Provider = class {
4105
4001
  if (estimateTxDependencies) {
4106
4002
  await this.estimateTxDependencies(transactionRequest);
4107
4003
  }
4108
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4004
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4109
4005
  let abis;
4110
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4006
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4111
4007
  abis = transactionRequest.abis;
4112
4008
  }
4113
4009
  if (awaitExecution) {
@@ -4148,14 +4044,15 @@ var _Provider = class {
4148
4044
  if (estimateTxDependencies) {
4149
4045
  return this.estimateTxDependencies(transactionRequest);
4150
4046
  }
4151
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4152
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4153
- encodedTransactions: encodedTransaction,
4047
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4048
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4049
+ encodedTransaction,
4154
4050
  utxoValidation: utxoValidation || false
4155
4051
  });
4156
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4157
- const receipts = rawReceipts.map(processGqlReceipt);
4158
- return { receipts, dryrunStatus: status };
4052
+ const receipts = gqlReceipts.map(processGqlReceipt);
4053
+ return {
4054
+ receipts
4055
+ };
4159
4056
  }
4160
4057
  /**
4161
4058
  * Verifies whether enough gas is available to complete transaction.
@@ -4166,13 +4063,13 @@ var _Provider = class {
4166
4063
  async estimatePredicates(transactionRequest) {
4167
4064
  const shouldEstimatePredicates = Boolean(
4168
4065
  transactionRequest.inputs.find(
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()
4066
+ (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()
4170
4067
  )
4171
4068
  );
4172
4069
  if (!shouldEstimatePredicates) {
4173
4070
  return transactionRequest;
4174
4071
  }
4175
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4072
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4176
4073
  const response = await this.operations.estimatePredicates({
4177
4074
  encodedTransaction
4178
4075
  });
@@ -4181,7 +4078,7 @@ var _Provider = class {
4181
4078
  } = response;
4182
4079
  if (inputs) {
4183
4080
  inputs.forEach((input, index) => {
4184
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4081
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4185
4082
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4186
4083
  }
4187
4084
  });
@@ -4194,31 +4091,31 @@ var _Provider = class {
4194
4091
  * If there are missing variable outputs,
4195
4092
  * `addVariableOutputs` is called on the transaction.
4196
4093
  *
4094
+ * @privateRemarks
4095
+ * TODO: Investigate support for missing contract IDs
4096
+ * TODO: Add support for missing output messages
4197
4097
  *
4198
4098
  * @param transactionRequest - The transaction request object.
4199
4099
  * @returns A promise.
4200
4100
  */
4201
4101
  async estimateTxDependencies(transactionRequest) {
4202
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4102
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4203
4103
  return {
4204
4104
  receipts: [],
4205
4105
  outputVariables: 0,
4206
4106
  missingContractIds: []
4207
4107
  };
4208
4108
  }
4109
+ await this.estimatePredicates(transactionRequest);
4209
4110
  let receipts = [];
4210
4111
  const missingContractIds = [];
4211
4112
  let outputVariables = 0;
4212
- let dryrunStatus;
4213
4113
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4214
- const {
4215
- dryRun: [{ receipts: rawReceipts, status }]
4216
- } = await this.operations.dryRun({
4217
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4114
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4115
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4218
4116
  utxoValidation: false
4219
4117
  });
4220
- receipts = rawReceipts.map(processGqlReceipt);
4221
- dryrunStatus = status;
4118
+ receipts = gqlReceipts.map(processGqlReceipt);
4222
4119
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4223
4120
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4224
4121
  if (hasMissingOutputs) {
@@ -4228,11 +4125,6 @@ var _Provider = class {
4228
4125
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4229
4126
  missingContractIds.push(contractId);
4230
4127
  });
4231
- const { maxFee } = await this.estimateTxGasAndFee({
4232
- transactionRequest,
4233
- optimizeGas: false
4234
- });
4235
- transactionRequest.maxFee = maxFee;
4236
4128
  } else {
4237
4129
  break;
4238
4130
  }
@@ -4240,133 +4132,37 @@ var _Provider = class {
4240
4132
  return {
4241
4133
  receipts,
4242
4134
  outputVariables,
4243
- missingContractIds,
4244
- dryrunStatus
4135
+ missingContractIds
4245
4136
  };
4246
4137
  }
4247
4138
  /**
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.
4139
+ * Estimates the transaction gas and fee based on the provided transaction request.
4140
+ * @param transactionRequest - The transaction request object.
4141
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4256
4142
  */
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;
4143
+ estimateTxGasAndFee(params) {
4144
+ const { transactionRequest } = params;
4145
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4335
4146
  const chainInfo = this.getChain();
4336
- const { gasPriceFactor } = this.getGasConfig();
4147
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4148
+ transactionRequest.gasPrice = gasPrice;
4337
4149
  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) {
4150
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4151
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4152
+ if (transactionRequest.gasLimit.eq(0)) {
4351
4153
  transactionRequest.gasLimit = minGas;
4352
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4353
- transactionRequest.gasLimit = gasLimit;
4154
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4155
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4156
+ );
4354
4157
  }
4355
4158
  }
4356
4159
  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);
4160
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4363
4161
  return {
4364
4162
  minGas,
4365
4163
  minFee,
4366
4164
  maxGas,
4367
- maxFee,
4368
- gasPrice,
4369
- gasLimit
4165
+ maxFee
4370
4166
  };
4371
4167
  }
4372
4168
  /**
@@ -4384,17 +4180,15 @@ var _Provider = class {
4384
4180
  if (estimateTxDependencies) {
4385
4181
  return this.estimateTxDependencies(transactionRequest);
4386
4182
  }
4387
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4388
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4389
- encodedTransactions,
4183
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4184
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4185
+ encodedTransaction,
4390
4186
  utxoValidation: true
4391
4187
  });
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 };
4188
+ const receipts = gqlReceipts.map(processGqlReceipt);
4189
+ return {
4190
+ receipts
4191
+ };
4398
4192
  }
4399
4193
  /**
4400
4194
  * Returns a transaction cost to enable user
@@ -4411,80 +4205,77 @@ var _Provider = class {
4411
4205
  * @param tolerance - The tolerance to add on top of the gasUsed.
4412
4206
  * @returns A promise that resolves to the transaction cost object.
4413
4207
  */
4414
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4208
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4209
+ estimateTxDependencies = true,
4210
+ estimatePredicates = true,
4211
+ resourcesOwner,
4212
+ signatureCallback
4213
+ } = {}) {
4415
4214
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4416
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4215
+ const { minGasPrice } = this.getGasConfig();
4216
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4217
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4417
4218
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4418
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4219
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4419
4220
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4420
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4421
4221
  if (isScriptTransaction) {
4422
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4222
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4423
4223
  }
4424
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4425
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4224
+ if (estimatePredicates) {
4225
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4226
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4227
+ }
4228
+ await this.estimatePredicates(txRequestClone);
4426
4229
  }
4427
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4428
- let addedSignatures = 0;
4429
4230
  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
4231
+ await signatureCallback(txRequestClone);
4232
+ }
4233
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4234
+ transactionRequest: txRequestClone
4438
4235
  });
4439
- txRequestClone.maxFee = maxFee;
4440
4236
  let receipts = [];
4441
4237
  let missingContractIds = [];
4442
4238
  let outputVariables = 0;
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;
4239
+ let gasUsed = (0, import_math15.bn)(0);
4240
+ if (isScriptTransaction && estimateTxDependencies) {
4241
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4450
4242
  const result = await this.estimateTxDependencies(txRequestClone);
4451
4243
  receipts = result.receipts;
4452
4244
  outputVariables = result.outputVariables;
4453
4245
  missingContractIds = result.missingContractIds;
4454
- gasUsed = getGasUsedFromReceipts(receipts);
4246
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4455
4247
  txRequestClone.gasLimit = gasUsed;
4456
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4457
- transactionRequest: txRequestClone,
4458
- gasPrice
4248
+ txRequestClone.gasPrice = setGasPrice;
4249
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4250
+ transactionRequest: txRequestClone
4459
4251
  }));
4460
4252
  }
4461
4253
  return {
4462
4254
  requiredQuantities: allQuantities,
4463
4255
  receipts,
4464
4256
  gasUsed,
4465
- gasPrice,
4257
+ minGasPrice,
4258
+ gasPrice: setGasPrice,
4466
4259
  minGas,
4467
4260
  maxGas,
4468
4261
  minFee,
4469
4262
  maxFee,
4263
+ estimatedInputs: txRequestClone.inputs,
4470
4264
  outputVariables,
4471
- missingContractIds,
4472
- addedSignatures,
4473
- estimatedPredicates: txRequestClone.inputs
4265
+ missingContractIds
4474
4266
  };
4475
4267
  }
4476
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4268
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4477
4269
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4478
4270
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4479
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4480
- quantitiesToContract
4481
- });
4271
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4482
4272
  transactionRequest.addResources(
4483
4273
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4484
4274
  );
4485
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4486
- quantitiesToContract
4487
- });
4275
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4276
+ transactionRequest,
4277
+ forwardingQuantities
4278
+ );
4488
4279
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4489
4280
  return {
4490
4281
  resources,
@@ -4500,16 +4291,17 @@ var _Provider = class {
4500
4291
  const result = await this.operations.getCoins({
4501
4292
  first: 10,
4502
4293
  ...paginationArgs,
4503
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4294
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4504
4295
  });
4505
4296
  const coins = result.coins.edges.map((edge) => edge.node);
4506
4297
  return coins.map((coin) => ({
4507
4298
  id: coin.utxoId,
4508
4299
  assetId: coin.assetId,
4509
- amount: (0, import_math16.bn)(coin.amount),
4300
+ amount: (0, import_math15.bn)(coin.amount),
4510
4301
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4511
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4512
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4302
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4303
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4304
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4513
4305
  }));
4514
4306
  }
4515
4307
  /**
@@ -4523,19 +4315,19 @@ var _Provider = class {
4523
4315
  async getResourcesToSpend(owner, quantities, excludedIds) {
4524
4316
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4525
4317
  const excludeInput = {
4526
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4527
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4318
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4319
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4528
4320
  };
4529
4321
  if (this.cache) {
4530
4322
  const uniqueUtxos = new Set(
4531
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4323
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4532
4324
  );
4533
4325
  excludeInput.utxos = Array.from(uniqueUtxos);
4534
4326
  }
4535
4327
  const coinsQuery = {
4536
4328
  owner: ownerAddress.toB256(),
4537
4329
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4538
- assetId: (0, import_utils22.hexlify)(assetId),
4330
+ assetId: (0, import_utils23.hexlify)(assetId),
4539
4331
  amount: amount.toString(10),
4540
4332
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4541
4333
  })),
@@ -4546,9 +4338,9 @@ var _Provider = class {
4546
4338
  switch (coin.__typename) {
4547
4339
  case "MessageCoin":
4548
4340
  return {
4549
- amount: (0, import_math16.bn)(coin.amount),
4341
+ amount: (0, import_math15.bn)(coin.amount),
4550
4342
  assetId: coin.assetId,
4551
- daHeight: (0, import_math16.bn)(coin.daHeight),
4343
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4552
4344
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4553
4345
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4554
4346
  nonce: coin.nonce
@@ -4556,11 +4348,12 @@ var _Provider = class {
4556
4348
  case "Coin":
4557
4349
  return {
4558
4350
  id: coin.utxoId,
4559
- amount: (0, import_math16.bn)(coin.amount),
4351
+ amount: (0, import_math15.bn)(coin.amount),
4560
4352
  assetId: coin.assetId,
4561
4353
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4562
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4563
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4354
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4355
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4356
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4564
4357
  };
4565
4358
  default:
4566
4359
  return null;
@@ -4577,13 +4370,13 @@ var _Provider = class {
4577
4370
  async getBlock(idOrHeight) {
4578
4371
  let variables;
4579
4372
  if (typeof idOrHeight === "number") {
4580
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4373
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4581
4374
  } else if (idOrHeight === "latest") {
4582
4375
  variables = { height: (await this.getBlockNumber()).toString(10) };
4583
4376
  } else if (idOrHeight.length === 66) {
4584
4377
  variables = { blockId: idOrHeight };
4585
4378
  } else {
4586
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4379
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4587
4380
  }
4588
4381
  const { block } = await this.operations.getBlock(variables);
4589
4382
  if (!block) {
@@ -4591,7 +4384,7 @@ var _Provider = class {
4591
4384
  }
4592
4385
  return {
4593
4386
  id: block.id,
4594
- height: (0, import_math16.bn)(block.height),
4387
+ height: (0, import_math15.bn)(block.header.height),
4595
4388
  time: block.header.time,
4596
4389
  transactionIds: block.transactions.map((tx) => tx.id)
4597
4390
  };
@@ -4606,7 +4399,7 @@ var _Provider = class {
4606
4399
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4607
4400
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4608
4401
  id: block.id,
4609
- height: (0, import_math16.bn)(block.height),
4402
+ height: (0, import_math15.bn)(block.header.height),
4610
4403
  time: block.header.time,
4611
4404
  transactionIds: block.transactions.map((tx) => tx.id)
4612
4405
  }));
@@ -4621,7 +4414,7 @@ var _Provider = class {
4621
4414
  async getBlockWithTransactions(idOrHeight) {
4622
4415
  let variables;
4623
4416
  if (typeof idOrHeight === "number") {
4624
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4417
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4625
4418
  } else if (idOrHeight === "latest") {
4626
4419
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4627
4420
  } else {
@@ -4633,11 +4426,11 @@ var _Provider = class {
4633
4426
  }
4634
4427
  return {
4635
4428
  id: block.id,
4636
- height: (0, import_math16.bn)(block.height, 10),
4429
+ height: (0, import_math15.bn)(block.header.height, 10),
4637
4430
  time: block.header.time,
4638
4431
  transactionIds: block.transactions.map((tx) => tx.id),
4639
4432
  transactions: block.transactions.map(
4640
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4433
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4641
4434
  )
4642
4435
  };
4643
4436
  }
@@ -4652,8 +4445,8 @@ var _Provider = class {
4652
4445
  if (!transaction) {
4653
4446
  return null;
4654
4447
  }
4655
- return new import_transactions19.TransactionCoder().decode(
4656
- (0, import_utils22.arrayify)(transaction.rawPayload),
4448
+ return new import_transactions18.TransactionCoder().decode(
4449
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4657
4450
  0
4658
4451
  )?.[0];
4659
4452
  }
@@ -4680,9 +4473,9 @@ var _Provider = class {
4680
4473
  async getContractBalance(contractId, assetId) {
4681
4474
  const { contractBalance } = await this.operations.getContractBalance({
4682
4475
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4683
- asset: (0, import_utils22.hexlify)(assetId)
4476
+ asset: (0, import_utils23.hexlify)(assetId)
4684
4477
  });
4685
- return (0, import_math16.bn)(contractBalance.amount, 10);
4478
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4686
4479
  }
4687
4480
  /**
4688
4481
  * Returns the balance for the given owner for the given asset ID.
@@ -4694,9 +4487,9 @@ var _Provider = class {
4694
4487
  async getBalance(owner, assetId) {
4695
4488
  const { balance } = await this.operations.getBalance({
4696
4489
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4697
- assetId: (0, import_utils22.hexlify)(assetId)
4490
+ assetId: (0, import_utils23.hexlify)(assetId)
4698
4491
  });
4699
- return (0, import_math16.bn)(balance.amount, 10);
4492
+ return (0, import_math15.bn)(balance.amount, 10);
4700
4493
  }
4701
4494
  /**
4702
4495
  * Returns balances for the given owner.
@@ -4714,7 +4507,7 @@ var _Provider = class {
4714
4507
  const balances = result.balances.edges.map((edge) => edge.node);
4715
4508
  return balances.map((balance) => ({
4716
4509
  assetId: balance.assetId,
4717
- amount: (0, import_math16.bn)(balance.amount)
4510
+ amount: (0, import_math15.bn)(balance.amount)
4718
4511
  }));
4719
4512
  }
4720
4513
  /**
@@ -4732,19 +4525,19 @@ var _Provider = class {
4732
4525
  });
4733
4526
  const messages = result.messages.edges.map((edge) => edge.node);
4734
4527
  return messages.map((message) => ({
4735
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4528
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4736
4529
  sender: message.sender,
4737
4530
  recipient: message.recipient,
4738
4531
  nonce: message.nonce,
4739
- amount: (0, import_math16.bn)(message.amount),
4532
+ amount: (0, import_math15.bn)(message.amount),
4740
4533
  data: message.data
4741
4534
  }),
4742
4535
  sender: import_address3.Address.fromAddressOrString(message.sender),
4743
4536
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4744
4537
  nonce: message.nonce,
4745
- amount: (0, import_math16.bn)(message.amount),
4746
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4747
- daHeight: (0, import_math16.bn)(message.daHeight)
4538
+ amount: (0, import_math15.bn)(message.amount),
4539
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4540
+ daHeight: (0, import_math15.bn)(message.daHeight)
4748
4541
  }));
4749
4542
  }
4750
4543
  /**
@@ -4797,60 +4590,44 @@ var _Provider = class {
4797
4590
  } = result.messageProof;
4798
4591
  return {
4799
4592
  messageProof: {
4800
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4593
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4801
4594
  proofSet: messageProof.proofSet
4802
4595
  },
4803
4596
  blockProof: {
4804
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4597
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4805
4598
  proofSet: blockProof.proofSet
4806
4599
  },
4807
4600
  messageBlockHeader: {
4808
4601
  id: messageBlockHeader.id,
4809
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4810
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4602
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4603
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4811
4604
  transactionsRoot: messageBlockHeader.transactionsRoot,
4812
- height: (0, import_math16.bn)(messageBlockHeader.height),
4605
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4813
4606
  prevRoot: messageBlockHeader.prevRoot,
4814
4607
  time: messageBlockHeader.time,
4815
4608
  applicationHash: messageBlockHeader.applicationHash,
4816
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4817
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4818
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4819
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4820
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4609
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4610
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4821
4611
  },
4822
4612
  commitBlockHeader: {
4823
4613
  id: commitBlockHeader.id,
4824
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4825
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4614
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4615
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4826
4616
  transactionsRoot: commitBlockHeader.transactionsRoot,
4827
- height: (0, import_math16.bn)(commitBlockHeader.height),
4617
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4828
4618
  prevRoot: commitBlockHeader.prevRoot,
4829
4619
  time: commitBlockHeader.time,
4830
4620
  applicationHash: commitBlockHeader.applicationHash,
4831
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4832
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4833
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4834
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4835
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4621
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4622
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4836
4623
  },
4837
4624
  sender: import_address3.Address.fromAddressOrString(sender),
4838
4625
  recipient: import_address3.Address.fromAddressOrString(recipient),
4839
4626
  nonce,
4840
- amount: (0, import_math16.bn)(amount),
4627
+ amount: (0, import_math15.bn)(amount),
4841
4628
  data
4842
4629
  };
4843
4630
  }
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
- }
4854
4631
  /**
4855
4632
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4856
4633
  *
@@ -4870,10 +4647,10 @@ var _Provider = class {
4870
4647
  */
4871
4648
  async produceBlocks(amount, startTime) {
4872
4649
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4873
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4874
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4650
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4651
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4875
4652
  });
4876
- return (0, import_math16.bn)(latestBlockHeight);
4653
+ return (0, import_math15.bn)(latestBlockHeight);
4877
4654
  }
4878
4655
  // eslint-disable-next-line @typescript-eslint/require-await
4879
4656
  async getTransactionResponse(transactionId) {
@@ -4887,7 +4664,7 @@ cacheInputs_fn = function(inputs) {
4887
4664
  return;
4888
4665
  }
4889
4666
  inputs.forEach((input) => {
4890
- if (input.type === import_transactions19.InputType.Coin) {
4667
+ if (input.type === import_transactions18.InputType.Coin) {
4891
4668
  this.cache?.set(input.id);
4892
4669
  }
4893
4670
  });
@@ -4897,9 +4674,9 @@ __publicField(Provider, "nodeInfoCache", {});
4897
4674
 
4898
4675
  // src/providers/transaction-summary/get-transaction-summary.ts
4899
4676
  var import_errors15 = require("@fuel-ts/errors");
4900
- var import_math17 = require("@fuel-ts/math");
4901
- var import_transactions20 = require("@fuel-ts/transactions");
4902
- var import_utils25 = require("@fuel-ts/utils");
4677
+ var import_math16 = require("@fuel-ts/math");
4678
+ var import_transactions19 = require("@fuel-ts/transactions");
4679
+ var import_utils26 = require("@fuel-ts/utils");
4903
4680
  async function getTransactionSummary(params) {
4904
4681
  const { id, provider, abiMap } = params;
4905
4682
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4911,32 +4688,25 @@ async function getTransactionSummary(params) {
4911
4688
  `Transaction not found for given id: ${id}.`
4912
4689
  );
4913
4690
  }
4914
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4915
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4691
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4692
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4916
4693
  0
4917
4694
  );
4918
- let txReceipts = [];
4919
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4920
- txReceipts = gqlTransaction.status.receipts;
4921
- }
4922
- const receipts = txReceipts.map(processGqlReceipt);
4695
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4923
4696
  const {
4924
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4697
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4925
4698
  } = provider.getChain();
4926
- const gasPrice = await provider.getLatestGasPrice();
4927
4699
  const transactionInfo = assembleTransactionSummary({
4928
4700
  id: gqlTransaction.id,
4929
4701
  receipts,
4930
4702
  transaction: decodedTransaction,
4931
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4703
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4932
4704
  gqlTransactionStatus: gqlTransaction.status,
4933
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4934
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4705
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4706
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4935
4707
  abiMap,
4936
4708
  maxInputs,
4937
- gasCosts,
4938
- maxGasPerTx,
4939
- gasPrice
4709
+ gasCosts
4940
4710
  });
4941
4711
  return {
4942
4712
  gqlTransaction,
@@ -4946,11 +4716,10 @@ async function getTransactionSummary(params) {
4946
4716
  async function getTransactionSummaryFromRequest(params) {
4947
4717
  const { provider, transactionRequest, abiMap } = params;
4948
4718
  const { receipts } = await provider.call(transactionRequest);
4949
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4719
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4950
4720
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4951
4721
  const transaction = transactionRequest.toTransaction();
4952
4722
  const transactionBytes = transactionRequest.toTransactionBytes();
4953
- const gasPrice = await provider.getLatestGasPrice();
4954
4723
  const transactionSummary = assembleTransactionSummary({
4955
4724
  receipts,
4956
4725
  transaction,
@@ -4959,9 +4728,7 @@ async function getTransactionSummaryFromRequest(params) {
4959
4728
  gasPerByte,
4960
4729
  gasPriceFactor,
4961
4730
  maxInputs,
4962
- gasCosts,
4963
- maxGasPerTx,
4964
- gasPrice
4731
+ gasCosts
4965
4732
  });
4966
4733
  return transactionSummary;
4967
4734
  }
@@ -4970,31 +4737,24 @@ async function getTransactionsSummaries(params) {
4970
4737
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4971
4738
  const { edges, pageInfo } = transactionsByOwner;
4972
4739
  const {
4973
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4740
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4974
4741
  } = provider.getChain();
4975
- const gasPrice = await provider.getLatestGasPrice();
4976
4742
  const transactions = edges.map((edge) => {
4977
4743
  const { node: gqlTransaction } = edge;
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);
4744
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4745
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4746
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4985
4747
  const transactionSummary = assembleTransactionSummary({
4986
4748
  id,
4987
4749
  receipts,
4988
4750
  transaction: decodedTransaction,
4989
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4751
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4990
4752
  gqlTransactionStatus: status,
4991
4753
  abiMap,
4992
4754
  gasPerByte,
4993
4755
  gasPriceFactor,
4994
4756
  maxInputs,
4995
- gasCosts,
4996
- maxGasPerTx,
4997
- gasPrice
4757
+ gasCosts
4998
4758
  });
4999
4759
  const output = {
5000
4760
  gqlTransaction,
@@ -5130,18 +4890,18 @@ var assets = [
5130
4890
  ];
5131
4891
 
5132
4892
  // src/utils/formatTransferToContractScriptData.ts
5133
- var import_abi_coder4 = require("@fuel-ts/abi-coder");
5134
- var import_math18 = require("@fuel-ts/math");
5135
- var import_utils26 = require("@fuel-ts/utils");
4893
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
4894
+ var import_math17 = require("@fuel-ts/math");
4895
+ var import_utils27 = require("@fuel-ts/utils");
5136
4896
  var asm = __toESM(require("@fuels/vm-asm"));
5137
4897
  var formatTransferToContractScriptData = (params) => {
5138
4898
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5139
- const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
5140
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4899
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4900
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5141
4901
  const scriptData = Uint8Array.from([
5142
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4902
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5143
4903
  ...encoded,
5144
- ...(0, import_utils26.arrayify)(assetId)
4904
+ ...(0, import_utils27.arrayify)(assetId)
5145
4905
  ]);
5146
4906
  return scriptData;
5147
4907
  };
@@ -5326,33 +5086,36 @@ var Account = class extends import_interfaces.AbstractAccount {
5326
5086
  * @param fee - The estimated transaction fee.
5327
5087
  * @returns A promise that resolves when the resources are added to the transaction.
5328
5088
  */
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),
5089
+ async fund(request, coinQuantities, fee) {
5090
+ const updatedQuantities = addAmountToAsset({
5091
+ amount: (0, import_math18.bn)(fee),
5334
5092
  assetId: import_configs12.BaseAssetId,
5335
- coinQuantities: requiredQuantities
5093
+ coinQuantities
5336
5094
  });
5337
5095
  const quantitiesDict = {};
5338
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5096
+ updatedQuantities.forEach(({ amount, assetId }) => {
5339
5097
  quantitiesDict[assetId] = {
5340
5098
  required: amount,
5341
- owned: (0, import_math19.bn)(0)
5099
+ owned: (0, import_math18.bn)(0)
5342
5100
  };
5343
5101
  });
5344
- txRequest.inputs.forEach((input) => {
5102
+ const cachedUtxos = [];
5103
+ const cachedMessages = [];
5104
+ const owner = this.address.toB256();
5105
+ request.inputs.forEach((input) => {
5345
5106
  const isResource = "amount" in input;
5346
5107
  if (isResource) {
5347
5108
  const isCoin2 = "owner" in input;
5348
5109
  if (isCoin2) {
5349
5110
  const assetId = String(input.assetId);
5350
- if (quantitiesDict[assetId]) {
5351
- const amount = (0, import_math19.bn)(input.amount);
5111
+ if (input.owner === owner && quantitiesDict[assetId]) {
5112
+ const amount = (0, import_math18.bn)(input.amount);
5352
5113
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5114
+ cachedUtxos.push(input.id);
5353
5115
  }
5354
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5116
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5355
5117
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5118
+ cachedMessages.push(input.nonce);
5356
5119
  }
5357
5120
  }
5358
5121
  });
@@ -5367,23 +5130,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5367
5130
  });
5368
5131
  const needsToBeFunded = missingQuantities.length;
5369
5132
  if (needsToBeFunded) {
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
- );
5133
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5134
+ messages: cachedMessages,
5135
+ utxos: cachedUtxos
5136
+ });
5137
+ request.addResources(resources);
5381
5138
  }
5382
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5383
- transactionRequest: requestToBeReEstimate
5384
- });
5385
- txRequest.maxFee = maxFee;
5386
- return txRequest;
5387
5139
  }
5388
5140
  /**
5389
5141
  * A helper that creates a transfer transaction request and returns it.
@@ -5391,25 +5143,28 @@ var Account = class extends import_interfaces.AbstractAccount {
5391
5143
  * @param destination - The address of the destination.
5392
5144
  * @param amount - The amount of coins to transfer.
5393
5145
  * @param assetId - The asset ID of the coins to transfer.
5394
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5146
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5395
5147
  * @returns A promise that resolves to the prepared transaction request.
5396
5148
  */
5397
5149
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5398
- const request = new ScriptTransactionRequest(txParams);
5150
+ const { minGasPrice } = this.provider.getGasConfig();
5151
+ const params = { gasPrice: minGasPrice, ...txParams };
5152
+ const request = new ScriptTransactionRequest(params);
5399
5153
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5400
- const txCost = await this.provider.getTransactionCost(request, {
5154
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5401
5155
  estimateTxDependencies: true,
5402
5156
  resourcesOwner: this
5403
5157
  });
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);
5158
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5159
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5160
+ this.validateGas({
5161
+ gasUsed,
5162
+ gasPrice: request.gasPrice,
5163
+ gasLimit: request.gasLimit,
5164
+ minGasPrice
5165
+ });
5166
+ await this.fund(request, requiredQuantities, maxFee);
5167
+ request.updatePredicateInputs(estimatedInputs);
5413
5168
  return request;
5414
5169
  }
5415
5170
  /**
@@ -5422,7 +5177,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5422
5177
  * @returns A promise that resolves to the transaction response.
5423
5178
  */
5424
5179
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5425
- if ((0, import_math19.bn)(amount).lte(0)) {
5180
+ if ((0, import_math18.bn)(amount).lte(0)) {
5426
5181
  throw new import_errors16.FuelError(
5427
5182
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5428
5183
  "Transfer amount must be a positive number."
@@ -5441,37 +5196,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5441
5196
  * @returns A promise that resolves to the transaction response.
5442
5197
  */
5443
5198
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5444
- if ((0, import_math19.bn)(amount).lte(0)) {
5199
+ if ((0, import_math18.bn)(amount).lte(0)) {
5445
5200
  throw new import_errors16.FuelError(
5446
5201
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5447
5202
  "Transfer amount must be a positive number."
5448
5203
  );
5449
5204
  }
5450
5205
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5206
+ const { minGasPrice } = this.provider.getGasConfig();
5207
+ const params = { gasPrice: minGasPrice, ...txParams };
5451
5208
  const { script, scriptData } = await assembleTransferToContractScript({
5452
5209
  hexlifiedContractId: contractAddress.toB256(),
5453
- amountToTransfer: (0, import_math19.bn)(amount),
5210
+ amountToTransfer: (0, import_math18.bn)(amount),
5454
5211
  assetId
5455
5212
  });
5456
5213
  const request = new ScriptTransactionRequest({
5457
- ...txParams,
5214
+ ...params,
5458
5215
  script,
5459
5216
  scriptData
5460
5217
  });
5461
5218
  request.addContractInputAndOutput(contractAddress);
5462
- const txCost = await this.provider.getTransactionCost(request, {
5463
- resourcesOwner: this,
5464
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5219
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5220
+ request,
5221
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5222
+ );
5223
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5224
+ this.validateGas({
5225
+ gasUsed,
5226
+ gasPrice: request.gasPrice,
5227
+ gasLimit: request.gasLimit,
5228
+ minGasPrice
5465
5229
  });
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);
5230
+ await this.fund(request, requiredQuantities, maxFee);
5475
5231
  return this.sendTransaction(request);
5476
5232
  }
5477
5233
  /**
@@ -5483,31 +5239,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5483
5239
  * @returns A promise that resolves to the transaction response.
5484
5240
  */
5485
5241
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5242
+ const { minGasPrice } = this.provider.getGasConfig();
5486
5243
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5487
- const recipientDataArray = (0, import_utils27.arrayify)(
5244
+ const recipientDataArray = (0, import_utils28.arrayify)(
5488
5245
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5489
5246
  );
5490
- const amountDataArray = (0, import_utils27.arrayify)(
5491
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5247
+ const amountDataArray = (0, import_utils28.arrayify)(
5248
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5492
5249
  );
5493
5250
  const script = new Uint8Array([
5494
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5251
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5495
5252
  ...recipientDataArray,
5496
5253
  ...amountDataArray
5497
5254
  ]);
5498
- const params = { script, ...txParams };
5255
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5499
5256
  const request = new ScriptTransactionRequest(params);
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);
5257
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5258
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5259
+ request,
5260
+ forwardingQuantities
5261
+ );
5262
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5263
+ this.validateGas({
5264
+ gasUsed,
5265
+ gasPrice: request.gasPrice,
5266
+ gasLimit: request.gasLimit,
5267
+ minGasPrice
5268
+ });
5269
+ await this.fund(request, requiredQuantities, maxFee);
5511
5270
  return this.sendTransaction(request);
5512
5271
  }
5513
5272
  async signMessage(message) {
@@ -5565,7 +5324,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5565
5324
  }
5566
5325
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5567
5326
  }
5568
- validateGas({ gasUsed, gasLimit }) {
5327
+ validateGas({
5328
+ gasUsed,
5329
+ gasPrice,
5330
+ gasLimit,
5331
+ minGasPrice
5332
+ }) {
5333
+ if (minGasPrice.gt(gasPrice)) {
5334
+ throw new import_errors16.FuelError(
5335
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5336
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5337
+ );
5338
+ }
5569
5339
  if (gasUsed.gt(gasLimit)) {
5570
5340
  throw new import_errors16.FuelError(
5571
5341
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5577,14 +5347,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5577
5347
 
5578
5348
  // src/wallet/base-wallet-unlocked.ts
5579
5349
  var import_hasher3 = require("@fuel-ts/hasher");
5580
- var import_utils30 = require("@fuel-ts/utils");
5350
+ var import_utils31 = require("@fuel-ts/utils");
5581
5351
 
5582
5352
  // src/signer/signer.ts
5583
5353
  var import_address5 = require("@fuel-ts/address");
5584
- var import_crypto = require("@fuel-ts/crypto");
5354
+ var import_crypto2 = require("@fuel-ts/crypto");
5585
5355
  var import_hasher2 = require("@fuel-ts/hasher");
5586
- var import_math20 = require("@fuel-ts/math");
5587
- var import_utils28 = require("@fuel-ts/utils");
5356
+ var import_math19 = require("@fuel-ts/math");
5357
+ var import_utils29 = require("@fuel-ts/utils");
5588
5358
  var import_secp256k1 = require("@noble/curves/secp256k1");
5589
5359
  var Signer = class {
5590
5360
  address;
@@ -5603,10 +5373,10 @@ var Signer = class {
5603
5373
  privateKey = `0x${privateKey}`;
5604
5374
  }
5605
5375
  }
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
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5377
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5378
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5379
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5610
5380
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5611
5381
  }
5612
5382
  /**
@@ -5620,11 +5390,11 @@ var Signer = class {
5620
5390
  * @returns hashed signature
5621
5391
  */
5622
5392
  sign(data) {
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);
5393
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5394
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5395
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5626
5396
  s[0] |= (signature.recovery || 0) << 7;
5627
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5397
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5628
5398
  }
5629
5399
  /**
5630
5400
  * Add point on the current elliptic curve
@@ -5633,8 +5403,8 @@ var Signer = class {
5633
5403
  * @returns compressed point on the curve
5634
5404
  */
5635
5405
  addPoint(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));
5406
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5407
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5638
5408
  const result = p0.add(p1);
5639
5409
  return `0x${result.toHex(true)}`;
5640
5410
  }
@@ -5646,16 +5416,16 @@ var Signer = class {
5646
5416
  * @returns public key from signature from the
5647
5417
  */
5648
5418
  static recoverPublicKey(data, signature) {
5649
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5419
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5650
5420
  const r = signedMessageBytes.slice(0, 32);
5651
5421
  const s = signedMessageBytes.slice(32, 64);
5652
5422
  const recoveryParam = (s[0] & 128) >> 7;
5653
5423
  s[0] &= 127;
5654
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5424
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5655
5425
  recoveryParam
5656
5426
  );
5657
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5658
- return (0, import_utils28.hexlify)(publicKey);
5427
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5428
+ return (0, import_utils29.hexlify)(publicKey);
5659
5429
  }
5660
5430
  /**
5661
5431
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5674,7 +5444,7 @@ var Signer = class {
5674
5444
  * @returns random 32-byte hashed
5675
5445
  */
5676
5446
  static generatePrivateKey(entropy) {
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);
5447
+ return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5678
5448
  }
5679
5449
  /**
5680
5450
  * Extended publicKey from a compact publicKey
@@ -5683,16 +5453,16 @@ var Signer = class {
5683
5453
  * @returns extended publicKey
5684
5454
  */
5685
5455
  static extendPublicKey(publicKey) {
5686
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5687
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5456
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5457
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5688
5458
  }
5689
5459
  };
5690
5460
 
5691
5461
  // src/wallet/keystore-wallet.ts
5692
5462
  var import_address6 = require("@fuel-ts/address");
5693
- var import_crypto2 = require("@fuel-ts/crypto");
5463
+ var import_crypto3 = require("@fuel-ts/crypto");
5694
5464
  var import_errors17 = require("@fuel-ts/errors");
5695
- var import_utils29 = require("@fuel-ts/utils");
5465
+ var import_utils30 = require("@fuel-ts/utils");
5696
5466
  var import_uuid = require("uuid");
5697
5467
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5698
5468
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5706,22 +5476,22 @@ var removeHexPrefix = (hexString) => {
5706
5476
  return hexString;
5707
5477
  };
5708
5478
  async function encryptKeystoreWallet(privateKey, address, password) {
5709
- const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
5479
+ const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
5710
5480
  const ownerAddress = import_address6.Address.fromAddressOrString(address);
5711
- const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
5712
- const key = (0, import_crypto2.scrypt)({
5713
- password: (0, import_crypto2.bufferFromString)(password),
5481
+ const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
5482
+ const key = (0, import_crypto3.scrypt)({
5483
+ password: (0, import_crypto3.bufferFromString)(password),
5714
5484
  salt,
5715
5485
  dklen: DEFAULT_KEY_SIZE,
5716
5486
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5717
5487
  r: DEFAULT_KDF_PARAMS_R,
5718
5488
  p: DEFAULT_KDF_PARAMS_P
5719
5489
  });
5720
- const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
5721
- const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5490
+ const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
5491
+ const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5722
5492
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5723
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5724
- const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5493
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5494
+ const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5725
5495
  const keystore = {
5726
5496
  id: (0, import_uuid.v4)(),
5727
5497
  version: 3,
@@ -5729,15 +5499,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5729
5499
  crypto: {
5730
5500
  cipher: "aes-128-ctr",
5731
5501
  mac,
5732
- cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
5733
- ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
5502
+ cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
5503
+ ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
5734
5504
  kdf: "scrypt",
5735
5505
  kdfparams: {
5736
5506
  dklen: DEFAULT_KEY_SIZE,
5737
5507
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5738
5508
  p: DEFAULT_KDF_PARAMS_P,
5739
5509
  r: DEFAULT_KDF_PARAMS_R,
5740
- salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
5510
+ salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
5741
5511
  }
5742
5512
  }
5743
5513
  };
@@ -5753,11 +5523,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5753
5523
  kdfparams: { dklen, n, r, p, salt }
5754
5524
  }
5755
5525
  } = keystoreWallet;
5756
- const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
5757
- const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
5758
- const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
5759
- const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
5760
- const key = (0, import_crypto2.scrypt)({
5526
+ const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
5527
+ const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
5528
+ const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
5529
+ const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
5530
+ const key = (0, import_crypto3.scrypt)({
5761
5531
  password: passwordBuffer,
5762
5532
  salt: saltBuffer,
5763
5533
  n,
@@ -5766,16 +5536,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5766
5536
  dklen
5767
5537
  });
5768
5538
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
5769
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5770
- const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5539
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5540
+ const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5771
5541
  if (mac !== macHash) {
5772
5542
  throw new import_errors17.FuelError(
5773
5543
  import_errors17.ErrorCode.INVALID_PASSWORD,
5774
5544
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5775
5545
  );
5776
5546
  }
5777
- const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5778
- const privateKey = (0, import_utils29.hexlify)(buffer);
5547
+ const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5548
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5779
5549
  return privateKey;
5780
5550
  }
5781
5551
 
@@ -5820,7 +5590,7 @@ var BaseWalletUnlocked = class extends Account {
5820
5590
  */
5821
5591
  async signMessage(message) {
5822
5592
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5823
- return (0, import_utils30.hexlify)(signedMessage);
5593
+ return (0, import_utils31.hexlify)(signedMessage);
5824
5594
  }
5825
5595
  /**
5826
5596
  * Signs a transaction with the wallet's private key.
@@ -5833,7 +5603,7 @@ var BaseWalletUnlocked = class extends Account {
5833
5603
  const chainId = this.provider.getChainId();
5834
5604
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5835
5605
  const signature = await this.signer().sign(hashedTransaction);
5836
- return (0, import_utils30.hexlify)(signature);
5606
+ return (0, import_utils31.hexlify)(signature);
5837
5607
  }
5838
5608
  /**
5839
5609
  * Populates a transaction with the witnesses signature.
@@ -5853,7 +5623,7 @@ var BaseWalletUnlocked = class extends Account {
5853
5623
  * @param transactionRequestLike - The transaction request to send.
5854
5624
  * @returns A promise that resolves to the TransactionResponse object.
5855
5625
  */
5856
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5626
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5857
5627
  const transactionRequest = transactionRequestify(transactionRequestLike);
5858
5628
  if (estimateTxDependencies) {
5859
5629
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5894,16 +5664,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5894
5664
  // src/hdwallet/hdwallet.ts
5895
5665
  var import_errors20 = require("@fuel-ts/errors");
5896
5666
  var import_hasher6 = require("@fuel-ts/hasher");
5897
- var import_math21 = require("@fuel-ts/math");
5898
- var import_utils34 = require("@fuel-ts/utils");
5899
- var import_ethers4 = require("ethers");
5667
+ var import_math20 = require("@fuel-ts/math");
5668
+ var import_utils35 = require("@fuel-ts/utils");
5669
+ var import_ethers3 = require("ethers");
5900
5670
 
5901
5671
  // src/mnemonic/mnemonic.ts
5902
- var import_crypto3 = require("@fuel-ts/crypto");
5672
+ var import_crypto4 = require("@fuel-ts/crypto");
5903
5673
  var import_errors19 = require("@fuel-ts/errors");
5904
5674
  var import_hasher5 = require("@fuel-ts/hasher");
5905
- var import_utils32 = require("@fuel-ts/utils");
5906
- var import_ethers3 = require("ethers");
5675
+ var import_utils33 = require("@fuel-ts/utils");
5676
+ var import_ethers2 = require("ethers");
5907
5677
 
5908
5678
  // src/wordlists/words/english.ts
5909
5679
  var english = [
@@ -7966,7 +7736,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7966
7736
  // src/mnemonic/utils.ts
7967
7737
  var import_errors18 = require("@fuel-ts/errors");
7968
7738
  var import_hasher4 = require("@fuel-ts/hasher");
7969
- var import_utils31 = require("@fuel-ts/utils");
7739
+ var import_utils32 = require("@fuel-ts/utils");
7970
7740
  function toUtf8Bytes(stri) {
7971
7741
  const str = stri.normalize("NFKD");
7972
7742
  const result = [];
@@ -8033,14 +7803,14 @@ function entropyToMnemonicIndices(entropy) {
8033
7803
  }
8034
7804
  }
8035
7805
  const checksumBits = entropy.length / 4;
8036
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7806
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8037
7807
  indices[indices.length - 1] <<= checksumBits;
8038
7808
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8039
7809
  return indices;
8040
7810
  }
8041
7811
  function mnemonicWordsToEntropy(words, wordlist) {
8042
7812
  const size = Math.ceil(11 * words.length / 8);
8043
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7813
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8044
7814
  let offset = 0;
8045
7815
  for (let i = 0; i < words.length; i += 1) {
8046
7816
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8060,7 +7830,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8060
7830
  const entropyBits = 32 * words.length / 3;
8061
7831
  const checksumBits = words.length / 3;
8062
7832
  const checksumMask = getUpperMask(checksumBits);
8063
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7833
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8064
7834
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8065
7835
  throw new import_errors18.FuelError(
8066
7836
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8135,7 +7905,7 @@ var Mnemonic = class {
8135
7905
  static mnemonicToEntropy(phrase, wordlist = english) {
8136
7906
  const words = getWords(phrase);
8137
7907
  assertMnemonic(words);
8138
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7908
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8139
7909
  }
8140
7910
  /**
8141
7911
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8143,7 +7913,7 @@ var Mnemonic = class {
8143
7913
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8144
7914
  */
8145
7915
  static entropyToMnemonic(entropy, wordlist = english) {
8146
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7916
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8147
7917
  assertWordList(wordlist);
8148
7918
  assertEntropy(entropyBytes);
8149
7919
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8157,7 +7927,7 @@ var Mnemonic = class {
8157
7927
  assertMnemonic(getWords(phrase));
8158
7928
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
8159
7929
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
8160
- return (0, import_ethers3.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7930
+ return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8161
7931
  }
8162
7932
  /**
8163
7933
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -8212,14 +7982,14 @@ var Mnemonic = class {
8212
7982
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8213
7983
  */
8214
7984
  static masterKeysFromSeed(seed) {
8215
- const seedArray = (0, import_utils32.arrayify)(seed);
7985
+ const seedArray = (0, import_utils33.arrayify)(seed);
8216
7986
  if (seedArray.length < 16 || seedArray.length > 64) {
8217
7987
  throw new import_errors19.FuelError(
8218
7988
  import_errors19.ErrorCode.INVALID_SEED,
8219
7989
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8220
7990
  );
8221
7991
  }
8222
- return (0, import_utils32.arrayify)((0, import_ethers3.computeHmac)("sha512", MasterSecret, seedArray));
7992
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8223
7993
  }
8224
7994
  /**
8225
7995
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8230,22 +8000,22 @@ var Mnemonic = class {
8230
8000
  */
8231
8001
  static seedToExtendedKey(seed, testnet = false) {
8232
8002
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8233
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8003
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8234
8004
  const depth = "0x00";
8235
8005
  const fingerprint = "0x00000000";
8236
8006
  const index = "0x00000000";
8237
8007
  const chainCode = masterKey.slice(32);
8238
8008
  const privateKey = masterKey.slice(0, 32);
8239
- const extendedKey = (0, import_utils32.concat)([
8009
+ const extendedKey = (0, import_utils33.concat)([
8240
8010
  prefix,
8241
8011
  depth,
8242
8012
  fingerprint,
8243
8013
  index,
8244
8014
  chainCode,
8245
- (0, import_utils32.concat)(["0x00", privateKey])
8015
+ (0, import_utils33.concat)(["0x00", privateKey])
8246
8016
  ]);
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]));
8017
+ const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8018
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8249
8019
  }
8250
8020
  /**
8251
8021
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8260,7 +8030,7 @@ var Mnemonic = class {
8260
8030
  * @returns A randomly generated mnemonic
8261
8031
  */
8262
8032
  static generate(size = 32, extraEntropy = "") {
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);
8033
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8264
8034
  return Mnemonic.entropyToMnemonic(entropy);
8265
8035
  }
8266
8036
  };
@@ -8268,12 +8038,12 @@ var mnemonic_default = Mnemonic;
8268
8038
 
8269
8039
  // src/hdwallet/hdwallet.ts
8270
8040
  var HARDENED_INDEX = 2147483648;
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
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8042
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8043
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8044
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8275
8045
  function base58check(data) {
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)]));
8046
+ 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)]));
8277
8047
  }
8278
8048
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8279
8049
  if (isPublic) {
@@ -8282,11 +8052,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8282
8052
  return testnet ? TestnetPRV2 : MainnetPRV2;
8283
8053
  }
8284
8054
  function isPublicExtendedKey(extendedKey) {
8285
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8055
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8286
8056
  }
8287
8057
  function isValidExtendedKey(extendedKey) {
8288
8058
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8289
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8059
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8290
8060
  );
8291
8061
  }
8292
8062
  function parsePath(path, depth = 0) {
@@ -8304,8 +8074,8 @@ function parsePath(path, depth = 0) {
8304
8074
  var HDWallet = class {
8305
8075
  depth = 0;
8306
8076
  index = 0;
8307
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
8308
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8077
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8078
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8309
8079
  privateKey;
8310
8080
  publicKey;
8311
8081
  chainCode;
@@ -8317,8 +8087,8 @@ var HDWallet = class {
8317
8087
  constructor(config) {
8318
8088
  if (config.privateKey) {
8319
8089
  const signer = new Signer(config.privateKey);
8320
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8321
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8090
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8091
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8322
8092
  } else {
8323
8093
  if (!config.publicKey) {
8324
8094
  throw new import_errors20.FuelError(
@@ -8326,10 +8096,10 @@ var HDWallet = class {
8326
8096
  "Both public and private Key cannot be missing. At least one should be provided."
8327
8097
  );
8328
8098
  }
8329
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8099
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8330
8100
  }
8331
8101
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8332
- this.fingerprint = (0, import_ethers4.dataSlice)((0, import_ethers4.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8102
+ this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8333
8103
  this.depth = config.depth || this.depth;
8334
8104
  this.index = config.index || this.index;
8335
8105
  this.chainCode = config.chainCode;
@@ -8345,9 +8115,9 @@ var HDWallet = class {
8345
8115
  * @returns A new instance of HDWallet on the derived index
8346
8116
  */
8347
8117
  deriveIndex(index) {
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);
8118
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8119
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8120
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8351
8121
  const data = new Uint8Array(37);
8352
8122
  if (index & HARDENED_INDEX) {
8353
8123
  if (!privateKey) {
@@ -8358,15 +8128,15 @@ var HDWallet = class {
8358
8128
  }
8359
8129
  data.set(privateKey, 1);
8360
8130
  } else {
8361
- data.set((0, import_utils34.arrayify)(this.publicKey));
8131
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8362
8132
  }
8363
- data.set((0, import_math21.toBytes)(index, 4), 33);
8364
- const bytes = (0, import_utils34.arrayify)((0, import_ethers4.computeHmac)("sha512", chainCode, data));
8133
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8134
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8365
8135
  const IL = bytes.slice(0, 32);
8366
8136
  const IR = bytes.slice(32);
8367
8137
  if (privateKey) {
8368
8138
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8369
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8139
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8370
8140
  return new HDWallet({
8371
8141
  privateKey: ki,
8372
8142
  chainCode: IR,
@@ -8375,7 +8145,7 @@ var HDWallet = class {
8375
8145
  parentFingerprint: this.fingerprint
8376
8146
  });
8377
8147
  }
8378
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8148
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8379
8149
  const Ki = signer.addPoint(publicKey);
8380
8150
  return new HDWallet({
8381
8151
  publicKey: Ki,
@@ -8410,12 +8180,12 @@ var HDWallet = class {
8410
8180
  );
8411
8181
  }
8412
8182
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8413
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8183
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8414
8184
  const parentFingerprint = this.parentFingerprint;
8415
- const index = (0, import_math21.toHex)(this.index, 4);
8185
+ const index = (0, import_math20.toHex)(this.index, 4);
8416
8186
  const chainCode = this.chainCode;
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]));
8187
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8188
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8419
8189
  return base58check(extendedKey);
8420
8190
  }
8421
8191
  /**
@@ -8427,13 +8197,13 @@ var HDWallet = class {
8427
8197
  static fromSeed(seed) {
8428
8198
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8429
8199
  return new HDWallet({
8430
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8431
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8200
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8201
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8432
8202
  });
8433
8203
  }
8434
8204
  static fromExtendedKey(extendedKey) {
8435
- const decoded = (0, import_ethers4.toBeHex)((0, import_ethers4.decodeBase58)(extendedKey));
8436
- const bytes = (0, import_utils34.arrayify)(decoded);
8205
+ const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8206
+ const bytes = (0, import_utils35.arrayify)(decoded);
8437
8207
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8438
8208
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8439
8209
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8442,9 +8212,9 @@ var HDWallet = class {
8442
8212
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8443
8213
  }
8444
8214
  const depth = bytes[4];
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));
8215
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8216
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8217
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8448
8218
  const key = bytes.slice(45, 78);
8449
8219
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8450
8220
  throw new import_errors20.FuelError(
@@ -8632,7 +8402,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8632
8402
 
8633
8403
  // src/wallet-manager/wallet-manager.ts
8634
8404
  var import_address9 = require("@fuel-ts/address");
8635
- var import_crypto4 = require("@fuel-ts/crypto");
8405
+ var import_crypto5 = require("@fuel-ts/crypto");
8636
8406
  var import_errors23 = require("@fuel-ts/errors");
8637
8407
  var import_events = require("events");
8638
8408
 
@@ -8960,7 +8730,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8960
8730
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8961
8731
  const data = await this.storage.getItem(this.STORAGE_KEY);
8962
8732
  if (data) {
8963
- const state = await (0, import_crypto4.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8733
+ const state = await (0, import_crypto5.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8964
8734
  __privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
8965
8735
  }
8966
8736
  }
@@ -8969,7 +8739,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8969
8739
  */
8970
8740
  async saveState() {
8971
8741
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8972
- const encryptedData = await (0, import_crypto4.encrypt)(__privateGet(this, _passphrase), {
8742
+ const encryptedData = await (0, import_crypto5.encrypt)(__privateGet(this, _passphrase), {
8973
8743
  vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
8974
8744
  });
8975
8745
  await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
@@ -9045,23 +8815,23 @@ var StorageAbstract = class {
9045
8815
  };
9046
8816
 
9047
8817
  // src/predicate/predicate.ts
9048
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
8818
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
9049
8819
  var import_address10 = require("@fuel-ts/address");
9050
8820
  var import_configs13 = require("@fuel-ts/address/configs");
9051
8821
  var import_errors25 = require("@fuel-ts/errors");
9052
- var import_transactions21 = require("@fuel-ts/transactions");
9053
- var import_utils36 = require("@fuel-ts/utils");
8822
+ var import_transactions20 = require("@fuel-ts/transactions");
8823
+ var import_utils37 = require("@fuel-ts/utils");
9054
8824
 
9055
8825
  // src/predicate/utils/getPredicateRoot.ts
9056
8826
  var import_hasher7 = require("@fuel-ts/hasher");
9057
8827
  var import_merkle = require("@fuel-ts/merkle");
9058
- var import_utils35 = require("@fuel-ts/utils");
8828
+ var import_utils36 = require("@fuel-ts/utils");
9059
8829
  var getPredicateRoot = (bytecode) => {
9060
8830
  const chunkSize = 16 * 1024;
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]));
8831
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8832
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8833
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8834
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9065
8835
  return predicateRoot;
9066
8836
  };
9067
8837
 
@@ -9109,9 +8879,9 @@ var Predicate = class extends Account {
9109
8879
  const request = transactionRequestify(transactionRequestLike);
9110
8880
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9111
8881
  request.inputs?.forEach((input) => {
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));
8882
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8883
+ input.predicate = this.bytes;
8884
+ input.predicateData = this.getPredicateData(policies.length);
9115
8885
  }
9116
8886
  });
9117
8887
  return request;
@@ -9126,7 +8896,8 @@ var Predicate = class extends Account {
9126
8896
  * @returns A promise that resolves to the prepared transaction request.
9127
8897
  */
9128
8898
  async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
9129
- return super.createTransfer(destination, amount, assetId, txParams);
8899
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8900
+ return this.populateTransactionPredicateData(request);
9130
8901
  }
9131
8902
  /**
9132
8903
  * Sends a transaction with the populated predicate data.
@@ -9134,9 +8905,9 @@ var Predicate = class extends Account {
9134
8905
  * @param transactionRequestLike - The transaction request-like object.
9135
8906
  * @returns A promise that resolves to the transaction response.
9136
8907
  */
9137
- sendTransaction(transactionRequestLike) {
9138
- const transactionRequest = transactionRequestify(transactionRequestLike);
9139
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8908
+ sendTransaction(transactionRequestLike, options) {
8909
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8910
+ return super.sendTransaction(transactionRequest, options);
9140
8911
  }
9141
8912
  /**
9142
8913
  * Simulates a transaction with the populated predicate data.
@@ -9145,19 +8916,19 @@ var Predicate = class extends Account {
9145
8916
  * @returns A promise that resolves to the call result.
9146
8917
  */
9147
8918
  simulateTransaction(transactionRequestLike) {
9148
- const transactionRequest = transactionRequestify(transactionRequestLike);
9149
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8919
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8920
+ return super.simulateTransaction(transactionRequest);
9150
8921
  }
9151
8922
  getPredicateData(policiesLength) {
9152
8923
  if (!this.predicateData.length) {
9153
8924
  return new Uint8Array();
9154
8925
  }
9155
8926
  const mainFn = this.interface?.functions.main;
9156
- const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9157
- const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8927
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8928
+ const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9158
8929
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9159
8930
  });
9160
- const OFFSET = VM_TX_MEMORY + import_abi_coder5.SCRIPT_FIXED_SIZE + import_abi_coder5.INPUT_COIN_FIXED_SIZE + import_abi_coder5.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder5.WORD_SIZE;
8931
+ const OFFSET = VM_TX_MEMORY + import_abi_coder7.SCRIPT_FIXED_SIZE + import_abi_coder7.INPUT_COIN_FIXED_SIZE + import_abi_coder7.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder7.WORD_SIZE;
9161
8932
  return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
9162
8933
  }
9163
8934
  /**
@@ -9169,10 +8940,10 @@ var Predicate = class extends Account {
9169
8940
  * @returns An object containing the new predicate bytes and interface.
9170
8941
  */
9171
8942
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9172
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8943
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9173
8944
  let abiInterface;
9174
8945
  if (jsonAbi) {
9175
- abiInterface = new import_abi_coder5.Interface(jsonAbi);
8946
+ abiInterface = new import_abi_coder7.Interface(jsonAbi);
9176
8947
  if (abiInterface.functions.main === void 0) {
9177
8948
  throw new import_errors25.FuelError(
9178
8949
  import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,
@@ -9192,25 +8963,6 @@ var Predicate = class extends Account {
9192
8963
  predicateInterface: abiInterface
9193
8964
  };
9194
8965
  }
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
- }
9214
8966
  /**
9215
8967
  * Sets the configurable constants for the predicate.
9216
8968
  *
@@ -9960,7 +9712,7 @@ __publicField(Fuel, "defaultConfig", {});
9960
9712
  WalletLocked,
9961
9713
  WalletManager,
9962
9714
  WalletUnlocked,
9963
- addAmountToCoinQuantities,
9715
+ addAmountToAsset,
9964
9716
  addOperation,
9965
9717
  assemblePanicError,
9966
9718
  assembleReceiptByType,
@@ -9969,10 +9721,9 @@ __publicField(Fuel, "defaultConfig", {});
9969
9721
  assets,
9970
9722
  buildBlockExplorerUrl,
9971
9723
  cacheFor,
9972
- cacheTxInputsFromOwner,
9973
- calculateGasFee,
9974
9724
  calculateMetadataGasForTxCreate,
9975
9725
  calculateMetadataGasForTxScript,
9726
+ calculatePriceWithFactor,
9976
9727
  calculateTransactionFee,
9977
9728
  coinQuantityfy,
9978
9729
  deferPromise,