@fuel-ts/account 0.0.0-rc-2021-20240411154255 → 0.0.0-rc-2037-20240411163513

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 +563 -841
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +565 -825
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +400 -659
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -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 +1 -2
  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 -6
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +30 -37
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +5 -6
  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 +1047 -1557
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +543 -800
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +394 -651
  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");
@@ -76,24 +75,24 @@ var import_utils = require("@fuel-ts/utils");
76
75
  var coinQuantityfy = (coinQuantityLike) => {
77
76
  let assetId;
78
77
  let amount;
79
- let max;
78
+ let max2;
80
79
  if (Array.isArray(coinQuantityLike)) {
81
80
  amount = coinQuantityLike[0];
82
81
  assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
83
- max = coinQuantityLike[2] ?? void 0;
82
+ max2 = coinQuantityLike[2] ?? void 0;
84
83
  } else {
85
84
  amount = coinQuantityLike.amount;
86
85
  assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
87
- max = coinQuantityLike.max ?? void 0;
86
+ max2 = coinQuantityLike.max ?? void 0;
88
87
  }
89
88
  const bnAmount = (0, import_math.bn)(amount);
90
89
  return {
91
90
  assetId: (0, import_utils.hexlify)(assetId),
92
91
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
93
- max: max ? (0, import_math.bn)(max) : void 0
92
+ max: max2 ? (0, import_math.bn)(max2) : void 0
94
93
  };
95
94
  };
96
- var addAmountToCoinQuantities = (params) => {
95
+ var addAmountToAsset = (params) => {
97
96
  const { amount, assetId } = params;
98
97
  const coinQuantities = [...params.coinQuantities];
99
98
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -108,12 +107,12 @@ 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");
116
- var import_ethers2 = require("ethers");
114
+ var import_utils24 = require("@noble/curves/abstract/utils");
115
+ var import_ethers = require("ethers");
117
116
  var import_graphql_request = require("graphql-request");
118
117
  var import_ramda3 = require("ramda");
119
118
 
@@ -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)) {
@@ -1119,6 +1051,7 @@ var MemoryCache = class {
1119
1051
  };
1120
1052
 
1121
1053
  // src/providers/transaction-request/input.ts
1054
+ var import_abi_coder = require("@fuel-ts/abi-coder");
1122
1055
  var import_configs2 = require("@fuel-ts/address/configs");
1123
1056
  var import_errors3 = require("@fuel-ts/errors");
1124
1057
  var import_math2 = require("@fuel-ts/math");
@@ -1132,8 +1065,8 @@ var inputify = (value) => {
1132
1065
  const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1133
1066
  return {
1134
1067
  type: import_transactions.InputType.Coin,
1135
- txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1136
- outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 34)),
1068
+ txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
1069
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
1137
1070
  owner: (0, import_utils3.hexlify)(value.owner),
1138
1071
  amount: (0, import_math2.bn)(value.amount),
1139
1072
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1142,9 +1075,10 @@ var inputify = (value) => {
1142
1075
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1143
1076
  },
1144
1077
  witnessIndex: value.witnessIndex,
1078
+ maturity: value.maturity ?? 0,
1145
1079
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1146
- predicateLength: (0, import_math2.bn)(predicate.length),
1147
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1080
+ predicateLength: predicate.length,
1081
+ predicateDataLength: predicateData.length,
1148
1082
  predicate: (0, import_utils3.hexlify)(predicate),
1149
1083
  predicateData: (0, import_utils3.hexlify)(predicateData)
1150
1084
  };
