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

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