@fuel-ts/account 0.0.0-rc-2021-20240415193305 → 0.0.0-rc-2045-20240416150348

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

Potentially problematic release.


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

Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +545 -796
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +507 -762
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +388 -642
  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/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -7
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +27 -37
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +25 -8
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1057 -1546
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +503 -740
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +397 -634
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
package/dist/index.mjs CHANGED
@@ -32,9 +32,8 @@ import { Address as Address3 } from "@fuel-ts/address";
32
32
  import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
33
33
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
34
34
  import { AbstractAccount } from "@fuel-ts/interfaces";
35
- import { bn as bn18 } from "@fuel-ts/math";
35
+ import { bn as bn17 } from "@fuel-ts/math";
36
36
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
37
- import { clone as clone4 } from "ramda";
38
37
 
39
38
  // src/providers/coin-quantity.ts
40
39
  import { BaseAssetId } from "@fuel-ts/address/configs";
@@ -60,7 +59,7 @@ var coinQuantityfy = (coinQuantityLike) => {
60
59
  max: max2 ? bn(max2) : void 0
61
60
  };
62
61
  };
63
- var addAmountToCoinQuantities = (params) => {
62
+ var addAmountToAsset = (params) => {
64
63
  const { amount, assetId } = params;
65
64
  const coinQuantities = [...params.coinQuantities];
66
65
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -75,9 +74,9 @@ var addAmountToCoinQuantities = (params) => {
75
74
  // src/providers/provider.ts
76
75
  import { Address as Address2 } from "@fuel-ts/address";
77
76
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
78
- import { BN, bn as bn16 } from "@fuel-ts/math";
77
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
79
78
  import {
80
- InputType as InputType7,
79
+ InputType as InputType6,
81
80
  TransactionType as TransactionType8,
82
81
  InputMessageCoder,
83
82
  TransactionCoder as TransactionCoder5
@@ -93,10 +92,14 @@ import { clone as clone3 } from "ramda";
93
92
  import gql from "graphql-tag";
94
93
  var ReceiptFragmentFragmentDoc = gql`
95
94
  fragment receiptFragment on Receipt {
96
- id
95
+ contract {
96
+ id
97
+ }
97
98
  pc
98
99
  is
99
- to
100
+ to {
101
+ id
102
+ }
100
103
  toAddress
101
104
  amount
102
105
  assetId
@@ -134,16 +137,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
134
137
  id
135
138
  }
136
139
  time
137
- receipts {
138
- ...receiptFragment
139
- }
140
140
  programState {
141
141
  returnType
142
142
  data
143
143
  }
144
- receipts {
145
- ...receiptFragment
146
- }
147
144
  }
148
145
  ... on FailureStatus {
149
146
  block {
@@ -151,24 +148,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
151
148
  }
152
149
  time
153
150
  reason
154
- receipts {
155
- ...receiptFragment
156
- }
157
151
  }
158
152
  ... on SqueezedOutStatus {
159
153
  reason
160
154
  }
161
155
  }
162
- ${ReceiptFragmentFragmentDoc}`;
156
+ `;
163
157
  var TransactionFragmentFragmentDoc = gql`
164
158
  fragment transactionFragment on Transaction {
165
159
  id
166
160
  rawPayload
161
+ gasPrice
162
+ receipts {
163
+ ...receiptFragment
164
+ }
167
165
  status {
168
166
  ...transactionStatusFragment
169
167
  }
170
168
  }
171
- ${TransactionStatusFragmentFragmentDoc}`;
169
+ ${ReceiptFragmentFragmentDoc}
170
+ ${TransactionStatusFragmentFragmentDoc}`;
172
171
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
173
172
  fragment inputEstimatePredicatesFragment on Input {
174
173
  ... on InputCoin {
@@ -186,46 +185,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
186
185
  }
187
186
  }
188
187
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
189
- var DryRunFailureStatusFragmentFragmentDoc = gql`
190
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
191
- reason
192
- programState {
193
- returnType
194
- data
195
- }
196
- }
197
- `;
198
- var DryRunSuccessStatusFragmentFragmentDoc = gql`
199
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
200
- programState {
201
- returnType
202
- data
203
- }
204
- }
205
- `;
206
- var DryRunTransactionStatusFragmentFragmentDoc = gql`
207
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
208
- ... on DryRunFailureStatus {
209
- ...dryRunFailureStatusFragment
210
- }
211
- ... on DryRunSuccessStatus {
212
- ...dryRunSuccessStatusFragment
213
- }
214
- }
215
- ${DryRunFailureStatusFragmentFragmentDoc}
216
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
217
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
218
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
219
- id
220
- status {
221
- ...dryRunTransactionStatusFragment
222
- }
223
- receipts {
224
- ...receiptFragment
225
- }
226
- }
227
- ${DryRunTransactionStatusFragmentFragmentDoc}
228
- ${ReceiptFragmentFragmentDoc}`;
229
188
  var CoinFragmentFragmentDoc = gql`
230
189
  fragment coinFragment on Coin {
231
190
  __typename
@@ -233,6 +192,7 @@ var CoinFragmentFragmentDoc = gql`
233
192
  owner
234
193
  amount
235
194
  assetId
195
+ maturity
236
196
  blockCreated
237
197
  txCreatedIdx
238
198
  }
@@ -271,32 +231,26 @@ var MessageProofFragmentFragmentDoc = gql`
271
231
  messageBlockHeader {
272
232
  id
273
233
  daHeight
274
- consensusParametersVersion
275
- stateTransitionBytecodeVersion
276
234
  transactionsCount
277
- messageReceiptCount
278
235
  transactionsRoot
279
- messageOutboxRoot
280
- eventInboxRoot
281
236
  height
282
237
  prevRoot
283
238
  time
284
239
  applicationHash
240
+ messageReceiptRoot
241
+ messageReceiptCount
285
242
  }
286
243
  commitBlockHeader {
287
244
  id
288
245
  daHeight
289
- consensusParametersVersion
290
- stateTransitionBytecodeVersion
291
246
  transactionsCount
292
- messageReceiptCount
293
247
  transactionsRoot
294
- messageOutboxRoot
295
- eventInboxRoot
296
248
  height
297
249
  prevRoot
298
250
  time
299
251
  applicationHash
252
+ messageReceiptRoot
253
+ messageReceiptCount
300
254
  }
301
255
  sender
302
256
  recipient
@@ -315,8 +269,8 @@ var BalanceFragmentFragmentDoc = gql`
315
269
  var BlockFragmentFragmentDoc = gql`
316
270
  fragment blockFragment on Block {
317
271
  id
318
- height
319
272
  header {
273
+ height
320
274
  time
321
275
  }
322
276
  transactions {
@@ -374,11 +328,6 @@ var DependentCostFragmentFragmentDoc = gql`
374
328
  `;
375
329
  var GasCostsFragmentFragmentDoc = gql`
376
330
  fragment GasCostsFragment on GasCosts {
377
- version {
378
- ... on Version {
379
- value
380
- }
381
- }
382
331
  add
383
332
  addi
384
333
  aloc
@@ -391,6 +340,7 @@ var GasCostsFragmentFragmentDoc = gql`
391
340
  cb
392
341
  cfei
393
342
  cfsi
343
+ croo
394
344
  div
395
345
  divi
396
346
  ecr1
@@ -473,9 +423,6 @@ var GasCostsFragmentFragmentDoc = gql`
473
423
  ccp {
474
424
  ...DependentCostFragment
475
425
  }
476
- croo {
477
- ...DependentCostFragment
478
- }
479
426
  csiz {
480
427
  ...DependentCostFragment
481
428
  }
@@ -535,11 +482,6 @@ var GasCostsFragmentFragmentDoc = gql`
535
482
  ${DependentCostFragmentFragmentDoc}`;
536
483
  var ConsensusParametersFragmentFragmentDoc = gql`
537
484
  fragment consensusParametersFragment on ConsensusParameters {
538
- version {
539
- ... on Version {
540
- value
541
- }
542
- }
543
485
  txParams {
544
486
  ...TxParametersFragment
545
487
  }
@@ -599,9 +541,18 @@ var NodeInfoFragmentFragmentDoc = gql`
599
541
  fragment nodeInfoFragment on NodeInfo {
600
542
  utxoValidation
601
543
  vmBacktrace
544
+ minGasPrice
602
545
  maxTx
603
546
  maxDepth
604
547
  nodeVersion
548
+ peers {
549
+ id
550
+ addresses
551
+ clientVersion
552
+ blockHeight
553
+ lastHeartbeatMs
554
+ appScore
555
+ }
605
556
  }
606
557
  `;
607
558
  var GetVersionDocument = gql`
@@ -636,9 +587,13 @@ var GetTransactionWithReceiptsDocument = gql`
636
587
  query getTransactionWithReceipts($transactionId: TransactionId!) {
637
588
  transaction(id: $transactionId) {
638
589
  ...transactionFragment
590
+ receipts {
591
+ ...receiptFragment
592
+ }
639
593
  }
640
594
  }
641
- ${TransactionFragmentFragmentDoc}`;
595
+ ${TransactionFragmentFragmentDoc}
596
+ ${ReceiptFragmentFragmentDoc}`;
642
597
  var GetTransactionsDocument = gql`
643
598
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
644
599
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -766,20 +721,6 @@ var GetBalanceDocument = gql`
766
721
  }
767
722
  }
768
723
  ${BalanceFragmentFragmentDoc}`;
769
- var GetLatestGasPriceDocument = gql`
770
- query getLatestGasPrice {
771
- latestGasPrice {
772
- gasPrice
773
- }
774
- }
775
- `;
776
- var EstimateGasPriceDocument = gql`
777
- query estimateGasPrice($blockHorizon: U32!) {
778
- estimateGasPrice(blockHorizon: $blockHorizon) {
779
- gasPrice
780
- }
781
- }
782
- `;
783
724
  var GetBalancesDocument = gql`
784
725
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
785
726
  balances(
@@ -834,12 +775,12 @@ var GetMessageStatusDocument = gql`
834
775
  }
835
776
  `;
836
777
  var DryRunDocument = gql`
837
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
838
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
839
- ...dryRunTransactionExecutionStatusFragment
778
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
779
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
780
+ ...receiptFragment
840
781
  }
841
782
  }
842
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
783
+ ${ReceiptFragmentFragmentDoc}`;
843
784
  var SubmitDocument = gql`
844
785
  mutation submit($encodedTransaction: HexString!) {
845
786
  submit(tx: $encodedTransaction) {
@@ -922,12 +863,6 @@ function getSdk(requester) {
922
863
  getBalance(variables, options) {
923
864
  return requester(GetBalanceDocument, variables, options);
924
865
  },
925
- getLatestGasPrice(variables, options) {
926
- return requester(GetLatestGasPriceDocument, variables, options);
927
- },
928
- estimateGasPrice(variables, options) {
929
- return requester(EstimateGasPriceDocument, variables, options);
930
- },
931
866
  getBalances(variables, options) {
932
867
  return requester(GetBalancesDocument, variables, options);
933
868
  },
@@ -997,14 +932,11 @@ var _FuelGraphqlSubscriber = class {
997
932
  let data;
998
933
  let errors;
999
934
  try {
1000
- const sanitizedText = text.replace(/\s/g, "");
1001
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
935
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1002
936
  } catch (e) {
1003
937
  throw new FuelError(
1004
938
  ErrorCode.STREAM_PARSING_ERROR,
1005
- `Error while parsing stream data response: ${text}
1006
-
1007
- Thrown error: ${e}`
939
+ `Error while parsing stream data response: ${text}`
1008
940
  );
1009
941
  }
1010
942
  if (Array.isArray(errors)) {
@@ -1115,9 +1047,10 @@ var inputify = (value) => {
1115
1047
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1116
1048
  },
1117
1049
  witnessIndex: value.witnessIndex,
1050
+ maturity: value.maturity ?? 0,
1118
1051
  predicateGasUsed: bn2(value.predicateGasUsed),
1119
- predicateLength: bn2(predicate.length),
1120
- predicateDataLength: bn2(predicateData.length),
1052
+ predicateLength: predicate.length,
1053
+ predicateDataLength: predicateData.length,
1121
1054
  predicate: hexlify3(predicate),
1122
1055
  predicateData: hexlify3(predicateData)
1123
1056
  };
@@ -1148,8 +1081,8 @@ var inputify = (value) => {
1148
1081
  nonce: hexlify3(value.nonce),
1149
1082
  witnessIndex: value.witnessIndex,
1150
1083
  predicateGasUsed: bn2(value.predicateGasUsed),
1151
- predicateLength: bn2(predicate.length),
1152
- predicateDataLength: bn2(predicateData.length),
1084
+ predicateLength: predicate.length,
1085
+ predicateDataLength: predicateData.length,
1153
1086
  predicate: hexlify3(predicate),
1154
1087
  predicateData: hexlify3(predicateData),
1155
1088
  data: hexlify3(data),
@@ -1279,8 +1212,8 @@ function assembleReceiptByType(receipt) {
1279
1212
  case "CALL" /* Call */: {
1280
1213
  const callReceipt = {
1281
1214
  type: ReceiptType.Call,
1282
- from: hexOrZero(receipt.id || receipt.contractId),
1283
- to: hexOrZero(receipt?.to),
1215
+ from: hexOrZero(receipt.contract?.id),
1216
+ to: hexOrZero(receipt?.to?.id),
1284
1217
  amount: bn4(receipt.amount),
1285
1218
  assetId: hexOrZero(receipt.assetId),
1286
1219
  gas: bn4(receipt.gas),
@@ -1294,7 +1227,7 @@ function assembleReceiptByType(receipt) {
1294
1227
  case "RETURN" /* Return */: {
1295
1228
  const returnReceipt = {
1296
1229
  type: ReceiptType.Return,
1297
- id: hexOrZero(receipt.id || receipt.contractId),
1230
+ id: hexOrZero(receipt.contract?.id),
1298
1231
  val: bn4(receipt.val),
1299
1232
  pc: bn4(receipt.pc),
1300
1233
  is: bn4(receipt.is)
@@ -1304,7 +1237,7 @@ function assembleReceiptByType(receipt) {
1304
1237
  case "RETURN_DATA" /* ReturnData */: {
1305
1238
  const returnDataReceipt = {
1306
1239
  type: ReceiptType.ReturnData,
1307
- id: hexOrZero(receipt.id || receipt.contractId),
1240
+ id: hexOrZero(receipt.contract?.id),
1308
1241
  ptr: bn4(receipt.ptr),
1309
1242
  len: bn4(receipt.len),
1310
1243
  digest: hexOrZero(receipt.digest),
@@ -1316,7 +1249,7 @@ function assembleReceiptByType(receipt) {
1316
1249
  case "PANIC" /* Panic */: {
1317
1250
  const panicReceipt = {
1318
1251
  type: ReceiptType.Panic,
1319
- id: hexOrZero(receipt.id),
1252
+ id: hexOrZero(receipt.contract?.id),
1320
1253
  reason: bn4(receipt.reason),
1321
1254
  pc: bn4(receipt.pc),
1322
1255
  is: bn4(receipt.is),
@@ -1327,7 +1260,7 @@ function assembleReceiptByType(receipt) {
1327
1260
  case "REVERT" /* Revert */: {
1328
1261
  const revertReceipt = {
1329
1262
  type: ReceiptType.Revert,
1330
- id: hexOrZero(receipt.id || receipt.contractId),
1263
+ id: hexOrZero(receipt.contract?.id),
1331
1264
  val: bn4(receipt.ra),
1332
1265
  pc: bn4(receipt.pc),
1333
1266
  is: bn4(receipt.is)
@@ -1337,7 +1270,7 @@ function assembleReceiptByType(receipt) {
1337
1270
  case "LOG" /* Log */: {
1338
1271
  const logReceipt = {
1339
1272
  type: ReceiptType.Log,
1340
- id: hexOrZero(receipt.id || receipt.contractId),
1273
+ id: hexOrZero(receipt.contract?.id),
1341
1274
  val0: bn4(receipt.ra),
1342
1275
  val1: bn4(receipt.rb),
1343
1276
  val2: bn4(receipt.rc),
@@ -1350,7 +1283,7 @@ function assembleReceiptByType(receipt) {
1350
1283
  case "LOG_DATA" /* LogData */: {
1351
1284
  const logDataReceipt = {
1352
1285
  type: ReceiptType.LogData,
1353
- id: hexOrZero(receipt.id || receipt.contractId),
1286
+ id: hexOrZero(receipt.contract?.id),
1354
1287
  val0: bn4(receipt.ra),
1355
1288
  val1: bn4(receipt.rb),
1356
1289
  ptr: bn4(receipt.ptr),
@@ -1364,8 +1297,8 @@ function assembleReceiptByType(receipt) {
1364
1297
  case "TRANSFER" /* Transfer */: {
1365
1298
  const transferReceipt = {
1366
1299
  type: ReceiptType.Transfer,
1367
- from: hexOrZero(receipt.id || receipt.contractId),
1368
- to: hexOrZero(receipt.toAddress || receipt?.to),
1300
+ from: hexOrZero(receipt.contract?.id),
1301
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1369
1302
  amount: bn4(receipt.amount),
1370
1303
  assetId: hexOrZero(receipt.assetId),
1371
1304
  pc: bn4(receipt.pc),
@@ -1376,8 +1309,8 @@ function assembleReceiptByType(receipt) {
1376
1309
  case "TRANSFER_OUT" /* TransferOut */: {
1377
1310
  const transferOutReceipt = {
1378
1311
  type: ReceiptType.TransferOut,
1379
- from: hexOrZero(receipt.id || receipt.contractId),
1380
- to: hexOrZero(receipt.toAddress || receipt.to),
1312
+ from: hexOrZero(receipt.contract?.id),
1313
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1381
1314
  amount: bn4(receipt.amount),
1382
1315
  assetId: hexOrZero(receipt.assetId),
1383
1316
  pc: bn4(receipt.pc),
@@ -1420,7 +1353,7 @@ function assembleReceiptByType(receipt) {
1420
1353
  return receiptMessageOut;
1421
1354
  }
1422
1355
  case "MINT" /* Mint */: {
1423
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1356
+ const contractId = hexOrZero(receipt.contract?.id);
1424
1357
  const subId = hexOrZero(receipt.subId);
1425
1358
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1426
1359
  const mintReceipt = {
@@ -1435,7 +1368,7 @@ function assembleReceiptByType(receipt) {
1435
1368
  return mintReceipt;
1436
1369
  }
1437
1370
  case "BURN" /* Burn */: {
1438
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1371
+ const contractId = hexOrZero(receipt.contract?.id);
1439
1372
  const subId = hexOrZero(receipt.subId);
1440
1373
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1441
1374
  const burnReceipt = {
@@ -1520,6 +1453,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1520
1453
  import { bn as bn5 } from "@fuel-ts/math";
1521
1454
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1522
1455
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1456
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1523
1457
  var getGasUsedFromReceipts = (receipts) => {
1524
1458
  const scriptResult = receipts.filter(
1525
1459
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1540,28 +1474,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1540
1474
  }
1541
1475
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1542
1476
  const witnessCache = [];
1543
- const chargeableInputs = inputs.filter((input) => {
1544
- const isCoinOrMessage = "owner" in input || "sender" in input;
1545
- if (isCoinOrMessage) {
1546
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1547
- return true;
1548
- }
1549
- if (!witnessCache.includes(input.witnessIndex)) {
1550
- witnessCache.push(input.witnessIndex);
1551
- return true;
1552
- }
1553
- }
1554
- return false;
1555
- });
1556
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1557
- const totalGas = chargeableInputs.reduce((total, input) => {
1477
+ const totalGas = inputs.reduce((total, input) => {
1558
1478
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1559
1479
  return total.add(
1560
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1480
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1561
1481
  );
1562
1482
  }
1563
- return total.add(gasCosts.ecr1);
1564
- }, bn5(0));
1483
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1484
+ witnessCache.push(input.witnessIndex);
1485
+ return total.add(gasCosts.ecr1);
1486
+ }
1487
+ return total;
1488
+ }, bn5());
1565
1489
  return totalGas;
1566
1490
  }
1567
1491
  function getMinGas(params) {
@@ -1573,20 +1497,12 @@ function getMinGas(params) {
1573
1497
  return minGas;
1574
1498
  }
1575
1499
  function getMaxGas(params) {
1576
- const {
1577
- gasPerByte,
1578
- witnessesLength,
1579
- witnessLimit,
1580
- minGas,
1581
- gasLimit = bn5(0),
1582
- maxGasPerTx
1583
- } = params;
1500
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1584
1501
  let remainingAllowedWitnessGas = bn5(0);
1585
1502
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1586
1503
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1587
1504
  }
1588
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1589
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1505
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1590
1506
  }
1591
1507
  function calculateMetadataGasForTxCreate({
1592
1508
  gasCosts,
@@ -1608,10 +1524,6 @@ function calculateMetadataGasForTxScript({
1608
1524
  }) {
1609
1525
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1610
1526
  }
1611
- var calculateGasFee = (params) => {
1612
- const { gas, gasPrice, priceFactor, tip } = params;
1613
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1614
- };
1615
1527
 
1616
1528
  // src/providers/utils/json.ts
1617
1529
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1768,7 +1680,7 @@ var witnessify = (value) => {
1768
1680
  // src/providers/transaction-request/transaction-request.ts
1769
1681
  var BaseTransactionRequest = class {
1770
1682
  /** Gas price for transaction */
1771
- tip;
1683
+ gasPrice;
1772
1684
  /** Block until which tx cannot be included */
1773
1685
  maturity;
1774
1686
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1787,7 +1699,7 @@ var BaseTransactionRequest = class {
1787
1699
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1788
1700
  */
1789
1701
  constructor({
1790
- tip,
1702
+ gasPrice,
1791
1703
  maturity,
1792
1704
  maxFee,
1793
1705
  witnessLimit,
@@ -1795,7 +1707,7 @@ var BaseTransactionRequest = class {
1795
1707
  outputs,
1796
1708
  witnesses
1797
1709
  } = {}) {
1798
- this.tip = bn7(tip);
1710
+ this.gasPrice = bn7(gasPrice);
1799
1711
  this.maturity = maturity ?? 0;
1800
1712
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1801
1713
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
@@ -1806,9 +1718,9 @@ var BaseTransactionRequest = class {
1806
1718
  static getPolicyMeta(req) {
1807
1719
  let policyTypes = 0;
1808
1720
  const policies = [];
1809
- if (req.tip) {
1810
- policyTypes += PolicyType.Tip;
1811
- policies.push({ data: req.tip, type: PolicyType.Tip });
1721
+ if (req.gasPrice) {
1722
+ policyTypes += PolicyType.GasPrice;
1723
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1812
1724
  }
1813
1725
  if (req.witnessLimit) {
1814
1726
  policyTypes += PolicyType.WitnessLimit;
@@ -1995,10 +1907,10 @@ var BaseTransactionRequest = class {
1995
1907
  * @param predicate - Predicate bytes.
1996
1908
  * @param predicateData - Predicate data bytes.
1997
1909
  */
1998
- addCoinInput(coin) {
1910
+ addCoinInput(coin, predicate) {
1999
1911
  const { assetId, owner, amount } = coin;
2000
1912
  let witnessIndex;
2001
- if (coin.predicate) {
1913
+ if (predicate) {
2002
1914
  witnessIndex = 0;
2003
1915
  } else {
2004
1916
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2013,7 +1925,8 @@ var BaseTransactionRequest = class {
2013
1925
  amount,
2014
1926
  assetId,
2015
1927
  txPointer: "0x00000000000000000000000000000000",
2016
- witnessIndex
1928
+ witnessIndex,
1929
+ predicate: predicate?.bytes
2017
1930
  };
2018
1931
  this.pushInput(input);
2019
1932
  this.addChangeOutput(owner, assetId);
@@ -2026,11 +1939,11 @@ var BaseTransactionRequest = class {
2026
1939
  * @param predicate - Predicate bytes.
2027
1940
  * @param predicateData - Predicate data bytes.
2028
1941
  */
2029
- addMessageInput(message) {
1942
+ addMessageInput(message, predicate) {
2030
1943
  const { recipient, sender, amount } = message;
2031
1944
  const assetId = BaseAssetId2;
2032
1945
  let witnessIndex;
2033
- if (message.predicate) {
1946
+ if (predicate) {
2034
1947
  witnessIndex = 0;
2035
1948
  } else {
2036
1949
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2044,7 +1957,8 @@ var BaseTransactionRequest = class {
2044
1957
  sender: sender.toB256(),
2045
1958
  recipient: recipient.toB256(),
2046
1959
  amount,
2047
- witnessIndex
1960
+ witnessIndex,
1961
+ predicate: predicate?.bytes
2048
1962
  };
2049
1963
  this.pushInput(input);
2050
1964
  this.addChangeOutput(recipient, assetId);
@@ -2075,6 +1989,32 @@ var BaseTransactionRequest = class {
2075
1989
  resources.forEach((resource) => this.addResource(resource));
2076
1990
  return this;
2077
1991
  }
1992
+ /**
1993
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1994
+ * outputs from the related assetIds.
1995
+ *
1996
+ * @param resources - The resources to add.
1997
+ * @returns This transaction.
1998
+ */
1999
+ addPredicateResource(resource, predicate) {
2000
+ if (isCoin(resource)) {
2001
+ this.addCoinInput(resource, predicate);
2002
+ } else {
2003
+ this.addMessageInput(resource, predicate);
2004
+ }
2005
+ return this;
2006
+ }
2007
+ /**
2008
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2009
+ * from the related assetIds.
2010
+ *
2011
+ * @param resources - The resources to add.
2012
+ * @returns This transaction.
2013
+ */
2014
+ addPredicateResources(resources, predicate) {
2015
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2016
+ return this;
2017
+ }
2078
2018
  /**
2079
2019
  * Adds a coin output to the transaction.
2080
2020
  *
@@ -2154,7 +2094,7 @@ var BaseTransactionRequest = class {
2154
2094
  }
2155
2095
  calculateMaxGas(chainInfo, minGas) {
2156
2096
  const { consensusParameters } = chainInfo;
2157
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2097
+ const { gasPerByte } = consensusParameters;
2158
2098
  const witnessesLength = this.toTransaction().witnesses.reduce(
2159
2099
  (acc, wit) => acc + wit.dataLength,
2160
2100
  0
@@ -2163,8 +2103,7 @@ var BaseTransactionRequest = class {
2163
2103
  gasPerByte,
2164
2104
  minGas,
2165
2105
  witnessesLength,
2166
- witnessLimit: this.witnessLimit,
2167
- maxGasPerTx
2106
+ witnessLimit: this.witnessLimit
2168
2107
  });
2169
2108
  }
2170
2109
  /**
@@ -2182,20 +2121,17 @@ var BaseTransactionRequest = class {
2182
2121
  });
2183
2122
  const updateAssetInput = (assetId, quantity) => {
2184
2123
  const assetInput = findAssetInput(assetId);
2185
- let usedQuantity = quantity;
2186
- if (assetId === BaseAssetId2) {
2187
- usedQuantity = bn7("1000000000000000000");
2188
- }
2189
2124
  if (assetInput && "assetId" in assetInput) {
2190
2125
  assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2191
- assetInput.amount = usedQuantity;
2126
+ assetInput.amount = quantity;
2192
2127
  } else {
2193
2128
  this.addResources([
2194
2129
  {
2195
2130
  id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2196
- amount: usedQuantity,
2131
+ amount: quantity,
2197
2132
  assetId,
2198
2133
  owner: resourcesOwner || Address.fromRandom(),
2134
+ maturity: 0,
2199
2135
  blockCreated: bn7(1),
2200
2136
  txCreatedIdx: bn7(1)
2201
2137
  }
@@ -2227,7 +2163,7 @@ var BaseTransactionRequest = class {
2227
2163
  toJSON() {
2228
2164
  return normalizeJSON(this);
2229
2165
  }
2230
- updatePredicateGasUsed(inputs) {
2166
+ updatePredicateInputs(inputs) {
2231
2167
  this.inputs.forEach((i) => {
2232
2168
  let correspondingInput;
2233
2169
  switch (i.type) {
@@ -2249,15 +2185,6 @@ var BaseTransactionRequest = class {
2249
2185
  }
2250
2186
  });
2251
2187
  }
2252
- shiftPredicateData() {
2253
- this.inputs.forEach((input) => {
2254
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2255
- input.predicateData = input.paddPredicateData(
2256
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2257
- );
2258
- }
2259
- });
2260
- }
2261
2188
  };
2262
2189
 
2263
2190
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2404,8 +2331,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2404
2331
  return {
2405
2332
  type: TransactionType3.Create,
2406
2333
  ...baseTransaction,
2334
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2407
2335
  bytecodeWitnessIndex,
2408
- storageSlotsCount: bn9(storageSlots.length),
2336
+ storageSlotsCount: storageSlots.length,
2409
2337
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2410
2338
  storageSlots
2411
2339
  };
@@ -2528,8 +2456,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2528
2456
  type: TransactionType4.Script,
2529
2457
  scriptGasLimit: this.gasLimit,
2530
2458
  ...super.getBaseTransaction(),
2531
- scriptLength: bn10(script.length),
2532
- scriptDataLength: bn10(scriptData.length),
2459
+ scriptLength: script.length,
2460
+ scriptDataLength: scriptData.length,
2533
2461
  receiptsRoot: ZeroBytes327,
2534
2462
  script: hexlify10(script),
2535
2463
  scriptData: hexlify10(scriptData)
@@ -2593,7 +2521,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2593
2521
  }
2594
2522
  calculateMaxGas(chainInfo, minGas) {
2595
2523
  const { consensusParameters } = chainInfo;
2596
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2524
+ const { gasPerByte } = consensusParameters;
2597
2525
  const witnessesLength = this.toTransaction().witnesses.reduce(
2598
2526
  (acc, wit) => acc + wit.dataLength,
2599
2527
  0
@@ -2603,8 +2531,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2603
2531
  minGas,
2604
2532
  witnessesLength,
2605
2533
  witnessLimit: this.witnessLimit,
2606
- gasLimit: this.gasLimit,
2607
- maxGasPerTx
2534
+ gasLimit: this.gasLimit
2608
2535
  });
2609
2536
  }
2610
2537
  /**
@@ -2661,7 +2588,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2661
2588
 
2662
2589
  // src/providers/transaction-request/utils.ts
2663
2590
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2664
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2591
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2665
2592
  var transactionRequestify = (obj) => {
2666
2593
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2667
2594
  return obj;
@@ -2679,31 +2606,14 @@ var transactionRequestify = (obj) => {
2679
2606
  }
2680
2607
  }
2681
2608
  };
2682
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2683
- (acc, input) => {
2684
- if (input.type === InputType5.Coin && input.owner === owner) {
2685
- acc.utxos.push(input.id);
2686
- }
2687
- if (input.type === InputType5.Message && input.recipient === owner) {
2688
- acc.messages.push(input.nonce);
2689
- }
2690
- return acc;
2691
- },
2692
- {
2693
- utxos: [],
2694
- messages: []
2695
- }
2696
- );
2697
2609
 
2698
2610
  // src/providers/transaction-response/transaction-response.ts
2699
2611
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2700
- import { bn as bn15 } from "@fuel-ts/math";
2612
+ import { bn as bn14 } from "@fuel-ts/math";
2701
2613
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2702
2614
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2703
2615
 
2704
2616
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2705
- import { bn as bn14 } from "@fuel-ts/math";
2706
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2707
2617
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2708
2618
 
2709
2619
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2712,10 +2622,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2712
2622
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2713
2623
  var calculateTransactionFee = (params) => {
2714
2624
  const {
2715
- gasPrice,
2625
+ gasUsed,
2716
2626
  rawPayload,
2717
- tip,
2718
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2627
+ consensusParameters: { gasCosts, feeParams }
2719
2628
  } = params;
2720
2629
  const gasPerByte = bn11(feeParams.gasPerByte);
2721
2630
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2725,7 +2634,8 @@ var calculateTransactionFee = (params) => {
2725
2634
  return {
2726
2635
  fee: bn11(0),
2727
2636
  minFee: bn11(0),
2728
- maxFee: bn11(0)
2637
+ maxFee: bn11(0),
2638
+ feeFromGasUsed: bn11(0)
2729
2639
  };
2730
2640
  }
2731
2641
  const { type, witnesses, inputs, policies } = transaction;
@@ -2757,6 +2667,7 @@ var calculateTransactionFee = (params) => {
2757
2667
  metadataGas,
2758
2668
  txBytesSize: transactionBytes.length
2759
2669
  });
2670
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2760
2671
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2761
2672
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2762
2673
  const maxGas = getMaxGas({
@@ -2764,25 +2675,17 @@ var calculateTransactionFee = (params) => {
2764
2675
  minGas,
2765
2676
  witnessesLength,
2766
2677
  gasLimit,
2767
- witnessLimit,
2768
- maxGasPerTx
2769
- });
2770
- const minFee = calculateGasFee({
2771
- gasPrice,
2772
- gas: minGas,
2773
- priceFactor: gasPriceFactor,
2774
- tip
2775
- });
2776
- const maxFee = calculateGasFee({
2777
- gasPrice,
2778
- gas: maxGas,
2779
- priceFactor: gasPriceFactor,
2780
- tip
2678
+ witnessLimit
2781
2679
  });
2680
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2681
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2682
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2683
+ const fee = minFee.add(feeFromGasUsed);
2782
2684
  return {
2685
+ fee,
2783
2686
  minFee,
2784
2687
  maxFee,
2785
- fee: maxFee
2688
+ feeFromGasUsed
2786
2689
  };
2787
2690
  };
2788
2691
 
@@ -2838,7 +2741,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2838
2741
 
2839
2742
  // src/providers/transaction-summary/input.ts
2840
2743
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2841
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2744
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2842
2745
  function getInputsByTypes(inputs, types) {
2843
2746
  return inputs.filter((i) => types.includes(i.type));
2844
2747
  }
@@ -2846,16 +2749,16 @@ function getInputsByType(inputs, type) {
2846
2749
  return inputs.filter((i) => i.type === type);
2847
2750
  }
2848
2751
  function getInputsCoin(inputs) {
2849
- return getInputsByType(inputs, InputType6.Coin);
2752
+ return getInputsByType(inputs, InputType5.Coin);
2850
2753
  }
2851
2754
  function getInputsMessage(inputs) {
2852
- return getInputsByType(inputs, InputType6.Message);
2755
+ return getInputsByType(inputs, InputType5.Message);
2853
2756
  }
2854
2757
  function getInputsCoinAndMessage(inputs) {
2855
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2758
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2856
2759
  }
2857
2760
  function getInputsContract(inputs) {
2858
- return getInputsByType(inputs, InputType6.Contract);
2761
+ return getInputsByType(inputs, InputType5.Contract);
2859
2762
  }
2860
2763
  function getInputFromAssetId(inputs, assetId) {
2861
2764
  const coinInputs = getInputsCoin(inputs);
@@ -2874,7 +2777,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2874
2777
  if (!contractInput) {
2875
2778
  return void 0;
2876
2779
  }
2877
- if (contractInput.type !== InputType6.Contract) {
2780
+ if (contractInput.type !== InputType5.Contract) {
2878
2781
  throw new FuelError9(
2879
2782
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2880
2783
  `Contract input should be of type 'contract'.`
@@ -2883,10 +2786,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2883
2786
  return contractInput;
2884
2787
  }
2885
2788
  function getInputAccountAddress(input) {
2886
- if (input.type === InputType6.Coin) {
2789
+ if (input.type === InputType5.Coin) {
2887
2790
  return input.owner.toString();
2888
2791
  }
2889
- if (input.type === InputType6.Message) {
2792
+ if (input.type === InputType5.Message) {
2890
2793
  return input.recipient.toString();
2891
2794
  }
2892
2795
  return "";
@@ -3396,9 +3299,7 @@ function assembleTransactionSummary(params) {
3396
3299
  gqlTransactionStatus,
3397
3300
  abiMap = {},
3398
3301
  maxInputs,
3399
- gasCosts,
3400
- maxGasPerTx,
3401
- gasPrice
3302
+ gasCosts
3402
3303
  } = params;
3403
3304
  const gasUsed = getGasUsedFromReceipts(receipts);
3404
3305
  const rawPayload = hexlify11(transactionBytes);
@@ -3412,14 +3313,11 @@ function assembleTransactionSummary(params) {
3412
3313
  maxInputs
3413
3314
  });
3414
3315
  const typeName = getTransactionTypeName(transaction.type);
3415
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3416
3316
  const { fee } = calculateTransactionFee({
3417
- gasPrice,
3317
+ gasUsed,
3418
3318
  rawPayload,
3419
- tip,
3420
3319
  consensusParameters: {
3421
3320
  gasCosts,
3422
- maxGasPerTx,
3423
3321
  feeParams: {
3424
3322
  gasPerByte,
3425
3323
  gasPriceFactor
@@ -3479,7 +3377,7 @@ var TransactionResponse = class {
3479
3377
  /** Current provider */
3480
3378
  provider;
3481
3379
  /** Gas used on the transaction */
3482
- gasUsed = bn15(0);
3380
+ gasUsed = bn14(0);
3483
3381
  /** The graphql Transaction with receipts object. */
3484
3382
  gqlTransaction;
3485
3383
  abis;
@@ -3557,13 +3455,8 @@ var TransactionResponse = class {
3557
3455
  const decodedTransaction = this.decodeTransaction(
3558
3456
  transaction
3559
3457
  );
3560
- let txReceipts = [];
3561
- if (transaction?.status && "receipts" in transaction.status) {
3562
- txReceipts = transaction.status.receipts;
3563
- }
3564
- const receipts = txReceipts.map(processGqlReceipt) || [];
3565
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3566
- const gasPrice = await this.provider.getLatestGasPrice();
3458
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3459
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3567
3460
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3568
3461
  const transactionSummary = assembleTransactionSummary({
3569
3462
  id: this.id,
@@ -3575,9 +3468,7 @@ var TransactionResponse = class {
3575
3468
  gasPriceFactor,
3576
3469
  abiMap: contractsAbiMap,
3577
3470
  maxInputs,
3578
- gasCosts,
3579
- maxGasPerTx,
3580
- gasPrice
3471
+ gasCosts
3581
3472
  });
3582
3473
  return transactionSummary;
3583
3474
  }
@@ -3704,29 +3595,29 @@ var processGqlChain = (chain) => {
3704
3595
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3705
3596
  return {
3706
3597
  name,
3707
- baseChainHeight: bn16(daHeight),
3598
+ baseChainHeight: bn15(daHeight),
3708
3599
  consensusParameters: {
3709
- contractMaxSize: bn16(contractParams.contractMaxSize),
3710
- maxInputs: bn16(txParams.maxInputs),
3711
- maxOutputs: bn16(txParams.maxOutputs),
3712
- maxWitnesses: bn16(txParams.maxWitnesses),
3713
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3714
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3715
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3716
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3717
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3718
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3719
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3720
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3721
- gasPerByte: bn16(feeParams.gasPerByte),
3722
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3723
- chainId: bn16(consensusParameters.chainId),
3600
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3601
+ maxInputs: bn15(txParams.maxInputs),
3602
+ maxOutputs: bn15(txParams.maxOutputs),
3603
+ maxWitnesses: bn15(txParams.maxWitnesses),
3604
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3605
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3606
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3607
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3608
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3609
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3610
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3611
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3612
+ gasPerByte: bn15(feeParams.gasPerByte),
3613
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3614
+ chainId: bn15(consensusParameters.chainId),
3724
3615
  gasCosts
3725
3616
  },
3726
3617
  gasCosts,
3727
3618
  latestBlock: {
3728
3619
  id: latestBlock.id,
3729
- height: bn16(latestBlock.height),
3620
+ height: bn15(latestBlock.header.height),
3730
3621
  time: latestBlock.header.time,
3731
3622
  transactions: latestBlock.transactions.map((i) => ({
3732
3623
  id: i.id
@@ -3820,8 +3711,10 @@ var _Provider = class {
3820
3711
  * Returns some helpful parameters related to gas fees.
3821
3712
  */
3822
3713
  getGasConfig() {
3714
+ const { minGasPrice } = this.getNode();
3823
3715
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3824
3716
  return {
3717
+ minGasPrice,
3825
3718
  maxGasPerTx,
3826
3719
  maxGasPerPredicate,
3827
3720
  gasPriceFactor,
@@ -3919,7 +3812,7 @@ var _Provider = class {
3919
3812
  */
3920
3813
  async getBlockNumber() {
3921
3814
  const { chain } = await this.operations.getChain();
3922
- return bn16(chain.latestBlock.height, 10);
3815
+ return bn15(chain.latestBlock.header.height, 10);
3923
3816
  }
3924
3817
  /**
3925
3818
  * Returns the chain information.
@@ -3929,11 +3822,13 @@ var _Provider = class {
3929
3822
  async fetchNode() {
3930
3823
  const { nodeInfo } = await this.operations.getNodeInfo();
3931
3824
  const processedNodeInfo = {
3932
- maxDepth: bn16(nodeInfo.maxDepth),
3933
- maxTx: bn16(nodeInfo.maxTx),
3825
+ maxDepth: bn15(nodeInfo.maxDepth),
3826
+ maxTx: bn15(nodeInfo.maxTx),
3827
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3934
3828
  nodeVersion: nodeInfo.nodeVersion,
3935
3829
  utxoValidation: nodeInfo.utxoValidation,
3936
- vmBacktrace: nodeInfo.vmBacktrace
3830
+ vmBacktrace: nodeInfo.vmBacktrace,
3831
+ peers: nodeInfo.peers
3937
3832
  };
3938
3833
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3939
3834
  return processedNodeInfo;
@@ -4019,13 +3914,14 @@ var _Provider = class {
4019
3914
  return this.estimateTxDependencies(transactionRequest);
4020
3915
  }
4021
3916
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4022
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4023
- encodedTransactions: encodedTransaction,
3917
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3918
+ encodedTransaction,
4024
3919
  utxoValidation: utxoValidation || false
4025
3920
  });
4026
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4027
- const receipts = rawReceipts.map(processGqlReceipt);
4028
- return { receipts, dryrunStatus: status };
3921
+ const receipts = gqlReceipts.map(processGqlReceipt);
3922
+ return {
3923
+ receipts
3924
+ };
4029
3925
  }
4030
3926
  /**
4031
3927
  * Verifies whether enough gas is available to complete transaction.
@@ -4051,7 +3947,7 @@ var _Provider = class {
4051
3947
  } = response;
4052
3948
  if (inputs) {
4053
3949
  inputs.forEach((input, index) => {
4054
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3950
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
4055
3951
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4056
3952
  }
4057
3953
  });
@@ -4064,6 +3960,9 @@ var _Provider = class {
4064
3960
  * If there are missing variable outputs,
4065
3961
  * `addVariableOutputs` is called on the transaction.
4066
3962
  *
3963
+ * @privateRemarks
3964
+ * TODO: Investigate support for missing contract IDs
3965
+ * TODO: Add support for missing output messages
4067
3966
  *
4068
3967
  * @param transactionRequest - The transaction request object.
4069
3968
  * @returns A promise.
@@ -4076,19 +3975,16 @@ var _Provider = class {
4076
3975
  missingContractIds: []
4077
3976
  };
4078
3977
  }
3978
+ await this.estimatePredicates(transactionRequest);
4079
3979
  let receipts = [];
4080
3980
  const missingContractIds = [];
4081
3981
  let outputVariables = 0;
4082
- let dryrunStatus;
4083
3982
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4084
- const {
4085
- dryRun: [{ receipts: rawReceipts, status }]
4086
- } = await this.operations.dryRun({
4087
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3983
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3984
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
4088
3985
  utxoValidation: false
4089
3986
  });
4090
- receipts = rawReceipts.map(processGqlReceipt);
4091
- dryrunStatus = status;
3987
+ receipts = gqlReceipts.map(processGqlReceipt);
4092
3988
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4093
3989
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4094
3990
  if (hasMissingOutputs) {
@@ -4098,10 +3994,6 @@ var _Provider = class {
4098
3994
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
4099
3995
  missingContractIds.push(contractId);
4100
3996
  });
4101
- const { maxFee } = await this.estimateTxGasAndFee({
4102
- transactionRequest
4103
- });
4104
- transactionRequest.maxFee = maxFee;
4105
3997
  } else {
4106
3998
  break;
4107
3999
  }
@@ -4109,139 +4001,37 @@ var _Provider = class {
4109
4001
  return {
4110
4002
  receipts,
4111
4003
  outputVariables,
4112
- missingContractIds,
4113
- dryrunStatus
4004
+ missingContractIds
4114
4005
  };
4115
4006
  }
4116
- /**
4117
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4118
- *
4119
- * Transactions are dry run in batches. After each dry run, transactions requiring
4120
- * further modifications are identified. The method iteratively updates these transactions
4121
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4122
- *
4123
- * @param transactionRequests - Array of transaction request objects.
4124
- * @returns A promise that resolves to an array of results for each transaction.
4125
- */
4126
- async estimateMultipleTxDependencies(transactionRequests) {
4127
- const results = transactionRequests.map(() => ({
4128
- receipts: [],
4129
- outputVariables: 0,
4130
- missingContractIds: [],
4131
- dryrunStatus: void 0
4132
- }));
4133
- const allRequests = clone3(transactionRequests);
4134
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4135
- allRequests.forEach((req, index) => {
4136
- if (req.type === TransactionType8.Script) {
4137
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4138
- }
4139
- });
4140
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4141
- let attempt = 0;
4142
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4143
- const encodedTransactions = transactionsToProcess.map(
4144
- (index) => serializedTransactionsMap.get(index)
4145
- );
4146
- const dryRunResults = await this.operations.dryRun({
4147
- encodedTransactions,
4148
- utxoValidation: false
4149
- });
4150
- const nextRoundTransactions = [];
4151
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4152
- const currentResultIndex = transactionsToProcess[i];
4153
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4154
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4155
- results[currentResultIndex].dryrunStatus = status;
4156
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4157
- results[currentResultIndex].receipts
4158
- );
4159
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4160
- const requestToProcess = allRequests[currentResultIndex];
4161
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4162
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4163
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4164
- missingOutputContractIds.forEach(({ contractId }) => {
4165
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4166
- results[currentResultIndex].missingContractIds.push(contractId);
4167
- });
4168
- const { maxFee } = await this.estimateTxGasAndFee({
4169
- transactionRequest: requestToProcess
4170
- });
4171
- requestToProcess.maxFee = maxFee;
4172
- serializedTransactionsMap.set(
4173
- currentResultIndex,
4174
- hexlify12(requestToProcess.toTransactionBytes())
4175
- );
4176
- nextRoundTransactions.push(currentResultIndex);
4177
- allRequests[currentResultIndex] = requestToProcess;
4178
- }
4179
- }
4180
- transactionsToProcess = nextRoundTransactions;
4181
- attempt += 1;
4182
- }
4183
- return results;
4184
- }
4185
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4186
- if (estimateTxDependencies) {
4187
- return this.estimateMultipleTxDependencies(transactionRequests);
4188
- }
4189
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4190
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4191
- encodedTransactions,
4192
- utxoValidation: utxoValidation || false
4193
- });
4194
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4195
- const receipts = rawReceipts.map(processGqlReceipt);
4196
- return { receipts, dryrunStatus: status };
4197
- });
4198
- return results;
4199
- }
4200
4007
  /**
4201
4008
  * Estimates the transaction gas and fee based on the provided transaction request.
4202
4009
  * @param transactionRequest - The transaction request object.
4203
4010
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4204
4011
  */
4205
- async estimateTxGasAndFee(params) {
4012
+ estimateTxGasAndFee(params) {
4206
4013
  const { transactionRequest } = params;
4207
- let { gasPrice } = params;
4014
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4208
4015
  const chainInfo = this.getChain();
4209
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4016
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4017
+ transactionRequest.gasPrice = gasPrice;
4210
4018
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4211
- if (!gasPrice) {
4212
- gasPrice = await this.estimateGasPrice(10);
4213
- }
4214
- const minFee = calculateGasFee({
4215
- gasPrice: bn16(gasPrice),
4216
- gas: minGas,
4217
- priceFactor: gasPriceFactor,
4218
- tip: transactionRequest.tip
4219
- }).add(1);
4220
- let gasLimit = bn16(0);
4019
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4221
4020
  if (transactionRequest.type === TransactionType8.Script) {
4222
- gasLimit = transactionRequest.gasLimit;
4223
4021
  if (transactionRequest.gasLimit.eq(0)) {
4224
4022
  transactionRequest.gasLimit = minGas;
4225
4023
  transactionRequest.gasLimit = maxGasPerTx.sub(
4226
4024
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4227
4025
  );
4228
- gasLimit = transactionRequest.gasLimit;
4229
4026
  }
4230
4027
  }
4231
4028
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4232
- const maxFee = calculateGasFee({
4233
- gasPrice: bn16(gasPrice),
4234
- gas: maxGas,
4235
- priceFactor: gasPriceFactor,
4236
- tip: transactionRequest.tip
4237
- }).add(1);
4029
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4238
4030
  return {
4239
4031
  minGas,
4240
4032
  minFee,
4241
4033
  maxGas,
4242
- maxFee,
4243
- gasPrice,
4244
- gasLimit
4034
+ maxFee
4245
4035
  };
4246
4036
  }
4247
4037
  /**
@@ -4259,17 +4049,15 @@ var _Provider = class {
4259
4049
  if (estimateTxDependencies) {
4260
4050
  return this.estimateTxDependencies(transactionRequest);
4261
4051
  }
4262
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4263
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4264
- encodedTransactions,
4052
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4053
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4054
+ encodedTransaction,
4265
4055
  utxoValidation: true
4266
4056
  });
4267
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4268
- const { id, receipts, status } = dryRunStatus;
4269
- const processedReceipts = receipts.map(processGqlReceipt);
4270
- return { id, receipts: processedReceipts, status };
4271
- });
4272
- return { receipts: callResult[0].receipts };
4057
+ const receipts = gqlReceipts.map(processGqlReceipt);
4058
+ return {
4059
+ receipts
4060
+ };
4273
4061
  }
4274
4062
  /**
4275
4063
  * Returns a transaction cost to enable user
@@ -4286,79 +4074,77 @@ var _Provider = class {
4286
4074
  * @param tolerance - The tolerance to add on top of the gasUsed.
4287
4075
  * @returns A promise that resolves to the transaction cost object.
4288
4076
  */
4289
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4077
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4078
+ estimateTxDependencies = true,
4079
+ estimatePredicates = true,
4080
+ resourcesOwner,
4081
+ signatureCallback
4082
+ } = {}) {
4290
4083
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4084
+ const { minGasPrice } = this.getGasConfig();
4085
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4291
4086
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4292
4087
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4293
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4088
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4294
4089
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4295
- txRequestClone.maxFee = bn16(0);
4296
4090
  if (isScriptTransaction) {
4297
- txRequestClone.gasLimit = bn16(0);
4091
+ txRequestClone.gasLimit = bn15(0);
4298
4092
  }
4299
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4300
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4093
+ if (estimatePredicates) {
4094
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4095
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4096
+ }
4097
+ await this.estimatePredicates(txRequestClone);
4301
4098
  }
4302
- const signedRequest = clone3(txRequestClone);
4303
- let addedSignatures = 0;
4304
4099
  if (signatureCallback && isScriptTransaction) {
4305
- const lengthBefore = signedRequest.witnesses.length;
4306
- await signatureCallback(signedRequest);
4307
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4100
+ await signatureCallback(txRequestClone);
4308
4101
  }
4309
- await this.estimatePredicates(signedRequest);
4310
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4311
- transactionRequest: signedRequest
4102
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4103
+ transactionRequest: txRequestClone
4312
4104
  });
4313
4105
  let receipts = [];
4314
4106
  let missingContractIds = [];
4315
4107
  let outputVariables = 0;
4316
- let gasUsed = bn16(0);
4317
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4318
- txRequestClone.maxFee = maxFee;
4319
- if (isScriptTransaction) {
4320
- txRequestClone.gasLimit = gasLimit;
4321
- if (signatureCallback) {
4322
- await signatureCallback(txRequestClone);
4323
- }
4108
+ let gasUsed = bn15(0);
4109
+ if (isScriptTransaction && estimateTxDependencies) {
4110
+ txRequestClone.gasPrice = bn15(0);
4324
4111
  const result = await this.estimateTxDependencies(txRequestClone);
4325
4112
  receipts = result.receipts;
4326
4113
  outputVariables = result.outputVariables;
4327
4114
  missingContractIds = result.missingContractIds;
4328
4115
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4329
4116
  txRequestClone.gasLimit = gasUsed;
4330
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4331
- transactionRequest: txRequestClone,
4332
- gasPrice
4117
+ txRequestClone.gasPrice = setGasPrice;
4118
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4119
+ transactionRequest: txRequestClone
4333
4120
  }));
4334
4121
  }
4335
4122
  return {
4336
4123
  requiredQuantities: allQuantities,
4337
4124
  receipts,
4338
4125
  gasUsed,
4339
- gasPrice,
4126
+ minGasPrice,
4127
+ gasPrice: setGasPrice,
4340
4128
  minGas,
4341
4129
  maxGas,
4342
4130
  minFee,
4343
4131
  maxFee,
4132
+ estimatedInputs: txRequestClone.inputs,
4344
4133
  outputVariables,
4345
- missingContractIds,
4346
- addedSignatures,
4347
- estimatedPredicates: txRequestClone.inputs
4134
+ missingContractIds
4348
4135
  };
4349
4136
  }
4350
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4137
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4351
4138
  const ownerAddress = Address2.fromAddressOrString(owner);
4352
4139
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4353
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4354
- quantitiesToContract
4355
- });
4140
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4356
4141
  transactionRequest.addResources(
4357
4142
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4358
4143
  );
4359
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4360
- quantitiesToContract
4361
- });
4144
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4145
+ transactionRequest,
4146
+ forwardingQuantities
4147
+ );
4362
4148
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4363
4149
  return {
4364
4150
  resources,
@@ -4380,10 +4166,11 @@ var _Provider = class {
4380
4166
  return coins.map((coin) => ({
4381
4167
  id: coin.utxoId,
4382
4168
  assetId: coin.assetId,
4383
- amount: bn16(coin.amount),
4169
+ amount: bn15(coin.amount),
4384
4170
  owner: Address2.fromAddressOrString(coin.owner),
4385
- blockCreated: bn16(coin.blockCreated),
4386
- txCreatedIdx: bn16(coin.txCreatedIdx)
4171
+ maturity: bn15(coin.maturity).toNumber(),
4172
+ blockCreated: bn15(coin.blockCreated),
4173
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4387
4174
  }));
4388
4175
  }
4389
4176
  /**
@@ -4420,9 +4207,9 @@ var _Provider = class {
4420
4207
  switch (coin.__typename) {
4421
4208
  case "MessageCoin":
4422
4209
  return {
4423
- amount: bn16(coin.amount),
4210
+ amount: bn15(coin.amount),
4424
4211
  assetId: coin.assetId,
4425
- daHeight: bn16(coin.daHeight),
4212
+ daHeight: bn15(coin.daHeight),
4426
4213
  sender: Address2.fromAddressOrString(coin.sender),
4427
4214
  recipient: Address2.fromAddressOrString(coin.recipient),
4428
4215
  nonce: coin.nonce
@@ -4430,11 +4217,12 @@ var _Provider = class {
4430
4217
  case "Coin":
4431
4218
  return {
4432
4219
  id: coin.utxoId,
4433
- amount: bn16(coin.amount),
4220
+ amount: bn15(coin.amount),
4434
4221
  assetId: coin.assetId,
4435
4222
  owner: Address2.fromAddressOrString(coin.owner),
4436
- blockCreated: bn16(coin.blockCreated),
4437
- txCreatedIdx: bn16(coin.txCreatedIdx)
4223
+ maturity: bn15(coin.maturity).toNumber(),
4224
+ blockCreated: bn15(coin.blockCreated),
4225
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4438
4226
  };
4439
4227
  default:
4440
4228
  return null;
@@ -4451,13 +4239,13 @@ var _Provider = class {
4451
4239
  async getBlock(idOrHeight) {
4452
4240
  let variables;
4453
4241
  if (typeof idOrHeight === "number") {
4454
- variables = { height: bn16(idOrHeight).toString(10) };
4242
+ variables = { height: bn15(idOrHeight).toString(10) };
4455
4243
  } else if (idOrHeight === "latest") {
4456
4244
  variables = { height: (await this.getBlockNumber()).toString(10) };
4457
4245
  } else if (idOrHeight.length === 66) {
4458
4246
  variables = { blockId: idOrHeight };
4459
4247
  } else {
4460
- variables = { blockId: bn16(idOrHeight).toString(10) };
4248
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4461
4249
  }
4462
4250
  const { block } = await this.operations.getBlock(variables);
4463
4251
  if (!block) {
@@ -4465,7 +4253,7 @@ var _Provider = class {
4465
4253
  }
4466
4254
  return {
4467
4255
  id: block.id,
4468
- height: bn16(block.height),
4256
+ height: bn15(block.header.height),
4469
4257
  time: block.header.time,
4470
4258
  transactionIds: block.transactions.map((tx) => tx.id)
4471
4259
  };
@@ -4480,7 +4268,7 @@ var _Provider = class {
4480
4268
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4481
4269
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4482
4270
  id: block.id,
4483
- height: bn16(block.height),
4271
+ height: bn15(block.header.height),
4484
4272
  time: block.header.time,
4485
4273
  transactionIds: block.transactions.map((tx) => tx.id)
4486
4274
  }));
@@ -4495,7 +4283,7 @@ var _Provider = class {
4495
4283
  async getBlockWithTransactions(idOrHeight) {
4496
4284
  let variables;
4497
4285
  if (typeof idOrHeight === "number") {
4498
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4286
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4499
4287
  } else if (idOrHeight === "latest") {
4500
4288
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4501
4289
  } else {
@@ -4507,7 +4295,7 @@ var _Provider = class {
4507
4295
  }
4508
4296
  return {
4509
4297
  id: block.id,
4510
- height: bn16(block.height, 10),
4298
+ height: bn15(block.header.height, 10),
4511
4299
  time: block.header.time,
4512
4300
  transactionIds: block.transactions.map((tx) => tx.id),
4513
4301
  transactions: block.transactions.map(
@@ -4556,7 +4344,7 @@ var _Provider = class {
4556
4344
  contract: Address2.fromAddressOrString(contractId).toB256(),
4557
4345
  asset: hexlify12(assetId)
4558
4346
  });
4559
- return bn16(contractBalance.amount, 10);
4347
+ return bn15(contractBalance.amount, 10);
4560
4348
  }
4561
4349
  /**
4562
4350
  * Returns the balance for the given owner for the given asset ID.
@@ -4570,7 +4358,7 @@ var _Provider = class {
4570
4358
  owner: Address2.fromAddressOrString(owner).toB256(),
4571
4359
  assetId: hexlify12(assetId)
4572
4360
  });
4573
- return bn16(balance.amount, 10);
4361
+ return bn15(balance.amount, 10);
4574
4362
  }
4575
4363
  /**
4576
4364
  * Returns balances for the given owner.
@@ -4588,7 +4376,7 @@ var _Provider = class {
4588
4376
  const balances = result.balances.edges.map((edge) => edge.node);
4589
4377
  return balances.map((balance) => ({
4590
4378
  assetId: balance.assetId,
4591
- amount: bn16(balance.amount)
4379
+ amount: bn15(balance.amount)
4592
4380
  }));
4593
4381
  }
4594
4382
  /**
@@ -4610,15 +4398,15 @@ var _Provider = class {
4610
4398
  sender: message.sender,
4611
4399
  recipient: message.recipient,
4612
4400
  nonce: message.nonce,
4613
- amount: bn16(message.amount),
4401
+ amount: bn15(message.amount),
4614
4402
  data: message.data
4615
4403
  }),
4616
4404
  sender: Address2.fromAddressOrString(message.sender),
4617
4405
  recipient: Address2.fromAddressOrString(message.recipient),
4618
4406
  nonce: message.nonce,
4619
- amount: bn16(message.amount),
4407
+ amount: bn15(message.amount),
4620
4408
  data: InputMessageCoder.decodeData(message.data),
4621
- daHeight: bn16(message.daHeight)
4409
+ daHeight: bn15(message.daHeight)
4622
4410
  }));
4623
4411
  }
4624
4412
  /**
@@ -4671,60 +4459,44 @@ var _Provider = class {
4671
4459
  } = result.messageProof;
4672
4460
  return {
4673
4461
  messageProof: {
4674
- proofIndex: bn16(messageProof.proofIndex),
4462
+ proofIndex: bn15(messageProof.proofIndex),
4675
4463
  proofSet: messageProof.proofSet
4676
4464
  },
4677
4465
  blockProof: {
4678
- proofIndex: bn16(blockProof.proofIndex),
4466
+ proofIndex: bn15(blockProof.proofIndex),
4679
4467
  proofSet: blockProof.proofSet
4680
4468
  },
4681
4469
  messageBlockHeader: {
4682
4470
  id: messageBlockHeader.id,
4683
- daHeight: bn16(messageBlockHeader.daHeight),
4684
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4471
+ daHeight: bn15(messageBlockHeader.daHeight),
4472
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4685
4473
  transactionsRoot: messageBlockHeader.transactionsRoot,
4686
- height: bn16(messageBlockHeader.height),
4474
+ height: bn15(messageBlockHeader.height),
4687
4475
  prevRoot: messageBlockHeader.prevRoot,
4688
4476
  time: messageBlockHeader.time,
4689
4477
  applicationHash: messageBlockHeader.applicationHash,
4690
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4691
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4692
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4693
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4694
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4478
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4479
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4695
4480
  },
4696
4481
  commitBlockHeader: {
4697
4482
  id: commitBlockHeader.id,
4698
- daHeight: bn16(commitBlockHeader.daHeight),
4699
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4483
+ daHeight: bn15(commitBlockHeader.daHeight),
4484
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4700
4485
  transactionsRoot: commitBlockHeader.transactionsRoot,
4701
- height: bn16(commitBlockHeader.height),
4486
+ height: bn15(commitBlockHeader.height),
4702
4487
  prevRoot: commitBlockHeader.prevRoot,
4703
4488
  time: commitBlockHeader.time,
4704
4489
  applicationHash: commitBlockHeader.applicationHash,
4705
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4706
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4707
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4708
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4709
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4490
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4491
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4710
4492
  },
4711
4493
  sender: Address2.fromAddressOrString(sender),
4712
4494
  recipient: Address2.fromAddressOrString(recipient),
4713
4495
  nonce,
4714
- amount: bn16(amount),
4496
+ amount: bn15(amount),
4715
4497
  data
4716
4498
  };
4717
4499
  }
4718
- async getLatestGasPrice() {
4719
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4720
- return bn16(latestGasPrice.gasPrice);
4721
- }
4722
- async estimateGasPrice(blockHorizon) {
4723
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4724
- blockHorizon: String(blockHorizon)
4725
- });
4726
- return bn16(estimateGasPrice.gasPrice);
4727
- }
4728
4500
  /**
4729
4501
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4730
4502
  *
@@ -4744,10 +4516,10 @@ var _Provider = class {
4744
4516
  */
4745
4517
  async produceBlocks(amount, startTime) {
4746
4518
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4747
- blocksToProduce: bn16(amount).toString(10),
4519
+ blocksToProduce: bn15(amount).toString(10),
4748
4520
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4749
4521
  });
4750
- return bn16(latestBlockHeight);
4522
+ return bn15(latestBlockHeight);
4751
4523
  }
4752
4524
  // eslint-disable-next-line @typescript-eslint/require-await
4753
4525
  async getTransactionResponse(transactionId) {
@@ -4761,7 +4533,7 @@ cacheInputs_fn = function(inputs) {
4761
4533
  return;
4762
4534
  }
4763
4535
  inputs.forEach((input) => {
4764
- if (input.type === InputType7.Coin) {
4536
+ if (input.type === InputType6.Coin) {
4765
4537
  this.cache?.set(input.id);
4766
4538
  }
4767
4539
  });
@@ -4771,7 +4543,7 @@ __publicField(Provider, "nodeInfoCache", {});
4771
4543
 
4772
4544
  // src/providers/transaction-summary/get-transaction-summary.ts
4773
4545
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4774
- import { bn as bn17 } from "@fuel-ts/math";
4546
+ import { bn as bn16 } from "@fuel-ts/math";
4775
4547
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4776
4548
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4777
4549
  async function getTransactionSummary(params) {
@@ -4789,28 +4561,21 @@ async function getTransactionSummary(params) {
4789
4561
  arrayify12(gqlTransaction.rawPayload),
4790
4562
  0
4791
4563
  );
4792
- let txReceipts = [];
4793
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4794
- txReceipts = gqlTransaction.status.receipts;
4795
- }
4796
- const receipts = txReceipts.map(processGqlReceipt);
4564
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4797
4565
  const {
4798
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4566
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4799
4567
  } = provider.getChain();
4800
- const gasPrice = await provider.getLatestGasPrice();
4801
4568
  const transactionInfo = assembleTransactionSummary({
4802
4569
  id: gqlTransaction.id,
4803
4570
  receipts,
4804
4571
  transaction: decodedTransaction,
4805
4572
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4806
4573
  gqlTransactionStatus: gqlTransaction.status,
4807
- gasPerByte: bn17(gasPerByte),
4808
- gasPriceFactor: bn17(gasPriceFactor),
4574
+ gasPerByte: bn16(gasPerByte),
4575
+ gasPriceFactor: bn16(gasPriceFactor),
4809
4576
  abiMap,
4810
4577
  maxInputs,
4811
- gasCosts,
4812
- maxGasPerTx,
4813
- gasPrice
4578
+ gasCosts
4814
4579
  });
4815
4580
  return {
4816
4581
  gqlTransaction,
@@ -4820,11 +4585,10 @@ async function getTransactionSummary(params) {
4820
4585
  async function getTransactionSummaryFromRequest(params) {
4821
4586
  const { provider, transactionRequest, abiMap } = params;
4822
4587
  const { receipts } = await provider.call(transactionRequest);
4823
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4588
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4824
4589
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4825
4590
  const transaction = transactionRequest.toTransaction();
4826
4591
  const transactionBytes = transactionRequest.toTransactionBytes();
4827
- const gasPrice = await provider.getLatestGasPrice();
4828
4592
  const transactionSummary = assembleTransactionSummary({
4829
4593
  receipts,
4830
4594
  transaction,
@@ -4833,9 +4597,7 @@ async function getTransactionSummaryFromRequest(params) {
4833
4597
  gasPerByte,
4834
4598
  gasPriceFactor,
4835
4599
  maxInputs,
4836
- gasCosts,
4837
- maxGasPerTx,
4838
- gasPrice
4600
+ gasCosts
4839
4601
  });
4840
4602
  return transactionSummary;
4841
4603
  }
@@ -4844,18 +4606,13 @@ async function getTransactionsSummaries(params) {
4844
4606
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4845
4607
  const { edges, pageInfo } = transactionsByOwner;
4846
4608
  const {
4847
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4609
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4848
4610
  } = provider.getChain();
4849
- const gasPrice = await provider.getLatestGasPrice();
4850
4611
  const transactions = edges.map((edge) => {
4851
4612
  const { node: gqlTransaction } = edge;
4852
- const { id, rawPayload, status } = gqlTransaction;
4613
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4853
4614
  const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
4854
- let txReceipts = [];
4855
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4856
- txReceipts = gqlTransaction.status.receipts;
4857
- }
4858
- const receipts = txReceipts.map(processGqlReceipt);
4615
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4859
4616
  const transactionSummary = assembleTransactionSummary({
4860
4617
  id,
4861
4618
  receipts,
@@ -4866,9 +4623,7 @@ async function getTransactionsSummaries(params) {
4866
4623
  gasPerByte,
4867
4624
  gasPriceFactor,
4868
4625
  maxInputs,
4869
- gasCosts,
4870
- maxGasPerTx,
4871
- gasPrice
4626
+ gasCosts
4872
4627
  });
4873
4628
  const output = {
4874
4629
  gqlTransaction,
@@ -5200,33 +4955,36 @@ var Account = class extends AbstractAccount {
5200
4955
  * @param fee - The estimated transaction fee.
5201
4956
  * @returns A promise that resolves when the resources are added to the transaction.
5202
4957
  */
5203
- async fund(request, params) {
5204
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5205
- const txRequest = request;
5206
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5207
- amount: bn18(fee),
4958
+ async fund(request, coinQuantities, fee) {
4959
+ const updatedQuantities = addAmountToAsset({
4960
+ amount: bn17(fee),
5208
4961
  assetId: BaseAssetId3,
5209
- coinQuantities: requiredQuantities
4962
+ coinQuantities
5210
4963
  });
5211
4964
  const quantitiesDict = {};
5212
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4965
+ updatedQuantities.forEach(({ amount, assetId }) => {
5213
4966
  quantitiesDict[assetId] = {
5214
4967
  required: amount,
5215
- owned: bn18(0)
4968
+ owned: bn17(0)
5216
4969
  };
5217
4970
  });
5218
- txRequest.inputs.forEach((input) => {
4971
+ const cachedUtxos = [];
4972
+ const cachedMessages = [];
4973
+ const owner = this.address.toB256();
4974
+ request.inputs.forEach((input) => {
5219
4975
  const isResource = "amount" in input;
5220
4976
  if (isResource) {
5221
4977
  const isCoin2 = "owner" in input;
5222
4978
  if (isCoin2) {
5223
4979
  const assetId = String(input.assetId);
5224
- if (quantitiesDict[assetId]) {
5225
- const amount = bn18(input.amount);
4980
+ if (input.owner === owner && quantitiesDict[assetId]) {
4981
+ const amount = bn17(input.amount);
5226
4982
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4983
+ cachedUtxos.push(input.id);
5227
4984
  }
5228
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4985
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
5229
4986
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4987
+ cachedMessages.push(input.nonce);
5230
4988
  }
5231
4989
  }
5232
4990
  });
@@ -5241,23 +4999,12 @@ var Account = class extends AbstractAccount {
5241
4999
  });
5242
5000
  const needsToBeFunded = missingQuantities.length;
5243
5001
  if (needsToBeFunded) {
5244
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5245
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5246
- txRequest.addResources(resources);
5247
- }
5248
- txRequest.shiftPredicateData();
5249
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5250
- const requestToBeReEstimate = clone4(txRequest);
5251
- if (addedSignatures) {
5252
- Array.from({ length: addedSignatures }).forEach(
5253
- () => requestToBeReEstimate.addEmptyWitness()
5254
- );
5002
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5003
+ messages: cachedMessages,
5004
+ utxos: cachedUtxos
5005
+ });
5006
+ request.addResources(resources);
5255
5007
  }
5256
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5257
- transactionRequest: requestToBeReEstimate
5258
- });
5259
- txRequest.maxFee = maxFee;
5260
- return txRequest;
5261
5008
  }
5262
5009
  /**
5263
5010
  * A helper that creates a transfer transaction request and returns it.
@@ -5265,25 +5012,28 @@ var Account = class extends AbstractAccount {
5265
5012
  * @param destination - The address of the destination.
5266
5013
  * @param amount - The amount of coins to transfer.
5267
5014
  * @param assetId - The asset ID of the coins to transfer.
5268
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5015
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5269
5016
  * @returns A promise that resolves to the prepared transaction request.
5270
5017
  */
5271
5018
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5272
- const request = new ScriptTransactionRequest(txParams);
5019
+ const { minGasPrice } = this.provider.getGasConfig();
5020
+ const params = { gasPrice: minGasPrice, ...txParams };
5021
+ const request = new ScriptTransactionRequest(params);
5273
5022
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5274
- const txCost = await this.provider.getTransactionCost(request, {
5023
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5275
5024
  estimateTxDependencies: true,
5276
5025
  resourcesOwner: this
5277
5026
  });
5278
- if ("gasLimit" in txParams) {
5279
- this.validateGas({
5280
- gasUsed: txCost.gasUsed,
5281
- gasLimit: request.gasLimit
5282
- });
5283
- }
5284
- request.gasLimit = txCost.gasUsed;
5285
- request.maxFee = txCost.maxFee;
5286
- await this.fund(request, txCost);
5027
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5028
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
5029
+ this.validateGas({
5030
+ gasUsed,
5031
+ gasPrice: request.gasPrice,
5032
+ gasLimit: request.gasLimit,
5033
+ minGasPrice
5034
+ });
5035
+ await this.fund(request, requiredQuantities, maxFee);
5036
+ request.updatePredicateInputs(estimatedInputs);
5287
5037
  return request;
5288
5038
  }
5289
5039
  /**
@@ -5296,7 +5046,7 @@ var Account = class extends AbstractAccount {
5296
5046
  * @returns A promise that resolves to the transaction response.
5297
5047
  */
5298
5048
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5299
- if (bn18(amount).lte(0)) {
5049
+ if (bn17(amount).lte(0)) {
5300
5050
  throw new FuelError15(
5301
5051
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5302
5052
  "Transfer amount must be a positive number."
@@ -5315,37 +5065,38 @@ var Account = class extends AbstractAccount {
5315
5065
  * @returns A promise that resolves to the transaction response.
5316
5066
  */
5317
5067
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5318
- if (bn18(amount).lte(0)) {
5068
+ if (bn17(amount).lte(0)) {
5319
5069
  throw new FuelError15(
5320
5070
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5321
5071
  "Transfer amount must be a positive number."
5322
5072
  );
5323
5073
  }
5324
5074
  const contractAddress = Address3.fromAddressOrString(contractId);
5075
+ const { minGasPrice } = this.provider.getGasConfig();
5076
+ const params = { gasPrice: minGasPrice, ...txParams };
5325
5077
  const { script, scriptData } = await assembleTransferToContractScript({
5326
5078
  hexlifiedContractId: contractAddress.toB256(),
5327
- amountToTransfer: bn18(amount),
5079
+ amountToTransfer: bn17(amount),
5328
5080
  assetId
5329
5081
  });
5330
5082
  const request = new ScriptTransactionRequest({
5331
- ...txParams,
5083
+ ...params,
5332
5084
  script,
5333
5085
  scriptData
5334
5086
  });
5335
5087
  request.addContractInputAndOutput(contractAddress);
5336
- const txCost = await this.provider.getTransactionCost(request, {
5337
- resourcesOwner: this,
5338
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
5088
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5089
+ request,
5090
+ [{ amount: bn17(amount), assetId: String(assetId) }]
5091
+ );
5092
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5093
+ this.validateGas({
5094
+ gasUsed,
5095
+ gasPrice: request.gasPrice,
5096
+ gasLimit: request.gasLimit,
5097
+ minGasPrice
5339
5098
  });
5340
- if (txParams.gasLimit) {
5341
- this.validateGas({
5342
- gasUsed: txCost.gasUsed,
5343
- gasLimit: request.gasLimit
5344
- });
5345
- }
5346
- request.gasLimit = txCost.gasUsed;
5347
- request.maxFee = txCost.maxFee;
5348
- await this.fund(request, txCost);
5099
+ await this.fund(request, requiredQuantities, maxFee);
5349
5100
  return this.sendTransaction(request);
5350
5101
  }
5351
5102
  /**
@@ -5357,31 +5108,34 @@ var Account = class extends AbstractAccount {
5357
5108
  * @returns A promise that resolves to the transaction response.
5358
5109
  */
5359
5110
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5111
+ const { minGasPrice } = this.provider.getGasConfig();
5360
5112
  const recipientAddress = Address3.fromAddressOrString(recipient);
5361
5113
  const recipientDataArray = arrayify14(
5362
5114
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5363
5115
  );
5364
5116
  const amountDataArray = arrayify14(
5365
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
5117
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5366
5118
  );
5367
5119
  const script = new Uint8Array([
5368
5120
  ...arrayify14(withdrawScript.bytes),
5369
5121
  ...recipientDataArray,
5370
5122
  ...amountDataArray
5371
5123
  ]);
5372
- const params = { script, ...txParams };
5124
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5373
5125
  const request = new ScriptTransactionRequest(params);
5374
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5375
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5376
- if (txParams.gasLimit) {
5377
- this.validateGas({
5378
- gasUsed: txCost.gasUsed,
5379
- gasLimit: request.gasLimit
5380
- });
5381
- }
5382
- request.maxFee = txCost.maxFee;
5383
- request.gasLimit = txCost.gasUsed;
5384
- await this.fund(request, txCost);
5126
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5127
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5128
+ request,
5129
+ forwardingQuantities
5130
+ );
5131
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5132
+ this.validateGas({
5133
+ gasUsed,
5134
+ gasPrice: request.gasPrice,
5135
+ gasLimit: request.gasLimit,
5136
+ minGasPrice
5137
+ });
5138
+ await this.fund(request, requiredQuantities, maxFee);
5385
5139
  return this.sendTransaction(request);
5386
5140
  }
5387
5141
  async signMessage(message) {
@@ -5439,7 +5193,18 @@ var Account = class extends AbstractAccount {
5439
5193
  }
5440
5194
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5441
5195
  }
5442
- validateGas({ gasUsed, gasLimit }) {
5196
+ validateGas({
5197
+ gasUsed,
5198
+ gasPrice,
5199
+ gasLimit,
5200
+ minGasPrice
5201
+ }) {
5202
+ if (minGasPrice.gt(gasPrice)) {
5203
+ throw new FuelError15(
5204
+ ErrorCode15.GAS_PRICE_TOO_LOW,
5205
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5206
+ );
5207
+ }
5443
5208
  if (gasUsed.gt(gasLimit)) {
5444
5209
  throw new FuelError15(
5445
5210
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5735,7 +5500,7 @@ var BaseWalletUnlocked = class extends Account {
5735
5500
  * @param transactionRequestLike - The transaction request to send.
5736
5501
  * @returns A promise that resolves to the TransactionResponse object.
5737
5502
  */
5738
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5503
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5739
5504
  const transactionRequest = transactionRequestify(transactionRequestLike);
5740
5505
  if (estimateTxDependencies) {
5741
5506
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5776,7 +5541,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5776
5541
  // src/hdwallet/hdwallet.ts
5777
5542
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5778
5543
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5779
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5544
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5780
5545
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5781
5546
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5782
5547
 
@@ -8248,7 +8013,7 @@ var HDWallet = class {
8248
8013
  const IR = bytes.slice(32);
8249
8014
  if (privateKey) {
8250
8015
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8251
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
8016
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
8252
8017
  return new HDWallet({
8253
8018
  privateKey: ki,
8254
8019
  chainCode: IR,
@@ -8937,7 +8702,7 @@ import {
8937
8702
  import { Address as Address9 } from "@fuel-ts/address";
8938
8703
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8939
8704
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8940
- import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
8705
+ import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8941
8706
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8942
8707
 
8943
8708
  // src/predicate/utils/getPredicateRoot.ts
@@ -8997,9 +8762,9 @@ var Predicate = class extends Account {
8997
8762
  const request = transactionRequestify(transactionRequestLike);
8998
8763
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8999
8764
  request.inputs?.forEach((input) => {
9000
- if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
9001
- input.predicate = hexlify19(this.bytes);
9002
- input.predicateData = hexlify19(this.getPredicateData(policies.length));
8765
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8766
+ input.predicate = this.bytes;
8767
+ input.predicateData = this.getPredicateData(policies.length);
9003
8768
  }
9004
8769
  });
9005
8770
  return request;
@@ -9014,7 +8779,8 @@ var Predicate = class extends Account {
9014
8779
  * @returns A promise that resolves to the prepared transaction request.
9015
8780
  */
9016
8781
  async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
9017
- return super.createTransfer(destination, amount, assetId, txParams);
8782
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8783
+ return this.populateTransactionPredicateData(request);
9018
8784
  }
9019
8785
  /**
9020
8786
  * Sends a transaction with the populated predicate data.
@@ -9022,9 +8788,9 @@ var Predicate = class extends Account {
9022
8788
  * @param transactionRequestLike - The transaction request-like object.
9023
8789
  * @returns A promise that resolves to the transaction response.
9024
8790
  */
9025
- sendTransaction(transactionRequestLike) {
9026
- const transactionRequest = transactionRequestify(transactionRequestLike);
9027
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8791
+ sendTransaction(transactionRequestLike, options) {
8792
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8793
+ return super.sendTransaction(transactionRequest, options);
9028
8794
  }
9029
8795
  /**
9030
8796
  * Simulates a transaction with the populated predicate data.
@@ -9033,8 +8799,8 @@ var Predicate = class extends Account {
9033
8799
  * @returns A promise that resolves to the call result.
9034
8800
  */
9035
8801
  simulateTransaction(transactionRequestLike) {
9036
- const transactionRequest = transactionRequestify(transactionRequestLike);
9037
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8802
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8803
+ return super.simulateTransaction(transactionRequest);
9038
8804
  }
9039
8805
  getPredicateData(policiesLength) {
9040
8806
  if (!this.predicateData.length) {
@@ -9080,25 +8846,6 @@ var Predicate = class extends Account {
9080
8846
  predicateInterface: abiInterface
9081
8847
  };
9082
8848
  }
9083
- /**
9084
- * Retrieves resources satisfying the spend query for the account.
9085
- *
9086
- * @param quantities - IDs of coins to exclude.
9087
- * @param excludedIds - IDs of resources to be excluded from the query.
9088
- * @returns A promise that resolves to an array of Resources.
9089
- */
9090
- async getResourcesToSpend(quantities, excludedIds) {
9091
- const resources = await this.provider.getResourcesToSpend(
9092
- this.address,
9093
- quantities,
9094
- excludedIds
9095
- );
9096
- return resources.map((resource) => ({
9097
- ...resource,
9098
- predicate: hexlify19(this.bytes),
9099
- paddPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
9100
- }));
9101
- }
9102
8849
  /**
9103
8850
  * Sets the configurable constants for the predicate.
9104
8851
  *
@@ -9847,7 +9594,7 @@ export {
9847
9594
  WalletLocked,
9848
9595
  WalletManager,
9849
9596
  WalletUnlocked,
9850
- addAmountToCoinQuantities,
9597
+ addAmountToAsset,
9851
9598
  addOperation,
9852
9599
  assemblePanicError,
9853
9600
  assembleReceiptByType,
@@ -9856,10 +9603,9 @@ export {
9856
9603
  assets,
9857
9604
  buildBlockExplorerUrl,
9858
9605
  cacheFor,
9859
- cacheTxInputsFromOwner,
9860
- calculateGasFee,
9861
9606
  calculateMetadataGasForTxCreate,
9862
9607
  calculateMetadataGasForTxScript,
9608
+ calculatePriceWithFactor,
9863
9609
  calculateTransactionFee,
9864
9610
  coinQuantityfy,
9865
9611
  deferPromise,