@fuel-ts/account 0.0.0-rc-1976-20240424110729 → 0.0.0-rc-2021-20240424121206

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 (56) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +5 -4
  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 +861 -611
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +864 -608
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +706 -451
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -2
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +822 -328
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +3 -3
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +4 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +7 -1
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +37 -34
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts +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 +1 -1
  34. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/transaction-request.d.ts +8 -32
  36. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  37. package/dist/providers/transaction-request/utils.d.ts +3 -0
  38. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  39. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
  41. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
  43. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  45. package/dist/providers/utils/gas.d.ts +8 -2
  46. package/dist/providers/utils/gas.d.ts.map +1 -1
  47. package/dist/test-utils/launchNode.d.ts.map +1 -1
  48. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  49. package/dist/test-utils.global.js +1578 -1114
  50. package/dist/test-utils.global.js.map +1 -1
  51. package/dist/test-utils.js +845 -609
  52. package/dist/test-utils.js.map +1 -1
  53. package/dist/test-utils.mjs +699 -463
  54. package/dist/test-utils.mjs.map +1 -1
  55. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  56. package/package.json +16 -16
@@ -58,39 +58,42 @@ 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_utils31 = require("@fuel-ts/utils");
61
+ var import_utils30 = require("@fuel-ts/utils");
62
62
 
63
63
  // src/account.ts
64
64
  var import_address4 = require("@fuel-ts/address");
65
+ var import_configs12 = require("@fuel-ts/address/configs");
65
66
  var import_errors16 = require("@fuel-ts/errors");
66
67
  var import_interfaces = require("@fuel-ts/interfaces");
67
- var import_math18 = require("@fuel-ts/math");
68
- var import_utils28 = require("@fuel-ts/utils");
68
+ var import_math19 = require("@fuel-ts/math");
69
+ var import_utils27 = require("@fuel-ts/utils");
70
+ var import_ramda4 = require("ramda");
69
71
 
70
72
  // src/providers/coin-quantity.ts
73
+ var import_configs = require("@fuel-ts/address/configs");
71
74
  var import_math = require("@fuel-ts/math");
72
75
  var import_utils = require("@fuel-ts/utils");
73
76
  var coinQuantityfy = (coinQuantityLike) => {
74
77
  let assetId;
75
78
  let amount;
76
- let max2;
79
+ let max;
77
80
  if (Array.isArray(coinQuantityLike)) {
78
81
  amount = coinQuantityLike[0];
79
- assetId = coinQuantityLike[1];
80
- max2 = coinQuantityLike[2];
82
+ assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
83
+ max = coinQuantityLike[2] ?? void 0;
81
84
  } else {
82
85
  amount = coinQuantityLike.amount;
83
- assetId = coinQuantityLike.assetId;
84
- max2 = coinQuantityLike.max ?? void 0;
86
+ assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
87
+ max = coinQuantityLike.max ?? void 0;
85
88
  }
86
89
  const bnAmount = (0, import_math.bn)(amount);
87
90
  return {
88
91
  assetId: (0, import_utils.hexlify)(assetId),
89
92
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
90
- max: max2 ? (0, import_math.bn)(max2) : void 0
93
+ max: max ? (0, import_math.bn)(max) : void 0
91
94
  };
92
95
  };
93
- var addAmountToAsset = (params) => {
96
+ var addAmountToCoinQuantities = (params) => {
94
97
  const { amount, assetId } = params;
95
98
  const coinQuantities = [...params.coinQuantities];
96
99
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -105,27 +108,51 @@ var addAmountToAsset = (params) => {
105
108
  // src/providers/provider.ts
106
109
  var import_address3 = require("@fuel-ts/address");
107
110
  var import_errors14 = require("@fuel-ts/errors");
108
- var import_math15 = require("@fuel-ts/math");
109
- var import_transactions18 = require("@fuel-ts/transactions");
110
- var import_utils23 = require("@fuel-ts/utils");
111
+ var import_math16 = require("@fuel-ts/math");
112
+ var import_transactions19 = require("@fuel-ts/transactions");
113
+ var import_utils22 = require("@fuel-ts/utils");
111
114
  var import_versions = require("@fuel-ts/versions");
112
- var import_utils24 = require("@noble/curves/abstract/utils");
115
+ var import_utils23 = require("@noble/curves/abstract/utils");
113
116
  var import_ethers = require("ethers");
114
117
  var import_graphql_request = require("graphql-request");
115
118
  var import_ramda3 = require("ramda");
116
119
 
117
120
  // src/providers/__generated__/operations.ts
118
121
  var import_graphql_tag = __toESM(require("graphql-tag"));
122
+ var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.default`
123
+ fragment transactionStatusSubscriptionFragment on TransactionStatus {
124
+ type: __typename
125
+ ... on SubmittedStatus {
126
+ time
127
+ }
128
+ ... on SuccessStatus {
129
+ block {
130
+ id
131
+ }
132
+ time
133
+ programState {
134
+ returnType
135
+ data
136
+ }
137
+ }
138
+ ... on FailureStatus {
139
+ block {
140
+ id
141
+ }
142
+ time
143
+ reason
144
+ }
145
+ ... on SqueezedOutStatus {
146
+ reason
147
+ }
148
+ }
149
+ `;
119
150
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
120
151
  fragment receiptFragment on Receipt {
121
- contract {
122
- id
123
- }
152
+ id
124
153
  pc
125
154
  is
126
- to {
127
- id
128
- }
155
+ to
129
156
  toAddress
130
157
  amount
131
158
  assetId
@@ -163,10 +190,16 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
163
190
  id
164
191
  }
165
192
  time
193
+ receipts {
194
+ ...receiptFragment
195
+ }
166
196
  programState {
167
197
  returnType
168
198
  data
169
199
  }
200
+ receipts {
201
+ ...receiptFragment
202
+ }
170
203
  }
171
204
  ... on FailureStatus {
172
205
  block {
@@ -174,26 +207,24 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
174
207
  }
175
208
  time
176
209
  reason
210
+ receipts {
211
+ ...receiptFragment
212
+ }
177
213
  }
178
214
  ... on SqueezedOutStatus {
179
215
  reason
180
216
  }
181
217
  }
182
- `;
218
+ ${ReceiptFragmentFragmentDoc}`;
183
219
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
184
220
  fragment transactionFragment on Transaction {
185
221
  id
186
222
  rawPayload
187
- gasPrice
188
- receipts {
189
- ...receiptFragment
190
- }
191
223
  status {
192
224
  ...transactionStatusFragment
193
225
  }
194
226
  }
195
- ${ReceiptFragmentFragmentDoc}
196
- ${TransactionStatusFragmentFragmentDoc}`;
227
+ ${TransactionStatusFragmentFragmentDoc}`;
197
228
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
198
229
  fragment inputEstimatePredicatesFragment on Input {
199
230
  ... on InputCoin {
@@ -211,6 +242,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
211
242
  }
212
243
  }
213
244
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
245
+ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
246
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
247
+ reason
248
+ programState {
249
+ returnType
250
+ data
251
+ }
252
+ }
253
+ `;
254
+ var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
255
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
256
+ programState {
257
+ returnType
258
+ data
259
+ }
260
+ }
261
+ `;
262
+ var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
263
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
264
+ ... on DryRunFailureStatus {
265
+ ...dryRunFailureStatusFragment
266
+ }
267
+ ... on DryRunSuccessStatus {
268
+ ...dryRunSuccessStatusFragment
269
+ }
270
+ }
271
+ ${DryRunFailureStatusFragmentFragmentDoc}
272
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
273
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
274
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
275
+ id
276
+ status {
277
+ ...dryRunTransactionStatusFragment
278
+ }
279
+ receipts {
280
+ ...receiptFragment
281
+ }
282
+ }
283
+ ${DryRunTransactionStatusFragmentFragmentDoc}
284
+ ${ReceiptFragmentFragmentDoc}`;
214
285
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
215
286
  fragment coinFragment on Coin {
216
287
  __typename
@@ -218,7 +289,6 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
218
289
  owner
219
290
  amount
220
291
  assetId
221
- maturity
222
292
  blockCreated
223
293
  txCreatedIdx
224
294
  }
@@ -257,26 +327,32 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
257
327
  messageBlockHeader {
258
328
  id
259
329
  daHeight
330
+ consensusParametersVersion
331
+ stateTransitionBytecodeVersion
260
332
  transactionsCount
333
+ messageReceiptCount
261
334
  transactionsRoot
335
+ messageOutboxRoot
336
+ eventInboxRoot
262
337
  height
263
338
  prevRoot
264
339
  time
265
340
  applicationHash
266
- messageReceiptRoot
267
- messageReceiptCount
268
341
  }
269
342
  commitBlockHeader {
270
343
  id
271
344
  daHeight
345
+ consensusParametersVersion
346
+ stateTransitionBytecodeVersion
272
347
  transactionsCount
348
+ messageReceiptCount
273
349
  transactionsRoot
350
+ messageOutboxRoot
351
+ eventInboxRoot
274
352
  height
275
353
  prevRoot
276
354
  time
277
355
  applicationHash
278
- messageReceiptRoot
279
- messageReceiptCount
280
356
  }
281
357
  sender
282
358
  recipient
@@ -295,8 +371,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
295
371
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
296
372
  fragment blockFragment on Block {
297
373
  id
374
+ height
298
375
  header {
299
- height
300
376
  time
301
377
  }
302
378
  transactions {
@@ -354,6 +430,11 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
354
430
  `;
