@fuel-ts/account 0.0.0-rc-2021-20240419013807 → 0.0.0-rc-1976-20240419063349

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 (56) 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 +604 -830
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +601 -833
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +444 -675
  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 +3 -3
  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/message.d.ts +1 -7
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +34 -37
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts +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 +1 -1
  34. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/transaction-request.d.ts +29 -9
  36. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  37. package/dist/providers/transaction-request/utils.d.ts +0 -3
  38. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  39. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  41. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  43. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  45. package/dist/providers/utils/gas.d.ts +2 -8
  46. package/dist/providers/utils/gas.d.ts.map +1 -1
  47. package/dist/test-utils/launchNode.d.ts.map +1 -1
  48. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  49. package/dist/test-utils.global.js +1118 -1579
  50. package/dist/test-utils.global.js.map +1 -1
  51. package/dist/test-utils.js +600 -811
  52. package/dist/test-utils.js.map +1 -1
  53. package/dist/test-utils.mjs +456 -667
  54. package/dist/test-utils.mjs.map +1 -1
  55. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  56. package/package.json +16 -16
@@ -24,38 +24,35 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
24
24
 
25
25
  // src/account.ts
26
26
  import { Address as Address3 } from "@fuel-ts/address";
27
- import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
28
27
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
29
28
  import { AbstractAccount } from "@fuel-ts/interfaces";
30
- import { bn as bn18 } from "@fuel-ts/math";
29
+ import { bn as bn17 } from "@fuel-ts/math";
31
30
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
32
- import { clone as clone4 } from "ramda";
33
31
 
34
32
  // src/providers/coin-quantity.ts
35
- import { BaseAssetId } from "@fuel-ts/address/configs";
36
33
  import { bn } from "@fuel-ts/math";
37
34
  import { hexlify } from "@fuel-ts/utils";
38
35
  var coinQuantityfy = (coinQuantityLike) => {
39
36
  let assetId;
40
37
  let amount;
41
- let max;
38
+ let max2;
42
39
  if (Array.isArray(coinQuantityLike)) {
43
40
  amount = coinQuantityLike[0];
44
- assetId = coinQuantityLike[1] ?? BaseAssetId;
45
- max = coinQuantityLike[2] ?? void 0;
41
+ assetId = coinQuantityLike[1];
42
+ max2 = coinQuantityLike[2];
46
43
  } else {
47
44
  amount = coinQuantityLike.amount;
48
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
49
- max = coinQuantityLike.max ?? void 0;
45
+ assetId = coinQuantityLike.assetId;
46
+ max2 = coinQuantityLike.max ?? void 0;
50
47
  }
51
48
  const bnAmount = bn(amount);
52
49
  return {
53
50
  assetId: hexlify(assetId),
54
51
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
55
- max: max ? bn(max) : void 0
52
+ max: max2 ? bn(max2) : void 0
56
53
  };
57
54
  };
