@fuel-ts/account 0.0.0-rc-2021-20240409151049 → 0.0.0-rc-2034-20240410011904

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

Potentially problematic release.


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

Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +623 -868
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +525 -759
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +406 -639
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +328 -894
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -3
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +31 -36
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +25 -8
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1122 -1582
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +521 -735
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +415 -629
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
package/dist/index.mjs CHANGED
@@ -32,9 +32,8 @@ import { Address as Address3 } from "@fuel-ts/address";
32
32
  import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
33
33
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
34
34
  import { AbstractAccount } from "@fuel-ts/interfaces";
35
- import { bn as bn18 } from "@fuel-ts/math";
35
+ import { bn as bn17 } from "@fuel-ts/math";
36
36
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
37
- import { clone as clone4 } from "ramda";
38
37
 
39
38
  // src/providers/coin-quantity.ts
40
39
  import { BaseAssetId } from "@fuel-ts/address/configs";
@@ -43,24 +42,24 @@ import { hexlify } from "@fuel-ts/utils";
43
42
  var coinQuantityfy = (coinQuantityLike) => {
44
43
  let assetId;
45
44
  let amount;
46
- let max;
45
+ let max2;
47
46
  if (Array.isArray(coinQuantityLike)) {
48
47
  amount = coinQuantityLike[0];
49
48
  assetId = coinQuantityLike[1] ?? BaseAssetId;
50
- max = coinQuantityLike[2] ?? void 0;
49
+ max2 = coinQuantityLike[2] ?? void 0;
51
50
  } else {
52
51
  amount = coinQuantityLike.amount;
53
52
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
54
- max = coinQuantityLike.max ?? void 0;
53
+ max2 = coinQuantityLike.max ?? void 0;
55
54
  }
56
55
  const bnAmount = bn(amount);
57
56
  return {
58
57
  assetId: hexlify(assetId),
59
58
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
60
- max: max ? bn(max) : void 0
59
+ max: max2 ? bn(max2) : void 0
61
60
  };
62
61
  };
