@fuel-ts/account 0.0.0-rc-1764-20240404125616 → 0.0.0-rc-1832-20240404143349

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 (52) 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 +558 -772
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +511 -764
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +392 -644
  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 +305 -824
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +0 -3
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +24 -44
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/input.d.ts +2 -2
  31. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/transaction-request.d.ts +25 -8
  34. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/utils.d.ts +0 -3
  36. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  37. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  38. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/utils/gas.d.ts +2 -8
  44. package/dist/providers/utils/gas.d.ts.map +1 -1
  45. package/dist/test-utils.global.js +551 -729
  46. package/dist/test-utils.global.js.map +1 -1
  47. package/dist/test-utils.js +490 -705
  48. package/dist/test-utils.js.map +1 -1
  49. package/dist/test-utils.mjs +379 -594
  50. package/dist/test-utils.mjs.map +1 -1
  51. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  52. package/package.json +17 -17
@@ -27,9 +27,8 @@ import { Address as Address3 } from "@fuel-ts/address";
27
27
  import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
28
28
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
29
29
  import { AbstractAccount } from "@fuel-ts/interfaces";
30
- import { bn as bn18 } from "@fuel-ts/math";
30
+ import { bn as bn17 } from "@fuel-ts/math";
31
31
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
32
- import { clone as clone4 } from "ramda";
33
32
 
34
33
  // src/providers/coin-quantity.ts
35
34
  import { BaseAssetId } from "@fuel-ts/address/configs";
@@ -38,24 +37,24 @@ import { hexlify } from "@fuel-ts/utils";
38
37
  var coinQuantityfy = (coinQuantityLike) => {
39
38
  let assetId;
40
39
  let amount;
41
- let max;
40
+ let max2;
42
41
  if (Array.isArray(coinQuantityLike)) {
43
42
  amount = coinQuantityLike[0];
44
43
  assetId = coinQuantityLike[1] ?? BaseAssetId;
45
- max = coinQuantityLike[2] ?? void 0;
44
+ max2 = coinQuantityLike[2] ?? void 0;
46
45
  } else {
47
46
  amount = coinQuantityLike.amount;
48
47
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
49
- max = coinQuantityLike.max ?? void 0;
48
+ max2 = coinQuantityLike.max ?? void 0;
50
49
  }
51
50
  const bnAmount = bn(amount);
52
51
  return {
53
52
  assetId: hexlify(assetId),
54
53
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
55
- max: max ? bn(max) : void 0
54
+ max: max2 ? bn(max2) : void 0
56
55
  };
57
56
  };
