@fuel-ts/account 0.0.0-rc-2021-20240410132122 → 0.0.0-rc-2034-20240410133013

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 +560 -793
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +523 -760
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +404 -640
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -11
  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 +1059 -1506
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +519 -735
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +413 -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,8 @@ var BaseTransactionRequest = class {
2003
1923
  amount,
2004
1924
  assetId,
2005
1925
  txPointer: "0x00000000000000000000000000000000",
2006
- witnessIndex
1926
+ witnessIndex,
1927
+ predicate: predicate?.bytes
2007
1928
  };
2008
1929
  this.pushInput(input);
2009
1930
  this.addChangeOutput(owner, assetId);
@@ -2016,11 +1937,11 @@ var BaseTransactionRequest = class {
2016
1937
  * @param predicate - Predicate bytes.
2017
1938
  * @param predicateData - Predicate data bytes.
2018
1939
  */
2019
- addMessageInput(message) {
1940
+ addMessageInput(message, predicate) {
2020
1941
  const { recipient, sender, amount } = message;
2021
1942
  const assetId = BaseAssetId2;
2022
1943
  let witnessIndex;
2023
- if (message.predicate) {
1944
+ if (predicate) {
2024
1945
  witnessIndex = 0;
2025
1946
  } else {
2026
1947
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2034,7 +1955,8 @@ var BaseTransactionRequest = class {
2034
1955
  sender: sender.toB256(),
2035
1956
  recipient: recipient.toB256(),
2036
1957
  amount,
2037
- witnessIndex
1958
+ witnessIndex,
1959
+ predicate: predicate?.bytes
2038
1960
  };
2039
1961
  this.pushInput(input);
2040
1962
  this.addChangeOutput(recipient, assetId);
@@ -2065,6 +1987,32 @@ var BaseTransactionRequest = class {
2065
1987
  resources.forEach((resource) => this.addResource(resource));
2066
1988
  return this;
2067
1989
  }
1990
+ /**
1991
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1992
+ * outputs from the related assetIds.
1993
+ *
1994
+ * @param resources - The resources to add.
1995
+ * @returns This transaction.
1996
+ */
1997
+ addPredicateResource(resource, predicate) {
1998
+ if (isCoin(resource)) {
1999
+ this.addCoinInput(resource, predicate);
2000
+ } else {
2001
+ this.addMessageInput(resource, predicate);
2002
+ }
2003
+ return this;
2004
+ }
2005
+ /**
2006
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2007
+ * from the related assetIds.
2008
+ *
2009
+ * @param resources - The resources to add.
2010
+ * @returns This transaction.
2011
+ */
2012
+ addPredicateResources(resources, predicate) {
2013
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2014
+ return this;
2015
+ }
2068
2016
  /**
2069
2017
  * Adds a coin output to the transaction.
2070
2018
  *
@@ -2144,7 +2092,7 @@ var BaseTransactionRequest = class {
2144
2092
  }
2145
2093
  calculateMaxGas(chainInfo, minGas) {
2146
2094
  const { consensusParameters } = chainInfo;
2147
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2095
+ const { gasPerByte } = consensusParameters;
2148
2096
  const witnessesLength = this.toTransaction().witnesses.reduce(
2149
2097
  (acc, wit) => acc + wit.dataLength,
2150
2098
  0
@@ -2153,8 +2101,7 @@ var BaseTransactionRequest = class {
2153
2101
  gasPerByte,
2154
2102
  minGas,
2155
2103
  witnessesLength,
2156
- witnessLimit: this.witnessLimit,
2157
- maxGasPerTx
2104
+ witnessLimit: this.witnessLimit
2158
2105
  });
2159
2106
  }
2160
2107
  /**
@@ -2172,20 +2119,17 @@ var BaseTransactionRequest = class {
2172
2119
  });
2173
2120
  const updateAssetInput = (assetId, quantity) => {
2174
2121
  const assetInput = findAssetInput(assetId);
2175
- let usedQuantity = quantity;
2176
- if (assetId === BaseAssetId2) {
2177
- usedQuantity = bn7("1000000000000000000");
2178
- }
2179
2122
  if (assetInput && "assetId" in assetInput) {
2180
- assetInput.id = hexlify7(randomBytes(34));
2181
- assetInput.amount = usedQuantity;
2123
+ assetInput.id = hexlify7(randomBytes(33));
2124
+ assetInput.amount = quantity;
2182
2125
  } else {
2183
2126
  this.addResources([
2184
2127
  {
2185
- id: hexlify7(randomBytes(34)),
2186
- amount: usedQuantity,
2128
+ id: hexlify7(randomBytes(33)),
2129
+ amount: quantity,
2187
2130
  assetId,
2188
2131
  owner: resourcesOwner || Address.fromRandom(),
2132
+ maturity: 0,
2189
2133
  blockCreated: bn7(1),
2190
2134
  txCreatedIdx: bn7(1)
2191
2135
  }
@@ -2217,7 +2161,7 @@ var BaseTransactionRequest = class {
2217
2161
  toJSON() {
2218
2162
  return normalizeJSON(this);
2219
2163
  }
2220
- updatePredicateGasUsed(inputs) {
2164
+ updatePredicateInputs(inputs) {
2221
2165
  this.inputs.forEach((i) => {
2222
2166
  let correspondingInput;
2223
2167
  switch (i.type) {
@@ -2239,15 +2183,6 @@ var BaseTransactionRequest = class {
2239
2183
  }
2240
2184
  });
2241
2185
  }
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
2186
  };
2252
2187
 
2253
2188
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2394,8 +2329,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2394
2329
  return {
2395
2330
  type: TransactionType3.Create,
2396
2331
  ...baseTransaction,
2332
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2397
2333
  bytecodeWitnessIndex,
2398
- storageSlotsCount: bn9(storageSlots.length),
2334
+ storageSlotsCount: storageSlots.length,
2399
2335
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2400
2336
  storageSlots
2401
2337
  };
@@ -2518,8 +2454,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2518
2454
  type: TransactionType4.Script,
2519
2455
  scriptGasLimit: this.gasLimit,
2520
2456
  ...super.getBaseTransaction(),
2521
- scriptLength: bn10(script.length),
2522
- scriptDataLength: bn10(scriptData.length),
2457
+ scriptLength: script.length,
2458
+ scriptDataLength: scriptData.length,
2523
2459
  receiptsRoot: ZeroBytes327,
2524
2460
  script: hexlify10(script),
2525
2461
  scriptData: hexlify10(scriptData)
@@ -2583,7 +2519,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2583
2519
  }
2584
2520
  calculateMaxGas(chainInfo, minGas) {
2585
2521
  const { consensusParameters } = chainInfo;
2586
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2522
+ const { gasPerByte } = consensusParameters;
2587
2523
  const witnessesLength = this.toTransaction().witnesses.reduce(
2588
2524
  (acc, wit) => acc + wit.dataLength,
2589
2525
  0
@@ -2593,8 +2529,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2593
2529
  minGas,
2594
2530
  witnessesLength,
2595
2531
  witnessLimit: this.witnessLimit,
2596
- gasLimit: this.gasLimit,
2597
- maxGasPerTx
2532
+ gasLimit: this.gasLimit
2598
2533
  });
2599
2534
  }
2600
2535
  /**
@@ -2651,7 +2586,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2651
2586
 
2652
2587
  // src/providers/transaction-request/utils.ts
2653
2588
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2654
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2589
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2655
2590
  var transactionRequestify = (obj) => {
2656
2591
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2657
2592
  return obj;
@@ -2669,31 +2604,14 @@ var transactionRequestify = (obj) => {
2669
2604
  }
2670
2605
  }
2671
2606
  };
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
2607
 
2688
2608
  // src/providers/transaction-response/transaction-response.ts
2689
2609
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2690
- import { bn as bn15 } from "@fuel-ts/math";
2610
+ import { bn as bn14 } from "@fuel-ts/math";
2691
2611
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2692
2612
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2693
2613
 
2694
2614
  // 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
2615
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2698
2616
 
2699
2617
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2702,10 +2620,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2702
2620
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2703
2621
  var calculateTransactionFee = (params) => {
2704
2622
  const {
2705
- gasPrice,
2623
+ gasUsed,
2706
2624
  rawPayload,
2707
- tip,
2708
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2625
+ consensusParameters: { gasCosts, feeParams }
2709
2626
  } = params;
2710
2627
  const gasPerByte = bn11(feeParams.gasPerByte);
2711
2628
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2715,7 +2632,8 @@ var calculateTransactionFee = (params) => {
2715
2632
  return {
2716
2633
  fee: bn11(0),
2717
2634
  minFee: bn11(0),
2718
- maxFee: bn11(0)
2635
+ maxFee: bn11(0),
2636
+ feeFromGasUsed: bn11(0)
2719
2637
  };
2720
2638
  }
2721
2639
  const { type, witnesses, inputs, policies } = transaction;
@@ -2747,6 +2665,7 @@ var calculateTransactionFee = (params) => {
2747
2665
  metadataGas,
2748
2666
  txBytesSize: transactionBytes.length
2749
2667
  });
2668
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2750
2669
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2751
2670
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2752
2671
  const maxGas = getMaxGas({
@@ -2754,25 +2673,17 @@ var calculateTransactionFee = (params) => {
2754
2673
  minGas,
2755
2674
  witnessesLength,
2756
2675
  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
2676
+ witnessLimit
2771
2677
  });
2678
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2679
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2680
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2681
+ const fee = minFee.add(feeFromGasUsed);
2772
2682
  return {
2683
+ fee,
2773
2684
  minFee,
2774
2685
  maxFee,
2775
- fee: maxFee
2686
+ feeFromGasUsed
2776
2687
  };
2777
2688
  };
2778
2689
 
@@ -2828,7 +2739,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2828
2739
 
2829
2740
  // src/providers/transaction-summary/input.ts
2830
2741
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2831
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2742
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2832
2743
  function getInputsByTypes(inputs, types) {
2833
2744
  return inputs.filter((i) => types.includes(i.type));
2834
2745
  }
@@ -2836,16 +2747,16 @@ function getInputsByType(inputs, type) {
2836
2747
  return inputs.filter((i) => i.type === type);
2837
2748
  }
2838
2749
  function getInputsCoin(inputs) {
2839
- return getInputsByType(inputs, InputType6.Coin);
2750
+ return getInputsByType(inputs, InputType5.Coin);
2840
2751
  }
2841
2752
  function getInputsMessage(inputs) {
2842
- return getInputsByType(inputs, InputType6.Message);
2753
+ return getInputsByType(inputs, InputType5.Message);
2843
2754
  }
2844
2755
  function getInputsCoinAndMessage(inputs) {
2845
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2756
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2846
2757
  }
2847
2758
  function getInputsContract(inputs) {
2848
- return getInputsByType(inputs, InputType6.Contract);
2759
+ return getInputsByType(inputs, InputType5.Contract);
2849
2760
  }
2850
2761
  function getInputFromAssetId(inputs, assetId) {
2851
2762
  const coinInputs = getInputsCoin(inputs);
@@ -2864,7 +2775,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2864
2775
  if (!contractInput) {
2865
2776
  return void 0;
2866
2777
  }
2867
- if (contractInput.type !== InputType6.Contract) {
2778
+ if (contractInput.type !== InputType5.Contract) {
2868
2779
  throw new FuelError9(
2869
2780
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2870
2781
  `Contract input should be of type 'contract'.`
@@ -2873,10 +2784,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2873
2784
  return contractInput;
2874
2785
  }
2875
2786
  function getInputAccountAddress(input) {
2876
- if (input.type === InputType6.Coin) {
2787
+ if (input.type === InputType5.Coin) {
2877
2788
  return input.owner.toString();
2878
2789
  }
2879
- if (input.type === InputType6.Message) {
2790
+ if (input.type === InputType5.Message) {
2880
2791
  return input.recipient.toString();
2881
2792
  }
2882
2793
  return "";
@@ -3386,9 +3297,7 @@ function assembleTransactionSummary(params) {
3386
3297
  gqlTransactionStatus,
3387
3298
  abiMap = {},
3388
3299
  maxInputs,
3389
- gasCosts,
3390
- maxGasPerTx,
3391
- gasPrice
3300
+ gasCosts
3392
3301
  } = params;
3393
3302
  const gasUsed = getGasUsedFromReceipts(receipts);
3394
3303
  const rawPayload = hexlify11(transactionBytes);
@@ -3402,14 +3311,11 @@ function assembleTransactionSummary(params) {
3402
3311
  maxInputs
3403
3312
  });
3404
3313
  const typeName = getTransactionTypeName(transaction.type);
3405
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3406
3314
  const { fee } = calculateTransactionFee({
3407
- gasPrice,
3315
+ gasUsed,
3408
3316
  rawPayload,
3409
- tip,
3410
3317
  consensusParameters: {
3411
3318
  gasCosts,
3412
- maxGasPerTx,
3413
3319
  feeParams: {
3414
3320
  gasPerByte,
3415
3321
  gasPriceFactor
@@ -3469,7 +3375,7 @@ var TransactionResponse = class {
3469
3375
  /** Current provider */
3470
3376
  provider;
3471
3377
  /** Gas used on the transaction */
3472
- gasUsed = bn15(0);
3378
+ gasUsed = bn14(0);
3473
3379
  /** The graphql Transaction with receipts object. */
3474
3380
  gqlTransaction;
3475
3381
  abis;
@@ -3547,13 +3453,8 @@ var TransactionResponse = class {
3547
3453
  const decodedTransaction = this.decodeTransaction(
3548
3454
  transaction
3549
3455
  );
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();
3456
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3457
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3557
3458
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3558
3459
  const transactionSummary = assembleTransactionSummary({
3559
3460
  id: this.id,
@@ -3565,9 +3466,7 @@ var TransactionResponse = class {
3565
3466
  gasPriceFactor,
3566
3467
  abiMap: contractsAbiMap,
3567
3468
  maxInputs,
3568
- gasCosts,
3569
- maxGasPerTx,
3570
- gasPrice
3469
+ gasCosts
3571
3470
  });
3572
3471
  return transactionSummary;
3573
3472
  }
@@ -3694,29 +3593,29 @@ var processGqlChain = (chain) => {
3694
3593
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3695
3594
  return {
3696
3595
  name,
3697
- baseChainHeight: bn16(daHeight),
3596
+ baseChainHeight: bn15(daHeight),
3698
3597
  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),
3598
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3599
+ maxInputs: bn15(txParams.maxInputs),
3600
+ maxOutputs: bn15(txParams.maxOutputs),
3601
+ maxWitnesses: bn15(txParams.maxWitnesses),
3602
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3603
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3604
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3605
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3606
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3607
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3608
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3609
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3610
+ gasPerByte: bn15(feeParams.gasPerByte),
3611
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3612
+ chainId: bn15(consensusParameters.chainId),
3714
3613
  gasCosts
3715
3614
  },
3716
3615
  gasCosts,
3717
3616
  latestBlock: {
3718
3617
  id: latestBlock.id,
3719
- height: bn16(latestBlock.height),
3618
+ height: bn15(latestBlock.header.height),
3720
3619
  time: latestBlock.header.time,
3721
3620
  transactions: latestBlock.transactions.map((i) => ({
3722
3621
  id: i.id
@@ -3810,8 +3709,10 @@ var _Provider = class {
3810
3709
  * Returns some helpful parameters related to gas fees.
3811
3710
  */
3812
3711
  getGasConfig() {
3712
+ const { minGasPrice } = this.getNode();
3813
3713
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3814
3714
  return {
3715
+ minGasPrice,
3815
3716
  maxGasPerTx,
3816
3717
  maxGasPerPredicate,
3817
3718
  gasPriceFactor,
@@ -3909,7 +3810,7 @@ var _Provider = class {
3909
3810
  */
3910
3811
  async getBlockNumber() {
3911
3812
  const { chain } = await this.operations.getChain();
3912
- return bn16(chain.latestBlock.height, 10);
3813
+ return bn15(chain.latestBlock.header.height, 10);
3913
3814
  }
3914
3815
  /**
3915
3816
  * Returns the chain information.
@@ -3919,11 +3820,13 @@ var _Provider = class {
3919
3820
  async fetchNode() {
3920
3821
  const { nodeInfo } = await this.operations.getNodeInfo();
3921
3822
  const processedNodeInfo = {
3922
- maxDepth: bn16(nodeInfo.maxDepth),
3923
- maxTx: bn16(nodeInfo.maxTx),
3823
+ maxDepth: bn15(nodeInfo.maxDepth),
3824
+ maxTx: bn15(nodeInfo.maxTx),
3825
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3924
3826
  nodeVersion: nodeInfo.nodeVersion,
3925
3827
  utxoValidation: nodeInfo.utxoValidation,
3926
- vmBacktrace: nodeInfo.vmBacktrace
3828
+ vmBacktrace: nodeInfo.vmBacktrace,
3829
+ peers: nodeInfo.peers
3927
3830
  };
3928
3831
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3929
3832
  return processedNodeInfo;
@@ -4009,13 +3912,14 @@ var _Provider = class {
4009
3912
  return this.estimateTxDependencies(transactionRequest);
4010
3913
  }
4011
3914
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4012
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4013
- encodedTransactions: encodedTransaction,
3915
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3916
+ encodedTransaction,
4014
3917
  utxoValidation: utxoValidation || false
4015
3918
  });
4016
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4017
- const receipts = rawReceipts.map(processGqlReceipt);
4018
- return { receipts, dryrunStatus: status };
3919
+ const receipts = gqlReceipts.map(processGqlReceipt);
3920
+ return {
3921
+ receipts
3922
+ };
4019
3923
  }
4020
3924
  /**
4021
3925
  * Verifies whether enough gas is available to complete transaction.
@@ -4041,7 +3945,7 @@ var _Provider = class {
4041
3945
  } = response;
4042
3946
  if (inputs) {
4043
3947
  inputs.forEach((input, index) => {
4044
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3948
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
4045
3949
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4046
3950
  }
4047
3951
  });
@@ -4054,6 +3958,9 @@ var _Provider = class {
4054
3958
  * If there are missing variable outputs,
4055
3959
  * `addVariableOutputs` is called on the transaction.
4056
3960
  *
3961
+ * @privateRemarks
3962
+ * TODO: Investigate support for missing contract IDs
3963
+ * TODO: Add support for missing output messages
4057
3964
  *
4058
3965
  * @param transactionRequest - The transaction request object.
4059
3966
  * @returns A promise.
@@ -4066,19 +3973,16 @@ var _Provider = class {
4066
3973
  missingContractIds: []
4067
3974
  };
4068
3975
  }
3976
+ await this.estimatePredicates(transactionRequest);
4069
3977
  let receipts = [];
4070
3978
  const missingContractIds = [];
4071
3979
  let outputVariables = 0;
4072
- let dryrunStatus;
4073
3980
  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())],
3981
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3982
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
4078
3983
  utxoValidation: false
4079
3984
  });
4080
- receipts = rawReceipts.map(processGqlReceipt);
4081
- dryrunStatus = status;
3985
+ receipts = gqlReceipts.map(processGqlReceipt);
4082
3986
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4083
3987
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4084
3988
  if (hasMissingOutputs) {
@@ -4088,11 +3992,6 @@ var _Provider = class {
4088
3992
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
4089
3993
  missingContractIds.push(contractId);
4090
3994
  });
4091
- const { maxFee } = await this.estimateTxGasAndFee({
4092
- transactionRequest,
4093
- optimizeGas: false
4094
- });
4095
- transactionRequest.maxFee = maxFee;
4096
3995
  } else {
4097
3996
  break;
4098
3997
  }
@@ -4100,133 +3999,38 @@ var _Provider = class {
4100
3999
  return {
4101
4000
  receipts,
4102
4001
  outputVariables,
4103
- missingContractIds,
4104
- dryrunStatus
4002
+ missingContractIds
4105
4003
  };
4106
4004
  }
4107
4005
  /**
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.
4006
+ * Estimates the transaction gas and fee based on the provided transaction request.
4007
+ * @param transactionRequest - The transaction request object.
4008
+ * @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
4009
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4116
4010
  */
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;
4011
+ estimateTxGasAndFee(params) {
4012
+ const { transactionRequest } = params;
4013
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4195
4014
  const chainInfo = this.getChain();
4196
- const { gasPriceFactor } = this.getGasConfig();
4015
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4016
+ transactionRequest.gasPrice = gasPrice;
4197
4017
  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);
4018
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4208
4019
  if (transactionRequest.type === TransactionType8.Script) {
4209
- gasLimit = transactionRequest.gasLimit;
4210
- if (!optimizeGas) {
4020
+ if (transactionRequest.gasLimit.eq(0)) {
4211
4021
  transactionRequest.gasLimit = minGas;
4212
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4213
- transactionRequest.gasLimit = gasLimit;
4022
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4023
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4024
+ );
4214
4025
  }
4215
4026
  }
4216
4027
  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);
4028
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4223
4029
  return {
4224
4030
  minGas,
4225
4031
  minFee,
4226
4032
  maxGas,
4227
- maxFee,
4228
- gasPrice,
4229
- gasLimit
4033
+ maxFee
4230
4034
  };
4231
4035
  }
4232
4036
  /**
@@ -4244,17 +4048,15 @@ var _Provider = class {
4244
4048
  if (estimateTxDependencies) {
4245
4049
  return this.estimateTxDependencies(transactionRequest);
4246
4050
  }
4247
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4248
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4249
- encodedTransactions,
4051
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4052
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4053
+ encodedTransaction,
4250
4054
  utxoValidation: true
4251
4055
  });
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 };
4056
+ const receipts = gqlReceipts.map(processGqlReceipt);
4057
+ return {
4058
+ receipts
4059
+ };
4258
4060
  }
4259
4061
  /**
4260
4062
  * Returns a transaction cost to enable user
@@ -4271,80 +4073,77 @@ var _Provider = class {
4271
4073
  * @param tolerance - The tolerance to add on top of the gasUsed.
4272
4074
  * @returns A promise that resolves to the transaction cost object.
4273
4075
  */
4274
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4076
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4077
+ estimateTxDependencies = true,
4078
+ estimatePredicates = true,
4079
+ resourcesOwner,
4080
+ signatureCallback
4081
+ } = {}) {
4275
4082
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4083
+ const { minGasPrice } = this.getGasConfig();
4084
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4276
4085
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4277
4086
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4278
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4087
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4279
4088
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4280
- txRequestClone.maxFee = bn16(0);
4281
4089
  if (isScriptTransaction) {
4282
- txRequestClone.gasLimit = bn16(0);
4090
+ txRequestClone.gasLimit = bn15(0);
4283
4091
  }
4284
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4285
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4092
+ if (estimatePredicates) {
4093
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4094
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4095
+ }
4096
+ await this.estimatePredicates(txRequestClone);
4286
4097
  }
4287
- const signedRequest = clone3(txRequestClone);
4288
- let addedSignatures = 0;
4289
4098
  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
4099
+ await signatureCallback(txRequestClone);
4100
+ }
4101
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4102
+ transactionRequest: txRequestClone
4298
4103
  });
4299
- txRequestClone.maxFee = maxFee;
4300
4104
  let receipts = [];
4301
4105
  let missingContractIds = [];
4302
4106
  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;
4107
+ let gasUsed = bn15(0);
4108
+ if (isScriptTransaction && estimateTxDependencies) {
4109
+ txRequestClone.gasPrice = bn15(0);
4310
4110
  const result = await this.estimateTxDependencies(txRequestClone);
4311
4111
  receipts = result.receipts;
4312
4112
  outputVariables = result.outputVariables;
4313
4113
  missingContractIds = result.missingContractIds;
4314
- gasUsed = getGasUsedFromReceipts(receipts);
4114
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4315
4115
  txRequestClone.gasLimit = gasUsed;
4316
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4317
- transactionRequest: txRequestClone,
4318
- gasPrice
4116
+ txRequestClone.gasPrice = setGasPrice;
4117
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4118
+ transactionRequest: txRequestClone
4319
4119
  }));
4320
4120
  }
4321
4121
  return {
4322
4122
  requiredQuantities: allQuantities,
4323
4123
  receipts,
4324
4124
  gasUsed,
4325
- gasPrice,
4125
+ minGasPrice,
4126
+ gasPrice: setGasPrice,
4326
4127
  minGas,
4327
4128
  maxGas,
4328
4129
  minFee,
4329
4130
  maxFee,
4131
+ estimatedInputs: txRequestClone.inputs,
4330
4132
  outputVariables,
4331
- missingContractIds,
4332
- addedSignatures,
4333
- estimatedPredicates: txRequestClone.inputs
4133
+ missingContractIds
4334
4134
  };
4335
4135
  }
4336
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4136
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4337
4137
  const ownerAddress = Address2.fromAddressOrString(owner);
4338
4138
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4339
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4340
- quantitiesToContract
4341
- });
4139
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4342
4140
  transactionRequest.addResources(
4343
4141
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4344
4142
  );
4345
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4346
- quantitiesToContract
4347
- });
4143
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4144
+ transactionRequest,
4145
+ forwardingQuantities
4146
+ );
4348
4147
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4349
4148
  return {
4350
4149
  resources,
@@ -4366,10 +4165,11 @@ var _Provider = class {
4366
4165
  return coins.map((coin) => ({
4367
4166
  id: coin.utxoId,
4368
4167
  assetId: coin.assetId,
4369
- amount: bn16(coin.amount),
4168
+ amount: bn15(coin.amount),
4370
4169
  owner: Address2.fromAddressOrString(coin.owner),
4371
- blockCreated: bn16(coin.blockCreated),
4372
- txCreatedIdx: bn16(coin.txCreatedIdx)
4170
+ maturity: bn15(coin.maturity).toNumber(),
4171
+ blockCreated: bn15(coin.blockCreated),
4172
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4373
4173
  }));
4374
4174
  }
4375
4175
  /**
@@ -4406,9 +4206,9 @@ var _Provider = class {
4406
4206
  switch (coin.__typename) {
4407
4207
  case "MessageCoin":
4408
4208
  return {
4409
- amount: bn16(coin.amount),
4209
+ amount: bn15(coin.amount),
4410
4210
  assetId: coin.assetId,
4411
- daHeight: bn16(coin.daHeight),
4211
+ daHeight: bn15(coin.daHeight),
4412
4212
  sender: Address2.fromAddressOrString(coin.sender),
4413
4213
  recipient: Address2.fromAddressOrString(coin.recipient),
4414
4214
  nonce: coin.nonce
@@ -4416,11 +4216,12 @@ var _Provider = class {
4416
4216
  case "Coin":
4417
4217
  return {
4418
4218
  id: coin.utxoId,
4419
- amount: bn16(coin.amount),
4219
+ amount: bn15(coin.amount),
4420
4220
  assetId: coin.assetId,
4421
4221
  owner: Address2.fromAddressOrString(coin.owner),
4422
- blockCreated: bn16(coin.blockCreated),
4423
- txCreatedIdx: bn16(coin.txCreatedIdx)
4222
+ maturity: bn15(coin.maturity).toNumber(),
4223
+ blockCreated: bn15(coin.blockCreated),
4224
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4424
4225
  };
4425
4226
  default:
4426
4227
  return null;
@@ -4437,13 +4238,13 @@ var _Provider = class {
4437
4238
  async getBlock(idOrHeight) {
4438
4239
  let variables;
4439
4240
  if (typeof idOrHeight === "number") {
4440
- variables = { height: bn16(idOrHeight).toString(10) };
4241
+ variables = { height: bn15(idOrHeight).toString(10) };
4441
4242
  } else if (idOrHeight === "latest") {
4442
4243
  variables = { height: (await this.getBlockNumber()).toString(10) };
4443
4244
  } else if (idOrHeight.length === 66) {
4444
4245
  variables = { blockId: idOrHeight };
4445
4246
  } else {
4446
- variables = { blockId: bn16(idOrHeight).toString(10) };
4247
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4447
4248
  }
4448
4249
  const { block } = await this.operations.getBlock(variables);
4449
4250
  if (!block) {
@@ -4451,7 +4252,7 @@ var _Provider = class {
4451
4252
  }
4452
4253
  return {
4453
4254
  id: block.id,
4454
- height: bn16(block.height),
4255
+ height: bn15(block.header.height),
4455
4256
  time: block.header.time,
4456
4257
  transactionIds: block.transactions.map((tx) => tx.id)
4457
4258
  };
@@ -4466,7 +4267,7 @@ var _Provider = class {
4466
4267
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4467
4268
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4468
4269
  id: block.id,
4469
- height: bn16(block.height),
4270
+ height: bn15(block.header.height),
4470
4271
  time: block.header.time,
4471
4272
  transactionIds: block.transactions.map((tx) => tx.id)
4472
4273
  }));
@@ -4481,7 +4282,7 @@ var _Provider = class {
4481
4282
  async getBlockWithTransactions(idOrHeight) {
4482
4283
  let variables;
4483
4284
  if (typeof idOrHeight === "number") {
4484
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4285
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4485
4286
  } else if (idOrHeight === "latest") {
4486
4287
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4487
4288
  } else {
@@ -4493,7 +4294,7 @@ var _Provider = class {
4493
4294
  }
4494
4295
  return {
4495
4296
  id: block.id,
4496
- height: bn16(block.height, 10),
4297
+ height: bn15(block.header.height, 10),
4497
4298
  time: block.header.time,
4498
4299
  transactionIds: block.transactions.map((tx) => tx.id),
4499
4300
  transactions: block.transactions.map(
@@ -4542,7 +4343,7 @@ var _Provider = class {
4542
4343
  contract: Address2.fromAddressOrString(contractId).toB256(),
4543
4344
  asset: hexlify12(assetId)
4544
4345
  });
4545
- return bn16(contractBalance.amount, 10);
4346
+ return bn15(contractBalance.amount, 10);
4546
4347
  }
4547
4348
  /**
4548
4349
  * Returns the balance for the given owner for the given asset ID.
@@ -4556,7 +4357,7 @@ var _Provider = class {
4556
4357
  owner: Address2.fromAddressOrString(owner).toB256(),
4557
4358
  assetId: hexlify12(assetId)
4558
4359
  });
4559
- return bn16(balance.amount, 10);
4360
+ return bn15(balance.amount, 10);
4560
4361
  }
4561
4362
  /**
4562
4363
  * Returns balances for the given owner.
@@ -4574,7 +4375,7 @@ var _Provider = class {
4574
4375
  const balances = result.balances.edges.map((edge) => edge.node);
4575
4376
  return balances.map((balance) => ({
4576
4377
  assetId: balance.assetId,
4577
- amount: bn16(balance.amount)
4378
+ amount: bn15(balance.amount)
4578
4379
  }));
4579
4380
  }
4580
4381
  /**
@@ -4596,15 +4397,15 @@ var _Provider = class {
4596
4397
  sender: message.sender,
4597
4398
  recipient: message.recipient,
4598
4399
  nonce: message.nonce,
4599
- amount: bn16(message.amount),
4400
+ amount: bn15(message.amount),
4600
4401
  data: message.data
4601
4402
  }),
4602
4403
  sender: Address2.fromAddressOrString(message.sender),
4603
4404
  recipient: Address2.fromAddressOrString(message.recipient),
4604
4405
  nonce: message.nonce,
4605
- amount: bn16(message.amount),
4406
+ amount: bn15(message.amount),
4606
4407
  data: InputMessageCoder.decodeData(message.data),
4607
- daHeight: bn16(message.daHeight)
4408
+ daHeight: bn15(message.daHeight)
4608
4409
  }));
4609
4410
  }
4610
4411
  /**
@@ -4657,52 +4458,44 @@ var _Provider = class {
4657
4458
  } = result.messageProof;
4658
4459
  return {
4659
4460
  messageProof: {
4660
- proofIndex: bn16(messageProof.proofIndex),
4461
+ proofIndex: bn15(messageProof.proofIndex),
4661
4462
  proofSet: messageProof.proofSet
4662
4463
  },
4663
4464
  blockProof: {
4664
- proofIndex: bn16(blockProof.proofIndex),
4465
+ proofIndex: bn15(blockProof.proofIndex),
4665
4466
  proofSet: blockProof.proofSet
4666
4467
  },
4667
4468
  messageBlockHeader: {
4668
4469
  id: messageBlockHeader.id,
4669
- daHeight: bn16(messageBlockHeader.daHeight),
4670
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4470
+ daHeight: bn15(messageBlockHeader.daHeight),
4471
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4671
4472
  transactionsRoot: messageBlockHeader.transactionsRoot,
4672
- height: bn16(messageBlockHeader.height),
4473
+ height: bn15(messageBlockHeader.height),
4673
4474
  prevRoot: messageBlockHeader.prevRoot,
4674
4475
  time: messageBlockHeader.time,
4675
4476
  applicationHash: messageBlockHeader.applicationHash,
4676
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount)
4477
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4478
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4677
4479
  },
4678
4480
  commitBlockHeader: {
4679
4481
  id: commitBlockHeader.id,
4680
- daHeight: bn16(commitBlockHeader.daHeight),
4681
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4482
+ daHeight: bn15(commitBlockHeader.daHeight),
4483
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4682
4484
  transactionsRoot: commitBlockHeader.transactionsRoot,
4683
- height: bn16(commitBlockHeader.height),
4485
+ height: bn15(commitBlockHeader.height),
4684
4486
  prevRoot: commitBlockHeader.prevRoot,
4685
4487
  time: commitBlockHeader.time,
4686
4488
  applicationHash: commitBlockHeader.applicationHash,
4687
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount)
4489
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4490
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4688
4491
  },
4689
4492
  sender: Address2.fromAddressOrString(sender),
4690
4493
  recipient: Address2.fromAddressOrString(recipient),
4691
4494
  nonce,
4692
- amount: bn16(amount),
4495
+ amount: bn15(amount),
4693
4496
  data
4694
4497
  };
4695
4498
  }
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
4499
  /**
4707
4500
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4708
4501
  *
@@ -4722,10 +4515,10 @@ var _Provider = class {
4722
4515
  */
4723
4516
  async produceBlocks(amount, startTime) {
4724
4517
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4725
- blocksToProduce: bn16(amount).toString(10),
4518
+ blocksToProduce: bn15(amount).toString(10),
4726
4519
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4727
4520
  });
