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

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

Potentially problematic release.


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

Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +574 -841
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +574 -823
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +409 -657
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +329 -911
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -7
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +30 -37
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +25 -8
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1073 -1557
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +567 -798
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +418 -649
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
@@ -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;
@@ -1914,10 +1828,10 @@ var BaseTransactionRequest = class {
1914
1828
  * @param predicate - Predicate bytes.
1915
1829
  * @param predicateData - Predicate data bytes.
1916
1830
  */
1917
- addCoinInput(coin) {
1831
+ addCoinInput(coin, predicate) {
1918
1832
  const { assetId, owner, amount } = 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);
@@ -1932,7 +1846,8 @@ var BaseTransactionRequest = class {
1932
1846
  amount,
1933
1847
  assetId,
1934
1848
  txPointer: "0x00000000000000000000000000000000",
1935
- witnessIndex
1849
+ witnessIndex,
1850
+ predicate: predicate?.bytes
1936
1851
  };
1937
1852
  this.pushInput(input);
1938
1853
  this.addChangeOutput(owner, assetId);
@@ -1945,11 +1860,11 @@ var BaseTransactionRequest = class {
1945
1860
  * @param predicate - Predicate bytes.
1946
1861
  * @param predicateData - Predicate data bytes.
1947
1862
  */
1948
- addMessageInput(message) {
1863
+ addMessageInput(message, predicate) {
1949
1864
  const { recipient, sender, amount } = 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);
@@ -1963,7 +1878,8 @@ var BaseTransactionRequest = class {
1963
1878
  sender: sender.toB256(),
1964
1879
  recipient: recipient.toB256(),
1965
1880
  amount,
1966
- witnessIndex
1881
+ witnessIndex,
1882
+ predicate: predicate?.bytes
1967
1883
  };
1968
1884
  this.pushInput(input);
1969
1885
  this.addChangeOutput(recipient, assetId);
@@ -1994,6 +1910,32 @@ var BaseTransactionRequest = class {
1994
1910
  resources.forEach((resource) => this.addResource(resource));
1995
1911
  return this;
1996
1912
  }
1913
+ /**
1914
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1915
+ * outputs from the related assetIds.
1916
+ *
1917
+ * @param resources - The resources to add.
1918
+ * @returns This transaction.
1919
+ */
1920
+ addPredicateResource(resource, predicate) {
1921
+ if (isCoin(resource)) {
1922
+ this.addCoinInput(resource, predicate);
1923
+ } else {
1924
+ this.addMessageInput(resource, predicate);
1925
+ }
1926
+ return this;
1927
+ }
1928
+ /**
1929
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
1930
+ * from the related assetIds.
1931
+ *
1932
+ * @param resources - The resources to add.
1933
+ * @returns This transaction.
1934
+ */
1935
+ addPredicateResources(resources, predicate) {
1936
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1937
+ return this;
1938
+ }
1997
1939
  /**
1998
1940
  * Adds a coin output to the transaction.
1999
1941
  *
@@ -2073,7 +2015,7 @@ var BaseTransactionRequest = class {
2073
2015
  }
2074
2016
  calculateMaxGas(chainInfo, minGas) {
2075
2017
  const { consensusParameters } = chainInfo;
2076
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2018
+ const { gasPerByte } = consensusParameters;
2077
2019
  const witnessesLength = this.toTransaction().witnesses.reduce(
2078
2020
  (acc, wit) => acc + wit.dataLength,
2079
2021
  0
@@ -2082,8 +2024,7 @@ var BaseTransactionRequest = class {
2082
2024
  gasPerByte,
2083
2025
  minGas,
2084
2026
  witnessesLength,
2085
- witnessLimit: this.witnessLimit,
2086
- maxGasPerTx
2027
+ witnessLimit: this.witnessLimit
2087
2028
  });
2088
2029
  }
2089
2030
  /**
@@ -2101,20 +2042,17 @@ var BaseTransactionRequest = class {
2101
2042
  });
2102
2043
  const updateAssetInput = (assetId, quantity) => {
2103
2044
  const assetInput = findAssetInput(assetId);
2104
- let usedQuantity = quantity;
2105
- if (assetId === BaseAssetId2) {
2106
- usedQuantity = bn7("1000000000000000000");
2107
- }
2108
2045
  if (assetInput && "assetId" in assetInput) {
2109
- assetInput.id = hexlify7(randomBytes(34));
2110
- assetInput.amount = usedQuantity;
2046
+ assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2047
+ assetInput.amount = quantity;
2111
2048
  } else {
2112
2049
  this.addResources([
2113
2050
  {
2114
- id: hexlify7(randomBytes(34)),
2115
- amount: usedQuantity,
2051
+ id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2052
+ amount: quantity,
2116
2053
  assetId,
2117
2054
  owner: resourcesOwner || Address.fromRandom(),
2055
+ maturity: 0,
2118
2056
  blockCreated: bn7(1),
2119
2057
  txCreatedIdx: bn7(1)
2120
2058
  }
@@ -2146,7 +2084,7 @@ var BaseTransactionRequest = class {
2146
2084
  toJSON() {
2147
2085
  return normalizeJSON(this);
2148
2086
  }
2149
- updatePredicateGasUsed(inputs) {
2087
+ updatePredicateInputs(inputs) {
2150
2088
  this.inputs.forEach((i) => {
2151
2089
  let correspondingInput;
2152
2090
  switch (i.type) {
@@ -2168,15 +2106,6 @@ var BaseTransactionRequest = class {
2168
2106
  }
2169
2107
  });
2170
2108
  }
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
2109
  };
2181
2110
 
2182
2111
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2323,8 +2252,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2323
2252
  return {
2324
2253
  type: TransactionType3.Create,
2325
2254
  ...baseTransaction,
2255
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2326
2256
  bytecodeWitnessIndex,
2327
- storageSlotsCount: bn9(storageSlots.length),
2257
+ storageSlotsCount: storageSlots.length,
2328
2258
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2329
2259
  storageSlots
2330
2260
  };
@@ -2447,8 +2377,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2447
2377
  type: TransactionType4.Script,
2448
2378
  scriptGasLimit: this.gasLimit,
2449
2379
  ...super.getBaseTransaction(),
2450
- scriptLength: bn10(script.length),
2451
- scriptDataLength: bn10(scriptData.length),
2380
+ scriptLength: script.length,
2381
+ scriptDataLength: scriptData.length,
2452
2382
  receiptsRoot: ZeroBytes327,
2453
2383
  script: hexlify10(script),
2454
2384
  scriptData: hexlify10(scriptData)
@@ -2512,7 +2442,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2512
2442
  }
2513
2443
  calculateMaxGas(chainInfo, minGas) {
2514
2444
  const { consensusParameters } = chainInfo;
2515
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2445
+ const { gasPerByte } = consensusParameters;
2516
2446
  const witnessesLength = this.toTransaction().witnesses.reduce(
2517
2447
  (acc, wit) => acc + wit.dataLength,
2518
2448
  0
@@ -2522,8 +2452,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2522
2452
  minGas,
2523
2453
  witnessesLength,
2524
2454
  witnessLimit: this.witnessLimit,
2525
- gasLimit: this.gasLimit,
2526
- maxGasPerTx
2455
+ gasLimit: this.gasLimit
2527
2456
  });
2528
2457
  }
2529
2458
  /**
@@ -2580,7 +2509,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2580
2509
 
2581
2510
  // src/providers/transaction-request/utils.ts
2582
2511
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2583
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2512
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2584
2513
  var transactionRequestify = (obj) => {
2585
2514
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2586
2515
  return obj;
@@ -2598,31 +2527,14 @@ var transactionRequestify = (obj) => {
2598
2527
  }
2599
2528
  }
2600
2529
  };
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
2530
 
2617
2531
  // src/providers/transaction-response/transaction-response.ts
2618
2532
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2619
- import { bn as bn15 } from "@fuel-ts/math";
2533
+ import { bn as bn14 } from "@fuel-ts/math";
2620
2534
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2621
2535
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2622
2536
 
2623
2537
  // 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
2538
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2627
2539
 
2628
2540
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2631,10 +2543,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2631
2543
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2632
2544
  var calculateTransactionFee = (params) => {
2633
2545
  const {
2634
- gasPrice,
2546
+ gasUsed,
2635
2547
  rawPayload,
2636
- tip,
2637
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2548
+ consensusParameters: { gasCosts, feeParams }
2638
2549
  } = params;
2639
2550
  const gasPerByte = bn11(feeParams.gasPerByte);
2640
2551
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2644,7 +2555,8 @@ var calculateTransactionFee = (params) => {
2644
2555
  return {
2645
2556
  fee: bn11(0),
2646
2557
  minFee: bn11(0),
2647
- maxFee: bn11(0)
2558
+ maxFee: bn11(0),
2559
+ feeFromGasUsed: bn11(0)
2648
2560
  };
2649
2561
  }
2650
2562
  const { type, witnesses, inputs, policies } = transaction;
@@ -2676,6 +2588,7 @@ var calculateTransactionFee = (params) => {
2676
2588
  metadataGas,
2677
2589
  txBytesSize: transactionBytes.length
2678
2590
  });
2591
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2679
2592
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2680
2593
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2681
2594
  const maxGas = getMaxGas({
@@ -2683,25 +2596,17 @@ var calculateTransactionFee = (params) => {
2683
2596
  minGas,
2684
2597
  witnessesLength,
2685
2598
  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
2599
+ witnessLimit
2700
2600
  });
2601
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2602
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2603
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2604
+ const fee = minFee.add(feeFromGasUsed);
2701
2605
  return {
2606
+ fee,
2702
2607
  minFee,
2703
2608
  maxFee,
2704
- fee: maxFee
2609
+ feeFromGasUsed
2705
2610
  };
2706
2611
  };
2707
2612
 
@@ -2757,7 +2662,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2757
2662
 
2758
2663
  // src/providers/transaction-summary/input.ts
2759
2664
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2760
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2665
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2761
2666
  function getInputsByTypes(inputs, types) {
2762
2667
  return inputs.filter((i) => types.includes(i.type));
2763
2668
  }
@@ -2765,16 +2670,16 @@ function getInputsByType(inputs, type) {
2765
2670
  return inputs.filter((i) => i.type === type);
2766
2671
  }
2767
2672
  function getInputsCoin(inputs) {
2768
- return getInputsByType(inputs, InputType6.Coin);
2673
+ return getInputsByType(inputs, InputType5.Coin);
2769
2674
  }
2770
2675
  function getInputsMessage(inputs) {
2771
- return getInputsByType(inputs, InputType6.Message);
2676
+ return getInputsByType(inputs, InputType5.Message);
2772
2677
  }
2773
2678
  function getInputsCoinAndMessage(inputs) {
2774
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2679
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2775
2680
  }
2776
2681
  function getInputsContract(inputs) {
2777
- return getInputsByType(inputs, InputType6.Contract);
2682
+ return getInputsByType(inputs, InputType5.Contract);
2778
2683
  }
2779
2684
  function getInputFromAssetId(inputs, assetId) {
2780
2685
  const coinInputs = getInputsCoin(inputs);
@@ -2793,7 +2698,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2793
2698
  if (!contractInput) {
2794
2699
  return void 0;
2795
2700
  }
2796
- if (contractInput.type !== InputType6.Contract) {
2701
+ if (contractInput.type !== InputType5.Contract) {
2797
2702
  throw new FuelError9(
2798
2703
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2799
2704
  `Contract input should be of type 'contract'.`
@@ -2802,10 +2707,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2802
2707
  return contractInput;
2803
2708
  }
2804
2709
  function getInputAccountAddress(input) {
2805
- if (input.type === InputType6.Coin) {
2710
+ if (input.type === InputType5.Coin) {
2806
2711
  return input.owner.toString();
2807
2712
  }
2808
- if (input.type === InputType6.Message) {
2713
+ if (input.type === InputType5.Message) {
2809
2714
  return input.recipient.toString();
2810
2715
  }
2811
2716
  return "";
@@ -3268,9 +3173,7 @@ function assembleTransactionSummary(params) {
3268
3173
  gqlTransactionStatus,
3269
3174
  abiMap = {},
3270
3175
  maxInputs,
3271
- gasCosts,
3272
- maxGasPerTx,
3273
- gasPrice
3176
+ gasCosts
3274
3177
  } = params;
3275
3178
  const gasUsed = getGasUsedFromReceipts(receipts);
3276
3179
  const rawPayload = hexlify11(transactionBytes);
@@ -3284,14 +3187,11 @@ function assembleTransactionSummary(params) {
3284
3187
  maxInputs
3285
3188
  });
3286
3189
  const typeName = getTransactionTypeName(transaction.type);
3287
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3288
3190
  const { fee } = calculateTransactionFee({
3289
- gasPrice,
3191
+ gasUsed,
3290
3192
  rawPayload,
3291
- tip,
3292
3193
  consensusParameters: {
3293
3194
  gasCosts,
3294
- maxGasPerTx,
3295
3195
  feeParams: {
3296
3196
  gasPerByte,
3297
3197
  gasPriceFactor
@@ -3351,7 +3251,7 @@ var TransactionResponse = class {
3351
3251
  /** Current provider */
3352
3252
  provider;
3353
3253
  /** Gas used on the transaction */
3354
- gasUsed = bn15(0);
3254
+ gasUsed = bn14(0);
3355
3255
  /** The graphql Transaction with receipts object. */
3356
3256
  gqlTransaction;
3357
3257
  abis;
@@ -3429,13 +3329,8 @@ var TransactionResponse = class {
3429
3329
  const decodedTransaction = this.decodeTransaction(
3430
3330
  transaction
3431
3331
  );
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();
3332
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3333
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3439
3334
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3440
3335
  const transactionSummary = assembleTransactionSummary({
3441
3336
  id: this.id,
@@ -3447,9 +3342,7 @@ var TransactionResponse = class {
3447
3342
  gasPriceFactor,
3448
3343
  abiMap: contractsAbiMap,
3449
3344
  maxInputs,
3450
- gasCosts,
3451
- maxGasPerTx,
3452
- gasPrice
3345
+ gasCosts
3453
3346
  });
3454
3347
  return transactionSummary;
3455
3348
  }
@@ -3576,29 +3469,29 @@ var processGqlChain = (chain) => {
3576
3469
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3577
3470
  return {
3578
3471
  name,
3579
- baseChainHeight: bn16(daHeight),
3472
+ baseChainHeight: bn15(daHeight),
3580
3473
  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),
3474
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3475
+ maxInputs: bn15(txParams.maxInputs),
3476
+ maxOutputs: bn15(txParams.maxOutputs),
3477
+ maxWitnesses: bn15(txParams.maxWitnesses),
3478
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3479
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3480
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3481
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3482
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3483
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3484
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3485
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3486
+ gasPerByte: bn15(feeParams.gasPerByte),
3487
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3488
+ chainId: bn15(consensusParameters.chainId),
3596
3489
  gasCosts
3597
3490
  },
3598
3491
  gasCosts,
3599
3492
  latestBlock: {
3600
3493
  id: latestBlock.id,
3601
- height: bn16(latestBlock.height),
3494
+ height: bn15(latestBlock.header.height),
3602
3495
  time: latestBlock.header.time,
3603
3496
  transactions: latestBlock.transactions.map((i) => ({
3604
3497
  id: i.id
@@ -3692,8 +3585,10 @@ var _Provider = class {
3692
3585
  * Returns some helpful parameters related to gas fees.
3693
3586
  */
3694
3587
  getGasConfig() {
3588
+ const { minGasPrice } = this.getNode();
3695
3589
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3696
3590
  return {
3591
+ minGasPrice,
3697
3592
  maxGasPerTx,
3698
3593
  maxGasPerPredicate,
3699
3594
  gasPriceFactor,
@@ -3791,7 +3686,7 @@ var _Provider = class {
3791
3686
  */
3792
3687
  async getBlockNumber() {
3793
3688
  const { chain } = await this.operations.getChain();
3794
- return bn16(chain.latestBlock.height, 10);
3689
+ return bn15(chain.latestBlock.header.height, 10);
3795
3690
  }
3796
3691
  /**
3797
3692
  * Returns the chain information.
@@ -3801,11 +3696,13 @@ var _Provider = class {
3801
3696
  async fetchNode() {
3802
3697
  const { nodeInfo } = await this.operations.getNodeInfo();
3803
3698
  const processedNodeInfo = {
3804
- maxDepth: bn16(nodeInfo.maxDepth),
3805
- maxTx: bn16(nodeInfo.maxTx),
3699
+ maxDepth: bn15(nodeInfo.maxDepth),
3700
+ maxTx: bn15(nodeInfo.maxTx),
3701
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3806
3702
  nodeVersion: nodeInfo.nodeVersion,
3807
3703
  utxoValidation: nodeInfo.utxoValidation,
3808
- vmBacktrace: nodeInfo.vmBacktrace
3704
+ vmBacktrace: nodeInfo.vmBacktrace,
3705
+ peers: nodeInfo.peers
3809
3706
  };
3810
3707
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3811
3708
  return processedNodeInfo;
@@ -3891,13 +3788,14 @@ var _Provider = class {
3891
3788
  return this.estimateTxDependencies(transactionRequest);
3892
3789
  }
3893
3790
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3894
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3895
- encodedTransactions: encodedTransaction,
3791
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3792
+ encodedTransaction,
3896
3793
  utxoValidation: utxoValidation || false
3897
3794
  });
3898
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3899
- const receipts = rawReceipts.map(processGqlReceipt);
3900
- return { receipts, dryrunStatus: status };
3795
+ const receipts = gqlReceipts.map(processGqlReceipt);
3796
+ return {
3797
+ receipts
3798
+ };
3901
3799
  }
3902
3800
  /**
3903
3801
  * Verifies whether enough gas is available to complete transaction.
@@ -3923,7 +3821,7 @@ var _Provider = class {
3923
3821
  } = response;
3924
3822
  if (inputs) {
3925
3823
  inputs.forEach((input, index) => {
3926
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3824
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3927
3825
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3928
3826
  }
3929
3827
  });
@@ -3936,6 +3834,9 @@ var _Provider = class {
3936
3834
  * If there are missing variable outputs,
3937
3835
  * `addVariableOutputs` is called on the transaction.
3938
3836
  *
3837
+ * @privateRemarks
3838
+ * TODO: Investigate support for missing contract IDs
3839
+ * TODO: Add support for missing output messages
3939
3840
  *
3940
3841
  * @param transactionRequest - The transaction request object.
3941
3842
  * @returns A promise.
@@ -3948,19 +3849,16 @@ var _Provider = class {
3948
3849
  missingContractIds: []
3949
3850
  };
3950
3851
  }
3852
+ await this.estimatePredicates(transactionRequest);
3951
3853
  let receipts = [];
3952
3854
  const missingContractIds = [];
3953
3855
  let outputVariables = 0;
3954
- let dryrunStatus;
3955
3856
  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())],
3857
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3858
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3960
3859
  utxoValidation: false
3961
3860
  });
3962
- receipts = rawReceipts.map(processGqlReceipt);
3963
- dryrunStatus = status;
3861
+ receipts = gqlReceipts.map(processGqlReceipt);
3964
3862
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3965
3863
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3966
3864
  if (hasMissingOutputs) {
@@ -3970,11 +3868,6 @@ var _Provider = class {
3970
3868
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3971
3869
  missingContractIds.push(contractId);
3972
3870
  });
3973
- const { maxFee } = await this.estimateTxGasAndFee({
3974
- transactionRequest,
3975
- optimizeGas: false
3976
- });
3977
- transactionRequest.maxFee = maxFee;
3978
3871
  } else {
3979
3872
  break;
3980
3873
  }
@@ -3982,133 +3875,37 @@ var _Provider = class {
3982
3875
  return {
3983
3876
  receipts,
3984
3877
  outputVariables,
3985
- missingContractIds,
3986
- dryrunStatus
3878
+ missingContractIds
3987
3879
  };
3988
3880
  }
3989
3881
  /**
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.
3882
+ * Estimates the transaction gas and fee based on the provided transaction request.
3883
+ * @param transactionRequest - The transaction request object.
3884
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3998
3885
  */
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;
3886
+ estimateTxGasAndFee(params) {
3887
+ const { transactionRequest } = params;
3888
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4077
3889
  const chainInfo = this.getChain();
4078
- const { gasPriceFactor } = this.getGasConfig();
3890
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3891
+ transactionRequest.gasPrice = gasPrice;
4079
3892
  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);
3893
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4090
3894
  if (transactionRequest.type === TransactionType8.Script) {
4091
- gasLimit = transactionRequest.gasLimit;
4092
- if (!optimizeGas) {
3895
+ if (transactionRequest.gasLimit.eq(0)) {
4093
3896
  transactionRequest.gasLimit = minGas;
4094
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4095
- transactionRequest.gasLimit = gasLimit;
3897
+ transactionRequest.gasLimit = maxGasPerTx.sub(
3898
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
3899
+ );
4096
3900
  }
4097
3901
  }
4098
3902
  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);
3903
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4105
3904
  return {
4106
3905
  minGas,
4107
3906
  minFee,
4108
3907
  maxGas,
4109
- maxFee,
4110
- gasPrice,
4111
- gasLimit
3908
+ maxFee
4112
3909
  };
4113
3910
  }
4114
3911
  /**
@@ -4126,17 +3923,15 @@ var _Provider = class {
4126
3923
  if (estimateTxDependencies) {
4127
3924
  return this.estimateTxDependencies(transactionRequest);
4128
3925
  }
4129
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4130
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4131
- encodedTransactions,
3926
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3927
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3928
+ encodedTransaction,
4132
3929
  utxoValidation: true
4133
3930
  });
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 };
3931
+ const receipts = gqlReceipts.map(processGqlReceipt);
3932
+ return {
3933
+ receipts
3934
+ };
4140
3935
  }
4141
3936
  /**
4142
3937
  * Returns a transaction cost to enable user
@@ -4153,80 +3948,77 @@ var _Provider = class {
4153
3948
  * @param tolerance - The tolerance to add on top of the gasUsed.
4154
3949
  * @returns A promise that resolves to the transaction cost object.
4155
3950
  */
4156
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3951
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3952
+ estimateTxDependencies = true,
3953
+ estimatePredicates = true,
3954
+ resourcesOwner,
3955
+ signatureCallback
3956
+ } = {}) {
4157
3957
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3958
+ const { minGasPrice } = this.getGasConfig();
3959
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4158
3960
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4159
3961
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4160
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3962
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4161
3963
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4162
- txRequestClone.maxFee = bn16(0);
4163
3964
  if (isScriptTransaction) {
4164
- txRequestClone.gasLimit = bn16(0);
3965
+ txRequestClone.gasLimit = bn15(0);
4165
3966
  }
4166
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4167
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3967
+ if (estimatePredicates) {
3968
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3969
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3970
+ }
3971
+ await this.estimatePredicates(txRequestClone);
4168
3972
  }
4169
- const signedRequest = clone3(txRequestClone);
4170
- let addedSignatures = 0;
4171
3973
  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
3974
+ await signatureCallback(txRequestClone);
3975
+ }
3976
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3977
+ transactionRequest: txRequestClone
4180
3978
  });
4181
- txRequestClone.maxFee = maxFee;
4182
3979
  let receipts = [];
4183
3980
  let missingContractIds = [];
4184
3981
  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;
3982
+ let gasUsed = bn15(0);
3983
+ if (isScriptTransaction && estimateTxDependencies) {
3984
+ txRequestClone.gasPrice = bn15(0);
4192
3985
  const result = await this.estimateTxDependencies(txRequestClone);
4193
3986
  receipts = result.receipts;
4194
3987
  outputVariables = result.outputVariables;
4195
3988
  missingContractIds = result.missingContractIds;
4196
- gasUsed = getGasUsedFromReceipts(receipts);
3989
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4197
3990
  txRequestClone.gasLimit = gasUsed;
4198
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4199
- transactionRequest: txRequestClone,
4200
- gasPrice
3991
+ txRequestClone.gasPrice = setGasPrice;
3992
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3993
+ transactionRequest: txRequestClone
4201
3994
  }));
4202
3995
  }
4203
3996
  return {
4204
3997
  requiredQuantities: allQuantities,
4205
3998
  receipts,
4206
3999
  gasUsed,
4207
- gasPrice,
4000
+ minGasPrice,
4001
+ gasPrice: setGasPrice,
4208
4002
  minGas,
4209
4003
  maxGas,
4210
4004
  minFee,
4211
4005
  maxFee,
4006
+ estimatedInputs: txRequestClone.inputs,
4212
4007
  outputVariables,
4213
- missingContractIds,
4214
- addedSignatures,
4215
- estimatedPredicates: txRequestClone.inputs
4008
+ missingContractIds
4216
4009
  };
4217
4010
  }
4218
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4011
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4219
4012
  const ownerAddress = Address2.fromAddressOrString(owner);
4220
4013
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4221
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4222
- quantitiesToContract
4223
- });
4014
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4224
4015
  transactionRequest.addResources(
4225
4016
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4226
4017
  );
4227
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4228
- quantitiesToContract
4229
- });
4018
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4019
+ transactionRequest,
4020
+ forwardingQuantities
4021
+ );
4230
4022
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4231
4023
  return {
4232
4024
  resources,
@@ -4248,10 +4040,11 @@ var _Provider = class {
4248
4040
  return coins.map((coin) => ({
4249
4041
  id: coin.utxoId,
4250
4042
  assetId: coin.assetId,
4251
- amount: bn16(coin.amount),
4043
+ amount: bn15(coin.amount),
4252
4044
  owner: Address2.fromAddressOrString(coin.owner),
4253
- blockCreated: bn16(coin.blockCreated),
4254
- txCreatedIdx: bn16(coin.txCreatedIdx)
4045
+ maturity: bn15(coin.maturity).toNumber(),
4046
+ blockCreated: bn15(coin.blockCreated),
4047
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4255
4048
  }));
4256
4049
  }
4257
4050
  /**
@@ -4288,9 +4081,9 @@ var _Provider = class {
4288
4081
  switch (coin.__typename) {
4289
4082
  case "MessageCoin":
4290
4083
  return {
4291
- amount: bn16(coin.amount),
4084
+ amount: bn15(coin.amount),
4292
4085
  assetId: coin.assetId,
4293
- daHeight: bn16(coin.daHeight),
4086
+ daHeight: bn15(coin.daHeight),
4294
4087
  sender: Address2.fromAddressOrString(coin.sender),
4295
4088
  recipient: Address2.fromAddressOrString(coin.recipient),
4296
4089
  nonce: coin.nonce
@@ -4298,11 +4091,12 @@ var _Provider = class {
4298
4091
  case "Coin":
4299
4092
  return {
4300
4093
  id: coin.utxoId,
4301
- amount: bn16(coin.amount),
4094
+ amount: bn15(coin.amount),
4302
4095
  assetId: coin.assetId,
4303
4096
  owner: Address2.fromAddressOrString(coin.owner),
4304
- blockCreated: bn16(coin.blockCreated),
4305
- txCreatedIdx: bn16(coin.txCreatedIdx)
4097
+ maturity: bn15(coin.maturity).toNumber(),
4098
+ blockCreated: bn15(coin.blockCreated),
4099
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4306
4100
  };
4307
4101
  default:
4308
4102
  return null;
@@ -4319,13 +4113,13 @@ var _Provider = class {
4319
4113
  async getBlock(idOrHeight) {
4320
4114
  let variables;
4321
4115
  if (typeof idOrHeight === "number") {
4322
- variables = { height: bn16(idOrHeight).toString(10) };
4116
+ variables = { height: bn15(idOrHeight).toString(10) };
4323
4117
  } else if (idOrHeight === "latest") {
4324
4118
  variables = { height: (await this.getBlockNumber()).toString(10) };
4325
4119
  } else if (idOrHeight.length === 66) {
4326
4120
  variables = { blockId: idOrHeight };
4327
4121
  } else {
4328
- variables = { blockId: bn16(idOrHeight).toString(10) };
4122
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4329
4123
  }
4330
4124
  const { block } = await this.operations.getBlock(variables);
4331
4125
  if (!block) {
@@ -4333,7 +4127,7 @@ var _Provider = class {
4333
4127
  }
4334
4128
  return {
4335
4129
  id: block.id,
4336
- height: bn16(block.height),
4130
+ height: bn15(block.header.height),
4337
4131
  time: block.header.time,
4338
4132
  transactionIds: block.transactions.map((tx) => tx.id)
4339
4133
  };
@@ -4348,7 +4142,7 @@ var _Provider = class {
4348
4142
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4349
4143
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4350
4144
  id: block.id,
4351
- height: bn16(block.height),
4145
+ height: bn15(block.header.height),
4352
4146
  time: block.header.time,
4353
4147
  transactionIds: block.transactions.map((tx) => tx.id)
4354
4148
  }));
@@ -4363,7 +4157,7 @@ var _Provider = class {
4363
4157
  async getBlockWithTransactions(idOrHeight) {
4364
4158
  let variables;
4365
4159
  if (typeof idOrHeight === "number") {
4366
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4160
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4367
4161
  } else if (idOrHeight === "latest") {
4368
4162
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4369
4163
  } else {
@@ -4375,7 +4169,7 @@ var _Provider = class {
4375
4169
  }
4376
4170
  return {
4377
4171
  id: block.id,
4378
- height: bn16(block.height, 10),
4172
+ height: bn15(block.header.height, 10),
4379
4173
  time: block.header.time,
4380
4174
  transactionIds: block.transactions.map((tx) => tx.id),
4381
4175
  transactions: block.transactions.map(
@@ -4424,7 +4218,7 @@ var _Provider = class {
4424
4218
  contract: Address2.fromAddressOrString(contractId).toB256(),
4425
4219
  asset: hexlify12(assetId)
4426
4220
  });
4427
- return bn16(contractBalance.amount, 10);
4221
+ return bn15(contractBalance.amount, 10);
4428
4222
  }
4429
4223
  /**
4430
4224
  * Returns the balance for the given owner for the given asset ID.
@@ -4438,7 +4232,7 @@ var _Provider = class {
4438
4232
  owner: Address2.fromAddressOrString(owner).toB256(),
4439
4233
  assetId: hexlify12(assetId)
4440
4234
  });
4441
- return bn16(balance.amount, 10);
4235
+ return bn15(balance.amount, 10);
4442
4236
  }
4443
4237
  /**
4444
4238
  * Returns balances for the given owner.
@@ -4456,7 +4250,7 @@ var _Provider = class {
4456
4250
  const balances = result.balances.edges.map((edge) => edge.node);
4457
4251
  return balances.map((balance) => ({
4458
4252
  assetId: balance.assetId,
4459
- amount: bn16(balance.amount)
4253
+ amount: bn15(balance.amount)
4460
4254
  }));
4461
4255
  }
4462
4256
  /**
@@ -4478,15 +4272,15 @@ var _Provider = class {
4478
4272
  sender: message.sender,
4479
4273
  recipient: message.recipient,
4480
4274
  nonce: message.nonce,
4481
- amount: bn16(message.amount),
4275
+ amount: bn15(message.amount),
4482
4276
  data: message.data
4483
4277
  }),
4484
4278
  sender: Address2.fromAddressOrString(message.sender),
4485
4279
  recipient: Address2.fromAddressOrString(message.recipient),
4486
4280
  nonce: message.nonce,
4487
- amount: bn16(message.amount),
4281
+ amount: bn15(message.amount),
4488
4282
  data: InputMessageCoder.decodeData(message.data),
4489
- daHeight: bn16(message.daHeight)
4283
+ daHeight: bn15(message.daHeight)
4490
4284
  }));
4491
4285
  }
4492
4286
  /**
@@ -4539,60 +4333,44 @@ var _Provider = class {
4539
4333
  } = result.messageProof;
4540
4334
  return {
4541
4335
  messageProof: {
4542
- proofIndex: bn16(messageProof.proofIndex),
4336
+ proofIndex: bn15(messageProof.proofIndex),
4543
4337
  proofSet: messageProof.proofSet
4544
4338
  },
4545
4339
  blockProof: {
4546
- proofIndex: bn16(blockProof.proofIndex),
4340
+ proofIndex: bn15(blockProof.proofIndex),
4547
4341
  proofSet: blockProof.proofSet
4548
4342
  },
4549
4343
  messageBlockHeader: {
4550
4344
  id: messageBlockHeader.id,
4551
- daHeight: bn16(messageBlockHeader.daHeight),
4552
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4345
+ daHeight: bn15(messageBlockHeader.daHeight),
4346
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4553
4347
  transactionsRoot: messageBlockHeader.transactionsRoot,
4554
- height: bn16(messageBlockHeader.height),
4348
+ height: bn15(messageBlockHeader.height),
4555
4349
  prevRoot: messageBlockHeader.prevRoot,
4556
4350
  time: messageBlockHeader.time,
4557
4351
  applicationHash: messageBlockHeader.applicationHash,
4558
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4559
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4560
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4561
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4562
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4352
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4353
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4563
4354
  },
4564
4355
  commitBlockHeader: {
4565
4356
  id: commitBlockHeader.id,
4566
- daHeight: bn16(commitBlockHeader.daHeight),
4567
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4357
+ daHeight: bn15(commitBlockHeader.daHeight),
4358
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4568
4359
  transactionsRoot: commitBlockHeader.transactionsRoot,
4569
- height: bn16(commitBlockHeader.height),
4360
+ height: bn15(commitBlockHeader.height),
4570
4361
  prevRoot: commitBlockHeader.prevRoot,
4571
4362
  time: commitBlockHeader.time,
4572
4363
  applicationHash: commitBlockHeader.applicationHash,
4573
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4574
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4575
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4576
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4577
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4364
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4365
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4578
4366
  },
4579
4367
  sender: Address2.fromAddressOrString(sender),
4580
4368
  recipient: Address2.fromAddressOrString(recipient),
4581
4369
  nonce,
4582
- amount: bn16(amount),
4370
+ amount: bn15(amount),
4583
4371
  data
4584
4372
  };
4585
4373
  }
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
4374
  /**
4597
4375
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4598
4376
  *
@@ -4612,10 +4390,10 @@ var _Provider = class {
4612
4390
  */
4613
4391
  async produceBlocks(amount, startTime) {
4614
4392
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4615
- blocksToProduce: bn16(amount).toString(10),
4393
+ blocksToProduce: bn15(amount).toString(10),
4616
4394
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4617
4395
  });