@@ -1175,8 +1109,8 @@ var inputify = (value) => {
1175
1109
  nonce: (0, import_utils3.hexlify)(value.nonce),
1176
1110
  witnessIndex: value.witnessIndex,
1177
1111
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1178
- predicateLength: (0, import_math2.bn)(predicate.length),
1179
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1112
+ predicateLength: predicate.length,
1113
+ predicateDataLength: predicateData.length,
1180
1114
  predicate: (0, import_utils3.hexlify)(predicate),
1181
1115
  predicateData: (0, import_utils3.hexlify)(predicateData),
1182
1116
  data: (0, import_utils3.hexlify)(data),
@@ -1250,12 +1184,13 @@ var outputify = (value) => {
1250
1184
  };
1251
1185
 
1252
1186
  // src/providers/transaction-request/transaction-request.ts
1187
+ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1253
1188
  var import_address = require("@fuel-ts/address");
1254
1189
  var import_configs7 = require("@fuel-ts/address/configs");
1190
+ var import_crypto = require("@fuel-ts/crypto");
1255
1191
  var import_math7 = require("@fuel-ts/math");
1256
1192
  var import_transactions6 = require("@fuel-ts/transactions");
1257
1193
  var import_utils9 = require("@fuel-ts/utils");
1258
- var import_ethers = require("ethers");
1259
1194
 
1260
1195
  // src/providers/resource.ts
1261
1196
  var isCoin = (resource) => "id" in resource;
@@ -1291,8 +1226,8 @@ function assembleReceiptByType(receipt) {
1291
1226
  case "CALL" /* Call */: {
1292
1227
  const callReceipt = {
1293
1228
  type: import_transactions3.ReceiptType.Call,
1294
- from: hexOrZero(receipt.id || receipt.contractId),
1295
- to: hexOrZero(receipt?.to),
1229
+ from: hexOrZero(receipt.contract?.id),
1230
+ to: hexOrZero(receipt?.to?.id),
1296
1231
  amount: (0, import_math4.bn)(receipt.amount),
1297
1232
  assetId: hexOrZero(receipt.assetId),
1298
1233
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1306,7 +1241,7 @@ function assembleReceiptByType(receipt) {
1306
1241
  case "RETURN" /* Return */: {
1307
1242
  const returnReceipt = {
1308
1243
  type: import_transactions3.ReceiptType.Return,
1309
- id: hexOrZero(receipt.id || receipt.contractId),
1244
+ id: hexOrZero(receipt.contract?.id),
1310
1245
  val: (0, import_math4.bn)(receipt.val),
1311
1246
  pc: (0, import_math4.bn)(receipt.pc),
1312
1247
  is: (0, import_math4.bn)(receipt.is)
@@ -1316,7 +1251,7 @@ function assembleReceiptByType(receipt) {
1316
1251
  case "RETURN_DATA" /* ReturnData */: {
1317
1252
  const returnDataReceipt = {
1318
1253
  type: import_transactions3.ReceiptType.ReturnData,
1319
- id: hexOrZero(receipt.id || receipt.contractId),
1254
+ id: hexOrZero(receipt.contract?.id),
1320
1255
  ptr: (0, import_math4.bn)(receipt.ptr),
1321
1256
  len: (0, import_math4.bn)(receipt.len),
1322
1257
  digest: hexOrZero(receipt.digest),
@@ -1328,7 +1263,7 @@ function assembleReceiptByType(receipt) {
1328
1263
  case "PANIC" /* Panic */: {
1329
1264
  const panicReceipt = {
1330
1265
  type: import_transactions3.ReceiptType.Panic,
1331
- id: hexOrZero(receipt.id),
1266
+ id: hexOrZero(receipt.contract?.id),
1332
1267
  reason: (0, import_math4.bn)(receipt.reason),
1333
1268
  pc: (0, import_math4.bn)(receipt.pc),
1334
1269
  is: (0, import_math4.bn)(receipt.is),
@@ -1339,7 +1274,7 @@ function assembleReceiptByType(receipt) {
1339
1274
  case "REVERT" /* Revert */: {
1340
1275
  const revertReceipt = {
1341
1276
  type: import_transactions3.ReceiptType.Revert,
1342
- id: hexOrZero(receipt.id || receipt.contractId),
1277
+ id: hexOrZero(receipt.contract?.id),
1343
1278
  val: (0, import_math4.bn)(receipt.ra),
1344
1279
  pc: (0, import_math4.bn)(receipt.pc),
1345
1280
  is: (0, import_math4.bn)(receipt.is)
@@ -1349,7 +1284,7 @@ function assembleReceiptByType(receipt) {
1349
1284
  case "LOG" /* Log */: {
1350
1285
  const logReceipt = {
1351
1286
  type: import_transactions3.ReceiptType.Log,
1352
- id: hexOrZero(receipt.id || receipt.contractId),
1287
+ id: hexOrZero(receipt.contract?.id),
1353
1288
  val0: (0, import_math4.bn)(receipt.ra),
1354
1289
  val1: (0, import_math4.bn)(receipt.rb),
1355
1290
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1362,7 +1297,7 @@ function assembleReceiptByType(receipt) {
1362
1297
  case "LOG_DATA" /* LogData */: {
1363
1298
  const logDataReceipt = {
1364
1299
  type: import_transactions3.ReceiptType.LogData,
1365
- id: hexOrZero(receipt.id || receipt.contractId),
1300
+ id: hexOrZero(receipt.contract?.id),
1366
1301
  val0: (0, import_math4.bn)(receipt.ra),
1367
1302
  val1: (0, import_math4.bn)(receipt.rb),
1368
1303
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1376,8 +1311,8 @@ function assembleReceiptByType(receipt) {
1376
1311
  case "TRANSFER" /* Transfer */: {
1377
1312
  const transferReceipt = {
1378
1313
  type: import_transactions3.ReceiptType.Transfer,
1379
- from: hexOrZero(receipt.id || receipt.contractId),
1380
- to: hexOrZero(receipt.toAddress || receipt?.to),
1314
+ from: hexOrZero(receipt.contract?.id),
1315
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1381
1316
  amount: (0, import_math4.bn)(receipt.amount),
1382
1317
  assetId: hexOrZero(receipt.assetId),
1383
1318
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1388,8 +1323,8 @@ function assembleReceiptByType(receipt) {
1388
1323
  case "TRANSFER_OUT" /* TransferOut */: {
1389
1324
  const transferOutReceipt = {
1390
1325
  type: import_transactions3.ReceiptType.TransferOut,
1391
- from: hexOrZero(receipt.id || receipt.contractId),
1392
- to: hexOrZero(receipt.toAddress || receipt.to),
1326
+ from: hexOrZero(receipt.contract?.id),
1327
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1393
1328
  amount: (0, import_math4.bn)(receipt.amount),
1394
1329
  assetId: hexOrZero(receipt.assetId),
1395
1330
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1432,7 +1367,7 @@ function assembleReceiptByType(receipt) {
1432
1367
  return receiptMessageOut;
1433
1368
  }
1434
1369
  case "MINT" /* Mint */: {
1435
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1370
+ const contractId = hexOrZero(receipt.contract?.id);
1436
1371
  const subId = hexOrZero(receipt.subId);
1437
1372
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1438
1373
  const mintReceipt = {
@@ -1447,7 +1382,7 @@ function assembleReceiptByType(receipt) {
1447
1382
  return mintReceipt;
1448
1383
  }
1449
1384
  case "BURN" /* Burn */: {
1450
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1385
+ const contractId = hexOrZero(receipt.contract?.id);
1451
1386
  const subId = hexOrZero(receipt.subId);
1452
1387
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1453
1388
  const burnReceipt = {
@@ -1473,6 +1408,7 @@ var import_errors6 = require("@fuel-ts/errors");
1473
1408
  var import_math5 = require("@fuel-ts/math");
1474
1409
  var import_transactions4 = require("@fuel-ts/transactions");
1475
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()));
1476
1412
  var getGasUsedFromReceipts = (receipts) => {
1477
1413
  const scriptResult = receipts.filter(
1478
1414
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1493,28 +1429,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1493
1429
  }
1494
1430
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1495
1431
  const witnessCache = [];
1496
- const chargeableInputs = inputs.filter((input) => {
1497
- const isCoinOrMessage = "owner" in input || "sender" in input;
1498
- if (isCoinOrMessage) {
1499
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1500
- return true;
1501
- }
1502
- if (!witnessCache.includes(input.witnessIndex)) {
1503
- witnessCache.push(input.witnessIndex);
1504
- return true;
1505
- }
1506
- }
1507
- return false;
1508
- });
1509
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1510
- const totalGas = chargeableInputs.reduce((total, input) => {
1432
+ const totalGas = inputs.reduce((total, input) => {
1511
1433
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1512
1434
  return total.add(
1513
- 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))
1514
1436
  );
1515
1437
  }
1516
- return total.add(gasCosts.ecr1);
1517
- }, (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)());
1518
1444
  return totalGas;
1519
1445
  }
1520
1446
  function getMinGas(params) {
@@ -1526,20 +1452,12 @@ function getMinGas(params) {
1526
1452
  return minGas;
1527
1453
  }
1528
1454
  function getMaxGas(params) {
1529
- const {
1530
- gasPerByte,
1531
- witnessesLength,
1532
- witnessLimit,
1533
- minGas,
1534
- gasLimit = (0, import_math5.bn)(0),
1535
- maxGasPerTx
1536
- } = params;
1455
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1537
1456
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1538
1457
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1539
1458
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1540
1459
  }
1541
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1542
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1460
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1543
1461
  }
1544
1462
  function calculateMetadataGasForTxCreate({
1545
1463
  gasCosts,
@@ -1561,10 +1479,6 @@ function calculateMetadataGasForTxScript({
1561
1479
  }) {
1562
1480
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1563
1481
  }
1564
- var calculateGasFee = (params) => {
1565
- const { gas, gasPrice, priceFactor, tip } = params;
1566
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1567
- };
1568
1482
 
1569
1483
  // src/providers/utils/json.ts
1570
1484
  var import_utils7 = require("@fuel-ts/utils");
@@ -1701,7 +1615,7 @@ var witnessify = (value) => {
1701
1615
  // src/providers/transaction-request/transaction-request.ts
1702
1616
  var BaseTransactionRequest = class {
1703
1617
  /** Gas price for transaction */
1704
- tip;
1618
+ gasPrice;
1705
1619
  /** Block until which tx cannot be included */
1706
1620
  maturity;
1707
1621
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1720,7 +1634,7 @@ var BaseTransactionRequest = class {
1720
1634
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1721
1635
  */
1722
1636
  constructor({
1723
- tip,
1637
+ gasPrice,
1724
1638
  maturity,
1725
1639
  maxFee,
1726
1640
  witnessLimit,
@@ -1728,7 +1642,7 @@ var BaseTransactionRequest = class {
1728
1642
  outputs,
1729
1643
  witnesses
1730
1644
  } = {}) {
1731
- this.tip = (0, import_math7.bn)(tip);
1645
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1732
1646
  this.maturity = maturity ?? 0;
1733
1647
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1734
1648
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1739,9 +1653,9 @@ var BaseTransactionRequest = class {
1739
1653
  static getPolicyMeta(req) {
1740
1654
  let policyTypes = 0;
1741
1655
  const policies = [];
1742
- if (req.tip) {
1743
- policyTypes += import_transactions6.PolicyType.Tip;
1744
- 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 });
1745
1659
  }
1746
1660
  if (req.witnessLimit) {
1747
1661
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -1929,9 +1843,9 @@ var BaseTransactionRequest = class {
1929
1843
  * @param predicateData - Predicate data bytes.
1930
1844
  */
1931
1845
  addCoinInput(coin) {
1932
- const { assetId, owner, amount } = coin;
1846
+ const { assetId, owner, amount, id, predicate } = coin;
1933
1847
  let witnessIndex;
1934
- if (coin.predicate) {
1848
+ if (predicate) {
1935
1849
  witnessIndex = 0;
1936
1850
  } else {
1937
1851
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1940,13 +1854,14 @@ var BaseTransactionRequest = class {
1940
1854
  }
1941
1855
  }
1942
1856
  const input = {
1943
- ...coin,
1857
+ id,
1944
1858
  type: import_transactions6.InputType.Coin,
1945
1859
  owner: owner.toB256(),
1946
1860
  amount,
1947
1861
  assetId,
1948
1862
  txPointer: "0x00000000000000000000000000000000",
1949
- witnessIndex
1863
+ witnessIndex,
1864
+ predicate
1950
1865
  };
1951
1866
  this.pushInput(input);
1952
1867
  this.addChangeOutput(owner, assetId);
@@ -1960,10 +1875,10 @@ var BaseTransactionRequest = class {
1960
1875
  * @param predicateData - Predicate data bytes.
1961
1876
  */
1962
1877
  addMessageInput(message) {
1963
- const { recipient, sender, amount } = message;
1878
+ const { recipient, sender, amount, predicate, nonce } = message;
1964
1879
  const assetId = import_configs7.BaseAssetId;
1965
1880
  let witnessIndex;
1966
- if (message.predicate) {
1881
+ if (predicate) {
1967
1882
  witnessIndex = 0;
1968
1883
  } else {
1969
1884
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1972,12 +1887,13 @@ var BaseTransactionRequest = class {
1972
1887
  }
1973
1888
  }
1974
1889
  const input = {
1975
- ...message,
1890
+ nonce,
1976
1891
  type: import_transactions6.InputType.Message,
1977
1892
  sender: sender.toB256(),
1978
1893
  recipient: recipient.toB256(),
1979
1894
  amount,
1980
- witnessIndex
1895
+ witnessIndex,
1896
+ predicate
1981
1897
  };
1982
1898
  this.pushInput(input);
1983
1899
  this.addChangeOutput(recipient, assetId);
@@ -2087,7 +2003,7 @@ var BaseTransactionRequest = class {
2087
2003
  }
2088
2004
  calculateMaxGas(chainInfo, minGas) {
2089
2005
  const { consensusParameters } = chainInfo;
2090
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2006
+ const { gasPerByte } = consensusParameters;
2091
2007
  const witnessesLength = this.toTransaction().witnesses.reduce(
2092
2008
  (acc, wit) => acc + wit.dataLength,
2093
2009
  0
@@ -2096,8 +2012,7 @@ var BaseTransactionRequest = class {
2096
2012
  gasPerByte,
2097
2013
  minGas,
2098
2014
  witnessesLength,
2099
- witnessLimit: this.witnessLimit,
2100
- maxGasPerTx
2015
+ witnessLimit: this.witnessLimit
2101
2016
  });
2102
2017
  }
2103
2018
  /**
@@ -2115,20 +2030,17 @@ var BaseTransactionRequest = class {
2115
2030
  });
2116
2031
  const updateAssetInput = (assetId, quantity) => {
2117
2032
  const assetInput = findAssetInput(assetId);
2118
- let usedQuantity = quantity;
2119
- if (assetId === import_configs7.BaseAssetId) {
2120
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2121
- }
2122
2033
  if (assetInput && "assetId" in assetInput) {
2123
- assetInput.id = (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34));
2124
- assetInput.amount = usedQuantity;
2034
+ assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2035
+ assetInput.amount = quantity;
2125
2036
  } else {
2126
2037
  this.addResources([
2127
2038
  {
2128
- id: (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34)),
2129
- amount: usedQuantity,
2039
+ id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2040
+ amount: quantity,
2130
2041
  assetId,
2131
2042
  owner: resourcesOwner || import_address.Address.fromRandom(),
2043
+ maturity: 0,
2132
2044
  blockCreated: (0, import_math7.bn)(1),
2133
2045
  txCreatedIdx: (0, import_math7.bn)(1)
2134
2046
  }
@@ -2160,7 +2072,7 @@ var BaseTransactionRequest = class {
2160
2072
  toJSON() {
2161
2073
  return normalizeJSON(this);
2162
2074
  }
2163
- updatePredicateGasUsed(inputs) {
2075
+ updatePredicateInputs(inputs) {
2164
2076
  this.inputs.forEach((i) => {
2165
2077
  let correspondingInput;
2166
2078
  switch (i.type) {
@@ -2182,15 +2094,6 @@ var BaseTransactionRequest = class {
2182
2094
  }
2183
2095
  });
2184
2096
  }
2185
- shiftPredicateData() {
2186
- this.inputs.forEach((input) => {
2187
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2188
- input.predicateData = input.paddPredicateData(
2189
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2190
- );
2191
- }
2192
- });
2193
- }
2194
2097
  };
2195
2098
 
2196
2099
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2337,8 +2240,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2337
2240
  return {
2338
2241
  type: import_transactions8.TransactionType.Create,
2339
2242
  ...baseTransaction,
2243
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2340
2244
  bytecodeWitnessIndex,
2341
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2245
+ storageSlotsCount: storageSlots.length,
2342
2246
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2343
2247
  storageSlots
2344
2248
  };
@@ -2387,7 +2291,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2387
2291
  };
2388
2292
 
2389
2293
  // src/providers/transaction-request/script-transaction-request.ts
2390
- var import_abi_coder = require("@fuel-ts/abi-coder");
2294
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2391
2295
  var import_address2 = require("@fuel-ts/address");
2392
2296
  var import_configs10 = require("@fuel-ts/address/configs");
2393
2297
  var import_math10 = require("@fuel-ts/math");
@@ -2461,8 +2365,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2461
2365
  type: import_transactions9.TransactionType.Script,
2462
2366
  scriptGasLimit: this.gasLimit,
2463
2367
  ...super.getBaseTransaction(),
2464
- scriptLength: (0, import_math10.bn)(script.length),
2465
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2368
+ scriptLength: script.length,
2369
+ scriptDataLength: scriptData.length,
2466
2370
  receiptsRoot: import_configs10.ZeroBytes32,
2467
2371
  script: (0, import_utils15.hexlify)(script),
2468
2372
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2526,7 +2430,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2526
2430
  }
2527
2431
  calculateMaxGas(chainInfo, minGas) {
2528
2432
  const { consensusParameters } = chainInfo;
2529
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2433
+ const { gasPerByte } = consensusParameters;
2530
2434
  const witnessesLength = this.toTransaction().witnesses.reduce(
2531
2435
  (acc, wit) => acc + wit.dataLength,
2532
2436
  0
@@ -2536,8 +2440,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2536
2440
  minGas,
2537
2441
  witnessesLength,
2538
2442
  witnessLimit: this.witnessLimit,
2539
- gasLimit: this.gasLimit,
2540
- maxGasPerTx
2443
+ gasLimit: this.gasLimit
2541
2444
  });
2542
2445
  }
2543
2446
  /**
@@ -2580,7 +2483,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2580
2483
  * @returns The current instance of the `ScriptTransactionRequest`.
2581
2484
  */
2582
2485
  setData(abi, args) {
2583
- const abiInterface = new import_abi_coder.Interface(abi);
2486
+ const abiInterface = new import_abi_coder3.Interface(abi);
2584
2487
  this.scriptData = abiInterface.functions.main.encodeArguments(args);
2585
2488
  return this;
2586
2489
  }
@@ -2612,32 +2515,15 @@ var transactionRequestify = (obj) => {
2612
2515
  }
2613
2516
  }
2614
2517
  };
2615
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2616
- (acc, input) => {
2617
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2618
- acc.utxos.push(input.id);
2619
- }
2620
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2621
- acc.messages.push(input.nonce);
2622
- }
2623
- return acc;
2624
- },
2625
- {
2626
- utxos: [],
2627
- messages: []
2628
- }
2629
- );
2630
2518
 
2631
2519
  // src/providers/transaction-response/transaction-response.ts
2632
2520
  var import_errors13 = require("@fuel-ts/errors");
2633
- var import_math15 = require("@fuel-ts/math");
2634
- var import_transactions18 = require("@fuel-ts/transactions");
2635
- var import_utils20 = require("@fuel-ts/utils");
2521
+ var import_math14 = require("@fuel-ts/math");
2522
+ var import_transactions17 = require("@fuel-ts/transactions");
2523
+ var import_utils21 = require("@fuel-ts/utils");
2636
2524
 
2637
2525
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2638
- var import_math14 = require("@fuel-ts/math");
2639
- var import_transactions16 = require("@fuel-ts/transactions");
2640
- var import_utils18 = require("@fuel-ts/utils");
2526
+ var import_utils19 = require("@fuel-ts/utils");
2641
2527
 
2642
2528
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2643
2529
  var import_math11 = require("@fuel-ts/math");
@@ -2645,10 +2531,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2645
2531
  var import_utils16 = require("@fuel-ts/utils");
2646
2532
  var calculateTransactionFee = (params) => {
2647
2533
  const {
2648
- gasPrice,
2534
+ gasUsed,
2649
2535
  rawPayload,
2650
- tip,
2651
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2536
+ consensusParameters: { gasCosts, feeParams }
2652
2537
  } = params;
2653
2538
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2654
2539
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2658,7 +2543,8 @@ var calculateTransactionFee = (params) => {
2658
2543
  return {
2659
2544
  fee: (0, import_math11.bn)(0),
2660
2545
  minFee: (0, import_math11.bn)(0),
2661
- maxFee: (0, import_math11.bn)(0)
2546
+ maxFee: (0, import_math11.bn)(0),
2547
+ feeFromGasUsed: (0, import_math11.bn)(0)
2662
2548
  };
2663
2549
  }
2664
2550
  const { type, witnesses, inputs, policies } = transaction;
@@ -2690,6 +2576,7 @@ var calculateTransactionFee = (params) => {
2690
2576
  metadataGas,
2691
2577
  txBytesSize: transactionBytes.length
2692
2578
  });
2579
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2693
2580
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2694
2581
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2695
2582
  const maxGas = getMaxGas({
@@ -2697,25 +2584,17 @@ var calculateTransactionFee = (params) => {
2697
2584
  minGas,
2698
2585
  witnessesLength,
2699
2586
  gasLimit,
2700
- witnessLimit,
2701
- maxGasPerTx
2702
- });
2703
- const minFee = calculateGasFee({
2704
- gasPrice,
2705
- gas: minGas,
2706
- priceFactor: gasPriceFactor,
2707
- tip
2708
- });
2709
- const maxFee = calculateGasFee({
2710
- gasPrice,
2711
- gas: maxGas,
2712
- priceFactor: gasPriceFactor,
2713
- tip
2587
+ witnessLimit
2714
2588
  });
2589
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2590
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2591
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2592
+ const fee = minFee.add(feeFromGasUsed);
2715
2593
  return {
2594
+ fee,
2716
2595
  minFee,
2717
2596
  maxFee,
2718
- fee: maxFee
2597
+ feeFromGasUsed
2719
2598
  };
2720
2599
  };
2721
2600
 
@@ -2726,17 +2605,17 @@ var import_math13 = require("@fuel-ts/math");
2726
2605
  var import_transactions14 = require("@fuel-ts/transactions");
2727
2606
 
2728
2607
  // src/providers/transaction-summary/call.ts
2729
- var import_abi_coder2 = require("@fuel-ts/abi-coder");
2608
+ var import_abi_coder4 = require("@fuel-ts/abi-coder");
2730
2609
  var import_math12 = require("@fuel-ts/math");
2731
2610
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2732
- const abiInterface = new import_abi_coder2.Interface(abi);
2611
+ const abiInterface = new import_abi_coder4.Interface(abi);
2733
2612
  const callFunctionSelector = receipt.param1.toHex(8);
2734
2613
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2735
2614
  const inputs = functionFragment.jsonFn.inputs;
2736
2615
  let encodedArgs;
2737
2616
  if (functionFragment.isInputDataPointer) {
2738
2617
  if (rawPayload) {
2739
- const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2618
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2740
2619
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2741
2620
  }
2742
2621
  } else {
@@ -3282,12 +3161,10 @@ function assembleTransactionSummary(params) {
3282
3161
  gqlTransactionStatus,
3283
3162
  abiMap = {},
3284
3163
  maxInputs,
3285
- gasCosts,
3286
- maxGasPerTx,
3287
- gasPrice
3164
+ gasCosts
3288
3165
  } = params;
3289
3166
  const gasUsed = getGasUsedFromReceipts(receipts);
3290
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3167
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3291
3168
  const operations = getOperations({
3292
3169
  transactionType: transaction.type,
3293
3170
  inputs: transaction.inputs || [],
@@ -3298,14 +3175,11 @@ function assembleTransactionSummary(params) {
3298
3175
  maxInputs
3299
3176
  });
3300
3177
  const typeName = getTransactionTypeName(transaction.type);
3301
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3302
3178
  const { fee } = calculateTransactionFee({
3303
- gasPrice,
3179
+ gasUsed,
3304
3180
  rawPayload,
3305
- tip,
3306
3181
  consensusParameters: {
3307
3182
  gasCosts,
3308
- maxGasPerTx,
3309
3183
  feeParams: {
3310
3184
  gasPerByte,
3311
3185
  gasPriceFactor
@@ -3317,7 +3191,7 @@ function assembleTransactionSummary(params) {
3317
3191
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3318
3192
  let date;
3319
3193
  if (time) {
3320
- date = import_utils18.DateTime.fromTai64(time);
3194
+ date = import_utils19.DateTime.fromTai64(time);
3321
3195
  }
3322
3196
  const transactionSummary = {
3323
3197
  id,
@@ -3344,13 +3218,13 @@ function assembleTransactionSummary(params) {
3344
3218
  }
3345
3219
 
3346
3220
  // src/providers/transaction-response/getDecodedLogs.ts
3347
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3348
- var import_transactions17 = require("@fuel-ts/transactions");
3221
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
3222
+ var import_transactions16 = require("@fuel-ts/transactions");
3349
3223
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3350
3224
  return receipts.reduce((logs, receipt) => {
3351
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3352
- const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3353
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3225
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3226
+ const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3227
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3354
3228
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3355
3229
  logs.push(decodedLog);
3356
3230
  }
@@ -3365,7 +3239,7 @@ var TransactionResponse = class {
3365
3239
  /** Current provider */
3366
3240
  provider;
3367
3241
  /** Gas used on the transaction */
3368
- gasUsed = (0, import_math15.bn)(0);
3242
+ gasUsed = (0, import_math14.bn)(0);
3369
3243
  /** The graphql Transaction with receipts object. */
3370
3244
  gqlTransaction;
3371
3245
  abis;
@@ -3423,8 +3297,8 @@ var TransactionResponse = class {
3423
3297
  * @returns The decoded transaction.
3424
3298
  */
3425
3299
  decodeTransaction(transactionWithReceipts) {
3426
- return new import_transactions18.TransactionCoder().decode(
3427
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3300
+ return new import_transactions17.TransactionCoder().decode(
3301
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3428
3302
  0
3429
3303
  )?.[0];
3430
3304
  }
@@ -3443,27 +3317,20 @@ var TransactionResponse = class {
3443
3317
  const decodedTransaction = this.decodeTransaction(
3444
3318
  transaction
3445
3319
  );
3446
- let txReceipts = [];
3447
- if (transaction?.status && "receipts" in transaction.status) {
3448
- txReceipts = transaction.status.receipts;
3449
- }
3450
- const receipts = txReceipts.map(processGqlReceipt) || [];
3451
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3452
- const gasPrice = await this.provider.getLatestGasPrice();
3320
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3321
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3453
3322
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3454
3323
  const transactionSummary = assembleTransactionSummary({
3455
3324
  id: this.id,
3456
3325
  receipts,
3457
3326
  transaction: decodedTransaction,
3458
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3327
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3459
3328
  gqlTransactionStatus: transaction.status,
3460
3329
  gasPerByte,
3461
3330
  gasPriceFactor,
3462
3331
  abiMap: contractsAbiMap,
3463
3332
  maxInputs,
3464
- gasCosts,
3465
- maxGasPerTx,
3466
- gasPrice
3333
+ gasCosts
3467
3334
  });
3468
3335
  return transactionSummary;
3469
3336
  }
@@ -3590,29 +3457,29 @@ var processGqlChain = (chain) => {
3590
3457
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3591
3458
  return {
3592
3459
  name,
3593
- baseChainHeight: (0, import_math16.bn)(daHeight),
3460
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3594
3461
  consensusParameters: {
3595
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3596
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3597
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3598
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3599
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3600
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3601
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3602
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3603
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3604
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3605
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3606
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3607
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3608
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3609
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3462
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3463
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3464
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3465
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3466
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3467
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3468
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3469
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3470
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3471
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3472
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3473
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3474
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3475
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3476
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3610
3477
  gasCosts
3611
3478
  },
3612
3479
  gasCosts,
3613
3480
  latestBlock: {
3614
3481
  id: latestBlock.id,
3615
- height: (0, import_math16.bn)(latestBlock.height),
3482
+ height: (0, import_math15.bn)(latestBlock.header.height),
3616
3483
  time: latestBlock.header.time,
3617
3484
  transactions: latestBlock.transactions.map((i) => ({
3618
3485
  id: i.id
@@ -3706,8 +3573,10 @@ var _Provider = class {
3706
3573
  * Returns some helpful parameters related to gas fees.
3707
3574
  */
3708
3575
  getGasConfig() {
3576
+ const { minGasPrice } = this.getNode();
3709
3577
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3710
3578
  return {
3579
+ minGasPrice,
3711
3580
  maxGasPerTx,
3712
3581
  maxGasPerPredicate,
3713
3582
  gasPriceFactor,
@@ -3795,7 +3664,7 @@ var _Provider = class {
3795
3664
  name,
3796
3665
  consensusParameters: { chainId }
3797
3666
  } = await this.getChain();
3798
- const network = new import_ethers2.Network(name, chainId.toNumber());
3667
+ const network = new import_ethers.Network(name, chainId.toNumber());
3799
3668
  return Promise.resolve(network);
3800
3669
  }
3801
3670
  /**
@@ -3805,7 +3674,7 @@ var _Provider = class {
3805
3674
  */
3806
3675
  async getBlockNumber() {
3807
3676
  const { chain } = await this.operations.getChain();
3808
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3677
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3809
3678
  }
3810
3679
  /**
3811
3680
  * Returns the chain information.
@@ -3815,11 +3684,13 @@ var _Provider = class {
3815
3684
  async fetchNode() {
3816
3685
  const { nodeInfo } = await this.operations.getNodeInfo();
3817
3686
  const processedNodeInfo = {
3818
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3819
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3687
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3688
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3689
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3820
3690
  nodeVersion: nodeInfo.nodeVersion,
3821
3691
  utxoValidation: nodeInfo.utxoValidation,
3822
- vmBacktrace: nodeInfo.vmBacktrace
3692
+ vmBacktrace: nodeInfo.vmBacktrace,
3693
+ peers: nodeInfo.peers
3823
3694
  };
3824
3695
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3825
3696
  return processedNodeInfo;
@@ -3861,9 +3732,9 @@ var _Provider = class {
3861
3732
  if (estimateTxDependencies) {
3862
3733
  await this.estimateTxDependencies(transactionRequest);
3863
3734
  }
3864
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3735
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3865
3736
  let abis;
3866
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3737
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3867
3738
  abis = transactionRequest.abis;
3868
3739
  }
3869
3740
  if (awaitExecution) {
@@ -3904,14 +3775,15 @@ var _Provider = class {
3904
3775
  if (estimateTxDependencies) {
3905
3776
  return this.estimateTxDependencies(transactionRequest);
3906
3777
  }
3907
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3908
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3909
- encodedTransactions: encodedTransaction,
3778
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3779
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3780
+ encodedTransaction,
3910
3781
  utxoValidation: utxoValidation || false
3911
3782
  });
3912
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3913
- const receipts = rawReceipts.map(processGqlReceipt);
3914
- return { receipts, dryrunStatus: status };
3783
+ const receipts = gqlReceipts.map(processGqlReceipt);
3784
+ return {
3785
+ receipts
3786
+ };
3915
3787
  }
3916
3788
  /**
3917
3789
  * Verifies whether enough gas is available to complete transaction.
@@ -3922,13 +3794,13 @@ var _Provider = class {
3922
3794
  async estimatePredicates(transactionRequest) {
3923
3795
  const shouldEstimatePredicates = Boolean(
3924
3796
  transactionRequest.inputs.find(
3925
- (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()
3797
+ (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()
3926
3798
  )
3927
3799
  );
3928
3800
  if (!shouldEstimatePredicates) {
3929
3801
  return transactionRequest;
3930
3802
  }
3931
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3803
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3932
3804
  const response = await this.operations.estimatePredicates({
3933
3805
  encodedTransaction
3934
3806
  });
@@ -3937,7 +3809,7 @@ var _Provider = class {
3937
3809
  } = response;
3938
3810
  if (inputs) {
3939
3811
  inputs.forEach((input, index) => {
3940
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
3812
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3941
3813
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3942
3814
  }
3943
3815
  });
@@ -3950,31 +3822,31 @@ var _Provider = class {
3950
3822
  * If there are missing variable outputs,
3951
3823
  * `addVariableOutputs` is called on the transaction.
3952
3824
  *
3825
+ * @privateRemarks
3826
+ * TODO: Investigate support for missing contract IDs
3827
+ * TODO: Add support for missing output messages
3953
3828
  *
3954
3829
  * @param transactionRequest - The transaction request object.
3955
3830
  * @returns A promise.
3956
3831
  */
3957
3832
  async estimateTxDependencies(transactionRequest) {
3958
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
3833
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3959
3834
  return {
3960
3835
  receipts: [],
3961
3836
  outputVariables: 0,
3962
3837
  missingContractIds: []
3963
3838
  };
3964
3839
  }
3840
+ await this.estimatePredicates(transactionRequest);
3965
3841
  let receipts = [];
3966
3842
  const missingContractIds = [];
3967
3843
  let outputVariables = 0;
3968
- let dryrunStatus;
3969
3844
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3970
- const {
3971
- dryRun: [{ receipts: rawReceipts, status }]
3972
- } = await this.operations.dryRun({
3973
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
3845
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3846
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
3974
3847
  utxoValidation: false
3975
3848
  });
3976
- receipts = rawReceipts.map(processGqlReceipt);
3977
- dryrunStatus = status;
3849
+ receipts = gqlReceipts.map(processGqlReceipt);
3978
3850
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3979
3851
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3980
3852
  if (hasMissingOutputs) {
@@ -3984,11 +3856,6 @@ var _Provider = class {
3984
3856
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
3985
3857
  missingContractIds.push(contractId);
3986
3858
  });
3987
- const { maxFee } = await this.estimateTxGasAndFee({
3988
- transactionRequest,
3989
- optimizeGas: false
3990
- });
3991
- transactionRequest.maxFee = maxFee;
3992
3859
  } else {
3993
3860
  break;
3994
3861
  }
@@ -3996,133 +3863,37 @@ var _Provider = class {
3996
3863
  return {
3997
3864
  receipts,
3998
3865
  outputVariables,
3999
- missingContractIds,
4000
- dryrunStatus
3866
+ missingContractIds
4001
3867
  };
4002
3868
  }
4003
3869
  /**
4004
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4005
- *
4006
- * Transactions are dry run in batches. After each dry run, transactions requiring
4007
- * further modifications are identified. The method iteratively updates these transactions
4008
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4009
- *
4010
- * @param transactionRequests - Array of transaction request objects.
4011
- * @returns A promise that resolves to an array of results for each transaction.
3870
+ * Estimates the transaction gas and fee based on the provided transaction request.
3871
+ * @param transactionRequest - The transaction request object.
3872
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4012
3873
  */
4013
- async estimateMultipleTxDependencies(transactionRequests) {
4014
- const results = transactionRequests.map(() => ({
4015
- receipts: [],
4016
- outputVariables: 0,
4017
- missingContractIds: [],
4018
- dryrunStatus: void 0
4019
- }));
4020
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4021
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4022
- allRequests.forEach((req, index) => {
4023
- if (req.type === import_transactions19.TransactionType.Script) {
4024
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4025
- }
4026
- });
4027
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4028
- let attempt = 0;
4029
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4030
- const encodedTransactions = transactionsToProcess.map(
4031
- (index) => serializedTransactionsMap.get(index)
4032
- );
4033
- const dryRunResults = await this.operations.dryRun({
4034
- encodedTransactions,
4035
- utxoValidation: false
4036
- });
4037
- const nextRoundTransactions = [];
4038
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4039
- const currentResultIndex = transactionsToProcess[i];
4040
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4041
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4042
- results[currentResultIndex].dryrunStatus = status;
4043
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4044
- results[currentResultIndex].receipts
4045
- );
4046
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4047
- const requestToProcess = allRequests[currentResultIndex];
4048
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4049
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4050
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4051
- missingOutputContractIds.forEach(({ contractId }) => {
4052
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4053
- results[currentResultIndex].missingContractIds.push(contractId);
4054
- });
4055
- const { maxFee } = await this.estimateTxGasAndFee({
4056
- transactionRequest: requestToProcess,
4057
- optimizeGas: false
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
- async estimateTxGasAndFee(params) {
4089
- const { transactionRequest, optimizeGas = true } = params;
4090
- let { gasPrice } = params;
3874
+ estimateTxGasAndFee(params) {
3875
+ const { transactionRequest } = params;
3876
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4091
3877
  const chainInfo = this.getChain();
4092
- const { gasPriceFactor } = this.getGasConfig();
3878
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3879
+ transactionRequest.gasPrice = gasPrice;
4093
3880
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4094
- if (!gasPrice) {
4095
- gasPrice = await this.estimateGasPrice(10);
4096
- }
4097
- const minFee = calculateGasFee({
4098
- gasPrice: (0, import_math16.bn)(gasPrice),
4099
- gas: minGas,
4100
- priceFactor: gasPriceFactor,
4101
- tip: transactionRequest.tip
4102
- }).add(1);
4103
- let gasLimit = (0, import_math16.bn)(0);
4104
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4105
- gasLimit = transactionRequest.gasLimit;
4106
- if (!optimizeGas) {
3881
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3882
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3883
+ if (transactionRequest.gasLimit.eq(0)) {
4107
3884
  transactionRequest.gasLimit = minGas;
4108
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4109
- transactionRequest.gasLimit = gasLimit;
3885
+ transactionRequest.gasLimit = maxGasPerTx.sub(
3886
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
3887
+ );
4110
3888
  }
4111
3889
  }
4112
3890
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4113
- const maxFee = calculateGasFee({
4114
- gasPrice: (0, import_math16.bn)(gasPrice),
4115
- gas: maxGas,
4116
- priceFactor: gasPriceFactor,
4117
- tip: transactionRequest.tip
4118
- }).add(1);
3891
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4119
3892
  return {
4120
3893
  minGas,
4121
3894
  minFee,
4122
3895
  maxGas,
4123
- maxFee,
4124
- gasPrice,
4125
- gasLimit
3896
+ maxFee
4126
3897
  };
4127
3898
  }
4128
3899
  /**
@@ -4140,17 +3911,15 @@ var _Provider = class {
4140
3911
  if (estimateTxDependencies) {
4141
3912
  return this.estimateTxDependencies(transactionRequest);
4142
3913
  }
4143
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4144
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4145
- encodedTransactions,
3914
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3915
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3916
+ encodedTransaction,
4146
3917
  utxoValidation: true
4147
3918
  });
4148
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4149
- const { id, receipts, status } = dryRunStatus;
4150
- const processedReceipts = receipts.map(processGqlReceipt);
4151
- return { id, receipts: processedReceipts, status };
4152
- });
4153
- return { receipts: callResult[0].receipts };
3919
+ const receipts = gqlReceipts.map(processGqlReceipt);
3920
+ return {
3921
+ receipts
3922
+ };
4154
3923
  }
4155
3924
  /**
4156
3925
  * Returns a transaction cost to enable user
@@ -4167,80 +3936,77 @@ var _Provider = class {
4167
3936
  * @param tolerance - The tolerance to add on top of the gasUsed.
4168
3937
  * @returns A promise that resolves to the transaction cost object.
4169
3938
  */
4170
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3939
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3940
+ estimateTxDependencies = true,
3941
+ estimatePredicates = true,
3942
+ resourcesOwner,
3943
+ signatureCallback
3944
+ } = {}) {
4171
3945
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4172
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
3946
+ const { minGasPrice } = this.getGasConfig();
3947
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3948
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4173
3949
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4174
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3950
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4175
3951
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4176
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4177
3952
  if (isScriptTransaction) {
4178
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
3953
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4179
3954
  }
4180
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4181
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3955
+ if (estimatePredicates) {
3956
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3957
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3958
+ }
3959
+ await this.estimatePredicates(txRequestClone);
4182
3960
  }
4183
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4184
- let addedSignatures = 0;
4185
3961
  if (signatureCallback && isScriptTransaction) {
4186
- const lengthBefore = signedRequest.witnesses.length;
4187
- await signatureCallback(signedRequest);
4188
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4189
- }
4190
- await this.estimatePredicates(signedRequest);
4191
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4192
- transactionRequest: signedRequest,
4193
- optimizeGas: false
3962
+ await signatureCallback(txRequestClone);
3963
+ }
3964
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3965
+ transactionRequest: txRequestClone
4194
3966
  });
4195
- txRequestClone.maxFee = maxFee;
4196
3967
  let receipts = [];
4197
3968
  let missingContractIds = [];
4198
3969
  let outputVariables = 0;
4199
- let gasUsed = (0, import_math16.bn)(0);
4200
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4201
- if (isScriptTransaction) {
4202
- if (signatureCallback) {
4203
- await signatureCallback(txRequestClone);
4204
- }
4205
- txRequestClone.gasLimit = gasLimit;
3970
+ let gasUsed = (0, import_math15.bn)(0);
3971
+ if (isScriptTransaction && estimateTxDependencies) {
3972
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4206
3973
  const result = await this.estimateTxDependencies(txRequestClone);
4207
3974
  receipts = result.receipts;
4208
3975
  outputVariables = result.outputVariables;
4209
3976
  missingContractIds = result.missingContractIds;
4210
- gasUsed = getGasUsedFromReceipts(receipts);
3977
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4211
3978
  txRequestClone.gasLimit = gasUsed;
4212
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4213
- transactionRequest: txRequestClone,
4214
- gasPrice
3979
+ txRequestClone.gasPrice = setGasPrice;
3980
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3981
+ transactionRequest: txRequestClone
4215
3982
  }));
4216
3983
  }
4217
3984
  return {
4218
3985
  requiredQuantities: allQuantities,
4219
3986
  receipts,
4220
3987
  gasUsed,
4221
- gasPrice,
3988
+ minGasPrice,
3989
+ gasPrice: setGasPrice,
4222
3990
  minGas,
4223
3991
  maxGas,
4224
3992
  minFee,
4225
3993
  maxFee,
3994
+ estimatedInputs: txRequestClone.inputs,
4226
3995
  outputVariables,
4227
- missingContractIds,
4228
- addedSignatures,
4229
- estimatedPredicates: txRequestClone.inputs
3996
+ missingContractIds
4230
3997
  };
4231
3998
  }
4232
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
3999
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4233
4000
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4234
4001
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4235
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4236
- quantitiesToContract
4237
- });
4002
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4238
4003
  transactionRequest.addResources(
4239
4004
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4240
4005
  );
4241
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4242
- quantitiesToContract
4243
- });
4006
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4007
+ transactionRequest,
4008
+ forwardingQuantities
4009
+ );
4244
4010
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4245
4011
  return {
4246
4012
  resources,
@@ -4256,16 +4022,17 @@ var _Provider = class {
4256
4022
  const result = await this.operations.getCoins({
4257
4023
  first: 10,
4258
4024
  ...paginationArgs,
4259
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4025
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4260
4026
  });
4261
4027
  const coins = result.coins.edges.map((edge) => edge.node);
4262
4028
  return coins.map((coin) => ({
4263
4029
  id: coin.utxoId,
4264
4030
  assetId: coin.assetId,
4265
- amount: (0, import_math16.bn)(coin.amount),
4031
+ amount: (0, import_math15.bn)(coin.amount),
4266
4032
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4267
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4268
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4033
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4034
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4035
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4269
4036
  }));
4270
4037
  }
4271
4038
  /**
@@ -4279,19 +4046,19 @@ var _Provider = class {
4279
4046
  async getResourcesToSpend(owner, quantities, excludedIds) {
4280
4047
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4281
4048
  const excludeInput = {
4282
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4283
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4049
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4050
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4284
4051
  };
4285
4052
  if (this.cache) {
4286
4053
  const uniqueUtxos = new Set(
4287
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4054
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4288
4055
  );
4289
4056
  excludeInput.utxos = Array.from(uniqueUtxos);
4290
4057
  }
4291
4058
  const coinsQuery = {
4292
4059
  owner: ownerAddress.toB256(),
4293
4060
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4294
- assetId: (0, import_utils22.hexlify)(assetId),
4061
+ assetId: (0, import_utils23.hexlify)(assetId),
4295
4062
  amount: amount.toString(10),
4296
4063
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4297
4064
  })),
@@ -4302,9 +4069,9 @@ var _Provider = class {
4302
4069
  switch (coin.__typename) {
4303
4070
  case "MessageCoin":
4304
4071
  return {
4305
- amount: (0, import_math16.bn)(coin.amount),
4072
+ amount: (0, import_math15.bn)(coin.amount),
4306
4073
  assetId: coin.assetId,
4307
- daHeight: (0, import_math16.bn)(coin.daHeight),
4074
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4308
4075
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4309
4076
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4310
4077
  nonce: coin.nonce
@@ -4312,11 +4079,12 @@ var _Provider = class {
4312
4079
  case "Coin":
4313
4080
  return {
4314
4081
  id: coin.utxoId,
4315
- amount: (0, import_math16.bn)(coin.amount),
4082
+ amount: (0, import_math15.bn)(coin.amount),
4316
4083
  assetId: coin.assetId,
4317
4084
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4318
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4319
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4085
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4086
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4087
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4320
4088
  };
4321
4089
  default:
4322
4090
  return null;
@@ -4333,13 +4101,13 @@ var _Provider = class {
4333
4101
  async getBlock(idOrHeight) {
4334
4102
  let variables;
4335
4103
  if (typeof idOrHeight === "number") {
4336
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4104
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4337
4105
  } else if (idOrHeight === "latest") {
4338
4106
  variables = { height: (await this.getBlockNumber()).toString(10) };
4339
4107
  } else if (idOrHeight.length === 66) {
4340
4108
  variables = { blockId: idOrHeight };
4341
4109
  } else {
4342
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4110
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4343
4111
  }
4344
4112
  const { block } = await this.operations.getBlock(variables);
4345
4113
  if (!block) {
@@ -4347,7 +4115,7 @@ var _Provider = class {
4347
4115
  }
4348
4116
  return {
4349
4117
  id: block.id,
4350
- height: (0, import_math16.bn)(block.height),
4118
+ height: (0, import_math15.bn)(block.header.height),
4351
4119
  time: block.header.time,
4352
4120
  transactionIds: block.transactions.map((tx) => tx.id)
4353
4121
  };
@@ -4362,7 +4130,7 @@ var _Provider = class {
4362
4130
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4363
4131
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4364
4132
  id: block.id,
4365
- height: (0, import_math16.bn)(block.height),
4133
+ height: (0, import_math15.bn)(block.header.height),
4366
4134
  time: block.header.time,
4367
4135
  transactionIds: block.transactions.map((tx) => tx.id)
4368
4136
  }));
@@ -4377,7 +4145,7 @@ var _Provider = class {
4377
4145
  async getBlockWithTransactions(idOrHeight) {
4378
4146
  let variables;
4379
4147
  if (typeof idOrHeight === "number") {
4380
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4148
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4381
4149
  } else if (idOrHeight === "latest") {
4382
4150
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4383
4151
  } else {
@@ -4389,11 +4157,11 @@ var _Provider = class {
4389
4157
  }
4390
4158
  return {
4391
4159
  id: block.id,
4392
- height: (0, import_math16.bn)(block.height, 10),
4160
+ height: (0, import_math15.bn)(block.header.height, 10),
4393
4161
  time: block.header.time,
4394
4162
  transactionIds: block.transactions.map((tx) => tx.id),
4395
4163
  transactions: block.transactions.map(
4396
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4164
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4397
4165
  )
4398
4166
  };
4399
4167
  }
@@ -4408,8 +4176,8 @@ var _Provider = class {
4408
4176
  if (!transaction) {
4409
4177
  return null;
4410
4178
  }
4411
- return new import_transactions19.TransactionCoder().decode(
4412
- (0, import_utils22.arrayify)(transaction.rawPayload),
4179
+ return new import_transactions18.TransactionCoder().decode(
4180
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4413
4181
  0
4414
4182
  )?.[0];
4415
4183
  }
@@ -4436,9 +4204,9 @@ var _Provider = class {
4436
4204
  async getContractBalance(contractId, assetId) {
4437
4205
  const { contractBalance } = await this.operations.getContractBalance({
4438
4206
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4439
- asset: (0, import_utils22.hexlify)(assetId)
4207
+ asset: (0, import_utils23.hexlify)(assetId)
4440
4208
  });
4441
- return (0, import_math16.bn)(contractBalance.amount, 10);
4209
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4442
4210
  }
4443
4211
  /**
4444
4212
  * Returns the balance for the given owner for the given asset ID.
@@ -4450,9 +4218,9 @@ var _Provider = class {
4450
4218
  async getBalance(owner, assetId) {
4451
4219
  const { balance } = await this.operations.getBalance({
4452
4220
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4453
- assetId: (0, import_utils22.hexlify)(assetId)
4221
+ assetId: (0, import_utils23.hexlify)(assetId)
4454
4222
  });
4455
- return (0, import_math16.bn)(balance.amount, 10);
4223
+ return (0, import_math15.bn)(balance.amount, 10);
4456
4224
  }
4457
4225
  /**
4458
4226
  * Returns balances for the given owner.
@@ -4470,7 +4238,7 @@ var _Provider = class {
4470
4238
  const balances = result.balances.edges.map((edge) => edge.node);
4471
4239
  return balances.map((balance) => ({
4472
4240
  assetId: balance.assetId,
4473
- amount: (0, import_math16.bn)(balance.amount)
4241
+ amount: (0, import_math15.bn)(balance.amount)
4474
4242
  }));
4475
4243
  }
4476
4244
  /**
@@ -4488,19 +4256,19 @@ var _Provider = class {
4488
4256
  });
4489
4257
  const messages = result.messages.edges.map((edge) => edge.node);
4490
4258
  return messages.map((message) => ({
4491
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4259
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4492
4260
  sender: message.sender,
4493
4261
  recipient: message.recipient,
4494
4262
  nonce: message.nonce,
4495
- amount: (0, import_math16.bn)(message.amount),
4263
+ amount: (0, import_math15.bn)(message.amount),
4496
4264
  data: message.data
4497
4265
  }),
4498
4266
  sender: import_address3.Address.fromAddressOrString(message.sender),
4499
4267
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4500
4268
  nonce: message.nonce,
4501
- amount: (0, import_math16.bn)(message.amount),
4502
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4503
- daHeight: (0, import_math16.bn)(message.daHeight)
4269
+ amount: (0, import_math15.bn)(message.amount),
4270
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4271
+ daHeight: (0, import_math15.bn)(message.daHeight)
4504
4272
  }));
4505
4273
  }
4506
4274
  /**
@@ -4553,60 +4321,44 @@ var _Provider = class {
4553
4321
  } = result.messageProof;
4554
4322
  return {
4555
4323
  messageProof: {
4556
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4324
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4557
4325
  proofSet: messageProof.proofSet
4558
4326
  },
4559
4327
  blockProof: {
4560
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4328
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4561
4329
  proofSet: blockProof.proofSet
4562
4330
  },
4563
4331
  messageBlockHeader: {
4564
4332
  id: messageBlockHeader.id,
4565
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4566
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4333
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4334
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4567
4335
  transactionsRoot: messageBlockHeader.transactionsRoot,
4568
- height: (0, import_math16.bn)(messageBlockHeader.height),
4336
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4569
4337
  prevRoot: messageBlockHeader.prevRoot,
4570
4338
  time: messageBlockHeader.time,
4571
4339
  applicationHash: messageBlockHeader.applicationHash,
4572
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4573
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4574
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4575
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4576
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4340
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4341
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4577
4342
  },
4578
4343
  commitBlockHeader: {
4579
4344
  id: commitBlockHeader.id,
4580
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4581
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4345
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4346
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4582
4347
  transactionsRoot: commitBlockHeader.transactionsRoot,
4583
- height: (0, import_math16.bn)(commitBlockHeader.height),
4348
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4584
4349
  prevRoot: commitBlockHeader.prevRoot,
4585
4350
  time: commitBlockHeader.time,
4586
4351
  applicationHash: commitBlockHeader.applicationHash,
4587
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4588
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4589
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4590
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4591
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4352
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4353
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4592
4354
  },
4593
4355
  sender: import_address3.Address.fromAddressOrString(sender),
4594
4356
  recipient: import_address3.Address.fromAddressOrString(recipient),
4595
4357
  nonce,
4596
- amount: (0, import_math16.bn)(amount),
4358
+ amount: (0, import_math15.bn)(amount),
4597
4359
  data
4598
4360
  };
4599
4361
  }
4600
- async getLatestGasPrice() {
4601
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4602
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4603
- }
4604
- async estimateGasPrice(blockHorizon) {
4605
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4606
- blockHorizon: String(blockHorizon)
4607
- });
4608
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4609
- }
4610
4362
  /**
4611
4363
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4612
4364
  *
@@ -4626,10 +4378,10 @@ var _Provider = class {
4626
4378
  */
4627
4379
  async produceBlocks(amount, startTime) {
4628
4380
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4629
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4630
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4381
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4382
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4631
4383
  });
4632
- return (0, import_math16.bn)(latestBlockHeight);
4384
+ return (0, import_math15.bn)(latestBlockHeight);
4633
4385
  }
4634
4386
  // eslint-disable-next-line @typescript-eslint/require-await
4635
4387
  async getTransactionResponse(transactionId) {
@@ -4643,7 +4395,7 @@ cacheInputs_fn = function(inputs) {
4643
4395
  return;
4644
4396
  }
4645
4397
  inputs.forEach((input) => {
4646
- if (input.type === import_transactions19.InputType.Coin) {
4398
+ if (input.type === import_transactions18.InputType.Coin) {
4647
4399
  this.cache?.set(input.id);
4648
4400
  }
4649
4401
  });
@@ -4653,9 +4405,9 @@ __publicField(Provider, "nodeInfoCache", {});
4653
4405
 
4654
4406
  // src/providers/transaction-summary/get-transaction-summary.ts
4655
4407
  var import_errors15 = require("@fuel-ts/errors");
4656
- var import_math17 = require("@fuel-ts/math");
4657
- var import_transactions20 = require("@fuel-ts/transactions");
4658
- var import_utils25 = require("@fuel-ts/utils");
4408
+ var import_math16 = require("@fuel-ts/math");
4409
+ var import_transactions19 = require("@fuel-ts/transactions");
4410
+ var import_utils26 = require("@fuel-ts/utils");
4659
4411
 
4660
4412
  // src/providers/chains.ts
4661
4413
  var CHAIN_IDS = {
@@ -4703,18 +4455,18 @@ var assets = [
4703
4455
  ];
4704
4456
 
4705
4457
  // src/utils/formatTransferToContractScriptData.ts
4706
- var import_abi_coder4 = require("@fuel-ts/abi-coder");
4707
- var import_math18 = require("@fuel-ts/math");
4708
- var import_utils26 = require("@fuel-ts/utils");
4458
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
4459
+ var import_math17 = require("@fuel-ts/math");
4460
+ var import_utils27 = require("@fuel-ts/utils");
4709
4461
  var asm = __toESM(require("@fuels/vm-asm"));
4710
4462
  var formatTransferToContractScriptData = (params) => {
4711
4463
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4712
- const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4713
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4464
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4465
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4714
4466
  const scriptData = Uint8Array.from([
4715
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4467
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4716
4468
  ...encoded,
4717
- ...(0, import_utils26.arrayify)(assetId)
4469
+ ...(0, import_utils27.arrayify)(assetId)
4718
4470
  ]);
4719
4471
  return scriptData;
4720
4472
  };
@@ -4899,33 +4651,36 @@ var Account = class extends import_interfaces.AbstractAccount {
4899
4651
  * @param fee - The estimated transaction fee.
4900
4652
  * @returns A promise that resolves when the resources are added to the transaction.
4901
4653
  */
4902
- async fund(request, params) {
4903
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4904
- const txRequest = request;
4905
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4906
- amount: (0, import_math19.bn)(fee),
4654
+ async fund(request, coinQuantities, fee) {
4655
+ const updatedQuantities = addAmountToAsset({
4656
+ amount: (0, import_math18.bn)(fee),
4907
4657
  assetId: import_configs12.BaseAssetId,
4908
- coinQuantities: requiredQuantities
4658
+ coinQuantities
4909
4659
  });
4910
4660
  const quantitiesDict = {};
4911
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4661
+ updatedQuantities.forEach(({ amount, assetId }) => {
4912
4662
  quantitiesDict[assetId] = {
4913
4663
  required: amount,
4914
- owned: (0, import_math19.bn)(0)
4664
+ owned: (0, import_math18.bn)(0)
4915
4665
  };
4916
4666
  });
4917
- txRequest.inputs.forEach((input) => {
4667
+ const cachedUtxos = [];
4668
+ const cachedMessages = [];
4669
+ const owner = this.address.toB256();
4670
+ request.inputs.forEach((input) => {
4918
4671
  const isResource = "amount" in input;
4919
4672
  if (isResource) {
4920
4673
  const isCoin2 = "owner" in input;
4921
4674
  if (isCoin2) {
4922
4675
  const assetId = String(input.assetId);
4923
- if (quantitiesDict[assetId]) {
4924
- const amount = (0, import_math19.bn)(input.amount);
4676
+ if (input.owner === owner && quantitiesDict[assetId]) {
4677
+ const amount = (0, import_math18.bn)(input.amount);
4925
4678
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4679
+ cachedUtxos.push(input.id);
4926
4680
  }
4927
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4681
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4928
4682
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4683
+ cachedMessages.push(input.nonce);
4929
4684
  }
4930
4685
  }
4931
4686
  });
@@ -4940,23 +4695,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4940
4695
  });
4941
4696
  const needsToBeFunded = missingQuantities.length;
4942
4697
  if (needsToBeFunded) {
4943
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4944
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4945
- txRequest.addResources(resources);
4946
- }
4947
- txRequest.shiftPredicateData();
4948
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4949
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
4950
- if (addedSignatures) {
4951
- Array.from({ length: addedSignatures }).forEach(
4952
- () => requestToBeReEstimate.addEmptyWitness()
4953
- );
4698
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4699
+ messages: cachedMessages,
4700
+ utxos: cachedUtxos
4701
+ });
4702
+ request.addResources(resources);
4954
4703
  }
4955
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4956
- transactionRequest: requestToBeReEstimate
4957
- });
4958
- txRequest.maxFee = maxFee;
4959
- return txRequest;
4960
4704
  }
4961
4705
  /**
4962
4706
  * A helper that creates a transfer transaction request and returns it.
@@ -4964,25 +4708,28 @@ var Account = class extends import_interfaces.AbstractAccount {
4964
4708
  * @param destination - The address of the destination.
4965
4709
  * @param amount - The amount of coins to transfer.
4966
4710
  * @param assetId - The asset ID of the coins to transfer.
4967
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4711
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4968
4712
  * @returns A promise that resolves to the prepared transaction request.
4969
4713
  */
4970
4714
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4971
- const request = new ScriptTransactionRequest(txParams);
4715
+ const { minGasPrice } = this.provider.getGasConfig();
4716
+ const params = { gasPrice: minGasPrice, ...txParams };
4717
+ const request = new ScriptTransactionRequest(params);
4972
4718
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
4973
- const txCost = await this.provider.getTransactionCost(request, {
4719
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4974
4720
  estimateTxDependencies: true,
4975
4721
  resourcesOwner: this
4976
4722
  });
4977
- if ("gasLimit" in txParams) {
4978
- this.validateGas({
4979
- gasUsed: txCost.gasUsed,
4980
- gasLimit: request.gasLimit
4981
- });
4982
- }
4983
- request.gasLimit = txCost.gasUsed;
4984
- request.maxFee = txCost.maxFee;
4985
- await this.fund(request, txCost);
4723
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
4724
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
4725
+ this.validateGas({
4726
+ gasUsed,
4727
+ gasPrice: request.gasPrice,
4728
+ gasLimit: request.gasLimit,
4729
+ minGasPrice
4730
+ });
4731
+ await this.fund(request, requiredQuantities, maxFee);
4732
+ request.updatePredicateInputs(estimatedInputs);
4986
4733
  return request;
4987
4734
  }
4988
4735
  /**
@@ -4995,7 +4742,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4995
4742
  * @returns A promise that resolves to the transaction response.
4996
4743
  */
4997
4744
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4998
- if ((0, import_math19.bn)(amount).lte(0)) {
4745
+ if ((0, import_math18.bn)(amount).lte(0)) {
4999
4746
  throw new import_errors16.FuelError(
5000
4747
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5001
4748
  "Transfer amount must be a positive number."
@@ -5014,37 +4761,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5014
4761
  * @returns A promise that resolves to the transaction response.
5015
4762
  */
5016
4763
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5017
- if ((0, import_math19.bn)(amount).lte(0)) {
4764
+ if ((0, import_math18.bn)(amount).lte(0)) {
5018
4765
  throw new import_errors16.FuelError(
5019
4766
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5020
4767
  "Transfer amount must be a positive number."
5021
4768
  );
5022
4769
  }
5023
4770
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4771
+ const { minGasPrice } = this.provider.getGasConfig();
4772
+ const params = { gasPrice: minGasPrice, ...txParams };
5024
4773
  const { script, scriptData } = await assembleTransferToContractScript({
5025
4774
  hexlifiedContractId: contractAddress.toB256(),
5026
- amountToTransfer: (0, import_math19.bn)(amount),
4775
+ amountToTransfer: (0, import_math18.bn)(amount),
5027
4776
  assetId
5028
4777
  });
5029
4778
  const request = new ScriptTransactionRequest({
5030
- ...txParams,
4779
+ ...params,
5031
4780
  script,
5032
4781
  scriptData
5033
4782
  });
5034
4783
  request.addContractInputAndOutput(contractAddress);
5035
- const txCost = await this.provider.getTransactionCost(request, {
5036
- resourcesOwner: this,
5037
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
4784
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4785
+ request,
4786
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
4787
+ );
4788
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4789
+ this.validateGas({
4790
+ gasUsed,
4791
+ gasPrice: request.gasPrice,
4792
+ gasLimit: request.gasLimit,
4793
+ minGasPrice
5038
4794
  });
5039
- if (txParams.gasLimit) {
5040
- this.validateGas({
5041
- gasUsed: txCost.gasUsed,
5042
- gasLimit: request.gasLimit
5043
- });
5044
- }
5045
- request.gasLimit = txCost.gasUsed;
5046
- request.maxFee = txCost.maxFee;
5047
- await this.fund(request, txCost);
4795
+ await this.fund(request, requiredQuantities, maxFee);
5048
4796
  return this.sendTransaction(request);
5049
4797
  }
5050
4798
  /**
@@ -5056,31 +4804,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5056
4804
  * @returns A promise that resolves to the transaction response.
5057
4805
  */
5058
4806
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4807
+ const { minGasPrice } = this.provider.getGasConfig();
5059
4808
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5060
- const recipientDataArray = (0, import_utils27.arrayify)(
4809
+ const recipientDataArray = (0, import_utils28.arrayify)(
5061
4810
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5062
4811
  );
5063
- const amountDataArray = (0, import_utils27.arrayify)(
5064
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
4812
+ const amountDataArray = (0, import_utils28.arrayify)(
4813
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5065
4814
  );
5066
4815
  const script = new Uint8Array([
5067
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4816
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5068
4817
  ...recipientDataArray,
5069
4818
  ...amountDataArray
5070
4819
  ]);
5071
- const params = { script, ...txParams };
4820
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5072
4821
  const request = new ScriptTransactionRequest(params);
5073
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5074
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5075
- if (txParams.gasLimit) {
5076
- this.validateGas({
5077
- gasUsed: txCost.gasUsed,
5078
- gasLimit: request.gasLimit
5079
- });
5080
- }
5081
- request.maxFee = txCost.maxFee;
5082
- request.gasLimit = txCost.gasUsed;
5083
- await this.fund(request, txCost);
4822
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
4823
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4824
+ request,
4825
+ forwardingQuantities
4826
+ );
4827
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4828
+ this.validateGas({
4829
+ gasUsed,
4830
+ gasPrice: request.gasPrice,
4831
+ gasLimit: request.gasLimit,
4832
+ minGasPrice
4833
+ });
4834
+ await this.fund(request, requiredQuantities, maxFee);
5084
4835
  return this.sendTransaction(request);
5085
4836
  }
5086
4837
  async signMessage(message) {
@@ -5138,7 +4889,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5138
4889
  }
5139
4890
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5140
4891
  }
5141
- validateGas({ gasUsed, gasLimit }) {
4892
+ validateGas({
4893
+ gasUsed,
4894
+ gasPrice,
4895
+ gasLimit,
4896
+ minGasPrice
4897
+ }) {
4898
+ if (minGasPrice.gt(gasPrice)) {
4899
+ throw new import_errors16.FuelError(
4900
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4901
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4902
+ );
4903
+ }
5142
4904
  if (gasUsed.gt(gasLimit)) {
5143
4905
  throw new import_errors16.FuelError(
5144
4906
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5150,10 +4912,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5150
4912
 
5151
4913
  // src/signer/signer.ts
5152
4914
  var import_address5 = require("@fuel-ts/address");
5153
- var import_crypto = require("@fuel-ts/crypto");
4915
+ var import_crypto2 = require("@fuel-ts/crypto");
5154
4916
  var import_hasher2 = require("@fuel-ts/hasher");
5155
- var import_math20 = require("@fuel-ts/math");
5156
- var import_utils28 = require("@fuel-ts/utils");
4917
+ var import_math19 = require("@fuel-ts/math");
4918
+ var import_utils29 = require("@fuel-ts/utils");
5157
4919
  var import_secp256k1 = require("@noble/curves/secp256k1");
5158
4920
  var Signer = class {
5159
4921
  address;
@@ -5172,10 +4934,10 @@ var Signer = class {
5172
4934
  privateKey = `0x${privateKey}`;
5173
4935
  }
5174
4936
  }
5175
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5176
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5177
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5178
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4937
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
4938
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4939
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4940
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5179
4941
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5180
4942
  }
5181
4943
  /**
@@ -5189,11 +4951,11 @@ var Signer = class {
5189
4951
  * @returns hashed signature
5190
4952
  */
5191
4953
  sign(data) {
5192
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5193
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5194
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
4954
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
4955
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
4956
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5195
4957
  s[0] |= (signature.recovery || 0) << 7;
5196
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4958
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5197
4959
  }
5198
4960
  /**
5199
4961
  * Add point on the current elliptic curve
@@ -5202,8 +4964,8 @@ var Signer = class {
5202
4964
  * @returns compressed point on the curve
5203
4965
  */
5204
4966
  addPoint(point) {
5205
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5206
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
4967
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
4968
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5207
4969
  const result = p0.add(p1);
5208
4970
  return `0x${result.toHex(true)}`;
5209
4971
  }
@@ -5215,16 +4977,16 @@ var Signer = class {
5215
4977
  * @returns public key from signature from the
5216
4978
  */
5217
4979
  static recoverPublicKey(data, signature) {
5218
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
4980
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5219
4981
  const r = signedMessageBytes.slice(0, 32);
5220
4982
  const s = signedMessageBytes.slice(32, 64);
5221
4983
  const recoveryParam = (s[0] & 128) >> 7;
5222
4984
  s[0] &= 127;
5223
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
4985
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5224
4986
  recoveryParam
5225
4987
  );
5226
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5227
- return (0, import_utils28.hexlify)(publicKey);
4988
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
4989
+ return (0, import_utils29.hexlify)(publicKey);
5228
4990
  }
5229
4991
  /**
5230
4992
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5243,7 +5005,7 @@ var Signer = class {
5243
5005
  * @returns random 32-byte hashed
5244
5006
  */
5245
5007
  static generatePrivateKey(entropy) {
5246
- return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5008
+ 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);
5247
5009
  }
5248
5010
  /**
5249
5011
  * Extended publicKey from a compact publicKey
@@ -5252,16 +5014,16 @@ var Signer = class {
5252
5014
  * @returns extended publicKey
5253
5015
  */
5254
5016
  static extendPublicKey(publicKey) {
5255
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5256
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5017
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5018
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5257
5019
  }
5258
5020
  };
5259
5021
 
5260
5022
  // src/wallet/keystore-wallet.ts
5261
5023
  var import_address6 = require("@fuel-ts/address");
5262
- var import_crypto2 = require("@fuel-ts/crypto");
5024
+ var import_crypto3 = require("@fuel-ts/crypto");
5263
5025
  var import_errors17 = require("@fuel-ts/errors");
5264
- var import_utils29 = require("@fuel-ts/utils");
5026
+ var import_utils30 = require("@fuel-ts/utils");
5265
5027
  var import_uuid = require("uuid");
5266
5028
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5267
5029
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5275,22 +5037,22 @@ var removeHexPrefix = (hexString) => {
5275
5037
  return hexString;
5276
5038
  };
5277
5039
  async function encryptKeystoreWallet(privateKey, address, password) {
5278
- const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
5040
+ const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
5279
5041
  const ownerAddress = import_address6.Address.fromAddressOrString(address);
5280
- const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
5281
- const key = (0, import_crypto2.scrypt)({
5282
- password: (0, import_crypto2.bufferFromString)(password),
5042
+ const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
5043
+ const key = (0, import_crypto3.scrypt)({
5044
+ password: (0, import_crypto3.bufferFromString)(password),
5283
5045
  salt,
5284
5046
  dklen: DEFAULT_KEY_SIZE,
5285
5047
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5286
5048
  r: DEFAULT_KDF_PARAMS_R,
5287
5049
  p: DEFAULT_KDF_PARAMS_P
5288
5050
  });
5289
- const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
5290
- const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5051
+ const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
5052
+ const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5291
5053
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5292
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5293
- const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5054
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5055
+ const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5294
5056
  const keystore = {
5295
5057
  id: (0, import_uuid.v4)(),
5296
5058
  version: 3,
@@ -5298,15 +5060,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5298
5060
  crypto: {
5299
5061
  cipher: "aes-128-ctr",
5300
5062
  mac,
5301
- cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
5302
- ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
5063
+ cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
5064
+ ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
5303
5065
  kdf: "scrypt",
5304
5066
  kdfparams: {
5305
5067
  dklen: DEFAULT_KEY_SIZE,
5306
5068
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5307
5069
  p: DEFAULT_KDF_PARAMS_P,
5308
5070
  r: DEFAULT_KDF_PARAMS_R,
5309
- salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
5071
+ salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
5310
5072
  }
5311
5073
  }
5312
5074
  };
@@ -5322,11 +5084,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5322
5084
  kdfparams: { dklen, n, r, p, salt }
5323
5085
  }
5324
5086
  } = keystoreWallet;
5325
- const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
5326
- const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
5327
- const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
5328
- const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
5329
- const key = (0, import_crypto2.scrypt)({
5087
+ const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
5088
+ const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
5089
+ const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
5090
+ const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
5091
+ const key = (0, import_crypto3.scrypt)({
5330
5092
  password: passwordBuffer,
5331
5093
  salt: saltBuffer,
5332
5094
  n,
@@ -5335,16 +5097,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5335
5097
  dklen
5336
5098
  });
5337
5099
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
5338
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5339
- const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5100
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5101
+ const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5340
5102
  if (mac !== macHash) {
5341
5103
  throw new import_errors17.FuelError(
5342
5104
  import_errors17.ErrorCode.INVALID_PASSWORD,
5343
5105
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5344
5106
  );
5345
5107
  }
5346
- const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5347
- const privateKey = (0, import_utils29.hexlify)(buffer);
5108
+ const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5109
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5348
5110
  return privateKey;
5349
5111
  }
5350
5112
 
@@ -5389,7 +5151,7 @@ var BaseWalletUnlocked = class extends Account {
5389
5151
  */
5390
5152
  async signMessage(message) {
5391
5153
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5392
- return (0, import_utils30.hexlify)(signedMessage);
5154
+ return (0, import_utils31.hexlify)(signedMessage);
5393
5155
  }
5394
5156
  /**
5395
5157
  * Signs a transaction with the wallet's private key.
@@ -5402,7 +5164,7 @@ var BaseWalletUnlocked = class extends Account {
5402
5164
  const chainId = this.provider.getChainId();
5403
5165
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5404
5166
  const signature = await this.signer().sign(hashedTransaction);
5405
- return (0, import_utils30.hexlify)(signature);
5167
+ return (0, import_utils31.hexlify)(signature);
5406
5168
  }
5407
5169
  /**
5408
5170
  * Populates a transaction with the witnesses signature.
@@ -5422,7 +5184,7 @@ var BaseWalletUnlocked = class extends Account {
5422
5184
  * @param transactionRequestLike - The transaction request to send.
5423
5185
  * @returns A promise that resolves to the TransactionResponse object.
5424
5186
  */
5425
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5187
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5426
5188
  const transactionRequest = transactionRequestify(transactionRequestLike);
5427
5189
  if (estimateTxDependencies) {
5428
5190
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5463,16 +5225,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5463
5225
  // src/hdwallet/hdwallet.ts
5464
5226
  var import_errors20 = require("@fuel-ts/errors");
5465
5227
  var import_hasher6 = require("@fuel-ts/hasher");
5466
- var import_math21 = require("@fuel-ts/math");
5467
- var import_utils34 = require("@fuel-ts/utils");
5468
- var import_ethers4 = require("ethers");
5228
+ var import_math20 = require("@fuel-ts/math");
5229
+ var import_utils35 = require("@fuel-ts/utils");
5230
+ var import_ethers3 = require("ethers");
5469
5231
 
5470
5232
  // src/mnemonic/mnemonic.ts
5471
- var import_crypto3 = require("@fuel-ts/crypto");
5233
+ var import_crypto4 = require("@fuel-ts/crypto");
5472
5234
  var import_errors19 = require("@fuel-ts/errors");
5473
5235
  var import_hasher5 = require("@fuel-ts/hasher");
5474
- var import_utils32 = require("@fuel-ts/utils");
5475
- var import_ethers3 = require("ethers");
5236
+ var import_utils33 = require("@fuel-ts/utils");
5237
+ var import_ethers2 = require("ethers");
5476
5238
 
5477
5239
  // src/wordlists/words/english.ts
5478
5240
  var english = [
@@ -7529,7 +7291,7 @@ var english = [
7529
7291
  // src/mnemonic/utils.ts
7530
7292
  var import_errors18 = require("@fuel-ts/errors");
7531
7293
  var import_hasher4 = require("@fuel-ts/hasher");
7532
- var import_utils31 = require("@fuel-ts/utils");
7294
+ var import_utils32 = require("@fuel-ts/utils");
7533
7295
  function toUtf8Bytes(stri) {
7534
7296
  const str = stri.normalize("NFKD");
7535
7297
  const result = [];
@@ -7596,14 +7358,14 @@ function entropyToMnemonicIndices(entropy) {
7596
7358
  }
7597
7359
  }
7598
7360
  const checksumBits = entropy.length / 4;
7599
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7361
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7600
7362
  indices[indices.length - 1] <<= checksumBits;
7601
7363
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7602
7364
  return indices;
7603
7365
  }
7604
7366
  function mnemonicWordsToEntropy(words, wordlist) {
7605
7367
  const size = Math.ceil(11 * words.length / 8);
7606
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7368
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7607
7369
  let offset = 0;
7608
7370
  for (let i = 0; i < words.length; i += 1) {
7609
7371
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7623,7 +7385,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7623
7385
  const entropyBits = 32 * words.length / 3;
7624
7386
  const checksumBits = words.length / 3;
7625
7387
  const checksumMask = getUpperMask(checksumBits);
7626
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7388
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7627
7389
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7628
7390
  throw new import_errors18.FuelError(
7629
7391
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7698,7 +7460,7 @@ var Mnemonic = class {
7698
7460
  static mnemonicToEntropy(phrase, wordlist = english) {
7699
7461
  const words = getWords(phrase);
7700
7462
  assertMnemonic(words);
7701
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7463
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7702
7464
  }
7703
7465
  /**
7704
7466
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7706,7 +7468,7 @@ var Mnemonic = class {
7706
7468
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7707
7469
  */
7708
7470
  static entropyToMnemonic(entropy, wordlist = english) {
7709
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7471
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7710
7472
  assertWordList(wordlist);
7711
7473
  assertEntropy(entropyBytes);
7712
7474
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7720,7 +7482,7 @@ var Mnemonic = class {
7720
7482
  assertMnemonic(getWords(phrase));
7721
7483
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7722
7484
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7723
- return (0, import_ethers3.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7485
+ return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7724
7486
  }
7725
7487
  /**
7726
7488
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7775,14 +7537,14 @@ var Mnemonic = class {
7775
7537
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7776
7538
  */
7777
7539
  static masterKeysFromSeed(seed) {
7778
- const seedArray = (0, import_utils32.arrayify)(seed);
7540
+ const seedArray = (0, import_utils33.arrayify)(seed);
7779
7541
  if (seedArray.length < 16 || seedArray.length > 64) {
7780
7542
  throw new import_errors19.FuelError(
7781
7543
  import_errors19.ErrorCode.INVALID_SEED,
7782
7544
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7783
7545
  );
7784
7546
  }
7785
- return (0, import_utils32.arrayify)((0, import_ethers3.computeHmac)("sha512", MasterSecret, seedArray));
7547
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7786
7548
  }
7787
7549
  /**
7788
7550
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7793,22 +7555,22 @@ var Mnemonic = class {
7793
7555
  */
7794
7556
  static seedToExtendedKey(seed, testnet = false) {
7795
7557
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7796
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7558
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7797
7559
  const depth = "0x00";
7798
7560
  const fingerprint = "0x00000000";
7799
7561
  const index = "0x00000000";
7800
7562
  const chainCode = masterKey.slice(32);
7801
7563
  const privateKey = masterKey.slice(0, 32);
7802
- const extendedKey = (0, import_utils32.concat)([
7564
+ const extendedKey = (0, import_utils33.concat)([
7803
7565
  prefix,
7804
7566
  depth,
7805
7567
  fingerprint,
7806
7568
  index,
7807
7569
  chainCode,
7808
- (0, import_utils32.concat)(["0x00", privateKey])
7570
+ (0, import_utils33.concat)(["0x00", privateKey])
7809
7571
  ]);
7810
- const checksum = (0, import_ethers3.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7811
- return (0, import_ethers3.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7572
+ const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7573
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7812
7574
  }
7813
7575
  /**
7814
7576
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7823,7 +7585,7 @@ var Mnemonic = class {
7823
7585
  * @returns A randomly generated mnemonic
7824
7586
  */
7825
7587
  static generate(size = 32, extraEntropy = "") {
7826
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7588
+ 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);
7827
7589
  return Mnemonic.entropyToMnemonic(entropy);
7828
7590
  }
7829
7591
  };
@@ -7831,12 +7593,12 @@ var mnemonic_default = Mnemonic;
7831
7593
 
7832
7594
  // src/hdwallet/hdwallet.ts
7833
7595
  var HARDENED_INDEX = 2147483648;
7834
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7835
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7836
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7837
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7596
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7597
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7598
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7599
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7838
7600
  function base58check(data) {
7839
- return (0, import_ethers4.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers4.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7601
+ 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)]));
7840
7602
  }
7841
7603
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7842
7604
  if (isPublic) {
@@ -7845,11 +7607,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7845
7607
  return testnet ? TestnetPRV2 : MainnetPRV2;
7846
7608
  }
7847
7609
  function isPublicExtendedKey(extendedKey) {
7848
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7610
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7849
7611
  }
7850
7612
  function isValidExtendedKey(extendedKey) {
7851
7613
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7852
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7614
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7853
7615
  );
7854
7616
  }
7855
7617
  function parsePath(path2, depth = 0) {
@@ -7867,8 +7629,8 @@ function parsePath(path2, depth = 0) {
7867
7629
  var HDWallet = class {
7868
7630
  depth = 0;
7869
7631
  index = 0;
7870
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7871
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7632
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
7633
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7872
7634
  privateKey;
7873
7635
  publicKey;
7874
7636
  chainCode;
@@ -7880,8 +7642,8 @@ var HDWallet = class {
7880
7642
  constructor(config) {
7881
7643
  if (config.privateKey) {
7882
7644
  const signer = new Signer(config.privateKey);
7883
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7884
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7645
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7646
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7885
7647
  } else {
7886
7648
  if (!config.publicKey) {
7887
7649
  throw new import_errors20.FuelError(
@@ -7889,10 +7651,10 @@ var HDWallet = class {
7889
7651
  "Both public and private Key cannot be missing. At least one should be provided."
7890
7652
  );
7891
7653
  }
7892
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7654
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7893
7655
  }
7894
7656
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7895
- this.fingerprint = (0, import_ethers4.dataSlice)((0, import_ethers4.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
7657
+ this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
7896
7658
  this.depth = config.depth || this.depth;
7897
7659
  this.index = config.index || this.index;
7898
7660
  this.chainCode = config.chainCode;
@@ -7908,9 +7670,9 @@ var HDWallet = class {
7908
7670
  * @returns A new instance of HDWallet on the derived index
7909
7671
  */
7910
7672
  deriveIndex(index) {
7911
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7912
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7913
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7673
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7674
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7675
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7914
7676
  const data = new Uint8Array(37);
7915
7677
  if (index & HARDENED_INDEX) {
7916
7678
  if (!privateKey) {
@@ -7921,15 +7683,15 @@ var HDWallet = class {
7921
7683
  }
7922
7684
  data.set(privateKey, 1);
7923
7685
  } else {
7924
- data.set((0, import_utils34.arrayify)(this.publicKey));
7686
+ data.set((0, import_utils35.arrayify)(this.publicKey));
7925
7687
  }
7926
- data.set((0, import_math21.toBytes)(index, 4), 33);
7927
- const bytes = (0, import_utils34.arrayify)((0, import_ethers4.computeHmac)("sha512", chainCode, data));
7688
+ data.set((0, import_math20.toBytes)(index, 4), 33);
7689
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7928
7690
  const IL = bytes.slice(0, 32);
7929
7691
  const IR = bytes.slice(32);
7930
7692
  if (privateKey) {
7931
7693
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7932
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
7694
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7933
7695
  return new HDWallet({
7934
7696
  privateKey: ki,
7935
7697
  chainCode: IR,
@@ -7938,7 +7700,7 @@ var HDWallet = class {
7938
7700
  parentFingerprint: this.fingerprint
7939
7701
  });
7940
7702
  }
7941
- const signer = new Signer((0, import_utils34.hexlify)(IL));
7703
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
7942
7704
  const Ki = signer.addPoint(publicKey);
7943
7705
  return new HDWallet({
7944
7706
  publicKey: Ki,
@@ -7973,12 +7735,12 @@ var HDWallet = class {
7973
7735
  );
7974
7736
  }
7975
7737
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7976
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7738
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
7977
7739
  const parentFingerprint = this.parentFingerprint;
7978
- const index = (0, import_math21.toHex)(this.index, 4);
7740
+ const index = (0, import_math20.toHex)(this.index, 4);
7979
7741
  const chainCode = this.chainCode;
7980
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
7981
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7742
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7743
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7982
7744
  return base58check(extendedKey);
7983
7745
  }
7984
7746
  /**
@@ -7990,13 +7752,13 @@ var HDWallet = class {
7990
7752
  static fromSeed(seed) {
7991
7753
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7992
7754
  return new HDWallet({
7993
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
7994
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7755
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7756
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
7995
7757
  });
7996
7758
  }
7997
7759
  static fromExtendedKey(extendedKey) {
7998
- const decoded = (0, import_ethers4.toBeHex)((0, import_ethers4.decodeBase58)(extendedKey));
7999
- const bytes = (0, import_utils34.arrayify)(decoded);
7760
+ const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
7761
+ const bytes = (0, import_utils35.arrayify)(decoded);
8000
7762
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8001
7763
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8002
7764
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8005,9 +7767,9 @@ var HDWallet = class {
8005
7767
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8006
7768
  }
8007
7769
  const depth = bytes[4];
8008
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8009
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8010
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7770
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7771
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7772
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8011
7773
  const key = bytes.slice(45, 78);
8012
7774
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8013
7775
  throw new import_errors20.FuelError(
@@ -8194,21 +7956,20 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
8194
7956
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8195
7957
 
8196
7958
  // src/test-utils/seedTestWallet.ts
8197
- var import_crypto4 = require("@fuel-ts/crypto");
7959
+ var import_crypto5 = require("@fuel-ts/crypto");
8198
7960
  var seedTestWallet = async (wallet, quantities) => {
8199
7961
  const genesisWallet = new WalletUnlocked(
8200
- process.env.GENESIS_SECRET || (0, import_crypto4.randomBytes)(32),
7962
+ process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
8201
7963
  wallet.provider
8202
7964
  );
8203
- const request = new ScriptTransactionRequest();
8204
- quantities.forEach((quantity) => {
8205
- const { amount, assetId } = coinQuantityfy(quantity);
8206
- request.addCoinOutput(wallet.address, amount, assetId);
7965
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
7966
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
7967
+ const request = new ScriptTransactionRequest({
7968
+ gasLimit: 1e4,
7969
+ gasPrice: minGasPrice
8207
7970
  });
8208
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8209
- request.gasLimit = txCost.gasUsed;
8210
- request.maxFee = txCost.maxFee;
8211
- await genesisWallet.fund(request, txCost);
7971
+ request.addResources(resources);
7972
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8212
7973
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8213
7974
  };
8214
7975
 
@@ -8223,11 +7984,11 @@ var generateTestWallet = async (provider, quantities) => {
8223
7984
 
8224
7985
  // src/test-utils/launchNode.ts
8225
7986
  var import_configs13 = require("@fuel-ts/address/configs");
8226
- var import_utils35 = require("@fuel-ts/utils");
7987
+ var import_math21 = require("@fuel-ts/math");
7988
+ var import_utils36 = require("@fuel-ts/utils");
8227
7989
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8228
7990
  var import_child_process = require("child_process");
8229
- var import_crypto5 = require("crypto");
8230
- var import_ethers5 = require("ethers");
7991
+ var import_crypto6 = require("crypto");
8231
7992
  var import_fs = require("fs");
8232
7993
  var import_os = __toESM(require("os"));
8233
7994
  var import_path = __toESM(require("path"));
@@ -8276,13 +8037,13 @@ var launchNode = async ({
8276
8037
  // eslint-disable-next-line no-async-promise-executor
8277
8038
  new Promise(async (resolve, reject) => {
8278
8039
  const remainingArgs = extractRemainingArgs(args, [
8279
- "--snapshot",
8040
+ "--chain",
8280
8041
  "--consensus-key",
8281
8042
  "--db-type",
8282
8043
  "--poa-instant"
8283
8044
  ]);
8284
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8285
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8045
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8046
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8286
8047
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8287
8048
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8288
8049
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -8299,55 +8060,37 @@ var launchNode = async ({
8299
8060
  })).toString();
8300
8061
  let chainConfigPathToUse;
8301
8062
  const prefix = basePath || import_os.default.tmpdir();
8302
- const suffix = basePath ? "" : (0, import_crypto5.randomUUID)();
8303
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
8063
+ const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
8064
+ const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
8304
8065
  if (chainConfigPath) {
8305
8066
  chainConfigPathToUse = chainConfigPath;
8306
8067
  } else {
8307
8068
  if (!(0, import_fs.existsSync)(tempDirPath)) {
8308
8069
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8309
8070
  }
8310
- let { stateConfigJson } = import_utils35.defaultChainConfigs;
8311
- const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
8312
- stateConfigJson = {
8313
- ...stateConfigJson,
8314
- coins: [
8315
- ...stateConfigJson.coins.map((coin) => ({
8316
- ...coin,
8317
- amount: "18446744073709551615"
8318
- }))
8319
- ],
8320
- messages: stateConfigJson.messages.map((message) => ({
8321
- ...message,
8322
- amount: "18446744073709551615"
8323
- }))
8324
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8325
- };
8071
+ const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
8072
+ let chainConfig = import_utils36.defaultChainConfig;
8326
8073
  if (!process.env.GENESIS_SECRET) {
8327
8074
  const pk = Signer.generatePrivateKey();
8328
8075
  const signer = new Signer(pk);
8329
- process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8330
- stateConfigJson.coins.push({
8331
- tx_id: (0, import_utils35.hexlify)((0, import_ethers5.randomBytes)(34)),
8332
- owner: signer.address.toHexString(),
8333
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8334
- amount: "18446744073709551615",
8335
- asset_id: import_configs13.BaseAssetId,
8336
- output_index: 0,
8337
- tx_pointer_block_height: 0,
8338
- tx_pointer_tx_idx: 0
8339
- });
8076
+ process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8077
+ chainConfig = {
8078
+ ...import_utils36.defaultChainConfig,
8079
+ initial_state: {
8080
+ ...import_utils36.defaultChainConfig.initial_state,
8081
+ coins: [
8082
+ ...import_utils36.defaultChainConfig.initial_state.coins,
8083
+ {
8084
+ owner: signer.address.toHexString(),
8085
+ amount: (0, import_math21.toHex)(1e9),
8086
+ asset_id: import_configs13.BaseAssetId
8087
+ }
8088
+ ]
8089
+ }
8090
+ };
8340
8091
  }
8341
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8342
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8343
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8344
- const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8345
- const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8346
- const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8347
- (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8348
- (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8349
- (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8350
- chainConfigPathToUse = tempDirPath;
8092
+ (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8093
+ chainConfigPathToUse = tempChainConfigFilePath;
8351
8094
  }
8352
8095
  const child = (0, import_child_process.spawn)(
8353
8096
  command,
@@ -8356,10 +8099,10 @@ var launchNode = async ({
8356
8099
  ["--ip", ipToUse],
8357
8100
  ["--port", portToUse],
8358
8101
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8359
- ["--min-gas-price", "1"],
8102
+ ["--min-gas-price", "0"],
8360
8103
  poaInstant ? ["--poa-instant", "true"] : [],
8361
8104
  ["--consensus-key", consensusKey],
8362
- ["--snapshot", chainConfigPathToUse],
8105
+ ["--chain", chainConfigPathToUse],
8363
8106
  "--vm-backtrace",
8364
8107
  "--utxo-validation",
8365
8108
  "--debug",
@@ -8418,7 +8161,7 @@ var launchNodeAndGetWallets = async ({
8418
8161
  walletCount = 10
8419
8162
  } = {}) => {
8420
8163
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8421
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8164
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8422
8165
  const wallets = await generateWallets(walletCount, provider);
8423
8166
  const cleanup = () => {
8424
8167
  closeNode();