@fuel-ts/account 0.0.0-rc-2021-20240409152935 → 0.0.0-rc-1976-20240410103621

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

Potentially problematic release.


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

Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +678 -946
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +611 -850
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +454 -692
  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 +328 -894
  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/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -3
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +34 -45
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +29 -9
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1179 -1661
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +608 -826
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +466 -684
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
@@ -24,38 +24,35 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
24
24
 
25
25
  // src/account.ts
26
26
  import { Address as Address3 } from "@fuel-ts/address";
27
- import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
28
27
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
29
28
  import { AbstractAccount } from "@fuel-ts/interfaces";
30
- import { bn as bn18 } from "@fuel-ts/math";
29
+ import { bn as bn17 } from "@fuel-ts/math";
31
30
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
32
- import { clone as clone4 } from "ramda";
33
31
 
34
32
  // src/providers/coin-quantity.ts
35
- import { BaseAssetId } from "@fuel-ts/address/configs";
36
33
  import { bn } from "@fuel-ts/math";
37
34
  import { hexlify } from "@fuel-ts/utils";
38
35
  var coinQuantityfy = (coinQuantityLike) => {
39
36
  let assetId;
40
37
  let amount;
41
- let max;
38
+ let max2;
42
39
  if (Array.isArray(coinQuantityLike)) {
43
40
  amount = coinQuantityLike[0];
44
- assetId = coinQuantityLike[1] ?? BaseAssetId;
45
- max = coinQuantityLike[2] ?? void 0;
41
+ assetId = coinQuantityLike[1];
42
+ max2 = coinQuantityLike[2];
46
43
  } else {
47
44
  amount = coinQuantityLike.amount;
48
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
49
- max = coinQuantityLike.max ?? void 0;
45
+ assetId = coinQuantityLike.assetId;
46
+ max2 = coinQuantityLike.max ?? void 0;
50
47
  }
51
48
  const bnAmount = bn(amount);
52
49
  return {
53
50
  assetId: hexlify(assetId),
54
51
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
55
- max: max ? bn(max) : void 0
52
+ max: max2 ? bn(max2) : void 0
56
53
  };
57
54
  };
