@fuel-ts/account 0.0.0-rc-2021-20240422173414 → 0.0.0-rc-2045-20240422220518

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 (53) 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 +550 -798
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +509 -761
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +390 -641
  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 +329 -911
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +1 -7
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +27 -37
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.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/launchNode.d.ts.map +1 -1
  46. package/dist/test-utils.global.js +1062 -1548
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +505 -739
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +399 -633
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  53. package/package.json +16 -16
@@ -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
  }
@@ -266,32 +226,26 @@ var MessageProofFragmentFragmentDoc = gql`
266
226
  messageBlockHeader {
267
227
  id
268
228
  daHeight
269
- consensusParametersVersion
270
- stateTransitionBytecodeVersion
271
229
  transactionsCount
272
- messageReceiptCount
273
230
  transactionsRoot
274
- messageOutboxRoot
275
- eventInboxRoot
276
231
  height
277
232
  prevRoot
278
233
  time
279
234
  applicationHash
235
+ messageReceiptRoot
236
+ messageReceiptCount
280
237
  }
281
238
  commitBlockHeader {
282
239
  id
283
240
  daHeight
284
- consensusParametersVersion
285
- stateTransitionBytecodeVersion
286
241
  transactionsCount
287
- messageReceiptCount
288
242
  transactionsRoot
289
- messageOutboxRoot
290
- eventInboxRoot
291
243
  height
292
244
  prevRoot
293
245
  time
294
246
  applicationHash
247
+ messageReceiptRoot
248
+ messageReceiptCount
295
249
  }
296
250
  sender
297
251
  recipient
@@ -310,8 +264,8 @@ var BalanceFragmentFragmentDoc = gql`
310
264
  var BlockFragmentFragmentDoc = gql`
311
265
  fragment blockFragment on Block {
312
266
  id
313
- height
314
267
  header {
268
+ height
315
269
  time
316
270
  }
317
271
  transactions {
@@ -369,11 +323,6 @@ var DependentCostFragmentFragmentDoc = gql`
369
323
  `;
370
324
  var GasCostsFragmentFragmentDoc = gql`
371
325
  fragment GasCostsFragment on GasCosts {
372
- version {
373
- ... on Version {
374
- value
375
- }
376
- }
377
326
  add
378
327
  addi
379
328
  aloc
@@ -386,6 +335,7 @@ var GasCostsFragmentFragmentDoc = gql`
386
335
  cb
387
336
  cfei
388
337
  cfsi
338
+ croo
389
339
  div
390
340
  divi
391
341
  ecr1
@@ -468,9 +418,6 @@ var GasCostsFragmentFragmentDoc = gql`
468
418
  ccp {
469
419
  ...DependentCostFragment
470
420
  }
471
- croo {
472
- ...DependentCostFragment
473
- }
474
421
  csiz {
475
422
  ...DependentCostFragment
476
423
  }
@@ -530,11 +477,6 @@ var GasCostsFragmentFragmentDoc = gql`
530
477
  ${DependentCostFragmentFragmentDoc}`;
531
478
  var ConsensusParametersFragmentFragmentDoc = gql`
532
479
  fragment consensusParametersFragment on ConsensusParameters {
533
- version {
534
- ... on Version {
535
- value
536
- }
537
- }
538
480
  txParams {
539
481
  ...TxParametersFragment
540
482
  }
@@ -594,9 +536,18 @@ var NodeInfoFragmentFragmentDoc = gql`
594
536
  fragment nodeInfoFragment on NodeInfo {
595
537
  utxoValidation
596
538
  vmBacktrace
539
+ minGasPrice
597
540
  maxTx
598
541
  maxDepth
599
542
  nodeVersion
543
+ peers {
544
+ id
545
+ addresses
546
+ clientVersion
547
+ blockHeight
548
+ lastHeartbeatMs
549
+ appScore
550
+ }
600
551
  }
601
552
  `;
602
553
  var GetVersionDocument = gql`
@@ -631,9 +582,13 @@ var GetTransactionWithReceiptsDocument = gql`
631
582
  query getTransactionWithReceipts($transactionId: TransactionId!) {
632
583
  transaction(id: $transactionId) {
633
584
  ...transactionFragment
585
+ receipts {
586
+ ...receiptFragment
587
+ }
634
588
  }
635
589
  }
636
- ${TransactionFragmentFragmentDoc}`;
590
+ ${TransactionFragmentFragmentDoc}
591
+ ${ReceiptFragmentFragmentDoc}`;
637
592
  var GetTransactionsDocument = gql`
638
593
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
639
594
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -761,20 +716,6 @@ var GetBalanceDocument = gql`
761
716
  }
762
717
  }
763
718
  ${BalanceFragmentFragmentDoc}`;
764
- var GetLatestGasPriceDocument = gql`
765
- query getLatestGasPrice {
766
- latestGasPrice {
767
- gasPrice
768
- }
769
- }
770
- `;
771
- var EstimateGasPriceDocument = gql`
772
- query estimateGasPrice($blockHorizon: U32!) {
773
- estimateGasPrice(blockHorizon: $blockHorizon) {
774
- gasPrice
775
- }
776
- }
777
- `;
778
719
  var GetBalancesDocument = gql`
779
720
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
780
721
  balances(
@@ -829,12 +770,12 @@ var GetMessageStatusDocument = gql`
829
770
  }
830
771
  `;
831
772
  var DryRunDocument = gql`
832
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
833
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
834
- ...dryRunTransactionExecutionStatusFragment
773
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
774
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
775
+ ...receiptFragment
835
776
  }
836
777
  }
837
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
778
+ ${ReceiptFragmentFragmentDoc}`;
838
779
  var SubmitDocument = gql`
