@fuel-ts/account 0.0.0-rc-2021-20240408141516 → 0.0.0-rc-1976-20240409133547

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

Potentially problematic release.


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

Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +619 -869
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +609 -845
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +452 -687
  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 +328 -894
  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 -3
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +34 -45
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +29 -9
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1120 -1584
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +606 -821
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +464 -679
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ __export(src_exports, {
95
95
  WalletLocked: () => WalletLocked,
96
96
  WalletManager: () => WalletManager,
97
97
  WalletUnlocked: () => WalletUnlocked,
98
- addAmountToCoinQuantities: () => addAmountToCoinQuantities,
98
+ addAmountToAsset: () => addAmountToAsset,
99
99
  addOperation: () => addOperation,
100
100
  assemblePanicError: () => assemblePanicError,
101
101
  assembleReceiptByType: () => assembleReceiptByType,
@@ -104,10 +104,9 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
- cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
108
- calculateGasFee: () => calculateGasFee,
109
107
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
110
108
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
109
+ calculatePriceWithFactor: () => calculatePriceWithFactor,
111
110
  calculateTransactionFee: () => calculateTransactionFee,
112
111
  coinQuantityfy: () => coinQuantityfy,
113
112
  deferPromise: () => deferPromise,
@@ -185,38 +184,35 @@ 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) => {
200
196
  let assetId;
201
197
  let amount;
202
- let max;
198
+ let max2;
203
199
  if (Array.isArray(coinQuantityLike)) {
204
200
  amount = coinQuantityLike[0];
205
- assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
206
- max = 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;
210
- max = coinQuantityLike.max ?? void 0;
205
+ assetId = coinQuantityLike.assetId;
206
+ max2 = coinQuantityLike.max ?? void 0;
211
207
  }
212
208
  const bnAmount = (0, import_math.bn)(amount);
213
209
  return {
214
210
  assetId: (0, import_utils.hexlify)(assetId),
215
211
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
216
- max: max ? (0, import_math.bn)(max) : void 0
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,12 +227,12 @@ 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");
239
- var import_ethers2 = require("ethers");
234
+ var import_utils24 = require("@noble/curves/abstract/utils");
235
+ var import_ethers = require("ethers");
240
236
  var import_graphql_request = require("graphql-request");
241
237
  var import_ramda3 = require("ramda");
242
238
 
@@ -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
  }
@@ -428,6 +385,7 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
428
385
  prevRoot
429
386
  time
430
387
  applicationHash
388
+ messageReceiptRoot
431
389
  messageReceiptCount
432
390
  }
433
391
  commitBlockHeader {
@@ -439,6 +397,7 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
439
397
  prevRoot
440
398
  time
441
399
  applicationHash
400
+ messageReceiptRoot
442
401
  messageReceiptCount
443
402
  }
444
403
  sender
@@ -458,8 +417,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
458
417
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
459
418
  fragment blockFragment on Block {
460
419
  id
461
- height
462
420
  header {
421
+ height
463
422
  time
464
423
  }
465
424
  transactions {
@@ -517,11 +476,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
517
476
  `;
518
477
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
519
478
  fragment GasCostsFragment on GasCosts {
520
- version {
521
- ... on Version {
522
- value
523
- }
524
- }
525
479
  add
526
480
  addi
527
481
  aloc
@@ -534,6 +488,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
534
488
  cb
535
489
  cfei
536
490
  cfsi
491
+ croo
537
492
  div
538
493
  divi
539
494
  ecr1
@@ -616,9 +571,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
616
571
  ccp {
617
572
  ...DependentCostFragment
618
573
  }
619
- croo {
620
- ...DependentCostFragment
621
- }
622
574
  csiz {
623
575
  ...DependentCostFragment
624
576
  }
@@ -678,11 +630,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
678
630
  ${DependentCostFragmentFragmentDoc}`;
679
631
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
680
632
  fragment consensusParametersFragment on ConsensusParameters {
681
- version {
682
- ... on Version {
683
- value
684
- }
685
- }
686
633
  txParams {
687
634
  ...TxParametersFragment
688
635
  }
@@ -742,9 +689,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
742
689
  fragment nodeInfoFragment on NodeInfo {
743
690
  utxoValidation
744
691
  vmBacktrace
692
+ minGasPrice
745
693
  maxTx
746
694
  maxDepth
747
695
  nodeVersion
696
+ peers {
697
+ id
698
+ addresses
699
+ clientVersion
700
+ blockHeight
701
+ lastHeartbeatMs
702
+ appScore
703
+ }
748
704
  }
749
705
  `;
750
706
  var GetVersionDocument = import_graphql_tag.default`
@@ -779,9 +735,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
779
735
  query getTransactionWithReceipts($transactionId: TransactionId!) {
780
736
  transaction(id: $transactionId) {
781
737
  ...transactionFragment
738
+ receipts {
739
+ ...receiptFragment
740
+ }
782
741
  }
783
742
  }
784
- ${TransactionFragmentFragmentDoc}`;
743
+ ${TransactionFragmentFragmentDoc}
744
+ ${ReceiptFragmentFragmentDoc}`;
785
745
  var GetTransactionsDocument = import_graphql_tag.default`
786
746
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
787
747
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -909,20 +869,6 @@ var GetBalanceDocument = import_graphql_tag.default`
909
869
  }
910
870
  }
911
871
  ${BalanceFragmentFragmentDoc}`;
912
- var GetLatestGasPriceDocument = import_graphql_tag.default`
913
- query getLatestGasPrice {
914
- latestGasPrice {
915
- gasPrice
916
- }
917
- }
918
- `;
919
- var EstimateGasPriceDocument = import_graphql_tag.default`
920
- query estimateGasPrice($blockHorizon: U32!) {
921
- estimateGasPrice(blockHorizon: $blockHorizon) {
922
- gasPrice
923
- }
924
- }
925
- `;
926
872
  var GetBalancesDocument = import_graphql_tag.default`
927
873
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
928
874
  balances(
@@ -977,12 +923,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
977
923
  }
978
924
  `;
979
925
  var DryRunDocument = import_graphql_tag.default`
980
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
981
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
982
- ...dryRunTransactionExecutionStatusFragment
926
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
927
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
928
+ ...receiptFragment
983
929
  }
984
930
  }
985
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
931
+ ${ReceiptFragmentFragmentDoc}`;
986
932
  var SubmitDocument = import_graphql_tag.default`
