@fuel-ts/account 0.0.0-rc-2021-20240415193305 → 0.0.0-rc-2045-20240416150348

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

Potentially problematic release.


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

Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +545 -796
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +507 -762
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +388 -642
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +329 -911
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -7
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +27 -37
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +25 -8
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1057 -1546
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +503 -740
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +397 -634
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
@@ -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");
@@ -93,7 +92,7 @@ var coinQuantityfy = (coinQuantityLike) => {
93
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
  },
@@ -1025,14 +960,11 @@ var _FuelGraphqlSubscriber = class {
1025
960
  let data;
1026
961
  let errors;
1027
962
  try {
1028
- const sanitizedText = text.replace(/\s/g, "");
1029
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
963
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1030
964
  } catch (e) {
1031
965
  throw new import_errors.FuelError(
1032
966
  import_errors.ErrorCode.STREAM_PARSING_ERROR,
1033
- `Error while parsing stream data response: ${text}
1034
-
1035
- Thrown error: ${e}`
967
+ `Error while parsing stream data response: ${text}`
1036
968
  );
1037
969
  }
1038
970
  if (Array.isArray(errors)) {
@@ -1143,9 +1075,10 @@ var inputify = (value) => {
1143
1075
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1144
1076
  },
1145
1077
  witnessIndex: value.witnessIndex,
1078
+ maturity: value.maturity ?? 0,
1146
1079
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1147
- predicateLength: (0, import_math2.bn)(predicate.length),
1148
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1080
+ predicateLength: predicate.length,
1081
+ predicateDataLength: predicateData.length,
1149
1082
  predicate: (0, import_utils3.hexlify)(predicate),
1150
1083
  predicateData: (0, import_utils3.hexlify)(predicateData)
1151
1084
  };
@@ -1176,8 +1109,8 @@ var inputify = (value) => {
1176
1109
  nonce: (0, import_utils3.hexlify)(value.nonce),
1177
1110
  witnessIndex: value.witnessIndex,
1178
1111
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1179
- predicateLength: (0, import_math2.bn)(predicate.length),
1180
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1112
+ predicateLength: predicate.length,
1113
+ predicateDataLength: predicateData.length,
1181
1114
  predicate: (0, import_utils3.hexlify)(predicate),
1182
1115
  predicateData: (0, import_utils3.hexlify)(predicateData),
1183
1116
  data: (0, import_utils3.hexlify)(data),
@@ -1293,8 +1226,8 @@ function assembleReceiptByType(receipt) {
1293
1226
  case "CALL" /* Call */: {
1294
1227
  const callReceipt = {
1295
1228
  type: import_transactions3.ReceiptType.Call,
1296
- from: hexOrZero(receipt.id || receipt.contractId),
1297
- to: hexOrZero(receipt?.to),
1229
+ from: hexOrZero(receipt.contract?.id),
1230
+ to: hexOrZero(receipt?.to?.id),
1298
1231
  amount: (0, import_math4.bn)(receipt.amount),
1299
1232
  assetId: hexOrZero(receipt.assetId),
1300
1233
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1308,7 +1241,7 @@ function assembleReceiptByType(receipt) {
1308
1241
  case "RETURN" /* Return */: {
1309
1242
  const returnReceipt = {
1310
1243
  type: import_transactions3.ReceiptType.Return,
1311
- id: hexOrZero(receipt.id || receipt.contractId),
1244
+ id: hexOrZero(receipt.contract?.id),
1312
1245
  val: (0, import_math4.bn)(receipt.val),
1313
1246
  pc: (0, import_math4.bn)(receipt.pc),
1314
1247
  is: (0, import_math4.bn)(receipt.is)
@@ -1318,7 +1251,7 @@ function assembleReceiptByType(receipt) {
1318
1251
  case "RETURN_DATA" /* ReturnData */: {
1319
1252
  const returnDataReceipt = {
1320
1253
  type: import_transactions3.ReceiptType.ReturnData,
1321
- id: hexOrZero(receipt.id || receipt.contractId),
1254
+ id: hexOrZero(receipt.contract?.id),
1322
1255
  ptr: (0, import_math4.bn)(receipt.ptr),
1323
1256
  len: (0, import_math4.bn)(receipt.len),
1324
1257
  digest: hexOrZero(receipt.digest),
@@ -1330,7 +1263,7 @@ function assembleReceiptByType(receipt) {
1330
1263
  case "PANIC" /* Panic */: {
1331
1264
  const panicReceipt = {
1332
1265
  type: import_transactions3.ReceiptType.Panic,
1333
- id: hexOrZero(receipt.id),
1266
+ id: hexOrZero(receipt.contract?.id),
1334
1267
  reason: (0, import_math4.bn)(receipt.reason),
1335
1268
  pc: (0, import_math4.bn)(receipt.pc),
1336
1269
  is: (0, import_math4.bn)(receipt.is),
@@ -1341,7 +1274,7 @@ function assembleReceiptByType(receipt) {
1341
1274
  case "REVERT" /* Revert */: {
1342
1275
  const revertReceipt = {
1343
1276
  type: import_transactions3.ReceiptType.Revert,
1344
- id: hexOrZero(receipt.id || receipt.contractId),
1277
+ id: hexOrZero(receipt.contract?.id),
1345
1278
  val: (0, import_math4.bn)(receipt.ra),
1346
1279
  pc: (0, import_math4.bn)(receipt.pc),
1347
1280
  is: (0, import_math4.bn)(receipt.is)
@@ -1351,7 +1284,7 @@ function assembleReceiptByType(receipt) {
1351
1284
  case "LOG" /* Log */: {
1352
1285
  const logReceipt = {
1353
1286
  type: import_transactions3.ReceiptType.Log,
1354
- id: hexOrZero(receipt.id || receipt.contractId),
1287
+ id: hexOrZero(receipt.contract?.id),
1355
1288
  val0: (0, import_math4.bn)(receipt.ra),
1356
1289
  val1: (0, import_math4.bn)(receipt.rb),
1357
1290
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1364,7 +1297,7 @@ function assembleReceiptByType(receipt) {
1364
1297
  case "LOG_DATA" /* LogData */: {
1365
1298
  const logDataReceipt = {
1366
1299
  type: import_transactions3.ReceiptType.LogData,
1367
- id: hexOrZero(receipt.id || receipt.contractId),
1300
+ id: hexOrZero(receipt.contract?.id),
1368
1301
  val0: (0, import_math4.bn)(receipt.ra),
1369
1302
  val1: (0, import_math4.bn)(receipt.rb),
1370
1303
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1378,8 +1311,8 @@ function assembleReceiptByType(receipt) {
1378
1311
  case "TRANSFER" /* Transfer */: {
1379
1312
  const transferReceipt = {
1380
1313
  type: import_transactions3.ReceiptType.Transfer,
1381
- from: hexOrZero(receipt.id || receipt.contractId),
1382
- to: hexOrZero(receipt.toAddress || receipt?.to),
1314
+ from: hexOrZero(receipt.contract?.id),
1315
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1383
1316
  amount: (0, import_math4.bn)(receipt.amount),
1384
1317
  assetId: hexOrZero(receipt.assetId),
1385
1318
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1390,8 +1323,8 @@ function assembleReceiptByType(receipt) {
1390
1323
  case "TRANSFER_OUT" /* TransferOut */: {
1391
1324
  const transferOutReceipt = {
1392
1325
  type: import_transactions3.ReceiptType.TransferOut,
1393
- from: hexOrZero(receipt.id || receipt.contractId),
1394
- to: hexOrZero(receipt.toAddress || receipt.to),
1326
+ from: hexOrZero(receipt.contract?.id),
1327
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1395
1328
  amount: (0, import_math4.bn)(receipt.amount),
1396
1329
  assetId: hexOrZero(receipt.assetId),
1397
1330
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1434,7 +1367,7 @@ function assembleReceiptByType(receipt) {
1434
1367
  return receiptMessageOut;
1435
1368
  }
1436
1369
  case "MINT" /* Mint */: {
1437
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1370
+ const contractId = hexOrZero(receipt.contract?.id);
1438
1371
  const subId = hexOrZero(receipt.subId);
1439
1372
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1440
1373
  const mintReceipt = {
@@ -1449,7 +1382,7 @@ function assembleReceiptByType(receipt) {
1449
1382
  return mintReceipt;
1450
1383
  }
1451
1384
  case "BURN" /* Burn */: {
1452
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1385
+ const contractId = hexOrZero(receipt.contract?.id);
1453
1386
  const subId = hexOrZero(receipt.subId);
1454
1387
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1455
1388
  const burnReceipt = {
@@ -1475,6 +1408,7 @@ var import_errors6 = require("@fuel-ts/errors");
1475
1408
  var import_math5 = require("@fuel-ts/math");
1476
1409
  var import_transactions4 = require("@fuel-ts/transactions");
1477
1410
  var import_utils6 = require("@fuel-ts/utils");
1411
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1478
1412
  var getGasUsedFromReceipts = (receipts) => {
1479
1413
  const scriptResult = receipts.filter(
1480
1414
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1495,28 +1429,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1495
1429
  }
1496
1430
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1497
1431
  const witnessCache = [];
1498
- const chargeableInputs = inputs.filter((input) => {
1499
- const isCoinOrMessage = "owner" in input || "sender" in input;
1500
- if (isCoinOrMessage) {
1501
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1502
- return true;
1503
- }
1504
- if (!witnessCache.includes(input.witnessIndex)) {
1505
- witnessCache.push(input.witnessIndex);
1506
- return true;
1507
- }
1508
- }
1509
- return false;
1510
- });
1511
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1512
- const totalGas = chargeableInputs.reduce((total, input) => {
1432
+ const totalGas = inputs.reduce((total, input) => {
1513
1433
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1514
1434
  return total.add(
1515
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1435
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1516
1436
  );
1517
1437
  }
1518
- return total.add(gasCosts.ecr1);
1519
- }, (0, import_math5.bn)(0));
1438
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1439
+ witnessCache.push(input.witnessIndex);
1440
+ return total.add(gasCosts.ecr1);
1441
+ }
1442
+ return total;
1443
+ }, (0, import_math5.bn)());
1520
1444
  return totalGas;
1521
1445
  }
1522
1446
  function getMinGas(params) {
@@ -1528,20 +1452,12 @@ function getMinGas(params) {
1528
1452
  return minGas;
1529
1453
  }
1530
1454
  function getMaxGas(params) {
1531
- const {
1532
- gasPerByte,
1533
- witnessesLength,
1534
- witnessLimit,
1535
- minGas,
1536
- gasLimit = (0, import_math5.bn)(0),
1537
- maxGasPerTx
1538
- } = params;
1455
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1539
1456
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1540
1457
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1541
1458
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1542
1459
  }
1543
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1544
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1460
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1545
1461
  }
1546
1462
  function calculateMetadataGasForTxCreate({
1547
1463
  gasCosts,
@@ -1563,10 +1479,6 @@ function calculateMetadataGasForTxScript({
1563
1479
  }) {
1564
1480
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1565
1481
  }
1566
- var calculateGasFee = (params) => {
1567
- const { gas, gasPrice, priceFactor, tip } = params;
1568
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1569
- };
1570
1482
 
1571
1483
  // src/providers/utils/json.ts
1572
1484
  var import_utils7 = require("@fuel-ts/utils");
@@ -1703,7 +1615,7 @@ var witnessify = (value) => {
1703
1615
  // src/providers/transaction-request/transaction-request.ts
1704
1616
  var BaseTransactionRequest = class {
1705
1617
  /** Gas price for transaction */
1706
- tip;
1618
+ gasPrice;
1707
1619
  /** Block until which tx cannot be included */
1708
1620
  maturity;
1709
1621
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1722,7 +1634,7 @@ var BaseTransactionRequest = class {
1722
1634
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1723
1635
  */
1724
1636
  constructor({
1725
- tip,
1637
+ gasPrice,
1726
1638
  maturity,
1727
1639
  maxFee,
1728
1640
  witnessLimit,
@@ -1730,7 +1642,7 @@ var BaseTransactionRequest = class {
1730
1642
  outputs,
1731
1643
  witnesses
1732
1644
  } = {}) {
1733
- this.tip = (0, import_math7.bn)(tip);
1645
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1734
1646
  this.maturity = maturity ?? 0;
1735
1647
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1736
1648
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1741,9 +1653,9 @@ var BaseTransactionRequest = class {
1741
1653
  static getPolicyMeta(req) {
1742
1654
  let policyTypes = 0;
1743
1655
  const policies = [];
1744
- if (req.tip) {
1745
- policyTypes += import_transactions6.PolicyType.Tip;
1746
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1656
+ if (req.gasPrice) {
1657
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1658
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1747
1659
  }
1748
1660
  if (req.witnessLimit) {
1749
1661
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -1930,10 +1842,10 @@ var BaseTransactionRequest = class {
1930
1842
  * @param predicate - Predicate bytes.
1931
1843
  * @param predicateData - Predicate data bytes.
1932
1844
  */
1933
- addCoinInput(coin) {
1845
+ addCoinInput(coin, predicate) {
1934
1846
  const { assetId, owner, amount } = coin;
1935
1847
  let witnessIndex;
1936
- if (coin.predicate) {
1848
+ if (predicate) {
1937
1849
  witnessIndex = 0;
1938
1850
  } else {
1939
1851
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1948,7 +1860,8 @@ var BaseTransactionRequest = class {
1948
1860
  amount,
1949
1861
  assetId,
1950
1862
  txPointer: "0x00000000000000000000000000000000",
1951
- witnessIndex
1863
+ witnessIndex,
1864
+ predicate: predicate?.bytes
1952
1865
  };
1953
1866
  this.pushInput(input);
1954
1867
  this.addChangeOutput(owner, assetId);
@@ -1961,11 +1874,11 @@ var BaseTransactionRequest = class {
1961
1874
  * @param predicate - Predicate bytes.
1962
1875
  * @param predicateData - Predicate data bytes.
1963
1876
  */
1964
- addMessageInput(message) {
1877
+ addMessageInput(message, predicate) {
1965
1878
  const { recipient, sender, amount } = message;
1966
1879
  const assetId = import_configs7.BaseAssetId;
1967
1880
  let witnessIndex;
1968
- if (message.predicate) {
1881
+ if (predicate) {
1969
1882
  witnessIndex = 0;
1970
1883
  } else {
1971
1884
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1979,7 +1892,8 @@ var BaseTransactionRequest = class {
1979
1892
  sender: sender.toB256(),
1980
1893
  recipient: recipient.toB256(),
1981
1894
  amount,
1982
- witnessIndex
1895
+ witnessIndex,
1896
+ predicate: predicate?.bytes
1983
1897
  };
1984
1898
  this.pushInput(input);
1985
1899
  this.addChangeOutput(recipient, assetId);
@@ -2010,6 +1924,32 @@ var BaseTransactionRequest = class {
2010
1924
  resources.forEach((resource) => this.addResource(resource));
2011
1925
  return this;
2012
1926
  }
1927
+ /**
1928
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1929
+ * outputs from the related assetIds.
1930
+ *
1931
+ * @param resources - The resources to add.
1932
+ * @returns This transaction.
1933
+ */
1934
+ addPredicateResource(resource, predicate) {
1935
+ if (isCoin(resource)) {
1936
+ this.addCoinInput(resource, predicate);
1937
+ } else {
1938
+ this.addMessageInput(resource, predicate);
1939
+ }
1940
+ return this;
1941
+ }
1942
+ /**
1943
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
1944
+ * from the related assetIds.
1945
+ *
1946
+ * @param resources - The resources to add.
1947
+ * @returns This transaction.
1948
+ */
1949
+ addPredicateResources(resources, predicate) {
1950
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1951
+ return this;
1952
+ }
2013
1953
  /**
2014
1954
  * Adds a coin output to the transaction.
2015
1955
  *
@@ -2089,7 +2029,7 @@ var BaseTransactionRequest = class {
2089
2029
  }
2090
2030
  calculateMaxGas(chainInfo, minGas) {
2091
2031
  const { consensusParameters } = chainInfo;
2092
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2032
+ const { gasPerByte } = consensusParameters;
2093
2033
  const witnessesLength = this.toTransaction().witnesses.reduce(
2094
2034
  (acc, wit) => acc + wit.dataLength,
2095
2035
  0
@@ -2098,8 +2038,7 @@ var BaseTransactionRequest = class {
2098
2038
  gasPerByte,
2099
2039
  minGas,
2100
2040
  witnessesLength,
2101
- witnessLimit: this.witnessLimit,
2102
- maxGasPerTx
2041
+ witnessLimit: this.witnessLimit
2103
2042
  });
2104
2043
  }
2105
2044
  /**
@@ -2117,20 +2056,17 @@ var BaseTransactionRequest = class {
2117
2056
  });
2118
2057
  const updateAssetInput = (assetId, quantity) => {
2119
2058
  const assetInput = findAssetInput(assetId);
2120
- let usedQuantity = quantity;
2121
- if (assetId === import_configs7.BaseAssetId) {
2122
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2123
- }
2124
2059
  if (assetInput && "assetId" in assetInput) {
2125
2060
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2126
- assetInput.amount = usedQuantity;
2061
+ assetInput.amount = quantity;
2127
2062
  } else {
2128
2063
  this.addResources([
2129
2064
  {
2130
2065
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2131
- amount: usedQuantity,
2066
+ amount: quantity,
2132
2067
  assetId,
2133
2068
  owner: resourcesOwner || import_address.Address.fromRandom(),
2069
+ maturity: 0,
2134
2070
  blockCreated: (0, import_math7.bn)(1),
2135
2071
  txCreatedIdx: (0, import_math7.bn)(1)
2136
2072
  }
@@ -2162,7 +2098,7 @@ var BaseTransactionRequest = class {
2162
2098
  toJSON() {
2163
2099
  return normalizeJSON(this);
2164
2100
  }
2165
- updatePredicateGasUsed(inputs) {
2101
+ updatePredicateInputs(inputs) {
2166
2102
  this.inputs.forEach((i) => {
2167
2103
  let correspondingInput;
2168
2104
  switch (i.type) {
@@ -2184,15 +2120,6 @@ var BaseTransactionRequest = class {
2184
2120
  }
2185
2121
  });
2186
2122
  }
2187
- shiftPredicateData() {
2188
- this.inputs.forEach((input) => {
2189
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2190
- input.predicateData = input.paddPredicateData(
2191
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2192
- );
2193
- }
2194
- });
2195
- }
2196
2123
  };
2197
2124
 
2198
2125
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2339,8 +2266,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2339
2266
  return {
2340
2267
  type: import_transactions8.TransactionType.Create,
2341
2268
  ...baseTransaction,
2269
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2342
2270
  bytecodeWitnessIndex,
2343
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2271
+ storageSlotsCount: storageSlots.length,
2344
2272
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2345
2273
  storageSlots
2346
2274
  };
@@ -2463,8 +2391,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2463
2391
  type: import_transactions9.TransactionType.Script,
2464
2392
  scriptGasLimit: this.gasLimit,
2465
2393
  ...super.getBaseTransaction(),
2466
- scriptLength: (0, import_math10.bn)(script.length),
2467
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2394
+ scriptLength: script.length,
2395
+ scriptDataLength: scriptData.length,
2468
2396
  receiptsRoot: import_configs10.ZeroBytes32,
2469
2397
  script: (0, import_utils15.hexlify)(script),
2470
2398
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2528,7 +2456,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2528
2456
  }
2529
2457
  calculateMaxGas(chainInfo, minGas) {
2530
2458
  const { consensusParameters } = chainInfo;
2531
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2459
+ const { gasPerByte } = consensusParameters;
2532
2460
  const witnessesLength = this.toTransaction().witnesses.reduce(
2533
2461
  (acc, wit) => acc + wit.dataLength,
2534
2462
  0
@@ -2538,8 +2466,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2538
2466
  minGas,
2539
2467
  witnessesLength,
2540
2468
  witnessLimit: this.witnessLimit,
2541
- gasLimit: this.gasLimit,
2542
- maxGasPerTx
2469
+ gasLimit: this.gasLimit
2543
2470
  });
2544
2471
  }
2545
2472
  /**
@@ -2614,32 +2541,15 @@ var transactionRequestify = (obj) => {
2614
2541
  }
2615
2542
  }
2616
2543
  };
2617
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2618
- (acc, input) => {
2619
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2620
- acc.utxos.push(input.id);
2621
- }
2622
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2623
- acc.messages.push(input.nonce);
2624
- }
2625
- return acc;
2626
- },
2627
- {
2628
- utxos: [],
2629
- messages: []
2630
- }
2631
- );
2632
2544
 
2633
2545
  // src/providers/transaction-response/transaction-response.ts
2634
2546
  var import_errors13 = require("@fuel-ts/errors");
2635
- var import_math15 = require("@fuel-ts/math");
2636
- var import_transactions18 = require("@fuel-ts/transactions");
2637
- var import_utils20 = require("@fuel-ts/utils");
2547
+ var import_math14 = require("@fuel-ts/math");
2548
+ var import_transactions17 = require("@fuel-ts/transactions");
2549
+ var import_utils21 = require("@fuel-ts/utils");
2638
2550
 
2639
2551
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2640
- var import_math14 = require("@fuel-ts/math");
2641
- var import_transactions16 = require("@fuel-ts/transactions");
2642
- var import_utils18 = require("@fuel-ts/utils");
2552
+ var import_utils19 = require("@fuel-ts/utils");
2643
2553
 
2644
2554
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2645
2555
  var import_math11 = require("@fuel-ts/math");
@@ -2647,10 +2557,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2647
2557
  var import_utils16 = require("@fuel-ts/utils");
2648
2558
  var calculateTransactionFee = (params) => {
2649
2559
  const {
2650
- gasPrice,
2560
+ gasUsed,
2651
2561
  rawPayload,
2652
- tip,
2653
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2562
+ consensusParameters: { gasCosts, feeParams }
2654
2563
  } = params;
2655
2564
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2656
2565
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2660,7 +2569,8 @@ var calculateTransactionFee = (params) => {
2660
2569
  return {
2661
2570
  fee: (0, import_math11.bn)(0),
2662
2571
  minFee: (0, import_math11.bn)(0),
2663
- maxFee: (0, import_math11.bn)(0)
2572
+ maxFee: (0, import_math11.bn)(0),
2573
+ feeFromGasUsed: (0, import_math11.bn)(0)
2664
2574
  };
2665
2575
  }
2666
2576
  const { type, witnesses, inputs, policies } = transaction;
@@ -2692,6 +2602,7 @@ var calculateTransactionFee = (params) => {
2692
2602
  metadataGas,
2693
2603
  txBytesSize: transactionBytes.length
2694
2604
  });
2605
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2695
2606
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2696
2607
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2697
2608
  const maxGas = getMaxGas({
@@ -2699,25 +2610,17 @@ var calculateTransactionFee = (params) => {
2699
2610
  minGas,
2700
2611
  witnessesLength,
2701
2612
  gasLimit,
2702
- witnessLimit,
2703
- maxGasPerTx
2704
- });
2705
- const minFee = calculateGasFee({
2706
- gasPrice,
2707
- gas: minGas,
2708
- priceFactor: gasPriceFactor,
2709
- tip
2710
- });
2711
- const maxFee = calculateGasFee({
2712
- gasPrice,
2713
- gas: maxGas,
2714
- priceFactor: gasPriceFactor,
2715
- tip
2613
+ witnessLimit
2716
2614
  });
2615
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2616
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2617
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2618
+ const fee = minFee.add(feeFromGasUsed);
2717
2619
  return {
2620
+ fee,
2718
2621
  minFee,
2719
2622
  maxFee,
2720
- fee: maxFee
2623
+ feeFromGasUsed
2721
2624
  };
2722
2625
  };
2723
2626
 
@@ -3284,12 +3187,10 @@ function assembleTransactionSummary(params) {
3284
3187
  gqlTransactionStatus,
3285
3188
  abiMap = {},
3286
3189
  maxInputs,
3287
- gasCosts,
3288
- maxGasPerTx,
3289
- gasPrice
3190
+ gasCosts
3290
3191
  } = params;
3291
3192
  const gasUsed = getGasUsedFromReceipts(receipts);
3292
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3193
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3293
3194
  const operations = getOperations({
3294
3195
  transactionType: transaction.type,
3295
3196
  inputs: transaction.inputs || [],
@@ -3300,14 +3201,11 @@ function assembleTransactionSummary(params) {
3300
3201
  maxInputs
3301
3202
  });
3302
3203
  const typeName = getTransactionTypeName(transaction.type);
3303
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3304
3204
  const { fee } = calculateTransactionFee({
3305
- gasPrice,
3205
+ gasUsed,
3306
3206
  rawPayload,
3307
- tip,
3308
3207
  consensusParameters: {
3309
3208
  gasCosts,
3310
- maxGasPerTx,
3311
3209
  feeParams: {
3312
3210
  gasPerByte,
3313
3211
  gasPriceFactor
@@ -3319,7 +3217,7 @@ function assembleTransactionSummary(params) {
3319
3217
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3320
3218
  let date;
3321
3219
  if (time) {
3322
- date = import_utils18.DateTime.fromTai64(time);
3220
+ date = import_utils19.DateTime.fromTai64(time);
3323
3221
  }
3324
3222
  const transactionSummary = {
3325
3223
  id,
@@ -3347,12 +3245,12 @@ function assembleTransactionSummary(params) {
3347
3245
 
3348
3246
  // src/providers/transaction-response/getDecodedLogs.ts
3349
3247
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3350
- var import_transactions17 = require("@fuel-ts/transactions");
3248
+ var import_transactions16 = require("@fuel-ts/transactions");
3351
3249
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3352
3250
  return receipts.reduce((logs, receipt) => {
3353
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3251
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3354
3252
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3355
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3253
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3356
3254
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3357
3255
  logs.push(decodedLog);
3358
3256
  }
@@ -3367,7 +3265,7 @@ var TransactionResponse = class {
3367
3265
  /** Current provider */
3368
3266
  provider;
3369
3267
  /** Gas used on the transaction */
3370
- gasUsed = (0, import_math15.bn)(0);
3268
+ gasUsed = (0, import_math14.bn)(0);
3371
3269
  /** The graphql Transaction with receipts object. */
3372
3270
  gqlTransaction;
3373
3271
  abis;
@@ -3425,8 +3323,8 @@ var TransactionResponse = class {
3425
3323
  * @returns The decoded transaction.
3426
3324
  */
3427
3325
  decodeTransaction(transactionWithReceipts) {
3428
- return new import_transactions18.TransactionCoder().decode(
3429
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3326
+ return new import_transactions17.TransactionCoder().decode(
3327
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3430
3328
  0
3431
3329
  )?.[0];
3432
3330
  }
@@ -3445,27 +3343,20 @@ var TransactionResponse = class {
3445
3343
  const decodedTransaction = this.decodeTransaction(
3446
3344
  transaction
3447
3345
  );
3448
- let txReceipts = [];
3449
- if (transaction?.status && "receipts" in transaction.status) {
3450
- txReceipts = transaction.status.receipts;
3451
- }
3452
- const receipts = txReceipts.map(processGqlReceipt) || [];
3453
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3454
- const gasPrice = await this.provider.getLatestGasPrice();
3346
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3347
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3455
3348
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3456
3349
  const transactionSummary = assembleTransactionSummary({
3457
3350
  id: this.id,
3458
3351
  receipts,
3459
3352
  transaction: decodedTransaction,
3460
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3353
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3461
3354
  gqlTransactionStatus: transaction.status,
3462
3355
  gasPerByte,
3463
3356
  gasPriceFactor,
3464
3357
  abiMap: contractsAbiMap,
3465
3358
  maxInputs,
3466
- gasCosts,
3467
- maxGasPerTx,
3468
- gasPrice
3359
+ gasCosts
3469
3360
  });
3470
3361
  return transactionSummary;
3471
3362
  }
@@ -3592,29 +3483,29 @@ var processGqlChain = (chain) => {
3592
3483
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3593
3484
  return {
3594
3485
  name,
3595
- baseChainHeight: (0, import_math16.bn)(daHeight),
3486
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3596
3487
  consensusParameters: {
3597
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3598
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3599
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3600
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3601
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3602
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3603
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3604
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3605
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3606
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3607
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3608
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3609
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3610
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3611
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3488
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3489
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3490
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3491
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3492
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3493
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3494
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3495
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3496
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3497
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3498
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3499
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3500
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3501
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3502
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3612
3503
  gasCosts
3613
3504
  },
3614
3505
  gasCosts,
3615
3506
  latestBlock: {
3616
3507
  id: latestBlock.id,
3617
- height: (0, import_math16.bn)(latestBlock.height),
3508
+ height: (0, import_math15.bn)(latestBlock.header.height),
3618
3509
  time: latestBlock.header.time,
3619
3510
  transactions: latestBlock.transactions.map((i) => ({
3620
3511
  id: i.id
@@ -3708,8 +3599,10 @@ var _Provider = class {
3708
3599
  * Returns some helpful parameters related to gas fees.
3709
3600
  */
3710
3601
  getGasConfig() {
3602
+ const { minGasPrice } = this.getNode();
3711
3603
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3712
3604
  return {
3605
+ minGasPrice,
3713
3606
  maxGasPerTx,
3714
3607
  maxGasPerPredicate,
3715
3608
  gasPriceFactor,
@@ -3807,7 +3700,7 @@ var _Provider = class {
3807
3700
  */
3808
3701
  async getBlockNumber() {
3809
3702
  const { chain } = await this.operations.getChain();
3810
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3703
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3811
3704
  }
3812
3705
  /**
3813
3706
  * Returns the chain information.
@@ -3817,11 +3710,13 @@ var _Provider = class {
3817
3710
  async fetchNode() {
3818
3711
  const { nodeInfo } = await this.operations.getNodeInfo();
3819
3712
  const processedNodeInfo = {
3820
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3821
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3713
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3714
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3715
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3822
3716
  nodeVersion: nodeInfo.nodeVersion,
3823
3717
  utxoValidation: nodeInfo.utxoValidation,
3824
- vmBacktrace: nodeInfo.vmBacktrace
3718
+ vmBacktrace: nodeInfo.vmBacktrace,
3719
+ peers: nodeInfo.peers
3825
3720
  };
3826
3721
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3827
3722
  return processedNodeInfo;
@@ -3863,9 +3758,9 @@ var _Provider = class {
3863
3758
  if (estimateTxDependencies) {
3864
3759
  await this.estimateTxDependencies(transactionRequest);
3865
3760
  }
3866
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3761
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3867
3762
  let abis;
3868
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3763
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3869
3764
  abis = transactionRequest.abis;
3870
3765
  }
3871
3766
  if (awaitExecution) {
@@ -3906,14 +3801,15 @@ var _Provider = class {
3906
3801
  if (estimateTxDependencies) {
3907
3802
  return this.estimateTxDependencies(transactionRequest);
3908
3803
  }
3909
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3910
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3911
- encodedTransactions: encodedTransaction,
3804
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3805
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3806
+ encodedTransaction,
3912
3807
  utxoValidation: utxoValidation || false
3913
3808
  });
3914
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3915
- const receipts = rawReceipts.map(processGqlReceipt);
3916
- return { receipts, dryrunStatus: status };
3809
+ const receipts = gqlReceipts.map(processGqlReceipt);
3810
+ return {
3811
+ receipts
3812
+ };
3917
3813
  }
3918
3814
  /**
3919
3815
  * Verifies whether enough gas is available to complete transaction.
@@ -3924,13 +3820,13 @@ var _Provider = class {
3924
3820
  async estimatePredicates(transactionRequest) {
3925
3821
  const shouldEstimatePredicates = Boolean(
3926
3822
  transactionRequest.inputs.find(
3927
- (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()
3823
+ (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()
3928
3824
  )
3929
3825
  );
3930
3826
  if (!shouldEstimatePredicates) {
3931
3827
  return transactionRequest;
3932
3828
  }
3933
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3829
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3934
3830
  const response = await this.operations.estimatePredicates({
3935
3831
  encodedTransaction
3936
3832
  });
@@ -3939,7 +3835,7 @@ var _Provider = class {
3939
3835
  } = response;
3940
3836
  if (inputs) {
3941
3837
  inputs.forEach((input, index) => {
3942
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
3838
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3943
3839
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3944
3840
  }
3945
3841
  });
@@ -3952,31 +3848,31 @@ var _Provider = class {
3952
3848
  * If there are missing variable outputs,
3953
3849
  * `addVariableOutputs` is called on the transaction.
3954
3850
  *
3851
+ * @privateRemarks
3852
+ * TODO: Investigate support for missing contract IDs
3853
+ * TODO: Add support for missing output messages
3955
3854
  *
3956
3855
  * @param transactionRequest - The transaction request object.
3957
3856
  * @returns A promise.
3958
3857
  */
3959
3858
  async estimateTxDependencies(transactionRequest) {
3960
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
3859
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3961
3860
  return {
3962
3861
  receipts: [],
3963
3862
  outputVariables: 0,
3964
3863
  missingContractIds: []
3965
3864
  };
3966
3865
  }
3866
+ await this.estimatePredicates(transactionRequest);
3967
3867
  let receipts = [];
3968
3868
  const missingContractIds = [];
3969
3869
  let outputVariables = 0;
3970
- let dryrunStatus;
3971
3870
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3972
- const {
3973
- dryRun: [{ receipts: rawReceipts, status }]
3974
- } = await this.operations.dryRun({
3975
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
3871
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3872
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
3976
3873
  utxoValidation: false
3977
3874
  });
3978
- receipts = rawReceipts.map(processGqlReceipt);
3979
- dryrunStatus = status;
3875
+ receipts = gqlReceipts.map(processGqlReceipt);
3980
3876
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3981
3877
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3982
3878
  if (hasMissingOutputs) {
@@ -3986,10 +3882,6 @@ var _Provider = class {
3986
3882
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
3987
3883
  missingContractIds.push(contractId);
3988
3884
  });
3989
- const { maxFee } = await this.estimateTxGasAndFee({
3990
- transactionRequest
3991
- });
3992
- transactionRequest.maxFee = maxFee;
3993
3885
  } else {
3994
3886
  break;
3995
3887
  }
@@ -3997,139 +3889,37 @@ var _Provider = class {
3997
3889
  return {
3998
3890
  receipts,
3999
3891
  outputVariables,
4000
- missingContractIds,
4001
- dryrunStatus
3892
+ missingContractIds
4002
3893
  };
4003
3894
  }
4004
- /**
4005
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4006
- *
4007
- * Transactions are dry run in batches. After each dry run, transactions requiring
4008
- * further modifications are identified. The method iteratively updates these transactions
4009
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4010
- *
4011
- * @param transactionRequests - Array of transaction request objects.
4012
- * @returns A promise that resolves to an array of results for each transaction.
4013
- */
4014
- async estimateMultipleTxDependencies(transactionRequests) {
4015
- const results = transactionRequests.map(() => ({
4016
- receipts: [],
4017
- outputVariables: 0,
4018
- missingContractIds: [],
4019
- dryrunStatus: void 0
4020
- }));
4021
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4022
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4023
- allRequests.forEach((req, index) => {
4024
- if (req.type === import_transactions19.TransactionType.Script) {
4025
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4026
- }
4027
- });
4028
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4029
- let attempt = 0;
4030
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4031
- const encodedTransactions = transactionsToProcess.map(
4032
- (index) => serializedTransactionsMap.get(index)
4033
- );
4034
- const dryRunResults = await this.operations.dryRun({
4035
- encodedTransactions,
4036
- utxoValidation: false
4037
- });
4038
- const nextRoundTransactions = [];
4039
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4040
- const currentResultIndex = transactionsToProcess[i];
4041
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4042
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4043
- results[currentResultIndex].dryrunStatus = status;
4044
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4045
- results[currentResultIndex].receipts
4046
- );
4047
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4048
- const requestToProcess = allRequests[currentResultIndex];
4049
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4050
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4051
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4052
- missingOutputContractIds.forEach(({ contractId }) => {
4053
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4054
- results[currentResultIndex].missingContractIds.push(contractId);
4055
- });
4056
- const { maxFee } = await this.estimateTxGasAndFee({
4057
- transactionRequest: requestToProcess
4058
- });
4059
- requestToProcess.maxFee = maxFee;
4060
- serializedTransactionsMap.set(
4061
- currentResultIndex,
4062
- (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4063
- );
4064
- nextRoundTransactions.push(currentResultIndex);
4065
- allRequests[currentResultIndex] = requestToProcess;
4066
- }
4067
- }
4068
- transactionsToProcess = nextRoundTransactions;
4069
- attempt += 1;
4070
- }
4071
- return results;
4072
- }
4073
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4074
- if (estimateTxDependencies) {
4075
- return this.estimateMultipleTxDependencies(transactionRequests);
4076
- }
4077
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4078
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4079
- encodedTransactions,
4080
- utxoValidation: utxoValidation || false
4081
- });
4082
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4083
- const receipts = rawReceipts.map(processGqlReceipt);
4084
- return { receipts, dryrunStatus: status };
4085
- });
4086
- return results;
4087
- }
4088
3895
  /**
4089
3896
  * Estimates the transaction gas and fee based on the provided transaction request.
4090
3897
  * @param transactionRequest - The transaction request object.
4091
3898
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4092
3899
  */
4093
- async estimateTxGasAndFee(params) {
3900
+ estimateTxGasAndFee(params) {
4094
3901
  const { transactionRequest } = params;
4095
- let { gasPrice } = params;
3902
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4096
3903
  const chainInfo = this.getChain();
4097
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3904
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3905
+ transactionRequest.gasPrice = gasPrice;
4098
3906
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4099
- if (!gasPrice) {
4100
- gasPrice = await this.estimateGasPrice(10);
4101
- }
4102
- const minFee = calculateGasFee({
4103
- gasPrice: (0, import_math16.bn)(gasPrice),
4104
- gas: minGas,
4105
- priceFactor: gasPriceFactor,
4106
- tip: transactionRequest.tip
4107
- }).add(1);
4108
- let gasLimit = (0, import_math16.bn)(0);
4109
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4110
- gasLimit = transactionRequest.gasLimit;
3907
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3908
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4111
3909
  if (transactionRequest.gasLimit.eq(0)) {
4112
3910
  transactionRequest.gasLimit = minGas;
4113
3911
  transactionRequest.gasLimit = maxGasPerTx.sub(
4114
3912
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4115
3913
  );
4116
- gasLimit = transactionRequest.gasLimit;
4117
3914
  }
4118
3915
  }
4119
3916
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4120
- const maxFee = calculateGasFee({
4121
- gasPrice: (0, import_math16.bn)(gasPrice),
4122
- gas: maxGas,
4123
- priceFactor: gasPriceFactor,
4124
- tip: transactionRequest.tip
4125
- }).add(1);
3917
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4126
3918
  return {
4127
3919
  minGas,
4128
3920
  minFee,
4129
3921
  maxGas,
4130
- maxFee,
4131
- gasPrice,
4132
- gasLimit
3922
+ maxFee
4133
3923
  };
4134
3924
  }
4135
3925
  /**
@@ -4147,17 +3937,15 @@ var _Provider = class {
4147
3937
  if (estimateTxDependencies) {
4148
3938
  return this.estimateTxDependencies(transactionRequest);
4149
3939
  }
4150
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4151
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4152
- encodedTransactions,
3940
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3941
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3942
+ encodedTransaction,
4153
3943
  utxoValidation: true
4154
3944
  });
4155
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4156
- const { id, receipts, status } = dryRunStatus;
4157
- const processedReceipts = receipts.map(processGqlReceipt);
4158
- return { id, receipts: processedReceipts, status };
4159
- });
4160
- return { receipts: callResult[0].receipts };
3945
+ const receipts = gqlReceipts.map(processGqlReceipt);
3946
+ return {
3947
+ receipts
3948
+ };
4161
3949
  }
4162
3950
  /**
4163
3951
  * Returns a transaction cost to enable user
@@ -4174,79 +3962,77 @@ var _Provider = class {
4174
3962
  * @param tolerance - The tolerance to add on top of the gasUsed.
4175
3963
  * @returns A promise that resolves to the transaction cost object.
4176
3964
  */
4177
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3965
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3966
+ estimateTxDependencies = true,
3967
+ estimatePredicates = true,
3968
+ resourcesOwner,
3969
+ signatureCallback
3970
+ } = {}) {
4178
3971
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4179
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
3972
+ const { minGasPrice } = this.getGasConfig();
3973
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3974
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4180
3975
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4181
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3976
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4182
3977
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4183
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4184
3978
  if (isScriptTransaction) {
4185
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
3979
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4186
3980
  }
4187
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4188
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3981
+ if (estimatePredicates) {
3982
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3983
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3984
+ }
3985
+ await this.estimatePredicates(txRequestClone);
4189
3986
  }
4190
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4191
- let addedSignatures = 0;
4192
3987
  if (signatureCallback && isScriptTransaction) {
4193
- const lengthBefore = signedRequest.witnesses.length;
4194
- await signatureCallback(signedRequest);
4195
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
3988
+ await signatureCallback(txRequestClone);
4196
3989
  }
4197
- await this.estimatePredicates(signedRequest);
4198
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4199
- transactionRequest: signedRequest
3990
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3991
+ transactionRequest: txRequestClone
4200
3992
  });
4201
3993
  let receipts = [];
4202
3994
  let missingContractIds = [];
4203
3995
  let outputVariables = 0;
4204
- let gasUsed = (0, import_math16.bn)(0);
4205
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4206
- txRequestClone.maxFee = maxFee;
4207
- if (isScriptTransaction) {
4208
- txRequestClone.gasLimit = gasLimit;
4209
- if (signatureCallback) {
4210
- await signatureCallback(txRequestClone);
4211
- }
3996
+ let gasUsed = (0, import_math15.bn)(0);
3997
+ if (isScriptTransaction && estimateTxDependencies) {
3998
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4212
3999
  const result = await this.estimateTxDependencies(txRequestClone);
4213
4000
  receipts = result.receipts;
4214
4001
  outputVariables = result.outputVariables;
4215
4002
  missingContractIds = result.missingContractIds;
4216
4003
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4217
4004
  txRequestClone.gasLimit = gasUsed;
4218
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4219
- transactionRequest: txRequestClone,
4220
- gasPrice
4005
+ txRequestClone.gasPrice = setGasPrice;
4006
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4007
+ transactionRequest: txRequestClone
4221
4008
  }));
4222
4009
  }
4223
4010
  return {
4224
4011
  requiredQuantities: allQuantities,
4225
4012
  receipts,
4226
4013
  gasUsed,
4227
- gasPrice,
4014
+ minGasPrice,
4015
+ gasPrice: setGasPrice,
4228
4016
  minGas,
4229
4017
  maxGas,
4230
4018
  minFee,
4231
4019
  maxFee,
4020
+ estimatedInputs: txRequestClone.inputs,
4232
4021
  outputVariables,
4233
- missingContractIds,
4234
- addedSignatures,
4235
- estimatedPredicates: txRequestClone.inputs
4022
+ missingContractIds
4236
4023
  };
4237
4024
  }
4238
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4025
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4239
4026
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4240
4027
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4241
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4242
- quantitiesToContract
4243
- });
4028
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4244
4029
  transactionRequest.addResources(
4245
4030
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4246
4031
  );
4247
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4248
- quantitiesToContract
4249
- });
4032
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4033
+ transactionRequest,
4034
+ forwardingQuantities
4035
+ );
4250
4036
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4251
4037
  return {
4252
4038
  resources,
@@ -4262,16 +4048,17 @@ var _Provider = class {
4262
4048
  const result = await this.operations.getCoins({
4263
4049
  first: 10,
4264
4050
  ...paginationArgs,
4265
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4051
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4266
4052
  });
4267
4053
  const coins = result.coins.edges.map((edge) => edge.node);
4268
4054
  return coins.map((coin) => ({
4269
4055
  id: coin.utxoId,
4270
4056
  assetId: coin.assetId,
4271
- amount: (0, import_math16.bn)(coin.amount),
4057
+ amount: (0, import_math15.bn)(coin.amount),
4272
4058
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4273
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4274
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4059
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4060
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4061
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4275
4062
  }));
4276
4063
  }
4277
4064
  /**
@@ -4285,19 +4072,19 @@ var _Provider = class {
4285
4072
  async getResourcesToSpend(owner, quantities, excludedIds) {
4286
4073
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4287
4074
  const excludeInput = {
4288
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4289
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4075
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4076
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4290
4077
  };
4291
4078
  if (this.cache) {
4292
4079
  const uniqueUtxos = new Set(
4293
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4080
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4294
4081
  );
4295
4082
  excludeInput.utxos = Array.from(uniqueUtxos);
4296
4083
  }
4297
4084
  const coinsQuery = {
4298
4085
  owner: ownerAddress.toB256(),
4299
4086
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4300
- assetId: (0, import_utils22.hexlify)(assetId),
4087
+ assetId: (0, import_utils23.hexlify)(assetId),
4301
4088
  amount: amount.toString(10),
4302
4089
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4303
4090
  })),
@@ -4308,9 +4095,9 @@ var _Provider = class {
4308
4095
  switch (coin.__typename) {
4309
4096
  case "MessageCoin":
4310
4097
  return {
4311
- amount: (0, import_math16.bn)(coin.amount),
4098
+ amount: (0, import_math15.bn)(coin.amount),
4312
4099
  assetId: coin.assetId,
4313
- daHeight: (0, import_math16.bn)(coin.daHeight),
4100
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4314
4101
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4315
4102
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4316
4103
  nonce: coin.nonce
@@ -4318,11 +4105,12 @@ var _Provider = class {
4318
4105
  case "Coin":
4319
4106
  return {
4320
4107
  id: coin.utxoId,
4321
- amount: (0, import_math16.bn)(coin.amount),
4108
+ amount: (0, import_math15.bn)(coin.amount),
4322
4109
  assetId: coin.assetId,
4323
4110
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4324
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4325
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4111
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4112
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4113
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4326
4114
  };
4327
4115
  default:
4328
4116
  return null;
@@ -4339,13 +4127,13 @@ var _Provider = class {
4339
4127
  async getBlock(idOrHeight) {
4340
4128
  let variables;
4341
4129
  if (typeof idOrHeight === "number") {
4342
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4130
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4343
4131
  } else if (idOrHeight === "latest") {
4344
4132
  variables = { height: (await this.getBlockNumber()).toString(10) };
4345
4133
  } else if (idOrHeight.length === 66) {
4346
4134
  variables = { blockId: idOrHeight };
4347
4135
  } else {
4348
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4136
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4349
4137
  }
4350
4138
  const { block } = await this.operations.getBlock(variables);
4351
4139
  if (!block) {
@@ -4353,7 +4141,7 @@ var _Provider = class {
4353
4141
  }
4354
4142
  return {
4355
4143
  id: block.id,
4356
- height: (0, import_math16.bn)(block.height),
4144
+ height: (0, import_math15.bn)(block.header.height),
4357
4145
  time: block.header.time,
4358
4146
  transactionIds: block.transactions.map((tx) => tx.id)
4359
4147
  };
@@ -4368,7 +4156,7 @@ var _Provider = class {
4368
4156
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4369
4157
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4370
4158
  id: block.id,
4371
- height: (0, import_math16.bn)(block.height),
4159
+ height: (0, import_math15.bn)(block.header.height),
4372
4160
  time: block.header.time,
4373
4161
  transactionIds: block.transactions.map((tx) => tx.id)
4374
4162
  }));
@@ -4383,7 +4171,7 @@ var _Provider = class {
4383
4171
  async getBlockWithTransactions(idOrHeight) {
4384
4172
  let variables;
4385
4173
  if (typeof idOrHeight === "number") {
4386
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4174
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4387
4175
  } else if (idOrHeight === "latest") {
4388
4176
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4389
4177
  } else {
@@ -4395,11 +4183,11 @@ var _Provider = class {
4395
4183
  }
4396
4184
  return {
4397
4185
  id: block.id,
4398
- height: (0, import_math16.bn)(block.height, 10),
4186
+ height: (0, import_math15.bn)(block.header.height, 10),
4399
4187
  time: block.header.time,
4400
4188
  transactionIds: block.transactions.map((tx) => tx.id),
4401
4189
  transactions: block.transactions.map(
4402
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4190
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4403
4191
  )
4404
4192
  };
4405
4193
  }
@@ -4414,8 +4202,8 @@ var _Provider = class {
4414
4202
  if (!transaction) {
4415
4203
  return null;
4416
4204
  }
4417
- return new import_transactions19.TransactionCoder().decode(
4418
- (0, import_utils22.arrayify)(transaction.rawPayload),
4205
+ return new import_transactions18.TransactionCoder().decode(
4206
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4419
4207
  0
4420
4208
  )?.[0];
4421
4209
  }
@@ -4442,9 +4230,9 @@ var _Provider = class {
4442
4230
  async getContractBalance(contractId, assetId) {
4443
4231
  const { contractBalance } = await this.operations.getContractBalance({
4444
4232
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4445
- asset: (0, import_utils22.hexlify)(assetId)
4233
+ asset: (0, import_utils23.hexlify)(assetId)
4446
4234
  });
4447
- return (0, import_math16.bn)(contractBalance.amount, 10);
4235
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4448
4236
  }
4449
4237
  /**
4450
4238
  * Returns the balance for the given owner for the given asset ID.
@@ -4456,9 +4244,9 @@ var _Provider = class {
4456
4244
  async getBalance(owner, assetId) {
4457
4245
  const { balance } = await this.operations.getBalance({
4458
4246
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4459
- assetId: (0, import_utils22.hexlify)(assetId)
4247
+ assetId: (0, import_utils23.hexlify)(assetId)
4460
4248
  });
4461
- return (0, import_math16.bn)(balance.amount, 10);
4249
+ return (0, import_math15.bn)(balance.amount, 10);
4462
4250
  }
4463
4251
  /**
4464
4252
  * Returns balances for the given owner.
@@ -4476,7 +4264,7 @@ var _Provider = class {
4476
4264
  const balances = result.balances.edges.map((edge) => edge.node);
4477
4265
  return balances.map((balance) => ({
4478
4266
  assetId: balance.assetId,
4479
- amount: (0, import_math16.bn)(balance.amount)
4267
+ amount: (0, import_math15.bn)(balance.amount)
4480
4268
  }));
4481
4269
  }
4482
4270
  /**
@@ -4494,19 +4282,19 @@ var _Provider = class {
4494
4282
  });
4495
4283
  const messages = result.messages.edges.map((edge) => edge.node);
4496
4284
  return messages.map((message) => ({
4497
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4285
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4498
4286
  sender: message.sender,
4499
4287
  recipient: message.recipient,
4500
4288
  nonce: message.nonce,
4501
- amount: (0, import_math16.bn)(message.amount),
4289
+ amount: (0, import_math15.bn)(message.amount),
4502
4290
  data: message.data
4503
4291
  }),
4504
4292
  sender: import_address3.Address.fromAddressOrString(message.sender),
4505
4293
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4506
4294
  nonce: message.nonce,
4507
- amount: (0, import_math16.bn)(message.amount),
4508
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4509
- daHeight: (0, import_math16.bn)(message.daHeight)
4295
+ amount: (0, import_math15.bn)(message.amount),
4296
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4297
+ daHeight: (0, import_math15.bn)(message.daHeight)
4510
4298
  }));
4511
4299
  }
4512
4300
  /**
@@ -4559,60 +4347,44 @@ var _Provider = class {
4559
4347
  } = result.messageProof;
4560
4348
  return {
4561
4349
  messageProof: {
4562
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4350
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4563
4351
  proofSet: messageProof.proofSet
4564
4352
  },
4565
4353
  blockProof: {
4566
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4354
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4567
4355
  proofSet: blockProof.proofSet
4568
4356
  },
4569
4357
  messageBlockHeader: {
4570
4358
  id: messageBlockHeader.id,
4571
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4572
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4359
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4360
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4573
4361
  transactionsRoot: messageBlockHeader.transactionsRoot,
4574
- height: (0, import_math16.bn)(messageBlockHeader.height),
4362
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4575
4363
  prevRoot: messageBlockHeader.prevRoot,
4576
4364
  time: messageBlockHeader.time,
4577
4365
  applicationHash: messageBlockHeader.applicationHash,
4578
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4579
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4580
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4581
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4582
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4366
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4367
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4583
4368
  },
4584
4369
  commitBlockHeader: {
4585
4370
  id: commitBlockHeader.id,
4586
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4587
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4371
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4372
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4588
4373
  transactionsRoot: commitBlockHeader.transactionsRoot,
4589
- height: (0, import_math16.bn)(commitBlockHeader.height),
4374
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4590
4375
  prevRoot: commitBlockHeader.prevRoot,
4591
4376
  time: commitBlockHeader.time,
4592
4377
  applicationHash: commitBlockHeader.applicationHash,
4593
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4594
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4595
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4596
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4597
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4378
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4379
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4598
4380
  },
4599
4381
  sender: import_address3.Address.fromAddressOrString(sender),
4600
4382
  recipient: import_address3.Address.fromAddressOrString(recipient),
4601
4383
  nonce,
4602
- amount: (0, import_math16.bn)(amount),
4384
+ amount: (0, import_math15.bn)(amount),
4603
4385
  data
4604
4386
  };
4605
4387
  }
4606
- async getLatestGasPrice() {
4607
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4608
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4609
- }
4610
- async estimateGasPrice(blockHorizon) {
4611
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4612
- blockHorizon: String(blockHorizon)
4613
- });
4614
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4615
- }
4616
4388
  /**
4617
4389
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4618
4390
  *
@@ -4632,10 +4404,10 @@ var _Provider = class {
4632
4404
  */
4633
4405
  async produceBlocks(amount, startTime) {
4634
4406
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4635
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4636
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4407
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4408
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4637
4409
  });
4638
- return (0, import_math16.bn)(latestBlockHeight);
4410
+ return (0, import_math15.bn)(latestBlockHeight);
4639
4411
  }
4640
4412
  // eslint-disable-next-line @typescript-eslint/require-await
4641
4413
  async getTransactionResponse(transactionId) {
@@ -4649,7 +4421,7 @@ cacheInputs_fn = function(inputs) {
4649
4421
  return;
4650
4422
  }
4651
4423
  inputs.forEach((input) => {
4652
- if (input.type === import_transactions19.InputType.Coin) {
4424
+ if (input.type === import_transactions18.InputType.Coin) {
4653
4425
  this.cache?.set(input.id);
4654
4426
  }
4655
4427
  });
@@ -4659,9 +4431,9 @@ __publicField(Provider, "nodeInfoCache", {});
4659
4431
 
4660
4432
  // src/providers/transaction-summary/get-transaction-summary.ts
4661
4433
  var import_errors15 = require("@fuel-ts/errors");
4662
- var import_math17 = require("@fuel-ts/math");
4663
- var import_transactions20 = require("@fuel-ts/transactions");
4664
- var import_utils25 = require("@fuel-ts/utils");
4434
+ var import_math16 = require("@fuel-ts/math");
4435
+ var import_transactions19 = require("@fuel-ts/transactions");
4436
+ var import_utils26 = require("@fuel-ts/utils");
4665
4437
 
4666
4438
  // src/providers/chains.ts
4667
4439
  var CHAIN_IDS = {
@@ -4710,17 +4482,17 @@ var assets = [
4710
4482
 
4711
4483
  // src/utils/formatTransferToContractScriptData.ts
4712
4484
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4713
- var import_math18 = require("@fuel-ts/math");
4714
- var import_utils26 = require("@fuel-ts/utils");
4485
+ var import_math17 = require("@fuel-ts/math");
4486
+ var import_utils27 = require("@fuel-ts/utils");
4715
4487
  var asm = __toESM(require("@fuels/vm-asm"));
4716
4488
  var formatTransferToContractScriptData = (params) => {
4717
4489
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4718
4490
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4719
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4491
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4720
4492
  const scriptData = Uint8Array.from([
4721
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4493
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4722
4494
  ...encoded,
4723
- ...(0, import_utils26.arrayify)(assetId)
4495
+ ...(0, import_utils27.arrayify)(assetId)
4724
4496
  ]);
4725
4497
  return scriptData;
4726
4498
  };
@@ -4905,33 +4677,36 @@ var Account = class extends import_interfaces.AbstractAccount {
4905
4677
  * @param fee - The estimated transaction fee.
4906
4678
  * @returns A promise that resolves when the resources are added to the transaction.
4907
4679
  */
4908
- async fund(request, params) {
4909
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4910
- const txRequest = request;
4911
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4912
- amount: (0, import_math19.bn)(fee),
4680
+ async fund(request, coinQuantities, fee) {
4681
+ const updatedQuantities = addAmountToAsset({
4682
+ amount: (0, import_math18.bn)(fee),
4913
4683
  assetId: import_configs12.BaseAssetId,
4914
- coinQuantities: requiredQuantities
4684
+ coinQuantities
4915
4685
  });
4916
4686
  const quantitiesDict = {};
4917
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4687
+ updatedQuantities.forEach(({ amount, assetId }) => {
4918
4688
  quantitiesDict[assetId] = {
4919
4689
  required: amount,
4920
- owned: (0, import_math19.bn)(0)
4690
+ owned: (0, import_math18.bn)(0)
4921
4691
  };
4922
4692
  });
4923
- txRequest.inputs.forEach((input) => {
4693
+ const cachedUtxos = [];
4694
+ const cachedMessages = [];
4695
+ const owner = this.address.toB256();
4696
+ request.inputs.forEach((input) => {
4924
4697
  const isResource = "amount" in input;
4925
4698
  if (isResource) {
4926
4699
  const isCoin2 = "owner" in input;
4927
4700
  if (isCoin2) {
4928
4701
  const assetId = String(input.assetId);
4929
- if (quantitiesDict[assetId]) {
4930
- const amount = (0, import_math19.bn)(input.amount);
4702
+ if (input.owner === owner && quantitiesDict[assetId]) {
4703
+ const amount = (0, import_math18.bn)(input.amount);
4931
4704
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4705
+ cachedUtxos.push(input.id);
4932
4706
  }
4933
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4707
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4934
4708
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4709
+ cachedMessages.push(input.nonce);
4935
4710
  }
4936
4711
  }
4937
4712
  });
@@ -4946,23 +4721,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4946
4721
  });
4947
4722
  const needsToBeFunded = missingQuantities.length;
4948
4723
  if (needsToBeFunded) {
4949
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4950
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4951
- txRequest.addResources(resources);
4952
- }
4953
- txRequest.shiftPredicateData();
4954
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4955
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
4956
- if (addedSignatures) {
4957
- Array.from({ length: addedSignatures }).forEach(
4958
- () => requestToBeReEstimate.addEmptyWitness()
4959
- );
4724
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4725
+ messages: cachedMessages,
4726
+ utxos: cachedUtxos
4727
+ });
4728
+ request.addResources(resources);
4960
4729
  }
4961
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4962
- transactionRequest: requestToBeReEstimate
4963
- });
4964
- txRequest.maxFee = maxFee;
4965
- return txRequest;
4966
4730
  }
4967
4731
  /**
4968
4732
  * A helper that creates a transfer transaction request and returns it.
@@ -4970,25 +4734,28 @@ var Account = class extends import_interfaces.AbstractAccount {
4970
4734
  * @param destination - The address of the destination.
4971
4735
  * @param amount - The amount of coins to transfer.
4972
4736
  * @param assetId - The asset ID of the coins to transfer.
4973
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4737
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4974
4738
  * @returns A promise that resolves to the prepared transaction request.
4975
4739
  */
4976
4740
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4977
- const request = new ScriptTransactionRequest(txParams);
4741
+ const { minGasPrice } = this.provider.getGasConfig();
4742
+ const params = { gasPrice: minGasPrice, ...txParams };
4743
+ const request = new ScriptTransactionRequest(params);
4978
4744
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
4979
- const txCost = await this.provider.getTransactionCost(request, {
4745
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4980
4746
  estimateTxDependencies: true,
4981
4747
  resourcesOwner: this
4982
4748
  });
4983
- if ("gasLimit" in txParams) {
4984
- this.validateGas({
4985
- gasUsed: txCost.gasUsed,
4986
- gasLimit: request.gasLimit
4987
- });
4988
- }
4989
- request.gasLimit = txCost.gasUsed;
4990
- request.maxFee = txCost.maxFee;
4991
- await this.fund(request, txCost);
4749
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
4750
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
4751
+ this.validateGas({
4752
+ gasUsed,
4753
+ gasPrice: request.gasPrice,
4754
+ gasLimit: request.gasLimit,
4755
+ minGasPrice
4756
+ });
4757
+ await this.fund(request, requiredQuantities, maxFee);
4758
+ request.updatePredicateInputs(estimatedInputs);
4992
4759
  return request;
4993
4760
  }
4994
4761
  /**
@@ -5001,7 +4768,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5001
4768
  * @returns A promise that resolves to the transaction response.
5002
4769
  */
5003
4770
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5004
- if ((0, import_math19.bn)(amount).lte(0)) {
4771
+ if ((0, import_math18.bn)(amount).lte(0)) {
5005
4772
  throw new import_errors16.FuelError(
5006
4773
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5007
4774
  "Transfer amount must be a positive number."
@@ -5020,37 +4787,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5020
4787
  * @returns A promise that resolves to the transaction response.
5021
4788
  */
5022
4789
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5023
- if ((0, import_math19.bn)(amount).lte(0)) {
4790
+ if ((0, import_math18.bn)(amount).lte(0)) {
5024
4791
  throw new import_errors16.FuelError(
5025
4792
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5026
4793
  "Transfer amount must be a positive number."
5027
4794
  );
5028
4795
  }
5029
4796
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4797
+ const { minGasPrice } = this.provider.getGasConfig();
4798
+ const params = { gasPrice: minGasPrice, ...txParams };
5030
4799
  const { script, scriptData } = await assembleTransferToContractScript({
5031
4800
  hexlifiedContractId: contractAddress.toB256(),
5032
- amountToTransfer: (0, import_math19.bn)(amount),
4801
+ amountToTransfer: (0, import_math18.bn)(amount),
5033
4802
  assetId
5034
4803
  });
5035
4804
  const request = new ScriptTransactionRequest({
5036
- ...txParams,
4805
+ ...params,
5037
4806
  script,
5038
4807
  scriptData
5039
4808
  });
5040
4809
  request.addContractInputAndOutput(contractAddress);
5041
- const txCost = await this.provider.getTransactionCost(request, {
5042
- resourcesOwner: this,
5043
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
4810
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4811
+ request,
4812
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
4813
+ );
4814
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4815
+ this.validateGas({
4816
+ gasUsed,
4817
+ gasPrice: request.gasPrice,
4818
+ gasLimit: request.gasLimit,
4819
+ minGasPrice
5044
4820
  });
5045
- if (txParams.gasLimit) {
5046
- this.validateGas({
5047
- gasUsed: txCost.gasUsed,
5048
- gasLimit: request.gasLimit
5049
- });
5050
- }
5051
- request.gasLimit = txCost.gasUsed;
5052
- request.maxFee = txCost.maxFee;
5053
- await this.fund(request, txCost);
4821
+ await this.fund(request, requiredQuantities, maxFee);
5054
4822
  return this.sendTransaction(request);
5055
4823
  }
5056
4824
  /**
@@ -5062,31 +4830,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5062
4830
  * @returns A promise that resolves to the transaction response.
5063
4831
  */
5064
4832
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4833
+ const { minGasPrice } = this.provider.getGasConfig();
5065
4834
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5066
- const recipientDataArray = (0, import_utils27.arrayify)(
4835
+ const recipientDataArray = (0, import_utils28.arrayify)(
5067
4836
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5068
4837
  );
5069
- const amountDataArray = (0, import_utils27.arrayify)(
5070
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
4838
+ const amountDataArray = (0, import_utils28.arrayify)(
4839
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5071
4840
  );
5072
4841
  const script = new Uint8Array([
5073
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4842
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5074
4843
  ...recipientDataArray,
5075
4844
  ...amountDataArray
5076
4845
  ]);
5077
- const params = { script, ...txParams };
4846
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5078
4847
  const request = new ScriptTransactionRequest(params);
5079
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5080
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5081
- if (txParams.gasLimit) {
5082
- this.validateGas({
5083
- gasUsed: txCost.gasUsed,
5084
- gasLimit: request.gasLimit
5085
- });
5086
- }
5087
- request.maxFee = txCost.maxFee;
5088
- request.gasLimit = txCost.gasUsed;
5089
- await this.fund(request, txCost);
4848
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
4849
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4850
+ request,
4851
+ forwardingQuantities
4852
+ );
4853
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4854
+ this.validateGas({
4855
+ gasUsed,
4856
+ gasPrice: request.gasPrice,
4857
+ gasLimit: request.gasLimit,
4858
+ minGasPrice
4859
+ });
4860
+ await this.fund(request, requiredQuantities, maxFee);
5090
4861
  return this.sendTransaction(request);
5091
4862
  }
5092
4863
  async signMessage(message) {
@@ -5144,7 +4915,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5144
4915
  }
5145
4916
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5146
4917
  }
5147
- validateGas({ gasUsed, gasLimit }) {
4918
+ validateGas({
4919
+ gasUsed,
4920
+ gasPrice,
4921
+ gasLimit,
4922
+ minGasPrice
4923
+ }) {
4924
+ if (minGasPrice.gt(gasPrice)) {
4925
+ throw new import_errors16.FuelError(
4926
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4927
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4928
+ );
4929
+ }
5148
4930
  if (gasUsed.gt(gasLimit)) {
5149
4931
  throw new import_errors16.FuelError(
5150
4932
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5158,8 +4940,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5158
4940
  var import_address5 = require("@fuel-ts/address");
5159
4941
  var import_crypto2 = require("@fuel-ts/crypto");
5160
4942
  var import_hasher2 = require("@fuel-ts/hasher");
5161
- var import_math20 = require("@fuel-ts/math");
5162
- var import_utils28 = require("@fuel-ts/utils");
4943
+ var import_math19 = require("@fuel-ts/math");
4944
+ var import_utils29 = require("@fuel-ts/utils");
5163
4945
  var import_secp256k1 = require("@noble/curves/secp256k1");
5164
4946
  var Signer = class {
5165
4947
  address;
@@ -5178,10 +4960,10 @@ var Signer = class {
5178
4960
  privateKey = `0x${privateKey}`;
5179
4961
  }
5180
4962
  }
5181
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5182
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5183
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5184
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4963
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
4964
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4965
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4966
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5185
4967
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5186
4968
  }
5187
4969
  /**
@@ -5195,11 +4977,11 @@ var Signer = class {
5195
4977
  * @returns hashed signature
5196
4978
  */
5197
4979
  sign(data) {
5198
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5199
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5200
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
4980
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
4981
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
4982
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5201
4983
  s[0] |= (signature.recovery || 0) << 7;
5202
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4984
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5203
4985
  }
5204
4986
  /**
5205
4987
  * Add point on the current elliptic curve
@@ -5208,8 +4990,8 @@ var Signer = class {
5208
4990
  * @returns compressed point on the curve
5209
4991
  */
5210
4992
  addPoint(point) {
5211
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5212
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
4993
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
4994
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5213
4995
  const result = p0.add(p1);
5214
4996
  return `0x${result.toHex(true)}`;
5215
4997
  }
@@ -5221,16 +5003,16 @@ var Signer = class {
5221
5003
  * @returns public key from signature from the
5222
5004
  */
5223
5005
  static recoverPublicKey(data, signature) {
5224
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5006
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5225
5007
  const r = signedMessageBytes.slice(0, 32);
5226
5008
  const s = signedMessageBytes.slice(32, 64);
5227
5009
  const recoveryParam = (s[0] & 128) >> 7;
5228
5010
  s[0] &= 127;
5229
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5011
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5230
5012
  recoveryParam
5231
5013
  );
5232
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5233
- return (0, import_utils28.hexlify)(publicKey);
5014
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5015
+ return (0, import_utils29.hexlify)(publicKey);
5234
5016
  }
5235
5017
  /**
5236
5018
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5249,7 +5031,7 @@ var Signer = class {
5249
5031
  * @returns random 32-byte hashed
5250
5032
  */
5251
5033
  static generatePrivateKey(entropy) {
5252
- 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);
5034
+ 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);
5253
5035
  }
5254
5036
  /**
5255
5037
  * Extended publicKey from a compact publicKey
@@ -5258,8 +5040,8 @@ var Signer = class {
5258
5040
  * @returns extended publicKey
5259
5041
  */
5260
5042
  static extendPublicKey(publicKey) {
5261
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5262
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5043
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5044
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5263
5045
  }
5264
5046
  };
5265
5047
 
@@ -5267,7 +5049,7 @@ var Signer = class {
5267
5049
  var import_address6 = require("@fuel-ts/address");
5268
5050
  var import_crypto3 = require("@fuel-ts/crypto");
5269
5051
  var import_errors17 = require("@fuel-ts/errors");
5270
- var import_utils29 = require("@fuel-ts/utils");
5052
+ var import_utils30 = require("@fuel-ts/utils");
5271
5053
  var import_uuid = require("uuid");
5272
5054
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5273
5055
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5350,7 +5132,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5350
5132
  );
5351
5133
  }
5352
5134
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5353
- const privateKey = (0, import_utils29.hexlify)(buffer);
5135
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5354
5136
  return privateKey;
5355
5137
  }
5356
5138
 
@@ -5395,7 +5177,7 @@ var BaseWalletUnlocked = class extends Account {
5395
5177
  */
5396
5178
  async signMessage(message) {
5397
5179
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5398
- return (0, import_utils30.hexlify)(signedMessage);
5180
+ return (0, import_utils31.hexlify)(signedMessage);
5399
5181
  }
5400
5182
  /**
5401
5183
  * Signs a transaction with the wallet's private key.
@@ -5408,7 +5190,7 @@ var BaseWalletUnlocked = class extends Account {
5408
5190
  const chainId = this.provider.getChainId();
5409
5191
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5410
5192
  const signature = await this.signer().sign(hashedTransaction);
5411
- return (0, import_utils30.hexlify)(signature);
5193
+ return (0, import_utils31.hexlify)(signature);
5412
5194
  }
5413
5195
  /**
5414
5196
  * Populates a transaction with the witnesses signature.
@@ -5428,7 +5210,7 @@ var BaseWalletUnlocked = class extends Account {
5428
5210
  * @param transactionRequestLike - The transaction request to send.
5429
5211
  * @returns A promise that resolves to the TransactionResponse object.
5430
5212
  */
5431
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5213
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5432
5214
  const transactionRequest = transactionRequestify(transactionRequestLike);
5433
5215
  if (estimateTxDependencies) {
5434
5216
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5469,15 +5251,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5469
5251
  // src/hdwallet/hdwallet.ts
5470
5252
  var import_errors20 = require("@fuel-ts/errors");
5471
5253
  var import_hasher6 = require("@fuel-ts/hasher");
5472
- var import_math21 = require("@fuel-ts/math");
5473
- var import_utils34 = require("@fuel-ts/utils");
5254
+ var import_math20 = require("@fuel-ts/math");
5255
+ var import_utils35 = require("@fuel-ts/utils");
5474
5256
  var import_ethers3 = require("ethers");
5475
5257
 
5476
5258
  // src/mnemonic/mnemonic.ts
5477
5259
  var import_crypto4 = require("@fuel-ts/crypto");
5478
5260
  var import_errors19 = require("@fuel-ts/errors");
5479
5261
  var import_hasher5 = require("@fuel-ts/hasher");
5480
- var import_utils32 = require("@fuel-ts/utils");
5262
+ var import_utils33 = require("@fuel-ts/utils");
5481
5263
  var import_ethers2 = require("ethers");
5482
5264
 
5483
5265
  // src/wordlists/words/english.ts
@@ -7535,7 +7317,7 @@ var english = [
7535
7317
  // src/mnemonic/utils.ts
7536
7318
  var import_errors18 = require("@fuel-ts/errors");
7537
7319
  var import_hasher4 = require("@fuel-ts/hasher");
7538
- var import_utils31 = require("@fuel-ts/utils");
7320
+ var import_utils32 = require("@fuel-ts/utils");
7539
7321
  function toUtf8Bytes(stri) {
7540
7322
  const str = stri.normalize("NFKD");
7541
7323
  const result = [];
@@ -7602,14 +7384,14 @@ function entropyToMnemonicIndices(entropy) {
7602
7384
  }
7603
7385
  }
7604
7386
  const checksumBits = entropy.length / 4;
7605
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7387
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7606
7388
  indices[indices.length - 1] <<= checksumBits;
7607
7389
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7608
7390
  return indices;
7609
7391
  }
7610
7392
  function mnemonicWordsToEntropy(words, wordlist) {
7611
7393
  const size = Math.ceil(11 * words.length / 8);
7612
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7394
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7613
7395
  let offset = 0;
7614
7396
  for (let i = 0; i < words.length; i += 1) {
7615
7397
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7629,7 +7411,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7629
7411
  const entropyBits = 32 * words.length / 3;
7630
7412
  const checksumBits = words.length / 3;
7631
7413
  const checksumMask = getUpperMask(checksumBits);
7632
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7414
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7633
7415
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7634
7416
  throw new import_errors18.FuelError(
7635
7417
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7704,7 +7486,7 @@ var Mnemonic = class {
7704
7486
  static mnemonicToEntropy(phrase, wordlist = english) {
7705
7487
  const words = getWords(phrase);
7706
7488
  assertMnemonic(words);
7707
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7489
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7708
7490
  }
7709
7491
  /**
7710
7492
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7712,7 +7494,7 @@ var Mnemonic = class {
7712
7494
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7713
7495
  */
7714
7496
  static entropyToMnemonic(entropy, wordlist = english) {
7715
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7497
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7716
7498
  assertWordList(wordlist);
7717
7499
  assertEntropy(entropyBytes);
7718
7500
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7781,14 +7563,14 @@ var Mnemonic = class {
7781
7563
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7782
7564
  */
7783
7565
  static masterKeysFromSeed(seed) {
7784
- const seedArray = (0, import_utils32.arrayify)(seed);
7566
+ const seedArray = (0, import_utils33.arrayify)(seed);
7785
7567
  if (seedArray.length < 16 || seedArray.length > 64) {
7786
7568
  throw new import_errors19.FuelError(
7787
7569
  import_errors19.ErrorCode.INVALID_SEED,
7788
7570
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7789
7571
  );
7790
7572
  }
7791
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7573
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7792
7574
  }
7793
7575
  /**
7794
7576
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7799,22 +7581,22 @@ var Mnemonic = class {
7799
7581
  */
7800
7582
  static seedToExtendedKey(seed, testnet = false) {
7801
7583
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7802
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7584
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7803
7585
  const depth = "0x00";
7804
7586
  const fingerprint = "0x00000000";
7805
7587
  const index = "0x00000000";
7806
7588
  const chainCode = masterKey.slice(32);
7807
7589
  const privateKey = masterKey.slice(0, 32);
7808
- const extendedKey = (0, import_utils32.concat)([
7590
+ const extendedKey = (0, import_utils33.concat)([
7809
7591
  prefix,
7810
7592
  depth,
7811
7593
  fingerprint,
7812
7594
  index,
7813
7595
  chainCode,
7814
- (0, import_utils32.concat)(["0x00", privateKey])
7596
+ (0, import_utils33.concat)(["0x00", privateKey])
7815
7597
  ]);
7816
7598
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7817
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7599
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7818
7600
  }
7819
7601
  /**
7820
7602
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7829,7 +7611,7 @@ var Mnemonic = class {
7829
7611
  * @returns A randomly generated mnemonic
7830
7612
  */
7831
7613
  static generate(size = 32, extraEntropy = "") {
7832
- 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);
7614
+ 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);
7833
7615
  return Mnemonic.entropyToMnemonic(entropy);
7834
7616
  }
7835
7617
  };
@@ -7837,12 +7619,12 @@ var mnemonic_default = Mnemonic;
7837
7619
 
7838
7620
  // src/hdwallet/hdwallet.ts
7839
7621
  var HARDENED_INDEX = 2147483648;
7840
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7841
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7842
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7843
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7622
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7623
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7624
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7625
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7844
7626
  function base58check(data) {
7845
- 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)]));
7627
+ 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)]));
7846
7628
  }
7847
7629
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7848
7630
  if (isPublic) {
@@ -7851,11 +7633,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7851
7633
  return testnet ? TestnetPRV2 : MainnetPRV2;
7852
7634
  }
7853
7635
  function isPublicExtendedKey(extendedKey) {
7854
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7636
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7855
7637
  }
7856
7638
  function isValidExtendedKey(extendedKey) {
7857
7639
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7858
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7640
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7859
7641
  );
7860
7642
  }
7861
7643
  function parsePath(path2, depth = 0) {
@@ -7873,8 +7655,8 @@ function parsePath(path2, depth = 0) {
7873
7655
  var HDWallet = class {
7874
7656
  depth = 0;
7875
7657
  index = 0;
7876
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7877
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7658
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
7659
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7878
7660
  privateKey;
7879
7661
  publicKey;
7880
7662
  chainCode;
@@ -7886,8 +7668,8 @@ var HDWallet = class {
7886
7668
  constructor(config) {
7887
7669
  if (config.privateKey) {
7888
7670
  const signer = new Signer(config.privateKey);
7889
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7890
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7671
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7672
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7891
7673
  } else {
7892
7674
  if (!config.publicKey) {
7893
7675
  throw new import_errors20.FuelError(
@@ -7895,7 +7677,7 @@ var HDWallet = class {
7895
7677
  "Both public and private Key cannot be missing. At least one should be provided."
7896
7678
  );
7897
7679
  }
7898
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7680
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7899
7681
  }
7900
7682
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7901
7683
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7914,9 +7696,9 @@ var HDWallet = class {
7914
7696
  * @returns A new instance of HDWallet on the derived index
7915
7697
  */
7916
7698
  deriveIndex(index) {
7917
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7918
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7919
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7699
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7700
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7701
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7920
7702
  const data = new Uint8Array(37);
7921
7703
  if (index & HARDENED_INDEX) {
7922
7704
  if (!privateKey) {
@@ -7927,15 +7709,15 @@ var HDWallet = class {
7927
7709
  }
7928
7710
  data.set(privateKey, 1);
7929
7711
  } else {
7930
- data.set((0, import_utils34.arrayify)(this.publicKey));
7712
+ data.set((0, import_utils35.arrayify)(this.publicKey));
7931
7713
  }
7932
- data.set((0, import_math21.toBytes)(index, 4), 33);
7933
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7714
+ data.set((0, import_math20.toBytes)(index, 4), 33);
7715
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7934
7716
  const IL = bytes.slice(0, 32);
7935
7717
  const IR = bytes.slice(32);
7936
7718
  if (privateKey) {
7937
7719
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7938
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
7720
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7939
7721
  return new HDWallet({
7940
7722
  privateKey: ki,
7941
7723
  chainCode: IR,
@@ -7944,7 +7726,7 @@ var HDWallet = class {
7944
7726
  parentFingerprint: this.fingerprint
7945
7727
  });
7946
7728
  }
7947
- const signer = new Signer((0, import_utils34.hexlify)(IL));
7729
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
7948
7730
  const Ki = signer.addPoint(publicKey);
7949
7731
  return new HDWallet({
7950
7732
  publicKey: Ki,
@@ -7979,12 +7761,12 @@ var HDWallet = class {
7979
7761
  );
7980
7762
  }
7981
7763
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7982
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7764
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
7983
7765
  const parentFingerprint = this.parentFingerprint;
7984
- const index = (0, import_math21.toHex)(this.index, 4);
7766
+ const index = (0, import_math20.toHex)(this.index, 4);
7985
7767
  const chainCode = this.chainCode;
7986
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
7987
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7768
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7769
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7988
7770
  return base58check(extendedKey);
7989
7771
  }
7990
7772
  /**
@@ -7996,13 +7778,13 @@ var HDWallet = class {
7996
7778
  static fromSeed(seed) {
7997
7779
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7998
7780
  return new HDWallet({
7999
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8000
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7781
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7782
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8001
7783
  });
8002
7784
  }
8003
7785
  static fromExtendedKey(extendedKey) {
8004
7786
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8005
- const bytes = (0, import_utils34.arrayify)(decoded);
7787
+ const bytes = (0, import_utils35.arrayify)(decoded);
8006
7788
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8007
7789
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8008
7790
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8011,9 +7793,9 @@ var HDWallet = class {
8011
7793
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8012
7794
  }
8013
7795
  const depth = bytes[4];
8014
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8015
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8016
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7796
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7797
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7798
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8017
7799
  const key = bytes.slice(45, 78);
8018
7800
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8019
7801
  throw new import_errors20.FuelError(
@@ -8206,15 +7988,14 @@ var seedTestWallet = async (wallet, quantities) => {
8206
7988
  process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
8207
7989
  wallet.provider
8208
7990
  );
8209
- const request = new ScriptTransactionRequest();
8210
- quantities.forEach((quantity) => {
8211
- const { amount, assetId } = coinQuantityfy(quantity);
8212
- request.addCoinOutput(wallet.address, amount, assetId);
7991
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
7992
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
7993
+ const request = new ScriptTransactionRequest({
7994
+ gasLimit: 1e4,
7995
+ gasPrice: minGasPrice
8213
7996
  });
8214
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8215
- request.gasLimit = txCost.gasUsed;
8216
- request.maxFee = txCost.maxFee;
8217
- await genesisWallet.fund(request, txCost);
7997
+ request.addResources(resources);
7998
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8218
7999
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8219
8000
  };
8220
8001
 
@@ -8229,11 +8010,11 @@ var generateTestWallet = async (provider, quantities) => {
8229
8010
 
8230
8011
  // src/test-utils/launchNode.ts
8231
8012
  var import_configs13 = require("@fuel-ts/address/configs");
8232
- var import_utils35 = require("@fuel-ts/utils");
8013
+ var import_math21 = require("@fuel-ts/math");
8014
+ var import_utils36 = require("@fuel-ts/utils");
8233
8015
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8234
8016
  var import_child_process = require("child_process");
8235
8017
  var import_crypto6 = require("crypto");
8236
- var import_ethers4 = require("ethers");
8237
8018
  var import_fs = require("fs");
8238
8019
  var import_os = __toESM(require("os"));
8239
8020
  var import_path = __toESM(require("path"));
@@ -8282,13 +8063,13 @@ var launchNode = async ({
8282
8063
  // eslint-disable-next-line no-async-promise-executor
8283
8064
  new Promise(async (resolve, reject) => {
8284
8065
  const remainingArgs = extractRemainingArgs(args, [
8285
- "--snapshot",
8066
+ "--chain",
8286
8067
  "--consensus-key",
8287
8068
  "--db-type",
8288
8069
  "--poa-instant"
8289
8070
  ]);
8290
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8291
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8071
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8072
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8292
8073
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8293
8074
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8294
8075
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -8306,54 +8087,36 @@ var launchNode = async ({
8306
8087
  let chainConfigPathToUse;
8307
8088
  const prefix = basePath || import_os.default.tmpdir();
8308
8089
  const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
8309
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
8090
+ const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
8310
8091
  if (chainConfigPath) {
8311
8092
  chainConfigPathToUse = chainConfigPath;
8312
8093
  } else {
8313
8094
  if (!(0, import_fs.existsSync)(tempDirPath)) {
8314
8095
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8315
8096
  }
8316
- let { stateConfigJson } = import_utils35.defaultChainConfigs;
8317
- const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
8318
- stateConfigJson = {
8319
- ...stateConfigJson,
8320
- coins: [
8321
- ...stateConfigJson.coins.map((coin) => ({
8322
- ...coin,
8323
- amount: "18446744073709551615"
8324
- }))
8325
- ],
8326
- messages: stateConfigJson.messages.map((message) => ({
8327
- ...message,
8328
- amount: "18446744073709551615"
8329
- }))
8330
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8331
- };
8097
+ const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
8098
+ let chainConfig = import_utils36.defaultChainConfig;
8332
8099
  if (!process.env.GENESIS_SECRET) {
8333
8100
  const pk = Signer.generatePrivateKey();
8334
8101
  const signer = new Signer(pk);
8335
- process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8336
- stateConfigJson.coins.push({
8337
- tx_id: (0, import_utils35.hexlify)((0, import_ethers4.randomBytes)(34)),
8338
- owner: signer.address.toHexString(),
8339
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8340
- amount: "18446744073709551615",
8341
- asset_id: import_configs13.BaseAssetId,
8342
- output_index: 0,
8343
- tx_pointer_block_height: 0,
8344
- tx_pointer_tx_idx: 0
8345
- });
8102
+ process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8103
+ chainConfig = {
8104
+ ...import_utils36.defaultChainConfig,
8105
+ initial_state: {
8106
+ ...import_utils36.defaultChainConfig.initial_state,
8107
+ coins: [
8108
+ ...import_utils36.defaultChainConfig.initial_state.coins,
8109
+ {
8110
+ owner: signer.address.toHexString(),
8111
+ amount: (0, import_math21.toHex)(1e9),
8112
+ asset_id: import_configs13.BaseAssetId
8113
+ }
8114
+ ]
8115
+ }
8116
+ };
8346
8117
  }
8347
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8348
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8349
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8350
- const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8351
- const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8352
- const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8353
- (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8354
- (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8355
- (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8356
- chainConfigPathToUse = tempDirPath;
8118
+ (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8119
+ chainConfigPathToUse = tempChainConfigFilePath;
8357
8120
  }
8358
8121
  const child = (0, import_child_process.spawn)(
8359
8122
  command,
@@ -8362,10 +8125,10 @@ var launchNode = async ({
8362
8125
  ["--ip", ipToUse],
8363
8126
  ["--port", portToUse],
8364
8127
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8365
- ["--min-gas-price", "1"],
8128
+ ["--min-gas-price", "0"],
8366
8129
  poaInstant ? ["--poa-instant", "true"] : [],
8367
8130
  ["--consensus-key", consensusKey],
8368
- ["--snapshot", chainConfigPathToUse],
8131
+ ["--chain", chainConfigPathToUse],
8369
8132
  "--vm-backtrace",
8370
8133
  "--utxo-validation",
8371
8134
  "--debug",
@@ -8424,7 +8187,7 @@ var launchNodeAndGetWallets = async ({
8424
8187
  walletCount = 10
8425
8188
  } = {}) => {
8426
8189
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8427
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8190
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8428
8191
  const wallets = await generateWallets(walletCount, provider);
8429
8192
  const cleanup = () => {
8430
8193
  closeNode();