355
431
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
356
432
  fragment GasCostsFragment on GasCosts {
433
+ version {
434
+ ... on Version {
435
+ value
436
+ }
437
+ }
357
438
  add
358
439
  addi
359
440
  aloc
@@ -366,7 +447,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
366
447
  cb
367
448
  cfei
368
449
  cfsi
369
- croo
370
450
  div
371
451
  divi
372
452
  ecr1
@@ -449,6 +529,9 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
449
529
  ccp {
450
530
  ...DependentCostFragment
451
531
  }
532
+ croo {
533
+ ...DependentCostFragment
534
+ }
452
535
  csiz {
453
536
  ...DependentCostFragment
454
537
  }
@@ -508,6 +591,11 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
508
591
  ${DependentCostFragmentFragmentDoc}`;
509
592
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
510
593
  fragment consensusParametersFragment on ConsensusParameters {
594
+ version {
595
+ ... on Version {
596
+ value
597
+ }
598
+ }
511
599
  txParams {
512
600
  ...TxParametersFragment
513
601
  }
@@ -567,18 +655,9 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
567
655
  fragment nodeInfoFragment on NodeInfo {
568
656
  utxoValidation
569
657
  vmBacktrace
570
- minGasPrice
571
658
  maxTx
572
659
  maxDepth
573
660
  nodeVersion
574
- peers {
575
- id
576
- addresses
577
- clientVersion
578
- blockHeight
579
- lastHeartbeatMs
580
- appScore
581
- }
582
661
  }
583
662
  `;
584
663
  var GetVersionDocument = import_graphql_tag.default`
@@ -613,13 +692,9 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
613
692
  query getTransactionWithReceipts($transactionId: TransactionId!) {
614
693
  transaction(id: $transactionId) {
615
694
  ...transactionFragment
616
- receipts {
617
- ...receiptFragment
618
- }
619
695
  }
620
696
  }
621
- ${TransactionFragmentFragmentDoc}
622
- ${ReceiptFragmentFragmentDoc}`;
697
+ ${TransactionFragmentFragmentDoc}`;
623
698
  var GetTransactionsDocument = import_graphql_tag.default`
624
699
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
625
700
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -747,6 +822,20 @@ var GetBalanceDocument = import_graphql_tag.default`
747
822
  }
748
823
  }
749
824
  ${BalanceFragmentFragmentDoc}`;
825
+ var GetLatestGasPriceDocument = import_graphql_tag.default`
826
+ query getLatestGasPrice {
827
+ latestGasPrice {
828
+ gasPrice
829
+ }
830
+ }
831
+ `;
832
+ var EstimateGasPriceDocument = import_graphql_tag.default`
833
+ query estimateGasPrice($blockHorizon: U32!) {
834
+ estimateGasPrice(blockHorizon: $blockHorizon) {
835
+ gasPrice
836
+ }
837
+ }
838
+ `;
750
839
  var GetBalancesDocument = import_graphql_tag.default`
751
840
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
752
841
  balances(
@@ -801,12 +890,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
801
890
  }
802
891
  `;
803
892
  var DryRunDocument = import_graphql_tag.default`
804
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
805
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
806
- ...receiptFragment
893
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
894
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
895
+ ...dryRunTransactionExecutionStatusFragment
807
896
  }
808
897
  }
809
- ${ReceiptFragmentFragmentDoc}`;
898
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
810
899
  var SubmitDocument = import_graphql_tag.default`
811
900
  mutation submit($encodedTransaction: HexString!) {
812
901
  submit(tx: $encodedTransaction) {
@@ -825,17 +914,17 @@ var ProduceBlocksDocument = import_graphql_tag.default`
825
914
  var SubmitAndAwaitDocument = import_graphql_tag.default`
826
915
  subscription submitAndAwait($encodedTransaction: HexString!) {
827
916
  submitAndAwait(tx: $encodedTransaction) {
828
- ...transactionStatusFragment
917
+ ...transactionStatusSubscriptionFragment
829
918
  }
830
919
  }
831
- ${TransactionStatusFragmentFragmentDoc}`;
920
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
832
921
  var StatusChangeDocument = import_graphql_tag.default`
833
922
  subscription statusChange($transactionId: TransactionId!) {
834
923
  statusChange(id: $transactionId) {
835
- ...transactionStatusFragment
924
+ ...transactionStatusSubscriptionFragment
836
925
  }
837
926
  }
838
- ${TransactionStatusFragmentFragmentDoc}`;
927
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
839
928
  function getSdk(requester) {
840
929
  return {
841
930
  getVersion(variables, options) {
@@ -889,6 +978,12 @@ function getSdk(requester) {
889
978
  getBalance(variables, options) {
890
979
  return requester(GetBalanceDocument, variables, options);
891
980
  },
981
+ getLatestGasPrice(variables, options) {
982
+ return requester(GetLatestGasPriceDocument, variables, options);
983
+ },
984
+ estimateGasPrice(variables, options) {
985
+ return requester(EstimateGasPriceDocument, variables, options);
986
+ },
892
987
  getBalances(variables, options) {
893
988
  return requester(GetBalancesDocument, variables, options);
894
989
  },
@@ -1059,7 +1154,7 @@ var MemoryCache = class {
1059
1154
 
1060
1155
  // src/providers/transaction-request/input.ts
1061
1156
  var import_abi_coder = require("@fuel-ts/abi-coder");
1062
- var import_configs = require("@fuel-ts/address/configs");
1157
+ var import_configs2 = require("@fuel-ts/address/configs");
1063
1158
  var import_errors3 = require("@fuel-ts/errors");
1064
1159
  var import_math2 = require("@fuel-ts/math");
1065
1160
  var import_transactions = require("@fuel-ts/transactions");
@@ -1082,10 +1177,9 @@ var inputify = (value) => {
1082
1177
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1083
1178
  },
1084
1179
  witnessIndex: value.witnessIndex,
1085
- maturity: value.maturity ?? 0,
1086
1180
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1087
- predicateLength: predicate.length,
1088
- predicateDataLength: predicateData.length,
1181
+ predicateLength: (0, import_math2.bn)(predicate.length),
1182
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1089
1183
  predicate: (0, import_utils3.hexlify)(predicate),
1090
1184
  predicateData: (0, import_utils3.hexlify)(predicateData)
1091
1185
  };
@@ -1093,10 +1187,10 @@ var inputify = (value) => {
1093
1187
  case import_transactions.InputType.Contract: {
1094
1188
  return {
1095
1189
  type: import_transactions.InputType.Contract,
1096
- txID: import_configs.ZeroBytes32,
1190
+ txID: import_configs2.ZeroBytes32,
1097
1191
  outputIndex: 0,
1098
- balanceRoot: import_configs.ZeroBytes32,
1099
- stateRoot: import_configs.ZeroBytes32,
1192
+ balanceRoot: import_configs2.ZeroBytes32,
1193
+ stateRoot: import_configs2.ZeroBytes32,
1100
1194
  txPointer: {
1101
1195
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1102
1196
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1116,8 +1210,8 @@ var inputify = (value) => {
1116
1210
  nonce: (0, import_utils3.hexlify)(value.nonce),
1117
1211
  witnessIndex: value.witnessIndex,
1118
1212
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1119
- predicateLength: predicate.length,
1120
- predicateDataLength: predicateData.length,
1213
+ predicateLength: (0, import_math2.bn)(predicate.length),
1214
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1121
1215
  predicate: (0, import_utils3.hexlify)(predicate),
1122
1216
  predicateData: (0, import_utils3.hexlify)(predicateData),
1123
1217
  data: (0, import_utils3.hexlify)(data),
@@ -1134,7 +1228,7 @@ var inputify = (value) => {
1134
1228
  };
1135
1229
 
1136
1230
  // src/providers/transaction-request/output.ts
1137
- var import_configs2 = require("@fuel-ts/address/configs");
1231
+ var import_configs3 = require("@fuel-ts/address/configs");
1138
1232
  var import_errors4 = require("@fuel-ts/errors");
1139
1233
  var import_math3 = require("@fuel-ts/math");
1140
1234
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1154,8 +1248,8 @@ var outputify = (value) => {
1154
1248
  return {
1155
1249
  type: import_transactions2.OutputType.Contract,
1156
1250
  inputIndex: value.inputIndex,
1157
- balanceRoot: import_configs2.ZeroBytes32,
1158
- stateRoot: import_configs2.ZeroBytes32
1251
+ balanceRoot: import_configs3.ZeroBytes32,
1252
+ stateRoot: import_configs3.ZeroBytes32
1159
1253
  };
1160
1254
  }
1161
1255
  case import_transactions2.OutputType.Change: {
@@ -1169,9 +1263,9 @@ var outputify = (value) => {
1169
1263
  case import_transactions2.OutputType.Variable: {
1170
1264
  return {
1171
1265
  type: import_transactions2.OutputType.Variable,
1172
- to: import_configs2.ZeroBytes32,
1266
+ to: import_configs3.ZeroBytes32,
1173
1267
  amount: (0, import_math3.bn)(0),
1174
- assetId: import_configs2.ZeroBytes32
1268
+ assetId: import_configs3.ZeroBytes32
1175
1269
  };
1176
1270
  }
1177
1271
  case import_transactions2.OutputType.ContractCreated: {
@@ -1193,7 +1287,7 @@ var outputify = (value) => {
1193
1287
  // src/providers/transaction-request/transaction-request.ts
1194
1288
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
1195
1289
  var import_address = require("@fuel-ts/address");
1196
- var import_configs6 = require("@fuel-ts/address/configs");
1290
+ var import_configs7 = require("@fuel-ts/address/configs");
1197
1291
  var import_crypto = require("@fuel-ts/crypto");
1198
1292
  var import_math7 = require("@fuel-ts/math");
1199
1293
  var import_transactions6 = require("@fuel-ts/transactions");
@@ -1203,13 +1297,13 @@ var import_utils9 = require("@fuel-ts/utils");
1203
1297
  var isCoin = (resource) => "id" in resource;
1204
1298
 
1205
1299
  // src/providers/utils/receipts.ts
1206
- var import_configs3 = require("@fuel-ts/address/configs");
1300
+ var import_configs4 = require("@fuel-ts/address/configs");
1207
1301
  var import_errors5 = require("@fuel-ts/errors");
1208
1302
  var import_math4 = require("@fuel-ts/math");
1209
1303
  var import_transactions3 = require("@fuel-ts/transactions");
1210
- var import_configs4 = require("@fuel-ts/transactions/configs");
1304
+ var import_configs5 = require("@fuel-ts/transactions/configs");
1211
1305
  var import_utils5 = require("@fuel-ts/utils");
1212
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1306
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1213
1307
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1214
1308
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1215
1309
  (memo, receipt) => {
@@ -1226,15 +1320,15 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1226
1320
  missingOutputContractIds: []
1227
1321
  }
1228
1322
  );
1229
- var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1323
+ var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1230
1324
  function assembleReceiptByType(receipt) {
1231
1325
  const { receiptType } = receipt;
1232
1326
  switch (receiptType) {
1233
1327
  case "CALL" /* Call */: {
1234
1328
  const callReceipt = {
1235
1329
  type: import_transactions3.ReceiptType.Call,
1236
- from: hexOrZero(receipt.contract?.id),
1237
- to: hexOrZero(receipt?.to?.id),
1330
+ from: hexOrZero(receipt.id || receipt.contractId),
1331
+ to: hexOrZero(receipt?.to),
1238
1332
  amount: (0, import_math4.bn)(receipt.amount),
1239
1333
  assetId: hexOrZero(receipt.assetId),
1240
1334
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1248,7 +1342,7 @@ function assembleReceiptByType(receipt) {
1248
1342
  case "RETURN" /* Return */: {
1249
1343
  const returnReceipt = {
1250
1344
  type: import_transactions3.ReceiptType.Return,
1251
- id: hexOrZero(receipt.contract?.id),
1345
+ id: hexOrZero(receipt.id || receipt.contractId),
1252
1346
  val: (0, import_math4.bn)(receipt.val),
1253
1347
  pc: (0, import_math4.bn)(receipt.pc),
1254
1348
  is: (0, import_math4.bn)(receipt.is)
@@ -1258,7 +1352,7 @@ function assembleReceiptByType(receipt) {
1258
1352
  case "RETURN_DATA" /* ReturnData */: {
1259
1353
  const returnDataReceipt = {
1260
1354
  type: import_transactions3.ReceiptType.ReturnData,
1261
- id: hexOrZero(receipt.contract?.id),
1355
+ id: hexOrZero(receipt.id || receipt.contractId),
1262
1356
  ptr: (0, import_math4.bn)(receipt.ptr),
1263
1357
  len: (0, import_math4.bn)(receipt.len),
1264
1358
  digest: hexOrZero(receipt.digest),
@@ -1270,7 +1364,7 @@ function assembleReceiptByType(receipt) {
1270
1364
  case "PANIC" /* Panic */: {
1271
1365
  const panicReceipt = {
1272
1366
  type: import_transactions3.ReceiptType.Panic,
1273
- id: hexOrZero(receipt.contract?.id),
1367
+ id: hexOrZero(receipt.id),
1274
1368
  reason: (0, import_math4.bn)(receipt.reason),
1275
1369
  pc: (0, import_math4.bn)(receipt.pc),
1276
1370
  is: (0, import_math4.bn)(receipt.is),
@@ -1281,7 +1375,7 @@ function assembleReceiptByType(receipt) {
1281
1375
  case "REVERT" /* Revert */: {
1282
1376
  const revertReceipt = {
1283
1377
  type: import_transactions3.ReceiptType.Revert,
1284
- id: hexOrZero(receipt.contract?.id),
1378
+ id: hexOrZero(receipt.id || receipt.contractId),
1285
1379
  val: (0, import_math4.bn)(receipt.ra),
1286
1380
  pc: (0, import_math4.bn)(receipt.pc),
1287
1381
  is: (0, import_math4.bn)(receipt.is)
@@ -1291,7 +1385,7 @@ function assembleReceiptByType(receipt) {
1291
1385
  case "LOG" /* Log */: {
1292
1386
  const logReceipt = {
1293
1387
  type: import_transactions3.ReceiptType.Log,
1294
- id: hexOrZero(receipt.contract?.id),
1388
+ id: hexOrZero(receipt.id || receipt.contractId),
1295
1389
  val0: (0, import_math4.bn)(receipt.ra),
1296
1390
  val1: (0, import_math4.bn)(receipt.rb),
1297
1391
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1304,7 +1398,7 @@ function assembleReceiptByType(receipt) {
1304
1398
  case "LOG_DATA" /* LogData */: {
1305
1399
  const logDataReceipt = {
1306
1400
  type: import_transactions3.ReceiptType.LogData,
1307
- id: hexOrZero(receipt.contract?.id),
1401
+ id: hexOrZero(receipt.id || receipt.contractId),
1308
1402
  val0: (0, import_math4.bn)(receipt.ra),
1309
1403
  val1: (0, import_math4.bn)(receipt.rb),
1310
1404
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1318,8 +1412,8 @@ function assembleReceiptByType(receipt) {
1318
1412
  case "TRANSFER" /* Transfer */: {
1319
1413
  const transferReceipt = {
1320
1414
  type: import_transactions3.ReceiptType.Transfer,
1321
- from: hexOrZero(receipt.contract?.id),
1322
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1415
+ from: hexOrZero(receipt.id || receipt.contractId),
1416
+ to: hexOrZero(receipt.toAddress || receipt?.to),
1323
1417
  amount: (0, import_math4.bn)(receipt.amount),
1324
1418
  assetId: hexOrZero(receipt.assetId),
1325
1419
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1330,8 +1424,8 @@ function assembleReceiptByType(receipt) {
1330
1424
  case "TRANSFER_OUT" /* TransferOut */: {
1331
1425
  const transferOutReceipt = {
1332
1426
  type: import_transactions3.ReceiptType.TransferOut,
1333
- from: hexOrZero(receipt.contract?.id),
1334
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
1427
+ from: hexOrZero(receipt.id || receipt.contractId),
1428
+ to: hexOrZero(receipt.toAddress || receipt.to),
1335
1429
  amount: (0, import_math4.bn)(receipt.amount),
1336
1430
  assetId: hexOrZero(receipt.assetId),
1337
1431
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1374,7 +1468,7 @@ function assembleReceiptByType(receipt) {
1374
1468
  return receiptMessageOut;
1375
1469
  }
1376
1470
  case "MINT" /* Mint */: {
1377
- const contractId = hexOrZero(receipt.contract?.id);
1471
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1378
1472
  const subId = hexOrZero(receipt.subId);
1379
1473
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1380
1474
  const mintReceipt = {
@@ -1389,7 +1483,7 @@ function assembleReceiptByType(receipt) {
1389
1483
  return mintReceipt;
1390
1484
  }
1391
1485
  case "BURN" /* Burn */: {
1392
- const contractId = hexOrZero(receipt.contract?.id);
1486
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1393
1487
  const subId = hexOrZero(receipt.subId);
1394
1488
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1395
1489
  const burnReceipt = {
@@ -1415,7 +1509,6 @@ var import_errors6 = require("@fuel-ts/errors");
1415
1509
  var import_math5 = require("@fuel-ts/math");
1416
1510
  var import_transactions4 = require("@fuel-ts/transactions");
1417
1511
  var import_utils6 = require("@fuel-ts/utils");
1418
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1419
1512
  var getGasUsedFromReceipts = (receipts) => {
1420
1513
  const scriptResult = receipts.filter(
1421
1514
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1436,18 +1529,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1436
1529
  }
1437
1530
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1438
1531
  const witnessCache = [];
1439
- const totalGas = inputs.reduce((total, input) => {
1532
+ const chargeableInputs = inputs.filter((input) => {
1533
+ const isCoinOrMessage = "owner" in input || "sender" in input;
1534
+ if (isCoinOrMessage) {
1535
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1536
+ return true;
1537
+ }
1538
+ if (!witnessCache.includes(input.witnessIndex)) {
1539
+ witnessCache.push(input.witnessIndex);
1540
+ return true;
1541
+ }
1542
+ }
1543
+ return false;
1544
+ });
1545
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1546
+ const totalGas = chargeableInputs.reduce((total, input) => {
1440
1547
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1441
1548
  return total.add(
1442
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1549
+ vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1443
1550
  );
1444
1551
  }
1445
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1446
- witnessCache.push(input.witnessIndex);
1447
- return total.add(gasCosts.ecr1);
1448
- }
1449
- return total;
1450
- }, (0, import_math5.bn)());
1552
+ return total.add(gasCosts.ecr1);
1553
+ }, (0, import_math5.bn)(0));
1451
1554
  return totalGas;
1452
1555
  }
1453
1556
  function getMinGas(params) {
@@ -1459,12 +1562,20 @@ function getMinGas(params) {
1459
1562
  return minGas;
1460
1563
  }
1461
1564
  function getMaxGas(params) {
1462
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1565
+ const {
1566
+ gasPerByte,
1567
+ witnessesLength,
1568
+ witnessLimit,
1569
+ minGas,
1570
+ gasLimit = (0, import_math5.bn)(0),
1571
+ maxGasPerTx
1572
+ } = params;
1463
1573
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1464
1574
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1465
1575
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1466
1576
  }
1467
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1577
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1578
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1468
1579
  }
1469
1580
  function calculateMetadataGasForTxCreate({
1470
1581
  gasCosts,
@@ -1486,6 +1597,10 @@ function calculateMetadataGasForTxScript({
1486
1597
  }) {
1487
1598
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1488
1599
  }
1600
+ var calculateGasFee = (params) => {
1601
+ const { gas, gasPrice, priceFactor, tip } = params;
1602
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
1603
+ };
1489
1604
 
1490
1605
  // src/providers/utils/json.ts
1491
1606
  var import_utils7 = require("@fuel-ts/utils");
@@ -1531,16 +1646,16 @@ function sleep(time) {
1531
1646
  var import_errors7 = require("@fuel-ts/errors");
1532
1647
  var import_math6 = require("@fuel-ts/math");
1533
1648
  var import_transactions5 = require("@fuel-ts/transactions");
1534
- var import_configs5 = require("@fuel-ts/transactions/configs");
1649
+ var import_configs6 = require("@fuel-ts/transactions/configs");
1535
1650
  var assemblePanicError = (status) => {
1536
1651
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1537
1652
  const reason = status.reason;
1538
- if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1653
+ if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1539
1654
  errorMessage = `${errorMessage}
1540
1655
 
1541
1656
  You can read more about this error at:
1542
1657
 
1543
- ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1658
+ ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1544
1659
  }
1545
1660
  return { errorMessage, reason };
1546
1661
  };
@@ -1552,28 +1667,28 @@ var assembleRevertError = (receipts, logs) => {
1552
1667
  if (revertReceipt) {
1553
1668
  const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1554
1669
  switch (reasonHex) {
1555
- case import_configs5.FAILED_REQUIRE_SIGNAL: {
1670
+ case import_configs6.FAILED_REQUIRE_SIGNAL: {
1556
1671
  reason = "require";
1557
1672
  errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1558
1673
  break;
1559
1674
  }
1560
- case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
1675
+ case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1561
1676
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1562
1677
  reason = "assert_eq";
1563
1678
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1564
1679
  break;
1565
1680
  }
1566
- case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
1681
+ case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1567
1682
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1568
1683
  reason = "assert_ne";
1569
1684
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1570
1685
  break;
1571
1686
  }
1572
- case import_configs5.FAILED_ASSERT_SIGNAL:
1687
+ case import_configs6.FAILED_ASSERT_SIGNAL:
1573
1688
  reason = "assert";
1574
1689
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1575
1690
  break;
1576
- case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1691
+ case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1577
1692
  reason = "MissingOutputChange";
1578
1693
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1579
1694
  break;
@@ -1622,7 +1737,7 @@ var witnessify = (value) => {
1622
1737
  // src/providers/transaction-request/transaction-request.ts
1623
1738
  var BaseTransactionRequest = class {
1624
1739
  /** Gas price for transaction */
1625
- gasPrice;
1740
+ tip;
1626
1741
  /** Block until which tx cannot be included */
1627
1742
  maturity;
1628
1743
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1635,38 +1750,34 @@ var BaseTransactionRequest = class {
1635
1750
  outputs = [];
1636
1751
  /** List of witnesses */
1637
1752
  witnesses = [];
1638
- /** Base asset ID - should be fetched from the chain */
1639
- baseAssetId;
1640
1753
  /**
1641
1754
  * Constructor for initializing a base transaction request.
1642
1755
  *
1643
1756
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1644
1757
  */
1645
1758
  constructor({
1646
- gasPrice,
1759
+ tip,
1647
1760
  maturity,
1648
1761
  maxFee,
1649
1762
  witnessLimit,
1650
1763
  inputs,
1651
1764
  outputs,
1652
- witnesses,
1653
- baseAssetId
1654
- }) {
1655
- this.gasPrice = (0, import_math7.bn)(gasPrice);
1765
+ witnesses
1766
+ } = {}) {
1767
+ this.tip = (0, import_math7.bn)(tip);
1656
1768
  this.maturity = maturity ?? 0;
1657
1769
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1658
1770
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1659
1771
  this.inputs = inputs ?? [];
1660
1772
  this.outputs = outputs ?? [];
1661
1773
  this.witnesses = witnesses ?? [];
1662
- this.baseAssetId = baseAssetId;
1663
1774
  }
1664
1775
  static getPolicyMeta(req) {
1665
1776
  let policyTypes = 0;
1666
1777
  const policies = [];
1667
- if (req.gasPrice) {
1668
- policyTypes += import_transactions6.PolicyType.GasPrice;
1669
- policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1778
+ if (req.tip) {
1779
+ policyTypes += import_transactions6.PolicyType.Tip;
1780
+ policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1670
1781
  }
1671
1782
  if (req.witnessLimit) {
1672
1783
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -1752,7 +1863,7 @@ var BaseTransactionRequest = class {
1752
1863
  * @returns The index of the created witness.
1753
1864
  */
1754
1865
  addEmptyWitness() {
1755
- this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1866
+ this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1756
1867
  return this.witnesses.length - 1;
1757
1868
  }
1758
1869
  /**
@@ -1850,13 +1961,11 @@ var BaseTransactionRequest = class {
1850
1961
  * assetId, if one it was not added yet.
1851
1962
  *
1852
1963
  * @param coin - Coin resource.
1853
- * @param predicate - Predicate bytes.
1854
- * @param predicateData - Predicate data bytes.
1855
1964
  */
1856
- addCoinInput(coin, predicate) {
1965
+ addCoinInput(coin) {
1857
1966
  const { assetId, owner, amount } = coin;
1858
1967
  let witnessIndex;
1859
- if (predicate) {
1968
+ if (coin.predicate) {
1860
1969
  witnessIndex = 0;
1861
1970
  } else {
1862
1971
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1871,8 +1980,7 @@ var BaseTransactionRequest = class {
1871
1980
  amount,
1872
1981
  assetId,
1873
1982
  txPointer: "0x00000000000000000000000000000000",
1874
- witnessIndex,
1875
- predicate: predicate?.bytes
1983
+ witnessIndex
1876
1984
  };
1877
1985
  this.pushInput(input);
1878
1986
  this.addChangeOutput(owner, assetId);
@@ -1882,12 +1990,12 @@ var BaseTransactionRequest = class {
1882
1990
  * baseAssetId, if one it was not added yet.
1883
1991
  *
1884
1992
  * @param message - Message resource.
1885
- * @param predicate - Predicate bytes.
1886
1993
  */
1887
- addMessageInput(message, predicate) {
1994
+ addMessageInput(message) {
1888
1995
  const { recipient, sender, amount } = message;
1996
+ const assetId = import_configs7.BaseAssetId;
1889
1997
  let witnessIndex;
1890
- if (predicate) {
1998
+ if (message.predicate) {
1891
1999
  witnessIndex = 0;
1892
2000
  } else {
1893
2001
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1901,11 +2009,10 @@ var BaseTransactionRequest = class {
1901
2009
  sender: sender.toB256(),
1902
2010
  recipient: recipient.toB256(),
1903
2011
  amount,
1904
- witnessIndex,
1905
- predicate: predicate?.bytes
2012
+ witnessIndex
1906
2013
  };
1907
2014
  this.pushInput(input);
1908
- this.addChangeOutput(recipient, this.baseAssetId);
2015
+ this.addChangeOutput(recipient, assetId);
1909
2016
  }
1910
2017
  /**
1911
2018
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -1933,32 +2040,6 @@ var BaseTransactionRequest = class {
1933
2040
  resources.forEach((resource) => this.addResource(resource));
1934
2041
  return this;
1935
2042
  }
1936
- /**
1937
- * Adds multiple resources to the transaction by adding coin/message inputs and change
1938
- * outputs from the related assetIds.
1939
- *
1940
- * @param resources - The resources to add.
1941
- * @returns This transaction.
1942
- */
1943
- addPredicateResource(resource, predicate) {
1944
- if (isCoin(resource)) {
1945
- this.addCoinInput(resource, predicate);
1946
- } else {
1947
- this.addMessageInput(resource, predicate);
1948
- }
1949
- return this;
1950
- }
1951
- /**
1952
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
1953
- * from the related assetIds.
1954
- *
1955
- * @param resources - The resources to add.
1956
- * @returns This transaction.
1957
- */
1958
- addPredicateResources(resources, predicate) {
1959
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1960
- return this;
1961
- }
1962
2043
  /**
1963
2044
  * Adds a coin output to the transaction.
1964
2045
  *
@@ -1966,12 +2047,12 @@ var BaseTransactionRequest = class {
1966
2047
  * @param amount - Amount of coin.
1967
2048
  * @param assetId - Asset ID of coin.
1968
2049
  */
1969
- addCoinOutput(to, amount, assetId) {
2050
+ addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
1970
2051
  this.pushOutput({
1971
2052
  type: import_transactions6.OutputType.Coin,
1972
2053
  to: (0, import_address.addressify)(to).toB256(),
1973
2054
  amount,
1974
- assetId: assetId ?? this.baseAssetId
2055
+ assetId
1975
2056
  });
1976
2057
  return this;
1977
2058
  }
@@ -1998,7 +2079,7 @@ var BaseTransactionRequest = class {
1998
2079
  * @param to - Address of the owner.
1999
2080
  * @param assetId - Asset ID of coin.
2000
2081
  */
2001
- addChangeOutput(to, assetId) {
2082
+ addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2002
2083
  const changeOutput = this.getChangeOutputs().find(
2003
2084
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2004
2085
  );
@@ -2006,7 +2087,7 @@ var BaseTransactionRequest = class {
2006
2087
  this.pushOutput({
2007
2088
  type: import_transactions6.OutputType.Change,
2008
2089
  to: (0, import_address.addressify)(to).toB256(),
2009
- assetId: assetId ?? this.baseAssetId
2090
+ assetId
2010
2091
  });
2011
2092
  }
2012
2093
  }
@@ -2038,7 +2119,7 @@ var BaseTransactionRequest = class {
2038
2119
  }
2039
2120
  calculateMaxGas(chainInfo, minGas) {
2040
2121
  const { consensusParameters } = chainInfo;
2041
- const { gasPerByte } = consensusParameters;
2122
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2042
2123
  const witnessesLength = this.toTransaction().witnesses.reduce(
2043
2124
  (acc, wit) => acc + wit.dataLength,
2044
2125
  0
@@ -2047,7 +2128,8 @@ var BaseTransactionRequest = class {
2047
2128
  gasPerByte,
2048
2129
  minGas,
2049
2130
  witnessesLength,
2050
- witnessLimit: this.witnessLimit
2131
+ witnessLimit: this.witnessLimit,
2132
+ maxGasPerTx
2051
2133
  });
2052
2134
  }
2053
2135
  /**
@@ -2065,24 +2147,27 @@ var BaseTransactionRequest = class {
2065
2147
  });
2066
2148
  const updateAssetInput = (assetId, quantity) => {
2067
2149
  const assetInput = findAssetInput(assetId);
2150
+ let usedQuantity = quantity;
2151
+ if (assetId === import_configs7.BaseAssetId) {
2152
+ usedQuantity = (0, import_math7.bn)("1000000000000000000");
2153
+ }
2068
2154
  if (assetInput && "assetId" in assetInput) {
2069
2155
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2070
- assetInput.amount = quantity;
2156
+ assetInput.amount = usedQuantity;
2071
2157
  } else {
2072
2158
  this.addResources([
2073
2159
  {
2074
2160
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2075
- amount: quantity,
2161
+ amount: usedQuantity,
2076
2162
  assetId,
2077
2163
  owner: resourcesOwner || import_address.Address.fromRandom(),
2078
- maturity: 0,
2079
2164
  blockCreated: (0, import_math7.bn)(1),
2080
2165
  txCreatedIdx: (0, import_math7.bn)(1)
2081
2166
  }
2082
2167
  ]);
2083
2168
  }
2084
2169
  };
2085
- updateAssetInput(this.baseAssetId, (0, import_math7.bn)(1e11));
2170
+ updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2086
2171
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2087
2172
  }
2088
2173
  /**
@@ -2107,7 +2192,7 @@ var BaseTransactionRequest = class {
2107
2192
  toJSON() {
2108
2193
  return normalizeJSON(this);
2109
2194
  }
2110
- updatePredicateInputs(inputs) {
2195
+ updatePredicateGasUsed(inputs) {
2111
2196
  this.inputs.forEach((i) => {
2112
2197
  let correspondingInput;
2113
2198
  switch (i.type) {
@@ -2129,16 +2214,25 @@ var BaseTransactionRequest = class {
2129
2214
  }
2130
2215
  });
2131
2216
  }
2217
+ shiftPredicateData() {
2218
+ this.inputs.forEach((input) => {
2219
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2220
+ input.predicateData = input.paddPredicateData(
2221
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2222
+ );
2223
+ }
2224
+ });
2225
+ }
2132
2226
  };
2133
2227
 
2134
2228
  // src/providers/transaction-request/create-transaction-request.ts
2135
- var import_configs8 = require("@fuel-ts/address/configs");
2229
+ var import_configs9 = require("@fuel-ts/address/configs");
2136
2230
  var import_math9 = require("@fuel-ts/math");
2137
2231
  var import_transactions8 = require("@fuel-ts/transactions");
2138
2232
  var import_utils13 = require("@fuel-ts/utils");
2139
2233
 
2140
2234
  // src/providers/transaction-request/hash-transaction.ts
2141
- var import_configs7 = require("@fuel-ts/address/configs");
2235
+ var import_configs8 = require("@fuel-ts/address/configs");
2142
2236
  var import_hasher = require("@fuel-ts/hasher");
2143
2237
  var import_math8 = require("@fuel-ts/math");
2144
2238
  var import_transactions7 = require("@fuel-ts/transactions");
@@ -2147,7 +2241,7 @@ var import_ramda2 = require("ramda");
2147
2241
  function hashTransaction(transactionRequest, chainId) {
2148
2242
  const transaction = transactionRequest.toTransaction();
2149
2243
  if (transaction.type === import_transactions7.TransactionType.Script) {
2150
- transaction.receiptsRoot = import_configs7.ZeroBytes32;
2244
+ transaction.receiptsRoot = import_configs8.ZeroBytes32;
2151
2245
  }
2152
2246
  transaction.inputs = transaction.inputs.map((input) => {
2153
2247
  const inputClone = (0, import_ramda2.clone)(input);
@@ -2169,10 +2263,10 @@ function hashTransaction(transactionRequest, chainId) {
2169
2263
  blockHeight: 0,
2170
2264
  txIndex: 0
2171
2265
  };
2172
- inputClone.txID = import_configs7.ZeroBytes32;
2266
+ inputClone.txID = import_configs8.ZeroBytes32;
2173
2267
  inputClone.outputIndex = 0;
2174
- inputClone.balanceRoot = import_configs7.ZeroBytes32;
2175
- inputClone.stateRoot = import_configs7.ZeroBytes32;
2268
+ inputClone.balanceRoot = import_configs8.ZeroBytes32;
2269
+ inputClone.stateRoot = import_configs8.ZeroBytes32;
2176
2270
  return inputClone;
2177
2271
  }
2178
2272
  default:
@@ -2183,8 +2277,8 @@ function hashTransaction(transactionRequest, chainId) {
2183
2277
  const outputClone = (0, import_ramda2.clone)(output);
2184
2278
  switch (outputClone.type) {
2185
2279
  case import_transactions7.OutputType.Contract: {
2186
- outputClone.balanceRoot = import_configs7.ZeroBytes32;
2187
- outputClone.stateRoot = import_configs7.ZeroBytes32;
2280
+ outputClone.balanceRoot = import_configs8.ZeroBytes32;
2281
+ outputClone.stateRoot = import_configs8.ZeroBytes32;
2188
2282
  return outputClone;
2189
2283
  }
2190
2284
  case import_transactions7.OutputType.Change: {
@@ -2192,9 +2286,9 @@ function hashTransaction(transactionRequest, chainId) {
2192
2286
  return outputClone;
2193
2287
  }
2194
2288
  case import_transactions7.OutputType.Variable: {
2195
- outputClone.to = import_configs7.ZeroBytes32;
2289
+ outputClone.to = import_configs8.ZeroBytes32;
2196
2290
  outputClone.amount = (0, import_math8.bn)(0);
2197
- outputClone.assetId = import_configs7.ZeroBytes32;
2291
+ outputClone.assetId = import_configs8.ZeroBytes32;
2198
2292
  return outputClone;
2199
2293
  }
2200
2294
  default:
@@ -2252,10 +2346,15 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2252
2346
  *
2253
2347
  * @param createTransactionRequestLike - The initial values for the instance
2254
2348
  */
2255
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2349
+ constructor({
2350
+ bytecodeWitnessIndex,
2351
+ salt,
2352
+ storageSlots,
2353
+ ...rest
2354
+ } = {}) {
2256
2355
  super(rest);
2257
2356
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2258
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2357
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2259
2358
  this.storageSlots = [...storageSlots ?? []];
2260
2359
  }
2261
2360
  /**
@@ -2270,10 +2369,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2270
2369
  return {
2271
2370
  type: import_transactions8.TransactionType.Create,
2272
2371
  ...baseTransaction,
2273
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2274
2372
  bytecodeWitnessIndex,
2275
- storageSlotsCount: storageSlots.length,
2276
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2373
+ storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2374
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2277
2375
  storageSlots
2278
2376
  };
2279
2377
  }
@@ -2323,7 +2421,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2323
2421
  // src/providers/transaction-request/script-transaction-request.ts
2324
2422
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
2325
2423
  var import_address2 = require("@fuel-ts/address");
2326
- var import_configs9 = require("@fuel-ts/address/configs");
2424
+ var import_configs10 = require("@fuel-ts/address/configs");
2327
2425
  var import_math10 = require("@fuel-ts/math");
2328
2426
  var import_transactions9 = require("@fuel-ts/transactions");
2329
2427
  var import_utils15 = require("@fuel-ts/utils");
@@ -2376,7 +2474,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2376
2474
  *
2377
2475
  * @param scriptTransactionRequestLike - The initial values for the instance.
2378
2476
  */
2379
- constructor({ script, scriptData, gasLimit, ...rest }) {
2477
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2380
2478
  super(rest);
2381
2479
  this.gasLimit = (0, import_math10.bn)(gasLimit);
2382
2480
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
@@ -2395,9 +2493,9 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2395
2493
  type: import_transactions9.TransactionType.Script,
2396
2494
  scriptGasLimit: this.gasLimit,
2397
2495
  ...super.getBaseTransaction(),
2398
- scriptLength: script.length,
2399
- scriptDataLength: scriptData.length,
2400
- receiptsRoot: import_configs9.ZeroBytes32,
2496
+ scriptLength: (0, import_math10.bn)(script.length),
2497
+ scriptDataLength: (0, import_math10.bn)(scriptData.length),
2498
+ receiptsRoot: import_configs10.ZeroBytes32,
2401
2499
  script: (0, import_utils15.hexlify)(script),
2402
2500
  scriptData: (0, import_utils15.hexlify)(scriptData)
2403
2501
  };
@@ -2460,7 +2558,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2460
2558
  }
2461
2559
  calculateMaxGas(chainInfo, minGas) {
2462
2560
  const { consensusParameters } = chainInfo;
2463
- const { gasPerByte } = consensusParameters;
2561
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2464
2562
  const witnessesLength = this.toTransaction().witnesses.reduce(
2465
2563
  (acc, wit) => acc + wit.dataLength,
2466
2564
  0
@@ -2470,7 +2568,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2470
2568
  minGas,
2471
2569
  witnessesLength,
2472
2570
  witnessLimit: this.witnessLimit,
2473
- gasLimit: this.gasLimit
2571
+ gasLimit: this.gasLimit,
2572
+ maxGasPerTx
2474
2573
  });
2475
2574
  }
2476
2575
  /**
@@ -2545,15 +2644,32 @@ var transactionRequestify = (obj) => {
2545
2644
  }
2546
2645
  }
2547
2646
  };
2647
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2648
+ (acc, input) => {
2649
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2650
+ acc.utxos.push(input.id);
2651
+ }
2652
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2653
+ acc.messages.push(input.nonce);
2654
+ }
2655
+ return acc;
2656
+ },
2657
+ {
2658
+ utxos: [],
2659
+ messages: []
2660
+ }
2661
+ );
2548
2662
 
2549
2663
  // src/providers/transaction-response/transaction-response.ts
2550
2664
  var import_errors13 = require("@fuel-ts/errors");
2551
- var import_math14 = require("@fuel-ts/math");
2552
- var import_transactions17 = require("@fuel-ts/transactions");
2553
- var import_utils21 = require("@fuel-ts/utils");
2665
+ var import_math15 = require("@fuel-ts/math");
2666
+ var import_transactions18 = require("@fuel-ts/transactions");
2667
+ var import_utils20 = require("@fuel-ts/utils");
2554
2668
 
2555
2669
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2556
- var import_utils19 = require("@fuel-ts/utils");
2670
+ var import_math14 = require("@fuel-ts/math");
2671
+ var import_transactions16 = require("@fuel-ts/transactions");
2672
+ var import_utils18 = require("@fuel-ts/utils");
2557
2673
 
2558
2674
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2559
2675
  var import_math11 = require("@fuel-ts/math");
@@ -2561,9 +2677,10 @@ var import_transactions11 = require("@fuel-ts/transactions");
2561
2677
  var import_utils16 = require("@fuel-ts/utils");
2562
2678
  var calculateTransactionFee = (params) => {
2563
2679
  const {
2564
- gasUsed,
2680
+ gasPrice,
2565
2681
  rawPayload,
2566
- consensusParameters: { gasCosts, feeParams }
2682
+ tip,
2683
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2567
2684
  } = params;
2568
2685
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2569
2686
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2573,8 +2690,7 @@ var calculateTransactionFee = (params) => {
2573
2690
  return {
2574
2691
  fee: (0, import_math11.bn)(0),
2575
2692
  minFee: (0, import_math11.bn)(0),
2576
- maxFee: (0, import_math11.bn)(0),
2577
- feeFromGasUsed: (0, import_math11.bn)(0)
2693
+ maxFee: (0, import_math11.bn)(0)
2578
2694
  };
2579
2695
  }
2580
2696
  const { type, witnesses, inputs, policies } = transaction;
@@ -2606,7 +2722,6 @@ var calculateTransactionFee = (params) => {
2606
2722
  metadataGas,
2607
2723
  txBytesSize: transactionBytes.length
2608
2724
  });
2609
- const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2610
2725
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2611
2726
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2612
2727
  const maxGas = getMaxGas({
@@ -2614,22 +2729,30 @@ var calculateTransactionFee = (params) => {
2614
2729
  minGas,
2615
2730
  witnessesLength,
2616
2731
  gasLimit,
2617
- witnessLimit
2732
+ witnessLimit,
2733
+ maxGasPerTx
2734
+ });
2735
+ const minFee = calculateGasFee({
2736
+ gasPrice,
2737
+ gas: minGas,
2738
+ priceFactor: gasPriceFactor,
2739
+ tip
2740
+ });
2741
+ const maxFee = calculateGasFee({
2742
+ gasPrice,
2743
+ gas: maxGas,
2744
+ priceFactor: gasPriceFactor,
2745
+ tip
2618
2746
  });
2619
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2620
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2621
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2622
- const fee = minFee.add(feeFromGasUsed);
2623
2747
  return {
2624
- fee,
2625
2748
  minFee,
2626
2749
  maxFee,
2627
- feeFromGasUsed
2750
+ fee: maxFee
2628
2751
  };
2629
2752
  };
2630
2753
 
2631
2754
  // src/providers/transaction-summary/operations.ts
2632
- var import_configs10 = require("@fuel-ts/address/configs");
2755
+ var import_configs11 = require("@fuel-ts/address/configs");
2633
2756
  var import_errors11 = require("@fuel-ts/errors");
2634
2757
  var import_math13 = require("@fuel-ts/math");
2635
2758
  var import_transactions14 = require("@fuel-ts/transactions");
@@ -2927,7 +3050,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
2927
3050
  const { to: toAddress, assetId, amount } = receipt;
2928
3051
  let { from: fromAddress } = receipt;
2929
3052
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
2930
- if (import_configs10.ZeroBytes32 === fromAddress) {
3053
+ if (import_configs11.ZeroBytes32 === fromAddress) {
2931
3054
  const change = changeOutputs.find((output) => output.assetId === assetId);
2932
3055
  fromAddress = change?.to || fromAddress;
2933
3056
  }
@@ -3191,10 +3314,12 @@ function assembleTransactionSummary(params) {
3191
3314
  gqlTransactionStatus,
3192
3315
  abiMap = {},
3193
3316
  maxInputs,
3194
- gasCosts
3317
+ gasCosts,
3318
+ maxGasPerTx,
3319
+ gasPrice
3195
3320
  } = params;
3196
3321
  const gasUsed = getGasUsedFromReceipts(receipts);
3197
- const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3322
+ const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3198
3323
  const operations = getOperations({
3199
3324
  transactionType: transaction.type,
3200
3325
  inputs: transaction.inputs || [],
@@ -3205,11 +3330,14 @@ function assembleTransactionSummary(params) {
3205
3330
  maxInputs
3206
3331
  });
3207
3332
  const typeName = getTransactionTypeName(transaction.type);
3333
+ const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3208
3334
  const { fee } = calculateTransactionFee({
3209
- gasUsed,
3335
+ gasPrice,
3210
3336
  rawPayload,
3337
+ tip,
3211
3338
  consensusParameters: {
3212
3339
  gasCosts,
3340
+ maxGasPerTx,
3213
3341
  feeParams: {
3214
3342
  gasPerByte,
3215
3343
  gasPriceFactor
@@ -3221,7 +3349,7 @@ function assembleTransactionSummary(params) {
3221
3349
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3222
3350
  let date;
3223
3351
  if (time) {
3224
- date = import_utils19.DateTime.fromTai64(time);
3352
+ date = import_utils18.DateTime.fromTai64(time);
3225
3353
  }
3226
3354
  const transactionSummary = {
3227
3355
  id,
@@ -3249,12 +3377,12 @@ function assembleTransactionSummary(params) {
3249
3377
 
3250
3378
  // src/providers/transaction-response/getDecodedLogs.ts
3251
3379
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3252
- var import_transactions16 = require("@fuel-ts/transactions");
3380
+ var import_transactions17 = require("@fuel-ts/transactions");
3253
3381
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3254
3382
  return receipts.reduce((logs, receipt) => {
3255
- if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3383
+ if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3256
3384
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3257
- const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3385
+ const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3258
3386
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3259
3387
  logs.push(decodedLog);
3260
3388
  }
@@ -3269,7 +3397,7 @@ var TransactionResponse = class {
3269
3397
  /** Current provider */
3270
3398
  provider;
3271
3399
  /** Gas used on the transaction */
3272
- gasUsed = (0, import_math14.bn)(0);
3400
+ gasUsed = (0, import_math15.bn)(0);
3273
3401
  /** The graphql Transaction with receipts object. */
3274
3402
  gqlTransaction;
3275
3403
  abis;
@@ -3327,8 +3455,8 @@ var TransactionResponse = class {
3327
3455
  * @returns The decoded transaction.
3328
3456
  */
3329
3457
  decodeTransaction(transactionWithReceipts) {
3330
- return new import_transactions17.TransactionCoder().decode(
3331
- (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3458
+ return new import_transactions18.TransactionCoder().decode(
3459
+ (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3332
3460
  0
3333
3461
  )?.[0];
3334
3462
  }
@@ -3347,20 +3475,27 @@ var TransactionResponse = class {
3347
3475
  const decodedTransaction = this.decodeTransaction(
3348
3476
  transaction
3349
3477
  );
3350
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3351
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3478
+ let txReceipts = [];
3479
+ if (transaction?.status && "receipts" in transaction.status) {
3480
+ txReceipts = transaction.status.receipts;
3481
+ }
3482
+ const receipts = txReceipts.map(processGqlReceipt) || [];
3483
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3484
+ const gasPrice = await this.provider.getLatestGasPrice();
3352
3485
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3353
3486
  const transactionSummary = assembleTransactionSummary({
3354
3487
  id: this.id,
3355
3488
  receipts,
3356
3489
  transaction: decodedTransaction,
3357
- transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3490
+ transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3358
3491
  gqlTransactionStatus: transaction.status,
3359
3492
  gasPerByte,
3360
3493
  gasPriceFactor,
3361
3494
  abiMap: contractsAbiMap,
3362
3495
  maxInputs,
3363
- gasCosts
3496
+ gasCosts,
3497
+ maxGasPerTx,
3498
+ gasPrice
3364
3499
  });
3365
3500
  return transactionSummary;
3366
3501
  }
@@ -3487,30 +3622,29 @@ var processGqlChain = (chain) => {
3487
3622
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3488
3623
  return {
3489
3624
  name,
3490
- baseChainHeight: (0, import_math15.bn)(daHeight),
3625
+ baseChainHeight: (0, import_math16.bn)(daHeight),
3491
3626
  consensusParameters: {
3492
- contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3493
- maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3494
- maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3495
- maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3496
- maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3497
- maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3498
- maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3499
- maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3500
- maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3501
- maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3502
- maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3503
- gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3504
- gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3505
- maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3506
- chainId: (0, import_math15.bn)(consensusParameters.chainId),
3507
- baseAssetId: consensusParameters.baseAssetId,
3627
+ contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3628
+ maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3629
+ maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3630
+ maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3631
+ maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3632
+ maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3633
+ maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3634
+ maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3635
+ maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3636
+ maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3637
+ maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3638
+ gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3639
+ gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3640
+ maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3641
+ chainId: (0, import_math16.bn)(consensusParameters.chainId),
3508
3642
  gasCosts
3509
3643
  },
3510
3644
  gasCosts,
3511
3645
  latestBlock: {
3512
3646
  id: latestBlock.id,
3513
- height: (0, import_math15.bn)(latestBlock.header.height),
3647
+ height: (0, import_math16.bn)(latestBlock.height),
3514
3648
  time: latestBlock.header.time,
3515
3649
  transactions: latestBlock.transactions.map((i) => ({
3516
3650
  id: i.id
@@ -3604,10 +3738,8 @@ var _Provider = class {
3604
3738
  * Returns some helpful parameters related to gas fees.
3605
3739
  */
3606
3740
  getGasConfig() {
3607
- const { minGasPrice } = this.getNode();
3608
3741
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3609
3742
  return {
3610
- minGasPrice,
3611
3743
  maxGasPerTx,
3612
3744
  maxGasPerPredicate,
3613
3745
  gasPriceFactor,
@@ -3705,7 +3837,7 @@ var _Provider = class {
3705
3837
  */
3706
3838
  async getBlockNumber() {
3707
3839
  const { chain } = await this.operations.getChain();
3708
- return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3840
+ return (0, import_math16.bn)(chain.latestBlock.height, 10);
3709
3841
  }
3710
3842
  /**
3711
3843
  * Returns the chain information.
@@ -3715,13 +3847,11 @@ var _Provider = class {
3715
3847
  async fetchNode() {
3716
3848
  const { nodeInfo } = await this.operations.getNodeInfo();
3717
3849
  const processedNodeInfo = {
3718
- maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3719
- maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3720
- minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3850
+ maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3851
+ maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3721
3852
  nodeVersion: nodeInfo.nodeVersion,
3722
3853
  utxoValidation: nodeInfo.utxoValidation,
3723
- vmBacktrace: nodeInfo.vmBacktrace,
3724
- peers: nodeInfo.peers
3854
+ vmBacktrace: nodeInfo.vmBacktrace
3725
3855
  };
3726
3856
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3727
3857
  return processedNodeInfo;
@@ -3747,17 +3877,6 @@ var _Provider = class {
3747
3877
  } = this.getChain();
3748
3878
  return chainId.toNumber();
3749
3879
  }
3750
- /**
3751
- * Returns the base asset ID
3752
- *
3753
- * @returns A promise that resolves to the base asset ID
3754
- */
3755
- getBaseAssetId() {
3756
- const {
3757
- consensusParameters: { baseAssetId }
3758
- } = this.getChain();
3759
- return baseAssetId;
3760
- }
3761
3880
  /**
3762
3881
  * Submits a transaction to the chain to be executed.
3763
3882
  *
@@ -3774,9 +3893,9 @@ var _Provider = class {
3774
3893
  if (estimateTxDependencies) {
3775
3894
  await this.estimateTxDependencies(transactionRequest);
3776
3895
  }
3777
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3896
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3778
3897
  let abis;
3779
- if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3898
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3780
3899
  abis = transactionRequest.abis;
3781
3900
  }
3782
3901
  if (awaitExecution) {
@@ -3817,15 +3936,14 @@ var _Provider = class {
3817
3936
  if (estimateTxDependencies) {
3818
3937
  return this.estimateTxDependencies(transactionRequest);
3819
3938
  }
3820
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3821
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3822
- encodedTransaction,
3939
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3940
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3941
+ encodedTransactions: encodedTransaction,
3823
3942
  utxoValidation: utxoValidation || false
3824
3943
  });
3825
- const receipts = gqlReceipts.map(processGqlReceipt);
3826
- return {
3827
- receipts
3828
- };
3944
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3945
+ const receipts = rawReceipts.map(processGqlReceipt);
3946
+ return { receipts, dryrunStatus: status };
3829
3947
  }
3830
3948
  /**
3831
3949
  * Verifies whether enough gas is available to complete transaction.
@@ -3836,13 +3954,13 @@ var _Provider = class {
3836
3954
  async estimatePredicates(transactionRequest) {
3837
3955
  const shouldEstimatePredicates = Boolean(
3838
3956
  transactionRequest.inputs.find(
3839
- (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()
3957
+ (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()
3840
3958
  )
3841
3959
  );
3842
3960
  if (!shouldEstimatePredicates) {
3843
3961
  return transactionRequest;
3844
3962
  }
3845
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3963
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3846
3964
  const response = await this.operations.estimatePredicates({
3847
3965
  encodedTransaction
3848
3966
  });
@@ -3851,7 +3969,7 @@ var _Provider = class {
3851
3969
  } = response;
3852
3970
  if (inputs) {
3853
3971
  inputs.forEach((input, index) => {
3854
- if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3972
+ if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
3855
3973
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3856
3974
  }
3857
3975
  });
@@ -3864,31 +3982,31 @@ var _Provider = class {
3864
3982
  * If there are missing variable outputs,
3865
3983
  * `addVariableOutputs` is called on the transaction.
3866
3984
  *
3867
- * @privateRemarks
3868
- * TODO: Investigate support for missing contract IDs
3869
- * TODO: Add support for missing output messages
3870
3985
  *
3871
3986
  * @param transactionRequest - The transaction request object.
3872
3987
  * @returns A promise.
3873
3988
  */
3874
3989
  async estimateTxDependencies(transactionRequest) {
3875
- if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3990
+ if (transactionRequest.type === import_transactions19.TransactionType.Create) {
3876
3991
  return {
3877
3992
  receipts: [],
3878
3993
  outputVariables: 0,
3879
3994
  missingContractIds: []
3880
3995
  };
3881
3996
  }
3882
- await this.estimatePredicates(transactionRequest);
3883
3997
  let receipts = [];
3884
3998
  const missingContractIds = [];
3885
3999
  let outputVariables = 0;
4000
+ let dryrunStatus;
3886
4001
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3887
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3888
- encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4002
+ const {
4003
+ dryRun: [{ receipts: rawReceipts, status }]
4004
+ } = await this.operations.dryRun({
4005
+ encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
3889
4006
  utxoValidation: false
3890
4007
  });
3891
- receipts = gqlReceipts.map(processGqlReceipt);
4008
+ receipts = rawReceipts.map(processGqlReceipt);
4009
+ dryrunStatus = status;
3892
4010
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3893
4011
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3894
4012
  if (hasMissingOutputs) {
@@ -3898,6 +4016,10 @@ var _Provider = class {
3898
4016
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
3899
4017
  missingContractIds.push(contractId);
3900
4018
  });
4019
+ const { maxFee } = await this.estimateTxGasAndFee({
4020
+ transactionRequest
4021
+ });
4022
+ transactionRequest.maxFee = maxFee;
3901
4023
  } else {
3902
4024
  break;
3903
4025
  }
@@ -3905,37 +4027,139 @@ var _Provider = class {
3905
4027
  return {
3906
4028
  receipts,
3907
4029
  outputVariables,
3908
- missingContractIds
4030
+ missingContractIds,
4031
+ dryrunStatus
3909
4032
  };
3910
4033
  }
4034
+ /**
4035
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
4036
+ *
4037
+ * Transactions are dry run in batches. After each dry run, transactions requiring
4038
+ * further modifications are identified. The method iteratively updates these transactions
4039
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4040
+ *
4041
+ * @param transactionRequests - Array of transaction request objects.
4042
+ * @returns A promise that resolves to an array of results for each transaction.
4043
+ */
4044
+ async estimateMultipleTxDependencies(transactionRequests) {
4045
+ const results = transactionRequests.map(() => ({
4046
+ receipts: [],
4047
+ outputVariables: 0,
4048
+ missingContractIds: [],
4049
+ dryrunStatus: void 0
4050
+ }));
4051
+ const allRequests = (0, import_ramda3.clone)(transactionRequests);
4052
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
4053
+ allRequests.forEach((req, index) => {
4054
+ if (req.type === import_transactions19.TransactionType.Script) {
4055
+ serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4056
+ }
4057
+ });
4058
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4059
+ let attempt = 0;
4060
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4061
+ const encodedTransactions = transactionsToProcess.map(
4062
+ (index) => serializedTransactionsMap.get(index)
4063
+ );
4064
+ const dryRunResults = await this.operations.dryRun({
4065
+ encodedTransactions,
4066
+ utxoValidation: false
4067
+ });
4068
+ const nextRoundTransactions = [];
4069
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4070
+ const currentResultIndex = transactionsToProcess[i];
4071
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4072
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4073
+ results[currentResultIndex].dryrunStatus = status;
4074
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4075
+ results[currentResultIndex].receipts
4076
+ );
4077
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4078
+ const requestToProcess = allRequests[currentResultIndex];
4079
+ if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4080
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
4081
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
4082
+ missingOutputContractIds.forEach(({ contractId }) => {
4083
+ requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4084
+ results[currentResultIndex].missingContractIds.push(contractId);
4085
+ });
4086
+ const { maxFee } = await this.estimateTxGasAndFee({
4087
+ transactionRequest: requestToProcess
4088
+ });
4089
+ requestToProcess.maxFee = maxFee;
4090
+ serializedTransactionsMap.set(
4091
+ currentResultIndex,
4092
+ (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4093
+ );
4094
+ nextRoundTransactions.push(currentResultIndex);
4095
+ allRequests[currentResultIndex] = requestToProcess;
4096
+ }
4097
+ }
4098
+ transactionsToProcess = nextRoundTransactions;
4099
+ attempt += 1;
4100
+ }
4101
+ return results;
4102
+ }
4103
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4104
+ if (estimateTxDependencies) {
4105
+ return this.estimateMultipleTxDependencies(transactionRequests);
4106
+ }
4107
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4108
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4109
+ encodedTransactions,
4110
+ utxoValidation: utxoValidation || false
4111
+ });
4112
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4113
+ const receipts = rawReceipts.map(processGqlReceipt);
4114
+ return { receipts, dryrunStatus: status };
4115
+ });
4116
+ return results;
4117
+ }
3911
4118
  /**
3912
4119
  * Estimates the transaction gas and fee based on the provided transaction request.
3913
4120
  * @param transactionRequest - The transaction request object.
3914
4121
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3915
4122
  */
3916
- estimateTxGasAndFee(params) {
4123
+ async estimateTxGasAndFee(params) {
3917
4124
  const { transactionRequest } = params;
3918
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4125
+ let { gasPrice } = params;
3919
4126
  const chainInfo = this.getChain();
3920
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3921
- transactionRequest.gasPrice = gasPrice;
4127
+ const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3922
4128
  const minGas = transactionRequest.calculateMinGas(chainInfo);
3923
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3924
- if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4129
+ if (!gasPrice) {
4130
+ gasPrice = await this.estimateGasPrice(10);
4131
+ }
4132
+ const minFee = calculateGasFee({
4133
+ gasPrice: (0, import_math16.bn)(gasPrice),
4134
+ gas: minGas,
4135
+ priceFactor: gasPriceFactor,
4136
+ tip: transactionRequest.tip
4137
+ }).add(1);
4138
+ let gasLimit = (0, import_math16.bn)(0);
4139
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4140
+ gasLimit = transactionRequest.gasLimit;
3925
4141
  if (transactionRequest.gasLimit.eq(0)) {
3926
4142
  transactionRequest.gasLimit = minGas;
3927
4143
  transactionRequest.gasLimit = maxGasPerTx.sub(
3928
4144
  transactionRequest.calculateMaxGas(chainInfo, minGas)
3929
4145
  );
4146
+ gasLimit = transactionRequest.gasLimit;
3930
4147
  }
3931
4148
  }
3932
4149
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3933
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4150
+ const maxFee = calculateGasFee({
4151
+ gasPrice: (0, import_math16.bn)(gasPrice),
4152
+ gas: maxGas,
4153
+ priceFactor: gasPriceFactor,
4154
+ tip: transactionRequest.tip
4155
+ }).add(1);
3934
4156
  return {
3935
4157
  minGas,
3936
4158
  minFee,
3937
4159
  maxGas,
3938
- maxFee
4160
+ maxFee,
4161
+ gasPrice,
4162
+ gasLimit
3939
4163
  };
3940
4164
  }
3941
4165
  /**
@@ -3953,15 +4177,17 @@ var _Provider = class {
3953
4177
  if (estimateTxDependencies) {
3954
4178
  return this.estimateTxDependencies(transactionRequest);
3955
4179
  }
3956
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3957
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3958
- encodedTransaction,
4180
+ const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4181
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4182
+ encodedTransactions,
3959
4183
  utxoValidation: true
3960
4184
  });
3961
- const receipts = gqlReceipts.map(processGqlReceipt);
3962
- return {
3963
- receipts
3964
- };
4185
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
4186
+ const { id, receipts, status } = dryRunStatus;
4187
+ const processedReceipts = receipts.map(processGqlReceipt);
4188
+ return { id, receipts: processedReceipts, status };
4189
+ });
4190
+ return { receipts: callResult[0].receipts };
3965
4191
  }
3966
4192
  /**
3967
4193
  * Returns a transaction cost to enable user
@@ -3978,77 +4204,79 @@ var _Provider = class {
3978
4204
  * @param tolerance - The tolerance to add on top of the gasUsed.
3979
4205
  * @returns A promise that resolves to the transaction cost object.
3980
4206
  */
3981
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3982
- estimateTxDependencies = true,
3983
- estimatePredicates = true,
3984
- resourcesOwner,
3985
- signatureCallback
3986
- } = {}) {
4207
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3987
4208
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
3988
- const { minGasPrice } = this.getGasConfig();
3989
- const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3990
- const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4209
+ const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
3991
4210
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3992
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4211
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3993
4212
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4213
+ txRequestClone.maxFee = (0, import_math16.bn)(0);
3994
4214
  if (isScriptTransaction) {
3995
- txRequestClone.gasLimit = (0, import_math15.bn)(0);
4215
+ txRequestClone.gasLimit = (0, import_math16.bn)(0);
3996
4216
  }
3997
- if (estimatePredicates) {
3998
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3999
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4000
- }
4001
- await this.estimatePredicates(txRequestClone);
4217
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4218
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4002
4219
  }
4220
+ const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4221
+ let addedSignatures = 0;
4003
4222
  if (signatureCallback && isScriptTransaction) {
4004
- await signatureCallback(txRequestClone);
4223
+ const lengthBefore = signedRequest.witnesses.length;
4224
+ await signatureCallback(signedRequest);
4225
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
4005
4226
  }
4006
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4007
- transactionRequest: txRequestClone
4227
+ await this.estimatePredicates(signedRequest);
4228
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4229
+ transactionRequest: signedRequest
4008
4230
  });
4009
4231
  let receipts = [];
4010
4232
  let missingContractIds = [];
4011
4233
  let outputVariables = 0;
4012
- let gasUsed = (0, import_math15.bn)(0);
4013
- if (isScriptTransaction && estimateTxDependencies) {
4014
- txRequestClone.gasPrice = (0, import_math15.bn)(0);
4234
+ let gasUsed = (0, import_math16.bn)(0);
4235
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4236
+ txRequestClone.maxFee = maxFee;
4237
+ if (isScriptTransaction) {
4238
+ txRequestClone.gasLimit = gasLimit;
4239
+ if (signatureCallback) {
4240
+ await signatureCallback(txRequestClone);
4241
+ }
4015
4242
  const result = await this.estimateTxDependencies(txRequestClone);
4016
4243
  receipts = result.receipts;
4017
4244
  outputVariables = result.outputVariables;
4018
4245
  missingContractIds = result.missingContractIds;
4019
4246
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4020
4247
  txRequestClone.gasLimit = gasUsed;
4021
- txRequestClone.gasPrice = setGasPrice;
4022
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4023
- transactionRequest: txRequestClone
4248
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4249
+ transactionRequest: txRequestClone,
4250
+ gasPrice
4024
4251
  }));
4025
4252
  }
4026
4253
  return {
4027
4254
  requiredQuantities: allQuantities,
4028
4255
  receipts,
4029
4256
  gasUsed,
4030
- minGasPrice,
4031
- gasPrice: setGasPrice,
4257
+ gasPrice,
4032
4258
  minGas,
4033
4259
  maxGas,
4034
4260
  minFee,
4035
4261
  maxFee,
4036
- estimatedInputs: txRequestClone.inputs,
4037
4262
  outputVariables,
4038
- missingContractIds
4263
+ missingContractIds,
4264
+ addedSignatures,
4265
+ estimatedPredicates: txRequestClone.inputs
4039
4266
  };
4040
4267
  }
4041
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4268
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4042
4269
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4043
4270
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4044
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4271
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
4272
+ quantitiesToContract
4273
+ });
4045
4274
  transactionRequest.addResources(
4046
4275
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4047
4276
  );
4048
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4049
- transactionRequest,
4050
- forwardingQuantities
4051
- );
4277
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4278
+ quantitiesToContract
4279
+ });
4052
4280
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4053
4281
  return {
4054
4282
  resources,
@@ -4064,17 +4292,16 @@ var _Provider = class {
4064
4292
  const result = await this.operations.getCoins({
4065
4293
  first: 10,
4066
4294
  ...paginationArgs,
4067
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4295
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4068
4296
  });
4069
4297
  const coins = result.coins.edges.map((edge) => edge.node);
4070
4298
  return coins.map((coin) => ({
4071
4299
  id: coin.utxoId,
4072
4300
  assetId: coin.assetId,
4073
- amount: (0, import_math15.bn)(coin.amount),
4301
+ amount: (0, import_math16.bn)(coin.amount),
4074
4302
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4075
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4076
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4077
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4303
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4304
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4078
4305
  }));
4079
4306
  }
4080
4307
  /**
@@ -4088,19 +4315,19 @@ var _Provider = class {
4088
4315
  async getResourcesToSpend(owner, quantities, excludedIds) {
4089
4316
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4090
4317
  const excludeInput = {
4091
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4092
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4318
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4319
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4093
4320
  };
4094
4321
  if (this.cache) {
4095
4322
  const uniqueUtxos = new Set(
4096
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4323
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4097
4324
  );
4098
4325
  excludeInput.utxos = Array.from(uniqueUtxos);
4099
4326
  }
4100
4327
  const coinsQuery = {
4101
4328
  owner: ownerAddress.toB256(),
4102
4329
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4103
- assetId: (0, import_utils23.hexlify)(assetId),
4330
+ assetId: (0, import_utils22.hexlify)(assetId),
4104
4331
  amount: amount.toString(10),
4105
4332
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4106
4333
  })),
@@ -4111,9 +4338,9 @@ var _Provider = class {
4111
4338
  switch (coin.__typename) {
4112
4339
  case "MessageCoin":
4113
4340
  return {
4114
- amount: (0, import_math15.bn)(coin.amount),
4341
+ amount: (0, import_math16.bn)(coin.amount),
4115
4342
  assetId: coin.assetId,
4116
- daHeight: (0, import_math15.bn)(coin.daHeight),
4343
+ daHeight: (0, import_math16.bn)(coin.daHeight),
4117
4344
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4118
4345
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4119
4346
  nonce: coin.nonce
@@ -4121,12 +4348,11 @@ var _Provider = class {
4121
4348
  case "Coin":
4122
4349
  return {
4123
4350
  id: coin.utxoId,
4124
- amount: (0, import_math15.bn)(coin.amount),
4351
+ amount: (0, import_math16.bn)(coin.amount),
4125
4352
  assetId: coin.assetId,
4126
4353
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4127
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4128
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4129
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4354
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4355
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4130
4356
  };
4131
4357
  default:
4132
4358
  return null;
@@ -4143,13 +4369,13 @@ var _Provider = class {
4143
4369
  async getBlock(idOrHeight) {
4144
4370
  let variables;
4145
4371
  if (typeof idOrHeight === "number") {
4146
- variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4372
+ variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4147
4373
  } else if (idOrHeight === "latest") {
4148
4374
  variables = { height: (await this.getBlockNumber()).toString(10) };
4149
4375
  } else if (idOrHeight.length === 66) {
4150
4376
  variables = { blockId: idOrHeight };
4151
4377
  } else {
4152
- variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4378
+ variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4153
4379
  }
4154
4380
  const { block } = await this.operations.getBlock(variables);
4155
4381
  if (!block) {
@@ -4157,7 +4383,7 @@ var _Provider = class {
4157
4383
  }
4158
4384
  return {
4159
4385
  id: block.id,
4160
- height: (0, import_math15.bn)(block.header.height),
4386
+ height: (0, import_math16.bn)(block.height),
4161
4387
  time: block.header.time,
4162
4388
  transactionIds: block.transactions.map((tx) => tx.id)
4163
4389
  };
@@ -4172,7 +4398,7 @@ var _Provider = class {
4172
4398
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4173
4399
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4174
4400
  id: block.id,
4175
- height: (0, import_math15.bn)(block.header.height),
4401
+ height: (0, import_math16.bn)(block.height),
4176
4402
  time: block.header.time,
4177
4403
  transactionIds: block.transactions.map((tx) => tx.id)
4178
4404
  }));
@@ -4187,7 +4413,7 @@ var _Provider = class {
4187
4413
  async getBlockWithTransactions(idOrHeight) {
4188
4414
  let variables;
4189
4415
  if (typeof idOrHeight === "number") {
4190
- variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4416
+ variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4191
4417
  } else if (idOrHeight === "latest") {
4192
4418
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4193
4419
  } else {
@@ -4199,11 +4425,11 @@ var _Provider = class {
4199
4425
  }
4200
4426
  return {
4201
4427
  id: block.id,
4202
- height: (0, import_math15.bn)(block.header.height, 10),
4428
+ height: (0, import_math16.bn)(block.height, 10),
4203
4429
  time: block.header.time,
4204
4430
  transactionIds: block.transactions.map((tx) => tx.id),
4205
4431
  transactions: block.transactions.map(
4206
- (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4432
+ (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4207
4433
  )
4208
4434
  };
4209
4435
  }
@@ -4218,8 +4444,8 @@ var _Provider = class {
4218
4444
  if (!transaction) {
4219
4445
  return null;
4220
4446
  }
4221
- return new import_transactions18.TransactionCoder().decode(
4222
- (0, import_utils23.arrayify)(transaction.rawPayload),
4447
+ return new import_transactions19.TransactionCoder().decode(
4448
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4223
4449
  0
4224
4450
  )?.[0];
4225
4451
  }
@@ -4246,9 +4472,9 @@ var _Provider = class {
4246
4472
  async getContractBalance(contractId, assetId) {
4247
4473
  const { contractBalance } = await this.operations.getContractBalance({
4248
4474
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4249
- asset: (0, import_utils23.hexlify)(assetId)
4475
+ asset: (0, import_utils22.hexlify)(assetId)
4250
4476
  });
4251
- return (0, import_math15.bn)(contractBalance.amount, 10);
4477
+ return (0, import_math16.bn)(contractBalance.amount, 10);
4252
4478
  }
4253
4479
  /**
4254
4480
  * Returns the balance for the given owner for the given asset ID.
@@ -4260,9 +4486,9 @@ var _Provider = class {
4260
4486
  async getBalance(owner, assetId) {
4261
4487
  const { balance } = await this.operations.getBalance({
4262
4488
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4263
- assetId: (0, import_utils23.hexlify)(assetId)
4489
+ assetId: (0, import_utils22.hexlify)(assetId)
4264
4490
  });
4265
- return (0, import_math15.bn)(balance.amount, 10);
4491
+ return (0, import_math16.bn)(balance.amount, 10);
4266
4492
  }
4267
4493
  /**
4268
4494
  * Returns balances for the given owner.
@@ -4280,7 +4506,7 @@ var _Provider = class {
4280
4506
  const balances = result.balances.edges.map((edge) => edge.node);
4281
4507
  return balances.map((balance) => ({
4282
4508
  assetId: balance.assetId,
4283
- amount: (0, import_math15.bn)(balance.amount)
4509
+ amount: (0, import_math16.bn)(balance.amount)
4284
4510
  }));
4285
4511
  }
4286
4512
  /**
@@ -4298,19 +4524,19 @@ var _Provider = class {
4298
4524
  });
4299
4525
  const messages = result.messages.edges.map((edge) => edge.node);
4300
4526
  return messages.map((message) => ({
4301
- messageId: import_transactions18.InputMessageCoder.getMessageId({
4527
+ messageId: import_transactions19.InputMessageCoder.getMessageId({
4302
4528
  sender: message.sender,
4303
4529
  recipient: message.recipient,
4304
4530
  nonce: message.nonce,
4305
- amount: (0, import_math15.bn)(message.amount),
4531
+ amount: (0, import_math16.bn)(message.amount),
4306
4532
  data: message.data
4307
4533
  }),
4308
4534
  sender: import_address3.Address.fromAddressOrString(message.sender),
4309
4535
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4310
4536
  nonce: message.nonce,
4311
- amount: (0, import_math15.bn)(message.amount),
4312
- data: import_transactions18.InputMessageCoder.decodeData(message.data),
4313
- daHeight: (0, import_math15.bn)(message.daHeight)
4537
+ amount: (0, import_math16.bn)(message.amount),
4538
+ data: import_transactions19.InputMessageCoder.decodeData(message.data),
4539
+ daHeight: (0, import_math16.bn)(message.daHeight)
4314
4540
  }));
4315
4541
  }
4316
4542
  /**
@@ -4363,44 +4589,60 @@ var _Provider = class {
4363
4589
  } = result.messageProof;
4364
4590
  return {
4365
4591
  messageProof: {
4366
- proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4592
+ proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4367
4593
  proofSet: messageProof.proofSet
4368
4594
  },
4369
4595
  blockProof: {
4370
- proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4596
+ proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4371
4597
  proofSet: blockProof.proofSet
4372
4598
  },
4373
4599
  messageBlockHeader: {
4374
4600
  id: messageBlockHeader.id,
4375
- daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4376
- transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4601
+ daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4602
+ transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4377
4603
  transactionsRoot: messageBlockHeader.transactionsRoot,
4378
- height: (0, import_math15.bn)(messageBlockHeader.height),
4604
+ height: (0, import_math16.bn)(messageBlockHeader.height),
4379
4605
  prevRoot: messageBlockHeader.prevRoot,
4380
4606
  time: messageBlockHeader.time,
4381
4607
  applicationHash: messageBlockHeader.applicationHash,
4382
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4383
- messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4608
+ messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4609
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4610
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4611
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
4612
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4384
4613
  },
4385
4614
  commitBlockHeader: {
4386
4615
  id: commitBlockHeader.id,
4387
- daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4388
- transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4616
+ daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4617
+ transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4389
4618
  transactionsRoot: commitBlockHeader.transactionsRoot,
4390
- height: (0, import_math15.bn)(commitBlockHeader.height),
4619
+ height: (0, import_math16.bn)(commitBlockHeader.height),
4391
4620
  prevRoot: commitBlockHeader.prevRoot,
4392
4621
  time: commitBlockHeader.time,
4393
4622
  applicationHash: commitBlockHeader.applicationHash,
4394
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4395
- messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4623
+ messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4624
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4625
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4626
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
4627
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4396
4628
  },
4397
4629
  sender: import_address3.Address.fromAddressOrString(sender),
4398
4630
  recipient: import_address3.Address.fromAddressOrString(recipient),
4399
4631
  nonce,
4400
- amount: (0, import_math15.bn)(amount),
4632
+ amount: (0, import_math16.bn)(amount),
4401
4633
  data
4402
4634
  };
4403
4635
  }
4636
+ async getLatestGasPrice() {
4637
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
4638
+ return (0, import_math16.bn)(latestGasPrice.gasPrice);
4639
+ }
4640
+ async estimateGasPrice(blockHorizon) {
4641
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
4642
+ blockHorizon: String(blockHorizon)
4643
+ });
4644
+ return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4645
+ }
4404
4646
  /**
4405
4647
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4406
4648
  *
@@ -4420,10 +4662,10 @@ var _Provider = class {
4420
4662
  */
4421
4663
  async produceBlocks(amount, startTime) {
4422
4664
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4423
- blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4424
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4665
+ blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4666
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4425
4667
  });
4426
- return (0, import_math15.bn)(latestBlockHeight);
4668
+ return (0, import_math16.bn)(latestBlockHeight);
4427
4669
  }
4428
4670
  // eslint-disable-next-line @typescript-eslint/require-await
4429
4671
  async getTransactionResponse(transactionId) {
@@ -4437,7 +4679,7 @@ cacheInputs_fn = function(inputs) {
4437
4679
  return;
4438
4680
  }
4439
4681
  inputs.forEach((input) => {
4440
- if (input.type === import_transactions18.InputType.Coin) {
4682
+ if (input.type === import_transactions19.InputType.Coin) {
4441
4683
  this.cache?.set(input.id);
4442
4684
  }
4443
4685
  });
@@ -4447,9 +4689,9 @@ __publicField(Provider, "nodeInfoCache", {});
4447
4689
 
4448
4690
  // src/providers/transaction-summary/get-transaction-summary.ts
4449
4691
  var import_errors15 = require("@fuel-ts/errors");
4450
- var import_math16 = require("@fuel-ts/math");
4451
- var import_transactions19 = require("@fuel-ts/transactions");
4452
- var import_utils26 = require("@fuel-ts/utils");
4692
+ var import_math17 = require("@fuel-ts/math");
4693
+ var import_transactions20 = require("@fuel-ts/transactions");
4694
+ var import_utils25 = require("@fuel-ts/utils");
4453
4695
 
4454
4696
  // src/providers/chains.ts
4455
4697
  var CHAIN_IDS = {
@@ -4498,17 +4740,17 @@ var assets = [
4498
4740
 
4499
4741
  // src/utils/formatTransferToContractScriptData.ts
4500
4742
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4501
- var import_math17 = require("@fuel-ts/math");
4502
- var import_utils27 = require("@fuel-ts/utils");
4743
+ var import_math18 = require("@fuel-ts/math");
4744
+ var import_utils26 = require("@fuel-ts/utils");
4503
4745
  var asm = __toESM(require("@fuels/vm-asm"));
4504
4746
  var formatTransferToContractScriptData = (params) => {
4505
4747
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4506
4748
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4507
- const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4749
+ const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4508
4750
  const scriptData = Uint8Array.from([
4509
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
4751
+ ...(0, import_utils26.arrayify)(hexlifiedContractId),
4510
4752
  ...encoded,
4511
- ...(0, import_utils27.arrayify)(assetId)
4753
+ ...(0, import_utils26.arrayify)(assetId)
4512
4754
  ]);
4513
4755
  return scriptData;
4514
4756
  };
@@ -4655,9 +4897,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4655
4897
  * @param assetId - The asset ID to check the balance for.
4656
4898
  * @returns A promise that resolves to the balance amount.
4657
4899
  */
4658
- async getBalance(assetId) {
4659
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4660
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4900
+ async getBalance(assetId = import_configs12.BaseAssetId) {
4901
+ const amount = await this.provider.getBalance(this.address, assetId);
4661
4902
  return amount;
4662
4903
  }
4663
4904
  /**
@@ -4694,37 +4935,33 @@ var Account = class extends import_interfaces.AbstractAccount {
4694
4935
  * @param fee - The estimated transaction fee.
4695
4936
  * @returns A promise that resolves when the resources are added to the transaction.
4696
4937
  */
4697
- async fund(request, coinQuantities, fee) {
4698
- const baseAssetId = this.provider.getBaseAssetId();
4699
- const updatedQuantities = addAmountToAsset({
4700
- amount: (0, import_math18.bn)(fee),
4701
- assetId: baseAssetId,
4702
- coinQuantities
4938
+ async fund(request, params) {
4939
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4940
+ const txRequest = request;
4941
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4942
+ amount: (0, import_math19.bn)(fee),
4943
+ assetId: import_configs12.BaseAssetId,
4944
+ coinQuantities: requiredQuantities
4703
4945
  });
4704
4946
  const quantitiesDict = {};
4705
- updatedQuantities.forEach(({ amount, assetId }) => {
4947
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4706
4948
  quantitiesDict[assetId] = {
4707
4949
  required: amount,
4708
- owned: (0, import_math18.bn)(0)
4950
+ owned: (0, import_math19.bn)(0)
4709
4951
  };
4710
4952
  });
4711
- const cachedUtxos = [];
4712
- const cachedMessages = [];
4713
- const owner = this.address.toB256();
4714
- request.inputs.forEach((input) => {
4953
+ txRequest.inputs.forEach((input) => {
4715
4954
  const isResource = "amount" in input;
4716
4955
  if (isResource) {
4717
4956
  const isCoin2 = "owner" in input;
4718
4957
  if (isCoin2) {
4719
4958
  const assetId = String(input.assetId);
4720
- if (input.owner === owner && quantitiesDict[assetId]) {
4721
- const amount = (0, import_math18.bn)(input.amount);
4959
+ if (quantitiesDict[assetId]) {
4960
+ const amount = (0, import_math19.bn)(input.amount);
4722
4961
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4723
- cachedUtxos.push(input.id);
4724
4962
  }
4725
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4726
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4727
- cachedMessages.push(input.nonce);
4963
+ } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4964
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4728
4965
  }
4729
4966
  }
4730
4967
  });
@@ -4739,12 +4976,23 @@ var Account = class extends import_interfaces.AbstractAccount {
4739
4976
  });
4740
4977
  const needsToBeFunded = missingQuantities.length;
4741
4978
  if (needsToBeFunded) {
4742
- const resources = await this.getResourcesToSpend(missingQuantities, {
4743
- messages: cachedMessages,
4744
- utxos: cachedUtxos
4745
- });
4746
- request.addResources(resources);
4979
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4980
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4981
+ txRequest.addResources(resources);
4982
+ }
4983
+ txRequest.shiftPredicateData();
4984
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
4985
+ const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
4986
+ if (addedSignatures) {
4987
+ Array.from({ length: addedSignatures }).forEach(
4988
+ () => requestToBeReEstimate.addEmptyWitness()
4989
+ );
4747
4990
  }
4991
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
4992
+ transactionRequest: requestToBeReEstimate
4993
+ });
4994
+ txRequest.maxFee = maxFee;
4995
+ return txRequest;
4748
4996
  }
4749
4997
  /**
4750
4998
  * A helper that creates a transfer transaction request and returns it.
@@ -4752,30 +5000,25 @@ var Account = class extends import_interfaces.AbstractAccount {
4752
5000
  * @param destination - The address of the destination.
4753
5001
  * @param amount - The amount of coins to transfer.
4754
5002
  * @param assetId - The asset ID of the coins to transfer.
4755
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5003
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4756
5004
  * @returns A promise that resolves to the prepared transaction request.
4757
5005
  */
4758
- async createTransfer(destination, amount, assetId, txParams = {}) {
4759
- const { minGasPrice } = this.provider.getGasConfig();
4760
- const baseAssetId = this.provider.getBaseAssetId();
4761
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4762
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
4763
- const request = new ScriptTransactionRequest(params);
4764
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
4765
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5006
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5007
+ const request = new ScriptTransactionRequest(txParams);
5008
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5009
+ const txCost = await this.provider.getTransactionCost(request, {
4766
5010
  estimateTxDependencies: true,
4767
5011
  resourcesOwner: this
4768
5012
  });
4769
- request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
4770
- request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
4771
- this.validateGas({
4772
- gasUsed,
4773
- gasPrice: request.gasPrice,
4774
- gasLimit: request.gasLimit,
4775
- minGasPrice
4776
- });
4777
- await this.fund(request, requiredQuantities, maxFee);
4778
- request.updatePredicateInputs(estimatedInputs);
5013
+ if ("gasLimit" in txParams) {
5014
+ this.validateGas({
5015
+ gasUsed: txCost.gasUsed,
5016
+ gasLimit: request.gasLimit
5017
+ });
5018
+ }
5019
+ request.gasLimit = txCost.gasUsed;
5020
+ request.maxFee = txCost.maxFee;
5021
+ await this.fund(request, txCost);
4779
5022
  return request;
4780
5023
  }
4781
5024
  /**
@@ -4787,15 +5030,14 @@ var Account = class extends import_interfaces.AbstractAccount {
4787
5030
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4788
5031
  * @returns A promise that resolves to the transaction response.
4789
5032
  */
4790
- async transfer(destination, amount, assetId, txParams = {}) {
4791
- if ((0, import_math18.bn)(amount).lte(0)) {
5033
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5034
+ if ((0, import_math19.bn)(amount).lte(0)) {
4792
5035
  throw new import_errors16.FuelError(
4793
5036
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4794
5037
  "Transfer amount must be a positive number."
4795
5038
  );
4796
5039
  }
4797
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4798
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5040
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
4799
5041
  return this.sendTransaction(request, { estimateTxDependencies: false });
4800
5042
  }
4801
5043
  /**
@@ -4807,41 +5049,38 @@ var Account = class extends import_interfaces.AbstractAccount {
4807
5049
  * @param txParams - The optional transaction parameters.
4808
5050
  * @returns A promise that resolves to the transaction response.
4809
5051
  */
4810
- async transferToContract(contractId, amount, assetId, txParams = {}) {
4811
- if ((0, import_math18.bn)(amount).lte(0)) {
5052
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5053
+ if ((0, import_math19.bn)(amount).lte(0)) {
4812
5054
  throw new import_errors16.FuelError(
4813
5055
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4814
5056
  "Transfer amount must be a positive number."
4815
5057
  );
4816
5058
  }
4817
5059
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4818
- const { minGasPrice } = this.provider.getGasConfig();
4819
- const baseAssetId = this.provider.getBaseAssetId();
4820
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4821
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
4822
5060
  const { script, scriptData } = await assembleTransferToContractScript({
4823
5061
  hexlifiedContractId: contractAddress.toB256(),
4824
- amountToTransfer: (0, import_math18.bn)(amount),
4825
- assetId: assetIdToTransfer
5062
+ amountToTransfer: (0, import_math19.bn)(amount),
5063
+ assetId
4826
5064
  });
4827
5065
  const request = new ScriptTransactionRequest({
4828
- ...params,
5066
+ ...txParams,
4829
5067
  script,
4830
5068
  scriptData
4831
5069
  });
4832
5070
  request.addContractInputAndOutput(contractAddress);
4833
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4834
- request,
4835
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
4836
- );
4837
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4838
- this.validateGas({
4839
- gasUsed,
4840
- gasPrice: request.gasPrice,
4841
- gasLimit: request.gasLimit,
4842
- minGasPrice
5071
+ const txCost = await this.provider.getTransactionCost(request, {
5072
+ resourcesOwner: this,
5073
+ quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
4843
5074
  });
4844
- await this.fund(request, requiredQuantities, maxFee);
5075
+ if (txParams.gasLimit) {
5076
+ this.validateGas({
5077
+ gasUsed: txCost.gasUsed,
5078
+ gasLimit: request.gasLimit
5079
+ });
5080
+ }
5081
+ request.gasLimit = txCost.gasUsed;
5082
+ request.maxFee = txCost.maxFee;
5083
+ await this.fund(request, txCost);
4845
5084
  return this.sendTransaction(request);
4846
5085
  }
4847
5086
  /**
@@ -4853,40 +5092,31 @@ var Account = class extends import_interfaces.AbstractAccount {
4853
5092
  * @returns A promise that resolves to the transaction response.
4854
5093
  */
4855
5094
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4856
- const { minGasPrice } = this.provider.getGasConfig();
4857
- const baseAssetId = this.provider.getBaseAssetId();
4858
5095
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
4859
- const recipientDataArray = (0, import_utils28.arrayify)(
5096
+ const recipientDataArray = (0, import_utils27.arrayify)(
4860
5097
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4861
5098
  );
4862
- const amountDataArray = (0, import_utils28.arrayify)(
4863
- "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5099
+ const amountDataArray = (0, import_utils27.arrayify)(
5100
+ "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
4864
5101
  );
4865
5102
  const script = new Uint8Array([
4866
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5103
+ ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4867
5104
  ...recipientDataArray,
4868
5105
  ...amountDataArray
4869
5106
  ]);
4870
- const params = {
4871
- script,
4872
- gasPrice: minGasPrice,
4873
- baseAssetId,
4874
- ...txParams
4875
- };
5107
+ const params = { script, ...txParams };
4876
5108
  const request = new ScriptTransactionRequest(params);
4877
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
4878
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4879
- request,
4880
- forwardingQuantities
4881
- );
4882
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4883
- this.validateGas({
4884
- gasUsed,
4885
- gasPrice: request.gasPrice,
4886
- gasLimit: request.gasLimit,
4887
- minGasPrice
4888
- });
4889
- await this.fund(request, requiredQuantities, maxFee);
5109
+ const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5110
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5111
+ if (txParams.gasLimit) {
5112
+ this.validateGas({
5113
+ gasUsed: txCost.gasUsed,
5114
+ gasLimit: request.gasLimit
5115
+ });
5116
+ }
5117
+ request.maxFee = txCost.maxFee;
5118
+ request.gasLimit = txCost.gasUsed;
5119
+ await this.fund(request, txCost);
4890
5120
  return this.sendTransaction(request);
4891
5121
  }
4892
5122
  async signMessage(message) {
@@ -4944,18 +5174,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4944
5174
  }
4945
5175
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4946
5176
  }
4947
- validateGas({
4948
- gasUsed,
4949
- gasPrice,
4950
- gasLimit,
4951
- minGasPrice
4952
- }) {
4953
- if (minGasPrice.gt(gasPrice)) {
4954
- throw new import_errors16.FuelError(
4955
- import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4956
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4957
- );
4958
- }
5177
+ validateGas({ gasUsed, gasLimit }) {
4959
5178
  if (gasUsed.gt(gasLimit)) {
4960
5179
  throw new import_errors16.FuelError(
4961
5180
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -4969,8 +5188,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4969
5188
  var import_address5 = require("@fuel-ts/address");
4970
5189
  var import_crypto2 = require("@fuel-ts/crypto");
4971
5190
  var import_hasher2 = require("@fuel-ts/hasher");
4972
- var import_math19 = require("@fuel-ts/math");
4973
- var import_utils29 = require("@fuel-ts/utils");
5191
+ var import_math20 = require("@fuel-ts/math");
5192
+ var import_utils28 = require("@fuel-ts/utils");
4974
5193
  var import_secp256k1 = require("@noble/curves/secp256k1");
4975
5194
  var Signer = class {
4976
5195
  address;
@@ -4989,10 +5208,10 @@ var Signer = class {
4989
5208
  privateKey = `0x${privateKey}`;
4990
5209
  }
4991
5210
  }
4992
- const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
4993
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4994
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4995
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5211
+ const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5212
+ this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5213
+ this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5214
+ this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4996
5215
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
4997
5216
  }
4998
5217
  /**
@@ -5006,11 +5225,11 @@ var Signer = class {
5006
5225
  * @returns hashed signature
5007
5226
  */
5008
5227
  sign(data) {
5009
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5010
- const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5011
- const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5228
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5229
+ const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5230
+ const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5012
5231
  s[0] |= (signature.recovery || 0) << 7;
5013
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5232
+ return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5014
5233
  }
5015
5234
  /**
5016
5235
  * Add point on the current elliptic curve
@@ -5019,8 +5238,8 @@ var Signer = class {
5019
5238
  * @returns compressed point on the curve
5020
5239
  */
5021
5240
  addPoint(point) {
5022
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5023
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5241
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5242
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5024
5243
  const result = p0.add(p1);
5025
5244
  return `0x${result.toHex(true)}`;
5026
5245
  }
@@ -5032,16 +5251,16 @@ var Signer = class {
5032
5251
  * @returns public key from signature from the
5033
5252
  */
5034
5253
  static recoverPublicKey(data, signature) {
5035
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5254
+ const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5036
5255
  const r = signedMessageBytes.slice(0, 32);
5037
5256
  const s = signedMessageBytes.slice(32, 64);
5038
5257
  const recoveryParam = (s[0] & 128) >> 7;
5039
5258
  s[0] &= 127;
5040
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5259
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5041
5260
  recoveryParam
5042
5261
  );
5043
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5044
- return (0, import_utils29.hexlify)(publicKey);
5262
+ const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5263
+ return (0, import_utils28.hexlify)(publicKey);
5045
5264
  }
5046
5265
  /**
5047
5266
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5060,7 +5279,7 @@ var Signer = class {
5060
5279
  * @returns random 32-byte hashed
5061
5280
  */
5062
5281
  static generatePrivateKey(entropy) {
5063
- 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);
5282
+ return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5064
5283
  }
5065
5284
  /**
5066
5285
  * Extended publicKey from a compact publicKey
@@ -5069,8 +5288,8 @@ var Signer = class {
5069
5288
  * @returns extended publicKey
5070
5289
  */
5071
5290
  static extendPublicKey(publicKey) {
5072
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5073
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5291
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5292
+ return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5074
5293
  }
5075
5294
  };
5076
5295
 
@@ -5078,7 +5297,7 @@ var Signer = class {
5078
5297
  var import_address6 = require("@fuel-ts/address");
5079
5298
  var import_crypto3 = require("@fuel-ts/crypto");
5080
5299
  var import_errors17 = require("@fuel-ts/errors");
5081
- var import_utils30 = require("@fuel-ts/utils");
5300
+ var import_utils29 = require("@fuel-ts/utils");
5082
5301
  var import_uuid = require("uuid");
5083
5302
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5084
5303
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5161,7 +5380,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5161
5380
  );
5162
5381
  }
5163
5382
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5164
- const privateKey = (0, import_utils30.hexlify)(buffer);
5383
+ const privateKey = (0, import_utils29.hexlify)(buffer);
5165
5384
  return privateKey;
5166
5385
  }
5167
5386
 
@@ -5206,7 +5425,7 @@ var BaseWalletUnlocked = class extends Account {
5206
5425
  */
5207
5426
  async signMessage(message) {
5208
5427
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5209
- return (0, import_utils31.hexlify)(signedMessage);
5428
+ return (0, import_utils30.hexlify)(signedMessage);
5210
5429
  }
5211
5430
  /**
5212
5431
  * Signs a transaction with the wallet's private key.
@@ -5219,7 +5438,7 @@ var BaseWalletUnlocked = class extends Account {
5219
5438
  const chainId = this.provider.getChainId();
5220
5439
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5221
5440
  const signature = await this.signer().sign(hashedTransaction);
5222
- return (0, import_utils31.hexlify)(signature);
5441
+ return (0, import_utils30.hexlify)(signature);
5223
5442
  }
5224
5443
  /**
5225
5444
  * Populates a transaction with the witnesses signature.
@@ -5239,7 +5458,7 @@ var BaseWalletUnlocked = class extends Account {
5239
5458
  * @param transactionRequestLike - The transaction request to send.
5240
5459
  * @returns A promise that resolves to the TransactionResponse object.
5241
5460
  */
5242
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5461
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5243
5462
  const transactionRequest = transactionRequestify(transactionRequestLike);
5244
5463
  if (estimateTxDependencies) {
5245
5464
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5280,15 +5499,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5280
5499
  // src/hdwallet/hdwallet.ts
5281
5500
  var import_errors20 = require("@fuel-ts/errors");
5282
5501
  var import_hasher6 = require("@fuel-ts/hasher");
5283
- var import_math20 = require("@fuel-ts/math");
5284
- var import_utils35 = require("@fuel-ts/utils");
5502
+ var import_math21 = require("@fuel-ts/math");
5503
+ var import_utils34 = require("@fuel-ts/utils");
5285
5504
  var import_ethers3 = require("ethers");
5286
5505
 
5287
5506
  // src/mnemonic/mnemonic.ts
5288
5507
  var import_crypto4 = require("@fuel-ts/crypto");
5289
5508
  var import_errors19 = require("@fuel-ts/errors");
5290
5509
  var import_hasher5 = require("@fuel-ts/hasher");
5291
- var import_utils33 = require("@fuel-ts/utils");
5510
+ var import_utils32 = require("@fuel-ts/utils");
5292
5511
  var import_ethers2 = require("ethers");
5293
5512
 
5294
5513
  // src/wordlists/words/english.ts
@@ -7346,7 +7565,7 @@ var english = [
7346
7565
  // src/mnemonic/utils.ts
7347
7566
  var import_errors18 = require("@fuel-ts/errors");
7348
7567
  var import_hasher4 = require("@fuel-ts/hasher");
7349
- var import_utils32 = require("@fuel-ts/utils");
7568
+ var import_utils31 = require("@fuel-ts/utils");
7350
7569
  function toUtf8Bytes(stri) {
7351
7570
  const str = stri.normalize("NFKD");
7352
7571
  const result = [];
@@ -7413,14 +7632,14 @@ function entropyToMnemonicIndices(entropy) {
7413
7632
  }
7414
7633
  }
7415
7634
  const checksumBits = entropy.length / 4;
7416
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7635
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7417
7636
  indices[indices.length - 1] <<= checksumBits;
7418
7637
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7419
7638
  return indices;
7420
7639
  }
7421
7640
  function mnemonicWordsToEntropy(words, wordlist) {
7422
7641
  const size = Math.ceil(11 * words.length / 8);
7423
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7642
+ const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7424
7643
  let offset = 0;
7425
7644
  for (let i = 0; i < words.length; i += 1) {
7426
7645
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7440,7 +7659,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7440
7659
  const entropyBits = 32 * words.length / 3;
7441
7660
  const checksumBits = words.length / 3;
7442
7661
  const checksumMask = getUpperMask(checksumBits);
7443
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7662
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7444
7663
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7445
7664
  throw new import_errors18.FuelError(
7446
7665
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7515,7 +7734,7 @@ var Mnemonic = class {
7515
7734
  static mnemonicToEntropy(phrase, wordlist = english) {
7516
7735
  const words = getWords(phrase);
7517
7736
  assertMnemonic(words);
7518
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7737
+ return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7519
7738
  }
7520
7739
  /**
7521
7740
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7523,7 +7742,7 @@ var Mnemonic = class {
7523
7742
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7524
7743
  */
7525
7744
  static entropyToMnemonic(entropy, wordlist = english) {
7526
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
7745
+ const entropyBytes = (0, import_utils32.arrayify)(entropy);
7527
7746
  assertWordList(wordlist);
7528
7747
  assertEntropy(entropyBytes);
7529
7748
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7592,14 +7811,14 @@ var Mnemonic = class {
7592
7811
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7593
7812
  */
7594
7813
  static masterKeysFromSeed(seed) {
7595
- const seedArray = (0, import_utils33.arrayify)(seed);
7814
+ const seedArray = (0, import_utils32.arrayify)(seed);
7596
7815
  if (seedArray.length < 16 || seedArray.length > 64) {
7597
7816
  throw new import_errors19.FuelError(
7598
7817
  import_errors19.ErrorCode.INVALID_SEED,
7599
7818
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7600
7819
  );
7601
7820
  }
7602
- return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7821
+ return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7603
7822
  }
7604
7823
  /**
7605
7824
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7610,22 +7829,22 @@ var Mnemonic = class {
7610
7829
  */
7611
7830
  static seedToExtendedKey(seed, testnet = false) {
7612
7831
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7613
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7832
+ const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7614
7833
  const depth = "0x00";
7615
7834
  const fingerprint = "0x00000000";
7616
7835
  const index = "0x00000000";
7617
7836
  const chainCode = masterKey.slice(32);
7618
7837
  const privateKey = masterKey.slice(0, 32);
7619
- const extendedKey = (0, import_utils33.concat)([
7838
+ const extendedKey = (0, import_utils32.concat)([
7620
7839
  prefix,
7621
7840
  depth,
7622
7841
  fingerprint,
7623
7842
  index,
7624
7843
  chainCode,
7625
- (0, import_utils33.concat)(["0x00", privateKey])
7844
+ (0, import_utils32.concat)(["0x00", privateKey])
7626
7845
  ]);
7627
7846
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7628
- return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7847
+ return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7629
7848
  }
7630
7849
  /**
7631
7850
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7640,7 +7859,7 @@ var Mnemonic = class {
7640
7859
  * @returns A randomly generated mnemonic
7641
7860
  */
7642
7861
  static generate(size = 32, extraEntropy = "") {
7643
- 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);
7862
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
7644
7863
  return Mnemonic.entropyToMnemonic(entropy);
7645
7864
  }
7646
7865
  };
@@ -7648,12 +7867,12 @@ var mnemonic_default = Mnemonic;
7648
7867
 
7649
7868
  // src/hdwallet/hdwallet.ts
7650
7869
  var HARDENED_INDEX = 2147483648;
7651
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7652
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7653
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7654
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7870
+ var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7871
+ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7872
+ var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7873
+ var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7655
7874
  function base58check(data) {
7656
- 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)]));
7875
+ return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7657
7876
  }
7658
7877
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7659
7878
  if (isPublic) {
@@ -7662,11 +7881,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7662
7881
  return testnet ? TestnetPRV2 : MainnetPRV2;
7663
7882
  }
7664
7883
  function isPublicExtendedKey(extendedKey) {
7665
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7884
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7666
7885
  }
7667
7886
  function isValidExtendedKey(extendedKey) {
7668
7887
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7669
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7888
+ (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7670
7889
  );
7671
7890
  }
7672
7891
  function parsePath(path2, depth = 0) {
@@ -7684,8 +7903,8 @@ function parsePath(path2, depth = 0) {
7684
7903
  var HDWallet = class {
7685
7904
  depth = 0;
7686
7905
  index = 0;
7687
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
7688
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7906
+ fingerprint = (0, import_utils34.hexlify)("0x00000000");
7907
+ parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7689
7908
  privateKey;
7690
7909
  publicKey;
7691
7910
  chainCode;
@@ -7697,8 +7916,8 @@ var HDWallet = class {
7697
7916
  constructor(config) {
7698
7917
  if (config.privateKey) {
7699
7918
  const signer = new Signer(config.privateKey);
7700
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7701
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7919
+ this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7920
+ this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7702
7921
  } else {
7703
7922
  if (!config.publicKey) {
7704
7923
  throw new import_errors20.FuelError(
@@ -7706,7 +7925,7 @@ var HDWallet = class {
7706
7925
  "Both public and private Key cannot be missing. At least one should be provided."
7707
7926
  );
7708
7927
  }
7709
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7928
+ this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7710
7929
  }
7711
7930
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7712
7931
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7725,9 +7944,9 @@ var HDWallet = class {
7725
7944
  * @returns A new instance of HDWallet on the derived index
7726
7945
  */
7727
7946
  deriveIndex(index) {
7728
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7729
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7730
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7947
+ const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7948
+ const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7949
+ const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7731
7950
  const data = new Uint8Array(37);
7732
7951
  if (index & HARDENED_INDEX) {
7733
7952
  if (!privateKey) {
@@ -7738,15 +7957,15 @@ var HDWallet = class {
7738
7957
  }
7739
7958
  data.set(privateKey, 1);
7740
7959
  } else {
7741
- data.set((0, import_utils35.arrayify)(this.publicKey));
7960
+ data.set((0, import_utils34.arrayify)(this.publicKey));
7742
7961
  }
7743
- data.set((0, import_math20.toBytes)(index, 4), 33);
7744
- const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7962
+ data.set((0, import_math21.toBytes)(index, 4), 33);
7963
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7745
7964
  const IL = bytes.slice(0, 32);
7746
7965
  const IR = bytes.slice(32);
7747
7966
  if (privateKey) {
7748
7967
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7749
- const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7968
+ const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
7750
7969
  return new HDWallet({
7751
7970
  privateKey: ki,
7752
7971
  chainCode: IR,
@@ -7755,7 +7974,7 @@ var HDWallet = class {
7755
7974
  parentFingerprint: this.fingerprint
7756
7975
  });
7757
7976
  }
7758
- const signer = new Signer((0, import_utils35.hexlify)(IL));
7977
+ const signer = new Signer((0, import_utils34.hexlify)(IL));
7759
7978
  const Ki = signer.addPoint(publicKey);
7760
7979
  return new HDWallet({
7761
7980
  publicKey: Ki,
@@ -7790,12 +8009,12 @@ var HDWallet = class {
7790
8009
  );
7791
8010
  }
7792
8011
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7793
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8012
+ const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7794
8013
  const parentFingerprint = this.parentFingerprint;
7795
- const index = (0, import_math20.toHex)(this.index, 4);
8014
+ const index = (0, import_math21.toHex)(this.index, 4);
7796
8015
  const chainCode = this.chainCode;
7797
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7798
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8016
+ const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8017
+ const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7799
8018
  return base58check(extendedKey);
7800
8019
  }
7801
8020
  /**
@@ -7807,13 +8026,13 @@ var HDWallet = class {
7807
8026
  static fromSeed(seed) {
7808
8027
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7809
8028
  return new HDWallet({
7810
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7811
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8029
+ chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8030
+ privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7812
8031
  });
7813
8032
  }
7814
8033
  static fromExtendedKey(extendedKey) {
7815
8034
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
7816
- const bytes = (0, import_utils35.arrayify)(decoded);
8035
+ const bytes = (0, import_utils34.arrayify)(decoded);
7817
8036
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7818
8037
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7819
8038
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -7822,9 +8041,9 @@ var HDWallet = class {
7822
8041
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7823
8042
  }
7824
8043
  const depth = bytes[4];
7825
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7826
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7827
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8044
+ const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8045
+ const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8046
+ const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7828
8047
  const key = bytes.slice(45, 78);
7829
8048
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7830
8049
  throw new import_errors20.FuelError(
@@ -8017,16 +8236,15 @@ var seedTestWallet = async (wallet, quantities) => {
8017
8236
  process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
8018
8237
  wallet.provider
8019
8238
  );
8020
- const resources = await genesisWallet.getResourcesToSpend(quantities);
8021
- const { minGasPrice } = genesisWallet.provider.getGasConfig();
8022
- const baseAssetId = genesisWallet.provider.getBaseAssetId();
8023
- const request = new ScriptTransactionRequest({
8024
- baseAssetId,
8025
- gasLimit: 1e4,
8026
- gasPrice: minGasPrice
8239
+ const request = new ScriptTransactionRequest();
8240
+ quantities.forEach((quantity) => {
8241
+ const { amount, assetId } = coinQuantityfy(quantity);
8242
+ request.addCoinOutput(wallet.address, amount, assetId);
8027
8243
  });
8028
- request.addResources(resources);
8029
- quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8244
+ const txCost = await genesisWallet.provider.getTransactionCost(request);
8245
+ request.gasLimit = txCost.gasUsed;
8246
+ request.maxFee = txCost.maxFee;
8247
+ await genesisWallet.fund(request, txCost);
8030
8248
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8031
8249
  };
8032
8250
 
@@ -8040,12 +8258,13 @@ var generateTestWallet = async (provider, quantities) => {
8040
8258
  };
8041
8259
 
8042
8260
  // src/test-utils/launchNode.ts
8043
- var import_configs11 = require("@fuel-ts/address/configs");
8044
- var import_math21 = require("@fuel-ts/math");
8045
- var import_utils36 = require("@fuel-ts/utils");
8261
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
8262
+ var import_configs13 = require("@fuel-ts/address/configs");
8263
+ var import_crypto6 = require("@fuel-ts/crypto");
8264
+ var import_utils35 = require("@fuel-ts/utils");
8046
8265
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8047
8266
  var import_child_process = require("child_process");
8048
- var import_crypto6 = require("crypto");
8267
+ var import_crypto7 = require("crypto");
8049
8268
  var import_fs = require("fs");
8050
8269
  var import_os = __toESM(require("os"));
8051
8270
  var import_path = __toESM(require("path"));
@@ -8094,13 +8313,13 @@ var launchNode = async ({
8094
8313
  // eslint-disable-next-line no-async-promise-executor
8095
8314
  new Promise(async (resolve, reject) => {
8096
8315
  const remainingArgs = extractRemainingArgs(args, [
8097
- "--chain",
8316
+ "--snapshot",
8098
8317
  "--consensus-key",
8099
8318
  "--db-type",
8100
8319
  "--poa-instant"
8101
8320
  ]);
8102
- const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8103
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8321
+ const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8322
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8104
8323
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8105
8324
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8106
8325
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -8117,37 +8336,55 @@ var launchNode = async ({
8117
8336
  })).toString();
8118
8337
  let chainConfigPathToUse;
8119
8338
  const prefix = basePath || import_os.default.tmpdir();
8120
- const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
8121
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
8339
+ const suffix = basePath ? "" : (0, import_crypto7.randomUUID)();
8340
+ const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
8122
8341
  if (chainConfigPath) {
8123
8342
  chainConfigPathToUse = chainConfigPath;
8124
8343
  } else {
8125
8344
  if (!(0, import_fs.existsSync)(tempDirPath)) {
8126
8345
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8127
8346
  }
8128
- const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
8129
- let chainConfig = import_utils36.defaultChainConfig;
8347
+ let { stateConfigJson } = import_utils35.defaultChainConfigs;
8348
+ const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
8349
+ stateConfigJson = {
8350
+ ...stateConfigJson,
8351
+ coins: [
8352
+ ...stateConfigJson.coins.map((coin) => ({
8353
+ ...coin,
8354
+ amount: "18446744073709551615"
8355
+ }))
8356
+ ],
8357
+ messages: stateConfigJson.messages.map((message) => ({
8358
+ ...message,
8359
+ amount: "18446744073709551615"
8360
+ }))
8361
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8362
+ };
8130
8363
  if (!process.env.GENESIS_SECRET) {
8131
8364
  const pk = Signer.generatePrivateKey();
8132
8365
  const signer = new Signer(pk);
8133
- process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8134
- chainConfig = {
8135
- ...import_utils36.defaultChainConfig,
8136
- initial_state: {
8137
- ...import_utils36.defaultChainConfig.initial_state,
8138
- coins: [
8139
- ...import_utils36.defaultChainConfig.initial_state.coins,
8140
- {
8141
- owner: signer.address.toHexString(),
8142
- amount: (0, import_math21.toHex)(1e9),
8143
- asset_id: import_utils36.defaultChainConfig?.consensus_parameters?.base_asset_id ?? import_configs11.ZeroBytes32
8144
- }
8145
- ]
8146
- }
8147
- };
8366
+ process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8367
+ stateConfigJson.coins.push({
8368
+ tx_id: (0, import_utils35.hexlify)((0, import_crypto6.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8369
+ owner: signer.address.toHexString(),
8370
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8371
+ amount: "18446744073709551615",
8372
+ asset_id: import_configs13.BaseAssetId,
8373
+ output_index: 0,
8374
+ tx_pointer_block_height: 0,
8375
+ tx_pointer_tx_idx: 0
8376
+ });
8148
8377
  }
8149
- (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8150
- chainConfigPathToUse = tempChainConfigFilePath;
8378
+ let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8379
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8380
+ fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8381
+ const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8382
+ const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8383
+ const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8384
+ (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8385
+ (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8386
+ (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8387
+ chainConfigPathToUse = tempDirPath;
8151
8388
  }
8152
8389
  const child = (0, import_child_process.spawn)(
8153
8390
  command,
@@ -8156,10 +8393,10 @@ var launchNode = async ({
8156
8393
  ["--ip", ipToUse],
8157
8394
  ["--port", portToUse],
8158
8395
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8159
- ["--min-gas-price", "0"],
8396
+ ["--min-gas-price", "1"],
8160
8397
  poaInstant ? ["--poa-instant", "true"] : [],
8161
8398
  ["--consensus-key", consensusKey],
8162
- ["--chain", chainConfigPathToUse],
8399
+ ["--snapshot", chainConfigPathToUse],
8163
8400
  "--vm-backtrace",
8164
8401
  "--utxo-validation",
8165
8402
  "--debug",
@@ -8206,10 +8443,9 @@ var launchNode = async ({
8206
8443
  })
8207
8444
  );
8208
8445
  var generateWallets = async (count, provider) => {
8209
- const baseAssetId = provider.getBaseAssetId();
8210
8446
  const wallets = [];
8211
8447
  for (let i = 0; i < count; i += 1) {
8212
- const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8448
+ const wallet = await generateTestWallet(provider, [[1e3, import_configs13.BaseAssetId]]);
8213
8449
  wallets.push(wallet);
8214
8450
  }
8215
8451
  return wallets;
@@ -8219,7 +8455,7 @@ var launchNodeAndGetWallets = async ({
8219
8455
  walletCount = 10
8220
8456
  } = {}) => {
8221
8457
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8222
- const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8458
+ const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8223
8459
  const wallets = await generateWallets(walletCount, provider);
8224
8460
  const cleanup = () => {
8225
8461
  closeNode();