58
- var addAmountToCoinQuantities = (params) => {
55
+ var addAmountToAsset = (params) => {
59
56
  const { amount, assetId } = params;
60
57
  const coinQuantities = [...params.coinQuantities];
61
58
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -70,9 +67,9 @@ var addAmountToCoinQuantities = (params) => {
70
67
  // src/providers/provider.ts
71
68
  import { Address as Address2 } from "@fuel-ts/address";
72
69
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
73
- import { BN, bn as bn16 } from "@fuel-ts/math";
70
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
74
71
  import {
75
- InputType as InputType7,
72
+ InputType as InputType6,
76
73
  TransactionType as TransactionType8,
77
74
  InputMessageCoder,
78
75
  TransactionCoder as TransactionCoder5
@@ -88,10 +85,14 @@ import { clone as clone3 } from "ramda";
88
85
  import gql from "graphql-tag";
89
86
  var ReceiptFragmentFragmentDoc = gql`
90
87
  fragment receiptFragment on Receipt {
91
- id
88
+ contract {
89
+ id
90
+ }
92
91
  pc
93
92
  is
94
- to
93
+ to {
94
+ id
95
+ }
95
96
  toAddress
96
97
  amount
97
98
  assetId
@@ -129,16 +130,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
129
130
  id
130
131
  }
131
132
  time
132
- receipts {
133
- ...receiptFragment
134
- }
135
133
  programState {
136
134
  returnType
137
135
  data
138
136
  }
139
- receipts {
140
- ...receiptFragment
141
- }
142
137
  }
143
138
  ... on FailureStatus {
144
139
  block {
@@ -146,24 +141,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
146
141
  }
147
142
  time
148
143
  reason
149
- receipts {
150
- ...receiptFragment
151
- }
152
144
  }
153
145
  ... on SqueezedOutStatus {
154
146
  reason
155
147
  }
156
148
  }
157
- ${ReceiptFragmentFragmentDoc}`;
149
+ `;
158
150
  var TransactionFragmentFragmentDoc = gql`
159
151
  fragment transactionFragment on Transaction {
160
152
  id
161
153
  rawPayload
154
+ gasPrice
155
+ receipts {
156
+ ...receiptFragment
157
+ }
162
158
  status {
163
159
  ...transactionStatusFragment
164
160
  }
165
161
  }
166
- ${TransactionStatusFragmentFragmentDoc}`;
162
+ ${ReceiptFragmentFragmentDoc}
163
+ ${TransactionStatusFragmentFragmentDoc}`;
167
164
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
168
165
  fragment inputEstimatePredicatesFragment on Input {
169
166
  ... on InputCoin {
@@ -181,46 +178,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
181
178
  }
182
179
  }
183
180
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
184
- var DryRunFailureStatusFragmentFragmentDoc = gql`
185
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
186
- reason
187
- programState {
188
- returnType
189
- data
190
- }
191
- }
192
- `;
193
- var DryRunSuccessStatusFragmentFragmentDoc = gql`
194
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
195
- programState {
196
- returnType
197
- data
198
- }
199
- }
200
- `;
201
- var DryRunTransactionStatusFragmentFragmentDoc = gql`
202
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
203
- ... on DryRunFailureStatus {
204
- ...dryRunFailureStatusFragment
205
- }
206
- ... on DryRunSuccessStatus {
207
- ...dryRunSuccessStatusFragment
208
- }
209
- }
210
- ${DryRunFailureStatusFragmentFragmentDoc}
211
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
212
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
213
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
214
- id
215
- status {
216
- ...dryRunTransactionStatusFragment
217
- }
218
- receipts {
219
- ...receiptFragment
220
- }
221
- }
222
- ${DryRunTransactionStatusFragmentFragmentDoc}
223
- ${ReceiptFragmentFragmentDoc}`;
224
181
  var CoinFragmentFragmentDoc = gql`
225
182
  fragment coinFragment on Coin {
226
183
  __typename
@@ -228,6 +185,7 @@ var CoinFragmentFragmentDoc = gql`
228
185
  owner
229
186
  amount
230
187
  assetId
188
+ maturity
231
189
  blockCreated
232
190
  txCreatedIdx
233
191
  }
@@ -272,6 +230,7 @@ var MessageProofFragmentFragmentDoc = gql`
272
230
  prevRoot
273
231
  time
274
232
  applicationHash
233
+ messageReceiptRoot
275
234
  messageReceiptCount
276
235
  }
277
236
  commitBlockHeader {
@@ -283,6 +242,7 @@ var MessageProofFragmentFragmentDoc = gql`
283
242
  prevRoot
284
243
  time
285
244
  applicationHash
245
+ messageReceiptRoot
286
246
  messageReceiptCount
287
247
  }
288
248
  sender
@@ -302,8 +262,8 @@ var BalanceFragmentFragmentDoc = gql`
302
262
  var BlockFragmentFragmentDoc = gql`
303
263
  fragment blockFragment on Block {
304
264
  id
305
- height
306
265
  header {
266
+ height
307
267
  time
308
268
  }
309
269
  transactions {
@@ -361,11 +321,6 @@ var DependentCostFragmentFragmentDoc = gql`
361
321
  `;
362
322
  var GasCostsFragmentFragmentDoc = gql`
363
323
  fragment GasCostsFragment on GasCosts {
364
- version {
365
- ... on Version {
366
- value
367
- }
368
- }
369
324
  add
370
325
  addi
371
326
  aloc
@@ -378,6 +333,7 @@ var GasCostsFragmentFragmentDoc = gql`
378
333
  cb
379
334
  cfei
380
335
  cfsi
336
+ croo
381
337
  div
382
338
  divi
383
339
  ecr1
@@ -460,9 +416,6 @@ var GasCostsFragmentFragmentDoc = gql`
460
416
  ccp {
461
417
  ...DependentCostFragment
462
418
  }
463
- croo {
464
- ...DependentCostFragment
465
- }
466
419
  csiz {
467
420
  ...DependentCostFragment
468
421
  }
@@ -522,11 +475,6 @@ var GasCostsFragmentFragmentDoc = gql`
522
475
  ${DependentCostFragmentFragmentDoc}`;
523
476
  var ConsensusParametersFragmentFragmentDoc = gql`
524
477
  fragment consensusParametersFragment on ConsensusParameters {
525
- version {
526
- ... on Version {
527
- value
528
- }
529
- }
530
478
  txParams {
531
479
  ...TxParametersFragment
532
480
  }
@@ -586,9 +534,18 @@ var NodeInfoFragmentFragmentDoc = gql`
586
534
  fragment nodeInfoFragment on NodeInfo {
587
535
  utxoValidation
588
536
  vmBacktrace
537
+ minGasPrice
589
538
  maxTx
590
539
  maxDepth
591
540
  nodeVersion
541
+ peers {
542
+ id
543
+ addresses
544
+ clientVersion
545
+ blockHeight
546
+ lastHeartbeatMs
547
+ appScore
548
+ }
592
549
  }
593
550
  `;
594
551
  var GetVersionDocument = gql`
@@ -623,9 +580,13 @@ var GetTransactionWithReceiptsDocument = gql`
623
580
  query getTransactionWithReceipts($transactionId: TransactionId!) {
624
581
  transaction(id: $transactionId) {
625
582
  ...transactionFragment
583
+ receipts {
584
+ ...receiptFragment
585
+ }
626
586
  }
627
587
  }
628
- ${TransactionFragmentFragmentDoc}`;
588
+ ${TransactionFragmentFragmentDoc}
589
+ ${ReceiptFragmentFragmentDoc}`;
629
590
  var GetTransactionsDocument = gql`
630
591
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
631
592
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -753,20 +714,6 @@ var GetBalanceDocument = gql`
753
714
  }
754
715
  }
755
716
  ${BalanceFragmentFragmentDoc}`;
756
- var GetLatestGasPriceDocument = gql`
757
- query getLatestGasPrice {
758
- latestGasPrice {
759
- gasPrice
760
- }
761
- }
762
- `;
763
- var EstimateGasPriceDocument = gql`
764
- query estimateGasPrice($blockHorizon: U32!) {
765
- estimateGasPrice(blockHorizon: $blockHorizon) {
766
- gasPrice
767
- }
768
- }
769
- `;
770
717
  var GetBalancesDocument = gql`
771
718
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
772
719
  balances(
@@ -821,12 +768,12 @@ var GetMessageStatusDocument = gql`
821
768
  }
822
769
  `;
823
770
  var DryRunDocument = gql`
824
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
825
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
826
- ...dryRunTransactionExecutionStatusFragment
771
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
772
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
773
+ ...receiptFragment
827
774
  }
828
775
  }
829
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
776
+ ${ReceiptFragmentFragmentDoc}`;
830
777
  var SubmitDocument = gql`
831
778
  mutation submit($encodedTransaction: HexString!) {
832
779
  submit(tx: $encodedTransaction) {
@@ -909,12 +856,6 @@ function getSdk(requester) {
909
856
  getBalance(variables, options) {
910
857
  return requester(GetBalanceDocument, variables, options);
911
858
  },
912
- getLatestGasPrice(variables, options) {
913
- return requester(GetLatestGasPriceDocument, variables, options);
914
- },
915
- estimateGasPrice(variables, options) {
916
- return requester(EstimateGasPriceDocument, variables, options);
917
- },
918
859
  getBalances(variables, options) {
919
860
  return requester(GetBalancesDocument, variables, options);
920
861
  },
@@ -984,14 +925,11 @@ var _FuelGraphqlSubscriber = class {
984
925
  let data;
985
926
  let errors;
986
927
  try {
987
- const sanitizedText = text.replace(/\s/g, "");
988
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
928
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
989
929
  } catch (e) {
990
930
  throw new FuelError(
991
931
  ErrorCode.STREAM_PARSING_ERROR,
992
- `Error while parsing stream data response: ${text}
993
-
994
- Thrown error: ${e}`
932
+ `Error while parsing stream data response: ${text}`
995
933
  );
996
934
  }
997
935
  if (Array.isArray(errors)) {
@@ -1092,7 +1030,7 @@ var inputify = (value) => {
1092
1030
  return {
1093
1031
  type: InputType.Coin,
1094
1032
  txID: hexlify3(arrayify(value.id).slice(0, 32)),
1095
- outputIndex: toNumber(arrayify(value.id).slice(32, 34)),
1033
+ outputIndex: arrayify(value.id)[32],
1096
1034
  owner: hexlify3(value.owner),
1097
1035
  amount: bn2(value.amount),
1098
1036
  assetId: hexlify3(value.assetId),
@@ -1101,9 +1039,10 @@ var inputify = (value) => {
1101
1039
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1102
1040
  },
1103
1041
  witnessIndex: value.witnessIndex,
1042
+ maturity: value.maturity ?? 0,
1104
1043
  predicateGasUsed: bn2(value.predicateGasUsed),
1105
- predicateLength: bn2(predicate.length),
1106
- predicateDataLength: bn2(predicateData.length),
1044
+ predicateLength: predicate.length,
1045
+ predicateDataLength: predicateData.length,
1107
1046
  predicate: hexlify3(predicate),
1108
1047
  predicateData: hexlify3(predicateData)
1109
1048
  };
@@ -1134,8 +1073,8 @@ var inputify = (value) => {
1134
1073
  nonce: hexlify3(value.nonce),
1135
1074
  witnessIndex: value.witnessIndex,
1136
1075
  predicateGasUsed: bn2(value.predicateGasUsed),
1137
- predicateLength: bn2(predicate.length),
1138
- predicateDataLength: bn2(predicateData.length),
1076
+ predicateLength: predicate.length,
1077
+ predicateDataLength: predicateData.length,
1139
1078
  predicate: hexlify3(predicate),
1140
1079
  predicateData: hexlify3(predicateData),
1141
1080
  data: hexlify3(data),
@@ -1210,7 +1149,7 @@ var outputify = (value) => {
1210
1149
 
1211
1150
  // src/providers/transaction-request/transaction-request.ts
1212
1151
  import { Address, addressify } from "@fuel-ts/address";
1213
- import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1152
+ import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1214
1153
  import { bn as bn7 } from "@fuel-ts/math";
1215
1154
  import {
1216
1155
  PolicyType,
@@ -1220,7 +1159,6 @@ import {
1220
1159
  TransactionType
1221
1160
  } from "@fuel-ts/transactions";
1222
1161
  import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1223
- import { randomBytes } from "ethers";
1224
1162
 
1225
1163
  // src/providers/resource.ts
1226
1164
  var isCoin = (resource) => "id" in resource;
@@ -1261,8 +1199,8 @@ function assembleReceiptByType(receipt) {
1261
1199
  case "CALL" /* Call */: {
1262
1200
  const callReceipt = {
1263
1201
  type: ReceiptType.Call,
1264
- from: hexOrZero(receipt.id || receipt.contractId),
1265
- to: hexOrZero(receipt?.to),
1202
+ from: hexOrZero(receipt.contract?.id),
1203
+ to: hexOrZero(receipt?.to?.id),
1266
1204
  amount: bn4(receipt.amount),
1267
1205
  assetId: hexOrZero(receipt.assetId),
1268
1206
  gas: bn4(receipt.gas),
@@ -1276,7 +1214,7 @@ function assembleReceiptByType(receipt) {
1276
1214
  case "RETURN" /* Return */: {
1277
1215
  const returnReceipt = {
1278
1216
  type: ReceiptType.Return,
1279
- id: hexOrZero(receipt.id || receipt.contractId),
1217
+ id: hexOrZero(receipt.contract?.id),
1280
1218
  val: bn4(receipt.val),
1281
1219
  pc: bn4(receipt.pc),
1282
1220
  is: bn4(receipt.is)
@@ -1286,7 +1224,7 @@ function assembleReceiptByType(receipt) {
1286
1224
  case "RETURN_DATA" /* ReturnData */: {
1287
1225
  const returnDataReceipt = {
1288
1226
  type: ReceiptType.ReturnData,
1289
- id: hexOrZero(receipt.id || receipt.contractId),
1227
+ id: hexOrZero(receipt.contract?.id),
1290
1228
  ptr: bn4(receipt.ptr),
1291
1229
  len: bn4(receipt.len),
1292
1230
  digest: hexOrZero(receipt.digest),
@@ -1298,7 +1236,7 @@ function assembleReceiptByType(receipt) {
1298
1236
  case "PANIC" /* Panic */: {
1299
1237
  const panicReceipt = {
1300
1238
  type: ReceiptType.Panic,
1301
- id: hexOrZero(receipt.id),
1239
+ id: hexOrZero(receipt.contract?.id),
1302
1240
  reason: bn4(receipt.reason),
1303
1241
  pc: bn4(receipt.pc),
1304
1242
  is: bn4(receipt.is),
@@ -1309,7 +1247,7 @@ function assembleReceiptByType(receipt) {
1309
1247
  case "REVERT" /* Revert */: {
1310
1248
  const revertReceipt = {
1311
1249
  type: ReceiptType.Revert,
1312
- id: hexOrZero(receipt.id || receipt.contractId),
1250
+ id: hexOrZero(receipt.contract?.id),
1313
1251
  val: bn4(receipt.ra),
1314
1252
  pc: bn4(receipt.pc),
1315
1253
  is: bn4(receipt.is)
@@ -1319,7 +1257,7 @@ function assembleReceiptByType(receipt) {
1319
1257
  case "LOG" /* Log */: {
1320
1258
  const logReceipt = {
1321
1259
  type: ReceiptType.Log,
1322
- id: hexOrZero(receipt.id || receipt.contractId),
1260
+ id: hexOrZero(receipt.contract?.id),
1323
1261
  val0: bn4(receipt.ra),
1324
1262
  val1: bn4(receipt.rb),
1325
1263
  val2: bn4(receipt.rc),
@@ -1332,7 +1270,7 @@ function assembleReceiptByType(receipt) {
1332
1270
  case "LOG_DATA" /* LogData */: {
1333
1271
  const logDataReceipt = {
1334
1272
  type: ReceiptType.LogData,
1335
- id: hexOrZero(receipt.id || receipt.contractId),
1273
+ id: hexOrZero(receipt.contract?.id),
1336
1274
  val0: bn4(receipt.ra),
1337
1275
  val1: bn4(receipt.rb),
1338
1276
  ptr: bn4(receipt.ptr),
@@ -1346,8 +1284,8 @@ function assembleReceiptByType(receipt) {
1346
1284
  case "TRANSFER" /* Transfer */: {
1347
1285
  const transferReceipt = {
1348
1286
  type: ReceiptType.Transfer,
1349
- from: hexOrZero(receipt.id || receipt.contractId),
1350
- to: hexOrZero(receipt.toAddress || receipt?.to),
1287
+ from: hexOrZero(receipt.contract?.id),
1288
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1351
1289
  amount: bn4(receipt.amount),
1352
1290
  assetId: hexOrZero(receipt.assetId),
1353
1291
  pc: bn4(receipt.pc),
@@ -1358,8 +1296,8 @@ function assembleReceiptByType(receipt) {
1358
1296
  case "TRANSFER_OUT" /* TransferOut */: {
1359
1297
  const transferOutReceipt = {
1360
1298
  type: ReceiptType.TransferOut,
1361
- from: hexOrZero(receipt.id || receipt.contractId),
1362
- to: hexOrZero(receipt.toAddress || receipt.to),
1299
+ from: hexOrZero(receipt.contract?.id),
1300
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1363
1301
  amount: bn4(receipt.amount),
1364
1302
  assetId: hexOrZero(receipt.assetId),
1365
1303
  pc: bn4(receipt.pc),
@@ -1402,7 +1340,7 @@ function assembleReceiptByType(receipt) {
1402
1340
  return receiptMessageOut;
1403
1341
  }
1404
1342
  case "MINT" /* Mint */: {
1405
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1343
+ const contractId = hexOrZero(receipt.contract?.id);
1406
1344
  const subId = hexOrZero(receipt.subId);
1407
1345
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1408
1346
  const mintReceipt = {
@@ -1417,7 +1355,7 @@ function assembleReceiptByType(receipt) {
1417
1355
  return mintReceipt;
1418
1356
  }
1419
1357
  case "BURN" /* Burn */: {
1420
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1358
+ const contractId = hexOrZero(receipt.contract?.id);
1421
1359
  const subId = hexOrZero(receipt.subId);
1422
1360
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1423
1361
  const burnReceipt = {
@@ -1443,6 +1381,7 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
1443
1381
  import { bn as bn5 } from "@fuel-ts/math";
1444
1382
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1445
1383
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1384
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1446
1385
  var getGasUsedFromReceipts = (receipts) => {
1447
1386
  const scriptResult = receipts.filter(
1448
1387
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1463,28 +1402,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1463
1402
  }
1464
1403
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1465
1404
  const witnessCache = [];
1466
- const chargeableInputs = inputs.filter((input) => {
1467
- const isCoinOrMessage = "owner" in input || "sender" in input;
1468
- if (isCoinOrMessage) {
1469
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1470
- return true;
1471
- }
1472
- if (!witnessCache.includes(input.witnessIndex)) {
1473
- witnessCache.push(input.witnessIndex);
1474
- return true;
1475
- }
1476
- }
1477
- return false;
1478
- });
1479
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1480
- const totalGas = chargeableInputs.reduce((total, input) => {
1405
+ const totalGas = inputs.reduce((total, input) => {
1481
1406
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1482
1407
  return total.add(
1483
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1408
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1484
1409
  );
1485
1410
  }
1486
- return total.add(gasCosts.ecr1);
1487
- }, bn5(0));
1411
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1412
+ witnessCache.push(input.witnessIndex);
1413
+ return total.add(gasCosts.ecr1);
1414
+ }
1415
+ return total;
1416
+ }, bn5());
1488
1417
  return totalGas;
1489
1418
  }
1490
1419
  function getMinGas(params) {
@@ -1496,20 +1425,12 @@ function getMinGas(params) {
1496
1425
  return minGas;
1497
1426
  }
1498
1427
  function getMaxGas(params) {
1499
- const {
1500
- gasPerByte,
1501
- witnessesLength,
1502
- witnessLimit,
1503
- minGas,
1504
- gasLimit = bn5(0),
1505
- maxGasPerTx
1506
- } = params;
1428
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1507
1429
  let remainingAllowedWitnessGas = bn5(0);
1508
1430
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1509
1431
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1510
1432
  }
1511
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1512
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1433
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1513
1434
  }
1514
1435
  function calculateMetadataGasForTxCreate({
1515
1436
  gasCosts,
@@ -1531,10 +1452,6 @@ function calculateMetadataGasForTxScript({
1531
1452
  }) {
1532
1453
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1533
1454
  }
1534
- var calculateGasFee = (params) => {
1535
- const { gas, gasPrice, priceFactor, tip } = params;
1536
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1537
- };
1538
1455
 
1539
1456
  // src/providers/utils/json.ts
1540
1457
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1679,7 +1596,7 @@ var witnessify = (value) => {
1679
1596
  // src/providers/transaction-request/transaction-request.ts
1680
1597
  var BaseTransactionRequest = class {
1681
1598
  /** Gas price for transaction */
1682
- tip;
1599
+ gasPrice;
1683
1600
  /** Block until which tx cannot be included */
1684
1601
  maturity;
1685
1602
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1692,34 +1609,38 @@ var BaseTransactionRequest = class {
1692
1609
  outputs = [];
1693
1610
  /** List of witnesses */
1694
1611
  witnesses = [];
1612
+ /** Base asset ID - should be fetched from the chain */
1613
+ baseAssetId = ZeroBytes324;
1695
1614
  /**
1696
1615
  * Constructor for initializing a base transaction request.
1697
1616
  *
1698
1617
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1699
1618
  */
1700
1619
  constructor({
1701
- tip,
1620
+ gasPrice,
1702
1621
  maturity,
1703
1622
  maxFee,
1704
1623
  witnessLimit,
1705
1624
  inputs,
1706
1625
  outputs,
1707
- witnesses
1626
+ witnesses,
1627
+ baseAssetId
1708
1628
  } = {}) {
1709
- this.tip = bn7(tip);
1629
+ this.gasPrice = bn7(gasPrice);
1710
1630
  this.maturity = maturity ?? 0;
1711
1631
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1712
1632
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
1713
1633
  this.inputs = inputs ?? [];
1714
1634
  this.outputs = outputs ?? [];
1715
1635
  this.witnesses = witnesses ?? [];
1636
+ this.baseAssetId = baseAssetId ?? ZeroBytes324;
1716
1637
  }
1717
1638
  static getPolicyMeta(req) {
1718
1639
  let policyTypes = 0;
1719
1640
  const policies = [];
1720
- if (req.tip) {
1721
- policyTypes += PolicyType.Tip;
1722
- policies.push({ data: req.tip, type: PolicyType.Tip });
1641
+ if (req.gasPrice) {
1642
+ policyTypes += PolicyType.GasPrice;
1643
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1723
1644
  }
1724
1645
  if (req.witnessLimit) {
1725
1646
  policyTypes += PolicyType.WitnessLimit;
@@ -1906,10 +1827,10 @@ var BaseTransactionRequest = class {
1906
1827
  * @param predicate - Predicate bytes.
1907
1828
  * @param predicateData - Predicate data bytes.
1908
1829
  */
1909
- addCoinInput(coin) {
1830
+ addCoinInput(coin, predicate) {
1910
1831
  const { assetId, owner, amount } = coin;
1911
1832
  let witnessIndex;
1912
- if (coin.predicate) {
1833
+ if (predicate) {
1913
1834
  witnessIndex = 0;
1914
1835
  } else {
1915
1836
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1924,7 +1845,9 @@ var BaseTransactionRequest = class {
1924
1845
  amount,
1925
1846
  assetId,
1926
1847
  txPointer: "0x00000000000000000000000000000000",
1927
- witnessIndex
1848
+ witnessIndex,
1849
+ predicate: predicate?.bytes,
1850
+ predicateData: predicate?.predicateDataBytes
1928
1851
  };
1929
1852
  this.pushInput(input);
1930
1853
  this.addChangeOutput(owner, assetId);
@@ -1935,13 +1858,11 @@ var BaseTransactionRequest = class {
1935
1858
  *
1936
1859
  * @param message - Message resource.
1937
1860
  * @param predicate - Predicate bytes.
1938
- * @param predicateData - Predicate data bytes.
1939
1861
  */
1940
- addMessageInput(message) {
1862
+ addMessageInput(message, predicate) {
1941
1863
  const { recipient, sender, amount } = message;
1942
- const assetId = BaseAssetId2;
1943
1864
  let witnessIndex;
1944
- if (message.predicate) {
1865
+ if (predicate) {
1945
1866
  witnessIndex = 0;
1946
1867
  } else {
1947
1868
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1955,10 +1876,12 @@ var BaseTransactionRequest = class {
1955
1876
  sender: sender.toB256(),
1956
1877
  recipient: recipient.toB256(),
1957
1878
  amount,
1958
- witnessIndex
1879
+ witnessIndex,
1880
+ predicate: predicate?.bytes,
1881
+ predicateData: predicate?.predicateDataBytes
1959
1882
  };
1960
1883
  this.pushInput(input);
1961
- this.addChangeOutput(recipient, assetId);
1884
+ this.addChangeOutput(recipient, this.baseAssetId);
1962
1885
  }
1963
1886
  /**
1964
1887
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -1986,6 +1909,32 @@ var BaseTransactionRequest = class {
1986
1909
  resources.forEach((resource) => this.addResource(resource));
1987
1910
  return this;
1988
1911
  }
1912
+ /**
1913
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1914
+ * outputs from the related assetIds.
1915
+ *
1916
+ * @param resources - The resources to add.
1917
+ * @returns This transaction.
1918
+ */
1919
+ addPredicateResource(resource, predicate) {
1920
+ if (isCoin(resource)) {
1921
+ this.addCoinInput(resource, predicate);
1922
+ } else {
1923
+ this.addMessageInput(resource, predicate);
1924
+ }
1925
+ return this;
1926
+ }
1927
+ /**
1928
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
1929
+ * from the related assetIds.
1930
+ *
1931
+ * @param resources - The resources to add.
1932
+ * @returns This transaction.
1933
+ */
1934
+ addPredicateResources(resources, predicate) {
1935
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1936
+ return this;
1937
+ }
1989
1938
  /**
1990
1939
  * Adds a coin output to the transaction.
1991
1940
  *
@@ -1993,12 +1942,12 @@ var BaseTransactionRequest = class {
1993
1942
  * @param amount - Amount of coin.
1994
1943
  * @param assetId - Asset ID of coin.
1995
1944
  */
1996
- addCoinOutput(to, amount, assetId = BaseAssetId2) {
1945
+ addCoinOutput(to, amount, assetId) {
1997
1946
  this.pushOutput({
1998
1947
  type: OutputType2.Coin,
1999
1948
  to: addressify(to).toB256(),
2000
1949
  amount,
2001
- assetId
1950
+ assetId: assetId ?? this.baseAssetId
2002
1951
  });
2003
1952
  return this;
2004
1953
  }
@@ -2025,7 +1974,7 @@ var BaseTransactionRequest = class {
2025
1974
  * @param to - Address of the owner.
2026
1975
  * @param assetId - Asset ID of coin.
2027
1976
  */
2028
- addChangeOutput(to, assetId = BaseAssetId2) {
1977
+ addChangeOutput(to, assetId) {
2029
1978
  const changeOutput = this.getChangeOutputs().find(
2030
1979
  (output) => hexlify7(output.assetId) === assetId
2031
1980
  );
@@ -2033,7 +1982,7 @@ var BaseTransactionRequest = class {
2033
1982
  this.pushOutput({
2034
1983
  type: OutputType2.Change,
2035
1984
  to: addressify(to).toB256(),
2036
- assetId
1985
+ assetId: assetId ?? this.baseAssetId
2037
1986
  });
2038
1987
  }
2039
1988
  }
@@ -2065,7 +2014,7 @@ var BaseTransactionRequest = class {
2065
2014
  }
2066
2015
  calculateMaxGas(chainInfo, minGas) {
2067
2016
  const { consensusParameters } = chainInfo;
2068
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2017
+ const { gasPerByte } = consensusParameters;
2069
2018
  const witnessesLength = this.toTransaction().witnesses.reduce(
2070
2019
  (acc, wit) => acc + wit.dataLength,
2071
2020
  0
@@ -2074,8 +2023,7 @@ var BaseTransactionRequest = class {
2074
2023
  gasPerByte,
2075
2024
  minGas,
2076
2025
  witnessesLength,
2077
- witnessLimit: this.witnessLimit,
2078
- maxGasPerTx
2026
+ witnessLimit: this.witnessLimit
2079
2027
  });
2080
2028
  }
2081
2029
  /**
@@ -2085,6 +2033,12 @@ var BaseTransactionRequest = class {
2085
2033
  * @param quantities - CoinQuantity Array.
2086
2034
  */
2087
2035
  fundWithFakeUtxos(quantities, resourcesOwner) {
2036
+ let idCounter = 0;
2037
+ const generateId = () => {
2038
+ const counterString = String(idCounter++);
2039
+ const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
2040
+ return id;
2041
+ };
2088
2042
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2089
2043
  if ("assetId" in input) {
2090
2044
  return input.assetId === assetId;
@@ -2093,27 +2047,24 @@ var BaseTransactionRequest = class {
2093
2047
  });
2094
2048
  const updateAssetInput = (assetId, quantity) => {
2095
2049
  const assetInput = findAssetInput(assetId);
2096
- let usedQuantity = quantity;
2097
- if (assetId === BaseAssetId2) {
2098
- usedQuantity = bn7("1000000000000000000");
2099
- }
2100
2050
  if (assetInput && "assetId" in assetInput) {
2101
- assetInput.id = hexlify7(randomBytes(34));
2102
- assetInput.amount = usedQuantity;
2051
+ assetInput.id = generateId();
2052
+ assetInput.amount = quantity;
2103
2053
  } else {
2104
2054
  this.addResources([
2105
2055
  {
2106
- id: hexlify7(randomBytes(34)),
2107
- amount: usedQuantity,
2056
+ id: generateId(),
2057
+ amount: quantity,
2108
2058
  assetId,
2109
2059
  owner: resourcesOwner || Address.fromRandom(),
2060
+ maturity: 0,
2110
2061
  blockCreated: bn7(1),
2111
2062
  txCreatedIdx: bn7(1)
2112
2063
  }
2113
2064
  ]);
2114
2065
  }
2115
2066
  };
2116
- updateAssetInput(BaseAssetId2, bn7(1e11));
2067
+ updateAssetInput(this.baseAssetId, bn7(1e11));
2117
2068
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2118
2069
  }
2119
2070
  /**
@@ -2138,7 +2089,7 @@ var BaseTransactionRequest = class {
2138
2089
  toJSON() {
2139
2090
  return normalizeJSON(this);
2140
2091
  }
2141
- updatePredicateGasUsed(inputs) {
2092
+ updatePredicateInputs(inputs) {
2142
2093
  this.inputs.forEach((i) => {
2143
2094
  let correspondingInput;
2144
2095
  switch (i.type) {
@@ -2160,15 +2111,6 @@ var BaseTransactionRequest = class {
2160
2111
  }
2161
2112
  });
2162
2113
  }
2163
- shiftPredicateData() {
2164
- this.inputs.forEach((input) => {
2165
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2166
- input.predicateData = input.paddPredicateData(
2167
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2168
- );
2169
- }
2170
- });
2171
- }
2172
2114
  };
2173
2115
 
2174
2116
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2315,8 +2257,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2315
2257
  return {
2316
2258
  type: TransactionType3.Create,
2317
2259
  ...baseTransaction,
2260
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2318
2261
  bytecodeWitnessIndex,
2319
- storageSlotsCount: bn9(storageSlots.length),
2262
+ storageSlotsCount: storageSlots.length,
2320
2263
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2321
2264
  storageSlots
2322
2265
  };
@@ -2439,8 +2382,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2439
2382
  type: TransactionType4.Script,
2440
2383
  scriptGasLimit: this.gasLimit,
2441
2384
  ...super.getBaseTransaction(),
2442
- scriptLength: bn10(script.length),
2443
- scriptDataLength: bn10(scriptData.length),
2385
+ scriptLength: script.length,
2386
+ scriptDataLength: scriptData.length,
2444
2387
  receiptsRoot: ZeroBytes327,
2445
2388
  script: hexlify10(script),
2446
2389
  scriptData: hexlify10(scriptData)
@@ -2504,7 +2447,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2504
2447
  }
2505
2448
  calculateMaxGas(chainInfo, minGas) {
2506
2449
  const { consensusParameters } = chainInfo;
2507
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2450
+ const { gasPerByte } = consensusParameters;
2508
2451
  const witnessesLength = this.toTransaction().witnesses.reduce(
2509
2452
  (acc, wit) => acc + wit.dataLength,
2510
2453
  0
@@ -2514,8 +2457,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2514
2457
  minGas,
2515
2458
  witnessesLength,
2516
2459
  witnessLimit: this.witnessLimit,
2517
- gasLimit: this.gasLimit,
2518
- maxGasPerTx
2460
+ gasLimit: this.gasLimit
2519
2461
  });
2520
2462
  }
2521
2463
  /**
@@ -2572,7 +2514,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2572
2514
 
2573
2515
  // src/providers/transaction-request/utils.ts
2574
2516
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2575
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2517
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2576
2518
  var transactionRequestify = (obj) => {
2577
2519
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2578
2520
  return obj;
@@ -2590,31 +2532,14 @@ var transactionRequestify = (obj) => {
2590
2532
  }
2591
2533
  }
2592
2534
  };
2593
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2594
- (acc, input) => {
2595
- if (input.type === InputType5.Coin && input.owner === owner) {
2596
- acc.utxos.push(input.id);
2597
- }
2598
- if (input.type === InputType5.Message && input.recipient === owner) {
2599
- acc.messages.push(input.nonce);
2600
- }
2601
- return acc;
2602
- },
2603
- {
2604
- utxos: [],
2605
- messages: []
2606
- }
2607
- );
2608
2535
 
2609
2536
  // src/providers/transaction-response/transaction-response.ts
2610
2537
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2611
- import { bn as bn15 } from "@fuel-ts/math";
2538
+ import { bn as bn14 } from "@fuel-ts/math";
2612
2539
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2613
2540
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2614
2541
 
2615
2542
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2616
- import { bn as bn14 } from "@fuel-ts/math";
2617
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2618
2543
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2619
2544
 
2620
2545
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2623,10 +2548,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2623
2548
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2624
2549
  var calculateTransactionFee = (params) => {
2625
2550
  const {
2626
- gasPrice,
2551
+ gasUsed,
2627
2552
  rawPayload,
2628
- tip,
2629
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2553
+ consensusParameters: { gasCosts, feeParams }
2630
2554
  } = params;
2631
2555
  const gasPerByte = bn11(feeParams.gasPerByte);
2632
2556
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2636,7 +2560,8 @@ var calculateTransactionFee = (params) => {
2636
2560
  return {
2637
2561
  fee: bn11(0),
2638
2562
  minFee: bn11(0),
2639
- maxFee: bn11(0)
2563
+ maxFee: bn11(0),
2564
+ feeFromGasUsed: bn11(0)
2640
2565
  };
2641
2566
  }
2642
2567
  const { type, witnesses, inputs, policies } = transaction;
@@ -2668,6 +2593,7 @@ var calculateTransactionFee = (params) => {
2668
2593
  metadataGas,
2669
2594
  txBytesSize: transactionBytes.length
2670
2595
  });
2596
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2671
2597
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2672
2598
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2673
2599
  const maxGas = getMaxGas({
@@ -2675,25 +2601,17 @@ var calculateTransactionFee = (params) => {
2675
2601
  minGas,
2676
2602
  witnessesLength,
2677
2603
  gasLimit,
2678
- witnessLimit,
2679
- maxGasPerTx
2680
- });
2681
- const minFee = calculateGasFee({
2682
- gasPrice,
2683
- gas: minGas,
2684
- priceFactor: gasPriceFactor,
2685
- tip
2686
- });
2687
- const maxFee = calculateGasFee({
2688
- gasPrice,
2689
- gas: maxGas,
2690
- priceFactor: gasPriceFactor,
2691
- tip
2604
+ witnessLimit
2692
2605
  });
2606
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2607
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2608
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2609
+ const fee = minFee.add(feeFromGasUsed);
2693
2610
  return {
2611
+ fee,
2694
2612
  minFee,
2695
2613
  maxFee,
2696
- fee: maxFee
2614
+ feeFromGasUsed
2697
2615
  };
2698
2616
  };
2699
2617
 
@@ -2749,7 +2667,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2749
2667
 
2750
2668
  // src/providers/transaction-summary/input.ts
2751
2669
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2752
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2670
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2753
2671
  function getInputsByTypes(inputs, types) {
2754
2672
  return inputs.filter((i) => types.includes(i.type));
2755
2673
  }
@@ -2757,16 +2675,16 @@ function getInputsByType(inputs, type) {
2757
2675
  return inputs.filter((i) => i.type === type);
2758
2676
  }
2759
2677
  function getInputsCoin(inputs) {
2760
- return getInputsByType(inputs, InputType6.Coin);
2678
+ return getInputsByType(inputs, InputType5.Coin);
2761
2679
  }
2762
2680
  function getInputsMessage(inputs) {
2763
- return getInputsByType(inputs, InputType6.Message);
2681
+ return getInputsByType(inputs, InputType5.Message);
2764
2682
  }
2765
2683
  function getInputsCoinAndMessage(inputs) {
2766
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2684
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2767
2685
  }
2768
2686
  function getInputsContract(inputs) {
2769
- return getInputsByType(inputs, InputType6.Contract);
2687
+ return getInputsByType(inputs, InputType5.Contract);
2770
2688
  }
2771
2689
  function getInputFromAssetId(inputs, assetId) {
2772
2690
  const coinInputs = getInputsCoin(inputs);
@@ -2785,7 +2703,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2785
2703
  if (!contractInput) {
2786
2704
  return void 0;
2787
2705
  }
2788
- if (contractInput.type !== InputType6.Contract) {
2706
+ if (contractInput.type !== InputType5.Contract) {
2789
2707
  throw new FuelError9(
2790
2708
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2791
2709
  `Contract input should be of type 'contract'.`
@@ -2794,10 +2712,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2794
2712
  return contractInput;
2795
2713
  }
2796
2714
  function getInputAccountAddress(input) {
2797
- if (input.type === InputType6.Coin) {
2715
+ if (input.type === InputType5.Coin) {
2798
2716
  return input.owner.toString();
2799
2717
  }
2800
- if (input.type === InputType6.Message) {
2718
+ if (input.type === InputType5.Message) {
2801
2719
  return input.recipient.toString();
2802
2720
  }
2803
2721
  return "";
@@ -3260,9 +3178,7 @@ function assembleTransactionSummary(params) {
3260
3178
  gqlTransactionStatus,
3261
3179
  abiMap = {},
3262
3180
  maxInputs,
3263
- gasCosts,
3264
- maxGasPerTx,
3265
- gasPrice
3181
+ gasCosts
3266
3182
  } = params;
3267
3183
  const gasUsed = getGasUsedFromReceipts(receipts);
3268
3184
  const rawPayload = hexlify11(transactionBytes);
@@ -3276,14 +3192,11 @@ function assembleTransactionSummary(params) {
3276
3192
  maxInputs
3277
3193
  });
3278
3194
  const typeName = getTransactionTypeName(transaction.type);
3279
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3280
3195
  const { fee } = calculateTransactionFee({
3281
- gasPrice,
3196
+ gasUsed,
3282
3197
  rawPayload,
3283
- tip,
3284
3198
  consensusParameters: {
3285
3199
  gasCosts,
3286
- maxGasPerTx,
3287
3200
  feeParams: {
3288
3201
  gasPerByte,
3289
3202
  gasPriceFactor
@@ -3343,7 +3256,7 @@ var TransactionResponse = class {
3343
3256
  /** Current provider */
3344
3257
  provider;
3345
3258
  /** Gas used on the transaction */
3346
- gasUsed = bn15(0);
3259
+ gasUsed = bn14(0);
3347
3260
  /** The graphql Transaction with receipts object. */
3348
3261
  gqlTransaction;
3349
3262
  abis;
@@ -3421,13 +3334,8 @@ var TransactionResponse = class {
3421
3334
  const decodedTransaction = this.decodeTransaction(
3422
3335
  transaction
3423
3336
  );
3424
- let txReceipts = [];
3425
- if (transaction?.status && "receipts" in transaction.status) {
3426
- txReceipts = transaction.status.receipts;
3427
- }
3428
- const receipts = txReceipts.map(processGqlReceipt) || [];
3429
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3430
- const gasPrice = await this.provider.getLatestGasPrice();
3337
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3338
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3431
3339
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3432
3340
  const transactionSummary = assembleTransactionSummary({
3433
3341
  id: this.id,
@@ -3439,9 +3347,7 @@ var TransactionResponse = class {
3439
3347
  gasPriceFactor,
3440
3348
  abiMap: contractsAbiMap,
3441
3349
  maxInputs,
3442
- gasCosts,
3443
- maxGasPerTx,
3444
- gasPrice
3350
+ gasCosts
3445
3351
  });
3446
3352
  return transactionSummary;
3447
3353
  }
@@ -3568,29 +3474,30 @@ var processGqlChain = (chain) => {
3568
3474
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3569
3475
  return {
3570
3476
  name,
3571
- baseChainHeight: bn16(daHeight),
3477
+ baseChainHeight: bn15(daHeight),
3572
3478
  consensusParameters: {
3573
- contractMaxSize: bn16(contractParams.contractMaxSize),
3574
- maxInputs: bn16(txParams.maxInputs),
3575
- maxOutputs: bn16(txParams.maxOutputs),
3576
- maxWitnesses: bn16(txParams.maxWitnesses),
3577
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3578
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3579
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3580
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3581
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3582
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3583
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3584
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3585
- gasPerByte: bn16(feeParams.gasPerByte),
3586
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3587
- chainId: bn16(consensusParameters.chainId),
3479
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3480
+ maxInputs: bn15(txParams.maxInputs),
3481
+ maxOutputs: bn15(txParams.maxOutputs),
3482
+ maxWitnesses: bn15(txParams.maxWitnesses),
3483
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3484
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3485
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3486
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3487
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3488
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3489
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3490
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3491
+ gasPerByte: bn15(feeParams.gasPerByte),
3492
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3493
+ chainId: bn15(consensusParameters.chainId),
3494
+ baseAssetId: consensusParameters.baseAssetId,
3588
3495
  gasCosts
3589
3496
  },
3590
3497
  gasCosts,
3591
3498
  latestBlock: {
3592
3499
  id: latestBlock.id,
3593
- height: bn16(latestBlock.height),
3500
+ height: bn15(latestBlock.header.height),
3594
3501
  time: latestBlock.header.time,
3595
3502
  transactions: latestBlock.transactions.map((i) => ({
3596
3503
  id: i.id
@@ -3684,8 +3591,10 @@ var _Provider = class {
3684
3591
  * Returns some helpful parameters related to gas fees.
3685
3592
  */
3686
3593
  getGasConfig() {
3594
+ const { minGasPrice } = this.getNode();
3687
3595
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3688
3596
  return {
3597
+ minGasPrice,
3689
3598
  maxGasPerTx,
3690
3599
  maxGasPerPredicate,
3691
3600
  gasPriceFactor,
@@ -3783,7 +3692,7 @@ var _Provider = class {
3783
3692
  */
3784
3693
  async getBlockNumber() {
3785
3694
  const { chain } = await this.operations.getChain();
3786
- return bn16(chain.latestBlock.height, 10);
3695
+ return bn15(chain.latestBlock.header.height, 10);
3787
3696
  }
3788
3697
  /**
3789
3698
  * Returns the chain information.
@@ -3793,11 +3702,13 @@ var _Provider = class {
3793
3702
  async fetchNode() {
3794
3703
  const { nodeInfo } = await this.operations.getNodeInfo();
3795
3704
  const processedNodeInfo = {
3796
- maxDepth: bn16(nodeInfo.maxDepth),
3797
- maxTx: bn16(nodeInfo.maxTx),
3705
+ maxDepth: bn15(nodeInfo.maxDepth),
3706
+ maxTx: bn15(nodeInfo.maxTx),
3707
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3798
3708
  nodeVersion: nodeInfo.nodeVersion,
3799
3709
  utxoValidation: nodeInfo.utxoValidation,
3800
- vmBacktrace: nodeInfo.vmBacktrace
3710
+ vmBacktrace: nodeInfo.vmBacktrace,
3711
+ peers: nodeInfo.peers
3801
3712
  };
3802
3713
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3803
3714
  return processedNodeInfo;
@@ -3823,6 +3734,17 @@ var _Provider = class {
3823
3734
  } = this.getChain();
3824
3735
  return chainId.toNumber();
3825
3736
  }
3737
+ /**
3738
+ * Returns the base asset ID
3739
+ *
3740
+ * @returns A promise that resolves to the base asset ID
3741
+ */
3742
+ getBaseAssetId() {
3743
+ const {
3744
+ consensusParameters: { baseAssetId }
3745
+ } = this.getChain();
3746
+ return baseAssetId;
3747
+ }
3826
3748
  /**
3827
3749
  * Submits a transaction to the chain to be executed.
3828
3750
  *
@@ -3883,13 +3805,14 @@ var _Provider = class {
3883
3805
  return this.estimateTxDependencies(transactionRequest);
3884
3806
  }
3885
3807
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3886
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3887
- encodedTransactions: encodedTransaction,
3808
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3809
+ encodedTransaction,
3888
3810
  utxoValidation: utxoValidation || false
3889
3811
  });
3890
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3891
- const receipts = rawReceipts.map(processGqlReceipt);
3892
- return { receipts, dryrunStatus: status };
3812
+ const receipts = gqlReceipts.map(processGqlReceipt);
3813
+ return {
3814
+ receipts
3815
+ };
3893
3816
  }
3894
3817
  /**
3895
3818
  * Verifies whether enough gas is available to complete transaction.
@@ -3915,7 +3838,7 @@ var _Provider = class {
3915
3838
  } = response;
3916
3839
  if (inputs) {
3917
3840
  inputs.forEach((input, index) => {
3918
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3841
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3919
3842
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3920
3843
  }
3921
3844
  });
@@ -3928,6 +3851,9 @@ var _Provider = class {
3928
3851
  * If there are missing variable outputs,
3929
3852
  * `addVariableOutputs` is called on the transaction.
3930
3853
  *
3854
+ * @privateRemarks
3855
+ * TODO: Investigate support for missing contract IDs
3856
+ * TODO: Add support for missing output messages
3931
3857
  *
3932
3858
  * @param transactionRequest - The transaction request object.
3933
3859
  * @returns A promise.
@@ -3940,19 +3866,16 @@ var _Provider = class {
3940
3866
  missingContractIds: []
3941
3867
  };
3942
3868
  }
3869
+ await this.estimatePredicates(transactionRequest);
3943
3870
  let receipts = [];
3944
3871
  const missingContractIds = [];
3945
3872
  let outputVariables = 0;
3946
- let dryrunStatus;
3947
3873
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3948
- const {
3949
- dryRun: [{ receipts: rawReceipts, status }]
3950
- } = await this.operations.dryRun({
3951
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3874
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3875
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3952
3876
  utxoValidation: false
3953
3877
  });
3954
- receipts = rawReceipts.map(processGqlReceipt);
3955
- dryrunStatus = status;
3878
+ receipts = gqlReceipts.map(processGqlReceipt);
3956
3879
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3957
3880
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3958
3881
  if (hasMissingOutputs) {
@@ -3962,11 +3885,6 @@ var _Provider = class {
3962
3885
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3963
3886
  missingContractIds.push(contractId);
3964
3887
  });
3965
- const { maxFee } = await this.estimateTxGasAndFee({
3966
- transactionRequest,
3967
- optimizeGas: false
3968
- });
3969
- transactionRequest.maxFee = maxFee;
3970
3888
  } else {
3971
3889
  break;
3972
3890
  }
@@ -3974,133 +3892,7 @@ var _Provider = class {
3974
3892
  return {
3975
3893
  receipts,
3976
3894
  outputVariables,
3977
- missingContractIds,
3978
- dryrunStatus
3979
- };
3980
- }
3981
- /**
3982
- * Dry runs multiple transactions and checks for missing dependencies in batches.
3983
- *
3984
- * Transactions are dry run in batches. After each dry run, transactions requiring
3985
- * further modifications are identified. The method iteratively updates these transactions
3986
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
3987
- *
3988
- * @param transactionRequests - Array of transaction request objects.
3989
- * @returns A promise that resolves to an array of results for each transaction.
3990
- */
3991
- async estimateMultipleTxDependencies(transactionRequests) {
3992
- const results = transactionRequests.map(() => ({
3993
- receipts: [],
3994
- outputVariables: 0,
3995
- missingContractIds: [],
3996
- dryrunStatus: void 0
3997
- }));
3998
- const allRequests = clone3(transactionRequests);
3999
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4000
- allRequests.forEach((req, index) => {
4001
- if (req.type === TransactionType8.Script) {
4002
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4003
- }
4004
- });
4005
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4006
- let attempt = 0;
4007
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4008
- const encodedTransactions = transactionsToProcess.map(
4009
- (index) => serializedTransactionsMap.get(index)
4010
- );
4011
- const dryRunResults = await this.operations.dryRun({
4012
- encodedTransactions,
4013
- utxoValidation: false
4014
- });
4015
- const nextRoundTransactions = [];
4016
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4017
- const currentResultIndex = transactionsToProcess[i];
4018
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4019
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4020
- results[currentResultIndex].dryrunStatus = status;
4021
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4022
- results[currentResultIndex].receipts
4023
- );
4024
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4025
- const requestToProcess = allRequests[currentResultIndex];
4026
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4027
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4028
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4029
- missingOutputContractIds.forEach(({ contractId }) => {
4030
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4031
- results[currentResultIndex].missingContractIds.push(contractId);
4032
- });
4033
- const { maxFee } = await this.estimateTxGasAndFee({
4034
- transactionRequest: requestToProcess,
4035
- optimizeGas: false
4036
- });
4037
- requestToProcess.maxFee = maxFee;
4038
- serializedTransactionsMap.set(
4039
- currentResultIndex,
4040
- hexlify12(requestToProcess.toTransactionBytes())
4041
- );
4042
- nextRoundTransactions.push(currentResultIndex);
4043
- allRequests[currentResultIndex] = requestToProcess;
4044
- }
4045
- }
4046
- transactionsToProcess = nextRoundTransactions;
4047
- attempt += 1;
4048
- }
4049
- return results;
4050
- }
4051
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4052
- if (estimateTxDependencies) {
4053
- return this.estimateMultipleTxDependencies(transactionRequests);
4054
- }
4055
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4056
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4057
- encodedTransactions,
4058
- utxoValidation: utxoValidation || false
4059
- });
4060
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4061
- const receipts = rawReceipts.map(processGqlReceipt);
4062
- return { receipts, dryrunStatus: status };
4063
- });
4064
- return results;
4065
- }
4066
- async estimateTxGasAndFee(params) {
4067
- const { transactionRequest, optimizeGas = true } = params;
4068
- let { gasPrice } = params;
4069
- const chainInfo = this.getChain();
4070
- const { gasPriceFactor } = this.getGasConfig();
4071
- const minGas = transactionRequest.calculateMinGas(chainInfo);
4072
- if (!gasPrice) {
4073
- gasPrice = await this.estimateGasPrice(10);
4074
- }
4075
- const minFee = calculateGasFee({
4076
- gasPrice: bn16(gasPrice),
4077
- gas: minGas,
4078
- priceFactor: gasPriceFactor,
4079
- tip: transactionRequest.tip
4080
- }).add(1);
4081
- let gasLimit = bn16(0);
4082
- if (transactionRequest.type === TransactionType8.Script) {
4083
- gasLimit = transactionRequest.gasLimit;
4084
- if (!optimizeGas) {
4085
- transactionRequest.gasLimit = minGas;
4086
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4087
- transactionRequest.gasLimit = gasLimit;
4088
- }
4089
- }
4090
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4091
- const maxFee = calculateGasFee({
4092
- gasPrice: bn16(gasPrice),
4093
- gas: maxGas,
4094
- priceFactor: gasPriceFactor,
4095
- tip: transactionRequest.tip
4096
- }).add(1);
4097
- return {
4098
- minGas,
4099
- minFee,
4100
- maxGas,
4101
- maxFee,
4102
- gasPrice,
4103
- gasLimit
3895
+ missingContractIds
4104
3896
  };
4105
3897
  }
4106
3898
  /**
@@ -4118,17 +3910,15 @@ var _Provider = class {
4118
3910
  if (estimateTxDependencies) {
4119
3911
  return this.estimateTxDependencies(transactionRequest);
4120
3912
  }
4121
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4122
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4123
- encodedTransactions,
3913
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3914
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3915
+ encodedTransaction,
4124
3916
  utxoValidation: true
4125
3917
  });
4126
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4127
- const { id, receipts, status } = dryRunStatus;
4128
- const processedReceipts = receipts.map(processGqlReceipt);
4129
- return { id, receipts: processedReceipts, status };
4130
- });
4131
- return { receipts: callResult[0].receipts };
3918
+ const receipts = gqlReceipts.map(processGqlReceipt);
3919
+ return {
3920
+ receipts
3921
+ };
4132
3922
  }
4133
3923
  /**
4134
3924
  * Returns a transaction cost to enable user
@@ -4145,80 +3935,80 @@ var _Provider = class {
4145
3935
  * @param tolerance - The tolerance to add on top of the gasUsed.
4146
3936
  * @returns A promise that resolves to the transaction cost object.
4147
3937
  */
4148
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3938
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3939
+ estimateTxDependencies = true,
3940
+ estimatePredicates = true,
3941
+ resourcesOwner,
3942
+ signatureCallback
3943
+ } = {}) {
4149
3944
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3945
+ const chainInfo = this.getChain();
3946
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3947
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
4150
3948
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4151
3949
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4152
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3950
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4153
3951
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4154
- txRequestClone.maxFee = bn16(0);
4155
- if (isScriptTransaction) {
4156
- txRequestClone.gasLimit = bn16(0);
4157
- }
4158
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4159
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3952
+ if (estimatePredicates) {
3953
+ if (isScriptTransaction) {
3954
+ txRequestClone.gasLimit = bn15(0);
3955
+ }
3956
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3957
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3958
+ }
3959
+ await this.estimatePredicates(txRequestClone);
4160
3960
  }
4161
- const signedRequest = clone3(txRequestClone);
4162
- let addedSignatures = 0;
4163
3961
  if (signatureCallback && isScriptTransaction) {
4164
- const lengthBefore = signedRequest.witnesses.length;
4165
- await signatureCallback(signedRequest);
4166
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4167
- }
4168
- await this.estimatePredicates(signedRequest);
4169
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4170
- transactionRequest: signedRequest,
4171
- optimizeGas: false
4172
- });
4173
- txRequestClone.maxFee = maxFee;
3962
+ await signatureCallback(txRequestClone);
3963
+ }
3964
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
3965
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4174
3966
  let receipts = [];
4175
3967
  let missingContractIds = [];
4176
3968
  let outputVariables = 0;
4177
- let gasUsed = bn16(0);
4178
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4179
- if (isScriptTransaction) {
4180
- if (signatureCallback) {
4181
- await signatureCallback(txRequestClone);
4182
- }
4183
- txRequestClone.gasLimit = gasLimit;
3969
+ if (isScriptTransaction && estimateTxDependencies) {
3970
+ txRequestClone.gasPrice = bn15(0);
3971
+ txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4184
3972
  const result = await this.estimateTxDependencies(txRequestClone);
4185
3973
  receipts = result.receipts;
4186
3974
  outputVariables = result.outputVariables;
4187
3975
  missingContractIds = result.missingContractIds;
4188
- gasUsed = getGasUsedFromReceipts(receipts);
4189
- txRequestClone.gasLimit = gasUsed;
4190
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4191
- transactionRequest: txRequestClone,
4192
- gasPrice
4193
- }));
4194
3976
  }
3977
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3978
+ const usedFee = calculatePriceWithFactor(
3979
+ gasUsed,
3980
+ gasPrice,
3981
+ gasPriceFactor
3982
+ ).normalizeZeroToOne();
3983
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3984
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4195
3985
  return {
4196
3986
  requiredQuantities: allQuantities,
4197
3987
  receipts,
4198
3988
  gasUsed,
3989
+ minGasPrice,
4199
3990
  gasPrice,
4200
3991
  minGas,
4201
3992
  maxGas,
3993
+ usedFee,
4202
3994
  minFee,
4203
3995
  maxFee,
3996
+ estimatedInputs: txRequestClone.inputs,
4204
3997
  outputVariables,
4205
- missingContractIds,
4206
- addedSignatures,
4207
- estimatedPredicates: txRequestClone.inputs
3998
+ missingContractIds
4208
3999
  };
4209
4000
  }
4210
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4001
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4211
4002
  const ownerAddress = Address2.fromAddressOrString(owner);
4212
4003
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4213
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4214
- quantitiesToContract
4215
- });
4004
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4216
4005
  transactionRequest.addResources(
4217
4006
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4218
4007
  );
4219
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4220
- quantitiesToContract
4221
- });
4008
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4009
+ transactionRequest,
4010
+ forwardingQuantities
4011
+ );
4222
4012
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4223
4013
  return {
4224
4014
  resources,
@@ -4240,10 +4030,11 @@ var _Provider = class {
4240
4030
  return coins.map((coin) => ({
4241
4031
  id: coin.utxoId,
4242
4032
  assetId: coin.assetId,
4243
- amount: bn16(coin.amount),
4033
+ amount: bn15(coin.amount),
4244
4034
  owner: Address2.fromAddressOrString(coin.owner),
4245
- blockCreated: bn16(coin.blockCreated),
4246
- txCreatedIdx: bn16(coin.txCreatedIdx)
4035
+ maturity: bn15(coin.maturity).toNumber(),
4036
+ blockCreated: bn15(coin.blockCreated),
4037
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4247
4038
  }));
4248
4039
  }
4249
4040
  /**
@@ -4280,9 +4071,9 @@ var _Provider = class {
4280
4071
  switch (coin.__typename) {
4281
4072
  case "MessageCoin":
4282
4073
  return {
4283
- amount: bn16(coin.amount),
4074
+ amount: bn15(coin.amount),
4284
4075
  assetId: coin.assetId,
4285
- daHeight: bn16(coin.daHeight),
4076
+ daHeight: bn15(coin.daHeight),
4286
4077
  sender: Address2.fromAddressOrString(coin.sender),
4287
4078
  recipient: Address2.fromAddressOrString(coin.recipient),
4288
4079
  nonce: coin.nonce
@@ -4290,11 +4081,12 @@ var _Provider = class {
4290
4081
  case "Coin":
4291
4082
  return {
4292
4083
  id: coin.utxoId,
4293
- amount: bn16(coin.amount),
4084
+ amount: bn15(coin.amount),
4294
4085
  assetId: coin.assetId,
4295
4086
  owner: Address2.fromAddressOrString(coin.owner),
4296
- blockCreated: bn16(coin.blockCreated),
4297
- txCreatedIdx: bn16(coin.txCreatedIdx)
4087
+ maturity: bn15(coin.maturity).toNumber(),
4088
+ blockCreated: bn15(coin.blockCreated),
4089
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4298
4090
  };
4299
4091
  default:
4300
4092
  return null;
@@ -4311,13 +4103,13 @@ var _Provider = class {
4311
4103
  async getBlock(idOrHeight) {
4312
4104
  let variables;
4313
4105
  if (typeof idOrHeight === "number") {
4314
- variables = { height: bn16(idOrHeight).toString(10) };
4106
+ variables = { height: bn15(idOrHeight).toString(10) };
4315
4107
  } else if (idOrHeight === "latest") {
4316
4108
  variables = { height: (await this.getBlockNumber()).toString(10) };
4317
4109
  } else if (idOrHeight.length === 66) {
4318
4110
  variables = { blockId: idOrHeight };
4319
4111
  } else {
4320
- variables = { blockId: bn16(idOrHeight).toString(10) };
4112
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4321
4113
  }
4322
4114
  const { block } = await this.operations.getBlock(variables);
4323
4115
  if (!block) {
@@ -4325,7 +4117,7 @@ var _Provider = class {
4325
4117
  }
4326
4118
  return {
4327
4119
  id: block.id,
4328
- height: bn16(block.height),
4120
+ height: bn15(block.header.height),
4329
4121
  time: block.header.time,
4330
4122
  transactionIds: block.transactions.map((tx) => tx.id)
4331
4123
  };
@@ -4340,7 +4132,7 @@ var _Provider = class {
4340
4132
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4341
4133
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4342
4134
  id: block.id,
4343
- height: bn16(block.height),
4135
+ height: bn15(block.header.height),
4344
4136
  time: block.header.time,
4345
4137
  transactionIds: block.transactions.map((tx) => tx.id)
4346
4138
  }));
@@ -4355,7 +4147,7 @@ var _Provider = class {
4355
4147
  async getBlockWithTransactions(idOrHeight) {
4356
4148
  let variables;
4357
4149
  if (typeof idOrHeight === "number") {
4358
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4150
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4359
4151
  } else if (idOrHeight === "latest") {
4360
4152
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4361
4153
  } else {
@@ -4367,7 +4159,7 @@ var _Provider = class {
4367
4159
  }
4368
4160
  return {
4369
4161
  id: block.id,
4370
- height: bn16(block.height, 10),
4162
+ height: bn15(block.header.height, 10),
4371
4163
  time: block.header.time,
4372
4164
  transactionIds: block.transactions.map((tx) => tx.id),
4373
4165
  transactions: block.transactions.map(
@@ -4416,7 +4208,7 @@ var _Provider = class {
4416
4208
  contract: Address2.fromAddressOrString(contractId).toB256(),
4417
4209
  asset: hexlify12(assetId)
4418
4210
  });
4419
- return bn16(contractBalance.amount, 10);
4211
+ return bn15(contractBalance.amount, 10);
4420
4212
  }
4421
4213
  /**
4422
4214
  * Returns the balance for the given owner for the given asset ID.
@@ -4430,7 +4222,7 @@ var _Provider = class {
4430
4222
  owner: Address2.fromAddressOrString(owner).toB256(),
4431
4223
  assetId: hexlify12(assetId)
4432
4224
  });
4433
- return bn16(balance.amount, 10);
4225
+ return bn15(balance.amount, 10);
4434
4226
  }
4435
4227
  /**
4436
4228
  * Returns balances for the given owner.
@@ -4448,7 +4240,7 @@ var _Provider = class {
4448
4240
  const balances = result.balances.edges.map((edge) => edge.node);
4449
4241
  return balances.map((balance) => ({
4450
4242
  assetId: balance.assetId,
4451
- amount: bn16(balance.amount)
4243
+ amount: bn15(balance.amount)
4452
4244
  }));
4453
4245
  }
4454
4246
  /**
@@ -4470,15 +4262,15 @@ var _Provider = class {
4470
4262
  sender: message.sender,
4471
4263
  recipient: message.recipient,
4472
4264
  nonce: message.nonce,
4473
- amount: bn16(message.amount),
4265
+ amount: bn15(message.amount),
4474
4266
  data: message.data
4475
4267
  }),
4476
4268
  sender: Address2.fromAddressOrString(message.sender),
4477
4269
  recipient: Address2.fromAddressOrString(message.recipient),
4478
4270
  nonce: message.nonce,
4479
- amount: bn16(message.amount),
4271
+ amount: bn15(message.amount),
4480
4272
  data: InputMessageCoder.decodeData(message.data),
4481
- daHeight: bn16(message.daHeight)
4273
+ daHeight: bn15(message.daHeight)
4482
4274
  }));
4483
4275
  }
4484
4276
  /**
@@ -4531,52 +4323,44 @@ var _Provider = class {
4531
4323
  } = result.messageProof;
4532
4324
  return {
4533
4325
  messageProof: {
4534
- proofIndex: bn16(messageProof.proofIndex),
4326
+ proofIndex: bn15(messageProof.proofIndex),
4535
4327
  proofSet: messageProof.proofSet
4536
4328
  },
4537
4329
  blockProof: {
4538
- proofIndex: bn16(blockProof.proofIndex),
4330
+ proofIndex: bn15(blockProof.proofIndex),
4539
4331
  proofSet: blockProof.proofSet
4540
4332
  },
4541
4333
  messageBlockHeader: {
4542
4334
  id: messageBlockHeader.id,
4543
- daHeight: bn16(messageBlockHeader.daHeight),
4544
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4335
+ daHeight: bn15(messageBlockHeader.daHeight),
4336
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4545
4337
  transactionsRoot: messageBlockHeader.transactionsRoot,
4546
- height: bn16(messageBlockHeader.height),
4338
+ height: bn15(messageBlockHeader.height),
4547
4339
  prevRoot: messageBlockHeader.prevRoot,
4548
4340
  time: messageBlockHeader.time,
4549
4341
  applicationHash: messageBlockHeader.applicationHash,
4550
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount)
4342
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4343
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4551
4344
  },
4552
4345
  commitBlockHeader: {
4553
4346
  id: commitBlockHeader.id,
4554
- daHeight: bn16(commitBlockHeader.daHeight),
4555
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4347
+ daHeight: bn15(commitBlockHeader.daHeight),
4348
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4556
4349
  transactionsRoot: commitBlockHeader.transactionsRoot,
4557
- height: bn16(commitBlockHeader.height),
4350
+ height: bn15(commitBlockHeader.height),
4558
4351
  prevRoot: commitBlockHeader.prevRoot,
4559
4352
  time: commitBlockHeader.time,
4560
4353
  applicationHash: commitBlockHeader.applicationHash,
4561
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount)
4354
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4355
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4562
4356
  },
4563
4357
  sender: Address2.fromAddressOrString(sender),
4564
4358
  recipient: Address2.fromAddressOrString(recipient),
4565
4359
  nonce,
4566
- amount: bn16(amount),
4360
+ amount: bn15(amount),
4567
4361
  data
4568
4362
  };
4569
4363
  }
4570
- async getLatestGasPrice() {
4571
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4572
- return bn16(latestGasPrice.gasPrice);
4573
- }
4574
- async estimateGasPrice(blockHorizon) {
4575
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4576
- blockHorizon: String(blockHorizon)
4577
- });
4578
- return bn16(estimateGasPrice.gasPrice);
4579
- }
4580
4364
  /**
4581
4365
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4582
4366
  *
@@ -4596,10 +4380,10 @@ var _Provider = class {
4596
4380
  */
4597
4381
  async produceBlocks(amount, startTime) {
4598
4382
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4599
- blocksToProduce: bn16(amount).toString(10),
4383
+ blocksToProduce: bn15(amount).toString(10),
4600
4384
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4601
4385
  });
4602
- return bn16(latestBlockHeight);
4386
+ return bn15(latestBlockHeight);
4603
4387
  }
4604
4388
  // eslint-disable-next-line @typescript-eslint/require-await
4605
4389
  async getTransactionResponse(transactionId) {
@@ -4613,7 +4397,7 @@ cacheInputs_fn = function(inputs) {
4613
4397
  return;
4614
4398
  }
4615
4399
  inputs.forEach((input) => {
4616
- if (input.type === InputType7.Coin) {
4400
+ if (input.type === InputType6.Coin) {
4617
4401
  this.cache?.set(input.id);
4618
4402
  }
4619
4403
  });
@@ -4623,7 +4407,7 @@ __publicField(Provider, "nodeInfoCache", {});
4623
4407
 
4624
4408
  // src/providers/transaction-summary/get-transaction-summary.ts
4625
4409
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4626
- import { bn as bn17 } from "@fuel-ts/math";
4410
+ import { bn as bn16 } from "@fuel-ts/math";
4627
4411
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4628
4412
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4629
4413
 
@@ -4831,8 +4615,9 @@ var Account = class extends AbstractAccount {
4831
4615
  * @param assetId - The asset ID to check the balance for.
4832
4616
  * @returns A promise that resolves to the balance amount.
4833
4617
  */
4834
- async getBalance(assetId = BaseAssetId3) {
4835
- const amount = await this.provider.getBalance(this.address, assetId);
4618
+ async getBalance(assetId) {
4619
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4620
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4836
4621
  return amount;
4837
4622
  }
4838
4623
  /**
@@ -4869,33 +4654,37 @@ var Account = class extends AbstractAccount {
4869
4654
  * @param fee - The estimated transaction fee.
4870
4655
  * @returns A promise that resolves when the resources are added to the transaction.
4871
4656
  */
4872
- async fund(request, params) {
4873
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4874
- const txRequest = request;
4875
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4876
- amount: bn18(fee),
4877
- assetId: BaseAssetId3,
4878
- coinQuantities: requiredQuantities
4657
+ async fund(request, coinQuantities, fee) {
4658
+ const baseAssetId = this.provider.getBaseAssetId();
4659
+ const updatedQuantities = addAmountToAsset({
4660
+ amount: bn17(fee),
4661
+ assetId: baseAssetId,
4662
+ coinQuantities
4879
4663
  });
4880
4664
  const quantitiesDict = {};
4881
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4665
+ updatedQuantities.forEach(({ amount, assetId }) => {
4882
4666
  quantitiesDict[assetId] = {
4883
4667
  required: amount,
4884
- owned: bn18(0)
4668
+ owned: bn17(0)
4885
4669
  };
4886
4670
  });
4887
- txRequest.inputs.forEach((input) => {
4671
+ const cachedUtxos = [];
4672
+ const cachedMessages = [];
4673
+ const owner = this.address.toB256();
4674
+ request.inputs.forEach((input) => {
4888
4675
  const isResource = "amount" in input;
4889
4676
  if (isResource) {
4890
4677
  const isCoin2 = "owner" in input;
4891
4678
  if (isCoin2) {
4892
4679
  const assetId = String(input.assetId);
4893
- if (quantitiesDict[assetId]) {
4894
- const amount = bn18(input.amount);
4680
+ if (input.owner === owner && quantitiesDict[assetId]) {
4681
+ const amount = bn17(input.amount);
4895
4682
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4683
+ cachedUtxos.push(input.id);
4896
4684
  }
4897
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4898
- quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4685
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4686
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4687
+ cachedMessages.push(input.nonce);
4899
4688
  }
4900
4689
  }
4901
4690
  });
@@ -4910,23 +4699,12 @@ var Account = class extends AbstractAccount {
4910
4699
  });
4911
4700
  const needsToBeFunded = missingQuantities.length;
4912
4701
  if (needsToBeFunded) {
4913
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4914
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4915
- txRequest.addResources(resources);
4916
- }
4917
- txRequest.shiftPredicateData();
4918
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4919
- const requestToBeReEstimate = clone4(txRequest);
4920
- if (addedSignatures) {
4921
- Array.from({ length: addedSignatures }).forEach(
4922
- () => requestToBeReEstimate.addEmptyWitness()
4923
- );
4702
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4703
+ messages: cachedMessages,
4704
+ utxos: cachedUtxos
4705
+ });
4706
+ request.addResources(resources);
4924
4707
  }
4925
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4926
- transactionRequest: requestToBeReEstimate
4927
- });
4928
- txRequest.maxFee = maxFee;
4929
- return txRequest;
4930
4708
  }
4931
4709
  /**
4932
4710
  * A helper that creates a transfer transaction request and returns it.
@@ -4934,25 +4712,29 @@ var Account = class extends AbstractAccount {
4934
4712
  * @param destination - The address of the destination.
4935
4713
  * @param amount - The amount of coins to transfer.
4936
4714
  * @param assetId - The asset ID of the coins to transfer.
4937
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4715
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4938
4716
  * @returns A promise that resolves to the prepared transaction request.
4939
4717
  */
4940
- async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4941
- const request = new ScriptTransactionRequest(txParams);
4942
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4943
- const txCost = await this.provider.getTransactionCost(request, {
4718
+ async createTransfer(destination, amount, assetId, txParams = {}) {
4719
+ const { minGasPrice } = this.provider.getGasConfig();
4720
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4721
+ const params = { gasPrice: minGasPrice, ...txParams };
4722
+ const request = new ScriptTransactionRequest(params);
4723
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
4724
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4944
4725
  estimateTxDependencies: true,
4945
4726
  resourcesOwner: this
4946
4727
  });
4947
- if ("gasLimit" in txParams) {
4948
- this.validateGas({
4949
- gasUsed: txCost.gasUsed,
4950
- gasLimit: request.gasLimit
4951
- });
4952
- }
4953
- request.gasLimit = txCost.gasUsed;
4954
- request.maxFee = txCost.maxFee;
4955
- await this.fund(request, txCost);
4728
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4729
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4730
+ this.validateGas({
4731
+ gasUsed,
4732
+ gasPrice: request.gasPrice,
4733
+ gasLimit: request.gasLimit,
4734
+ minGasPrice
4735
+ });
4736
+ await this.fund(request, requiredQuantities, maxFee);
4737
+ request.updatePredicateInputs(estimatedInputs);
4956
4738
  return request;
4957
4739
  }
4958
4740
  /**
@@ -4964,14 +4746,15 @@ var Account = class extends AbstractAccount {
4964
4746
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4965
4747
  * @returns A promise that resolves to the transaction response.
4966
4748
  */
4967
- async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4968
- if (bn18(amount).lte(0)) {
4749
+ async transfer(destination, amount, assetId, txParams = {}) {
4750
+ if (bn17(amount).lte(0)) {
4969
4751
  throw new FuelError15(
4970
4752
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4971
4753
  "Transfer amount must be a positive number."
4972
4754
  );
4973
4755
  }
4974
- const request = await this.createTransfer(destination, amount, assetId, txParams);
4756
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4757
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
4975
4758
  return this.sendTransaction(request, { estimateTxDependencies: false });
4976
4759
  }
4977
4760
  /**
@@ -4983,38 +4766,40 @@ var Account = class extends AbstractAccount {
4983
4766
  * @param txParams - The optional transaction parameters.
4984
4767
  * @returns A promise that resolves to the transaction response.
4985
4768
  */
4986
- async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4987
- if (bn18(amount).lte(0)) {
4769
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
4770
+ if (bn17(amount).lte(0)) {
4988
4771
  throw new FuelError15(
4989
4772
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4990
4773
  "Transfer amount must be a positive number."
4991
4774
  );
4992
4775
  }
4993
4776
  const contractAddress = Address3.fromAddressOrString(contractId);
4777
+ const { minGasPrice } = this.provider.getGasConfig();
4778
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4779
+ const params = { gasPrice: minGasPrice, ...txParams };
4994
4780
  const { script, scriptData } = await assembleTransferToContractScript({
4995
4781
  hexlifiedContractId: contractAddress.toB256(),
4996
- amountToTransfer: bn18(amount),
4997
- assetId
4782
+ amountToTransfer: bn17(amount),
4783
+ assetId: assetIdToTransfer
4998
4784
  });
4999
4785
  const request = new ScriptTransactionRequest({
5000
- ...txParams,
4786
+ ...params,
5001
4787
  script,
5002
4788
  scriptData
5003
4789
  });
5004
4790
  request.addContractInputAndOutput(contractAddress);
5005
- const txCost = await this.provider.getTransactionCost(request, {
5006
- resourcesOwner: this,
5007
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
4791
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4792
+ request,
4793
+ [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
4794
+ );
4795
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4796
+ this.validateGas({
4797
+ gasUsed,
4798
+ gasPrice: request.gasPrice,
4799
+ gasLimit: request.gasLimit,
4800
+ minGasPrice
5008
4801
  });
5009
- if (txParams.gasLimit) {
5010
- this.validateGas({
5011
- gasUsed: txCost.gasUsed,
5012
- gasLimit: request.gasLimit
5013
- });
5014
- }
5015
- request.gasLimit = txCost.gasUsed;
5016
- request.maxFee = txCost.maxFee;
5017
- await this.fund(request, txCost);
4802
+ await this.fund(request, requiredQuantities, maxFee);
5018
4803
  return this.sendTransaction(request);
5019
4804
  }
5020
4805
  /**
@@ -5026,31 +4811,35 @@ var Account = class extends AbstractAccount {
5026
4811
  * @returns A promise that resolves to the transaction response.
5027
4812
  */
5028
4813
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4814
+ const { minGasPrice } = this.provider.getGasConfig();
4815
+ const baseAssetId = this.provider.getBaseAssetId();
5029
4816
  const recipientAddress = Address3.fromAddressOrString(recipient);
5030
4817
  const recipientDataArray = arrayify14(
5031
4818
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5032
4819
  );
5033
4820
  const amountDataArray = arrayify14(
5034
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
4821
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5035
4822
  );
5036
4823
  const script = new Uint8Array([
5037
4824
  ...arrayify14(withdrawScript.bytes),
5038
4825
  ...recipientDataArray,
5039
4826
  ...amountDataArray
5040
4827
  ]);
5041
- const params = { script, ...txParams };
4828
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5042
4829
  const request = new ScriptTransactionRequest(params);
5043
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5044
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5045
- if (txParams.gasLimit) {
5046
- this.validateGas({
5047
- gasUsed: txCost.gasUsed,
5048
- gasLimit: request.gasLimit
5049
- });
5050
- }
5051
- request.maxFee = txCost.maxFee;
5052
- request.gasLimit = txCost.gasUsed;
5053
- await this.fund(request, txCost);
4830
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
4831
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4832
+ request,
4833
+ forwardingQuantities
4834
+ );
4835
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4836
+ this.validateGas({
4837
+ gasUsed,
4838
+ gasPrice: request.gasPrice,
4839
+ gasLimit: request.gasLimit,
4840
+ minGasPrice
4841
+ });
4842
+ await this.fund(request, requiredQuantities, maxFee);
5054
4843
  return this.sendTransaction(request);
5055
4844
  }
5056
4845
  async signMessage(message) {
@@ -5108,7 +4897,18 @@ var Account = class extends AbstractAccount {
5108
4897
  }
5109
4898
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5110
4899
  }
5111
- validateGas({ gasUsed, gasLimit }) {
4900
+ validateGas({
4901
+ gasUsed,
4902
+ gasPrice,
4903
+ gasLimit,
4904
+ minGasPrice
4905
+ }) {
4906
+ if (minGasPrice.gt(gasPrice)) {
4907
+ throw new FuelError15(
4908
+ ErrorCode15.GAS_PRICE_TOO_LOW,
4909
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4910
+ );
4911
+ }
5112
4912
  if (gasUsed.gt(gasLimit)) {
5113
4913
  throw new FuelError15(
5114
4914
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5120,7 +4920,7 @@ var Account = class extends AbstractAccount {
5120
4920
 
5121
4921
  // src/signer/signer.ts
5122
4922
  import { Address as Address4 } from "@fuel-ts/address";
5123
- import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
4923
+ import { randomBytes } from "@fuel-ts/crypto";
5124
4924
  import { hash } from "@fuel-ts/hasher";
5125
4925
  import { toBytes } from "@fuel-ts/math";
5126
4926
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5213,7 +5013,7 @@ var Signer = class {
5213
5013
  * @returns random 32-byte hashed
5214
5014
  */
5215
5015
  static generatePrivateKey(entropy) {
5216
- return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5016
+ return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5217
5017
  }
5218
5018
  /**
5219
5019
  * Extended publicKey from a compact publicKey
@@ -5232,7 +5032,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5232
5032
  import {
5233
5033
  bufferFromString,
5234
5034
  keccak256,
5235
- randomBytes as randomBytes3,
5035
+ randomBytes as randomBytes2,
5236
5036
  scrypt,
5237
5037
  stringFromBuffer,
5238
5038
  decryptJsonWalletData,
@@ -5255,7 +5055,7 @@ var removeHexPrefix = (hexString) => {
5255
5055
  async function encryptKeystoreWallet(privateKey, address, password) {
5256
5056
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5257
5057
  const ownerAddress = Address5.fromAddressOrString(address);
5258
- const salt = randomBytes3(DEFAULT_KEY_SIZE);
5058
+ const salt = randomBytes2(DEFAULT_KEY_SIZE);
5259
5059
  const key = scrypt({
5260
5060
  password: bufferFromString(password),
5261
5061
  salt,
@@ -5264,7 +5064,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5264
5064
  r: DEFAULT_KDF_PARAMS_R,
5265
5065
  p: DEFAULT_KDF_PARAMS_P
5266
5066
  });
5267
- const iv = randomBytes3(DEFAULT_IV_SIZE);
5067
+ const iv = randomBytes2(DEFAULT_IV_SIZE);
5268
5068
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5269
5069
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5270
5070
  const macHashUint8Array = keccak256(data);
@@ -5400,7 +5200,7 @@ var BaseWalletUnlocked = class extends Account {
5400
5200
  * @param transactionRequestLike - The transaction request to send.
5401
5201
  * @returns A promise that resolves to the TransactionResponse object.
5402
5202
  */
5403
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5203
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5404
5204
  const transactionRequest = transactionRequestify(transactionRequestLike);
5405
5205
  if (estimateTxDependencies) {
5406
5206
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5441,12 +5241,12 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5441
5241
  // src/hdwallet/hdwallet.ts
5442
5242
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5443
5243
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5444
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5244
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5445
5245
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5446
5246
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5447
5247
 
5448
5248
  // src/mnemonic/mnemonic.ts
5449
- import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5249
+ import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5450
5250
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5451
5251
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5452
5252
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -7801,7 +7601,7 @@ var Mnemonic = class {
7801
7601
  * @returns A randomly generated mnemonic
7802
7602
  */
7803
7603
  static generate(size = 32, extraEntropy = "") {
7804
- const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7604
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7805
7605
  return Mnemonic.entropyToMnemonic(entropy);
7806
7606
  }
7807
7607
  };
@@ -7907,7 +7707,7 @@ var HDWallet = class {
7907
7707
  const IR = bytes.slice(32);
7908
7708
  if (privateKey) {
7909
7709
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7910
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
7710
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7911
7711
  return new HDWallet({
7912
7712
  privateKey: ki,
7913
7713
  chainCode: IR,
@@ -8172,21 +7972,20 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
8172
7972
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8173
7973
 
8174
7974
  // src/test-utils/seedTestWallet.ts
8175
- import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
7975
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
8176
7976
  var seedTestWallet = async (wallet, quantities) => {
8177
7977
  const genesisWallet = new WalletUnlocked(
8178
- process.env.GENESIS_SECRET || randomBytes5(32),
7978
+ process.env.GENESIS_SECRET || randomBytes4(32),
8179
7979
  wallet.provider
8180
7980
  );
8181
- const request = new ScriptTransactionRequest();
8182
- quantities.forEach((quantity) => {
8183
- const { amount, assetId } = coinQuantityfy(quantity);
8184
- request.addCoinOutput(wallet.address, amount, assetId);
7981
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
7982
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
7983
+ const request = new ScriptTransactionRequest({
7984
+ gasLimit: 1e4,
7985
+ gasPrice: minGasPrice
8185
7986
  });
8186
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8187
- request.gasLimit = txCost.gasUsed;
8188
- request.maxFee = txCost.maxFee;
8189
- await genesisWallet.fund(request, txCost);
7987
+ request.addResources(resources);
7988
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8190
7989
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8191
7990
  };
8192
7991
 
@@ -8200,12 +7999,12 @@ var generateTestWallet = async (provider, quantities) => {
8200
7999
  };
8201
8000
 
8202
8001
  // src/test-utils/launchNode.ts
8203
- import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8204
- import { defaultChainConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8002
+ import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
8003
+ import { toHex as toHex2 } from "@fuel-ts/math";
8004
+ import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8205
8005
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
8206
8006
  import { spawn } from "child_process";
8207
8007
  import { randomUUID } from "crypto";
8208
- import { randomBytes as randomBytes6 } from "ethers";
8209
8008
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
8210
8009
  import os from "os";
8211
8010
  import path from "path";
@@ -8254,12 +8053,12 @@ var launchNode = async ({
8254
8053
  // eslint-disable-next-line no-async-promise-executor
8255
8054
  new Promise(async (resolve, reject) => {
8256
8055
  const remainingArgs = extractRemainingArgs(args, [
8257
- "--snapshot",
8056
+ "--chain",
8258
8057
  "--consensus-key",
8259
8058
  "--db-type",
8260
8059
  "--poa-instant"
8261
8060
  ]);
8262
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8061
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8263
8062
  const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
8264
8063
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8265
8064
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
@@ -8278,54 +8077,36 @@ var launchNode = async ({
8278
8077
  let chainConfigPathToUse;
8279
8078
  const prefix = basePath || os.tmpdir();
8280
8079
  const suffix = basePath ? "" : randomUUID();
8281
- const tempDirPath = path.join(prefix, ".fuels", suffix, "chainConfigs");
8080
+ const tempDirPath = path.join(prefix, ".fuels", suffix);
8282
8081
  if (chainConfigPath) {
8283
8082
  chainConfigPathToUse = chainConfigPath;
8284
8083
  } else {
8285
8084
  if (!existsSync(tempDirPath)) {
8286
8085
  mkdirSync(tempDirPath, { recursive: true });
8287
8086
  }
8288
- let { stateConfigJson } = defaultChainConfigs;
8289
- const { chainConfigJson, metadataJson } = defaultChainConfigs;
8290
- stateConfigJson = {
8291
- ...stateConfigJson,
8292
- coins: [
8293
- ...stateConfigJson.coins.map((coin) => ({
8294
- ...coin,
8295
- amount: "18446744073709551615"
8296
- }))
8297
- ],
8298
- messages: stateConfigJson.messages.map((message) => ({
8299
- ...message,
8300
- amount: "18446744073709551615"
8301
- }))
8302
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8303
- };
8087
+ const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
8088
+ let chainConfig = defaultChainConfig;
8304
8089
  if (!process.env.GENESIS_SECRET) {
8305
8090
  const pk = Signer.generatePrivateKey();
8306
8091
  const signer = new Signer(pk);
8307
8092
  process.env.GENESIS_SECRET = hexlify18(pk);
8308
- stateConfigJson.coins.push({
8309
- tx_id: hexlify18(randomBytes6(34)),
8310
- owner: signer.address.toHexString(),
8311
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8312
- amount: "18446744073709551615",
8313
- asset_id: BaseAssetId4,
8314
- output_index: 0,
8315
- tx_pointer_block_height: 0,
8316
- tx_pointer_tx_idx: 0
8317
- });
8093
+ chainConfig = {
8094
+ ...defaultChainConfig,
8095
+ initial_state: {
8096
+ ...defaultChainConfig.initial_state,
8097
+ coins: [
8098
+ ...defaultChainConfig.initial_state.coins,
8099
+ {
8100
+ owner: signer.address.toHexString(),
8101
+ amount: toHex2(1e9),
8102
+ asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes329
8103
+ }
8104
+ ]
8105
+ }
8106
+ };
8318
8107
  }
8319
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8320
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8321
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8322
- const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8323
- const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8324
- const metadataWritePath = path.join(tempDirPath, "metadata.json");
8325
- writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8326
- writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8327
- writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8328
- chainConfigPathToUse = tempDirPath;
8108
+ writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8109
+ chainConfigPathToUse = tempChainConfigFilePath;
8329
8110
  }
8330
8111
  const child = spawn(
8331
8112
  command,
@@ -8334,10 +8115,10 @@ var launchNode = async ({
8334
8115
  ["--ip", ipToUse],
8335
8116
  ["--port", portToUse],
8336
8117
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8337
- ["--min-gas-price", "1"],
8118
+ ["--min-gas-price", "0"],
8338
8119
  poaInstant ? ["--poa-instant", "true"] : [],
8339
8120
  ["--consensus-key", consensusKey],
8340
- ["--snapshot", chainConfigPathToUse],
8121
+ ["--chain", chainConfigPathToUse],
8341
8122
  "--vm-backtrace",
8342
8123
  "--utxo-validation",
8343
8124
  "--debug",
@@ -8384,9 +8165,10 @@ var launchNode = async ({
8384
8165
  })
8385
8166
  );
8386
8167
  var generateWallets = async (count, provider) => {
8168
+ const baseAssetId = provider.getBaseAssetId();
8387
8169
  const wallets = [];
8388
8170
  for (let i = 0; i < count; i += 1) {
8389
- const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId4]]);
8171
+ const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8390
8172
  wallets.push(wallet);
8391
8173
  }
8392
8174
  return wallets;
@@ -8396,7 +8178,7 @@ var launchNodeAndGetWallets = async ({
8396
8178
  walletCount = 10
8397
8179
  } = {}) => {
8398
8180
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8399
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8181
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8400
8182
  const wallets = await generateWallets(walletCount, provider);
8401
8183
  const cleanup = () => {
8402
8184
  closeNode();