4728
- return bn16(latestBlockHeight);
4521
+ return bn15(latestBlockHeight);
4729
4522
  }
4730
4523
  // eslint-disable-next-line @typescript-eslint/require-await
4731
4524
  async getTransactionResponse(transactionId) {
@@ -4739,7 +4532,7 @@ cacheInputs_fn = function(inputs) {
4739
4532
  return;
4740
4533
  }
4741
4534
  inputs.forEach((input) => {
4742
- if (input.type === InputType7.Coin) {
4535
+ if (input.type === InputType6.Coin) {
4743
4536
  this.cache?.set(input.id);
4744
4537
  }
4745
4538
  });
@@ -4749,7 +4542,7 @@ __publicField(Provider, "nodeInfoCache", {});
4749
4542
 
4750
4543
  // src/providers/transaction-summary/get-transaction-summary.ts
4751
4544
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4752
- import { bn as bn17 } from "@fuel-ts/math";
4545
+ import { bn as bn16 } from "@fuel-ts/math";
4753
4546
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4754
4547
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4755
4548
  async function getTransactionSummary(params) {
@@ -4767,28 +4560,21 @@ async function getTransactionSummary(params) {
4767
4560
  arrayify12(gqlTransaction.rawPayload),
4768
4561
  0
4769
4562
  );
4770
- let txReceipts = [];
4771
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4772
- txReceipts = gqlTransaction.status.receipts;
4773
- }
4774
- const receipts = txReceipts.map(processGqlReceipt);
4563
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4775
4564
  const {
4776
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4565
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4777
4566
  } = provider.getChain();
4778
- const gasPrice = await provider.getLatestGasPrice();
4779
4567
  const transactionInfo = assembleTransactionSummary({
4780
4568
  id: gqlTransaction.id,
4781
4569
  receipts,
4782
4570
  transaction: decodedTransaction,
4783
4571
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4784
4572
  gqlTransactionStatus: gqlTransaction.status,
4785
- gasPerByte: bn17(gasPerByte),
4786
- gasPriceFactor: bn17(gasPriceFactor),
4573
+ gasPerByte: bn16(gasPerByte),
4574
+ gasPriceFactor: bn16(gasPriceFactor),
4787
4575
  abiMap,
4788
4576
  maxInputs,
4789
- gasCosts,
4790
- maxGasPerTx,
4791
- gasPrice
4577
+ gasCosts
4792
4578
  });
4793
4579
  return {
4794
4580
  gqlTransaction,
@@ -4798,11 +4584,10 @@ async function getTransactionSummary(params) {
4798
4584
  async function getTransactionSummaryFromRequest(params) {
4799
4585
  const { provider, transactionRequest, abiMap } = params;
4800
4586
  const { receipts } = await provider.call(transactionRequest);
4801
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4587
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4802
4588
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4803
4589
  const transaction = transactionRequest.toTransaction();
4804
4590
  const transactionBytes = transactionRequest.toTransactionBytes();
4805
- const gasPrice = await provider.getLatestGasPrice();
4806
4591
  const transactionSummary = assembleTransactionSummary({
4807
4592
  receipts,
4808
4593
  transaction,
@@ -4811,9 +4596,7 @@ async function getTransactionSummaryFromRequest(params) {
4811
4596
  gasPerByte,
4812
4597
  gasPriceFactor,
4813
4598
  maxInputs,
4814
- gasCosts,
4815
- maxGasPerTx,
4816
- gasPrice
4599
+ gasCosts
4817
4600
  });
4818
4601
  return transactionSummary;
4819
4602
  }
@@ -4822,18 +4605,13 @@ async function getTransactionsSummaries(params) {
4822
4605
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4823
4606
  const { edges, pageInfo } = transactionsByOwner;
4824
4607
  const {
4825
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4608
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4826
4609
  } = provider.getChain();
4827
- const gasPrice = await provider.getLatestGasPrice();
4828
4610
  const transactions = edges.map((edge) => {
4829
4611
  const { node: gqlTransaction } = edge;
4830
- const { id, rawPayload, status } = gqlTransaction;
4612
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4831
4613
  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);
4614
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4837
4615
  const transactionSummary = assembleTransactionSummary({
4838
4616
  id,
4839
4617
  receipts,
@@ -4844,9 +4622,7 @@ async function getTransactionsSummaries(params) {
4844
4622
  gasPerByte,
4845
4623
  gasPriceFactor,
4846
4624
  maxInputs,
4847
- gasCosts,
4848
- maxGasPerTx,
4849
- gasPrice
4625
+ gasCosts
4850
4626
  });
4851
4627
  const output = {
4852
4628
  gqlTransaction,
@@ -5178,33 +4954,36 @@ var Account = class extends AbstractAccount {
5178
4954
  * @param fee - The estimated transaction fee.
5179
4955
  * @returns A promise that resolves when the resources are added to the transaction.
5180
4956
  */
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),
4957
+ async fund(request, coinQuantities, fee) {
4958
+ const updatedQuantities = addAmountToAsset({
4959
+ amount: bn17(fee),
5186
4960
  assetId: BaseAssetId3,
5187
- coinQuantities: requiredQuantities
4961
+ coinQuantities
5188
4962
  });
5189
4963
  const quantitiesDict = {};
5190
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4964
+ updatedQuantities.forEach(({ amount, assetId }) => {
5191
4965
  quantitiesDict[assetId] = {
5192
4966
  required: amount,
5193
- owned: bn18(0)
4967
+ owned: bn17(0)
5194
4968
  };
5195
4969
  });
5196
- txRequest.inputs.forEach((input) => {
4970
+ const cachedUtxos = [];
4971
+ const cachedMessages = [];
4972
+ const owner = this.address.toB256();
4973
+ request.inputs.forEach((input) => {
5197
4974
  const isResource = "amount" in input;
5198
4975
  if (isResource) {
5199
4976
  const isCoin2 = "owner" in input;
5200
4977
  if (isCoin2) {
5201
4978
  const assetId = String(input.assetId);
5202
- if (quantitiesDict[assetId]) {
5203
- const amount = bn18(input.amount);
4979
+ if (input.owner === owner && quantitiesDict[assetId]) {
4980
+ const amount = bn17(input.amount);
5204
4981
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4982
+ cachedUtxos.push(input.id);
5205
4983
  }
5206
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4984
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
5207
4985
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4986
+ cachedMessages.push(input.nonce);
5208
4987
  }
5209
4988
  }
5210
4989
  });
@@ -5219,23 +4998,12 @@ var Account = class extends AbstractAccount {
5219
4998
  });
5220
4999
  const needsToBeFunded = missingQuantities.length;
5221
5000
  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
- );
5001
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5002
+ messages: cachedMessages,
5003
+ utxos: cachedUtxos
5004
+ });
5005
+ request.addResources(resources);
5233
5006
  }
5234
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5235
- transactionRequest: requestToBeReEstimate
5236
- });
5237
- txRequest.maxFee = maxFee;
5238
- return txRequest;
5239
5007
  }
5240
5008
  /**
5241
5009
  * A helper that creates a transfer transaction request and returns it.
@@ -5243,25 +5011,28 @@ var Account = class extends AbstractAccount {
5243
5011
  * @param destination - The address of the destination.
5244
5012
  * @param amount - The amount of coins to transfer.
5245
5013
  * @param assetId - The asset ID of the coins to transfer.
5246
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5014
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5247
5015
  * @returns A promise that resolves to the prepared transaction request.
5248
5016
  */
5249
5017
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5250
- const request = new ScriptTransactionRequest(txParams);
5018
+ const { minGasPrice } = this.provider.getGasConfig();
5019
+ const params = { gasPrice: minGasPrice, ...txParams };
5020
+ const request = new ScriptTransactionRequest(params);
5251
5021
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5252
- const txCost = await this.provider.getTransactionCost(request, {
5022
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5253
5023
  estimateTxDependencies: true,
5254
5024
  resourcesOwner: this
5255
5025
  });
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);
5026
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5027
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
5028
+ this.validateGas({
5029
+ gasUsed,
5030
+ gasPrice: request.gasPrice,
5031
+ gasLimit: request.gasLimit,
5032
+ minGasPrice
5033
+ });
5034
+ await this.fund(request, requiredQuantities, maxFee);
5035
+ request.updatePredicateInputs(estimatedInputs);
5265
5036
  return request;
5266
5037
  }
5267
5038
  /**
@@ -5274,7 +5045,7 @@ var Account = class extends AbstractAccount {
5274
5045
  * @returns A promise that resolves to the transaction response.
5275
5046
  */
5276
5047
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5277
- if (bn18(amount).lte(0)) {
5048
+ if (bn17(amount).lte(0)) {
5278
5049
  throw new FuelError15(
5279
5050
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5280
5051
  "Transfer amount must be a positive number."
@@ -5293,37 +5064,38 @@ var Account = class extends AbstractAccount {
5293
5064
  * @returns A promise that resolves to the transaction response.
5294
5065
  */
5295
5066
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5296
- if (bn18(amount).lte(0)) {
5067
+ if (bn17(amount).lte(0)) {
5297
5068
  throw new FuelError15(
5298
5069
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5299
5070
  "Transfer amount must be a positive number."
5300
5071
  );
5301
5072
  }
5302
5073
  const contractAddress = Address3.fromAddressOrString(contractId);
5074
+ const { minGasPrice } = this.provider.getGasConfig();
5075
+ const params = { gasPrice: minGasPrice, ...txParams };
5303
5076
  const { script, scriptData } = await assembleTransferToContractScript({
5304
5077
  hexlifiedContractId: contractAddress.toB256(),
5305
- amountToTransfer: bn18(amount),
5078
+ amountToTransfer: bn17(amount),
5306
5079
  assetId
5307
5080
  });
5308
5081
  const request = new ScriptTransactionRequest({
5309
- ...txParams,
5082
+ ...params,
5310
5083
  script,
5311
5084
  scriptData
5312
5085
  });
5313
5086
  request.addContractInputAndOutput(contractAddress);
5314
- const txCost = await this.provider.getTransactionCost(request, {
5315
- resourcesOwner: this,
5316
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
5087
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5088
+ request,
5089
+ [{ amount: bn17(amount), assetId: String(assetId) }]
5090
+ );
5091
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5092
+ this.validateGas({
5093
+ gasUsed,
5094
+ gasPrice: request.gasPrice,
5095
+ gasLimit: request.gasLimit,
5096
+ minGasPrice
5317
5097
  });
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);
5098
+ await this.fund(request, requiredQuantities, maxFee);
5327
5099
  return this.sendTransaction(request);
5328
5100
  }
5329
5101
  /**
@@ -5335,31 +5107,34 @@ var Account = class extends AbstractAccount {
5335
5107
  * @returns A promise that resolves to the transaction response.
5336
5108
  */
5337
5109
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5110
+ const { minGasPrice } = this.provider.getGasConfig();
5338
5111
  const recipientAddress = Address3.fromAddressOrString(recipient);
5339
5112
  const recipientDataArray = arrayify14(
5340
5113
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5341
5114
  );
5342
5115
  const amountDataArray = arrayify14(
5343
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
5116
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5344
5117
  );
5345
5118
  const script = new Uint8Array([
5346
5119
  ...arrayify14(withdrawScript.bytes),
5347
5120
  ...recipientDataArray,
5348
5121
  ...amountDataArray
5349
5122
  ]);
5350
- const params = { script, ...txParams };
5123
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5351
5124
  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);
5125
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5126
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5127
+ request,
5128
+ forwardingQuantities
5129
+ );
5130
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5131
+ this.validateGas({
5132
+ gasUsed,
5133
+ gasPrice: request.gasPrice,
5134
+ gasLimit: request.gasLimit,
5135
+ minGasPrice
5136
+ });
5137
+ await this.fund(request, requiredQuantities, maxFee);
5363
5138
  return this.sendTransaction(request);
5364
5139
  }
5365
5140
  async signMessage(message) {
@@ -5417,7 +5192,18 @@ var Account = class extends AbstractAccount {
5417
5192
  }
5418
5193
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5419
5194
  }
5420
- validateGas({ gasUsed, gasLimit }) {
5195
+ validateGas({
5196
+ gasUsed,
5197
+ gasPrice,
5198
+ gasLimit,
5199
+ minGasPrice
5200
+ }) {
5201
+ if (minGasPrice.gt(gasPrice)) {
5202
+ throw new FuelError15(
5203
+ ErrorCode15.GAS_PRICE_TOO_LOW,
5204
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5205
+ );
5206
+ }
5421
5207
  if (gasUsed.gt(gasLimit)) {
5422
5208
  throw new FuelError15(
5423
5209
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5713,7 +5499,7 @@ var BaseWalletUnlocked = class extends Account {
5713
5499
  * @param transactionRequestLike - The transaction request to send.
5714
5500
  * @returns A promise that resolves to the TransactionResponse object.
5715
5501
  */
5716
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5502
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5717
5503
  const transactionRequest = transactionRequestify(transactionRequestLike);
5718
5504
  if (estimateTxDependencies) {
5719
5505
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5754,7 +5540,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5754
5540
  // src/hdwallet/hdwallet.ts
5755
5541
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5756
5542
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5757
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5543
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5758
5544
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5759
5545
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5760
5546
 
@@ -8226,7 +8012,7 @@ var HDWallet = class {
8226
8012
  const IR = bytes.slice(32);
8227
8013
  if (privateKey) {
8228
8014
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8229
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
8015
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
8230
8016
  return new HDWallet({
8231
8017
  privateKey: ki,
8232
8018
  chainCode: IR,
@@ -8915,7 +8701,7 @@ import {
8915
8701
  import { Address as Address9 } from "@fuel-ts/address";
8916
8702
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8917
8703
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8918
- import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
8704
+ import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8919
8705
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8920
8706
 
8921
8707
  // src/predicate/utils/getPredicateRoot.ts
@@ -8934,7 +8720,6 @@ var getPredicateRoot = (bytecode) => {
8934
8720
  // src/predicate/predicate.ts
8935
8721
  var Predicate = class extends Account {
8936
8722
  bytes;
8937
- predicateDataBytes = Uint8Array.from([]);
8938
8723
  predicateData = [];
8939
8724
  interface;
8940
8725
  /**
@@ -8964,7 +8749,6 @@ var Predicate = class extends Account {
8964
8749
  this.interface = predicateInterface;
8965
8750
  if (inputData !== void 0 && inputData.length > 0) {
8966
8751
  this.predicateData = inputData;
8967
- this.predicateDataBytes = this.getPredicateData(0);
8968
8752
  }
8969
8753
  }
8970
8754
  /**
@@ -8977,9 +8761,9 @@ var Predicate = class extends Account {
8977
8761
  const request = transactionRequestify(transactionRequestLike);
8978
8762
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8979
8763
  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));
8764
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8765
+ input.predicate = this.bytes;
8766
+ input.predicateData = this.getPredicateData(policies.length);
8983
8767
  }
8984
8768
  });
8985
8769
  return request;
@@ -8994,7 +8778,8 @@ var Predicate = class extends Account {
8994
8778
  * @returns A promise that resolves to the prepared transaction request.
8995
8779
  */
8996
8780
  async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
8997
- return super.createTransfer(destination, amount, assetId, txParams);
8781
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8782
+ return this.populateTransactionPredicateData(request);
8998
8783
  }
8999
8784
  /**
9000
8785
  * Sends a transaction with the populated predicate data.
@@ -9002,9 +8787,9 @@ var Predicate = class extends Account {
9002
8787
  * @param transactionRequestLike - The transaction request-like object.
9003
8788
  * @returns A promise that resolves to the transaction response.
9004
8789
  */
9005
- sendTransaction(transactionRequestLike) {
9006
- const transactionRequest = transactionRequestify(transactionRequestLike);
9007
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8790
+ sendTransaction(transactionRequestLike, options) {
8791
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8792
+ return super.sendTransaction(transactionRequest, options);
9008
8793
  }
9009
8794
  /**
9010
8795
  * Simulates a transaction with the populated predicate data.
@@ -9013,8 +8798,8 @@ var Predicate = class extends Account {
9013
8798
  * @returns A promise that resolves to the call result.
9014
8799
  */
9015
8800
  simulateTransaction(transactionRequestLike) {
9016
- const transactionRequest = transactionRequestify(transactionRequestLike);
9017
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8801
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8802
+ return super.simulateTransaction(transactionRequest);
9018
8803
  }
9019
8804
  getPredicateData(policiesLength) {
9020
8805
  if (!this.predicateData.length) {
@@ -9060,26 +8845,6 @@ var Predicate = class extends Account {
9060
8845
  predicateInterface: abiInterface
9061
8846
  };
9062
8847
  }
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
8848
  /**
9084
8849
  * Sets the configurable constants for the predicate.
9085
8850
  *
@@ -9828,7 +9593,7 @@ export {
9828
9593
  WalletLocked,
9829
9594
  WalletManager,
9830
9595
  WalletUnlocked,
9831
- addAmountToCoinQuantities,
9596
+ addAmountToAsset,
9832
9597
  addOperation,
9833
9598
  assemblePanicError,
9834
9599
  assembleReceiptByType,
@@ -9837,10 +9602,9 @@ export {
9837
9602
  assets,
9838
9603
  buildBlockExplorerUrl,
9839
9604
  cacheFor,
9840
- cacheTxInputsFromOwner,
9841
- calculateGasFee,
9842
9605
  calculateMetadataGasForTxCreate,
9843
9606
  calculateMetadataGasForTxScript,
9607
+ calculatePriceWithFactor,
9844
9608
  calculateTransactionFee,
9845
9609
  coinQuantityfy,
9846
9610
  deferPromise,