@fuel-ts/account 0.0.0-rc-2021-20240419013807 → 0.0.0-rc-1976-20240419063349

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

Potentially problematic release.


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

Files changed (56) hide show
  1. package/README.md +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 +604 -830
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +601 -833
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +444 -675
  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 +3 -3
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +1 -7
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +34 -37
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
  34. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/transaction-request.d.ts +29 -9
  36. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  37. package/dist/providers/transaction-request/utils.d.ts +0 -3
  38. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  39. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  41. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  43. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  45. package/dist/providers/utils/gas.d.ts +2 -8
  46. package/dist/providers/utils/gas.d.ts.map +1 -1
  47. package/dist/test-utils/launchNode.d.ts.map +1 -1
  48. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  49. package/dist/test-utils.global.js +1118 -1579
  50. package/dist/test-utils.global.js.map +1 -1
  51. package/dist/test-utils.js +600 -811
  52. package/dist/test-utils.js.map +1 -1
  53. package/dist/test-utils.mjs +456 -667
  54. package/dist/test-utils.mjs.map +1 -1
  55. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  56. package/package.json +16 -16
package/dist/index.mjs CHANGED
@@ -29,38 +29,35 @@ var __privateMethod = (obj, member, method) => {
29
29
 
30
30
  // src/account.ts
31
31
  import { Address as Address3 } from "@fuel-ts/address";
32
- import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
33
32
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
34
33
  import { AbstractAccount } from "@fuel-ts/interfaces";
35
- import { bn as bn18 } from "@fuel-ts/math";
34
+ import { bn as bn17 } from "@fuel-ts/math";
36
35
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
37
- import { clone as clone4 } from "ramda";
38
36
 
39
37
  // src/providers/coin-quantity.ts
40
- import { BaseAssetId } from "@fuel-ts/address/configs";
41
38
  import { bn } from "@fuel-ts/math";
42
39
  import { hexlify } from "@fuel-ts/utils";
43
40
  var coinQuantityfy = (coinQuantityLike) => {
44
41
  let assetId;
45
42
  let amount;
46
- let max;
43
+ let max2;
47
44
  if (Array.isArray(coinQuantityLike)) {
48
45
  amount = coinQuantityLike[0];
49
- assetId = coinQuantityLike[1] ?? BaseAssetId;
50
- max = coinQuantityLike[2] ?? void 0;
46
+ assetId = coinQuantityLike[1];
47
+ max2 = coinQuantityLike[2];
51
48
  } else {
52
49
  amount = coinQuantityLike.amount;
53
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
54
- max = coinQuantityLike.max ?? void 0;
50
+ assetId = coinQuantityLike.assetId;
51
+ max2 = coinQuantityLike.max ?? void 0;
55
52
  }
56
53
  const bnAmount = bn(amount);
57
54
  return {
58
55
  assetId: hexlify(assetId),
59
56
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
60
- max: max ? bn(max) : void 0
57
+ max: max2 ? bn(max2) : void 0
61
58
  };
62
59
  };
63
- var addAmountToCoinQuantities = (params) => {
60
+ var addAmountToAsset = (params) => {
64
61
  const { amount, assetId } = params;
65
62
  const coinQuantities = [...params.coinQuantities];
66
63
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -75,9 +72,9 @@ var addAmountToCoinQuantities = (params) => {
75
72
  // src/providers/provider.ts
76
73
  import { Address as Address2 } from "@fuel-ts/address";
77
74
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
78
- import { BN, bn as bn16 } from "@fuel-ts/math";
75
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
79
76
  import {
80
- InputType as InputType7,
77
+ InputType as InputType6,
81
78
  TransactionType as TransactionType8,
82
79
  InputMessageCoder,
83
80
  TransactionCoder as TransactionCoder5
@@ -93,10 +90,14 @@ import { clone as clone3 } from "ramda";
93
90
  import gql from "graphql-tag";
94
91
  var ReceiptFragmentFragmentDoc = gql`
95
92
  fragment receiptFragment on Receipt {
96
- id
93
+ contract {
94
+ id
95
+ }
97
96
  pc
98
97
  is
99
- to
98
+ to {
99
+ id
100
+ }
100
101
  toAddress
101
102
  amount
102
103
  assetId
@@ -134,16 +135,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
134
135
  id
135
136
  }
136
137
  time
137
- receipts {
138
- ...receiptFragment
139
- }
140
138
  programState {
141
139
  returnType
142
140
  data
143
141
  }
144
- receipts {
145
- ...receiptFragment
146
- }
147
142
  }
148
143
  ... on FailureStatus {
149
144
  block {
@@ -151,24 +146,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
151
146
  }
152
147
  time
153
148
  reason
154
- receipts {
155
- ...receiptFragment
156
- }
157
149
  }
158
150
  ... on SqueezedOutStatus {
159
151
  reason
160
152
  }
161
153
  }
162
- ${ReceiptFragmentFragmentDoc}`;
154
+ `;
163
155
  var TransactionFragmentFragmentDoc = gql`
164
156
  fragment transactionFragment on Transaction {
165
157
  id
166
158
  rawPayload
159
+ gasPrice
160
+ receipts {
161
+ ...receiptFragment
162
+ }
167
163
  status {
168
164
  ...transactionStatusFragment
169
165
  }
170
166
  }
171
- ${TransactionStatusFragmentFragmentDoc}`;
167
+ ${ReceiptFragmentFragmentDoc}
168
+ ${TransactionStatusFragmentFragmentDoc}`;
172
169
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
173
170
  fragment inputEstimatePredicatesFragment on Input {
174
171
  ... on InputCoin {
@@ -186,46 +183,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
186
183
  }
187
184
  }
188
185
  ${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
186
  var CoinFragmentFragmentDoc = gql`
230
187
  fragment coinFragment on Coin {
231
188
  __typename
@@ -233,6 +190,7 @@ var CoinFragmentFragmentDoc = gql`
233
190
  owner
234
191
  amount
235
192
  assetId
193
+ maturity
236
194
  blockCreated
237
195
  txCreatedIdx
238
196
  }
@@ -271,32 +229,26 @@ var MessageProofFragmentFragmentDoc = gql`
271
229
  messageBlockHeader {
272
230
  id
273
231
  daHeight
274
- consensusParametersVersion
275
- stateTransitionBytecodeVersion
276
232
  transactionsCount
277
- messageReceiptCount
278
233
  transactionsRoot
279
- messageOutboxRoot
280
- eventInboxRoot
281
234
  height
282
235
  prevRoot
283
236
  time
284
237
  applicationHash
238
+ messageReceiptRoot
239
+ messageReceiptCount
285
240
  }
286
241
  commitBlockHeader {
287
242
  id
288
243
  daHeight
289
- consensusParametersVersion
290
- stateTransitionBytecodeVersion
291
244
  transactionsCount
292
- messageReceiptCount
293
245
  transactionsRoot
294
- messageOutboxRoot
295
- eventInboxRoot
296
246
  height
297
247
  prevRoot
298
248
  time
299
249
  applicationHash
250
+ messageReceiptRoot
251
+ messageReceiptCount
300
252
  }
301
253
  sender
302
254
  recipient
@@ -315,8 +267,8 @@ var BalanceFragmentFragmentDoc = gql`
315
267
  var BlockFragmentFragmentDoc = gql`
316
268
  fragment blockFragment on Block {
317
269
  id
318
- height
319
270
  header {
271
+ height
320
272
  time
321
273
  }
322
274
  transactions {
@@ -374,11 +326,6 @@ var DependentCostFragmentFragmentDoc = gql`
374
326
  `;
375
327
  var GasCostsFragmentFragmentDoc = gql`
376
328
  fragment GasCostsFragment on GasCosts {
377
- version {
378
- ... on Version {
379
- value
380
- }
381
- }
382
329
  add
383
330
  addi
384
331
  aloc
@@ -391,6 +338,7 @@ var GasCostsFragmentFragmentDoc = gql`
391
338
  cb
392
339
  cfei
393
340
  cfsi
341
+ croo
394
342
  div
395
343
  divi
396
344
  ecr1
@@ -473,9 +421,6 @@ var GasCostsFragmentFragmentDoc = gql`
473
421
  ccp {
474
422
  ...DependentCostFragment
475
423
  }
476
- croo {
477
- ...DependentCostFragment
478
- }
479
424
  csiz {
480
425
  ...DependentCostFragment
481
426
  }
@@ -535,11 +480,6 @@ var GasCostsFragmentFragmentDoc = gql`
535
480
  ${DependentCostFragmentFragmentDoc}`;
536
481
  var ConsensusParametersFragmentFragmentDoc = gql`
537
482
  fragment consensusParametersFragment on ConsensusParameters {
538
- version {
539
- ... on Version {
540
- value
541
- }
542
- }
543
483
  txParams {
544
484
  ...TxParametersFragment
545
485
  }
@@ -599,9 +539,18 @@ var NodeInfoFragmentFragmentDoc = gql`
599
539
  fragment nodeInfoFragment on NodeInfo {
600
540
  utxoValidation
601
541
  vmBacktrace
542
+ minGasPrice
602
543
  maxTx
603
544
  maxDepth
604
545
  nodeVersion
546
+ peers {
547
+ id
548
+ addresses
549
+ clientVersion
550
+ blockHeight
551
+ lastHeartbeatMs
552
+ appScore
553
+ }
605
554
  }
606
555
  `;
607
556
  var GetVersionDocument = gql`
@@ -636,9 +585,13 @@ var GetTransactionWithReceiptsDocument = gql`
636
585
  query getTransactionWithReceipts($transactionId: TransactionId!) {
637
586
  transaction(id: $transactionId) {
638
587
  ...transactionFragment
588
+ receipts {
589
+ ...receiptFragment
590
+ }
639
591
  }
640
592
  }
641
- ${TransactionFragmentFragmentDoc}`;
593
+ ${TransactionFragmentFragmentDoc}
594
+ ${ReceiptFragmentFragmentDoc}`;
642
595
  var GetTransactionsDocument = gql`
643
596
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
644
597
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -766,20 +719,6 @@ var GetBalanceDocument = gql`
766
719
  }
767
720
  }
768
721
  ${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
722
  var GetBalancesDocument = gql`
784
723
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
785
724
  balances(
@@ -834,12 +773,12 @@ var GetMessageStatusDocument = gql`
834
773
  }
835
774
  `;
836
775
  var DryRunDocument = gql`
837
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
838
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
839
- ...dryRunTransactionExecutionStatusFragment
776
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
777
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
778
+ ...receiptFragment
840
779
  }
841
780
  }
842
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
781
+ ${ReceiptFragmentFragmentDoc}`;
843
782
  var SubmitDocument = gql`
844
783
  mutation submit($encodedTransaction: HexString!) {
845
784
  submit(tx: $encodedTransaction) {
@@ -922,12 +861,6 @@ function getSdk(requester) {
922
861
  getBalance(variables, options) {
923
862
  return requester(GetBalanceDocument, variables, options);
924
863
  },
925
- getLatestGasPrice(variables, options) {
926
- return requester(GetLatestGasPriceDocument, variables, options);
927
- },
928
- estimateGasPrice(variables, options) {
929
- return requester(EstimateGasPriceDocument, variables, options);
930
- },
931
864
  getBalances(variables, options) {
932
865
  return requester(GetBalancesDocument, variables, options);
933
866
  },
@@ -1121,9 +1054,10 @@ var inputify = (value) => {
1121
1054
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1122
1055
  },
1123
1056
  witnessIndex: value.witnessIndex,
1057
+ maturity: value.maturity ?? 0,
1124
1058
  predicateGasUsed: bn2(value.predicateGasUsed),
1125
- predicateLength: bn2(predicate.length),
1126
- predicateDataLength: bn2(predicateData.length),
1059
+ predicateLength: predicate.length,
1060
+ predicateDataLength: predicateData.length,
1127
1061
  predicate: hexlify3(predicate),
1128
1062
  predicateData: hexlify3(predicateData)
1129
1063
  };
@@ -1154,8 +1088,8 @@ var inputify = (value) => {
1154
1088
  nonce: hexlify3(value.nonce),
1155
1089
  witnessIndex: value.witnessIndex,
1156
1090
  predicateGasUsed: bn2(value.predicateGasUsed),
1157
- predicateLength: bn2(predicate.length),
1158
- predicateDataLength: bn2(predicateData.length),
1091
+ predicateLength: predicate.length,
1092
+ predicateDataLength: predicateData.length,
1159
1093
  predicate: hexlify3(predicate),
1160
1094
  predicateData: hexlify3(predicateData),
1161
1095
  data: hexlify3(data),
@@ -1231,7 +1165,7 @@ var outputify = (value) => {
1231
1165
  // src/providers/transaction-request/transaction-request.ts
1232
1166
  import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1233
1167
  import { Address, addressify } from "@fuel-ts/address";
1234
- import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1168
+ import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1235
1169
  import { randomBytes } from "@fuel-ts/crypto";
1236
1170
  import { bn as bn7 } from "@fuel-ts/math";
1237
1171
  import {
@@ -1285,8 +1219,8 @@ function assembleReceiptByType(receipt) {
1285
1219
  case "CALL" /* Call */: {
1286
1220
  const callReceipt = {
1287
1221
  type: ReceiptType.Call,
1288
- from: hexOrZero(receipt.id || receipt.contractId),
1289
- to: hexOrZero(receipt?.to),
1222
+ from: hexOrZero(receipt.contract?.id),
1223
+ to: hexOrZero(receipt?.to?.id),
1290
1224
  amount: bn4(receipt.amount),
1291
1225
  assetId: hexOrZero(receipt.assetId),
1292
1226
  gas: bn4(receipt.gas),
@@ -1300,7 +1234,7 @@ function assembleReceiptByType(receipt) {
1300
1234
  case "RETURN" /* Return */: {
1301
1235
  const returnReceipt = {
1302
1236
  type: ReceiptType.Return,
1303
- id: hexOrZero(receipt.id || receipt.contractId),
1237
+ id: hexOrZero(receipt.contract?.id),
1304
1238
  val: bn4(receipt.val),
1305
1239
  pc: bn4(receipt.pc),
1306
1240
  is: bn4(receipt.is)
@@ -1310,7 +1244,7 @@ function assembleReceiptByType(receipt) {
1310
1244
  case "RETURN_DATA" /* ReturnData */: {
1311
1245
  const returnDataReceipt = {
1312
1246
  type: ReceiptType.ReturnData,
1313
- id: hexOrZero(receipt.id || receipt.contractId),
1247
+ id: hexOrZero(receipt.contract?.id),
1314
1248
  ptr: bn4(receipt.ptr),
1315
1249
  len: bn4(receipt.len),
1316
1250
  digest: hexOrZero(receipt.digest),
@@ -1322,7 +1256,7 @@ function assembleReceiptByType(receipt) {
1322
1256
  case "PANIC" /* Panic */: {
1323
1257
  const panicReceipt = {
1324
1258
  type: ReceiptType.Panic,
1325
- id: hexOrZero(receipt.id),
1259
+ id: hexOrZero(receipt.contract?.id),
1326
1260
  reason: bn4(receipt.reason),
1327
1261
  pc: bn4(receipt.pc),
1328
1262
  is: bn4(receipt.is),
@@ -1333,7 +1267,7 @@ function assembleReceiptByType(receipt) {
1333
1267
  case "REVERT" /* Revert */: {
1334
1268
  const revertReceipt = {
1335
1269
  type: ReceiptType.Revert,
1336
- id: hexOrZero(receipt.id || receipt.contractId),
1270
+ id: hexOrZero(receipt.contract?.id),
1337
1271
  val: bn4(receipt.ra),
1338
1272
  pc: bn4(receipt.pc),
1339
1273
  is: bn4(receipt.is)
@@ -1343,7 +1277,7 @@ function assembleReceiptByType(receipt) {
1343
1277
  case "LOG" /* Log */: {
1344
1278
  const logReceipt = {
1345
1279
  type: ReceiptType.Log,
1346
- id: hexOrZero(receipt.id || receipt.contractId),
1280
+ id: hexOrZero(receipt.contract?.id),
1347
1281
  val0: bn4(receipt.ra),
1348
1282
  val1: bn4(receipt.rb),
1349
1283
  val2: bn4(receipt.rc),
@@ -1356,7 +1290,7 @@ function assembleReceiptByType(receipt) {
1356
1290
  case "LOG_DATA" /* LogData */: {
1357
1291
  const logDataReceipt = {
1358
1292
  type: ReceiptType.LogData,
1359
- id: hexOrZero(receipt.id || receipt.contractId),
1293
+ id: hexOrZero(receipt.contract?.id),
1360
1294
  val0: bn4(receipt.ra),
1361
1295
  val1: bn4(receipt.rb),
1362
1296
  ptr: bn4(receipt.ptr),
@@ -1370,8 +1304,8 @@ function assembleReceiptByType(receipt) {
1370
1304
  case "TRANSFER" /* Transfer */: {
1371
1305
  const transferReceipt = {
1372
1306
  type: ReceiptType.Transfer,
1373
- from: hexOrZero(receipt.id || receipt.contractId),
1374
- to: hexOrZero(receipt.toAddress || receipt?.to),
1307
+ from: hexOrZero(receipt.contract?.id),
1308
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1375
1309
  amount: bn4(receipt.amount),
1376
1310
  assetId: hexOrZero(receipt.assetId),
1377
1311
  pc: bn4(receipt.pc),
@@ -1382,8 +1316,8 @@ function assembleReceiptByType(receipt) {
1382
1316
  case "TRANSFER_OUT" /* TransferOut */: {
1383
1317
  const transferOutReceipt = {
1384
1318
  type: ReceiptType.TransferOut,
1385
- from: hexOrZero(receipt.id || receipt.contractId),
1386
- to: hexOrZero(receipt.toAddress || receipt.to),
1319
+ from: hexOrZero(receipt.contract?.id),
1320
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1387
1321
  amount: bn4(receipt.amount),
1388
1322
  assetId: hexOrZero(receipt.assetId),
1389
1323
  pc: bn4(receipt.pc),
@@ -1426,7 +1360,7 @@ function assembleReceiptByType(receipt) {
1426
1360
  return receiptMessageOut;
1427
1361
  }
1428
1362
  case "MINT" /* Mint */: {
1429
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1363
+ const contractId = hexOrZero(receipt.contract?.id);
1430
1364
  const subId = hexOrZero(receipt.subId);
1431
1365
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1432
1366
  const mintReceipt = {
@@ -1441,7 +1375,7 @@ function assembleReceiptByType(receipt) {
1441
1375
  return mintReceipt;
1442
1376
  }
1443
1377
  case "BURN" /* Burn */: {
1444
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1378
+ const contractId = hexOrZero(receipt.contract?.id);
1445
1379
  const subId = hexOrZero(receipt.subId);
1446
1380
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1447
1381
  const burnReceipt = {
@@ -1526,6 +1460,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1526
1460
  import { bn as bn5 } from "@fuel-ts/math";
1527
1461
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1528
1462
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1463
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1529
1464
  var getGasUsedFromReceipts = (receipts) => {
1530
1465
  const scriptResult = receipts.filter(
1531
1466
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1546,28 +1481,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1546
1481
  }
1547
1482
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1548
1483
  const witnessCache = [];
1549
- const chargeableInputs = inputs.filter((input) => {
1550
- const isCoinOrMessage = "owner" in input || "sender" in input;
1551
- if (isCoinOrMessage) {
1552
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1553
- return true;
1554
- }
1555
- if (!witnessCache.includes(input.witnessIndex)) {
1556
- witnessCache.push(input.witnessIndex);
1557
- return true;
1558
- }
1559
- }
1560
- return false;
1561
- });
1562
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1563
- const totalGas = chargeableInputs.reduce((total, input) => {
1484
+ const totalGas = inputs.reduce((total, input) => {
1564
1485
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1565
1486
  return total.add(
1566
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1487
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1567
1488
  );
1568
1489
  }
1569
- return total.add(gasCosts.ecr1);
1570
- }, bn5(0));
1490
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1491
+ witnessCache.push(input.witnessIndex);
1492
+ return total.add(gasCosts.ecr1);
1493
+ }
1494
+ return total;
1495
+ }, bn5());
1571
1496
  return totalGas;
1572
1497
  }
1573
1498
  function getMinGas(params) {
@@ -1579,20 +1504,12 @@ function getMinGas(params) {
1579
1504
  return minGas;
1580
1505
  }
1581
1506
  function getMaxGas(params) {
1582
- const {
1583
- gasPerByte,
1584
- witnessesLength,
1585
- witnessLimit,
1586
- minGas,
1587
- gasLimit = bn5(0),
1588
- maxGasPerTx
1589
- } = params;
1507
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1590
1508
  let remainingAllowedWitnessGas = bn5(0);
1591
1509
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1592
1510
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1593
1511
  }
1594
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1595
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1512
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1596
1513
  }
1597
1514
  function calculateMetadataGasForTxCreate({
1598
1515
  gasCosts,
@@ -1614,10 +1531,6 @@ function calculateMetadataGasForTxScript({
1614
1531
  }) {
1615
1532
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1616
1533
  }
1617
- var calculateGasFee = (params) => {
1618
- const { gas, gasPrice, priceFactor, tip } = params;
1619
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1620
- };
1621
1534
 
1622
1535
  // src/providers/utils/json.ts
1623
1536
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1774,7 +1687,7 @@ var witnessify = (value) => {
1774
1687
  // src/providers/transaction-request/transaction-request.ts
1775
1688
  var BaseTransactionRequest = class {
1776
1689
  /** Gas price for transaction */
1777
- tip;
1690
+ gasPrice;
1778
1691
  /** Block until which tx cannot be included */
1779
1692
  maturity;
1780
1693
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1787,34 +1700,38 @@ var BaseTransactionRequest = class {
1787
1700
  outputs = [];
1788
1701
  /** List of witnesses */
1789
1702
  witnesses = [];
1703
+ /** Base asset ID - should be fetched from the chain */
1704
+ baseAssetId;
1790
1705
  /**
1791
1706
  * Constructor for initializing a base transaction request.
1792
1707
  *
1793
1708
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1794
1709
  */
1795
1710
  constructor({
1796
- tip,
1711
+ gasPrice,
1797
1712
  maturity,
1798
1713
  maxFee,
1799
1714
  witnessLimit,
1800
1715
  inputs,
1801
1716
  outputs,
1802
- witnesses
1803
- } = {}) {
1804
- this.tip = bn7(tip);
1717
+ witnesses,
1718
+ baseAssetId
1719
+ }) {
1720
+ this.gasPrice = bn7(gasPrice);
1805
1721
  this.maturity = maturity ?? 0;
1806
1722
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1807
1723
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
1808
1724
  this.inputs = inputs ?? [];
1809
1725
  this.outputs = outputs ?? [];
1810
1726
  this.witnesses = witnesses ?? [];
1727
+ this.baseAssetId = baseAssetId;
1811
1728
  }
1812
1729
  static getPolicyMeta(req) {
1813
1730
  let policyTypes = 0;
1814
1731
  const policies = [];
1815
- if (req.tip) {
1816
- policyTypes += PolicyType.Tip;
1817
- policies.push({ data: req.tip, type: PolicyType.Tip });
1732
+ if (req.gasPrice) {
1733
+ policyTypes += PolicyType.GasPrice;
1734
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1818
1735
  }
1819
1736
  if (req.witnessLimit) {
1820
1737
  policyTypes += PolicyType.WitnessLimit;
@@ -2001,10 +1918,10 @@ var BaseTransactionRequest = class {
2001
1918
  * @param predicate - Predicate bytes.
2002
1919
  * @param predicateData - Predicate data bytes.
2003
1920
  */
2004
- addCoinInput(coin) {
1921
+ addCoinInput(coin, predicate) {
2005
1922
  const { assetId, owner, amount } = coin;
2006
1923
  let witnessIndex;
2007
- if (coin.predicate) {
1924
+ if (predicate) {
2008
1925
  witnessIndex = 0;
2009
1926
  } else {
2010
1927
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2019,7 +1936,8 @@ var BaseTransactionRequest = class {
2019
1936
  amount,
2020
1937
  assetId,
2021
1938
  txPointer: "0x00000000000000000000000000000000",
2022
- witnessIndex
1939
+ witnessIndex,
1940
+ predicate: predicate?.bytes
2023
1941
  };
2024
1942
  this.pushInput(input);
2025
1943
  this.addChangeOutput(owner, assetId);
@@ -2030,13 +1948,11 @@ var BaseTransactionRequest = class {
2030
1948
  *
2031
1949
  * @param message - Message resource.
2032
1950
  * @param predicate - Predicate bytes.
2033
- * @param predicateData - Predicate data bytes.
2034
1951
  */
2035
- addMessageInput(message) {
1952
+ addMessageInput(message, predicate) {
2036
1953
  const { recipient, sender, amount } = message;
2037
- const assetId = BaseAssetId2;
2038
1954
  let witnessIndex;
2039
- if (message.predicate) {
1955
+ if (predicate) {
2040
1956
  witnessIndex = 0;
2041
1957
  } else {
2042
1958
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2050,10 +1966,11 @@ var BaseTransactionRequest = class {
2050
1966
  sender: sender.toB256(),
2051
1967
  recipient: recipient.toB256(),
2052
1968
  amount,
2053
- witnessIndex
1969
+ witnessIndex,
1970
+ predicate: predicate?.bytes
2054
1971
  };
2055
1972
  this.pushInput(input);
2056
- this.addChangeOutput(recipient, assetId);
1973
+ this.addChangeOutput(recipient, this.baseAssetId);
2057
1974
  }
2058
1975
  /**
2059
1976
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2081,6 +1998,32 @@ var BaseTransactionRequest = class {
2081
1998
  resources.forEach((resource) => this.addResource(resource));
2082
1999
  return this;
2083
2000
  }
2001
+ /**
2002
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2003
+ * outputs from the related assetIds.
2004
+ *
2005
+ * @param resources - The resources to add.
2006
+ * @returns This transaction.
2007
+ */
2008
+ addPredicateResource(resource, predicate) {
2009
+ if (isCoin(resource)) {
2010
+ this.addCoinInput(resource, predicate);
2011
+ } else {
2012
+ this.addMessageInput(resource, predicate);
2013
+ }
2014
+ return this;
2015
+ }
2016
+ /**
2017
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2018
+ * from the related assetIds.
2019
+ *
2020
+ * @param resources - The resources to add.
2021
+ * @returns This transaction.
2022
+ */
2023
+ addPredicateResources(resources, predicate) {
2024
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2025
+ return this;
2026
+ }
2084
2027
  /**
2085
2028
  * Adds a coin output to the transaction.
2086
2029
  *
@@ -2088,12 +2031,12 @@ var BaseTransactionRequest = class {
2088
2031
  * @param amount - Amount of coin.
2089
2032
  * @param assetId - Asset ID of coin.
2090
2033
  */
2091
- addCoinOutput(to, amount, assetId = BaseAssetId2) {
2034
+ addCoinOutput(to, amount, assetId) {
2092
2035
  this.pushOutput({
2093
2036
  type: OutputType2.Coin,
2094
2037
  to: addressify(to).toB256(),
2095
2038
  amount,
2096
- assetId
2039
+ assetId: assetId ?? this.baseAssetId
2097
2040
  });
2098
2041
  return this;
2099
2042
  }
@@ -2120,7 +2063,7 @@ var BaseTransactionRequest = class {
2120
2063
  * @param to - Address of the owner.
2121
2064
  * @param assetId - Asset ID of coin.
2122
2065
  */
2123
- addChangeOutput(to, assetId = BaseAssetId2) {
2066
+ addChangeOutput(to, assetId) {
2124
2067
  const changeOutput = this.getChangeOutputs().find(
2125
2068
  (output) => hexlify7(output.assetId) === assetId
2126
2069
  );
@@ -2128,7 +2071,7 @@ var BaseTransactionRequest = class {
2128
2071
  this.pushOutput({
2129
2072
  type: OutputType2.Change,
2130
2073
  to: addressify(to).toB256(),
2131
- assetId
2074
+ assetId: assetId ?? this.baseAssetId
2132
2075
  });
2133
2076
  }
2134
2077
  }
@@ -2160,7 +2103,7 @@ var BaseTransactionRequest = class {
2160
2103
  }
2161
2104
  calculateMaxGas(chainInfo, minGas) {
2162
2105
  const { consensusParameters } = chainInfo;
2163
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2106
+ const { gasPerByte } = consensusParameters;
2164
2107
  const witnessesLength = this.toTransaction().witnesses.reduce(
2165
2108
  (acc, wit) => acc + wit.dataLength,
2166
2109
  0
@@ -2169,8 +2112,7 @@ var BaseTransactionRequest = class {
2169
2112
  gasPerByte,
2170
2113
  minGas,
2171
2114
  witnessesLength,
2172
- witnessLimit: this.witnessLimit,
2173
- maxGasPerTx
2115
+ witnessLimit: this.witnessLimit
2174
2116
  });
2175
2117
  }
2176
2118
  /**
@@ -2188,27 +2130,24 @@ var BaseTransactionRequest = class {
2188
2130
  });
2189
2131
  const updateAssetInput = (assetId, quantity) => {
2190
2132
  const assetInput = findAssetInput(assetId);
2191
- let usedQuantity = quantity;
2192
- if (assetId === BaseAssetId2) {
2193
- usedQuantity = bn7("1000000000000000000");
2194
- }
2195
2133
  if (assetInput && "assetId" in assetInput) {
2196
2134
  assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2197
- assetInput.amount = usedQuantity;
2135
+ assetInput.amount = quantity;
2198
2136
  } else {
2199
2137
  this.addResources([
2200
2138
  {
2201
2139
  id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2202
- amount: usedQuantity,
2140
+ amount: quantity,
2203
2141
  assetId,
2204
2142
  owner: resourcesOwner || Address.fromRandom(),
2143
+ maturity: 0,
2205
2144
  blockCreated: bn7(1),
2206
2145
  txCreatedIdx: bn7(1)
2207
2146
  }
2208
2147
  ]);
2209
2148
  }
2210
2149
  };
2211
- updateAssetInput(BaseAssetId2, bn7(1e11));
2150
+ updateAssetInput(this.baseAssetId, bn7(1e11));
2212
2151
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2213
2152
  }
2214
2153
  /**
@@ -2233,7 +2172,7 @@ var BaseTransactionRequest = class {
2233
2172
  toJSON() {
2234
2173
  return normalizeJSON(this);
2235
2174
  }
2236
- updatePredicateGasUsed(inputs) {
2175
+ updatePredicateInputs(inputs) {
2237
2176
  this.inputs.forEach((i) => {
2238
2177
  let correspondingInput;
2239
2178
  switch (i.type) {
@@ -2255,15 +2194,6 @@ var BaseTransactionRequest = class {
2255
2194
  }
2256
2195
  });
2257
2196
  }
2258
- shiftPredicateData() {
2259
- this.inputs.forEach((input) => {
2260
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2261
- input.predicateData = input.paddPredicateData(
2262
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2263
- );
2264
- }
2265
- });
2266
- }
2267
2197
  };
2268
2198
 
2269
2199
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2387,12 +2317,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2387
2317
  *
2388
2318
  * @param createTransactionRequestLike - The initial values for the instance
2389
2319
  */
2390
- constructor({
2391
- bytecodeWitnessIndex,
2392
- salt,
2393
- storageSlots,
2394
- ...rest
2395
- } = {}) {
2320
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2396
2321
  super(rest);
2397
2322
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2398
2323
  this.salt = hexlify9(salt ?? ZeroBytes326);
@@ -2410,8 +2335,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2410
2335
  return {
2411
2336
  type: TransactionType3.Create,
2412
2337
  ...baseTransaction,
2338
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2413
2339
  bytecodeWitnessIndex,
2414
- storageSlotsCount: bn9(storageSlots.length),
2340
+ storageSlotsCount: storageSlots.length,
2415
2341
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2416
2342
  storageSlots
2417
2343
  };
@@ -2515,7 +2441,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2515
2441
  *
2516
2442
  * @param scriptTransactionRequestLike - The initial values for the instance.
2517
2443
  */
2518
- constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2444
+ constructor({ script, scriptData, gasLimit, ...rest }) {
2519
2445
  super(rest);
2520
2446
  this.gasLimit = bn10(gasLimit);
2521
2447
  this.script = arrayify8(script ?? returnZeroScript.bytes);
@@ -2534,8 +2460,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2534
2460
  type: TransactionType4.Script,
2535
2461
  scriptGasLimit: this.gasLimit,
2536
2462
  ...super.getBaseTransaction(),
2537
- scriptLength: bn10(script.length),
2538
- scriptDataLength: bn10(scriptData.length),
2463
+ scriptLength: script.length,
2464
+ scriptDataLength: scriptData.length,
2539
2465
  receiptsRoot: ZeroBytes327,
2540
2466
  script: hexlify10(script),
2541
2467
  scriptData: hexlify10(scriptData)
@@ -2599,7 +2525,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2599
2525
  }
2600
2526
  calculateMaxGas(chainInfo, minGas) {
2601
2527
  const { consensusParameters } = chainInfo;
2602
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2528
+ const { gasPerByte } = consensusParameters;
2603
2529
  const witnessesLength = this.toTransaction().witnesses.reduce(
2604
2530
  (acc, wit) => acc + wit.dataLength,
2605
2531
  0
@@ -2609,8 +2535,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2609
2535
  minGas,
2610
2536
  witnessesLength,
2611
2537
  witnessLimit: this.witnessLimit,
2612
- gasLimit: this.gasLimit,
2613
- maxGasPerTx
2538
+ gasLimit: this.gasLimit
2614
2539
  });
2615
2540
  }
2616
2541
  /**
@@ -2667,7 +2592,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2667
2592
 
2668
2593
  // src/providers/transaction-request/utils.ts
2669
2594
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2670
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2595
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2671
2596
  var transactionRequestify = (obj) => {
2672
2597
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2673
2598
  return obj;
@@ -2685,31 +2610,14 @@ var transactionRequestify = (obj) => {
2685
2610
  }
2686
2611
  }
2687
2612
  };
2688
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2689
- (acc, input) => {
2690
- if (input.type === InputType5.Coin && input.owner === owner) {
2691
- acc.utxos.push(input.id);
2692
- }
2693
- if (input.type === InputType5.Message && input.recipient === owner) {
2694
- acc.messages.push(input.nonce);
2695
- }
2696
- return acc;
2697
- },
2698
- {
2699
- utxos: [],
2700
- messages: []
2701
- }
2702
- );
2703
2613
 
2704
2614
  // src/providers/transaction-response/transaction-response.ts
2705
2615
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2706
- import { bn as bn15 } from "@fuel-ts/math";
2616
+ import { bn as bn14 } from "@fuel-ts/math";
2707
2617
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2708
2618
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2709
2619
 
2710
2620
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2711
- import { bn as bn14 } from "@fuel-ts/math";
2712
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2713
2621
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2714
2622
 
2715
2623
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2718,10 +2626,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2718
2626
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2719
2627
  var calculateTransactionFee = (params) => {
2720
2628
  const {
2721
- gasPrice,
2629
+ gasUsed,
2722
2630
  rawPayload,
2723
- tip,
2724
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2631
+ consensusParameters: { gasCosts, feeParams }
2725
2632
  } = params;
2726
2633
  const gasPerByte = bn11(feeParams.gasPerByte);
2727
2634
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2731,7 +2638,8 @@ var calculateTransactionFee = (params) => {
2731
2638
  return {
2732
2639
  fee: bn11(0),
2733
2640
  minFee: bn11(0),
2734
- maxFee: bn11(0)
2641
+ maxFee: bn11(0),
2642
+ feeFromGasUsed: bn11(0)
2735
2643
  };
2736
2644
  }
2737
2645
  const { type, witnesses, inputs, policies } = transaction;
@@ -2763,6 +2671,7 @@ var calculateTransactionFee = (params) => {
2763
2671
  metadataGas,
2764
2672
  txBytesSize: transactionBytes.length
2765
2673
  });
2674
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2766
2675
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2767
2676
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2768
2677
  const maxGas = getMaxGas({
@@ -2770,25 +2679,17 @@ var calculateTransactionFee = (params) => {
2770
2679
  minGas,
2771
2680
  witnessesLength,
2772
2681
  gasLimit,
2773
- witnessLimit,
2774
- maxGasPerTx
2775
- });
2776
- const minFee = calculateGasFee({
2777
- gasPrice,
2778
- gas: minGas,
2779
- priceFactor: gasPriceFactor,
2780
- tip
2781
- });
2782
- const maxFee = calculateGasFee({
2783
- gasPrice,
2784
- gas: maxGas,
2785
- priceFactor: gasPriceFactor,
2786
- tip
2682
+ witnessLimit
2787
2683
  });
2684
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2685
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2686
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2687
+ const fee = minFee.add(feeFromGasUsed);
2788
2688
  return {
2689
+ fee,
2789
2690
  minFee,
2790
2691
  maxFee,
2791
- fee: maxFee
2692
+ feeFromGasUsed
2792
2693
  };
2793
2694
  };
2794
2695
 
@@ -2844,7 +2745,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2844
2745
 
2845
2746
  // src/providers/transaction-summary/input.ts
2846
2747
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2847
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2748
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2848
2749
  function getInputsByTypes(inputs, types) {
2849
2750
  return inputs.filter((i) => types.includes(i.type));
2850
2751
  }
@@ -2852,16 +2753,16 @@ function getInputsByType(inputs, type) {
2852
2753
  return inputs.filter((i) => i.type === type);
2853
2754
  }
2854
2755
  function getInputsCoin(inputs) {
2855
- return getInputsByType(inputs, InputType6.Coin);
2756
+ return getInputsByType(inputs, InputType5.Coin);
2856
2757
  }
2857
2758
  function getInputsMessage(inputs) {
2858
- return getInputsByType(inputs, InputType6.Message);
2759
+ return getInputsByType(inputs, InputType5.Message);
2859
2760
  }
2860
2761
  function getInputsCoinAndMessage(inputs) {
2861
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2762
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2862
2763
  }
2863
2764
  function getInputsContract(inputs) {
2864
- return getInputsByType(inputs, InputType6.Contract);
2765
+ return getInputsByType(inputs, InputType5.Contract);
2865
2766
  }
2866
2767
  function getInputFromAssetId(inputs, assetId) {
2867
2768
  const coinInputs = getInputsCoin(inputs);
@@ -2880,7 +2781,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2880
2781
  if (!contractInput) {
2881
2782
  return void 0;
2882
2783
  }
2883
- if (contractInput.type !== InputType6.Contract) {
2784
+ if (contractInput.type !== InputType5.Contract) {
2884
2785
  throw new FuelError9(
2885
2786
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2886
2787
  `Contract input should be of type 'contract'.`
@@ -2889,10 +2790,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2889
2790
  return contractInput;
2890
2791
  }
2891
2792
  function getInputAccountAddress(input) {
2892
- if (input.type === InputType6.Coin) {
2793
+ if (input.type === InputType5.Coin) {
2893
2794
  return input.owner.toString();
2894
2795
  }
2895
- if (input.type === InputType6.Message) {
2796
+ if (input.type === InputType5.Message) {
2896
2797
  return input.recipient.toString();
2897
2798
  }
2898
2799
  return "";
@@ -3402,9 +3303,7 @@ function assembleTransactionSummary(params) {
3402
3303
  gqlTransactionStatus,
3403
3304
  abiMap = {},
3404
3305
  maxInputs,
3405
- gasCosts,
3406
- maxGasPerTx,
3407
- gasPrice
3306
+ gasCosts
3408
3307
  } = params;
3409
3308
  const gasUsed = getGasUsedFromReceipts(receipts);
3410
3309
  const rawPayload = hexlify11(transactionBytes);
@@ -3418,14 +3317,11 @@ function assembleTransactionSummary(params) {
3418
3317
  maxInputs
3419
3318
  });
3420
3319
  const typeName = getTransactionTypeName(transaction.type);
3421
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3422
3320
  const { fee } = calculateTransactionFee({
3423
- gasPrice,
3321
+ gasUsed,
3424
3322
  rawPayload,
3425
- tip,
3426
3323
  consensusParameters: {
3427
3324
  gasCosts,
3428
- maxGasPerTx,
3429
3325
  feeParams: {
3430
3326
  gasPerByte,
3431
3327
  gasPriceFactor
@@ -3485,7 +3381,7 @@ var TransactionResponse = class {
3485
3381
  /** Current provider */
3486
3382
  provider;
3487
3383
  /** Gas used on the transaction */
3488
- gasUsed = bn15(0);
3384
+ gasUsed = bn14(0);
3489
3385
  /** The graphql Transaction with receipts object. */
3490
3386
  gqlTransaction;
3491
3387
  abis;
@@ -3563,13 +3459,8 @@ var TransactionResponse = class {
3563
3459
  const decodedTransaction = this.decodeTransaction(
3564
3460
  transaction
3565
3461
  );
3566
- let txReceipts = [];
3567
- if (transaction?.status && "receipts" in transaction.status) {
3568
- txReceipts = transaction.status.receipts;
3569
- }
3570
- const receipts = txReceipts.map(processGqlReceipt) || [];
3571
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3572
- const gasPrice = await this.provider.getLatestGasPrice();
3462
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3463
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3573
3464
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3574
3465
  const transactionSummary = assembleTransactionSummary({
3575
3466
  id: this.id,
@@ -3581,9 +3472,7 @@ var TransactionResponse = class {
3581
3472
  gasPriceFactor,
3582
3473
  abiMap: contractsAbiMap,
3583
3474
  maxInputs,
3584
- gasCosts,
3585
- maxGasPerTx,
3586
- gasPrice
3475
+ gasCosts
3587
3476
  });
3588
3477
  return transactionSummary;
3589
3478
  }
@@ -3710,29 +3599,30 @@ var processGqlChain = (chain) => {
3710
3599
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3711
3600
  return {
3712
3601
  name,
3713
- baseChainHeight: bn16(daHeight),
3602
+ baseChainHeight: bn15(daHeight),
3714
3603
  consensusParameters: {
3715
- contractMaxSize: bn16(contractParams.contractMaxSize),
3716
- maxInputs: bn16(txParams.maxInputs),
3717
- maxOutputs: bn16(txParams.maxOutputs),
3718
- maxWitnesses: bn16(txParams.maxWitnesses),
3719
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3720
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3721
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3722
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3723
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3724
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3725
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3726
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3727
- gasPerByte: bn16(feeParams.gasPerByte),
3728
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3729
- chainId: bn16(consensusParameters.chainId),
3604
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3605
+ maxInputs: bn15(txParams.maxInputs),
3606
+ maxOutputs: bn15(txParams.maxOutputs),
3607
+ maxWitnesses: bn15(txParams.maxWitnesses),
3608
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3609
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3610
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3611
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3612
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3613
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3614
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3615
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3616
+ gasPerByte: bn15(feeParams.gasPerByte),
3617
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3618
+ chainId: bn15(consensusParameters.chainId),
3619
+ baseAssetId: consensusParameters.baseAssetId,
3730
3620
  gasCosts
3731
3621
  },
3732
3622
  gasCosts,
3733
3623
  latestBlock: {
3734
3624
  id: latestBlock.id,
3735
- height: bn16(latestBlock.height),
3625
+ height: bn15(latestBlock.header.height),
3736
3626
  time: latestBlock.header.time,
3737
3627
  transactions: latestBlock.transactions.map((i) => ({
3738
3628
  id: i.id
@@ -3826,8 +3716,10 @@ var _Provider = class {
3826
3716
  * Returns some helpful parameters related to gas fees.
3827
3717
  */
3828
3718
  getGasConfig() {
3719
+ const { minGasPrice } = this.getNode();
3829
3720
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3830
3721
  return {
3722
+ minGasPrice,
3831
3723
  maxGasPerTx,
3832
3724
  maxGasPerPredicate,
3833
3725
  gasPriceFactor,
@@ -3925,7 +3817,7 @@ var _Provider = class {
3925
3817
  */
3926
3818
  async getBlockNumber() {
3927
3819
  const { chain } = await this.operations.getChain();
3928
- return bn16(chain.latestBlock.height, 10);
3820
+ return bn15(chain.latestBlock.header.height, 10);
3929
3821
  }
3930
3822
  /**
3931
3823
  * Returns the chain information.
@@ -3935,11 +3827,13 @@ var _Provider = class {
3935
3827
  async fetchNode() {
3936
3828
  const { nodeInfo } = await this.operations.getNodeInfo();
3937
3829
  const processedNodeInfo = {
3938
- maxDepth: bn16(nodeInfo.maxDepth),
3939
- maxTx: bn16(nodeInfo.maxTx),
3830
+ maxDepth: bn15(nodeInfo.maxDepth),
3831
+ maxTx: bn15(nodeInfo.maxTx),
3832
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3940
3833
  nodeVersion: nodeInfo.nodeVersion,
3941
3834
  utxoValidation: nodeInfo.utxoValidation,
3942
- vmBacktrace: nodeInfo.vmBacktrace
3835
+ vmBacktrace: nodeInfo.vmBacktrace,
3836
+ peers: nodeInfo.peers
3943
3837
  };
3944
3838
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3945
3839
  return processedNodeInfo;
@@ -3965,6 +3859,17 @@ var _Provider = class {
3965
3859
  } = this.getChain();
3966
3860
  return chainId.toNumber();
3967
3861
  }
3862
+ /**
3863
+ * Returns the base asset ID
3864
+ *
3865
+ * @returns A promise that resolves to the base asset ID
3866
+ */
3867
+ getBaseAssetId() {
3868
+ const {
3869
+ consensusParameters: { baseAssetId }
3870
+ } = this.getChain();
3871
+ return baseAssetId;
3872
+ }
3968
3873
  /**
3969
3874
  * Submits a transaction to the chain to be executed.
3970
3875
  *
@@ -4025,13 +3930,14 @@ var _Provider = class {
4025
3930
  return this.estimateTxDependencies(transactionRequest);
4026
3931
  }
4027
3932
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4028
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4029
- encodedTransactions: encodedTransaction,
3933
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3934
+ encodedTransaction,
4030
3935
  utxoValidation: utxoValidation || false
4031
3936
  });
4032
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4033
- const receipts = rawReceipts.map(processGqlReceipt);
4034
- return { receipts, dryrunStatus: status };
3937
+ const receipts = gqlReceipts.map(processGqlReceipt);
3938
+ return {
3939
+ receipts
3940
+ };
4035
3941
  }
4036
3942
  /**
4037
3943
  * Verifies whether enough gas is available to complete transaction.
@@ -4057,7 +3963,7 @@ var _Provider = class {
4057
3963
  } = response;
4058
3964
  if (inputs) {
4059
3965
  inputs.forEach((input, index) => {
4060
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3966
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
4061
3967
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4062
3968
  }
4063
3969
  });
@@ -4070,6 +3976,9 @@ var _Provider = class {
4070
3976
  * If there are missing variable outputs,
4071
3977
  * `addVariableOutputs` is called on the transaction.
4072
3978
  *
3979
+ * @privateRemarks
3980
+ * TODO: Investigate support for missing contract IDs
3981
+ * TODO: Add support for missing output messages
4073
3982
  *
4074
3983
  * @param transactionRequest - The transaction request object.
4075
3984
  * @returns A promise.
@@ -4082,19 +3991,16 @@ var _Provider = class {
4082
3991
  missingContractIds: []
4083
3992
  };
4084
3993
  }
3994
+ await this.estimatePredicates(transactionRequest);
4085
3995
  let receipts = [];
4086
3996
  const missingContractIds = [];
4087
3997
  let outputVariables = 0;
4088
- let dryrunStatus;
4089
3998
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4090
- const {
4091
- dryRun: [{ receipts: rawReceipts, status }]
4092
- } = await this.operations.dryRun({
4093
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3999
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4000
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
4094
4001
  utxoValidation: false
4095
4002
  });
4096
- receipts = rawReceipts.map(processGqlReceipt);
4097
- dryrunStatus = status;
4003
+ receipts = gqlReceipts.map(processGqlReceipt);
4098
4004
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4099
4005
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4100
4006
  if (hasMissingOutputs) {
@@ -4104,10 +4010,6 @@ var _Provider = class {
4104
4010
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
4105
4011
  missingContractIds.push(contractId);
4106
4012
  });
4107
- const { maxFee } = await this.estimateTxGasAndFee({
4108
- transactionRequest
4109
- });
4110
- transactionRequest.maxFee = maxFee;
4111
4013
  } else {
4112
4014
  break;
4113
4015
  }
@@ -4115,139 +4017,37 @@ var _Provider = class {
4115
4017
  return {
4116
4018
  receipts,
4117
4019
  outputVariables,
4118
- missingContractIds,
4119
- dryrunStatus
4020
+ missingContractIds
4120
4021
  };
4121
4022
  }
4122
- /**
4123
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4124
- *
4125
- * Transactions are dry run in batches. After each dry run, transactions requiring
4126
- * further modifications are identified. The method iteratively updates these transactions
4127
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4128
- *
4129
- * @param transactionRequests - Array of transaction request objects.
4130
- * @returns A promise that resolves to an array of results for each transaction.
4131
- */
4132
- async estimateMultipleTxDependencies(transactionRequests) {
4133
- const results = transactionRequests.map(() => ({
4134
- receipts: [],
4135
- outputVariables: 0,
4136
- missingContractIds: [],
4137
- dryrunStatus: void 0
4138
- }));
4139
- const allRequests = clone3(transactionRequests);
4140
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4141
- allRequests.forEach((req, index) => {
4142
- if (req.type === TransactionType8.Script) {
4143
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4144
- }
4145
- });
4146
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4147
- let attempt = 0;
4148
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4149
- const encodedTransactions = transactionsToProcess.map(
4150
- (index) => serializedTransactionsMap.get(index)
4151
- );
4152
- const dryRunResults = await this.operations.dryRun({
4153
- encodedTransactions,
4154
- utxoValidation: false
4155
- });
4156
- const nextRoundTransactions = [];
4157
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4158
- const currentResultIndex = transactionsToProcess[i];
4159
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4160
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4161
- results[currentResultIndex].dryrunStatus = status;
4162
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4163
- results[currentResultIndex].receipts
4164
- );
4165
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4166
- const requestToProcess = allRequests[currentResultIndex];
4167
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4168
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4169
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4170
- missingOutputContractIds.forEach(({ contractId }) => {
4171
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4172
- results[currentResultIndex].missingContractIds.push(contractId);
4173
- });
4174
- const { maxFee } = await this.estimateTxGasAndFee({
4175
- transactionRequest: requestToProcess
4176
- });
4177
- requestToProcess.maxFee = maxFee;
4178
- serializedTransactionsMap.set(
4179
- currentResultIndex,
4180
- hexlify12(requestToProcess.toTransactionBytes())
4181
- );
4182
- nextRoundTransactions.push(currentResultIndex);
4183
- allRequests[currentResultIndex] = requestToProcess;
4184
- }
4185
- }
4186
- transactionsToProcess = nextRoundTransactions;
4187
- attempt += 1;
4188
- }
4189
- return results;
4190
- }
4191
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4192
- if (estimateTxDependencies) {
4193
- return this.estimateMultipleTxDependencies(transactionRequests);
4194
- }
4195
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4196
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4197
- encodedTransactions,
4198
- utxoValidation: utxoValidation || false
4199
- });
4200
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4201
- const receipts = rawReceipts.map(processGqlReceipt);
4202
- return { receipts, dryrunStatus: status };
4203
- });
4204
- return results;
4205
- }
4206
4023
  /**
4207
4024
  * Estimates the transaction gas and fee based on the provided transaction request.
4208
4025
  * @param transactionRequest - The transaction request object.
4209
4026
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4210
4027
  */
4211
- async estimateTxGasAndFee(params) {
4028
+ estimateTxGasAndFee(params) {
4212
4029
  const { transactionRequest } = params;
4213
- let { gasPrice } = params;
4030
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4214
4031
  const chainInfo = this.getChain();
4215
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4032
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4033
+ transactionRequest.gasPrice = gasPrice;
4216
4034
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4217
- if (!gasPrice) {
4218
- gasPrice = await this.estimateGasPrice(10);
4219
- }
4220
- const minFee = calculateGasFee({
4221
- gasPrice: bn16(gasPrice),
4222
- gas: minGas,
4223
- priceFactor: gasPriceFactor,
4224
- tip: transactionRequest.tip
4225
- }).add(1);
4226
- let gasLimit = bn16(0);
4035
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4227
4036
  if (transactionRequest.type === TransactionType8.Script) {
4228
- gasLimit = transactionRequest.gasLimit;
4229
4037
  if (transactionRequest.gasLimit.eq(0)) {
4230
4038
  transactionRequest.gasLimit = minGas;
4231
4039
  transactionRequest.gasLimit = maxGasPerTx.sub(
4232
4040
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4233
4041
  );
4234
- gasLimit = transactionRequest.gasLimit;
4235
4042
  }
4236
4043
  }
4237
4044
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4238
- const maxFee = calculateGasFee({
4239
- gasPrice: bn16(gasPrice),
4240
- gas: maxGas,
4241
- priceFactor: gasPriceFactor,
4242
- tip: transactionRequest.tip
4243
- }).add(1);
4045
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4244
4046
  return {
4245
4047
  minGas,
4246
4048
  minFee,
4247
4049
  maxGas,
4248
- maxFee,
4249
- gasPrice,
4250
- gasLimit
4050
+ maxFee
4251
4051
  };
4252
4052
  }
4253
4053
  /**
@@ -4265,17 +4065,15 @@ var _Provider = class {
4265
4065
  if (estimateTxDependencies) {
4266
4066
  return this.estimateTxDependencies(transactionRequest);
4267
4067
  }
4268
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4269
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4270
- encodedTransactions,
4068
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4069
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4070
+ encodedTransaction,
4271
4071
  utxoValidation: true
4272
4072
  });
4273
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4274
- const { id, receipts, status } = dryRunStatus;
4275
- const processedReceipts = receipts.map(processGqlReceipt);
4276
- return { id, receipts: processedReceipts, status };
4277
- });
4278
- return { receipts: callResult[0].receipts };
4073
+ const receipts = gqlReceipts.map(processGqlReceipt);
4074
+ return {
4075
+ receipts
4076
+ };
4279
4077
  }
4280
4078
  /**
4281
4079
  * Returns a transaction cost to enable user
@@ -4292,79 +4090,77 @@ var _Provider = class {
4292
4090
  * @param tolerance - The tolerance to add on top of the gasUsed.
4293
4091
  * @returns A promise that resolves to the transaction cost object.
4294
4092
  */
4295
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4093
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4094
+ estimateTxDependencies = true,
4095
+ estimatePredicates = true,
4096
+ resourcesOwner,
4097
+ signatureCallback
4098
+ } = {}) {
4296
4099
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4100
+ const { minGasPrice } = this.getGasConfig();
4101
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4297
4102
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4298
4103
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4299
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4104
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4300
4105
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4301
- txRequestClone.maxFee = bn16(0);
4302
4106
  if (isScriptTransaction) {
4303
- txRequestClone.gasLimit = bn16(0);
4107
+ txRequestClone.gasLimit = bn15(0);
4304
4108
  }
4305
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4306
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4109
+ if (estimatePredicates) {
4110
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4111
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4112
+ }
4113
+ await this.estimatePredicates(txRequestClone);
4307
4114
  }
4308
- const signedRequest = clone3(txRequestClone);
4309
- let addedSignatures = 0;
4310
4115
  if (signatureCallback && isScriptTransaction) {
4311
- const lengthBefore = signedRequest.witnesses.length;
4312
- await signatureCallback(signedRequest);
4313
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4116
+ await signatureCallback(txRequestClone);
4314
4117
  }
4315
- await this.estimatePredicates(signedRequest);
4316
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4317
- transactionRequest: signedRequest
4118
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4119
+ transactionRequest: txRequestClone
4318
4120
  });
4319
4121
  let receipts = [];
4320
4122
  let missingContractIds = [];
4321
4123
  let outputVariables = 0;
4322
- let gasUsed = bn16(0);
4323
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4324
- txRequestClone.maxFee = maxFee;
4325
- if (isScriptTransaction) {
4326
- txRequestClone.gasLimit = gasLimit;
4327
- if (signatureCallback) {
4328
- await signatureCallback(txRequestClone);
4329
- }
4124
+ let gasUsed = bn15(0);
4125
+ if (isScriptTransaction && estimateTxDependencies) {
4126
+ txRequestClone.gasPrice = bn15(0);
4330
4127
  const result = await this.estimateTxDependencies(txRequestClone);
4331
4128
  receipts = result.receipts;
4332
4129
  outputVariables = result.outputVariables;
4333
4130
  missingContractIds = result.missingContractIds;
4334
4131
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4335
4132
  txRequestClone.gasLimit = gasUsed;
4336
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4337
- transactionRequest: txRequestClone,
4338
- gasPrice
4133
+ txRequestClone.gasPrice = setGasPrice;
4134
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4135
+ transactionRequest: txRequestClone
4339
4136
  }));
4340
4137
  }
4341
4138
  return {
4342
4139
  requiredQuantities: allQuantities,
4343
4140
  receipts,
4344
4141
  gasUsed,
4345
- gasPrice,
4142
+ minGasPrice,
4143
+ gasPrice: setGasPrice,
4346
4144
  minGas,
4347
4145
  maxGas,
4348
4146
  minFee,
4349
4147
  maxFee,
4148
+ estimatedInputs: txRequestClone.inputs,
4350
4149
  outputVariables,
4351
- missingContractIds,
4352
- addedSignatures,
4353
- estimatedPredicates: txRequestClone.inputs
4150
+ missingContractIds
4354
4151
  };
4355
4152
  }
4356
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4153
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4357
4154
  const ownerAddress = Address2.fromAddressOrString(owner);
4358
4155
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4359
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4360
- quantitiesToContract
4361
- });
4156
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4362
4157
  transactionRequest.addResources(
4363
4158
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4364
4159
  );
4365
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4366
- quantitiesToContract
4367
- });
4160
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4161
+ transactionRequest,
4162
+ forwardingQuantities
4163
+ );
4368
4164
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4369
4165
  return {
4370
4166
  resources,
@@ -4386,10 +4182,11 @@ var _Provider = class {
4386
4182
  return coins.map((coin) => ({
4387
4183
  id: coin.utxoId,
4388
4184
  assetId: coin.assetId,
4389
- amount: bn16(coin.amount),
4185
+ amount: bn15(coin.amount),
4390
4186
  owner: Address2.fromAddressOrString(coin.owner),
4391
- blockCreated: bn16(coin.blockCreated),
4392
- txCreatedIdx: bn16(coin.txCreatedIdx)
4187
+ maturity: bn15(coin.maturity).toNumber(),
4188
+ blockCreated: bn15(coin.blockCreated),
4189
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4393
4190
  }));
4394
4191
  }
4395
4192
  /**
@@ -4426,9 +4223,9 @@ var _Provider = class {
4426
4223
  switch (coin.__typename) {
4427
4224
  case "MessageCoin":
4428
4225
  return {
4429
- amount: bn16(coin.amount),
4226
+ amount: bn15(coin.amount),
4430
4227
  assetId: coin.assetId,
4431
- daHeight: bn16(coin.daHeight),
4228
+ daHeight: bn15(coin.daHeight),
4432
4229
  sender: Address2.fromAddressOrString(coin.sender),
4433
4230
  recipient: Address2.fromAddressOrString(coin.recipient),
4434
4231
  nonce: coin.nonce
@@ -4436,11 +4233,12 @@ var _Provider = class {
4436
4233
  case "Coin":
4437
4234
  return {
4438
4235
  id: coin.utxoId,
4439
- amount: bn16(coin.amount),
4236
+ amount: bn15(coin.amount),
4440
4237
  assetId: coin.assetId,
4441
4238
  owner: Address2.fromAddressOrString(coin.owner),
4442
- blockCreated: bn16(coin.blockCreated),
4443
- txCreatedIdx: bn16(coin.txCreatedIdx)
4239
+ maturity: bn15(coin.maturity).toNumber(),
4240
+ blockCreated: bn15(coin.blockCreated),
4241
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4444
4242
  };
4445
4243
  default:
4446
4244
  return null;
@@ -4457,13 +4255,13 @@ var _Provider = class {
4457
4255
  async getBlock(idOrHeight) {
4458
4256
  let variables;
4459
4257
  if (typeof idOrHeight === "number") {
4460
- variables = { height: bn16(idOrHeight).toString(10) };
4258
+ variables = { height: bn15(idOrHeight).toString(10) };
4461
4259
  } else if (idOrHeight === "latest") {
4462
4260
  variables = { height: (await this.getBlockNumber()).toString(10) };
4463
4261
  } else if (idOrHeight.length === 66) {
4464
4262
  variables = { blockId: idOrHeight };
4465
4263
  } else {
4466
- variables = { blockId: bn16(idOrHeight).toString(10) };
4264
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4467
4265
  }
4468
4266
  const { block } = await this.operations.getBlock(variables);
4469
4267
  if (!block) {
@@ -4471,7 +4269,7 @@ var _Provider = class {
4471
4269
  }
4472
4270
  return {
4473
4271
  id: block.id,
4474
- height: bn16(block.height),
4272
+ height: bn15(block.header.height),
4475
4273
  time: block.header.time,
4476
4274
  transactionIds: block.transactions.map((tx) => tx.id)
4477
4275
  };
@@ -4486,7 +4284,7 @@ var _Provider = class {
4486
4284
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4487
4285
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4488
4286
  id: block.id,
4489
- height: bn16(block.height),
4287
+ height: bn15(block.header.height),
4490
4288
  time: block.header.time,
4491
4289
  transactionIds: block.transactions.map((tx) => tx.id)
4492
4290
  }));
@@ -4501,7 +4299,7 @@ var _Provider = class {
4501
4299
  async getBlockWithTransactions(idOrHeight) {
4502
4300
  let variables;
4503
4301
  if (typeof idOrHeight === "number") {
4504
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4302
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4505
4303
  } else if (idOrHeight === "latest") {
4506
4304
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4507
4305
  } else {
@@ -4513,7 +4311,7 @@ var _Provider = class {
4513
4311
  }
4514
4312
  return {
4515
4313
  id: block.id,
4516
- height: bn16(block.height, 10),
4314
+ height: bn15(block.header.height, 10),
4517
4315
  time: block.header.time,
4518
4316
  transactionIds: block.transactions.map((tx) => tx.id),
4519
4317
  transactions: block.transactions.map(
@@ -4562,7 +4360,7 @@ var _Provider = class {
4562
4360
  contract: Address2.fromAddressOrString(contractId).toB256(),
4563
4361
  asset: hexlify12(assetId)
4564
4362
  });
4565
- return bn16(contractBalance.amount, 10);
4363
+ return bn15(contractBalance.amount, 10);
4566
4364
  }
4567
4365
  /**
4568
4366
  * Returns the balance for the given owner for the given asset ID.
@@ -4576,7 +4374,7 @@ var _Provider = class {
4576
4374
  owner: Address2.fromAddressOrString(owner).toB256(),
4577
4375
  assetId: hexlify12(assetId)
4578
4376
  });
4579
- return bn16(balance.amount, 10);
4377
+ return bn15(balance.amount, 10);
4580
4378
  }
4581
4379
  /**
4582
4380
  * Returns balances for the given owner.
@@ -4594,7 +4392,7 @@ var _Provider = class {
4594
4392
  const balances = result.balances.edges.map((edge) => edge.node);
4595
4393
  return balances.map((balance) => ({
4596
4394
  assetId: balance.assetId,
4597
- amount: bn16(balance.amount)
4395
+ amount: bn15(balance.amount)
4598
4396
  }));
4599
4397
  }
4600
4398
  /**
@@ -4616,15 +4414,15 @@ var _Provider = class {
4616
4414
  sender: message.sender,
4617
4415
  recipient: message.recipient,
4618
4416
  nonce: message.nonce,
4619
- amount: bn16(message.amount),
4417
+ amount: bn15(message.amount),
4620
4418
  data: message.data
4621
4419
  }),
4622
4420
  sender: Address2.fromAddressOrString(message.sender),
4623
4421
  recipient: Address2.fromAddressOrString(message.recipient),
4624
4422
  nonce: message.nonce,
4625
- amount: bn16(message.amount),
4423
+ amount: bn15(message.amount),
4626
4424
  data: InputMessageCoder.decodeData(message.data),
4627
- daHeight: bn16(message.daHeight)
4425
+ daHeight: bn15(message.daHeight)
4628
4426
  }));
4629
4427
  }
4630
4428
  /**
@@ -4677,60 +4475,44 @@ var _Provider = class {
4677
4475
  } = result.messageProof;
4678
4476
  return {
4679
4477
  messageProof: {
4680
- proofIndex: bn16(messageProof.proofIndex),
4478
+ proofIndex: bn15(messageProof.proofIndex),
4681
4479
  proofSet: messageProof.proofSet
4682
4480
  },
4683
4481
  blockProof: {
4684
- proofIndex: bn16(blockProof.proofIndex),
4482
+ proofIndex: bn15(blockProof.proofIndex),
4685
4483
  proofSet: blockProof.proofSet
4686
4484
  },
4687
4485
  messageBlockHeader: {
4688
4486
  id: messageBlockHeader.id,
4689
- daHeight: bn16(messageBlockHeader.daHeight),
4690
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4487
+ daHeight: bn15(messageBlockHeader.daHeight),
4488
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4691
4489
  transactionsRoot: messageBlockHeader.transactionsRoot,
4692
- height: bn16(messageBlockHeader.height),
4490
+ height: bn15(messageBlockHeader.height),
4693
4491
  prevRoot: messageBlockHeader.prevRoot,
4694
4492
  time: messageBlockHeader.time,
4695
4493
  applicationHash: messageBlockHeader.applicationHash,
4696
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4697
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4698
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4699
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4700
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4494
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4495
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4701
4496
  },
4702
4497
  commitBlockHeader: {
4703
4498
  id: commitBlockHeader.id,
4704
- daHeight: bn16(commitBlockHeader.daHeight),
4705
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4499
+ daHeight: bn15(commitBlockHeader.daHeight),
4500
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4706
4501
  transactionsRoot: commitBlockHeader.transactionsRoot,
4707
- height: bn16(commitBlockHeader.height),
4502
+ height: bn15(commitBlockHeader.height),
4708
4503
  prevRoot: commitBlockHeader.prevRoot,
4709
4504
  time: commitBlockHeader.time,
4710
4505
  applicationHash: commitBlockHeader.applicationHash,
4711
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4712
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4713
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4714
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4715
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4506
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4507
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4716
4508
  },
4717
4509
  sender: Address2.fromAddressOrString(sender),
4718
4510
  recipient: Address2.fromAddressOrString(recipient),
4719
4511
  nonce,
4720
- amount: bn16(amount),
4512
+ amount: bn15(amount),
4721
4513
  data
4722
4514
  };
4723
4515
  }
4724
- async getLatestGasPrice() {
4725
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4726
- return bn16(latestGasPrice.gasPrice);
4727
- }
4728
- async estimateGasPrice(blockHorizon) {
4729
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4730
- blockHorizon: String(blockHorizon)
4731
- });
4732
- return bn16(estimateGasPrice.gasPrice);
4733
- }
4734
4516
  /**
4735
4517
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4736
4518
  *
@@ -4750,10 +4532,10 @@ var _Provider = class {
4750
4532
  */
4751
4533
  async produceBlocks(amount, startTime) {
4752
4534
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4753
- blocksToProduce: bn16(amount).toString(10),
4535
+ blocksToProduce: bn15(amount).toString(10),
4754
4536
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4755
4537
  });
4756
- return bn16(latestBlockHeight);
4538
+ return bn15(latestBlockHeight);
4757
4539
  }
4758
4540
  // eslint-disable-next-line @typescript-eslint/require-await
4759
4541
  async getTransactionResponse(transactionId) {
@@ -4767,7 +4549,7 @@ cacheInputs_fn = function(inputs) {
4767
4549
  return;
4768
4550
  }
4769
4551
  inputs.forEach((input) => {
4770
- if (input.type === InputType7.Coin) {
4552
+ if (input.type === InputType6.Coin) {
4771
4553
  this.cache?.set(input.id);
4772
4554
  }
4773
4555
  });
@@ -4777,7 +4559,7 @@ __publicField(Provider, "nodeInfoCache", {});
4777
4559
 
4778
4560
  // src/providers/transaction-summary/get-transaction-summary.ts
4779
4561
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4780
- import { bn as bn17 } from "@fuel-ts/math";
4562
+ import { bn as bn16 } from "@fuel-ts/math";
4781
4563
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4782
4564
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4783
4565
  async function getTransactionSummary(params) {
@@ -4795,28 +4577,21 @@ async function getTransactionSummary(params) {
4795
4577
  arrayify12(gqlTransaction.rawPayload),
4796
4578
  0
4797
4579
  );
4798
- let txReceipts = [];
4799
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4800
- txReceipts = gqlTransaction.status.receipts;
4801
- }
4802
- const receipts = txReceipts.map(processGqlReceipt);
4580
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4803
4581
  const {
4804
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4582
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4805
4583
  } = provider.getChain();
4806
- const gasPrice = await provider.getLatestGasPrice();
4807
4584
  const transactionInfo = assembleTransactionSummary({
4808
4585
  id: gqlTransaction.id,
4809
4586
  receipts,
4810
4587
  transaction: decodedTransaction,
4811
4588
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4812
4589
  gqlTransactionStatus: gqlTransaction.status,
4813
- gasPerByte: bn17(gasPerByte),
4814
- gasPriceFactor: bn17(gasPriceFactor),
4590
+ gasPerByte: bn16(gasPerByte),
4591
+ gasPriceFactor: bn16(gasPriceFactor),
4815
4592
  abiMap,
4816
4593
  maxInputs,
4817
- gasCosts,
4818
- maxGasPerTx,
4819
- gasPrice
4594
+ gasCosts
4820
4595
  });
4821
4596
  return {
4822
4597
  gqlTransaction,
@@ -4826,11 +4601,10 @@ async function getTransactionSummary(params) {
4826
4601
  async function getTransactionSummaryFromRequest(params) {
4827
4602
  const { provider, transactionRequest, abiMap } = params;
4828
4603
  const { receipts } = await provider.call(transactionRequest);
4829
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4604
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4830
4605
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4831
4606
  const transaction = transactionRequest.toTransaction();
4832
4607
  const transactionBytes = transactionRequest.toTransactionBytes();
4833
- const gasPrice = await provider.getLatestGasPrice();
4834
4608
  const transactionSummary = assembleTransactionSummary({
4835
4609
  receipts,
4836
4610
  transaction,
@@ -4839,9 +4613,7 @@ async function getTransactionSummaryFromRequest(params) {
4839
4613
  gasPerByte,
4840
4614
  gasPriceFactor,
4841
4615
  maxInputs,
4842
- gasCosts,
4843
- maxGasPerTx,
4844
- gasPrice
4616
+ gasCosts
4845
4617
  });
4846
4618
  return transactionSummary;
4847
4619
  }
@@ -4850,18 +4622,13 @@ async function getTransactionsSummaries(params) {
4850
4622
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4851
4623
  const { edges, pageInfo } = transactionsByOwner;
4852
4624
  const {
4853
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4625
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4854
4626
  } = provider.getChain();
4855
- const gasPrice = await provider.getLatestGasPrice();
4856
4627
  const transactions = edges.map((edge) => {
4857
4628
  const { node: gqlTransaction } = edge;
4858
- const { id, rawPayload, status } = gqlTransaction;
4629
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4859
4630
  const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
4860
- let txReceipts = [];
4861
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4862
- txReceipts = gqlTransaction.status.receipts;
4863
- }
4864
- const receipts = txReceipts.map(processGqlReceipt);
4631
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4865
4632
  const transactionSummary = assembleTransactionSummary({
4866
4633
  id,
4867
4634
  receipts,
@@ -4872,9 +4639,7 @@ async function getTransactionsSummaries(params) {
4872
4639
  gasPerByte,
4873
4640
  gasPriceFactor,
4874
4641
  maxInputs,
4875
- gasCosts,
4876
- maxGasPerTx,
4877
- gasPrice
4642
+ gasCosts
4878
4643
  });
4879
4644
  const output = {
4880
4645
  gqlTransaction,
@@ -5168,8 +4933,9 @@ var Account = class extends AbstractAccount {
5168
4933
  * @param assetId - The asset ID to check the balance for.
5169
4934
  * @returns A promise that resolves to the balance amount.
5170
4935
  */
5171
- async getBalance(assetId = BaseAssetId3) {
5172
- const amount = await this.provider.getBalance(this.address, assetId);
4936
+ async getBalance(assetId) {
4937
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4938
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
5173
4939
  return amount;
5174
4940
  }
5175
4941
  /**
@@ -5206,33 +4972,37 @@ var Account = class extends AbstractAccount {
5206
4972
  * @param fee - The estimated transaction fee.
5207
4973
  * @returns A promise that resolves when the resources are added to the transaction.
5208
4974
  */
5209
- async fund(request, params) {
5210
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5211
- const txRequest = request;
5212
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5213
- amount: bn18(fee),
5214
- assetId: BaseAssetId3,
5215
- coinQuantities: requiredQuantities
4975
+ async fund(request, coinQuantities, fee) {
4976
+ const baseAssetId = this.provider.getBaseAssetId();
4977
+ const updatedQuantities = addAmountToAsset({
4978
+ amount: bn17(fee),
4979
+ assetId: baseAssetId,
4980
+ coinQuantities
5216
4981
  });
5217
4982
  const quantitiesDict = {};
5218
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4983
+ updatedQuantities.forEach(({ amount, assetId }) => {
5219
4984
  quantitiesDict[assetId] = {
5220
4985
  required: amount,
5221
- owned: bn18(0)
4986
+ owned: bn17(0)
5222
4987
  };
5223
4988
  });
5224
- txRequest.inputs.forEach((input) => {
4989
+ const cachedUtxos = [];
4990
+ const cachedMessages = [];
4991
+ const owner = this.address.toB256();
4992
+ request.inputs.forEach((input) => {
5225
4993
  const isResource = "amount" in input;
5226
4994
  if (isResource) {
5227
4995
  const isCoin2 = "owner" in input;
5228
4996
  if (isCoin2) {
5229
4997
  const assetId = String(input.assetId);
5230
- if (quantitiesDict[assetId]) {
5231
- const amount = bn18(input.amount);
4998
+ if (input.owner === owner && quantitiesDict[assetId]) {
4999
+ const amount = bn17(input.amount);
5232
5000
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5001
+ cachedUtxos.push(input.id);
5233
5002
  }
5234
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
5235
- quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
5003
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
5004
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
5005
+ cachedMessages.push(input.nonce);
5236
5006
  }
5237
5007
  }
5238
5008
  });
@@ -5247,23 +5017,12 @@ var Account = class extends AbstractAccount {
5247
5017
  });
5248
5018
  const needsToBeFunded = missingQuantities.length;
5249
5019
  if (needsToBeFunded) {
5250
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5251
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5252
- txRequest.addResources(resources);
5253
- }
5254
- txRequest.shiftPredicateData();
5255
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5256
- const requestToBeReEstimate = clone4(txRequest);
5257
- if (addedSignatures) {
5258
- Array.from({ length: addedSignatures }).forEach(
5259
- () => requestToBeReEstimate.addEmptyWitness()
5260
- );
5020
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5021
+ messages: cachedMessages,
5022
+ utxos: cachedUtxos
5023
+ });
5024
+ request.addResources(resources);
5261
5025
  }
5262
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5263
- transactionRequest: requestToBeReEstimate
5264
- });
5265
- txRequest.maxFee = maxFee;
5266
- return txRequest;
5267
5026
  }
5268
5027
  /**
5269
5028
  * A helper that creates a transfer transaction request and returns it.
@@ -5271,25 +5030,30 @@ var Account = class extends AbstractAccount {
5271
5030
  * @param destination - The address of the destination.
5272
5031
  * @param amount - The amount of coins to transfer.
5273
5032
  * @param assetId - The asset ID of the coins to transfer.
5274
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5033
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5275
5034
  * @returns A promise that resolves to the prepared transaction request.
5276
5035
  */
5277
- async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5278
- const request = new ScriptTransactionRequest(txParams);
5279
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5280
- const txCost = await this.provider.getTransactionCost(request, {
5036
+ async createTransfer(destination, amount, assetId, txParams = {}) {
5037
+ const { minGasPrice } = this.provider.getGasConfig();
5038
+ const baseAssetId = this.provider.getBaseAssetId();
5039
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5040
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5041
+ const request = new ScriptTransactionRequest(params);
5042
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5043
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5281
5044
  estimateTxDependencies: true,
5282
5045
  resourcesOwner: this
5283
5046
  });
5284
- if ("gasLimit" in txParams) {
5285
- this.validateGas({
5286
- gasUsed: txCost.gasUsed,
5287
- gasLimit: request.gasLimit
5288
- });
5289
- }
5290
- request.gasLimit = txCost.gasUsed;
5291
- request.maxFee = txCost.maxFee;
5292
- await this.fund(request, txCost);
5047
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5048
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
5049
+ this.validateGas({
5050
+ gasUsed,
5051
+ gasPrice: request.gasPrice,
5052
+ gasLimit: request.gasLimit,
5053
+ minGasPrice
5054
+ });
5055
+ await this.fund(request, requiredQuantities, maxFee);
5056
+ request.updatePredicateInputs(estimatedInputs);
5293
5057
  return request;
5294
5058
  }
5295
5059
  /**
@@ -5301,14 +5065,15 @@ var Account = class extends AbstractAccount {
5301
5065
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5302
5066
  * @returns A promise that resolves to the transaction response.
5303
5067
  */
5304
- async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5305
- if (bn18(amount).lte(0)) {
5068
+ async transfer(destination, amount, assetId, txParams = {}) {
5069
+ if (bn17(amount).lte(0)) {
5306
5070
  throw new FuelError15(
5307
5071
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5308
5072
  "Transfer amount must be a positive number."
5309
5073
  );
5310
5074
  }
5311
- const request = await this.createTransfer(destination, amount, assetId, txParams);
5075
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5076
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5312
5077
  return this.sendTransaction(request, { estimateTxDependencies: false });
5313
5078
  }
5314
5079
  /**
@@ -5320,38 +5085,41 @@ var Account = class extends AbstractAccount {
5320
5085
  * @param txParams - The optional transaction parameters.
5321
5086
  * @returns A promise that resolves to the transaction response.
5322
5087
  */
5323
- async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5324
- if (bn18(amount).lte(0)) {
5088
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
5089
+ if (bn17(amount).lte(0)) {
5325
5090
  throw new FuelError15(
5326
5091
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5327
5092
  "Transfer amount must be a positive number."
5328
5093
  );
5329
5094
  }
5330
5095
  const contractAddress = Address3.fromAddressOrString(contractId);
5096
+ const { minGasPrice } = this.provider.getGasConfig();
5097
+ const baseAssetId = this.provider.getBaseAssetId();
5098
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5099
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5331
5100
  const { script, scriptData } = await assembleTransferToContractScript({
5332
5101
  hexlifiedContractId: contractAddress.toB256(),
5333
- amountToTransfer: bn18(amount),
5334
- assetId
5102
+ amountToTransfer: bn17(amount),
5103
+ assetId: assetIdToTransfer
5335
5104
  });
5336
5105
  const request = new ScriptTransactionRequest({
5337
- ...txParams,
5106
+ ...params,
5338
5107
  script,
5339
5108
  scriptData
5340
5109
  });
5341
5110
  request.addContractInputAndOutput(contractAddress);
5342
- const txCost = await this.provider.getTransactionCost(request, {
5343
- resourcesOwner: this,
5344
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
5111
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5112
+ request,
5113
+ [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
5114
+ );
5115
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5116
+ this.validateGas({
5117
+ gasUsed,
5118
+ gasPrice: request.gasPrice,
5119
+ gasLimit: request.gasLimit,
5120
+ minGasPrice
5345
5121
  });
5346
- if (txParams.gasLimit) {
5347
- this.validateGas({
5348
- gasUsed: txCost.gasUsed,
5349
- gasLimit: request.gasLimit
5350
- });
5351
- }
5352
- request.gasLimit = txCost.gasUsed;
5353
- request.maxFee = txCost.maxFee;
5354
- await this.fund(request, txCost);
5122
+ await this.fund(request, requiredQuantities, maxFee);
5355
5123
  return this.sendTransaction(request);
5356
5124
  }
5357
5125
  /**
@@ -5363,31 +5131,40 @@ var Account = class extends AbstractAccount {
5363
5131
  * @returns A promise that resolves to the transaction response.
5364
5132
  */
5365
5133
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5134
+ const { minGasPrice } = this.provider.getGasConfig();
5135
+ const baseAssetId = this.provider.getBaseAssetId();
5366
5136
  const recipientAddress = Address3.fromAddressOrString(recipient);
5367
5137
  const recipientDataArray = arrayify14(
5368
5138
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5369
5139
  );
5370
5140
  const amountDataArray = arrayify14(
5371
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
5141
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5372
5142
  );
5373
5143
  const script = new Uint8Array([
5374
5144
  ...arrayify14(withdrawScript.bytes),
5375
5145
  ...recipientDataArray,
5376
5146
  ...amountDataArray
5377
5147
  ]);
5378
- const params = { script, ...txParams };
5148
+ const params = {
5149
+ script,
5150
+ gasPrice: minGasPrice,
5151
+ baseAssetId,
5152
+ ...txParams
5153
+ };
5379
5154
  const request = new ScriptTransactionRequest(params);
5380
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5381
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5382
- if (txParams.gasLimit) {
5383
- this.validateGas({
5384
- gasUsed: txCost.gasUsed,
5385
- gasLimit: request.gasLimit
5386
- });
5387
- }
5388
- request.maxFee = txCost.maxFee;
5389
- request.gasLimit = txCost.gasUsed;
5390
- await this.fund(request, txCost);
5155
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
5156
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5157
+ request,
5158
+ forwardingQuantities
5159
+ );
5160
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5161
+ this.validateGas({
5162
+ gasUsed,
5163
+ gasPrice: request.gasPrice,
5164
+ gasLimit: request.gasLimit,
5165
+ minGasPrice
5166
+ });
5167
+ await this.fund(request, requiredQuantities, maxFee);
5391
5168
  return this.sendTransaction(request);
5392
5169
  }
5393
5170
  async signMessage(message) {
@@ -5445,7 +5222,18 @@ var Account = class extends AbstractAccount {
5445
5222
  }
5446
5223
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5447
5224
  }
5448
- validateGas({ gasUsed, gasLimit }) {
5225
+ validateGas({
5226
+ gasUsed,
5227
+ gasPrice,
5228
+ gasLimit,
5229
+ minGasPrice
5230
+ }) {
5231
+ if (minGasPrice.gt(gasPrice)) {
5232
+ throw new FuelError15(
5233
+ ErrorCode15.GAS_PRICE_TOO_LOW,
5234
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5235
+ );
5236
+ }
5449
5237
  if (gasUsed.gt(gasLimit)) {
5450
5238
  throw new FuelError15(
5451
5239
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5741,7 +5529,7 @@ var BaseWalletUnlocked = class extends Account {
5741
5529
  * @param transactionRequestLike - The transaction request to send.
5742
5530
  * @returns A promise that resolves to the TransactionResponse object.
5743
5531
  */
5744
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5532
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5745
5533
  const transactionRequest = transactionRequestify(transactionRequestLike);
5746
5534
  if (estimateTxDependencies) {
5747
5535
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5782,7 +5570,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5782
5570
  // src/hdwallet/hdwallet.ts
5783
5571
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5784
5572
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5785
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5573
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5786
5574
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5787
5575
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5788
5576
 
@@ -8254,7 +8042,7 @@ var HDWallet = class {
8254
8042
  const IR = bytes.slice(32);
8255
8043
  if (privateKey) {
8256
8044
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8257
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
8045
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
8258
8046
  return new HDWallet({
8259
8047
  privateKey: ki,
8260
8048
  chainCode: IR,
@@ -8941,9 +8729,8 @@ import {
8941
8729
  SCRIPT_FIXED_SIZE
8942
8730
  } from "@fuel-ts/abi-coder";
8943
8731
  import { Address as Address9 } from "@fuel-ts/address";
8944
- import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8945
8732
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8946
- import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
8733
+ import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8947
8734
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8948
8735
 
8949
8736
  // src/predicate/utils/getPredicateRoot.ts
@@ -9003,9 +8790,9 @@ var Predicate = class extends Account {
9003
8790
  const request = transactionRequestify(transactionRequestLike);
9004
8791
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9005
8792
  request.inputs?.forEach((input) => {
9006
- if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
9007
- input.predicate = hexlify19(this.bytes);
9008
- input.predicateData = hexlify19(this.getPredicateData(policies.length));
8793
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8794
+ input.predicate = this.bytes;
8795
+ input.predicateData = this.getPredicateData(policies.length);
9009
8796
  }
9010
8797
  });
9011
8798
  return request;
@@ -9019,8 +8806,10 @@ var Predicate = class extends Account {
9019
8806
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
9020
8807
  * @returns A promise that resolves to the prepared transaction request.
9021
8808
  */
9022
- async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
9023
- return super.createTransfer(destination, amount, assetId, txParams);
8809
+ async createTransfer(destination, amount, assetId, txParams = {}) {
8810
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8811
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8812
+ return this.populateTransactionPredicateData(request);
9024
8813
  }
9025
8814
  /**
9026
8815
  * Sends a transaction with the populated predicate data.
@@ -9028,9 +8817,9 @@ var Predicate = class extends Account {
9028
8817
  * @param transactionRequestLike - The transaction request-like object.
9029
8818
  * @returns A promise that resolves to the transaction response.
9030
8819
  */
9031
- sendTransaction(transactionRequestLike) {
9032
- const transactionRequest = transactionRequestify(transactionRequestLike);
9033
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8820
+ sendTransaction(transactionRequestLike, options) {
8821
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8822
+ return super.sendTransaction(transactionRequest, options);
9034
8823
  }
9035
8824
  /**
9036
8825
  * Simulates a transaction with the populated predicate data.
@@ -9039,8 +8828,8 @@ var Predicate = class extends Account {
9039
8828
  * @returns A promise that resolves to the call result.
9040
8829
  */
9041
8830
  simulateTransaction(transactionRequestLike) {
9042
- const transactionRequest = transactionRequestify(transactionRequestLike);
9043
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8831
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8832
+ return super.simulateTransaction(transactionRequest);
9044
8833
  }
9045
8834
  getPredicateData(policiesLength) {
9046
8835
  if (!this.predicateData.length) {
@@ -9086,25 +8875,6 @@ var Predicate = class extends Account {
9086
8875
  predicateInterface: abiInterface
9087
8876
  };
9088
8877
  }
9089
- /**
9090
- * Retrieves resources satisfying the spend query for the account.
9091
- *
9092
- * @param quantities - IDs of coins to exclude.
9093
- * @param excludedIds - IDs of resources to be excluded from the query.
9094
- * @returns A promise that resolves to an array of Resources.
9095
- */
9096
- async getResourcesToSpend(quantities, excludedIds) {
9097
- const resources = await this.provider.getResourcesToSpend(
9098
- this.address,
9099
- quantities,
9100
- excludedIds
9101
- );
9102
- return resources.map((resource) => ({
9103
- ...resource,
9104
- predicate: hexlify19(this.bytes),
9105
- paddPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
9106
- }));
9107
- }
9108
8878
  /**
9109
8879
  * Sets the configurable constants for the predicate.
9110
8880
  *
@@ -9853,7 +9623,7 @@ export {
9853
9623
  WalletLocked,
9854
9624
  WalletManager,
9855
9625
  WalletUnlocked,
9856
- addAmountToCoinQuantities,
9626
+ addAmountToAsset,
9857
9627
  addOperation,
9858
9628
  assemblePanicError,
9859
9629
  assembleReceiptByType,
@@ -9862,10 +9632,9 @@ export {
9862
9632
  assets,
9863
9633
  buildBlockExplorerUrl,
9864
9634
  cacheFor,
9865
- cacheTxInputsFromOwner,
9866
- calculateGasFee,
9867
9635
  calculateMetadataGasForTxCreate,
9868
9636
  calculateMetadataGasForTxScript,
9637
+ calculatePriceWithFactor,
9869
9638
  calculateTransactionFee,
9870
9639
  coinQuantityfy,
9871
9640
  deferPromise,