58
- var addAmountToCoinQuantities = (params) => {
57
+ var addAmountToAsset = (params) => {
59
58
  const { amount, assetId } = params;
60
59
  const coinQuantities = [...params.coinQuantities];
61
60
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -70,9 +69,9 @@ var addAmountToCoinQuantities = (params) => {
70
69
  // src/providers/provider.ts
71
70
  import { Address as Address2 } from "@fuel-ts/address";
72
71
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
73
- import { BN, bn as bn16 } from "@fuel-ts/math";
72
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
74
73
  import {
75
- InputType as InputType7,
74
+ InputType as InputType6,
76
75
  TransactionType as TransactionType8,
77
76
  InputMessageCoder,
78
77
  TransactionCoder as TransactionCoder5
@@ -88,10 +87,14 @@ import { clone as clone3 } from "ramda";
88
87
  import gql from "graphql-tag";
89
88
  var ReceiptFragmentFragmentDoc = gql`
90
89
  fragment receiptFragment on Receipt {
91
- id
90
+ contract {
91
+ id
92
+ }
92
93
  pc
93
94
  is
94
- to
95
+ to {
96
+ id
97
+ }
95
98
  toAddress
96
99
  amount
97
100
  assetId
@@ -129,16 +132,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
129
132
  id
130
133
  }
131
134
  time
132
- receipts {
133
- ...receiptFragment
134
- }
135
135
  programState {
136
136
  returnType
137
137
  data
138
138
  }
139
- receipts {
140
- ...receiptFragment
141
- }
142
139
  }
143
140
  ... on FailureStatus {
144
141
  block {
@@ -146,24 +143,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
146
143
  }
147
144
  time
148
145
  reason
149
- receipts {
150
- ...receiptFragment
151
- }
152
146
  }
153
147
  ... on SqueezedOutStatus {
154
148
  reason
155
149
  }
156
150
  }
157
- ${ReceiptFragmentFragmentDoc}`;
151
+ `;
158
152
  var TransactionFragmentFragmentDoc = gql`
159
153
  fragment transactionFragment on Transaction {
160
154
  id
161
155
  rawPayload
156
+ gasPrice
157
+ receipts {
158
+ ...receiptFragment
159
+ }
162
160
  status {
163
161
  ...transactionStatusFragment
164
162
  }
165
163
  }
166
- ${TransactionStatusFragmentFragmentDoc}`;
164
+ ${ReceiptFragmentFragmentDoc}
165
+ ${TransactionStatusFragmentFragmentDoc}`;
167
166
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
168
167
  fragment inputEstimatePredicatesFragment on Input {
169
168
  ... on InputCoin {
@@ -181,46 +180,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
181
180
  }
182
181
  }
183
182
  ${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
183
  var CoinFragmentFragmentDoc = gql`
225
184
  fragment coinFragment on Coin {
226
185
  __typename
@@ -228,6 +187,7 @@ var CoinFragmentFragmentDoc = gql`
228
187
  owner
229
188
  amount
230
189
  assetId
190
+ maturity
231
191
  blockCreated
232
192
  txCreatedIdx
233
193
  }
@@ -304,8 +264,8 @@ var BalanceFragmentFragmentDoc = gql`
304
264
  var BlockFragmentFragmentDoc = gql`
305
265
  fragment blockFragment on Block {
306
266
  id
307
- height
308
267
  header {
268
+ height
309
269
  time
310
270
  }
311
271
  transactions {
@@ -375,6 +335,7 @@ var GasCostsFragmentFragmentDoc = gql`
375
335
  cb
376
336
  cfei
377
337
  cfsi
338
+ croo
378
339
  div
379
340
  divi
380
341
  ecr1
@@ -457,9 +418,6 @@ var GasCostsFragmentFragmentDoc = gql`
457
418
  ccp {
458
419
  ...DependentCostFragment
459
420
  }
460
- croo {
461
- ...DependentCostFragment
462
- }
463
421
  csiz {
464
422
  ...DependentCostFragment
465
423
  }
@@ -582,6 +540,14 @@ var NodeInfoFragmentFragmentDoc = gql`
582
540
  maxTx
583
541
  maxDepth
584
542
  nodeVersion
543
+ peers {
544
+ id
545
+ addresses
546
+ clientVersion
547
+ blockHeight
548
+ lastHeartbeatMs
549
+ appScore
550
+ }
585
551
  }
586
552
  `;
587
553
  var GetVersionDocument = gql`
@@ -616,9 +582,13 @@ var GetTransactionWithReceiptsDocument = gql`
616
582
  query getTransactionWithReceipts($transactionId: TransactionId!) {
617
583
  transaction(id: $transactionId) {
618
584
  ...transactionFragment
585
+ receipts {
586
+ ...receiptFragment
587
+ }
619
588
  }
620
589
  }
621
- ${TransactionFragmentFragmentDoc}`;
590
+ ${TransactionFragmentFragmentDoc}
591
+ ${ReceiptFragmentFragmentDoc}`;
622
592
  var GetTransactionsDocument = gql`
623
593
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
624
594
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -746,20 +716,6 @@ var GetBalanceDocument = gql`
746
716
  }
747
717
  }
748
718
  ${BalanceFragmentFragmentDoc}`;
749
- var GetLatestGasPriceDocument = gql`
750
- query getLatestGasPrice {
751
- latestGasPrice {
752
- gasPrice
753
- }
754
- }
755
- `;
756
- var EstimateGasPriceDocument = gql`
757
- query estimateGasPrice($blockHorizon: U32!) {
758
- estimateGasPrice(blockHorizon: $blockHorizon) {
759
- gasPrice
760
- }
761
- }
762
- `;
763
719
  var GetBalancesDocument = gql`
764
720
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
765
721
  balances(
@@ -814,12 +770,12 @@ var GetMessageStatusDocument = gql`
814
770
  }
815
771
  `;
816
772
  var DryRunDocument = gql`
817
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
818
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
819
- ...dryRunTransactionExecutionStatusFragment
773
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
774
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
775
+ ...receiptFragment
820
776
  }
821
777
  }
822
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
778
+ ${ReceiptFragmentFragmentDoc}`;
823
779
  var SubmitDocument = gql`
824
780
  mutation submit($encodedTransaction: HexString!) {
825
781
  submit(tx: $encodedTransaction) {
@@ -902,12 +858,6 @@ function getSdk(requester) {
902
858
  getBalance(variables, options) {
903
859
  return requester(GetBalanceDocument, variables, options);
904
860
  },
905
- getLatestGasPrice(variables, options) {
906
- return requester(GetLatestGasPriceDocument, variables, options);
907
- },
908
- estimateGasPrice(variables, options) {
909
- return requester(EstimateGasPriceDocument, variables, options);
910
- },
911
861
  getBalances(variables, options) {
912
862
  return requester(GetBalancesDocument, variables, options);
913
863
  },
@@ -1091,6 +1041,7 @@ var inputify = (value) => {
1091
1041
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1092
1042
  },
1093
1043
  witnessIndex: value.witnessIndex,
1044
+ maturity: value.maturity ?? 0,
1094
1045
  predicateGasUsed: bn2(value.predicateGasUsed),
1095
1046
  predicateLength: predicate.length,
1096
1047
  predicateDataLength: predicateData.length,
@@ -1210,7 +1161,6 @@ import {
1210
1161
  TransactionType
1211
1162
  } from "@fuel-ts/transactions";
1212
1163
  import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1213
- import { randomBytes } from "ethers";
1214
1164
 
1215
1165
  // src/providers/resource.ts
1216
1166
  var isCoin = (resource) => "id" in resource;
@@ -1251,8 +1201,8 @@ function assembleReceiptByType(receipt) {
1251
1201
  case "CALL" /* Call */: {
1252
1202
  const callReceipt = {
1253
1203
  type: ReceiptType.Call,
1254
- from: hexOrZero(receipt.id || receipt.contractId),
1255
- to: hexOrZero(receipt?.to),
1204
+ from: hexOrZero(receipt.contract?.id),
1205
+ to: hexOrZero(receipt?.to?.id),
1256
1206
  amount: bn4(receipt.amount),
1257
1207
  assetId: hexOrZero(receipt.assetId),
1258
1208
  gas: bn4(receipt.gas),
@@ -1266,7 +1216,7 @@ function assembleReceiptByType(receipt) {
1266
1216
  case "RETURN" /* Return */: {
1267
1217
  const returnReceipt = {
1268
1218
  type: ReceiptType.Return,
1269
- id: hexOrZero(receipt.id || receipt.contractId),
1219
+ id: hexOrZero(receipt.contract?.id),
1270
1220
  val: bn4(receipt.val),
1271
1221
  pc: bn4(receipt.pc),
1272
1222
  is: bn4(receipt.is)
@@ -1276,7 +1226,7 @@ function assembleReceiptByType(receipt) {
1276
1226
  case "RETURN_DATA" /* ReturnData */: {
1277
1227
  const returnDataReceipt = {
1278
1228
  type: ReceiptType.ReturnData,
1279
- id: hexOrZero(receipt.id || receipt.contractId),
1229
+ id: hexOrZero(receipt.contract?.id),
1280
1230
  ptr: bn4(receipt.ptr),
1281
1231
  len: bn4(receipt.len),
1282
1232
  digest: hexOrZero(receipt.digest),
@@ -1288,7 +1238,7 @@ function assembleReceiptByType(receipt) {
1288
1238
  case "PANIC" /* Panic */: {
1289
1239
  const panicReceipt = {
1290
1240
  type: ReceiptType.Panic,
1291
- id: hexOrZero(receipt.id),
1241
+ id: hexOrZero(receipt.contract?.id),
1292
1242
  reason: bn4(receipt.reason),
1293
1243
  pc: bn4(receipt.pc),
1294
1244
  is: bn4(receipt.is),
@@ -1299,7 +1249,7 @@ function assembleReceiptByType(receipt) {
1299
1249
  case "REVERT" /* Revert */: {
1300
1250
  const revertReceipt = {
1301
1251
  type: ReceiptType.Revert,
1302
- id: hexOrZero(receipt.id || receipt.contractId),
1252
+ id: hexOrZero(receipt.contract?.id),
1303
1253
  val: bn4(receipt.ra),
1304
1254
  pc: bn4(receipt.pc),
1305
1255
  is: bn4(receipt.is)
@@ -1309,7 +1259,7 @@ function assembleReceiptByType(receipt) {
1309
1259
  case "LOG" /* Log */: {
1310
1260
  const logReceipt = {
1311
1261
  type: ReceiptType.Log,
1312
- id: hexOrZero(receipt.id || receipt.contractId),
1262
+ id: hexOrZero(receipt.contract?.id),
1313
1263
  val0: bn4(receipt.ra),
1314
1264
  val1: bn4(receipt.rb),
1315
1265
  val2: bn4(receipt.rc),
@@ -1322,7 +1272,7 @@ function assembleReceiptByType(receipt) {
1322
1272
  case "LOG_DATA" /* LogData */: {
1323
1273
  const logDataReceipt = {
1324
1274
  type: ReceiptType.LogData,
1325
- id: hexOrZero(receipt.id || receipt.contractId),
1275
+ id: hexOrZero(receipt.contract?.id),
1326
1276
  val0: bn4(receipt.ra),
1327
1277
  val1: bn4(receipt.rb),
1328
1278
  ptr: bn4(receipt.ptr),
@@ -1336,8 +1286,8 @@ function assembleReceiptByType(receipt) {
1336
1286
  case "TRANSFER" /* Transfer */: {
1337
1287
  const transferReceipt = {
1338
1288
  type: ReceiptType.Transfer,
1339
- from: hexOrZero(receipt.id || receipt.contractId),
1340
- to: hexOrZero(receipt.toAddress || receipt?.to),
1289
+ from: hexOrZero(receipt.contract?.id),
1290
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1341
1291
  amount: bn4(receipt.amount),
1342
1292
  assetId: hexOrZero(receipt.assetId),
1343
1293
  pc: bn4(receipt.pc),
@@ -1348,8 +1298,8 @@ function assembleReceiptByType(receipt) {
1348
1298
  case "TRANSFER_OUT" /* TransferOut */: {
1349
1299
  const transferOutReceipt = {
1350
1300
  type: ReceiptType.TransferOut,
1351
- from: hexOrZero(receipt.id || receipt.contractId),
1352
- to: hexOrZero(receipt.toAddress || receipt.to),
1301
+ from: hexOrZero(receipt.contract?.id),
1302
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1353
1303
  amount: bn4(receipt.amount),
1354
1304
  assetId: hexOrZero(receipt.assetId),
1355
1305
  pc: bn4(receipt.pc),
@@ -1392,7 +1342,7 @@ function assembleReceiptByType(receipt) {
1392
1342
  return receiptMessageOut;
1393
1343
  }
1394
1344
  case "MINT" /* Mint */: {
1395
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1345
+ const contractId = hexOrZero(receipt.contract?.id);
1396
1346
  const subId = hexOrZero(receipt.subId);
1397
1347
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1398
1348
  const mintReceipt = {
@@ -1407,7 +1357,7 @@ function assembleReceiptByType(receipt) {
1407
1357
  return mintReceipt;
1408
1358
  }
1409
1359
  case "BURN" /* Burn */: {
1410
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1360
+ const contractId = hexOrZero(receipt.contract?.id);
1411
1361
  const subId = hexOrZero(receipt.subId);
1412
1362
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1413
1363
  const burnReceipt = {
@@ -1433,6 +1383,7 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
1433
1383
  import { bn as bn5 } from "@fuel-ts/math";
1434
1384
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1435
1385
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1386
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1436
1387
  var getGasUsedFromReceipts = (receipts) => {
1437
1388
  const scriptResult = receipts.filter(
1438
1389
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1453,28 +1404,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1453
1404
  }
1454
1405
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1455
1406
  const witnessCache = [];
1456
- const chargeableInputs = inputs.filter((input) => {
1457
- const isCoinOrMessage = "owner" in input || "sender" in input;
1458
- if (isCoinOrMessage) {
1459
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1460
- return true;
1461
- }
1462
- if (!witnessCache.includes(input.witnessIndex)) {
1463
- witnessCache.push(input.witnessIndex);
1464
- return true;
1465
- }
1466
- }
1467
- return false;
1468
- });
1469
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1470
- const totalGas = chargeableInputs.reduce((total, input) => {
1407
+ const totalGas = inputs.reduce((total, input) => {
1471
1408
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1472
1409
  return total.add(
1473
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1410
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1474
1411
  );
1475
1412
  }
1476
- return total.add(gasCosts.ecr1);
1477
- }, bn5(0));
1413
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1414
+ witnessCache.push(input.witnessIndex);
1415
+ return total.add(gasCosts.ecr1);
1416
+ }
1417
+ return total;
1418
+ }, bn5());
1478
1419
  return totalGas;
1479
1420
  }
1480
1421
  function getMinGas(params) {
@@ -1486,20 +1427,12 @@ function getMinGas(params) {
1486
1427
  return minGas;
1487
1428
  }
1488
1429
  function getMaxGas(params) {
1489
- const {
1490
- gasPerByte,
1491
- witnessesLength,
1492
- witnessLimit,
1493
- minGas,
1494
- gasLimit = bn5(0),
1495
- maxGasPerTx
1496
- } = params;
1430
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1497
1431
  let remainingAllowedWitnessGas = bn5(0);
1498
1432
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1499
1433
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1500
1434
  }
1501
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1502
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1435
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1503
1436
  }
1504
1437
  function calculateMetadataGasForTxCreate({
1505
1438
  gasCosts,
@@ -1521,10 +1454,6 @@ function calculateMetadataGasForTxScript({
1521
1454
  }) {
1522
1455
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1523
1456
  }
1524
- var calculateGasFee = (params) => {
1525
- const { gas, gasPrice, priceFactor, tip } = params;
1526
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1527
- };
1528
1457
 
1529
1458
  // src/providers/utils/json.ts
1530
1459
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1669,7 +1598,7 @@ var witnessify = (value) => {
1669
1598
  // src/providers/transaction-request/transaction-request.ts
1670
1599
  var BaseTransactionRequest = class {
1671
1600
  /** Gas price for transaction */
1672
- tip;
1601
+ gasPrice;
1673
1602
  /** Block until which tx cannot be included */
1674
1603
  maturity;
1675
1604
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1688,7 +1617,7 @@ var BaseTransactionRequest = class {
1688
1617
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1689
1618
  */
1690
1619
  constructor({
1691
- tip,
1620
+ gasPrice,
1692
1621
  maturity,
1693
1622
  maxFee,
1694
1623
  witnessLimit,
@@ -1696,7 +1625,7 @@ var BaseTransactionRequest = class {
1696
1625
  outputs,
1697
1626
  witnesses
1698
1627
  } = {}) {
1699
- this.tip = bn7(tip);
1628
+ this.gasPrice = bn7(gasPrice);
1700
1629
  this.maturity = maturity ?? 0;
1701
1630
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1702
1631
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
@@ -1707,9 +1636,9 @@ var BaseTransactionRequest = class {
1707
1636
  static getPolicyMeta(req) {
1708
1637
  let policyTypes = 0;
1709
1638
  const policies = [];
1710
- if (req.tip) {
1711
- policyTypes += PolicyType.Tip;
1712
- policies.push({ data: req.tip, type: PolicyType.Tip });
1639
+ if (req.gasPrice) {
1640
+ policyTypes += PolicyType.GasPrice;
1641
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1713
1642
  }
1714
1643
  if (req.witnessLimit) {
1715
1644
  policyTypes += PolicyType.WitnessLimit;
@@ -1896,10 +1825,10 @@ var BaseTransactionRequest = class {
1896
1825
  * @param predicate - Predicate bytes.
1897
1826
  * @param predicateData - Predicate data bytes.
1898
1827
  */
1899
- addCoinInput(coin) {
1828
+ addCoinInput(coin, predicate) {
1900
1829
  const { assetId, owner, amount } = coin;
1901
1830
  let witnessIndex;
1902
- if (coin.predicate) {
1831
+ if (predicate) {
1903
1832
  witnessIndex = 0;
1904
1833
  } else {
1905
1834
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1914,7 +1843,9 @@ var BaseTransactionRequest = class {
1914
1843
  amount,
1915
1844
  assetId,
1916
1845
  txPointer: "0x00000000000000000000000000000000",
1917
- witnessIndex
1846
+ witnessIndex,
1847
+ predicate: predicate?.bytes,
1848
+ predicateData: predicate?.predicateDataBytes
1918
1849
  };
1919
1850
  this.pushInput(input);
1920
1851
  this.addChangeOutput(owner, assetId);
@@ -1927,11 +1858,11 @@ var BaseTransactionRequest = class {
1927
1858
  * @param predicate - Predicate bytes.
1928
1859
  * @param predicateData - Predicate data bytes.
1929
1860
  */
1930
- addMessageInput(message) {
1861
+ addMessageInput(message, predicate) {
1931
1862
  const { recipient, sender, amount } = message;
1932
1863
  const assetId = BaseAssetId2;
1933
1864
  let witnessIndex;
1934
- if (message.predicate) {
1865
+ if (predicate) {
1935
1866
  witnessIndex = 0;
1936
1867
  } else {
1937
1868
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1945,7 +1876,9 @@ var BaseTransactionRequest = class {
1945
1876
  sender: sender.toB256(),
1946
1877
  recipient: recipient.toB256(),
1947
1878
  amount,
1948
- witnessIndex
1879
+ witnessIndex,
1880
+ predicate: predicate?.bytes,
1881
+ predicateData: predicate?.predicateDataBytes
1949
1882
  };
1950
1883
  this.pushInput(input);
1951
1884
  this.addChangeOutput(recipient, assetId);
@@ -1976,6 +1909,32 @@ var BaseTransactionRequest = class {
1976
1909
  resources.forEach((resource) => this.addResource(resource));
1977
1910
  return this;
1978
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
+ }
1979
1938
  /**
1980
1939
  * Adds a coin output to the transaction.
1981
1940
  *
@@ -2055,7 +2014,7 @@ var BaseTransactionRequest = class {
2055
2014
  }
2056
2015
  calculateMaxGas(chainInfo, minGas) {
2057
2016
  const { consensusParameters } = chainInfo;
2058
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2017
+ const { gasPerByte } = consensusParameters;
2059
2018
  const witnessesLength = this.toTransaction().witnesses.reduce(
2060
2019
  (acc, wit) => acc + wit.dataLength,
2061
2020
  0
@@ -2064,8 +2023,7 @@ var BaseTransactionRequest = class {
2064
2023
  gasPerByte,
2065
2024
  minGas,
2066
2025
  witnessesLength,
2067
- witnessLimit: this.witnessLimit,
2068
- maxGasPerTx
2026
+ witnessLimit: this.witnessLimit
2069
2027
  });
2070
2028
  }
2071
2029
  /**
@@ -2075,6 +2033,12 @@ var BaseTransactionRequest = class {
2075
2033
  * @param quantities - CoinQuantity Array.
2076
2034
  */
2077
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
+ };
2078
2042
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2079
2043
  if ("assetId" in input) {
2080
2044
  return input.assetId === assetId;
@@ -2083,20 +2047,17 @@ var BaseTransactionRequest = class {
2083
2047
  });
2084
2048
  const updateAssetInput = (assetId, quantity) => {
2085
2049
  const assetInput = findAssetInput(assetId);
2086
- let usedQuantity = quantity;
2087
- if (assetId === BaseAssetId2) {
2088
- usedQuantity = bn7("1000000000000000000");
2089
- }
2090
2050
  if (assetInput && "assetId" in assetInput) {
2091
- assetInput.id = hexlify7(randomBytes(33));
2092
- assetInput.amount = usedQuantity;
2051
+ assetInput.id = generateId();
2052
+ assetInput.amount = quantity;
2093
2053
  } else {
2094
2054
  this.addResources([
2095
2055
  {
2096
- id: hexlify7(randomBytes(33)),
2097
- amount: usedQuantity,
2056
+ id: generateId(),
2057
+ amount: quantity,
2098
2058
  assetId,
2099
2059
  owner: resourcesOwner || Address.fromRandom(),
2060
+ maturity: 0,
2100
2061
  blockCreated: bn7(1),
2101
2062
  txCreatedIdx: bn7(1)
2102
2063
  }
@@ -2128,7 +2089,7 @@ var BaseTransactionRequest = class {
2128
2089
  toJSON() {
2129
2090
  return normalizeJSON(this);
2130
2091
  }
2131
- updatePredicateGasUsed(inputs) {
2092
+ updatePredicateInputs(inputs) {
2132
2093
  this.inputs.forEach((i) => {
2133
2094
  let correspondingInput;
2134
2095
  switch (i.type) {
@@ -2150,15 +2111,6 @@ var BaseTransactionRequest = class {
2150
2111
  }
2151
2112
  });
2152
2113
  }
2153
- shiftPredicateData() {
2154
- this.inputs.forEach((input) => {
2155
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2156
- input.predicateData = input.paddPredicateData(
2157
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2158
- );
2159
- }
2160
- });
2161
- }
2162
2114
  };
2163
2115
 
2164
2116
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2495,7 +2447,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2495
2447
  }
2496
2448
  calculateMaxGas(chainInfo, minGas) {
2497
2449
  const { consensusParameters } = chainInfo;
2498
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2450
+ const { gasPerByte } = consensusParameters;
2499
2451
  const witnessesLength = this.toTransaction().witnesses.reduce(
2500
2452
  (acc, wit) => acc + wit.dataLength,
2501
2453
  0
@@ -2505,8 +2457,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2505
2457
  minGas,
2506
2458
  witnessesLength,
2507
2459
  witnessLimit: this.witnessLimit,
2508
- gasLimit: this.gasLimit,
2509
- maxGasPerTx
2460
+ gasLimit: this.gasLimit
2510
2461
  });
2511
2462
  }
2512
2463
  /**
@@ -2563,7 +2514,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2563
2514
 
2564
2515
  // src/providers/transaction-request/utils.ts
2565
2516
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2566
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2517
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2567
2518
  var transactionRequestify = (obj) => {
2568
2519
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2569
2520
  return obj;
@@ -2581,31 +2532,14 @@ var transactionRequestify = (obj) => {
2581
2532
  }
2582
2533
  }
2583
2534
  };
2584
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2585
- (acc, input) => {
2586
- if (input.type === InputType5.Coin && input.owner === owner) {
2587
- acc.utxos.push(input.id);
2588
- }
2589
- if (input.type === InputType5.Message && input.recipient === owner) {
2590
- acc.messages.push(input.nonce);
2591
- }
2592
- return acc;
2593
- },
2594
- {
2595
- utxos: [],
2596
- messages: []
2597
- }
2598
- );
2599
2535
 
2600
2536
  // src/providers/transaction-response/transaction-response.ts
2601
2537
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2602
- import { bn as bn15 } from "@fuel-ts/math";
2538
+ import { bn as bn14 } from "@fuel-ts/math";
2603
2539
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2604
2540
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2605
2541
 
2606
2542
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2607
- import { bn as bn14 } from "@fuel-ts/math";
2608
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2609
2543
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2610
2544
 
2611
2545
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2614,10 +2548,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2614
2548
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2615
2549
  var calculateTransactionFee = (params) => {
2616
2550
  const {
2617
- gasPrice,
2551
+ gasUsed,
2618
2552
  rawPayload,
2619
- tip,
2620
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2553
+ consensusParameters: { gasCosts, feeParams }
2621
2554
  } = params;
2622
2555
  const gasPerByte = bn11(feeParams.gasPerByte);
2623
2556
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2627,7 +2560,8 @@ var calculateTransactionFee = (params) => {
2627
2560
  return {
2628
2561
  fee: bn11(0),
2629
2562
  minFee: bn11(0),
2630
- maxFee: bn11(0)
2563
+ maxFee: bn11(0),
2564
+ feeFromGasUsed: bn11(0)
2631
2565
  };
2632
2566
  }
2633
2567
  const { type, witnesses, inputs, policies } = transaction;
@@ -2659,6 +2593,7 @@ var calculateTransactionFee = (params) => {
2659
2593
  metadataGas,
2660
2594
  txBytesSize: transactionBytes.length
2661
2595
  });
2596
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2662
2597
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2663
2598
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2664
2599
  const maxGas = getMaxGas({
@@ -2666,25 +2601,17 @@ var calculateTransactionFee = (params) => {
2666
2601
  minGas,
2667
2602
  witnessesLength,
2668
2603
  gasLimit,
2669
- witnessLimit,
2670
- maxGasPerTx
2671
- });
2672
- const minFee = calculateGasFee({
2673
- gasPrice,
2674
- gas: minGas,
2675
- priceFactor: gasPriceFactor,
2676
- tip
2677
- });
2678
- const maxFee = calculateGasFee({
2679
- gasPrice,
2680
- gas: maxGas,
2681
- priceFactor: gasPriceFactor,
2682
- tip
2604
+ witnessLimit
2683
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);
2684
2610
  return {
2611
+ fee,
2685
2612
  minFee,
2686
2613
  maxFee,
2687
- fee: maxFee
2614
+ feeFromGasUsed
2688
2615
  };
2689
2616
  };
2690
2617
 
@@ -2740,7 +2667,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2740
2667
 
2741
2668
  // src/providers/transaction-summary/input.ts
2742
2669
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2743
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2670
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2744
2671
  function getInputsByTypes(inputs, types) {
2745
2672
  return inputs.filter((i) => types.includes(i.type));
2746
2673
  }
@@ -2748,16 +2675,16 @@ function getInputsByType(inputs, type) {
2748
2675
  return inputs.filter((i) => i.type === type);
2749
2676
  }
2750
2677
  function getInputsCoin(inputs) {
2751
- return getInputsByType(inputs, InputType6.Coin);
2678
+ return getInputsByType(inputs, InputType5.Coin);
2752
2679
  }
2753
2680
  function getInputsMessage(inputs) {
2754
- return getInputsByType(inputs, InputType6.Message);
2681
+ return getInputsByType(inputs, InputType5.Message);
2755
2682
  }
2756
2683
  function getInputsCoinAndMessage(inputs) {
2757
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2684
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2758
2685
  }
2759
2686
  function getInputsContract(inputs) {
2760
- return getInputsByType(inputs, InputType6.Contract);
2687
+ return getInputsByType(inputs, InputType5.Contract);
2761
2688
  }
2762
2689
  function getInputFromAssetId(inputs, assetId) {
2763
2690
  const coinInputs = getInputsCoin(inputs);
@@ -2776,7 +2703,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2776
2703
  if (!contractInput) {
2777
2704
  return void 0;
2778
2705
  }
2779
- if (contractInput.type !== InputType6.Contract) {
2706
+ if (contractInput.type !== InputType5.Contract) {
2780
2707
  throw new FuelError9(
2781
2708
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2782
2709
  `Contract input should be of type 'contract'.`
@@ -2785,10 +2712,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2785
2712
  return contractInput;
2786
2713
  }
2787
2714
  function getInputAccountAddress(input) {
2788
- if (input.type === InputType6.Coin) {
2715
+ if (input.type === InputType5.Coin) {
2789
2716
  return input.owner.toString();
2790
2717
  }
2791
- if (input.type === InputType6.Message) {
2718
+ if (input.type === InputType5.Message) {
2792
2719
  return input.recipient.toString();
2793
2720
  }
2794
2721
  return "";
@@ -3251,9 +3178,7 @@ function assembleTransactionSummary(params) {
3251
3178
  gqlTransactionStatus,
3252
3179
  abiMap = {},
3253
3180
  maxInputs,
3254
- gasCosts,
3255
- maxGasPerTx,
3256
- gasPrice
3181
+ gasCosts
3257
3182
  } = params;
3258
3183
  const gasUsed = getGasUsedFromReceipts(receipts);
3259
3184
  const rawPayload = hexlify11(transactionBytes);
@@ -3267,14 +3192,11 @@ function assembleTransactionSummary(params) {
3267
3192
  maxInputs
3268
3193
  });
3269
3194
  const typeName = getTransactionTypeName(transaction.type);
3270
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3271
3195
  const { fee } = calculateTransactionFee({
3272
- gasPrice,
3196
+ gasUsed,
3273
3197
  rawPayload,
3274
- tip,
3275
3198
  consensusParameters: {
3276
3199
  gasCosts,
3277
- maxGasPerTx,
3278
3200
  feeParams: {
3279
3201
  gasPerByte,
3280
3202
  gasPriceFactor
@@ -3334,7 +3256,7 @@ var TransactionResponse = class {
3334
3256
  /** Current provider */
3335
3257
  provider;
3336
3258
  /** Gas used on the transaction */
3337
- gasUsed = bn15(0);
3259
+ gasUsed = bn14(0);
3338
3260
  /** The graphql Transaction with receipts object. */
3339
3261
  gqlTransaction;
3340
3262
  abis;
@@ -3412,13 +3334,8 @@ var TransactionResponse = class {
3412
3334
  const decodedTransaction = this.decodeTransaction(
3413
3335
  transaction
3414
3336
  );
3415
- let txReceipts = [];
3416
- if (transaction?.status && "receipts" in transaction.status) {
3417
- txReceipts = transaction.status.receipts;
3418
- }
3419
- const receipts = txReceipts.map(processGqlReceipt) || [];
3420
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3421
- const gasPrice = await this.provider.getLatestGasPrice();
3337
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3338
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3422
3339
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3423
3340
  const transactionSummary = assembleTransactionSummary({
3424
3341
  id: this.id,
@@ -3430,9 +3347,7 @@ var TransactionResponse = class {
3430
3347
  gasPriceFactor,
3431
3348
  abiMap: contractsAbiMap,
3432
3349
  maxInputs,
3433
- gasCosts,
3434
- maxGasPerTx,
3435
- gasPrice
3350
+ gasCosts
3436
3351
  });
3437
3352
  return transactionSummary;
3438
3353
  }
@@ -3559,29 +3474,29 @@ var processGqlChain = (chain) => {
3559
3474
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3560
3475
  return {
3561
3476
  name,
3562
- baseChainHeight: bn16(daHeight),
3477
+ baseChainHeight: bn15(daHeight),
3563
3478
  consensusParameters: {
3564
- contractMaxSize: bn16(contractParams.contractMaxSize),
3565
- maxInputs: bn16(txParams.maxInputs),
3566
- maxOutputs: bn16(txParams.maxOutputs),
3567
- maxWitnesses: bn16(txParams.maxWitnesses),
3568
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3569
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3570
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3571
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3572
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3573
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3574
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3575
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3576
- gasPerByte: bn16(feeParams.gasPerByte),
3577
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3578
- 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),
3579
3494
  gasCosts
3580
3495
  },
3581
3496
  gasCosts,
3582
3497
  latestBlock: {
3583
3498
  id: latestBlock.id,
3584
- height: bn16(latestBlock.height),
3499
+ height: bn15(latestBlock.header.height),
3585
3500
  time: latestBlock.header.time,
3586
3501
  transactions: latestBlock.transactions.map((i) => ({
3587
3502
  id: i.id
@@ -3776,7 +3691,7 @@ var _Provider = class {
3776
3691
  */
3777
3692
  async getBlockNumber() {
3778
3693
  const { chain } = await this.operations.getChain();
3779
- return bn16(chain.latestBlock.height, 10);
3694
+ return bn15(chain.latestBlock.header.height, 10);
3780
3695
  }
3781
3696
  /**
3782
3697
  * Returns the chain information.
@@ -3786,12 +3701,13 @@ var _Provider = class {
3786
3701
  async fetchNode() {
3787
3702
  const { nodeInfo } = await this.operations.getNodeInfo();
3788
3703
  const processedNodeInfo = {
3789
- maxDepth: bn16(nodeInfo.maxDepth),
3790
- maxTx: bn16(nodeInfo.maxTx),
3791
- minGasPrice: bn16(nodeInfo.minGasPrice),
3704
+ maxDepth: bn15(nodeInfo.maxDepth),
3705
+ maxTx: bn15(nodeInfo.maxTx),
3706
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3792
3707
  nodeVersion: nodeInfo.nodeVersion,
3793
3708
  utxoValidation: nodeInfo.utxoValidation,
3794
- vmBacktrace: nodeInfo.vmBacktrace
3709
+ vmBacktrace: nodeInfo.vmBacktrace,
3710
+ peers: nodeInfo.peers
3795
3711
  };
3796
3712
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3797
3713
  return processedNodeInfo;
@@ -3877,13 +3793,14 @@ var _Provider = class {
3877
3793
  return this.estimateTxDependencies(transactionRequest);
3878
3794
  }
3879
3795
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3880
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3881
- encodedTransactions: encodedTransaction,
3796
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3797
+ encodedTransaction,
3882
3798
  utxoValidation: utxoValidation || false
3883
3799
  });
3884
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3885
- const receipts = rawReceipts.map(processGqlReceipt);
3886
- return { receipts, dryrunStatus: status };
3800
+ const receipts = gqlReceipts.map(processGqlReceipt);
3801
+ return {
3802
+ receipts
3803
+ };
3887
3804
  }
3888
3805
  /**
3889
3806
  * Verifies whether enough gas is available to complete transaction.
@@ -3909,7 +3826,7 @@ var _Provider = class {
3909
3826
  } = response;
3910
3827
  if (inputs) {
3911
3828
  inputs.forEach((input, index) => {
3912
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3829
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3913
3830
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3914
3831
  }
3915
3832
  });
@@ -3922,6 +3839,9 @@ var _Provider = class {
3922
3839
  * If there are missing variable outputs,
3923
3840
  * `addVariableOutputs` is called on the transaction.
3924
3841
  *
3842
+ * @privateRemarks
3843
+ * TODO: Investigate support for missing contract IDs
3844
+ * TODO: Add support for missing output messages
3925
3845
  *
3926
3846
  * @param transactionRequest - The transaction request object.
3927
3847
  * @returns A promise.
@@ -3934,19 +3854,16 @@ var _Provider = class {
3934
3854
  missingContractIds: []
3935
3855
  };
3936
3856
  }
3857
+ await this.estimatePredicates(transactionRequest);
3937
3858
  let receipts = [];
3938
3859
  const missingContractIds = [];
3939
3860
  let outputVariables = 0;
3940
- let dryrunStatus;
3941
3861
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3942
- const {
3943
- dryRun: [{ receipts: rawReceipts, status }]
3944
- } = await this.operations.dryRun({
3945
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3862
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3863
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3946
3864
  utxoValidation: false
3947
3865
  });
3948
- receipts = rawReceipts.map(processGqlReceipt);
3949
- dryrunStatus = status;
3866
+ receipts = gqlReceipts.map(processGqlReceipt);
3950
3867
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3951
3868
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3952
3869
  if (hasMissingOutputs) {
@@ -3956,11 +3873,6 @@ var _Provider = class {
3956
3873
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3957
3874
  missingContractIds.push(contractId);
3958
3875
  });
3959
- const { maxFee } = await this.estimateTxGasAndFee({
3960
- transactionRequest,
3961
- optimizeGas: false
3962
- });
3963
- transactionRequest.maxFee = maxFee;
3964
3876
  } else {
3965
3877
  break;
3966
3878
  }
@@ -3968,133 +3880,7 @@ var _Provider = class {
3968
3880
  return {
3969
3881
  receipts,
3970
3882
  outputVariables,
3971
- missingContractIds,
3972
- dryrunStatus
3973
- };
3974
- }
3975
- /**
3976
- * Dry runs multiple transactions and checks for missing dependencies in batches.
3977
- *
3978
- * Transactions are dry run in batches. After each dry run, transactions requiring
3979
- * further modifications are identified. The method iteratively updates these transactions
3980
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
3981
- *
3982
- * @param transactionRequests - Array of transaction request objects.
3983
- * @returns A promise that resolves to an array of results for each transaction.
3984
- */
3985
- async estimateMultipleTxDependencies(transactionRequests) {
3986
- const results = transactionRequests.map(() => ({
3987
- receipts: [],
3988
- outputVariables: 0,
3989
- missingContractIds: [],
3990
- dryrunStatus: void 0
3991
- }));
3992
- const allRequests = clone3(transactionRequests);
3993
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
3994
- allRequests.forEach((req, index) => {
3995
- if (req.type === TransactionType8.Script) {
3996
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
3997
- }
3998
- });
3999
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4000
- let attempt = 0;
4001
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4002
- const encodedTransactions = transactionsToProcess.map(
4003
- (index) => serializedTransactionsMap.get(index)
4004
- );
4005
- const dryRunResults = await this.operations.dryRun({
4006
- encodedTransactions,
4007
- utxoValidation: false
4008
- });
4009
- const nextRoundTransactions = [];
4010
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4011
- const currentResultIndex = transactionsToProcess[i];
4012
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4013
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4014
- results[currentResultIndex].dryrunStatus = status;
4015
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4016
- results[currentResultIndex].receipts
4017
- );
4018
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4019
- const requestToProcess = allRequests[currentResultIndex];
4020
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4021
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4022
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4023
- missingOutputContractIds.forEach(({ contractId }) => {
4024
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4025
- results[currentResultIndex].missingContractIds.push(contractId);
4026
- });
4027
- const { maxFee } = await this.estimateTxGasAndFee({
4028
- transactionRequest: requestToProcess,
4029
- optimizeGas: false
4030
- });
4031
- requestToProcess.maxFee = maxFee;
4032
- serializedTransactionsMap.set(
4033
- currentResultIndex,
4034
- hexlify12(requestToProcess.toTransactionBytes())
4035
- );
4036
- nextRoundTransactions.push(currentResultIndex);
4037
- allRequests[currentResultIndex] = requestToProcess;
4038
- }
4039
- }
4040
- transactionsToProcess = nextRoundTransactions;
4041
- attempt += 1;
4042
- }
4043
- return results;
4044
- }
4045
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4046
- if (estimateTxDependencies) {
4047
- return this.estimateMultipleTxDependencies(transactionRequests);
4048
- }
4049
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4050
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4051
- encodedTransactions,
4052
- utxoValidation: utxoValidation || false
4053
- });
4054
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4055
- const receipts = rawReceipts.map(processGqlReceipt);
4056
- return { receipts, dryrunStatus: status };
4057
- });
4058
- return results;
4059
- }
4060
- async estimateTxGasAndFee(params) {
4061
- const { transactionRequest, totalGasUsedByPredicates = bn16(0), optimizeGas = true } = params;
4062
- let { gasPrice } = params;
4063
- const chainInfo = this.getChain();
4064
- const { gasPriceFactor } = this.getGasConfig();
4065
- const minGas = transactionRequest.calculateMinGas(chainInfo);
4066
- if (!gasPrice) {
4067
- gasPrice = await this.estimateGasPrice(10);
4068
- }
4069
- const shouldSetGaslimit = transactionRequest.type === TransactionType8.Script && !optimizeGas;
4070
- const minFee = calculateGasFee({
4071
- gasPrice: bn16(gasPrice),
4072
- gas: minGas,
4073
- priceFactor: gasPriceFactor,
4074
- tip: transactionRequest.tip
4075
- }).add(1);
4076
- if (shouldSetGaslimit) {
4077
- transactionRequest.gasLimit = chainInfo.consensusParameters.maxGasPerTx.sub(
4078
- minGas.add(totalGasUsedByPredicates)
4079
- );
4080
- }
4081
- let maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4082
- const maxFee = calculateGasFee({
4083
- gasPrice: bn16(gasPrice),
4084
- gas: maxGas,
4085
- priceFactor: gasPriceFactor,
4086
- tip: transactionRequest.tip
4087
- }).add(1);
4088
- if (shouldSetGaslimit) {
4089
- maxGas = chainInfo.consensusParameters.maxGasPerTx.sub(maxFee);
4090
- transactionRequest.gasLimit = maxGas;
4091
- }
4092
- return {
4093
- minGas,
4094
- minFee,
4095
- maxGas,
4096
- maxFee,
4097
- gasPrice
3883
+ missingContractIds
4098
3884
  };
4099
3885
  }
4100
3886
  /**
@@ -4112,17 +3898,15 @@ var _Provider = class {
4112
3898
  if (estimateTxDependencies) {
4113
3899
  return this.estimateTxDependencies(transactionRequest);
4114
3900
  }
4115
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4116
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4117
- encodedTransactions,
3901
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3902
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3903
+ encodedTransaction,
4118
3904
  utxoValidation: true
4119
3905
  });
4120
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4121
- const { id, receipts, status } = dryRunStatus;
4122
- const processedReceipts = receipts.map(processGqlReceipt);
4123
- return { id, receipts: processedReceipts, status };
4124
- });
4125
- return { receipts: callResult[0].receipts };
3906
+ const receipts = gqlReceipts.map(processGqlReceipt);
3907
+ return {
3908
+ receipts
3909
+ };
4126
3910
  }
4127
3911
  /**
4128
3912
  * Returns a transaction cost to enable user
@@ -4139,80 +3923,80 @@ var _Provider = class {
4139
3923
  * @param tolerance - The tolerance to add on top of the gasUsed.
4140
3924
  * @returns A promise that resolves to the transaction cost object.
4141
3925
  */
4142
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3926
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3927
+ estimateTxDependencies = true,
3928
+ estimatePredicates = true,
3929
+ resourcesOwner,
3930
+ signatureCallback
3931
+ } = {}) {
4143
3932
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3933
+ const chainInfo = this.getChain();
3934
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3935
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
4144
3936
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4145
3937
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4146
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3938
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4147
3939
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4148
- txRequestClone.maxFee = bn16(0);
4149
- if (isScriptTransaction) {
4150
- txRequestClone.gasLimit = bn16(0);
4151
- }
4152
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4153
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3940
+ if (estimatePredicates) {
3941
+ if (isScriptTransaction) {
3942
+ txRequestClone.gasLimit = bn15(0);
3943
+ }
3944
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3945
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3946
+ }
3947
+ await this.estimatePredicates(txRequestClone);
4154
3948
  }
4155
- const signedRequest = clone3(txRequestClone);
4156
- let addedSignatures = 0;
4157
3949
  if (signatureCallback && isScriptTransaction) {
4158
- const lengthBefore = signedRequest.witnesses.length;
4159
- await signatureCallback(signedRequest);
4160
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4161
- }
4162
- await this.estimatePredicates(signedRequest);
4163
- let { maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4164
- transactionRequest: signedRequest,
4165
- optimizeGas: false
4166
- });
4167
- txRequestClone.maxFee = maxFee;
3950
+ await signatureCallback(txRequestClone);
3951
+ }
3952
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
3953
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4168
3954
  let receipts = [];
4169
3955
  let missingContractIds = [];
4170
3956
  let outputVariables = 0;
4171
- let gasUsed = bn16(0);
4172
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4173
- if (isScriptTransaction) {
4174
- if (signatureCallback) {
4175
- await signatureCallback(txRequestClone);
4176
- }
4177
- txRequestClone.gasLimit = maxGas;
3957
+ if (isScriptTransaction && estimateTxDependencies) {
3958
+ txRequestClone.gasPrice = bn15(0);
3959
+ txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4178
3960
  const result = await this.estimateTxDependencies(txRequestClone);
4179
3961
  receipts = result.receipts;
4180
3962
  outputVariables = result.outputVariables;
4181
3963
  missingContractIds = result.missingContractIds;
4182
- gasUsed = getGasUsedFromReceipts(receipts);
4183
- txRequestClone.gasLimit = gasUsed;
4184
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4185
- transactionRequest: txRequestClone,
4186
- gasPrice
4187
- }));
4188
3964
  }
3965
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3966
+ const usedFee = calculatePriceWithFactor(
3967
+ gasUsed,
3968
+ gasPrice,
3969
+ gasPriceFactor
3970
+ ).normalizeZeroToOne();
3971
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3972
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4189
3973
  return {
4190
3974
  requiredQuantities: allQuantities,
4191
3975
  receipts,
4192
3976
  gasUsed,
3977
+ minGasPrice,
4193
3978
  gasPrice,
4194
3979
  minGas,
4195
3980
  maxGas,
3981
+ usedFee,
4196
3982
  minFee,
4197
3983
  maxFee,
3984
+ estimatedInputs: txRequestClone.inputs,
4198
3985
  outputVariables,
4199
- missingContractIds,
4200
- addedSignatures,
4201
- estimatedPredicates: txRequestClone.inputs
3986
+ missingContractIds
4202
3987
  };
4203
3988
  }
4204
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
3989
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4205
3990
  const ownerAddress = Address2.fromAddressOrString(owner);
4206
3991
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4207
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4208
- quantitiesToContract
4209
- });
3992
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4210
3993
  transactionRequest.addResources(
4211
3994
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4212
3995
  );
4213
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4214
- quantitiesToContract
4215
- });
3996
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
3997
+ transactionRequest,
3998
+ forwardingQuantities
3999
+ );
4216
4000
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4217
4001
  return {
4218
4002
  resources,
@@ -4234,10 +4018,11 @@ var _Provider = class {
4234
4018
  return coins.map((coin) => ({
4235
4019
  id: coin.utxoId,
4236
4020
  assetId: coin.assetId,
4237
- amount: bn16(coin.amount),
4021
+ amount: bn15(coin.amount),
4238
4022
  owner: Address2.fromAddressOrString(coin.owner),
4239
- blockCreated: bn16(coin.blockCreated),
4240
- txCreatedIdx: bn16(coin.txCreatedIdx)
4023
+ maturity: bn15(coin.maturity).toNumber(),
4024
+ blockCreated: bn15(coin.blockCreated),
4025
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4241
4026
  }));
4242
4027
  }
4243
4028
  /**
@@ -4274,9 +4059,9 @@ var _Provider = class {
4274
4059
  switch (coin.__typename) {
4275
4060
  case "MessageCoin":
4276
4061
  return {
4277
- amount: bn16(coin.amount),
4062
+ amount: bn15(coin.amount),
4278
4063
  assetId: coin.assetId,
4279
- daHeight: bn16(coin.daHeight),
4064
+ daHeight: bn15(coin.daHeight),
4280
4065
  sender: Address2.fromAddressOrString(coin.sender),
4281
4066
  recipient: Address2.fromAddressOrString(coin.recipient),
4282
4067
  nonce: coin.nonce
@@ -4284,11 +4069,12 @@ var _Provider = class {
4284
4069
  case "Coin":
4285
4070
  return {
4286
4071
  id: coin.utxoId,
4287
- amount: bn16(coin.amount),
4072
+ amount: bn15(coin.amount),
4288
4073
  assetId: coin.assetId,
4289
4074
  owner: Address2.fromAddressOrString(coin.owner),
4290
- blockCreated: bn16(coin.blockCreated),
4291
- txCreatedIdx: bn16(coin.txCreatedIdx)
4075
+ maturity: bn15(coin.maturity).toNumber(),
4076
+ blockCreated: bn15(coin.blockCreated),
4077
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4292
4078
  };
4293
4079
  default:
4294
4080
  return null;
@@ -4305,13 +4091,13 @@ var _Provider = class {
4305
4091
  async getBlock(idOrHeight) {
4306
4092
  let variables;
4307
4093
  if (typeof idOrHeight === "number") {
4308
- variables = { height: bn16(idOrHeight).toString(10) };
4094
+ variables = { height: bn15(idOrHeight).toString(10) };
4309
4095
  } else if (idOrHeight === "latest") {
4310
4096
  variables = { height: (await this.getBlockNumber()).toString(10) };
4311
4097
  } else if (idOrHeight.length === 66) {
4312
4098
  variables = { blockId: idOrHeight };
4313
4099
  } else {
4314
- variables = { blockId: bn16(idOrHeight).toString(10) };
4100
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4315
4101
  }
4316
4102
  const { block } = await this.operations.getBlock(variables);
4317
4103
  if (!block) {
@@ -4319,7 +4105,7 @@ var _Provider = class {
4319
4105
  }
4320
4106
  return {
4321
4107
  id: block.id,
4322
- height: bn16(block.height),
4108
+ height: bn15(block.header.height),
4323
4109
  time: block.header.time,
4324
4110
  transactionIds: block.transactions.map((tx) => tx.id)
4325
4111
  };
@@ -4334,7 +4120,7 @@ var _Provider = class {
4334
4120
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4335
4121
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4336
4122
  id: block.id,
4337
- height: bn16(block.height),
4123
+ height: bn15(block.header.height),
4338
4124
  time: block.header.time,
4339
4125
  transactionIds: block.transactions.map((tx) => tx.id)
4340
4126
  }));
@@ -4349,7 +4135,7 @@ var _Provider = class {
4349
4135
  async getBlockWithTransactions(idOrHeight) {
4350
4136
  let variables;
4351
4137
  if (typeof idOrHeight === "number") {
4352
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4138
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4353
4139
  } else if (idOrHeight === "latest") {
4354
4140
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4355
4141
  } else {
@@ -4361,7 +4147,7 @@ var _Provider = class {
4361
4147
  }
4362
4148
  return {
4363
4149
  id: block.id,
4364
- height: bn16(block.height, 10),
4150
+ height: bn15(block.header.height, 10),
4365
4151
  time: block.header.time,
4366
4152
  transactionIds: block.transactions.map((tx) => tx.id),
4367
4153
  transactions: block.transactions.map(
@@ -4410,7 +4196,7 @@ var _Provider = class {
4410
4196
  contract: Address2.fromAddressOrString(contractId).toB256(),
4411
4197
  asset: hexlify12(assetId)
4412
4198
  });
4413
- return bn16(contractBalance.amount, 10);
4199
+ return bn15(contractBalance.amount, 10);
4414
4200
  }
4415
4201
  /**
4416
4202
  * Returns the balance for the given owner for the given asset ID.
@@ -4424,7 +4210,7 @@ var _Provider = class {
4424
4210
  owner: Address2.fromAddressOrString(owner).toB256(),
4425
4211
  assetId: hexlify12(assetId)
4426
4212
  });
4427
- return bn16(balance.amount, 10);
4213
+ return bn15(balance.amount, 10);
4428
4214
  }
4429
4215
  /**
4430
4216
  * Returns balances for the given owner.
@@ -4442,7 +4228,7 @@ var _Provider = class {
4442
4228
  const balances = result.balances.edges.map((edge) => edge.node);
4443
4229
  return balances.map((balance) => ({
4444
4230
  assetId: balance.assetId,
4445
- amount: bn16(balance.amount)
4231
+ amount: bn15(balance.amount)
4446
4232
  }));
4447
4233
  }
4448
4234
  /**
@@ -4464,15 +4250,15 @@ var _Provider = class {
4464
4250
  sender: message.sender,
4465
4251
  recipient: message.recipient,
4466
4252
  nonce: message.nonce,
4467
- amount: bn16(message.amount),
4253
+ amount: bn15(message.amount),
4468
4254
  data: message.data
4469
4255
  }),
4470
4256
  sender: Address2.fromAddressOrString(message.sender),
4471
4257
  recipient: Address2.fromAddressOrString(message.recipient),
4472
4258
  nonce: message.nonce,
4473
- amount: bn16(message.amount),
4259
+ amount: bn15(message.amount),
4474
4260
  data: InputMessageCoder.decodeData(message.data),
4475
- daHeight: bn16(message.daHeight)
4261
+ daHeight: bn15(message.daHeight)
4476
4262
  }));
4477
4263
  }
4478
4264
  /**
@@ -4525,54 +4311,44 @@ var _Provider = class {
4525
4311
  } = result.messageProof;
4526
4312
  return {
4527
4313
  messageProof: {
4528
- proofIndex: bn16(messageProof.proofIndex),
4314
+ proofIndex: bn15(messageProof.proofIndex),
4529
4315
  proofSet: messageProof.proofSet
4530
4316
  },
4531
4317
  blockProof: {
4532
- proofIndex: bn16(blockProof.proofIndex),
4318
+ proofIndex: bn15(blockProof.proofIndex),
4533
4319
  proofSet: blockProof.proofSet
4534
4320
  },
4535
4321
  messageBlockHeader: {
4536
4322
  id: messageBlockHeader.id,
4537
- daHeight: bn16(messageBlockHeader.daHeight),
4538
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4323
+ daHeight: bn15(messageBlockHeader.daHeight),
4324
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4539
4325
  transactionsRoot: messageBlockHeader.transactionsRoot,
4540
- height: bn16(messageBlockHeader.height),
4326
+ height: bn15(messageBlockHeader.height),
4541
4327
  prevRoot: messageBlockHeader.prevRoot,
4542
4328
  time: messageBlockHeader.time,
4543
4329
  applicationHash: messageBlockHeader.applicationHash,
4544
4330
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4545
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount)
4331
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4546
4332
  },
4547
4333
  commitBlockHeader: {
4548
4334
  id: commitBlockHeader.id,
4549
- daHeight: bn16(commitBlockHeader.daHeight),
4550
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4335
+ daHeight: bn15(commitBlockHeader.daHeight),
4336
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4551
4337
  transactionsRoot: commitBlockHeader.transactionsRoot,
4552
- height: bn16(commitBlockHeader.height),
4338
+ height: bn15(commitBlockHeader.height),
4553
4339
  prevRoot: commitBlockHeader.prevRoot,
4554
4340
  time: commitBlockHeader.time,
4555
4341
  applicationHash: commitBlockHeader.applicationHash,
4556
4342
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4557
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount)
4343
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4558
4344
  },
4559
4345
  sender: Address2.fromAddressOrString(sender),
4560
4346
  recipient: Address2.fromAddressOrString(recipient),
4561
4347
  nonce,
4562
- amount: bn16(amount),
4348
+ amount: bn15(amount),
4563
4349
  data
4564
4350
  };
4565
4351
  }
4566
- async getLatestGasPrice() {
4567
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4568
- return bn16(latestGasPrice.gasPrice);
4569
- }
4570
- async estimateGasPrice(blockHorizon) {
4571
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4572
- blockHorizon: String(blockHorizon)
4573
- });
4574
- return bn16(estimateGasPrice.gasPrice);
4575
- }
4576
4352
  /**
4577
4353
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4578
4354
  *
@@ -4592,10 +4368,10 @@ var _Provider = class {
4592
4368
  */
4593
4369
  async produceBlocks(amount, startTime) {
4594
4370
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4595
- blocksToProduce: bn16(amount).toString(10),
4371
+ blocksToProduce: bn15(amount).toString(10),
4596
4372
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4597
4373
  });
4598
- return bn16(latestBlockHeight);
4374
+ return bn15(latestBlockHeight);
4599
4375
  }
4600
4376
  // eslint-disable-next-line @typescript-eslint/require-await
4601
4377
  async getTransactionResponse(transactionId) {
@@ -4609,7 +4385,7 @@ cacheInputs_fn = function(inputs) {
4609
4385
  return;
4610
4386
  }
4611
4387
  inputs.forEach((input) => {
4612
- if (input.type === InputType7.Coin) {
4388
+ if (input.type === InputType6.Coin) {
4613
4389
  this.cache?.set(input.id);
4614
4390
  }
4615
4391
  });
@@ -4619,7 +4395,7 @@ __publicField(Provider, "nodeInfoCache", {});
4619
4395
 
4620
4396
  // src/providers/transaction-summary/get-transaction-summary.ts
4621
4397
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4622
- import { bn as bn17 } from "@fuel-ts/math";
4398
+ import { bn as bn16 } from "@fuel-ts/math";
4623
4399
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4624
4400
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4625
4401
 
@@ -4865,33 +4641,36 @@ var Account = class extends AbstractAccount {
4865
4641
  * @param fee - The estimated transaction fee.
4866
4642
  * @returns A promise that resolves when the resources are added to the transaction.
4867
4643
  */
4868
- async fund(request, params) {
4869
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4870
- const txRequest = request;
4871
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4872
- amount: bn18(fee),
4644
+ async fund(request, coinQuantities, fee) {
4645
+ const updatedQuantities = addAmountToAsset({
4646
+ amount: bn17(fee),
4873
4647
  assetId: BaseAssetId3,
4874
- coinQuantities: requiredQuantities
4648
+ coinQuantities
4875
4649
  });
4876
4650
  const quantitiesDict = {};
4877
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4651
+ updatedQuantities.forEach(({ amount, assetId }) => {
4878
4652
  quantitiesDict[assetId] = {
4879
4653
  required: amount,
4880
- owned: bn18(0)
4654
+ owned: bn17(0)
4881
4655
  };
4882
4656
  });
4883
- txRequest.inputs.forEach((input) => {
4657
+ const cachedUtxos = [];
4658
+ const cachedMessages = [];
4659
+ const owner = this.address.toB256();
4660
+ request.inputs.forEach((input) => {
4884
4661
  const isResource = "amount" in input;
4885
4662
  if (isResource) {
4886
4663
  const isCoin2 = "owner" in input;
4887
4664
  if (isCoin2) {
4888
4665
  const assetId = String(input.assetId);
4889
- if (quantitiesDict[assetId]) {
4890
- const amount = bn18(input.amount);
4666
+ if (input.owner === owner && quantitiesDict[assetId]) {
4667
+ const amount = bn17(input.amount);
4891
4668
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4669
+ cachedUtxos.push(input.id);
4892
4670
  }
4893
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4671
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4894
4672
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4673
+ cachedMessages.push(input.nonce);
4895
4674
  }
4896
4675
  }
4897
4676
  });
@@ -4906,23 +4685,12 @@ var Account = class extends AbstractAccount {
4906
4685
  });
4907
4686
  const needsToBeFunded = missingQuantities.length;
4908
4687
  if (needsToBeFunded) {
4909
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toString());
4910
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4911
- txRequest.addResources(resources);
4912
- }
4913
- txRequest.shiftPredicateData();
4914
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4915
- const requestToBeReEstimate = clone4(txRequest);
4916
- if (addedSignatures) {
4917
- Array.from({ length: addedSignatures }).forEach(
4918
- () => requestToBeReEstimate.addEmptyWitness()
4919
- );
4688
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4689
+ messages: cachedMessages,
4690
+ utxos: cachedUtxos
4691
+ });
4692
+ request.addResources(resources);
4920
4693
  }
4921
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4922
- transactionRequest: requestToBeReEstimate
4923
- });
4924
- txRequest.maxFee = maxFee;
4925
- return txRequest;
4926
4694
  }
4927
4695
  /**
4928
4696
  * A helper that creates a transfer transaction request and returns it.
@@ -4930,25 +4698,28 @@ var Account = class extends AbstractAccount {
4930
4698
  * @param destination - The address of the destination.
4931
4699
  * @param amount - The amount of coins to transfer.
4932
4700
  * @param assetId - The asset ID of the coins to transfer.
4933
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4701
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4934
4702
  * @returns A promise that resolves to the prepared transaction request.
4935
4703
  */
4936
4704
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4937
- const request = new ScriptTransactionRequest(txParams);
4705
+ const { minGasPrice } = this.provider.getGasConfig();
4706
+ const params = { gasPrice: minGasPrice, ...txParams };
4707
+ const request = new ScriptTransactionRequest(params);
4938
4708
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4939
- const txCost = await this.provider.getTransactionCost(request, {
4709
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4940
4710
  estimateTxDependencies: true,
4941
4711
  resourcesOwner: this
4942
4712
  });
4943
- if ("gasLimit" in txParams) {
4944
- this.validateGas({
4945
- gasUsed: txCost.gasUsed,
4946
- gasLimit: request.gasLimit
4947
- });
4948
- }
4949
- request.gasLimit = txCost.gasUsed;
4950
- request.maxFee = txCost.maxFee;
4951
- await this.fund(request, txCost);
4713
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4714
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4715
+ this.validateGas({
4716
+ gasUsed,
4717
+ gasPrice: request.gasPrice,
4718
+ gasLimit: request.gasLimit,
4719
+ minGasPrice
4720
+ });
4721
+ await this.fund(request, requiredQuantities, maxFee);
4722
+ request.updatePredicateInputs(estimatedInputs);
4952
4723
  return request;
4953
4724
  }
4954
4725
  /**
@@ -4961,7 +4732,7 @@ var Account = class extends AbstractAccount {
4961
4732
  * @returns A promise that resolves to the transaction response.
4962
4733
  */
4963
4734
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4964
- if (bn18(amount).lte(0)) {
4735
+ if (bn17(amount).lte(0)) {
4965
4736
  throw new FuelError15(
4966
4737
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4967
4738
  "Transfer amount must be a positive number."
@@ -4980,37 +4751,38 @@ var Account = class extends AbstractAccount {
4980
4751
  * @returns A promise that resolves to the transaction response.
4981
4752
  */
4982
4753
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4983
- if (bn18(amount).lte(0)) {
4754
+ if (bn17(amount).lte(0)) {
4984
4755
  throw new FuelError15(
4985
4756
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4986
4757
  "Transfer amount must be a positive number."
4987
4758
  );
4988
4759
  }
4989
4760
  const contractAddress = Address3.fromAddressOrString(contractId);
4761
+ const { minGasPrice } = this.provider.getGasConfig();
4762
+ const params = { gasPrice: minGasPrice, ...txParams };
4990
4763
  const { script, scriptData } = await assembleTransferToContractScript({
4991
4764
  hexlifiedContractId: contractAddress.toB256(),
4992
- amountToTransfer: bn18(amount),
4765
+ amountToTransfer: bn17(amount),
4993
4766
  assetId
4994
4767
  });
4995
4768
  const request = new ScriptTransactionRequest({
4996
- ...txParams,
4769
+ ...params,
4997
4770
  script,
4998
4771
  scriptData
4999
4772
  });
5000
4773
  request.addContractInputAndOutput(contractAddress);
5001
- const txCost = await this.provider.getTransactionCost(request, {
5002
- resourcesOwner: this,
5003
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
4774
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4775
+ request,
4776
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4777
+ );
4778
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4779
+ this.validateGas({
4780
+ gasUsed,
4781
+ gasPrice: request.gasPrice,
4782
+ gasLimit: request.gasLimit,
4783
+ minGasPrice
5004
4784
  });
5005
- if (txParams.gasLimit) {
5006
- this.validateGas({
5007
- gasUsed: txCost.gasUsed,
5008
- gasLimit: request.gasLimit
5009
- });
5010
- }
5011
- request.gasLimit = txCost.gasUsed;
5012
- request.maxFee = txCost.maxFee;
5013
- await this.fund(request, txCost);
4785
+ await this.fund(request, requiredQuantities, maxFee);
5014
4786
  return this.sendTransaction(request);
5015
4787
  }
5016
4788
  /**
@@ -5022,31 +4794,34 @@ var Account = class extends AbstractAccount {
5022
4794
  * @returns A promise that resolves to the transaction response.
5023
4795
  */
5024
4796
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4797
+ const { minGasPrice } = this.provider.getGasConfig();
5025
4798
  const recipientAddress = Address3.fromAddressOrString(recipient);
5026
4799
  const recipientDataArray = arrayify14(
5027
4800
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5028
4801
  );
5029
4802
  const amountDataArray = arrayify14(
5030
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
4803
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5031
4804
  );
5032
4805
  const script = new Uint8Array([
5033
4806
  ...arrayify14(withdrawScript.bytes),
5034
4807
  ...recipientDataArray,
5035
4808
  ...amountDataArray
5036
4809
  ]);
5037
- const params = { script, ...txParams };
4810
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5038
4811
  const request = new ScriptTransactionRequest(params);
5039
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5040
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5041
- if (txParams.gasLimit) {
5042
- this.validateGas({
5043
- gasUsed: txCost.gasUsed,
5044
- gasLimit: request.gasLimit
5045
- });
5046
- }
5047
- request.maxFee = txCost.maxFee;
5048
- request.gasLimit = txCost.gasUsed;
5049
- await this.fund(request, txCost);
4812
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4813
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4814
+ request,
4815
+ forwardingQuantities
4816
+ );
4817
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4818
+ this.validateGas({
4819
+ gasUsed,
4820
+ gasPrice: request.gasPrice,
4821
+ gasLimit: request.gasLimit,
4822
+ minGasPrice
4823
+ });
4824
+ await this.fund(request, requiredQuantities, maxFee);
5050
4825
  return this.sendTransaction(request);
5051
4826
  }
5052
4827
  async signMessage(message) {
@@ -5104,7 +4879,18 @@ var Account = class extends AbstractAccount {
5104
4879
  }
5105
4880
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5106
4881
  }
5107
- validateGas({ gasUsed, gasLimit }) {
4882
+ validateGas({
4883
+ gasUsed,
4884
+ gasPrice,
4885
+ gasLimit,
4886
+ minGasPrice
4887
+ }) {
4888
+ if (minGasPrice.gt(gasPrice)) {
4889
+ throw new FuelError15(
4890
+ ErrorCode15.GAS_PRICE_TOO_LOW,
4891
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4892
+ );
4893
+ }
5108
4894
  if (gasUsed.gt(gasLimit)) {
5109
4895
  throw new FuelError15(
5110
4896
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5116,7 +4902,7 @@ var Account = class extends AbstractAccount {
5116
4902
 
5117
4903
  // src/signer/signer.ts
5118
4904
  import { Address as Address4 } from "@fuel-ts/address";
5119
- import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
4905
+ import { randomBytes } from "@fuel-ts/crypto";
5120
4906
  import { hash } from "@fuel-ts/hasher";
5121
4907
  import { toBytes } from "@fuel-ts/math";
5122
4908
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5209,7 +4995,7 @@ var Signer = class {
5209
4995
  * @returns random 32-byte hashed
5210
4996
  */
5211
4997
  static generatePrivateKey(entropy) {
5212
- return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
4998
+ return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5213
4999
  }
5214
5000
  /**
5215
5001
  * Extended publicKey from a compact publicKey
@@ -5228,7 +5014,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5228
5014
  import {
5229
5015
  bufferFromString,
5230
5016
  keccak256,
5231
- randomBytes as randomBytes3,
5017
+ randomBytes as randomBytes2,
5232
5018
  scrypt,
5233
5019
  stringFromBuffer,
5234
5020
  decryptJsonWalletData,
@@ -5251,7 +5037,7 @@ var removeHexPrefix = (hexString) => {
5251
5037
  async function encryptKeystoreWallet(privateKey, address, password) {
5252
5038
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5253
5039
  const ownerAddress = Address5.fromAddressOrString(address);
5254
- const salt = randomBytes3(DEFAULT_KEY_SIZE);
5040
+ const salt = randomBytes2(DEFAULT_KEY_SIZE);
5255
5041
  const key = scrypt({
5256
5042
  password: bufferFromString(password),
5257
5043
  salt,
@@ -5260,7 +5046,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5260
5046
  r: DEFAULT_KDF_PARAMS_R,
5261
5047
  p: DEFAULT_KDF_PARAMS_P
5262
5048
  });
5263
- const iv = randomBytes3(DEFAULT_IV_SIZE);
5049
+ const iv = randomBytes2(DEFAULT_IV_SIZE);
5264
5050
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5265
5051
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5266
5052
  const macHashUint8Array = keccak256(data);
@@ -5396,7 +5182,7 @@ var BaseWalletUnlocked = class extends Account {
5396
5182
  * @param transactionRequestLike - The transaction request to send.
5397
5183
  * @returns A promise that resolves to the TransactionResponse object.
5398
5184
  */
5399
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5185
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5400
5186
  const transactionRequest = transactionRequestify(transactionRequestLike);
5401
5187
  if (estimateTxDependencies) {
5402
5188
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5437,12 +5223,12 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5437
5223
  // src/hdwallet/hdwallet.ts
5438
5224
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5439
5225
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5440
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5226
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5441
5227
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5442
5228
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5443
5229
 
5444
5230
  // src/mnemonic/mnemonic.ts
5445
- import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5231
+ import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5446
5232
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5447
5233
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5448
5234
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -7797,7 +7583,7 @@ var Mnemonic = class {
7797
7583
  * @returns A randomly generated mnemonic
7798
7584
  */
7799
7585
  static generate(size = 32, extraEntropy = "") {
7800
- const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7586
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7801
7587
  return Mnemonic.entropyToMnemonic(entropy);
7802
7588
  }
7803
7589
  };
@@ -7903,7 +7689,7 @@ var HDWallet = class {
7903
7689
  const IR = bytes.slice(32);
7904
7690
  if (privateKey) {
7905
7691
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7906
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
7692
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7907
7693
  return new HDWallet({
7908
7694
  privateKey: ki,
7909
7695
  chainCode: IR,
@@ -8168,21 +7954,20 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
8168
7954
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8169
7955
 
8170
7956
  // src/test-utils/seedTestWallet.ts
8171
- import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
7957
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
8172
7958
  var seedTestWallet = async (wallet, quantities) => {
8173
7959
  const genesisWallet = new WalletUnlocked(
8174
- process.env.GENESIS_SECRET || randomBytes5(32),
7960
+ process.env.GENESIS_SECRET || randomBytes4(32),
8175
7961
  wallet.provider
8176
7962
  );
8177
- const request = new ScriptTransactionRequest();
8178
- quantities.forEach((quantity) => {
8179
- const { amount, assetId } = coinQuantityfy(quantity);
8180
- request.addCoinOutput(wallet.address, amount, assetId);
7963
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
7964
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
7965
+ const request = new ScriptTransactionRequest({
7966
+ gasLimit: 1e4,
7967
+ gasPrice: minGasPrice
8181
7968
  });
8182
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8183
- request.gasLimit = txCost.gasUsed;
8184
- request.maxFee = txCost.maxFee;
8185
- await genesisWallet.fund(request, txCost);
7969
+ request.addResources(resources);
7970
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8186
7971
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8187
7972
  };
8188
7973
 
@@ -8312,7 +8097,7 @@ var launchNode = async ({
8312
8097
  ["--ip", ipToUse],
8313
8098
  ["--port", portToUse],
8314
8099
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8315
- ["--min-gas-price", "1"],
8100
+ ["--min-gas-price", "0"],
8316
8101
  poaInstant ? ["--poa-instant", "true"] : [],
8317
8102
  ["--consensus-key", consensusKey],
8318
8103
  ["--chain", chainConfigPathToUse],
@@ -8374,7 +8159,7 @@ var launchNodeAndGetWallets = async ({
8374
8159
  walletCount = 10
8375
8160
  } = {}) => {
8376
8161
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8377
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8162
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8378
8163
  const wallets = await generateWallets(walletCount, provider);
8379
8164
  const cleanup = () => {
8380
8165
  closeNode();