@fuel-ts/account 0.0.0-rc-2021-20240422173414 → 0.0.0-rc-2045-20240422223402

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 (53) 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 +550 -798
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +509 -761
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +390 -641
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +329 -911
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +1 -7
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +27 -37
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/input.d.ts +2 -2
  31. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/transaction-request.d.ts +25 -8
  34. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/utils.d.ts +0 -3
  36. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  37. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  38. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/utils/gas.d.ts +2 -8
  44. package/dist/providers/utils/gas.d.ts.map +1 -1
  45. package/dist/test-utils/launchNode.d.ts.map +1 -1
  46. package/dist/test-utils.global.js +1062 -1548
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +505 -739
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +399 -633
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  53. package/package.json +16 -16
@@ -58,16 +58,15 @@ module.exports = __toCommonJS(test_utils_exports);
58
58
 
59
59
  // src/wallet/base-wallet-unlocked.ts
60
60
  var import_hasher3 = require("@fuel-ts/hasher");
61
- var import_utils30 = require("@fuel-ts/utils");
61
+ var import_utils31 = require("@fuel-ts/utils");
62
62
 
63
63
  // src/account.ts
64
64
  var import_address4 = require("@fuel-ts/address");
65
65
  var import_configs12 = require("@fuel-ts/address/configs");
66
66
  var import_errors16 = require("@fuel-ts/errors");
67
67
  var import_interfaces = require("@fuel-ts/interfaces");
68
- var import_math19 = require("@fuel-ts/math");
69
- var import_utils27 = require("@fuel-ts/utils");
70
- var import_ramda4 = require("ramda");
68
+ var import_math18 = require("@fuel-ts/math");
69
+ var import_utils28 = require("@fuel-ts/utils");
71
70
 
72
71
  // src/providers/coin-quantity.ts
73
72
  var import_configs = require("@fuel-ts/address/configs");
@@ -76,24 +75,24 @@ var import_utils = require("@fuel-ts/utils");
76
75
  var coinQuantityfy = (coinQuantityLike) => {
77
76
  let assetId;
78
77
  let amount;
79
- let max;
78
+ let max2;
80
79
  if (Array.isArray(coinQuantityLike)) {
81
80
  amount = coinQuantityLike[0];
82
81
  assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
83
- max = coinQuantityLike[2] ?? void 0;
82
+ max2 = coinQuantityLike[2] ?? void 0;
84
83
  } else {
85
84
  amount = coinQuantityLike.amount;
86
85
  assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
87
- max = coinQuantityLike.max ?? void 0;
86
+ max2 = coinQuantityLike.max ?? void 0;
88
87
  }
89
88
  const bnAmount = (0, import_math.bn)(amount);
90
89
  return {
91
90
  assetId: (0, import_utils.hexlify)(assetId),
92
91
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
93
- max: max ? (0, import_math.bn)(max) : void 0
92
+ max: max2 ? (0, import_math.bn)(max2) : void 0
94
93
  };
95
94
  };
96
- var addAmountToCoinQuantities = (params) => {
95
+ var addAmountToAsset = (params) => {
97
96
  const { amount, assetId } = params;
98
97
  const coinQuantities = [...params.coinQuantities];
99
98
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -108,11 +107,11 @@ var addAmountToCoinQuantities = (params) => {
108
107
  // src/providers/provider.ts
109
108
  var import_address3 = require("@fuel-ts/address");
110
109
  var import_errors14 = require("@fuel-ts/errors");
111
- var import_math16 = require("@fuel-ts/math");
112
- var import_transactions19 = require("@fuel-ts/transactions");
113
- var import_utils22 = require("@fuel-ts/utils");
110
+ var import_math15 = require("@fuel-ts/math");
111
+ var import_transactions18 = require("@fuel-ts/transactions");
112
+ var import_utils23 = require("@fuel-ts/utils");
114
113
  var import_versions = require("@fuel-ts/versions");
115
- var import_utils23 = require("@noble/curves/abstract/utils");
114
+ var import_utils24 = require("@noble/curves/abstract/utils");
116
115
  var import_ethers = require("ethers");
117
116
  var import_graphql_request = require("graphql-request");
118
117
  var import_ramda3 = require("ramda");
@@ -121,10 +120,14 @@ var import_ramda3 = require("ramda");
121
120
  var import_graphql_tag = __toESM(require("graphql-tag"));
122
121
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
123
122
  fragment receiptFragment on Receipt {
124
- id
123
+ contract {
124
+ id
125
+ }
125
126
  pc
126
127
  is
127
- to
128
+ to {
129
+ id
130
+ }
128
131
  toAddress
129
132
  amount
130
133
  assetId
@@ -162,16 +165,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
162
165
  id
163
166
  }
164
167
  time
165
- receipts {
166
- ...receiptFragment
167
- }
168
168
  programState {
169
169
  returnType
170
170
  data
171
171
  }
172
- receipts {
173
- ...receiptFragment
174
- }
175
172
  }
176
173
  ... on FailureStatus {
177
174
  block {
@@ -179,24 +176,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
179
176
  }
180
177
  time
181
178
  reason
182
- receipts {
183
- ...receiptFragment
184
- }
185
179
  }
186
180
  ... on SqueezedOutStatus {
187
181
  reason
188
182
  }
189
183
  }
190
- ${ReceiptFragmentFragmentDoc}`;
184
+ `;
191
185
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
192
186
  fragment transactionFragment on Transaction {
193
187
  id
194
188
  rawPayload
189
+ gasPrice
190
+ receipts {
191
+ ...receiptFragment
192
+ }
195
193
  status {
196
194
  ...transactionStatusFragment
197
195
  }
198
196
  }
199
- ${TransactionStatusFragmentFragmentDoc}`;
197
+ ${ReceiptFragmentFragmentDoc}
198
+ ${TransactionStatusFragmentFragmentDoc}`;
200
199
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
201
200
  fragment inputEstimatePredicatesFragment on Input {
202
201
  ... on InputCoin {
@@ -214,46 +213,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
214
213
  }
215
214
  }
216
215
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
217
- var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
218
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
219
- reason
220
- programState {
221
- returnType
222
- data
223
- }
224
- }
225
- `;
226
- var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
227
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
228
- programState {
229
- returnType
230
- data
231
- }
232
- }
233
- `;
234
- var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
235
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
236
- ... on DryRunFailureStatus {
237
- ...dryRunFailureStatusFragment
238
- }
239
- ... on DryRunSuccessStatus {
240
- ...dryRunSuccessStatusFragment
241
- }
242
- }
243
- ${DryRunFailureStatusFragmentFragmentDoc}
244
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
245
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
246
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
247
- id
248
- status {
249
- ...dryRunTransactionStatusFragment
250
- }
251
- receipts {
252
- ...receiptFragment
253
- }
254
- }
255
- ${DryRunTransactionStatusFragmentFragmentDoc}
256
- ${ReceiptFragmentFragmentDoc}`;
257
216
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
258
217
  fragment coinFragment on Coin {
259
218
  __typename
@@ -261,6 +220,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
261
220
  owner
262
221
  amount
263
222
  assetId
223
+ maturity
264
224
  blockCreated
265
225
  txCreatedIdx
266
226
  }
@@ -299,32 +259,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
299
259
  messageBlockHeader {
300
260
  id
301
261
  daHeight
302
- consensusParametersVersion
303
- stateTransitionBytecodeVersion
304
262
  transactionsCount
305
- messageReceiptCount
306
263
  transactionsRoot
307
- messageOutboxRoot
308
- eventInboxRoot
309
264
  height
310
265
  prevRoot
311
266
  time
312
267
  applicationHash
268
+ messageReceiptRoot
269
+ messageReceiptCount
313
270
  }
314
271
  commitBlockHeader {
315
272
  id
316
273
  daHeight
317
- consensusParametersVersion
318
- stateTransitionBytecodeVersion
319
274
  transactionsCount
320
- messageReceiptCount
321
275
  transactionsRoot
322
- messageOutboxRoot
323
- eventInboxRoot
324
276
  height
325
277
  prevRoot
326
278
  time
327
279
  applicationHash
280
+ messageReceiptRoot
281
+ messageReceiptCount
328
282
  }
329
283
  sender
330
284
  recipient
@@ -343,8 +297,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
343
297
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
344
298
  fragment blockFragment on Block {
345
299
  id
346
- height
347
300
  header {
301
+ height
348
302
  time
349
303
  }
350
304
  transactions {
@@ -402,11 +356,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
402
356
  `;
