@fuel-ts/account 0.0.0-rc-1976-20240411153008 → 0.0.0-rc-2021-20240411154255

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 (57) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +5 -4
  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 +896 -629
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +874 -621
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +716 -464
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -2
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +906 -324
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +3 -3
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +4 -2
  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 +7 -1
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +45 -34
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  31. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/input.d.ts +2 -2
  33. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
  35. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/transaction-request.d.ts +9 -29
  37. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  38. package/dist/providers/transaction-request/utils.d.ts +3 -0
  39. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  40. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
  42. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
  44. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  45. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  46. package/dist/providers/utils/gas.d.ts +8 -2
  47. package/dist/providers/utils/gas.d.ts.map +1 -1
  48. package/dist/test-utils/launchNode.d.ts.map +1 -1
  49. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  50. package/dist/test-utils.global.js +1613 -1132
  51. package/dist/test-utils.global.js.map +1 -1
  52. package/dist/test-utils.js +852 -620
  53. package/dist/test-utils.js.map +1 -1
  54. package/dist/test-utils.mjs +710 -478
  55. package/dist/test-utils.mjs.map +1 -1
  56. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  57. package/package.json +17 -17
package/dist/index.mjs CHANGED
@@ -29,35 +29,38 @@ var __privateMethod = (obj, member, method) => {
29
29
 
30
30
  // src/account.ts
31
31
  import { Address as Address3 } from "@fuel-ts/address";
32
+ import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
32
33
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
33
34
  import { AbstractAccount } from "@fuel-ts/interfaces";
34
- import { bn as bn17 } from "@fuel-ts/math";
35
+ import { bn as bn18 } from "@fuel-ts/math";
35
36
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
37
+ import { clone as clone4 } from "ramda";
36
38
 
37
39
  // src/providers/coin-quantity.ts
40
+ import { BaseAssetId } from "@fuel-ts/address/configs";
38
41
  import { bn } from "@fuel-ts/math";
39
42
  import { hexlify } from "@fuel-ts/utils";
40
43
  var coinQuantityfy = (coinQuantityLike) => {
41
44
  let assetId;
42
45
  let amount;
43
- let max2;
46
+ let max;
44
47
  if (Array.isArray(coinQuantityLike)) {
45
48
  amount = coinQuantityLike[0];
46
- assetId = coinQuantityLike[1];
47
- max2 = coinQuantityLike[2];
49
+ assetId = coinQuantityLike[1] ?? BaseAssetId;
50
+ max = coinQuantityLike[2] ?? void 0;
48
51
  } else {
49
52
  amount = coinQuantityLike.amount;
50
- assetId = coinQuantityLike.assetId;
51
- max2 = coinQuantityLike.max ?? void 0;
53
+ assetId = coinQuantityLike.assetId ?? BaseAssetId;
54
+ max = coinQuantityLike.max ?? void 0;
52
55
  }
53
56
  const bnAmount = bn(amount);
54
57
  return {
55
58
  assetId: hexlify(assetId),
56
59
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
57
- max: max2 ? bn(max2) : void 0
60
+ max: max ? bn(max) : void 0
58
61
  };
59
62
  };
60
- var addAmountToAsset = (params) => {
63
+ var addAmountToCoinQuantities = (params) => {
61
64
  const { amount, assetId } = params;
62
65
  const coinQuantities = [...params.coinQuantities];
63
66
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -72,9 +75,9 @@ var addAmountToAsset = (params) => {
72
75
  // src/providers/provider.ts
73
76
  import { Address as Address2 } from "@fuel-ts/address";
74
77
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
75
- import { BN, bn as bn15, max } from "@fuel-ts/math";
78
+ import { BN, bn as bn16 } from "@fuel-ts/math";
76
79
  import {
77
- InputType as InputType6,
80
+ InputType as InputType7,
78
81
  TransactionType as TransactionType8,
79
82
  InputMessageCoder,
80
83
  TransactionCoder as TransactionCoder5
@@ -90,14 +93,10 @@ import { clone as clone3 } from "ramda";
90
93
  import gql from "graphql-tag";
91
94
  var ReceiptFragmentFragmentDoc = gql`
92
95
  fragment receiptFragment on Receipt {
93
- contract {
94
- id
95
- }
96
+ id
96
97
  pc
97
98
  is
98
- to {
99
- id
100
- }
99
+ to
101
100
  toAddress
102
101
  amount
103
102
  assetId
@@ -135,10 +134,16 @@ var TransactionStatusFragmentFragmentDoc = gql`
135
134
  id
136
135
  }
137
136
  time
137
+ receipts {
138
+ ...receiptFragment
139
+ }
138
140
  programState {
139
141
  returnType
140
142
  data
141
143
  }
144
+ receipts {
145
+ ...receiptFragment
146
+ }
142
147
  }
143
148
  ... on FailureStatus {
144
149
  block {
@@ -146,26 +151,24 @@ var TransactionStatusFragmentFragmentDoc = gql`
146
151
  }
147
152
  time
148
153
  reason
154
+ receipts {
155
+ ...receiptFragment
156
+ }
149
157
  }
150
158
  ... on SqueezedOutStatus {
151
159
  reason
152
160
  }
153
161
  }
154
- `;
162
+ ${ReceiptFragmentFragmentDoc}`;
155
163
  var TransactionFragmentFragmentDoc = gql`
156
164
  fragment transactionFragment on Transaction {
157
165
  id
158
166
  rawPayload
159
- gasPrice
160
- receipts {
161
- ...receiptFragment
162
- }
163
167
  status {
164
168
  ...transactionStatusFragment
165
169
  }
166
170
  }
167
- ${ReceiptFragmentFragmentDoc}
168
- ${TransactionStatusFragmentFragmentDoc}`;
171
+ ${TransactionStatusFragmentFragmentDoc}`;
169
172
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
170
173
  fragment inputEstimatePredicatesFragment on Input {
171
174
  ... on InputCoin {
@@ -183,6 +186,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
183
186
  }
184
187
  }
185
188
  ${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}`;
186
229
  var CoinFragmentFragmentDoc = gql`
187
230
  fragment coinFragment on Coin {
188
231
  __typename
@@ -190,7 +233,6 @@ var CoinFragmentFragmentDoc = gql`
190
233
  owner
191
234
  amount
192
235
  assetId
193
- maturity
194
236
  blockCreated
195
237
  txCreatedIdx
196
238
  }
@@ -229,26 +271,32 @@ var MessageProofFragmentFragmentDoc = gql`
229
271
  messageBlockHeader {
230
272
  id
231
273
  daHeight
274
+ consensusParametersVersion
275
+ stateTransitionBytecodeVersion
232
276
  transactionsCount
277
+ messageReceiptCount
233
278
  transactionsRoot
279
+ messageOutboxRoot
280
+ eventInboxRoot
234
281
  height
235
282
  prevRoot
236
283
  time
237
284
  applicationHash
238
- messageReceiptRoot
239
- messageReceiptCount
240
285
  }
241
286
  commitBlockHeader {
242
287
  id
243
288
  daHeight
289
+ consensusParametersVersion
290
+ stateTransitionBytecodeVersion
244
291
  transactionsCount
292
+ messageReceiptCount
245
293
  transactionsRoot
294
+ messageOutboxRoot
295
+ eventInboxRoot
246
296
  height
247
297
  prevRoot
248
298
  time
249
299
  applicationHash
250
- messageReceiptRoot
251
- messageReceiptCount
252
300
  }
253
301
  sender
254
302
  recipient
@@ -267,8 +315,8 @@ var BalanceFragmentFragmentDoc = gql`
267
315
  var BlockFragmentFragmentDoc = gql`
268
316
  fragment blockFragment on Block {
269
317
  id
318
+ height
270
319
  header {
271
- height
272
320
  time
273
321
  }
274
322
  transactions {
@@ -326,6 +374,11 @@ var DependentCostFragmentFragmentDoc = gql`
326
374
  `;
327
375
  var GasCostsFragmentFragmentDoc = gql`
328
376
  fragment GasCostsFragment on GasCosts {
377
+ version {
378
+ ... on Version {
379
+ value
380
+ }
381
+ }
329
382
  add
330
383
  addi
331
384
  aloc
@@ -338,7 +391,6 @@ var GasCostsFragmentFragmentDoc = gql`
338
391
  cb
339
392
  cfei
340
393
  cfsi
341
- croo
342
394
  div
343
395
  divi
344
396
  ecr1
@@ -421,6 +473,9 @@ var GasCostsFragmentFragmentDoc = gql`
421
473
  ccp {
422
474
  ...DependentCostFragment
423
475
  }
476
+ croo {
477
+ ...DependentCostFragment
478
+ }
424
479
  csiz {
425
480
  ...DependentCostFragment
426
481
  }
@@ -480,6 +535,11 @@ var GasCostsFragmentFragmentDoc = gql`
480
535
  ${DependentCostFragmentFragmentDoc}`;
481
536
  var ConsensusParametersFragmentFragmentDoc = gql`
482
537
  fragment consensusParametersFragment on ConsensusParameters {
538
+ version {
539
+ ... on Version {
540
+ value
541
+ }
542
+ }
483
543
  txParams {
484
544
  ...TxParametersFragment
485
545
  }
@@ -539,18 +599,9 @@ var NodeInfoFragmentFragmentDoc = gql`
539
599
  fragment nodeInfoFragment on NodeInfo {
540
600
  utxoValidation
541
601
  vmBacktrace
542
- minGasPrice
543
602
  maxTx
544
603
  maxDepth
545
604
  nodeVersion
546
- peers {
547
- id
548
- addresses
549
- clientVersion
550
- blockHeight
551
- lastHeartbeatMs
552
- appScore
553
- }
554
605
  }
555
606
  `;
556
607
  var GetVersionDocument = gql`
@@ -585,13 +636,9 @@ var GetTransactionWithReceiptsDocument = gql`
585
636
  query getTransactionWithReceipts($transactionId: TransactionId!) {
586
637
  transaction(id: $transactionId) {
587
638
  ...transactionFragment
588
- receipts {
589
- ...receiptFragment
590
- }
591
639
  }
592
640
  }
593
- ${TransactionFragmentFragmentDoc}
594
- ${ReceiptFragmentFragmentDoc}`;
641
+ ${TransactionFragmentFragmentDoc}`;
595
642
  var GetTransactionsDocument = gql`
596
643
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
597
644
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -719,6 +766,20 @@ var GetBalanceDocument = gql`
719
766
  }
720
767
  }
721
768
  ${BalanceFragmentFragmentDoc}`;
769
+ var GetLatestGasPriceDocument = gql`
770
+ query getLatestGasPrice {
771
+ latestGasPrice {
772
+ gasPrice
773
+ }
774
+ }
775
+ `;
776
+ var EstimateGasPriceDocument = gql`
777
+ query estimateGasPrice($blockHorizon: U32!) {
778
+ estimateGasPrice(blockHorizon: $blockHorizon) {
779
+ gasPrice
780
+ }
781
+ }
782
+ `;
722
783
  var GetBalancesDocument = gql`
723
784
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
724
785
  balances(
@@ -773,12 +834,12 @@ var GetMessageStatusDocument = gql`
773
834
  }
774
835
  `;
775
836
  var DryRunDocument = gql`
776
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
777
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
778
- ...receiptFragment
837
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
838
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
839
+ ...dryRunTransactionExecutionStatusFragment
779
840
  }
780
841
  }
781
- ${ReceiptFragmentFragmentDoc}`;
842
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
782
843
  var SubmitDocument = gql`
783
844
  mutation submit($encodedTransaction: HexString!) {
784
845
  submit(tx: $encodedTransaction) {
@@ -861,6 +922,12 @@ function getSdk(requester) {
861
922
  getBalance(variables, options) {
862
923
  return requester(GetBalanceDocument, variables, options);
863
924
  },
925
+ getLatestGasPrice(variables, options) {
926
+ return requester(GetLatestGasPriceDocument, variables, options);
927
+ },
928
+ estimateGasPrice(variables, options) {
929
+ return requester(EstimateGasPriceDocument, variables, options);
930
+ },
864
931
  getBalances(variables, options) {
865
932
  return requester(GetBalancesDocument, variables, options);
866
933
  },
@@ -930,11 +997,14 @@ var _FuelGraphqlSubscriber = class {
930
997
  let data;
931
998
  let errors;
932
999
  try {
933
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1000
+ const sanitizedText = text.replace(/\s/g, "");
1001
+ ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
934
1002
  } catch (e) {
935
1003
  throw new FuelError(
936
1004
  ErrorCode.STREAM_PARSING_ERROR,
937
- `Error while parsing stream data response: ${text}`
1005
+ `Error while parsing stream data response: ${text}
1006
+
1007
+ Thrown error: ${e}`
938
1008
  );
939
1009
  }
940
1010
  if (Array.isArray(errors)) {
@@ -1035,7 +1105,7 @@ var inputify = (value) => {
1035
1105
  return {
1036
1106
  type: InputType.Coin,
1037
1107
  txID: hexlify3(arrayify(value.id).slice(0, 32)),
1038
- outputIndex: arrayify(value.id)[32],
1108
+ outputIndex: toNumber(arrayify(value.id).slice(32, 34)),
1039
1109
  owner: hexlify3(value.owner),
1040
1110
  amount: bn2(value.amount),
1041
1111
  assetId: hexlify3(value.assetId),
@@ -1044,10 +1114,9 @@ var inputify = (value) => {
1044
1114
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1045
1115
  },
1046
1116
  witnessIndex: value.witnessIndex,
1047
- maturity: value.maturity ?? 0,
1048
1117
  predicateGasUsed: bn2(value.predicateGasUsed),
1049
- predicateLength: predicate.length,
1050
- predicateDataLength: predicateData.length,
1118
+ predicateLength: bn2(predicate.length),
1119
+ predicateDataLength: bn2(predicateData.length),
1051
1120
  predicate: hexlify3(predicate),
1052
1121
  predicateData: hexlify3(predicateData)
1053
1122
  };
@@ -1078,8 +1147,8 @@ var inputify = (value) => {
1078
1147
  nonce: hexlify3(value.nonce),
1079
1148
  witnessIndex: value.witnessIndex,
1080
1149
  predicateGasUsed: bn2(value.predicateGasUsed),
1081
- predicateLength: predicate.length,
1082
- predicateDataLength: predicateData.length,
1150
+ predicateLength: bn2(predicate.length),
1151
+ predicateDataLength: bn2(predicateData.length),
1083
1152
  predicate: hexlify3(predicate),
1084
1153
  predicateData: hexlify3(predicateData),
1085
1154
  data: hexlify3(data),
@@ -1154,7 +1223,7 @@ var outputify = (value) => {
1154
1223
 
1155
1224
  // src/providers/transaction-request/transaction-request.ts
1156
1225
  import { Address, addressify } from "@fuel-ts/address";
1157
- import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1226
+ import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1158
1227
  import { bn as bn7 } from "@fuel-ts/math";
1159
1228
  import {
1160
1229
  PolicyType,
@@ -1164,6 +1233,7 @@ import {
1164
1233
  TransactionType
1165
1234
  } from "@fuel-ts/transactions";
1166
1235
  import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1236
+ import { randomBytes } from "ethers";
1167
1237
 
1168
1238
  // src/providers/resource.ts
1169
1239
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1207,8 +1277,8 @@ function assembleReceiptByType(receipt) {
1207
1277
  case "CALL" /* Call */: {
1208
1278
  const callReceipt = {
1209
1279
  type: ReceiptType.Call,
1210
- from: hexOrZero(receipt.contract?.id),
1211
- to: hexOrZero(receipt?.to?.id),
1280
+ from: hexOrZero(receipt.id || receipt.contractId),
1281
+ to: hexOrZero(receipt?.to),
1212
1282
  amount: bn4(receipt.amount),
1213
1283
  assetId: hexOrZero(receipt.assetId),
1214
1284
  gas: bn4(receipt.gas),
@@ -1222,7 +1292,7 @@ function assembleReceiptByType(receipt) {
1222
1292
  case "RETURN" /* Return */: {
1223
1293
  const returnReceipt = {
1224
1294
  type: ReceiptType.Return,
1225
- id: hexOrZero(receipt.contract?.id),
1295
+ id: hexOrZero(receipt.id || receipt.contractId),
1226
1296
  val: bn4(receipt.val),
1227
1297
  pc: bn4(receipt.pc),
1228
1298
  is: bn4(receipt.is)
@@ -1232,7 +1302,7 @@ function assembleReceiptByType(receipt) {
1232
1302
  case "RETURN_DATA" /* ReturnData */: {
1233
1303
  const returnDataReceipt = {
1234
1304
  type: ReceiptType.ReturnData,
1235
- id: hexOrZero(receipt.contract?.id),
1305
+ id: hexOrZero(receipt.id || receipt.contractId),
1236
1306
  ptr: bn4(receipt.ptr),
1237
1307
  len: bn4(receipt.len),
1238
1308
  digest: hexOrZero(receipt.digest),
@@ -1244,7 +1314,7 @@ function assembleReceiptByType(receipt) {
1244
1314
  case "PANIC" /* Panic */: {
1245
1315
  const panicReceipt = {
1246
1316
  type: ReceiptType.Panic,
1247
- id: hexOrZero(receipt.contract?.id),
1317
+ id: hexOrZero(receipt.id),
1248
1318
  reason: bn4(receipt.reason),
1249
1319
  pc: bn4(receipt.pc),
1250
1320
  is: bn4(receipt.is),
@@ -1255,7 +1325,7 @@ function assembleReceiptByType(receipt) {
1255
1325
  case "REVERT" /* Revert */: {
1256
1326
  const revertReceipt = {
1257
1327
  type: ReceiptType.Revert,
1258
- id: hexOrZero(receipt.contract?.id),
1328
+ id: hexOrZero(receipt.id || receipt.contractId),
1259
1329
  val: bn4(receipt.ra),
1260
1330
  pc: bn4(receipt.pc),
1261
1331
  is: bn4(receipt.is)
@@ -1265,7 +1335,7 @@ function assembleReceiptByType(receipt) {
1265
1335
  case "LOG" /* Log */: {
1266
1336
  const logReceipt = {
1267
1337
  type: ReceiptType.Log,
1268
- id: hexOrZero(receipt.contract?.id),
1338
+ id: hexOrZero(receipt.id || receipt.contractId),
1269
1339
  val0: bn4(receipt.ra),
1270
1340
  val1: bn4(receipt.rb),
1271
1341
  val2: bn4(receipt.rc),
@@ -1278,7 +1348,7 @@ function assembleReceiptByType(receipt) {
1278
1348
  case "LOG_DATA" /* LogData */: {
1279
1349
  const logDataReceipt = {
1280
1350
  type: ReceiptType.LogData,
1281
- id: hexOrZero(receipt.contract?.id),
1351
+ id: hexOrZero(receipt.id || receipt.contractId),
1282
1352
  val0: bn4(receipt.ra),
1283
1353
  val1: bn4(receipt.rb),
1284
1354
  ptr: bn4(receipt.ptr),
@@ -1292,8 +1362,8 @@ function assembleReceiptByType(receipt) {
1292
1362
  case "TRANSFER" /* Transfer */: {
1293
1363
  const transferReceipt = {
1294
1364
  type: ReceiptType.Transfer,
1295
- from: hexOrZero(receipt.contract?.id),
1296
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1365
+ from: hexOrZero(receipt.id || receipt.contractId),
1366
+ to: hexOrZero(receipt.toAddress || receipt?.to),
1297
1367
  amount: bn4(receipt.amount),
1298
1368
  assetId: hexOrZero(receipt.assetId),
1299
1369
  pc: bn4(receipt.pc),
@@ -1304,8 +1374,8 @@ function assembleReceiptByType(receipt) {
1304
1374
  case "TRANSFER_OUT" /* TransferOut */: {
1305
1375
  const transferOutReceipt = {
1306
1376
  type: ReceiptType.TransferOut,
1307
- from: hexOrZero(receipt.contract?.id),
1308
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
1377
+ from: hexOrZero(receipt.id || receipt.contractId),
1378
+ to: hexOrZero(receipt.toAddress || receipt.to),
1309
1379
  amount: bn4(receipt.amount),
1310
1380
  assetId: hexOrZero(receipt.assetId),
1311
1381
  pc: bn4(receipt.pc),
@@ -1348,7 +1418,7 @@ function assembleReceiptByType(receipt) {
1348
1418
  return receiptMessageOut;
1349
1419
  }
1350
1420
  case "MINT" /* Mint */: {
1351
- const contractId = hexOrZero(receipt.contract?.id);
1421
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1352
1422
  const subId = hexOrZero(receipt.subId);
1353
1423
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1354
1424
  const mintReceipt = {
@@ -1363,7 +1433,7 @@ function assembleReceiptByType(receipt) {
1363
1433
  return mintReceipt;
1364
1434
  }
1365
1435
  case "BURN" /* Burn */: {
1366
- const contractId = hexOrZero(receipt.contract?.id);
1436
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1367
1437
  const subId = hexOrZero(receipt.subId);
1368
1438
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1369
1439
  const burnReceipt = {
@@ -1448,7 +1518,6 @@ var buildBlockExplorerUrl = (options = {}) => {
1448
1518
  import { bn as bn5 } from "@fuel-ts/math";
1449
1519
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1450
1520
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1451
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1452
1521
  var getGasUsedFromReceipts = (receipts) => {
1453
1522
  const scriptResult = receipts.filter(
1454
1523
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1469,18 +1538,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1469
1538
  }
1470
1539
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1471
1540
  const witnessCache = [];
1472
- const totalGas = inputs.reduce((total, input) => {
1541
+ const chargeableInputs = inputs.filter((input) => {
1542
+ const isCoinOrMessage = "owner" in input || "sender" in input;
1543
+ if (isCoinOrMessage) {
1544
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1545
+ return true;
1546
+ }
1547
+ if (!witnessCache.includes(input.witnessIndex)) {
1548
+ witnessCache.push(input.witnessIndex);
1549
+ return true;
1550
+ }
1551
+ }
1552
+ return false;
1553
+ });
1554
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1555
+ const totalGas = chargeableInputs.reduce((total, input) => {
1473
1556
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1474
1557
  return total.add(
1475
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1558
+ vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1476
1559
  );
1477
1560
  }
1478
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1479
- witnessCache.push(input.witnessIndex);
1480
- return total.add(gasCosts.ecr1);
1481
- }
1482
- return total;
1483
- }, bn5());
1561
+ return total.add(gasCosts.ecr1);
1562
+ }, bn5(0));
1484
1563
  return totalGas;
1485
1564
  }
1486
1565
  function getMinGas(params) {
@@ -1492,12 +1571,20 @@ function getMinGas(params) {
1492
1571
  return minGas;
1493
1572
  }
1494
1573
  function getMaxGas(params) {
1495
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1574
+ const {
1575
+ gasPerByte,
1576
+ witnessesLength,
1577
+ witnessLimit,
1578
+ minGas,
1579
+ gasLimit = bn5(0),
1580
+ maxGasPerTx
1581
+ } = params;
1496
1582
  let remainingAllowedWitnessGas = bn5(0);
1497
1583
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1498
1584
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1499
1585
  }
1500
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1586
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1587
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1501
1588
  }
1502
1589
  function calculateMetadataGasForTxCreate({
1503
1590
  gasCosts,
@@ -1519,6 +1606,10 @@ function calculateMetadataGasForTxScript({
1519
1606
  }) {
1520
1607
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1521
1608
  }
1609
+ var calculateGasFee = (params) => {
1610
+ const { gas, gasPrice, priceFactor, tip } = params;
1611
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
1612
+ };
1522
1613
 
1523
1614
  // src/providers/utils/json.ts
1524
1615
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1675,7 +1766,7 @@ var witnessify = (value) => {
1675
1766
  // src/providers/transaction-request/transaction-request.ts
1676
1767
  var BaseTransactionRequest = class {
1677
1768
  /** Gas price for transaction */
1678
- gasPrice;
1769
+ tip;
1679
1770
  /** Block until which tx cannot be included */
1680
1771
  maturity;
1681
1772
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1688,38 +1779,34 @@ var BaseTransactionRequest = class {
1688
1779
  outputs = [];
1689
1780
  /** List of witnesses */
1690
1781
  witnesses = [];
1691
- /** Base asset ID - should be fetched from the chain */
1692
- baseAssetId;
1693
1782
  /**
1694
1783
  * Constructor for initializing a base transaction request.
1695
1784
  *
1696
1785
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1697
1786
  */
1698
1787
  constructor({
1699
- gasPrice,
1788
+ tip,
1700
1789
  maturity,
1701
1790
  maxFee,
1702
1791
  witnessLimit,
1703
1792
  inputs,
1704
1793
  outputs,
1705
- witnesses,
1706
- baseAssetId
1707
- }) {
1708
- this.gasPrice = bn7(gasPrice);
1794
+ witnesses
1795
+ } = {}) {
1796
+ this.tip = bn7(tip);
1709
1797
  this.maturity = maturity ?? 0;
1710
1798
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1711
1799
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
1712
1800
  this.inputs = inputs ?? [];
1713
1801
  this.outputs = outputs ?? [];
1714
1802
  this.witnesses = witnesses ?? [];
1715
- this.baseAssetId = baseAssetId;
1716
1803
  }
1717
1804
  static getPolicyMeta(req) {
1718
1805
  let policyTypes = 0;
1719
1806
  const policies = [];
1720
- if (req.gasPrice) {
1721
- policyTypes += PolicyType.GasPrice;
1722
- policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1807
+ if (req.tip) {
1808
+ policyTypes += PolicyType.Tip;
1809
+ policies.push({ data: req.tip, type: PolicyType.Tip });
1723
1810
  }
1724
1811
  if (req.witnessLimit) {
1725
1812
  policyTypes += PolicyType.WitnessLimit;
@@ -1906,10 +1993,10 @@ var BaseTransactionRequest = class {
1906
1993
  * @param predicate - Predicate bytes.
1907
1994
  * @param predicateData - Predicate data bytes.
1908
1995
  */
1909
- addCoinInput(coin, predicate) {
1996
+ addCoinInput(coin) {
1910
1997
  const { assetId, owner, amount } = coin;
1911
1998
  let witnessIndex;
1912
- if (predicate) {
1999
+ if (coin.predicate) {
1913
2000
  witnessIndex = 0;
1914
2001
  } else {
1915
2002
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1924,8 +2011,7 @@ var BaseTransactionRequest = class {
1924
2011
  amount,
1925
2012
  assetId,
1926
2013
  txPointer: "0x00000000000000000000000000000000",
1927
- witnessIndex,
1928
- predicate: predicate?.bytes
2014
+ witnessIndex
1929
2015
  };
1930
2016
  this.pushInput(input);
1931
2017
  this.addChangeOutput(owner, assetId);
@@ -1936,11 +2022,13 @@ var BaseTransactionRequest = class {
1936
2022
  *
1937
2023
  * @param message - Message resource.
1938
2024
  * @param predicate - Predicate bytes.
2025
+ * @param predicateData - Predicate data bytes.
1939
2026
  */
1940
- addMessageInput(message, predicate) {
2027
+ addMessageInput(message) {
1941
2028
  const { recipient, sender, amount } = message;
2029
+ const assetId = BaseAssetId2;
1942
2030
  let witnessIndex;
1943
- if (predicate) {
2031
+ if (message.predicate) {
1944
2032
  witnessIndex = 0;
1945
2033
  } else {
1946
2034
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1954,11 +2042,10 @@ var BaseTransactionRequest = class {
1954
2042
  sender: sender.toB256(),
1955
2043
  recipient: recipient.toB256(),
1956
2044
  amount,
1957
- witnessIndex,
1958
- predicate: predicate?.bytes
2045
+ witnessIndex
1959
2046
  };
1960
2047
  this.pushInput(input);
1961
- this.addChangeOutput(recipient, this.baseAssetId);
2048
+ this.addChangeOutput(recipient, assetId);
1962
2049
  }
1963
2050
  /**
1964
2051
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -1986,32 +2073,6 @@ var BaseTransactionRequest = class {
1986
2073
  resources.forEach((resource) => this.addResource(resource));
1987
2074
  return this;
1988
2075
  }
1989
- /**
1990
- * Adds multiple resources to the transaction by adding coin/message inputs and change
1991
- * outputs from the related assetIds.
1992
- *
1993
- * @param resources - The resources to add.
1994
- * @returns This transaction.
1995
- */
1996
- addPredicateResource(resource, predicate) {
1997
- if (isCoin(resource)) {
1998
- this.addCoinInput(resource, predicate);
1999
- } else {
2000
- this.addMessageInput(resource, predicate);
2001
- }
2002
- return this;
2003
- }
2004
- /**
2005
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
2006
- * from the related assetIds.
2007
- *
2008
- * @param resources - The resources to add.
2009
- * @returns This transaction.
2010
- */
2011
- addPredicateResources(resources, predicate) {
2012
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2013
- return this;
2014
- }
2015
2076
  /**
2016
2077
  * Adds a coin output to the transaction.
2017
2078
  *
@@ -2019,12 +2080,12 @@ var BaseTransactionRequest = class {
2019
2080
  * @param amount - Amount of coin.
2020
2081
  * @param assetId - Asset ID of coin.
2021
2082
  */
2022
- addCoinOutput(to, amount, assetId) {
2083
+ addCoinOutput(to, amount, assetId = BaseAssetId2) {
2023
2084
  this.pushOutput({
2024
2085
  type: OutputType2.Coin,
2025
2086
  to: addressify(to).toB256(),
2026
2087
  amount,
2027
- assetId: assetId ?? this.baseAssetId
2088
+ assetId
2028
2089
  });
2029
2090
  return this;
2030
2091
  }
@@ -2051,7 +2112,7 @@ var BaseTransactionRequest = class {
2051
2112
  * @param to - Address of the owner.
2052
2113
  * @param assetId - Asset ID of coin.
2053
2114
  */
2054
- addChangeOutput(to, assetId) {
2115
+ addChangeOutput(to, assetId = BaseAssetId2) {
2055
2116
  const changeOutput = this.getChangeOutputs().find(
2056
2117
  (output) => hexlify7(output.assetId) === assetId
2057
2118
  );
@@ -2059,7 +2120,7 @@ var BaseTransactionRequest = class {
2059
2120
  this.pushOutput({
2060
2121
  type: OutputType2.Change,
2061
2122
  to: addressify(to).toB256(),
2062
- assetId: assetId ?? this.baseAssetId
2123
+ assetId
2063
2124
  });
2064
2125
  }
2065
2126
  }
@@ -2091,7 +2152,7 @@ var BaseTransactionRequest = class {
2091
2152
  }
2092
2153
  calculateMaxGas(chainInfo, minGas) {
2093
2154
  const { consensusParameters } = chainInfo;
2094
- const { gasPerByte } = consensusParameters;
2155
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2095
2156
  const witnessesLength = this.toTransaction().witnesses.reduce(
2096
2157
  (acc, wit) => acc + wit.dataLength,
2097
2158
  0
@@ -2100,7 +2161,8 @@ var BaseTransactionRequest = class {
2100
2161
  gasPerByte,
2101
2162
  minGas,
2102
2163
  witnessesLength,
2103
- witnessLimit: this.witnessLimit
2164
+ witnessLimit: this.witnessLimit,
2165
+ maxGasPerTx
2104
2166
  });
2105
2167
  }
2106
2168
  /**
@@ -2110,12 +2172,6 @@ var BaseTransactionRequest = class {
2110
2172
  * @param quantities - CoinQuantity Array.
2111
2173
  */
2112
2174
  fundWithFakeUtxos(quantities, resourcesOwner) {
2113
- let idCounter = 0;
2114
- const generateId = () => {
2115
- const counterString = String(idCounter++);
2116
- const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
2117
- return id;
2118
- };
2119
2175
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2120
2176
  if ("assetId" in input) {
2121
2177
  return input.assetId === assetId;
@@ -2124,24 +2180,27 @@ var BaseTransactionRequest = class {
2124
2180
  });
2125
2181
  const updateAssetInput = (assetId, quantity) => {
2126
2182
  const assetInput = findAssetInput(assetId);
2183
+ let usedQuantity = quantity;
2184
+ if (assetId === BaseAssetId2) {
2185
+ usedQuantity = bn7("1000000000000000000");
2186
+ }
2127
2187
  if (assetInput && "assetId" in assetInput) {
2128
- assetInput.id = generateId();
2129
- assetInput.amount = quantity;
2188
+ assetInput.id = hexlify7(randomBytes(34));
2189
+ assetInput.amount = usedQuantity;
2130
2190
  } else {
2131
2191
  this.addResources([
2132
2192
  {
2133
- id: generateId(),
2134
- amount: quantity,
2193
+ id: hexlify7(randomBytes(34)),
2194
+ amount: usedQuantity,
2135
2195
  assetId,
2136
2196
  owner: resourcesOwner || Address.fromRandom(),
2137
- maturity: 0,
2138
2197
  blockCreated: bn7(1),
2139
2198
  txCreatedIdx: bn7(1)
2140
2199
  }
2141
2200
  ]);
2142
2201
  }
2143
2202
  };
2144
- updateAssetInput(this.baseAssetId, bn7(1e11));
2203
+ updateAssetInput(BaseAssetId2, bn7(1e11));
2145
2204
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2146
2205
  }
2147
2206
  /**
@@ -2166,7 +2225,7 @@ var BaseTransactionRequest = class {
2166
2225
  toJSON() {
2167
2226
  return normalizeJSON(this);
2168
2227
  }
2169
- updatePredicateInputs(inputs) {
2228
+ updatePredicateGasUsed(inputs) {
2170
2229
  this.inputs.forEach((i) => {
2171
2230
  let correspondingInput;
2172
2231
  switch (i.type) {
@@ -2188,6 +2247,15 @@ var BaseTransactionRequest = class {
2188
2247
  }
2189
2248
  });
2190
2249
  }
2250
+ shiftPredicateData() {
2251
+ this.inputs.forEach((input) => {
2252
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2253
+ input.predicateData = input.paddPredicateData(
2254
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2255
+ );
2256
+ }
2257
+ });
2258
+ }
2191
2259
  };
2192
2260
 
2193
2261
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2311,7 +2379,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2311
2379
  *
2312
2380
  * @param createTransactionRequestLike - The initial values for the instance
2313
2381
  */
2314
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2382
+ constructor({
2383
+ bytecodeWitnessIndex,
2384
+ salt,
2385
+ storageSlots,
2386
+ ...rest
2387
+ } = {}) {
2315
2388
  super(rest);
2316
2389
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2317
2390
  this.salt = hexlify9(salt ?? ZeroBytes326);
@@ -2329,9 +2402,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2329
2402
  return {
2330
2403
  type: TransactionType3.Create,
2331
2404
  ...baseTransaction,
2332
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2333
2405
  bytecodeWitnessIndex,
2334
- storageSlotsCount: storageSlots.length,
2406
+ storageSlotsCount: bn9(storageSlots.length),
2335
2407
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2336
2408
  storageSlots
2337
2409
  };
@@ -2435,7 +2507,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2435
2507
  *
2436
2508
  * @param scriptTransactionRequestLike - The initial values for the instance.
2437
2509
  */
2438
- constructor({ script, scriptData, gasLimit, ...rest }) {
2510
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2439
2511
  super(rest);
2440
2512
  this.gasLimit = bn10(gasLimit);
2441
2513
  this.script = arrayify8(script ?? returnZeroScript.bytes);
@@ -2454,8 +2526,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2454
2526
  type: TransactionType4.Script,
2455
2527
  scriptGasLimit: this.gasLimit,
2456
2528
  ...super.getBaseTransaction(),
2457
- scriptLength: script.length,
2458
- scriptDataLength: scriptData.length,
2529
+ scriptLength: bn10(script.length),
2530
+ scriptDataLength: bn10(scriptData.length),
2459
2531
  receiptsRoot: ZeroBytes327,
2460
2532
  script: hexlify10(script),
2461
2533
  scriptData: hexlify10(scriptData)
@@ -2519,7 +2591,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2519
2591
  }
2520
2592
  calculateMaxGas(chainInfo, minGas) {
2521
2593
  const { consensusParameters } = chainInfo;
2522
- const { gasPerByte } = consensusParameters;
2594
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2523
2595
  const witnessesLength = this.toTransaction().witnesses.reduce(
2524
2596
  (acc, wit) => acc + wit.dataLength,
2525
2597
  0
@@ -2529,7 +2601,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2529
2601
  minGas,
2530
2602
  witnessesLength,
2531
2603
  witnessLimit: this.witnessLimit,
2532
- gasLimit: this.gasLimit
2604
+ gasLimit: this.gasLimit,
2605
+ maxGasPerTx
2533
2606
  });
2534
2607
  }
2535
2608
  /**
@@ -2586,7 +2659,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2586
2659
 
2587
2660
  // src/providers/transaction-request/utils.ts
2588
2661
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2589
- import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2662
+ import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2590
2663
  var transactionRequestify = (obj) => {
2591
2664
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2592
2665
  return obj;
@@ -2604,14 +2677,31 @@ var transactionRequestify = (obj) => {
2604
2677
  }
2605
2678
  }
2606
2679
  };
2680
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2681
+ (acc, input) => {
2682
+ if (input.type === InputType5.Coin && input.owner === owner) {
2683
+ acc.utxos.push(input.id);
2684
+ }
2685
+ if (input.type === InputType5.Message && input.recipient === owner) {
2686
+ acc.messages.push(input.nonce);
2687
+ }
2688
+ return acc;
2689
+ },
2690
+ {
2691
+ utxos: [],
2692
+ messages: []
2693
+ }
2694
+ );
2607
2695
 
2608
2696
  // src/providers/transaction-response/transaction-response.ts
2609
2697
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2610
- import { bn as bn14 } from "@fuel-ts/math";
2698
+ import { bn as bn15 } from "@fuel-ts/math";
2611
2699
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2612
2700
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2613
2701
 
2614
2702
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2703
+ import { bn as bn14 } from "@fuel-ts/math";
2704
+ import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2615
2705
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2616
2706
 
2617
2707
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2620,9 +2710,10 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2620
2710
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2621
2711
  var calculateTransactionFee = (params) => {
2622
2712
  const {
2623
- gasUsed,
2713
+ gasPrice,
2624
2714
  rawPayload,
2625
- consensusParameters: { gasCosts, feeParams }
2715
+ tip,
2716
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2626
2717
  } = params;
2627
2718
  const gasPerByte = bn11(feeParams.gasPerByte);
2628
2719
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2632,8 +2723,7 @@ var calculateTransactionFee = (params) => {
2632
2723
  return {
2633
2724
  fee: bn11(0),
2634
2725
  minFee: bn11(0),
2635
- maxFee: bn11(0),
2636
- feeFromGasUsed: bn11(0)
2726
+ maxFee: bn11(0)
2637
2727
  };
2638
2728
  }
2639
2729
  const { type, witnesses, inputs, policies } = transaction;
@@ -2665,7 +2755,6 @@ var calculateTransactionFee = (params) => {
2665
2755
  metadataGas,
2666
2756
  txBytesSize: transactionBytes.length
2667
2757
  });
2668
- const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2669
2758
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2670
2759
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2671
2760
  const maxGas = getMaxGas({
@@ -2673,17 +2762,25 @@ var calculateTransactionFee = (params) => {
2673
2762
  minGas,
2674
2763
  witnessesLength,
2675
2764
  gasLimit,
2676
- witnessLimit
2765
+ witnessLimit,
2766
+ maxGasPerTx
2767
+ });
2768
+ const minFee = calculateGasFee({
2769
+ gasPrice,
2770
+ gas: minGas,
2771
+ priceFactor: gasPriceFactor,
2772
+ tip
2773
+ });
2774
+ const maxFee = calculateGasFee({
2775
+ gasPrice,
2776
+ gas: maxGas,
2777
+ priceFactor: gasPriceFactor,
2778
+ tip
2677
2779
  });
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);
2682
2780
  return {
2683
- fee,
2684
2781
  minFee,
2685
2782
  maxFee,
2686
- feeFromGasUsed
2783
+ fee: maxFee
2687
2784
  };
2688
2785
  };
2689
2786
 
@@ -2739,7 +2836,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2739
2836
 
2740
2837
  // src/providers/transaction-summary/input.ts
2741
2838
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2742
- import { InputType as InputType5 } from "@fuel-ts/transactions";
2839
+ import { InputType as InputType6 } from "@fuel-ts/transactions";
2743
2840
  function getInputsByTypes(inputs, types) {
2744
2841
  return inputs.filter((i) => types.includes(i.type));
2745
2842
  }
@@ -2747,16 +2844,16 @@ function getInputsByType(inputs, type) {
2747
2844
  return inputs.filter((i) => i.type === type);
2748
2845
  }
2749
2846
  function getInputsCoin(inputs) {
2750
- return getInputsByType(inputs, InputType5.Coin);
2847
+ return getInputsByType(inputs, InputType6.Coin);
2751
2848
  }
2752
2849
  function getInputsMessage(inputs) {
2753
- return getInputsByType(inputs, InputType5.Message);
2850
+ return getInputsByType(inputs, InputType6.Message);
2754
2851
  }
2755
2852
  function getInputsCoinAndMessage(inputs) {
2756
- return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2853
+ return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2757
2854
  }
2758
2855
  function getInputsContract(inputs) {
2759
- return getInputsByType(inputs, InputType5.Contract);
2856
+ return getInputsByType(inputs, InputType6.Contract);
2760
2857
  }
2761
2858
  function getInputFromAssetId(inputs, assetId) {
2762
2859
  const coinInputs = getInputsCoin(inputs);
@@ -2775,7 +2872,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2775
2872
  if (!contractInput) {
2776
2873
  return void 0;
2777
2874
  }
2778
- if (contractInput.type !== InputType5.Contract) {
2875
+ if (contractInput.type !== InputType6.Contract) {
2779
2876
  throw new FuelError9(
2780
2877
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2781
2878
  `Contract input should be of type 'contract'.`
@@ -2784,10 +2881,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2784
2881
  return contractInput;
2785
2882
  }
2786
2883
  function getInputAccountAddress(input) {
2787
- if (input.type === InputType5.Coin) {
2884
+ if (input.type === InputType6.Coin) {
2788
2885
  return input.owner.toString();
2789
2886
  }
2790
- if (input.type === InputType5.Message) {
2887
+ if (input.type === InputType6.Message) {
2791
2888
  return input.recipient.toString();
2792
2889
  }
2793
2890
  return "";
@@ -3297,7 +3394,9 @@ function assembleTransactionSummary(params) {
3297
3394
  gqlTransactionStatus,
3298
3395
  abiMap = {},
3299
3396
  maxInputs,
3300
- gasCosts
3397
+ gasCosts,
3398
+ maxGasPerTx,
3399
+ gasPrice
3301
3400
  } = params;
3302
3401
  const gasUsed = getGasUsedFromReceipts(receipts);
3303
3402
  const rawPayload = hexlify11(transactionBytes);
@@ -3311,11 +3410,14 @@ function assembleTransactionSummary(params) {
3311
3410
  maxInputs
3312
3411
  });
3313
3412
  const typeName = getTransactionTypeName(transaction.type);
3413
+ const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3314
3414
  const { fee } = calculateTransactionFee({
3315
- gasUsed,
3415
+ gasPrice,
3316
3416
  rawPayload,
3417
+ tip,
3317
3418
  consensusParameters: {
3318
3419
  gasCosts,
3420
+ maxGasPerTx,
3319
3421
  feeParams: {
3320
3422
  gasPerByte,
3321
3423
  gasPriceFactor
@@ -3375,7 +3477,7 @@ var TransactionResponse = class {
3375
3477
  /** Current provider */
3376
3478
  provider;
3377
3479
  /** Gas used on the transaction */
3378
- gasUsed = bn14(0);
3480
+ gasUsed = bn15(0);
3379
3481
  /** The graphql Transaction with receipts object. */
3380
3482
  gqlTransaction;
3381
3483
  abis;
@@ -3453,8 +3555,13 @@ var TransactionResponse = class {
3453
3555
  const decodedTransaction = this.decodeTransaction(
3454
3556
  transaction
3455
3557
  );
3456
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3457
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3558
+ let txReceipts = [];
3559
+ if (transaction?.status && "receipts" in transaction.status) {
3560
+ txReceipts = transaction.status.receipts;
3561
+ }
3562
+ const receipts = txReceipts.map(processGqlReceipt) || [];
3563
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3564
+ const gasPrice = await this.provider.getLatestGasPrice();
3458
3565
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3459
3566
  const transactionSummary = assembleTransactionSummary({
3460
3567
  id: this.id,
@@ -3466,7 +3573,9 @@ var TransactionResponse = class {
3466
3573
  gasPriceFactor,
3467
3574
  abiMap: contractsAbiMap,
3468
3575
  maxInputs,
3469
- gasCosts
3576
+ gasCosts,
3577
+ maxGasPerTx,
3578
+ gasPrice
3470
3579
  });
3471
3580
  return transactionSummary;
3472
3581
  }
@@ -3593,30 +3702,29 @@ var processGqlChain = (chain) => {
3593
3702
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3594
3703
  return {
3595
3704
  name,
3596
- baseChainHeight: bn15(daHeight),
3705
+ baseChainHeight: bn16(daHeight),
3597
3706
  consensusParameters: {
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),
3613
- baseAssetId: consensusParameters.baseAssetId,
3707
+ contractMaxSize: bn16(contractParams.contractMaxSize),
3708
+ maxInputs: bn16(txParams.maxInputs),
3709
+ maxOutputs: bn16(txParams.maxOutputs),
3710
+ maxWitnesses: bn16(txParams.maxWitnesses),
3711
+ maxGasPerTx: bn16(txParams.maxGasPerTx),
3712
+ maxScriptLength: bn16(scriptParams.maxScriptLength),
3713
+ maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3714
+ maxStorageSlots: bn16(contractParams.maxStorageSlots),
3715
+ maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3716
+ maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3717
+ maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3718
+ gasPriceFactor: bn16(feeParams.gasPriceFactor),
3719
+ gasPerByte: bn16(feeParams.gasPerByte),
3720
+ maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3721
+ chainId: bn16(consensusParameters.chainId),
3614
3722
  gasCosts
3615
3723
  },
3616
3724
  gasCosts,
3617
3725
  latestBlock: {
3618
3726
  id: latestBlock.id,
3619
- height: bn15(latestBlock.header.height),
3727
+ height: bn16(latestBlock.height),
3620
3728
  time: latestBlock.header.time,
3621
3729
  transactions: latestBlock.transactions.map((i) => ({
3622
3730
  id: i.id
@@ -3710,10 +3818,8 @@ var _Provider = class {
3710
3818
  * Returns some helpful parameters related to gas fees.
3711
3819
  */
3712
3820
  getGasConfig() {
3713
- const { minGasPrice } = this.getNode();
3714
3821
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3715
3822
  return {
3716
- minGasPrice,
3717
3823
  maxGasPerTx,
3718
3824
  maxGasPerPredicate,
3719
3825
  gasPriceFactor,
@@ -3811,7 +3917,7 @@ var _Provider = class {
3811
3917
  */
3812
3918
  async getBlockNumber() {
3813
3919
  const { chain } = await this.operations.getChain();
3814
- return bn15(chain.latestBlock.header.height, 10);
3920
+ return bn16(chain.latestBlock.height, 10);
3815
3921
  }
3816
3922
  /**
3817
3923
  * Returns the chain information.
@@ -3821,13 +3927,11 @@ var _Provider = class {
3821
3927
  async fetchNode() {
3822
3928
  const { nodeInfo } = await this.operations.getNodeInfo();
3823
3929
  const processedNodeInfo = {
3824
- maxDepth: bn15(nodeInfo.maxDepth),
3825
- maxTx: bn15(nodeInfo.maxTx),
3826
- minGasPrice: bn15(nodeInfo.minGasPrice),
3930
+ maxDepth: bn16(nodeInfo.maxDepth),
3931
+ maxTx: bn16(nodeInfo.maxTx),
3827
3932
  nodeVersion: nodeInfo.nodeVersion,
3828
3933
  utxoValidation: nodeInfo.utxoValidation,
3829
- vmBacktrace: nodeInfo.vmBacktrace,
3830
- peers: nodeInfo.peers
3934
+ vmBacktrace: nodeInfo.vmBacktrace
3831
3935
  };
3832
3936
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3833
3937
  return processedNodeInfo;
@@ -3853,17 +3957,6 @@ var _Provider = class {
3853
3957
  } = this.getChain();
3854
3958
  return chainId.toNumber();
3855
3959
  }
3856
- /**
3857
- * Returns the base asset ID
3858
- *
3859
- * @returns A promise that resolves to the base asset ID
3860
- */
3861
- getBaseAssetId() {
3862
- const {
3863
- consensusParameters: { baseAssetId }
3864
- } = this.getChain();
3865
- return baseAssetId;
3866
- }
3867
3960
  /**
3868
3961
  * Submits a transaction to the chain to be executed.
3869
3962
  *
@@ -3924,14 +4017,13 @@ var _Provider = class {
3924
4017
  return this.estimateTxDependencies(transactionRequest);
3925
4018
  }
3926
4019
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3927
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3928
- encodedTransaction,
4020
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4021
+ encodedTransactions: encodedTransaction,
3929
4022
  utxoValidation: utxoValidation || false
3930
4023
  });
3931
- const receipts = gqlReceipts.map(processGqlReceipt);
3932
- return {
3933
- receipts
3934
- };
4024
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4025
+ const receipts = rawReceipts.map(processGqlReceipt);
4026
+ return { receipts, dryrunStatus: status };
3935
4027
  }
3936
4028
  /**
3937
4029
  * Verifies whether enough gas is available to complete transaction.
@@ -3957,7 +4049,7 @@ var _Provider = class {
3957
4049
  } = response;
3958
4050
  if (inputs) {
3959
4051
  inputs.forEach((input, index) => {
3960
- if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
4052
+ if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3961
4053
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3962
4054
  }
3963
4055
  });
@@ -3970,9 +4062,6 @@ var _Provider = class {
3970
4062
  * If there are missing variable outputs,
3971
4063
  * `addVariableOutputs` is called on the transaction.
3972
4064
  *
3973
- * @privateRemarks
3974
- * TODO: Investigate support for missing contract IDs
3975
- * TODO: Add support for missing output messages
3976
4065
  *
3977
4066
  * @param transactionRequest - The transaction request object.
3978
4067
  * @returns A promise.
@@ -3985,16 +4074,19 @@ var _Provider = class {
3985
4074
  missingContractIds: []
3986
4075
  };
3987
4076
  }
3988
- await this.estimatePredicates(transactionRequest);
3989
4077
  let receipts = [];
3990
4078
  const missingContractIds = [];
3991
4079
  let outputVariables = 0;
4080
+ let dryrunStatus;
3992
4081
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3993
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3994
- encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
4082
+ const {
4083
+ dryRun: [{ receipts: rawReceipts, status }]
4084
+ } = await this.operations.dryRun({
4085
+ encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3995
4086
  utxoValidation: false
3996
4087
  });
3997
- receipts = gqlReceipts.map(processGqlReceipt);
4088
+ receipts = rawReceipts.map(processGqlReceipt);
4089
+ dryrunStatus = status;
3998
4090
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3999
4091
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4000
4092
  if (hasMissingOutputs) {
@@ -4004,6 +4096,11 @@ var _Provider = class {
4004
4096
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
4005
4097
  missingContractIds.push(contractId);
4006
4098
  });
4099
+ const { maxFee } = await this.estimateTxGasAndFee({
4100
+ transactionRequest,
4101
+ optimizeGas: false
4102
+ });
4103
+ transactionRequest.maxFee = maxFee;
4007
4104
  } else {
4008
4105
  break;
4009
4106
  }
@@ -4011,7 +4108,133 @@ var _Provider = class {
4011
4108
  return {
4012
4109
  receipts,
4013
4110
  outputVariables,
4014
- missingContractIds
4111
+ missingContractIds,
4112
+ dryrunStatus
4113
+ };
4114
+ }
4115
+ /**
4116
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
4117
+ *
4118
+ * Transactions are dry run in batches. After each dry run, transactions requiring
4119
+ * further modifications are identified. The method iteratively updates these transactions
4120
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4121
+ *
4122
+ * @param transactionRequests - Array of transaction request objects.
4123
+ * @returns A promise that resolves to an array of results for each transaction.
4124
+ */
4125
+ async estimateMultipleTxDependencies(transactionRequests) {
4126
+ const results = transactionRequests.map(() => ({
4127
+ receipts: [],
4128
+ outputVariables: 0,
4129
+ missingContractIds: [],
4130
+ dryrunStatus: void 0
4131
+ }));
4132
+ const allRequests = clone3(transactionRequests);
4133
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
4134
+ allRequests.forEach((req, index) => {
4135
+ if (req.type === TransactionType8.Script) {
4136
+ serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4137
+ }
4138
+ });
4139
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4140
+ let attempt = 0;
4141
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4142
+ const encodedTransactions = transactionsToProcess.map(
4143
+ (index) => serializedTransactionsMap.get(index)
4144
+ );
4145
+ const dryRunResults = await this.operations.dryRun({
4146
+ encodedTransactions,
4147
+ utxoValidation: false
4148
+ });
4149
+ const nextRoundTransactions = [];
4150
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4151
+ const currentResultIndex = transactionsToProcess[i];
4152
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4153
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4154
+ results[currentResultIndex].dryrunStatus = status;
4155
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4156
+ results[currentResultIndex].receipts
4157
+ );
4158
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4159
+ const requestToProcess = allRequests[currentResultIndex];
4160
+ if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4161
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
4162
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
4163
+ missingOutputContractIds.forEach(({ contractId }) => {
4164
+ requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4165
+ results[currentResultIndex].missingContractIds.push(contractId);
4166
+ });
4167
+ const { maxFee } = await this.estimateTxGasAndFee({
4168
+ transactionRequest: requestToProcess,
4169
+ optimizeGas: false
4170
+ });
4171
+ requestToProcess.maxFee = maxFee;
4172
+ serializedTransactionsMap.set(
4173
+ currentResultIndex,
4174
+ hexlify12(requestToProcess.toTransactionBytes())
4175
+ );
4176
+ nextRoundTransactions.push(currentResultIndex);
4177
+ allRequests[currentResultIndex] = requestToProcess;
4178
+ }
4179
+ }
4180
+ transactionsToProcess = nextRoundTransactions;
4181
+ attempt += 1;
4182
+ }
4183
+ return results;
4184
+ }
4185
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4186
+ if (estimateTxDependencies) {
4187
+ return this.estimateMultipleTxDependencies(transactionRequests);
4188
+ }
4189
+ const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4190
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4191
+ encodedTransactions,
4192
+ utxoValidation: utxoValidation || false
4193
+ });
4194
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4195
+ const receipts = rawReceipts.map(processGqlReceipt);
4196
+ return { receipts, dryrunStatus: status };
4197
+ });
4198
+ return results;
4199
+ }
4200
+ async estimateTxGasAndFee(params) {
4201
+ const { transactionRequest, optimizeGas = true } = params;
4202
+ let { gasPrice } = params;
4203
+ const chainInfo = this.getChain();
4204
+ const { gasPriceFactor } = this.getGasConfig();
4205
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4206
+ if (!gasPrice) {
4207
+ gasPrice = await this.estimateGasPrice(10);
4208
+ }
4209
+ const minFee = calculateGasFee({
4210
+ gasPrice: bn16(gasPrice),
4211
+ gas: minGas,
4212
+ priceFactor: gasPriceFactor,
4213
+ tip: transactionRequest.tip
4214
+ }).add(1);
4215
+ let gasLimit = bn16(0);
4216
+ if (transactionRequest.type === TransactionType8.Script) {
4217
+ gasLimit = transactionRequest.gasLimit;
4218
+ if (!optimizeGas) {
4219
+ transactionRequest.gasLimit = minGas;
4220
+ gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4221
+ transactionRequest.gasLimit = gasLimit;
4222
+ }
4223
+ }
4224
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4225
+ const maxFee = calculateGasFee({
4226
+ gasPrice: bn16(gasPrice),
4227
+ gas: maxGas,
4228
+ priceFactor: gasPriceFactor,
4229
+ tip: transactionRequest.tip
4230
+ }).add(1);
4231
+ return {
4232
+ minGas,
4233
+ minFee,
4234
+ maxGas,
4235
+ maxFee,
4236
+ gasPrice,
4237
+ gasLimit
4015
4238
  };
4016
4239
  }
4017
4240
  /**
@@ -4029,15 +4252,17 @@ var _Provider = class {
4029
4252
  if (estimateTxDependencies) {
4030
4253
  return this.estimateTxDependencies(transactionRequest);
4031
4254
  }
4032
- const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4033
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4034
- encodedTransaction,
4255
+ const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4256
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4257
+ encodedTransactions,
4035
4258
  utxoValidation: true
4036
4259
  });
4037
- const receipts = gqlReceipts.map(processGqlReceipt);
4038
- return {
4039
- receipts
4040
- };
4260
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
4261
+ const { id, receipts, status } = dryRunStatus;
4262
+ const processedReceipts = receipts.map(processGqlReceipt);
4263
+ return { id, receipts: processedReceipts, status };
4264
+ });
4265
+ return { receipts: callResult[0].receipts };
4041
4266
  }
4042
4267
  /**
4043
4268
  * Returns a transaction cost to enable user
@@ -4054,80 +4279,80 @@ var _Provider = class {
4054
4279
  * @param tolerance - The tolerance to add on top of the gasUsed.
4055
4280
  * @returns A promise that resolves to the transaction cost object.
4056
4281
  */
4057
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4058
- estimateTxDependencies = true,
4059
- estimatePredicates = true,
4060
- resourcesOwner,
4061
- signatureCallback
4062
- } = {}) {
4282
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4063
4283
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4064
- const chainInfo = this.getChain();
4065
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4066
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
4067
4284
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4068
4285
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4069
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4286
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4070
4287
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4071
- if (estimatePredicates) {
4072
- if (isScriptTransaction) {
4073
- txRequestClone.gasLimit = bn15(0);
4074
- }
4075
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4076
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4077
- }
4078
- await this.estimatePredicates(txRequestClone);
4288
+ txRequestClone.maxFee = bn16(0);
4289
+ if (isScriptTransaction) {
4290
+ txRequestClone.gasLimit = bn16(0);
4079
4291
  }
4080
- if (signatureCallback && isScriptTransaction) {
4081
- await signatureCallback(txRequestClone);
4292
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4293
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4082
4294
  }
4083
- const minGas = txRequestClone.calculateMinGas(chainInfo);
4084
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4295
+ const signedRequest = clone3(txRequestClone);
4296
+ let addedSignatures = 0;
4297
+ if (signatureCallback && isScriptTransaction) {
4298
+ const lengthBefore = signedRequest.witnesses.length;
4299
+ await signatureCallback(signedRequest);
4300
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
4301
+ }
4302
+ await this.estimatePredicates(signedRequest);
4303
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4304
+ transactionRequest: signedRequest,
4305
+ optimizeGas: false
4306
+ });
4307
+ txRequestClone.maxFee = maxFee;
4085
4308
  let receipts = [];
4086
4309
  let missingContractIds = [];
4087
4310
  let outputVariables = 0;
4088
- if (isScriptTransaction && estimateTxDependencies) {
4089
- txRequestClone.gasPrice = bn15(0);
4090
- txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4311
+ let gasUsed = bn16(0);
4312
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4313
+ if (isScriptTransaction) {
4314
+ if (signatureCallback) {
4315
+ await signatureCallback(txRequestClone);
4316
+ }
4317
+ txRequestClone.gasLimit = gasLimit;
4091
4318
  const result = await this.estimateTxDependencies(txRequestClone);
4092
4319
  receipts = result.receipts;
4093
4320
  outputVariables = result.outputVariables;
4094
4321
  missingContractIds = result.missingContractIds;
4322
+ gasUsed = getGasUsedFromReceipts(receipts);
4323
+ txRequestClone.gasLimit = gasUsed;
4324
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4325
+ transactionRequest: txRequestClone,
4326
+ gasPrice
4327
+ }));
4095
4328
  }
4096
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4097
- const usedFee = calculatePriceWithFactor(
4098
- gasUsed,
4099
- gasPrice,
4100
- gasPriceFactor
4101
- ).normalizeZeroToOne();
4102
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4103
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4104
4329
  return {
4105
4330
  requiredQuantities: allQuantities,
4106
4331
  receipts,
4107
4332
  gasUsed,
4108
- minGasPrice,
4109
4333
  gasPrice,
4110
4334
  minGas,
4111
4335
  maxGas,
4112
- usedFee,
4113
4336
  minFee,
4114
4337
  maxFee,
4115
- estimatedInputs: txRequestClone.inputs,
4116
4338
  outputVariables,
4117
- missingContractIds
4339
+ missingContractIds,
4340
+ addedSignatures,
4341
+ estimatedPredicates: txRequestClone.inputs
4118
4342
  };
4119
4343
  }
4120
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4344
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4121
4345
  const ownerAddress = Address2.fromAddressOrString(owner);
4122
4346
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4123
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4347
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
4348
+ quantitiesToContract
4349
+ });
4124
4350
  transactionRequest.addResources(
4125
4351
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4126
4352
  );
4127
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4128
- transactionRequest,
4129
- forwardingQuantities
4130
- );
4353
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4354
+ quantitiesToContract
4355
+ });
4131
4356
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4132
4357
  return {
4133
4358
  resources,
@@ -4149,11 +4374,10 @@ var _Provider = class {
4149
4374
  return coins.map((coin) => ({
4150
4375
  id: coin.utxoId,
4151
4376
  assetId: coin.assetId,
4152
- amount: bn15(coin.amount),
4377
+ amount: bn16(coin.amount),
4153
4378
  owner: Address2.fromAddressOrString(coin.owner),
4154
- maturity: bn15(coin.maturity).toNumber(),
4155
- blockCreated: bn15(coin.blockCreated),
4156
- txCreatedIdx: bn15(coin.txCreatedIdx)
4379
+ blockCreated: bn16(coin.blockCreated),
4380
+ txCreatedIdx: bn16(coin.txCreatedIdx)
4157
4381
  }));
4158
4382
  }
4159
4383
  /**
@@ -4190,9 +4414,9 @@ var _Provider = class {
4190
4414
  switch (coin.__typename) {
4191
4415
  case "MessageCoin":
4192
4416
  return {
4193
- amount: bn15(coin.amount),
4417
+ amount: bn16(coin.amount),
4194
4418
  assetId: coin.assetId,
4195
- daHeight: bn15(coin.daHeight),
4419
+ daHeight: bn16(coin.daHeight),
4196
4420
  sender: Address2.fromAddressOrString(coin.sender),
4197
4421
  recipient: Address2.fromAddressOrString(coin.recipient),
4198
4422
  nonce: coin.nonce
@@ -4200,12 +4424,11 @@ var _Provider = class {
4200
4424
  case "Coin":
4201
4425
  return {
4202
4426
  id: coin.utxoId,
4203
- amount: bn15(coin.amount),
4427
+ amount: bn16(coin.amount),
4204
4428
  assetId: coin.assetId,
4205
4429
  owner: Address2.fromAddressOrString(coin.owner),
4206
- maturity: bn15(coin.maturity).toNumber(),
4207
- blockCreated: bn15(coin.blockCreated),
4208
- txCreatedIdx: bn15(coin.txCreatedIdx)
4430
+ blockCreated: bn16(coin.blockCreated),
4431
+ txCreatedIdx: bn16(coin.txCreatedIdx)
4209
4432
  };
4210
4433
  default:
4211
4434
  return null;
@@ -4222,13 +4445,13 @@ var _Provider = class {
4222
4445
  async getBlock(idOrHeight) {
4223
4446
  let variables;
4224
4447
  if (typeof idOrHeight === "number") {
4225
- variables = { height: bn15(idOrHeight).toString(10) };
4448
+ variables = { height: bn16(idOrHeight).toString(10) };
4226
4449
  } else if (idOrHeight === "latest") {
4227
4450
  variables = { height: (await this.getBlockNumber()).toString(10) };
4228
4451
  } else if (idOrHeight.length === 66) {
4229
4452
  variables = { blockId: idOrHeight };
4230
4453
  } else {
4231
- variables = { blockId: bn15(idOrHeight).toString(10) };
4454
+ variables = { blockId: bn16(idOrHeight).toString(10) };
4232
4455
  }
4233
4456
  const { block } = await this.operations.getBlock(variables);
4234
4457
  if (!block) {
@@ -4236,7 +4459,7 @@ var _Provider = class {
4236
4459
  }
4237
4460
  return {
4238
4461
  id: block.id,
4239
- height: bn15(block.header.height),
4462
+ height: bn16(block.height),
4240
4463
  time: block.header.time,
4241
4464
  transactionIds: block.transactions.map((tx) => tx.id)
4242
4465
  };
@@ -4251,7 +4474,7 @@ var _Provider = class {
4251
4474
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4252
4475
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4253
4476
  id: block.id,
4254
- height: bn15(block.header.height),
4477
+ height: bn16(block.height),
4255
4478
  time: block.header.time,
4256
4479
  transactionIds: block.transactions.map((tx) => tx.id)
4257
4480
  }));
@@ -4266,7 +4489,7 @@ var _Provider = class {
4266
4489
  async getBlockWithTransactions(idOrHeight) {
4267
4490
  let variables;
4268
4491
  if (typeof idOrHeight === "number") {
4269
- variables = { blockHeight: bn15(idOrHeight).toString(10) };
4492
+ variables = { blockHeight: bn16(idOrHeight).toString(10) };
4270
4493
  } else if (idOrHeight === "latest") {
4271
4494
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4272
4495
  } else {
@@ -4278,7 +4501,7 @@ var _Provider = class {
4278
4501
  }
4279
4502
  return {
4280
4503
  id: block.id,
4281
- height: bn15(block.header.height, 10),
4504
+ height: bn16(block.height, 10),
4282
4505
  time: block.header.time,
4283
4506
  transactionIds: block.transactions.map((tx) => tx.id),
4284
4507
  transactions: block.transactions.map(
@@ -4327,7 +4550,7 @@ var _Provider = class {
4327
4550
  contract: Address2.fromAddressOrString(contractId).toB256(),
4328
4551
  asset: hexlify12(assetId)
4329
4552
  });
4330
- return bn15(contractBalance.amount, 10);
4553
+ return bn16(contractBalance.amount, 10);
4331
4554
  }
4332
4555
  /**
4333
4556
  * Returns the balance for the given owner for the given asset ID.
@@ -4341,7 +4564,7 @@ var _Provider = class {
4341
4564
  owner: Address2.fromAddressOrString(owner).toB256(),
4342
4565
  assetId: hexlify12(assetId)
4343
4566
  });
4344
- return bn15(balance.amount, 10);
4567
+ return bn16(balance.amount, 10);
4345
4568
  }
4346
4569
  /**
4347
4570
  * Returns balances for the given owner.
@@ -4359,7 +4582,7 @@ var _Provider = class {
4359
4582
  const balances = result.balances.edges.map((edge) => edge.node);
4360
4583
  return balances.map((balance) => ({
4361
4584
  assetId: balance.assetId,
4362
- amount: bn15(balance.amount)
4585
+ amount: bn16(balance.amount)
4363
4586
  }));
4364
4587
  }
4365
4588
  /**
@@ -4381,15 +4604,15 @@ var _Provider = class {
4381
4604
  sender: message.sender,
4382
4605
  recipient: message.recipient,
4383
4606
  nonce: message.nonce,
4384
- amount: bn15(message.amount),
4607
+ amount: bn16(message.amount),
4385
4608
  data: message.data
4386
4609
  }),
4387
4610
  sender: Address2.fromAddressOrString(message.sender),
4388
4611
  recipient: Address2.fromAddressOrString(message.recipient),
4389
4612
  nonce: message.nonce,
4390
- amount: bn15(message.amount),
4613
+ amount: bn16(message.amount),
4391
4614
  data: InputMessageCoder.decodeData(message.data),
4392
- daHeight: bn15(message.daHeight)
4615
+ daHeight: bn16(message.daHeight)
4393
4616
  }));
4394
4617
  }
4395
4618
  /**
@@ -4442,44 +4665,60 @@ var _Provider = class {
4442
4665
  } = result.messageProof;
4443
4666
  return {
4444
4667
  messageProof: {
4445
- proofIndex: bn15(messageProof.proofIndex),
4668
+ proofIndex: bn16(messageProof.proofIndex),
4446
4669
  proofSet: messageProof.proofSet
4447
4670
  },
4448
4671
  blockProof: {
4449
- proofIndex: bn15(blockProof.proofIndex),
4672
+ proofIndex: bn16(blockProof.proofIndex),
4450
4673
  proofSet: blockProof.proofSet
4451
4674
  },
4452
4675
  messageBlockHeader: {
4453
4676
  id: messageBlockHeader.id,
4454
- daHeight: bn15(messageBlockHeader.daHeight),
4455
- transactionsCount: bn15(messageBlockHeader.transactionsCount),
4677
+ daHeight: bn16(messageBlockHeader.daHeight),
4678
+ transactionsCount: bn16(messageBlockHeader.transactionsCount),
4456
4679
  transactionsRoot: messageBlockHeader.transactionsRoot,
4457
- height: bn15(messageBlockHeader.height),
4680
+ height: bn16(messageBlockHeader.height),
4458
4681
  prevRoot: messageBlockHeader.prevRoot,
4459
4682
  time: messageBlockHeader.time,
4460
4683
  applicationHash: messageBlockHeader.applicationHash,
4461
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4462
- messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4684
+ messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4685
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4686
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4687
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
4688
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4463
4689
  },
4464
4690
  commitBlockHeader: {
4465
4691
  id: commitBlockHeader.id,
4466
- daHeight: bn15(commitBlockHeader.daHeight),
4467
- transactionsCount: bn15(commitBlockHeader.transactionsCount),
4692
+ daHeight: bn16(commitBlockHeader.daHeight),
4693
+ transactionsCount: bn16(commitBlockHeader.transactionsCount),
4468
4694
  transactionsRoot: commitBlockHeader.transactionsRoot,
4469
- height: bn15(commitBlockHeader.height),
4695
+ height: bn16(commitBlockHeader.height),
4470
4696
  prevRoot: commitBlockHeader.prevRoot,
4471
4697
  time: commitBlockHeader.time,
4472
4698
  applicationHash: commitBlockHeader.applicationHash,
4473
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4474
- messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4699
+ messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4700
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4701
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4702
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
4703
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4475
4704
  },
4476
4705
  sender: Address2.fromAddressOrString(sender),
4477
4706
  recipient: Address2.fromAddressOrString(recipient),
4478
4707
  nonce,
4479
- amount: bn15(amount),
4708
+ amount: bn16(amount),
4480
4709
  data
4481
4710
  };
4482
4711
  }
4712
+ async getLatestGasPrice() {
4713
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
4714
+ return bn16(latestGasPrice.gasPrice);
4715
+ }
4716
+ async estimateGasPrice(blockHorizon) {
4717
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
4718
+ blockHorizon: String(blockHorizon)
4719
+ });
4720
+ return bn16(estimateGasPrice.gasPrice);
4721
+ }
4483
4722
  /**
4484
4723
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4485
4724
  *
@@ -4499,10 +4738,10 @@ var _Provider = class {
4499
4738
  */
4500
4739
  async produceBlocks(amount, startTime) {
4501
4740
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4502
- blocksToProduce: bn15(amount).toString(10),
4741
+ blocksToProduce: bn16(amount).toString(10),
4503
4742
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4504
4743
  });
4505
- return bn15(latestBlockHeight);
4744
+ return bn16(latestBlockHeight);
4506
4745
  }
4507
4746
  // eslint-disable-next-line @typescript-eslint/require-await
4508
4747
  async getTransactionResponse(transactionId) {
@@ -4516,7 +4755,7 @@ cacheInputs_fn = function(inputs) {
4516
4755
  return;
4517
4756
  }
4518
4757
  inputs.forEach((input) => {
4519
- if (input.type === InputType6.Coin) {
4758
+ if (input.type === InputType7.Coin) {
4520
4759
  this.cache?.set(input.id);
4521
4760
  }
4522
4761
  });
@@ -4526,7 +4765,7 @@ __publicField(Provider, "nodeInfoCache", {});
4526
4765
 
4527
4766
  // src/providers/transaction-summary/get-transaction-summary.ts
4528
4767
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4529
- import { bn as bn16 } from "@fuel-ts/math";
4768
+ import { bn as bn17 } from "@fuel-ts/math";
4530
4769
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4531
4770
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4532
4771
  async function getTransactionSummary(params) {
@@ -4544,21 +4783,28 @@ async function getTransactionSummary(params) {
4544
4783
  arrayify12(gqlTransaction.rawPayload),
4545
4784
  0
4546
4785
  );
4547
- const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4786
+ let txReceipts = [];
4787
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4788
+ txReceipts = gqlTransaction.status.receipts;
4789
+ }
4790
+ const receipts = txReceipts.map(processGqlReceipt);
4548
4791
  const {
4549
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4792
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4550
4793
  } = provider.getChain();
4794
+ const gasPrice = await provider.getLatestGasPrice();
4551
4795
  const transactionInfo = assembleTransactionSummary({
4552
4796
  id: gqlTransaction.id,
4553
4797
  receipts,
4554
4798
  transaction: decodedTransaction,
4555
4799
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4556
4800
  gqlTransactionStatus: gqlTransaction.status,
4557
- gasPerByte: bn16(gasPerByte),
4558
- gasPriceFactor: bn16(gasPriceFactor),
4801
+ gasPerByte: bn17(gasPerByte),
4802
+ gasPriceFactor: bn17(gasPriceFactor),
4559
4803
  abiMap,
4560
4804
  maxInputs,
4561
- gasCosts
4805
+ gasCosts,
4806
+ maxGasPerTx,
4807
+ gasPrice
4562
4808
  });
4563
4809
  return {
4564
4810
  gqlTransaction,
@@ -4568,10 +4814,11 @@ async function getTransactionSummary(params) {
4568
4814
  async function getTransactionSummaryFromRequest(params) {
4569
4815
  const { provider, transactionRequest, abiMap } = params;
4570
4816
  const { receipts } = await provider.call(transactionRequest);
4571
- const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4817
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4572
4818
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4573
4819
  const transaction = transactionRequest.toTransaction();
4574
4820
  const transactionBytes = transactionRequest.toTransactionBytes();
4821
+ const gasPrice = await provider.getLatestGasPrice();
4575
4822
  const transactionSummary = assembleTransactionSummary({
4576
4823
  receipts,
4577
4824
  transaction,
@@ -4580,7 +4827,9 @@ async function getTransactionSummaryFromRequest(params) {
4580
4827
  gasPerByte,
4581
4828
  gasPriceFactor,
4582
4829
  maxInputs,
4583
- gasCosts
4830
+ gasCosts,
4831
+ maxGasPerTx,
4832
+ gasPrice
4584
4833
  });
4585
4834
  return transactionSummary;
4586
4835
  }
@@ -4589,13 +4838,18 @@ async function getTransactionsSummaries(params) {
4589
4838
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4590
4839
  const { edges, pageInfo } = transactionsByOwner;
4591
4840
  const {
4592
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4841
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4593
4842
  } = provider.getChain();
4843
+ const gasPrice = await provider.getLatestGasPrice();
4594
4844
  const transactions = edges.map((edge) => {
4595
4845
  const { node: gqlTransaction } = edge;
4596
- const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4846
+ const { id, rawPayload, status } = gqlTransaction;
4597
4847
  const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
4598
- const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4848
+ let txReceipts = [];
4849
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4850
+ txReceipts = gqlTransaction.status.receipts;
4851
+ }
4852
+ const receipts = txReceipts.map(processGqlReceipt);
4599
4853
  const transactionSummary = assembleTransactionSummary({
4600
4854
  id,
4601
4855
  receipts,
@@ -4606,7 +4860,9 @@ async function getTransactionsSummaries(params) {
4606
4860
  gasPerByte,
4607
4861
  gasPriceFactor,
4608
4862
  maxInputs,
4609
- gasCosts
4863
+ gasCosts,
4864
+ maxGasPerTx,
4865
+ gasPrice
4610
4866
  });
4611
4867
  const output = {
4612
4868
  gqlTransaction,
@@ -4900,9 +5156,8 @@ var Account = class extends AbstractAccount {
4900
5156
  * @param assetId - The asset ID to check the balance for.
4901
5157
  * @returns A promise that resolves to the balance amount.
4902
5158
  */
4903
- async getBalance(assetId) {
4904
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4905
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
5159
+ async getBalance(assetId = BaseAssetId3) {
5160
+ const amount = await this.provider.getBalance(this.address, assetId);
4906
5161
  return amount;
4907
5162
  }
4908
5163
  /**
@@ -4939,37 +5194,33 @@ var Account = class extends AbstractAccount {
4939
5194
  * @param fee - The estimated transaction fee.
4940
5195
  * @returns A promise that resolves when the resources are added to the transaction.
4941
5196
  */
4942
- async fund(request, coinQuantities, fee) {
4943
- const baseAssetId = this.provider.getBaseAssetId();
4944
- const updatedQuantities = addAmountToAsset({
4945
- amount: bn17(fee),
4946
- assetId: baseAssetId,
4947
- coinQuantities
5197
+ async fund(request, params) {
5198
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5199
+ const txRequest = request;
5200
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5201
+ amount: bn18(fee),
5202
+ assetId: BaseAssetId3,
5203
+ coinQuantities: requiredQuantities
4948
5204
  });
4949
5205
  const quantitiesDict = {};
4950
- updatedQuantities.forEach(({ amount, assetId }) => {
5206
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4951
5207
  quantitiesDict[assetId] = {
4952
5208
  required: amount,
4953
- owned: bn17(0)
5209
+ owned: bn18(0)
4954
5210
  };
4955
5211
  });
4956
- const cachedUtxos = [];
4957
- const cachedMessages = [];
4958
- const owner = this.address.toB256();
4959
- request.inputs.forEach((input) => {
5212
+ txRequest.inputs.forEach((input) => {
4960
5213
  const isResource = "amount" in input;
4961
5214
  if (isResource) {
4962
5215
  const isCoin2 = "owner" in input;
4963
5216
  if (isCoin2) {
4964
5217
  const assetId = String(input.assetId);
4965
- if (input.owner === owner && quantitiesDict[assetId]) {
4966
- const amount = bn17(input.amount);
5218
+ if (quantitiesDict[assetId]) {
5219
+ const amount = bn18(input.amount);
4967
5220
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4968
- cachedUtxos.push(input.id);
4969
5221
  }
4970
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4971
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4972
- cachedMessages.push(input.nonce);
5222
+ } else if (input.amount && quantitiesDict[BaseAssetId3]) {
5223
+ quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4973
5224
  }
4974
5225
  }
4975
5226
  });
@@ -4984,12 +5235,23 @@ var Account = class extends AbstractAccount {
4984
5235
  });
4985
5236
  const needsToBeFunded = missingQuantities.length;
4986
5237
  if (needsToBeFunded) {
4987
- const resources = await this.getResourcesToSpend(missingQuantities, {
4988
- messages: cachedMessages,
4989
- utxos: cachedUtxos
4990
- });
4991
- request.addResources(resources);
5238
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5239
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5240
+ txRequest.addResources(resources);
5241
+ }
5242
+ txRequest.shiftPredicateData();
5243
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5244
+ const requestToBeReEstimate = clone4(txRequest);
5245
+ if (addedSignatures) {
5246
+ Array.from({ length: addedSignatures }).forEach(
5247
+ () => requestToBeReEstimate.addEmptyWitness()
5248
+ );
4992
5249
  }
5250
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
5251
+ transactionRequest: requestToBeReEstimate
5252
+ });
5253
+ txRequest.maxFee = maxFee;
5254
+ return txRequest;
4993
5255
  }
4994
5256
  /**
4995
5257
  * A helper that creates a transfer transaction request and returns it.
@@ -4997,30 +5259,25 @@ var Account = class extends AbstractAccount {
4997
5259
  * @param destination - The address of the destination.
4998
5260
  * @param amount - The amount of coins to transfer.
4999
5261
  * @param assetId - The asset ID of the coins to transfer.
5000
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5262
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5001
5263
  * @returns A promise that resolves to the prepared transaction request.
5002
5264
  */
5003
- async createTransfer(destination, amount, assetId, txParams = {}) {
5004
- const { minGasPrice } = this.provider.getGasConfig();
5005
- const baseAssetId = this.provider.getBaseAssetId();
5006
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5007
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5008
- const request = new ScriptTransactionRequest(params);
5009
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5010
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5265
+ async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5266
+ const request = new ScriptTransactionRequest(txParams);
5267
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5268
+ const txCost = await this.provider.getTransactionCost(request, {
5011
5269
  estimateTxDependencies: true,
5012
5270
  resourcesOwner: this
5013
5271
  });
5014
- request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5015
- request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
5016
- this.validateGas({
5017
- gasUsed,
5018
- gasPrice: request.gasPrice,
5019
- gasLimit: request.gasLimit,
5020
- minGasPrice
5021
- });
5022
- await this.fund(request, requiredQuantities, maxFee);
5023
- request.updatePredicateInputs(estimatedInputs);
5272
+ if ("gasLimit" in txParams) {
5273
+ this.validateGas({
5274
+ gasUsed: txCost.gasUsed,
5275
+ gasLimit: request.gasLimit
5276
+ });
5277
+ }
5278
+ request.gasLimit = txCost.gasUsed;
5279
+ request.maxFee = txCost.maxFee;
5280
+ await this.fund(request, txCost);
5024
5281
  return request;
5025
5282
  }
5026
5283
  /**
@@ -5032,15 +5289,14 @@ var Account = class extends AbstractAccount {
5032
5289
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5033
5290
  * @returns A promise that resolves to the transaction response.
5034
5291
  */
5035
- async transfer(destination, amount, assetId, txParams = {}) {
5036
- if (bn17(amount).lte(0)) {
5292
+ async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5293
+ if (bn18(amount).lte(0)) {
5037
5294
  throw new FuelError15(
5038
5295
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5039
5296
  "Transfer amount must be a positive number."
5040
5297
  );
5041
5298
  }
5042
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5043
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5299
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5044
5300
  return this.sendTransaction(request, { estimateTxDependencies: false });
5045
5301
  }
5046
5302
  /**
@@ -5052,41 +5308,38 @@ var Account = class extends AbstractAccount {
5052
5308
  * @param txParams - The optional transaction parameters.
5053
5309
  * @returns A promise that resolves to the transaction response.
5054
5310
  */
5055
- async transferToContract(contractId, amount, assetId, txParams = {}) {
5056
- if (bn17(amount).lte(0)) {
5311
+ async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5312
+ if (bn18(amount).lte(0)) {
5057
5313
  throw new FuelError15(
5058
5314
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5059
5315
  "Transfer amount must be a positive number."
5060
5316
  );
5061
5317
  }
5062
5318
  const contractAddress = Address3.fromAddressOrString(contractId);
5063
- const { minGasPrice } = this.provider.getGasConfig();
5064
- const baseAssetId = this.provider.getBaseAssetId();
5065
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5066
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5067
5319
  const { script, scriptData } = await assembleTransferToContractScript({
5068
5320
  hexlifiedContractId: contractAddress.toB256(),
5069
- amountToTransfer: bn17(amount),
5070
- assetId: assetIdToTransfer
5321
+ amountToTransfer: bn18(amount),
5322
+ assetId
5071
5323
  });
5072
5324
  const request = new ScriptTransactionRequest({
5073
- ...params,
5325
+ ...txParams,
5074
5326
  script,
5075
5327
  scriptData
5076
5328
  });
5077
5329
  request.addContractInputAndOutput(contractAddress);
5078
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5079
- request,
5080
- [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
5081
- );
5082
- request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5083
- this.validateGas({
5084
- gasUsed,
5085
- gasPrice: request.gasPrice,
5086
- gasLimit: request.gasLimit,
5087
- minGasPrice
5330
+ const txCost = await this.provider.getTransactionCost(request, {
5331
+ resourcesOwner: this,
5332
+ quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
5088
5333
  });
5089
- await this.fund(request, requiredQuantities, maxFee);
5334
+ if (txParams.gasLimit) {
5335
+ this.validateGas({
5336
+ gasUsed: txCost.gasUsed,
5337
+ gasLimit: request.gasLimit
5338
+ });
5339
+ }
5340
+ request.gasLimit = txCost.gasUsed;
5341
+ request.maxFee = txCost.maxFee;
5342
+ await this.fund(request, txCost);
5090
5343
  return this.sendTransaction(request);
5091
5344
  }
5092
5345
  /**
@@ -5098,40 +5351,31 @@ var Account = class extends AbstractAccount {
5098
5351
  * @returns A promise that resolves to the transaction response.
5099
5352
  */
5100
5353
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5101
- const { minGasPrice } = this.provider.getGasConfig();
5102
- const baseAssetId = this.provider.getBaseAssetId();
5103
5354
  const recipientAddress = Address3.fromAddressOrString(recipient);
5104
5355
  const recipientDataArray = arrayify14(
5105
5356
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5106
5357
  );
5107
5358
  const amountDataArray = arrayify14(
5108
- "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5359
+ "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
5109
5360
  );
5110
5361
  const script = new Uint8Array([
5111
5362
  ...arrayify14(withdrawScript.bytes),
5112
5363
  ...recipientDataArray,
5113
5364
  ...amountDataArray
5114
5365
  ]);
5115
- const params = {
5116
- script,
5117
- gasPrice: minGasPrice,
5118
- baseAssetId,
5119
- ...txParams
5120
- };
5366
+ const params = { script, ...txParams };
5121
5367
  const request = new ScriptTransactionRequest(params);
5122
- const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
5123
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5124
- request,
5125
- forwardingQuantities
5126
- );
5127
- request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5128
- this.validateGas({
5129
- gasUsed,
5130
- gasPrice: request.gasPrice,
5131
- gasLimit: request.gasLimit,
5132
- minGasPrice
5133
- });
5134
- await this.fund(request, requiredQuantities, maxFee);
5368
+ const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5369
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5370
+ if (txParams.gasLimit) {
5371
+ this.validateGas({
5372
+ gasUsed: txCost.gasUsed,
5373
+ gasLimit: request.gasLimit
5374
+ });
5375
+ }
5376
+ request.maxFee = txCost.maxFee;
5377
+ request.gasLimit = txCost.gasUsed;
5378
+ await this.fund(request, txCost);
5135
5379
  return this.sendTransaction(request);
5136
5380
  }
5137
5381
  async signMessage(message) {
@@ -5189,18 +5433,7 @@ var Account = class extends AbstractAccount {
5189
5433
  }
5190
5434
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5191
5435
  }
5192
- validateGas({
5193
- gasUsed,
5194
- gasPrice,
5195
- gasLimit,
5196
- minGasPrice
5197
- }) {
5198
- if (minGasPrice.gt(gasPrice)) {
5199
- throw new FuelError15(
5200
- ErrorCode15.GAS_PRICE_TOO_LOW,
5201
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5202
- );
5203
- }
5436
+ validateGas({ gasUsed, gasLimit }) {
5204
5437
  if (gasUsed.gt(gasLimit)) {
5205
5438
  throw new FuelError15(
5206
5439
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5216,7 +5449,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
5216
5449
 
5217
5450
  // src/signer/signer.ts
5218
5451
  import { Address as Address4 } from "@fuel-ts/address";
5219
- import { randomBytes } from "@fuel-ts/crypto";
5452
+ import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
5220
5453
  import { hash } from "@fuel-ts/hasher";
5221
5454
  import { toBytes } from "@fuel-ts/math";
5222
5455
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5309,7 +5542,7 @@ var Signer = class {
5309
5542
  * @returns random 32-byte hashed
5310
5543
  */
5311
5544
  static generatePrivateKey(entropy) {
5312
- return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5545
+ return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5313
5546
  }
5314
5547
  /**
5315
5548
  * Extended publicKey from a compact publicKey
@@ -5328,7 +5561,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5328
5561
  import {
5329
5562
  bufferFromString,
5330
5563
  keccak256,
5331
- randomBytes as randomBytes2,
5564
+ randomBytes as randomBytes3,
5332
5565
  scrypt,
5333
5566
  stringFromBuffer,
5334
5567
  decryptJsonWalletData,
@@ -5351,7 +5584,7 @@ var removeHexPrefix = (hexString) => {
5351
5584
  async function encryptKeystoreWallet(privateKey, address, password) {
5352
5585
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5353
5586
  const ownerAddress = Address5.fromAddressOrString(address);
5354
- const salt = randomBytes2(DEFAULT_KEY_SIZE);
5587
+ const salt = randomBytes3(DEFAULT_KEY_SIZE);
5355
5588
  const key = scrypt({
5356
5589
  password: bufferFromString(password),
5357
5590
  salt,
@@ -5360,7 +5593,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5360
5593
  r: DEFAULT_KDF_PARAMS_R,
5361
5594
  p: DEFAULT_KDF_PARAMS_P
5362
5595
  });
5363
- const iv = randomBytes2(DEFAULT_IV_SIZE);
5596
+ const iv = randomBytes3(DEFAULT_IV_SIZE);
5364
5597
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5365
5598
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5366
5599
  const macHashUint8Array = keccak256(data);
@@ -5496,7 +5729,7 @@ var BaseWalletUnlocked = class extends Account {
5496
5729
  * @param transactionRequestLike - The transaction request to send.
5497
5730
  * @returns A promise that resolves to the TransactionResponse object.
5498
5731
  */
5499
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5732
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5500
5733
  const transactionRequest = transactionRequestify(transactionRequestLike);
5501
5734
  if (estimateTxDependencies) {
5502
5735
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5537,12 +5770,12 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5537
5770
  // src/hdwallet/hdwallet.ts
5538
5771
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5539
5772
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5540
- import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5773
+ import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5541
5774
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5542
5775
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5543
5776
 
5544
5777
  // src/mnemonic/mnemonic.ts
5545
- import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5778
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5546
5779
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5547
5780
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5548
5781
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -7903,7 +8136,7 @@ var Mnemonic = class {
7903
8136
  * @returns A randomly generated mnemonic
7904
8137
  */
7905
8138
  static generate(size = 32, extraEntropy = "") {
7906
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
8139
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7907
8140
  return Mnemonic.entropyToMnemonic(entropy);
7908
8141
  }
7909
8142
  };
@@ -8009,7 +8242,7 @@ var HDWallet = class {
8009
8242
  const IR = bytes.slice(32);
8010
8243
  if (privateKey) {
8011
8244
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8012
- const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
8245
+ const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
8013
8246
  return new HDWallet({
8014
8247
  privateKey: ki,
8015
8248
  chainCode: IR,
@@ -8696,8 +8929,9 @@ import {
8696
8929
  SCRIPT_FIXED_SIZE
8697
8930
  } from "@fuel-ts/abi-coder";
8698
8931
  import { Address as Address9 } from "@fuel-ts/address";
8932
+ import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8699
8933
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8700
- import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8934
+ import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
8701
8935
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8702
8936
 
8703
8937
  // src/predicate/utils/getPredicateRoot.ts
@@ -8757,9 +8991,9 @@ var Predicate = class extends Account {
8757
8991
  const request = transactionRequestify(transactionRequestLike);
8758
8992
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8759
8993
  request.inputs?.forEach((input) => {
8760
- if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8761
- input.predicate = this.bytes;
8762
- input.predicateData = this.getPredicateData(policies.length);
8994
+ if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
8995
+ input.predicate = hexlify19(this.bytes);
8996
+ input.predicateData = hexlify19(this.getPredicateData(policies.length));
8763
8997
  }
8764
8998
  });
8765
8999
  return request;
@@ -8773,10 +9007,8 @@ var Predicate = class extends Account {
8773
9007
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8774
9008
  * @returns A promise that resolves to the prepared transaction request.
8775
9009
  */
8776
- async createTransfer(destination, amount, assetId, txParams = {}) {
8777
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8778
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8779
- return this.populateTransactionPredicateData(request);
9010
+ async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
9011
+ return super.createTransfer(destination, amount, assetId, txParams);
8780
9012
  }
8781
9013
  /**
8782
9014
  * Sends a transaction with the populated predicate data.
@@ -8784,9 +9016,9 @@ var Predicate = class extends Account {
8784
9016
  * @param transactionRequestLike - The transaction request-like object.
8785
9017
  * @returns A promise that resolves to the transaction response.
8786
9018
  */
8787
- sendTransaction(transactionRequestLike, options) {
8788
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8789
- return super.sendTransaction(transactionRequest, options);
9019
+ sendTransaction(transactionRequestLike) {
9020
+ const transactionRequest = transactionRequestify(transactionRequestLike);
9021
+ return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8790
9022
  }
8791
9023
  /**
8792
9024
  * Simulates a transaction with the populated predicate data.
@@ -8795,8 +9027,8 @@ var Predicate = class extends Account {
8795
9027
  * @returns A promise that resolves to the call result.
8796
9028
  */
8797
9029
  simulateTransaction(transactionRequestLike) {
8798
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8799
- return super.simulateTransaction(transactionRequest);
9030
+ const transactionRequest = transactionRequestify(transactionRequestLike);
9031
+ return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8800
9032
  }
8801
9033
  getPredicateData(policiesLength) {
8802
9034
  if (!this.predicateData.length) {
@@ -8842,6 +9074,25 @@ var Predicate = class extends Account {
8842
9074
  predicateInterface: abiInterface
8843
9075
  };
8844
9076
  }
9077
+ /**
9078
+ * Retrieves resources satisfying the spend query for the account.
9079
+ *
9080
+ * @param quantities - IDs of coins to exclude.
9081
+ * @param excludedIds - IDs of resources to be excluded from the query.
9082
+ * @returns A promise that resolves to an array of Resources.
9083
+ */
9084
+ async getResourcesToSpend(quantities, excludedIds) {
9085
+ const resources = await this.provider.getResourcesToSpend(
9086
+ this.address,
9087
+ quantities,
9088
+ excludedIds
9089
+ );
9090
+ return resources.map((resource) => ({
9091
+ ...resource,
9092
+ predicate: hexlify19(this.bytes),
9093
+ paddPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
9094
+ }));
9095
+ }
8845
9096
  /**
8846
9097
  * Sets the configurable constants for the predicate.
8847
9098
  *
@@ -9590,7 +9841,7 @@ export {
9590
9841
  WalletLocked,
9591
9842
  WalletManager,
9592
9843
  WalletUnlocked,
9593
- addAmountToAsset,
9844
+ addAmountToCoinQuantities,
9594
9845
  addOperation,
9595
9846
  assemblePanicError,
9596
9847
  assembleReceiptByType,
@@ -9599,9 +9850,10 @@ export {
9599
9850
  assets,
9600
9851
  buildBlockExplorerUrl,
9601
9852
  cacheFor,
9853
+ cacheTxInputsFromOwner,
9854
+ calculateGasFee,
9602
9855
  calculateMetadataGasForTxCreate,
9603
9856
  calculateMetadataGasForTxScript,
9604
- calculatePriceWithFactor,
9605
9857
  calculateTransactionFee,
9606
9858
  coinQuantityfy,
9607
9859
  deferPromise,