4618
- return bn16(latestBlockHeight);
4396
+ return bn15(latestBlockHeight);
4619
4397
  }
4620
4398
  // eslint-disable-next-line @typescript-eslint/require-await
4621
4399
  async getTransactionResponse(transactionId) {
@@ -4629,7 +4407,7 @@ cacheInputs_fn = function(inputs) {
4629
4407
  return;
4630
4408
  }
4631
4409
  inputs.forEach((input) => {
4632
- if (input.type === InputType7.Coin) {
4410
+ if (input.type === InputType6.Coin) {
4633
4411
  this.cache?.set(input.id);
4634
4412
  }
4635
4413
  });
@@ -4639,7 +4417,7 @@ __publicField(Provider, "nodeInfoCache", {});
4639
4417
 
4640
4418
  // src/providers/transaction-summary/get-transaction-summary.ts
4641
4419
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4642
- import { bn as bn17 } from "@fuel-ts/math";
4420
+ import { bn as bn16 } from "@fuel-ts/math";
4643
4421
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4644
4422
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4645
4423
 
@@ -4885,33 +4663,36 @@ var Account = class extends AbstractAccount {
4885
4663
  * @param fee - The estimated transaction fee.
4886
4664
  * @returns A promise that resolves when the resources are added to the transaction.
4887
4665
  */
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),
4666
+ async fund(request, coinQuantities, fee) {
4667
+ const updatedQuantities = addAmountToAsset({
4668
+ amount: bn17(fee),
4893
4669
  assetId: BaseAssetId3,
4894
- coinQuantities: requiredQuantities
4670
+ coinQuantities
4895
4671
  });
4896
4672
  const quantitiesDict = {};
4897
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4673
+ updatedQuantities.forEach(({ amount, assetId }) => {
4898
4674
  quantitiesDict[assetId] = {
4899
4675
  required: amount,
4900
- owned: bn18(0)
4676
+ owned: bn17(0)
4901
4677
  };
4902
4678
  });
4903
- txRequest.inputs.forEach((input) => {
4679
+ const cachedUtxos = [];
4680
+ const cachedMessages = [];
4681
+ const owner = this.address.toB256();
4682
+ request.inputs.forEach((input) => {
4904
4683
  const isResource = "amount" in input;
4905
4684
  if (isResource) {
4906
4685
  const isCoin2 = "owner" in input;
4907
4686
  if (isCoin2) {
4908
4687
  const assetId = String(input.assetId);
4909
- if (quantitiesDict[assetId]) {
4910
- const amount = bn18(input.amount);
4688
+ if (input.owner === owner && quantitiesDict[assetId]) {
4689
+ const amount = bn17(input.amount);
4911
4690
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4691
+ cachedUtxos.push(input.id);
4912
4692
  }
4913
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4693
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4914
4694
  quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4695
+ cachedMessages.push(input.nonce);
4915
4696
  }
4916
4697
  }
4917
4698
  });
@@ -4926,23 +4707,12 @@ var Account = class extends AbstractAccount {
4926
4707
  });
4927
4708
  const needsToBeFunded = missingQuantities.length;
4928
4709
  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
- );
4710
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4711
+ messages: cachedMessages,
4712
+ utxos: cachedUtxos
4713
+ });
4714
+ request.addResources(resources);
4940
4715
  }
4941
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4942
- transactionRequest: requestToBeReEstimate
4943
- });
4944
- txRequest.maxFee = maxFee;
4945
- return txRequest;
4946
4716
  }
