@fuel-ts/account 0.0.0-rc-2021-20240415193305 → 0.0.0-rc-1976-20240416161016

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +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 +600 -829
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +600 -835
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +443 -677
  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 +3 -3
  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 +34 -37
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  31. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/input.d.ts +2 -2
  33. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
  35. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/transaction-request.d.ts +29 -9
  37. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  38. package/dist/providers/transaction-request/utils.d.ts +0 -3
  39. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  40. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  42. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  44. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  45. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  46. package/dist/providers/utils/gas.d.ts +2 -8
  47. package/dist/providers/utils/gas.d.ts.map +1 -1
  48. package/dist/test-utils/launchNode.d.ts.map +1 -1
  49. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  50. package/dist/test-utils.global.js +1114 -1578
  51. package/dist/test-utils.global.js.map +1 -1
  52. package/dist/test-utils.js +599 -813
  53. package/dist/test-utils.js.map +1 -1
  54. package/dist/test-utils.mjs +455 -669
  55. package/dist/test-utils.mjs.map +1 -1
  56. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  57. package/package.json +22 -27
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,
@@ -185,15 +184,12 @@ module.exports = __toCommonJS(src_exports);
185
184
 
186
185
  // src/account.ts
187
186
  var import_address4 = require("@fuel-ts/address");
188
- var import_configs12 = require("@fuel-ts/address/configs");
189
187
  var import_errors16 = require("@fuel-ts/errors");
190
188
  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");
189
+ var import_math18 = require("@fuel-ts/math");
190
+ var import_utils28 = require("@fuel-ts/utils");
194
191
 
195
192
  // src/providers/coin-quantity.ts
196
- var import_configs = require("@fuel-ts/address/configs");
197
193
  var import_math = require("@fuel-ts/math");
198
194
  var import_utils = require("@fuel-ts/utils");