403
357
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
404
358
  fragment GasCostsFragment on GasCosts {
405
- version {
406
- ... on Version {
407
- value
408
- }
409
- }
410
359
  add
411
360
  addi
412
361
  aloc
@@ -419,6 +368,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
419
368
  cb
420
369
  cfei
421
370
  cfsi
371
+ croo
422
372
  div
423
373
  divi
424
374
  ecr1
@@ -501,9 +451,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
501
451
  ccp {
502
452
  ...DependentCostFragment
503
453
  }
504
- croo {
505
- ...DependentCostFragment
506
- }
507
454
  csiz {
508
455
  ...DependentCostFragment
509
456
  }
@@ -563,11 +510,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
563
510
  ${DependentCostFragmentFragmentDoc}`;
564
511
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
565
512
  fragment consensusParametersFragment on ConsensusParameters {
566
- version {
567
- ... on Version {
568
- value
569
- }
570
- }
571
513
  txParams {
572
514
  ...TxParametersFragment
573
515
  }
@@ -627,9 +569,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
627
569
  fragment nodeInfoFragment on NodeInfo {
628
570
  utxoValidation
629
571
  vmBacktrace
572
+ minGasPrice
630
573
  maxTx
631
574
  maxDepth
632
575
  nodeVersion
576
+ peers {
577
+ id
578
+ addresses
579
+ clientVersion
580
+ blockHeight
581
+ lastHeartbeatMs
582
+ appScore
583
+ }
633
584
  }
634
585
  `;
635
586
  var GetVersionDocument = import_graphql_tag.default`
@@ -664,9 +615,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
664
615
  query getTransactionWithReceipts($transactionId: TransactionId!) {
665
616
  transaction(id: $transactionId) {
666
617
  ...transactionFragment
618
+ receipts {
619
+ ...receiptFragment
620
+ }
667
621
  }
668
622
  }
669
- ${TransactionFragmentFragmentDoc}`;
623
+ ${TransactionFragmentFragmentDoc}
624
+ ${ReceiptFragmentFragmentDoc}`;
670
625
  var GetTransactionsDocument = import_graphql_tag.default`
671
626
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
672
627
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -794,20 +749,6 @@ var GetBalanceDocument = import_graphql_tag.default`
794
749
  }
795
750
  }
796
751
  ${BalanceFragmentFragmentDoc}`;
797
- var GetLatestGasPriceDocument = import_graphql_tag.default`
798
- query getLatestGasPrice {
799
- latestGasPrice {
800
- gasPrice
801
- }
802
- }
803
- `;
804
- var EstimateGasPriceDocument = import_graphql_tag.default`
805
- query estimateGasPrice($blockHorizon: U32!) {
806
- estimateGasPrice(blockHorizon: $blockHorizon) {
807
- gasPrice
808
- }
809
- }
810
- `;
811
752
  var GetBalancesDocument = import_graphql_tag.default`
812
753
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
813
754
  balances(
@@ -862,12 +803,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
862
803
  }
863
804
  `;
864
805
  var DryRunDocument = import_graphql_tag.default`
865
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
866
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
867
- ...dryRunTransactionExecutionStatusFragment
806
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
807
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
808
+ ...receiptFragment
868
809
  }
869
810
  }
870
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
811
+ ${ReceiptFragmentFragmentDoc}`;
871
812
  var SubmitDocument = import_graphql_tag.default`
872
813
  mutation submit($encodedTransaction: HexString!) {
873
814
  submit(tx: $encodedTransaction) {
@@ -950,12 +891,6 @@ function getSdk(requester) {
950
891
  getBalance(variables, options) {
951
892
  return requester(GetBalanceDocument, variables, options);
952
893
  },
953
- getLatestGasPrice(variables, options) {
954
- return requester(GetLatestGasPriceDocument, variables, options);
955
- },
956
- estimateGasPrice(variables, options) {
957
- return requester(EstimateGasPriceDocument, variables, options);
958
- },
959
894
  getBalances(variables, options) {
960
895
  return requester(GetBalancesDocument, variables, options);
961
896
  },
@@ -1149,9 +1084,10 @@ var inputify = (value) => {
1149
1084
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1150
1085
  },
1151
1086
  witnessIndex: value.witnessIndex,
1087
+ maturity: value.maturity ?? 0,
1152
1088
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1153
- predicateLength: (0, import_math2.bn)(predicate.length),
1154
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1089
+ predicateLength: predicate.length,
1090
+ predicateDataLength: predicateData.length,
1155
1091
  predicate: (0, import_utils3.hexlify)(predicate),
1156
1092
  predicateData: (0, import_utils3.hexlify)(predicateData)
1157
1093
  };
@@ -1182,8 +1118,8 @@ var inputify = (value) => {
1182
1118
  nonce: (0, import_utils3.hexlify)(value.nonce),
1183
1119
  witnessIndex: value.witnessIndex,
1184
1120
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1185
- predicateLength: (0, import_math2.bn)(predicate.length),
1186
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1121
+ predicateLength: predicate.length,
1122
+ predicateDataLength: predicateData.length,
1187
1123
  predicate: (0, import_utils3.hexlify)(predicate),
1188
1124
  predicateData: (0, import_utils3.hexlify)(predicateData),
1189
1125
  data: (0, import_utils3.hexlify)(data),
@@ -1299,8 +1235,8 @@ function assembleReceiptByType(receipt) {
1299
1235
  case "CALL" /* Call */: {
1300
1236
  const callReceipt = {
1301
1237
  type: import_transactions3.ReceiptType.Call,
1302
- from: hexOrZero(receipt.id || receipt.contractId),
1303
- to: hexOrZero(receipt?.to),
1238
+ from: hexOrZero(receipt.contract?.id),
1239
+ to: hexOrZero(receipt?.to?.id),
1304
1240
  amount: (0, import_math4.bn)(receipt.amount),
1305
1241
  assetId: hexOrZero(receipt.assetId),
1306
1242
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1314,7 +1250,7 @@ function assembleReceiptByType(receipt) {
1314
1250
  case "RETURN" /* Return */: {
1315
1251
  const returnReceipt = {
1316
1252
  type: import_transactions3.ReceiptType.Return,
1317
- id: hexOrZero(receipt.id || receipt.contractId),
1253
+ id: hexOrZero(receipt.contract?.id),
1318
1254
  val: (0, import_math4.bn)(receipt.val),
1319
1255
  pc: (0, import_math4.bn)(receipt.pc),
1320
1256
  is: (0, import_math4.bn)(receipt.is)
@@ -1324,7 +1260,7 @@ function assembleReceiptByType(receipt) {
1324
1260
  case "RETURN_DATA" /* ReturnData */: {
1325
1261
  const returnDataReceipt = {
1326
1262
  type: import_transactions3.ReceiptType.ReturnData,
1327
- id: hexOrZero(receipt.id || receipt.contractId),
1263
+ id: hexOrZero(receipt.contract?.id),
1328
1264
  ptr: (0, import_math4.bn)(receipt.ptr),
1329
1265
  len: (0, import_math4.bn)(receipt.len),
1330
1266
  digest: hexOrZero(receipt.digest),
@@ -1336,7 +1272,7 @@ function assembleReceiptByType(receipt) {
1336
1272
  case "PANIC" /* Panic */: {
1337
1273
  const panicReceipt = {
1338
1274
  type: import_transactions3.ReceiptType.Panic,
1339
- id: hexOrZero(receipt.id),
1275
+ id: hexOrZero(receipt.contract?.id),
1340
1276
  reason: (0, import_math4.bn)(receipt.reason),
1341
1277
  pc: (0, import_math4.bn)(receipt.pc),
1342
1278
  is: (0, import_math4.bn)(receipt.is),
@@ -1347,7 +1283,7 @@ function assembleReceiptByType(receipt) {
1347
1283
  case "REVERT" /* Revert */: {
1348
1284
  const revertReceipt = {
1349
1285
  type: import_transactions3.ReceiptType.Revert,
1350
- id: hexOrZero(receipt.id || receipt.contractId),
1286
+ id: hexOrZero(receipt.contract?.id),
1351
1287
  val: (0, import_math4.bn)(receipt.ra),
1352
1288
  pc: (0, import_math4.bn)(receipt.pc),
1353
1289
  is: (0, import_math4.bn)(receipt.is)
@@ -1357,7 +1293,7 @@ function assembleReceiptByType(receipt) {
1357
1293
  case "LOG" /* Log */: {
1358
1294
  const logReceipt = {
1359
1295
  type: import_transactions3.ReceiptType.Log,
1360
- id: hexOrZero(receipt.id || receipt.contractId),
1296
+ id: hexOrZero(receipt.contract?.id),
1361
1297
  val0: (0, import_math4.bn)(receipt.ra),
1362
1298
  val1: (0, import_math4.bn)(receipt.rb),
1363
1299
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1370,7 +1306,7 @@ function assembleReceiptByType(receipt) {
1370
1306
  case "LOG_DATA" /* LogData */: {
1371
1307
  const logDataReceipt = {
1372
1308
  type: import_transactions3.ReceiptType.LogData,
1373
- id: hexOrZero(receipt.id || receipt.contractId),
1309
+ id: hexOrZero(receipt.contract?.id),
1374
1310
  val0: (0, import_math4.bn)(receipt.ra),
1375
1311
  val1: (0, import_math4.bn)(receipt.rb),
1376
1312
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1384,8 +1320,8 @@ function assembleReceiptByType(receipt) {
1384
1320
  case "TRANSFER" /* Transfer */: {
1385
1321
  const transferReceipt = {
1386
1322
  type: import_transactions3.ReceiptType.Transfer,
1387
- from: hexOrZero(receipt.id || receipt.contractId),
1388
- to: hexOrZero(receipt.toAddress || receipt?.to),
1323
+ from: hexOrZero(receipt.contract?.id),
1324
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1389
1325
  amount: (0, import_math4.bn)(receipt.amount),
1390
1326
  assetId: hexOrZero(receipt.assetId),
1391
1327
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1396,8 +1332,8 @@ function assembleReceiptByType(receipt) {
1396
1332
  case "TRANSFER_OUT" /* TransferOut */: {
1397
1333
  const transferOutReceipt = {
1398
1334
  type: import_transactions3.ReceiptType.TransferOut,
1399
- from: hexOrZero(receipt.id || receipt.contractId),
1400
- to: hexOrZero(receipt.toAddress || receipt.to),
1335
+ from: hexOrZero(receipt.contract?.id),
1336
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1401
1337
  amount: (0, import_math4.bn)(receipt.amount),
1402
1338
  assetId: hexOrZero(receipt.assetId),
1403
1339
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1440,7 +1376,7 @@ function assembleReceiptByType(receipt) {
1440
1376
  return receiptMessageOut;
1441
1377
  }
1442
1378
  case "MINT" /* Mint */: {
1443
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1379
+ const contractId = hexOrZero(receipt.contract?.id);
1444
1380
  const subId = hexOrZero(receipt.subId);
1445
1381
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1446
1382
  const mintReceipt = {
@@ -1455,7 +1391,7 @@ function assembleReceiptByType(receipt) {
1455
1391
  return mintReceipt;
1456
1392
  }
1457
1393
  case "BURN" /* Burn */: {
1458
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1394
+ const contractId = hexOrZero(receipt.contract?.id);
1459
1395
  const subId = hexOrZero(receipt.subId);
1460
1396
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1461
1397
  const burnReceipt = {
@@ -1481,6 +1417,7 @@ var import_errors6 = require("@fuel-ts/errors");
1481
1417
  var import_math5 = require("@fuel-ts/math");
1482
1418
  var import_transactions4 = require("@fuel-ts/transactions");
1483
1419
  var import_utils6 = require("@fuel-ts/utils");
1420
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1484
1421
  var getGasUsedFromReceipts = (receipts) => {
1485
1422
  const scriptResult = receipts.filter(
1486
1423
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1501,28 +1438,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1501
1438
  }
1502
1439
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1503
1440
  const witnessCache = [];
1504
- const chargeableInputs = inputs.filter((input) => {
1505
- const isCoinOrMessage = "owner" in input || "sender" in input;
1506
- if (isCoinOrMessage) {
1507
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1508
- return true;
1509
- }
1510
- if (!witnessCache.includes(input.witnessIndex)) {
1511
- witnessCache.push(input.witnessIndex);
1512
- return true;
1513
- }
1514
- }
1515
- return false;
1516
- });
1517
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1518
- const totalGas = chargeableInputs.reduce((total, input) => {
1441
+ const totalGas = inputs.reduce((total, input) => {
1519
1442
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1520
1443
  return total.add(
1521
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1444
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1522
1445
  );
1523
1446
  }
1524
- return total.add(gasCosts.ecr1);
1525
- }, (0, import_math5.bn)(0));
1447
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1448
+ witnessCache.push(input.witnessIndex);
1449
+ return total.add(gasCosts.ecr1);
1450
+ }
1451
+ return total;
1452
+ }, (0, import_math5.bn)());
1526
1453
  return totalGas;
1527
1454
  }
1528
1455
  function getMinGas(params) {
@@ -1534,20 +1461,12 @@ function getMinGas(params) {
1534
1461
  return minGas;
1535
1462
  }
1536
1463
  function getMaxGas(params) {
1537
- const {
1538
- gasPerByte,
1539
- witnessesLength,
1540
- witnessLimit,
1541
- minGas,
1542
- gasLimit = (0, import_math5.bn)(0),
1543
- maxGasPerTx
1544
- } = params;
1464
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1545
1465
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1546
1466
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1547
1467
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1548
1468
  }
1549
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1550
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1469
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1551
1470
  }
1552
1471
  function calculateMetadataGasForTxCreate({
1553
1472
  gasCosts,
@@ -1569,10 +1488,6 @@ function calculateMetadataGasForTxScript({
1569
1488
  }) {
1570
1489
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1571
1490
  }
1572
- var calculateGasFee = (params) => {
1573
- const { gas, gasPrice, priceFactor, tip } = params;
1574
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1575
- };
1576
1491
 
1577
1492
  // src/providers/utils/json.ts
1578
1493
  var import_utils7 = require("@fuel-ts/utils");
@@ -1709,7 +1624,7 @@ var witnessify = (value) => {
1709
1624
  // src/providers/transaction-request/transaction-request.ts
1710
1625
  var BaseTransactionRequest = class {
1711
1626
  /** Gas price for transaction */
1712
- tip;
1627
+ gasPrice;
1713
1628
  /** Block until which tx cannot be included */
1714
1629
  maturity;
1715
1630
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1728,7 +1643,7 @@ var BaseTransactionRequest = class {
1728
1643
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1729
1644
  */
1730
1645
  constructor({
1731
- tip,
1646
+ gasPrice,
1732
1647
  maturity,
1733
1648
  maxFee,
1734
1649
  witnessLimit,
@@ -1736,7 +1651,7 @@ var BaseTransactionRequest = class {
1736
1651
  outputs,
1737
1652
  witnesses
1738
1653
  } = {}) {
1739
- this.tip = (0, import_math7.bn)(tip);
1654
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1740
1655
  this.maturity = maturity ?? 0;
1741
1656
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1742
1657
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1747,9 +1662,9 @@ var BaseTransactionRequest = class {
1747
1662
  static getPolicyMeta(req) {
1748
1663
  let policyTypes = 0;
1749
1664
  const policies = [];
1750
- if (req.tip) {
1751
- policyTypes += import_transactions6.PolicyType.Tip;
1752
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1665
+ if (req.gasPrice) {
1666
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1667
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1753
1668
  }
1754
1669
  if (req.witnessLimit) {
1755
1670
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -1936,10 +1851,10 @@ var BaseTransactionRequest = class {
1936
1851
  * @param predicate - Predicate bytes.
1937
1852
  * @param predicateData - Predicate data bytes.
1938
1853
  */
1939
- addCoinInput(coin) {
1854
+ addCoinInput(coin, predicate) {
1940
1855
  const { assetId, owner, amount } = coin;
1941
1856
  let witnessIndex;
1942
- if (coin.predicate) {
1857
+ if (predicate) {
1943
1858
  witnessIndex = 0;
1944
1859
  } else {
1945
1860
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1954,7 +1869,8 @@ var BaseTransactionRequest = class {
1954
1869
  amount,
1955
1870
  assetId,
1956
1871
  txPointer: "0x00000000000000000000000000000000",
1957
- witnessIndex
1872
+ witnessIndex,
1873
+ predicate: predicate?.bytes
1958
1874
  };
1959
1875
  this.pushInput(input);
1960
1876
  this.addChangeOutput(owner, assetId);
@@ -1967,11 +1883,11 @@ var BaseTransactionRequest = class {
1967
1883
  * @param predicate - Predicate bytes.
1968
1884
  * @param predicateData - Predicate data bytes.
1969
1885
  */
1970
- addMessageInput(message) {
1886
+ addMessageInput(message, predicate) {
1971
1887
  const { recipient, sender, amount } = message;
1972
1888
  const assetId = import_configs7.BaseAssetId;
1973
1889
  let witnessIndex;
1974
- if (message.predicate) {
1890
+ if (predicate) {
1975
1891
  witnessIndex = 0;
1976
1892
  } else {
1977
1893
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1985,7 +1901,8 @@ var BaseTransactionRequest = class {
1985
1901
  sender: sender.toB256(),
1986
1902
  recipient: recipient.toB256(),
1987
1903
  amount,
1988
- witnessIndex
1904
+ witnessIndex,
1905
+ predicate: predicate?.bytes
1989
1906
  };
1990
1907
  this.pushInput(input);
1991
1908
  this.addChangeOutput(recipient, assetId);
@@ -2016,6 +1933,32 @@ var BaseTransactionRequest = class {
2016
1933
  resources.forEach((resource) => this.addResource(resource));
2017
1934
  return this;
2018
1935
  }
1936
+ /**
1937
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1938
+ * outputs from the related assetIds.
1939
+ *
1940
+ * @param resources - The resources to add.
1941
+ * @returns This transaction.
1942
+ */
1943
+ addPredicateResource(resource, predicate) {
1944
+ if (isCoin(resource)) {
1945
+ this.addCoinInput(resource, predicate);
1946
+ } else {
1947
+ this.addMessageInput(resource, predicate);
1948
+ }
1949
+ return this;
1950
+ }
1951
+ /**
1952
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
1953
+ * from the related assetIds.
1954
+ *
1955
+ * @param resources - The resources to add.
1956
+ * @returns This transaction.
1957
+ */
1958
+ addPredicateResources(resources, predicate) {
1959
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1960
+ return this;
1961
+ }
2019
1962
  /**
2020
1963
  * Adds a coin output to the transaction.
2021
1964
  *
@@ -2095,7 +2038,7 @@ var BaseTransactionRequest = class {
2095
2038
  }
2096
2039
  calculateMaxGas(chainInfo, minGas) {
2097
2040
  const { consensusParameters } = chainInfo;
2098
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2041
+ const { gasPerByte } = consensusParameters;
2099
2042
  const witnessesLength = this.toTransaction().witnesses.reduce(
2100
2043
  (acc, wit) => acc + wit.dataLength,
2101
2044
  0
@@ -2104,8 +2047,7 @@ var BaseTransactionRequest = class {
2104
2047
  gasPerByte,
2105
2048
  minGas,
2106
2049
  witnessesLength,
2107
- witnessLimit: this.witnessLimit,
2108
- maxGasPerTx
2050
+ witnessLimit: this.witnessLimit
2109
2051
  });
2110
2052
  }
2111
2053
  /**
@@ -2123,20 +2065,17 @@ var BaseTransactionRequest = class {
2123
2065
  });
2124
2066
  const updateAssetInput = (assetId, quantity) => {
2125
2067
  const assetInput = findAssetInput(assetId);
2126
- let usedQuantity = quantity;
2127
- if (assetId === import_configs7.BaseAssetId) {
2128
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2129
- }
2130
2068
  if (assetInput && "assetId" in assetInput) {
2131
2069
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2132
- assetInput.amount = usedQuantity;
2070
+ assetInput.amount = quantity;
2133
2071
  } else {
2134
2072
  this.addResources([
2135
2073
  {
2136
2074
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2137
- amount: usedQuantity,
2075
+ amount: quantity,
2138
2076
  assetId,
2139
2077
  owner: resourcesOwner || import_address.Address.fromRandom(),
2078
+ maturity: 0,
2140
2079
  blockCreated: (0, import_math7.bn)(1),
2141
2080
  txCreatedIdx: (0, import_math7.bn)(1)
2142
2081
  }
@@ -2168,7 +2107,7 @@ var BaseTransactionRequest = class {
2168
2107
  toJSON() {
2169
2108
  return normalizeJSON(this);
2170
2109
  }
2171
- updatePredicateGasUsed(inputs) {
2110
+ updatePredicateInputs(inputs) {
2172
2111
  this.inputs.forEach((i) => {
2173
2112
  let correspondingInput;
2174
2113
  switch (i.type) {
@@ -2190,15 +2129,6 @@ var BaseTransactionRequest = class {
2190
2129
  }
2191
2130
  });
2192
2131
  }
2193
- shiftPredicateData() {
2194
- this.inputs.forEach((input) => {
2195
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2196
- input.predicateData = input.paddPredicateData(
2197
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2198
- );
2199
- }
2200
- });
2201
- }
2202
2132
  };
2203
2133
 
2204
2134
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2345,8 +2275,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2345
2275
  return {
2346
2276
  type: import_transactions8.TransactionType.Create,
2347
2277
  ...baseTransaction,
2278
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2348
2279
  bytecodeWitnessIndex,
2349
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2280
+ storageSlotsCount: storageSlots.length,
2350
2281
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2351
2282
  storageSlots
2352
2283
  };
@@ -2469,8 +2400,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2469
2400
  type: import_transactions9.TransactionType.Script,
2470
2401
  scriptGasLimit: this.gasLimit,
2471
2402
  ...super.getBaseTransaction(),
2472
- scriptLength: (0, import_math10.bn)(script.length),
2473
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2403
+ scriptLength: script.length,
2404
+ scriptDataLength: scriptData.length,
2474
2405
  receiptsRoot: import_configs10.ZeroBytes32,
2475
2406
  script: (0, import_utils15.hexlify)(script),
2476
2407
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2534,7 +2465,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2534
2465
  }
2535
2466
  calculateMaxGas(chainInfo, minGas) {
2536
2467
  const { consensusParameters } = chainInfo;
2537
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2468
+ const { gasPerByte } = consensusParameters;
2538
2469
  const witnessesLength = this.toTransaction().witnesses.reduce(
2539
2470
  (acc, wit) => acc + wit.dataLength,
2540
2471
  0
@@ -2544,8 +2475,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2544
2475
  minGas,
2545
2476
  witnessesLength,
2546
2477
  witnessLimit: this.witnessLimit,
2547
- gasLimit: this.gasLimit,
2548
- maxGasPerTx
2478
+ gasLimit: this.gasLimit
2549
2479
  });
2550
2480
  }
2551
2481
  /**
@@ -2620,32 +2550,15 @@ var transactionRequestify = (obj) => {
2620
2550
  }
2621
2551
  }
2622
2552
  };
2623
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2624
- (acc, input) => {
2625
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2626
- acc.utxos.push(input.id);
2627
- }
2628
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2629
- acc.messages.push(input.nonce);
2630
- }
2631
- return acc;
2632
- },
2633
- {
2634
- utxos: [],
2635
- messages: []
2636
- }
2637
- );
2638
2553
 
2639
2554
  // src/providers/transaction-response/transaction-response.ts
2640
2555
  var import_errors13 = require("@fuel-ts/errors");
2641
- var import_math15 = require("@fuel-ts/math");
2642
- var import_transactions18 = require("@fuel-ts/transactions");
2643
- var import_utils20 = require("@fuel-ts/utils");
2556
+ var import_math14 = require("@fuel-ts/math");
2557
+ var import_transactions17 = require("@fuel-ts/transactions");
2558
+ var import_utils21 = require("@fuel-ts/utils");
2644
2559
 
2645
2560
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2646
- var import_math14 = require("@fuel-ts/math");
2647
- var import_transactions16 = require("@fuel-ts/transactions");
2648
- var import_utils18 = require("@fuel-ts/utils");
2561
+ var import_utils19 = require("@fuel-ts/utils");
2649
2562
 
2650
2563
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2651
2564
  var import_math11 = require("@fuel-ts/math");
@@ -2653,10 +2566,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2653
2566
  var import_utils16 = require("@fuel-ts/utils");
2654
2567
  var calculateTransactionFee = (params) => {
2655
2568
  const {
2656
- gasPrice,
2569
+ gasUsed,
2657
2570
  rawPayload,
2658
- tip,
2659
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2571
+ consensusParameters: { gasCosts, feeParams }
2660
2572
  } = params;
2661
2573
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2662
2574
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2666,7 +2578,8 @@ var calculateTransactionFee = (params) => {
2666
2578
  return {
2667
2579
  fee: (0, import_math11.bn)(0),
2668
2580
  minFee: (0, import_math11.bn)(0),
2669
- maxFee: (0, import_math11.bn)(0)
2581
+ maxFee: (0, import_math11.bn)(0),
2582
+ feeFromGasUsed: (0, import_math11.bn)(0)
2670
2583
  };
2671
2584
  }
2672
2585
  const { type, witnesses, inputs, policies } = transaction;
@@ -2698,6 +2611,7 @@ var calculateTransactionFee = (params) => {
2698
2611
  metadataGas,
2699
2612
  txBytesSize: transactionBytes.length
2700
2613
  });
2614
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2701
2615
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2702
2616
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2703
2617
  const maxGas = getMaxGas({
@@ -2705,25 +2619,17 @@ var calculateTransactionFee = (params) => {
2705
2619
  minGas,
2706
2620
  witnessesLength,
2707
2621
  gasLimit,
2708
- witnessLimit,
2709
- maxGasPerTx
2710
- });
2711
- const minFee = calculateGasFee({
2712
- gasPrice,
2713
- gas: minGas,
2714
- priceFactor: gasPriceFactor,
2715
- tip
2716
- });
2717
- const maxFee = calculateGasFee({
2718
- gasPrice,
2719
- gas: maxGas,
2720
- priceFactor: gasPriceFactor,
2721
- tip
2622
+ witnessLimit
2722
2623
  });
2624
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2625
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2626
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2627
+ const fee = minFee.add(feeFromGasUsed);
2723
2628
  return {
2629
+ fee,
2724
2630
  minFee,
2725
2631
  maxFee,
2726
- fee: maxFee
2632
+ feeFromGasUsed
2727
2633
  };
2728
2634
  };
2729
2635
 
@@ -3290,12 +3196,10 @@ function assembleTransactionSummary(params) {
3290
3196
  gqlTransactionStatus,
3291
3197
  abiMap = {},
3292
3198
  maxInputs,
3293
- gasCosts,
3294
- maxGasPerTx,
3295
- gasPrice
3199
+ gasCosts
3296
3200
  } = params;
3297
3201
  const gasUsed = getGasUsedFromReceipts(receipts);
3298
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3202
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3299
3203
  const operations = getOperations({
3300
3204
  transactionType: transaction.type,
3301
3205
  inputs: transaction.inputs || [],
@@ -3306,14 +3210,11 @@ function assembleTransactionSummary(params) {
3306
3210
  maxInputs
3307
3211
  });
3308
3212
  const typeName = getTransactionTypeName(transaction.type);
3309
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3310
3213
  const { fee } = calculateTransactionFee({
3311
- gasPrice,
3214
+ gasUsed,
3312
3215
  rawPayload,
3313
- tip,
3314
3216
  consensusParameters: {
3315
3217
  gasCosts,
3316
- maxGasPerTx,
3317
3218
  feeParams: {
3318
3219
  gasPerByte,
3319
3220
  gasPriceFactor
@@ -3325,7 +3226,7 @@ function assembleTransactionSummary(params) {
3325
3226
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3326
3227
  let date;
3327
3228
  if (time) {
3328
- date = import_utils18.DateTime.fromTai64(time);
3229
+ date = import_utils19.DateTime.fromTai64(time);
3329
3230
  }
3330
3231
  const transactionSummary = {
3331
3232
  id,
@@ -3353,12 +3254,12 @@ function assembleTransactionSummary(params) {
3353
3254
 
3354
3255
  // src/providers/transaction-response/getDecodedLogs.ts
3355
3256
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3356
- var import_transactions17 = require("@fuel-ts/transactions");
3257
+ var import_transactions16 = require("@fuel-ts/transactions");
3357
3258
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3358
3259
  return receipts.reduce((logs, receipt) => {
3359
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3260
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3360
3261
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3361
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3262
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3362
3263
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3363
3264
  logs.push(decodedLog);
3364
3265
  }
@@ -3373,7 +3274,7 @@ var TransactionResponse = class {
3373
3274
  /** Current provider */
3374
3275
  provider;
3375
3276
  /** Gas used on the transaction */
3376
- gasUsed = (0, import_math15.bn)(0);
3277
+ gasUsed = (0, import_math14.bn)(0);
3377
3278
  /** The graphql Transaction with receipts object. */
3378
3279
  gqlTransaction;
3379
3280
  abis;
@@ -3431,8 +3332,8 @@ var TransactionResponse = class {
3431
3332
  * @returns The decoded transaction.
3432
3333
  */
3433
3334
  decodeTransaction(transactionWithReceipts) {
3434
- return new import_transactions18.TransactionCoder().decode(
3435
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3335
+ return new import_transactions17.TransactionCoder().decode(
3336
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3436
3337
  0
3437
3338
  )?.[0];
3438
3339
  }
@@ -3451,27 +3352,20 @@ var TransactionResponse = class {
3451
3352
  const decodedTransaction = this.decodeTransaction(
3452
3353
  transaction
3453
3354
  );
3454
- let txReceipts = [];
3455
- if (transaction?.status && "receipts" in transaction.status) {
3456
- txReceipts = transaction.status.receipts;
3457
- }
3458
- const receipts = txReceipts.map(processGqlReceipt) || [];
3459
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3460
- const gasPrice = await this.provider.getLatestGasPrice();
3355
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3356
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3461
3357
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3462
3358
  const transactionSummary = assembleTransactionSummary({
3463
3359
  id: this.id,
3464
3360
  receipts,
3465
3361
  transaction: decodedTransaction,
3466
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3362
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3467
3363
  gqlTransactionStatus: transaction.status,
3468
3364
  gasPerByte,
3469
3365
  gasPriceFactor,
3470
3366
  abiMap: contractsAbiMap,
3471
3367
  maxInputs,
3472
- gasCosts,
3473
- maxGasPerTx,
3474
- gasPrice
3368
+ gasCosts
3475
3369
  });
3476
3370
  return transactionSummary;
3477
3371
  }
@@ -3598,29 +3492,29 @@ var processGqlChain = (chain) => {
3598
3492
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3599
3493
  return {
3600
3494
  name,
3601
- baseChainHeight: (0, import_math16.bn)(daHeight),
3495
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3602
3496
  consensusParameters: {
3603
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3604
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3605
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3606
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3607
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3608
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3609
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3610
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3611
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3612
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3613
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3614
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3615
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3616
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3617
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3497
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3498
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3499
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3500
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3501
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3502
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3503
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3504
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3505
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3506
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3507
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3508
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3509
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3510
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3511
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3618
3512
  gasCosts
3619
3513
  },
3620
3514
  gasCosts,
3621
3515
  latestBlock: {
3622
3516
  id: latestBlock.id,
3623
- height: (0, import_math16.bn)(latestBlock.height),
3517
+ height: (0, import_math15.bn)(latestBlock.header.height),
3624
3518
  time: latestBlock.header.time,
3625
3519
  transactions: latestBlock.transactions.map((i) => ({
3626
3520
  id: i.id
@@ -3714,8 +3608,10 @@ var _Provider = class {
3714
3608
  * Returns some helpful parameters related to gas fees.
3715
3609
  */
3716
3610
  getGasConfig() {
3611
+ const { minGasPrice } = this.getNode();
3717
3612
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3718
3613
  return {
3614
+ minGasPrice,
3719
3615
  maxGasPerTx,
3720
3616
  maxGasPerPredicate,
3721
3617
  gasPriceFactor,
@@ -3813,7 +3709,7 @@ var _Provider = class {
3813
3709
  */
3814
3710
  async getBlockNumber() {
3815
3711
  const { chain } = await this.operations.getChain();
3816
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3712
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3817
3713
  }
3818
3714
  /**
3819
3715
  * Returns the chain information.
@@ -3823,11 +3719,13 @@ var _Provider = class {
3823
3719
  async fetchNode() {
3824
3720
  const { nodeInfo } = await this.operations.getNodeInfo();
3825
3721
  const processedNodeInfo = {
3826
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3827
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3722
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3723
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3724
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3828
3725
  nodeVersion: nodeInfo.nodeVersion,
3829
3726
  utxoValidation: nodeInfo.utxoValidation,
3830
- vmBacktrace: nodeInfo.vmBacktrace
3727
+ vmBacktrace: nodeInfo.vmBacktrace,
3728
+ peers: nodeInfo.peers
3831
3729
  };
3832
3730
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3833
3731
  return processedNodeInfo;
@@ -3869,9 +3767,9 @@ var _Provider = class {
3869
3767
  if (estimateTxDependencies) {
3870
3768
  await this.estimateTxDependencies(transactionRequest);
3871
3769
  }
3872
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3770
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3873
3771
  let abis;
3874
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3772
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3875
3773
  abis = transactionRequest.abis;
3876
3774
  }
3877
3775
  if (awaitExecution) {
@@ -3912,14 +3810,15 @@ var _Provider = class {
3912
3810
  if (estimateTxDependencies) {
3913
3811
  return this.estimateTxDependencies(transactionRequest);
3914
3812
  }
3915
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3916
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3917
- encodedTransactions: encodedTransaction,
3813
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3814
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3815
+ encodedTransaction,
3918
3816
  utxoValidation: utxoValidation || false
3919
3817
  });
3920
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3921
- const receipts = rawReceipts.map(processGqlReceipt);
3922
- return { receipts, dryrunStatus: status };
3818
+ const receipts = gqlReceipts.map(processGqlReceipt);
3819
+ return {
3820
+ receipts
3821
+ };
3923
3822
  }
3924
3823
  /**
3925
3824
  * Verifies whether enough gas is available to complete transaction.
@@ -3930,13 +3829,13 @@ var _Provider = class {
3930
3829
  async estimatePredicates(transactionRequest) {
3931
3830
  const shouldEstimatePredicates = Boolean(
3932
3831
  transactionRequest.inputs.find(
3933
- (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math16.BN(input.predicateGasUsed).isZero()
3832
+ (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()
3934
3833
  )
3935
3834
  );
3936
3835
  if (!shouldEstimatePredicates) {
3937
3836
  return transactionRequest;
3938
3837
  }
3939
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3838
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3940
3839
  const response = await this.operations.estimatePredicates({
3941
3840
  encodedTransaction
3942
3841
  });
@@ -3945,7 +3844,7 @@ var _Provider = class {
3945
3844
  } = response;
3946
3845
  if (inputs) {
3947
3846
  inputs.forEach((input, index) => {
3948
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
3847
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3949
3848
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3950
3849
  }
3951
3850
  });
@@ -3958,31 +3857,31 @@ var _Provider = class {
3958
3857
  * If there are missing variable outputs,
3959
3858
  * `addVariableOutputs` is called on the transaction.
3960
3859
  *
3860
+ * @privateRemarks
3861
+ * TODO: Investigate support for missing contract IDs
3862
+ * TODO: Add support for missing output messages
3961
3863
  *
3962
3864
  * @param transactionRequest - The transaction request object.
3963
3865
  * @returns A promise.
3964
3866
  */
3965
3867
  async estimateTxDependencies(transactionRequest) {
3966
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
3868
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3967
3869
  return {
3968
3870
  receipts: [],
3969
3871
  outputVariables: 0,
3970
3872
  missingContractIds: []
3971
3873
  };
3972
3874
  }
3875
+ await this.estimatePredicates(transactionRequest);
3973
3876
  let receipts = [];
3974
3877
  const missingContractIds = [];
3975
3878
  let outputVariables = 0;
3976
- let dryrunStatus;
3977
3879
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3978
- const {
3979
- dryRun: [{ receipts: rawReceipts, status }]
3980
- } = await this.operations.dryRun({
3981
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
3880
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3881
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
3982
3882
  utxoValidation: false
3983
3883
  });
3984
- receipts = rawReceipts.map(processGqlReceipt);
3985
- dryrunStatus = status;
3884
+ receipts = gqlReceipts.map(processGqlReceipt);
3986
3885
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3987
3886
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3988
3887
  if (hasMissingOutputs) {
@@ -3992,10 +3891,6 @@ var _Provider = class {
3992
3891
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
3993
3892
  missingContractIds.push(contractId);
3994
3893
  });
3995
- const { maxFee } = await this.estimateTxGasAndFee({
3996
- transactionRequest
3997
- });
3998
- transactionRequest.maxFee = maxFee;
3999
3894
  } else {
4000
3895
  break;
4001
3896
  }
@@ -4003,139 +3898,37 @@ var _Provider = class {
4003
3898
  return {
4004
3899
  receipts,
4005
3900
  outputVariables,
4006
- missingContractIds,
4007
- dryrunStatus
3901
+ missingContractIds
4008
3902
  };
4009
3903
  }
4010
- /**
4011
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4012
- *
4013
- * Transactions are dry run in batches. After each dry run, transactions requiring
4014
- * further modifications are identified. The method iteratively updates these transactions
4015
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4016
- *
4017
- * @param transactionRequests - Array of transaction request objects.
4018
- * @returns A promise that resolves to an array of results for each transaction.
4019
- */
4020
- async estimateMultipleTxDependencies(transactionRequests) {
4021
- const results = transactionRequests.map(() => ({
4022
- receipts: [],
4023
- outputVariables: 0,
4024
- missingContractIds: [],
4025
- dryrunStatus: void 0
4026
- }));
4027
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4028
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4029
- allRequests.forEach((req, index) => {
4030
- if (req.type === import_transactions19.TransactionType.Script) {
4031
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4032
- }
4033
- });
4034
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4035
- let attempt = 0;
4036
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4037
- const encodedTransactions = transactionsToProcess.map(
4038
- (index) => serializedTransactionsMap.get(index)
4039
- );
4040
- const dryRunResults = await this.operations.dryRun({
4041
- encodedTransactions,
4042
- utxoValidation: false
4043
- });
4044
- const nextRoundTransactions = [];
4045
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4046
- const currentResultIndex = transactionsToProcess[i];
4047
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4048
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4049
- results[currentResultIndex].dryrunStatus = status;
4050
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4051
- results[currentResultIndex].receipts
4052
- );
4053
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4054
- const requestToProcess = allRequests[currentResultIndex];
4055
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4056
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4057
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4058
- missingOutputContractIds.forEach(({ contractId }) => {
4059
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4060
- results[currentResultIndex].missingContractIds.push(contractId);
4061
- });
4062
- const { maxFee } = await this.estimateTxGasAndFee({
4063
- transactionRequest: requestToProcess
4064
- });
4065
- requestToProcess.maxFee = maxFee;
4066
- serializedTransactionsMap.set(
4067
- currentResultIndex,
4068
- (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4069
- );
4070
- nextRoundTransactions.push(currentResultIndex);
4071
- allRequests[currentResultIndex] = requestToProcess;
4072
- }
4073
- }
4074
- transactionsToProcess = nextRoundTransactions;
4075
- attempt += 1;
4076
- }
4077
- return results;
4078
- }
4079
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4080
- if (estimateTxDependencies) {
4081
- return this.estimateMultipleTxDependencies(transactionRequests);
4082
- }
4083
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4084
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4085
- encodedTransactions,
4086
- utxoValidation: utxoValidation || false
4087
- });
4088
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4089
- const receipts = rawReceipts.map(processGqlReceipt);
4090
- return { receipts, dryrunStatus: status };
4091
- });
4092
- return results;
4093
- }
4094
3904
  /**
4095
3905
  * Estimates the transaction gas and fee based on the provided transaction request.
4096
3906
  * @param transactionRequest - The transaction request object.
4097
3907
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4098
3908
  */
4099
- async estimateTxGasAndFee(params) {
3909
+ estimateTxGasAndFee(params) {
4100
3910
  const { transactionRequest } = params;
4101
- let { gasPrice } = params;
3911
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4102
3912
  const chainInfo = this.getChain();
4103
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3913
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3914
+ transactionRequest.gasPrice = gasPrice;
4104
3915
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4105
- if (!gasPrice) {
4106
- gasPrice = await this.estimateGasPrice(10);
4107
- }
4108
- const minFee = calculateGasFee({
4109
- gasPrice: (0, import_math16.bn)(gasPrice),
4110
- gas: minGas,
4111
- priceFactor: gasPriceFactor,
4112
- tip: transactionRequest.tip
4113
- }).add(1);
4114
- let gasLimit = (0, import_math16.bn)(0);
4115
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4116
- gasLimit = transactionRequest.gasLimit;
3916
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3917
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4117
3918
  if (transactionRequest.gasLimit.eq(0)) {
4118
3919
  transactionRequest.gasLimit = minGas;
4119
3920
  transactionRequest.gasLimit = maxGasPerTx.sub(
4120
3921
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4121
3922
  );
4122
- gasLimit = transactionRequest.gasLimit;
4123
3923
  }
4124
3924
  }
4125
3925
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4126
- const maxFee = calculateGasFee({
4127
- gasPrice: (0, import_math16.bn)(gasPrice),
4128
- gas: maxGas,
4129
- priceFactor: gasPriceFactor,
4130
- tip: transactionRequest.tip
4131
- }).add(1);
3926
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4132
3927
  return {
4133
3928
  minGas,
4134
3929
  minFee,
4135
3930
  maxGas,
4136
- maxFee,
4137
- gasPrice,
4138
- gasLimit
3931
+ maxFee
4139
3932
  };
4140
3933
  }
4141
3934
  /**
@@ -4153,17 +3946,15 @@ var _Provider = class {
4153
3946
  if (estimateTxDependencies) {
4154
3947
  return this.estimateTxDependencies(transactionRequest);
4155
3948
  }
4156
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4157
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4158
- encodedTransactions,
3949
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3950
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3951
+ encodedTransaction,
4159
3952
  utxoValidation: true
4160
3953
  });
4161
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4162
- const { id, receipts, status } = dryRunStatus;
4163
- const processedReceipts = receipts.map(processGqlReceipt);
4164
- return { id, receipts: processedReceipts, status };
4165
- });
4166
- return { receipts: callResult[0].receipts };
3954
+ const receipts = gqlReceipts.map(processGqlReceipt);
3955
+ return {
3956
+ receipts
3957
+ };
4167
3958
  }
4168
3959
  /**
4169
3960
  * Returns a transaction cost to enable user
@@ -4180,79 +3971,77 @@ var _Provider = class {
4180
3971
  * @param tolerance - The tolerance to add on top of the gasUsed.
4181
3972
  * @returns A promise that resolves to the transaction cost object.
4182
3973
  */
4183
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3974
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3975
+ estimateTxDependencies = true,
3976
+ estimatePredicates = true,
3977
+ resourcesOwner,
3978
+ signatureCallback
3979
+ } = {}) {
4184
3980
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4185
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
3981
+ const { minGasPrice } = this.getGasConfig();
3982
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3983
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4186
3984
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4187
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3985
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4188
3986
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4189
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4190
3987
  if (isScriptTransaction) {
4191
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
3988
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4192
3989
  }
4193
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4194
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3990
+ if (estimatePredicates) {
3991
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3992
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3993
+ }
3994
+ await this.estimatePredicates(txRequestClone);
4195
3995
  }
4196
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4197
- let addedSignatures = 0;
4198
3996
  if (signatureCallback && isScriptTransaction) {
4199
- const lengthBefore = signedRequest.witnesses.length;
4200
- await signatureCallback(signedRequest);
4201
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
3997
+ await signatureCallback(txRequestClone);
4202
3998
  }
4203
- await this.estimatePredicates(signedRequest);
4204
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4205
- transactionRequest: signedRequest
3999
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4000
+ transactionRequest: txRequestClone
4206
4001
  });
4207
4002
  let receipts = [];
4208
4003
  let missingContractIds = [];
4209
4004
  let outputVariables = 0;
4210
- let gasUsed = (0, import_math16.bn)(0);
4211
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4212
- txRequestClone.maxFee = maxFee;
4213
- if (isScriptTransaction) {
4214
- txRequestClone.gasLimit = gasLimit;
4215
- if (signatureCallback) {
4216
- await signatureCallback(txRequestClone);
4217
- }
4005
+ let gasUsed = (0, import_math15.bn)(0);
4006
+ if (isScriptTransaction && estimateTxDependencies) {
4007
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4218
4008
  const result = await this.estimateTxDependencies(txRequestClone);
4219
4009
  receipts = result.receipts;
4220
4010
  outputVariables = result.outputVariables;
4221
4011
  missingContractIds = result.missingContractIds;
4222
4012
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4223
4013
  txRequestClone.gasLimit = gasUsed;
4224
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4225
- transactionRequest: txRequestClone,
4226
- gasPrice
4014
+ txRequestClone.gasPrice = setGasPrice;
4015
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4016
+ transactionRequest: txRequestClone
4227
4017
  }));
4228
4018
  }
4229
4019
  return {
4230
4020
  requiredQuantities: allQuantities,
4231
4021
  receipts,
4232
4022
  gasUsed,
4233
- gasPrice,
4023
+ minGasPrice,
4024
+ gasPrice: setGasPrice,
4234
4025
  minGas,
4235
4026
  maxGas,
4236
4027
  minFee,
4237
4028
  maxFee,
4029
+ estimatedInputs: txRequestClone.inputs,
4238
4030
  outputVariables,
4239
- missingContractIds,
4240
- addedSignatures,
4241
- estimatedPredicates: txRequestClone.inputs
4031
+ missingContractIds
4242
4032
  };
4243
4033
  }
4244
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4034
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4245
4035
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4246
4036
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4247
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4248
- quantitiesToContract
4249
- });
4037
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4250
4038
  transactionRequest.addResources(
4251
4039
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4252
4040
  );
4253
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4254
- quantitiesToContract
4255
- });
4041
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4042
+ transactionRequest,
4043
+ forwardingQuantities
4044
+ );
4256
4045
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4257
4046
  return {
4258
4047
  resources,
@@ -4268,16 +4057,17 @@ var _Provider = class {
4268
4057
  const result = await this.operations.getCoins({
4269
4058
  first: 10,
4270
4059
  ...paginationArgs,
4271
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4060
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4272
4061
  });
4273
4062
  const coins = result.coins.edges.map((edge) => edge.node);
4274
4063
  return coins.map((coin) => ({
4275
4064
  id: coin.utxoId,
4276
4065
  assetId: coin.assetId,
4277
- amount: (0, import_math16.bn)(coin.amount),
4066
+ amount: (0, import_math15.bn)(coin.amount),
4278
4067
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4279
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4280
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4068
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4069
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4070
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4281
4071
  }));
4282
4072
  }
4283
4073
  /**
@@ -4291,19 +4081,19 @@ var _Provider = class {
4291
4081
  async getResourcesToSpend(owner, quantities, excludedIds) {
4292
4082
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4293
4083
  const excludeInput = {
4294
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4295
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4084
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4085
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4296
4086
  };
4297
4087
  if (this.cache) {
4298
4088
  const uniqueUtxos = new Set(
4299
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4089
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4300
4090
  );
4301
4091
  excludeInput.utxos = Array.from(uniqueUtxos);
4302
4092
  }
4303
4093
  const coinsQuery = {
4304
4094
  owner: ownerAddress.toB256(),
4305
4095
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4306
- assetId: (0, import_utils22.hexlify)(assetId),
4096
+ assetId: (0, import_utils23.hexlify)(assetId),
4307
4097
  amount: amount.toString(10),
4308
4098
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4309
4099
  })),
@@ -4314,9 +4104,9 @@ var _Provider = class {
4314
4104
  switch (coin.__typename) {
4315
4105
  case "MessageCoin":
4316
4106
  return {
4317
- amount: (0, import_math16.bn)(coin.amount),
4107
+ amount: (0, import_math15.bn)(coin.amount),
4318
4108
  assetId: coin.assetId,
4319
- daHeight: (0, import_math16.bn)(coin.daHeight),
4109
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4320
4110
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4321
4111
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4322
4112
  nonce: coin.nonce
@@ -4324,11 +4114,12 @@ var _Provider = class {
4324
4114
  case "Coin":
4325
4115
  return {
4326
4116
  id: coin.utxoId,
4327
- amount: (0, import_math16.bn)(coin.amount),
4117
+ amount: (0, import_math15.bn)(coin.amount),
4328
4118
  assetId: coin.assetId,
4329
4119
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4330
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4331
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4120
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4121
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4122
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4332
4123
  };
4333
4124
  default:
4334
4125
  return null;
@@ -4345,13 +4136,13 @@ var _Provider = class {
4345
4136
  async getBlock(idOrHeight) {
4346
4137
  let variables;
4347
4138
  if (typeof idOrHeight === "number") {
4348
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4139
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4349
4140
  } else if (idOrHeight === "latest") {
4350
4141
  variables = { height: (await this.getBlockNumber()).toString(10) };
4351
4142
  } else if (idOrHeight.length === 66) {
4352
4143
  variables = { blockId: idOrHeight };
4353
4144
  } else {
4354
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4145
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4355
4146
  }
4356
4147
  const { block } = await this.operations.getBlock(variables);
4357
4148
  if (!block) {
@@ -4359,7 +4150,7 @@ var _Provider = class {
4359
4150
  }
4360
4151
  return {
4361
4152
  id: block.id,
4362
- height: (0, import_math16.bn)(block.height),
4153
+ height: (0, import_math15.bn)(block.header.height),
4363
4154
  time: block.header.time,
4364
4155
  transactionIds: block.transactions.map((tx) => tx.id)
4365
4156
  };
@@ -4374,7 +4165,7 @@ var _Provider = class {
4374
4165
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4375
4166
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4376
4167
  id: block.id,
4377
- height: (0, import_math16.bn)(block.height),
4168
+ height: (0, import_math15.bn)(block.header.height),
4378
4169
  time: block.header.time,
4379
4170
  transactionIds: block.transactions.map((tx) => tx.id)
4380
4171
  }));
@@ -4389,7 +4180,7 @@ var _Provider = class {
4389
4180
  async getBlockWithTransactions(idOrHeight) {
4390
4181
  let variables;
4391
4182
  if (typeof idOrHeight === "number") {
4392
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4183
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4393
4184
  } else if (idOrHeight === "latest") {
4394
4185
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4395
4186
  } else {
@@ -4401,11 +4192,11 @@ var _Provider = class {
4401
4192
  }
4402
4193
  return {
4403
4194
  id: block.id,
4404
- height: (0, import_math16.bn)(block.height, 10),
4195
+ height: (0, import_math15.bn)(block.header.height, 10),
4405
4196
  time: block.header.time,
4406
4197
  transactionIds: block.transactions.map((tx) => tx.id),
4407
4198
  transactions: block.transactions.map(
4408
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4199
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4409
4200
  )
4410
4201
  };
4411
4202
  }
@@ -4420,8 +4211,8 @@ var _Provider = class {
4420
4211
  if (!transaction) {
4421
4212
  return null;
4422
4213
  }
4423
- return new import_transactions19.TransactionCoder().decode(
4424
- (0, import_utils22.arrayify)(transaction.rawPayload),
4214
+ return new import_transactions18.TransactionCoder().decode(
4215
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4425
4216
  0
4426
4217
  )?.[0];
4427
4218
  }
@@ -4448,9 +4239,9 @@ var _Provider = class {
4448
4239
  async getContractBalance(contractId, assetId) {
4449
4240
  const { contractBalance } = await this.operations.getContractBalance({
4450
4241
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4451
- asset: (0, import_utils22.hexlify)(assetId)
4242
+ asset: (0, import_utils23.hexlify)(assetId)
4452
4243
  });
4453
- return (0, import_math16.bn)(contractBalance.amount, 10);
4244
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4454
4245
  }
4455
4246
  /**
4456
4247
  * Returns the balance for the given owner for the given asset ID.
@@ -4462,9 +4253,9 @@ var _Provider = class {
4462
4253
  async getBalance(owner, assetId) {
4463
4254
  const { balance } = await this.operations.getBalance({
4464
4255
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4465
- assetId: (0, import_utils22.hexlify)(assetId)
4256
+ assetId: (0, import_utils23.hexlify)(assetId)
4466
4257
  });
4467
- return (0, import_math16.bn)(balance.amount, 10);
4258
+ return (0, import_math15.bn)(balance.amount, 10);
4468
4259
  }
4469
4260
  /**
4470
4261
  * Returns balances for the given owner.
@@ -4482,7 +4273,7 @@ var _Provider = class {
4482
4273
  const balances = result.balances.edges.map((edge) => edge.node);
4483
4274
  return balances.map((balance) => ({
4484
4275
  assetId: balance.assetId,
4485
- amount: (0, import_math16.bn)(balance.amount)
4276
+ amount: (0, import_math15.bn)(balance.amount)
4486
4277
  }));
4487
4278
  }
4488
4279
  /**
@@ -4500,19 +4291,19 @@ var _Provider = class {
4500
4291
  });
4501
4292
  const messages = result.messages.edges.map((edge) => edge.node);
4502
4293
  return messages.map((message) => ({
4503
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4294
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4504
4295
  sender: message.sender,
4505
4296
  recipient: message.recipient,
4506
4297
  nonce: message.nonce,
4507
- amount: (0, import_math16.bn)(message.amount),
4298
+ amount: (0, import_math15.bn)(message.amount),
4508
4299
  data: message.data
4509
4300
  }),
4510
4301
  sender: import_address3.Address.fromAddressOrString(message.sender),
4511
4302
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4512
4303
  nonce: message.nonce,
4513
- amount: (0, import_math16.bn)(message.amount),
4514
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4515
- daHeight: (0, import_math16.bn)(message.daHeight)
4304
+ amount: (0, import_math15.bn)(message.amount),
4305
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4306
+ daHeight: (0, import_math15.bn)(message.daHeight)
4516
4307
  }));
4517
4308
  }
4518
4309
  /**
@@ -4565,60 +4356,44 @@ var _Provider = class {
4565
4356
  } = result.messageProof;
4566
4357
  return {
4567
4358
  messageProof: {
4568
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4359
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4569
4360
  proofSet: messageProof.proofSet
4570
4361
  },
4571
4362
  blockProof: {
4572
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4363
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4573
4364
  proofSet: blockProof.proofSet
4574
4365
  },
4575
4366
  messageBlockHeader: {
4576
4367
  id: messageBlockHeader.id,
4577
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4578
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4368
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4369
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4579
4370
  transactionsRoot: messageBlockHeader.transactionsRoot,
4580
- height: (0, import_math16.bn)(messageBlockHeader.height),
4371
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4581
4372
  prevRoot: messageBlockHeader.prevRoot,
4582
4373
  time: messageBlockHeader.time,
4583
4374
  applicationHash: messageBlockHeader.applicationHash,
4584
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4585
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4586
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4587
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4588
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4375
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4376
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4589
4377
  },
4590
4378
  commitBlockHeader: {
4591
4379
  id: commitBlockHeader.id,
4592
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4593
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4380
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4381
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4594
4382
  transactionsRoot: commitBlockHeader.transactionsRoot,
4595
- height: (0, import_math16.bn)(commitBlockHeader.height),
4383
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4596
4384
  prevRoot: commitBlockHeader.prevRoot,
4597
4385
  time: commitBlockHeader.time,
4598
4386
  applicationHash: commitBlockHeader.applicationHash,
4599
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4600
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4601
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4602
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4603
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4387
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4388
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4604
4389
  },
4605
4390
  sender: import_address3.Address.fromAddressOrString(sender),
4606
4391
  recipient: import_address3.Address.fromAddressOrString(recipient),
4607
4392
  nonce,
4608
- amount: (0, import_math16.bn)(amount),
4393
+ amount: (0, import_math15.bn)(amount),
4609
4394
  data
4610
4395
  };
4611
4396
  }
4612
- async getLatestGasPrice() {
4613
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4614
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4615
- }
4616
- async estimateGasPrice(blockHorizon) {
4617
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4618
- blockHorizon: String(blockHorizon)
4619
- });
4620
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4621
- }
4622
4397
  /**
4623
4398
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4624
4399
  *
@@ -4638,10 +4413,10 @@ var _Provider = class {
4638
4413
  */
4639
4414
  async produceBlocks(amount, startTime) {
4640
4415
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4641
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4642
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4416
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4417
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4643
4418
  });
4644
- return (0, import_math16.bn)(latestBlockHeight);
4419
+ return (0, import_math15.bn)(latestBlockHeight);
4645
4420
  }
4646
4421
  // eslint-disable-next-line @typescript-eslint/require-await
4647
4422
  async getTransactionResponse(transactionId) {
@@ -4655,7 +4430,7 @@ cacheInputs_fn = function(inputs) {
4655
4430
  return;
4656
4431
  }
4657
4432
  inputs.forEach((input) => {
4658
- if (input.type === import_transactions19.InputType.Coin) {
4433
+ if (input.type === import_transactions18.InputType.Coin) {
4659
4434
  this.cache?.set(input.id);
4660
4435
  }
4661
4436
  });
@@ -4665,9 +4440,9 @@ __publicField(Provider, "nodeInfoCache", {});
4665
4440
 
4666
4441
  // src/providers/transaction-summary/get-transaction-summary.ts
4667
4442
  var import_errors15 = require("@fuel-ts/errors");
4668
- var import_math17 = require("@fuel-ts/math");
4669
- var import_transactions20 = require("@fuel-ts/transactions");
4670
- var import_utils25 = require("@fuel-ts/utils");
4443
+ var import_math16 = require("@fuel-ts/math");
4444
+ var import_transactions19 = require("@fuel-ts/transactions");
4445
+ var import_utils26 = require("@fuel-ts/utils");
4671
4446
 
4672
4447
  // src/providers/chains.ts
4673
4448
  var CHAIN_IDS = {
@@ -4716,17 +4491,17 @@ var assets = [
4716
4491
 
4717
4492
  // src/utils/formatTransferToContractScriptData.ts
4718
4493
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4719
- var import_math18 = require("@fuel-ts/math");
4720
- var import_utils26 = require("@fuel-ts/utils");
4494
+ var import_math17 = require("@fuel-ts/math");
4495
+ var import_utils27 = require("@fuel-ts/utils");
4721
4496
  var asm = __toESM(require("@fuels/vm-asm"));
4722
4497
  var formatTransferToContractScriptData = (params) => {
4723
4498
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4724
4499
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4725
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4500
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4726
4501
  const scriptData = Uint8Array.from([
4727
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4502
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4728
4503
  ...encoded,
4729
- ...(0, import_utils26.arrayify)(assetId)
4504
+ ...(0, import_utils27.arrayify)(assetId)
4730
4505
  ]);
4731
4506
  return scriptData;
4732
4507
  };
@@ -4911,33 +4686,36 @@ var Account = class extends import_interfaces.AbstractAccount {
4911
4686
  * @param fee - The estimated transaction fee.
4912
4687
  * @returns A promise that resolves when the resources are added to the transaction.
4913
4688
  */
4914
- async fund(request, params) {
4915
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4916
- const txRequest = request;
4917
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4918
- amount: (0, import_math19.bn)(fee),
4689
+ async fund(request, coinQuantities, fee) {
4690
+ const updatedQuantities = addAmountToAsset({
4691
+ amount: (0, import_math18.bn)(fee),
4919
4692
  assetId: import_configs12.BaseAssetId,
4920
- coinQuantities: requiredQuantities
4693
+ coinQuantities
4921
4694
  });
4922
4695
  const quantitiesDict = {};
4923
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4696
+ updatedQuantities.forEach(({ amount, assetId }) => {
4924
4697
  quantitiesDict[assetId] = {
4925
4698
  required: amount,
4926
- owned: (0, import_math19.bn)(0)
4699
+ owned: (0, import_math18.bn)(0)
4927
4700
  };
4928
4701
  });
4929
- txRequest.inputs.forEach((input) => {
4702
+ const cachedUtxos = [];
4703
+ const cachedMessages = [];
4704
+ const owner = this.address.toB256();
4705
+ request.inputs.forEach((input) => {
4930
4706
  const isResource = "amount" in input;
4931
4707
  if (isResource) {
4932
4708
  const isCoin2 = "owner" in input;
4933
4709
  if (isCoin2) {
4934
4710
  const assetId = String(input.assetId);
4935
- if (quantitiesDict[assetId]) {
4936
- const amount = (0, import_math19.bn)(input.amount);
4711
+ if (input.owner === owner && quantitiesDict[assetId]) {
4712
+ const amount = (0, import_math18.bn)(input.amount);
4937
4713
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4714
+ cachedUtxos.push(input.id);
4938
4715
  }
4939
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4716
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4940
4717
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4718
+ cachedMessages.push(input.nonce);
4941
4719
  }
4942
4720
  }
4943
4721
  });
@@ -4952,23 +4730,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4952
4730
  });
4953
4731
  const needsToBeFunded = missingQuantities.length;
4954
4732
  if (needsToBeFunded) {
4955
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4956
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4957
- txRequest.addResources(resources);
4958
- }
4959
- txRequest.shiftPredicateData();
4960
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4961
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
4962
- if (addedSignatures) {
4963
- Array.from({ length: addedSignatures }).forEach(
4964
- () => requestToBeReEstimate.addEmptyWitness()
4965
- );
4733
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4734
+ messages: cachedMessages,
4735
+ utxos: cachedUtxos
4736
+ });
4737
+ request.addResources(resources);
4966
4738
  }
4967
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4968
- transactionRequest: requestToBeReEstimate
4969
- });
4970
- txRequest.maxFee = maxFee;
4971
- return txRequest;
4972
4739
  }
4973
4740
  /**
4974
4741
  * A helper that creates a transfer transaction request and returns it.
@@ -4976,25 +4743,28 @@ var Account = class extends import_interfaces.AbstractAccount {
4976
4743
  * @param destination - The address of the destination.
4977
4744
  * @param amount - The amount of coins to transfer.
4978
4745
  * @param assetId - The asset ID of the coins to transfer.
4979
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4746
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4980
4747
  * @returns A promise that resolves to the prepared transaction request.
4981
4748
  */
4982
4749
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4983
- const request = new ScriptTransactionRequest(txParams);
4750
+ const { minGasPrice } = this.provider.getGasConfig();
4751
+ const params = { gasPrice: minGasPrice, ...txParams };
4752
+ const request = new ScriptTransactionRequest(params);
4984
4753
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
4985
- const txCost = await this.provider.getTransactionCost(request, {
4754
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4986
4755
  estimateTxDependencies: true,
4987
4756
  resourcesOwner: this
4988
4757
  });
4989
- if ("gasLimit" in txParams) {
4990
- this.validateGas({
4991
- gasUsed: txCost.gasUsed,
4992
- gasLimit: request.gasLimit
4993
- });
4994
- }
4995
- request.gasLimit = txCost.gasUsed;
4996
- request.maxFee = txCost.maxFee;
4997
- await this.fund(request, txCost);
4758
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
4759
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
4760
+ this.validateGas({
4761
+ gasUsed,
4762
+ gasPrice: request.gasPrice,
4763
+ gasLimit: request.gasLimit,
4764
+ minGasPrice
4765
+ });
4766
+ await this.fund(request, requiredQuantities, maxFee);
4767
+ request.updatePredicateInputs(estimatedInputs);
4998
4768
  return request;
4999
4769
  }
5000
4770
  /**
@@ -5007,7 +4777,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5007
4777
  * @returns A promise that resolves to the transaction response.
5008
4778
  */
5009
4779
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5010
- if ((0, import_math19.bn)(amount).lte(0)) {
4780
+ if ((0, import_math18.bn)(amount).lte(0)) {
5011
4781
  throw new import_errors16.FuelError(
5012
4782
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5013
4783
  "Transfer amount must be a positive number."
@@ -5026,37 +4796,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5026
4796
  * @returns A promise that resolves to the transaction response.
5027
4797
  */
5028
4798
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5029
- if ((0, import_math19.bn)(amount).lte(0)) {
4799
+ if ((0, import_math18.bn)(amount).lte(0)) {
5030
4800
  throw new import_errors16.FuelError(
5031
4801
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5032
4802
  "Transfer amount must be a positive number."
5033
4803
  );
5034
4804
  }
5035
4805
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4806
+ const { minGasPrice } = this.provider.getGasConfig();
4807
+ const params = { gasPrice: minGasPrice, ...txParams };
5036
4808
  const { script, scriptData } = await assembleTransferToContractScript({
5037
4809
  hexlifiedContractId: contractAddress.toB256(),
5038
- amountToTransfer: (0, import_math19.bn)(amount),
4810
+ amountToTransfer: (0, import_math18.bn)(amount),
5039
4811
  assetId
5040
4812
  });
5041
4813
  const request = new ScriptTransactionRequest({
5042
- ...txParams,
4814
+ ...params,
5043
4815
  script,
5044
4816
  scriptData
5045
4817
  });
5046
4818
  request.addContractInputAndOutput(contractAddress);
5047
- const txCost = await this.provider.getTransactionCost(request, {
5048
- resourcesOwner: this,
5049
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
4819
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4820
+ request,
4821
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
4822
+ );
4823
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4824
+ this.validateGas({
4825
+ gasUsed,
4826
+ gasPrice: request.gasPrice,
4827
+ gasLimit: request.gasLimit,
4828
+ minGasPrice
5050
4829
  });
5051
- if (txParams.gasLimit) {
5052
- this.validateGas({
5053
- gasUsed: txCost.gasUsed,
5054
- gasLimit: request.gasLimit
5055
- });
5056
- }
5057
- request.gasLimit = txCost.gasUsed;
5058
- request.maxFee = txCost.maxFee;
5059
- await this.fund(request, txCost);
4830
+ await this.fund(request, requiredQuantities, maxFee);
5060
4831
  return this.sendTransaction(request);
5061
4832
  }
5062
4833
  /**
@@ -5068,31 +4839,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5068
4839
  * @returns A promise that resolves to the transaction response.
5069
4840
  */
5070
4841
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4842
+ const { minGasPrice } = this.provider.getGasConfig();
5071
4843
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5072
- const recipientDataArray = (0, import_utils27.arrayify)(
4844
+ const recipientDataArray = (0, import_utils28.arrayify)(
5073
4845
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5074
4846
  );
5075
- const amountDataArray = (0, import_utils27.arrayify)(
5076
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
4847
+ const amountDataArray = (0, import_utils28.arrayify)(
4848
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5077
4849
  );
5078
4850
  const script = new Uint8Array([
5079
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4851
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5080
4852
  ...recipientDataArray,
5081
4853
  ...amountDataArray
5082
4854
  ]);
5083
- const params = { script, ...txParams };
4855
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5084
4856
  const request = new ScriptTransactionRequest(params);
5085
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5086
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5087
- if (txParams.gasLimit) {
5088
- this.validateGas({
5089
- gasUsed: txCost.gasUsed,
5090
- gasLimit: request.gasLimit
5091
- });
5092
- }
5093
- request.maxFee = txCost.maxFee;
5094
- request.gasLimit = txCost.gasUsed;
5095
- await this.fund(request, txCost);
4857
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
4858
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4859
+ request,
4860
+ forwardingQuantities
4861
+ );
4862
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4863
+ this.validateGas({
4864
+ gasUsed,
4865
+ gasPrice: request.gasPrice,
4866
+ gasLimit: request.gasLimit,
4867
+ minGasPrice
4868
+ });
4869
+ await this.fund(request, requiredQuantities, maxFee);
5096
4870
  return this.sendTransaction(request);
5097
4871
  }
5098
4872
  async signMessage(message) {
@@ -5150,7 +4924,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5150
4924
  }
5151
4925
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5152
4926
  }
5153
- validateGas({ gasUsed, gasLimit }) {
4927
+ validateGas({
4928
+ gasUsed,
4929
+ gasPrice,
4930
+ gasLimit,
4931
+ minGasPrice
4932
+ }) {
4933
+ if (minGasPrice.gt(gasPrice)) {
4934
+ throw new import_errors16.FuelError(
4935
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4936
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4937
+ );
4938
+ }
5154
4939
  if (gasUsed.gt(gasLimit)) {
5155
4940
  throw new import_errors16.FuelError(
5156
4941
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5164,8 +4949,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5164
4949
  var import_address5 = require("@fuel-ts/address");
5165
4950
  var import_crypto2 = require("@fuel-ts/crypto");
5166
4951
  var import_hasher2 = require("@fuel-ts/hasher");
5167
- var import_math20 = require("@fuel-ts/math");
5168
- var import_utils28 = require("@fuel-ts/utils");
4952
+ var import_math19 = require("@fuel-ts/math");
4953
+ var import_utils29 = require("@fuel-ts/utils");
5169
4954
  var import_secp256k1 = require("@noble/curves/secp256k1");
5170
4955
  var Signer = class {
5171
4956
  address;
@@ -5184,10 +4969,10 @@ var Signer = class {
5184
4969
  privateKey = `0x${privateKey}`;
5185
4970
  }
5186
4971
  }
5187
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5188
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5189
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5190
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4972
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
4973
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4974
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4975
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5191
4976
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5192
4977
  }
5193
4978
  /**
@@ -5201,11 +4986,11 @@ var Signer = class {
5201
4986
  * @returns hashed signature
5202
4987
  */
5203
4988
  sign(data) {
5204
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5205
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5206
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
4989
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
4990
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
4991
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5207
4992
  s[0] |= (signature.recovery || 0) << 7;
5208
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4993
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5209
4994
  }
5210
4995
  /**
5211
4996
  * Add point on the current elliptic curve
@@ -5214,8 +4999,8 @@ var Signer = class {
5214
4999
  * @returns compressed point on the curve
5215
5000
  */
5216
5001
  addPoint(point) {
5217
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5218
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5002
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5003
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5219
5004
  const result = p0.add(p1);
5220
5005
  return `0x${result.toHex(true)}`;
5221
5006
  }
@@ -5227,16 +5012,16 @@ var Signer = class {
5227
5012
  * @returns public key from signature from the
5228
5013
  */
5229
5014
  static recoverPublicKey(data, signature) {
5230
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5015
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5231
5016
  const r = signedMessageBytes.slice(0, 32);
5232
5017
  const s = signedMessageBytes.slice(32, 64);
5233
5018
  const recoveryParam = (s[0] & 128) >> 7;
5234
5019
  s[0] &= 127;
5235
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5020
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5236
5021
  recoveryParam
5237
5022
  );
5238
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5239
- return (0, import_utils28.hexlify)(publicKey);
5023
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5024
+ return (0, import_utils29.hexlify)(publicKey);
5240
5025
  }
5241
5026
  /**
5242
5027
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5255,7 +5040,7 @@ var Signer = class {
5255
5040
  * @returns random 32-byte hashed
5256
5041
  */
5257
5042
  static generatePrivateKey(entropy) {
5258
- return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5043
+ return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5259
5044
  }
5260
5045
  /**
5261
5046
  * Extended publicKey from a compact publicKey
@@ -5264,8 +5049,8 @@ var Signer = class {
5264
5049
  * @returns extended publicKey
5265
5050
  */
5266
5051
  static extendPublicKey(publicKey) {
5267
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5268
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5052
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5053
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5269
5054
  }
5270
5055
  };
5271
5056
 
@@ -5273,7 +5058,7 @@ var Signer = class {
5273
5058
  var import_address6 = require("@fuel-ts/address");
5274
5059
  var import_crypto3 = require("@fuel-ts/crypto");
5275
5060
  var import_errors17 = require("@fuel-ts/errors");
5276
- var import_utils29 = require("@fuel-ts/utils");
5061
+ var import_utils30 = require("@fuel-ts/utils");
5277
5062
  var import_uuid = require("uuid");
5278
5063
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5279
5064
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5356,7 +5141,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5356
5141
  );
5357
5142
  }
5358
5143
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5359
- const privateKey = (0, import_utils29.hexlify)(buffer);
5144
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5360
5145
  return privateKey;
5361
5146
  }
5362
5147
 
@@ -5401,7 +5186,7 @@ var BaseWalletUnlocked = class extends Account {
5401
5186
  */
5402
5187
  async signMessage(message) {
5403
5188
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5404
- return (0, import_utils30.hexlify)(signedMessage);
5189
+ return (0, import_utils31.hexlify)(signedMessage);
5405
5190
  }
5406
5191
  /**
5407
5192
  * Signs a transaction with the wallet's private key.
@@ -5414,7 +5199,7 @@ var BaseWalletUnlocked = class extends Account {
5414
5199
  const chainId = this.provider.getChainId();
5415
5200
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5416
5201
  const signature = await this.signer().sign(hashedTransaction);
5417
- return (0, import_utils30.hexlify)(signature);
5202
+ return (0, import_utils31.hexlify)(signature);
5418
5203
  }
5419
5204
  /**
5420
5205
  * Populates a transaction with the witnesses signature.
@@ -5434,7 +5219,7 @@ var BaseWalletUnlocked = class extends Account {
5434
5219
  * @param transactionRequestLike - The transaction request to send.
5435
5220
  * @returns A promise that resolves to the TransactionResponse object.
5436
5221
  */
5437
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5222
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5438
5223
  const transactionRequest = transactionRequestify(transactionRequestLike);
5439
5224
  if (estimateTxDependencies) {
5440
5225
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5475,15 +5260,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5475
5260
  // src/hdwallet/hdwallet.ts
5476
5261
  var import_errors20 = require("@fuel-ts/errors");
5477
5262
  var import_hasher6 = require("@fuel-ts/hasher");
5478
- var import_math21 = require("@fuel-ts/math");
5479
- var import_utils34 = require("@fuel-ts/utils");
5263
+ var import_math20 = require("@fuel-ts/math");
5264
+ var import_utils35 = require("@fuel-ts/utils");
5480
5265
  var import_ethers3 = require("ethers");
5481
5266
 
5482
5267
  // src/mnemonic/mnemonic.ts
5483
5268
  var import_crypto4 = require("@fuel-ts/crypto");
5484
5269
  var import_errors19 = require("@fuel-ts/errors");
5485
5270
  var import_hasher5 = require("@fuel-ts/hasher");
5486
- var import_utils32 = require("@fuel-ts/utils");
5271
+ var import_utils33 = require("@fuel-ts/utils");
5487
5272
  var import_ethers2 = require("ethers");
5488
5273
 
5489
5274
  // src/wordlists/words/english.ts
@@ -7541,7 +7326,7 @@ var english = [
7541
7326
  // src/mnemonic/utils.ts
7542
7327
  var import_errors18 = require("@fuel-ts/errors");
7543
7328
  var import_hasher4 = require("@fuel-ts/hasher");
7544
- var import_utils31 = require("@fuel-ts/utils");
7329
+ var import_utils32 = require("@fuel-ts/utils");
7545
7330
  function toUtf8Bytes(stri) {
7546
7331
  const str = stri.normalize("NFKD");
7547
7332
  const result = [];
@@ -7608,14 +7393,14 @@ function entropyToMnemonicIndices(entropy) {
7608
7393
  }
7609
7394
  }
7610
7395
  const checksumBits = entropy.length / 4;
7611
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7396
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7612
7397
  indices[indices.length - 1] <<= checksumBits;
7613
7398
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7614
7399
  return indices;
7615
7400
  }
7616
7401
  function mnemonicWordsToEntropy(words, wordlist) {
7617
7402
  const size = Math.ceil(11 * words.length / 8);
7618
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7403
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7619
7404
  let offset = 0;
7620
7405
  for (let i = 0; i < words.length; i += 1) {
7621
7406
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7635,7 +7420,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7635
7420
  const entropyBits = 32 * words.length / 3;
7636
7421
  const checksumBits = words.length / 3;
7637
7422
  const checksumMask = getUpperMask(checksumBits);
7638
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7423
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7639
7424
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7640
7425
  throw new import_errors18.FuelError(
7641
7426
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7710,7 +7495,7 @@ var Mnemonic = class {
7710
7495
  static mnemonicToEntropy(phrase, wordlist = english) {
7711
7496
  const words = getWords(phrase);
7712
7497
  assertMnemonic(words);
7713
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7498
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7714
7499
  }
7715
7500
  /**
7716
7501
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7718,7 +7503,7 @@ var Mnemonic = class {
7718
7503
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7719
7504
  */
7720
7505
  static entropyToMnemonic(entropy, wordlist = english) {
7721
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7506
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7722
7507
  assertWordList(wordlist);
7723
7508
  assertEntropy(entropyBytes);
7724
7509
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7787,14 +7572,14 @@ var Mnemonic = class {
7787
7572
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7788
7573
  */
7789
7574
  static masterKeysFromSeed(seed) {
7790
- const seedArray = (0, import_utils32.arrayify)(seed);
7575
+ const seedArray = (0, import_utils33.arrayify)(seed);
7791
7576
  if (seedArray.length < 16 || seedArray.length > 64) {
7792
7577
  throw new import_errors19.FuelError(
7793
7578
  import_errors19.ErrorCode.INVALID_SEED,
7794
7579
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7795
7580
  );
7796
7581
  }
7797
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7582
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7798
7583
  }
7799
7584
  /**
7800
7585
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7805,22 +7590,22 @@ var Mnemonic = class {
7805
7590
  */
7806
7591
  static seedToExtendedKey(seed, testnet = false) {
7807
7592
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7808
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7593
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7809
7594
  const depth = "0x00";
7810
7595
  const fingerprint = "0x00000000";
7811
7596
  const index = "0x00000000";
7812
7597
  const chainCode = masterKey.slice(32);
7813
7598
  const privateKey = masterKey.slice(0, 32);
7814
- const extendedKey = (0, import_utils32.concat)([
7599
+ const extendedKey = (0, import_utils33.concat)([
7815
7600
  prefix,
7816
7601
  depth,
7817
7602
  fingerprint,
7818
7603
  index,
7819
7604
  chainCode,
7820
- (0, import_utils32.concat)(["0x00", privateKey])
7605
+ (0, import_utils33.concat)(["0x00", privateKey])
7821
7606
  ]);
7822
7607
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7823
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7608
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7824
7609
  }
7825
7610
  /**
7826
7611
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7835,7 +7620,7 @@ var Mnemonic = class {
7835
7620
  * @returns A randomly generated mnemonic
7836
7621
  */
7837
7622
  static generate(size = 32, extraEntropy = "") {
7838
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
7623
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
7839
7624
  return Mnemonic.entropyToMnemonic(entropy);
7840
7625
  }
7841
7626
  };
@@ -7843,12 +7628,12 @@ var mnemonic_default = Mnemonic;
7843
7628
 
7844
7629
  // src/hdwallet/hdwallet.ts
7845
7630
  var HARDENED_INDEX = 2147483648;
7846
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7847
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7848
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7849
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7631
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7632
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7633
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7634
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7850
7635
  function base58check(data) {
7851
- return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7636
+ 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)]));
7852
7637
  }
7853
7638
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7854
7639
  if (isPublic) {
@@ -7857,11 +7642,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7857
7642
  return testnet ? TestnetPRV2 : MainnetPRV2;
7858
7643
  }
7859
7644
  function isPublicExtendedKey(extendedKey) {
7860
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7645
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7861
7646
  }
7862
7647
  function isValidExtendedKey(extendedKey) {
7863
7648
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7864
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7649
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7865
7650
  );
7866
7651
  }
7867
7652
  function parsePath(path2, depth = 0) {
@@ -7879,8 +7664,8 @@ function parsePath(path2, depth = 0) {
7879
7664
  var HDWallet = class {
7880
7665
  depth = 0;
7881
7666
  index = 0;
7882
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7883
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7667
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
7668
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7884
7669
  privateKey;
7885
7670
  publicKey;
7886
7671
  chainCode;
@@ -7892,8 +7677,8 @@ var HDWallet = class {
7892
7677
  constructor(config) {
7893
7678
  if (config.privateKey) {
7894
7679
  const signer = new Signer(config.privateKey);
7895
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7896
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7680
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7681
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7897
7682
  } else {
7898
7683
  if (!config.publicKey) {
7899
7684
  throw new import_errors20.FuelError(
@@ -7901,7 +7686,7 @@ var HDWallet = class {
7901
7686
  "Both public and private Key cannot be missing. At least one should be provided."
7902
7687
  );
7903
7688
  }
7904
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7689
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7905
7690
  }
7906
7691
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7907
7692
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7920,9 +7705,9 @@ var HDWallet = class {
7920
7705
  * @returns A new instance of HDWallet on the derived index
7921
7706
  */
7922
7707
  deriveIndex(index) {
7923
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7924
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7925
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7708
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7709
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7710
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7926
7711
  const data = new Uint8Array(37);
7927
7712
  if (index & HARDENED_INDEX) {
7928
7713
  if (!privateKey) {
@@ -7933,15 +7718,15 @@ var HDWallet = class {
7933
7718
  }
7934
7719
  data.set(privateKey, 1);
7935
7720
  } else {
7936
- data.set((0, import_utils34.arrayify)(this.publicKey));
7721
+ data.set((0, import_utils35.arrayify)(this.publicKey));
7937
7722
  }
7938
- data.set((0, import_math21.toBytes)(index, 4), 33);
7939
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7723
+ data.set((0, import_math20.toBytes)(index, 4), 33);
7724
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7940
7725
  const IL = bytes.slice(0, 32);
7941
7726
  const IR = bytes.slice(32);
7942
7727
  if (privateKey) {
7943
7728
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7944
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
7729
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7945
7730
  return new HDWallet({
7946
7731
  privateKey: ki,
7947
7732
  chainCode: IR,
@@ -7950,7 +7735,7 @@ var HDWallet = class {
7950
7735
  parentFingerprint: this.fingerprint
7951
7736
  });
7952
7737
  }
7953
- const signer = new Signer((0, import_utils34.hexlify)(IL));
7738
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
7954
7739
  const Ki = signer.addPoint(publicKey);
7955
7740
  return new HDWallet({
7956
7741
  publicKey: Ki,
@@ -7985,12 +7770,12 @@ var HDWallet = class {
7985
7770
  );
7986
7771
  }
7987
7772
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7988
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7773
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
7989
7774
  const parentFingerprint = this.parentFingerprint;
7990
- const index = (0, import_math21.toHex)(this.index, 4);
7775
+ const index = (0, import_math20.toHex)(this.index, 4);
7991
7776
  const chainCode = this.chainCode;
7992
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
7993
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7777
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7778
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7994
7779
  return base58check(extendedKey);
7995
7780
  }
7996
7781
  /**
@@ -8002,13 +7787,13 @@ var HDWallet = class {
8002
7787
  static fromSeed(seed) {
8003
7788
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8004
7789
  return new HDWallet({
8005
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8006
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7790
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7791
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8007
7792
  });
8008
7793
  }
8009
7794
  static fromExtendedKey(extendedKey) {
8010
7795
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8011
- const bytes = (0, import_utils34.arrayify)(decoded);
7796
+ const bytes = (0, import_utils35.arrayify)(decoded);
8012
7797
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8013
7798
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8014
7799
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8017,9 +7802,9 @@ var HDWallet = class {
8017
7802
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8018
7803
  }
8019
7804
  const depth = bytes[4];
8020
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8021
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8022
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7805
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7806
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7807
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8023
7808
  const key = bytes.slice(45, 78);
8024
7809
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8025
7810
  throw new import_errors20.FuelError(
@@ -8212,15 +7997,14 @@ var seedTestWallet = async (wallet, quantities) => {
8212
7997
  process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
8213
7998
  wallet.provider
8214
7999
  );
8215
- const request = new ScriptTransactionRequest();
8216
- quantities.forEach((quantity) => {
8217
- const { amount, assetId } = coinQuantityfy(quantity);
8218
- request.addCoinOutput(wallet.address, amount, assetId);
8000
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
8001
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
8002
+ const request = new ScriptTransactionRequest({
8003
+ gasLimit: 1e4,
8004
+ gasPrice: minGasPrice
8219
8005
  });
8220
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8221
- request.gasLimit = txCost.gasUsed;
8222
- request.maxFee = txCost.maxFee;
8223
- await genesisWallet.fund(request, txCost);
8006
+ request.addResources(resources);
8007
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8224
8008
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8225
8009
  };
8226
8010
 
@@ -8235,11 +8019,11 @@ var generateTestWallet = async (provider, quantities) => {
8235
8019
 
8236
8020
  // src/test-utils/launchNode.ts
8237
8021
  var import_configs13 = require("@fuel-ts/address/configs");
8238
- var import_utils35 = require("@fuel-ts/utils");
8022
+ var import_math21 = require("@fuel-ts/math");
8023
+ var import_utils36 = require("@fuel-ts/utils");
8239
8024
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8240
8025
  var import_child_process = require("child_process");
8241
8026
  var import_crypto6 = require("crypto");
8242
- var import_ethers4 = require("ethers");
8243
8027
  var import_fs = require("fs");
8244
8028
  var import_os = __toESM(require("os"));
8245
8029
  var import_path = __toESM(require("path"));
@@ -8288,13 +8072,13 @@ var launchNode = async ({
8288
8072
  // eslint-disable-next-line no-async-promise-executor
8289
8073
  new Promise(async (resolve, reject) => {
8290
8074
  const remainingArgs = extractRemainingArgs(args, [
8291
- "--snapshot",
8075
+ "--chain",
8292
8076
  "--consensus-key",
8293
8077
  "--db-type",
8294
8078
  "--poa-instant"
8295
8079
  ]);
8296
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8297
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8080
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8081
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8298
8082
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8299
8083
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8300
8084
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -8312,54 +8096,36 @@ var launchNode = async ({
8312
8096
  let chainConfigPathToUse;
8313
8097
  const prefix = basePath || import_os.default.tmpdir();
8314
8098
  const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
8315
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
8099
+ const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
8316
8100
  if (chainConfigPath) {
8317
8101
  chainConfigPathToUse = chainConfigPath;
8318
8102
  } else {
8319
8103
  if (!(0, import_fs.existsSync)(tempDirPath)) {
8320
8104
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8321
8105
  }
8322
- let { stateConfigJson } = import_utils35.defaultChainConfigs;
8323
- const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
8324
- stateConfigJson = {
8325
- ...stateConfigJson,
8326
- coins: [
8327
- ...stateConfigJson.coins.map((coin) => ({
8328
- ...coin,
8329
- amount: "18446744073709551615"
8330
- }))
8331
- ],
8332
- messages: stateConfigJson.messages.map((message) => ({
8333
- ...message,
8334
- amount: "18446744073709551615"
8335
- }))
8336
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8337
- };
8106
+ const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
8107
+ let chainConfig = import_utils36.defaultChainConfig;
8338
8108
  if (!process.env.GENESIS_SECRET) {
8339
8109
  const pk = Signer.generatePrivateKey();
8340
8110
  const signer = new Signer(pk);
8341
- process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8342
- stateConfigJson.coins.push({
8343
- tx_id: (0, import_utils35.hexlify)((0, import_ethers4.randomBytes)(34)),
8344
- owner: signer.address.toHexString(),
8345
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8346
- amount: "18446744073709551615",
8347
- asset_id: import_configs13.BaseAssetId,
8348
- output_index: 0,
8349
- tx_pointer_block_height: 0,
8350
- tx_pointer_tx_idx: 0
8351
- });
8111
+ process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8112
+ chainConfig = {
8113
+ ...import_utils36.defaultChainConfig,
8114
+ initial_state: {
8115
+ ...import_utils36.defaultChainConfig.initial_state,
8116
+ coins: [
8117
+ ...import_utils36.defaultChainConfig.initial_state.coins,
8118
+ {
8119
+ owner: signer.address.toHexString(),
8120
+ amount: (0, import_math21.toHex)(1e9),
8121
+ asset_id: import_configs13.BaseAssetId
8122
+ }
8123
+ ]
8124
+ }
8125
+ };
8352
8126
  }
8353
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8354
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8355
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8356
- const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8357
- const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8358
- const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8359
- (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8360
- (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8361
- (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8362
- chainConfigPathToUse = tempDirPath;
8127
+ (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8128
+ chainConfigPathToUse = tempChainConfigFilePath;
8363
8129
  }
8364
8130
  const child = (0, import_child_process.spawn)(
8365
8131
  command,
@@ -8368,10 +8134,10 @@ var launchNode = async ({
8368
8134
  ["--ip", ipToUse],
8369
8135
  ["--port", portToUse],
8370
8136
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8371
- ["--min-gas-price", "1"],
8137
+ ["--min-gas-price", "0"],
8372
8138
  poaInstant ? ["--poa-instant", "true"] : [],
8373
8139
  ["--consensus-key", consensusKey],
8374
- ["--snapshot", chainConfigPathToUse],
8140
+ ["--chain", chainConfigPathToUse],
8375
8141
  "--vm-backtrace",
8376
8142
  "--utxo-validation",
8377
8143
  "--debug",
@@ -8430,7 +8196,7 @@ var launchNodeAndGetWallets = async ({
8430
8196
  walletCount = 10
8431
8197
  } = {}) => {
8432
8198
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8433
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8199
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8434
8200
  const wallets = await generateWallets(walletCount, provider);
8435
8201
  const cleanup = () => {
8436
8202
  closeNode();