4947
4717
  /**
4948
4718
  * A helper that creates a transfer transaction request and returns it.
@@ -4950,25 +4720,28 @@ var Account = class extends AbstractAccount {
4950
4720
  * @param destination - The address of the destination.
4951
4721
  * @param amount - The amount of coins to transfer.
4952
4722
  * @param assetId - The asset ID of the coins to transfer.
4953
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4723
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4954
4724
  * @returns A promise that resolves to the prepared transaction request.
4955
4725
  */
4956
4726
  async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4957
- const request = new ScriptTransactionRequest(txParams);
4727
+ const { minGasPrice } = this.provider.getGasConfig();
4728
+ const params = { gasPrice: minGasPrice, ...txParams };
4729
+ const request = new ScriptTransactionRequest(params);
4958
4730
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4959
- const txCost = await this.provider.getTransactionCost(request, {
4731
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4960
4732
  estimateTxDependencies: true,
4961
4733
  resourcesOwner: this
4962
4734
  });
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);
4735
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4736
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4737
+ this.validateGas({
4738
+ gasUsed,
4739
+ gasPrice: request.gasPrice,
4740
+ gasLimit: request.gasLimit,
4741
+ minGasPrice
4742
+ });
4743
+ await this.fund(request, requiredQuantities, maxFee);
4744
+ request.updatePredicateInputs(estimatedInputs);
4972
4745
  return request;