58
- var addAmountToCoinQuantities = (params) => {
55
+ var addAmountToAsset = (params) => {
59
56
  const { amount, assetId } = params;
60
57
  const coinQuantities = [...params.coinQuantities];
61
58
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -70,9 +67,9 @@ var addAmountToCoinQuantities = (params) => {
70
67
  // src/providers/provider.ts
71
68
  import { Address as Address2 } from "@fuel-ts/address";
72
69
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
73
- import { BN, bn as bn16 } from "@fuel-ts/math";
70
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
74
71
  import {
75
- InputType as InputType7,
72
+ InputType as InputType6,
76
73
  TransactionType as TransactionType8,
77
74
  InputMessageCoder,
78
75
  TransactionCoder as TransactionCoder5
@@ -88,10 +85,14 @@ import { clone as clone3 } from "ramda";
88
85
  import gql from "graphql-tag";
89
86
  var ReceiptFragmentFragmentDoc = gql`
90
87
  fragment receiptFragment on Receipt {
91
- id
88
+ contract {
89
+ id
90
+ }
92
91
  pc
93
92
  is
94
- to
93
+ to {
94
+ id
95
+ }
95
96
  toAddress
96
97
  amount
97
98
  assetId
@@ -129,16 +130,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
129
130
  id
130
131
  }
131
132
  time
132
- receipts {
133
- ...receiptFragment
134
- }
135
133
  programState {
136
134
  returnType
137
135
  data
138
136
  }
139
- receipts {
140
- ...receiptFragment
141
- }
142
137
  }
143
138
  ... on FailureStatus {
144
139
  block {
@@ -146,24 +141,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
146
141
  }
147
142
  time
148
143
  reason
149
- receipts {
150
- ...receiptFragment
151
- }
152
144
  }
153
145
  ... on SqueezedOutStatus {
154
146
  reason
155
147
  }
156
148
  }
157
- ${ReceiptFragmentFragmentDoc}`;
149
+ `;
158
150
  var TransactionFragmentFragmentDoc = gql`
159
151
  fragment transactionFragment on Transaction {
160
152
  id
161
153
  rawPayload
154
+ gasPrice
155
+ receipts {
156
+ ...receiptFragment
157
+ }
162
158
  status {
163
159
  ...transactionStatusFragment
164
160
  }
165
161
  }
166
- ${TransactionStatusFragmentFragmentDoc}`;
162
+ ${ReceiptFragmentFragmentDoc}
163
+ ${TransactionStatusFragmentFragmentDoc}`;
167
164
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
168
165
  fragment inputEstimatePredicatesFragment on Input {
169
166
  ... on InputCoin {
@@ -181,46 +178,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
181
178
  }
182
179
  }
183
180
  ${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
181
  var CoinFragmentFragmentDoc = gql`
225
182
  fragment coinFragment on Coin {
226
183
  __typename
@@ -228,6 +185,7 @@ var CoinFragmentFragmentDoc = gql`
228
185
  owner
229
186
  amount
230
187
  assetId
188
+ maturity
231
189
  blockCreated
232
190
  txCreatedIdx
233
191
  }
@@ -266,32 +224,26 @@ var MessageProofFragmentFragmentDoc = gql`
266
224
  messageBlockHeader {
267
225
  id
268
226
  daHeight
269
- consensusParametersVersion
270
- stateTransitionBytecodeVersion
271
227
  transactionsCount
272
- messageReceiptCount
273
228
  transactionsRoot
274
- messageOutboxRoot
275
- eventInboxRoot
276
229
  height
277
230
  prevRoot
278
231
  time
279
232
  applicationHash
233
+ messageReceiptRoot
234
+ messageReceiptCount
280
235
  }
281
236
  commitBlockHeader {
282
237
  id
283
238
  daHeight
284
- consensusParametersVersion
285
- stateTransitionBytecodeVersion
286
239
  transactionsCount
287
- messageReceiptCount
288
240
  transactionsRoot
289
- messageOutboxRoot
290
- eventInboxRoot
291
241
  height
292
242
  prevRoot
293
243
  time
294
244
  applicationHash
245
+ messageReceiptRoot
246
+ messageReceiptCount
295
247
  }
296
248
  sender
297
249
  recipient
@@ -310,8 +262,8 @@ var BalanceFragmentFragmentDoc = gql`
310
262
  var BlockFragmentFragmentDoc = gql`
311
263
  fragment blockFragment on Block {
312
264
  id
313
- height
314
265
  header {
266
+ height
315
267
  time
316
268
  }
317
269
  transactions {
@@ -369,11 +321,6 @@ var DependentCostFragmentFragmentDoc = gql`
369
321
  `;
370
322
  var GasCostsFragmentFragmentDoc = gql`
371
323
  fragment GasCostsFragment on GasCosts {
372
- version {
373
- ... on Version {
374
- value
375
- }
376
- }
377
324
  add
378
325
  addi
379
326
  aloc
@@ -386,6 +333,7 @@ var GasCostsFragmentFragmentDoc = gql`
386
333
  cb
387
334
  cfei
388
335
  cfsi
336
+ croo
389
337
  div
390
338
  divi
391
339
  ecr1
@@ -468,9 +416,6 @@ var GasCostsFragmentFragmentDoc = gql`
468
416
  ccp {
469
417
  ...DependentCostFragment
470
418
  }
471
- croo {
472
- ...DependentCostFragment
473
- }
474
419
  csiz {
475
420
  ...DependentCostFragment
476
421
  }
@@ -530,11 +475,6 @@ var GasCostsFragmentFragmentDoc = gql`
530
475
  ${DependentCostFragmentFragmentDoc}`;
531
476
  var ConsensusParametersFragmentFragmentDoc = gql`
532
477
  fragment consensusParametersFragment on ConsensusParameters {
533
- version {
534
- ... on Version {
535
- value
536
- }
537
- }
538
478
  txParams {
539
479
  ...TxParametersFragment
540
480
  }
@@ -594,9 +534,18 @@ var NodeInfoFragmentFragmentDoc = gql`
594
534
  fragment nodeInfoFragment on NodeInfo {
595
535
  utxoValidation
596
536
  vmBacktrace
537
+ minGasPrice
597
538
  maxTx
598
539
  maxDepth
599
540
  nodeVersion
541
+ peers {
542
+ id
543
+ addresses
544
+ clientVersion
545
+ blockHeight
546
+ lastHeartbeatMs
547
+ appScore
548
+ }
600
549
  }
601
550
  `;
602
551
  var GetVersionDocument = gql`
@@ -631,9 +580,13 @@ var GetTransactionWithReceiptsDocument = gql`
631
580
  query getTransactionWithReceipts($transactionId: TransactionId!) {
632
581
  transaction(id: $transactionId) {
633
582
  ...transactionFragment
583
+ receipts {
584
+ ...receiptFragment
585
+ }
634
586
  }
635
587
  }
636
- ${TransactionFragmentFragmentDoc}`;
588
+ ${TransactionFragmentFragmentDoc}
589
+ ${ReceiptFragmentFragmentDoc}`;
637
590
  var GetTransactionsDocument = gql`
638
591
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
639
592
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -761,20 +714,6 @@ var GetBalanceDocument = gql`
761
714
  }
762
715
  }
763
716
  ${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
717
  var GetBalancesDocument = gql`
779
718
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
780
719
  balances(
@@ -829,12 +768,12 @@ var GetMessageStatusDocument = gql`
829
768
  }
830
769
  `;
831
770
  var DryRunDocument = gql`
832
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
833
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
834
- ...dryRunTransactionExecutionStatusFragment
771
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
772
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
773
+ ...receiptFragment
835
774
  }
836
775
  }
837
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
776
+ ${ReceiptFragmentFragmentDoc}`;
838
777
  var SubmitDocument = gql`
839
778
  mutation submit($encodedTransaction: HexString!) {
840
779
  submit(tx: $encodedTransaction) {
@@ -917,12 +856,6 @@ function getSdk(requester) {
917
856
  getBalance(variables, options) {
918
857
  return requester(GetBalanceDocument, variables, options);
919
858
  },
920
- getLatestGasPrice(variables, options) {
921
- return requester(GetLatestGasPriceDocument, variables, options);
922
- },
923
- estimateGasPrice(variables, options) {
924
- return requester(EstimateGasPriceDocument, variables, options);
925
- },
926
859
  getBalances(variables, options) {
927
860
  return requester(GetBalancesDocument, variables, options);
928
861
  },
@@ -1116,9 +1049,10 @@ var inputify = (value) => {
1116
1049
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1117
1050
  },
1118
1051
  witnessIndex: value.witnessIndex,
1052
+ maturity: value.maturity ?? 0,
1119
1053
  predicateGasUsed: bn2(value.predicateGasUsed),
1120
- predicateLength: bn2(predicate.length),
1121
- predicateDataLength: bn2(predicateData.length),
1054
+ predicateLength: predicate.length,
1055
+ predicateDataLength: predicateData.length,
1122
1056
  predicate: hexlify3(predicate),
1123
1057
  predicateData: hexlify3(predicateData)
1124
1058
  };
@@ -1149,8 +1083,8 @@ var inputify = (value) => {
1149
1083
  nonce: hexlify3(value.nonce),
1150
1084
  witnessIndex: value.witnessIndex,
1151
1085
  predicateGasUsed: bn2(value.predicateGasUsed),
1152
- predicateLength: bn2(predicate.length),
1153
- predicateDataLength: bn2(predicateData.length),
1086
+ predicateLength: predicate.length,
1087
+ predicateDataLength: predicateData.length,
1154
1088
  predicate: hexlify3(predicate),
1155
1089
  predicateData: hexlify3(predicateData),
1156
1090
  data: hexlify3(data),
@@ -1226,7 +1160,7 @@ var outputify = (value) => {
1226
1160
  // src/providers/transaction-request/transaction-request.ts
1227
1161
  import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1228
1162
  import { Address, addressify } from "@fuel-ts/address";
1229
- import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1163
+ import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1230
1164
  import { randomBytes } from "@fuel-ts/crypto";
1231
1165
  import { bn as bn7 } from "@fuel-ts/math";
1232
1166
  import {
@@ -1277,8 +1211,8 @@ function assembleReceiptByType(receipt) {
1277
1211
  case "CALL" /* Call */: {
1278
1212
  const callReceipt = {
1279
1213
  type: ReceiptType.Call,
1280
- from: hexOrZero(receipt.id || receipt.contractId),
1281
- to: hexOrZero(receipt?.to),
1214
+ from: hexOrZero(receipt.contract?.id),
1215
+ to: hexOrZero(receipt?.to?.id),
1282
1216
  amount: bn4(receipt.amount),
1283
1217
  assetId: hexOrZero(receipt.assetId),
1284
1218
  gas: bn4(receipt.gas),
@@ -1292,7 +1226,7 @@ function assembleReceiptByType(receipt) {
1292
1226
  case "RETURN" /* Return */: {
1293
1227
  const returnReceipt = {
1294
1228
  type: ReceiptType.Return,
1295
- id: hexOrZero(receipt.id || receipt.contractId),
1229
+ id: hexOrZero(receipt.contract?.id),
1296
1230
  val: bn4(receipt.val),
1297
1231
  pc: bn4(receipt.pc),
1298
1232
  is: bn4(receipt.is)
@@ -1302,7 +1236,7 @@ function assembleReceiptByType(receipt) {
1302
1236
  case "RETURN_DATA" /* ReturnData */: {
1303
1237
  const returnDataReceipt = {
1304
1238
  type: ReceiptType.ReturnData,
1305
- id: hexOrZero(receipt.id || receipt.contractId),
1239
+ id: hexOrZero(receipt.contract?.id),
1306
1240
  ptr: bn4(receipt.ptr),
1307
1241
  len: bn4(receipt.len),
1308
1242
  digest: hexOrZero(receipt.digest),
@@ -1314,7 +1248,7 @@ function assembleReceiptByType(receipt) {
1314
1248
  case "PANIC" /* Panic */: {
1315
1249
  const panicReceipt = {
1316
1250
  type: ReceiptType.Panic,
1317
- id: hexOrZero(receipt.id),
1251
+ id: hexOrZero(receipt.contract?.id),
1318
1252
  reason: bn4(receipt.reason),
1319
1253
  pc: bn4(receipt.pc),
1320
1254
  is: bn4(receipt.is),
@@ -1325,7 +1259,7 @@ function assembleReceiptByType(receipt) {
1325
1259
  case "REVERT" /* Revert */: {
1326
1260
  const revertReceipt = {
1327
1261
  type: ReceiptType.Revert,
1328
- id: hexOrZero(receipt.id || receipt.contractId),
1262
+ id: hexOrZero(receipt.contract?.id),
1329
1263
  val: bn4(receipt.ra),
1330
1264
  pc: bn4(receipt.pc),
1331
1265
  is: bn4(receipt.is)
@@ -1335,7 +1269,7 @@ function assembleReceiptByType(receipt) {
1335
1269
  case "LOG" /* Log */: {
1336
1270
  const logReceipt = {
1337
1271
  type: ReceiptType.Log,
1338
- id: hexOrZero(receipt.id || receipt.contractId),
1272
+ id: hexOrZero(receipt.contract?.id),
1339
1273
  val0: bn4(receipt.ra),
1340
1274
  val1: bn4(receipt.rb),
1341
1275
  val2: bn4(receipt.rc),
@@ -1348,7 +1282,7 @@ function assembleReceiptByType(receipt) {
1348
1282
  case "LOG_DATA" /* LogData */: {
1349
1283
  const logDataReceipt = {
1350
1284
  type: ReceiptType.LogData,
1351
- id: hexOrZero(receipt.id || receipt.contractId),
1285
+ id: hexOrZero(receipt.contract?.id),
1352
1286
  val0: bn4(receipt.ra),
1353
1287
  val1: bn4(receipt.rb),
1354
1288
  ptr: bn4(receipt.ptr),
@@ -1362,8 +1296,8 @@ function assembleReceiptByType(receipt) {
1362
1296
  case "TRANSFER" /* Transfer */: {
1363
1297
  const transferReceipt = {
1364
1298
  type: ReceiptType.Transfer,
1365
- from: hexOrZero(receipt.id || receipt.contractId),
1366
- to: hexOrZero(receipt.toAddress || receipt?.to),
1299
+ from: hexOrZero(receipt.contract?.id),
1300
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1367
1301
  amount: bn4(receipt.amount),
1368
1302
  assetId: hexOrZero(receipt.assetId),
1369
1303
  pc: bn4(receipt.pc),
@@ -1374,8 +1308,8 @@ function assembleReceiptByType(receipt) {
1374
1308
  case "TRANSFER_OUT" /* TransferOut */: {
1375
1309
  const transferOutReceipt = {
1376
1310
  type: ReceiptType.TransferOut,
1377
- from: hexOrZero(receipt.id || receipt.contractId),
1378
- to: hexOrZero(receipt.toAddress || receipt.to),
1311
+ from: hexOrZero(receipt.contract?.id),
1312
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1379
1313
  amount: bn4(receipt.amount),
1380
1314
  assetId: hexOrZero(receipt.assetId),
1381
1315
  pc: bn4(receipt.pc),
@@ -1418,7 +1352,7 @@ function assembleReceiptByType(receipt) {
1418
1352
  return receiptMessageOut;
1419
1353
  }
1420
1354
  case "MINT" /* Mint */: {
1421
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1355
+ const contractId = hexOrZero(receipt.contract?.id);
1422
1356
  const subId = hexOrZero(receipt.subId);
1423
1357
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1424
1358
  const mintReceipt = {
@@ -1433,7 +1367,7 @@ function assembleReceiptByType(receipt) {
1433
1367
  return mintReceipt;
1434
1368
  }
1435
1369
  case "BURN" /* Burn */: {
1436
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1370
+ const contractId = hexOrZero(receipt.contract?.id);
1437
1371
  const subId = hexOrZero(receipt.subId);
1438
1372
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1439
1373
  const burnReceipt = {
@@ -1459,6 +1393,7 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
1459
1393
  import { bn as bn5 } from "@fuel-ts/math";
1460
1394
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1461
1395
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1396
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1462
1397
  var getGasUsedFromReceipts = (receipts) => {
1463
1398
  const scriptResult = receipts.filter(
1464
1399
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1479,28 +1414,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1479
1414
  }
1480
1415
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1481
1416
  const witnessCache = [];
1482
- const chargeableInputs = inputs.filter((input) => {
1483
- const isCoinOrMessage = "owner" in input || "sender" in input;
1484
- if (isCoinOrMessage) {
1485
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1486
- return true;
1487
- }
1488
- if (!witnessCache.includes(input.witnessIndex)) {
1489
- witnessCache.push(input.witnessIndex);
1490
- return true;
1491
- }
1492
- }
1493
- return false;
1494
- });
1495
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1496
- const totalGas = chargeableInputs.reduce((total, input) => {
1417
+ const totalGas = inputs.reduce((total, input) => {
1497
1418
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1498
1419
  return total.add(
1499
- vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1420
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1500
1421
  );
1501
1422
  }
1502
- return total.add(gasCosts.ecr1);
1503
- }, bn5(0));
1423
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1424
+ witnessCache.push(input.witnessIndex);
1425
+ return total.add(gasCosts.ecr1);
1426
+ }
1427
+ return total;
1428
+ }, bn5());
1504
1429
  return totalGas;
1505
1430
  }
1506
1431
  function getMinGas(params) {
@@ -1512,20 +1437,12 @@ function getMinGas(params) {
1512
1437
  return minGas;
1513
1438
  }
1514
1439
  function getMaxGas(params) {
1515
- const {
1516
- gasPerByte,
1517
- witnessesLength,
1518
- witnessLimit,
1519
- minGas,
1520
- gasLimit = bn5(0),
1521
- maxGasPerTx
1522
- } = params;
1440
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1523
1441
  let remainingAllowedWitnessGas = bn5(0);
1524
1442
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1525
1443
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1526
1444
  }
1527
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1528
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1445
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1529
1446
  }
1530
1447
  function calculateMetadataGasForTxCreate({
1531
1448
  gasCosts,
@@ -1547,10 +1464,6 @@ function calculateMetadataGasForTxScript({
1547
1464
  }) {
1548
1465
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1549
1466
  }
1550
- var calculateGasFee = (params) => {
1551
- const { gas, gasPrice, priceFactor, tip } = params;
1552
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1553
- };
1554
1467
 
1555
1468
  // src/providers/utils/json.ts
1556
1469
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1695,7 +1608,7 @@ var witnessify = (value) => {
1695
1608
  // src/providers/transaction-request/transaction-request.ts
1696
1609
  var BaseTransactionRequest = class {
1697
1610
  /** Gas price for transaction */
1698
- tip;
1611
+ gasPrice;
1699
1612
  /** Block until which tx cannot be included */
1700
1613
  maturity;
1701
1614
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1708,34 +1621,38 @@ var BaseTransactionRequest = class {
1708
1621
  outputs = [];
1709
1622
  /** List of witnesses */
1710
1623
  witnesses = [];
1624
+ /** Base asset ID - should be fetched from the chain */
1625
+ baseAssetId;
1711
1626
  /**
1712
1627
  * Constructor for initializing a base transaction request.
1713
1628
  *
1714
1629
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1715
1630
  */
1716
1631
  constructor({
1717
- tip,
1632
+ gasPrice,
1718
1633
  maturity,
1719
1634
  maxFee,
1720
1635
  witnessLimit,
1721
1636
  inputs,
1722
1637
  outputs,
1723
- witnesses
1724
- } = {}) {
1725
- this.tip = bn7(tip);
1638
+ witnesses,
1639
+ baseAssetId
1640
+ }) {
1641
+ this.gasPrice = bn7(gasPrice);
1726
1642
  this.maturity = maturity ?? 0;
1727
1643
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1728
1644
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
1729
1645
  this.inputs = inputs ?? [];
1730
1646
  this.outputs = outputs ?? [];
1731
1647
  this.witnesses = witnesses ?? [];
1648
+ this.baseAssetId = baseAssetId;
1732
1649
  }
1733
1650
  static getPolicyMeta(req) {
1734
1651
  let policyTypes = 0;
1735
1652
  const policies = [];
1736
- if (req.tip) {
1737
- policyTypes += PolicyType.Tip;
1738
- policies.push({ data: req.tip, type: PolicyType.Tip });
1653
+ if (req.gasPrice) {
1654
+ policyTypes += PolicyType.GasPrice;
1655
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1739
1656
  }
1740
1657
  if (req.witnessLimit) {
1741
1658
  policyTypes += PolicyType.WitnessLimit;
@@ -1922,10 +1839,10 @@ var BaseTransactionRequest = class {
1922
1839
  * @param predicate - Predicate bytes.
1923
1840
  * @param predicateData - Predicate data bytes.
1924
1841
  */
1925
- addCoinInput(coin) {
1842
+ addCoinInput(coin, predicate) {
1926
1843
  const { assetId, owner, amount } = coin;
1927
1844
  let witnessIndex;
1928
- if (coin.predicate) {
1845
+ if (predicate) {
1929
1846
  witnessIndex = 0;
1930
1847
  } else {
1931
1848
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1940,7 +1857,8 @@ var BaseTransactionRequest = class {
1940
1857
  amount,
1941
1858
  assetId,
1942
1859
  txPointer: "0x00000000000000000000000000000000",
1943
- witnessIndex
1860
+ witnessIndex,
1861
+ predicate: predicate?.bytes
1944
1862
  };
1945
1863
  this.pushInput(input);
1946
1864
  this.addChangeOutput(owner, assetId);
@@ -1951,13 +1869,11 @@ var BaseTransactionRequest = class {
1951
1869
  *
1952
1870
  * @param message - Message resource.
1953
1871
  * @param predicate - Predicate bytes.
1954
- * @param predicateData - Predicate data bytes.
1955
1872
  */
1956
- addMessageInput(message) {
1873
+ addMessageInput(message, predicate) {
1957
1874
  const { recipient, sender, amount } = message;
1958
- const assetId = BaseAssetId2;
1959
1875
  let witnessIndex;
1960
- if (message.predicate) {
1876
+ if (predicate) {
1961
1877
  witnessIndex = 0;
1962
1878
  } else {
1963
1879
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1971,10 +1887,11 @@ var BaseTransactionRequest = class {
1971
1887
  sender: sender.toB256(),
1972
1888
  recipient: recipient.toB256(),
1973
1889
  amount,
1974
- witnessIndex
1890
+ witnessIndex,
1891
+ predicate: predicate?.bytes
1975
1892
  };
1976
1893
  this.pushInput(input);
1977
- this.addChangeOutput(recipient, assetId);
1894
+ this.addChangeOutput(recipient, this.baseAssetId);
1978
1895
  }
1979
1896
  /**
1980
1897
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2002,6 +1919,32 @@ var BaseTransactionRequest = class {
2002
1919
  resources.forEach((resource) => this.addResource(resource));
2003
1920
  return this;
2004
1921
  }
1922
+ /**
1923
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
1924
+ * outputs from the related assetIds.
1925
+ *
1926
+ * @param resources - The resources to add.
1927
+ * @returns This transaction.
1928
+ */
1929
+ addPredicateResource(resource, predicate) {
1930
+ if (isCoin(resource)) {
1931
+ this.addCoinInput(resource, predicate);
1932
+ } else {
1933
+ this.addMessageInput(resource, predicate);
1934
+ }
1935
+ return this;
1936
+ }
1937
+ /**
1938
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
1939
+ * from the related assetIds.
1940
+ *
1941
+ * @param resources - The resources to add.
1942
+ * @returns This transaction.
1943
+ */
1944
+ addPredicateResources(resources, predicate) {
1945
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1946
+ return this;
1947
+ }
2005
1948
  /**
2006
1949
  * Adds a coin output to the transaction.
2007
1950
  *
@@ -2009,12 +1952,12 @@ var BaseTransactionRequest = class {
2009
1952
  * @param amount - Amount of coin.
2010
1953
  * @param assetId - Asset ID of coin.
2011
1954
  */
2012
- addCoinOutput(to, amount, assetId = BaseAssetId2) {
1955
+ addCoinOutput(to, amount, assetId) {
2013
1956
  this.pushOutput({
2014
1957
  type: OutputType2.Coin,
2015
1958
  to: addressify(to).toB256(),
2016
1959
  amount,
2017
- assetId
1960
+ assetId: assetId ?? this.baseAssetId
2018
1961
  });
2019
1962
  return this;
2020
1963
  }
@@ -2041,7 +1984,7 @@ var BaseTransactionRequest = class {
2041
1984
  * @param to - Address of the owner.
2042
1985
  * @param assetId - Asset ID of coin.
2043
1986
  */
2044
- addChangeOutput(to, assetId = BaseAssetId2) {
1987
+ addChangeOutput(to, assetId) {
2045
1988
  const changeOutput = this.getChangeOutputs().find(
2046
1989
  (output) => hexlify7(output.assetId) === assetId
2047
1990
  );
@@ -2049,7 +1992,7 @@ var BaseTransactionRequest = class {
2049
1992
  this.pushOutput({
2050
1993
  type: OutputType2.Change,
2051
1994
  to: addressify(to).toB256(),
2052
- assetId
1995
+ assetId: assetId ?? this.baseAssetId
2053
1996
  });
2054
1997
  }
2055
1998
  }
@@ -2081,7 +2024,7 @@ var BaseTransactionRequest = class {
2081
2024
  }
2082
2025
  calculateMaxGas(chainInfo, minGas) {
2083
2026
  const { consensusParameters } = chainInfo;
2084
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2027
+ const { gasPerByte } = consensusParameters;
2085
2028
  const witnessesLength = this.toTransaction().witnesses.reduce(
2086
2029
  (acc, wit) => acc + wit.dataLength,
2087
2030
  0
@@ -2090,8 +2033,7 @@ var BaseTransactionRequest = class {
2090
2033
  gasPerByte,
2091
2034
  minGas,
2092
2035
  witnessesLength,
2093
- witnessLimit: this.witnessLimit,
2094
- maxGasPerTx
2036
+ witnessLimit: this.witnessLimit
2095
2037
  });
2096
2038
  }
2097
2039
  /**
@@ -2109,27 +2051,24 @@ var BaseTransactionRequest = class {
2109
2051
  });
2110
2052
  const updateAssetInput = (assetId, quantity) => {
2111
2053
  const assetInput = findAssetInput(assetId);
2112
- let usedQuantity = quantity;
2113
- if (assetId === BaseAssetId2) {
2114
- usedQuantity = bn7("1000000000000000000");
2115
- }
2116
2054
  if (assetInput && "assetId" in assetInput) {
2117
2055
  assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2118
- assetInput.amount = usedQuantity;
2056
+ assetInput.amount = quantity;
2119
2057
  } else {
2120
2058
  this.addResources([
2121
2059
  {
2122
2060
  id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2123
- amount: usedQuantity,
2061
+ amount: quantity,
2124
2062
  assetId,
2125
2063
  owner: resourcesOwner || Address.fromRandom(),
2064
+ maturity: 0,
2126
2065
  blockCreated: bn7(1),
2127
2066
  txCreatedIdx: bn7(1)
2128
2067
  }
2129
2068
  ]);
2130
2069
  }
2131
2070
  };
2132
- updateAssetInput(BaseAssetId2, bn7(1e11));
2071
+ updateAssetInput(this.baseAssetId, bn7(1e11));
2133
2072
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2134
2073
  }
2135
2074
  /**
@@ -2154,7 +2093,7 @@ var BaseTransactionRequest = class {
2154
2093
  toJSON() {
2155
2094
  return normalizeJSON(this);
2156
2095
  }
2157
- updatePredicateGasUsed(inputs) {
2096
+ updatePredicateInputs(inputs) {
2158
2097
  this.inputs.forEach((i) => {
2159
2098
  let correspondingInput;
2160
2099
  switch (i.type) {
@@ -2176,15 +2115,6 @@ var BaseTransactionRequest = class {
2176
2115
  }
2177
2116
  });
2178
2117
  }
2179
- shiftPredicateData() {
2180
- this.inputs.forEach((input) => {
2181
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2182
- input.predicateData = input.paddPredicateData(
2183
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2184
- );
2185
- }
2186
- });
2187
- }
2188
2118
  };
2189
2119
 
2190
2120
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2308,12 +2238,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2308
2238
  *
2309
2239
  * @param createTransactionRequestLike - The initial values for the instance
2310
2240
  */
2311
- constructor({
2312
- bytecodeWitnessIndex,
2313
- salt,
2314
- storageSlots,
2315
- ...rest
2316
- } = {}) {
2241
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2317
2242
  super(rest);
2318
2243
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2319
2244
  this.salt = hexlify9(salt ?? ZeroBytes326);
@@ -2331,8 +2256,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2331
2256
  return {
2332
2257
  type: TransactionType3.Create,
2333
2258
  ...baseTransaction,
2259
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2334
2260
  bytecodeWitnessIndex,
2335
- storageSlotsCount: bn9(storageSlots.length),
2261
+ storageSlotsCount: storageSlots.length,
2336
2262
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2337
2263
  storageSlots
2338
2264
  };
@@ -2436,7 +2362,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2436
2362
  *
2437
2363
  * @param scriptTransactionRequestLike - The initial values for the instance.
2438
2364
  */
2439
- constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2365
+ constructor({ script, scriptData, gasLimit, ...rest }) {
2440
2366
  super(rest);
2441
2367
  this.gasLimit = bn10(gasLimit);
2442
2368
  this.script = arrayify8(script ?? returnZeroScript.bytes);
@@ -2455,8 +2381,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2455
2381
  type: TransactionType4.Script,
2456
2382
  scriptGasLimit: this.gasLimit,
2457
2383
  ...super.getBaseTransaction(),
2458
- scriptLength: bn10(script.length),
2459
- scriptDataLength: bn10(scriptData.length),
2384
+ scriptLength: script.length,
2385
+ scriptDataLength: scriptData.length,
2460
2386
  receiptsRoot: ZeroBytes327,
2461
2387
  script: hexlify10(script),
2462
2388
  scriptData: hexlify10(scriptData)
@@ -2520,7 +2446,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2520
2446
  }
2521
2447
  calculateMaxGas(chainInfo, minGas) {
2522
2448
  const { consensusParameters } = chainInfo;
2523
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2449
+ const { gasPerByte } = consensusParameters;
2524
2450
  const witnessesLength = this.toTransaction().witnesses.reduce(
2525
2451
  (acc, wit) => acc + wit.dataLength,
2526
2452
  0
@@ -2530,8 +2456,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2530
2456
  minGas,
2531
2457
  witnessesLength,
2532
2458
  witnessLimit: this.witnessLimit,
2533
- gasLimit: this.gasLimit,
2534
- maxGasPerTx
2459
+ gasLimit: this.gasLimit
2535
2460
  });
2536
2461
  }
2537
2462
  /**
@@ -2588,7 +2513,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2588
2513
 
2589
2514
  // src/providers/transaction-request/utils.ts
2590
2515
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2591
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2516
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2592
2517
  var transactionRequestify = (obj) => {
2593
2518
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2594
2519
  return obj;
@@ -2606,31 +2531,14 @@ var transactionRequestify = (obj) => {
2606
2531
  }
2607
2532
  }
2608
2533
  };
2609
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2610
- (acc, input) => {
2611
- if (input.type === InputType5.Coin && input.owner === owner) {
2612
- acc.utxos.push(input.id);
2613
- }
2614
- if (input.type === InputType5.Message && input.recipient === owner) {
2615
- acc.messages.push(input.nonce);
2616
- }
2617
- return acc;
2618
- },
2619
- {
2620
- utxos: [],
2621
- messages: []
2622
- }
2623
- );
2624
2534
 
2625
2535
  // src/providers/transaction-response/transaction-response.ts
2626
2536
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2627
- import { bn as bn15 } from "@fuel-ts/math";
2537
+ import { bn as bn14 } from "@fuel-ts/math";
2628
2538
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2629
2539
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2630
2540
 
2631
2541
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2632
- import { bn as bn14 } from "@fuel-ts/math";
2633
- import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2634
2542
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2635
2543
 
2636
2544
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2639,10 +2547,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2639
2547
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2640
2548
  var calculateTransactionFee = (params) => {
2641
2549
  const {
2642
- gasPrice,
2550
+ gasUsed,
2643
2551
  rawPayload,
2644
- tip,
2645
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2552
+ consensusParameters: { gasCosts, feeParams }
2646
2553
  } = params;
2647
2554
  const gasPerByte = bn11(feeParams.gasPerByte);
2648
2555
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2652,7 +2559,8 @@ var calculateTransactionFee = (params) => {
2652
2559
  return {
2653
2560
  fee: bn11(0),
2654
2561
  minFee: bn11(0),
2655
- maxFee: bn11(0)
2562
+ maxFee: bn11(0),
2563
+ feeFromGasUsed: bn11(0)
2656
2564
  };
2657
2565
  }
2658
2566
  const { type, witnesses, inputs, policies } = transaction;
@@ -2684,6 +2592,7 @@ var calculateTransactionFee = (params) => {
2684
2592
  metadataGas,
2685
2593
  txBytesSize: transactionBytes.length
2686
2594
  });
2595
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2687
2596
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2688
2597
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2689
2598
  const maxGas = getMaxGas({
@@ -2691,25 +2600,17 @@ var calculateTransactionFee = (params) => {
2691
2600
  minGas,
2692
2601
  witnessesLength,
2693
2602
  gasLimit,
2694
- witnessLimit,
2695
- maxGasPerTx
2696
- });
2697
- const minFee = calculateGasFee({
2698
- gasPrice,
2699
- gas: minGas,
2700
- priceFactor: gasPriceFactor,
2701
- tip
2702
- });
2703
- const maxFee = calculateGasFee({
2704
- gasPrice,
2705
- gas: maxGas,
2706
- priceFactor: gasPriceFactor,
2707
- tip
2603
+ witnessLimit
2708
2604
  });
2605
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2606
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2607
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2608
+ const fee = minFee.add(feeFromGasUsed);
2709
2609
  return {
2610
+ fee,
2710
2611
  minFee,
2711
2612
  maxFee,
2712
- fee: maxFee
2613
+ feeFromGasUsed
2713
2614
  };
2714
2615
  };
2715
2616
 
@@ -2765,7 +2666,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2765
2666
 
2766
2667
  // src/providers/transaction-summary/input.ts
2767
2668
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2768
- import { InputType as InputType6 } from "@fuel-ts/transactions";
2669
+ import { InputType as InputType5 } from "@fuel-ts/transactions";
2769
2670
  function getInputsByTypes(inputs, types) {
2770
2671
  return inputs.filter((i) => types.includes(i.type));
2771
2672
  }
@@ -2773,16 +2674,16 @@ function getInputsByType(inputs, type) {
2773
2674
  return inputs.filter((i) => i.type === type);
2774
2675
  }
2775
2676
  function getInputsCoin(inputs) {
2776
- return getInputsByType(inputs, InputType6.Coin);
2677
+ return getInputsByType(inputs, InputType5.Coin);
2777
2678
  }
2778
2679
  function getInputsMessage(inputs) {
2779
- return getInputsByType(inputs, InputType6.Message);
2680
+ return getInputsByType(inputs, InputType5.Message);
2780
2681
  }
2781
2682
  function getInputsCoinAndMessage(inputs) {
2782
- return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2683
+ return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2783
2684
  }
2784
2685
  function getInputsContract(inputs) {
2785
- return getInputsByType(inputs, InputType6.Contract);
2686
+ return getInputsByType(inputs, InputType5.Contract);
2786
2687
  }
2787
2688
  function getInputFromAssetId(inputs, assetId) {
2788
2689
  const coinInputs = getInputsCoin(inputs);
@@ -2801,7 +2702,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2801
2702
  if (!contractInput) {
2802
2703
  return void 0;
2803
2704
  }
2804
- if (contractInput.type !== InputType6.Contract) {
2705
+ if (contractInput.type !== InputType5.Contract) {
2805
2706
  throw new FuelError9(
2806
2707
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2807
2708
  `Contract input should be of type 'contract'.`
@@ -2810,10 +2711,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2810
2711
  return contractInput;
2811
2712
  }
2812
2713
  function getInputAccountAddress(input) {
2813
- if (input.type === InputType6.Coin) {
2714
+ if (input.type === InputType5.Coin) {
2814
2715
  return input.owner.toString();
2815
2716
  }
2816
- if (input.type === InputType6.Message) {
2717
+ if (input.type === InputType5.Message) {
2817
2718
  return input.recipient.toString();
2818
2719
  }
2819
2720
  return "";
@@ -3276,9 +3177,7 @@ function assembleTransactionSummary(params) {
3276
3177
  gqlTransactionStatus,
3277
3178
  abiMap = {},
3278
3179
  maxInputs,
3279
- gasCosts,
3280
- maxGasPerTx,
3281
- gasPrice
3180
+ gasCosts
3282
3181
  } = params;
3283
3182
  const gasUsed = getGasUsedFromReceipts(receipts);
3284
3183
  const rawPayload = hexlify11(transactionBytes);
@@ -3292,14 +3191,11 @@ function assembleTransactionSummary(params) {
3292
3191
  maxInputs
3293
3192
  });
3294
3193
  const typeName = getTransactionTypeName(transaction.type);
3295
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3296
3194
  const { fee } = calculateTransactionFee({
3297
- gasPrice,
3195
+ gasUsed,
3298
3196
  rawPayload,
3299
- tip,
3300
3197
  consensusParameters: {
3301
3198
  gasCosts,
3302
- maxGasPerTx,
3303
3199
  feeParams: {
3304
3200
  gasPerByte,
3305
3201
  gasPriceFactor
@@ -3359,7 +3255,7 @@ var TransactionResponse = class {
3359
3255
  /** Current provider */
3360
3256
  provider;
3361
3257
  /** Gas used on the transaction */
3362
- gasUsed = bn15(0);
3258
+ gasUsed = bn14(0);
3363
3259
  /** The graphql Transaction with receipts object. */
3364
3260
  gqlTransaction;
3365
3261
  abis;
@@ -3437,13 +3333,8 @@ var TransactionResponse = class {
3437
3333
  const decodedTransaction = this.decodeTransaction(
3438
3334
  transaction
3439
3335
  );
3440
- let txReceipts = [];
3441
- if (transaction?.status && "receipts" in transaction.status) {
3442
- txReceipts = transaction.status.receipts;
3443
- }
3444
- const receipts = txReceipts.map(processGqlReceipt) || [];
3445
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3446
- const gasPrice = await this.provider.getLatestGasPrice();
3336
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3337
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3447
3338
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3448
3339
  const transactionSummary = assembleTransactionSummary({
3449
3340
  id: this.id,
@@ -3455,9 +3346,7 @@ var TransactionResponse = class {
3455
3346
  gasPriceFactor,
3456
3347
  abiMap: contractsAbiMap,
3457
3348
  maxInputs,
3458
- gasCosts,
3459
- maxGasPerTx,
3460
- gasPrice
3349
+ gasCosts
3461
3350
  });
3462
3351
  return transactionSummary;
3463
3352
  }
@@ -3584,29 +3473,30 @@ var processGqlChain = (chain) => {
3584
3473
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3585
3474
  return {
3586
3475
  name,
3587
- baseChainHeight: bn16(daHeight),
3476
+ baseChainHeight: bn15(daHeight),
3588
3477
  consensusParameters: {
3589
- contractMaxSize: bn16(contractParams.contractMaxSize),
3590
- maxInputs: bn16(txParams.maxInputs),
3591
- maxOutputs: bn16(txParams.maxOutputs),
3592
- maxWitnesses: bn16(txParams.maxWitnesses),
3593
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3594
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3595
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3596
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3597
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3598
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3599
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3600
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3601
- gasPerByte: bn16(feeParams.gasPerByte),
3602
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3603
- chainId: bn16(consensusParameters.chainId),
3478
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3479
+ maxInputs: bn15(txParams.maxInputs),
3480
+ maxOutputs: bn15(txParams.maxOutputs),
3481
+ maxWitnesses: bn15(txParams.maxWitnesses),
3482
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3483
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3484
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3485
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3486
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3487
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3488
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3489
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3490
+ gasPerByte: bn15(feeParams.gasPerByte),
3491
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3492
+ chainId: bn15(consensusParameters.chainId),
3493
+ baseAssetId: consensusParameters.baseAssetId,
3604
3494
  gasCosts
3605
3495
  },
3606
3496
  gasCosts,
3607
3497
  latestBlock: {
3608
3498
  id: latestBlock.id,
3609
- height: bn16(latestBlock.height),
3499
+ height: bn15(latestBlock.header.height),
3610
3500
  time: latestBlock.header.time,
3611
3501
  transactions: latestBlock.transactions.map((i) => ({
3612
3502
  id: i.id
@@ -3700,8 +3590,10 @@ var _Provider = class {
3700
3590
  * Returns some helpful parameters related to gas fees.
3701
3591
  */
3702
3592
  getGasConfig() {
3593
+ const { minGasPrice } = this.getNode();
3703
3594
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3704
3595
  return {
3596
+ minGasPrice,
3705
3597
  maxGasPerTx,
3706
3598
  maxGasPerPredicate,
3707
3599
  gasPriceFactor,
@@ -3799,7 +3691,7 @@ var _Provider = class {
3799
3691
  */
3800
3692
  async getBlockNumber() {
3801
3693
  const { chain } = await this.operations.getChain();
3802
- return bn16(chain.latestBlock.height, 10);
3694
+ return bn15(chain.latestBlock.header.height, 10);
3803
3695
  }
3804
3696
  /**
3805
3697
  * Returns the chain information.
@@ -3809,11 +3701,13 @@ var _Provider = class {
3809
3701
  async fetchNode() {
3810
3702
  const { nodeInfo } = await this.operations.getNodeInfo();
3811
3703
  const processedNodeInfo = {
3812
- maxDepth: bn16(nodeInfo.maxDepth),
3813
- maxTx: bn16(nodeInfo.maxTx),
3704
+ maxDepth: bn15(nodeInfo.maxDepth),
3705
+ maxTx: bn15(nodeInfo.maxTx),
3706
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3814
3707
  nodeVersion: nodeInfo.nodeVersion,
3815
3708
  utxoValidation: nodeInfo.utxoValidation,
3816
- vmBacktrace: nodeInfo.vmBacktrace
3709
+ vmBacktrace: nodeInfo.vmBacktrace,
3710
+ peers: nodeInfo.peers
3817
3711
  };
3818
3712
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3819
3713
  return processedNodeInfo;
@@ -3839,6 +3733,17 @@ var _Provider = class {
3839
3733
  } = this.getChain();
3840
3734
  return chainId.toNumber();
3841
3735
  }
3736
+ /**
3737
+ * Returns the base asset ID
3738
+ *
3739
+ * @returns A promise that resolves to the base asset ID
3740
+ */
3741
+ getBaseAssetId() {
3742
+ const {
3743
+ consensusParameters: { baseAssetId }
3744
+ } = this.getChain();
3745
+ return baseAssetId;
3746
+ }
3842
3747
  /**
3843
3748
  * Submits a transaction to the chain to be executed.
3844
3749
  *
@@ -3899,13 +3804,14 @@ var _Provider = class {
3899
3804
  return this.estimateTxDependencies(transactionRequest);
3900
3805
  }
3901
3806
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3902
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3903
- encodedTransactions: encodedTransaction,
3807
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3808
+ encodedTransaction,
3904
3809
  utxoValidation: utxoValidation || false
3905
3810
  });
3906
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3907
- const receipts = rawReceipts.map(processGqlReceipt);
3908
- return { receipts, dryrunStatus: status };
3811
+ const receipts = gqlReceipts.map(processGqlReceipt);
3812
+ return {
3813
+ receipts
3814
+ };
3909
3815
  }
3910
3816
  /**
3911
3817
  * Verifies whether enough gas is available to complete transaction.
@@ -3931,7 +3837,7 @@ var _Provider = class {
3931
3837
  } = response;
3932
3838
  if (inputs) {
3933
3839
  inputs.forEach((input, index) => {
3934
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3840
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3935
3841
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3936
3842
  }
3937
3843
  });
@@ -3944,6 +3850,9 @@ var _Provider = class {
3944
3850
  * If there are missing variable outputs,
3945
3851
  * `addVariableOutputs` is called on the transaction.
3946
3852
  *
3853
+ * @privateRemarks
3854
+ * TODO: Investigate support for missing contract IDs
3855
+ * TODO: Add support for missing output messages
3947
3856
  *
3948
3857
  * @param transactionRequest - The transaction request object.
3949
3858
  * @returns A promise.
@@ -3956,19 +3865,16 @@ var _Provider = class {
3956
3865
  missingContractIds: []
3957
3866
  };
3958
3867
  }
3868
+ await this.estimatePredicates(transactionRequest);
3959
3869
  let receipts = [];
3960
3870
  const missingContractIds = [];
3961
3871
  let outputVariables = 0;
3962
- let dryrunStatus;
3963
3872
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3964
- const {
3965
- dryRun: [{ receipts: rawReceipts, status }]
3966
- } = await this.operations.dryRun({
3967
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3873
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3874
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3968
3875
  utxoValidation: false
3969
3876
  });
3970
- receipts = rawReceipts.map(processGqlReceipt);
3971
- dryrunStatus = status;
3877
+ receipts = gqlReceipts.map(processGqlReceipt);
3972
3878
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3973
3879
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3974
3880
  if (hasMissingOutputs) {
@@ -3978,10 +3884,6 @@ var _Provider = class {
3978
3884
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3979
3885
  missingContractIds.push(contractId);
3980
3886
  });
3981
- const { maxFee } = await this.estimateTxGasAndFee({
3982
- transactionRequest
3983
- });
3984
- transactionRequest.maxFee = maxFee;
3985
3887
  } else {
3986
3888
  break;
3987
3889
  }
@@ -3989,139 +3891,37 @@ var _Provider = class {
3989
3891
  return {
3990
3892
  receipts,
3991
3893
  outputVariables,
3992
- missingContractIds,
3993
- dryrunStatus
3894
+ missingContractIds
3994
3895
  };
3995
3896
  }
3996
- /**
3997
- * Dry runs multiple transactions and checks for missing dependencies in batches.
3998
- *
3999
- * Transactions are dry run in batches. After each dry run, transactions requiring
4000
- * further modifications are identified. The method iteratively updates these transactions
4001
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4002
- *
4003
- * @param transactionRequests - Array of transaction request objects.
4004
- * @returns A promise that resolves to an array of results for each transaction.
4005
- */
4006
- async estimateMultipleTxDependencies(transactionRequests) {
4007
- const results = transactionRequests.map(() => ({
4008
- receipts: [],
4009
- outputVariables: 0,
4010
- missingContractIds: [],
4011
- dryrunStatus: void 0
4012
- }));
4013
- const allRequests = clone3(transactionRequests);
4014
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4015
- allRequests.forEach((req, index) => {
4016
- if (req.type === TransactionType8.Script) {
4017
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4018
- }
4019
- });
4020
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4021
- let attempt = 0;
4022
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4023
- const encodedTransactions = transactionsToProcess.map(
4024
- (index) => serializedTransactionsMap.get(index)
4025
- );
4026
- const dryRunResults = await this.operations.dryRun({
4027
- encodedTransactions,
4028
- utxoValidation: false
4029
- });
4030
- const nextRoundTransactions = [];
4031
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4032
- const currentResultIndex = transactionsToProcess[i];
4033
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4034
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4035
- results[currentResultIndex].dryrunStatus = status;
4036
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4037
- results[currentResultIndex].receipts
4038
- );
4039
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4040
- const requestToProcess = allRequests[currentResultIndex];
4041
- if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4042
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4043
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4044
- missingOutputContractIds.forEach(({ contractId }) => {
4045
- requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4046
- results[currentResultIndex].missingContractIds.push(contractId);
4047
- });
4048
- const { maxFee } = await this.estimateTxGasAndFee({
4049
- transactionRequest: requestToProcess
4050
- });
4051
- requestToProcess.maxFee = maxFee;
4052
- serializedTransactionsMap.set(
4053
- currentResultIndex,
4054
- hexlify12(requestToProcess.toTransactionBytes())
4055
- );
4056
- nextRoundTransactions.push(currentResultIndex);
4057
- allRequests[currentResultIndex] = requestToProcess;
4058
- }
4059
- }
4060
- transactionsToProcess = nextRoundTransactions;
4061
- attempt += 1;
4062
- }
4063
- return results;
4064
- }
4065
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4066
- if (estimateTxDependencies) {
4067
- return this.estimateMultipleTxDependencies(transactionRequests);
4068
- }
4069
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4070
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4071
- encodedTransactions,
4072
- utxoValidation: utxoValidation || false
4073
- });
4074
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4075
- const receipts = rawReceipts.map(processGqlReceipt);
4076
- return { receipts, dryrunStatus: status };
4077
- });
4078
- return results;
4079
- }
4080
3897
  /**
4081
3898
  * Estimates the transaction gas and fee based on the provided transaction request.
4082
3899
  * @param transactionRequest - The transaction request object.
4083
3900
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4084
3901
  */
4085
- async estimateTxGasAndFee(params) {
3902
+ estimateTxGasAndFee(params) {
4086
3903
  const { transactionRequest } = params;
4087
- let { gasPrice } = params;
3904
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4088
3905
  const chainInfo = this.getChain();
4089
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3906
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3907
+ transactionRequest.gasPrice = gasPrice;
4090
3908
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4091
- if (!gasPrice) {
4092
- gasPrice = await this.estimateGasPrice(10);
4093
- }
4094
- const minFee = calculateGasFee({
4095
- gasPrice: bn16(gasPrice),
4096
- gas: minGas,
4097
- priceFactor: gasPriceFactor,
4098
- tip: transactionRequest.tip
4099
- }).add(1);
4100
- let gasLimit = bn16(0);
3909
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4101
3910
  if (transactionRequest.type === TransactionType8.Script) {
4102
- gasLimit = transactionRequest.gasLimit;
4103
3911
  if (transactionRequest.gasLimit.eq(0)) {
4104
3912
  transactionRequest.gasLimit = minGas;
4105
3913
  transactionRequest.gasLimit = maxGasPerTx.sub(
4106
3914
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4107
3915
  );
4108
- gasLimit = transactionRequest.gasLimit;
4109
3916
  }
4110
3917
  }
4111
3918
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4112
- const maxFee = calculateGasFee({
4113
- gasPrice: bn16(gasPrice),
4114
- gas: maxGas,
4115
- priceFactor: gasPriceFactor,
4116
- tip: transactionRequest.tip
4117
- }).add(1);
3919
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4118
3920
  return {
4119
3921
  minGas,
4120
3922
  minFee,
4121
3923
  maxGas,
4122
- maxFee,
4123
- gasPrice,
4124
- gasLimit
3924
+ maxFee
4125
3925
  };
4126
3926
  }
4127
3927
  /**
@@ -4139,17 +3939,15 @@ var _Provider = class {
4139
3939
  if (estimateTxDependencies) {
4140
3940
  return this.estimateTxDependencies(transactionRequest);
4141
3941
  }
4142
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4143
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4144
- encodedTransactions,
3942
+ const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3943
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3944
+ encodedTransaction,
4145
3945
  utxoValidation: true
4146
3946
  });
4147
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4148
- const { id, receipts, status } = dryRunStatus;
4149
- const processedReceipts = receipts.map(processGqlReceipt);
4150
- return { id, receipts: processedReceipts, status };
4151
- });
4152
- return { receipts: callResult[0].receipts };
3947
+ const receipts = gqlReceipts.map(processGqlReceipt);
3948
+ return {
3949
+ receipts
3950
+ };
4153
3951
  }
4154
3952
  /**
4155
3953
  * Returns a transaction cost to enable user
@@ -4166,79 +3964,77 @@ var _Provider = class {
4166
3964
  * @param tolerance - The tolerance to add on top of the gasUsed.
4167
3965
  * @returns A promise that resolves to the transaction cost object.
4168
3966
  */
4169
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3967
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3968
+ estimateTxDependencies = true,
3969
+ estimatePredicates = true,
3970
+ resourcesOwner,
3971
+ signatureCallback
3972
+ } = {}) {
4170
3973
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3974
+ const { minGasPrice } = this.getGasConfig();
3975
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4171
3976
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4172
3977
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4173
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3978
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4174
3979
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4175
- txRequestClone.maxFee = bn16(0);
4176
3980
  if (isScriptTransaction) {
4177
- txRequestClone.gasLimit = bn16(0);
3981
+ txRequestClone.gasLimit = bn15(0);
4178
3982
  }
4179
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4180
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3983
+ if (estimatePredicates) {
3984
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3985
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3986
+ }
3987
+ await this.estimatePredicates(txRequestClone);
4181
3988
  }
4182
- const signedRequest = clone3(txRequestClone);
4183
- let addedSignatures = 0;
4184
3989
  if (signatureCallback && isScriptTransaction) {
4185
- const lengthBefore = signedRequest.witnesses.length;
4186
- await signatureCallback(signedRequest);
4187
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
3990
+ await signatureCallback(txRequestClone);
4188
3991
  }
4189
- await this.estimatePredicates(signedRequest);
4190
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4191
- transactionRequest: signedRequest
3992
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3993
+ transactionRequest: txRequestClone
4192
3994
  });
4193
3995
  let receipts = [];
4194
3996
  let missingContractIds = [];
4195
3997
  let outputVariables = 0;
4196
- let gasUsed = bn16(0);
4197
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4198
- txRequestClone.maxFee = maxFee;
4199
- if (isScriptTransaction) {
4200
- txRequestClone.gasLimit = gasLimit;
4201
- if (signatureCallback) {
4202
- await signatureCallback(txRequestClone);
4203
- }
3998
+ let gasUsed = bn15(0);
3999
+ if (isScriptTransaction && estimateTxDependencies) {
4000
+ txRequestClone.gasPrice = bn15(0);
4204
4001
  const result = await this.estimateTxDependencies(txRequestClone);
4205
4002
  receipts = result.receipts;
4206
4003
  outputVariables = result.outputVariables;
4207
4004
  missingContractIds = result.missingContractIds;
4208
4005
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4209
4006
  txRequestClone.gasLimit = gasUsed;
4210
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4211
- transactionRequest: txRequestClone,
4212
- gasPrice
4007
+ txRequestClone.gasPrice = setGasPrice;
4008
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4009
+ transactionRequest: txRequestClone
4213
4010
  }));
4214
4011
  }
4215
4012
  return {
4216
4013
  requiredQuantities: allQuantities,
4217
4014
  receipts,
4218
4015
  gasUsed,
4219
- gasPrice,
4016
+ minGasPrice,
4017
+ gasPrice: setGasPrice,
4220
4018
  minGas,
4221
4019
  maxGas,
4222
4020
  minFee,
4223
4021
  maxFee,
4022
+ estimatedInputs: txRequestClone.inputs,
4224
4023
  outputVariables,
4225
- missingContractIds,
4226
- addedSignatures,
4227
- estimatedPredicates: txRequestClone.inputs
4024
+ missingContractIds
4228
4025
  };
4229
4026
  }
4230
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4027
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4231
4028
  const ownerAddress = Address2.fromAddressOrString(owner);
4232
4029
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4233
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4234
- quantitiesToContract
4235
- });
4030
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4236
4031
  transactionRequest.addResources(
4237
4032
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4238
4033
  );
4239
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4240
- quantitiesToContract
4241
- });
4034
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4035
+ transactionRequest,
4036
+ forwardingQuantities
4037
+ );
4242
4038
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4243
4039
  return {
4244
4040
  resources,
@@ -4260,10 +4056,11 @@ var _Provider = class {
4260
4056
  return coins.map((coin) => ({
4261
4057
  id: coin.utxoId,
4262
4058
  assetId: coin.assetId,
4263
- amount: bn16(coin.amount),
4059
+ amount: bn15(coin.amount),
4264
4060
  owner: Address2.fromAddressOrString(coin.owner),
4265
- blockCreated: bn16(coin.blockCreated),
4266
- txCreatedIdx: bn16(coin.txCreatedIdx)
4061
+ maturity: bn15(coin.maturity).toNumber(),
4062
+ blockCreated: bn15(coin.blockCreated),
4063
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4267
4064
  }));
4268
4065
  }
4269
4066
  /**
@@ -4300,9 +4097,9 @@ var _Provider = class {
4300
4097
  switch (coin.__typename) {
4301
4098
  case "MessageCoin":
4302
4099
  return {
4303
- amount: bn16(coin.amount),
4100
+ amount: bn15(coin.amount),
4304
4101
  assetId: coin.assetId,
4305
- daHeight: bn16(coin.daHeight),
4102
+ daHeight: bn15(coin.daHeight),
4306
4103
  sender: Address2.fromAddressOrString(coin.sender),
4307
4104
  recipient: Address2.fromAddressOrString(coin.recipient),
4308
4105
  nonce: coin.nonce
@@ -4310,11 +4107,12 @@ var _Provider = class {
4310
4107
  case "Coin":
4311
4108
  return {
4312
4109
  id: coin.utxoId,
4313
- amount: bn16(coin.amount),
4110
+ amount: bn15(coin.amount),
4314
4111
  assetId: coin.assetId,
4315
4112
  owner: Address2.fromAddressOrString(coin.owner),
4316
- blockCreated: bn16(coin.blockCreated),
4317
- txCreatedIdx: bn16(coin.txCreatedIdx)
4113
+ maturity: bn15(coin.maturity).toNumber(),
4114
+ blockCreated: bn15(coin.blockCreated),
4115
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4318
4116
  };
4319
4117
  default:
4320
4118
  return null;
@@ -4331,13 +4129,13 @@ var _Provider = class {
4331
4129
  async getBlock(idOrHeight) {
4332
4130
  let variables;
4333
4131
  if (typeof idOrHeight === "number") {
4334
- variables = { height: bn16(idOrHeight).toString(10) };
4132
+ variables = { height: bn15(idOrHeight).toString(10) };
4335
4133
  } else if (idOrHeight === "latest") {
4336
4134
  variables = { height: (await this.getBlockNumber()).toString(10) };
4337
4135
  } else if (idOrHeight.length === 66) {
4338
4136
  variables = { blockId: idOrHeight };
4339
4137
  } else {
4340
- variables = { blockId: bn16(idOrHeight).toString(10) };
4138
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4341
4139
  }
4342
4140
  const { block } = await this.operations.getBlock(variables);
4343
4141
  if (!block) {
@@ -4345,7 +4143,7 @@ var _Provider = class {
4345
4143
  }
4346
4144
  return {
4347
4145
  id: block.id,
4348
- height: bn16(block.height),
4146
+ height: bn15(block.header.height),
4349
4147
  time: block.header.time,
4350
4148
  transactionIds: block.transactions.map((tx) => tx.id)
4351
4149
  };
@@ -4360,7 +4158,7 @@ var _Provider = class {
4360
4158
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4361
4159
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4362
4160
  id: block.id,
4363
- height: bn16(block.height),
4161
+ height: bn15(block.header.height),
4364
4162
  time: block.header.time,
4365
4163
  transactionIds: block.transactions.map((tx) => tx.id)
4366
4164
  }));
@@ -4375,7 +4173,7 @@ var _Provider = class {
4375
4173
  async getBlockWithTransactions(idOrHeight) {
4376
4174
  let variables;
4377
4175
  if (typeof idOrHeight === "number") {
4378
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4176
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4379
4177
  } else if (idOrHeight === "latest") {
4380
4178
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4381
4179
  } else {
@@ -4387,7 +4185,7 @@ var _Provider = class {
4387
4185
  }
4388
4186
  return {
4389
4187
  id: block.id,
4390
- height: bn16(block.height, 10),
4188
+ height: bn15(block.header.height, 10),
4391
4189
  time: block.header.time,
4392
4190
  transactionIds: block.transactions.map((tx) => tx.id),
4393
4191
  transactions: block.transactions.map(
@@ -4436,7 +4234,7 @@ var _Provider = class {
4436
4234
  contract: Address2.fromAddressOrString(contractId).toB256(),
4437
4235
  asset: hexlify12(assetId)
4438
4236
  });
4439
- return bn16(contractBalance.amount, 10);
4237
+ return bn15(contractBalance.amount, 10);
4440
4238
  }
4441
4239
  /**
4442
4240
  * Returns the balance for the given owner for the given asset ID.
@@ -4450,7 +4248,7 @@ var _Provider = class {
4450
4248
  owner: Address2.fromAddressOrString(owner).toB256(),
4451
4249
  assetId: hexlify12(assetId)
4452
4250
  });
4453
- return bn16(balance.amount, 10);
4251
+ return bn15(balance.amount, 10);
4454
4252
  }
4455
4253
  /**
4456
4254
  * Returns balances for the given owner.
@@ -4468,7 +4266,7 @@ var _Provider = class {
4468
4266
  const balances = result.balances.edges.map((edge) => edge.node);
4469
4267
  return balances.map((balance) => ({
4470
4268
  assetId: balance.assetId,
4471
- amount: bn16(balance.amount)
4269
+ amount: bn15(balance.amount)
4472
4270
  }));
4473
4271
  }
4474
4272
  /**
@@ -4490,15 +4288,15 @@ var _Provider = class {
4490
4288
  sender: message.sender,
4491
4289
  recipient: message.recipient,
4492
4290
  nonce: message.nonce,
4493
- amount: bn16(message.amount),
4291
+ amount: bn15(message.amount),
4494
4292
  data: message.data
4495
4293
  }),
4496
4294
  sender: Address2.fromAddressOrString(message.sender),
4497
4295
  recipient: Address2.fromAddressOrString(message.recipient),
4498
4296
  nonce: message.nonce,
4499
- amount: bn16(message.amount),
4297
+ amount: bn15(message.amount),
4500
4298
  data: InputMessageCoder.decodeData(message.data),
4501
- daHeight: bn16(message.daHeight)
4299
+ daHeight: bn15(message.daHeight)
4502
4300
  }));
4503
4301
  }
4504
4302
  /**
@@ -4551,60 +4349,44 @@ var _Provider = class {
4551
4349
  } = result.messageProof;
4552
4350
  return {
4553
4351
  messageProof: {
4554
- proofIndex: bn16(messageProof.proofIndex),
4352
+ proofIndex: bn15(messageProof.proofIndex),
4555
4353
  proofSet: messageProof.proofSet
4556
4354
  },
4557
4355
  blockProof: {
4558
- proofIndex: bn16(blockProof.proofIndex),
4356
+ proofIndex: bn15(blockProof.proofIndex),
4559
4357
  proofSet: blockProof.proofSet
4560
4358
  },
4561
4359
  messageBlockHeader: {
4562
4360
  id: messageBlockHeader.id,
4563
- daHeight: bn16(messageBlockHeader.daHeight),
4564
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4361
+ daHeight: bn15(messageBlockHeader.daHeight),
4362
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4565
4363
  transactionsRoot: messageBlockHeader.transactionsRoot,
4566
- height: bn16(messageBlockHeader.height),
4364
+ height: bn15(messageBlockHeader.height),
4567
4365
  prevRoot: messageBlockHeader.prevRoot,
4568
4366
  time: messageBlockHeader.time,
4569
4367
  applicationHash: messageBlockHeader.applicationHash,
4570
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4571
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4572
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4573
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4574
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4368
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4369
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4575
4370
  },
4576
4371
  commitBlockHeader: {
4577
4372
  id: commitBlockHeader.id,
4578
- daHeight: bn16(commitBlockHeader.daHeight),
4579
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4373
+ daHeight: bn15(commitBlockHeader.daHeight),
4374
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4580
4375
  transactionsRoot: commitBlockHeader.transactionsRoot,
4581
- height: bn16(commitBlockHeader.height),
4376
+ height: bn15(commitBlockHeader.height),
4582
4377
  prevRoot: commitBlockHeader.prevRoot,
4583
4378
  time: commitBlockHeader.time,
4584
4379
  applicationHash: commitBlockHeader.applicationHash,
4585
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4586
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4587
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4588
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4589
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4380
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4381
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4590
4382
  },
4591
4383
  sender: Address2.fromAddressOrString(sender),
4592
4384
  recipient: Address2.fromAddressOrString(recipient),
4593
4385
  nonce,
4594
- amount: bn16(amount),
4386
+ amount: bn15(amount),
4595
4387
  data
4596
4388
  };
4597
4389
  }
4598
- async getLatestGasPrice() {
4599
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4600
- return bn16(latestGasPrice.gasPrice);
4601
- }
4602
- async estimateGasPrice(blockHorizon) {
4603
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4604
- blockHorizon: String(blockHorizon)
4605
- });
4606
- return bn16(estimateGasPrice.gasPrice);
4607
- }
4608
4390
  /**
4609
4391
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4610
4392
  *
@@ -4624,10 +4406,10 @@ var _Provider = class {
4624
4406
  */
4625
4407
  async produceBlocks(amount, startTime) {
4626
4408
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4627
- blocksToProduce: bn16(amount).toString(10),
4409
+ blocksToProduce: bn15(amount).toString(10),
4628
4410
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4629
4411
  });
4630
- return bn16(latestBlockHeight);
4412
+ return bn15(latestBlockHeight);
4631
4413
  }
4632
4414
  // eslint-disable-next-line @typescript-eslint/require-await
4633
4415
  async getTransactionResponse(transactionId) {
@@ -4641,7 +4423,7 @@ cacheInputs_fn = function(inputs) {
4641
4423
  return;
4642
4424
  }
4643
4425
  inputs.forEach((input) => {
4644
- if (input.type === InputType7.Coin) {
4426
+ if (input.type === InputType6.Coin) {
4645
4427
  this.cache?.set(input.id);
4646
4428
  }
4647
4429
  });
@@ -4651,7 +4433,7 @@ __publicField(Provider, "nodeInfoCache", {});
4651
4433
 
4652
4434
  // src/providers/transaction-summary/get-transaction-summary.ts
4653
4435
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4654
- import { bn as bn17 } from "@fuel-ts/math";
4436
+ import { bn as bn16 } from "@fuel-ts/math";
4655
4437
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4656
4438
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4657
4439
 
@@ -4859,8 +4641,9 @@ var Account = class extends AbstractAccount {
4859
4641
  * @param assetId - The asset ID to check the balance for.
4860
4642
  * @returns A promise that resolves to the balance amount.
4861
4643
  */
4862
- async getBalance(assetId = BaseAssetId3) {
4863
- const amount = await this.provider.getBalance(this.address, assetId);
4644
+ async getBalance(assetId) {
4645
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4646
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4864
4647
  return amount;
4865
4648
  }
4866
4649
  /**
@@ -4897,33 +4680,37 @@ var Account = class extends AbstractAccount {
4897
4680
  * @param fee - The estimated transaction fee.
4898
4681
  * @returns A promise that resolves when the resources are added to the transaction.
4899
4682
  */
4900
- async fund(request, params) {
4901
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4902
- const txRequest = request;
4903
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4904
- amount: bn18(fee),
4905
- assetId: BaseAssetId3,
4906
- coinQuantities: requiredQuantities
4683
+ async fund(request, coinQuantities, fee) {
4684
+ const baseAssetId = this.provider.getBaseAssetId();
4685
+ const updatedQuantities = addAmountToAsset({
4686
+ amount: bn17(fee),
4687
+ assetId: baseAssetId,
4688
+ coinQuantities
4907
4689
  });
4908
4690
  const quantitiesDict = {};
4909
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4691
+ updatedQuantities.forEach(({ amount, assetId }) => {
4910
4692
  quantitiesDict[assetId] = {
4911
4693
  required: amount,
4912
- owned: bn18(0)
4694
+ owned: bn17(0)
4913
4695
  };
4914
4696
  });
4915
- txRequest.inputs.forEach((input) => {
4697
+ const cachedUtxos = [];
4698
+ const cachedMessages = [];
4699
+ const owner = this.address.toB256();
4700
+ request.inputs.forEach((input) => {
4916
4701
  const isResource = "amount" in input;
4917
4702
  if (isResource) {
4918
4703
  const isCoin2 = "owner" in input;
4919
4704
  if (isCoin2) {
4920
4705
  const assetId = String(input.assetId);
4921
- if (quantitiesDict[assetId]) {
4922
- const amount = bn18(input.amount);
4706
+ if (input.owner === owner && quantitiesDict[assetId]) {
4707
+ const amount = bn17(input.amount);
4923
4708
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4709
+ cachedUtxos.push(input.id);
4924
4710
  }
4925
- } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4926
- quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4711
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4712
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4713
+ cachedMessages.push(input.nonce);
4927
4714
  }
4928
4715
  }
4929
4716
  });
@@ -4938,23 +4725,12 @@ var Account = class extends AbstractAccount {
4938
4725
  });
4939
4726
  const needsToBeFunded = missingQuantities.length;
4940
4727
  if (needsToBeFunded) {
4941
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4942
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4943
- txRequest.addResources(resources);
4944
- }
4945
- txRequest.shiftPredicateData();
4946
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4947
- const requestToBeReEstimate = clone4(txRequest);
4948
- if (addedSignatures) {
4949
- Array.from({ length: addedSignatures }).forEach(
4950
- () => requestToBeReEstimate.addEmptyWitness()
4951
- );
4728
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4729
+ messages: cachedMessages,
4730
+ utxos: cachedUtxos
4731
+ });
4732
+ request.addResources(resources);
4952
4733
  }
4953
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4954
- transactionRequest: requestToBeReEstimate
4955
- });
4956
- txRequest.maxFee = maxFee;
4957
- return txRequest;
4958
4734
  }
4959
4735
  /**
4960
4736
  * A helper that creates a transfer transaction request and returns it.
@@ -4962,25 +4738,30 @@ var Account = class extends AbstractAccount {
4962
4738
  * @param destination - The address of the destination.
4963
4739
  * @param amount - The amount of coins to transfer.
4964
4740
  * @param assetId - The asset ID of the coins to transfer.
4965
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4741
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4966
4742
  * @returns A promise that resolves to the prepared transaction request.
4967
4743
  */
4968
- async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4969
- const request = new ScriptTransactionRequest(txParams);
4970
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4971
- const txCost = await this.provider.getTransactionCost(request, {
4744
+ async createTransfer(destination, amount, assetId, txParams = {}) {
4745
+ const { minGasPrice } = this.provider.getGasConfig();
4746
+ const baseAssetId = this.provider.getBaseAssetId();
4747
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4748
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
4749
+ const request = new ScriptTransactionRequest(params);
4750
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
4751
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4972
4752
  estimateTxDependencies: true,
4973
4753
  resourcesOwner: this
4974
4754
  });
4975
- if ("gasLimit" in txParams) {
4976
- this.validateGas({
4977
- gasUsed: txCost.gasUsed,
4978
- gasLimit: request.gasLimit
4979
- });
4980
- }
4981
- request.gasLimit = txCost.gasUsed;
4982
- request.maxFee = txCost.maxFee;
4983
- await this.fund(request, txCost);
4755
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4756
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4757
+ this.validateGas({
4758
+ gasUsed,
4759
+ gasPrice: request.gasPrice,
4760
+ gasLimit: request.gasLimit,
4761
+ minGasPrice
4762
+ });
4763
+ await this.fund(request, requiredQuantities, maxFee);
4764
+ request.updatePredicateInputs(estimatedInputs);
4984
4765
  return request;
4985
4766
  }
4986
4767
  /**
@@ -4992,14 +4773,15 @@ var Account = class extends AbstractAccount {
4992
4773
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4993
4774
  * @returns A promise that resolves to the transaction response.
4994
4775
  */
4995
- async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4996
- if (bn18(amount).lte(0)) {
4776
+ async transfer(destination, amount, assetId, txParams = {}) {
4777
+ if (bn17(amount).lte(0)) {
4997
4778
  throw new FuelError15(
4998
4779
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4999
4780
  "Transfer amount must be a positive number."
5000
4781
  );
5001
4782
  }
5002
- const request = await this.createTransfer(destination, amount, assetId, txParams);
4783
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4784
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5003
4785
  return this.sendTransaction(request, { estimateTxDependencies: false });
5004
4786
  }
5005
4787
  /**
@@ -5011,38 +4793,41 @@ var Account = class extends AbstractAccount {
5011
4793
  * @param txParams - The optional transaction parameters.
5012
4794
  * @returns A promise that resolves to the transaction response.
5013
4795
  */
5014
- async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5015
- if (bn18(amount).lte(0)) {
4796
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
4797
+ if (bn17(amount).lte(0)) {
5016
4798
  throw new FuelError15(
5017
4799
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5018
4800
  "Transfer amount must be a positive number."
5019
4801
  );
5020
4802
  }
5021
4803
  const contractAddress = Address3.fromAddressOrString(contractId);
4804
+ const { minGasPrice } = this.provider.getGasConfig();
4805
+ const baseAssetId = this.provider.getBaseAssetId();
4806
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4807
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5022
4808
  const { script, scriptData } = await assembleTransferToContractScript({
5023
4809
  hexlifiedContractId: contractAddress.toB256(),
5024
- amountToTransfer: bn18(amount),
5025
- assetId
4810
+ amountToTransfer: bn17(amount),
4811
+ assetId: assetIdToTransfer
5026
4812
  });
5027
4813
  const request = new ScriptTransactionRequest({
5028
- ...txParams,
4814
+ ...params,
5029
4815
  script,
5030
4816
  scriptData
5031
4817
  });
5032
4818
  request.addContractInputAndOutput(contractAddress);
5033
- const txCost = await this.provider.getTransactionCost(request, {
5034
- resourcesOwner: this,
5035
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
4819
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4820
+ request,
4821
+ [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
4822
+ );
4823
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4824
+ this.validateGas({
4825
+ gasUsed,
4826
+ gasPrice: request.gasPrice,
4827
+ gasLimit: request.gasLimit,
4828
+ minGasPrice
5036
4829
  });
5037
- if (txParams.gasLimit) {
5038
- this.validateGas({
5039
- gasUsed: txCost.gasUsed,
5040
- gasLimit: request.gasLimit
5041
- });
5042
- }
5043
- request.gasLimit = txCost.gasUsed;
5044
- request.maxFee = txCost.maxFee;
5045
- await this.fund(request, txCost);
4830
+ await this.fund(request, requiredQuantities, maxFee);
5046
4831
  return this.sendTransaction(request);
5047
4832
  }
5048
4833
  /**
@@ -5054,31 +4839,40 @@ var Account = class extends AbstractAccount {
5054
4839
  * @returns A promise that resolves to the transaction response.
5055
4840
  */
5056
4841
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4842
+ const { minGasPrice } = this.provider.getGasConfig();
4843
+ const baseAssetId = this.provider.getBaseAssetId();
5057
4844
  const recipientAddress = Address3.fromAddressOrString(recipient);
5058
4845
  const recipientDataArray = arrayify14(
5059
4846
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5060
4847
  );
5061
4848
  const amountDataArray = arrayify14(
5062
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
4849
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5063
4850
  );
5064
4851
  const script = new Uint8Array([
5065
4852
  ...arrayify14(withdrawScript.bytes),
5066
4853
  ...recipientDataArray,
5067
4854
  ...amountDataArray
5068
4855
  ]);
5069
- const params = { script, ...txParams };
4856
+ const params = {
4857
+ script,
4858
+ gasPrice: minGasPrice,
4859
+ baseAssetId,
4860
+ ...txParams
4861
+ };
5070
4862
  const request = new ScriptTransactionRequest(params);
5071
- const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5072
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5073
- if (txParams.gasLimit) {
5074
- this.validateGas({
5075
- gasUsed: txCost.gasUsed,
5076
- gasLimit: request.gasLimit
5077
- });
5078
- }
5079
- request.maxFee = txCost.maxFee;
5080
- request.gasLimit = txCost.gasUsed;
5081
- await this.fund(request, txCost);
4863
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
4864
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4865
+ request,
4866
+ forwardingQuantities
4867
+ );
4868
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4869
+ this.validateGas({
4870
+ gasUsed,
4871
+ gasPrice: request.gasPrice,
4872
+ gasLimit: request.gasLimit,
4873
+ minGasPrice
4874
+ });
4875
+ await this.fund(request, requiredQuantities, maxFee);
5082
4876
  return this.sendTransaction(request);
5083
4877
  }
5084
4878
  async signMessage(message) {
@@ -5136,7 +4930,18 @@ var Account = class extends AbstractAccount {
5136
4930
  }
5137
4931
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5138
4932
  }
5139
- validateGas({ gasUsed, gasLimit }) {
4933
+ validateGas({
4934
+ gasUsed,
4935
+ gasPrice,
4936
+ gasLimit,
4937
+ minGasPrice
4938
+ }) {
4939
+ if (minGasPrice.gt(gasPrice)) {
4940
+ throw new FuelError15(
4941
+ ErrorCode15.GAS_PRICE_TOO_LOW,
4942
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4943
+ );
4944
+ }
5140
4945
  if (gasUsed.gt(gasLimit)) {
5141
4946
  throw new FuelError15(
5142
4947
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -5428,7 +5233,7 @@ var BaseWalletUnlocked = class extends Account {
5428
5233
  * @param transactionRequestLike - The transaction request to send.
5429
5234
  * @returns A promise that resolves to the TransactionResponse object.
5430
5235
  */
5431
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5236
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5432
5237
  const transactionRequest = transactionRequestify(transactionRequestLike);
5433
5238
  if (estimateTxDependencies) {
5434
5239
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5469,7 +5274,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5469
5274
  // src/hdwallet/hdwallet.ts
5470
5275
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5471
5276
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5472
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5277
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5473
5278
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5474
5279
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5475
5280
 
@@ -7935,7 +7740,7 @@ var HDWallet = class {
7935
7740
  const IR = bytes.slice(32);
7936
7741
  if (privateKey) {
7937
7742
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7938
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
7743
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7939
7744
  return new HDWallet({
7940
7745
  privateKey: ki,
7941
7746
  chainCode: IR,
@@ -8206,15 +8011,16 @@ var seedTestWallet = async (wallet, quantities) => {
8206
8011
  process.env.GENESIS_SECRET || randomBytes5(32),
8207
8012
  wallet.provider
8208
8013
  );
8209
- const request = new ScriptTransactionRequest();
8210
- quantities.forEach((quantity) => {
8211
- const { amount, assetId } = coinQuantityfy(quantity);
8212
- request.addCoinOutput(wallet.address, amount, assetId);
8014
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
8015
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
8016
+ const baseAssetId = genesisWallet.provider.getBaseAssetId();
8017
+ const request = new ScriptTransactionRequest({
8018
+ baseAssetId,
8019
+ gasLimit: 1e4,
8020
+ gasPrice: minGasPrice
8213
8021
  });
8214
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8215
- request.gasLimit = txCost.gasUsed;
8216
- request.maxFee = txCost.maxFee;
8217
- await genesisWallet.fund(request, txCost);
8022
+ request.addResources(resources);
8023
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8218
8024
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8219
8025
  };
8220
8026
 
@@ -8228,12 +8034,12 @@ var generateTestWallet = async (provider, quantities) => {
8228
8034
  };
8229
8035
 
8230
8036
  // src/test-utils/launchNode.ts
8231
- import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8232
- import { defaultChainConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8037
+ import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
8038
+ import { toHex as toHex2 } from "@fuel-ts/math";
8039
+ import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8233
8040
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
8234
8041
  import { spawn } from "child_process";
8235
8042
  import { randomUUID } from "crypto";
8236
- import { randomBytes as randomBytes6 } from "ethers";
8237
8043
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
8238
8044
  import os from "os";
8239
8045
  import path from "path";
@@ -8282,12 +8088,12 @@ var launchNode = async ({
8282
8088
  // eslint-disable-next-line no-async-promise-executor
8283
8089
  new Promise(async (resolve, reject) => {
8284
8090
  const remainingArgs = extractRemainingArgs(args, [
8285
- "--snapshot",
8091
+ "--chain",
8286
8092
  "--consensus-key",
8287
8093
  "--db-type",
8288
8094
  "--poa-instant"
8289
8095
  ]);
8290
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8096
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8291
8097
  const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
8292
8098
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8293
8099
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
@@ -8306,54 +8112,36 @@ var launchNode = async ({
8306
8112
  let chainConfigPathToUse;
8307
8113
  const prefix = basePath || os.tmpdir();
8308
8114
  const suffix = basePath ? "" : randomUUID();
8309
- const tempDirPath = path.join(prefix, ".fuels", suffix, "chainConfigs");
8115
+ const tempDirPath = path.join(prefix, ".fuels", suffix);
8310
8116
  if (chainConfigPath) {
8311
8117
  chainConfigPathToUse = chainConfigPath;
8312
8118
  } else {
8313
8119
  if (!existsSync(tempDirPath)) {
8314
8120
  mkdirSync(tempDirPath, { recursive: true });
8315
8121
  }
8316
- let { stateConfigJson } = defaultChainConfigs;
8317
- const { chainConfigJson, metadataJson } = defaultChainConfigs;
8318
- stateConfigJson = {
8319
- ...stateConfigJson,
8320
- coins: [
8321
- ...stateConfigJson.coins.map((coin) => ({
8322
- ...coin,
8323
- amount: "18446744073709551615"
8324
- }))
8325
- ],
8326
- messages: stateConfigJson.messages.map((message) => ({
8327
- ...message,
8328
- amount: "18446744073709551615"
8329
- }))
8330
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8331
- };
8122
+ const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
8123
+ let chainConfig = defaultChainConfig;
8332
8124
  if (!process.env.GENESIS_SECRET) {
8333
8125
  const pk = Signer.generatePrivateKey();
8334
8126
  const signer = new Signer(pk);
8335
8127
  process.env.GENESIS_SECRET = hexlify18(pk);
8336
- stateConfigJson.coins.push({
8337
- tx_id: hexlify18(randomBytes6(34)),
8338
- owner: signer.address.toHexString(),
8339
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8340
- amount: "18446744073709551615",
8341
- asset_id: BaseAssetId4,
8342
- output_index: 0,
8343
- tx_pointer_block_height: 0,
8344
- tx_pointer_tx_idx: 0
8345
- });
8128
+ chainConfig = {
8129
+ ...defaultChainConfig,
8130
+ initial_state: {
8131
+ ...defaultChainConfig.initial_state,
8132
+ coins: [
8133
+ ...defaultChainConfig.initial_state.coins,
8134
+ {
8135
+ owner: signer.address.toHexString(),
8136
+ amount: toHex2(1e9),
8137
+ asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes329
8138
+ }
8139
+ ]
8140
+ }
8141
+ };
8346
8142
  }
8347
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8348
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8349
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8350
- const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8351
- const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8352
- const metadataWritePath = path.join(tempDirPath, "metadata.json");
8353
- writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8354
- writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8355
- writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8356
- chainConfigPathToUse = tempDirPath;
8143
+ writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8144
+ chainConfigPathToUse = tempChainConfigFilePath;
8357
8145
  }
8358
8146
  const child = spawn(
8359
8147
  command,
@@ -8362,10 +8150,10 @@ var launchNode = async ({
8362
8150
  ["--ip", ipToUse],
8363
8151
  ["--port", portToUse],
8364
8152
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8365
- ["--min-gas-price", "1"],
8153
+ ["--min-gas-price", "0"],
8366
8154
  poaInstant ? ["--poa-instant", "true"] : [],
8367
8155
  ["--consensus-key", consensusKey],
8368
- ["--snapshot", chainConfigPathToUse],
8156
+ ["--chain", chainConfigPathToUse],
8369
8157
  "--vm-backtrace",
8370
8158
  "--utxo-validation",
8371
8159
  "--debug",
@@ -8412,9 +8200,10 @@ var launchNode = async ({
8412
8200
  })
8413
8201
  );
8414
8202
  var generateWallets = async (count, provider) => {
8203
+ const baseAssetId = provider.getBaseAssetId();
8415
8204
  const wallets = [];
8416
8205
  for (let i = 0; i < count; i += 1) {
8417
- const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId4]]);
8206
+ const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8418
8207
  wallets.push(wallet);
8419
8208
  }
8420
8209
  return wallets;
@@ -8424,7 +8213,7 @@ var launchNodeAndGetWallets = async ({
8424
8213
  walletCount = 10
8425
8214
  } = {}) => {
8426
8215
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8427
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8216
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8428
8217
  const wallets = await generateWallets(walletCount, provider);
8429
8218
  const cleanup = () => {
8430
8219
  closeNode();