839
780
  mutation submit($encodedTransaction: HexString!) {
840
781
  submit(tx: $encodedTransaction) {
@@ -917,12 +858,6 @@ function getSdk(requester) {
917
858
  getBalance(variables, options) {
918
859
  return requester(GetBalanceDocument, variables, options);
919
860
  },
920
- getLatestGasPrice(variables, options) {
921
- return requester(GetLatestGasPriceDocument, variables, options);
922
- },
923
- estimateGasPrice(variables, options) {
924
- return requester(EstimateGasPriceDocument, variables, options);
925
- },
926
861
  getBalances(variables, options) {
927
862
  return requester(GetBalancesDocument, variables, options);
928
863
  },
@@ -1116,9 +1051,10 @@ var inputify = (value) => {
1116
1051
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1117
1052
  },
1118
1053
  witnessIndex: value.witnessIndex,
1054
+ maturity: value.maturity ?? 0,
1119
1055
  predicateGasUsed: bn2(value.predicateGasUsed),
1120
- predicateLength: bn2(predicate.length),
1121
- predicateDataLength: bn2(predicateData.length),
1056
+ predicateLength: predicate.length,
1057
+ predicateDataLength: predicateData.length,
1122
1058
  predicate: hexlify3(predicate),
1123
1059
  predicateData: hexlify3(predicateData)
1124
1060
  };
@@ -1149,8 +1085,8 @@ var inputify = (value) => {
1149
1085
  nonce: hexlify3(value.nonce),
1150
1086
  witnessIndex: value.witnessIndex,
1151
1087
  predicateGasUsed: bn2(value.predicateGasUsed),
1152
- predicateLength: bn2(predicate.length),
1153
- predicateDataLength: bn2(predicateData.length),
1088
+ predicateLength: predicate.length,
1089
+ predicateDataLength: predicateData.length,
1154
1090
  predicate: hexlify3(predicate),
1155
1091
  predicateData: hexlify3(predicateData),
1156
1092
  data: hexlify3(data),
@@ -1277,8 +1213,8 @@ function assembleReceiptByType(receipt) {
1277
1213
  case "CALL" /* Call */: {
1278
1214
  const callReceipt = {
1279
1215
  type: ReceiptType.Call,
1280
- from: hexOrZero(receipt.id || receipt.contractId),
1281
- to: hexOrZero(receipt?.to),
1216
+ from: hexOrZero(receipt.contract?.id),
1217
+ to: hexOrZero(receipt?.to?.id),
1282
1218
  amount: bn4(receipt.amount),
1283
1219
  assetId: hexOrZero(receipt.assetId),
1284
1220
  gas: bn4(receipt.gas),
@@ -1292,7 +1228,7 @@ function assembleReceiptByType(receipt) {
1292
1228
  case "RETURN" /* Return */: {
1293
1229
  const returnReceipt = {
1294
1230
  type: ReceiptType.Return,
1295
- id: hexOrZero(receipt.id || receipt.contractId),
1231
+ id: hexOrZero(receipt.contract?.id),
1296
1232
  val: bn4(receipt.val),
1297
1233
  pc: bn4(receipt.pc),
1298
1234
  is: bn4(receipt.is)
@@ -1302,7 +1238,7 @@ function assembleReceiptByType(receipt) {
1302
1238
  case "RETURN_DATA" /* ReturnData */: {
1303
1239
  const returnDataReceipt = {
1304
1240
  type: ReceiptType.ReturnData,
1305
- id: hexOrZero(receipt.id || receipt.contractId),
1241
+ id: hexOrZero(receipt.contract?.id),
1306
1242
  ptr: bn4(receipt.ptr),
1307
1243
  len: bn4(receipt.len),
1308
1244
  digest: hexOrZero(receipt.digest),
@@ -1314,7 +1250,7 @@ function assembleReceiptByType(receipt) {
1314
1250
  case "PANIC" /* Panic */: {
1315
1251
  const panicReceipt = {
1316
1252
  type: ReceiptType.Panic,
1317
- id: hexOrZero(receipt.id),
1253
+ id: hexOrZero(receipt.contract?.id),
1318
1254
  reason: bn4(receipt.reason),
1319
1255
  pc: bn4(receipt.pc),
1320
1256
  is: bn4(receipt.is),
@@ -1325,7 +1261,7 @@ function assembleReceiptByType(receipt) {
1325
1261
  case "REVERT" /* Revert */: {
1326
1262
  const revertReceipt = {
1327
1263
  type: ReceiptType.Revert,
1328
- id: hexOrZero(receipt.id || receipt.contractId),
1264
+ id: hexOrZero(receipt.contract?.id),
1329
1265
  val: bn4(receipt.ra),
1330
1266
  pc: bn4(receipt.pc),
1331
1267
  is: bn4(receipt.is)
@@ -1335,7 +1271,7 @@ function assembleReceiptByType(receipt) {
1335
1271
  case "LOG" /* Log */: {
1336
1272
  const logReceipt = {
1337
1273
  type: ReceiptType.Log,
1338
- id: hexOrZero(receipt.id || receipt.contractId),
1274
+ id: hexOrZero(receipt.contract?.id),
1339
1275
  val0: bn4(receipt.ra),
1340
1276
  val1: bn4(receipt.rb),
1341
1277
  val2: bn4(receipt.rc),
@@ -1348,7 +1284,7 @@ function assembleReceiptByType(receipt) {
1348
1284
  case "LOG_DATA" /* LogData */: {
1349
1285
  const logDataReceipt = {
1350
1286
  type: ReceiptType.LogData,
1351
- id: hexOrZero(receipt.id || receipt.contractId),
1287
+ id: hexOrZero(receipt.contract?.id),
1352
1288
  val0: bn4(receipt.ra),
1353
1289
  val1: bn4(receipt.rb),
1354
1290
  ptr: bn4(receipt.ptr),
@@ -1362,8 +1298,8 @@ function assembleReceiptByType(receipt) {
1362
1298
  case "TRANSFER" /* Transfer */: {
1363
1299
  const transferReceipt = {
1364
1300
  type: ReceiptType.Transfer,
1365
- from: hexOrZero(receipt.id || receipt.contractId),
1366
- to: hexOrZero(receipt.toAddress || receipt?.to),
1301
+ from: hexOrZero(receipt.contract?.id),
1302
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1367
1303
  amount: bn4(receipt.amount),
1368
1304
  assetId: hexOrZero(receipt.assetId),
1369
1305
  pc: bn4(receipt.pc),
@@ -1374,8 +1310,8 @@ function assembleReceiptByType(receipt) {
1374
1310
  case "TRANSFER_OUT" /* TransferOut */: {
1375
1311
  const transferOutReceipt = {
1376
1312
  type: ReceiptType.TransferOut,
1377
- from: hexOrZero(receipt.id || receipt.contractId),
1378
- to: hexOrZero(receipt.toAddress || receipt.to),
1313
+ from: hexOrZero(receipt.contract?.id),
1314
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1379
1315
  amount: bn4(receipt.amount),
1380
1316
  assetId: hexOrZero(receipt.assetId),
1381
1317
  pc: bn4(receipt.pc),
@@ -1418,7 +1354,7 @@ function assembleReceiptByType(receipt) {
1418
1354
  return receiptMessageOut;
1419
1355
  }
1420
1356
  case "MINT" /* Mint */: {
1421
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1357
+ const contractId = hexOrZero(receipt.contract?.id);
1422
1358
  const subId = hexOrZero(receipt.subId);
1423
1359
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1424
1360
  const mintReceipt = {
@@ -1433,7 +1369,7 @@ function assembleReceiptByType(receipt) {
1433
1369
  return mintReceipt;
1434
1370
  }
1435
1371
  case "BURN" /* Burn */: {
1436
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1372
+ const contractId = hexOrZero(receipt.contract?.id);
1437
1373
  const subId = hexOrZero(receipt.subId);
1438
1374
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1439
1375
  const burnReceipt = {
@@ -1459,6 +1395,7 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
1459
1395
  import { bn as bn5 } from "@fuel-ts/math";
1460
1396
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1461
1397
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1398
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1462
1399
  var getGasUsedFromReceipts = (receipts) => {
1463
1400
  const scriptResult = receipts.filter(
1464
1401
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1479,28 +1416,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1479
1416
  }
1480
1417
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1481
1418
  const witnessCache = [];
1482
- const chargeableInputs = inputs.filter((input) => {
1483
- const isCoinOrMessage = "owner" in input || "sender" in input;
1484
- if (isCoinOrMessage) {
1485
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1486
- return true;
1487
- }
1488
- if (!witnessCache.includes(input.witnessIndex)) {
1489
- witnessCache.push(input.witnessIndex);
1490
- return true;
1491
- }
1492
- }
1493
- return false;
1494
- });
1495
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1496
- const totalGas = chargeableInputs.reduce((total, input) => {
1419
+ const totalGas = inputs.reduce((total, input) => {
1497
1420
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1498
1421
  return total.add(
1499
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1422
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1500
1423
  );
1501
1424
  }
1502
- return total.add(gasCosts.ecr1);
1503
- }, bn5(0));
1425
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1426
+ witnessCache.push(input.witnessIndex);
1427
+ return total.add(gasCosts.ecr1);
1428
+ }
1429
+ return total;
1430
+ }, bn5());
1504
1431
  return totalGas;
1505
1432
  }
1506
1433
  function getMinGas(params) {
@@ -1512,20 +1439,12 @@ function getMinGas(params) {
1512
1439
  return minGas;
1513
1440
  }
1514
1441
  function getMaxGas(params) {
1515
- const {
1516
- gasPerByte,
1517
- witnessesLength,
1518
- witnessLimit,
1519
- minGas,
1520
- gasLimit = bn5(0),
1521
- maxGasPerTx
1522
- } = params;
1442
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1523
1443
  let remainingAllowedWitnessGas = bn5(0);
1524
1444
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1525
1445
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1526
1446
  }
1527
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1528
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1447
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1529
1448
  }
1530
1449
  function calculateMetadataGasForTxCreate({
1531
1450
  gasCosts,
@@ -1547,10 +1466,6 @@ function calculateMetadataGasForTxScript({
1547
1466
  }) {
1548
1467
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1549
1468
  }
1550
- var calculateGasFee = (params) => {
1551
- const { gas, gasPrice, priceFactor, tip } = params;
1552
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1553
- };
1554
1469
 
1555
1470
  // src/providers/utils/json.ts
1556
1471
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1695,7 +1610,7 @@ var witnessify = (value) => {
1695
1610
  // src/providers/transaction-request/transaction-request.ts
1696
1611
  var BaseTransactionRequest = class {
1697
1612
  /** Gas price for transaction */
1698
- tip;
1613
+ gasPrice;
1699
1614
  /** Block until which tx cannot be included */
1700
1615
  maturity;
1701
1616
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1714,7 +1629,7 @@ var BaseTransactionRequest = class {
1714
1629
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1715
1630
  */
1716
1631
  constructor({
1717
- tip,
1632
+ gasPrice,
1718
1633
  maturity,
1719
1634
  maxFee,
1720
1635
  witnessLimit,
@@ -1722,7 +1637,7 @@ var BaseTransactionRequest = class {
1722
1637
  outputs,
1723
1638
  witnesses
1724
1639
  } = {}) {
1725
- this.tip = bn7(tip);
1640
+ this.gasPrice = bn7(gasPrice);
1726
1641
  this.maturity = maturity ?? 0;
1727
1642
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1728
1643
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
@@ -1733,9 +1648,9 @@ var BaseTransactionRequest = class {
1733
1648
  static getPolicyMeta(req) {
1734
1649
  let policyTypes = 0;
1735
1650
  const policies = [];
1736
- if (req.tip) {
1737
- policyTypes += PolicyType.Tip;
1738
- policies.push({ data: req.tip, type: PolicyType.Tip });
1651
+ if (req.gasPrice) {
1652
+ policyTypes += PolicyType.GasPrice;
1653
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1739
1654
  }
1740
1655
  if (req.witnessLimit) {
1741
1656
  policyTypes += PolicyType.WitnessLimit;
@@ -1922,10 +1837,10 @@ var BaseTransactionRequest = class {
1922
1837
  * @param predicate - Predicate bytes.
1923
1838
  * @param predicateData - Predicate data bytes.
1924
1839
  */
1925
- addCoinInput(coin) {
1840
+ addCoinInput(coin, predicate) {
1926
1841
  const { assetId, owner, amount } = coin;
1927
1842
  let witnessIndex;
1928
- if (coin.predicate) {
1843
+ if (predicate) {
1929
1844
  witnessIndex = 0;
1930
1845
  } else {
1931
1846
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1940,7 +1855,8 @@ var BaseTransactionRequest = class {
1940
1855
  amount,
1941
1856
  assetId,
1942
1857
  txPointer: "0x00000000000000000000000000000000",
1943
- witnessIndex
1858
+ witnessIndex,
1859
+ predicate: predicate?.bytes
1944
1860
  };
1945
1861
  this.pushInput(input);
1946
1862
  this.addChangeOutput(owner, assetId);
@@ -1953,11 +1869,11 @@ var BaseTransactionRequest = class {
1953
1869
  * @param predicate - Predicate bytes.
1954
1870
  * @param predicateData - Predicate data bytes.
1955
1871
  */
1956
- addMessageInput(message) {
1872
+ addMessageInput(message, predicate) {
1957
1873
  const { recipient, sender, amount } = message;
1958
1874
  const assetId = BaseAssetId2;
1959
1875
  let witnessIndex;
1960
- if (message.predicate) {
1876
+ if (predicate) {
1961
1877
  witnessIndex = 0;
1962
1878
  } else {
1963
1879
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1971,7 +1887,8 @@ var BaseTransactionRequest = class {
1971
1887
  sender: sender.toB256(),
1972
1888
  recipient: recipient.toB256(),
1973
1889
  amount,
1974
- witnessIndex
1890
+ witnessIndex,
1891
+ predicate: predicate?.bytes
1975
1892
  };
1976
1893
  this.pushInput(input);
1977
1894
  this.addChangeOutput(recipient, assetId);
@@ -2002,6 +1919,32 @@ var BaseTransactionRequest = class {
2002
1919
  resources.forEach((resource) => this.addResource(resource));
2003
1920
  return this;
2004
1921
  }
1922
+ /**
1923
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1924
+ * outputs from the related assetIds.
1925
+ *
1926
+ * @param resources - The resources to add.
1927
+ * @returns This transaction.
1928
+ */
1929
+ addPredicateResource(resource, predicate) {
1930
+ if (isCoin(resource)) {
1931
+ this.addCoinInput(resource, predicate);
1932
+ } else {
1933
+ this.addMessageInput(resource, predicate);
1934
+ }
1935
+ return this;
1936
+ }
1937
+ /**
1938
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
1939
+ * from the related assetIds.
1940
+ *
1941
+ * @param resources - The resources to add.
1942
+ * @returns This transaction.
1943
+ */
1944
+ addPredicateResources(resources, predicate) {
1945
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1946
+ return this;
1947
+ }
2005
1948
  /**
2006
1949
  * Adds a coin output to the transaction.
2007
1950
  *
@@ -2081,7 +2024,7 @@ var BaseTransactionRequest = class {
2081
2024
  }
2082
2025
  calculateMaxGas(chainInfo, minGas) {
2083
2026
  const { consensusParameters } = chainInfo;
2084
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2027
+ const { gasPerByte } = consensusParameters;
2085
2028
  const witnessesLength = this.toTransaction().witnesses.reduce(
2086
2029
  (acc, wit) => acc + wit.dataLength,
2087
2030
  0
@@ -2090,8 +2033,7 @@ var BaseTransactionRequest = class {
2090
2033
  gasPerByte,
2091
2034
  minGas,
2092
2035
  witnessesLength,
2093
- witnessLimit: this.witnessLimit,
2094
- maxGasPerTx
2036
+ witnessLimit: this.witnessLimit
2095
2037
  });
2096
2038
  }
2097
2039
  /**
@@ -2109,20 +2051,17 @@ var BaseTransactionRequest = class {
2109
2051
  });
2110
2052
  const updateAssetInput = (assetId, quantity) => {
2111
2053
  const assetInput = findAssetInput(assetId);
2112
- let usedQuantity = quantity;
2113
- if (assetId === BaseAssetId2) {
2114
- usedQuantity = bn7("1000000000000000000");
2115
- }
2116
2054
  if (assetInput && "assetId" in assetInput) {
2117
2055
  assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2118
- assetInput.amount = usedQuantity;
2056
+ assetInput.amount = quantity;
2119
2057
  } else {
2120
2058
  this.addResources([
2121
2059
  {
2122
2060
  id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2123
- amount: usedQuantity,
2061
+ amount: quantity,
2124
2062
  assetId,
2125
2063
  owner: resourcesOwner || Address.fromRandom(),
2064
+ maturity: 0,
2126
2065
  blockCreated: bn7(1),
2127
2066
  txCreatedIdx: bn7(1)
2128
2067
  }
@@ -2154,7 +2093,7 @@ var BaseTransactionRequest = class {
2154
2093
  toJSON() {
2155
2094
  return normalizeJSON(this);
2156
2095
  }
2157
- updatePredicateGasUsed(inputs) {
2096
+ updatePredicateInputs(inputs) {
2158
2097
  this.inputs.forEach((i) => {
2159
2098
  let correspondingInput;
2160
2099
  switch (i.type) {
@@ -2176,15 +2115,6 @@ var BaseTransactionRequest = class {
2176
2115
  }
2177
2116
  });
2178
2117
  }
2179
- shiftPredicateData() {
2180
- this.inputs.forEach((input) => {
2181
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2182
- input.predicateData = input.paddPredicateData(
2183
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2184
- );
2185
- }
2186
- });
2187
- }
2188
2118
  };
2189
2119
 
2190
2120
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2331,8 +2261,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2331
2261
  return {
2332
2262
  type: TransactionType3.Create,
2333
2263
  ...baseTransaction,
2264
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2334
2265
  bytecodeWitnessIndex,
2335
- storageSlotsCount: bn9(storageSlots.length),
2266
+ storageSlotsCount: storageSlots.length,
2336
2267
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2337
2268
  storageSlots
2338
2269
  };
@@ -2455,8 +2386,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2455
2386
  type: TransactionType4.Script,
2456
2387
  scriptGasLimit: this.gasLimit,
2457
2388
  ...super.getBaseTransaction(),
2458
- scriptLength: bn10(script.length),
2459
- scriptDataLength: bn10(scriptData.length),
2389
+ scriptLength: script.length,
2390
+ scriptDataLength: scriptData.length,
2460
2391
  receiptsRoot: ZeroBytes327,
2461
2392
  script: hexlify10(script),
2462
2393
  scriptData: hexlify10(scriptData)
@@ -2520,7 +2451,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2520
2451
  }
2521
2452
  calculateMaxGas(chainInfo, minGas) {
2522
2453
  const { consensusParameters } = chainInfo;
2523
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2454
+ const { gasPerByte } = consensusParameters;
2524
2455
  const witnessesLength = this.toTransaction().witnesses.reduce(
2525
2456
  (acc, wit) => acc + wit.dataLength,
2526
2457
  0
@@ -2530,8 +2461,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2530
2461
  minGas,
2531
2462
  witnessesLength,
2532
2463
  witnessLimit: this.witnessLimit,
2533
- gasLimit: this.gasLimit,
2534
- maxGasPerTx
2464
+ gasLimit: this.gasLimit
2535
2465
  });
2536
2466
  }
2537
2467
  /**
@@ -2588,7 +2518,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2588
2518
 
2589
2519
  // src/providers/transaction-request/utils.ts
2590
2520
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2591
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2521
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2592
2522
  var transactionRequestify = (obj) => {
2593
2523
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2594
2524
  return obj;
@@ -2606,31 +2536,14 @@ var transactionRequestify = (obj) => {
2606
2536
  }
2607
2537
  }
2608
2538
  };
2609
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2610
- (acc, input) => {
2611
- if (input.type === InputType5.Coin && input.owner === owner) {
2612
- acc.utxos.push(input.id);
2613
- }
2614
- if (input.type === InputType5.Message && input.recipient === owner) {
2615
- acc.messages.push(input.nonce);
2616
- }
2617
- return acc;
2618
- },
2619
- {
2620
- utxos: [],
2621
- messages: []
2622
- }
2623
- );
2624
2539
 
2625
2540
  // src/providers/transaction-response/transaction-response.ts
2626
2541
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2627
- import { bn as bn15 } from "@fuel-ts/math";
2542
+ import { bn as bn14 } from "@fuel-ts/math";
2628
2543
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2629
2544
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2630
2545
 
2631
2546
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2632
- import { bn as bn14 } from "@fuel-ts/math";
2633
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2634
2547
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2635
2548
 
2636
2549
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2639,10 +2552,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2639
2552
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2640
2553
  var calculateTransactionFee = (params) => {
2641
2554
  const {
2642
- gasPrice,
2555
+ gasUsed,
2643
2556
  rawPayload,
2644
- tip,
2645
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2557
+ consensusParameters: { gasCosts, feeParams }
2646
2558
  } = params;
2647
2559
  const gasPerByte = bn11(feeParams.gasPerByte);
2648
2560
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2652,7 +2564,8 @@ var calculateTransactionFee = (params) => {
2652
2564
  return {
2653
2565
  fee: bn11(0),
2654
2566
  minFee: bn11(0),
2655
- maxFee: bn11(0)
2567
+ maxFee: bn11(0),
2568
+ feeFromGasUsed: bn11(0)
2656
2569
  };
2657
2570
  }
2658
2571
  const { type, witnesses, inputs, policies } = transaction;
@@ -2684,6 +2597,7 @@ var calculateTransactionFee = (params) => {
2684
2597
  metadataGas,
2685
2598
  txBytesSize: transactionBytes.length
2686
2599
  });
2600
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2687
2601
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2688
2602
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2689
2603
  const maxGas = getMaxGas({
@@ -2691,25 +2605,17 @@ var calculateTransactionFee = (params) => {
2691
2605
  minGas,
2692
2606
  witnessesLength,
2693
2607
  gasLimit,
2694
- witnessLimit,
2695
- maxGasPerTx
2696
- });
2697
- const minFee = calculateGasFee({
2698
- gasPrice,
2699
- gas: minGas,
2700
- priceFactor: gasPriceFactor,
2701
- tip
2702
- });
2703
- const maxFee = calculateGasFee({
2704
- gasPrice,
2705
- gas: maxGas,
2706
- priceFactor: gasPriceFactor,
2707
- tip
2608
+ witnessLimit
2708
2609
  });
2610
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2611
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2612
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2613
+ const fee = minFee.add(feeFromGasUsed);
2709
2614
  return {
2615
+ fee,
2710
2616
  minFee,
2711
2617
  maxFee,
2712
- fee: maxFee
2618
+ feeFromGasUsed
2713
2619
  };
2714
2620
  };
2715
2621
 
@@ -2765,7 +2671,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2765
2671
 
2766
2672
  // src/providers/transaction-summary/input.ts
2767
2673
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2768
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2674
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2769
2675
  function getInputsByTypes(inputs, types) {
2770
2676
  return inputs.filter((i) => types.includes(i.type));
2771
2677
  }
@@ -2773,16 +2679,16 @@ function getInputsByType(inputs, type) {
2773
2679
  return inputs.filter((i) => i.type === type);
2774
2680
  }
2775
2681
  function getInputsCoin(inputs) {
2776
- return getInputsByType(inputs, InputType6.Coin);
2682
+ return getInputsByType(inputs, InputType5.Coin);
2777
2683
  }
2778
2684
  function getInputsMessage(inputs) {
2779
- return getInputsByType(inputs, InputType6.Message);
2685
+ return getInputsByType(inputs, InputType5.Message);
2780
2686
  }
2781
2687
  function getInputsCoinAndMessage(inputs) {
2782
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2688
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2783
2689
  }
2784
2690
  function getInputsContract(inputs) {
2785
- return getInputsByType(inputs, InputType6.Contract);
2691
+ return getInputsByType(inputs, InputType5.Contract);
2786
2692
  }
2787
2693
  function getInputFromAssetId(inputs, assetId) {
2788
2694
  const coinInputs = getInputsCoin(inputs);
@@ -2801,7 +2707,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2801
2707
  if (!contractInput) {
2802
2708
  return void 0;
2803
2709
  }
2804
- if (contractInput.type !== InputType6.Contract) {
2710
+ if (contractInput.type !== InputType5.Contract) {
2805
2711
  throw new FuelError9(
2806
2712
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2807
2713
  `Contract input should be of type 'contract'.`
@@ -2810,10 +2716,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2810
2716
  return contractInput;
2811
2717
  }
2812
2718
  function getInputAccountAddress(input) {
2813
- if (input.type === InputType6.Coin) {
2719
+ if (input.type === InputType5.Coin) {
2814
2720
  return input.owner.toString();
2815
2721
  }
2816
- if (input.type === InputType6.Message) {
2722
+ if (input.type === InputType5.Message) {
2817
2723
  return input.recipient.toString();
2818
2724
  }
2819
2725
  return "";
@@ -3276,9 +3182,7 @@ function assembleTransactionSummary(params) {
3276
3182
  gqlTransactionStatus,
3277
3183
  abiMap = {},
3278
3184
  maxInputs,
3279
- gasCosts,
3280
- maxGasPerTx,
3281
- gasPrice
3185
+ gasCosts
3282
3186
  } = params;
3283
3187
  const gasUsed = getGasUsedFromReceipts(receipts);
3284
3188
  const rawPayload = hexlify11(transactionBytes);
@@ -3292,14 +3196,11 @@ function assembleTransactionSummary(params) {
3292
3196
  maxInputs
3293
3197
  });
3294
3198
  const typeName = getTransactionTypeName(transaction.type);
3295
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3296
3199
  const { fee } = calculateTransactionFee({
3297
- gasPrice,
3200
+ gasUsed,
3298
3201
  rawPayload,
3299
- tip,
3300
3202
  consensusParameters: {
3301
3203
  gasCosts,
3302
- maxGasPerTx,
3303
3204
  feeParams: {
3304
3205
  gasPerByte,
3305
3206
  gasPriceFactor
@@ -3359,7 +3260,7 @@ var TransactionResponse = class {
3359
3260
  /** Current provider */
3360
3261
  provider;
3361
3262
  /** Gas used on the transaction */
3362
- gasUsed = bn15(0);
3263
+ gasUsed = bn14(0);
3363
3264
  /** The graphql Transaction with receipts object. */
3364
3265
  gqlTransaction;
3365
3266
  abis;
@@ -3437,13 +3338,8 @@ var TransactionResponse = class {
3437
3338
  const decodedTransaction = this.decodeTransaction(
3438
3339
  transaction
3439
3340
  );
3440
- let txReceipts = [];
3441
- if (transaction?.status && "receipts" in transaction.status) {
3442
- txReceipts = transaction.status.receipts;
3443
- }
3444
- const receipts = txReceipts.map(processGqlReceipt) || [];
3445
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3446
- const gasPrice = await this.provider.getLatestGasPrice();
3341
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3342
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3447
3343
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3448
3344
  const transactionSummary = assembleTransactionSummary({
3449
3345
  id: this.id,
@@ -3455,9 +3351,7 @@ var TransactionResponse = class {
3455
3351
  gasPriceFactor,
3456
3352
  abiMap: contractsAbiMap,
3457
3353
  maxInputs,
3458
- gasCosts,
3459
- maxGasPerTx,
3460
- gasPrice
3354
+ gasCosts
3461
3355
  });
3462
3356
  return transactionSummary;
3463
3357
  }
@@ -3584,29 +3478,29 @@ var processGqlChain = (chain) => {
3584
3478
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3585
3479
  return {
3586
3480
  name,
3587
- baseChainHeight: bn16(daHeight),
3481
+ baseChainHeight: bn15(daHeight),
3588
3482
  consensusParameters: {
3589
- contractMaxSize: bn16(contractParams.contractMaxSize),
3590
- maxInputs: bn16(txParams.maxInputs),
3591
- maxOutputs: bn16(txParams.maxOutputs),
3592
- maxWitnesses: bn16(txParams.maxWitnesses),
3593
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3594
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3595
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3596
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3597
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3598
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3599
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3600
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3601
- gasPerByte: bn16(feeParams.gasPerByte),
3602
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3603
- chainId: bn16(consensusParameters.chainId),
3483
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3484
+ maxInputs: bn15(txParams.maxInputs),
3485
+ maxOutputs: bn15(txParams.maxOutputs),
3486
+ maxWitnesses: bn15(txParams.maxWitnesses),
3487
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3488
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3489
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3490
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3491
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3492
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3493
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3494
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3495
+ gasPerByte: bn15(feeParams.gasPerByte),
3496
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3497
+ chainId: bn15(consensusParameters.chainId),
3604
3498
  gasCosts
3605
3499
  },
3606
3500
  gasCosts,
3607
3501
  latestBlock: {
3608
3502
  id: latestBlock.id,
3609
- height: bn16(latestBlock.height),
3503
+ height: bn15(latestBlock.header.height),
3610
3504
  time: latestBlock.header.time,
3611
3505
  transactions: latestBlock.transactions.map((i) => ({
3612
3506
  id: i.id
@@ -3700,8 +3594,10 @@ var _Provider = class {
3700
3594
  * Returns some helpful parameters related to gas fees.
3701
3595
  */
3702
3596
  getGasConfig() {
3597
+ const { minGasPrice } = this.getNode();
3703
3598
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3704
3599
  return {
3600
+ minGasPrice,
3705
3601
  maxGasPerTx,
3706
3602
  maxGasPerPredicate,
3707
3603
  gasPriceFactor,
@@ -3799,7 +3695,7 @@ var _Provider = class {
3799
3695
  */
3800
3696
  async getBlockNumber() {
3801
3697
  const { chain } = await this.operations.getChain();
3802
- return bn16(chain.latestBlock.height, 10);
3698
+ return bn15(chain.latestBlock.header.height, 10);
3803
3699
  }
3804
3700
  /**
3805
3701
  * Returns the chain information.
@@ -3809,11 +3705,13 @@ var _Provider = class {
3809
3705
  async fetchNode() {
3810
3706
  const { nodeInfo } = await this.operations.getNodeInfo();
3811
3707
  const processedNodeInfo = {
3812
- maxDepth: bn16(nodeInfo.maxDepth),
3813
- maxTx: bn16(nodeInfo.maxTx),
3708
+ maxDepth: bn15(nodeInfo.maxDepth),
3709
+ maxTx: bn15(nodeInfo.maxTx),
3710
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3814
3711
  nodeVersion: nodeInfo.nodeVersion,
3815
3712
  utxoValidation: nodeInfo.utxoValidation,
3816
- vmBacktrace: nodeInfo.vmBacktrace
3713
+ vmBacktrace: nodeInfo.vmBacktrace,
3714
+ peers: nodeInfo.peers
3817
3715
  };
3818
3716
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3819
3717
  return processedNodeInfo;
@@ -3899,13 +3797,14 @@ var _Provider = class {
3899
3797
  return this.estimateTxDependencies(transactionRequest);
3900
3798
  }
3901
3799
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3902
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3903
- encodedTransactions: encodedTransaction,
3800
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3801
+ encodedTransaction,
3904
3802
  utxoValidation: utxoValidation || false
3905
3803
  });
3906
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3907
- const receipts = rawReceipts.map(processGqlReceipt);
3908
- return { receipts, dryrunStatus: status };
3804
+ const receipts = gqlReceipts.map(processGqlReceipt);
3805
+ return {
3806
+ receipts
3807
+ };
3909
3808
  }
3910
3809
  /**
3911
3810
  * Verifies whether enough gas is available to complete transaction.
@@ -3931,7 +3830,7 @@ var _Provider = class {
3931
3830
  } = response;
3932
3831
  if (inputs) {
3933
3832
  inputs.forEach((input, index) => {
3934
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3833
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3935
3834
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3936
3835
  }
3937
3836
  });
@@ -3944,6 +3843,9 @@ var _Provider = class {
3944
3843
  * If there are missing variable outputs,
3945
3844
  * `addVariableOutputs` is called on the transaction.
3946
3845
  *
3846
+ * @privateRemarks
3847
+ * TODO: Investigate support for missing contract IDs
3848
+ * TODO: Add support for missing output messages
3947
3849
  *
3948
3850
  * @param transactionRequest - The transaction request object.
3949
3851
  * @returns A promise.
@@ -3956,19 +3858,16 @@ var _Provider = class {
3956
3858
  missingContractIds: []
3957
3859
  };
3958
3860
  }
3861
+ await this.estimatePredicates(transactionRequest);
3959
3862
  let receipts = [];
3960
3863
  const missingContractIds = [];
3961
3864
  let outputVariables = 0;
3962
- let dryrunStatus;
3963
3865
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3964
- const {
3965
- dryRun: [{ receipts: rawReceipts, status }]
3966
- } = await this.operations.dryRun({
3967
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3866
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3867
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3968
3868
  utxoValidation: false
3969
3869
  });
3970
- receipts = rawReceipts.map(processGqlReceipt);
3971
- dryrunStatus = status;
3870
+ receipts = gqlReceipts.map(processGqlReceipt);
3972
3871
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3973
3872
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3974
3873
  if (hasMissingOutputs) {
@@ -3978,10 +3877,6 @@ var _Provider = class {
3978
3877
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3979
3878
  missingContractIds.push(contractId);
3980
3879
  });
3981
- const { maxFee } = await this.estimateTxGasAndFee({
3982
- transactionRequest
3983
- });
3984
- transactionRequest.maxFee = maxFee;
3985
3880
  } else {
3986
3881
  break;
3987
3882
  }
@@ -3989,139 +3884,37 @@ var _Provider = class {
3989
3884
  return {
3990
3885
  receipts,
3991
3886
  outputVariables,
3992
- missingContractIds,
3993
- dryrunStatus
3887
+ missingContractIds
3994
3888
  };
3995
3889
  }
3996
- /**
3997
- * Dry runs multiple transactions and checks for missing dependencies in batches.
3998
- *
3999
- * Transactions are dry run in batches. After each dry run, transactions requiring
4000
- * further modifications are identified. The method iteratively updates these transactions
4001
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4002
- *
4003
- * @param transactionRequests - Array of transaction request objects.
4004
- * @returns A promise that resolves to an array of results for each transaction.
4005
- */
4006
- async estimateMultipleTxDependencies(transactionRequests) {
4007
- const results = transactionRequests.map(() => ({
4008
- receipts: [],
4009
- outputVariables: 0,
4010
- missingContractIds: [],
4011
- dryrunStatus: void 0
4012
- }));
4013
- const allRequests = clone3(transactionRequests);
4014
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4015
- allRequests.forEach((req, index) => {
4016
- if (req.type === TransactionType8.Script) {
4017
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4018
- }
4019
- });
4020
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4021
- let attempt = 0;
4022
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4023
- const encodedTransactions = transactionsToProcess.map(
4024
- (index) => serializedTransactionsMap.get(index)
4025
- );
4026
- const dryRunResults = await this.operations.dryRun({
4027
- encodedTransactions,
4028
- utxoValidation: false
4029
- });
4030
- const nextRoundTransactions = [];
4031
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4032
- const currentResultIndex = transactionsToProcess[i];
4033
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4034
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4035
- results[currentResultIndex].dryrunStatus = status;
4036
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4037
- results[currentResultIndex].receipts
4038
- );
4039
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4040
- const requestToProcess = allRequests[currentResultIndex];
4041
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4042
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4043
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4044
- missingOutputContractIds.forEach(({ contractId }) => {
4045
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4046
- results[currentResultIndex].missingContractIds.push(contractId);
4047
- });
4048
- const { maxFee } = await this.estimateTxGasAndFee({
4049
- transactionRequest: requestToProcess
4050
- });
4051
- requestToProcess.maxFee = maxFee;
4052
- serializedTransactionsMap.set(
4053
- currentResultIndex,
4054
- hexlify12(requestToProcess.toTransactionBytes())
4055
- );
4056
- nextRoundTransactions.push(currentResultIndex);
4057
- allRequests[currentResultIndex] = requestToProcess;
4058
- }
4059
- }
4060
- transactionsToProcess = nextRoundTransactions;
4061
- attempt += 1;
4062
- }
4063
- return results;
4064
- }
4065
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4066
- if (estimateTxDependencies) {
4067
- return this.estimateMultipleTxDependencies(transactionRequests);
4068
- }
4069
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4070
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4071
- encodedTransactions,
4072
- utxoValidation: utxoValidation || false
4073
- });
4074
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4075
- const receipts = rawReceipts.map(processGqlReceipt);
4076
- return { receipts, dryrunStatus: status };
4077
- });
4078
- return results;
4079
- }
4080
3890
  /**
4081
3891
  * Estimates the transaction gas and fee based on the provided transaction request.
4082
3892
  * @param transactionRequest - The transaction request object.
4083
3893
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4084
3894
  */
4085
- async estimateTxGasAndFee(params) {
3895
+ estimateTxGasAndFee(params) {
4086
3896
  const { transactionRequest } = params;
4087
- let { gasPrice } = params;
3897
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4088
3898
  const chainInfo = this.getChain();
4089
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3899
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3900
+ transactionRequest.gasPrice = gasPrice;
4090
3901
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4091
- if (!gasPrice) {
4092
- gasPrice = await this.estimateGasPrice(10);
4093
- }
4094
- const minFee = calculateGasFee({
4095
- gasPrice: bn16(gasPrice),
4096
- gas: minGas,
4097
- priceFactor: gasPriceFactor,
4098
- tip: transactionRequest.tip
4099
- }).add(1);
4100
- let gasLimit = bn16(0);
3902
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4101
3903
  if (transactionRequest.type === TransactionType8.Script) {
4102
- gasLimit = transactionRequest.gasLimit;
4103
3904
  if (transactionRequest.gasLimit.eq(0)) {
4104
3905
  transactionRequest.gasLimit = minGas;
4105
3906
  transactionRequest.gasLimit = maxGasPerTx.sub(
4106
3907
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4107
3908
  );
4108
- gasLimit = transactionRequest.gasLimit;
4109
3909
  }
4110
3910
  }
4111
3911
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4112
- const maxFee = calculateGasFee({
4113
- gasPrice: bn16(gasPrice),
4114
- gas: maxGas,
4115
- priceFactor: gasPriceFactor,
4116
- tip: transactionRequest.tip
4117
- }).add(1);
3912
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4118
3913
  return {
4119
3914
  minGas,
4120
3915
  minFee,
4121
3916
  maxGas,
4122
- maxFee,
4123
- gasPrice,
4124
- gasLimit
3917
+ maxFee
4125
3918
  };
4126
3919
  }
4127
3920
  /**
@@ -4139,17 +3932,15 @@ var _Provider = class {
4139
3932
  if (estimateTxDependencies) {
4140
3933
  return this.estimateTxDependencies(transactionRequest);
4141
3934
  }
4142
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4143
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4144
- encodedTransactions,
3935
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3936
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3937
+ encodedTransaction,
4145
3938
  utxoValidation: true
4146
3939
  });
4147
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4148
- const { id, receipts, status } = dryRunStatus;
4149
- const processedReceipts = receipts.map(processGqlReceipt);
4150
- return { id, receipts: processedReceipts, status };
4151
- });
4152
- return { receipts: callResult[0].receipts };
3940
+ const receipts = gqlReceipts.map(processGqlReceipt);
3941
+ return {
3942
+ receipts
3943
+ };
4153
3944
  }
4154
3945
  /**
4155
3946
  * Returns a transaction cost to enable user
@@ -4166,79 +3957,77 @@ var _Provider = class {
4166
3957
  * @param tolerance - The tolerance to add on top of the gasUsed.
4167
3958
  * @returns A promise that resolves to the transaction cost object.
4168
3959
  */
4169
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3960
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3961
+ estimateTxDependencies = true,
3962
+ estimatePredicates = true,
3963
+ resourcesOwner,
3964
+ signatureCallback
3965
+ } = {}) {
4170
3966
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3967
+ const { minGasPrice } = this.getGasConfig();
3968
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4171
3969
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4172
3970
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4173
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3971
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4174
3972
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4175
- txRequestClone.maxFee = bn16(0);
4176
3973
  if (isScriptTransaction) {
4177
- txRequestClone.gasLimit = bn16(0);
3974
+ txRequestClone.gasLimit = bn15(0);
4178
3975
  }
4179
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4180
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3976
+ if (estimatePredicates) {
3977
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3978
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3979
+ }
3980
+ await this.estimatePredicates(txRequestClone);
4181
3981
  }
4182
- const signedRequest = clone3(txRequestClone);
4183
- let addedSignatures = 0;
4184
3982
  if (signatureCallback && isScriptTransaction) {
4185
- const lengthBefore = signedRequest.witnesses.length;
4186
- await signatureCallback(signedRequest);
4187
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
3983
+ await signatureCallback(txRequestClone);
4188
3984
  }
4189
- await this.estimatePredicates(signedRequest);
4190
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4191
- transactionRequest: signedRequest
3985
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3986
+ transactionRequest: txRequestClone
4192
3987
  });
4193
3988
  let receipts = [];
4194
3989
  let missingContractIds = [];
4195
3990
  let outputVariables = 0;
4196
- let gasUsed = bn16(0);
4197
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4198
- txRequestClone.maxFee = maxFee;
4199
- if (isScriptTransaction) {
4200
- txRequestClone.gasLimit = gasLimit;
4201
- if (signatureCallback) {
4202
- await signatureCallback(txRequestClone);
4203
- }
3991
+ let gasUsed = bn15(0);
3992
+ if (isScriptTransaction && estimateTxDependencies) {
3993
+ txRequestClone.gasPrice = bn15(0);
4204
3994
  const result = await this.estimateTxDependencies(txRequestClone);
4205
3995
  receipts = result.receipts;
4206
3996
  outputVariables = result.outputVariables;
4207
3997
  missingContractIds = result.missingContractIds;
4208
3998
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4209
3999
  txRequestClone.gasLimit = gasUsed;
4210
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4211
- transactionRequest: txRequestClone,
4212
- gasPrice
4000
+ txRequestClone.gasPrice = setGasPrice;
4001
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4002
+ transactionRequest: txRequestClone
4213
4003
  }));
4214
4004
  }
4215
4005
  return {
4216
4006
  requiredQuantities: allQuantities,
4217
4007
  receipts,
4218
4008
  gasUsed,
4219
- gasPrice,
4009
+ minGasPrice,
4010
+ gasPrice: setGasPrice,
4220
4011
  minGas,
4221
4012
  maxGas,
4222
4013
  minFee,
4223
4014
  maxFee,
4015
+ estimatedInputs: txRequestClone.inputs,
4224
4016
  outputVariables,
4225
- missingContractIds,
4226
- addedSignatures,
4227
- estimatedPredicates: txRequestClone.inputs
4017
+ missingContractIds
4228
4018
  };
4229
4019
  }
4230
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4020
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4231
4021
  const ownerAddress = Address2.fromAddressOrString(owner);
4232
4022
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4233
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4234
- quantitiesToContract
4235
- });
4023
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4236
4024
  transactionRequest.addResources(
4237
4025
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4238
4026
  );
4239
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4240
- quantitiesToContract
4241
- });
4027
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4028
+ transactionRequest,
4029
+ forwardingQuantities
4030
+ );
4242
4031
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4243
4032
  return {
4244
4033
  resources,
@@ -4260,10 +4049,11 @@ var _Provider = class {
4260
4049
  return coins.map((coin) => ({
4261
4050
  id: coin.utxoId,
4262
4051
  assetId: coin.assetId,
4263
- amount: bn16(coin.amount),
4052
+ amount: bn15(coin.amount),
4264
4053
  owner: Address2.fromAddressOrString(coin.owner),
4265
- blockCreated: bn16(coin.blockCreated),
4266
- txCreatedIdx: bn16(coin.txCreatedIdx)
4054
+ maturity: bn15(coin.maturity).toNumber(),
4055
+ blockCreated: bn15(coin.blockCreated),
4056
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4267
4057
  }));
4268
4058
  }
4269
4059
  /**
@@ -4300,9 +4090,9 @@ var _Provider = class {
4300
4090
  switch (coin.__typename) {
4301
4091
  case "MessageCoin":
4302
4092
  return {
4303
- amount: bn16(coin.amount),
4093
+ amount: bn15(coin.amount),
4304
4094
  assetId: coin.assetId,
4305
- daHeight: bn16(coin.daHeight),
4095
+ daHeight: bn15(coin.daHeight),
4306
4096
  sender: Address2.fromAddressOrString(coin.sender),
4307
4097
  recipient: Address2.fromAddressOrString(coin.recipient),
4308
4098
  nonce: coin.nonce
@@ -4310,11 +4100,12 @@ var _Provider = class {
4310
4100
  case "Coin":
4311
4101
  return {
4312
4102
  id: coin.utxoId,
4313
- amount: bn16(coin.amount),
4103
+ amount: bn15(coin.amount),
4314
4104
  assetId: coin.assetId,
4315
4105
  owner: Address2.fromAddressOrString(coin.owner),
4316
- blockCreated: bn16(coin.blockCreated),
4317
- txCreatedIdx: bn16(coin.txCreatedIdx)
4106
+ maturity: bn15(coin.maturity).toNumber(),
4107
+ blockCreated: bn15(coin.blockCreated),
4108
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4318
4109
  };
4319
4110
  default:
4320
4111
  return null;
@@ -4331,13 +4122,13 @@ var _Provider = class {
4331
4122
  async getBlock(idOrHeight) {
4332
4123
  let variables;
4333
4124
  if (typeof idOrHeight === "number") {
4334
- variables = { height: bn16(idOrHeight).toString(10) };
4125
+ variables = { height: bn15(idOrHeight).toString(10) };
4335
4126
  } else if (idOrHeight === "latest") {
4336
4127
  variables = { height: (await this.getBlockNumber()).toString(10) };
4337
4128
  } else if (idOrHeight.length === 66) {
4338
4129
  variables = { blockId: idOrHeight };
4339
4130
  } else {
4340
- variables = { blockId: bn16(idOrHeight).toString(10) };
4131
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4341
4132
  }
4342
4133
  const { block } = await this.operations.getBlock(variables);
4343
4134
  if (!block) {
@@ -4345,7 +4136,7 @@ var _Provider = class {
4345
4136
  }
4346
4137
  return {
4347
4138
  id: block.id,
4348
- height: bn16(block.height),
4139
+ height: bn15(block.header.height),
4349
4140
  time: block.header.time,
4350
4141
  transactionIds: block.transactions.map((tx) => tx.id)
4351
4142
  };
@@ -4360,7 +4151,7 @@ var _Provider = class {
4360
4151
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4361
4152
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4362
4153
  id: block.id,
4363
- height: bn16(block.height),
4154
+ height: bn15(block.header.height),
4364
4155
  time: block.header.time,
4365
4156
  transactionIds: block.transactions.map((tx) => tx.id)
4366
4157
  }));
@@ -4375,7 +4166,7 @@ var _Provider = class {
4375
4166
  async getBlockWithTransactions(idOrHeight) {
4376
4167
  let variables;
4377
4168
  if (typeof idOrHeight === "number") {
4378
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4169
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4379
4170
  } else if (idOrHeight === "latest") {
4380
4171
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4381
4172
  } else {
@@ -4387,7 +4178,7 @@ var _Provider = class {
4387
4178
  }
4388
4179
  return {
4389
4180
  id: block.id,
4390
- height: bn16(block.height, 10),
4181
+ height: bn15(block.header.height, 10),
4391
4182
  time: block.header.time,
4392
4183
  transactionIds: block.transactions.map((tx) => tx.id),
4393
4184
  transactions: block.transactions.map(
@@ -4436,7 +4227,7 @@ var _Provider = class {
4436
4227
  contract: Address2.fromAddressOrString(contractId).toB256(),
4437
4228
  asset: hexlify12(assetId)
4438
4229
  });
4439
- return bn16(contractBalance.amount, 10);
4230
+ return bn15(contractBalance.amount, 10);
4440
4231
  }
4441
4232
  /**
4442
4233
  * Returns the balance for the given owner for the given asset ID.
@@ -4450,7 +4241,7 @@ var _Provider = class {
4450
4241
  owner: Address2.fromAddressOrString(owner).toB256(),
4451
4242
  assetId: hexlify12(assetId)
4452
4243
  });
4453
- return bn16(balance.amount, 10);
4244
+ return bn15(balance.amount, 10);
4454
4245
  }
4455
4246
  /**
4456
4247
  * Returns balances for the given owner.
@@ -4468,7 +4259,7 @@ var _Provider = class {
4468
4259
  const balances = result.balances.edges.map((edge) => edge.node);
4469
4260
  return balances.map((balance) => ({
4470
4261
  assetId: balance.assetId,
4471
- amount: bn16(balance.amount)
4262
+ amount: bn15(balance.amount)
4472
4263
  }));
4473
4264
  }
4474
4265
  /**
@@ -4490,15 +4281,15 @@ var _Provider = class {
4490
4281
  sender: message.sender,
4491
4282
  recipient: message.recipient,
4492
4283
  nonce: message.nonce,
4493
- amount: bn16(message.amount),
4284
+ amount: bn15(message.amount),
4494
4285
  data: message.data
4495
4286
  }),
4496
4287
  sender: Address2.fromAddressOrString(message.sender),
4497
4288
  recipient: Address2.fromAddressOrString(message.recipient),
4498
4289
  nonce: message.nonce,
4499
- amount: bn16(message.amount),
4290
+ amount: bn15(message.amount),
4500
4291
  data: InputMessageCoder.decodeData(message.data),
4501
- daHeight: bn16(message.daHeight)
4292
+ daHeight: bn15(message.daHeight)
4502
4293
  }));
4503
4294
  }
4504
4295
  /**
@@ -4551,60 +4342,44 @@ var _Provider = class {
4551
4342
  } = result.messageProof;
4552
4343
  return {
4553
4344
  messageProof: {
4554
- proofIndex: bn16(messageProof.proofIndex),
4345
+ proofIndex: bn15(messageProof.proofIndex),
4555
4346
  proofSet: messageProof.proofSet
4556
4347
  },
4557
4348
  blockProof: {
4558
- proofIndex: bn16(blockProof.proofIndex),
4349
+ proofIndex: bn15(blockProof.proofIndex),
4559
4350
  proofSet: blockProof.proofSet
4560
4351
  },
4561
4352
  messageBlockHeader: {
4562
4353
  id: messageBlockHeader.id,
4563
- daHeight: bn16(messageBlockHeader.daHeight),
4564
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4354
+ daHeight: bn15(messageBlockHeader.daHeight),
4355
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4565
4356
  transactionsRoot: messageBlockHeader.transactionsRoot,
4566
- height: bn16(messageBlockHeader.height),
4357
+ height: bn15(messageBlockHeader.height),
4567
4358
  prevRoot: messageBlockHeader.prevRoot,
4568
4359
  time: messageBlockHeader.time,
4569
4360
  applicationHash: messageBlockHeader.applicationHash,
4570
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4571
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4572
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4573
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4574
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4361
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4362
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4575
4363
  },
4576
4364
  commitBlockHeader: {
4577
4365
  id: commitBlockHeader.id,
4578
- daHeight: bn16(commitBlockHeader.daHeight),
4579
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4366
+ daHeight: bn15(commitBlockHeader.daHeight),
4367
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4580
4368
  transactionsRoot: commitBlockHeader.transactionsRoot,
4581
- height: bn16(commitBlockHeader.height),
4369
+ height: bn15(commitBlockHeader.height),
4582
4370
  prevRoot: commitBlockHeader.prevRoot,
4583
4371
  time: commitBlockHeader.time,
4584
4372
  applicationHash: commitBlockHeader.applicationHash,
4585
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4586
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4587
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4588
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4589
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4373
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4374
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4590
4375
  },
4591
4376
  sender: Address2.fromAddressOrString(sender),
4592
4377
  recipient: Address2.fromAddressOrString(recipient),
4593
4378
  nonce,
4594
- amount: bn16(amount),
4379
+ amount: bn15(amount),
4595
4380
  data
4596
4381
  };
4597
4382
  }
4598
- async getLatestGasPrice() {
4599
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4600
- return bn16(latestGasPrice.gasPrice);
4601
- }
4602
- async estimateGasPrice(blockHorizon) {
4603
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4604
- blockHorizon: String(blockHorizon)
4605
- });
4606
- return bn16(estimateGasPrice.gasPrice);
4607
- }
4608
4383
  /**
4609
4384
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4610
4385
  *
@@ -4624,10 +4399,10 @@ var _Provider = class {
4624
4399
  */
4625
4400
  async produceBlocks(amount, startTime) {
4626
4401
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4627
- blocksToProduce: bn16(amount).toString(10),
4402
+ blocksToProduce: bn15(amount).toString(10),
4628
4403
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4629
4404
  });
4630
- return bn16(latestBlockHeight);
4405
+ return bn15(latestBlockHeight);
4631
4406
  }
4632
4407
  // eslint-disable-next-line @typescript-eslint/require-await
4633
4408
  async getTransactionResponse(transactionId) {
@@ -4641,7 +4416,7 @@ cacheInputs_fn = function(inputs) {
4641
4416
  return;
4642
4417
  }
4643
4418
  inputs.forEach((input) => {
4644
- if (input.type === InputType7.Coin) {
4419
+ if (input.type === InputType6.Coin) {
4645
4420
  this.cache?.set(input.id);
4646
4421
  }
4647
4422
  });
@@ -4651,7 +4426,7 @@ __publicField(Provider, "nodeInfoCache", {});
4651
4426
 
4652
4427
  // src/providers/transaction-summary/get-transaction-summary.ts
4653
4428
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4654
- import { bn as bn17 } from "@fuel-ts/math";
4429
+ import { bn as bn16 } from "@fuel-ts/math";
4655
4430
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4656
4431
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4657
4432
 
@@ -4897,33 +4672,36 @@ var Account = class extends AbstractAccount {
4897
4672
  * @param fee - The estimated transaction fee.
4898
4673
  * @returns A promise that resolves when the resources are added to the transaction.
4899
4674
  */
4900
- async fund(request, params) {
4901
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4902
- const txRequest = request;
4903
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4904
- amount: bn18(fee),
4675
+ async fund(request, coinQuantities, fee) {
4676
+ const updatedQuantities = addAmountToAsset({
4677
+ amount: bn17(fee),
4905
4678
  assetId: BaseAssetId3,
4906
- coinQuantities: requiredQuantities
4679
+ coinQuantities
4907
4680
  });
4908
4681
  const quantitiesDict = {};
4909
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4682
+ updatedQuantities.forEach(({ amount, assetId }) => {
4910
4683
  quantitiesDict[assetId] = {
4911
4684
  required: amount,
4912
- owned: bn18(0)
4685
+ owned: bn17(0)
4913
4686
  };
4914
4687
  });
4915
- txRequest.inputs.forEach((input) => {
4688
+ const cachedUtxos = [];
4689
+ const cachedMessages = [];
4690
+ const owner = this.address.toB256();
4691
+ request.inputs.forEach((input) => {
4916
4692
  const isResource = "amount" in input;
4917
4693
  if (isResource) {
4918
4694
  const isCoin2 = "owner" in input;
4919
4695
  if (isCoin2) {
4920
4696
  const assetId = String(input.assetId);
4921
- if (quantitiesDict[assetId]) {
4922
- const amount = bn18(input.amount);
4697
+ if (input.owner === owner && quantitiesDict[assetId]) {
4698
+ const amount = bn17(input.amount);
4923
4699
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4700
+ cachedUtxos.push(input.id);
4924
4701
  }
4925
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4702
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4926
4703
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4704
+ cachedMessages.push(input.nonce);
4927
4705
  }
4928
4706
  }
4929
4707
  });
@@ -4938,23 +4716,12 @@ var Account = class extends AbstractAccount {
4938
4716
  });
4939
4717
  const needsToBeFunded = missingQuantities.length;
4940
4718
  if (needsToBeFunded) {
4941
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4942
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4943
- txRequest.addResources(resources);
4944
- }
4945
- txRequest.shiftPredicateData();
4946
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4947
- const requestToBeReEstimate = clone4(txRequest);
4948
- if (addedSignatures) {
4949
- Array.from({ length: addedSignatures }).forEach(
4950
- () => requestToBeReEstimate.addEmptyWitness()
4951
- );
4719
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4720
+ messages: cachedMessages,
4721
+ utxos: cachedUtxos
4722
+ });
4723
+ request.addResources(resources);
4952
4724
  }
4953
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4954
- transactionRequest: requestToBeReEstimate
4955
- });
4956
- txRequest.maxFee = maxFee;
4957
- return txRequest;
4958
4725
  }
4959
4726
  /**
4960
4727
  * A helper that creates a transfer transaction request and returns it.
@@ -4962,25 +4729,28 @@ var Account = class extends AbstractAccount {
4962
4729
  * @param destination - The address of the destination.
4963
4730
  * @param amount - The amount of coins to transfer.
4964
4731
  * @param assetId - The asset ID of the coins to transfer.
4965
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4732
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4966
4733
  * @returns A promise that resolves to the prepared transaction request.
4967
4734
  */
4968
4735
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4969
- const request = new ScriptTransactionRequest(txParams);
4736
+ const { minGasPrice } = this.provider.getGasConfig();
4737
+ const params = { gasPrice: minGasPrice, ...txParams };
4738
+ const request = new ScriptTransactionRequest(params);
4970
4739
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4971
- const txCost = await this.provider.getTransactionCost(request, {
4740
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4972
4741
  estimateTxDependencies: true,
4973
4742
  resourcesOwner: this
4974
4743
  });
4975
- if ("gasLimit" in txParams) {
4976
- this.validateGas({
4977
- gasUsed: txCost.gasUsed,
4978
- gasLimit: request.gasLimit
4979
- });
4980
- }
4981
- request.gasLimit = txCost.gasUsed;
4982
- request.maxFee = txCost.maxFee;
4983
- await this.fund(request, txCost);
4744
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4745
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4746
+ this.validateGas({
4747
+ gasUsed,
4748
+ gasPrice: request.gasPrice,
4749
+ gasLimit: request.gasLimit,
4750
+ minGasPrice
4751
+ });
4752
+ await this.fund(request, requiredQuantities, maxFee);
4753
+ request.updatePredicateInputs(estimatedInputs);
4984
4754
  return request;
4985
4755
  }
4986
4756
  /**
@@ -4993,7 +4763,7 @@ var Account = class extends AbstractAccount {
4993
4763
  * @returns A promise that resolves to the transaction response.
4994
4764
  */
4995
4765
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4996
- if (bn18(amount).lte(0)) {
4766
+ if (bn17(amount).lte(0)) {
4997
4767
  throw new FuelError15(
4998
4768
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4999
4769
  "Transfer amount must be a positive number."
@@ -5012,37 +4782,38 @@ var Account = class extends AbstractAccount {
5012
4782
  * @returns A promise that resolves to the transaction response.
5013
4783
  */
5014
4784
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5015
- if (bn18(amount).lte(0)) {
4785
+ if (bn17(amount).lte(0)) {
5016
4786
  throw new FuelError15(
5017
4787
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5018
4788
  "Transfer amount must be a positive number."
5019
4789
  );
5020
4790
  }
5021
4791
  const contractAddress = Address3.fromAddressOrString(contractId);
4792
+ const { minGasPrice } = this.provider.getGasConfig();
4793
+ const params = { gasPrice: minGasPrice, ...txParams };
5022
4794
  const { script, scriptData } = await assembleTransferToContractScript({
5023
4795
  hexlifiedContractId: contractAddress.toB256(),
5024
- amountToTransfer: bn18(amount),
4796
+ amountToTransfer: bn17(amount),
5025
4797
  assetId
5026
4798
  });
5027
4799
  const request = new ScriptTransactionRequest({
5028
- ...txParams,
4800
+ ...params,
5029
4801
  script,
5030
4802
  scriptData
5031
4803
  });
5032
4804
  request.addContractInputAndOutput(contractAddress);
5033
- const txCost = await this.provider.getTransactionCost(request, {
5034
- resourcesOwner: this,
5035
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
4805
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4806
+ request,
4807
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4808
+ );
4809
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4810
+ this.validateGas({
4811
+ gasUsed,
4812
+ gasPrice: request.gasPrice,
4813
+ gasLimit: request.gasLimit,
4814
+ minGasPrice
5036
4815
  });
5037
- if (txParams.gasLimit) {
5038
- this.validateGas({
5039
- gasUsed: txCost.gasUsed,
5040
- gasLimit: request.gasLimit
5041
- });
5042
- }
5043
- request.gasLimit = txCost.gasUsed;
5044
- request.maxFee = txCost.maxFee;
5045
- await this.fund(request, txCost);
4816
+ await this.fund(request, requiredQuantities, maxFee);
5046
4817
  return this.sendTransaction(request);
5047
4818
  }
5048
4819
  /**
@@ -5054,31 +4825,34 @@ var Account = class extends AbstractAccount {
5054
4825
  * @returns A promise that resolves to the transaction response.
5055
4826
  */
5056
4827
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4828
+ const { minGasPrice } = this.provider.getGasConfig();
5057
4829
  const recipientAddress = Address3.fromAddressOrString(recipient);
5058
4830
  const recipientDataArray = arrayify14(
5059
4831
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5060
4832
  );
5061
4833
  const amountDataArray = arrayify14(
5062
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
4834
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5063
4835
  );
5064
4836
  const script = new Uint8Array([
5065
4837
  ...arrayify14(withdrawScript.bytes),
5066
4838
  ...recipientDataArray,
5067
4839
  ...amountDataArray
5068
4840
  ]);
5069
- const params = { script, ...txParams };
4841
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5070
4842
  const request = new ScriptTransactionRequest(params);
5071
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5072
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5073
- if (txParams.gasLimit) {
5074
- this.validateGas({
5075
- gasUsed: txCost.gasUsed,
5076
- gasLimit: request.gasLimit
5077
- });
5078
- }
5079
- request.maxFee = txCost.maxFee;
5080
- request.gasLimit = txCost.gasUsed;
5081
- await this.fund(request, txCost);
4843
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4844
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4845
+ request,
4846
+ forwardingQuantities
4847
+ );
4848
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4849
+ this.validateGas({
4850
+ gasUsed,
4851
+ gasPrice: request.gasPrice,
4852
+ gasLimit: request.gasLimit,
4853
+ minGasPrice
4854
+ });
4855
+ await this.fund(request, requiredQuantities, maxFee);
5082
4856
  return this.sendTransaction(request);
5083
4857
  }
5084
4858
  async signMessage(message) {
@@ -5136,7 +4910,18 @@ var Account = class extends AbstractAccount {
5136
4910
  }
5137
4911
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5138
4912
  }
5139
- validateGas({ gasUsed, gasLimit }) {
4913
+ validateGas({
4914
+ gasUsed,
4915
+ gasPrice,
4916
+ gasLimit,
4917
+ minGasPrice
4918
+ }) {
4919
+ if (minGasPrice.gt(gasPrice)) {
4920
+ throw new FuelError15(
4921
+ ErrorCode15.GAS_PRICE_TOO_LOW,
4922
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4923
+ );
4924
+ }
5140
4925
  if (gasUsed.gt(gasLimit)) {
5141
4926
  throw new FuelError15(
5142
4927
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5428,7 +5213,7 @@ var BaseWalletUnlocked = class extends Account {
5428
5213
  * @param transactionRequestLike - The transaction request to send.
5429
5214
  * @returns A promise that resolves to the TransactionResponse object.
5430
5215
  */
5431
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5216
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5432
5217
  const transactionRequest = transactionRequestify(transactionRequestLike);
5433
5218
  if (estimateTxDependencies) {
5434
5219
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5469,7 +5254,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5469
5254
  // src/hdwallet/hdwallet.ts
5470
5255
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5471
5256
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5472
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5257
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5473
5258
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5474
5259
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5475
5260
 
@@ -7935,7 +7720,7 @@ var HDWallet = class {
7935
7720
  const IR = bytes.slice(32);
7936
7721
  if (privateKey) {
7937
7722
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7938
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
7723
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7939
7724
  return new HDWallet({
7940
7725
  privateKey: ki,
7941
7726
  chainCode: IR,
@@ -8206,15 +7991,14 @@ var seedTestWallet = async (wallet, quantities) => {
8206
7991
  process.env.GENESIS_SECRET || randomBytes5(32),
8207
7992
  wallet.provider
8208
7993
  );
8209
- const request = new ScriptTransactionRequest();
8210
- quantities.forEach((quantity) => {
8211
- const { amount, assetId } = coinQuantityfy(quantity);
8212
- request.addCoinOutput(wallet.address, amount, assetId);
7994
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
7995
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
7996
+ const request = new ScriptTransactionRequest({
7997
+ gasLimit: 1e4,
7998
+ gasPrice: minGasPrice
8213
7999
  });
8214
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8215
- request.gasLimit = txCost.gasUsed;
8216
- request.maxFee = txCost.maxFee;
8217
- await genesisWallet.fund(request, txCost);
8000
+ request.addResources(resources);
8001
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8218
8002
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8219
8003
  };
8220
8004
 
@@ -8229,11 +8013,11 @@ var generateTestWallet = async (provider, quantities) => {
8229
8013
 
8230
8014
  // src/test-utils/launchNode.ts
8231
8015
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8232
- import { defaultChainConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8016
+ import { toHex as toHex2 } from "@fuel-ts/math";
8017
+ import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8233
8018
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
8234
8019
  import { spawn } from "child_process";
8235
8020
  import { randomUUID } from "crypto";
8236
- import { randomBytes as randomBytes6 } from "ethers";
8237
8021
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
8238
8022
  import os from "os";
8239
8023
  import path from "path";
@@ -8282,12 +8066,12 @@ var launchNode = async ({
8282
8066
  // eslint-disable-next-line no-async-promise-executor
8283
8067
  new Promise(async (resolve, reject) => {
8284
8068
  const remainingArgs = extractRemainingArgs(args, [
8285
- "--snapshot",
8069
+ "--chain",
8286
8070
  "--consensus-key",
8287
8071
  "--db-type",
8288
8072
  "--poa-instant"
8289
8073
  ]);
8290
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8074
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8291
8075
  const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
8292
8076
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8293
8077
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
@@ -8306,54 +8090,36 @@ var launchNode = async ({
8306
8090
  let chainConfigPathToUse;
8307
8091
  const prefix = basePath || os.tmpdir();
8308
8092
  const suffix = basePath ? "" : randomUUID();
8309
- const tempDirPath = path.join(prefix, ".fuels", suffix, "chainConfigs");
8093
+ const tempDirPath = path.join(prefix, ".fuels", suffix);
8310
8094
  if (chainConfigPath) {
8311
8095
  chainConfigPathToUse = chainConfigPath;
8312
8096
  } else {
8313
8097
  if (!existsSync(tempDirPath)) {
8314
8098
  mkdirSync(tempDirPath, { recursive: true });
8315
8099
  }
8316
- let { stateConfigJson } = defaultChainConfigs;
8317
- const { chainConfigJson, metadataJson } = defaultChainConfigs;
8318
- stateConfigJson = {
8319
- ...stateConfigJson,
8320
- coins: [
8321
- ...stateConfigJson.coins.map((coin) => ({
8322
- ...coin,
8323
- amount: "18446744073709551615"
8324
- }))
8325
- ],
8326
- messages: stateConfigJson.messages.map((message) => ({
8327
- ...message,
8328
- amount: "18446744073709551615"
8329
- }))
8330
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8331
- };
8100
+ const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
8101
+ let chainConfig = defaultChainConfig;
8332
8102
  if (!process.env.GENESIS_SECRET) {
8333
8103
  const pk = Signer.generatePrivateKey();
8334
8104
  const signer = new Signer(pk);
8335
8105
  process.env.GENESIS_SECRET = hexlify18(pk);
8336
- stateConfigJson.coins.push({
8337
- tx_id: hexlify18(randomBytes6(34)),
8338
- owner: signer.address.toHexString(),
8339
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8340
- amount: "18446744073709551615",
8341
- asset_id: BaseAssetId4,
8342
- output_index: 0,
8343
- tx_pointer_block_height: 0,
8344
- tx_pointer_tx_idx: 0
8345
- });
8106
+ chainConfig = {
8107
+ ...defaultChainConfig,
8108
+ initial_state: {
8109
+ ...defaultChainConfig.initial_state,
8110
+ coins: [
8111
+ ...defaultChainConfig.initial_state.coins,
8112
+ {
8113
+ owner: signer.address.toHexString(),
8114
+ amount: toHex2(1e9),
8115
+ asset_id: BaseAssetId4
8116
+ }
8117
+ ]
8118
+ }
8119
+ };
8346
8120
  }
8347
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8348
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8349
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8350
- const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8351
- const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8352
- const metadataWritePath = path.join(tempDirPath, "metadata.json");
8353
- writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8354
- writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8355
- writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8356
- chainConfigPathToUse = tempDirPath;
8121
+ writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8122
+ chainConfigPathToUse = tempChainConfigFilePath;
8357
8123
  }
8358
8124
  const child = spawn(
8359
8125
  command,
@@ -8362,10 +8128,10 @@ var launchNode = async ({
8362
8128
  ["--ip", ipToUse],
8363
8129
  ["--port", portToUse],
8364
8130
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8365
- ["--min-gas-price", "1"],
8131
+ ["--min-gas-price", "0"],
8366
8132
  poaInstant ? ["--poa-instant", "true"] : [],
8367
8133
  ["--consensus-key", consensusKey],
8368
- ["--snapshot", chainConfigPathToUse],
8134
+ ["--chain", chainConfigPathToUse],
8369
8135
  "--vm-backtrace",
8370
8136
  "--utxo-validation",
8371
8137
  "--debug",
@@ -8424,7 +8190,7 @@ var launchNodeAndGetWallets = async ({
8424
8190
  walletCount = 10
8425
8191
  } = {}) => {
8426
8192
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8427
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8193
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8428
8194
  const wallets = await generateWallets(walletCount, provider);
8429
8195
  const cleanup = () => {
8430
8196
  closeNode();