63
- var addAmountToCoinQuantities = (params) => {
62
+ var addAmountToAsset = (params) => {
64
63
  const { amount, assetId } = params;
65
64
  const coinQuantities = [...params.coinQuantities];
66
65
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -75,9 +74,9 @@ var addAmountToCoinQuantities = (params) => {
75
74
  // src/providers/provider.ts
76
75
  import { Address as Address2 } from "@fuel-ts/address";
77
76
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
78
- import { BN, bn as bn16 } from "@fuel-ts/math";
77
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
79
78
  import {
80
- InputType as InputType7,
79
+ InputType as InputType6,
81
80
  TransactionType as TransactionType8,
82
81
  InputMessageCoder,
83
82
  TransactionCoder as TransactionCoder5
@@ -93,10 +92,14 @@ import { clone as clone3 } from "ramda";
93
92
  import gql from "graphql-tag";
94
93
  var ReceiptFragmentFragmentDoc = gql`
95
94
  fragment receiptFragment on Receipt {
96
- id
95
+ contract {
96
+ id
97
+ }
97
98
  pc
98
99
  is
99
- to
100
+ to {
101
+ id
102
+ }
100
103
  toAddress
101
104
  amount
102
105
  assetId
@@ -134,16 +137,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
134
137
  id
135
138
  }
136
139
  time
137
- receipts {
138
- ...receiptFragment
139
- }
140
140
  programState {
141
141
  returnType
142
142
  data
143
143
  }
144
- receipts {
145
- ...receiptFragment
146
- }
147
144
  }
148
145
  ... on FailureStatus {
149
146
  block {
@@ -151,24 +148,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
151
148
  }
152
149
  time
153
150
  reason
154
- receipts {
155
- ...receiptFragment
156
- }
157
151
  }
158
152
  ... on SqueezedOutStatus {
159
153
  reason
160
154
  }
161
155
  }
162
- ${ReceiptFragmentFragmentDoc}`;
156
+ `;
163
157
  var TransactionFragmentFragmentDoc = gql`
164
158
  fragment transactionFragment on Transaction {
165
159
  id
166
160
  rawPayload
161
+ gasPrice
162
+ receipts {
163
+ ...receiptFragment
164
+ }
167
165
  status {
168
166
  ...transactionStatusFragment
169
167
  }
170
168
  }
171
- ${TransactionStatusFragmentFragmentDoc}`;
169
+ ${ReceiptFragmentFragmentDoc}
170
+ ${TransactionStatusFragmentFragmentDoc}`;
172
171
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
173
172
  fragment inputEstimatePredicatesFragment on Input {
174
173
  ... on InputCoin {
@@ -186,46 +185,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
186
185
  }
187
186
  }
188
187
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
189
- var DryRunFailureStatusFragmentFragmentDoc = gql`
190
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
191
- reason
192
- programState {
193
- returnType
194
- data
195
- }
196
- }
197
- `;
198
- var DryRunSuccessStatusFragmentFragmentDoc = gql`
199
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
200
- programState {
201
- returnType
202
- data
203
- }
204
- }
205
- `;
206
- var DryRunTransactionStatusFragmentFragmentDoc = gql`
207
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
208
- ... on DryRunFailureStatus {
209
- ...dryRunFailureStatusFragment
210
- }
211
- ... on DryRunSuccessStatus {
212
- ...dryRunSuccessStatusFragment
213
- }
214
- }
215
- ${DryRunFailureStatusFragmentFragmentDoc}
216
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
217
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
218
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
219
- id
220
- status {
221
- ...dryRunTransactionStatusFragment
222
- }
223
- receipts {
224
- ...receiptFragment
225
- }
226
- }
227
- ${DryRunTransactionStatusFragmentFragmentDoc}
228
- ${ReceiptFragmentFragmentDoc}`;
229
188
  var CoinFragmentFragmentDoc = gql`
230
189
  fragment coinFragment on Coin {
231
190
  __typename
@@ -233,6 +192,7 @@ var CoinFragmentFragmentDoc = gql`
233
192
  owner
234
193
  amount
235
194
  assetId
195
+ maturity
236
196
  blockCreated
237
197
  txCreatedIdx
238
198
  }
@@ -277,6 +237,7 @@ var MessageProofFragmentFragmentDoc = gql`
277
237
  prevRoot
278
238
  time
279
239
  applicationHash
240
+ messageReceiptRoot
280
241
  messageReceiptCount
281
242
  }
282
243
  commitBlockHeader {
@@ -288,6 +249,7 @@ var MessageProofFragmentFragmentDoc = gql`
288
249
  prevRoot
289
250
  time
290
251
  applicationHash
252
+ messageReceiptRoot
291
253
  messageReceiptCount
292
254
  }
293
255
  sender
@@ -307,8 +269,8 @@ var BalanceFragmentFragmentDoc = gql`
307
269
  var BlockFragmentFragmentDoc = gql`
308
270
  fragment blockFragment on Block {
309
271
  id
310
- height
311
272
  header {
273
+ height
312
274
  time
313
275
  }
314
276
  transactions {
@@ -366,11 +328,6 @@ var DependentCostFragmentFragmentDoc = gql`
366
328
  `;
367
329
  var GasCostsFragmentFragmentDoc = gql`
368
330
  fragment GasCostsFragment on GasCosts {
369
- version {
370
- ... on Version {
371
- value
372
- }
373
- }
374
331
  add
375
332
  addi
376
333
  aloc
@@ -383,6 +340,7 @@ var GasCostsFragmentFragmentDoc = gql`
383
340
  cb
384
341
  cfei
385
342
  cfsi
343
+ croo
386
344
  div
387
345
  divi
388
346
  ecr1
@@ -465,9 +423,6 @@ var GasCostsFragmentFragmentDoc = gql`
465
423
  ccp {
466
424
  ...DependentCostFragment
467
425
  }
468
- croo {
469
- ...DependentCostFragment
470
- }
471
426
  csiz {
472
427
  ...DependentCostFragment
473
428
  }
@@ -527,11 +482,6 @@ var GasCostsFragmentFragmentDoc = gql`
527
482
  ${DependentCostFragmentFragmentDoc}`;
528
483
  var ConsensusParametersFragmentFragmentDoc = gql`
529
484
  fragment consensusParametersFragment on ConsensusParameters {
530
- version {
531
- ... on Version {
532
- value
533
- }
534
- }
535
485
  txParams {
536
486
  ...TxParametersFragment
537
487
  }
@@ -591,9 +541,18 @@ var NodeInfoFragmentFragmentDoc = gql`
591
541
  fragment nodeInfoFragment on NodeInfo {
592
542
  utxoValidation
593
543
  vmBacktrace
544
+ minGasPrice
594
545
  maxTx
595
546
  maxDepth
596
547
  nodeVersion
548
+ peers {
549
+ id
550
+ addresses
551
+ clientVersion
552
+ blockHeight
553
+ lastHeartbeatMs
554
+ appScore
555
+ }
597
556
  }
598
557
  `;
599
558
  var GetVersionDocument = gql`
@@ -628,9 +587,13 @@ var GetTransactionWithReceiptsDocument = gql`
628
587
  query getTransactionWithReceipts($transactionId: TransactionId!) {
629
588
  transaction(id: $transactionId) {
630
589
  ...transactionFragment
590
+ receipts {
591
+ ...receiptFragment
592
+ }
631
593
  }
632
594
  }
633
- ${TransactionFragmentFragmentDoc}`;
595
+ ${TransactionFragmentFragmentDoc}
596
+ ${ReceiptFragmentFragmentDoc}`;
634
597
  var GetTransactionsDocument = gql`
635
598
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
636
599
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -758,20 +721,6 @@ var GetBalanceDocument = gql`
758
721
  }
759
722
  }
760
723
  ${BalanceFragmentFragmentDoc}`;
761
- var GetLatestGasPriceDocument = gql`
762
- query getLatestGasPrice {
763
- latestGasPrice {
764
- gasPrice
765
- }
766
- }
767
- `;
768
- var EstimateGasPriceDocument = gql`
769
- query estimateGasPrice($blockHorizon: U32!) {
770
- estimateGasPrice(blockHorizon: $blockHorizon) {
771
- gasPrice
772
- }
773
- }
774
- `;
775
724
  var GetBalancesDocument = gql`
776
725
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
777
726
  balances(
@@ -826,12 +775,12 @@ var GetMessageStatusDocument = gql`
826
775
  }
827
776
  `;
828
777
  var DryRunDocument = gql`
829
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
830
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
831
- ...dryRunTransactionExecutionStatusFragment
778
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
779
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
780
+ ...receiptFragment
832
781
  }
833
782
  }
834
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
783
+ ${ReceiptFragmentFragmentDoc}`;
835
784
  var SubmitDocument = gql`
836
785
  mutation submit($encodedTransaction: HexString!) {
837
786
  submit(tx: $encodedTransaction) {
@@ -914,12 +863,6 @@ function getSdk(requester) {
914
863
  getBalance(variables, options) {
915
864
  return requester(GetBalanceDocument, variables, options);
916
865
  },
917
- getLatestGasPrice(variables, options) {
918
- return requester(GetLatestGasPriceDocument, variables, options);
919
- },
920
- estimateGasPrice(variables, options) {
921
- return requester(EstimateGasPriceDocument, variables, options);
922
- },
923
866
  getBalances(variables, options) {
924
867
  return requester(GetBalancesDocument, variables, options);
925
868
  },
@@ -989,14 +932,11 @@ var _FuelGraphqlSubscriber = class {
989
932
  let data;
990
933
  let errors;
991
934
  try {
992
- const sanitizedText = text.replace(/\s/g, "");
993
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
935
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
994
936
  } catch (e) {
995
937
  throw new FuelError(
996
938
  ErrorCode.STREAM_PARSING_ERROR,
997
- `Error while parsing stream data response: ${text}
998
-
999
- Thrown error: ${e}`
939
+ `Error while parsing stream data response: ${text}`
1000
940
  );
1001
941
  }
1002
942
  if (Array.isArray(errors)) {
@@ -1097,7 +1037,7 @@ var inputify = (value) => {
1097
1037
  return {
1098
1038
  type: InputType.Coin,
1099
1039
  txID: hexlify3(arrayify(value.id).slice(0, 32)),
1100
- outputIndex: toNumber(arrayify(value.id).slice(32, 34)),
1040
+ outputIndex: toNumber(arrayify(value.id).slice(32, 33)),
1101
1041
  owner: hexlify3(value.owner),
1102
1042
  amount: bn2(value.amount),
1103
1043
  assetId: hexlify3(value.assetId),
@@ -1106,9 +1046,10 @@ var inputify = (value) => {
1106
1046
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1107
1047
  },
1108
1048
  witnessIndex: value.witnessIndex,
1049
+ maturity: value.maturity ?? 0,
1109
1050
  predicateGasUsed: bn2(value.predicateGasUsed),
1110
- predicateLength: bn2(predicate.length),
1111
- predicateDataLength: bn2(predicateData.length),
1051
+ predicateLength: predicate.length,
1052
+ predicateDataLength: predicateData.length,
1112
1053
  predicate: hexlify3(predicate),
1113
1054
  predicateData: hexlify3(predicateData)
1114
1055
  };
@@ -1139,8 +1080,8 @@ var inputify = (value) => {
1139
1080
  nonce: hexlify3(value.nonce),
1140
1081
  witnessIndex: value.witnessIndex,
1141
1082
  predicateGasUsed: bn2(value.predicateGasUsed),
1142
- predicateLength: bn2(predicate.length),
1143
- predicateDataLength: bn2(predicateData.length),
1083
+ predicateLength: predicate.length,
1084
+ predicateDataLength: predicateData.length,
1144
1085
  predicate: hexlify3(predicate),
1145
1086
  predicateData: hexlify3(predicateData),
1146
1087
  data: hexlify3(data),
@@ -1269,8 +1210,8 @@ function assembleReceiptByType(receipt) {
1269
1210
  case "CALL" /* Call */: {
1270
1211
  const callReceipt = {
1271
1212
  type: ReceiptType.Call,
1272
- from: hexOrZero(receipt.id || receipt.contractId),
1273
- to: hexOrZero(receipt?.to),
1213
+ from: hexOrZero(receipt.contract?.id),
1214
+ to: hexOrZero(receipt?.to?.id),
1274
1215
  amount: bn4(receipt.amount),
1275
1216
  assetId: hexOrZero(receipt.assetId),
1276
1217
  gas: bn4(receipt.gas),
@@ -1284,7 +1225,7 @@ function assembleReceiptByType(receipt) {
1284
1225
  case "RETURN" /* Return */: {
1285
1226
  const returnReceipt = {
1286
1227
  type: ReceiptType.Return,
1287
- id: hexOrZero(receipt.id || receipt.contractId),
1228
+ id: hexOrZero(receipt.contract?.id),
1288
1229
  val: bn4(receipt.val),
1289
1230
  pc: bn4(receipt.pc),
1290
1231
  is: bn4(receipt.is)
@@ -1294,7 +1235,7 @@ function assembleReceiptByType(receipt) {
1294
1235
  case "RETURN_DATA" /* ReturnData */: {
1295
1236
  const returnDataReceipt = {
1296
1237
  type: ReceiptType.ReturnData,
1297
- id: hexOrZero(receipt.id || receipt.contractId),
1238
+ id: hexOrZero(receipt.contract?.id),
1298
1239
  ptr: bn4(receipt.ptr),
1299
1240
  len: bn4(receipt.len),
1300
1241
  digest: hexOrZero(receipt.digest),
@@ -1306,7 +1247,7 @@ function assembleReceiptByType(receipt) {
1306
1247
  case "PANIC" /* Panic */: {
1307
1248
  const panicReceipt = {
1308
1249
  type: ReceiptType.Panic,
1309
- id: hexOrZero(receipt.id),
1250
+ id: hexOrZero(receipt.contract?.id),
1310
1251
  reason: bn4(receipt.reason),
1311
1252
  pc: bn4(receipt.pc),
1312
1253
  is: bn4(receipt.is),
@@ -1317,7 +1258,7 @@ function assembleReceiptByType(receipt) {
1317
1258
  case "REVERT" /* Revert */: {
1318
1259
  const revertReceipt = {
1319
1260
  type: ReceiptType.Revert,
1320
- id: hexOrZero(receipt.id || receipt.contractId),
1261
+ id: hexOrZero(receipt.contract?.id),
1321
1262
  val: bn4(receipt.ra),
1322
1263
  pc: bn4(receipt.pc),
1323
1264
  is: bn4(receipt.is)
@@ -1327,7 +1268,7 @@ function assembleReceiptByType(receipt) {
1327
1268
  case "LOG" /* Log */: {
1328
1269
  const logReceipt = {
1329
1270
  type: ReceiptType.Log,
1330
- id: hexOrZero(receipt.id || receipt.contractId),
1271
+ id: hexOrZero(receipt.contract?.id),
1331
1272
  val0: bn4(receipt.ra),
1332
1273
  val1: bn4(receipt.rb),
1333
1274
  val2: bn4(receipt.rc),
@@ -1340,7 +1281,7 @@ function assembleReceiptByType(receipt) {
1340
1281
  case "LOG_DATA" /* LogData */: {
1341
1282
  const logDataReceipt = {
1342
1283
  type: ReceiptType.LogData,
1343
- id: hexOrZero(receipt.id || receipt.contractId),
1284
+ id: hexOrZero(receipt.contract?.id),
1344
1285
  val0: bn4(receipt.ra),
1345
1286
  val1: bn4(receipt.rb),
1346
1287
  ptr: bn4(receipt.ptr),
@@ -1354,8 +1295,8 @@ function assembleReceiptByType(receipt) {
1354
1295
  case "TRANSFER" /* Transfer */: {
1355
1296
  const transferReceipt = {
1356
1297
  type: ReceiptType.Transfer,
1357
- from: hexOrZero(receipt.id || receipt.contractId),
1358
- to: hexOrZero(receipt.toAddress || receipt?.to),
1298
+ from: hexOrZero(receipt.contract?.id),
1299
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1359
1300
  amount: bn4(receipt.amount),
1360
1301
  assetId: hexOrZero(receipt.assetId),
1361
1302
  pc: bn4(receipt.pc),
@@ -1366,8 +1307,8 @@ function assembleReceiptByType(receipt) {
1366
1307
  case "TRANSFER_OUT" /* TransferOut */: {
1367
1308
  const transferOutReceipt = {
1368
1309
  type: ReceiptType.TransferOut,
1369
- from: hexOrZero(receipt.id || receipt.contractId),
1370
- to: hexOrZero(receipt.toAddress || receipt.to),
1310
+ from: hexOrZero(receipt.contract?.id),
1311
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1371
1312
  amount: bn4(receipt.amount),
1372
1313
  assetId: hexOrZero(receipt.assetId),
1373
1314
  pc: bn4(receipt.pc),
@@ -1410,7 +1351,7 @@ function assembleReceiptByType(receipt) {
1410
1351
  return receiptMessageOut;
1411
1352
  }
1412
1353
  case "MINT" /* Mint */: {
1413
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1354
+ const contractId = hexOrZero(receipt.contract?.id);
1414
1355
  const subId = hexOrZero(receipt.subId);
1415
1356
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1416
1357
  const mintReceipt = {
@@ -1425,7 +1366,7 @@ function assembleReceiptByType(receipt) {
1425
1366
  return mintReceipt;
1426
1367
  }
1427
1368
  case "BURN" /* Burn */: {
1428
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1369
+ const contractId = hexOrZero(receipt.contract?.id);
1429
1370
  const subId = hexOrZero(receipt.subId);
1430
1371
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1431
1372
  const burnReceipt = {
@@ -1510,6 +1451,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1510
1451
  import { bn as bn5 } from "@fuel-ts/math";
1511
1452
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1512
1453
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1454
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1513
1455
  var getGasUsedFromReceipts = (receipts) => {
1514
1456
  const scriptResult = receipts.filter(
1515
1457
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1530,28 +1472,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1530
1472
  }
1531
1473
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1532
1474
  const witnessCache = [];
1533
- const chargeableInputs = inputs.filter((input) => {
1534
- const isCoinOrMessage = "owner" in input || "sender" in input;
1535
- if (isCoinOrMessage) {
1536
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1537
- return true;
1538
- }
1539
- if (!witnessCache.includes(input.witnessIndex)) {
1540
- witnessCache.push(input.witnessIndex);
1541
- return true;
1542
- }
1543
- }
1544
- return false;
1545
- });
1546
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1547
- const totalGas = chargeableInputs.reduce((total, input) => {
1475
+ const totalGas = inputs.reduce((total, input) => {
1548
1476
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1549
1477
  return total.add(
1550
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1478
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1551
1479
  );
1552
1480
  }
1553
- return total.add(gasCosts.ecr1);
1554
- }, bn5(0));
1481
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1482
+ witnessCache.push(input.witnessIndex);
1483
+ return total.add(gasCosts.ecr1);
1484
+ }
1485
+ return total;
1486
+ }, bn5());
1555
1487
  return totalGas;
1556
1488
  }
1557
1489
  function getMinGas(params) {
@@ -1563,20 +1495,12 @@ function getMinGas(params) {
1563
1495
  return minGas;
1564
1496
  }
1565
1497
  function getMaxGas(params) {
1566
- const {
1567
- gasPerByte,
1568
- witnessesLength,
1569
- witnessLimit,
1570
- minGas,
1571
- gasLimit = bn5(0),
1572
- maxGasPerTx
1573
- } = params;
1498
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1574
1499
  let remainingAllowedWitnessGas = bn5(0);
1575
1500
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1576
1501
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1577
1502
  }
1578
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1579
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1503
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1580
1504
  }
1581
1505
  function calculateMetadataGasForTxCreate({
1582
1506
  gasCosts,
@@ -1598,10 +1522,6 @@ function calculateMetadataGasForTxScript({
1598
1522
  }) {
1599
1523
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1600
1524
  }
1601
- var calculateGasFee = (params) => {
1602
- const { gas, gasPrice, priceFactor, tip } = params;
1603
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1604
- };
1605
1525
 
1606
1526
  // src/providers/utils/json.ts
1607
1527
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1758,7 +1678,7 @@ var witnessify = (value) => {
1758
1678
  // src/providers/transaction-request/transaction-request.ts
1759
1679
  var BaseTransactionRequest = class {
1760
1680
  /** Gas price for transaction */
1761
- tip;
1681
+ gasPrice;
1762
1682
  /** Block until which tx cannot be included */
1763
1683
  maturity;
1764
1684
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1777,7 +1697,7 @@ var BaseTransactionRequest = class {
1777
1697
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1778
1698
  */
1779
1699
  constructor({
1780
- tip,
1700
+ gasPrice,
1781
1701
  maturity,
1782
1702
  maxFee,
1783
1703
  witnessLimit,
@@ -1785,7 +1705,7 @@ var BaseTransactionRequest = class {
1785
1705
  outputs,
1786
1706
  witnesses
1787
1707
  } = {}) {
1788
- this.tip = bn7(tip);
1708
+ this.gasPrice = bn7(gasPrice);
1789
1709
  this.maturity = maturity ?? 0;
1790
1710
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1791
1711
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
@@ -1796,9 +1716,9 @@ var BaseTransactionRequest = class {
1796
1716
  static getPolicyMeta(req) {
1797
1717
  let policyTypes = 0;
1798
1718
  const policies = [];
1799
- if (req.tip) {
1800
- policyTypes += PolicyType.Tip;
1801
- policies.push({ data: req.tip, type: PolicyType.Tip });
1719
+ if (req.gasPrice) {
1720
+ policyTypes += PolicyType.GasPrice;
1721
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1802
1722
  }
1803
1723
  if (req.witnessLimit) {
1804
1724
  policyTypes += PolicyType.WitnessLimit;
@@ -1985,10 +1905,10 @@ var BaseTransactionRequest = class {
1985
1905
  * @param predicate - Predicate bytes.
1986
1906
  * @param predicateData - Predicate data bytes.
1987
1907
  */
1988
- addCoinInput(coin) {
1908
+ addCoinInput(coin, predicate) {
1989
1909
  const { assetId, owner, amount } = coin;
1990
1910
  let witnessIndex;
1991
- if (coin.predicate) {
1911
+ if (predicate) {
1992
1912
  witnessIndex = 0;
1993
1913
  } else {
1994
1914
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2003,7 +1923,9 @@ var BaseTransactionRequest = class {
2003
1923
  amount,
2004
1924
  assetId,
2005
1925
  txPointer: "0x00000000000000000000000000000000",
2006
- witnessIndex
1926
+ witnessIndex,
1927
+ predicate: predicate?.bytes,
1928
+ predicateData: predicate?.predicateDataBytes
2007
1929
  };
2008
1930
  this.pushInput(input);
2009
1931
  this.addChangeOutput(owner, assetId);
@@ -2016,11 +1938,11 @@ var BaseTransactionRequest = class {
2016
1938
  * @param predicate - Predicate bytes.
2017
1939
  * @param predicateData - Predicate data bytes.
2018
1940
  */
2019
- addMessageInput(message) {
1941
+ addMessageInput(message, predicate) {
2020
1942
  const { recipient, sender, amount } = message;
2021
1943
  const assetId = BaseAssetId2;
2022
1944
  let witnessIndex;
2023
- if (message.predicate) {
1945
+ if (predicate) {
2024
1946
  witnessIndex = 0;
2025
1947
  } else {
2026
1948
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2034,7 +1956,9 @@ var BaseTransactionRequest = class {
2034
1956
  sender: sender.toB256(),
2035
1957
  recipient: recipient.toB256(),
2036
1958
  amount,
2037
- witnessIndex
1959
+ witnessIndex,
1960
+ predicate: predicate?.bytes,
1961
+ predicateData: predicate?.predicateDataBytes
2038
1962
  };
2039
1963
  this.pushInput(input);
2040
1964
  this.addChangeOutput(recipient, assetId);
@@ -2065,6 +1989,32 @@ var BaseTransactionRequest = class {
2065
1989
  resources.forEach((resource) => this.addResource(resource));
2066
1990
  return this;
2067
1991
  }
1992
+ /**
1993
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1994
+ * outputs from the related assetIds.
1995
+ *
1996
+ * @param resources - The resources to add.
1997
+ * @returns This transaction.
1998
+ */
1999
+ addPredicateResource(resource, predicate) {
2000
+ if (isCoin(resource)) {
2001
+ this.addCoinInput(resource, predicate);
2002
+ } else {
2003
+ this.addMessageInput(resource, predicate);
2004
+ }
2005
+ return this;
2006
+ }
2007
+ /**
2008
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2009
+ * from the related assetIds.
2010
+ *
2011
+ * @param resources - The resources to add.
2012
+ * @returns This transaction.
2013
+ */
2014
+ addPredicateResources(resources, predicate) {
2015
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2016
+ return this;
2017
+ }
2068
2018
  /**
2069
2019
  * Adds a coin output to the transaction.
2070
2020
  *
@@ -2144,7 +2094,7 @@ var BaseTransactionRequest = class {
2144
2094
  }
2145
2095
  calculateMaxGas(chainInfo, minGas) {
2146
2096
  const { consensusParameters } = chainInfo;
2147
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2097
+ const { gasPerByte } = consensusParameters;
2148
2098
  const witnessesLength = this.toTransaction().witnesses.reduce(
2149
2099
  (acc, wit) => acc + wit.dataLength,
2150
2100
  0
@@ -2153,8 +2103,7 @@ var BaseTransactionRequest = class {
2153
2103
  gasPerByte,
2154
2104
  minGas,
2155
2105
  witnessesLength,
2156
- witnessLimit: this.witnessLimit,
2157
- maxGasPerTx
2106
+ witnessLimit: this.witnessLimit
2158
2107
  });
2159
2108
  }
2160
2109
  /**
@@ -2172,20 +2121,17 @@ var BaseTransactionRequest = class {
2172
2121
  });
2173
2122
  const updateAssetInput = (assetId, quantity) => {
2174
2123
  const assetInput = findAssetInput(assetId);
2175
- let usedQuantity = quantity;
2176
- if (assetId === BaseAssetId2) {
2177
- usedQuantity = bn7("1000000000000000000");
2178
- }
2179
2124
  if (assetInput && "assetId" in assetInput) {
2180
- assetInput.id = hexlify7(randomBytes(34));
2181
- assetInput.amount = usedQuantity;
2125
+ assetInput.id = hexlify7(randomBytes(33));
2126
+ assetInput.amount = quantity;
2182
2127
  } else {
2183
2128
  this.addResources([
2184
2129
  {
2185
- id: hexlify7(randomBytes(34)),
2186
- amount: usedQuantity,
2130
+ id: hexlify7(randomBytes(33)),
2131
+ amount: quantity,
2187
2132
  assetId,
2188
2133
  owner: resourcesOwner || Address.fromRandom(),
2134
+ maturity: 0,
2189
2135
  blockCreated: bn7(1),
2190
2136
  txCreatedIdx: bn7(1)
2191
2137
  }
@@ -2217,7 +2163,7 @@ var BaseTransactionRequest = class {
2217
2163
  toJSON() {
2218
2164
  return normalizeJSON(this);
2219
2165
  }
2220
- updatePredicateGasUsed(inputs) {
2166
+ updatePredicateInputs(inputs) {
2221
2167
  this.inputs.forEach((i) => {
2222
2168
  let correspondingInput;
2223
2169
  switch (i.type) {
@@ -2239,15 +2185,6 @@ var BaseTransactionRequest = class {
2239
2185
  }
2240
2186
  });
2241
2187
  }
2242
- shiftPredicateData() {
2243
- this.inputs.forEach((input) => {
2244
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2245
- input.predicateData = input.paddPredicateData(
2246
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2247
- );
2248
- }
2249
- });
2250
- }
2251
2188
  };
2252
2189
 
2253
2190
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2394,8 +2331,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2394
2331
  return {
2395
2332
  type: TransactionType3.Create,
2396
2333
  ...baseTransaction,
2334
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2397
2335
  bytecodeWitnessIndex,
2398
- storageSlotsCount: bn9(storageSlots.length),
2336
+ storageSlotsCount: storageSlots.length,
2399
2337
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2400
2338
  storageSlots
2401
2339
  };
@@ -2518,8 +2456,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2518
2456
  type: TransactionType4.Script,
2519
2457
  scriptGasLimit: this.gasLimit,
2520
2458
  ...super.getBaseTransaction(),
2521
- scriptLength: bn10(script.length),
2522
- scriptDataLength: bn10(scriptData.length),
2459
+ scriptLength: script.length,
2460
+ scriptDataLength: scriptData.length,
2523
2461
  receiptsRoot: ZeroBytes327,
2524
2462
  script: hexlify10(script),
2525
2463
  scriptData: hexlify10(scriptData)
@@ -2583,7 +2521,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2583
2521
  }
2584
2522
  calculateMaxGas(chainInfo, minGas) {
2585
2523
  const { consensusParameters } = chainInfo;
2586
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2524
+ const { gasPerByte } = consensusParameters;
2587
2525
  const witnessesLength = this.toTransaction().witnesses.reduce(
2588
2526
  (acc, wit) => acc + wit.dataLength,
2589
2527
  0
@@ -2593,8 +2531,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2593
2531
  minGas,
2594
2532
  witnessesLength,
2595
2533
  witnessLimit: this.witnessLimit,
2596
- gasLimit: this.gasLimit,
2597
- maxGasPerTx
2534
+ gasLimit: this.gasLimit
2598
2535
  });
2599
2536
  }
2600
2537
  /**
@@ -2651,7 +2588,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2651
2588
 
2652
2589
  // src/providers/transaction-request/utils.ts
2653
2590
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2654
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2591
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2655
2592
  var transactionRequestify = (obj) => {
2656
2593
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2657
2594
  return obj;
@@ -2669,31 +2606,14 @@ var transactionRequestify = (obj) => {
2669
2606
  }
2670
2607
  }
2671
2608
  };
2672
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2673
- (acc, input) => {
2674
- if (input.type === InputType5.Coin && input.owner === owner) {
2675
- acc.utxos.push(input.id);
2676
- }
2677
- if (input.type === InputType5.Message && input.recipient === owner) {
2678
- acc.messages.push(input.nonce);
2679
- }
2680
- return acc;
2681
- },
2682
- {
2683
- utxos: [],
2684
- messages: []
2685
- }
2686
- );
2687
2609
 
2688
2610
  // src/providers/transaction-response/transaction-response.ts
2689
2611
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2690
- import { bn as bn15 } from "@fuel-ts/math";
2612
+ import { bn as bn14 } from "@fuel-ts/math";
2691
2613
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2692
2614
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2693
2615
 
2694
2616
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2695
- import { bn as bn14 } from "@fuel-ts/math";
2696
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2697
2617
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2698
2618
 
2699
2619
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2702,10 +2622,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2702
2622
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2703
2623
  var calculateTransactionFee = (params) => {
2704
2624
  const {
2705
- gasPrice,
2625
+ gasUsed,
2706
2626
  rawPayload,
2707
- tip,
2708
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2627
+ consensusParameters: { gasCosts, feeParams }
2709
2628
  } = params;
2710
2629
  const gasPerByte = bn11(feeParams.gasPerByte);
2711
2630
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2715,7 +2634,8 @@ var calculateTransactionFee = (params) => {
2715
2634
  return {
2716
2635
  fee: bn11(0),
2717
2636
  minFee: bn11(0),
2718
- maxFee: bn11(0)
2637
+ maxFee: bn11(0),
2638
+ feeFromGasUsed: bn11(0)
2719
2639
  };
2720
2640
  }
2721
2641
  const { type, witnesses, inputs, policies } = transaction;
@@ -2747,6 +2667,7 @@ var calculateTransactionFee = (params) => {
2747
2667
  metadataGas,
2748
2668
  txBytesSize: transactionBytes.length
2749
2669
  });
2670
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2750
2671
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2751
2672
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2752
2673
  const maxGas = getMaxGas({
@@ -2754,25 +2675,17 @@ var calculateTransactionFee = (params) => {
2754
2675
  minGas,
2755
2676
  witnessesLength,
2756
2677
  gasLimit,
2757
- witnessLimit,
2758
- maxGasPerTx
2759
- });
2760
- const minFee = calculateGasFee({
2761
- gasPrice,
2762
- gas: minGas,
2763
- priceFactor: gasPriceFactor,
2764
- tip
2765
- });
2766
- const maxFee = calculateGasFee({
2767
- gasPrice,
2768
- gas: maxGas,
2769
- priceFactor: gasPriceFactor,
2770
- tip
2678
+ witnessLimit
2771
2679
  });
2680
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2681
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2682
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2683
+ const fee = minFee.add(feeFromGasUsed);
2772
2684
  return {
2685
+ fee,
2773
2686
  minFee,
2774
2687
  maxFee,
2775
- fee: maxFee
2688
+ feeFromGasUsed
2776
2689
  };
2777
2690
  };
2778
2691
 
@@ -2828,7 +2741,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2828
2741
 
2829
2742
  // src/providers/transaction-summary/input.ts
2830
2743
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2831
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2744
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2832
2745
  function getInputsByTypes(inputs, types) {
2833
2746
  return inputs.filter((i) => types.includes(i.type));
2834
2747
  }
@@ -2836,16 +2749,16 @@ function getInputsByType(inputs, type) {
2836
2749
  return inputs.filter((i) => i.type === type);
2837
2750
  }
2838
2751
  function getInputsCoin(inputs) {
2839
- return getInputsByType(inputs, InputType6.Coin);
2752
+ return getInputsByType(inputs, InputType5.Coin);
2840
2753
  }
2841
2754
  function getInputsMessage(inputs) {
2842
- return getInputsByType(inputs, InputType6.Message);
2755
+ return getInputsByType(inputs, InputType5.Message);
2843
2756
  }
2844
2757
  function getInputsCoinAndMessage(inputs) {
2845
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2758
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2846
2759
  }
2847
2760
  function getInputsContract(inputs) {
2848
- return getInputsByType(inputs, InputType6.Contract);
2761
+ return getInputsByType(inputs, InputType5.Contract);
2849
2762
  }
2850
2763
  function getInputFromAssetId(inputs, assetId) {
2851
2764
  const coinInputs = getInputsCoin(inputs);
@@ -2864,7 +2777,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2864
2777
  if (!contractInput) {
2865
2778
  return void 0;
2866
2779
  }
2867
- if (contractInput.type !== InputType6.Contract) {
2780
+ if (contractInput.type !== InputType5.Contract) {
2868
2781
  throw new FuelError9(
2869
2782
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2870
2783
  `Contract input should be of type 'contract'.`
@@ -2873,10 +2786,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2873
2786
  return contractInput;
2874
2787
  }
2875
2788
  function getInputAccountAddress(input) {
2876
- if (input.type === InputType6.Coin) {
2789
+ if (input.type === InputType5.Coin) {
2877
2790
  return input.owner.toString();
2878
2791
  }
2879
- if (input.type === InputType6.Message) {
2792
+ if (input.type === InputType5.Message) {
2880
2793
  return input.recipient.toString();
2881
2794
  }
2882
2795
  return "";
@@ -3386,9 +3299,7 @@ function assembleTransactionSummary(params) {
3386
3299
  gqlTransactionStatus,
3387
3300
  abiMap = {},
3388
3301
  maxInputs,
3389
- gasCosts,
3390
- maxGasPerTx,
3391
- gasPrice
3302
+ gasCosts
3392
3303
  } = params;
3393
3304
  const gasUsed = getGasUsedFromReceipts(receipts);
3394
3305
  const rawPayload = hexlify11(transactionBytes);
@@ -3402,14 +3313,11 @@ function assembleTransactionSummary(params) {
3402
3313
  maxInputs
3403
3314
  });
3404
3315
  const typeName = getTransactionTypeName(transaction.type);
3405
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3406
3316
  const { fee } = calculateTransactionFee({
3407
- gasPrice,
3317
+ gasUsed,
3408
3318
  rawPayload,
3409
- tip,
3410
3319
  consensusParameters: {
3411
3320
  gasCosts,
3412
- maxGasPerTx,
3413
3321
  feeParams: {
3414
3322
  gasPerByte,
3415
3323
  gasPriceFactor
@@ -3469,7 +3377,7 @@ var TransactionResponse = class {
3469
3377
  /** Current provider */
3470
3378
  provider;
3471
3379
  /** Gas used on the transaction */
3472
- gasUsed = bn15(0);
3380
+ gasUsed = bn14(0);
3473
3381
  /** The graphql Transaction with receipts object. */
3474
3382
  gqlTransaction;
3475
3383
  abis;
@@ -3547,13 +3455,8 @@ var TransactionResponse = class {
3547
3455
  const decodedTransaction = this.decodeTransaction(
3548
3456
  transaction
3549
3457
  );
3550
- let txReceipts = [];
3551
- if (transaction?.status && "receipts" in transaction.status) {
3552
- txReceipts = transaction.status.receipts;
3553
- }
3554
- const receipts = txReceipts.map(processGqlReceipt) || [];
3555
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3556
- const gasPrice = await this.provider.getLatestGasPrice();
3458
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3459
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3557
3460
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3558
3461
  const transactionSummary = assembleTransactionSummary({
3559
3462
  id: this.id,
@@ -3565,9 +3468,7 @@ var TransactionResponse = class {
3565
3468
  gasPriceFactor,
3566
3469
  abiMap: contractsAbiMap,
3567
3470
  maxInputs,
3568
- gasCosts,
3569
- maxGasPerTx,
3570
- gasPrice
3471
+ gasCosts
3571
3472
  });
3572
3473
  return transactionSummary;
3573
3474
  }
@@ -3694,29 +3595,29 @@ var processGqlChain = (chain) => {
3694
3595
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3695
3596
  return {
3696
3597
  name,
3697
- baseChainHeight: bn16(daHeight),
3598
+ baseChainHeight: bn15(daHeight),
3698
3599
  consensusParameters: {
3699
- contractMaxSize: bn16(contractParams.contractMaxSize),
3700
- maxInputs: bn16(txParams.maxInputs),
3701
- maxOutputs: bn16(txParams.maxOutputs),
3702
- maxWitnesses: bn16(txParams.maxWitnesses),
3703
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3704
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3705
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3706
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3707
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3708
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3709
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3710
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3711
- gasPerByte: bn16(feeParams.gasPerByte),
3712
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3713
- chainId: bn16(consensusParameters.chainId),
3600
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3601
+ maxInputs: bn15(txParams.maxInputs),
3602
+ maxOutputs: bn15(txParams.maxOutputs),
3603
+ maxWitnesses: bn15(txParams.maxWitnesses),
3604
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3605
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3606
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3607
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3608
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3609
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3610
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3611
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3612
+ gasPerByte: bn15(feeParams.gasPerByte),
3613
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3614
+ chainId: bn15(consensusParameters.chainId),
3714
3615
  gasCosts
3715
3616
  },
3716
3617
  gasCosts,
3717
3618
  latestBlock: {
3718
3619
  id: latestBlock.id,
3719
- height: bn16(latestBlock.height),
3620
+ height: bn15(latestBlock.header.height),
3720
3621
  time: latestBlock.header.time,
3721
3622
  transactions: latestBlock.transactions.map((i) => ({
3722
3623
  id: i.id
@@ -3810,8 +3711,10 @@ var _Provider = class {
3810
3711
  * Returns some helpful parameters related to gas fees.
3811
3712
  */
3812
3713
  getGasConfig() {
3714
+ const { minGasPrice } = this.getNode();
3813
3715
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3814
3716
  return {
3717
+ minGasPrice,
3815
3718
  maxGasPerTx,
3816
3719
  maxGasPerPredicate,
3817
3720
  gasPriceFactor,
@@ -3909,7 +3812,7 @@ var _Provider = class {
3909
3812
  */
3910
3813
  async getBlockNumber() {
3911
3814
  const { chain } = await this.operations.getChain();
3912
- return bn16(chain.latestBlock.height, 10);
3815
+ return bn15(chain.latestBlock.header.height, 10);
3913
3816
  }
3914
3817
  /**
3915
3818
  * Returns the chain information.
@@ -3919,11 +3822,13 @@ var _Provider = class {
3919
3822
  async fetchNode() {
3920
3823
  const { nodeInfo } = await this.operations.getNodeInfo();
3921
3824
  const processedNodeInfo = {
3922
- maxDepth: bn16(nodeInfo.maxDepth),
3923
- maxTx: bn16(nodeInfo.maxTx),
3825
+ maxDepth: bn15(nodeInfo.maxDepth),
3826
+ maxTx: bn15(nodeInfo.maxTx),
3827
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3924
3828
  nodeVersion: nodeInfo.nodeVersion,
3925
3829
  utxoValidation: nodeInfo.utxoValidation,
3926
- vmBacktrace: nodeInfo.vmBacktrace
3830
+ vmBacktrace: nodeInfo.vmBacktrace,
3831
+ peers: nodeInfo.peers
3927
3832
  };
3928
3833
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3929
3834
  return processedNodeInfo;
@@ -4009,13 +3914,14 @@ var _Provider = class {
4009
3914
  return this.estimateTxDependencies(transactionRequest);
4010
3915
  }
4011
3916
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4012
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4013
- encodedTransactions: encodedTransaction,
3917
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3918
+ encodedTransaction,
4014
3919
  utxoValidation: utxoValidation || false
4015
3920
  });
4016
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4017
- const receipts = rawReceipts.map(processGqlReceipt);
4018
- return { receipts, dryrunStatus: status };
3921
+ const receipts = gqlReceipts.map(processGqlReceipt);
3922
+ return {
3923
+ receipts
3924
+ };
4019
3925
  }
4020
3926
  /**
4021
3927
  * Verifies whether enough gas is available to complete transaction.
@@ -4041,7 +3947,7 @@ var _Provider = class {
4041
3947
  } = response;
4042
3948
  if (inputs) {
4043
3949
  inputs.forEach((input, index) => {
4044
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3950
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
4045
3951
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4046
3952
  }
4047
3953
  });
@@ -4054,6 +3960,9 @@ var _Provider = class {
4054
3960
  * If there are missing variable outputs,
4055
3961
  * `addVariableOutputs` is called on the transaction.
4056
3962
  *
3963
+ * @privateRemarks
3964
+ * TODO: Investigate support for missing contract IDs
3965
+ * TODO: Add support for missing output messages
4057
3966
  *
4058
3967
  * @param transactionRequest - The transaction request object.
4059
3968
  * @returns A promise.
@@ -4066,19 +3975,16 @@ var _Provider = class {
4066
3975
  missingContractIds: []
4067
3976
  };
4068
3977
  }
3978
+ await this.estimatePredicates(transactionRequest);
4069
3979
  let receipts = [];
4070
3980
  const missingContractIds = [];
4071
3981
  let outputVariables = 0;
4072
- let dryrunStatus;
4073
3982
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4074
- const {
4075
- dryRun: [{ receipts: rawReceipts, status }]
4076
- } = await this.operations.dryRun({
4077
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3983
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3984
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
4078
3985
  utxoValidation: false
4079
3986
  });
4080
- receipts = rawReceipts.map(processGqlReceipt);
4081
- dryrunStatus = status;
3987
+ receipts = gqlReceipts.map(processGqlReceipt);
4082
3988
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4083
3989
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4084
3990
  if (hasMissingOutputs) {
@@ -4088,11 +3994,6 @@ var _Provider = class {
4088
3994
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
4089
3995
  missingContractIds.push(contractId);
4090
3996
  });
4091
- const { maxFee } = await this.estimateTxGasAndFee({
4092
- transactionRequest,
4093
- optimizeGas: false
4094
- });
4095
- transactionRequest.maxFee = maxFee;
4096
3997
  } else {
4097
3998
  break;
4098
3999
  }
@@ -4100,133 +4001,38 @@ var _Provider = class {
4100
4001
  return {
4101
4002
  receipts,
4102
4003
  outputVariables,
4103
- missingContractIds,
4104
- dryrunStatus
4004
+ missingContractIds
4105
4005
  };
4106
4006
  }
4107
4007
  /**
4108
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4109
- *
4110
- * Transactions are dry run in batches. After each dry run, transactions requiring
4111
- * further modifications are identified. The method iteratively updates these transactions
4112
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4113
- *
4114
- * @param transactionRequests - Array of transaction request objects.
4115
- * @returns A promise that resolves to an array of results for each transaction.
4008
+ * Estimates the transaction gas and fee based on the provided transaction request.
4009
+ * @param transactionRequest - The transaction request object.
4010
+ * @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
4011
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4116
4012
  */
4117
- async estimateMultipleTxDependencies(transactionRequests) {
4118
- const results = transactionRequests.map(() => ({
4119
- receipts: [],
4120
- outputVariables: 0,
4121
- missingContractIds: [],
4122
- dryrunStatus: void 0
4123
- }));
4124
- const allRequests = clone3(transactionRequests);
4125
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4126
- allRequests.forEach((req, index) => {
4127
- if (req.type === TransactionType8.Script) {
4128
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4129
- }
4130
- });
4131
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4132
- let attempt = 0;
4133
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4134
- const encodedTransactions = transactionsToProcess.map(
4135
- (index) => serializedTransactionsMap.get(index)
4136
- );
4137
- const dryRunResults = await this.operations.dryRun({
4138
- encodedTransactions,
4139
- utxoValidation: false
4140
- });
4141
- const nextRoundTransactions = [];
4142
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4143
- const currentResultIndex = transactionsToProcess[i];
4144
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4145
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4146
- results[currentResultIndex].dryrunStatus = status;
4147
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4148
- results[currentResultIndex].receipts
4149
- );
4150
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4151
- const requestToProcess = allRequests[currentResultIndex];
4152
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4153
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4154
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4155
- missingOutputContractIds.forEach(({ contractId }) => {
4156
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4157
- results[currentResultIndex].missingContractIds.push(contractId);
4158
- });
4159
- const { maxFee } = await this.estimateTxGasAndFee({
4160
- transactionRequest: requestToProcess,
4161
- optimizeGas: false
4162
- });
4163
- requestToProcess.maxFee = maxFee;
4164
- serializedTransactionsMap.set(
4165
- currentResultIndex,
4166
- hexlify12(requestToProcess.toTransactionBytes())
4167
- );
4168
- nextRoundTransactions.push(currentResultIndex);
4169
- allRequests[currentResultIndex] = requestToProcess;
4170
- }
4171
- }
4172
- transactionsToProcess = nextRoundTransactions;
4173
- attempt += 1;
4174
- }
4175
- return results;
4176
- }
4177
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4178
- if (estimateTxDependencies) {
4179
- return this.estimateMultipleTxDependencies(transactionRequests);
4180
- }
4181
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4182
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4183
- encodedTransactions,
4184
- utxoValidation: utxoValidation || false
4185
- });
4186
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4187
- const receipts = rawReceipts.map(processGqlReceipt);
4188
- return { receipts, dryrunStatus: status };
4189
- });
4190
- return results;
4191
- }
4192
- async estimateTxGasAndFee(params) {
4193
- const { transactionRequest, optimizeGas = true } = params;
4194
- let { gasPrice } = params;
4013
+ estimateTxGasAndFee(params) {
4014
+ const { transactionRequest } = params;
4015
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4195
4016
  const chainInfo = this.getChain();
4196
- const { gasPriceFactor } = this.getGasConfig();
4017
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4018
+ transactionRequest.gasPrice = gasPrice;
4197
4019
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4198
- if (!gasPrice) {
4199
- gasPrice = await this.estimateGasPrice(10);
4200
- }
4201
- const minFee = calculateGasFee({
4202
- gasPrice: bn16(gasPrice),
4203
- gas: minGas,
4204
- priceFactor: gasPriceFactor,
4205
- tip: transactionRequest.tip
4206
- }).add(1);
4207
- let gasLimit = bn16(0);
4020
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4208
4021
  if (transactionRequest.type === TransactionType8.Script) {
4209
- gasLimit = transactionRequest.gasLimit;
4210
- if (!optimizeGas) {
4022
+ if (transactionRequest.gasLimit.eq(0)) {
4211
4023
  transactionRequest.gasLimit = minGas;
4212
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4213
- transactionRequest.gasLimit = gasLimit;
4024
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4025
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4026
+ );
4214
4027
  }
4215
4028
  }
4216
4029
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4217
- const maxFee = calculateGasFee({
4218
- gasPrice: bn16(gasPrice),
4219
- gas: maxGas,
4220
- priceFactor: gasPriceFactor,
4221
- tip: transactionRequest.tip
4222
- }).add(1);
4030
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4223
4031
  return {
4224
4032
  minGas,
4225
4033
  minFee,
4226
4034
  maxGas,
4227
- maxFee,
4228
- gasPrice,
4229
- gasLimit
4035
+ maxFee
4230
4036
  };
4231
4037
  }
4232
4038
  /**
@@ -4244,17 +4050,15 @@ var _Provider = class {
4244
4050
  if (estimateTxDependencies) {
4245
4051
  return this.estimateTxDependencies(transactionRequest);
4246
4052
  }
4247
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4248
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4249
- encodedTransactions,
4053
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4054
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4055
+ encodedTransaction,
4250
4056
  utxoValidation: true
4251
4057
  });
4252
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4253
- const { id, receipts, status } = dryRunStatus;
4254
- const processedReceipts = receipts.map(processGqlReceipt);
4255
- return { id, receipts: processedReceipts, status };
4256
- });
4257
- return { receipts: callResult[0].receipts };
4058
+ const receipts = gqlReceipts.map(processGqlReceipt);
4059
+ return {
4060
+ receipts
4061
+ };
4258
4062
  }
4259
4063
  /**
4260
4064
  * Returns a transaction cost to enable user
@@ -4271,80 +4075,77 @@ var _Provider = class {
4271
4075
  * @param tolerance - The tolerance to add on top of the gasUsed.
4272
4076
  * @returns A promise that resolves to the transaction cost object.
4273
4077
  */
4274
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4078
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4079
+ estimateTxDependencies = true,
4080
+ estimatePredicates = true,
4081
+ resourcesOwner,
4082
+ signatureCallback
4083
+ } = {}) {
4275
4084
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4085
+ const { minGasPrice } = this.getGasConfig();
4086
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4276
4087
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4277
4088
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4278
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4089
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4279
4090
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4280
- txRequestClone.maxFee = bn16(0);
4281
4091
  if (isScriptTransaction) {
4282
- txRequestClone.gasLimit = bn16(0);
4092
+ txRequestClone.gasLimit = bn15(0);
4283
4093
  }
4284
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4285
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4094
+ if (estimatePredicates) {
4095
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4096
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4097
+ }
4098
+ await this.estimatePredicates(txRequestClone);
4286
4099
  }
4287
- const signedRequest = clone3(txRequestClone);
4288
- let addedSignatures = 0;
4289
4100
  if (signatureCallback && isScriptTransaction) {
4290
- const lengthBefore = signedRequest.witnesses.length;
4291
- await signatureCallback(signedRequest);
4292
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4293
- }
4294
- await this.estimatePredicates(signedRequest);
4295
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4296
- transactionRequest: signedRequest,
4297
- optimizeGas: false
4101
+ await signatureCallback(txRequestClone);
4102
+ }
4103
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4104
+ transactionRequest: txRequestClone
4298
4105
  });
4299
- txRequestClone.maxFee = maxFee;
4300
4106
  let receipts = [];
4301
4107
  let missingContractIds = [];
4302
4108
  let outputVariables = 0;
4303
- let gasUsed = bn16(0);
4304
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4305
- if (isScriptTransaction) {
4306
- if (signatureCallback) {
4307
- await signatureCallback(txRequestClone);
4308
- }
4309
- txRequestClone.gasLimit = gasLimit;
4109
+ let gasUsed = bn15(0);
4110
+ if (isScriptTransaction && estimateTxDependencies) {
4111
+ txRequestClone.gasPrice = bn15(0);
4310
4112
  const result = await this.estimateTxDependencies(txRequestClone);
4311
4113
  receipts = result.receipts;
4312
4114
  outputVariables = result.outputVariables;
4313
4115
  missingContractIds = result.missingContractIds;
4314
- gasUsed = getGasUsedFromReceipts(receipts);
4116
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4315
4117
  txRequestClone.gasLimit = gasUsed;
4316
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4317
- transactionRequest: txRequestClone,
4318
- gasPrice
4118
+ txRequestClone.gasPrice = setGasPrice;
4119
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4120
+ transactionRequest: txRequestClone
4319
4121
  }));
4320
4122
  }
4321
4123
  return {
4322
4124
  requiredQuantities: allQuantities,
4323
4125
  receipts,
4324
4126
  gasUsed,
4325
- gasPrice,
4127
+ minGasPrice,
4128
+ gasPrice: setGasPrice,
4326
4129
  minGas,
4327
4130
  maxGas,
4328
4131
  minFee,
4329
4132
  maxFee,
4133
+ estimatedInputs: txRequestClone.inputs,
4330
4134
  outputVariables,
4331
- missingContractIds,
4332
- addedSignatures,
4333
- estimatedPredicates: txRequestClone.inputs
4135
+ missingContractIds
4334
4136
  };
4335
4137
  }
4336
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4138
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4337
4139
  const ownerAddress = Address2.fromAddressOrString(owner);
4338
4140
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4339
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4340
- quantitiesToContract
4341
- });
4141
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4342
4142
  transactionRequest.addResources(
4343
4143
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4344
4144
  );
4345
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4346
- quantitiesToContract
4347
- });
4145
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4146
+ transactionRequest,
4147
+ forwardingQuantities
4148
+ );
4348
4149
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4349
4150
  return {
4350
4151
  resources,
@@ -4366,10 +4167,11 @@ var _Provider = class {
4366
4167
  return coins.map((coin) => ({
4367
4168
  id: coin.utxoId,
4368
4169
  assetId: coin.assetId,
4369
- amount: bn16(coin.amount),
4170
+ amount: bn15(coin.amount),
4370
4171
  owner: Address2.fromAddressOrString(coin.owner),
4371
- blockCreated: bn16(coin.blockCreated),
4372
- txCreatedIdx: bn16(coin.txCreatedIdx)
4172
+ maturity: bn15(coin.maturity).toNumber(),
4173
+ blockCreated: bn15(coin.blockCreated),
4174
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4373
4175
  }));
4374
4176
  }
4375
4177
  /**
@@ -4406,9 +4208,9 @@ var _Provider = class {
4406
4208
  switch (coin.__typename) {
4407
4209
  case "MessageCoin":
4408
4210
  return {
4409
- amount: bn16(coin.amount),
4211
+ amount: bn15(coin.amount),
4410
4212
  assetId: coin.assetId,
4411
- daHeight: bn16(coin.daHeight),
4213
+ daHeight: bn15(coin.daHeight),
4412
4214
  sender: Address2.fromAddressOrString(coin.sender),
4413
4215
  recipient: Address2.fromAddressOrString(coin.recipient),
4414
4216
  nonce: coin.nonce
@@ -4416,11 +4218,12 @@ var _Provider = class {
4416
4218
  case "Coin":
4417
4219
  return {
4418
4220
  id: coin.utxoId,
4419
- amount: bn16(coin.amount),
4221
+ amount: bn15(coin.amount),
4420
4222
  assetId: coin.assetId,
4421
4223
  owner: Address2.fromAddressOrString(coin.owner),
4422
- blockCreated: bn16(coin.blockCreated),
4423
- txCreatedIdx: bn16(coin.txCreatedIdx)
4224
+ maturity: bn15(coin.maturity).toNumber(),
4225
+ blockCreated: bn15(coin.blockCreated),
4226
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4424
4227
  };
4425
4228
  default:
4426
4229
  return null;
@@ -4437,13 +4240,13 @@ var _Provider = class {
4437
4240
  async getBlock(idOrHeight) {
4438
4241
  let variables;
4439
4242
  if (typeof idOrHeight === "number") {
4440
- variables = { height: bn16(idOrHeight).toString(10) };
4243
+ variables = { height: bn15(idOrHeight).toString(10) };
4441
4244
  } else if (idOrHeight === "latest") {
4442
4245
  variables = { height: (await this.getBlockNumber()).toString(10) };
4443
4246
  } else if (idOrHeight.length === 66) {
4444
4247
  variables = { blockId: idOrHeight };
4445
4248
  } else {
4446
- variables = { blockId: bn16(idOrHeight).toString(10) };
4249
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4447
4250
  }
4448
4251
  const { block } = await this.operations.getBlock(variables);
4449
4252
  if (!block) {
@@ -4451,7 +4254,7 @@ var _Provider = class {
4451
4254
  }
4452
4255
  return {
4453
4256
  id: block.id,
4454
- height: bn16(block.height),
4257
+ height: bn15(block.header.height),
4455
4258
  time: block.header.time,
4456
4259
  transactionIds: block.transactions.map((tx) => tx.id)
4457
4260
  };
@@ -4466,7 +4269,7 @@ var _Provider = class {
4466
4269
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4467
4270
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4468
4271
  id: block.id,
4469
- height: bn16(block.height),
4272
+ height: bn15(block.header.height),
4470
4273
  time: block.header.time,
4471
4274
  transactionIds: block.transactions.map((tx) => tx.id)
4472
4275
  }));
@@ -4481,7 +4284,7 @@ var _Provider = class {
4481
4284
  async getBlockWithTransactions(idOrHeight) {
4482
4285
  let variables;
4483
4286
  if (typeof idOrHeight === "number") {
4484
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4287
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4485
4288
  } else if (idOrHeight === "latest") {
4486
4289
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4487
4290
  } else {
@@ -4493,7 +4296,7 @@ var _Provider = class {
4493
4296
  }
4494
4297
  return {
4495
4298
  id: block.id,
4496
- height: bn16(block.height, 10),
4299
+ height: bn15(block.header.height, 10),
4497
4300
  time: block.header.time,
4498
4301
  transactionIds: block.transactions.map((tx) => tx.id),
4499
4302
  transactions: block.transactions.map(
@@ -4542,7 +4345,7 @@ var _Provider = class {
4542
4345
  contract: Address2.fromAddressOrString(contractId).toB256(),
4543
4346
  asset: hexlify12(assetId)
4544
4347
  });
4545
- return bn16(contractBalance.amount, 10);
4348
+ return bn15(contractBalance.amount, 10);
4546
4349
  }
4547
4350
  /**
4548
4351
  * Returns the balance for the given owner for the given asset ID.
@@ -4556,7 +4359,7 @@ var _Provider = class {
4556
4359
  owner: Address2.fromAddressOrString(owner).toB256(),
4557
4360
  assetId: hexlify12(assetId)
4558
4361
  });
4559
- return bn16(balance.amount, 10);
4362
+ return bn15(balance.amount, 10);
4560
4363
  }
4561
4364
  /**
4562
4365
  * Returns balances for the given owner.
@@ -4574,7 +4377,7 @@ var _Provider = class {
4574
4377
  const balances = result.balances.edges.map((edge) => edge.node);
4575
4378
  return balances.map((balance) => ({
4576
4379
  assetId: balance.assetId,
4577
- amount: bn16(balance.amount)
4380
+ amount: bn15(balance.amount)
4578
4381
  }));
4579
4382
  }
4580
4383
  /**
@@ -4596,15 +4399,15 @@ var _Provider = class {
4596
4399
  sender: message.sender,
4597
4400
  recipient: message.recipient,
4598
4401
  nonce: message.nonce,
4599
- amount: bn16(message.amount),
4402
+ amount: bn15(message.amount),
4600
4403
  data: message.data
4601
4404
  }),
4602
4405
  sender: Address2.fromAddressOrString(message.sender),
4603
4406
  recipient: Address2.fromAddressOrString(message.recipient),
4604
4407
  nonce: message.nonce,
4605
- amount: bn16(message.amount),
4408
+ amount: bn15(message.amount),
4606
4409
  data: InputMessageCoder.decodeData(message.data),
4607
- daHeight: bn16(message.daHeight)
4410
+ daHeight: bn15(message.daHeight)
4608
4411
  }));
4609
4412
  }
4610
4413
  /**
@@ -4657,52 +4460,44 @@ var _Provider = class {
4657
4460
  } = result.messageProof;
4658
4461
  return {
4659
4462
  messageProof: {
4660
- proofIndex: bn16(messageProof.proofIndex),
4463
+ proofIndex: bn15(messageProof.proofIndex),
4661
4464
  proofSet: messageProof.proofSet
4662
4465
  },
4663
4466
  blockProof: {
4664
- proofIndex: bn16(blockProof.proofIndex),
4467
+ proofIndex: bn15(blockProof.proofIndex),
4665
4468
  proofSet: blockProof.proofSet
4666
4469
  },
4667
4470
  messageBlockHeader: {
4668
4471
  id: messageBlockHeader.id,
4669
- daHeight: bn16(messageBlockHeader.daHeight),
4670
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4472
+ daHeight: bn15(messageBlockHeader.daHeight),
4473
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4671
4474
  transactionsRoot: messageBlockHeader.transactionsRoot,
4672
- height: bn16(messageBlockHeader.height),
4475
+ height: bn15(messageBlockHeader.height),
4673
4476
  prevRoot: messageBlockHeader.prevRoot,
4674
4477
  time: messageBlockHeader.time,
4675
4478
  applicationHash: messageBlockHeader.applicationHash,
4676
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount)
4479
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4480
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4677
4481
  },
4678
4482
  commitBlockHeader: {
4679
4483
  id: commitBlockHeader.id,
4680
- daHeight: bn16(commitBlockHeader.daHeight),
4681
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4484
+ daHeight: bn15(commitBlockHeader.daHeight),
4485
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4682
4486
  transactionsRoot: commitBlockHeader.transactionsRoot,
4683
- height: bn16(commitBlockHeader.height),
4487
+ height: bn15(commitBlockHeader.height),
4684
4488
  prevRoot: commitBlockHeader.prevRoot,
4685
4489
  time: commitBlockHeader.time,
4686
4490
  applicationHash: commitBlockHeader.applicationHash,
4687
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount)
4491
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4492
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4688
4493
  },
4689
4494
  sender: Address2.fromAddressOrString(sender),
4690
4495
  recipient: Address2.fromAddressOrString(recipient),
4691
4496
  nonce,
4692
- amount: bn16(amount),
4497
+ amount: bn15(amount),
4693
4498
  data
4694
4499
  };
4695
4500
  }
4696
- async getLatestGasPrice() {
4697
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4698
- return bn16(latestGasPrice.gasPrice);
4699
- }
4700
- async estimateGasPrice(blockHorizon) {
4701
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4702
- blockHorizon: String(blockHorizon)
4703
- });
4704
- return bn16(estimateGasPrice.gasPrice);
4705
- }
4706
4501
  /**
4707
4502
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4708
4503
  *
@@ -4722,10 +4517,10 @@ var _Provider = class {
4722
4517
  */
4723
4518
  async produceBlocks(amount, startTime) {
4724
4519
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4725
- blocksToProduce: bn16(amount).toString(10),
4520
+ blocksToProduce: bn15(amount).toString(10),
4726
4521
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4727
4522
  });
4728
- return bn16(latestBlockHeight);
4523
+ return bn15(latestBlockHeight);
4729
4524
  }
4730
4525
  // eslint-disable-next-line @typescript-eslint/require-await
4731
4526
  async getTransactionResponse(transactionId) {
@@ -4739,7 +4534,7 @@ cacheInputs_fn = function(inputs) {
4739
4534
  return;
4740
4535
  }
4741
4536
  inputs.forEach((input) => {
4742
- if (input.type === InputType7.Coin) {
4537
+ if (input.type === InputType6.Coin) {
4743
4538
  this.cache?.set(input.id);
4744
4539
  }
4745
4540
  });
@@ -4749,7 +4544,7 @@ __publicField(Provider, "nodeInfoCache", {});
4749
4544
 
4750
4545
  // src/providers/transaction-summary/get-transaction-summary.ts
4751
4546
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4752
- import { bn as bn17 } from "@fuel-ts/math";
4547
+ import { bn as bn16 } from "@fuel-ts/math";
4753
4548
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4754
4549
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4755
4550
  async function getTransactionSummary(params) {
@@ -4767,28 +4562,21 @@ async function getTransactionSummary(params) {
4767
4562
  arrayify12(gqlTransaction.rawPayload),
4768
4563
  0
4769
4564
  );
4770
- let txReceipts = [];
4771
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4772
- txReceipts = gqlTransaction.status.receipts;
4773
- }
4774
- const receipts = txReceipts.map(processGqlReceipt);
4565
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4775
4566
  const {
4776
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4567
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4777
4568
  } = provider.getChain();
4778
- const gasPrice = await provider.getLatestGasPrice();
4779
4569
  const transactionInfo = assembleTransactionSummary({
4780
4570
  id: gqlTransaction.id,
4781
4571
  receipts,
4782
4572
  transaction: decodedTransaction,
4783
4573
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4784
4574
  gqlTransactionStatus: gqlTransaction.status,
4785
- gasPerByte: bn17(gasPerByte),
4786
- gasPriceFactor: bn17(gasPriceFactor),
4575
+ gasPerByte: bn16(gasPerByte),
4576
+ gasPriceFactor: bn16(gasPriceFactor),
4787
4577
  abiMap,
4788
4578
  maxInputs,
4789
- gasCosts,
4790
- maxGasPerTx,
4791
- gasPrice
4579
+ gasCosts
4792
4580
  });
4793
4581
  return {
4794
4582
  gqlTransaction,
@@ -4798,11 +4586,10 @@ async function getTransactionSummary(params) {
4798
4586
  async function getTransactionSummaryFromRequest(params) {
4799
4587
  const { provider, transactionRequest, abiMap } = params;
4800
4588
  const { receipts } = await provider.call(transactionRequest);
4801
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4589
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4802
4590
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4803
4591
  const transaction = transactionRequest.toTransaction();
4804
4592
  const transactionBytes = transactionRequest.toTransactionBytes();
4805
- const gasPrice = await provider.getLatestGasPrice();
4806
4593
  const transactionSummary = assembleTransactionSummary({
4807
4594
  receipts,
4808
4595
  transaction,
@@ -4811,9 +4598,7 @@ async function getTransactionSummaryFromRequest(params) {
4811
4598
  gasPerByte,
4812
4599
  gasPriceFactor,
4813
4600
  maxInputs,
4814
- gasCosts,
4815
- maxGasPerTx,
4816
- gasPrice
4601
+ gasCosts
4817
4602
  });
4818
4603
  return transactionSummary;
4819
4604
  }
@@ -4822,18 +4607,13 @@ async function getTransactionsSummaries(params) {
4822
4607
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4823
4608
  const { edges, pageInfo } = transactionsByOwner;
4824
4609
  const {
4825
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4610
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4826
4611
  } = provider.getChain();
4827
- const gasPrice = await provider.getLatestGasPrice();
4828
4612
  const transactions = edges.map((edge) => {
4829
4613
  const { node: gqlTransaction } = edge;
4830
- const { id, rawPayload, status } = gqlTransaction;
4614
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4831
4615
  const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
4832
- let txReceipts = [];
4833
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4834
- txReceipts = gqlTransaction.status.receipts;
4835
- }
4836
- const receipts = txReceipts.map(processGqlReceipt);
4616
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4837
4617
  const transactionSummary = assembleTransactionSummary({
4838
4618
  id,
4839
4619
  receipts,
@@ -4844,9 +4624,7 @@ async function getTransactionsSummaries(params) {
4844
4624
  gasPerByte,
4845
4625
  gasPriceFactor,
4846
4626
  maxInputs,
4847
- gasCosts,
4848
- maxGasPerTx,
4849
- gasPrice
4627
+ gasCosts
4850
4628
  });
4851
4629
  const output = {
4852
4630
  gqlTransaction,
@@ -5178,33 +4956,36 @@ var Account = class extends AbstractAccount {
5178
4956
  * @param fee - The estimated transaction fee.
5179
4957
  * @returns A promise that resolves when the resources are added to the transaction.
5180
4958
  */
5181
- async fund(request, params) {
5182
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5183
- const txRequest = request;
5184
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5185
- amount: bn18(fee),
4959
+ async fund(request, coinQuantities, fee) {
4960
+ const updatedQuantities = addAmountToAsset({
4961
+ amount: bn17(fee),
5186
4962
  assetId: BaseAssetId3,
5187
- coinQuantities: requiredQuantities
4963
+ coinQuantities
5188
4964
  });
5189
4965
  const quantitiesDict = {};
5190
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4966
+ updatedQuantities.forEach(({ amount, assetId }) => {
5191
4967
  quantitiesDict[assetId] = {
5192
4968
  required: amount,
5193
- owned: bn18(0)
4969
+ owned: bn17(0)
5194
4970
  };
5195
4971
  });
5196
- txRequest.inputs.forEach((input) => {
4972
+ const cachedUtxos = [];
4973
+ const cachedMessages = [];
4974
+ const owner = this.address.toB256();
4975
+ request.inputs.forEach((input) => {
5197
4976
  const isResource = "amount" in input;
5198
4977
  if (isResource) {
5199
4978
  const isCoin2 = "owner" in input;
5200
4979
  if (isCoin2) {
5201
4980
  const assetId = String(input.assetId);
5202
- if (quantitiesDict[assetId]) {
5203
- const amount = bn18(input.amount);
4981
+ if (input.owner === owner && quantitiesDict[assetId]) {
4982
+ const amount = bn17(input.amount);
5204
4983
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4984
+ cachedUtxos.push(input.id);
5205
4985
  }
5206
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4986
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
5207
4987
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4988
+ cachedMessages.push(input.nonce);
5208
4989
  }
5209
4990
  }
5210
4991
  });
@@ -5219,23 +5000,12 @@ var Account = class extends AbstractAccount {
5219
5000
  });
5220
5001
  const needsToBeFunded = missingQuantities.length;
5221
5002
  if (needsToBeFunded) {
5222
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5223
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5224
- txRequest.addResources(resources);
5225
- }
5226
- txRequest.shiftPredicateData();
5227
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5228
- const requestToBeReEstimate = clone4(txRequest);
5229
- if (addedSignatures) {
5230
- Array.from({ length: addedSignatures }).forEach(
5231
- () => requestToBeReEstimate.addEmptyWitness()
5232
- );
5003
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5004
+ messages: cachedMessages,
5005
+ utxos: cachedUtxos
5006
+ });
5007
+ request.addResources(resources);
5233
5008
  }
5234
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5235
- transactionRequest: requestToBeReEstimate
5236
- });
5237
- txRequest.maxFee = maxFee;
5238
- return txRequest;
5239
5009
  }
5240
5010
  /**
5241
5011
  * A helper that creates a transfer transaction request and returns it.
@@ -5243,25 +5013,28 @@ var Account = class extends AbstractAccount {
5243
5013
  * @param destination - The address of the destination.
5244
5014
  * @param amount - The amount of coins to transfer.
5245
5015
  * @param assetId - The asset ID of the coins to transfer.
5246
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5016
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5247
5017
  * @returns A promise that resolves to the prepared transaction request.
5248
5018
  */
5249
5019
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5250
- const request = new ScriptTransactionRequest(txParams);
5020
+ const { minGasPrice } = this.provider.getGasConfig();
5021
+ const params = { gasPrice: minGasPrice, ...txParams };
5022
+ const request = new ScriptTransactionRequest(params);
5251
5023
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5252
- const txCost = await this.provider.getTransactionCost(request, {
5024
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5253
5025
  estimateTxDependencies: true,
5254
5026
  resourcesOwner: this
5255
5027
  });
5256
- if ("gasLimit" in txParams) {
5257
- this.validateGas({
5258
- gasUsed: txCost.gasUsed,
5259
- gasLimit: request.gasLimit
5260
- });
5261
- }
5262
- request.gasLimit = txCost.gasUsed;
5263
- request.maxFee = txCost.maxFee;
5264
- await this.fund(request, txCost);
5028
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5029
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
5030
+ this.validateGas({
5031
+ gasUsed,
5032
+ gasPrice: request.gasPrice,
5033
+ gasLimit: request.gasLimit,
5034
+ minGasPrice
5035
+ });
5036
+ await this.fund(request, requiredQuantities, maxFee);
5037
+ request.updatePredicateInputs(estimatedInputs);
5265
5038
  return request;
5266
5039
  }
5267
5040
  /**
@@ -5274,7 +5047,7 @@ var Account = class extends AbstractAccount {
5274
5047
  * @returns A promise that resolves to the transaction response.
5275
5048
  */
5276
5049
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5277
- if (bn18(amount).lte(0)) {
5050
+ if (bn17(amount).lte(0)) {
5278
5051
  throw new FuelError15(
5279
5052
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5280
5053
  "Transfer amount must be a positive number."
@@ -5293,37 +5066,38 @@ var Account = class extends AbstractAccount {
5293
5066
  * @returns A promise that resolves to the transaction response.
5294
5067
  */
5295
5068
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5296
- if (bn18(amount).lte(0)) {
5069
+ if (bn17(amount).lte(0)) {
5297
5070
  throw new FuelError15(
5298
5071
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5299
5072
  "Transfer amount must be a positive number."
5300
5073
  );
5301
5074
  }
5302
5075
  const contractAddress = Address3.fromAddressOrString(contractId);
5076
+ const { minGasPrice } = this.provider.getGasConfig();
5077
+ const params = { gasPrice: minGasPrice, ...txParams };
5303
5078
  const { script, scriptData } = await assembleTransferToContractScript({
5304
5079
  hexlifiedContractId: contractAddress.toB256(),
5305
- amountToTransfer: bn18(amount),
5080
+ amountToTransfer: bn17(amount),
5306
5081
  assetId
5307
5082
  });
5308
5083
  const request = new ScriptTransactionRequest({
5309
- ...txParams,
5084
+ ...params,
5310
5085
  script,
5311
5086
  scriptData
5312
5087
  });
5313
5088
  request.addContractInputAndOutput(contractAddress);
5314
- const txCost = await this.provider.getTransactionCost(request, {
5315
- resourcesOwner: this,
5316
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
5089
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5090
+ request,
5091
+ [{ amount: bn17(amount), assetId: String(assetId) }]
5092
+ );
5093
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5094
+ this.validateGas({
5095
+ gasUsed,
5096
+ gasPrice: request.gasPrice,
5097
+ gasLimit: request.gasLimit,
5098
+ minGasPrice
5317
5099
  });
5318
- if (txParams.gasLimit) {
5319
- this.validateGas({
5320
- gasUsed: txCost.gasUsed,
5321
- gasLimit: request.gasLimit
5322
- });
5323
- }
5324
- request.gasLimit = txCost.gasUsed;
5325
- request.maxFee = txCost.maxFee;
5326
- await this.fund(request, txCost);
5100
+ await this.fund(request, requiredQuantities, maxFee);
5327
5101
  return this.sendTransaction(request);
5328
5102
  }
5329
5103
  /**
@@ -5335,31 +5109,34 @@ var Account = class extends AbstractAccount {
5335
5109
  * @returns A promise that resolves to the transaction response.
5336
5110
  */
5337
5111
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5112
+ const { minGasPrice } = this.provider.getGasConfig();
5338
5113
  const recipientAddress = Address3.fromAddressOrString(recipient);
5339
5114
  const recipientDataArray = arrayify14(
5340
5115
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5341
5116
  );
5342
5117
  const amountDataArray = arrayify14(
5343
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
5118
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5344
5119
  );
5345
5120
  const script = new Uint8Array([
5346
5121
  ...arrayify14(withdrawScript.bytes),
5347
5122
  ...recipientDataArray,
5348
5123
  ...amountDataArray
5349
5124
  ]);
5350
- const params = { script, ...txParams };
5125
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5351
5126
  const request = new ScriptTransactionRequest(params);
5352
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5353
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5354
- if (txParams.gasLimit) {
5355
- this.validateGas({
5356
- gasUsed: txCost.gasUsed,
5357
- gasLimit: request.gasLimit
5358
- });
5359
- }
5360
- request.maxFee = txCost.maxFee;
5361
- request.gasLimit = txCost.gasUsed;
5362
- await this.fund(request, txCost);
5127
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5128
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5129
+ request,
5130
+ forwardingQuantities
5131
+ );
5132
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5133
+ this.validateGas({
5134
+ gasUsed,
5135
+ gasPrice: request.gasPrice,
5136
+ gasLimit: request.gasLimit,
5137
+ minGasPrice
5138
+ });
5139
+ await this.fund(request, requiredQuantities, maxFee);
5363
5140
  return this.sendTransaction(request);
5364
5141
  }
5365
5142
  async signMessage(message) {
@@ -5417,7 +5194,18 @@ var Account = class extends AbstractAccount {
5417
5194
  }
5418
5195
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5419
5196
  }
5420
- validateGas({ gasUsed, gasLimit }) {
5197
+ validateGas({
5198
+ gasUsed,
5199
+ gasPrice,
5200
+ gasLimit,
5201
+ minGasPrice
5202
+ }) {
5203
+ if (minGasPrice.gt(gasPrice)) {
5204
+ throw new FuelError15(
5205
+ ErrorCode15.GAS_PRICE_TOO_LOW,
5206
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5207
+ );
5208
+ }
5421
5209
  if (gasUsed.gt(gasLimit)) {
5422
5210
  throw new FuelError15(
5423
5211
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5713,7 +5501,7 @@ var BaseWalletUnlocked = class extends Account {
5713
5501
  * @param transactionRequestLike - The transaction request to send.
5714
5502
  * @returns A promise that resolves to the TransactionResponse object.
5715
5503
  */
5716
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5504
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5717
5505
  const transactionRequest = transactionRequestify(transactionRequestLike);
5718
5506
  if (estimateTxDependencies) {
5719
5507
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5754,7 +5542,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5754
5542
  // src/hdwallet/hdwallet.ts
5755
5543
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5756
5544
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5757
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5545
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5758
5546
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5759
5547
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5760
5548
 
@@ -8226,7 +8014,7 @@ var HDWallet = class {
8226
8014
  const IR = bytes.slice(32);
8227
8015
  if (privateKey) {
8228
8016
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8229
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
8017
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
8230
8018
  return new HDWallet({
8231
8019
  privateKey: ki,
8232
8020
  chainCode: IR,
@@ -8915,7 +8703,7 @@ import {
8915
8703
  import { Address as Address9 } from "@fuel-ts/address";
8916
8704
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8917
8705
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8918
- import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
8706
+ import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8919
8707
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8920
8708
 
8921
8709
  // src/predicate/utils/getPredicateRoot.ts
@@ -8964,7 +8752,6 @@ var Predicate = class extends Account {
8964
8752
  this.interface = predicateInterface;
8965
8753
  if (inputData !== void 0 && inputData.length > 0) {
8966
8754
  this.predicateData = inputData;
8967
- this.predicateDataBytes = this.getPredicateData(0);
8968
8755
  }
8969
8756
  }
8970
8757
  /**
@@ -8977,9 +8764,9 @@ var Predicate = class extends Account {
8977
8764
  const request = transactionRequestify(transactionRequestLike);
8978
8765
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8979
8766
  request.inputs?.forEach((input) => {
8980
- if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
8981
- input.predicate = hexlify19(this.bytes);
8982
- input.predicateData = hexlify19(this.getPredicateData(policies.length));
8767
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8768
+ input.predicate = this.bytes;
8769
+ input.predicateData = this.getPredicateData(policies.length);
8983
8770
  }
8984
8771
  });
8985
8772
  return request;
@@ -8994,7 +8781,8 @@ var Predicate = class extends Account {
8994
8781
  * @returns A promise that resolves to the prepared transaction request.
8995
8782
  */
8996
8783
  async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
8997
- return super.createTransfer(destination, amount, assetId, txParams);
8784
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8785
+ return this.populateTransactionPredicateData(request);
8998
8786
  }
8999
8787
  /**
9000
8788
  * Sends a transaction with the populated predicate data.
@@ -9002,9 +8790,9 @@ var Predicate = class extends Account {
9002
8790
  * @param transactionRequestLike - The transaction request-like object.
9003
8791
  * @returns A promise that resolves to the transaction response.
9004
8792
  */
9005
- sendTransaction(transactionRequestLike) {
9006
- const transactionRequest = transactionRequestify(transactionRequestLike);
9007
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8793
+ sendTransaction(transactionRequestLike, options) {
8794
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8795
+ return super.sendTransaction(transactionRequest, options);
9008
8796
  }
9009
8797
  /**
9010
8798
  * Simulates a transaction with the populated predicate data.
@@ -9013,8 +8801,8 @@ var Predicate = class extends Account {
9013
8801
  * @returns A promise that resolves to the call result.
9014
8802
  */
9015
8803
  simulateTransaction(transactionRequestLike) {
9016
- const transactionRequest = transactionRequestify(transactionRequestLike);
9017
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8804
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8805
+ return super.simulateTransaction(transactionRequest);
9018
8806
  }
9019
8807
  getPredicateData(policiesLength) {
9020
8808
  if (!this.predicateData.length) {
@@ -9060,26 +8848,6 @@ var Predicate = class extends Account {
9060
8848
  predicateInterface: abiInterface
9061
8849
  };
9062
8850
  }
9063
- /**
9064
- * Retrieves resources satisfying the spend query for the account.
9065
- *
9066
- * @param quantities - IDs of coins to exclude.
9067
- * @param excludedIds - IDs of resources to be excluded from the query.
9068
- * @returns A promise that resolves to an array of Resources.
9069
- */
9070
- async getResourcesToSpend(quantities, excludedIds) {
9071
- const resources = await this.provider.getResourcesToSpend(
9072
- this.address,
9073
- quantities,
9074
- excludedIds
9075
- );
9076
- return resources.map((resource) => ({
9077
- ...resource,
9078
- predicate: hexlify19(this.bytes),
9079
- predicateData: hexlify19(this.predicateDataBytes),
9080
- paddPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
9081
- }));
9082
- }
9083
8851
  /**
9084
8852
  * Sets the configurable constants for the predicate.
9085
8853
  *
@@ -9828,7 +9596,7 @@ export {
9828
9596
  WalletLocked,
9829
9597
  WalletManager,
9830
9598
  WalletUnlocked,
9831
- addAmountToCoinQuantities,
9599
+ addAmountToAsset,
9832
9600
  addOperation,
9833
9601
  assemblePanicError,
9834
9602
  assembleReceiptByType,
@@ -9837,10 +9605,9 @@ export {
9837
9605
  assets,
9838
9606
  buildBlockExplorerUrl,
9839
9607
  cacheFor,
9840
- cacheTxInputsFromOwner,
9841
- calculateGasFee,
9842
9608
  calculateMetadataGasForTxCreate,
9843
9609
  calculateMetadataGasForTxScript,
9610
+ calculatePriceWithFactor,
9844
9611
  calculateTransactionFee,
9845
9612
  coinQuantityfy,
9846
9613
  deferPromise,