@fuel-ts/account 0.0.0-rc-2021-20240411154255 → 0.0.0-rc-2037-20240411163513

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 +563 -841
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +565 -825
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +400 -659
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -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 +1 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -6
  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 +5 -6
  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 +1047 -1557
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +543 -800
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +394 -651
  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
@@ -27,9 +27,8 @@ import { Address as Address3 } from "@fuel-ts/address";
27
27
  import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
28
28
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
29
29
  import { AbstractAccount } from "@fuel-ts/interfaces";
30
- import { bn as bn18 } from "@fuel-ts/math";
30
+ import { bn as bn17 } from "@fuel-ts/math";
31
31
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
32
- import { clone as clone4 } from "ramda";
33
32
 
34
33
  // src/providers/coin-quantity.ts
35
34
  import { BaseAssetId } from "@fuel-ts/address/configs";
@@ -38,24 +37,24 @@ import { hexlify } from "@fuel-ts/utils";
38
37
  var coinQuantityfy = (coinQuantityLike) => {
39
38
  let assetId;
40
39
  let amount;
41
- let max;
40
+ let max2;
42
41
  if (Array.isArray(coinQuantityLike)) {
43
42
  amount = coinQuantityLike[0];
44
43
  assetId = coinQuantityLike[1] ?? BaseAssetId;
45
- max = coinQuantityLike[2] ?? void 0;
44
+ max2 = coinQuantityLike[2] ?? void 0;
46
45
  } else {
47
46
  amount = coinQuantityLike.amount;
48
47
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
49
- max = coinQuantityLike.max ?? void 0;
48
+ max2 = coinQuantityLike.max ?? void 0;
50
49
  }
51
50
  const bnAmount = bn(amount);
52
51
  return {
53
52
  assetId: hexlify(assetId),
54
53
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
55
- max: max ? bn(max) : void 0
54
+ max: max2 ? bn(max2) : void 0
56
55
  };
57
56
  };
