@fuel-ts/account 0.0.0-rc-2021-20240411154255 → 0.0.0-rc-2045-20240411190910

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

Potentially problematic release.


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

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