4973
4746
  }
4974
4747
  /**
@@ -4981,7 +4754,7 @@ var Account = class extends AbstractAccount {
4981
4754
  * @returns A promise that resolves to the transaction response.
4982
4755
  */
4983
4756
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4984
- if (bn18(amount).lte(0)) {
4757
+ if (bn17(amount).lte(0)) {
4985
4758
  throw new FuelError15(
4986
4759
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4987
4760
  "Transfer amount must be a positive number."
@@ -5000,37 +4773,38 @@ var Account = class extends AbstractAccount {
5000
4773
  * @returns A promise that resolves to the transaction response.
5001
4774
  */
5002
4775
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5003
- if (bn18(amount).lte(0)) {
4776
+ if (bn17(amount).lte(0)) {
5004
4777
  throw new FuelError15(
5005
4778
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5006
4779
  "Transfer amount must be a positive number."
5007
4780
  );
5008
4781
  }
5009
4782
  const contractAddress = Address3.fromAddressOrString(contractId);
4783
+ const { minGasPrice } = this.provider.getGasConfig();
4784
+ const params = { gasPrice: minGasPrice, ...txParams };
5010
4785
  const { script, scriptData } = await assembleTransferToContractScript({
5011
4786
  hexlifiedContractId: contractAddress.toB256(),
5012
- amountToTransfer: bn18(amount),
4787
+ amountToTransfer: bn17(amount),
5013
4788
  assetId
5014
4789
  });
5015
4790
  const request = new ScriptTransactionRequest({
5016
- ...txParams,
4791
+ ...params,
5017
4792
  script,
5018
4793
  scriptData
5019
4794
  });
5020
4795
  request.addContractInputAndOutput(contractAddress);
5021
- const txCost = await this.provider.getTransactionCost(request, {
5022
- resourcesOwner: this,
5023
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
4796
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4797
+ request,
4798
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4799
+ );
4800
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4801
+ this.validateGas({
4802
+ gasUsed,
4803
+ gasPrice: request.gasPrice,
4804
+ gasLimit: request.gasLimit,
4805
+ minGasPrice
5024
4806
  });
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);
4807
+ await this.fund(request, requiredQuantities, maxFee);
5034
4808
  return this.sendTransaction(request);
5035
4809
  }
5036
4810
  /**
@@ -5042,31 +4816,34 @@ var Account = class extends AbstractAccount {
5042
4816
  * @returns A promise that resolves to the transaction response.
5043
4817
  */
5044
4818
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4819
+ const { minGasPrice } = this.provider.getGasConfig();
5045
4820
  const recipientAddress = Address3.fromAddressOrString(recipient);
5046
4821
  const recipientDataArray = arrayify14(
5047
4822
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5048
4823
  );
5049
4824
  const amountDataArray = arrayify14(
5050
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
4825
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5051
4826
  );
5052
4827
  const script = new Uint8Array([
5053
4828
  ...arrayify14(withdrawScript.bytes),
5054
4829
  ...recipientDataArray,
5055
4830
  ...amountDataArray
5056
4831
  ]);
5057
- const params = { script, ...txParams };
4832
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5058
4833
  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);
4834
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4835
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4836
+ request,
4837
+ forwardingQuantities
4838
+ );
4839
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4840
+ this.validateGas({
4841
+ gasUsed,
4842
+ gasPrice: request.gasPrice,
4843
+ gasLimit: request.gasLimit,
4844
+ minGasPrice
4845
+ });
4846
+ await this.fund(request, requiredQuantities, maxFee);
5070
4847
  return this.sendTransaction(request);
5071
4848
  }
5072
4849
  async signMessage(message) {
@@ -5124,7 +4901,18 @@ var Account = class extends AbstractAccount {
5124
4901
  }
5125
4902
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5126
4903
  }
5127
- validateGas({ gasUsed, gasLimit }) {
4904
+ validateGas({
4905
+ gasUsed,
4906
+ gasPrice,
4907
+ gasLimit,
4908
+ minGasPrice
4909
+ }) {
4910
+ if (minGasPrice.gt(gasPrice)) {
4911
+ throw new FuelError15(
4912
+ ErrorCode15.GAS_PRICE_TOO_LOW,
4913
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4914
+ );
4915
+ }
5128
4916
  if (gasUsed.gt(gasLimit)) {
5129
4917
  throw new FuelError15(
5130
4918
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5416,7 +5204,7 @@ var BaseWalletUnlocked = class extends Account {
5416
5204
  * @param transactionRequestLike - The transaction request to send.
5417
5205
  * @returns A promise that resolves to the TransactionResponse object.
5418
5206
  */
5419
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5207
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5420
5208
  const transactionRequest = transactionRequestify(transactionRequestLike);
5421
5209
  if (estimateTxDependencies) {
5422
5210
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5457,7 +5245,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5457
5245
  // src/hdwallet/hdwallet.ts
5458
5246
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5459
5247
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5460
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5248
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5461
5249
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5462
5250
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5463
5251
 
@@ -7923,7 +7711,7 @@ var HDWallet = class {
7923
7711
  const IR = bytes.slice(32);
7924
7712
  if (privateKey) {
7925
7713
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7926
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
7714
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7927
7715
  return new HDWallet({
7928
7716
  privateKey: ki,
7929
7717
  chainCode: IR,
@@ -8194,15 +7982,14 @@ var seedTestWallet = async (wallet, quantities) => {
8194
7982
  process.env.GENESIS_SECRET || randomBytes5(32),
8195
7983
  wallet.provider
8196
7984
  );
8197
- const request = new ScriptTransactionRequest();
8198
- quantities.forEach((quantity) => {
8199
- const { amount, assetId } = coinQuantityfy(quantity);
8200
- request.addCoinOutput(wallet.address, amount, assetId);
7985
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
7986
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
7987
+ const request = new ScriptTransactionRequest({
7988
+ gasLimit: 1e4,
7989
+ gasPrice: minGasPrice
8201
7990
  });
8202
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8203
- request.gasLimit = txCost.gasUsed;
8204
- request.maxFee = txCost.maxFee;
8205
- await genesisWallet.fund(request, txCost);
7991
+ request.addResources(resources);
7992
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8206
7993
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8207
7994
  };
8208
7995
 
@@ -8217,11 +8004,11 @@ var generateTestWallet = async (provider, quantities) => {
8217
8004
 
8218
8005
  // src/test-utils/launchNode.ts
8219
8006
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8220
- import { defaultChainConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8007
+ import { toHex as toHex2 } from "@fuel-ts/math";
8008
+ import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8221
8009
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
8222
8010
  import { spawn } from "child_process";
8223
8011
  import { randomUUID } from "crypto";
8224
- import { randomBytes as randomBytes6 } from "ethers";
8225
8012
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
8226
8013
  import os from "os";
8227
8014
  import path from "path";
@@ -8270,12 +8057,12 @@ var launchNode = async ({
8270
8057
  // eslint-disable-next-line no-async-promise-executor
8271
8058
  new Promise(async (resolve, reject) => {
8272
8059
  const remainingArgs = extractRemainingArgs(args, [
8273
- "--snapshot",
8060
+ "--chain",
8274
8061
  "--consensus-key",
8275
8062
  "--db-type",
8276
8063
  "--poa-instant"
8277
8064
  ]);
8278
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8065
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8279
8066
  const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
8280
8067
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8281
8068
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
@@ -8294,54 +8081,36 @@ var launchNode = async ({
8294
8081
  let chainConfigPathToUse;
8295
8082
  const prefix = basePath || os.tmpdir();
8296
8083
  const suffix = basePath ? "" : randomUUID();
8297
- const tempDirPath = path.join(prefix, ".fuels", suffix, "chainConfigs");
8084
+ const tempDirPath = path.join(prefix, ".fuels", suffix);
8298
8085
  if (chainConfigPath) {
8299
8086
  chainConfigPathToUse = chainConfigPath;
8300
8087
  } else {
8301
8088
  if (!existsSync(tempDirPath)) {
8302
8089
  mkdirSync(tempDirPath, { recursive: true });
8303
8090
  }
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
- };
8091
+ const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
8092
+ let chainConfig = defaultChainConfig;
8320
8093
  if (!process.env.GENESIS_SECRET) {
8321
8094
  const pk = Signer.generatePrivateKey();
8322
8095
  const signer = new Signer(pk);
8323
8096
  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
- });
8097
+ chainConfig = {
8098
+ ...defaultChainConfig,
8099
+ initial_state: {
8100
+ ...defaultChainConfig.initial_state,
8101
+ coins: [
8102
+ ...defaultChainConfig.initial_state.coins,
8103
+ {
8104
+ owner: signer.address.toHexString(),
8105
+ amount: toHex2(1e9),
8106
+ asset_id: BaseAssetId4
8107
+ }
8108
+ ]
8109
+ }
8110
+ };
8334
8111
  }
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;
8112
+ writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8113
+ chainConfigPathToUse = tempChainConfigFilePath;
8345
8114
  }
8346
8115
  const child = spawn(
8347
8116
  command,
@@ -8350,10 +8119,10 @@ var launchNode = async ({
8350
8119
  ["--ip", ipToUse],
8351
8120
  ["--port", portToUse],
8352
8121
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8353
- ["--min-gas-price", "1"],
8122
+ ["--min-gas-price", "0"],
8354
8123
  poaInstant ? ["--poa-instant", "true"] : [],
8355
8124
  ["--consensus-key", consensusKey],
8356
- ["--snapshot", chainConfigPathToUse],
8125
+ ["--chain", chainConfigPathToUse],
8357
8126
  "--vm-backtrace",
8358
8127
  "--utxo-validation",
8359
8128
  "--debug",
@@ -8412,7 +8181,7 @@ var launchNodeAndGetWallets = async ({
8412
8181
  walletCount = 10
8413
8182
  } = {}) => {
8414
8183
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8415
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8184
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8416
8185
  const wallets = await generateWallets(walletCount, provider);
8417
8186
  const cleanup = () => {
8418
8187
  closeNode();