58
- var addAmountToCoinQuantities = (params) => {
57
+ var addAmountToAsset = (params) => {
59
58
  const { amount, assetId } = params;
60
59
  const coinQuantities = [...params.coinQuantities];
61
60
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -70,9 +69,9 @@ var addAmountToCoinQuantities = (params) => {
70
69
  // src/providers/provider.ts
71
70
  import { Address as Address2 } from "@fuel-ts/address";
72
71
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
73
- import { BN, bn as bn16 } from "@fuel-ts/math";
72
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
74
73
  import {
75
- InputType as InputType7,
74
+ InputType as InputType6,
76
75
  TransactionType as TransactionType8,
77
76
  InputMessageCoder,
78
77
  TransactionCoder as TransactionCoder5
@@ -88,10 +87,14 @@ import { clone as clone3 } from "ramda";
88
87
  import gql from "graphql-tag";
89
88
  var ReceiptFragmentFragmentDoc = gql`
90
89
  fragment receiptFragment on Receipt {
91
- id
90
+ contract {
91
+ id
92
+ }
92
93
  pc
93
94
  is
94
- to
95
+ to {
96
+ id
97
+ }
95
98
  toAddress
96
99
  amount
97
100
  assetId
@@ -129,16 +132,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
129
132
  id
130
133
  }
131
134
  time
132
- receipts {
133
- ...receiptFragment
134
- }
135
135
  programState {
136
136
  returnType
137
137
  data
138
138
  }
139
- receipts {
140
- ...receiptFragment
141
- }
142
139
  }
143
140
  ... on FailureStatus {
144
141
  block {
@@ -146,24 +143,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
146
143
  }
147
144
  time
148
145
  reason
149
- receipts {
150
- ...receiptFragment
151
- }
152
146
  }
153
147
  ... on SqueezedOutStatus {
154
148
  reason
155
149
  }
156
150
  }
157
- ${ReceiptFragmentFragmentDoc}`;
151
+ `;
158
152
  var TransactionFragmentFragmentDoc = gql`
159
153
  fragment transactionFragment on Transaction {
160
154
  id
161
155
  rawPayload
156
+ gasPrice
157
+ receipts {
158
+ ...receiptFragment
159
+ }
162
160
  status {
163
161
  ...transactionStatusFragment
164
162
  }
165
163
  }
166
- ${TransactionStatusFragmentFragmentDoc}`;
164
+ ${ReceiptFragmentFragmentDoc}
165
+ ${TransactionStatusFragmentFragmentDoc}`;
167
166
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
168
167
  fragment inputEstimatePredicatesFragment on Input {
169
168
  ... on InputCoin {
@@ -181,46 +180,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
181
180
  }
182
181
  }
183
182
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
184
- var DryRunFailureStatusFragmentFragmentDoc = gql`
185
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
186
- reason
187
- programState {
188
- returnType
189
- data
190
- }
191
- }
192
- `;
193
- var DryRunSuccessStatusFragmentFragmentDoc = gql`
194
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
195
- programState {
196
- returnType
197
- data
198
- }
199
- }
200
- `;
201
- var DryRunTransactionStatusFragmentFragmentDoc = gql`
202
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
203
- ... on DryRunFailureStatus {
204
- ...dryRunFailureStatusFragment
205
- }
206
- ... on DryRunSuccessStatus {
207
- ...dryRunSuccessStatusFragment
208
- }
209
- }
210
- ${DryRunFailureStatusFragmentFragmentDoc}
211
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
212
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
213
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
214
- id
215
- status {
216
- ...dryRunTransactionStatusFragment
217
- }
218
- receipts {
219
- ...receiptFragment
220
- }
221
- }
222
- ${DryRunTransactionStatusFragmentFragmentDoc}
223
- ${ReceiptFragmentFragmentDoc}`;
224
183
  var CoinFragmentFragmentDoc = gql`
225
184
  fragment coinFragment on Coin {
226
185
  __typename
@@ -228,6 +187,7 @@ var CoinFragmentFragmentDoc = gql`
228
187
  owner
229
188
  amount
230
189
  assetId
190
+ maturity
231
191
  blockCreated
232
192
  txCreatedIdx
233
193
  }
@@ -266,32 +226,26 @@ var MessageProofFragmentFragmentDoc = gql`
266
226
  messageBlockHeader {
267
227
  id
268
228
  daHeight
269
- consensusParametersVersion
270
- stateTransitionBytecodeVersion
271
229
  transactionsCount
272
- messageReceiptCount
273
230
  transactionsRoot
274
- messageOutboxRoot
275
- eventInboxRoot
276
231
  height
277
232
  prevRoot
278
233
  time
279
234
  applicationHash
235
+ messageReceiptRoot
236
+ messageReceiptCount
280
237
  }
281
238
  commitBlockHeader {
282
239
  id
283
240
  daHeight
284
- consensusParametersVersion
285
- stateTransitionBytecodeVersion
286
241
  transactionsCount
287
- messageReceiptCount
288
242
  transactionsRoot
289
- messageOutboxRoot
290
- eventInboxRoot
291
243
  height
292
244
  prevRoot
293
245
  time
294
246
  applicationHash
247
+ messageReceiptRoot
248
+ messageReceiptCount
295
249
  }
296
250
  sender
297
251
  recipient
@@ -310,8 +264,8 @@ var BalanceFragmentFragmentDoc = gql`
310
264
  var BlockFragmentFragmentDoc = gql`
311
265
  fragment blockFragment on Block {
312
266
  id
313
- height
314
267
  header {
268
+ height
315
269
  time
316
270
  }
317
271
  transactions {
@@ -369,11 +323,6 @@ var DependentCostFragmentFragmentDoc = gql`
369
323
  `;
370
324
  var GasCostsFragmentFragmentDoc = gql`
371
325
  fragment GasCostsFragment on GasCosts {
372
- version {
373
- ... on Version {
374
- value
375
- }
376
- }
377
326
  add
378
327
  addi
379
328
  aloc
@@ -386,6 +335,7 @@ var GasCostsFragmentFragmentDoc = gql`
386
335
  cb
387
336
  cfei
388
337
  cfsi
338
+ croo
389
339
  div
390
340
  divi
391
341
  ecr1
@@ -468,9 +418,6 @@ var GasCostsFragmentFragmentDoc = gql`
468
418
  ccp {
469
419
  ...DependentCostFragment
470
420
  }
471
- croo {
472
- ...DependentCostFragment
473
- }
474
421
  csiz {
475
422
  ...DependentCostFragment
476
423
  }
@@ -530,11 +477,6 @@ var GasCostsFragmentFragmentDoc = gql`
530
477
  ${DependentCostFragmentFragmentDoc}`;
531
478
  var ConsensusParametersFragmentFragmentDoc = gql`
532
479
  fragment consensusParametersFragment on ConsensusParameters {
533
- version {
534
- ... on Version {
535
- value
536
- }
537
- }
538
480
  txParams {
539
481
  ...TxParametersFragment
540
482
  }
@@ -594,9 +536,18 @@ var NodeInfoFragmentFragmentDoc = gql`
594
536
  fragment nodeInfoFragment on NodeInfo {
595
537
  utxoValidation
596
538
  vmBacktrace
539
+ minGasPrice
597
540
  maxTx
598
541
  maxDepth
599
542
  nodeVersion
543
+ peers {
544
+ id
545
+ addresses
546
+ clientVersion
547
+ blockHeight
548
+ lastHeartbeatMs
549
+ appScore
550
+ }
600
551
  }
601
552
  `;
602
553
  var GetVersionDocument = gql`
@@ -631,9 +582,13 @@ var GetTransactionWithReceiptsDocument = gql`
631
582
  query getTransactionWithReceipts($transactionId: TransactionId!) {
632
583
  transaction(id: $transactionId) {
633
584
  ...transactionFragment
585
+ receipts {
586
+ ...receiptFragment
587
+ }
634
588
  }
635
589
  }
636
- ${TransactionFragmentFragmentDoc}`;
590
+ ${TransactionFragmentFragmentDoc}
591
+ ${ReceiptFragmentFragmentDoc}`;
637
592
  var GetTransactionsDocument = gql`
638
593
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
639
594
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -761,20 +716,6 @@ var GetBalanceDocument = gql`
761
716
  }
762
717
  }
763
718
  ${BalanceFragmentFragmentDoc}`;
764
- var GetLatestGasPriceDocument = gql`
765
- query getLatestGasPrice {
766
- latestGasPrice {
767
- gasPrice
768
- }
769
- }
770
- `;
771
- var EstimateGasPriceDocument = gql`
772
- query estimateGasPrice($blockHorizon: U32!) {
773
- estimateGasPrice(blockHorizon: $blockHorizon) {
774
- gasPrice
775
- }
776
- }
777
- `;
778
719
  var GetBalancesDocument = gql`
779
720
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
780
721
  balances(
@@ -829,12 +770,12 @@ var GetMessageStatusDocument = gql`
829
770
  }
830
771
  `;
831
772
  var DryRunDocument = gql`
832
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
833
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
834
- ...dryRunTransactionExecutionStatusFragment
773
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
774
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
775
+ ...receiptFragment
835
776
  }
836
777
  }
837
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
778
+ ${ReceiptFragmentFragmentDoc}`;
838
779
  var SubmitDocument = gql`
839
780
  mutation submit($encodedTransaction: HexString!) {
840
781
  submit(tx: $encodedTransaction) {
@@ -917,12 +858,6 @@ function getSdk(requester) {
917
858
  getBalance(variables, options) {
918
859
  return requester(GetBalanceDocument, variables, options);
919
860
  },
920
- getLatestGasPrice(variables, options) {
921
- return requester(GetLatestGasPriceDocument, variables, options);
922
- },
923
- estimateGasPrice(variables, options) {
924
- return requester(EstimateGasPriceDocument, variables, options);
925
- },
926
861
  getBalances(variables, options) {
927
862
  return requester(GetBalancesDocument, variables, options);
928
863
  },
@@ -992,14 +927,11 @@ var _FuelGraphqlSubscriber = class {
992
927
  let data;
993
928
  let errors;
994
929
  try {
995
- const sanitizedText = text.replace(/\s/g, "");
996
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
930
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
997
931
  } catch (e) {
998
932
  throw new FuelError(
999
933
  ErrorCode.STREAM_PARSING_ERROR,
1000
- `Error while parsing stream data response: ${text}
1001
-
1002
- Thrown error: ${e}`
934
+ `Error while parsing stream data response: ${text}`
1003
935
  );
1004
936
  }
1005
937
  if (Array.isArray(errors)) {
@@ -1086,6 +1018,7 @@ var MemoryCache = class {
1086
1018
  };
1087
1019
 
1088
1020
  // src/providers/transaction-request/input.ts
1021
+ import { BYTES_32, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
1089
1022
  import { ZeroBytes32 } from "@fuel-ts/address/configs";
1090
1023
  import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
1091
1024
  import { bn as bn2, toNumber } from "@fuel-ts/math";
@@ -1099,8 +1032,8 @@ var inputify = (value) => {
1099
1032
  const predicateData = arrayify(value.predicateData ?? "0x");
1100
1033
  return {
1101
1034
  type: InputType.Coin,
1102
- txID: hexlify3(arrayify(value.id).slice(0, 32)),
1103
- outputIndex: toNumber(arrayify(value.id).slice(32, 34)),
1035
+ txID: hexlify3(arrayify(value.id).slice(0, BYTES_32)),
1036
+ outputIndex: toNumber(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
1104
1037
  owner: hexlify3(value.owner),
1105
1038
  amount: bn2(value.amount),
1106
1039
  assetId: hexlify3(value.assetId),
@@ -1109,9 +1042,10 @@ var inputify = (value) => {
1109
1042
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1110
1043
  },
1111
1044
  witnessIndex: value.witnessIndex,
1045
+ maturity: value.maturity ?? 0,
1112
1046
  predicateGasUsed: bn2(value.predicateGasUsed),
1113
- predicateLength: bn2(predicate.length),
1114
- predicateDataLength: bn2(predicateData.length),
1047
+ predicateLength: predicate.length,
1048
+ predicateDataLength: predicateData.length,
1115
1049
  predicate: hexlify3(predicate),
1116
1050
  predicateData: hexlify3(predicateData)
1117
1051
  };
@@ -1142,8 +1076,8 @@ var inputify = (value) => {
1142
1076
  nonce: hexlify3(value.nonce),
1143
1077
  witnessIndex: value.witnessIndex,
1144
1078
  predicateGasUsed: bn2(value.predicateGasUsed),
1145
- predicateLength: bn2(predicate.length),
1146
- predicateDataLength: bn2(predicateData.length),
1079
+ predicateLength: predicate.length,
1080
+ predicateDataLength: predicateData.length,
1147
1081
  predicate: hexlify3(predicate),
1148
1082
  predicateData: hexlify3(predicateData),
1149
1083
  data: hexlify3(data),
@@ -1217,8 +1151,10 @@ var outputify = (value) => {
1217
1151
  };
1218
1152
 
1219
1153
  // src/providers/transaction-request/transaction-request.ts
1154
+ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1220
1155
  import { Address, addressify } from "@fuel-ts/address";
1221
1156
  import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1157
+ import { randomBytes } from "@fuel-ts/crypto";
1222
1158
  import { bn as bn7 } from "@fuel-ts/math";
1223
1159
  import {
1224
1160
  PolicyType,
@@ -1228,7 +1164,6 @@ import {
1228
1164
  TransactionType
1229
1165
  } from "@fuel-ts/transactions";
1230
1166
  import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1231
- import { randomBytes } from "ethers";
1232
1167
 
1233
1168
  // src/providers/resource.ts
1234
1169
  var isCoin = (resource) => "id" in resource;
@@ -1269,8 +1204,8 @@ function assembleReceiptByType(receipt) {
1269
1204
  case "CALL" /* Call */: {
1270
1205
  const callReceipt = {
1271
1206
  type: ReceiptType.Call,
1272
- from: hexOrZero(receipt.id || receipt.contractId),
1273
- to: hexOrZero(receipt?.to),
1207
+ from: hexOrZero(receipt.contract?.id),
1208
+ to: hexOrZero(receipt?.to?.id),
1274
1209
  amount: bn4(receipt.amount),
1275
1210
  assetId: hexOrZero(receipt.assetId),
1276
1211
  gas: bn4(receipt.gas),
@@ -1284,7 +1219,7 @@ function assembleReceiptByType(receipt) {
1284
1219
  case "RETURN" /* Return */: {
1285
1220
  const returnReceipt = {
1286
1221
  type: ReceiptType.Return,
1287
- id: hexOrZero(receipt.id || receipt.contractId),
1222
+ id: hexOrZero(receipt.contract?.id),
1288
1223
  val: bn4(receipt.val),
1289
1224
  pc: bn4(receipt.pc),
1290
1225
  is: bn4(receipt.is)
@@ -1294,7 +1229,7 @@ function assembleReceiptByType(receipt) {
1294
1229
  case "RETURN_DATA" /* ReturnData */: {
1295
1230
  const returnDataReceipt = {
1296
1231
  type: ReceiptType.ReturnData,
1297
- id: hexOrZero(receipt.id || receipt.contractId),
1232
+ id: hexOrZero(receipt.contract?.id),
1298
1233
  ptr: bn4(receipt.ptr),
1299
1234
  len: bn4(receipt.len),
1300
1235
  digest: hexOrZero(receipt.digest),
@@ -1306,7 +1241,7 @@ function assembleReceiptByType(receipt) {
1306
1241
  case "PANIC" /* Panic */: {
1307
1242
  const panicReceipt = {
1308
1243
  type: ReceiptType.Panic,
1309
- id: hexOrZero(receipt.id),
1244
+ id: hexOrZero(receipt.contract?.id),
1310
1245
  reason: bn4(receipt.reason),
1311
1246
  pc: bn4(receipt.pc),
1312
1247
  is: bn4(receipt.is),
@@ -1317,7 +1252,7 @@ function assembleReceiptByType(receipt) {
1317
1252
  case "REVERT" /* Revert */: {
1318
1253
  const revertReceipt = {
1319
1254
  type: ReceiptType.Revert,
1320
- id: hexOrZero(receipt.id || receipt.contractId),
1255
+ id: hexOrZero(receipt.contract?.id),
1321
1256
  val: bn4(receipt.ra),
1322
1257
  pc: bn4(receipt.pc),
1323
1258
  is: bn4(receipt.is)
@@ -1327,7 +1262,7 @@ function assembleReceiptByType(receipt) {
1327
1262
  case "LOG" /* Log */: {
1328
1263
  const logReceipt = {
1329
1264
  type: ReceiptType.Log,
1330
- id: hexOrZero(receipt.id || receipt.contractId),
1265
+ id: hexOrZero(receipt.contract?.id),
1331
1266
  val0: bn4(receipt.ra),
1332
1267
  val1: bn4(receipt.rb),
1333
1268
  val2: bn4(receipt.rc),
@@ -1340,7 +1275,7 @@ function assembleReceiptByType(receipt) {
1340
1275
  case "LOG_DATA" /* LogData */: {
1341
1276
  const logDataReceipt = {
1342
1277
  type: ReceiptType.LogData,
1343
- id: hexOrZero(receipt.id || receipt.contractId),
1278
+ id: hexOrZero(receipt.contract?.id),
1344
1279
  val0: bn4(receipt.ra),
1345
1280
  val1: bn4(receipt.rb),
1346
1281
  ptr: bn4(receipt.ptr),
@@ -1354,8 +1289,8 @@ function assembleReceiptByType(receipt) {
1354
1289
  case "TRANSFER" /* Transfer */: {
1355
1290
  const transferReceipt = {
1356
1291
  type: ReceiptType.Transfer,
1357
- from: hexOrZero(receipt.id || receipt.contractId),
1358
- to: hexOrZero(receipt.toAddress || receipt?.to),
1292
+ from: hexOrZero(receipt.contract?.id),
1293
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1359
1294
  amount: bn4(receipt.amount),
1360
1295
  assetId: hexOrZero(receipt.assetId),
1361
1296
  pc: bn4(receipt.pc),
@@ -1366,8 +1301,8 @@ function assembleReceiptByType(receipt) {
1366
1301
  case "TRANSFER_OUT" /* TransferOut */: {
1367
1302
  const transferOutReceipt = {
1368
1303
  type: ReceiptType.TransferOut,
1369
- from: hexOrZero(receipt.id || receipt.contractId),
1370
- to: hexOrZero(receipt.toAddress || receipt.to),
1304
+ from: hexOrZero(receipt.contract?.id),
1305
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1371
1306
  amount: bn4(receipt.amount),
1372
1307
  assetId: hexOrZero(receipt.assetId),
1373
1308
  pc: bn4(receipt.pc),
@@ -1410,7 +1345,7 @@ function assembleReceiptByType(receipt) {
1410
1345
  return receiptMessageOut;
1411
1346
  }
1412
1347
  case "MINT" /* Mint */: {
1413
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1348
+ const contractId = hexOrZero(receipt.contract?.id);
1414
1349
  const subId = hexOrZero(receipt.subId);
1415
1350
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1416
1351
  const mintReceipt = {
@@ -1425,7 +1360,7 @@ function assembleReceiptByType(receipt) {
1425
1360
  return mintReceipt;
1426
1361
  }
1427
1362
  case "BURN" /* Burn */: {
1428
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1363
+ const contractId = hexOrZero(receipt.contract?.id);
1429
1364
  const subId = hexOrZero(receipt.subId);
1430
1365
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1431
1366
  const burnReceipt = {
@@ -1451,6 +1386,7 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
1451
1386
  import { bn as bn5 } from "@fuel-ts/math";
1452
1387
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1453
1388
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1389
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1454
1390
  var getGasUsedFromReceipts = (receipts) => {
1455
1391
  const scriptResult = receipts.filter(
1456
1392
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1471,28 +1407,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1471
1407
  }
1472
1408
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1473
1409
  const witnessCache = [];
1474
- const chargeableInputs = inputs.filter((input) => {
1475
- const isCoinOrMessage = "owner" in input || "sender" in input;
1476
- if (isCoinOrMessage) {
1477
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1478
- return true;
1479
- }
1480
- if (!witnessCache.includes(input.witnessIndex)) {
1481
- witnessCache.push(input.witnessIndex);
1482
- return true;
1483
- }
1484
- }
1485
- return false;
1486
- });
1487
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1488
- const totalGas = chargeableInputs.reduce((total, input) => {
1410
+ const totalGas = inputs.reduce((total, input) => {
1489
1411
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1490
1412
  return total.add(
1491
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1413
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1492
1414
  );
1493
1415
  }
1494
- return total.add(gasCosts.ecr1);
1495
- }, bn5(0));
1416
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1417
+ witnessCache.push(input.witnessIndex);
1418
+ return total.add(gasCosts.ecr1);
1419
+ }
1420
+ return total;
1421
+ }, bn5());
1496
1422
  return totalGas;
1497
1423
  }
1498
1424
  function getMinGas(params) {
@@ -1504,20 +1430,12 @@ function getMinGas(params) {
1504
1430
  return minGas;
1505
1431
  }
1506
1432
  function getMaxGas(params) {
1507
- const {
1508
- gasPerByte,
1509
- witnessesLength,
1510
- witnessLimit,
1511
- minGas,
1512
- gasLimit = bn5(0),
1513
- maxGasPerTx
1514
- } = params;
1433
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1515
1434
  let remainingAllowedWitnessGas = bn5(0);
1516
1435
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1517
1436
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1518
1437
  }
1519
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1520
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1438
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1521
1439
  }
1522
1440
  function calculateMetadataGasForTxCreate({
1523
1441
  gasCosts,
@@ -1539,10 +1457,6 @@ function calculateMetadataGasForTxScript({
1539
1457
  }) {
1540
1458
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1541
1459
  }
1542
- var calculateGasFee = (params) => {
1543
- const { gas, gasPrice, priceFactor, tip } = params;
1544
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1545
- };
1546
1460
 
1547
1461
  // src/providers/utils/json.ts
1548
1462
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1687,7 +1601,7 @@ var witnessify = (value) => {
1687
1601
  // src/providers/transaction-request/transaction-request.ts
1688
1602
  var BaseTransactionRequest = class {
1689
1603
  /** Gas price for transaction */
1690
- tip;
1604
+ gasPrice;
1691
1605
  /** Block until which tx cannot be included */
1692
1606
  maturity;
1693
1607
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1706,7 +1620,7 @@ var BaseTransactionRequest = class {
1706
1620
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1707
1621
  */
1708
1622
  constructor({
1709
- tip,
1623
+ gasPrice,
1710
1624
  maturity,
1711
1625
  maxFee,
1712
1626
  witnessLimit,
@@ -1714,7 +1628,7 @@ var BaseTransactionRequest = class {
1714
1628
  outputs,
1715
1629
  witnesses
1716
1630
  } = {}) {
1717
- this.tip = bn7(tip);
1631
+ this.gasPrice = bn7(gasPrice);
1718
1632
  this.maturity = maturity ?? 0;
1719
1633
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1720
1634
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
@@ -1725,9 +1639,9 @@ var BaseTransactionRequest = class {
1725
1639
  static getPolicyMeta(req) {
1726
1640
  let policyTypes = 0;
1727
1641
  const policies = [];
1728
- if (req.tip) {
1729
- policyTypes += PolicyType.Tip;
1730
- policies.push({ data: req.tip, type: PolicyType.Tip });
1642
+ if (req.gasPrice) {
1643
+ policyTypes += PolicyType.GasPrice;
1644
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1731
1645
  }
1732
1646
  if (req.witnessLimit) {
1733
1647
  policyTypes += PolicyType.WitnessLimit;
@@ -1915,9 +1829,9 @@ var BaseTransactionRequest = class {
1915
1829
  * @param predicateData - Predicate data bytes.
1916
1830
  */
1917
1831
  addCoinInput(coin) {
1918
- const { assetId, owner, amount } = coin;
1832
+ const { assetId, owner, amount, id, predicate } = coin;
1919
1833
  let witnessIndex;
1920
- if (coin.predicate) {
1834
+ if (predicate) {
1921
1835
  witnessIndex = 0;
1922
1836
  } else {
1923
1837
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1926,13 +1840,14 @@ var BaseTransactionRequest = class {
1926
1840
  }
1927
1841
  }
1928
1842
  const input = {
1929
- ...coin,
1843
+ id,
1930
1844
  type: InputType2.Coin,
1931
1845
  owner: owner.toB256(),
1932
1846
  amount,
1933
1847
  assetId,
1934
1848
  txPointer: "0x00000000000000000000000000000000",
1935
- witnessIndex
1849
+ witnessIndex,
1850
+ predicate
1936
1851
  };
1937
1852
  this.pushInput(input);
1938
1853
  this.addChangeOutput(owner, assetId);
@@ -1946,10 +1861,10 @@ var BaseTransactionRequest = class {
1946
1861
  * @param predicateData - Predicate data bytes.
1947
1862
  */
1948
1863
  addMessageInput(message) {
1949
- const { recipient, sender, amount } = message;
1864
+ const { recipient, sender, amount, predicate, nonce } = message;
1950
1865
  const assetId = BaseAssetId2;
1951
1866
  let witnessIndex;
1952
- if (message.predicate) {
1867
+ if (predicate) {
1953
1868
  witnessIndex = 0;
1954
1869
  } else {
1955
1870
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1958,12 +1873,13 @@ var BaseTransactionRequest = class {
1958
1873
  }
1959
1874
  }
1960
1875
  const input = {
1961
- ...message,
1876
+ nonce,
1962
1877
  type: InputType2.Message,
1963
1878
  sender: sender.toB256(),
1964
1879
  recipient: recipient.toB256(),
1965
1880
  amount,
1966
- witnessIndex
1881
+ witnessIndex,
1882
+ predicate
1967
1883
  };
1968
1884
  this.pushInput(input);
1969
1885
  this.addChangeOutput(recipient, assetId);
@@ -2073,7 +1989,7 @@ var BaseTransactionRequest = class {
2073
1989
  }
2074
1990
  calculateMaxGas(chainInfo, minGas) {
2075
1991
  const { consensusParameters } = chainInfo;
2076
- const { gasPerByte, maxGasPerTx } = consensusParameters;
1992
+ const { gasPerByte } = consensusParameters;
2077
1993
  const witnessesLength = this.toTransaction().witnesses.reduce(
2078
1994
  (acc, wit) => acc + wit.dataLength,
2079
1995
  0
@@ -2082,8 +1998,7 @@ var BaseTransactionRequest = class {
2082
1998
  gasPerByte,
2083
1999
  minGas,
2084
2000
  witnessesLength,
2085
- witnessLimit: this.witnessLimit,
2086
- maxGasPerTx
2001
+ witnessLimit: this.witnessLimit
2087
2002
  });
2088
2003
  }
2089
2004
  /**
@@ -2101,20 +2016,17 @@ var BaseTransactionRequest = class {
2101
2016
  });
2102
2017
  const updateAssetInput = (assetId, quantity) => {
2103
2018
  const assetInput = findAssetInput(assetId);
2104
- let usedQuantity = quantity;
2105
- if (assetId === BaseAssetId2) {
2106
- usedQuantity = bn7("1000000000000000000");
2107
- }
2108
2019
  if (assetInput && "assetId" in assetInput) {
2109
- assetInput.id = hexlify7(randomBytes(34));
2110
- assetInput.amount = usedQuantity;
2020
+ assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2021
+ assetInput.amount = quantity;
2111
2022
  } else {
2112
2023
  this.addResources([
2113
2024
  {
2114
- id: hexlify7(randomBytes(34)),
2115
- amount: usedQuantity,
2025
+ id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2026
+ amount: quantity,
2116
2027
  assetId,
2117
2028
  owner: resourcesOwner || Address.fromRandom(),
2029
+ maturity: 0,
2118
2030
  blockCreated: bn7(1),
2119
2031
  txCreatedIdx: bn7(1)
2120
2032
  }
@@ -2146,7 +2058,7 @@ var BaseTransactionRequest = class {
2146
2058
  toJSON() {
2147
2059
  return normalizeJSON(this);
2148
2060
  }
2149
- updatePredicateGasUsed(inputs) {
2061
+ updatePredicateInputs(inputs) {
2150
2062
  this.inputs.forEach((i) => {
2151
2063
  let correspondingInput;
2152
2064
  switch (i.type) {
@@ -2168,15 +2080,6 @@ var BaseTransactionRequest = class {
2168
2080
  }
2169
2081
  });
2170
2082
  }
2171
- shiftPredicateData() {
2172
- this.inputs.forEach((input) => {
2173
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2174
- input.predicateData = input.paddPredicateData(
2175
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2176
- );
2177
- }
2178
- });
2179
- }
2180
2083
  };
2181
2084
 
2182
2085
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2323,8 +2226,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2323
2226
  return {
2324
2227
  type: TransactionType3.Create,
2325
2228
  ...baseTransaction,
2229
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2326
2230
  bytecodeWitnessIndex,
2327
- storageSlotsCount: bn9(storageSlots.length),
2231
+ storageSlotsCount: storageSlots.length,
2328
2232
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2329
2233
  storageSlots
2330
2234
  };
@@ -2447,8 +2351,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2447
2351
  type: TransactionType4.Script,
2448
2352
  scriptGasLimit: this.gasLimit,
2449
2353
  ...super.getBaseTransaction(),
2450
- scriptLength: bn10(script.length),
2451
- scriptDataLength: bn10(scriptData.length),
2354
+ scriptLength: script.length,
2355
+ scriptDataLength: scriptData.length,
2452
2356
  receiptsRoot: ZeroBytes327,
2453
2357
  script: hexlify10(script),
2454
2358
  scriptData: hexlify10(scriptData)
@@ -2512,7 +2416,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2512
2416
  }
2513
2417
  calculateMaxGas(chainInfo, minGas) {
2514
2418
  const { consensusParameters } = chainInfo;
2515
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2419
+ const { gasPerByte } = consensusParameters;
2516
2420
  const witnessesLength = this.toTransaction().witnesses.reduce(
2517
2421
  (acc, wit) => acc + wit.dataLength,
2518
2422
  0
@@ -2522,8 +2426,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2522
2426
  minGas,
2523
2427
  witnessesLength,
2524
2428
  witnessLimit: this.witnessLimit,
2525
- gasLimit: this.gasLimit,
2526
- maxGasPerTx
2429
+ gasLimit: this.gasLimit
2527
2430
  });
2528
2431
  }
2529
2432
  /**
@@ -2580,7 +2483,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2580
2483
 
2581
2484
  // src/providers/transaction-request/utils.ts
2582
2485
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2583
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2486
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2584
2487
  var transactionRequestify = (obj) => {
2585
2488
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2586
2489
  return obj;
@@ -2598,31 +2501,14 @@ var transactionRequestify = (obj) => {
2598
2501
  }
2599
2502
  }
2600
2503
  };
2601
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2602
- (acc, input) => {
2603
- if (input.type === InputType5.Coin && input.owner === owner) {
2604
- acc.utxos.push(input.id);
2605
- }
2606
- if (input.type === InputType5.Message && input.recipient === owner) {
2607
- acc.messages.push(input.nonce);
2608
- }
2609
- return acc;
2610
- },
2611
- {
2612
- utxos: [],
2613
- messages: []
2614
- }
2615
- );
2616
2504
 
2617
2505
  // src/providers/transaction-response/transaction-response.ts
2618
2506
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2619
- import { bn as bn15 } from "@fuel-ts/math";
2507
+ import { bn as bn14 } from "@fuel-ts/math";
2620
2508
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2621
2509
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2622
2510
 
2623
2511
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2624
- import { bn as bn14 } from "@fuel-ts/math";
2625
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2626
2512
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2627
2513
 
2628
2514
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2631,10 +2517,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2631
2517
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2632
2518
  var calculateTransactionFee = (params) => {
2633
2519
  const {
2634
- gasPrice,
2520
+ gasUsed,
2635
2521
  rawPayload,
2636
- tip,
2637
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2522
+ consensusParameters: { gasCosts, feeParams }
2638
2523
  } = params;
2639
2524
  const gasPerByte = bn11(feeParams.gasPerByte);
2640
2525
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2644,7 +2529,8 @@ var calculateTransactionFee = (params) => {
2644
2529
  return {
2645
2530
  fee: bn11(0),
2646
2531
  minFee: bn11(0),
2647
- maxFee: bn11(0)
2532
+ maxFee: bn11(0),
2533
+ feeFromGasUsed: bn11(0)
2648
2534
  };
2649
2535
  }
2650
2536
  const { type, witnesses, inputs, policies } = transaction;
@@ -2676,6 +2562,7 @@ var calculateTransactionFee = (params) => {
2676
2562
  metadataGas,
2677
2563
  txBytesSize: transactionBytes.length
2678
2564
  });
2565
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2679
2566
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2680
2567
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2681
2568
  const maxGas = getMaxGas({
@@ -2683,25 +2570,17 @@ var calculateTransactionFee = (params) => {
2683
2570
  minGas,
2684
2571
  witnessesLength,
2685
2572
  gasLimit,
2686
- witnessLimit,
2687
- maxGasPerTx
2688
- });
2689
- const minFee = calculateGasFee({
2690
- gasPrice,
2691
- gas: minGas,
2692
- priceFactor: gasPriceFactor,
2693
- tip
2694
- });
2695
- const maxFee = calculateGasFee({
2696
- gasPrice,
2697
- gas: maxGas,
2698
- priceFactor: gasPriceFactor,
2699
- tip
2573
+ witnessLimit
2700
2574
  });
2575
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2576
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2577
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2578
+ const fee = minFee.add(feeFromGasUsed);
2701
2579
  return {
2580
+ fee,
2702
2581
  minFee,
2703
2582
  maxFee,
2704
- fee: maxFee
2583
+ feeFromGasUsed
2705
2584
  };
2706
2585
  };
2707
2586
 
@@ -2757,7 +2636,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2757
2636
 
2758
2637
  // src/providers/transaction-summary/input.ts
2759
2638
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2760
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2639
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2761
2640
  function getInputsByTypes(inputs, types) {
2762
2641
  return inputs.filter((i) => types.includes(i.type));
2763
2642
  }
@@ -2765,16 +2644,16 @@ function getInputsByType(inputs, type) {
2765
2644
  return inputs.filter((i) => i.type === type);
2766
2645
  }
2767
2646
  function getInputsCoin(inputs) {
2768
- return getInputsByType(inputs, InputType6.Coin);
2647
+ return getInputsByType(inputs, InputType5.Coin);
2769
2648
  }
2770
2649
  function getInputsMessage(inputs) {
2771
- return getInputsByType(inputs, InputType6.Message);
2650
+ return getInputsByType(inputs, InputType5.Message);
2772
2651
  }
2773
2652
  function getInputsCoinAndMessage(inputs) {
2774
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2653
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2775
2654
  }
2776
2655
  function getInputsContract(inputs) {
2777
- return getInputsByType(inputs, InputType6.Contract);
2656
+ return getInputsByType(inputs, InputType5.Contract);
2778
2657
  }
2779
2658
  function getInputFromAssetId(inputs, assetId) {
2780
2659
  const coinInputs = getInputsCoin(inputs);
@@ -2793,7 +2672,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2793
2672
  if (!contractInput) {
2794
2673
  return void 0;
2795
2674
  }
2796
- if (contractInput.type !== InputType6.Contract) {
2675
+ if (contractInput.type !== InputType5.Contract) {
2797
2676
  throw new FuelError9(
2798
2677
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2799
2678
  `Contract input should be of type 'contract'.`
@@ -2802,10 +2681,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2802
2681
  return contractInput;
2803
2682
  }
2804
2683
  function getInputAccountAddress(input) {
2805
- if (input.type === InputType6.Coin) {
2684
+ if (input.type === InputType5.Coin) {
2806
2685
  return input.owner.toString();
2807
2686
  }
2808
- if (input.type === InputType6.Message) {
2687
+ if (input.type === InputType5.Message) {
2809
2688
  return input.recipient.toString();
2810
2689
  }
2811
2690
  return "";
@@ -3268,9 +3147,7 @@ function assembleTransactionSummary(params) {
3268
3147
  gqlTransactionStatus,
3269
3148
  abiMap = {},
3270
3149
  maxInputs,
3271
- gasCosts,
3272
- maxGasPerTx,
3273
- gasPrice
3150
+ gasCosts
3274
3151
  } = params;
3275
3152
  const gasUsed = getGasUsedFromReceipts(receipts);
3276
3153
  const rawPayload = hexlify11(transactionBytes);
@@ -3284,14 +3161,11 @@ function assembleTransactionSummary(params) {
3284
3161
  maxInputs
3285
3162
  });
3286
3163
  const typeName = getTransactionTypeName(transaction.type);
3287
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3288
3164
  const { fee } = calculateTransactionFee({
3289
- gasPrice,
3165
+ gasUsed,
3290
3166
  rawPayload,
3291
- tip,
3292
3167
  consensusParameters: {
3293
3168
  gasCosts,
3294
- maxGasPerTx,
3295
3169
  feeParams: {
3296
3170
  gasPerByte,
3297
3171
  gasPriceFactor
@@ -3351,7 +3225,7 @@ var TransactionResponse = class {
3351
3225
  /** Current provider */
3352
3226
  provider;
3353
3227
  /** Gas used on the transaction */
3354
- gasUsed = bn15(0);
3228
+ gasUsed = bn14(0);
3355
3229
  /** The graphql Transaction with receipts object. */
3356
3230
  gqlTransaction;
3357
3231
  abis;
@@ -3429,13 +3303,8 @@ var TransactionResponse = class {
3429
3303
  const decodedTransaction = this.decodeTransaction(
3430
3304
  transaction
3431
3305
  );
3432
- let txReceipts = [];
3433
- if (transaction?.status && "receipts" in transaction.status) {
3434
- txReceipts = transaction.status.receipts;
3435
- }
3436
- const receipts = txReceipts.map(processGqlReceipt) || [];
3437
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3438
- const gasPrice = await this.provider.getLatestGasPrice();
3306
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3307
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3439
3308
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3440
3309
  const transactionSummary = assembleTransactionSummary({
3441
3310
  id: this.id,
@@ -3447,9 +3316,7 @@ var TransactionResponse = class {
3447
3316
  gasPriceFactor,
3448
3317
  abiMap: contractsAbiMap,
3449
3318
  maxInputs,
3450
- gasCosts,
3451
- maxGasPerTx,
3452
- gasPrice
3319
+ gasCosts
3453
3320
  });
3454
3321
  return transactionSummary;
3455
3322
  }
@@ -3576,29 +3443,29 @@ var processGqlChain = (chain) => {
3576
3443
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3577
3444
  return {
3578
3445
  name,
3579
- baseChainHeight: bn16(daHeight),
3446
+ baseChainHeight: bn15(daHeight),
3580
3447
  consensusParameters: {
3581
- contractMaxSize: bn16(contractParams.contractMaxSize),
3582
- maxInputs: bn16(txParams.maxInputs),
3583
- maxOutputs: bn16(txParams.maxOutputs),
3584
- maxWitnesses: bn16(txParams.maxWitnesses),
3585
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3586
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3587
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3588
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3589
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3590
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3591
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3592
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3593
- gasPerByte: bn16(feeParams.gasPerByte),
3594
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3595
- chainId: bn16(consensusParameters.chainId),
3448
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3449
+ maxInputs: bn15(txParams.maxInputs),
3450
+ maxOutputs: bn15(txParams.maxOutputs),
3451
+ maxWitnesses: bn15(txParams.maxWitnesses),
3452
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3453
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3454
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3455
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3456
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3457
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3458
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3459
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3460
+ gasPerByte: bn15(feeParams.gasPerByte),
3461
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3462
+ chainId: bn15(consensusParameters.chainId),
3596
3463
  gasCosts
3597
3464
  },
3598
3465
  gasCosts,
3599
3466
  latestBlock: {
3600
3467
  id: latestBlock.id,
3601
- height: bn16(latestBlock.height),
3468
+ height: bn15(latestBlock.header.height),
3602
3469
  time: latestBlock.header.time,
3603
3470
  transactions: latestBlock.transactions.map((i) => ({
3604
3471
  id: i.id
@@ -3692,8 +3559,10 @@ var _Provider = class {
3692
3559
  * Returns some helpful parameters related to gas fees.
3693
3560
  */
3694
3561
  getGasConfig() {
3562
+ const { minGasPrice } = this.getNode();
3695
3563
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3696
3564
  return {
3565
+ minGasPrice,
3697
3566
  maxGasPerTx,
3698
3567
  maxGasPerPredicate,
3699
3568
  gasPriceFactor,
@@ -3791,7 +3660,7 @@ var _Provider = class {
3791
3660
  */
3792
3661
  async getBlockNumber() {
3793
3662
  const { chain } = await this.operations.getChain();
3794
- return bn16(chain.latestBlock.height, 10);
3663
+ return bn15(chain.latestBlock.header.height, 10);
3795
3664
  }
3796
3665
  /**
3797
3666
  * Returns the chain information.
@@ -3801,11 +3670,13 @@ var _Provider = class {
3801
3670
  async fetchNode() {
3802
3671
  const { nodeInfo } = await this.operations.getNodeInfo();
3803
3672
  const processedNodeInfo = {
3804
- maxDepth: bn16(nodeInfo.maxDepth),
3805
- maxTx: bn16(nodeInfo.maxTx),
3673
+ maxDepth: bn15(nodeInfo.maxDepth),
3674
+ maxTx: bn15(nodeInfo.maxTx),
3675
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3806
3676
  nodeVersion: nodeInfo.nodeVersion,
3807
3677
  utxoValidation: nodeInfo.utxoValidation,
3808
- vmBacktrace: nodeInfo.vmBacktrace
3678
+ vmBacktrace: nodeInfo.vmBacktrace,
3679
+ peers: nodeInfo.peers
3809
3680
  };
3810
3681
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3811
3682
  return processedNodeInfo;
@@ -3891,13 +3762,14 @@ var _Provider = class {
3891
3762
  return this.estimateTxDependencies(transactionRequest);
3892
3763
  }
3893
3764
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3894
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3895
- encodedTransactions: encodedTransaction,
3765
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3766
+ encodedTransaction,
3896
3767
  utxoValidation: utxoValidation || false
3897
3768
  });
3898
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3899
- const receipts = rawReceipts.map(processGqlReceipt);
3900
- return { receipts, dryrunStatus: status };
3769
+ const receipts = gqlReceipts.map(processGqlReceipt);
3770
+ return {
3771
+ receipts
3772
+ };
3901
3773
  }
3902
3774
  /**
3903
3775
  * Verifies whether enough gas is available to complete transaction.
@@ -3923,7 +3795,7 @@ var _Provider = class {
3923
3795
  } = response;
3924
3796
  if (inputs) {
3925
3797
  inputs.forEach((input, index) => {
3926
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3798
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3927
3799
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3928
3800
  }
3929
3801
  });
@@ -3936,6 +3808,9 @@ var _Provider = class {
3936
3808
  * If there are missing variable outputs,
3937
3809
  * `addVariableOutputs` is called on the transaction.
3938
3810
  *
3811
+ * @privateRemarks
3812
+ * TODO: Investigate support for missing contract IDs
3813
+ * TODO: Add support for missing output messages
3939
3814
  *
3940
3815
  * @param transactionRequest - The transaction request object.
3941
3816
  * @returns A promise.
@@ -3948,19 +3823,16 @@ var _Provider = class {
3948
3823
  missingContractIds: []
3949
3824
  };
3950
3825
  }
3826
+ await this.estimatePredicates(transactionRequest);
3951
3827
  let receipts = [];
3952
3828
  const missingContractIds = [];
3953
3829
  let outputVariables = 0;
3954
- let dryrunStatus;
3955
3830
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3956
- const {
3957
- dryRun: [{ receipts: rawReceipts, status }]
3958
- } = await this.operations.dryRun({
3959
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3831
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3832
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3960
3833
  utxoValidation: false
3961
3834
  });
3962
- receipts = rawReceipts.map(processGqlReceipt);
3963
- dryrunStatus = status;
3835
+ receipts = gqlReceipts.map(processGqlReceipt);
3964
3836
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3965
3837
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3966
3838
  if (hasMissingOutputs) {
@@ -3970,11 +3842,6 @@ var _Provider = class {
3970
3842
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3971
3843
  missingContractIds.push(contractId);
3972
3844
  });
3973
- const { maxFee } = await this.estimateTxGasAndFee({
3974
- transactionRequest,
3975
- optimizeGas: false
3976
- });
3977
- transactionRequest.maxFee = maxFee;
3978
3845
  } else {
3979
3846
  break;
3980
3847
  }
@@ -3982,133 +3849,37 @@ var _Provider = class {
3982
3849
  return {
3983
3850
  receipts,
3984
3851
  outputVariables,
3985
- missingContractIds,
3986
- dryrunStatus
3852
+ missingContractIds
3987
3853
  };
3988
3854
  }
3989
3855
  /**
3990
- * Dry runs multiple transactions and checks for missing dependencies in batches.
3991
- *
3992
- * Transactions are dry run in batches. After each dry run, transactions requiring
3993
- * further modifications are identified. The method iteratively updates these transactions
3994
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
3995
- *
3996
- * @param transactionRequests - Array of transaction request objects.
3997
- * @returns A promise that resolves to an array of results for each transaction.
3856
+ * Estimates the transaction gas and fee based on the provided transaction request.
3857
+ * @param transactionRequest - The transaction request object.
3858
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3998
3859
  */
3999
- async estimateMultipleTxDependencies(transactionRequests) {
4000
- const results = transactionRequests.map(() => ({
4001
- receipts: [],
4002
- outputVariables: 0,
4003
- missingContractIds: [],
4004
- dryrunStatus: void 0
4005
- }));
4006
- const allRequests = clone3(transactionRequests);
4007
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4008
- allRequests.forEach((req, index) => {
4009
- if (req.type === TransactionType8.Script) {
4010
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4011
- }
4012
- });
4013
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4014
- let attempt = 0;
4015
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4016
- const encodedTransactions = transactionsToProcess.map(
4017
- (index) => serializedTransactionsMap.get(index)
4018
- );
4019
- const dryRunResults = await this.operations.dryRun({
4020
- encodedTransactions,
4021
- utxoValidation: false
4022
- });
4023
- const nextRoundTransactions = [];
4024
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4025
- const currentResultIndex = transactionsToProcess[i];
4026
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4027
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4028
- results[currentResultIndex].dryrunStatus = status;
4029
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4030
- results[currentResultIndex].receipts
4031
- );
4032
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4033
- const requestToProcess = allRequests[currentResultIndex];
4034
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4035
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4036
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4037
- missingOutputContractIds.forEach(({ contractId }) => {
4038
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4039
- results[currentResultIndex].missingContractIds.push(contractId);
4040
- });
4041
- const { maxFee } = await this.estimateTxGasAndFee({
4042
- transactionRequest: requestToProcess,
4043
- optimizeGas: false
4044
- });
4045
- requestToProcess.maxFee = maxFee;
4046
- serializedTransactionsMap.set(
4047
- currentResultIndex,
4048
- hexlify12(requestToProcess.toTransactionBytes())
4049
- );
4050
- nextRoundTransactions.push(currentResultIndex);
4051
- allRequests[currentResultIndex] = requestToProcess;
4052
- }
4053
- }
4054
- transactionsToProcess = nextRoundTransactions;
4055
- attempt += 1;
4056
- }
4057
- return results;
4058
- }
4059
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4060
- if (estimateTxDependencies) {
4061
- return this.estimateMultipleTxDependencies(transactionRequests);
4062
- }
4063
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4064
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4065
- encodedTransactions,
4066
- utxoValidation: utxoValidation || false
4067
- });
4068
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4069
- const receipts = rawReceipts.map(processGqlReceipt);
4070
- return { receipts, dryrunStatus: status };
4071
- });
4072
- return results;
4073
- }
4074
- async estimateTxGasAndFee(params) {
4075
- const { transactionRequest, optimizeGas = true } = params;
4076
- let { gasPrice } = params;
3860
+ estimateTxGasAndFee(params) {
3861
+ const { transactionRequest } = params;
3862
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4077
3863
  const chainInfo = this.getChain();
4078
- const { gasPriceFactor } = this.getGasConfig();
3864
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3865
+ transactionRequest.gasPrice = gasPrice;
4079
3866
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4080
- if (!gasPrice) {
4081
- gasPrice = await this.estimateGasPrice(10);
4082
- }
4083
- const minFee = calculateGasFee({
4084
- gasPrice: bn16(gasPrice),
4085
- gas: minGas,
4086
- priceFactor: gasPriceFactor,
4087
- tip: transactionRequest.tip
4088
- }).add(1);
4089
- let gasLimit = bn16(0);
3867
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4090
3868
  if (transactionRequest.type === TransactionType8.Script) {
4091
- gasLimit = transactionRequest.gasLimit;
4092
- if (!optimizeGas) {
3869
+ if (transactionRequest.gasLimit.eq(0)) {
4093
3870
  transactionRequest.gasLimit = minGas;
4094
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4095
- transactionRequest.gasLimit = gasLimit;
3871
+ transactionRequest.gasLimit = maxGasPerTx.sub(
3872
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
3873
+ );
4096
3874
  }
4097
3875
  }
4098
3876
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4099
- const maxFee = calculateGasFee({
4100
- gasPrice: bn16(gasPrice),
4101
- gas: maxGas,
4102
- priceFactor: gasPriceFactor,
4103
- tip: transactionRequest.tip
4104
- }).add(1);
3877
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4105
3878
  return {
4106
3879
  minGas,
4107
3880
  minFee,
4108
3881
  maxGas,
4109
- maxFee,
4110
- gasPrice,
4111
- gasLimit
3882
+ maxFee
4112
3883
  };
4113
3884
  }
4114
3885
  /**
@@ -4126,17 +3897,15 @@ var _Provider = class {
4126
3897
  if (estimateTxDependencies) {
4127
3898
  return this.estimateTxDependencies(transactionRequest);
4128
3899
  }
4129
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4130
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4131
- encodedTransactions,
3900
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3901
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3902
+ encodedTransaction,
4132
3903
  utxoValidation: true
4133
3904
  });
4134
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4135
- const { id, receipts, status } = dryRunStatus;
4136
- const processedReceipts = receipts.map(processGqlReceipt);
4137
- return { id, receipts: processedReceipts, status };
4138
- });
4139
- return { receipts: callResult[0].receipts };
3905
+ const receipts = gqlReceipts.map(processGqlReceipt);
3906
+ return {
3907
+ receipts
3908
+ };
4140
3909
  }
4141
3910
  /**
4142
3911
  * Returns a transaction cost to enable user
@@ -4153,80 +3922,77 @@ var _Provider = class {
4153
3922
  * @param tolerance - The tolerance to add on top of the gasUsed.
4154
3923
  * @returns A promise that resolves to the transaction cost object.
4155
3924
  */
4156
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3925
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3926
+ estimateTxDependencies = true,
3927
+ estimatePredicates = true,
3928
+ resourcesOwner,
3929
+ signatureCallback
3930
+ } = {}) {
4157
3931
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3932
+ const { minGasPrice } = this.getGasConfig();
3933
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4158
3934
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4159
3935
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4160
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3936
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4161
3937
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4162
- txRequestClone.maxFee = bn16(0);
4163
3938
  if (isScriptTransaction) {
4164
- txRequestClone.gasLimit = bn16(0);
3939
+ txRequestClone.gasLimit = bn15(0);
4165
3940
  }
4166
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4167
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3941
+ if (estimatePredicates) {
3942
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3943
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3944
+ }
3945
+ await this.estimatePredicates(txRequestClone);
4168
3946
  }
4169
- const signedRequest = clone3(txRequestClone);
4170
- let addedSignatures = 0;
4171
3947
  if (signatureCallback && isScriptTransaction) {
4172
- const lengthBefore = signedRequest.witnesses.length;
4173
- await signatureCallback(signedRequest);
4174
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4175
- }
4176
- await this.estimatePredicates(signedRequest);
4177
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4178
- transactionRequest: signedRequest,
4179
- optimizeGas: false
3948
+ await signatureCallback(txRequestClone);
3949
+ }
3950
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3951
+ transactionRequest: txRequestClone
4180
3952
  });
4181
- txRequestClone.maxFee = maxFee;
4182
3953
  let receipts = [];
4183
3954
  let missingContractIds = [];
4184
3955
  let outputVariables = 0;
4185
- let gasUsed = bn16(0);
4186
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4187
- if (isScriptTransaction) {
4188
- if (signatureCallback) {
4189
- await signatureCallback(txRequestClone);
4190
- }
4191
- txRequestClone.gasLimit = gasLimit;
3956
+ let gasUsed = bn15(0);
3957
+ if (isScriptTransaction && estimateTxDependencies) {
3958
+ txRequestClone.gasPrice = bn15(0);
4192
3959
  const result = await this.estimateTxDependencies(txRequestClone);
4193
3960
  receipts = result.receipts;
4194
3961
  outputVariables = result.outputVariables;
4195
3962
  missingContractIds = result.missingContractIds;
4196
- gasUsed = getGasUsedFromReceipts(receipts);
3963
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4197
3964
  txRequestClone.gasLimit = gasUsed;
4198
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4199
- transactionRequest: txRequestClone,
4200
- gasPrice
3965
+ txRequestClone.gasPrice = setGasPrice;
3966
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3967
+ transactionRequest: txRequestClone
4201
3968
  }));
4202
3969
  }
4203
3970
  return {
4204
3971
  requiredQuantities: allQuantities,
4205
3972
  receipts,
4206
3973
  gasUsed,
4207
- gasPrice,
3974
+ minGasPrice,
3975
+ gasPrice: setGasPrice,
4208
3976
  minGas,
4209
3977
  maxGas,
4210
3978
  minFee,
4211
3979
  maxFee,
3980
+ estimatedInputs: txRequestClone.inputs,
4212
3981
  outputVariables,
4213
- missingContractIds,
4214
- addedSignatures,
4215
- estimatedPredicates: txRequestClone.inputs
3982
+ missingContractIds
4216
3983
  };
4217
3984
  }
4218
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
3985
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4219
3986
  const ownerAddress = Address2.fromAddressOrString(owner);
4220
3987
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4221
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4222
- quantitiesToContract
4223
- });
3988
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4224
3989
  transactionRequest.addResources(
4225
3990
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4226
3991
  );
4227
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4228
- quantitiesToContract
4229
- });
3992
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
3993
+ transactionRequest,
3994
+ forwardingQuantities
3995
+ );
4230
3996
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4231
3997
  return {
4232
3998
  resources,
@@ -4248,10 +4014,11 @@ var _Provider = class {
4248
4014
  return coins.map((coin) => ({
4249
4015
  id: coin.utxoId,
4250
4016
  assetId: coin.assetId,
4251
- amount: bn16(coin.amount),
4017
+ amount: bn15(coin.amount),
4252
4018
  owner: Address2.fromAddressOrString(coin.owner),
4253
- blockCreated: bn16(coin.blockCreated),
4254
- txCreatedIdx: bn16(coin.txCreatedIdx)
4019
+ maturity: bn15(coin.maturity).toNumber(),
4020
+ blockCreated: bn15(coin.blockCreated),
4021
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4255
4022
  }));
4256
4023
  }
4257
4024
  /**
@@ -4288,9 +4055,9 @@ var _Provider = class {
4288
4055
  switch (coin.__typename) {
4289
4056
  case "MessageCoin":
4290
4057
  return {
4291
- amount: bn16(coin.amount),
4058
+ amount: bn15(coin.amount),
4292
4059
  assetId: coin.assetId,
4293
- daHeight: bn16(coin.daHeight),
4060
+ daHeight: bn15(coin.daHeight),
4294
4061
  sender: Address2.fromAddressOrString(coin.sender),
4295
4062
  recipient: Address2.fromAddressOrString(coin.recipient),
4296
4063
  nonce: coin.nonce
@@ -4298,11 +4065,12 @@ var _Provider = class {
4298
4065
  case "Coin":
4299
4066
  return {
4300
4067
  id: coin.utxoId,
4301
- amount: bn16(coin.amount),
4068
+ amount: bn15(coin.amount),
4302
4069
  assetId: coin.assetId,
4303
4070
  owner: Address2.fromAddressOrString(coin.owner),
4304
- blockCreated: bn16(coin.blockCreated),
4305
- txCreatedIdx: bn16(coin.txCreatedIdx)
4071
+ maturity: bn15(coin.maturity).toNumber(),
4072
+ blockCreated: bn15(coin.blockCreated),
4073
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4306
4074
  };
4307
4075
  default:
4308
4076
  return null;
@@ -4319,13 +4087,13 @@ var _Provider = class {
4319
4087
  async getBlock(idOrHeight) {
4320
4088
  let variables;
4321
4089
  if (typeof idOrHeight === "number") {
4322
- variables = { height: bn16(idOrHeight).toString(10) };
4090
+ variables = { height: bn15(idOrHeight).toString(10) };
4323
4091
  } else if (idOrHeight === "latest") {
4324
4092
  variables = { height: (await this.getBlockNumber()).toString(10) };
4325
4093
  } else if (idOrHeight.length === 66) {
4326
4094
  variables = { blockId: idOrHeight };
4327
4095
  } else {
4328
- variables = { blockId: bn16(idOrHeight).toString(10) };
4096
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4329
4097
  }
4330
4098
  const { block } = await this.operations.getBlock(variables);
4331
4099
  if (!block) {
@@ -4333,7 +4101,7 @@ var _Provider = class {
4333
4101
  }
4334
4102
  return {
4335
4103
  id: block.id,
4336
- height: bn16(block.height),
4104
+ height: bn15(block.header.height),
4337
4105
  time: block.header.time,
4338
4106
  transactionIds: block.transactions.map((tx) => tx.id)
4339
4107
  };
@@ -4348,7 +4116,7 @@ var _Provider = class {
4348
4116
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4349
4117
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4350
4118
  id: block.id,
4351
- height: bn16(block.height),
4119
+ height: bn15(block.header.height),
4352
4120
  time: block.header.time,
4353
4121
  transactionIds: block.transactions.map((tx) => tx.id)
4354
4122
  }));
@@ -4363,7 +4131,7 @@ var _Provider = class {
4363
4131
  async getBlockWithTransactions(idOrHeight) {
4364
4132
  let variables;
4365
4133
  if (typeof idOrHeight === "number") {
4366
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4134
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4367
4135
  } else if (idOrHeight === "latest") {
4368
4136
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4369
4137
  } else {
@@ -4375,7 +4143,7 @@ var _Provider = class {
4375
4143
  }
4376
4144
  return {
4377
4145
  id: block.id,
4378
- height: bn16(block.height, 10),
4146
+ height: bn15(block.header.height, 10),
4379
4147
  time: block.header.time,
4380
4148
  transactionIds: block.transactions.map((tx) => tx.id),
4381
4149
  transactions: block.transactions.map(
@@ -4424,7 +4192,7 @@ var _Provider = class {
4424
4192
  contract: Address2.fromAddressOrString(contractId).toB256(),
4425
4193
  asset: hexlify12(assetId)
4426
4194
  });
4427
- return bn16(contractBalance.amount, 10);
4195
+ return bn15(contractBalance.amount, 10);
4428
4196
  }
4429
4197
  /**
4430
4198
  * Returns the balance for the given owner for the given asset ID.
@@ -4438,7 +4206,7 @@ var _Provider = class {
4438
4206
  owner: Address2.fromAddressOrString(owner).toB256(),
4439
4207
  assetId: hexlify12(assetId)
4440
4208
  });
4441
- return bn16(balance.amount, 10);
4209
+ return bn15(balance.amount, 10);
4442
4210
  }
4443
4211
  /**
4444
4212
  * Returns balances for the given owner.
@@ -4456,7 +4224,7 @@ var _Provider = class {
4456
4224
  const balances = result.balances.edges.map((edge) => edge.node);
4457
4225
  return balances.map((balance) => ({
4458
4226
  assetId: balance.assetId,
4459
- amount: bn16(balance.amount)
4227
+ amount: bn15(balance.amount)
4460
4228
  }));
4461
4229
  }
4462
4230
  /**
@@ -4478,15 +4246,15 @@ var _Provider = class {
4478
4246
  sender: message.sender,
4479
4247
  recipient: message.recipient,
4480
4248
  nonce: message.nonce,
4481
- amount: bn16(message.amount),
4249
+ amount: bn15(message.amount),
4482
4250
  data: message.data
4483
4251
  }),
4484
4252
  sender: Address2.fromAddressOrString(message.sender),
4485
4253
  recipient: Address2.fromAddressOrString(message.recipient),
4486
4254
  nonce: message.nonce,
4487
- amount: bn16(message.amount),
4255
+ amount: bn15(message.amount),
4488
4256
  data: InputMessageCoder.decodeData(message.data),
4489
- daHeight: bn16(message.daHeight)
4257
+ daHeight: bn15(message.daHeight)
4490
4258
  }));
4491
4259
  }
4492
4260
  /**
@@ -4539,60 +4307,44 @@ var _Provider = class {
4539
4307
  } = result.messageProof;
4540
4308
  return {
4541
4309
  messageProof: {
4542
- proofIndex: bn16(messageProof.proofIndex),
4310
+ proofIndex: bn15(messageProof.proofIndex),
4543
4311
  proofSet: messageProof.proofSet
4544
4312
  },
4545
4313
  blockProof: {
4546
- proofIndex: bn16(blockProof.proofIndex),
4314
+ proofIndex: bn15(blockProof.proofIndex),
4547
4315
  proofSet: blockProof.proofSet
4548
4316
  },
4549
4317
  messageBlockHeader: {
4550
4318
  id: messageBlockHeader.id,
4551
- daHeight: bn16(messageBlockHeader.daHeight),
4552
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4319
+ daHeight: bn15(messageBlockHeader.daHeight),
4320
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4553
4321
  transactionsRoot: messageBlockHeader.transactionsRoot,
4554
- height: bn16(messageBlockHeader.height),
4322
+ height: bn15(messageBlockHeader.height),
4555
4323
  prevRoot: messageBlockHeader.prevRoot,
4556
4324
  time: messageBlockHeader.time,
4557
4325
  applicationHash: messageBlockHeader.applicationHash,
4558
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4559
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4560
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4561
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4562
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4326
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4327
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4563
4328
  },
4564
4329
  commitBlockHeader: {
4565
4330
  id: commitBlockHeader.id,
4566
- daHeight: bn16(commitBlockHeader.daHeight),
4567
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4331
+ daHeight: bn15(commitBlockHeader.daHeight),
4332
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4568
4333
  transactionsRoot: commitBlockHeader.transactionsRoot,
4569
- height: bn16(commitBlockHeader.height),
4334
+ height: bn15(commitBlockHeader.height),
4570
4335
  prevRoot: commitBlockHeader.prevRoot,
4571
4336
  time: commitBlockHeader.time,
4572
4337
  applicationHash: commitBlockHeader.applicationHash,
4573
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4574
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4575
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4576
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4577
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4338
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4339
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4578
4340
  },
4579
4341
  sender: Address2.fromAddressOrString(sender),
4580
4342
  recipient: Address2.fromAddressOrString(recipient),
4581
4343
  nonce,
4582
- amount: bn16(amount),
4344
+ amount: bn15(amount),
4583
4345
  data
4584
4346
  };
4585
4347
  }
4586
- async getLatestGasPrice() {
4587
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4588
- return bn16(latestGasPrice.gasPrice);
4589
- }
4590
- async estimateGasPrice(blockHorizon) {
4591
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4592
- blockHorizon: String(blockHorizon)
4593
- });
4594
- return bn16(estimateGasPrice.gasPrice);
4595
- }
4596
4348
  /**
4597
4349
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4598
4350
  *
@@ -4612,10 +4364,10 @@ var _Provider = class {
4612
4364
  */
4613
4365
  async produceBlocks(amount, startTime) {
4614
4366
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4615
- blocksToProduce: bn16(amount).toString(10),
4367
+ blocksToProduce: bn15(amount).toString(10),
4616
4368
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4617
4369
  });
4618
- return bn16(latestBlockHeight);
4370
+ return bn15(latestBlockHeight);
4619
4371
  }
4620
4372
  // eslint-disable-next-line @typescript-eslint/require-await
4621
4373
  async getTransactionResponse(transactionId) {
@@ -4629,7 +4381,7 @@ cacheInputs_fn = function(inputs) {
4629
4381
  return;
4630
4382
  }
4631
4383
  inputs.forEach((input) => {
4632
- if (input.type === InputType7.Coin) {
4384
+ if (input.type === InputType6.Coin) {
4633
4385
  this.cache?.set(input.id);
4634
4386
  }
4635
4387
  });
@@ -4639,7 +4391,7 @@ __publicField(Provider, "nodeInfoCache", {});
4639
4391
 
4640
4392
  // src/providers/transaction-summary/get-transaction-summary.ts
4641
4393
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4642
- import { bn as bn17 } from "@fuel-ts/math";
4394
+ import { bn as bn16 } from "@fuel-ts/math";
4643
4395
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4644
4396
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4645
4397
 
@@ -4885,33 +4637,36 @@ var Account = class extends AbstractAccount {
4885
4637
  * @param fee - The estimated transaction fee.
4886
4638
  * @returns A promise that resolves when the resources are added to the transaction.
4887
4639
  */
4888
- async fund(request, params) {
4889
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4890
- const txRequest = request;
4891
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4892
- amount: bn18(fee),
4640
+ async fund(request, coinQuantities, fee) {
4641
+ const updatedQuantities = addAmountToAsset({
4642
+ amount: bn17(fee),
4893
4643
  assetId: BaseAssetId3,
4894
- coinQuantities: requiredQuantities
4644
+ coinQuantities
4895
4645
  });
4896
4646
  const quantitiesDict = {};
4897
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4647
+ updatedQuantities.forEach(({ amount, assetId }) => {
4898
4648
  quantitiesDict[assetId] = {
4899
4649
  required: amount,
4900
- owned: bn18(0)
4650
+ owned: bn17(0)
4901
4651
  };
4902
4652
  });
4903
- txRequest.inputs.forEach((input) => {
4653
+ const cachedUtxos = [];
4654
+ const cachedMessages = [];
4655
+ const owner = this.address.toB256();
4656
+ request.inputs.forEach((input) => {
4904
4657
  const isResource = "amount" in input;
4905
4658
  if (isResource) {
4906
4659
  const isCoin2 = "owner" in input;
4907
4660
  if (isCoin2) {
4908
4661
  const assetId = String(input.assetId);
4909
- if (quantitiesDict[assetId]) {
4910
- const amount = bn18(input.amount);
4662
+ if (input.owner === owner && quantitiesDict[assetId]) {
4663
+ const amount = bn17(input.amount);
4911
4664
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4665
+ cachedUtxos.push(input.id);
4912
4666
  }
4913
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4667
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4914
4668
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4669
+ cachedMessages.push(input.nonce);
4915
4670
  }
4916
4671
  }
4917
4672
  });
@@ -4926,23 +4681,12 @@ var Account = class extends AbstractAccount {
4926
4681
  });
4927
4682
  const needsToBeFunded = missingQuantities.length;
4928
4683
  if (needsToBeFunded) {
4929
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4930
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4931
- txRequest.addResources(resources);
4932
- }
4933
- txRequest.shiftPredicateData();
4934
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4935
- const requestToBeReEstimate = clone4(txRequest);
4936
- if (addedSignatures) {
4937
- Array.from({ length: addedSignatures }).forEach(
4938
- () => requestToBeReEstimate.addEmptyWitness()
4939
- );
4684
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4685
+ messages: cachedMessages,
4686
+ utxos: cachedUtxos
4687
+ });
4688
+ request.addResources(resources);
4940
4689
  }
4941
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4942
- transactionRequest: requestToBeReEstimate
4943
- });
4944
- txRequest.maxFee = maxFee;
4945
- return txRequest;
4946
4690
  }
4947
4691
  /**
4948
4692
  * A helper that creates a transfer transaction request and returns it.
@@ -4950,25 +4694,28 @@ var Account = class extends AbstractAccount {
4950
4694
  * @param destination - The address of the destination.
4951
4695
  * @param amount - The amount of coins to transfer.
4952
4696
  * @param assetId - The asset ID of the coins to transfer.
4953
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4697
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4954
4698
  * @returns A promise that resolves to the prepared transaction request.
4955
4699
  */
4956
4700
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4957
- const request = new ScriptTransactionRequest(txParams);
4701
+ const { minGasPrice } = this.provider.getGasConfig();
4702
+ const params = { gasPrice: minGasPrice, ...txParams };
4703
+ const request = new ScriptTransactionRequest(params);
4958
4704
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4959
- const txCost = await this.provider.getTransactionCost(request, {
4705
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4960
4706
  estimateTxDependencies: true,
4961
4707
  resourcesOwner: this
4962
4708
  });
4963
- if ("gasLimit" in txParams) {
4964
- this.validateGas({
4965
- gasUsed: txCost.gasUsed,
4966
- gasLimit: request.gasLimit
4967
- });
4968
- }
4969
- request.gasLimit = txCost.gasUsed;
4970
- request.maxFee = txCost.maxFee;
4971
- await this.fund(request, txCost);
4709
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4710
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4711
+ this.validateGas({
4712
+ gasUsed,
4713
+ gasPrice: request.gasPrice,
4714
+ gasLimit: request.gasLimit,
4715
+ minGasPrice
4716
+ });
4717
+ await this.fund(request, requiredQuantities, maxFee);
4718
+ request.updatePredicateInputs(estimatedInputs);
4972
4719
  return request;
4973
4720
  }
4974
4721
  /**
@@ -4981,7 +4728,7 @@ var Account = class extends AbstractAccount {
4981
4728
  * @returns A promise that resolves to the transaction response.
4982
4729
  */
4983
4730
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4984
- if (bn18(amount).lte(0)) {
4731
+ if (bn17(amount).lte(0)) {
4985
4732
  throw new FuelError15(
4986
4733
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4987
4734
  "Transfer amount must be a positive number."
@@ -5000,37 +4747,38 @@ var Account = class extends AbstractAccount {
5000
4747
  * @returns A promise that resolves to the transaction response.
5001
4748
  */
5002
4749
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5003
- if (bn18(amount).lte(0)) {
4750
+ if (bn17(amount).lte(0)) {
5004
4751
  throw new FuelError15(
5005
4752
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5006
4753
  "Transfer amount must be a positive number."
5007
4754
  );
5008
4755
  }
5009
4756
  const contractAddress = Address3.fromAddressOrString(contractId);
4757
+ const { minGasPrice } = this.provider.getGasConfig();
4758
+ const params = { gasPrice: minGasPrice, ...txParams };
5010
4759
  const { script, scriptData } = await assembleTransferToContractScript({
5011
4760
  hexlifiedContractId: contractAddress.toB256(),
5012
- amountToTransfer: bn18(amount),
4761
+ amountToTransfer: bn17(amount),
5013
4762
  assetId
5014
4763
  });
5015
4764
  const request = new ScriptTransactionRequest({
5016
- ...txParams,
4765
+ ...params,
5017
4766
  script,
5018
4767
  scriptData
5019
4768
  });
5020
4769
  request.addContractInputAndOutput(contractAddress);
5021
- const txCost = await this.provider.getTransactionCost(request, {
5022
- resourcesOwner: this,
5023
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
4770
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4771
+ request,
4772
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4773
+ );
4774
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4775
+ this.validateGas({
4776
+ gasUsed,
4777
+ gasPrice: request.gasPrice,
4778
+ gasLimit: request.gasLimit,
4779
+ minGasPrice
5024
4780
  });
5025
- if (txParams.gasLimit) {
5026
- this.validateGas({
5027
- gasUsed: txCost.gasUsed,
5028
- gasLimit: request.gasLimit
5029
- });
5030
- }
5031
- request.gasLimit = txCost.gasUsed;
5032
- request.maxFee = txCost.maxFee;
5033
- await this.fund(request, txCost);
4781
+ await this.fund(request, requiredQuantities, maxFee);
5034
4782
  return this.sendTransaction(request);
5035
4783
  }
5036
4784
  /**
@@ -5042,31 +4790,34 @@ var Account = class extends AbstractAccount {
5042
4790
  * @returns A promise that resolves to the transaction response.
5043
4791
  */
5044
4792
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4793
+ const { minGasPrice } = this.provider.getGasConfig();
5045
4794
  const recipientAddress = Address3.fromAddressOrString(recipient);
5046
4795
  const recipientDataArray = arrayify14(
5047
4796
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5048
4797
  );
5049
4798
  const amountDataArray = arrayify14(
5050
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
4799
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5051
4800
  );
5052
4801
  const script = new Uint8Array([
5053
4802
  ...arrayify14(withdrawScript.bytes),
5054
4803
  ...recipientDataArray,
5055
4804
  ...amountDataArray
5056
4805
  ]);
5057
- const params = { script, ...txParams };
4806
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5058
4807
  const request = new ScriptTransactionRequest(params);
5059
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5060
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5061
- if (txParams.gasLimit) {
5062
- this.validateGas({
5063
- gasUsed: txCost.gasUsed,
5064
- gasLimit: request.gasLimit
5065
- });
5066
- }
5067
- request.maxFee = txCost.maxFee;
5068
- request.gasLimit = txCost.gasUsed;
5069
- await this.fund(request, txCost);
4808
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4809
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4810
+ request,
4811
+ forwardingQuantities
4812
+ );
4813
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4814
+ this.validateGas({
4815
+ gasUsed,
4816
+ gasPrice: request.gasPrice,
4817
+ gasLimit: request.gasLimit,
4818
+ minGasPrice
4819
+ });
4820
+ await this.fund(request, requiredQuantities, maxFee);
5070
4821
  return this.sendTransaction(request);
5071
4822
  }
5072
4823
  async signMessage(message) {
@@ -5124,7 +4875,18 @@ var Account = class extends AbstractAccount {
5124
4875
  }
5125
4876
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5126
4877
  }
5127
- validateGas({ gasUsed, gasLimit }) {
4878
+ validateGas({
4879
+ gasUsed,
4880
+ gasPrice,
4881
+ gasLimit,
4882
+ minGasPrice
4883
+ }) {
4884
+ if (minGasPrice.gt(gasPrice)) {
4885
+ throw new FuelError15(
4886
+ ErrorCode15.GAS_PRICE_TOO_LOW,
4887
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4888
+ );
4889
+ }
5128
4890
  if (gasUsed.gt(gasLimit)) {
5129
4891
  throw new FuelError15(
5130
4892
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5416,7 +5178,7 @@ var BaseWalletUnlocked = class extends Account {
5416
5178
  * @param transactionRequestLike - The transaction request to send.
5417
5179
  * @returns A promise that resolves to the TransactionResponse object.
5418
5180
  */
5419
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5181
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5420
5182
  const transactionRequest = transactionRequestify(transactionRequestLike);
5421
5183
  if (estimateTxDependencies) {
5422
5184
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5457,7 +5219,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5457
5219
  // src/hdwallet/hdwallet.ts
5458
5220
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5459
5221
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5460
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5222
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5461
5223
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5462
5224
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5463
5225
 
@@ -7923,7 +7685,7 @@ var HDWallet = class {
7923
7685
  const IR = bytes.slice(32);
7924
7686
  if (privateKey) {
7925
7687
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7926
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
7688
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7927
7689
  return new HDWallet({
7928
7690
  privateKey: ki,
7929
7691
  chainCode: IR,
@@ -8194,15 +7956,14 @@ var seedTestWallet = async (wallet, quantities) => {
8194
7956
  process.env.GENESIS_SECRET || randomBytes5(32),
8195
7957
  wallet.provider
8196
7958
  );
8197
- const request = new ScriptTransactionRequest();
8198
- quantities.forEach((quantity) => {
8199
- const { amount, assetId } = coinQuantityfy(quantity);
8200
- request.addCoinOutput(wallet.address, amount, assetId);
7959
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
7960
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
7961
+ const request = new ScriptTransactionRequest({
7962
+ gasLimit: 1e4,
7963
+ gasPrice: minGasPrice
8201
7964
  });
8202
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8203
- request.gasLimit = txCost.gasUsed;
8204
- request.maxFee = txCost.maxFee;
8205
- await genesisWallet.fund(request, txCost);
7965
+ request.addResources(resources);
7966
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8206
7967
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8207
7968
  };
8208
7969
 
@@ -8217,11 +7978,11 @@ var generateTestWallet = async (provider, quantities) => {
8217
7978
 
8218
7979
  // src/test-utils/launchNode.ts
8219
7980
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8220
- import { defaultChainConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
7981
+ import { toHex as toHex2 } from "@fuel-ts/math";
7982
+ import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8221
7983
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
8222
7984
  import { spawn } from "child_process";
8223
7985
  import { randomUUID } from "crypto";
8224
- import { randomBytes as randomBytes6 } from "ethers";
8225
7986
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
8226
7987
  import os from "os";
8227
7988
  import path from "path";
@@ -8270,12 +8031,12 @@ var launchNode = async ({
8270
8031
  // eslint-disable-next-line no-async-promise-executor
8271
8032
  new Promise(async (resolve, reject) => {
8272
8033
  const remainingArgs = extractRemainingArgs(args, [
8273
- "--snapshot",
8034
+ "--chain",
8274
8035
  "--consensus-key",
8275
8036
  "--db-type",
8276
8037
  "--poa-instant"
8277
8038
  ]);
8278
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8039
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8279
8040
  const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
8280
8041
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8281
8042
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
@@ -8294,54 +8055,36 @@ var launchNode = async ({
8294
8055
  let chainConfigPathToUse;
8295
8056
  const prefix = basePath || os.tmpdir();
8296
8057
  const suffix = basePath ? "" : randomUUID();
8297
- const tempDirPath = path.join(prefix, ".fuels", suffix, "chainConfigs");
8058
+ const tempDirPath = path.join(prefix, ".fuels", suffix);
8298
8059
  if (chainConfigPath) {
8299
8060
  chainConfigPathToUse = chainConfigPath;
8300
8061
  } else {
8301
8062
  if (!existsSync(tempDirPath)) {
8302
8063
  mkdirSync(tempDirPath, { recursive: true });
8303
8064
  }
8304
- let { stateConfigJson } = defaultChainConfigs;
8305
- const { chainConfigJson, metadataJson } = defaultChainConfigs;
8306
- stateConfigJson = {
8307
- ...stateConfigJson,
8308
- coins: [
8309
- ...stateConfigJson.coins.map((coin) => ({
8310
- ...coin,
8311
- amount: "18446744073709551615"
8312
- }))
8313
- ],
8314
- messages: stateConfigJson.messages.map((message) => ({
8315
- ...message,
8316
- amount: "18446744073709551615"
8317
- }))
8318
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8319
- };
8065
+ const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
8066
+ let chainConfig = defaultChainConfig;
8320
8067
  if (!process.env.GENESIS_SECRET) {
8321
8068
  const pk = Signer.generatePrivateKey();
8322
8069
  const signer = new Signer(pk);
8323
8070
  process.env.GENESIS_SECRET = hexlify18(pk);
8324
- stateConfigJson.coins.push({
8325
- tx_id: hexlify18(randomBytes6(34)),
8326
- owner: signer.address.toHexString(),
8327
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8328
- amount: "18446744073709551615",
8329
- asset_id: BaseAssetId4,
8330
- output_index: 0,
8331
- tx_pointer_block_height: 0,
8332
- tx_pointer_tx_idx: 0
8333
- });
8071
+ chainConfig = {
8072
+ ...defaultChainConfig,
8073
+ initial_state: {
8074
+ ...defaultChainConfig.initial_state,
8075
+ coins: [
8076
+ ...defaultChainConfig.initial_state.coins,
8077
+ {
8078
+ owner: signer.address.toHexString(),
8079
+ amount: toHex2(1e9),
8080
+ asset_id: BaseAssetId4
8081
+ }
8082
+ ]
8083
+ }
8084
+ };
8334
8085
  }
8335
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8336
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8337
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8338
- const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8339
- const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8340
- const metadataWritePath = path.join(tempDirPath, "metadata.json");
8341
- writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8342
- writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8343
- writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8344
- chainConfigPathToUse = tempDirPath;
8086
+ writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8087
+ chainConfigPathToUse = tempChainConfigFilePath;
8345
8088
  }
8346
8089
  const child = spawn(
8347
8090
  command,
@@ -8350,10 +8093,10 @@ var launchNode = async ({
8350
8093
  ["--ip", ipToUse],
8351
8094
  ["--port", portToUse],
8352
8095
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8353
- ["--min-gas-price", "1"],
8096
+ ["--min-gas-price", "0"],
8354
8097
  poaInstant ? ["--poa-instant", "true"] : [],
8355
8098
  ["--consensus-key", consensusKey],
8356
- ["--snapshot", chainConfigPathToUse],
8099
+ ["--chain", chainConfigPathToUse],
8357
8100
  "--vm-backtrace",
8358
8101
  "--utxo-validation",
8359
8102
  "--debug",
@@ -8412,7 +8155,7 @@ var launchNodeAndGetWallets = async ({
8412
8155
  walletCount = 10
8413
8156
  } = {}) => {
8414
8157
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8415
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8158
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8416
8159
  const wallets = await generateWallets(walletCount, provider);
8417
8160
  const cleanup = () => {
8418
8161
  closeNode();