987
933
  mutation submit($encodedTransaction: HexString!) {
988
934
  submit(tx: $encodedTransaction) {
@@ -1065,12 +1011,6 @@ function getSdk(requester) {
1065
1011
  getBalance(variables, options) {
1066
1012
  return requester(GetBalanceDocument, variables, options);
1067
1013
  },
1068
- getLatestGasPrice(variables, options) {
1069
- return requester(GetLatestGasPriceDocument, variables, options);
1070
- },
1071
- estimateGasPrice(variables, options) {
1072
- return requester(EstimateGasPriceDocument, variables, options);
1073
- },
1074
1014
  getBalances(variables, options) {
1075
1015
  return requester(GetBalancesDocument, variables, options);
1076
1016
  },
@@ -1231,7 +1171,7 @@ var MemoryCache = class {
1231
1171
  };
1232
1172
 
1233
1173
  // src/providers/transaction-request/input.ts
1234
- var import_configs2 = require("@fuel-ts/address/configs");
1174
+ var import_configs = require("@fuel-ts/address/configs");
1235
1175
  var import_errors3 = require("@fuel-ts/errors");
1236
1176
  var import_math2 = require("@fuel-ts/math");
1237
1177
  var import_transactions = require("@fuel-ts/transactions");
@@ -1245,7 +1185,7 @@ var inputify = (value) => {
1245
1185
  return {
1246
1186
  type: import_transactions.InputType.Coin,
1247
1187
  txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1248
- outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 34)),
1188
+ outputIndex: (0, import_utils3.arrayify)(value.id)[32],
1249
1189
  owner: (0, import_utils3.hexlify)(value.owner),
1250
1190
  amount: (0, import_math2.bn)(value.amount),
1251
1191
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1254,9 +1194,10 @@ var inputify = (value) => {
1254
1194
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1255
1195
  },
1256
1196
  witnessIndex: value.witnessIndex,
1197
+ maturity: value.maturity ?? 0,
1257
1198
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1258
- predicateLength: (0, import_math2.bn)(predicate.length),
1259
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1199
+ predicateLength: predicate.length,
1200
+ predicateDataLength: predicateData.length,
1260
1201
  predicate: (0, import_utils3.hexlify)(predicate),
1261
1202
  predicateData: (0, import_utils3.hexlify)(predicateData)
1262
1203
  };
@@ -1264,10 +1205,10 @@ var inputify = (value) => {
1264
1205
  case import_transactions.InputType.Contract: {
1265
1206
  return {
1266
1207
  type: import_transactions.InputType.Contract,
1267
- txID: import_configs2.ZeroBytes32,
1208
+ txID: import_configs.ZeroBytes32,
1268
1209
  outputIndex: 0,
1269
- balanceRoot: import_configs2.ZeroBytes32,
1270
- stateRoot: import_configs2.ZeroBytes32,
1210
+ balanceRoot: import_configs.ZeroBytes32,
1211
+ stateRoot: import_configs.ZeroBytes32,
1271
1212
  txPointer: {
1272
1213
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1273
1214
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1287,8 +1228,8 @@ var inputify = (value) => {
1287
1228
  nonce: (0, import_utils3.hexlify)(value.nonce),
1288
1229
  witnessIndex: value.witnessIndex,
1289
1230
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1290
- predicateLength: (0, import_math2.bn)(predicate.length),
1291
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1231
+ predicateLength: predicate.length,
1232
+ predicateDataLength: predicateData.length,
1292
1233
  predicate: (0, import_utils3.hexlify)(predicate),
1293
1234
  predicateData: (0, import_utils3.hexlify)(predicateData),
1294
1235
  data: (0, import_utils3.hexlify)(data),
@@ -1305,7 +1246,7 @@ var inputify = (value) => {
1305
1246
  };
1306
1247
 
1307
1248
  // src/providers/transaction-request/output.ts
1308
- var import_configs3 = require("@fuel-ts/address/configs");
1249
+ var import_configs2 = require("@fuel-ts/address/configs");
1309
1250
  var import_errors4 = require("@fuel-ts/errors");
1310
1251
  var import_math3 = require("@fuel-ts/math");
1311
1252
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1325,8 +1266,8 @@ var outputify = (value) => {
1325
1266
  return {
1326
1267
  type: import_transactions2.OutputType.Contract,
1327
1268
  inputIndex: value.inputIndex,
1328
- balanceRoot: import_configs3.ZeroBytes32,
1329
- stateRoot: import_configs3.ZeroBytes32
1269
+ balanceRoot: import_configs2.ZeroBytes32,
1270
+ stateRoot: import_configs2.ZeroBytes32
1330
1271
  };
1331
1272
  }
1332
1273
  case import_transactions2.OutputType.Change: {
@@ -1340,9 +1281,9 @@ var outputify = (value) => {
1340
1281
  case import_transactions2.OutputType.Variable: {
1341
1282
  return {
1342
1283
  type: import_transactions2.OutputType.Variable,
1343
- to: import_configs3.ZeroBytes32,
1284
+ to: import_configs2.ZeroBytes32,
1344
1285
  amount: (0, import_math3.bn)(0),
1345
- assetId: import_configs3.ZeroBytes32
1286
+ assetId: import_configs2.ZeroBytes32
1346
1287
  };
1347
1288
  }
1348
1289
  case import_transactions2.OutputType.ContractCreated: {
@@ -1363,11 +1304,10 @@ var outputify = (value) => {
1363
1304
 
1364
1305
  // src/providers/transaction-request/transaction-request.ts
1365
1306
  var import_address = require("@fuel-ts/address");
1366
- var import_configs7 = require("@fuel-ts/address/configs");
1307
+ var import_configs6 = require("@fuel-ts/address/configs");
1367
1308
  var import_math7 = require("@fuel-ts/math");
1368
1309
  var import_transactions6 = require("@fuel-ts/transactions");
1369
1310
  var import_utils9 = require("@fuel-ts/utils");
1370
- var import_ethers = require("ethers");
1371
1311
 
1372
1312
  // src/providers/resource.ts
1373
1313
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1376,13 +1316,13 @@ var isCoin = (resource) => "id" in resource;
1376
1316
  var isMessage = (resource) => "recipient" in resource;
1377
1317
 
1378
1318
  // src/providers/utils/receipts.ts
1379
- var import_configs4 = require("@fuel-ts/address/configs");
1319
+ var import_configs3 = require("@fuel-ts/address/configs");
1380
1320
  var import_errors5 = require("@fuel-ts/errors");
1381
1321
  var import_math4 = require("@fuel-ts/math");
1382
1322
  var import_transactions3 = require("@fuel-ts/transactions");
1383
- var import_configs5 = require("@fuel-ts/transactions/configs");
1323
+ var import_configs4 = require("@fuel-ts/transactions/configs");
1384
1324
  var import_utils5 = require("@fuel-ts/utils");
1385
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1325
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1386
1326
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1387
1327
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1388
1328
  (memo, receipt) => {
@@ -1399,15 +1339,15 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1399
1339
  missingOutputContractIds: []
1400
1340
  }
1401
1341
  );
1402
- var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1342
+ var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1403
1343
  function assembleReceiptByType(receipt) {
1404
1344
  const { receiptType } = receipt;
1405
1345
  switch (receiptType) {
1406
1346
  case "CALL" /* Call */: {
1407
1347
  const callReceipt = {
1408
1348
  type: import_transactions3.ReceiptType.Call,
1409
- from: hexOrZero(receipt.id || receipt.contractId),
1410
- to: hexOrZero(receipt?.to),
1349
+ from: hexOrZero(receipt.contract?.id),
1350
+ to: hexOrZero(receipt?.to?.id),
1411
1351
  amount: (0, import_math4.bn)(receipt.amount),
1412
1352
  assetId: hexOrZero(receipt.assetId),
1413
1353
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1421,7 +1361,7 @@ function assembleReceiptByType(receipt) {
1421
1361
  case "RETURN" /* Return */: {
1422
1362
  const returnReceipt = {
1423
1363
  type: import_transactions3.ReceiptType.Return,
1424
- id: hexOrZero(receipt.id || receipt.contractId),
1364
+ id: hexOrZero(receipt.contract?.id),
1425
1365
  val: (0, import_math4.bn)(receipt.val),
1426
1366
  pc: (0, import_math4.bn)(receipt.pc),
1427
1367
  is: (0, import_math4.bn)(receipt.is)
@@ -1431,7 +1371,7 @@ function assembleReceiptByType(receipt) {
1431
1371
  case "RETURN_DATA" /* ReturnData */: {
1432
1372
  const returnDataReceipt = {
1433
1373
  type: import_transactions3.ReceiptType.ReturnData,
1434
- id: hexOrZero(receipt.id || receipt.contractId),
1374
+ id: hexOrZero(receipt.contract?.id),
1435
1375
  ptr: (0, import_math4.bn)(receipt.ptr),
1436
1376
  len: (0, import_math4.bn)(receipt.len),
1437
1377
  digest: hexOrZero(receipt.digest),
@@ -1443,7 +1383,7 @@ function assembleReceiptByType(receipt) {
1443
1383
  case "PANIC" /* Panic */: {
1444
1384
  const panicReceipt = {
1445
1385
  type: import_transactions3.ReceiptType.Panic,
1446
- id: hexOrZero(receipt.id),
1386
+ id: hexOrZero(receipt.contract?.id),
1447
1387
  reason: (0, import_math4.bn)(receipt.reason),
1448
1388
  pc: (0, import_math4.bn)(receipt.pc),
1449
1389
  is: (0, import_math4.bn)(receipt.is),
@@ -1454,7 +1394,7 @@ function assembleReceiptByType(receipt) {
1454
1394
  case "REVERT" /* Revert */: {
1455
1395
  const revertReceipt = {
1456
1396
  type: import_transactions3.ReceiptType.Revert,
1457
- id: hexOrZero(receipt.id || receipt.contractId),
1397
+ id: hexOrZero(receipt.contract?.id),
1458
1398
  val: (0, import_math4.bn)(receipt.ra),
1459
1399
  pc: (0, import_math4.bn)(receipt.pc),
1460
1400
  is: (0, import_math4.bn)(receipt.is)
@@ -1464,7 +1404,7 @@ function assembleReceiptByType(receipt) {
1464
1404
  case "LOG" /* Log */: {
1465
1405
  const logReceipt = {
1466
1406
  type: import_transactions3.ReceiptType.Log,
1467
- id: hexOrZero(receipt.id || receipt.contractId),
1407
+ id: hexOrZero(receipt.contract?.id),
1468
1408
  val0: (0, import_math4.bn)(receipt.ra),
1469
1409
  val1: (0, import_math4.bn)(receipt.rb),
1470
1410
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1477,7 +1417,7 @@ function assembleReceiptByType(receipt) {
1477
1417
  case "LOG_DATA" /* LogData */: {
1478
1418
  const logDataReceipt = {
1479
1419
  type: import_transactions3.ReceiptType.LogData,
1480
- id: hexOrZero(receipt.id || receipt.contractId),
1420
+ id: hexOrZero(receipt.contract?.id),
1481
1421
  val0: (0, import_math4.bn)(receipt.ra),
1482
1422
  val1: (0, import_math4.bn)(receipt.rb),
1483
1423
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1491,8 +1431,8 @@ function assembleReceiptByType(receipt) {
1491
1431
  case "TRANSFER" /* Transfer */: {
1492
1432
  const transferReceipt = {
1493
1433
  type: import_transactions3.ReceiptType.Transfer,
1494
- from: hexOrZero(receipt.id || receipt.contractId),
1495
- to: hexOrZero(receipt.toAddress || receipt?.to),
1434
+ from: hexOrZero(receipt.contract?.id),
1435
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1496
1436
  amount: (0, import_math4.bn)(receipt.amount),
1497
1437
  assetId: hexOrZero(receipt.assetId),
1498
1438
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1503,8 +1443,8 @@ function assembleReceiptByType(receipt) {
1503
1443
  case "TRANSFER_OUT" /* TransferOut */: {
1504
1444
  const transferOutReceipt = {
1505
1445
  type: import_transactions3.ReceiptType.TransferOut,
1506
- from: hexOrZero(receipt.id || receipt.contractId),
1507
- to: hexOrZero(receipt.toAddress || receipt.to),
1446
+ from: hexOrZero(receipt.contract?.id),
1447
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1508
1448
  amount: (0, import_math4.bn)(receipt.amount),
1509
1449
  assetId: hexOrZero(receipt.assetId),
1510
1450
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1547,7 +1487,7 @@ function assembleReceiptByType(receipt) {
1547
1487
  return receiptMessageOut;
1548
1488
  }
1549
1489
  case "MINT" /* Mint */: {
1550
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1490
+ const contractId = hexOrZero(receipt.contract?.id);
1551
1491
  const subId = hexOrZero(receipt.subId);
1552
1492
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1553
1493
  const mintReceipt = {
@@ -1562,7 +1502,7 @@ function assembleReceiptByType(receipt) {
1562
1502
  return mintReceipt;
1563
1503
  }
1564
1504
  case "BURN" /* Burn */: {
1565
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1505
+ const contractId = hexOrZero(receipt.contract?.id);
1566
1506
  const subId = hexOrZero(receipt.subId);
1567
1507
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1568
1508
  const burnReceipt = {
@@ -1647,6 +1587,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1647
1587
  var import_math5 = require("@fuel-ts/math");
1648
1588
  var import_transactions4 = require("@fuel-ts/transactions");
1649
1589
  var import_utils6 = require("@fuel-ts/utils");
1590
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1650
1591
  var getGasUsedFromReceipts = (receipts) => {
1651
1592
  const scriptResult = receipts.filter(
1652
1593
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1667,28 +1608,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1667
1608
  }
1668
1609
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1669
1610
  const witnessCache = [];
1670
- const chargeableInputs = inputs.filter((input) => {
1671
- const isCoinOrMessage = "owner" in input || "sender" in input;
1672
- if (isCoinOrMessage) {
1673
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1674
- return true;
1675
- }
1676
- if (!witnessCache.includes(input.witnessIndex)) {
1677
- witnessCache.push(input.witnessIndex);
1678
- return true;
1679
- }
1680
- }
1681
- return false;
1682
- });
1683
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1684
- const totalGas = chargeableInputs.reduce((total, input) => {
1611
+ const totalGas = inputs.reduce((total, input) => {
1685
1612
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1686
1613
  return total.add(
1687
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1614
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1688
1615
  );
1689
1616
  }
1690
- return total.add(gasCosts.ecr1);
1691
- }, (0, import_math5.bn)(0));
1617
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1618
+ witnessCache.push(input.witnessIndex);
1619
+ return total.add(gasCosts.ecr1);
1620
+ }
1621
+ return total;
1622
+ }, (0, import_math5.bn)());
1692
1623
  return totalGas;
1693
1624
  }
1694
1625
  function getMinGas(params) {
@@ -1700,20 +1631,12 @@ function getMinGas(params) {
1700
1631
  return minGas;
1701
1632
  }
1702
1633
  function getMaxGas(params) {
1703
- const {
1704
- gasPerByte,
1705
- witnessesLength,
1706
- witnessLimit,
1707
- minGas,
1708
- gasLimit = (0, import_math5.bn)(0),
1709
- maxGasPerTx
1710
- } = params;
1634
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1711
1635
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1712
1636
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1713
1637
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1714
1638
  }
1715
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1716
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1639
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1717
1640
  }
1718
1641
  function calculateMetadataGasForTxCreate({
1719
1642
  gasCosts,
@@ -1735,10 +1658,6 @@ function calculateMetadataGasForTxScript({
1735
1658
  }) {
1736
1659
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1737
1660
  }
1738
- var calculateGasFee = (params) => {
1739
- const { gas, gasPrice, priceFactor, tip } = params;
1740
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1741
- };
1742
1661
 
1743
1662
  // src/providers/utils/json.ts
1744
1663
  var import_utils7 = require("@fuel-ts/utils");
@@ -1784,16 +1703,16 @@ function sleep(time) {
1784
1703
  var import_errors7 = require("@fuel-ts/errors");
1785
1704
  var import_math6 = require("@fuel-ts/math");
1786
1705
  var import_transactions5 = require("@fuel-ts/transactions");
1787
- var import_configs6 = require("@fuel-ts/transactions/configs");
1706
+ var import_configs5 = require("@fuel-ts/transactions/configs");
1788
1707
  var assemblePanicError = (status) => {
1789
1708
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1790
1709
  const reason = status.reason;
1791
- if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1710
+ if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1792
1711
  errorMessage = `${errorMessage}
1793
1712
 
1794
1713
  You can read more about this error at:
1795
1714
 
1796
- ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1715
+ ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1797
1716
  }
1798
1717
  return { errorMessage, reason };
1799
1718
  };
@@ -1805,28 +1724,28 @@ var assembleRevertError = (receipts, logs) => {
1805
1724
  if (revertReceipt) {
1806
1725
  const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1807
1726
  switch (reasonHex) {
1808
- case import_configs6.FAILED_REQUIRE_SIGNAL: {
1727
+ case import_configs5.FAILED_REQUIRE_SIGNAL: {
1809
1728
  reason = "require";
1810
1729
  errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1811
1730
  break;
1812
1731
  }
1813
- case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1732
+ case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
1814
1733
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1815
1734
  reason = "assert_eq";
1816
1735
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1817
1736
  break;
1818
1737
  }
1819
- case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1738
+ case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
1820
1739
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1821
1740
  reason = "assert_ne";
1822
1741
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1823
1742
  break;
1824
1743
  }
1825
- case import_configs6.FAILED_ASSERT_SIGNAL:
1744
+ case import_configs5.FAILED_ASSERT_SIGNAL:
1826
1745
  reason = "assert";
1827
1746
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1828
1747
  break;
1829
- case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1748
+ case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1830
1749
  reason = "MissingOutputChange";
1831
1750
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1832
1751
  break;
@@ -1887,7 +1806,7 @@ var witnessify = (value) => {
1887
1806
  // src/providers/transaction-request/transaction-request.ts
1888
1807
  var BaseTransactionRequest = class {
1889
1808
  /** Gas price for transaction */
1890
- tip;
1809
+ gasPrice;
1891
1810
  /** Block until which tx cannot be included */
1892
1811
  maturity;
1893
1812
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1900,34 +1819,38 @@ var BaseTransactionRequest = class {
1900
1819
  outputs = [];
1901
1820
  /** List of witnesses */
1902
1821
  witnesses = [];
1822
+ /** Base asset ID - should be fetched from the chain */
1823
+ baseAssetId = import_configs6.ZeroBytes32;
1903
1824
  /**
1904
1825
  * Constructor for initializing a base transaction request.
1905
1826
  *
1906
1827
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1907
1828
  */
1908
1829
  constructor({
1909
- tip,
1830
+ gasPrice,
1910
1831
  maturity,
1911
1832
  maxFee,
1912
1833
  witnessLimit,
1913
1834
  inputs,
1914
1835
  outputs,
1915
- witnesses
1836
+ witnesses,
1837
+ baseAssetId
1916
1838
  } = {}) {
1917
- this.tip = (0, import_math7.bn)(tip);
1839
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1918
1840
  this.maturity = maturity ?? 0;
1919
1841
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1920
1842
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1921
1843
  this.inputs = inputs ?? [];
1922
1844
  this.outputs = outputs ?? [];
1923
1845
  this.witnesses = witnesses ?? [];
1846
+ this.baseAssetId = baseAssetId ?? import_configs6.ZeroBytes32;
1924
1847
  }
1925
1848
  static getPolicyMeta(req) {
1926
1849
  let policyTypes = 0;
1927
1850
  const policies = [];
1928
- if (req.tip) {
1929
- policyTypes += import_transactions6.PolicyType.Tip;
1930
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1851
+ if (req.gasPrice) {
1852
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1853
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1931
1854
  }
1932
1855
  if (req.witnessLimit) {
1933
1856
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -2013,7 +1936,7 @@ var BaseTransactionRequest = class {
2013
1936
  * @returns The index of the created witness.
2014
1937
  */
2015
1938
  addEmptyWitness() {
2016
- this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1939
+ this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
2017
1940
  return this.witnesses.length - 1;
2018
1941
  }
2019
1942
  /**
@@ -2114,10 +2037,10 @@ var BaseTransactionRequest = class {
2114
2037
  * @param predicate - Predicate bytes.
2115
2038
  * @param predicateData - Predicate data bytes.
2116
2039
  */
2117
- addCoinInput(coin) {
2040
+ addCoinInput(coin, predicate) {
2118
2041
  const { assetId, owner, amount } = coin;
2119
2042
  let witnessIndex;
2120
- if (coin.predicate) {
2043
+ if (predicate) {
2121
2044
  witnessIndex = 0;
2122
2045
  } else {
2123
2046
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2132,7 +2055,9 @@ var BaseTransactionRequest = class {
2132
2055
  amount,
2133
2056
  assetId,
2134
2057
  txPointer: "0x00000000000000000000000000000000",
2135
- witnessIndex
2058
+ witnessIndex,
2059
+ predicate: predicate?.bytes,
2060
+ predicateData: predicate?.predicateDataBytes
2136
2061
  };
2137
2062
  this.pushInput(input);
2138
2063
  this.addChangeOutput(owner, assetId);
@@ -2143,13 +2068,11 @@ var BaseTransactionRequest = class {
2143
2068
  *
2144
2069
  * @param message - Message resource.
2145
2070
  * @param predicate - Predicate bytes.
2146
- * @param predicateData - Predicate data bytes.
2147
2071
  */
2148
- addMessageInput(message) {
2072
+ addMessageInput(message, predicate) {
2149
2073
  const { recipient, sender, amount } = message;
2150
- const assetId = import_configs7.BaseAssetId;
2151
2074
  let witnessIndex;
2152
- if (message.predicate) {
2075
+ if (predicate) {
2153
2076
  witnessIndex = 0;
2154
2077
  } else {
2155
2078
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2163,10 +2086,12 @@ var BaseTransactionRequest = class {
2163
2086
  sender: sender.toB256(),
2164
2087
  recipient: recipient.toB256(),
2165
2088
  amount,
2166
- witnessIndex
2089
+ witnessIndex,
2090
+ predicate: predicate?.bytes,
2091
+ predicateData: predicate?.predicateDataBytes
2167
2092
  };
2168
2093
  this.pushInput(input);
2169
- this.addChangeOutput(recipient, assetId);
2094
+ this.addChangeOutput(recipient, this.baseAssetId);
2170
2095
  }
2171
2096
  /**
2172
2097
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2194,6 +2119,32 @@ var BaseTransactionRequest = class {
2194
2119
  resources.forEach((resource) => this.addResource(resource));
2195
2120
  return this;
2196
2121
  }
2122
+ /**
2123
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2124
+ * outputs from the related assetIds.
2125
+ *
2126
+ * @param resources - The resources to add.
2127
+ * @returns This transaction.
2128
+ */
2129
+ addPredicateResource(resource, predicate) {
2130
+ if (isCoin(resource)) {
2131
+ this.addCoinInput(resource, predicate);
2132
+ } else {
2133
+ this.addMessageInput(resource, predicate);
2134
+ }
2135
+ return this;
2136
+ }
2137
+ /**
2138
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2139
+ * from the related assetIds.
2140
+ *
2141
+ * @param resources - The resources to add.
2142
+ * @returns This transaction.
2143
+ */
2144
+ addPredicateResources(resources, predicate) {
2145
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2146
+ return this;
2147
+ }
2197
2148
  /**
2198
2149
  * Adds a coin output to the transaction.
2199
2150
  *
@@ -2201,12 +2152,12 @@ var BaseTransactionRequest = class {
2201
2152
  * @param amount - Amount of coin.
2202
2153
  * @param assetId - Asset ID of coin.
2203
2154
  */
2204
- addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2155
+ addCoinOutput(to, amount, assetId) {
2205
2156
  this.pushOutput({
2206
2157
  type: import_transactions6.OutputType.Coin,
2207
2158
  to: (0, import_address.addressify)(to).toB256(),
2208
2159
  amount,
2209
- assetId
2160
+ assetId: assetId ?? this.baseAssetId
2210
2161
  });
2211
2162
  return this;
2212
2163
  }
@@ -2233,7 +2184,7 @@ var BaseTransactionRequest = class {
2233
2184
  * @param to - Address of the owner.
2234
2185
  * @param assetId - Asset ID of coin.
2235
2186
  */
2236
- addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2187
+ addChangeOutput(to, assetId) {
2237
2188
  const changeOutput = this.getChangeOutputs().find(
2238
2189
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2239
2190
  );
@@ -2241,7 +2192,7 @@ var BaseTransactionRequest = class {
2241
2192
  this.pushOutput({
2242
2193
  type: import_transactions6.OutputType.Change,
2243
2194
  to: (0, import_address.addressify)(to).toB256(),
2244
- assetId
2195
+ assetId: assetId ?? this.baseAssetId
2245
2196
  });
2246
2197
  }
2247
2198
  }
@@ -2273,7 +2224,7 @@ var BaseTransactionRequest = class {
2273
2224
  }
2274
2225
  calculateMaxGas(chainInfo, minGas) {
2275
2226
  const { consensusParameters } = chainInfo;
2276
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2227
+ const { gasPerByte } = consensusParameters;
2277
2228
  const witnessesLength = this.toTransaction().witnesses.reduce(
2278
2229
  (acc, wit) => acc + wit.dataLength,
2279
2230
  0
@@ -2282,8 +2233,7 @@ var BaseTransactionRequest = class {
2282
2233
  gasPerByte,
2283
2234
  minGas,
2284
2235
  witnessesLength,
2285
- witnessLimit: this.witnessLimit,
2286
- maxGasPerTx
2236
+ witnessLimit: this.witnessLimit
2287
2237
  });
2288
2238
  }
2289
2239
  /**
@@ -2293,6 +2243,12 @@ var BaseTransactionRequest = class {
2293
2243
  * @param quantities - CoinQuantity Array.
2294
2244
  */
2295
2245
  fundWithFakeUtxos(quantities, resourcesOwner) {
2246
+ let idCounter = 0;
2247
+ const generateId = () => {
2248
+ const counterString = String(idCounter++);
2249
+ const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2250
+ return id;
2251
+ };
2296
2252
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2297
2253
  if ("assetId" in input) {
2298
2254
  return input.assetId === assetId;
@@ -2301,27 +2257,24 @@ var BaseTransactionRequest = class {
2301
2257
  });
2302
2258
  const updateAssetInput = (assetId, quantity) => {
2303
2259
  const assetInput = findAssetInput(assetId);
2304
- let usedQuantity = quantity;
2305
- if (assetId === import_configs7.BaseAssetId) {
2306
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2307
- }
2308
2260
  if (assetInput && "assetId" in assetInput) {
2309
- assetInput.id = (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34));
2310
- assetInput.amount = usedQuantity;
2261
+ assetInput.id = generateId();
2262
+ assetInput.amount = quantity;
2311
2263
  } else {
2312
2264
  this.addResources([
2313
2265
  {
2314
- id: (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34)),
2315
- amount: usedQuantity,
2266
+ id: generateId(),
2267
+ amount: quantity,
2316
2268
  assetId,
2317
2269
  owner: resourcesOwner || import_address.Address.fromRandom(),
2270
+ maturity: 0,
2318
2271
  blockCreated: (0, import_math7.bn)(1),
2319
2272
  txCreatedIdx: (0, import_math7.bn)(1)
2320
2273
  }
2321
2274
  ]);
2322
2275
  }
2323
2276
  };
2324
- updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2277
+ updateAssetInput(this.baseAssetId, (0, import_math7.bn)(1e11));
2325
2278
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2326
2279
  }
2327
2280
  /**
@@ -2346,7 +2299,7 @@ var BaseTransactionRequest = class {
2346
2299
  toJSON() {
2347
2300
  return normalizeJSON(this);
2348
2301
  }
2349
- updatePredicateGasUsed(inputs) {
2302
+ updatePredicateInputs(inputs) {
2350
2303
  this.inputs.forEach((i) => {
2351
2304
  let correspondingInput;
2352
2305
  switch (i.type) {
@@ -2368,25 +2321,16 @@ var BaseTransactionRequest = class {
2368
2321
  }
2369
2322
  });
2370
2323
  }
2371
- shiftPredicateData() {
2372
- this.inputs.forEach((input) => {
2373
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2374
- input.predicateData = input.paddPredicateData(
2375
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2376
- );
2377
- }
2378
- });
2379
- }
2380
2324
  };
2381
2325
 
2382
2326
  // src/providers/transaction-request/create-transaction-request.ts
2383
- var import_configs9 = require("@fuel-ts/address/configs");
2327
+ var import_configs8 = require("@fuel-ts/address/configs");
2384
2328
  var import_math9 = require("@fuel-ts/math");
2385
2329
  var import_transactions8 = require("@fuel-ts/transactions");
2386
2330
  var import_utils13 = require("@fuel-ts/utils");
2387
2331
 
2388
2332
  // src/providers/transaction-request/hash-transaction.ts
2389
- var import_configs8 = require("@fuel-ts/address/configs");
2333
+ var import_configs7 = require("@fuel-ts/address/configs");
2390
2334
  var import_hasher = require("@fuel-ts/hasher");
2391
2335
  var import_math8 = require("@fuel-ts/math");
2392
2336
  var import_transactions7 = require("@fuel-ts/transactions");
@@ -2395,7 +2339,7 @@ var import_ramda2 = require("ramda");
2395
2339
  function hashTransaction(transactionRequest, chainId) {
2396
2340
  const transaction = transactionRequest.toTransaction();
2397
2341
  if (transaction.type === import_transactions7.TransactionType.Script) {
2398
- transaction.receiptsRoot = import_configs8.ZeroBytes32;
2342
+ transaction.receiptsRoot = import_configs7.ZeroBytes32;
2399
2343
  }
2400
2344
  transaction.inputs = transaction.inputs.map((input) => {
2401
2345
  const inputClone = (0, import_ramda2.clone)(input);
@@ -2417,10 +2361,10 @@ function hashTransaction(transactionRequest, chainId) {
2417
2361
  blockHeight: 0,
2418
2362
  txIndex: 0
2419
2363
  };
2420
- inputClone.txID = import_configs8.ZeroBytes32;
2364
+ inputClone.txID = import_configs7.ZeroBytes32;
2421
2365
  inputClone.outputIndex = 0;
2422
- inputClone.balanceRoot = import_configs8.ZeroBytes32;
2423
- inputClone.stateRoot = import_configs8.ZeroBytes32;
2366
+ inputClone.balanceRoot = import_configs7.ZeroBytes32;
2367
+ inputClone.stateRoot = import_configs7.ZeroBytes32;
2424
2368
  return inputClone;
2425
2369
  }
2426
2370
  default:
@@ -2431,8 +2375,8 @@ function hashTransaction(transactionRequest, chainId) {
2431
2375
  const outputClone = (0, import_ramda2.clone)(output);
2432
2376
  switch (outputClone.type) {
2433
2377
  case import_transactions7.OutputType.Contract: {
2434
- outputClone.balanceRoot = import_configs8.ZeroBytes32;
2435
- outputClone.stateRoot = import_configs8.ZeroBytes32;
2378
+ outputClone.balanceRoot = import_configs7.ZeroBytes32;
2379
+ outputClone.stateRoot = import_configs7.ZeroBytes32;
2436
2380
  return outputClone;
2437
2381
  }
2438
2382
  case import_transactions7.OutputType.Change: {
@@ -2440,9 +2384,9 @@ function hashTransaction(transactionRequest, chainId) {
2440
2384
  return outputClone;
2441
2385
  }
2442
2386
  case import_transactions7.OutputType.Variable: {
2443
- outputClone.to = import_configs8.ZeroBytes32;
2387
+ outputClone.to = import_configs7.ZeroBytes32;
2444
2388
  outputClone.amount = (0, import_math8.bn)(0);
2445
- outputClone.assetId = import_configs8.ZeroBytes32;
2389
+ outputClone.assetId = import_configs7.ZeroBytes32;
2446
2390
  return outputClone;
2447
2391
  }
2448
2392
  default:
@@ -2508,7 +2452,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2508
2452
  } = {}) {
2509
2453
  super(rest);
2510
2454
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2511
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2455
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2512
2456
  this.storageSlots = [...storageSlots ?? []];
2513
2457
  }
2514
2458
  /**
@@ -2523,9 +2467,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2523
2467
  return {
2524
2468
  type: import_transactions8.TransactionType.Create,
2525
2469
  ...baseTransaction,
2470
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2526
2471
  bytecodeWitnessIndex,
2527
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2528
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2472
+ storageSlotsCount: storageSlots.length,
2473
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2529
2474
  storageSlots
2530
2475
  };
2531
2476
  }
@@ -2575,7 +2520,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2575
2520
  // src/providers/transaction-request/script-transaction-request.ts
2576
2521
  var import_abi_coder = require("@fuel-ts/abi-coder");
2577
2522
  var import_address2 = require("@fuel-ts/address");
2578
- var import_configs10 = require("@fuel-ts/address/configs");
2523
+ var import_configs9 = require("@fuel-ts/address/configs");
2579
2524
  var import_math10 = require("@fuel-ts/math");
2580
2525
  var import_transactions9 = require("@fuel-ts/transactions");
2581
2526
  var import_utils15 = require("@fuel-ts/utils");
@@ -2647,9 +2592,9 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2647
2592
  type: import_transactions9.TransactionType.Script,
2648
2593
  scriptGasLimit: this.gasLimit,
2649
2594
  ...super.getBaseTransaction(),
2650
- scriptLength: (0, import_math10.bn)(script.length),
2651
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2652
- receiptsRoot: import_configs10.ZeroBytes32,
2595
+ scriptLength: script.length,
2596
+ scriptDataLength: scriptData.length,
2597
+ receiptsRoot: import_configs9.ZeroBytes32,
2653
2598
  script: (0, import_utils15.hexlify)(script),
2654
2599
  scriptData: (0, import_utils15.hexlify)(scriptData)
2655
2600
  };
@@ -2712,7 +2657,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2712
2657
  }
2713
2658
  calculateMaxGas(chainInfo, minGas) {
2714
2659
  const { consensusParameters } = chainInfo;
2715
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2660
+ const { gasPerByte } = consensusParameters;
2716
2661
  const witnessesLength = this.toTransaction().witnesses.reduce(
2717
2662
  (acc, wit) => acc + wit.dataLength,
2718
2663
  0
@@ -2722,8 +2667,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2722
2667
  minGas,
2723
2668
  witnessesLength,
2724
2669
  witnessLimit: this.witnessLimit,
2725
- gasLimit: this.gasLimit,
2726
- maxGasPerTx
2670
+ gasLimit: this.gasLimit
2727
2671
  });
2728
2672
  }
2729
2673
  /**
@@ -2798,32 +2742,15 @@ var transactionRequestify = (obj) => {
2798
2742
  }
2799
2743
  }
2800
2744
  };
2801
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2802
- (acc, input) => {
2803
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2804
- acc.utxos.push(input.id);
2805
- }
2806
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2807
- acc.messages.push(input.nonce);
2808
- }
2809
- return acc;
2810
- },
2811
- {
2812
- utxos: [],
2813
- messages: []
2814
- }
2815
- );
2816
2745
 
2817
2746
  // src/providers/transaction-response/transaction-response.ts
2818
2747
  var import_errors13 = require("@fuel-ts/errors");
2819
- var import_math15 = require("@fuel-ts/math");
2820
- var import_transactions18 = require("@fuel-ts/transactions");
2821
- var import_utils20 = require("@fuel-ts/utils");
2748
+ var import_math14 = require("@fuel-ts/math");
2749
+ var import_transactions17 = require("@fuel-ts/transactions");
2750
+ var import_utils21 = require("@fuel-ts/utils");
2822
2751
 
2823
2752
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2824
- var import_math14 = require("@fuel-ts/math");
2825
- var import_transactions16 = require("@fuel-ts/transactions");
2826
- var import_utils18 = require("@fuel-ts/utils");
2753
+ var import_utils19 = require("@fuel-ts/utils");
2827
2754
 
2828
2755
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2829
2756
  var import_math11 = require("@fuel-ts/math");
@@ -2831,10 +2758,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2831
2758
  var import_utils16 = require("@fuel-ts/utils");
2832
2759
  var calculateTransactionFee = (params) => {
2833
2760
  const {
2834
- gasPrice,
2761
+ gasUsed,
2835
2762
  rawPayload,
2836
- tip,
2837
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2763
+ consensusParameters: { gasCosts, feeParams }
2838
2764
  } = params;
2839
2765
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2840
2766
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2844,7 +2770,8 @@ var calculateTransactionFee = (params) => {
2844
2770
  return {
2845
2771
  fee: (0, import_math11.bn)(0),
2846
2772
  minFee: (0, import_math11.bn)(0),
2847
- maxFee: (0, import_math11.bn)(0)
2773
+ maxFee: (0, import_math11.bn)(0),
2774
+ feeFromGasUsed: (0, import_math11.bn)(0)
2848
2775
  };
2849
2776
  }
2850
2777
  const { type, witnesses, inputs, policies } = transaction;
@@ -2876,6 +2803,7 @@ var calculateTransactionFee = (params) => {
2876
2803
  metadataGas,
2877
2804
  txBytesSize: transactionBytes.length
2878
2805
  });
2806
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2879
2807
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2880
2808
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2881
2809
  const maxGas = getMaxGas({
@@ -2883,30 +2811,22 @@ var calculateTransactionFee = (params) => {
2883
2811
  minGas,
2884
2812
  witnessesLength,
2885
2813
  gasLimit,
2886
- witnessLimit,
2887
- maxGasPerTx
2888
- });
2889
- const minFee = calculateGasFee({
2890
- gasPrice,
2891
- gas: minGas,
2892
- priceFactor: gasPriceFactor,
2893
- tip
2894
- });
2895
- const maxFee = calculateGasFee({
2896
- gasPrice,
2897
- gas: maxGas,
2898
- priceFactor: gasPriceFactor,
2899
- tip
2814
+ witnessLimit
2900
2815
  });
2816
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2817
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2818
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2819
+ const fee = minFee.add(feeFromGasUsed);
2901
2820
  return {
2821
+ fee,
2902
2822
  minFee,
2903
2823
  maxFee,
2904
- fee: maxFee
2824
+ feeFromGasUsed
2905
2825
  };
2906
2826
  };
2907
2827
 
2908
2828
  // src/providers/transaction-summary/operations.ts
2909
- var import_configs11 = require("@fuel-ts/address/configs");
2829
+ var import_configs10 = require("@fuel-ts/address/configs");
2910
2830
  var import_errors11 = require("@fuel-ts/errors");
2911
2831
  var import_math13 = require("@fuel-ts/math");
2912
2832
  var import_transactions14 = require("@fuel-ts/transactions");
@@ -3251,7 +3171,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3251
3171
  const { to: toAddress, assetId, amount } = receipt;
3252
3172
  let { from: fromAddress } = receipt;
3253
3173
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3254
- if (import_configs11.ZeroBytes32 === fromAddress) {
3174
+ if (import_configs10.ZeroBytes32 === fromAddress) {
3255
3175
  const change = changeOutputs.find((output) => output.assetId === assetId);
3256
3176
  fromAddress = change?.to || fromAddress;
3257
3177
  }
@@ -3515,12 +3435,10 @@ function assembleTransactionSummary(params) {
3515
3435
  gqlTransactionStatus,
3516
3436
  abiMap = {},
3517
3437
  maxInputs,
3518
- gasCosts,
3519
- maxGasPerTx,
3520
- gasPrice
3438
+ gasCosts
3521
3439
  } = params;
3522
3440
  const gasUsed = getGasUsedFromReceipts(receipts);
3523
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3441
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3524
3442
  const operations = getOperations({
3525
3443
  transactionType: transaction.type,
3526
3444
  inputs: transaction.inputs || [],
@@ -3531,14 +3449,11 @@ function assembleTransactionSummary(params) {
3531
3449
  maxInputs
3532
3450
  });
3533
3451
  const typeName = getTransactionTypeName(transaction.type);
3534
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3535
3452
  const { fee } = calculateTransactionFee({
3536
- gasPrice,
3453
+ gasUsed,
3537
3454
  rawPayload,
3538
- tip,
3539
3455
  consensusParameters: {
3540
3456
  gasCosts,
3541
- maxGasPerTx,
3542
3457
  feeParams: {
3543
3458
  gasPerByte,
3544
3459
  gasPriceFactor
@@ -3550,7 +3465,7 @@ function assembleTransactionSummary(params) {
3550
3465
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3551
3466
  let date;
3552
3467
  if (time) {
3553
- date = import_utils18.DateTime.fromTai64(time);
3468
+ date = import_utils19.DateTime.fromTai64(time);
3554
3469
  }
3555
3470
  const transactionSummary = {
3556
3471
  id,
@@ -3578,12 +3493,12 @@ function assembleTransactionSummary(params) {
3578
3493
 
3579
3494
  // src/providers/transaction-response/getDecodedLogs.ts
3580
3495
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
3581
- var import_transactions17 = require("@fuel-ts/transactions");
3496
+ var import_transactions16 = require("@fuel-ts/transactions");
3582
3497
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3583
3498
  return receipts.reduce((logs, receipt) => {
3584
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3499
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3585
3500
  const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3586
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3501
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3587
3502
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3588
3503
  logs.push(decodedLog);
3589
3504
  }
@@ -3598,7 +3513,7 @@ var TransactionResponse = class {
3598
3513
  /** Current provider */
3599
3514
  provider;
3600
3515
  /** Gas used on the transaction */
3601
- gasUsed = (0, import_math15.bn)(0);
3516
+ gasUsed = (0, import_math14.bn)(0);
3602
3517
  /** The graphql Transaction with receipts object. */
3603
3518
  gqlTransaction;
3604
3519
  abis;
@@ -3656,8 +3571,8 @@ var TransactionResponse = class {
3656
3571
  * @returns The decoded transaction.
3657
3572
  */
3658
3573
  decodeTransaction(transactionWithReceipts) {
3659
- return new import_transactions18.TransactionCoder().decode(
3660
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3574
+ return new import_transactions17.TransactionCoder().decode(
3575
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3661
3576
  0
3662
3577
  )?.[0];
3663
3578
  }
@@ -3676,27 +3591,20 @@ var TransactionResponse = class {
3676
3591
  const decodedTransaction = this.decodeTransaction(
3677
3592
  transaction
3678
3593
  );
3679
- let txReceipts = [];
3680
- if (transaction?.status && "receipts" in transaction.status) {
3681
- txReceipts = transaction.status.receipts;
3682
- }
3683
- const receipts = txReceipts.map(processGqlReceipt) || [];
3684
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3685
- const gasPrice = await this.provider.getLatestGasPrice();
3594
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3595
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3686
3596
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3687
3597
  const transactionSummary = assembleTransactionSummary({
3688
3598
  id: this.id,
3689
3599
  receipts,
3690
3600
  transaction: decodedTransaction,
3691
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3601
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3692
3602
  gqlTransactionStatus: transaction.status,
3693
3603
  gasPerByte,
3694
3604
  gasPriceFactor,
3695
3605
  abiMap: contractsAbiMap,
3696
3606
  maxInputs,
3697
- gasCosts,
3698
- maxGasPerTx,
3699
- gasPrice
3607
+ gasCosts
3700
3608
  });
3701
3609
  return transactionSummary;
3702
3610
  }
@@ -3823,29 +3731,30 @@ var processGqlChain = (chain) => {
3823
3731
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3824
3732
  return {
3825
3733
  name,
3826
- baseChainHeight: (0, import_math16.bn)(daHeight),
3734
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3827
3735
  consensusParameters: {
3828
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3829
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3830
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3831
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3832
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3833
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3834
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3835
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3836
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3837
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3838
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3839
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3840
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3841
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3842
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3736
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3737
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3738
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3739
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3740
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3741
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3742
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3743
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3744
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3745
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3746
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3747
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3748
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3749
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3750
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3751
+ baseAssetId: consensusParameters.baseAssetId,
3843
3752
  gasCosts
3844
3753
  },
3845
3754
  gasCosts,
3846
3755
  latestBlock: {
3847
3756
  id: latestBlock.id,
3848
- height: (0, import_math16.bn)(latestBlock.height),
3757
+ height: (0, import_math15.bn)(latestBlock.header.height),
3849
3758
  time: latestBlock.header.time,
3850
3759
  transactions: latestBlock.transactions.map((i) => ({
3851
3760
  id: i.id
@@ -3939,8 +3848,10 @@ var _Provider = class {
3939
3848
  * Returns some helpful parameters related to gas fees.
3940
3849
  */
3941
3850
  getGasConfig() {
3851
+ const { minGasPrice } = this.getNode();
3942
3852
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3943
3853
  return {
3854
+ minGasPrice,
3944
3855
  maxGasPerTx,
3945
3856
  maxGasPerPredicate,
3946
3857
  gasPriceFactor,
@@ -4028,7 +3939,7 @@ var _Provider = class {
4028
3939
  name,
4029
3940
  consensusParameters: { chainId }
4030
3941
  } = await this.getChain();
4031
- const network = new import_ethers2.Network(name, chainId.toNumber());
3942
+ const network = new import_ethers.Network(name, chainId.toNumber());
4032
3943
  return Promise.resolve(network);
4033
3944
  }
4034
3945
  /**
@@ -4038,7 +3949,7 @@ var _Provider = class {
4038
3949
  */
4039
3950
  async getBlockNumber() {
4040
3951
  const { chain } = await this.operations.getChain();
4041
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3952
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4042
3953
  }
4043
3954
  /**
4044
3955
  * Returns the chain information.
@@ -4048,11 +3959,13 @@ var _Provider = class {
4048
3959
  async fetchNode() {
4049
3960
  const { nodeInfo } = await this.operations.getNodeInfo();
4050
3961
  const processedNodeInfo = {
4051
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4052
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3962
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3963
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3964
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4053
3965
  nodeVersion: nodeInfo.nodeVersion,
4054
3966
  utxoValidation: nodeInfo.utxoValidation,
4055
- vmBacktrace: nodeInfo.vmBacktrace
3967
+ vmBacktrace: nodeInfo.vmBacktrace,
3968
+ peers: nodeInfo.peers
4056
3969
  };
4057
3970
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
4058
3971
  return processedNodeInfo;
@@ -4078,6 +3991,17 @@ var _Provider = class {
4078
3991
  } = this.getChain();
4079
3992
  return chainId.toNumber();
4080
3993
  }
3994
+ /**
3995
+ * Returns the base asset ID
3996
+ *
3997
+ * @returns A promise that resolves to the base asset ID
3998
+ */
3999
+ getBaseAssetId() {
4000
+ const {
4001
+ consensusParameters: { baseAssetId }
4002
+ } = this.getChain();
4003
+ return baseAssetId;
4004
+ }
4081
4005
  /**
4082
4006
  * Submits a transaction to the chain to be executed.
4083
4007
  *
@@ -4094,9 +4018,9 @@ var _Provider = class {
4094
4018
  if (estimateTxDependencies) {
4095
4019
  await this.estimateTxDependencies(transactionRequest);
4096
4020
  }
4097
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4021
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4098
4022
  let abis;
4099
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4023
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4100
4024
  abis = transactionRequest.abis;
4101
4025
  }
4102
4026
  if (awaitExecution) {
@@ -4137,14 +4061,15 @@ var _Provider = class {
4137
4061
  if (estimateTxDependencies) {
4138
4062
  return this.estimateTxDependencies(transactionRequest);
4139
4063
  }
4140
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4141
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4142
- encodedTransactions: encodedTransaction,
4064
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4065
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4066
+ encodedTransaction,
4143
4067
  utxoValidation: utxoValidation || false
4144
4068
  });
4145
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4146
- const receipts = rawReceipts.map(processGqlReceipt);
4147
- return { receipts, dryrunStatus: status };
4069
+ const receipts = gqlReceipts.map(processGqlReceipt);
4070
+ return {
4071
+ receipts
4072
+ };
4148
4073
  }
4149
4074
  /**
4150
4075
  * Verifies whether enough gas is available to complete transaction.
@@ -4155,13 +4080,13 @@ var _Provider = class {
4155
4080
  async estimatePredicates(transactionRequest) {
4156
4081
  const shouldEstimatePredicates = Boolean(
4157
4082
  transactionRequest.inputs.find(
4158
- (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()
4083
+ (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()
4159
4084
  )
4160
4085
  );
4161
4086
  if (!shouldEstimatePredicates) {
4162
4087
  return transactionRequest;
4163
4088
  }
4164
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4089
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4165
4090
  const response = await this.operations.estimatePredicates({
4166
4091
  encodedTransaction
4167
4092
  });
@@ -4170,7 +4095,7 @@ var _Provider = class {
4170
4095
  } = response;
4171
4096
  if (inputs) {
4172
4097
  inputs.forEach((input, index) => {
4173
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4098
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4174
4099
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4175
4100
  }
4176
4101
  });
@@ -4183,31 +4108,31 @@ var _Provider = class {
4183
4108
  * If there are missing variable outputs,
4184
4109
  * `addVariableOutputs` is called on the transaction.
4185
4110
  *
4111
+ * @privateRemarks
4112
+ * TODO: Investigate support for missing contract IDs
4113
+ * TODO: Add support for missing output messages
4186
4114
  *
4187
4115
  * @param transactionRequest - The transaction request object.
4188
4116
  * @returns A promise.
4189
4117
  */
4190
4118
  async estimateTxDependencies(transactionRequest) {
4191
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4119
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4192
4120
  return {
4193
4121
  receipts: [],
4194
4122
  outputVariables: 0,
4195
4123
  missingContractIds: []
4196
4124
  };
4197
4125
  }
4126
+ await this.estimatePredicates(transactionRequest);
4198
4127
  let receipts = [];
4199
4128
  const missingContractIds = [];
4200
4129
  let outputVariables = 0;
4201
- let dryrunStatus;
4202
4130
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4203
- const {
4204
- dryRun: [{ receipts: rawReceipts, status }]
4205
- } = await this.operations.dryRun({
4206
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4131
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4132
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4207
4133
  utxoValidation: false
4208
4134
  });
4209
- receipts = rawReceipts.map(processGqlReceipt);
4210
- dryrunStatus = status;
4135
+ receipts = gqlReceipts.map(processGqlReceipt);
4211
4136
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4212
4137
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4213
4138
  if (hasMissingOutputs) {
@@ -4217,11 +4142,6 @@ var _Provider = class {
4217
4142
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4218
4143
  missingContractIds.push(contractId);
4219
4144
  });
4220
- const { maxFee } = await this.estimateTxGasAndFee({
4221
- transactionRequest,
4222
- optimizeGas: false
4223
- });
4224
- transactionRequest.maxFee = maxFee;
4225
4145
  } else {
4226
4146
  break;
4227
4147
  }
@@ -4229,133 +4149,7 @@ var _Provider = class {
4229
4149
  return {
4230
4150
  receipts,
4231
4151
  outputVariables,
4232
- missingContractIds,
4233
- dryrunStatus
4234
- };
4235
- }
4236
- /**
4237
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4238
- *
4239
- * Transactions are dry run in batches. After each dry run, transactions requiring
4240
- * further modifications are identified. The method iteratively updates these transactions
4241
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4242
- *
4243
- * @param transactionRequests - Array of transaction request objects.
4244
- * @returns A promise that resolves to an array of results for each transaction.
4245
- */
4246
- async estimateMultipleTxDependencies(transactionRequests) {
4247
- const results = transactionRequests.map(() => ({
4248
- receipts: [],
4249
- outputVariables: 0,
4250
- missingContractIds: [],
4251
- dryrunStatus: void 0
4252
- }));
4253
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4254
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4255
- allRequests.forEach((req, index) => {
4256
- if (req.type === import_transactions19.TransactionType.Script) {
4257
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4258
- }
4259
- });
4260
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4261
- let attempt = 0;
4262
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4263
- const encodedTransactions = transactionsToProcess.map(
4264
- (index) => serializedTransactionsMap.get(index)
4265
- );
4266
- const dryRunResults = await this.operations.dryRun({
4267
- encodedTransactions,
4268
- utxoValidation: false
4269
- });
4270
- const nextRoundTransactions = [];
4271
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4272
- const currentResultIndex = transactionsToProcess[i];
4273
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4274
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4275
- results[currentResultIndex].dryrunStatus = status;
4276
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4277
- results[currentResultIndex].receipts
4278
- );
4279
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4280
- const requestToProcess = allRequests[currentResultIndex];
4281
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4282
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4283
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4284
- missingOutputContractIds.forEach(({ contractId }) => {
4285
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4286
- results[currentResultIndex].missingContractIds.push(contractId);
4287
- });
4288
- const { maxFee } = await this.estimateTxGasAndFee({
4289
- transactionRequest: requestToProcess,
4290
- optimizeGas: false
4291
- });
4292
- requestToProcess.maxFee = maxFee;
4293
- serializedTransactionsMap.set(
4294
- currentResultIndex,
4295
- (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4296
- );
4297
- nextRoundTransactions.push(currentResultIndex);
4298
- allRequests[currentResultIndex] = requestToProcess;
4299
- }
4300
- }
4301
- transactionsToProcess = nextRoundTransactions;
4302
- attempt += 1;
4303
- }
4304
- return results;
4305
- }
4306
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4307
- if (estimateTxDependencies) {
4308
- return this.estimateMultipleTxDependencies(transactionRequests);
4309
- }
4310
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4311
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4312
- encodedTransactions,
4313
- utxoValidation: utxoValidation || false
4314
- });
4315
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4316
- const receipts = rawReceipts.map(processGqlReceipt);
4317
- return { receipts, dryrunStatus: status };
4318
- });
4319
- return results;
4320
- }
4321
- async estimateTxGasAndFee(params) {
4322
- const { transactionRequest, optimizeGas = true } = params;
4323
- let { gasPrice } = params;
4324
- const chainInfo = this.getChain();
4325
- const { gasPriceFactor } = this.getGasConfig();
4326
- const minGas = transactionRequest.calculateMinGas(chainInfo);
4327
- if (!gasPrice) {
4328
- gasPrice = await this.estimateGasPrice(10);
4329
- }
4330
- const minFee = calculateGasFee({
4331
- gasPrice: (0, import_math16.bn)(gasPrice),
4332
- gas: minGas,
4333
- priceFactor: gasPriceFactor,
4334
- tip: transactionRequest.tip
4335
- }).add(1);
4336
- let gasLimit = (0, import_math16.bn)(0);
4337
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4338
- gasLimit = transactionRequest.gasLimit;
4339
- if (!optimizeGas) {
4340
- transactionRequest.gasLimit = minGas;
4341
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4342
- transactionRequest.gasLimit = gasLimit;
4343
- }
4344
- }
4345
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4346
- const maxFee = calculateGasFee({
4347
- gasPrice: (0, import_math16.bn)(gasPrice),
4348
- gas: maxGas,
4349
- priceFactor: gasPriceFactor,
4350
- tip: transactionRequest.tip
4351
- }).add(1);
4352
- return {
4353
- minGas,
4354
- minFee,
4355
- maxGas,
4356
- maxFee,
4357
- gasPrice,
4358
- gasLimit
4152
+ missingContractIds
4359
4153
  };
4360
4154
  }
4361
4155
  /**
@@ -4373,17 +4167,15 @@ var _Provider = class {
4373
4167
  if (estimateTxDependencies) {
4374
4168
  return this.estimateTxDependencies(transactionRequest);
4375
4169
  }
4376
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4377
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4378
- encodedTransactions,
4170
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4171
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4172
+ encodedTransaction,
4379
4173
  utxoValidation: true
4380
4174
  });
4381
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4382
- const { id, receipts, status } = dryRunStatus;
4383
- const processedReceipts = receipts.map(processGqlReceipt);
4384
- return { id, receipts: processedReceipts, status };
4385
- });
4386
- return { receipts: callResult[0].receipts };
4175
+ const receipts = gqlReceipts.map(processGqlReceipt);
4176
+ return {
4177
+ receipts
4178
+ };
4387
4179
  }
4388
4180
  /**
4389
4181
  * Returns a transaction cost to enable user
@@ -4400,80 +4192,80 @@ var _Provider = class {
4400
4192
  * @param tolerance - The tolerance to add on top of the gasUsed.
4401
4193
  * @returns A promise that resolves to the transaction cost object.
4402
4194
  */
4403
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4195
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4196
+ estimateTxDependencies = true,
4197
+ estimatePredicates = true,
4198
+ resourcesOwner,
4199
+ signatureCallback
4200
+ } = {}) {
4404
4201
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4405
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4202
+ const chainInfo = this.getChain();
4203
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4204
+ const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4205
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4406
4206
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4407
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4207
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4408
4208
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4409
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4410
- if (isScriptTransaction) {
4411
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4412
- }
4413
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4414
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4209
+ if (estimatePredicates) {
4210
+ if (isScriptTransaction) {
4211
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4212
+ }
4213
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4214
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4215
+ }
4216
+ await this.estimatePredicates(txRequestClone);
4415
4217
  }
4416
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4417
- let addedSignatures = 0;
4418
4218
  if (signatureCallback && isScriptTransaction) {
4419
- const lengthBefore = signedRequest.witnesses.length;
4420
- await signatureCallback(signedRequest);
4421
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4422
- }
4423
- await this.estimatePredicates(signedRequest);
4424
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4425
- transactionRequest: signedRequest,
4426
- optimizeGas: false
4427
- });
4428
- txRequestClone.maxFee = maxFee;
4219
+ await signatureCallback(txRequestClone);
4220
+ }
4221
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
4222
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4429
4223
  let receipts = [];
4430
4224
  let missingContractIds = [];
4431
4225
  let outputVariables = 0;
4432
- let gasUsed = (0, import_math16.bn)(0);
4433
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4434
- if (isScriptTransaction) {
4435
- if (signatureCallback) {
4436
- await signatureCallback(txRequestClone);
4437
- }
4438
- txRequestClone.gasLimit = gasLimit;
4226
+ if (isScriptTransaction && estimateTxDependencies) {
4227
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4228
+ txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4439
4229
  const result = await this.estimateTxDependencies(txRequestClone);
4440
4230
  receipts = result.receipts;
4441
4231
  outputVariables = result.outputVariables;
4442
4232
  missingContractIds = result.missingContractIds;
4443
- gasUsed = getGasUsedFromReceipts(receipts);
4444
- txRequestClone.gasLimit = gasUsed;
4445
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4446
- transactionRequest: txRequestClone,
4447
- gasPrice
4448
- }));
4449
4233
  }
4234
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4235
+ const usedFee = calculatePriceWithFactor(
4236
+ gasUsed,
4237
+ gasPrice,
4238
+ gasPriceFactor
4239
+ ).normalizeZeroToOne();
4240
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4241
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4450
4242
  return {
4451
4243
  requiredQuantities: allQuantities,
4452
4244
  receipts,
4453
4245
  gasUsed,
4246
+ minGasPrice,
4454
4247
  gasPrice,
4455
4248
  minGas,
4456
4249
  maxGas,
4250
+ usedFee,
4457
4251
  minFee,
4458
4252
  maxFee,
4253
+ estimatedInputs: txRequestClone.inputs,
4459
4254
  outputVariables,
4460
- missingContractIds,
4461
- addedSignatures,
4462
- estimatedPredicates: txRequestClone.inputs
4255
+ missingContractIds
4463
4256
  };
4464
4257
  }
4465
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4258
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4466
4259
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4467
4260
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4468
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4469
- quantitiesToContract
4470
- });
4261
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4471
4262
  transactionRequest.addResources(
4472
4263
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4473
4264
  );
4474
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4475
- quantitiesToContract
4476
- });
4265
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4266
+ transactionRequest,
4267
+ forwardingQuantities
4268
+ );
4477
4269
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4478
4270
  return {
4479
4271
  resources,
@@ -4489,16 +4281,17 @@ var _Provider = class {
4489
4281
  const result = await this.operations.getCoins({
4490
4282
  first: 10,
4491
4283
  ...paginationArgs,
4492
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4284
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4493
4285
  });
4494
4286
  const coins = result.coins.edges.map((edge) => edge.node);
4495
4287
  return coins.map((coin) => ({
4496
4288
  id: coin.utxoId,
4497
4289
  assetId: coin.assetId,
4498
- amount: (0, import_math16.bn)(coin.amount),
4290
+ amount: (0, import_math15.bn)(coin.amount),
4499
4291
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4500
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4501
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4292
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4293
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4294
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4502
4295
  }));
4503
4296
  }
4504
4297
  /**
@@ -4512,19 +4305,19 @@ var _Provider = class {
4512
4305
  async getResourcesToSpend(owner, quantities, excludedIds) {
4513
4306
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4514
4307
  const excludeInput = {
4515
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4516
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4308
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4309
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4517
4310
  };
4518
4311
  if (this.cache) {
4519
4312
  const uniqueUtxos = new Set(
4520
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4313
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4521
4314
  );
4522
4315
  excludeInput.utxos = Array.from(uniqueUtxos);
4523
4316
  }
4524
4317
  const coinsQuery = {
4525
4318
  owner: ownerAddress.toB256(),
4526
4319
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4527
- assetId: (0, import_utils22.hexlify)(assetId),
4320
+ assetId: (0, import_utils23.hexlify)(assetId),
4528
4321
  amount: amount.toString(10),
4529
4322
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4530
4323
  })),
@@ -4535,9 +4328,9 @@ var _Provider = class {
4535
4328
  switch (coin.__typename) {
4536
4329
  case "MessageCoin":
4537
4330
  return {
4538
- amount: (0, import_math16.bn)(coin.amount),
4331
+ amount: (0, import_math15.bn)(coin.amount),
4539
4332
  assetId: coin.assetId,
4540
- daHeight: (0, import_math16.bn)(coin.daHeight),
4333
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4541
4334
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4542
4335
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4543
4336
  nonce: coin.nonce
@@ -4545,11 +4338,12 @@ var _Provider = class {
4545
4338
  case "Coin":
4546
4339
  return {
4547
4340
  id: coin.utxoId,
4548
- amount: (0, import_math16.bn)(coin.amount),
4341
+ amount: (0, import_math15.bn)(coin.amount),
4549
4342
  assetId: coin.assetId,
4550
4343
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4551
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4552
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4344
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4345
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4346
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4553
4347
  };
4554
4348
  default:
4555
4349
  return null;
@@ -4566,13 +4360,13 @@ var _Provider = class {
4566
4360
  async getBlock(idOrHeight) {
4567
4361
  let variables;
4568
4362
  if (typeof idOrHeight === "number") {
4569
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4363
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4570
4364
  } else if (idOrHeight === "latest") {
4571
4365
  variables = { height: (await this.getBlockNumber()).toString(10) };
4572
4366
  } else if (idOrHeight.length === 66) {
4573
4367
  variables = { blockId: idOrHeight };
4574
4368
  } else {
4575
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4369
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4576
4370
  }
4577
4371
  const { block } = await this.operations.getBlock(variables);
4578
4372
  if (!block) {
@@ -4580,7 +4374,7 @@ var _Provider = class {
4580
4374
  }
4581
4375
  return {
4582
4376
  id: block.id,
4583
- height: (0, import_math16.bn)(block.height),
4377
+ height: (0, import_math15.bn)(block.header.height),
4584
4378
  time: block.header.time,
4585
4379
  transactionIds: block.transactions.map((tx) => tx.id)
4586
4380
  };
@@ -4595,7 +4389,7 @@ var _Provider = class {
4595
4389
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4596
4390
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4597
4391
  id: block.id,
4598
- height: (0, import_math16.bn)(block.height),
4392
+ height: (0, import_math15.bn)(block.header.height),
4599
4393
  time: block.header.time,
4600
4394
  transactionIds: block.transactions.map((tx) => tx.id)
4601
4395
  }));
@@ -4610,7 +4404,7 @@ var _Provider = class {
4610
4404
  async getBlockWithTransactions(idOrHeight) {
4611
4405
  let variables;
4612
4406
  if (typeof idOrHeight === "number") {
4613
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4407
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4614
4408
  } else if (idOrHeight === "latest") {
4615
4409
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4616
4410
  } else {
@@ -4622,11 +4416,11 @@ var _Provider = class {
4622
4416
  }
4623
4417
  return {
4624
4418
  id: block.id,
4625
- height: (0, import_math16.bn)(block.height, 10),
4419
+ height: (0, import_math15.bn)(block.header.height, 10),
4626
4420
  time: block.header.time,
4627
4421
  transactionIds: block.transactions.map((tx) => tx.id),
4628
4422
  transactions: block.transactions.map(
4629
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4423
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4630
4424
  )
4631
4425
  };
4632
4426
  }
@@ -4641,8 +4435,8 @@ var _Provider = class {
4641
4435
  if (!transaction) {
4642
4436
  return null;
4643
4437
  }
4644
- return new import_transactions19.TransactionCoder().decode(
4645
- (0, import_utils22.arrayify)(transaction.rawPayload),
4438
+ return new import_transactions18.TransactionCoder().decode(
4439
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4646
4440
  0
4647
4441
  )?.[0];
4648
4442
  }
@@ -4669,9 +4463,9 @@ var _Provider = class {
4669
4463
  async getContractBalance(contractId, assetId) {
4670
4464
  const { contractBalance } = await this.operations.getContractBalance({
4671
4465
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4672
- asset: (0, import_utils22.hexlify)(assetId)
4466
+ asset: (0, import_utils23.hexlify)(assetId)
4673
4467
  });
4674
- return (0, import_math16.bn)(contractBalance.amount, 10);
4468
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4675
4469
  }
4676
4470
  /**
4677
4471
  * Returns the balance for the given owner for the given asset ID.
@@ -4683,9 +4477,9 @@ var _Provider = class {
4683
4477
  async getBalance(owner, assetId) {
4684
4478
  const { balance } = await this.operations.getBalance({
4685
4479
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4686
- assetId: (0, import_utils22.hexlify)(assetId)
4480
+ assetId: (0, import_utils23.hexlify)(assetId)
4687
4481
  });
4688
- return (0, import_math16.bn)(balance.amount, 10);
4482
+ return (0, import_math15.bn)(balance.amount, 10);
4689
4483
  }
4690
4484
  /**
4691
4485
  * Returns balances for the given owner.
@@ -4703,7 +4497,7 @@ var _Provider = class {
4703
4497
  const balances = result.balances.edges.map((edge) => edge.node);
4704
4498
  return balances.map((balance) => ({
4705
4499
  assetId: balance.assetId,
4706
- amount: (0, import_math16.bn)(balance.amount)
4500
+ amount: (0, import_math15.bn)(balance.amount)
4707
4501
  }));
4708
4502
  }
4709
4503
  /**
@@ -4721,19 +4515,19 @@ var _Provider = class {
4721
4515
  });
4722
4516
  const messages = result.messages.edges.map((edge) => edge.node);
4723
4517
  return messages.map((message) => ({
4724
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4518
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4725
4519
  sender: message.sender,
4726
4520
  recipient: message.recipient,
4727
4521
  nonce: message.nonce,
4728
- amount: (0, import_math16.bn)(message.amount),
4522
+ amount: (0, import_math15.bn)(message.amount),
4729
4523
  data: message.data
4730
4524
  }),
4731
4525
  sender: import_address3.Address.fromAddressOrString(message.sender),
4732
4526
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4733
4527
  nonce: message.nonce,
4734
- amount: (0, import_math16.bn)(message.amount),
4735
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4736
- daHeight: (0, import_math16.bn)(message.daHeight)
4528
+ amount: (0, import_math15.bn)(message.amount),
4529
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4530
+ daHeight: (0, import_math15.bn)(message.daHeight)
4737
4531
  }));
4738
4532
  }
4739
4533
  /**
@@ -4786,52 +4580,44 @@ var _Provider = class {
4786
4580
  } = result.messageProof;
4787
4581
  return {
4788
4582
  messageProof: {
4789
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4583
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4790
4584
  proofSet: messageProof.proofSet
4791
4585
  },
4792
4586
  blockProof: {
4793
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4587
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4794
4588
  proofSet: blockProof.proofSet
4795
4589
  },
4796
4590
  messageBlockHeader: {
4797
4591
  id: messageBlockHeader.id,
4798
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4799
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4592
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4593
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4800
4594
  transactionsRoot: messageBlockHeader.transactionsRoot,
4801
- height: (0, import_math16.bn)(messageBlockHeader.height),
4595
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4802
4596
  prevRoot: messageBlockHeader.prevRoot,
4803
4597
  time: messageBlockHeader.time,
4804
4598
  applicationHash: messageBlockHeader.applicationHash,
4805
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount)
4599
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4600
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4806
4601
  },
4807
4602
  commitBlockHeader: {
4808
4603
  id: commitBlockHeader.id,
4809
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4810
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4604
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4605
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4811
4606
  transactionsRoot: commitBlockHeader.transactionsRoot,
4812
- height: (0, import_math16.bn)(commitBlockHeader.height),
4607
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4813
4608
  prevRoot: commitBlockHeader.prevRoot,
4814
4609
  time: commitBlockHeader.time,
4815
4610
  applicationHash: commitBlockHeader.applicationHash,
4816
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount)
4611
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4612
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4817
4613
  },
4818
4614
  sender: import_address3.Address.fromAddressOrString(sender),
4819
4615
  recipient: import_address3.Address.fromAddressOrString(recipient),
4820
4616
  nonce,
4821
- amount: (0, import_math16.bn)(amount),
4617
+ amount: (0, import_math15.bn)(amount),
4822
4618
  data
4823
4619
  };
4824
4620
  }
4825
- async getLatestGasPrice() {
4826
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4827
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4828
- }
4829
- async estimateGasPrice(blockHorizon) {
4830
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4831
- blockHorizon: String(blockHorizon)
4832
- });
4833
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4834
- }
4835
4621
  /**
4836
4622
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4837
4623
  *
@@ -4851,10 +4637,10 @@ var _Provider = class {
4851
4637
  */
4852
4638
  async produceBlocks(amount, startTime) {
4853
4639
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4854
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4855
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4640
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4641
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4856
4642
  });
4857
- return (0, import_math16.bn)(latestBlockHeight);
4643
+ return (0, import_math15.bn)(latestBlockHeight);
4858
4644
  }
4859
4645
  // eslint-disable-next-line @typescript-eslint/require-await
4860
4646
  async getTransactionResponse(transactionId) {
@@ -4868,7 +4654,7 @@ cacheInputs_fn = function(inputs) {
4868
4654
  return;
4869
4655
  }
4870
4656
  inputs.forEach((input) => {
4871
- if (input.type === import_transactions19.InputType.Coin) {
4657
+ if (input.type === import_transactions18.InputType.Coin) {
4872
4658
  this.cache?.set(input.id);
4873
4659
  }
4874
4660
  });
@@ -4878,9 +4664,9 @@ __publicField(Provider, "nodeInfoCache", {});
4878
4664
 
4879
4665
  // src/providers/transaction-summary/get-transaction-summary.ts
4880
4666
  var import_errors15 = require("@fuel-ts/errors");
4881
- var import_math17 = require("@fuel-ts/math");
4882
- var import_transactions20 = require("@fuel-ts/transactions");
4883
- var import_utils25 = require("@fuel-ts/utils");
4667
+ var import_math16 = require("@fuel-ts/math");
4668
+ var import_transactions19 = require("@fuel-ts/transactions");
4669
+ var import_utils26 = require("@fuel-ts/utils");
4884
4670
  async function getTransactionSummary(params) {
4885
4671
  const { id, provider, abiMap } = params;
4886
4672
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4892,32 +4678,25 @@ async function getTransactionSummary(params) {
4892
4678
  `Transaction not found for given id: ${id}.`
4893
4679
  );
4894
4680
  }
4895
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4896
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4681
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4682
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4897
4683
  0
4898
4684
  );
4899
- let txReceipts = [];
4900
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4901
- txReceipts = gqlTransaction.status.receipts;
4902
- }
4903
- const receipts = txReceipts.map(processGqlReceipt);
4685
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4904
4686
  const {
4905
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4687
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4906
4688
  } = provider.getChain();
4907
- const gasPrice = await provider.getLatestGasPrice();
4908
4689
  const transactionInfo = assembleTransactionSummary({
4909
4690
  id: gqlTransaction.id,
4910
4691
  receipts,
4911
4692
  transaction: decodedTransaction,
4912
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4693
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4913
4694
  gqlTransactionStatus: gqlTransaction.status,
4914
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4915
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4695
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4696
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4916
4697
  abiMap,
4917
4698
  maxInputs,
4918
- gasCosts,
4919
- maxGasPerTx,
4920
- gasPrice
4699
+ gasCosts
4921
4700
  });
4922
4701
  return {
4923
4702
  gqlTransaction,
@@ -4927,11 +4706,10 @@ async function getTransactionSummary(params) {
4927
4706
  async function getTransactionSummaryFromRequest(params) {
4928
4707
  const { provider, transactionRequest, abiMap } = params;
4929
4708
  const { receipts } = await provider.call(transactionRequest);
4930
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4709
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4931
4710
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4932
4711
  const transaction = transactionRequest.toTransaction();
4933
4712
  const transactionBytes = transactionRequest.toTransactionBytes();
4934
- const gasPrice = await provider.getLatestGasPrice();
4935
4713
  const transactionSummary = assembleTransactionSummary({
4936
4714
  receipts,
4937
4715
  transaction,
@@ -4940,9 +4718,7 @@ async function getTransactionSummaryFromRequest(params) {
4940
4718
  gasPerByte,
4941
4719
  gasPriceFactor,
4942
4720
  maxInputs,
4943
- gasCosts,
4944
- maxGasPerTx,
4945
- gasPrice
4721
+ gasCosts
4946
4722
  });
4947
4723
  return transactionSummary;
4948
4724
  }
@@ -4951,31 +4727,24 @@ async function getTransactionsSummaries(params) {
4951
4727
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4952
4728
  const { edges, pageInfo } = transactionsByOwner;
4953
4729
  const {
4954
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4730
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4955
4731
  } = provider.getChain();
4956
- const gasPrice = await provider.getLatestGasPrice();
4957
4732
  const transactions = edges.map((edge) => {
4958
4733
  const { node: gqlTransaction } = edge;
4959
- const { id, rawPayload, status } = gqlTransaction;
4960
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4961
- let txReceipts = [];
4962
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4963
- txReceipts = gqlTransaction.status.receipts;
4964
- }
4965
- const receipts = txReceipts.map(processGqlReceipt);
4734
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4735
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4736
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4966
4737
  const transactionSummary = assembleTransactionSummary({
4967
4738
  id,
4968
4739
  receipts,
4969
4740
  transaction: decodedTransaction,
4970
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4741
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4971
4742
  gqlTransactionStatus: status,
4972
4743
  abiMap,
4973
4744
  gasPerByte,
4974
4745
  gasPriceFactor,
4975
4746
  maxInputs,
4976
- gasCosts,
4977
- maxGasPerTx,
4978
- gasPrice
4747
+ gasCosts
4979
4748
  });
4980
4749
  const output = {
4981
4750
  gqlTransaction,
@@ -5112,17 +4881,17 @@ var assets = [
5112
4881
 
5113
4882
  // src/utils/formatTransferToContractScriptData.ts
5114
4883
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
5115
- var import_math18 = require("@fuel-ts/math");
5116
- var import_utils26 = require("@fuel-ts/utils");
4884
+ var import_math17 = require("@fuel-ts/math");
4885
+ var import_utils27 = require("@fuel-ts/utils");
5117
4886
  var asm = __toESM(require("@fuels/vm-asm"));
5118
4887
  var formatTransferToContractScriptData = (params) => {
5119
4888
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5120
4889
  const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
5121
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4890
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5122
4891
  const scriptData = Uint8Array.from([
5123
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4892
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5124
4893
  ...encoded,
5125
- ...(0, import_utils26.arrayify)(assetId)
4894
+ ...(0, import_utils27.arrayify)(assetId)
5126
4895
  ]);
5127
4896
  return scriptData;
5128
4897
  };
@@ -5269,8 +5038,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5269
5038
  * @param assetId - The asset ID to check the balance for.
5270
5039
  * @returns A promise that resolves to the balance amount.
5271
5040
  */
5272
- async getBalance(assetId = import_configs12.BaseAssetId) {
5273
- const amount = await this.provider.getBalance(this.address, assetId);
5041
+ async getBalance(assetId) {
5042
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
5043
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
5274
5044
  return amount;
5275
5045
  }
5276
5046
  /**
@@ -5307,33 +5077,37 @@ var Account = class extends import_interfaces.AbstractAccount {
5307
5077
  * @param fee - The estimated transaction fee.
5308
5078
  * @returns A promise that resolves when the resources are added to the transaction.
5309
5079
  */
5310
- async fund(request, params) {
5311
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5312
- const txRequest = request;
5313
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5314
- amount: (0, import_math19.bn)(fee),
5315
- assetId: import_configs12.BaseAssetId,
5316
- coinQuantities: requiredQuantities
5080
+ async fund(request, coinQuantities, fee) {
5081
+ const baseAssetId = this.provider.getBaseAssetId();
5082
+ const updatedQuantities = addAmountToAsset({
5083
+ amount: (0, import_math18.bn)(fee),
5084
+ assetId: baseAssetId,
5085
+ coinQuantities
5317
5086
  });
5318
5087
  const quantitiesDict = {};
5319
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5088
+ updatedQuantities.forEach(({ amount, assetId }) => {
5320
5089
  quantitiesDict[assetId] = {
5321
5090
  required: amount,
5322
- owned: (0, import_math19.bn)(0)
5091
+ owned: (0, import_math18.bn)(0)
5323
5092
  };
5324
5093
  });
5325
- txRequest.inputs.forEach((input) => {
5094
+ const cachedUtxos = [];
5095
+ const cachedMessages = [];
5096
+ const owner = this.address.toB256();
5097
+ request.inputs.forEach((input) => {
5326
5098
  const isResource = "amount" in input;
5327
5099
  if (isResource) {
5328
5100
  const isCoin2 = "owner" in input;
5329
5101
  if (isCoin2) {
5330
5102
  const assetId = String(input.assetId);
5331
- if (quantitiesDict[assetId]) {
5332
- const amount = (0, import_math19.bn)(input.amount);
5103
+ if (input.owner === owner && quantitiesDict[assetId]) {
5104
+ const amount = (0, import_math18.bn)(input.amount);
5333
5105
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5106
+ cachedUtxos.push(input.id);
5334
5107
  }
5335
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5336
- quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5108
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
5109
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
5110
+ cachedMessages.push(input.nonce);
5337
5111
  }
5338
5112
  }
5339
5113
  });
@@ -5348,23 +5122,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5348
5122
  });
5349
5123
  const needsToBeFunded = missingQuantities.length;
5350
5124
  if (needsToBeFunded) {
5351
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5352
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5353
- txRequest.addResources(resources);
5354
- }
5355
- txRequest.shiftPredicateData();
5356
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5357
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
5358
- if (addedSignatures) {
5359
- Array.from({ length: addedSignatures }).forEach(
5360
- () => requestToBeReEstimate.addEmptyWitness()
5361
- );
5125
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5126
+ messages: cachedMessages,
5127
+ utxos: cachedUtxos
5128
+ });
5129
+ request.addResources(resources);
5362
5130
  }
5363
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5364
- transactionRequest: requestToBeReEstimate
5365
- });
5366
- txRequest.maxFee = maxFee;
5367
- return txRequest;
5368
5131
  }
5369
5132
  /**
5370
5133
  * A helper that creates a transfer transaction request and returns it.
@@ -5372,25 +5135,29 @@ var Account = class extends import_interfaces.AbstractAccount {
5372
5135
  * @param destination - The address of the destination.
5373
5136
  * @param amount - The amount of coins to transfer.
5374
5137
  * @param assetId - The asset ID of the coins to transfer.
5375
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5138
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5376
5139
  * @returns A promise that resolves to the prepared transaction request.
5377
5140
  */
5378
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5379
- const request = new ScriptTransactionRequest(txParams);
5380
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5381
- const txCost = await this.provider.getTransactionCost(request, {
5141
+ async createTransfer(destination, amount, assetId, txParams = {}) {
5142
+ const { minGasPrice } = this.provider.getGasConfig();
5143
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5144
+ const params = { gasPrice: minGasPrice, ...txParams };
5145
+ const request = new ScriptTransactionRequest(params);
5146
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5147
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5382
5148
  estimateTxDependencies: true,
5383
5149
  resourcesOwner: this
5384
5150
  });
5385
- if ("gasLimit" in txParams) {
5386
- this.validateGas({
5387
- gasUsed: txCost.gasUsed,
5388
- gasLimit: request.gasLimit
5389
- });
5390
- }
5391
- request.gasLimit = txCost.gasUsed;
5392
- request.maxFee = txCost.maxFee;
5393
- await this.fund(request, txCost);
5151
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5152
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5153
+ this.validateGas({
5154
+ gasUsed,
5155
+ gasPrice: request.gasPrice,
5156
+ gasLimit: request.gasLimit,
5157
+ minGasPrice
5158
+ });
5159
+ await this.fund(request, requiredQuantities, maxFee);
5160
+ request.updatePredicateInputs(estimatedInputs);
5394
5161
  return request;
5395
5162
  }
5396
5163
  /**
@@ -5402,14 +5169,15 @@ var Account = class extends import_interfaces.AbstractAccount {
5402
5169
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5403
5170
  * @returns A promise that resolves to the transaction response.
5404
5171
  */
5405
- async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5406
- if ((0, import_math19.bn)(amount).lte(0)) {
5172
+ async transfer(destination, amount, assetId, txParams = {}) {
5173
+ if ((0, import_math18.bn)(amount).lte(0)) {
5407
5174
  throw new import_errors16.FuelError(
5408
5175
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5409
5176
  "Transfer amount must be a positive number."
5410
5177
  );
5411
5178
  }
5412
- const request = await this.createTransfer(destination, amount, assetId, txParams);
5179
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5180
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5413
5181
  return this.sendTransaction(request, { estimateTxDependencies: false });
5414
5182
  }
5415
5183
  /**
@@ -5421,38 +5189,40 @@ var Account = class extends import_interfaces.AbstractAccount {
5421
5189
  * @param txParams - The optional transaction parameters.
5422
5190
  * @returns A promise that resolves to the transaction response.
5423
5191
  */
5424
- async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5425
- if ((0, import_math19.bn)(amount).lte(0)) {
5192
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
5193
+ if ((0, import_math18.bn)(amount).lte(0)) {
5426
5194
  throw new import_errors16.FuelError(
5427
5195
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5428
5196
  "Transfer amount must be a positive number."
5429
5197
  );
5430
5198
  }
5431
5199
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5200
+ const { minGasPrice } = this.provider.getGasConfig();
5201
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5202
+ const params = { gasPrice: minGasPrice, ...txParams };
5432
5203
  const { script, scriptData } = await assembleTransferToContractScript({
5433
5204
  hexlifiedContractId: contractAddress.toB256(),
5434
- amountToTransfer: (0, import_math19.bn)(amount),
5435
- assetId
5205
+ amountToTransfer: (0, import_math18.bn)(amount),
5206
+ assetId: assetIdToTransfer
5436
5207
  });
5437
5208
  const request = new ScriptTransactionRequest({
5438
- ...txParams,
5209
+ ...params,
5439
5210
  script,
5440
5211
  scriptData
5441
5212
  });
5442
5213
  request.addContractInputAndOutput(contractAddress);
5443
- const txCost = await this.provider.getTransactionCost(request, {
5444
- resourcesOwner: this,
5445
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5214
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5215
+ request,
5216
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
5217
+ );
5218
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5219
+ this.validateGas({
5220
+ gasUsed,
5221
+ gasPrice: request.gasPrice,
5222
+ gasLimit: request.gasLimit,
5223
+ minGasPrice
5446
5224
  });
5447
- if (txParams.gasLimit) {
5448
- this.validateGas({
5449
- gasUsed: txCost.gasUsed,
5450
- gasLimit: request.gasLimit
5451
- });
5452
- }
5453
- request.gasLimit = txCost.gasUsed;
5454
- request.maxFee = txCost.maxFee;
5455
- await this.fund(request, txCost);
5225
+ await this.fund(request, requiredQuantities, maxFee);
5456
5226
  return this.sendTransaction(request);
5457
5227
  }
5458
5228
  /**
@@ -5464,31 +5234,35 @@ var Account = class extends import_interfaces.AbstractAccount {
5464
5234
  * @returns A promise that resolves to the transaction response.
5465
5235
  */
5466
5236
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5237
+ const { minGasPrice } = this.provider.getGasConfig();
5238
+ const baseAssetId = this.provider.getBaseAssetId();
5467
5239
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5468
- const recipientDataArray = (0, import_utils27.arrayify)(
5240
+ const recipientDataArray = (0, import_utils28.arrayify)(
5469
5241
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5470
5242
  );
5471
- const amountDataArray = (0, import_utils27.arrayify)(
5472
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5243
+ const amountDataArray = (0, import_utils28.arrayify)(
5244
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5473
5245
  );
5474
5246
  const script = new Uint8Array([
5475
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5247
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5476
5248
  ...recipientDataArray,
5477
5249
  ...amountDataArray
5478
5250
  ]);
5479
- const params = { script, ...txParams };
5251
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5480
5252
  const request = new ScriptTransactionRequest(params);
5481
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5482
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5483
- if (txParams.gasLimit) {
5484
- this.validateGas({
5485
- gasUsed: txCost.gasUsed,
5486
- gasLimit: request.gasLimit
5487
- });
5488
- }
5489
- request.maxFee = txCost.maxFee;
5490
- request.gasLimit = txCost.gasUsed;
5491
- await this.fund(request, txCost);
5253
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
5254
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5255
+ request,
5256
+ forwardingQuantities
5257
+ );
5258
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5259
+ this.validateGas({
5260
+ gasUsed,
5261
+ gasPrice: request.gasPrice,
5262
+ gasLimit: request.gasLimit,
5263
+ minGasPrice
5264
+ });
5265
+ await this.fund(request, requiredQuantities, maxFee);
5492
5266
  return this.sendTransaction(request);
5493
5267
  }
5494
5268
  async signMessage(message) {
@@ -5546,7 +5320,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5546
5320
  }
5547
5321
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5548
5322
  }
5549
- validateGas({ gasUsed, gasLimit }) {
5323
+ validateGas({
5324
+ gasUsed,
5325
+ gasPrice,
5326
+ gasLimit,
5327
+ minGasPrice
5328
+ }) {
5329
+ if (minGasPrice.gt(gasPrice)) {
5330
+ throw new import_errors16.FuelError(
5331
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5332
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5333
+ );
5334
+ }
5550
5335
  if (gasUsed.gt(gasLimit)) {
5551
5336
  throw new import_errors16.FuelError(
5552
5337
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5558,14 +5343,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5558
5343
 
5559
5344
  // src/wallet/base-wallet-unlocked.ts
5560
5345
  var import_hasher3 = require("@fuel-ts/hasher");
5561
- var import_utils30 = require("@fuel-ts/utils");
5346
+ var import_utils31 = require("@fuel-ts/utils");
5562
5347
 
5563
5348
  // src/signer/signer.ts
5564
5349
  var import_address5 = require("@fuel-ts/address");
5565
5350
  var import_crypto = require("@fuel-ts/crypto");
5566
5351
  var import_hasher2 = require("@fuel-ts/hasher");
5567
- var import_math20 = require("@fuel-ts/math");
5568
- var import_utils28 = require("@fuel-ts/utils");
5352
+ var import_math19 = require("@fuel-ts/math");
5353
+ var import_utils29 = require("@fuel-ts/utils");
5569
5354
  var import_secp256k1 = require("@noble/curves/secp256k1");
5570
5355
  var Signer = class {
5571
5356
  address;
@@ -5584,10 +5369,10 @@ var Signer = class {
5584
5369
  privateKey = `0x${privateKey}`;
5585
5370
  }
5586
5371
  }
5587
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5588
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5589
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5590
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5372
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5373
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5374
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5375
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5591
5376
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5592
5377
  }
5593
5378
  /**
@@ -5601,11 +5386,11 @@ var Signer = class {
5601
5386
  * @returns hashed signature
5602
5387
  */
5603
5388
  sign(data) {
5604
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5605
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5606
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5389
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5390
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5391
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5607
5392
  s[0] |= (signature.recovery || 0) << 7;
5608
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5393
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5609
5394
  }
5610
5395
  /**
5611
5396
  * Add point on the current elliptic curve
@@ -5614,8 +5399,8 @@ var Signer = class {
5614
5399
  * @returns compressed point on the curve
5615
5400
  */
5616
5401
  addPoint(point) {
5617
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5618
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5402
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5403
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5619
5404
  const result = p0.add(p1);
5620
5405
  return `0x${result.toHex(true)}`;
5621
5406
  }
@@ -5627,16 +5412,16 @@ var Signer = class {
5627
5412
  * @returns public key from signature from the
5628
5413
  */
5629
5414
  static recoverPublicKey(data, signature) {
5630
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5415
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5631
5416
  const r = signedMessageBytes.slice(0, 32);
5632
5417
  const s = signedMessageBytes.slice(32, 64);
5633
5418
  const recoveryParam = (s[0] & 128) >> 7;
5634
5419
  s[0] &= 127;
5635
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5420
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5636
5421
  recoveryParam
5637
5422
  );
5638
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5639
- return (0, import_utils28.hexlify)(publicKey);
5423
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5424
+ return (0, import_utils29.hexlify)(publicKey);
5640
5425
  }
5641
5426
  /**
5642
5427
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5655,7 +5440,7 @@ var Signer = class {
5655
5440
  * @returns random 32-byte hashed
5656
5441
  */
5657
5442
  static generatePrivateKey(entropy) {
5658
- return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5443
+ return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5659
5444
  }
5660
5445
  /**
5661
5446
  * Extended publicKey from a compact publicKey
@@ -5664,8 +5449,8 @@ var Signer = class {
5664
5449
  * @returns extended publicKey
5665
5450
  */
5666
5451
  static extendPublicKey(publicKey) {
5667
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5668
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5452
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5453
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5669
5454
  }
5670
5455
  };
5671
5456
 
@@ -5673,7 +5458,7 @@ var Signer = class {
5673
5458
  var import_address6 = require("@fuel-ts/address");
5674
5459
  var import_crypto2 = require("@fuel-ts/crypto");
5675
5460
  var import_errors17 = require("@fuel-ts/errors");
5676
- var import_utils29 = require("@fuel-ts/utils");
5461
+ var import_utils30 = require("@fuel-ts/utils");
5677
5462
  var import_uuid = require("uuid");
5678
5463
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5679
5464
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5756,7 +5541,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5756
5541
  );
5757
5542
  }
5758
5543
  const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5759
- const privateKey = (0, import_utils29.hexlify)(buffer);
5544
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5760
5545
  return privateKey;
5761
5546
  }
5762
5547
 
@@ -5801,7 +5586,7 @@ var BaseWalletUnlocked = class extends Account {
5801
5586
  */
5802
5587
  async signMessage(message) {
5803
5588
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5804
- return (0, import_utils30.hexlify)(signedMessage);
5589
+ return (0, import_utils31.hexlify)(signedMessage);
5805
5590
  }
5806
5591
  /**
5807
5592
  * Signs a transaction with the wallet's private key.
@@ -5814,7 +5599,7 @@ var BaseWalletUnlocked = class extends Account {
5814
5599
  const chainId = this.provider.getChainId();
5815
5600
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5816
5601
  const signature = await this.signer().sign(hashedTransaction);
5817
- return (0, import_utils30.hexlify)(signature);
5602
+ return (0, import_utils31.hexlify)(signature);
5818
5603
  }
5819
5604
  /**
5820
5605
  * Populates a transaction with the witnesses signature.
@@ -5834,7 +5619,7 @@ var BaseWalletUnlocked = class extends Account {
5834
5619
  * @param transactionRequestLike - The transaction request to send.
5835
5620
  * @returns A promise that resolves to the TransactionResponse object.
5836
5621
  */
5837
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5622
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5838
5623
  const transactionRequest = transactionRequestify(transactionRequestLike);
5839
5624
  if (estimateTxDependencies) {
5840
5625
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5875,16 +5660,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5875
5660
  // src/hdwallet/hdwallet.ts
5876
5661
  var import_errors20 = require("@fuel-ts/errors");
5877
5662
  var import_hasher6 = require("@fuel-ts/hasher");
5878
- var import_math21 = require("@fuel-ts/math");
5879
- var import_utils34 = require("@fuel-ts/utils");
5880
- var import_ethers4 = require("ethers");
5663
+ var import_math20 = require("@fuel-ts/math");
5664
+ var import_utils35 = require("@fuel-ts/utils");
5665
+ var import_ethers3 = require("ethers");
5881
5666
 
5882
5667
  // src/mnemonic/mnemonic.ts
5883
5668
  var import_crypto3 = require("@fuel-ts/crypto");
5884
5669
  var import_errors19 = require("@fuel-ts/errors");
5885
5670
  var import_hasher5 = require("@fuel-ts/hasher");
5886
- var import_utils32 = require("@fuel-ts/utils");
5887
- var import_ethers3 = require("ethers");
5671
+ var import_utils33 = require("@fuel-ts/utils");
5672
+ var import_ethers2 = require("ethers");
5888
5673
 
5889
5674
  // src/wordlists/words/english.ts
5890
5675
  var english = [
@@ -7947,7 +7732,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7947
7732
  // src/mnemonic/utils.ts
7948
7733
  var import_errors18 = require("@fuel-ts/errors");
7949
7734
  var import_hasher4 = require("@fuel-ts/hasher");
7950
- var import_utils31 = require("@fuel-ts/utils");
7735
+ var import_utils32 = require("@fuel-ts/utils");
7951
7736
  function toUtf8Bytes(stri) {
7952
7737
  const str = stri.normalize("NFKD");
7953
7738
  const result = [];
@@ -8014,14 +7799,14 @@ function entropyToMnemonicIndices(entropy) {
8014
7799
  }
8015
7800
  }
8016
7801
  const checksumBits = entropy.length / 4;
8017
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7802
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8018
7803
  indices[indices.length - 1] <<= checksumBits;
8019
7804
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8020
7805
  return indices;
8021
7806
  }
8022
7807
  function mnemonicWordsToEntropy(words, wordlist) {
8023
7808
  const size = Math.ceil(11 * words.length / 8);
8024
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7809
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8025
7810
  let offset = 0;
8026
7811
  for (let i = 0; i < words.length; i += 1) {
8027
7812
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8041,7 +7826,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8041
7826
  const entropyBits = 32 * words.length / 3;
8042
7827
  const checksumBits = words.length / 3;
8043
7828
  const checksumMask = getUpperMask(checksumBits);
8044
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7829
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8045
7830
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8046
7831
  throw new import_errors18.FuelError(
8047
7832
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8116,7 +7901,7 @@ var Mnemonic = class {
8116
7901
  static mnemonicToEntropy(phrase, wordlist = english) {
8117
7902
  const words = getWords(phrase);
8118
7903
  assertMnemonic(words);
8119
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7904
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8120
7905
  }
8121
7906
  /**
8122
7907
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8124,7 +7909,7 @@ var Mnemonic = class {
8124
7909
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8125
7910
  */
8126
7911
  static entropyToMnemonic(entropy, wordlist = english) {
8127
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7912
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8128
7913
  assertWordList(wordlist);
8129
7914
  assertEntropy(entropyBytes);
8130
7915
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8138,7 +7923,7 @@ var Mnemonic = class {
8138
7923
  assertMnemonic(getWords(phrase));
8139
7924
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
8140
7925
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
8141
- return (0, import_ethers3.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7926
+ return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8142
7927
  }
8143
7928
  /**
8144
7929
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -8193,14 +7978,14 @@ var Mnemonic = class {
8193
7978
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8194
7979
  */
8195
7980
  static masterKeysFromSeed(seed) {
8196
- const seedArray = (0, import_utils32.arrayify)(seed);
7981
+ const seedArray = (0, import_utils33.arrayify)(seed);
8197
7982
  if (seedArray.length < 16 || seedArray.length > 64) {
8198
7983
  throw new import_errors19.FuelError(
8199
7984
  import_errors19.ErrorCode.INVALID_SEED,
8200
7985
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8201
7986
  );
8202
7987
  }
8203
- return (0, import_utils32.arrayify)((0, import_ethers3.computeHmac)("sha512", MasterSecret, seedArray));
7988
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8204
7989
  }
8205
7990
  /**
8206
7991
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8211,22 +7996,22 @@ var Mnemonic = class {
8211
7996
  */
8212
7997
  static seedToExtendedKey(seed, testnet = false) {
8213
7998
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8214
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7999
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8215
8000
  const depth = "0x00";
8216
8001
  const fingerprint = "0x00000000";
8217
8002
  const index = "0x00000000";
8218
8003
  const chainCode = masterKey.slice(32);
8219
8004
  const privateKey = masterKey.slice(0, 32);
8220
- const extendedKey = (0, import_utils32.concat)([
8005
+ const extendedKey = (0, import_utils33.concat)([
8221
8006
  prefix,
8222
8007
  depth,
8223
8008
  fingerprint,
8224
8009
  index,
8225
8010
  chainCode,
8226
- (0, import_utils32.concat)(["0x00", privateKey])
8011
+ (0, import_utils33.concat)(["0x00", privateKey])
8227
8012
  ]);
8228
- const checksum = (0, import_ethers3.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8229
- return (0, import_ethers3.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8013
+ const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8014
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8230
8015
  }
8231
8016
  /**
8232
8017
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8241,7 +8026,7 @@ var Mnemonic = class {
8241
8026
  * @returns A randomly generated mnemonic
8242
8027
  */
8243
8028
  static generate(size = 32, extraEntropy = "") {
8244
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
8029
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
8245
8030
  return Mnemonic.entropyToMnemonic(entropy);
8246
8031
  }
8247
8032
  };
@@ -8249,12 +8034,12 @@ var mnemonic_default = Mnemonic;
8249
8034
 
8250
8035
  // src/hdwallet/hdwallet.ts
8251
8036
  var HARDENED_INDEX = 2147483648;
8252
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8253
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8254
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8255
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8037
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8038
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8039
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8040
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8256
8041
  function base58check(data) {
8257
- return (0, import_ethers4.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers4.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8042
+ return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8258
8043
  }
8259
8044
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8260
8045
  if (isPublic) {
@@ -8263,11 +8048,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8263
8048
  return testnet ? TestnetPRV2 : MainnetPRV2;
8264
8049
  }
8265
8050
  function isPublicExtendedKey(extendedKey) {
8266
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8051
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8267
8052
  }
8268
8053
  function isValidExtendedKey(extendedKey) {
8269
8054
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8270
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8055
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8271
8056
  );
8272
8057
  }
8273
8058
  function parsePath(path, depth = 0) {
@@ -8285,8 +8070,8 @@ function parsePath(path, depth = 0) {
8285
8070
  var HDWallet = class {
8286
8071
  depth = 0;
8287
8072
  index = 0;
8288
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
8289
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8073
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8074
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8290
8075
  privateKey;
8291
8076
  publicKey;
8292
8077
  chainCode;
@@ -8298,8 +8083,8 @@ var HDWallet = class {
8298
8083
  constructor(config) {
8299
8084
  if (config.privateKey) {
8300
8085
  const signer = new Signer(config.privateKey);
8301
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8302
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8086
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8087
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8303
8088
  } else {
8304
8089
  if (!config.publicKey) {
8305
8090
  throw new import_errors20.FuelError(
@@ -8307,10 +8092,10 @@ var HDWallet = class {
8307
8092
  "Both public and private Key cannot be missing. At least one should be provided."
8308
8093
  );
8309
8094
  }
8310
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8095
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8311
8096
  }
8312
8097
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8313
- this.fingerprint = (0, import_ethers4.dataSlice)((0, import_ethers4.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8098
+ this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8314
8099
  this.depth = config.depth || this.depth;
8315
8100
  this.index = config.index || this.index;
8316
8101
  this.chainCode = config.chainCode;
@@ -8326,9 +8111,9 @@ var HDWallet = class {
8326
8111
  * @returns A new instance of HDWallet on the derived index
8327
8112
  */
8328
8113
  deriveIndex(index) {
8329
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8330
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8331
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8114
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8115
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8116
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8332
8117
  const data = new Uint8Array(37);
8333
8118
  if (index & HARDENED_INDEX) {
8334
8119
  if (!privateKey) {
@@ -8339,15 +8124,15 @@ var HDWallet = class {
8339
8124
  }
8340
8125
  data.set(privateKey, 1);
8341
8126
  } else {
8342
- data.set((0, import_utils34.arrayify)(this.publicKey));
8127
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8343
8128
  }
8344
- data.set((0, import_math21.toBytes)(index, 4), 33);
8345
- const bytes = (0, import_utils34.arrayify)((0, import_ethers4.computeHmac)("sha512", chainCode, data));
8129
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8130
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8346
8131
  const IL = bytes.slice(0, 32);
8347
8132
  const IR = bytes.slice(32);
8348
8133
  if (privateKey) {
8349
8134
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8350
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8135
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8351
8136
  return new HDWallet({
8352
8137
  privateKey: ki,
8353
8138
  chainCode: IR,
@@ -8356,7 +8141,7 @@ var HDWallet = class {
8356
8141
  parentFingerprint: this.fingerprint
8357
8142
  });
8358
8143
  }
8359
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8144
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8360
8145
  const Ki = signer.addPoint(publicKey);
8361
8146
  return new HDWallet({
8362
8147
  publicKey: Ki,
@@ -8391,12 +8176,12 @@ var HDWallet = class {
8391
8176
  );
8392
8177
  }
8393
8178
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8394
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8179
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8395
8180
  const parentFingerprint = this.parentFingerprint;
8396
- const index = (0, import_math21.toHex)(this.index, 4);
8181
+ const index = (0, import_math20.toHex)(this.index, 4);
8397
8182
  const chainCode = this.chainCode;
8398
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8399
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8183
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8184
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8400
8185
  return base58check(extendedKey);
8401
8186
  }
8402
8187
  /**
@@ -8408,13 +8193,13 @@ var HDWallet = class {
8408
8193
  static fromSeed(seed) {
8409
8194
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8410
8195
  return new HDWallet({
8411
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8412
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8196
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8197
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8413
8198
  });
8414
8199
  }
8415
8200
  static fromExtendedKey(extendedKey) {
8416
- const decoded = (0, import_ethers4.toBeHex)((0, import_ethers4.decodeBase58)(extendedKey));
8417
- const bytes = (0, import_utils34.arrayify)(decoded);
8201
+ const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8202
+ const bytes = (0, import_utils35.arrayify)(decoded);
8418
8203
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8419
8204
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8420
8205
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8423,9 +8208,9 @@ var HDWallet = class {
8423
8208
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8424
8209
  }
8425
8210
  const depth = bytes[4];
8426
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8427
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8428
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8211
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8212
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8213
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8429
8214
  const key = bytes.slice(45, 78);
8430
8215
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8431
8216
  throw new import_errors20.FuelError(
@@ -9028,21 +8813,20 @@ var StorageAbstract = class {
9028
8813
  // src/predicate/predicate.ts
9029
8814
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
9030
8815
  var import_address10 = require("@fuel-ts/address");
9031
- var import_configs13 = require("@fuel-ts/address/configs");
9032
8816
  var import_errors25 = require("@fuel-ts/errors");
9033
- var import_transactions21 = require("@fuel-ts/transactions");
9034
- var import_utils36 = require("@fuel-ts/utils");
8817
+ var import_transactions20 = require("@fuel-ts/transactions");
8818
+ var import_utils37 = require("@fuel-ts/utils");
9035
8819
 
9036
8820
  // src/predicate/utils/getPredicateRoot.ts
9037
8821
  var import_hasher7 = require("@fuel-ts/hasher");
9038
8822
  var import_merkle = require("@fuel-ts/merkle");
9039
- var import_utils35 = require("@fuel-ts/utils");
8823
+ var import_utils36 = require("@fuel-ts/utils");
9040
8824
  var getPredicateRoot = (bytecode) => {
9041
8825
  const chunkSize = 16 * 1024;
9042
- const bytes = (0, import_utils35.arrayify)(bytecode);
9043
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9044
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9045
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8826
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8827
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8828
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8829
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9046
8830
  return predicateRoot;
9047
8831
  };
9048
8832
 
@@ -9079,7 +8863,6 @@ var Predicate = class extends Account {
9079
8863
  this.interface = predicateInterface;
9080
8864
  if (inputData !== void 0 && inputData.length > 0) {
9081
8865
  this.predicateData = inputData;
9082
- this.predicateDataBytes = this.getPredicateData(0);
9083
8866
  }
9084
8867
  }
9085
8868
  /**
@@ -9092,9 +8875,9 @@ var Predicate = class extends Account {
9092
8875
  const request = transactionRequestify(transactionRequestLike);
9093
8876
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9094
8877
  request.inputs?.forEach((input) => {
9095
- if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9096
- input.predicate = (0, import_utils36.hexlify)(this.bytes);
9097
- input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8878
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8879
+ input.predicate = this.bytes;
8880
+ input.predicateData = this.getPredicateData(policies.length);
9098
8881
  }
9099
8882
  });
9100
8883
  return request;
@@ -9108,8 +8891,10 @@ var Predicate = class extends Account {
9108
8891
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
9109
8892
  * @returns A promise that resolves to the prepared transaction request.
9110
8893
  */
9111
- async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
9112
- return super.createTransfer(destination, amount, assetId, txParams);
8894
+ async createTransfer(destination, amount, assetId, txParams = {}) {
8895
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8896
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8897
+ return this.populateTransactionPredicateData(request);
9113
8898
  }
9114
8899
  /**
9115
8900
  * Sends a transaction with the populated predicate data.
@@ -9117,9 +8902,9 @@ var Predicate = class extends Account {
9117
8902
  * @param transactionRequestLike - The transaction request-like object.
9118
8903
  * @returns A promise that resolves to the transaction response.
9119
8904
  */
9120
- sendTransaction(transactionRequestLike) {
9121
- const transactionRequest = transactionRequestify(transactionRequestLike);
9122
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8905
+ sendTransaction(transactionRequestLike, options) {
8906
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8907
+ return super.sendTransaction(transactionRequest, options);
9123
8908
  }
9124
8909
  /**
9125
8910
  * Simulates a transaction with the populated predicate data.
@@ -9128,15 +8913,15 @@ var Predicate = class extends Account {
9128
8913
  * @returns A promise that resolves to the call result.
9129
8914
  */
9130
8915
  simulateTransaction(transactionRequestLike) {
9131
- const transactionRequest = transactionRequestify(transactionRequestLike);
9132
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8916
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8917
+ return super.simulateTransaction(transactionRequest);
9133
8918
  }
9134
8919
  getPredicateData(policiesLength) {
9135
8920
  if (!this.predicateData.length) {
9136
8921
  return new Uint8Array();
9137
8922
  }
9138
8923
  const mainFn = this.interface?.functions.main;
9139
- const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8924
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9140
8925
  const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
9141
8926
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9142
8927
  });
@@ -9152,7 +8937,7 @@ var Predicate = class extends Account {
9152
8937
  * @returns An object containing the new predicate bytes and interface.
9153
8938
  */
9154
8939
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9155
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8940
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9156
8941
  let abiInterface;
9157
8942
  if (jsonAbi) {
9158
8943
  abiInterface = new import_abi_coder5.Interface(jsonAbi);
@@ -9175,26 +8960,6 @@ var Predicate = class extends Account {
9175
8960
  predicateInterface: abiInterface
9176
8961
  };
9177
8962
  }
9178
- /**
9179
- * Retrieves resources satisfying the spend query for the account.
9180
- *
9181
- * @param quantities - IDs of coins to exclude.
9182
- * @param excludedIds - IDs of resources to be excluded from the query.
9183
- * @returns A promise that resolves to an array of Resources.
9184
- */
9185
- async getResourcesToSpend(quantities, excludedIds) {
9186
- const resources = await this.provider.getResourcesToSpend(
9187
- this.address,
9188
- quantities,
9189
- excludedIds
9190
- );
9191
- return resources.map((resource) => ({
9192
- ...resource,
9193
- predicate: (0, import_utils36.hexlify)(this.bytes),
9194
- predicateData: (0, import_utils36.hexlify)(this.predicateDataBytes),
9195
- paddPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9196
- }));
9197
- }
9198
8963
  /**
9199
8964
  * Sets the configurable constants for the predicate.
9200
8965
  *
@@ -9944,7 +9709,7 @@ __publicField(Fuel, "defaultConfig", {});
9944
9709
  WalletLocked,
9945
9710
  WalletManager,
9946
9711
  WalletUnlocked,
9947
- addAmountToCoinQuantities,
9712
+ addAmountToAsset,
9948
9713
  addOperation,
9949
9714
  assemblePanicError,
9950
9715
  assembleReceiptByType,
@@ -9953,10 +9718,9 @@ __publicField(Fuel, "defaultConfig", {});
9953
9718
  assets,
9954
9719
  buildBlockExplorerUrl,
9955
9720
  cacheFor,
9956
- cacheTxInputsFromOwner,
9957
- calculateGasFee,
9958
9721
  calculateMetadataGasForTxCreate,
9959
9722
  calculateMetadataGasForTxScript,
9723
+ calculatePriceWithFactor,
9960
9724
  calculateTransactionFee,
9961
9725
  coinQuantityfy,
9962
9726
  deferPromise,