199
195
  var coinQuantityfy = (coinQuantityLike) => {
@@ -202,11 +198,11 @@ var coinQuantityfy = (coinQuantityLike) => {
202
198
  let max2;
203
199
  if (Array.isArray(coinQuantityLike)) {
204
200
  amount = coinQuantityLike[0];
205
- assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
206
- max2 = coinQuantityLike[2] ?? void 0;
201
+ assetId = coinQuantityLike[1];
202
+ max2 = coinQuantityLike[2];
207
203
  } else {
208
204
  amount = coinQuantityLike.amount;
209
- assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
205
+ assetId = coinQuantityLike.assetId;
210
206
  max2 = coinQuantityLike.max ?? void 0;
211
207
  }
212
208
  const bnAmount = (0, import_math.bn)(amount);
@@ -216,7 +212,7 @@ var coinQuantityfy = (coinQuantityLike) => {
216
212
  max: max2 ? (0, import_math.bn)(max2) : void 0
217
213
  };
218
214
  };
219
- var addAmountToCoinQuantities = (params) => {
215
+ var addAmountToAsset = (params) => {
220
216
  const { amount, assetId } = params;
221
217
  const coinQuantities = [...params.coinQuantities];
222
218
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -231,11 +227,11 @@ var addAmountToCoinQuantities = (params) => {
231
227
  // src/providers/provider.ts
232
228
  var import_address3 = require("@fuel-ts/address");
233
229
  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");
230
+ var import_math15 = require("@fuel-ts/math");
231
+ var import_transactions18 = require("@fuel-ts/transactions");
232
+ var import_utils23 = require("@fuel-ts/utils");
237
233
  var import_versions = require("@fuel-ts/versions");
238
- var import_utils23 = require("@noble/curves/abstract/utils");
234
+ var import_utils24 = require("@noble/curves/abstract/utils");
239
235
  var import_ethers = require("ethers");
240
236
  var import_graphql_request = require("graphql-request");
241
237
  var import_ramda3 = require("ramda");
@@ -244,10 +240,14 @@ var import_ramda3 = require("ramda");
244
240
  var import_graphql_tag = __toESM(require("graphql-tag"));
245
241
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
246
242
  fragment receiptFragment on Receipt {
247
- id
243
+ contract {
244
+ id
245
+ }
248
246
  pc
249
247
  is
250
- to
248
+ to {
249
+ id
250
+ }
251
251
  toAddress
252
252
  amount
253
253
  assetId
@@ -285,16 +285,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
285
285
  id
286
286
  }
287
287
  time
288
- receipts {
289
- ...receiptFragment
290
- }
291
288
  programState {
292
289
  returnType
293
290
  data
294
291
  }
295
- receipts {
296
- ...receiptFragment
297
- }
298
292
  }
299
293
  ... on FailureStatus {
300
294
  block {
@@ -302,24 +296,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
302
296
  }
303
297
  time
304
298
  reason
305
- receipts {
306
- ...receiptFragment
307
- }
308
299
  }
309
300
  ... on SqueezedOutStatus {
310
301
  reason
311
302
  }
312
303
  }
313
- ${ReceiptFragmentFragmentDoc}`;
304
+ `;
314
305
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
315
306
  fragment transactionFragment on Transaction {
316
307
  id
317
308
  rawPayload
309
+ gasPrice
310
+ receipts {
311
+ ...receiptFragment
312
+ }
318
313
  status {
319
314
  ...transactionStatusFragment
320
315
  }
321
316
  }
322
- ${TransactionStatusFragmentFragmentDoc}`;
317
+ ${ReceiptFragmentFragmentDoc}
318
+ ${TransactionStatusFragmentFragmentDoc}`;
323
319
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
324
320
  fragment inputEstimatePredicatesFragment on Input {
325
321
  ... on InputCoin {
@@ -337,46 +333,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
337
333
  }
338
334
  }
339
335
  ${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
336
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
381
337
  fragment coinFragment on Coin {
382
338
  __typename
@@ -384,6 +340,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
384
340
  owner
385
341
  amount
386
342
  assetId
343
+ maturity
387
344
  blockCreated
388
345
  txCreatedIdx
389
346
  }
@@ -422,32 +379,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
422
379
  messageBlockHeader {
423
380
  id
424
381
  daHeight
425
- consensusParametersVersion
426
- stateTransitionBytecodeVersion
427
382
  transactionsCount
428
- messageReceiptCount
429
383
  transactionsRoot
430
- messageOutboxRoot
431
- eventInboxRoot
432
384
  height
433
385
  prevRoot
434
386
  time
435
387
  applicationHash
388
+ messageReceiptRoot
389
+ messageReceiptCount
436
390
  }
437
391
  commitBlockHeader {
438
392
  id
439
393
  daHeight
440
- consensusParametersVersion
441
- stateTransitionBytecodeVersion
442
394
  transactionsCount
443
- messageReceiptCount
444
395
  transactionsRoot
445
- messageOutboxRoot
446
- eventInboxRoot
447
396
  height
448
397
  prevRoot
449
398
  time
450
399
  applicationHash
400
+ messageReceiptRoot
401
+ messageReceiptCount
451
402
  }
452
403
  sender
453
404
  recipient
@@ -466,8 +417,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
466
417
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
467
418
  fragment blockFragment on Block {
468
419
  id
469
- height
470
420
  header {
421
+ height
471
422
  time
472
423
  }
473
424
  transactions {
@@ -525,11 +476,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
525
476
  `;
526
477
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
527
478
  fragment GasCostsFragment on GasCosts {
528
- version {
529
- ... on Version {
530
- value
531
- }
532
- }
533
479
  add
534
480
  addi
535
481
  aloc
@@ -542,6 +488,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
542
488
  cb
543
489
  cfei
544
490
  cfsi
491
+ croo
545
492
  div
546
493
  divi
547
494
  ecr1
@@ -624,9 +571,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
624
571
  ccp {
625
572
  ...DependentCostFragment
626
573
  }
627
- croo {
628
- ...DependentCostFragment
629
- }
630
574
  csiz {
631
575
  ...DependentCostFragment
632
576
  }
@@ -686,11 +630,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
686
630
  ${DependentCostFragmentFragmentDoc}`;
687
631
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
688
632
  fragment consensusParametersFragment on ConsensusParameters {
689
- version {
690
- ... on Version {
691
- value
692
- }
693
- }
694
633
  txParams {
695
634
  ...TxParametersFragment
696
635
  }
@@ -750,9 +689,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
750
689
  fragment nodeInfoFragment on NodeInfo {
751
690
  utxoValidation
752
691
  vmBacktrace
692
+ minGasPrice
753
693
  maxTx
754
694
  maxDepth
755
695
  nodeVersion
696
+ peers {
697
+ id
698
+ addresses
699
+ clientVersion
700
+ blockHeight
701
+ lastHeartbeatMs
702
+ appScore
703
+ }
756
704
  }
757
705
  `;
758
706
  var GetVersionDocument = import_graphql_tag.default`
@@ -787,9 +735,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
787
735
  query getTransactionWithReceipts($transactionId: TransactionId!) {
788
736
  transaction(id: $transactionId) {
789
737
  ...transactionFragment
738
+ receipts {
739
+ ...receiptFragment
740
+ }
790
741
  }
791
742
  }
792
- ${TransactionFragmentFragmentDoc}`;
743
+ ${TransactionFragmentFragmentDoc}
744
+ ${ReceiptFragmentFragmentDoc}`;
793
745
  var GetTransactionsDocument = import_graphql_tag.default`
794
746
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
795
747
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -917,20 +869,6 @@ var GetBalanceDocument = import_graphql_tag.default`
917
869
  }
918
870
  }
919
871
  ${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
872
  var GetBalancesDocument = import_graphql_tag.default`
935
873
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
936
874
  balances(
@@ -985,12 +923,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
985
923
  }
986
924
  `;
987
925
  var DryRunDocument = import_graphql_tag.default`
988
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
989
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
990
- ...dryRunTransactionExecutionStatusFragment
926
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
927
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
928
+ ...receiptFragment
991
929
  }
992
930
  }
993
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
931
+ ${ReceiptFragmentFragmentDoc}`;
994
932
  var SubmitDocument = import_graphql_tag.default`
995
933
  mutation submit($encodedTransaction: HexString!) {
996
934
  submit(tx: $encodedTransaction) {
@@ -1073,12 +1011,6 @@ function getSdk(requester) {
1073
1011
  getBalance(variables, options) {
1074
1012
  return requester(GetBalanceDocument, variables, options);
1075
1013
  },
1076
- getLatestGasPrice(variables, options) {
1077
- return requester(GetLatestGasPriceDocument, variables, options);
1078
- },
1079
- estimateGasPrice(variables, options) {
1080
- return requester(EstimateGasPriceDocument, variables, options);
1081
- },
1082
1014
  getBalances(variables, options) {
1083
1015
  return requester(GetBalancesDocument, variables, options);
1084
1016
  },
@@ -1148,14 +1080,11 @@ var _FuelGraphqlSubscriber = class {
1148
1080
  let data;
1149
1081
  let errors;
1150
1082
  try {
1151
- const sanitizedText = text.replace(/\s/g, "");
1152
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
1083
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1153
1084
  } catch (e) {
1154
1085
  throw new import_errors.FuelError(
1155
1086
  import_errors.ErrorCode.STREAM_PARSING_ERROR,
1156
- `Error while parsing stream data response: ${text}
1157
-
1158
- Thrown error: ${e}`
1087
+ `Error while parsing stream data response: ${text}`
1159
1088
  );
1160
1089
  }
1161
1090
  if (Array.isArray(errors)) {
@@ -1243,7 +1172,7 @@ var MemoryCache = class {
1243
1172
 
1244
1173
  // src/providers/transaction-request/input.ts
1245
1174
  var import_abi_coder = require("@fuel-ts/abi-coder");
1246
- var import_configs2 = require("@fuel-ts/address/configs");
1175
+ var import_configs = require("@fuel-ts/address/configs");
1247
1176
  var import_errors3 = require("@fuel-ts/errors");
1248
1177
  var import_math2 = require("@fuel-ts/math");
1249
1178
  var import_transactions = require("@fuel-ts/transactions");
@@ -1266,9 +1195,10 @@ var inputify = (value) => {
1266
1195
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1267
1196
  },
1268
1197
  witnessIndex: value.witnessIndex,
1198
+ maturity: value.maturity ?? 0,
1269
1199
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1270
- predicateLength: (0, import_math2.bn)(predicate.length),
1271
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1200
+ predicateLength: predicate.length,
1201
+ predicateDataLength: predicateData.length,
1272
1202
  predicate: (0, import_utils3.hexlify)(predicate),
1273
1203
  predicateData: (0, import_utils3.hexlify)(predicateData)
1274
1204
  };
@@ -1276,10 +1206,10 @@ var inputify = (value) => {
1276
1206
  case import_transactions.InputType.Contract: {
1277
1207
  return {
1278
1208
  type: import_transactions.InputType.Contract,
1279
- txID: import_configs2.ZeroBytes32,
1209
+ txID: import_configs.ZeroBytes32,
1280
1210
  outputIndex: 0,
1281
- balanceRoot: import_configs2.ZeroBytes32,
1282
- stateRoot: import_configs2.ZeroBytes32,
1211
+ balanceRoot: import_configs.ZeroBytes32,
1212
+ stateRoot: import_configs.ZeroBytes32,
1283
1213
  txPointer: {
1284
1214
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1285
1215
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1299,8 +1229,8 @@ var inputify = (value) => {
1299
1229
  nonce: (0, import_utils3.hexlify)(value.nonce),
1300
1230
  witnessIndex: value.witnessIndex,
1301
1231
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1302
- predicateLength: (0, import_math2.bn)(predicate.length),
1303
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1232
+ predicateLength: predicate.length,
1233
+ predicateDataLength: predicateData.length,
1304
1234
  predicate: (0, import_utils3.hexlify)(predicate),
1305
1235
  predicateData: (0, import_utils3.hexlify)(predicateData),
1306
1236
  data: (0, import_utils3.hexlify)(data),
@@ -1317,7 +1247,7 @@ var inputify = (value) => {
1317
1247
  };
1318
1248
 
1319
1249
  // src/providers/transaction-request/output.ts
1320
- var import_configs3 = require("@fuel-ts/address/configs");
1250
+ var import_configs2 = require("@fuel-ts/address/configs");
1321
1251
  var import_errors4 = require("@fuel-ts/errors");
1322
1252
  var import_math3 = require("@fuel-ts/math");
1323
1253
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1337,8 +1267,8 @@ var outputify = (value) => {
1337
1267
  return {
1338
1268
  type: import_transactions2.OutputType.Contract,
1339
1269
  inputIndex: value.inputIndex,
1340
- balanceRoot: import_configs3.ZeroBytes32,
1341
- stateRoot: import_configs3.ZeroBytes32
1270
+ balanceRoot: import_configs2.ZeroBytes32,
1271
+ stateRoot: import_configs2.ZeroBytes32
1342
1272
  };
1343
1273
  }
1344
1274
  case import_transactions2.OutputType.Change: {
@@ -1352,9 +1282,9 @@ var outputify = (value) => {
1352
1282
  case import_transactions2.OutputType.Variable: {
1353
1283
  return {
1354
1284
  type: import_transactions2.OutputType.Variable,
1355
- to: import_configs3.ZeroBytes32,
1285
+ to: import_configs2.ZeroBytes32,
1356
1286
  amount: (0, import_math3.bn)(0),
1357
- assetId: import_configs3.ZeroBytes32
1287
+ assetId: import_configs2.ZeroBytes32
1358
1288
  };
1359
1289
  }
1360
1290
  case import_transactions2.OutputType.ContractCreated: {
@@ -1376,7 +1306,7 @@ var outputify = (value) => {
1376
1306
  // src/providers/transaction-request/transaction-request.ts
1377
1307
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
1378
1308
  var import_address = require("@fuel-ts/address");
1379
- var import_configs7 = require("@fuel-ts/address/configs");
1309
+ var import_configs6 = require("@fuel-ts/address/configs");
1380
1310
  var import_crypto = require("@fuel-ts/crypto");
1381
1311
  var import_math7 = require("@fuel-ts/math");
1382
1312
  var import_transactions6 = require("@fuel-ts/transactions");
@@ -1389,13 +1319,13 @@ var isCoin = (resource) => "id" in resource;
1389
1319
  var isMessage = (resource) => "recipient" in resource;
1390
1320
 
1391
1321
  // src/providers/utils/receipts.ts
1392
- var import_configs4 = require("@fuel-ts/address/configs");
1322
+ var import_configs3 = require("@fuel-ts/address/configs");
1393
1323
  var import_errors5 = require("@fuel-ts/errors");
1394
1324
  var import_math4 = require("@fuel-ts/math");
1395
1325
  var import_transactions3 = require("@fuel-ts/transactions");
1396
- var import_configs5 = require("@fuel-ts/transactions/configs");
1326
+ var import_configs4 = require("@fuel-ts/transactions/configs");
1397
1327
  var import_utils5 = require("@fuel-ts/utils");
1398
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1328
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1399
1329
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1400
1330
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1401
1331
  (memo, receipt) => {
@@ -1412,15 +1342,15 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1412
1342
  missingOutputContractIds: []
1413
1343
  }
1414
1344
  );
1415
- var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1345
+ var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1416
1346
  function assembleReceiptByType(receipt) {
1417
1347
  const { receiptType } = receipt;
1418
1348
  switch (receiptType) {
1419
1349
  case "CALL" /* Call */: {
1420
1350
  const callReceipt = {
1421
1351
  type: import_transactions3.ReceiptType.Call,
1422
- from: hexOrZero(receipt.id || receipt.contractId),
1423
- to: hexOrZero(receipt?.to),
1352
+ from: hexOrZero(receipt.contract?.id),
1353
+ to: hexOrZero(receipt?.to?.id),
1424
1354
  amount: (0, import_math4.bn)(receipt.amount),
1425
1355
  assetId: hexOrZero(receipt.assetId),
1426
1356
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1434,7 +1364,7 @@ function assembleReceiptByType(receipt) {
1434
1364
  case "RETURN" /* Return */: {
1435
1365
  const returnReceipt = {
1436
1366
  type: import_transactions3.ReceiptType.Return,
1437
- id: hexOrZero(receipt.id || receipt.contractId),
1367
+ id: hexOrZero(receipt.contract?.id),
1438
1368
  val: (0, import_math4.bn)(receipt.val),
1439
1369
  pc: (0, import_math4.bn)(receipt.pc),
1440
1370
  is: (0, import_math4.bn)(receipt.is)
@@ -1444,7 +1374,7 @@ function assembleReceiptByType(receipt) {
1444
1374
  case "RETURN_DATA" /* ReturnData */: {
1445
1375
  const returnDataReceipt = {
1446
1376
  type: import_transactions3.ReceiptType.ReturnData,
1447
- id: hexOrZero(receipt.id || receipt.contractId),
1377
+ id: hexOrZero(receipt.contract?.id),
1448
1378
  ptr: (0, import_math4.bn)(receipt.ptr),
1449
1379
  len: (0, import_math4.bn)(receipt.len),
1450
1380
  digest: hexOrZero(receipt.digest),
@@ -1456,7 +1386,7 @@ function assembleReceiptByType(receipt) {
1456
1386
  case "PANIC" /* Panic */: {
1457
1387
  const panicReceipt = {
1458
1388
  type: import_transactions3.ReceiptType.Panic,
1459
- id: hexOrZero(receipt.id),
1389
+ id: hexOrZero(receipt.contract?.id),
1460
1390
  reason: (0, import_math4.bn)(receipt.reason),
1461
1391
  pc: (0, import_math4.bn)(receipt.pc),
1462
1392
  is: (0, import_math4.bn)(receipt.is),
@@ -1467,7 +1397,7 @@ function assembleReceiptByType(receipt) {
1467
1397
  case "REVERT" /* Revert */: {
1468
1398
  const revertReceipt = {
1469
1399
  type: import_transactions3.ReceiptType.Revert,
1470
- id: hexOrZero(receipt.id || receipt.contractId),
1400
+ id: hexOrZero(receipt.contract?.id),
1471
1401
  val: (0, import_math4.bn)(receipt.ra),
1472
1402
  pc: (0, import_math4.bn)(receipt.pc),
1473
1403
  is: (0, import_math4.bn)(receipt.is)
@@ -1477,7 +1407,7 @@ function assembleReceiptByType(receipt) {
1477
1407
  case "LOG" /* Log */: {
1478
1408
  const logReceipt = {
1479
1409
  type: import_transactions3.ReceiptType.Log,
1480
- id: hexOrZero(receipt.id || receipt.contractId),
1410
+ id: hexOrZero(receipt.contract?.id),
1481
1411
  val0: (0, import_math4.bn)(receipt.ra),
1482
1412
  val1: (0, import_math4.bn)(receipt.rb),
1483
1413
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1490,7 +1420,7 @@ function assembleReceiptByType(receipt) {
1490
1420
  case "LOG_DATA" /* LogData */: {
1491
1421
  const logDataReceipt = {
1492
1422
  type: import_transactions3.ReceiptType.LogData,
1493
- id: hexOrZero(receipt.id || receipt.contractId),
1423
+ id: hexOrZero(receipt.contract?.id),
1494
1424
  val0: (0, import_math4.bn)(receipt.ra),
1495
1425
  val1: (0, import_math4.bn)(receipt.rb),
1496
1426
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1504,8 +1434,8 @@ function assembleReceiptByType(receipt) {
1504
1434
  case "TRANSFER" /* Transfer */: {
1505
1435
  const transferReceipt = {
1506
1436
  type: import_transactions3.ReceiptType.Transfer,
1507
- from: hexOrZero(receipt.id || receipt.contractId),
1508
- to: hexOrZero(receipt.toAddress || receipt?.to),
1437
+ from: hexOrZero(receipt.contract?.id),
1438
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1509
1439
  amount: (0, import_math4.bn)(receipt.amount),
1510
1440
  assetId: hexOrZero(receipt.assetId),
1511
1441
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1516,8 +1446,8 @@ function assembleReceiptByType(receipt) {
1516
1446
  case "TRANSFER_OUT" /* TransferOut */: {
1517
1447
  const transferOutReceipt = {
1518
1448
  type: import_transactions3.ReceiptType.TransferOut,
1519
- from: hexOrZero(receipt.id || receipt.contractId),
1520
- to: hexOrZero(receipt.toAddress || receipt.to),
1449
+ from: hexOrZero(receipt.contract?.id),
1450
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1521
1451
  amount: (0, import_math4.bn)(receipt.amount),
1522
1452
  assetId: hexOrZero(receipt.assetId),
1523
1453
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1560,7 +1490,7 @@ function assembleReceiptByType(receipt) {
1560
1490
  return receiptMessageOut;
1561
1491
  }
1562
1492
  case "MINT" /* Mint */: {
1563
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1493
+ const contractId = hexOrZero(receipt.contract?.id);
1564
1494
  const subId = hexOrZero(receipt.subId);
1565
1495
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1566
1496
  const mintReceipt = {
@@ -1575,7 +1505,7 @@ function assembleReceiptByType(receipt) {
1575
1505
  return mintReceipt;
1576
1506
  }
1577
1507
  case "BURN" /* Burn */: {
1578
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1508
+ const contractId = hexOrZero(receipt.contract?.id);
1579
1509
  const subId = hexOrZero(receipt.subId);
1580
1510
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1581
1511
  const burnReceipt = {
@@ -1660,6 +1590,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1660
1590
  var import_math5 = require("@fuel-ts/math");
1661
1591
  var import_transactions4 = require("@fuel-ts/transactions");
1662
1592
  var import_utils6 = require("@fuel-ts/utils");
1593
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1663
1594
  var getGasUsedFromReceipts = (receipts) => {
1664
1595
  const scriptResult = receipts.filter(
1665
1596
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1680,28 +1611,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1680
1611
  }
1681
1612
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1682
1613
  const witnessCache = [];
1683
- const chargeableInputs = inputs.filter((input) => {
1684
- const isCoinOrMessage = "owner" in input || "sender" in input;
1685
- if (isCoinOrMessage) {
1686
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1687
- return true;
1688
- }
1689
- if (!witnessCache.includes(input.witnessIndex)) {
1690
- witnessCache.push(input.witnessIndex);
1691
- return true;
1692
- }
1693
- }
1694
- return false;
1695
- });
1696
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1697
- const totalGas = chargeableInputs.reduce((total, input) => {
1614
+ const totalGas = inputs.reduce((total, input) => {
1698
1615
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1699
1616
  return total.add(
1700
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1617
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1701
1618
  );
1702
1619
  }
1703
- return total.add(gasCosts.ecr1);
1704
- }, (0, import_math5.bn)(0));
1620
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1621
+ witnessCache.push(input.witnessIndex);
1622
+ return total.add(gasCosts.ecr1);
1623
+ }
1624
+ return total;
1625
+ }, (0, import_math5.bn)());
1705
1626
  return totalGas;
1706
1627
  }
1707
1628
  function getMinGas(params) {
@@ -1713,20 +1634,12 @@ function getMinGas(params) {
1713
1634
  return minGas;
1714
1635
  }
1715
1636
  function getMaxGas(params) {
1716
- const {
1717
- gasPerByte,
1718
- witnessesLength,
1719
- witnessLimit,
1720
- minGas,
1721
- gasLimit = (0, import_math5.bn)(0),
1722
- maxGasPerTx
1723
- } = params;
1637
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1724
1638
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1725
1639
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1726
1640
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1727
1641
  }
1728
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1729
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1642
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1730
1643
  }
1731
1644
  function calculateMetadataGasForTxCreate({
1732
1645
  gasCosts,
@@ -1748,10 +1661,6 @@ function calculateMetadataGasForTxScript({
1748
1661
  }) {
1749
1662
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1750
1663
  }
1751
- var calculateGasFee = (params) => {
1752
- const { gas, gasPrice, priceFactor, tip } = params;
1753
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1754
- };
1755
1664
 
1756
1665
  // src/providers/utils/json.ts
1757
1666
  var import_utils7 = require("@fuel-ts/utils");
@@ -1797,16 +1706,16 @@ function sleep(time) {
1797
1706
  var import_errors7 = require("@fuel-ts/errors");
1798
1707
  var import_math6 = require("@fuel-ts/math");
1799
1708
  var import_transactions5 = require("@fuel-ts/transactions");
1800
- var import_configs6 = require("@fuel-ts/transactions/configs");
1709
+ var import_configs5 = require("@fuel-ts/transactions/configs");
1801
1710
  var assemblePanicError = (status) => {
1802
1711
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1803
1712
  const reason = status.reason;
1804
- if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1713
+ if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1805
1714
  errorMessage = `${errorMessage}
1806
1715
 
1807
1716
  You can read more about this error at:
1808
1717
 
1809
- ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1718
+ ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1810
1719
  }
1811
1720
  return { errorMessage, reason };
1812
1721
  };
@@ -1818,28 +1727,28 @@ var assembleRevertError = (receipts, logs) => {
1818
1727
  if (revertReceipt) {
1819
1728
  const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1820
1729
  switch (reasonHex) {
1821
- case import_configs6.FAILED_REQUIRE_SIGNAL: {
1730
+ case import_configs5.FAILED_REQUIRE_SIGNAL: {
1822
1731
  reason = "require";
1823
1732
  errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1824
1733
  break;
1825
1734
  }
1826
- case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1735
+ case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
1827
1736
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1828
1737
  reason = "assert_eq";
1829
1738
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1830
1739
  break;
1831
1740
  }
1832
- case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1741
+ case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
1833
1742
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1834
1743
  reason = "assert_ne";
1835
1744
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1836
1745
  break;
1837
1746
  }
1838
- case import_configs6.FAILED_ASSERT_SIGNAL:
1747
+ case import_configs5.FAILED_ASSERT_SIGNAL:
1839
1748
  reason = "assert";
1840
1749
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1841
1750
  break;
1842
- case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1751
+ case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1843
1752
  reason = "MissingOutputChange";
1844
1753
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1845
1754
  break;
@@ -1900,7 +1809,7 @@ var witnessify = (value) => {
1900
1809
  // src/providers/transaction-request/transaction-request.ts
1901
1810
  var BaseTransactionRequest = class {
1902
1811
  /** Gas price for transaction */
1903
- tip;
1812
+ gasPrice;
1904
1813
  /** Block until which tx cannot be included */
1905
1814
  maturity;
1906
1815
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1913,34 +1822,38 @@ var BaseTransactionRequest = class {
1913
1822
  outputs = [];
1914
1823
  /** List of witnesses */
1915
1824
  witnesses = [];
1825
+ /** Base asset ID - should be fetched from the chain */
1826
+ baseAssetId;
1916
1827
  /**
1917
1828
  * Constructor for initializing a base transaction request.
1918
1829
  *
1919
1830
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1920
1831
  */
1921
1832
  constructor({
1922
- tip,
1833
+ gasPrice,
1923
1834
  maturity,
1924
1835
  maxFee,
1925
1836
  witnessLimit,
1926
1837
  inputs,
1927
1838
  outputs,
1928
- witnesses
1929
- } = {}) {
1930
- this.tip = (0, import_math7.bn)(tip);
1839
+ witnesses,
1840
+ baseAssetId
1841
+ }) {
1842
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1931
1843
  this.maturity = maturity ?? 0;
1932
1844
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1933
1845
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1934
1846
  this.inputs = inputs ?? [];
1935
1847
  this.outputs = outputs ?? [];
1936
1848
  this.witnesses = witnesses ?? [];
1849
+ this.baseAssetId = baseAssetId;
1937
1850
  }
1938
1851
  static getPolicyMeta(req) {
1939
1852
  let policyTypes = 0;
1940
1853
  const policies = [];
1941
- if (req.tip) {
1942
- policyTypes += import_transactions6.PolicyType.Tip;
1943
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1854
+ if (req.gasPrice) {
1855
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1856
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1944
1857
  }
1945
1858
  if (req.witnessLimit) {
1946
1859
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -2026,7 +1939,7 @@ var BaseTransactionRequest = class {
2026
1939
  * @returns The index of the created witness.
2027
1940
  */
2028
1941
  addEmptyWitness() {
2029
- this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1942
+ this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
2030
1943
  return this.witnesses.length - 1;
2031
1944
  }
2032
1945
  /**
@@ -2127,10 +2040,10 @@ var BaseTransactionRequest = class {
2127
2040
  * @param predicate - Predicate bytes.
2128
2041
  * @param predicateData - Predicate data bytes.
2129
2042
  */
2130
- addCoinInput(coin) {
2043
+ addCoinInput(coin, predicate) {
2131
2044
  const { assetId, owner, amount } = coin;
2132
2045
  let witnessIndex;
2133
- if (coin.predicate) {
2046
+ if (predicate) {
2134
2047
  witnessIndex = 0;
2135
2048
  } else {
2136
2049
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2145,7 +2058,8 @@ var BaseTransactionRequest = class {
2145
2058
  amount,
2146
2059
  assetId,
2147
2060
  txPointer: "0x00000000000000000000000000000000",
2148
- witnessIndex
2061
+ witnessIndex,
2062
+ predicate: predicate?.bytes
2149
2063
  };
2150
2064
  this.pushInput(input);
2151
2065
  this.addChangeOutput(owner, assetId);
@@ -2156,13 +2070,11 @@ var BaseTransactionRequest = class {
2156
2070
  *
2157
2071
  * @param message - Message resource.
2158
2072
  * @param predicate - Predicate bytes.
2159
- * @param predicateData - Predicate data bytes.
2160
2073
  */
2161
- addMessageInput(message) {
2074
+ addMessageInput(message, predicate) {
2162
2075
  const { recipient, sender, amount } = message;
2163
- const assetId = import_configs7.BaseAssetId;
2164
2076
  let witnessIndex;
2165
- if (message.predicate) {
2077
+ if (predicate) {
2166
2078
  witnessIndex = 0;
2167
2079
  } else {
2168
2080
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2176,10 +2088,11 @@ var BaseTransactionRequest = class {
2176
2088
  sender: sender.toB256(),
2177
2089
  recipient: recipient.toB256(),
2178
2090
  amount,
2179
- witnessIndex
2091
+ witnessIndex,
2092
+ predicate: predicate?.bytes
2180
2093
  };
2181
2094
  this.pushInput(input);
2182
- this.addChangeOutput(recipient, assetId);
2095
+ this.addChangeOutput(recipient, this.baseAssetId);
2183
2096
  }
2184
2097
  /**
2185
2098
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2207,6 +2120,32 @@ var BaseTransactionRequest = class {
2207
2120
  resources.forEach((resource) => this.addResource(resource));
2208
2121
  return this;
2209
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
+ }
2210
2149
  /**
2211
2150
  * Adds a coin output to the transaction.
2212
2151
  *
@@ -2214,12 +2153,12 @@ var BaseTransactionRequest = class {
2214
2153
  * @param amount - Amount of coin.
2215
2154
  * @param assetId - Asset ID of coin.
2216
2155
  */
2217
- addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2156
+ addCoinOutput(to, amount, assetId) {
2218
2157
  this.pushOutput({
2219
2158
  type: import_transactions6.OutputType.Coin,
2220
2159
  to: (0, import_address.addressify)(to).toB256(),
2221
2160
  amount,
2222
- assetId
2161
+ assetId: assetId ?? this.baseAssetId
2223
2162
  });
2224
2163
  return this;
2225
2164
  }
@@ -2246,7 +2185,7 @@ var BaseTransactionRequest = class {
2246
2185
  * @param to - Address of the owner.
2247
2186
  * @param assetId - Asset ID of coin.
2248
2187
  */
2249
- addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2188
+ addChangeOutput(to, assetId) {
2250
2189
  const changeOutput = this.getChangeOutputs().find(
2251
2190
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2252
2191
  );
@@ -2254,7 +2193,7 @@ var BaseTransactionRequest = class {
2254
2193
  this.pushOutput({
2255
2194
  type: import_transactions6.OutputType.Change,
2256
2195
  to: (0, import_address.addressify)(to).toB256(),
2257
- assetId
2196
+ assetId: assetId ?? this.baseAssetId
2258
2197
  });
2259
2198
  }
2260
2199
  }
@@ -2286,7 +2225,7 @@ var BaseTransactionRequest = class {
2286
2225
  }
2287
2226
  calculateMaxGas(chainInfo, minGas) {
2288
2227
  const { consensusParameters } = chainInfo;
2289
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2228
+ const { gasPerByte } = consensusParameters;
2290
2229
  const witnessesLength = this.toTransaction().witnesses.reduce(
2291
2230
  (acc, wit) => acc + wit.dataLength,
2292
2231
  0
@@ -2295,8 +2234,7 @@ var BaseTransactionRequest = class {
2295
2234
  gasPerByte,
2296
2235
  minGas,
2297
2236
  witnessesLength,
2298
- witnessLimit: this.witnessLimit,
2299
- maxGasPerTx
2237
+ witnessLimit: this.witnessLimit
2300
2238
  });
2301
2239
  }
2302
2240
  /**
@@ -2314,27 +2252,24 @@ var BaseTransactionRequest = class {
2314
2252
  });
2315
2253
  const updateAssetInput = (assetId, quantity) => {
2316
2254
  const assetInput = findAssetInput(assetId);
2317
- let usedQuantity = quantity;
2318
- if (assetId === import_configs7.BaseAssetId) {
2319
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2320
- }
2321
2255
  if (assetInput && "assetId" in assetInput) {
2322
2256
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2323
- assetInput.amount = usedQuantity;
2257
+ assetInput.amount = quantity;
2324
2258
  } else {
2325
2259
  this.addResources([
2326
2260
  {
2327
2261
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2328
- amount: usedQuantity,
2262
+ amount: quantity,
2329
2263
  assetId,
2330
2264
  owner: resourcesOwner || import_address.Address.fromRandom(),
2265
+ maturity: 0,
2331
2266
  blockCreated: (0, import_math7.bn)(1),
2332
2267
  txCreatedIdx: (0, import_math7.bn)(1)
2333
2268
  }
2334
2269
  ]);
2335
2270
  }
2336
2271
  };
2337
- updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2272
+ updateAssetInput(this.baseAssetId, (0, import_math7.bn)(1e11));
2338
2273
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2339
2274
  }
2340
2275
  /**
@@ -2359,7 +2294,7 @@ var BaseTransactionRequest = class {
2359
2294
  toJSON() {
2360
2295
  return normalizeJSON(this);
2361
2296
  }
2362
- updatePredicateGasUsed(inputs) {
2297
+ updatePredicateInputs(inputs) {
2363
2298
  this.inputs.forEach((i) => {
2364
2299
  let correspondingInput;
2365
2300
  switch (i.type) {
@@ -2381,25 +2316,16 @@ var BaseTransactionRequest = class {
2381
2316
  }
2382
2317
  });
2383
2318
  }
2384
- shiftPredicateData() {
2385
- this.inputs.forEach((input) => {
2386
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2387
- input.predicateData = input.paddPredicateData(
2388
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2389
- );
2390
- }
2391
- });
2392
- }
2393
2319
  };
2394
2320
 
2395
2321
  // src/providers/transaction-request/create-transaction-request.ts
2396
- var import_configs9 = require("@fuel-ts/address/configs");
2322
+ var import_configs8 = require("@fuel-ts/address/configs");
2397
2323
  var import_math9 = require("@fuel-ts/math");
2398
2324
  var import_transactions8 = require("@fuel-ts/transactions");
2399
2325
  var import_utils13 = require("@fuel-ts/utils");
2400
2326
 
2401
2327
  // src/providers/transaction-request/hash-transaction.ts
2402
- var import_configs8 = require("@fuel-ts/address/configs");
2328
+ var import_configs7 = require("@fuel-ts/address/configs");
2403
2329
  var import_hasher = require("@fuel-ts/hasher");
2404
2330
  var import_math8 = require("@fuel-ts/math");
2405
2331
  var import_transactions7 = require("@fuel-ts/transactions");
@@ -2408,7 +2334,7 @@ var import_ramda2 = require("ramda");
2408
2334
  function hashTransaction(transactionRequest, chainId) {
2409
2335
  const transaction = transactionRequest.toTransaction();
2410
2336
  if (transaction.type === import_transactions7.TransactionType.Script) {
2411
- transaction.receiptsRoot = import_configs8.ZeroBytes32;
2337
+ transaction.receiptsRoot = import_configs7.ZeroBytes32;
2412
2338
  }
2413
2339
  transaction.inputs = transaction.inputs.map((input) => {
2414
2340
  const inputClone = (0, import_ramda2.clone)(input);
@@ -2430,10 +2356,10 @@ function hashTransaction(transactionRequest, chainId) {
2430
2356
  blockHeight: 0,
2431
2357
  txIndex: 0
2432
2358
  };
2433
- inputClone.txID = import_configs8.ZeroBytes32;
2359
+ inputClone.txID = import_configs7.ZeroBytes32;
2434
2360
  inputClone.outputIndex = 0;
2435
- inputClone.balanceRoot = import_configs8.ZeroBytes32;
2436
- inputClone.stateRoot = import_configs8.ZeroBytes32;
2361
+ inputClone.balanceRoot = import_configs7.ZeroBytes32;
2362
+ inputClone.stateRoot = import_configs7.ZeroBytes32;
2437
2363
  return inputClone;
2438
2364
  }
2439
2365
  default:
@@ -2444,8 +2370,8 @@ function hashTransaction(transactionRequest, chainId) {
2444
2370
  const outputClone = (0, import_ramda2.clone)(output);
2445
2371
  switch (outputClone.type) {
2446
2372
  case import_transactions7.OutputType.Contract: {
2447
- outputClone.balanceRoot = import_configs8.ZeroBytes32;
2448
- outputClone.stateRoot = import_configs8.ZeroBytes32;
2373
+ outputClone.balanceRoot = import_configs7.ZeroBytes32;
2374
+ outputClone.stateRoot = import_configs7.ZeroBytes32;
2449
2375
  return outputClone;
2450
2376
  }
2451
2377
  case import_transactions7.OutputType.Change: {
@@ -2453,9 +2379,9 @@ function hashTransaction(transactionRequest, chainId) {
2453
2379
  return outputClone;
2454
2380
  }
2455
2381
  case import_transactions7.OutputType.Variable: {
2456
- outputClone.to = import_configs8.ZeroBytes32;
2382
+ outputClone.to = import_configs7.ZeroBytes32;
2457
2383
  outputClone.amount = (0, import_math8.bn)(0);
2458
- outputClone.assetId = import_configs8.ZeroBytes32;
2384
+ outputClone.assetId = import_configs7.ZeroBytes32;
2459
2385
  return outputClone;
2460
2386
  }
2461
2387
  default:
@@ -2513,15 +2439,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2513
2439
  *
2514
2440
  * @param createTransactionRequestLike - The initial values for the instance
2515
2441
  */
2516
- constructor({
2517
- bytecodeWitnessIndex,
2518
- salt,
2519
- storageSlots,
2520
- ...rest
2521
- } = {}) {
2442
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2522
2443
  super(rest);
2523
2444
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2524
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2445
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2525
2446
  this.storageSlots = [...storageSlots ?? []];
2526
2447
  }
2527
2448
  /**
@@ -2536,9 +2457,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2536
2457
  return {
2537
2458
  type: import_transactions8.TransactionType.Create,
2538
2459
  ...baseTransaction,
2460
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2539
2461
  bytecodeWitnessIndex,
2540
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2541
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2462
+ storageSlotsCount: storageSlots.length,
2463
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2542
2464
  storageSlots
2543
2465
  };
2544
2466
  }
@@ -2588,7 +2510,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2588
2510
  // src/providers/transaction-request/script-transaction-request.ts
2589
2511
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
2590
2512
  var import_address2 = require("@fuel-ts/address");
2591
- var import_configs10 = require("@fuel-ts/address/configs");
2513
+ var import_configs9 = require("@fuel-ts/address/configs");
2592
2514
  var import_math10 = require("@fuel-ts/math");
2593
2515
  var import_transactions9 = require("@fuel-ts/transactions");
2594
2516
  var import_utils15 = require("@fuel-ts/utils");
@@ -2641,7 +2563,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2641
2563
  *
2642
2564
  * @param scriptTransactionRequestLike - The initial values for the instance.
2643
2565
  */
2644
- constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2566
+ constructor({ script, scriptData, gasLimit, ...rest }) {
2645
2567
  super(rest);
2646
2568
  this.gasLimit = (0, import_math10.bn)(gasLimit);
2647
2569
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
@@ -2660,9 +2582,9 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2660
2582
  type: import_transactions9.TransactionType.Script,
2661
2583
  scriptGasLimit: this.gasLimit,
2662
2584
  ...super.getBaseTransaction(),
2663
- scriptLength: (0, import_math10.bn)(script.length),
2664
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2665
- receiptsRoot: import_configs10.ZeroBytes32,
2585
+ scriptLength: script.length,
2586
+ scriptDataLength: scriptData.length,
2587
+ receiptsRoot: import_configs9.ZeroBytes32,
2666
2588
  script: (0, import_utils15.hexlify)(script),
2667
2589
  scriptData: (0, import_utils15.hexlify)(scriptData)
2668
2590
  };
@@ -2725,7 +2647,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2725
2647
  }
2726
2648
  calculateMaxGas(chainInfo, minGas) {
2727
2649
  const { consensusParameters } = chainInfo;
2728
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2650
+ const { gasPerByte } = consensusParameters;
2729
2651
  const witnessesLength = this.toTransaction().witnesses.reduce(
2730
2652
  (acc, wit) => acc + wit.dataLength,
2731
2653
  0
@@ -2735,8 +2657,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2735
2657
  minGas,
2736
2658
  witnessesLength,
2737
2659
  witnessLimit: this.witnessLimit,
2738
- gasLimit: this.gasLimit,
2739
- maxGasPerTx
2660
+ gasLimit: this.gasLimit
2740
2661
  });
2741
2662
  }
2742
2663
  /**
@@ -2811,32 +2732,15 @@ var transactionRequestify = (obj) => {
2811
2732
  }
2812
2733
  }
2813
2734
  };
2814
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2815
- (acc, input) => {
2816
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2817
- acc.utxos.push(input.id);
2818
- }
2819
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2820
- acc.messages.push(input.nonce);
2821
- }
2822
- return acc;
2823
- },
2824
- {
2825
- utxos: [],
2826
- messages: []
2827
- }
2828
- );
2829
2735
 
2830
2736
  // src/providers/transaction-response/transaction-response.ts
2831
2737
  var import_errors13 = require("@fuel-ts/errors");
2832
- var import_math15 = require("@fuel-ts/math");
2833
- var import_transactions18 = require("@fuel-ts/transactions");
2834
- var import_utils20 = require("@fuel-ts/utils");
2738
+ var import_math14 = require("@fuel-ts/math");
2739
+ var import_transactions17 = require("@fuel-ts/transactions");
2740
+ var import_utils21 = require("@fuel-ts/utils");
2835
2741
 
2836
2742
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2837
- var import_math14 = require("@fuel-ts/math");
2838
- var import_transactions16 = require("@fuel-ts/transactions");
2839
- var import_utils18 = require("@fuel-ts/utils");
2743
+ var import_utils19 = require("@fuel-ts/utils");
2840
2744
 
2841
2745
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2842
2746
  var import_math11 = require("@fuel-ts/math");
@@ -2844,10 +2748,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2844
2748
  var import_utils16 = require("@fuel-ts/utils");
2845
2749
  var calculateTransactionFee = (params) => {
2846
2750
  const {
2847
- gasPrice,
2751
+ gasUsed,
2848
2752
  rawPayload,
2849
- tip,
2850
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2753
+ consensusParameters: { gasCosts, feeParams }
2851
2754
  } = params;
2852
2755
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2853
2756
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2857,7 +2760,8 @@ var calculateTransactionFee = (params) => {
2857
2760
  return {
2858
2761
  fee: (0, import_math11.bn)(0),
2859
2762
  minFee: (0, import_math11.bn)(0),
2860
- maxFee: (0, import_math11.bn)(0)
2763
+ maxFee: (0, import_math11.bn)(0),
2764
+ feeFromGasUsed: (0, import_math11.bn)(0)
2861
2765
  };
2862
2766
  }
2863
2767
  const { type, witnesses, inputs, policies } = transaction;
@@ -2889,6 +2793,7 @@ var calculateTransactionFee = (params) => {
2889
2793
  metadataGas,
2890
2794
  txBytesSize: transactionBytes.length
2891
2795
  });
2796
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2892
2797
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2893
2798
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2894
2799
  const maxGas = getMaxGas({
@@ -2896,30 +2801,22 @@ var calculateTransactionFee = (params) => {
2896
2801
  minGas,
2897
2802
  witnessesLength,
2898
2803
  gasLimit,
2899
- witnessLimit,
2900
- maxGasPerTx
2901
- });
2902
- const minFee = calculateGasFee({
2903
- gasPrice,
2904
- gas: minGas,
2905
- priceFactor: gasPriceFactor,
2906
- tip
2907
- });
2908
- const maxFee = calculateGasFee({
2909
- gasPrice,
2910
- gas: maxGas,
2911
- priceFactor: gasPriceFactor,
2912
- tip
2804
+ witnessLimit
2913
2805
  });
2806
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2807
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2808
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2809
+ const fee = minFee.add(feeFromGasUsed);
2914
2810
  return {
2811
+ fee,
2915
2812
  minFee,
2916
2813
  maxFee,
2917
- fee: maxFee
2814
+ feeFromGasUsed
2918
2815
  };
2919
2816
  };
2920
2817
 
2921
2818
  // src/providers/transaction-summary/operations.ts
2922
- var import_configs11 = require("@fuel-ts/address/configs");
2819
+ var import_configs10 = require("@fuel-ts/address/configs");
2923
2820
  var import_errors11 = require("@fuel-ts/errors");
2924
2821
  var import_math13 = require("@fuel-ts/math");
2925
2822
  var import_transactions14 = require("@fuel-ts/transactions");
@@ -3264,7 +3161,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3264
3161
  const { to: toAddress, assetId, amount } = receipt;
3265
3162
  let { from: fromAddress } = receipt;
3266
3163
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3267
- if (import_configs11.ZeroBytes32 === fromAddress) {
3164
+ if (import_configs10.ZeroBytes32 === fromAddress) {
3268
3165
  const change = changeOutputs.find((output) => output.assetId === assetId);
3269
3166
  fromAddress = change?.to || fromAddress;
3270
3167
  }
@@ -3528,12 +3425,10 @@ function assembleTransactionSummary(params) {
3528
3425
  gqlTransactionStatus,
3529
3426
  abiMap = {},
3530
3427
  maxInputs,
3531
- gasCosts,
3532
- maxGasPerTx,
3533
- gasPrice
3428
+ gasCosts
3534
3429
  } = params;
3535
3430
  const gasUsed = getGasUsedFromReceipts(receipts);
3536
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3431
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3537
3432
  const operations = getOperations({
3538
3433
  transactionType: transaction.type,
3539
3434
  inputs: transaction.inputs || [],
@@ -3544,14 +3439,11 @@ function assembleTransactionSummary(params) {
3544
3439
  maxInputs
3545
3440
  });
3546
3441
  const typeName = getTransactionTypeName(transaction.type);
3547
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3548
3442
  const { fee } = calculateTransactionFee({
3549
- gasPrice,
3443
+ gasUsed,
3550
3444
  rawPayload,
3551
- tip,
3552
3445
  consensusParameters: {
3553
3446
  gasCosts,
3554
- maxGasPerTx,
3555
3447
  feeParams: {
3556
3448
  gasPerByte,
3557
3449
  gasPriceFactor
@@ -3563,7 +3455,7 @@ function assembleTransactionSummary(params) {
3563
3455
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3564
3456
  let date;
3565
3457
  if (time) {
3566
- date = import_utils18.DateTime.fromTai64(time);
3458
+ date = import_utils19.DateTime.fromTai64(time);
3567
3459
  }
3568
3460
  const transactionSummary = {
3569
3461
  id,
@@ -3591,12 +3483,12 @@ function assembleTransactionSummary(params) {
3591
3483
 
3592
3484
  // src/providers/transaction-response/getDecodedLogs.ts
3593
3485
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3594
- var import_transactions17 = require("@fuel-ts/transactions");
3486
+ var import_transactions16 = require("@fuel-ts/transactions");
3595
3487
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3596
3488
  return receipts.reduce((logs, receipt) => {
3597
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3489
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3598
3490
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3599
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3491
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3600
3492
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3601
3493
  logs.push(decodedLog);
3602
3494
  }
@@ -3611,7 +3503,7 @@ var TransactionResponse = class {
3611
3503
  /** Current provider */
3612
3504
  provider;
3613
3505
  /** Gas used on the transaction */
3614
- gasUsed = (0, import_math15.bn)(0);
3506
+ gasUsed = (0, import_math14.bn)(0);
3615
3507
  /** The graphql Transaction with receipts object. */
3616
3508
  gqlTransaction;
3617
3509
  abis;
@@ -3669,8 +3561,8 @@ var TransactionResponse = class {
3669
3561
  * @returns The decoded transaction.
3670
3562
  */
3671
3563
  decodeTransaction(transactionWithReceipts) {
3672
- return new import_transactions18.TransactionCoder().decode(
3673
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3564
+ return new import_transactions17.TransactionCoder().decode(
3565
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3674
3566
  0
3675
3567
  )?.[0];
3676
3568
  }
@@ -3689,27 +3581,20 @@ var TransactionResponse = class {
3689
3581
  const decodedTransaction = this.decodeTransaction(
3690
3582
  transaction
3691
3583
  );
3692
- let txReceipts = [];
3693
- if (transaction?.status && "receipts" in transaction.status) {
3694
- txReceipts = transaction.status.receipts;
3695
- }
3696
- const receipts = txReceipts.map(processGqlReceipt) || [];
3697
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3698
- const gasPrice = await this.provider.getLatestGasPrice();
3584
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3585
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3699
3586
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3700
3587
  const transactionSummary = assembleTransactionSummary({
3701
3588
  id: this.id,
3702
3589
  receipts,
3703
3590
  transaction: decodedTransaction,
3704
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3591
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3705
3592
  gqlTransactionStatus: transaction.status,
3706
3593
  gasPerByte,
3707
3594
  gasPriceFactor,
3708
3595
  abiMap: contractsAbiMap,
3709
3596
  maxInputs,
3710
- gasCosts,
3711
- maxGasPerTx,
3712
- gasPrice
3597
+ gasCosts
3713
3598
  });
3714
3599
  return transactionSummary;
3715
3600
  }
@@ -3836,29 +3721,30 @@ var processGqlChain = (chain) => {
3836
3721
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3837
3722
  return {
3838
3723
  name,
3839
- baseChainHeight: (0, import_math16.bn)(daHeight),
3724
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3840
3725
  consensusParameters: {
3841
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3842
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3843
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3844
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3845
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3846
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3847
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3848
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3849
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3850
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3851
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3852
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3853
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3854
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3855
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3726
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3727
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3728
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3729
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3730
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3731
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3732
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3733
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3734
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3735
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3736
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3737
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3738
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3739
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3740
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3741
+ baseAssetId: consensusParameters.baseAssetId,
3856
3742
  gasCosts
3857
3743
  },
3858
3744
  gasCosts,
3859
3745
  latestBlock: {
3860
3746
  id: latestBlock.id,
3861
- height: (0, import_math16.bn)(latestBlock.height),
3747
+ height: (0, import_math15.bn)(latestBlock.header.height),
3862
3748
  time: latestBlock.header.time,
3863
3749
  transactions: latestBlock.transactions.map((i) => ({
3864
3750
  id: i.id
@@ -3952,8 +3838,10 @@ var _Provider = class {
3952
3838
  * Returns some helpful parameters related to gas fees.
3953
3839
  */
3954
3840
  getGasConfig() {
3841
+ const { minGasPrice } = this.getNode();
3955
3842
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3956
3843
  return {
3844
+ minGasPrice,
3957
3845
  maxGasPerTx,
3958
3846
  maxGasPerPredicate,
3959
3847
  gasPriceFactor,
@@ -4051,7 +3939,7 @@ var _Provider = class {
4051
3939
  */
4052
3940
  async getBlockNumber() {
4053
3941
  const { chain } = await this.operations.getChain();
4054
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3942
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4055
3943
  }
4056
3944
  /**
4057
3945
  * Returns the chain information.
@@ -4061,11 +3949,13 @@ var _Provider = class {
4061
3949
  async fetchNode() {
4062
3950
  const { nodeInfo } = await this.operations.getNodeInfo();
4063
3951
  const processedNodeInfo = {
4064
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4065
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3952
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3953
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3954
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4066
3955
  nodeVersion: nodeInfo.nodeVersion,
4067
3956
  utxoValidation: nodeInfo.utxoValidation,
4068
- vmBacktrace: nodeInfo.vmBacktrace
3957
+ vmBacktrace: nodeInfo.vmBacktrace,
3958
+ peers: nodeInfo.peers
4069
3959
  };
4070
3960
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
4071
3961
  return processedNodeInfo;
@@ -4091,6 +3981,17 @@ var _Provider = class {
4091
3981
  } = this.getChain();
4092
3982
  return chainId.toNumber();
4093
3983
  }
3984
+ /**
3985
+ * Returns the base asset ID
3986
+ *
3987
+ * @returns A promise that resolves to the base asset ID
3988
+ */
3989
+ getBaseAssetId() {
3990
+ const {
3991
+ consensusParameters: { baseAssetId }
3992
+ } = this.getChain();
3993
+ return baseAssetId;
3994
+ }
4094
3995
  /**
4095
3996
  * Submits a transaction to the chain to be executed.
4096
3997
  *
@@ -4107,9 +4008,9 @@ var _Provider = class {
4107
4008
  if (estimateTxDependencies) {
4108
4009
  await this.estimateTxDependencies(transactionRequest);
4109
4010
  }
4110
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4011
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4111
4012
  let abis;
4112
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4013
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4113
4014
  abis = transactionRequest.abis;
4114
4015
  }
4115
4016
  if (awaitExecution) {
@@ -4150,14 +4051,15 @@ var _Provider = class {
4150
4051
  if (estimateTxDependencies) {
4151
4052
  return this.estimateTxDependencies(transactionRequest);
4152
4053
  }
4153
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4154
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4155
- encodedTransactions: encodedTransaction,
4054
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4055
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4056
+ encodedTransaction,
4156
4057
  utxoValidation: utxoValidation || false
4157
4058
  });
4158
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4159
- const receipts = rawReceipts.map(processGqlReceipt);
4160
- return { receipts, dryrunStatus: status };
4059
+ const receipts = gqlReceipts.map(processGqlReceipt);
4060
+ return {
4061
+ receipts
4062
+ };
4161
4063
  }
4162
4064
  /**
4163
4065
  * Verifies whether enough gas is available to complete transaction.
@@ -4168,13 +4070,13 @@ var _Provider = class {
4168
4070
  async estimatePredicates(transactionRequest) {
4169
4071
  const shouldEstimatePredicates = Boolean(
4170
4072
  transactionRequest.inputs.find(
4171
- (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()
4073
+ (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()
4172
4074
  )
4173
4075
  );
4174
4076
  if (!shouldEstimatePredicates) {
4175
4077
  return transactionRequest;
4176
4078
  }
4177
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4079
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4178
4080
  const response = await this.operations.estimatePredicates({
4179
4081
  encodedTransaction
4180
4082
  });
@@ -4183,7 +4085,7 @@ var _Provider = class {
4183
4085
  } = response;
4184
4086
  if (inputs) {
4185
4087
  inputs.forEach((input, index) => {
4186
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4088
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4187
4089
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4188
4090
  }
4189
4091
  });
@@ -4196,31 +4098,31 @@ var _Provider = class {
4196
4098
  * If there are missing variable outputs,
4197
4099
  * `addVariableOutputs` is called on the transaction.
4198
4100
  *
4101
+ * @privateRemarks
4102
+ * TODO: Investigate support for missing contract IDs
4103
+ * TODO: Add support for missing output messages
4199
4104
  *
4200
4105
  * @param transactionRequest - The transaction request object.
4201
4106
  * @returns A promise.
4202
4107
  */
4203
4108
  async estimateTxDependencies(transactionRequest) {
4204
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4109
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4205
4110
  return {
4206
4111
  receipts: [],
4207
4112
  outputVariables: 0,
4208
4113
  missingContractIds: []
4209
4114
  };
4210
4115
  }
4116
+ await this.estimatePredicates(transactionRequest);
4211
4117
  let receipts = [];
4212
4118
  const missingContractIds = [];
4213
4119
  let outputVariables = 0;
4214
- let dryrunStatus;
4215
4120
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4216
- const {
4217
- dryRun: [{ receipts: rawReceipts, status }]
4218
- } = await this.operations.dryRun({
4219
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4121
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4122
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4220
4123
  utxoValidation: false
4221
4124
  });
4222
- receipts = rawReceipts.map(processGqlReceipt);
4223
- dryrunStatus = status;
4125
+ receipts = gqlReceipts.map(processGqlReceipt);
4224
4126
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4225
4127
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4226
4128
  if (hasMissingOutputs) {
@@ -4230,10 +4132,6 @@ var _Provider = class {
4230
4132
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4231
4133
  missingContractIds.push(contractId);
4232
4134
  });
4233
- const { maxFee } = await this.estimateTxGasAndFee({
4234
- transactionRequest
4235
- });
4236
- transactionRequest.maxFee = maxFee;
4237
4135
  } else {
4238
4136
  break;
4239
4137
  }
@@ -4241,139 +4139,37 @@ var _Provider = class {
4241
4139
  return {
4242
4140
  receipts,
4243
4141
  outputVariables,
4244
- missingContractIds,
4245
- dryrunStatus
4142
+ missingContractIds
4246
4143
  };
4247
4144
  }
4248
- /**
4249
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4250
- *
4251
- * Transactions are dry run in batches. After each dry run, transactions requiring
4252
- * further modifications are identified. The method iteratively updates these transactions
4253
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4254
- *
4255
- * @param transactionRequests - Array of transaction request objects.
4256
- * @returns A promise that resolves to an array of results for each transaction.
4257
- */
4258
- async estimateMultipleTxDependencies(transactionRequests) {
4259
- const results = transactionRequests.map(() => ({
4260
- receipts: [],
4261
- outputVariables: 0,
4262
- missingContractIds: [],
4263
- dryrunStatus: void 0
4264
- }));
4265
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4266
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4267
- allRequests.forEach((req, index) => {
4268
- if (req.type === import_transactions19.TransactionType.Script) {
4269
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4270
- }
4271
- });
4272
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4273
- let attempt = 0;
4274
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4275
- const encodedTransactions = transactionsToProcess.map(
4276
- (index) => serializedTransactionsMap.get(index)
4277
- );
4278
- const dryRunResults = await this.operations.dryRun({
4279
- encodedTransactions,
4280
- utxoValidation: false
4281
- });
4282
- const nextRoundTransactions = [];
4283
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4284
- const currentResultIndex = transactionsToProcess[i];
4285
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4286
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4287
- results[currentResultIndex].dryrunStatus = status;
4288
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4289
- results[currentResultIndex].receipts
4290
- );
4291
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4292
- const requestToProcess = allRequests[currentResultIndex];
4293
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4294
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4295
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4296
- missingOutputContractIds.forEach(({ contractId }) => {
4297
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4298
- results[currentResultIndex].missingContractIds.push(contractId);
4299
- });
4300
- const { maxFee } = await this.estimateTxGasAndFee({
4301
- transactionRequest: requestToProcess
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
4145
  /**
4333
4146
  * Estimates the transaction gas and fee based on the provided transaction request.
4334
4147
  * @param transactionRequest - The transaction request object.
4335
4148
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4336
4149
  */
4337
- async estimateTxGasAndFee(params) {
4150
+ estimateTxGasAndFee(params) {
4338
4151
  const { transactionRequest } = params;
4339
- let { gasPrice } = params;
4152
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4340
4153
  const chainInfo = this.getChain();
4341
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4154
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4155
+ transactionRequest.gasPrice = gasPrice;
4342
4156
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4343
- if (!gasPrice) {
4344
- gasPrice = await this.estimateGasPrice(10);
4345
- }
4346
- const minFee = calculateGasFee({
4347
- gasPrice: (0, import_math16.bn)(gasPrice),
4348
- gas: minGas,
4349
- priceFactor: gasPriceFactor,
4350
- tip: transactionRequest.tip
4351
- }).add(1);
4352
- let gasLimit = (0, import_math16.bn)(0);
4353
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4354
- gasLimit = transactionRequest.gasLimit;
4157
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4158
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4355
4159
  if (transactionRequest.gasLimit.eq(0)) {
4356
4160
  transactionRequest.gasLimit = minGas;
4357
4161
  transactionRequest.gasLimit = maxGasPerTx.sub(
4358
4162
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4359
4163
  );
4360
- gasLimit = transactionRequest.gasLimit;
4361
4164
  }
4362
4165
  }
4363
4166
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4364
- const maxFee = calculateGasFee({
4365
- gasPrice: (0, import_math16.bn)(gasPrice),
4366
- gas: maxGas,
4367
- priceFactor: gasPriceFactor,
4368
- tip: transactionRequest.tip
4369
- }).add(1);
4167
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4370
4168
  return {
4371
4169
  minGas,
4372
4170
  minFee,
4373
4171
  maxGas,
4374
- maxFee,
4375
- gasPrice,
4376
- gasLimit
4172
+ maxFee
4377
4173
  };
4378
4174
  }
4379
4175
  /**
@@ -4391,17 +4187,15 @@ var _Provider = class {
4391
4187
  if (estimateTxDependencies) {
4392
4188
  return this.estimateTxDependencies(transactionRequest);
4393
4189
  }
4394
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4395
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4396
- encodedTransactions,
4190
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4191
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4192
+ encodedTransaction,
4397
4193
  utxoValidation: true
4398
4194
  });
4399
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4400
- const { id, receipts, status } = dryRunStatus;
4401
- const processedReceipts = receipts.map(processGqlReceipt);
4402
- return { id, receipts: processedReceipts, status };
4403
- });
4404
- return { receipts: callResult[0].receipts };
4195
+ const receipts = gqlReceipts.map(processGqlReceipt);
4196
+ return {
4197
+ receipts
4198
+ };
4405
4199
  }
4406
4200
  /**
4407
4201
  * Returns a transaction cost to enable user
@@ -4418,79 +4212,77 @@ var _Provider = class {
4418
4212
  * @param tolerance - The tolerance to add on top of the gasUsed.
4419
4213
  * @returns A promise that resolves to the transaction cost object.
4420
4214
  */
4421
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4215
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4216
+ estimateTxDependencies = true,
4217
+ estimatePredicates = true,
4218
+ resourcesOwner,
4219
+ signatureCallback
4220
+ } = {}) {
4422
4221
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4423
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4222
+ const { minGasPrice } = this.getGasConfig();
4223
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4224
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4424
4225
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4425
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4226
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4426
4227
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4427
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4428
4228
  if (isScriptTransaction) {
4429
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4229
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4430
4230
  }
4431
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4432
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4231
+ if (estimatePredicates) {
4232
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4233
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4234
+ }
4235
+ await this.estimatePredicates(txRequestClone);
4433
4236
  }
4434
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4435
- let addedSignatures = 0;
4436
4237
  if (signatureCallback && isScriptTransaction) {
4437
- const lengthBefore = signedRequest.witnesses.length;
4438
- await signatureCallback(signedRequest);
4439
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4238
+ await signatureCallback(txRequestClone);
4440
4239
  }
4441
- await this.estimatePredicates(signedRequest);
4442
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4443
- transactionRequest: signedRequest
4240
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4241
+ transactionRequest: txRequestClone
4444
4242
  });
4445
4243
  let receipts = [];
4446
4244
  let missingContractIds = [];
4447
4245
  let outputVariables = 0;
4448
- let gasUsed = (0, import_math16.bn)(0);
4449
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4450
- txRequestClone.maxFee = maxFee;
4451
- if (isScriptTransaction) {
4452
- txRequestClone.gasLimit = gasLimit;
4453
- if (signatureCallback) {
4454
- await signatureCallback(txRequestClone);
4455
- }
4246
+ let gasUsed = (0, import_math15.bn)(0);
4247
+ if (isScriptTransaction && estimateTxDependencies) {
4248
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4456
4249
  const result = await this.estimateTxDependencies(txRequestClone);
4457
4250
  receipts = result.receipts;
4458
4251
  outputVariables = result.outputVariables;
4459
4252
  missingContractIds = result.missingContractIds;
4460
4253
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4461
4254
  txRequestClone.gasLimit = gasUsed;
4462
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4463
- transactionRequest: txRequestClone,
4464
- gasPrice
4255
+ txRequestClone.gasPrice = setGasPrice;
4256
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4257
+ transactionRequest: txRequestClone
4465
4258
  }));
4466
4259
  }
4467
4260
  return {
4468
4261
  requiredQuantities: allQuantities,
4469
4262
  receipts,
4470
4263
  gasUsed,
4471
- gasPrice,
4264
+ minGasPrice,
4265
+ gasPrice: setGasPrice,
4472
4266
  minGas,
4473
4267
  maxGas,
4474
4268
  minFee,
4475
4269
  maxFee,
4270
+ estimatedInputs: txRequestClone.inputs,
4476
4271
  outputVariables,
4477
- missingContractIds,
4478
- addedSignatures,
4479
- estimatedPredicates: txRequestClone.inputs
4272
+ missingContractIds
4480
4273
  };
4481
4274
  }
4482
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4275
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4483
4276
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4484
4277
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4485
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4486
- quantitiesToContract
4487
- });
4278
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4488
4279
  transactionRequest.addResources(
4489
4280
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4490
4281
  );
4491
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4492
- quantitiesToContract
4493
- });
4282
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4283
+ transactionRequest,
4284
+ forwardingQuantities
4285
+ );
4494
4286
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4495
4287
  return {
4496
4288
  resources,
@@ -4506,16 +4298,17 @@ var _Provider = class {
4506
4298
  const result = await this.operations.getCoins({
4507
4299
  first: 10,
4508
4300
  ...paginationArgs,
4509
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4301
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4510
4302
  });
4511
4303
  const coins = result.coins.edges.map((edge) => edge.node);
4512
4304
  return coins.map((coin) => ({
4513
4305
  id: coin.utxoId,
4514
4306
  assetId: coin.assetId,
4515
- amount: (0, import_math16.bn)(coin.amount),
4307
+ amount: (0, import_math15.bn)(coin.amount),
4516
4308
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4517
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4518
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4309
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4310
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4311
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4519
4312
  }));
4520
4313
  }
4521
4314
  /**
@@ -4529,19 +4322,19 @@ var _Provider = class {
4529
4322
  async getResourcesToSpend(owner, quantities, excludedIds) {
4530
4323
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4531
4324
  const excludeInput = {
4532
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4533
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4325
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4326
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4534
4327
  };
4535
4328
  if (this.cache) {
4536
4329
  const uniqueUtxos = new Set(
4537
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4330
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4538
4331
  );
4539
4332
  excludeInput.utxos = Array.from(uniqueUtxos);
4540
4333
  }
4541
4334
  const coinsQuery = {
4542
4335
  owner: ownerAddress.toB256(),
4543
4336
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4544
- assetId: (0, import_utils22.hexlify)(assetId),
4337
+ assetId: (0, import_utils23.hexlify)(assetId),
4545
4338
  amount: amount.toString(10),
4546
4339
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4547
4340
  })),
@@ -4552,9 +4345,9 @@ var _Provider = class {
4552
4345
  switch (coin.__typename) {
4553
4346
  case "MessageCoin":
4554
4347
  return {
4555
- amount: (0, import_math16.bn)(coin.amount),
4348
+ amount: (0, import_math15.bn)(coin.amount),
4556
4349
  assetId: coin.assetId,
4557
- daHeight: (0, import_math16.bn)(coin.daHeight),
4350
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4558
4351
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4559
4352
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4560
4353
  nonce: coin.nonce
@@ -4562,11 +4355,12 @@ var _Provider = class {
4562
4355
  case "Coin":
4563
4356
  return {
4564
4357
  id: coin.utxoId,
4565
- amount: (0, import_math16.bn)(coin.amount),
4358
+ amount: (0, import_math15.bn)(coin.amount),
4566
4359
  assetId: coin.assetId,
4567
4360
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4568
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4569
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4361
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4362
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4363
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4570
4364
  };
4571
4365
  default:
4572
4366
  return null;
@@ -4583,13 +4377,13 @@ var _Provider = class {
4583
4377
  async getBlock(idOrHeight) {
4584
4378
  let variables;
4585
4379
  if (typeof idOrHeight === "number") {
4586
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4380
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4587
4381
  } else if (idOrHeight === "latest") {
4588
4382
  variables = { height: (await this.getBlockNumber()).toString(10) };
4589
4383
  } else if (idOrHeight.length === 66) {
4590
4384
  variables = { blockId: idOrHeight };
4591
4385
  } else {
4592
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4386
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4593
4387
  }
4594
4388
  const { block } = await this.operations.getBlock(variables);
4595
4389
  if (!block) {
@@ -4597,7 +4391,7 @@ var _Provider = class {
4597
4391
  }
4598
4392
  return {
4599
4393
  id: block.id,
4600
- height: (0, import_math16.bn)(block.height),
4394
+ height: (0, import_math15.bn)(block.header.height),
4601
4395
  time: block.header.time,
4602
4396
  transactionIds: block.transactions.map((tx) => tx.id)
4603
4397
  };
@@ -4612,7 +4406,7 @@ var _Provider = class {
4612
4406
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4613
4407
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4614
4408
  id: block.id,
4615
- height: (0, import_math16.bn)(block.height),
4409
+ height: (0, import_math15.bn)(block.header.height),
4616
4410
  time: block.header.time,
4617
4411
  transactionIds: block.transactions.map((tx) => tx.id)
4618
4412
  }));
@@ -4627,7 +4421,7 @@ var _Provider = class {
4627
4421
  async getBlockWithTransactions(idOrHeight) {
4628
4422
  let variables;
4629
4423
  if (typeof idOrHeight === "number") {
4630
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4424
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4631
4425
  } else if (idOrHeight === "latest") {
4632
4426
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4633
4427
  } else {
@@ -4639,11 +4433,11 @@ var _Provider = class {
4639
4433
  }
4640
4434
  return {
4641
4435
  id: block.id,
4642
- height: (0, import_math16.bn)(block.height, 10),
4436
+ height: (0, import_math15.bn)(block.header.height, 10),
4643
4437
  time: block.header.time,
4644
4438
  transactionIds: block.transactions.map((tx) => tx.id),
4645
4439
  transactions: block.transactions.map(
4646
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4440
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4647
4441
  )
4648
4442
  };
4649
4443
  }
@@ -4658,8 +4452,8 @@ var _Provider = class {
4658
4452
  if (!transaction) {
4659
4453
  return null;
4660
4454
  }
4661
- return new import_transactions19.TransactionCoder().decode(
4662
- (0, import_utils22.arrayify)(transaction.rawPayload),
4455
+ return new import_transactions18.TransactionCoder().decode(
4456
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4663
4457
  0
4664
4458
  )?.[0];
4665
4459
  }
@@ -4686,9 +4480,9 @@ var _Provider = class {
4686
4480
  async getContractBalance(contractId, assetId) {
4687
4481
  const { contractBalance } = await this.operations.getContractBalance({
4688
4482
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4689
- asset: (0, import_utils22.hexlify)(assetId)
4483
+ asset: (0, import_utils23.hexlify)(assetId)
4690
4484
  });
4691
- return (0, import_math16.bn)(contractBalance.amount, 10);
4485
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4692
4486
  }
4693
4487
  /**
4694
4488
  * Returns the balance for the given owner for the given asset ID.
@@ -4700,9 +4494,9 @@ var _Provider = class {
4700
4494
  async getBalance(owner, assetId) {
4701
4495
  const { balance } = await this.operations.getBalance({
4702
4496
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4703
- assetId: (0, import_utils22.hexlify)(assetId)
4497
+ assetId: (0, import_utils23.hexlify)(assetId)
4704
4498
  });
4705
- return (0, import_math16.bn)(balance.amount, 10);
4499
+ return (0, import_math15.bn)(balance.amount, 10);
4706
4500
  }
4707
4501
  /**
4708
4502
  * Returns balances for the given owner.
@@ -4720,7 +4514,7 @@ var _Provider = class {
4720
4514
  const balances = result.balances.edges.map((edge) => edge.node);
4721
4515
  return balances.map((balance) => ({
4722
4516
  assetId: balance.assetId,
4723
- amount: (0, import_math16.bn)(balance.amount)
4517
+ amount: (0, import_math15.bn)(balance.amount)
4724
4518
  }));
4725
4519
  }
4726
4520
  /**
@@ -4738,19 +4532,19 @@ var _Provider = class {
4738
4532
  });
4739
4533
  const messages = result.messages.edges.map((edge) => edge.node);
4740
4534
  return messages.map((message) => ({
4741
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4535
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4742
4536
  sender: message.sender,
4743
4537
  recipient: message.recipient,
4744
4538
  nonce: message.nonce,
4745
- amount: (0, import_math16.bn)(message.amount),
4539
+ amount: (0, import_math15.bn)(message.amount),
4746
4540
  data: message.data
4747
4541
  }),
4748
4542
  sender: import_address3.Address.fromAddressOrString(message.sender),
4749
4543
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4750
4544
  nonce: message.nonce,
4751
- amount: (0, import_math16.bn)(message.amount),
4752
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4753
- daHeight: (0, import_math16.bn)(message.daHeight)
4545
+ amount: (0, import_math15.bn)(message.amount),
4546
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4547
+ daHeight: (0, import_math15.bn)(message.daHeight)
4754
4548
  }));
4755
4549
  }
4756
4550
  /**
@@ -4803,60 +4597,44 @@ var _Provider = class {
4803
4597
  } = result.messageProof;
4804
4598
  return {
4805
4599
  messageProof: {
4806
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4600
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4807
4601
  proofSet: messageProof.proofSet
4808
4602
  },
4809
4603
  blockProof: {
4810
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4604
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4811
4605
  proofSet: blockProof.proofSet
4812
4606
  },
4813
4607
  messageBlockHeader: {
4814
4608
  id: messageBlockHeader.id,
4815
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4816
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4609
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4610
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4817
4611
  transactionsRoot: messageBlockHeader.transactionsRoot,
4818
- height: (0, import_math16.bn)(messageBlockHeader.height),
4612
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4819
4613
  prevRoot: messageBlockHeader.prevRoot,
4820
4614
  time: messageBlockHeader.time,
4821
4615
  applicationHash: messageBlockHeader.applicationHash,
4822
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4823
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4824
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4825
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4826
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4616
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4617
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4827
4618
  },
4828
4619
  commitBlockHeader: {
4829
4620
  id: commitBlockHeader.id,
4830
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4831
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4621
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4622
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4832
4623
  transactionsRoot: commitBlockHeader.transactionsRoot,
4833
- height: (0, import_math16.bn)(commitBlockHeader.height),
4624
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4834
4625
  prevRoot: commitBlockHeader.prevRoot,
4835
4626
  time: commitBlockHeader.time,
4836
4627
  applicationHash: commitBlockHeader.applicationHash,
4837
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4838
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4839
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4840
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4841
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4628
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4629
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4842
4630
  },
4843
4631
  sender: import_address3.Address.fromAddressOrString(sender),
4844
4632
  recipient: import_address3.Address.fromAddressOrString(recipient),
4845
4633
  nonce,
4846
- amount: (0, import_math16.bn)(amount),
4634
+ amount: (0, import_math15.bn)(amount),
4847
4635
  data
4848
4636
  };
4849
4637
  }
4850
- async getLatestGasPrice() {
4851
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4852
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4853
- }
4854
- async estimateGasPrice(blockHorizon) {
4855
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4856
- blockHorizon: String(blockHorizon)
4857
- });
4858
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4859
- }
4860
4638
  /**
4861
4639
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4862
4640
  *
@@ -4876,10 +4654,10 @@ var _Provider = class {
4876
4654
  */
4877
4655
  async produceBlocks(amount, startTime) {
4878
4656
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4879
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4880
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4657
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4658
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4881
4659
  });
4882
- return (0, import_math16.bn)(latestBlockHeight);
4660
+ return (0, import_math15.bn)(latestBlockHeight);
4883
4661
  }
4884
4662
  // eslint-disable-next-line @typescript-eslint/require-await
4885
4663
  async getTransactionResponse(transactionId) {
@@ -4893,7 +4671,7 @@ cacheInputs_fn = function(inputs) {
4893
4671
  return;
4894
4672
  }
4895
4673
  inputs.forEach((input) => {
4896
- if (input.type === import_transactions19.InputType.Coin) {
4674
+ if (input.type === import_transactions18.InputType.Coin) {
4897
4675
  this.cache?.set(input.id);
4898
4676
  }
4899
4677
  });
@@ -4903,9 +4681,9 @@ __publicField(Provider, "nodeInfoCache", {});
4903
4681
 
4904
4682
  // src/providers/transaction-summary/get-transaction-summary.ts
4905
4683
  var import_errors15 = require("@fuel-ts/errors");
4906
- var import_math17 = require("@fuel-ts/math");
4907
- var import_transactions20 = require("@fuel-ts/transactions");
4908
- var import_utils25 = require("@fuel-ts/utils");
4684
+ var import_math16 = require("@fuel-ts/math");
4685
+ var import_transactions19 = require("@fuel-ts/transactions");
4686
+ var import_utils26 = require("@fuel-ts/utils");
4909
4687
  async function getTransactionSummary(params) {
4910
4688
  const { id, provider, abiMap } = params;
4911
4689
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4917,32 +4695,25 @@ async function getTransactionSummary(params) {
4917
4695
  `Transaction not found for given id: ${id}.`
4918
4696
  );
4919
4697
  }
4920
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4921
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4698
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4699
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4922
4700
  0
4923
4701
  );
4924
- let txReceipts = [];
4925
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4926
- txReceipts = gqlTransaction.status.receipts;
4927
- }
4928
- const receipts = txReceipts.map(processGqlReceipt);
4702
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4929
4703
  const {
4930
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4704
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4931
4705
  } = provider.getChain();
4932
- const gasPrice = await provider.getLatestGasPrice();
4933
4706
  const transactionInfo = assembleTransactionSummary({
4934
4707
  id: gqlTransaction.id,
4935
4708
  receipts,
4936
4709
  transaction: decodedTransaction,
4937
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4710
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4938
4711
  gqlTransactionStatus: gqlTransaction.status,
4939
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4940
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4712
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4713
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4941
4714
  abiMap,
4942
4715
  maxInputs,
4943
- gasCosts,
4944
- maxGasPerTx,
4945
- gasPrice
4716
+ gasCosts
4946
4717
  });
4947
4718
  return {
4948
4719
  gqlTransaction,
@@ -4952,11 +4723,10 @@ async function getTransactionSummary(params) {
4952
4723
  async function getTransactionSummaryFromRequest(params) {
4953
4724
  const { provider, transactionRequest, abiMap } = params;
4954
4725
  const { receipts } = await provider.call(transactionRequest);
4955
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4726
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4956
4727
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4957
4728
  const transaction = transactionRequest.toTransaction();
4958
4729
  const transactionBytes = transactionRequest.toTransactionBytes();
4959
- const gasPrice = await provider.getLatestGasPrice();
4960
4730
  const transactionSummary = assembleTransactionSummary({
4961
4731
  receipts,
4962
4732
  transaction,
@@ -4965,9 +4735,7 @@ async function getTransactionSummaryFromRequest(params) {
4965
4735
  gasPerByte,
4966
4736
  gasPriceFactor,
4967
4737
  maxInputs,
4968
- gasCosts,
4969
- maxGasPerTx,
4970
- gasPrice
4738
+ gasCosts
4971
4739
  });
4972
4740
  return transactionSummary;
4973
4741
  }
@@ -4976,31 +4744,24 @@ async function getTransactionsSummaries(params) {
4976
4744
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4977
4745
  const { edges, pageInfo } = transactionsByOwner;
4978
4746
  const {
4979
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4747
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4980
4748
  } = provider.getChain();
4981
- const gasPrice = await provider.getLatestGasPrice();
4982
4749
  const transactions = edges.map((edge) => {
4983
4750
  const { node: gqlTransaction } = edge;
4984
- const { id, rawPayload, status } = gqlTransaction;
4985
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4986
- let txReceipts = [];
4987
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4988
- txReceipts = gqlTransaction.status.receipts;
4989
- }
4990
- const receipts = txReceipts.map(processGqlReceipt);
4751
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4752
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4753
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4991
4754
  const transactionSummary = assembleTransactionSummary({
4992
4755
  id,
4993
4756
  receipts,
4994
4757
  transaction: decodedTransaction,
4995
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4758
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4996
4759
  gqlTransactionStatus: status,
4997
4760
  abiMap,
4998
4761
  gasPerByte,
4999
4762
  gasPriceFactor,
5000
4763
  maxInputs,
5001
- gasCosts,
5002
- maxGasPerTx,
5003
- gasPrice
4764
+ gasCosts
5004
4765
  });
5005
4766
  const output = {
5006
4767
  gqlTransaction,
@@ -5137,17 +4898,17 @@ var assets = [
5137
4898
 
5138
4899
  // src/utils/formatTransferToContractScriptData.ts
5139
4900
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5140
- var import_math18 = require("@fuel-ts/math");
5141
- var import_utils26 = require("@fuel-ts/utils");
4901
+ var import_math17 = require("@fuel-ts/math");
4902
+ var import_utils27 = require("@fuel-ts/utils");
5142
4903
  var asm = __toESM(require("@fuels/vm-asm"));
5143
4904
  var formatTransferToContractScriptData = (params) => {
5144
4905
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5145
4906
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5146
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4907
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5147
4908
  const scriptData = Uint8Array.from([
5148
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4909
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5149
4910
  ...encoded,
5150
- ...(0, import_utils26.arrayify)(assetId)
4911
+ ...(0, import_utils27.arrayify)(assetId)
5151
4912
  ]);
5152
4913
  return scriptData;
5153
4914
  };
@@ -5294,8 +5055,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5294
5055
  * @param assetId - The asset ID to check the balance for.
5295
5056
  * @returns A promise that resolves to the balance amount.
5296
5057
  */
5297
- async getBalance(assetId = import_configs12.BaseAssetId) {
5298
- const amount = await this.provider.getBalance(this.address, assetId);
5058
+ async getBalance(assetId) {
5059
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
5060
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
5299
5061
  return amount;
5300
5062
  }
5301
5063
  /**
@@ -5332,33 +5094,37 @@ var Account = class extends import_interfaces.AbstractAccount {
5332
5094
  * @param fee - The estimated transaction fee.
5333
5095
  * @returns A promise that resolves when the resources are added to the transaction.
5334
5096
  */
5335
- async fund(request, params) {
5336
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5337
- const txRequest = request;
5338
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5339
- amount: (0, import_math19.bn)(fee),
5340
- assetId: import_configs12.BaseAssetId,
5341
- coinQuantities: requiredQuantities
5097
+ async fund(request, coinQuantities, fee) {
5098
+ const baseAssetId = this.provider.getBaseAssetId();
5099
+ const updatedQuantities = addAmountToAsset({
5100
+ amount: (0, import_math18.bn)(fee),
5101
+ assetId: baseAssetId,
5102
+ coinQuantities
5342
5103
  });
5343
5104
  const quantitiesDict = {};
5344
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5105
+ updatedQuantities.forEach(({ amount, assetId }) => {
5345
5106
  quantitiesDict[assetId] = {
5346
5107
  required: amount,
5347
- owned: (0, import_math19.bn)(0)
5108
+ owned: (0, import_math18.bn)(0)
5348
5109
  };
5349
5110
  });
5350
- txRequest.inputs.forEach((input) => {
5111
+ const cachedUtxos = [];
5112
+ const cachedMessages = [];
5113
+ const owner = this.address.toB256();
5114
+ request.inputs.forEach((input) => {
5351
5115
  const isResource = "amount" in input;
5352
5116
  if (isResource) {
5353
5117
  const isCoin2 = "owner" in input;
5354
5118
  if (isCoin2) {
5355
5119
  const assetId = String(input.assetId);
5356
- if (quantitiesDict[assetId]) {
5357
- const amount = (0, import_math19.bn)(input.amount);
5120
+ if (input.owner === owner && quantitiesDict[assetId]) {
5121
+ const amount = (0, import_math18.bn)(input.amount);
5358
5122
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5123
+ cachedUtxos.push(input.id);
5359
5124
  }
5360
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5361
- quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5125
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
5126
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
5127
+ cachedMessages.push(input.nonce);
5362
5128
  }
5363
5129
  }
5364
5130
  });
@@ -5373,23 +5139,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5373
5139
  });
5374
5140
  const needsToBeFunded = missingQuantities.length;
5375
5141
  if (needsToBeFunded) {
5376
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5377
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5378
- txRequest.addResources(resources);
5379
- }
5380
- txRequest.shiftPredicateData();
5381
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5382
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
5383
- if (addedSignatures) {
5384
- Array.from({ length: addedSignatures }).forEach(
5385
- () => requestToBeReEstimate.addEmptyWitness()
5386
- );
5142
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5143
+ messages: cachedMessages,
5144
+ utxos: cachedUtxos
5145
+ });
5146
+ request.addResources(resources);
5387
5147
  }
5388
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5389
- transactionRequest: requestToBeReEstimate
5390
- });
5391
- txRequest.maxFee = maxFee;
5392
- return txRequest;
5393
5148
  }
5394
5149
  /**
5395
5150
  * A helper that creates a transfer transaction request and returns it.
@@ -5397,25 +5152,30 @@ var Account = class extends import_interfaces.AbstractAccount {
5397
5152
  * @param destination - The address of the destination.
5398
5153
  * @param amount - The amount of coins to transfer.
5399
5154
  * @param assetId - The asset ID of the coins to transfer.
5400
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5155
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5401
5156
  * @returns A promise that resolves to the prepared transaction request.
5402
5157
  */
5403
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5404
- const request = new ScriptTransactionRequest(txParams);
5405
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5406
- const txCost = await this.provider.getTransactionCost(request, {
5158
+ async createTransfer(destination, amount, assetId, txParams = {}) {
5159
+ const { minGasPrice } = this.provider.getGasConfig();
5160
+ const baseAssetId = this.provider.getBaseAssetId();
5161
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5162
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5163
+ const request = new ScriptTransactionRequest(params);
5164
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5165
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5407
5166
  estimateTxDependencies: true,
5408
5167
  resourcesOwner: this
5409
5168
  });
5410
- if ("gasLimit" in txParams) {
5411
- this.validateGas({
5412
- gasUsed: txCost.gasUsed,
5413
- gasLimit: request.gasLimit
5414
- });
5415
- }
5416
- request.gasLimit = txCost.gasUsed;
5417
- request.maxFee = txCost.maxFee;
5418
- await this.fund(request, txCost);
5169
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5170
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5171
+ this.validateGas({
5172
+ gasUsed,
5173
+ gasPrice: request.gasPrice,
5174
+ gasLimit: request.gasLimit,
5175
+ minGasPrice
5176
+ });
5177
+ await this.fund(request, requiredQuantities, maxFee);
5178
+ request.updatePredicateInputs(estimatedInputs);
5419
5179
  return request;
5420
5180
  }
5421
5181
  /**
@@ -5427,14 +5187,15 @@ var Account = class extends import_interfaces.AbstractAccount {
5427
5187
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5428
5188
  * @returns A promise that resolves to the transaction response.
5429
5189
  */
5430
- async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5431
- if ((0, import_math19.bn)(amount).lte(0)) {
5190
+ async transfer(destination, amount, assetId, txParams = {}) {
5191
+ if ((0, import_math18.bn)(amount).lte(0)) {
5432
5192
  throw new import_errors16.FuelError(
5433
5193
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5434
5194
  "Transfer amount must be a positive number."
5435
5195
  );
5436
5196
  }
5437
- const request = await this.createTransfer(destination, amount, assetId, txParams);
5197
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5198
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5438
5199
  return this.sendTransaction(request, { estimateTxDependencies: false });
5439
5200
  }
5440
5201
  /**
@@ -5446,38 +5207,41 @@ var Account = class extends import_interfaces.AbstractAccount {
5446
5207
  * @param txParams - The optional transaction parameters.
5447
5208
  * @returns A promise that resolves to the transaction response.
5448
5209
  */
5449
- async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5450
- if ((0, import_math19.bn)(amount).lte(0)) {
5210
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
5211
+ if ((0, import_math18.bn)(amount).lte(0)) {
5451
5212
  throw new import_errors16.FuelError(
5452
5213
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5453
5214
  "Transfer amount must be a positive number."
5454
5215
  );
5455
5216
  }
5456
5217
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5218
+ const { minGasPrice } = this.provider.getGasConfig();
5219
+ const baseAssetId = this.provider.getBaseAssetId();
5220
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5221
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5457
5222
  const { script, scriptData } = await assembleTransferToContractScript({
5458
5223
  hexlifiedContractId: contractAddress.toB256(),
5459
- amountToTransfer: (0, import_math19.bn)(amount),
5460
- assetId
5224
+ amountToTransfer: (0, import_math18.bn)(amount),
5225
+ assetId: assetIdToTransfer
5461
5226
  });
5462
5227
  const request = new ScriptTransactionRequest({
5463
- ...txParams,
5228
+ ...params,
5464
5229
  script,
5465
5230
  scriptData
5466
5231
  });
5467
5232
  request.addContractInputAndOutput(contractAddress);
5468
- const txCost = await this.provider.getTransactionCost(request, {
5469
- resourcesOwner: this,
5470
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5233
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5234
+ request,
5235
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
5236
+ );
5237
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5238
+ this.validateGas({
5239
+ gasUsed,
5240
+ gasPrice: request.gasPrice,
5241
+ gasLimit: request.gasLimit,
5242
+ minGasPrice
5471
5243
  });
5472
- if (txParams.gasLimit) {
5473
- this.validateGas({
5474
- gasUsed: txCost.gasUsed,
5475
- gasLimit: request.gasLimit
5476
- });
5477
- }
5478
- request.gasLimit = txCost.gasUsed;
5479
- request.maxFee = txCost.maxFee;
5480
- await this.fund(request, txCost);
5244
+ await this.fund(request, requiredQuantities, maxFee);
5481
5245
  return this.sendTransaction(request);
5482
5246
  }
5483
5247
  /**
@@ -5489,31 +5253,40 @@ var Account = class extends import_interfaces.AbstractAccount {
5489
5253
  * @returns A promise that resolves to the transaction response.
5490
5254
  */
5491
5255
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5256
+ const { minGasPrice } = this.provider.getGasConfig();
5257
+ const baseAssetId = this.provider.getBaseAssetId();
5492
5258
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5493
- const recipientDataArray = (0, import_utils27.arrayify)(
5259
+ const recipientDataArray = (0, import_utils28.arrayify)(
5494
5260
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5495
5261
  );
5496
- const amountDataArray = (0, import_utils27.arrayify)(
5497
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5262
+ const amountDataArray = (0, import_utils28.arrayify)(
5263
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5498
5264
  );
5499
5265
  const script = new Uint8Array([
5500
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5266
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5501
5267
  ...recipientDataArray,
5502
5268
  ...amountDataArray
5503
5269
  ]);
5504
- const params = { script, ...txParams };
5270
+ const params = {
5271
+ script,
5272
+ gasPrice: minGasPrice,
5273
+ baseAssetId,
5274
+ ...txParams
5275
+ };
5505
5276
  const request = new ScriptTransactionRequest(params);
5506
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5507
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5508
- if (txParams.gasLimit) {
5509
- this.validateGas({
5510
- gasUsed: txCost.gasUsed,
5511
- gasLimit: request.gasLimit
5512
- });
5513
- }
5514
- request.maxFee = txCost.maxFee;
5515
- request.gasLimit = txCost.gasUsed;
5516
- await this.fund(request, txCost);
5277
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
5278
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5279
+ request,
5280
+ forwardingQuantities
5281
+ );
5282
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5283
+ this.validateGas({
5284
+ gasUsed,
5285
+ gasPrice: request.gasPrice,
5286
+ gasLimit: request.gasLimit,
5287
+ minGasPrice
5288
+ });
5289
+ await this.fund(request, requiredQuantities, maxFee);
5517
5290
  return this.sendTransaction(request);
5518
5291
  }
5519
5292
  async signMessage(message) {
@@ -5571,7 +5344,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5571
5344
  }
5572
5345
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5573
5346
  }
5574
- validateGas({ gasUsed, gasLimit }) {
5347
+ validateGas({
5348
+ gasUsed,
5349
+ gasPrice,
5350
+ gasLimit,
5351
+ minGasPrice
5352
+ }) {
5353
+ if (minGasPrice.gt(gasPrice)) {
5354
+ throw new import_errors16.FuelError(
5355
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5356
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5357
+ );
5358
+ }
5575
5359
  if (gasUsed.gt(gasLimit)) {
5576
5360
  throw new import_errors16.FuelError(
5577
5361
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5583,14 +5367,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5583
5367
 
5584
5368
  // src/wallet/base-wallet-unlocked.ts
5585
5369
  var import_hasher3 = require("@fuel-ts/hasher");
5586
- var import_utils30 = require("@fuel-ts/utils");
5370
+ var import_utils31 = require("@fuel-ts/utils");
5587
5371
 
5588
5372
  // src/signer/signer.ts
5589
5373
  var import_address5 = require("@fuel-ts/address");
5590
5374
  var import_crypto2 = require("@fuel-ts/crypto");
5591
5375
  var import_hasher2 = require("@fuel-ts/hasher");
5592
- var import_math20 = require("@fuel-ts/math");
5593
- var import_utils28 = require("@fuel-ts/utils");
5376
+ var import_math19 = require("@fuel-ts/math");
5377
+ var import_utils29 = require("@fuel-ts/utils");
5594
5378
  var import_secp256k1 = require("@noble/curves/secp256k1");
5595
5379
  var Signer = class {
5596
5380
  address;
@@ -5609,10 +5393,10 @@ var Signer = class {
5609
5393
  privateKey = `0x${privateKey}`;
5610
5394
  }
5611
5395
  }
5612
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5613
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5614
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5615
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5396
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5397
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5398
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5399
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5616
5400
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5617
5401
  }
5618
5402
  /**
@@ -5626,11 +5410,11 @@ var Signer = class {
5626
5410
  * @returns hashed signature
5627
5411
  */
5628
5412
  sign(data) {
5629
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5630
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5631
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5413
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5414
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5415
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5632
5416
  s[0] |= (signature.recovery || 0) << 7;
5633
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5417
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5634
5418
  }
5635
5419
  /**
5636
5420
  * Add point on the current elliptic curve
@@ -5639,8 +5423,8 @@ var Signer = class {
5639
5423
  * @returns compressed point on the curve
5640
5424
  */
5641
5425
  addPoint(point) {
5642
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5643
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5426
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5427
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5644
5428
  const result = p0.add(p1);
5645
5429
  return `0x${result.toHex(true)}`;
5646
5430
  }
@@ -5652,16 +5436,16 @@ var Signer = class {
5652
5436
  * @returns public key from signature from the
5653
5437
  */
5654
5438
  static recoverPublicKey(data, signature) {
5655
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5439
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5656
5440
  const r = signedMessageBytes.slice(0, 32);
5657
5441
  const s = signedMessageBytes.slice(32, 64);
5658
5442
  const recoveryParam = (s[0] & 128) >> 7;
5659
5443
  s[0] &= 127;
5660
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5444
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5661
5445
  recoveryParam
5662
5446
  );
5663
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5664
- return (0, import_utils28.hexlify)(publicKey);
5447
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5448
+ return (0, import_utils29.hexlify)(publicKey);
5665
5449
  }
5666
5450
  /**
5667
5451
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5680,7 +5464,7 @@ var Signer = class {
5680
5464
  * @returns random 32-byte hashed
5681
5465
  */
5682
5466
  static generatePrivateKey(entropy) {
5683
- return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5467
+ 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);
5684
5468
  }
5685
5469
  /**
5686
5470
  * Extended publicKey from a compact publicKey
@@ -5689,8 +5473,8 @@ var Signer = class {
5689
5473
  * @returns extended publicKey
5690
5474
  */
5691
5475
  static extendPublicKey(publicKey) {
5692
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5693
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5476
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5477
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5694
5478
  }
5695
5479
  };
5696
5480
 
@@ -5698,7 +5482,7 @@ var Signer = class {
5698
5482
  var import_address6 = require("@fuel-ts/address");
5699
5483
  var import_crypto3 = require("@fuel-ts/crypto");
5700
5484
  var import_errors17 = require("@fuel-ts/errors");
5701
- var import_utils29 = require("@fuel-ts/utils");
5485
+ var import_utils30 = require("@fuel-ts/utils");
5702
5486
  var import_uuid = require("uuid");
5703
5487
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5704
5488
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5781,7 +5565,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5781
5565
  );
5782
5566
  }
5783
5567
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5784
- const privateKey = (0, import_utils29.hexlify)(buffer);
5568
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5785
5569
  return privateKey;
5786
5570
  }
5787
5571
 
@@ -5826,7 +5610,7 @@ var BaseWalletUnlocked = class extends Account {
5826
5610
  */
5827
5611
  async signMessage(message) {
5828
5612
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5829
- return (0, import_utils30.hexlify)(signedMessage);
5613
+ return (0, import_utils31.hexlify)(signedMessage);
5830
5614
  }
5831
5615
  /**
5832
5616
  * Signs a transaction with the wallet's private key.
@@ -5839,7 +5623,7 @@ var BaseWalletUnlocked = class extends Account {
5839
5623
  const chainId = this.provider.getChainId();
5840
5624
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5841
5625
  const signature = await this.signer().sign(hashedTransaction);
5842
- return (0, import_utils30.hexlify)(signature);
5626
+ return (0, import_utils31.hexlify)(signature);
5843
5627
  }
5844
5628
  /**
5845
5629
  * Populates a transaction with the witnesses signature.
@@ -5859,7 +5643,7 @@ var BaseWalletUnlocked = class extends Account {
5859
5643
  * @param transactionRequestLike - The transaction request to send.
5860
5644
  * @returns A promise that resolves to the TransactionResponse object.
5861
5645
  */
5862
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5646
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5863
5647
  const transactionRequest = transactionRequestify(transactionRequestLike);
5864
5648
  if (estimateTxDependencies) {
5865
5649
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5900,15 +5684,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5900
5684
  // src/hdwallet/hdwallet.ts
5901
5685
  var import_errors20 = require("@fuel-ts/errors");
5902
5686
  var import_hasher6 = require("@fuel-ts/hasher");
5903
- var import_math21 = require("@fuel-ts/math");
5904
- var import_utils34 = require("@fuel-ts/utils");
5687
+ var import_math20 = require("@fuel-ts/math");
5688
+ var import_utils35 = require("@fuel-ts/utils");
5905
5689
  var import_ethers3 = require("ethers");
5906
5690
 
5907
5691
  // src/mnemonic/mnemonic.ts
5908
5692
  var import_crypto4 = require("@fuel-ts/crypto");
5909
5693
  var import_errors19 = require("@fuel-ts/errors");
5910
5694
  var import_hasher5 = require("@fuel-ts/hasher");
5911
- var import_utils32 = require("@fuel-ts/utils");
5695
+ var import_utils33 = require("@fuel-ts/utils");
5912
5696
  var import_ethers2 = require("ethers");
5913
5697
 
5914
5698
  // src/wordlists/words/english.ts
@@ -7972,7 +7756,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7972
7756
  // src/mnemonic/utils.ts
7973
7757
  var import_errors18 = require("@fuel-ts/errors");
7974
7758
  var import_hasher4 = require("@fuel-ts/hasher");
7975
- var import_utils31 = require("@fuel-ts/utils");
7759
+ var import_utils32 = require("@fuel-ts/utils");
7976
7760
  function toUtf8Bytes(stri) {
7977
7761
  const str = stri.normalize("NFKD");
7978
7762
  const result = [];
@@ -8039,14 +7823,14 @@ function entropyToMnemonicIndices(entropy) {
8039
7823
  }
8040
7824
  }
8041
7825
  const checksumBits = entropy.length / 4;
8042
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7826
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8043
7827
  indices[indices.length - 1] <<= checksumBits;
8044
7828
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8045
7829
  return indices;
8046
7830
  }
8047
7831
  function mnemonicWordsToEntropy(words, wordlist) {
8048
7832
  const size = Math.ceil(11 * words.length / 8);
8049
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7833
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8050
7834
  let offset = 0;
8051
7835
  for (let i = 0; i < words.length; i += 1) {
8052
7836
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8066,7 +7850,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8066
7850
  const entropyBits = 32 * words.length / 3;
8067
7851
  const checksumBits = words.length / 3;
8068
7852
  const checksumMask = getUpperMask(checksumBits);
8069
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7853
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8070
7854
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8071
7855
  throw new import_errors18.FuelError(
8072
7856
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8141,7 +7925,7 @@ var Mnemonic = class {
8141
7925
  static mnemonicToEntropy(phrase, wordlist = english) {
8142
7926
  const words = getWords(phrase);
8143
7927
  assertMnemonic(words);
8144
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7928
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8145
7929
  }
8146
7930
  /**
8147
7931
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8149,7 +7933,7 @@ var Mnemonic = class {
8149
7933
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8150
7934
  */
8151
7935
  static entropyToMnemonic(entropy, wordlist = english) {
8152
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7936
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8153
7937
  assertWordList(wordlist);
8154
7938
  assertEntropy(entropyBytes);
8155
7939
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8218,14 +8002,14 @@ var Mnemonic = class {
8218
8002
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8219
8003
  */
8220
8004
  static masterKeysFromSeed(seed) {
8221
- const seedArray = (0, import_utils32.arrayify)(seed);
8005
+ const seedArray = (0, import_utils33.arrayify)(seed);
8222
8006
  if (seedArray.length < 16 || seedArray.length > 64) {
8223
8007
  throw new import_errors19.FuelError(
8224
8008
  import_errors19.ErrorCode.INVALID_SEED,
8225
8009
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8226
8010
  );
8227
8011
  }
8228
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8012
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8229
8013
  }
8230
8014
  /**
8231
8015
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8236,22 +8020,22 @@ var Mnemonic = class {
8236
8020
  */
8237
8021
  static seedToExtendedKey(seed, testnet = false) {
8238
8022
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8239
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8023
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8240
8024
  const depth = "0x00";
8241
8025
  const fingerprint = "0x00000000";
8242
8026
  const index = "0x00000000";
8243
8027
  const chainCode = masterKey.slice(32);
8244
8028
  const privateKey = masterKey.slice(0, 32);
8245
- const extendedKey = (0, import_utils32.concat)([
8029
+ const extendedKey = (0, import_utils33.concat)([
8246
8030
  prefix,
8247
8031
  depth,
8248
8032
  fingerprint,
8249
8033
  index,
8250
8034
  chainCode,
8251
- (0, import_utils32.concat)(["0x00", privateKey])
8035
+ (0, import_utils33.concat)(["0x00", privateKey])
8252
8036
  ]);
8253
8037
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8254
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8038
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8255
8039
  }
8256
8040
  /**
8257
8041
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8266,7 +8050,7 @@ var Mnemonic = class {
8266
8050
  * @returns A randomly generated mnemonic
8267
8051
  */
8268
8052
  static generate(size = 32, extraEntropy = "") {
8269
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8053
+ 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);
8270
8054
  return Mnemonic.entropyToMnemonic(entropy);
8271
8055
  }
8272
8056
  };
@@ -8274,12 +8058,12 @@ var mnemonic_default = Mnemonic;
8274
8058
 
8275
8059
  // src/hdwallet/hdwallet.ts
8276
8060
  var HARDENED_INDEX = 2147483648;
8277
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8278
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8279
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8280
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8061
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8062
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8063
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8064
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8281
8065
  function base58check(data) {
8282
- return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8066
+ 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)]));
8283
8067
  }
8284
8068
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8285
8069
  if (isPublic) {
@@ -8288,11 +8072,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8288
8072
  return testnet ? TestnetPRV2 : MainnetPRV2;
8289
8073
  }
8290
8074
  function isPublicExtendedKey(extendedKey) {
8291
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8075
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8292
8076
  }
8293
8077
  function isValidExtendedKey(extendedKey) {
8294
8078
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8295
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8079
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8296
8080
  );
8297
8081
  }
8298
8082
  function parsePath(path, depth = 0) {
@@ -8310,8 +8094,8 @@ function parsePath(path, depth = 0) {
8310
8094
  var HDWallet = class {
8311
8095
  depth = 0;
8312
8096
  index = 0;
8313
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
8314
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8097
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8098
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8315
8099
  privateKey;
8316
8100
  publicKey;
8317
8101
  chainCode;
@@ -8323,8 +8107,8 @@ var HDWallet = class {
8323
8107
  constructor(config) {
8324
8108
  if (config.privateKey) {
8325
8109
  const signer = new Signer(config.privateKey);
8326
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8327
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8110
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8111
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8328
8112
  } else {
8329
8113
  if (!config.publicKey) {
8330
8114
  throw new import_errors20.FuelError(
@@ -8332,7 +8116,7 @@ var HDWallet = class {
8332
8116
  "Both public and private Key cannot be missing. At least one should be provided."
8333
8117
  );
8334
8118
  }
8335
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8119
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8336
8120
  }
8337
8121
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8338
8122
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -8351,9 +8135,9 @@ var HDWallet = class {
8351
8135
  * @returns A new instance of HDWallet on the derived index
8352
8136
  */
8353
8137
  deriveIndex(index) {
8354
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8355
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8356
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8138
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8139
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8140
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8357
8141
  const data = new Uint8Array(37);
8358
8142
  if (index & HARDENED_INDEX) {
8359
8143
  if (!privateKey) {
@@ -8364,15 +8148,15 @@ var HDWallet = class {
8364
8148
  }
8365
8149
  data.set(privateKey, 1);
8366
8150
  } else {
8367
- data.set((0, import_utils34.arrayify)(this.publicKey));
8151
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8368
8152
  }
8369
- data.set((0, import_math21.toBytes)(index, 4), 33);
8370
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8153
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8154
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8371
8155
  const IL = bytes.slice(0, 32);
8372
8156
  const IR = bytes.slice(32);
8373
8157
  if (privateKey) {
8374
8158
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8375
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8159
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8376
8160
  return new HDWallet({
8377
8161
  privateKey: ki,
8378
8162
  chainCode: IR,
@@ -8381,7 +8165,7 @@ var HDWallet = class {
8381
8165
  parentFingerprint: this.fingerprint
8382
8166
  });
8383
8167
  }
8384
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8168
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8385
8169
  const Ki = signer.addPoint(publicKey);
8386
8170
  return new HDWallet({
8387
8171
  publicKey: Ki,
@@ -8416,12 +8200,12 @@ var HDWallet = class {
8416
8200
  );
8417
8201
  }
8418
8202
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8419
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8203
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8420
8204
  const parentFingerprint = this.parentFingerprint;
8421
- const index = (0, import_math21.toHex)(this.index, 4);
8205
+ const index = (0, import_math20.toHex)(this.index, 4);
8422
8206
  const chainCode = this.chainCode;
8423
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8424
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8207
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8208
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8425
8209
  return base58check(extendedKey);
8426
8210
  }
8427
8211
  /**
@@ -8433,13 +8217,13 @@ var HDWallet = class {
8433
8217
  static fromSeed(seed) {
8434
8218
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8435
8219
  return new HDWallet({
8436
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8437
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8220
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8221
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8438
8222
  });
8439
8223
  }
8440
8224
  static fromExtendedKey(extendedKey) {
8441
8225
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8442
- const bytes = (0, import_utils34.arrayify)(decoded);
8226
+ const bytes = (0, import_utils35.arrayify)(decoded);
8443
8227
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8444
8228
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8445
8229
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8448,9 +8232,9 @@ var HDWallet = class {
8448
8232
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8449
8233
  }
8450
8234
  const depth = bytes[4];
8451
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8452
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8453
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8235
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8236
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8237
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8454
8238
  const key = bytes.slice(45, 78);
8455
8239
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8456
8240
  throw new import_errors20.FuelError(
@@ -9053,21 +8837,20 @@ var StorageAbstract = class {
9053
8837
  // src/predicate/predicate.ts
9054
8838
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
9055
8839
  var import_address10 = require("@fuel-ts/address");
9056
- var import_configs13 = require("@fuel-ts/address/configs");
9057
8840
  var import_errors25 = require("@fuel-ts/errors");
9058
- var import_transactions21 = require("@fuel-ts/transactions");
9059
- var import_utils36 = require("@fuel-ts/utils");
8841
+ var import_transactions20 = require("@fuel-ts/transactions");
8842
+ var import_utils37 = require("@fuel-ts/utils");
9060
8843
 
9061
8844
  // src/predicate/utils/getPredicateRoot.ts
9062
8845
  var import_hasher7 = require("@fuel-ts/hasher");
9063
8846
  var import_merkle = require("@fuel-ts/merkle");
9064
- var import_utils35 = require("@fuel-ts/utils");
8847
+ var import_utils36 = require("@fuel-ts/utils");
9065
8848
  var getPredicateRoot = (bytecode) => {
9066
8849
  const chunkSize = 16 * 1024;
9067
- const bytes = (0, import_utils35.arrayify)(bytecode);
9068
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9069
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9070
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8850
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8851
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8852
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8853
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9071
8854
  return predicateRoot;
9072
8855
  };
9073
8856
 
@@ -9115,9 +8898,9 @@ var Predicate = class extends Account {
9115
8898
  const request = transactionRequestify(transactionRequestLike);
9116
8899
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9117
8900
  request.inputs?.forEach((input) => {
9118
- if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9119
- input.predicate = (0, import_utils36.hexlify)(this.bytes);
9120
- input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8901
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8902
+ input.predicate = this.bytes;
8903
+ input.predicateData = this.getPredicateData(policies.length);
9121
8904
  }
9122
8905
  });
9123
8906
  return request;
@@ -9131,8 +8914,10 @@ var Predicate = class extends Account {
9131
8914
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
9132
8915
  * @returns A promise that resolves to the prepared transaction request.
9133
8916
  */
9134
- async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
9135
- return super.createTransfer(destination, amount, assetId, txParams);
8917
+ async createTransfer(destination, amount, assetId, txParams = {}) {
8918
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8919
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8920
+ return this.populateTransactionPredicateData(request);
9136
8921
  }
9137
8922
  /**
9138
8923
  * Sends a transaction with the populated predicate data.
@@ -9140,9 +8925,9 @@ var Predicate = class extends Account {
9140
8925
  * @param transactionRequestLike - The transaction request-like object.
9141
8926
  * @returns A promise that resolves to the transaction response.
9142
8927
  */
9143
- sendTransaction(transactionRequestLike) {
9144
- const transactionRequest = transactionRequestify(transactionRequestLike);
9145
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8928
+ sendTransaction(transactionRequestLike, options) {
8929
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8930
+ return super.sendTransaction(transactionRequest, options);
9146
8931
  }
9147
8932
  /**
9148
8933
  * Simulates a transaction with the populated predicate data.
@@ -9151,15 +8936,15 @@ var Predicate = class extends Account {
9151
8936
  * @returns A promise that resolves to the call result.
9152
8937
  */
9153
8938
  simulateTransaction(transactionRequestLike) {
9154
- const transactionRequest = transactionRequestify(transactionRequestLike);
9155
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8939
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8940
+ return super.simulateTransaction(transactionRequest);
9156
8941
  }
9157
8942
  getPredicateData(policiesLength) {
9158
8943
  if (!this.predicateData.length) {
9159
8944
  return new Uint8Array();
9160
8945
  }
9161
8946
  const mainFn = this.interface?.functions.main;
9162
- const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8947
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9163
8948
  const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9164
8949
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9165
8950
  });
@@ -9175,7 +8960,7 @@ var Predicate = class extends Account {
9175
8960
  * @returns An object containing the new predicate bytes and interface.
9176
8961
  */
9177
8962
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9178
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8963
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9179
8964
  let abiInterface;
9180
8965
  if (jsonAbi) {
9181
8966
  abiInterface = new import_abi_coder7.Interface(jsonAbi);
@@ -9198,25 +8983,6 @@ var Predicate = class extends Account {
9198
8983
  predicateInterface: abiInterface
9199
8984
  };
9200
8985
  }
9201
- /**
9202
- * Retrieves resources satisfying the spend query for the account.
9203
- *
9204
- * @param quantities - IDs of coins to exclude.
9205
- * @param excludedIds - IDs of resources to be excluded from the query.
9206
- * @returns A promise that resolves to an array of Resources.
9207
- */
9208
- async getResourcesToSpend(quantities, excludedIds) {
9209
- const resources = await this.provider.getResourcesToSpend(
9210
- this.address,
9211
- quantities,
9212
- excludedIds
9213
- );
9214
- return resources.map((resource) => ({
9215
- ...resource,
9216
- predicate: (0, import_utils36.hexlify)(this.bytes),
9217
- paddPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9218
- }));
9219
- }
9220
8986
  /**
9221
8987
  * Sets the configurable constants for the predicate.
9222
8988
  *
@@ -9966,7 +9732,7 @@ __publicField(Fuel, "defaultConfig", {});
9966
9732
  WalletLocked,
9967
9733
  WalletManager,
9968
9734
  WalletUnlocked,
9969
- addAmountToCoinQuantities,
9735
+ addAmountToAsset,
9970
9736
  addOperation,
9971
9737
  assemblePanicError,
9972
9738
  assembleReceiptByType,
@@ -9975,10 +9741,9 @@ __publicField(Fuel, "defaultConfig", {});
9975
9741
  assets,
9976
9742
  buildBlockExplorerUrl,
9977
9743
  cacheFor,
9978
- cacheTxInputsFromOwner,
9979
- calculateGasFee,
9980
9744
  calculateMetadataGasForTxCreate,
9981
9745
  calculateMetadataGasForTxScript,
9746
+ calculatePriceWithFactor,
9982
9747
  calculateTransactionFee,
9983
9748
  coinQuantityfy,
9984
9749
  deferPromise,