@fuel-ts/account 0.0.0-rc-1976-20240409134753 → 0.0.0-rc-2021-20240409151049

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

Potentially problematic release.


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

Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +5 -4
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +870 -617
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +850 -611
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +692 -454
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -2
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +888 -322
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +3 -3
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +4 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +3 -1
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +45 -34
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +9 -29
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +3 -0
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +8 -2
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1585 -1118
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +826 -608
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +684 -466
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
@@ -24,35 +24,38 @@ 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";
27
28
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
28
29
  import { AbstractAccount } from "@fuel-ts/interfaces";
29
- import { bn as bn17 } from "@fuel-ts/math";
30
+ import { bn as bn18 } from "@fuel-ts/math";
30
31
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
32
+ import { clone as clone4 } from "ramda";
31
33
 
32
34
  // src/providers/coin-quantity.ts
35
+ import { BaseAssetId } from "@fuel-ts/address/configs";
33
36
  import { bn } from "@fuel-ts/math";
34
37
  import { hexlify } from "@fuel-ts/utils";
35
38
  var coinQuantityfy = (coinQuantityLike) => {
36
39
  let assetId;
37
40
  let amount;
38
- let max2;
41
+ let max;
39
42
  if (Array.isArray(coinQuantityLike)) {
40
43
  amount = coinQuantityLike[0];
41
- assetId = coinQuantityLike[1];
42
- max2 = coinQuantityLike[2];
44
+ assetId = coinQuantityLike[1] ?? BaseAssetId;
45
+ max = coinQuantityLike[2] ?? void 0;
43
46
  } else {
44
47
  amount = coinQuantityLike.amount;
45
- assetId = coinQuantityLike.assetId;
46
- max2 = coinQuantityLike.max ?? void 0;
48
+ assetId = coinQuantityLike.assetId ?? BaseAssetId;
49
+ max = coinQuantityLike.max ?? void 0;
47
50
  }
48
51
  const bnAmount = bn(amount);
49
52
  return {
50
53
  assetId: hexlify(assetId),
51
54
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
52
- max: max2 ? bn(max2) : void 0
55
+ max: max ? bn(max) : void 0
53
56
  };
54
57
  };
55
- var addAmountToAsset = (params) => {
58
+ var addAmountToCoinQuantities = (params) => {
56
59
  const { amount, assetId } = params;
57
60
  const coinQuantities = [...params.coinQuantities];
58
61
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -67,9 +70,9 @@ var addAmountToAsset = (params) => {
67
70
  // src/providers/provider.ts
68
71
  import { Address as Address2 } from "@fuel-ts/address";
69
72
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
70
- import { BN, bn as bn15, max } from "@fuel-ts/math";
73
+ import { BN, bn as bn16 } from "@fuel-ts/math";
71
74
  import {
72
- InputType as InputType6,
75
+ InputType as InputType7,
73
76
  TransactionType as TransactionType8,
74
77
  InputMessageCoder,
75
78
  TransactionCoder as TransactionCoder5
@@ -85,14 +88,10 @@ import { clone as clone3 } from "ramda";
85
88
  import gql from "graphql-tag";
86
89
  var ReceiptFragmentFragmentDoc = gql`
87
90
  fragment receiptFragment on Receipt {
88
- contract {
89
- id
90
- }
91
+ id
91
92
  pc
92
93
  is
93
- to {
94
- id
95
- }
94
+ to
96
95
  toAddress
97
96
  amount
98
97
  assetId
@@ -130,10 +129,16 @@ var TransactionStatusFragmentFragmentDoc = gql`
130
129
  id
131
130
  }
132
131
  time
132
+ receipts {
133
+ ...receiptFragment
134
+ }
133
135
  programState {
134
136
  returnType
135
137
  data
136
138
  }
139
+ receipts {
140
+ ...receiptFragment
141
+ }
137
142
  }
138
143
  ... on FailureStatus {
139
144
  block {
@@ -141,26 +146,24 @@ var TransactionStatusFragmentFragmentDoc = gql`
141
146
  }
142
147
  time
143
148
  reason
149
+ receipts {
150
+ ...receiptFragment
151
+ }
144
152
  }
145
153
  ... on SqueezedOutStatus {
146
154
  reason
147
155
  }
148
156
  }
149
- `;
157
+ ${ReceiptFragmentFragmentDoc}`;
150
158
  var TransactionFragmentFragmentDoc = gql`
151
159
  fragment transactionFragment on Transaction {
152
160
  id
153
161
  rawPayload
154
- gasPrice
155
- receipts {
156
- ...receiptFragment
157
- }
158
162
  status {
159
163
  ...transactionStatusFragment
160
164
  }
161
165
  }
162
- ${ReceiptFragmentFragmentDoc}
163
- ${TransactionStatusFragmentFragmentDoc}`;
166
+ ${TransactionStatusFragmentFragmentDoc}`;
164
167
  var InputEstimatePredicatesFragmentFragmentDoc = gql`
165
168
  fragment inputEstimatePredicatesFragment on Input {
166
169
  ... on InputCoin {
@@ -178,6 +181,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
178
181
  }
179
182
  }
180
183
  ${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}`;
181
224
  var CoinFragmentFragmentDoc = gql`
182
225
  fragment coinFragment on Coin {
183
226
  __typename
@@ -185,7 +228,6 @@ var CoinFragmentFragmentDoc = gql`
185
228
  owner
186
229
  amount
187
230
  assetId
188
- maturity
189
231
  blockCreated
190
232
  txCreatedIdx
191
233
  }
@@ -230,7 +272,6 @@ var MessageProofFragmentFragmentDoc = gql`
230
272
  prevRoot
231
273
  time
232
274
  applicationHash
233
- messageReceiptRoot
234
275
  messageReceiptCount
235
276
  }
236
277
  commitBlockHeader {
@@ -242,7 +283,6 @@ var MessageProofFragmentFragmentDoc = gql`
242
283
  prevRoot
243
284
  time
244
285
  applicationHash
245
- messageReceiptRoot
246
286
  messageReceiptCount
247
287
  }
248
288
  sender
@@ -262,8 +302,8 @@ var BalanceFragmentFragmentDoc = gql`
262
302
  var BlockFragmentFragmentDoc = gql`
263
303
  fragment blockFragment on Block {
264
304
  id
305
+ height
265
306
  header {
266
- height
267
307
  time
268
308
  }
269
309
  transactions {
@@ -321,6 +361,11 @@ var DependentCostFragmentFragmentDoc = gql`
321
361
  `;
322
362
  var GasCostsFragmentFragmentDoc = gql`
323
363
  fragment GasCostsFragment on GasCosts {
364
+ version {
365
+ ... on Version {
366
+ value
367
+ }
368
+ }
324
369
  add
325
370
  addi
326
371
  aloc
@@ -333,7 +378,6 @@ var GasCostsFragmentFragmentDoc = gql`
333
378
  cb
334
379
  cfei
335
380
  cfsi
336
- croo
337
381
  div
338
382
  divi
339
383
  ecr1
@@ -416,6 +460,9 @@ var GasCostsFragmentFragmentDoc = gql`
416
460
  ccp {
417
461
  ...DependentCostFragment
418
462
  }
463
+ croo {
464
+ ...DependentCostFragment
465
+ }
419
466
  csiz {
420
467
  ...DependentCostFragment
421
468
  }
@@ -475,6 +522,11 @@ var GasCostsFragmentFragmentDoc = gql`
475
522
  ${DependentCostFragmentFragmentDoc}`;
476
523
  var ConsensusParametersFragmentFragmentDoc = gql`
477
524
  fragment consensusParametersFragment on ConsensusParameters {
525
+ version {
526
+ ... on Version {
527
+ value
528
+ }
529
+ }
478
530
  txParams {
479
531
  ...TxParametersFragment
480
532
  }
@@ -534,18 +586,9 @@ var NodeInfoFragmentFragmentDoc = gql`
534
586
  fragment nodeInfoFragment on NodeInfo {
535
587
  utxoValidation
536
588
  vmBacktrace
537
- minGasPrice
538
589
  maxTx
539
590
  maxDepth
540
591
  nodeVersion
541
- peers {
542
- id
543
- addresses
544
- clientVersion
545
- blockHeight
546
- lastHeartbeatMs
547
- appScore
548
- }
549
592
  }
550
593
  `;
551
594
  var GetVersionDocument = gql`
@@ -580,13 +623,9 @@ var GetTransactionWithReceiptsDocument = gql`
580
623
  query getTransactionWithReceipts($transactionId: TransactionId!) {
581
624
  transaction(id: $transactionId) {
582
625
  ...transactionFragment
583
- receipts {
584
- ...receiptFragment
585
- }
586
626
  }
587
627
  }
588
- ${TransactionFragmentFragmentDoc}
589
- ${ReceiptFragmentFragmentDoc}`;
628
+ ${TransactionFragmentFragmentDoc}`;
590
629
  var GetTransactionsDocument = gql`
591
630
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
592
631
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -714,6 +753,20 @@ var GetBalanceDocument = gql`
714
753
  }
715
754
  }
716
755
  ${BalanceFragmentFragmentDoc}`;
756
+ var GetLatestGasPriceDocument = gql`
757
+ query getLatestGasPrice {
758
+ latestGasPrice {
759
+ gasPrice
760
+ }
761
+ }
762
+ `;
763
+ var EstimateGasPriceDocument = gql`
764
+ query estimateGasPrice($blockHorizon: U32!) {
765
+ estimateGasPrice(blockHorizon: $blockHorizon) {
766
+ gasPrice
767
+ }
768
+ }
769
+ `;
717
770
  var GetBalancesDocument = gql`
718
771
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
719
772
  balances(
@@ -768,12 +821,12 @@ var GetMessageStatusDocument = gql`
768
821
  }
769
822
  `;
770
823
  var DryRunDocument = gql`
771
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
772
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
773
- ...receiptFragment
824
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
825
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
826
+ ...dryRunTransactionExecutionStatusFragment
774
827
  }
775
828
  }
776
- ${ReceiptFragmentFragmentDoc}`;
829
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
777
830
  var SubmitDocument = gql`
778
831
  mutation submit($encodedTransaction: HexString!) {
779
832
  submit(tx: $encodedTransaction) {
@@ -856,6 +909,12 @@ function getSdk(requester) {
856
909
  getBalance(variables, options) {
857
910
  return requester(GetBalanceDocument, variables, options);
858
911
  },
912
+ getLatestGasPrice(variables, options) {
913
+ return requester(GetLatestGasPriceDocument, variables, options);
914
+ },
915
+ estimateGasPrice(variables, options) {
916
+ return requester(EstimateGasPriceDocument, variables, options);
917
+ },
859
918
  getBalances(variables, options) {
860
919
  return requester(GetBalancesDocument, variables, options);
861
920
  },
@@ -925,11 +984,14 @@ var _FuelGraphqlSubscriber = class {
925
984
  let data;
926
985
  let errors;
927
986
  try {
928
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
987
+ const sanitizedText = text.replace(/\s/g, "");
988
+ ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
929
989
  } catch (e) {
930
990
  throw new FuelError(
931
991
  ErrorCode.STREAM_PARSING_ERROR,
932
- `Error while parsing stream data response: ${text}`
992
+ `Error while parsing stream data response: ${text}
993
+
994
+ Thrown error: ${e}`
933
995
  );
934
996
  }
935
997
  if (Array.isArray(errors)) {
@@ -1030,7 +1092,7 @@ var inputify = (value) => {
1030
1092
  return {
1031
1093
  type: InputType.Coin,
1032
1094
  txID: hexlify3(arrayify(value.id).slice(0, 32)),
1033
- outputIndex: arrayify(value.id)[32],
1095
+ outputIndex: toNumber(arrayify(value.id).slice(32, 34)),
1034
1096
  owner: hexlify3(value.owner),
1035
1097
  amount: bn2(value.amount),
1036
1098
  assetId: hexlify3(value.assetId),
@@ -1039,10 +1101,9 @@ var inputify = (value) => {
1039
1101
  txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1040
1102
  },
1041
1103
  witnessIndex: value.witnessIndex,
1042
- maturity: value.maturity ?? 0,
1043
1104
  predicateGasUsed: bn2(value.predicateGasUsed),
1044
- predicateLength: predicate.length,
1045
- predicateDataLength: predicateData.length,
1105
+ predicateLength: bn2(predicate.length),
1106
+ predicateDataLength: bn2(predicateData.length),
1046
1107
  predicate: hexlify3(predicate),
1047
1108
  predicateData: hexlify3(predicateData)
1048
1109
  };
@@ -1073,8 +1134,8 @@ var inputify = (value) => {
1073
1134
  nonce: hexlify3(value.nonce),
1074
1135
  witnessIndex: value.witnessIndex,
1075
1136
  predicateGasUsed: bn2(value.predicateGasUsed),
1076
- predicateLength: predicate.length,
1077
- predicateDataLength: predicateData.length,
1137
+ predicateLength: bn2(predicate.length),
1138
+ predicateDataLength: bn2(predicateData.length),
1078
1139
  predicate: hexlify3(predicate),
1079
1140
  predicateData: hexlify3(predicateData),
1080
1141
  data: hexlify3(data),
@@ -1149,7 +1210,7 @@ var outputify = (value) => {
1149
1210
 
1150
1211
  // src/providers/transaction-request/transaction-request.ts
1151
1212
  import { Address, addressify } from "@fuel-ts/address";
1152
- import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1213
+ import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1153
1214
  import { bn as bn7 } from "@fuel-ts/math";
1154
1215
  import {
1155
1216
  PolicyType,
@@ -1159,6 +1220,7 @@ import {
1159
1220
  TransactionType
1160
1221
  } from "@fuel-ts/transactions";
1161
1222
  import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1223
+ import { randomBytes } from "ethers";
1162
1224
 
1163
1225
  // src/providers/resource.ts
1164
1226
  var isCoin = (resource) => "id" in resource;
@@ -1199,8 +1261,8 @@ function assembleReceiptByType(receipt) {
1199
1261
  case "CALL" /* Call */: {
1200
1262
  const callReceipt = {
1201
1263
  type: ReceiptType.Call,
1202
- from: hexOrZero(receipt.contract?.id),
1203
- to: hexOrZero(receipt?.to?.id),
1264
+ from: hexOrZero(receipt.id || receipt.contractId),
1265
+ to: hexOrZero(receipt?.to),
1204
1266
  amount: bn4(receipt.amount),
1205
1267
  assetId: hexOrZero(receipt.assetId),
1206
1268
  gas: bn4(receipt.gas),
@@ -1214,7 +1276,7 @@ function assembleReceiptByType(receipt) {
1214
1276
  case "RETURN" /* Return */: {
1215
1277
  const returnReceipt = {
1216
1278
  type: ReceiptType.Return,
1217
- id: hexOrZero(receipt.contract?.id),
1279
+ id: hexOrZero(receipt.id || receipt.contractId),
1218
1280
  val: bn4(receipt.val),
1219
1281
  pc: bn4(receipt.pc),
1220
1282
  is: bn4(receipt.is)
@@ -1224,7 +1286,7 @@ function assembleReceiptByType(receipt) {
1224
1286
  case "RETURN_DATA" /* ReturnData */: {
1225
1287
  const returnDataReceipt = {
1226
1288
  type: ReceiptType.ReturnData,
1227
- id: hexOrZero(receipt.contract?.id),
1289
+ id: hexOrZero(receipt.id || receipt.contractId),
1228
1290
  ptr: bn4(receipt.ptr),
1229
1291
  len: bn4(receipt.len),
1230
1292
  digest: hexOrZero(receipt.digest),
@@ -1236,7 +1298,7 @@ function assembleReceiptByType(receipt) {
1236
1298
  case "PANIC" /* Panic */: {
1237
1299
  const panicReceipt = {
1238
1300
  type: ReceiptType.Panic,
1239
- id: hexOrZero(receipt.contract?.id),
1301
+ id: hexOrZero(receipt.id),
1240
1302
  reason: bn4(receipt.reason),
1241
1303
  pc: bn4(receipt.pc),
1242
1304
  is: bn4(receipt.is),
@@ -1247,7 +1309,7 @@ function assembleReceiptByType(receipt) {
1247
1309
  case "REVERT" /* Revert */: {
1248
1310
  const revertReceipt = {
1249
1311
  type: ReceiptType.Revert,
1250
- id: hexOrZero(receipt.contract?.id),
1312
+ id: hexOrZero(receipt.id || receipt.contractId),
1251
1313
  val: bn4(receipt.ra),
1252
1314
  pc: bn4(receipt.pc),
1253
1315
  is: bn4(receipt.is)
@@ -1257,7 +1319,7 @@ function assembleReceiptByType(receipt) {
1257
1319
  case "LOG" /* Log */: {
1258
1320
  const logReceipt = {
1259
1321
  type: ReceiptType.Log,
1260
- id: hexOrZero(receipt.contract?.id),
1322
+ id: hexOrZero(receipt.id || receipt.contractId),
1261
1323
  val0: bn4(receipt.ra),
1262
1324
  val1: bn4(receipt.rb),
1263
1325
  val2: bn4(receipt.rc),
@@ -1270,7 +1332,7 @@ function assembleReceiptByType(receipt) {
1270
1332
  case "LOG_DATA" /* LogData */: {
1271
1333
  const logDataReceipt = {
1272
1334
  type: ReceiptType.LogData,
1273
- id: hexOrZero(receipt.contract?.id),
1335
+ id: hexOrZero(receipt.id || receipt.contractId),
1274
1336
  val0: bn4(receipt.ra),
1275
1337
  val1: bn4(receipt.rb),
1276
1338
  ptr: bn4(receipt.ptr),
@@ -1284,8 +1346,8 @@ function assembleReceiptByType(receipt) {
1284
1346
  case "TRANSFER" /* Transfer */: {
1285
1347
  const transferReceipt = {
1286
1348
  type: ReceiptType.Transfer,
1287
- from: hexOrZero(receipt.contract?.id),
1288
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1349
+ from: hexOrZero(receipt.id || receipt.contractId),
1350
+ to: hexOrZero(receipt.toAddress || receipt?.to),
1289
1351
  amount: bn4(receipt.amount),
1290
1352
  assetId: hexOrZero(receipt.assetId),
1291
1353
  pc: bn4(receipt.pc),
@@ -1296,8 +1358,8 @@ function assembleReceiptByType(receipt) {
1296
1358
  case "TRANSFER_OUT" /* TransferOut */: {
1297
1359
  const transferOutReceipt = {
1298
1360
  type: ReceiptType.TransferOut,
1299
- from: hexOrZero(receipt.contract?.id),
1300
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
1361
+ from: hexOrZero(receipt.id || receipt.contractId),
1362
+ to: hexOrZero(receipt.toAddress || receipt.to),
1301
1363
  amount: bn4(receipt.amount),
1302
1364
  assetId: hexOrZero(receipt.assetId),
1303
1365
  pc: bn4(receipt.pc),
@@ -1340,7 +1402,7 @@ function assembleReceiptByType(receipt) {
1340
1402
  return receiptMessageOut;
1341
1403
  }
1342
1404
  case "MINT" /* Mint */: {
1343
- const contractId = hexOrZero(receipt.contract?.id);
1405
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1344
1406
  const subId = hexOrZero(receipt.subId);
1345
1407
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1346
1408
  const mintReceipt = {
@@ -1355,7 +1417,7 @@ function assembleReceiptByType(receipt) {
1355
1417
  return mintReceipt;
1356
1418
  }
1357
1419
  case "BURN" /* Burn */: {
1358
- const contractId = hexOrZero(receipt.contract?.id);
1420
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1359
1421
  const subId = hexOrZero(receipt.subId);
1360
1422
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1361
1423
  const burnReceipt = {
@@ -1381,7 +1443,6 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
1381
1443
  import { bn as bn5 } from "@fuel-ts/math";
1382
1444
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1383
1445
  import { arrayify as arrayify3 } from "@fuel-ts/utils";
1384
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1385
1446
  var getGasUsedFromReceipts = (receipts) => {
1386
1447
  const scriptResult = receipts.filter(
1387
1448
  (receipt) => receipt.type === ReceiptType2.ScriptResult
@@ -1402,18 +1463,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1402
1463
  }
1403
1464
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1404
1465
  const witnessCache = [];
1405
- const totalGas = inputs.reduce((total, input) => {
1466
+ const chargeableInputs = inputs.filter((input) => {
1467
+ const isCoinOrMessage = "owner" in input || "sender" in input;
1468
+ if (isCoinOrMessage) {
1469
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1470
+ return true;
1471
+ }
1472
+ if (!witnessCache.includes(input.witnessIndex)) {
1473
+ witnessCache.push(input.witnessIndex);
1474
+ return true;
1475
+ }
1476
+ }
1477
+ return false;
1478
+ });
1479
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1480
+ const totalGas = chargeableInputs.reduce((total, input) => {
1406
1481
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1407
1482
  return total.add(
1408
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1483
+ vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1409
1484
  );
1410
1485
  }
1411
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1412
- witnessCache.push(input.witnessIndex);
1413
- return total.add(gasCosts.ecr1);
1414
- }
1415
- return total;
1416
- }, bn5());
1486
+ return total.add(gasCosts.ecr1);
1487
+ }, bn5(0));
1417
1488
  return totalGas;
1418
1489
  }
1419
1490
  function getMinGas(params) {
@@ -1425,12 +1496,20 @@ function getMinGas(params) {
1425
1496
  return minGas;
1426
1497
  }
1427
1498
  function getMaxGas(params) {
1428
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
1499
+ const {
1500
+ gasPerByte,
1501
+ witnessesLength,
1502
+ witnessLimit,
1503
+ minGas,
1504
+ gasLimit = bn5(0),
1505
+ maxGasPerTx
1506
+ } = params;
1429
1507
  let remainingAllowedWitnessGas = bn5(0);
1430
1508
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1431
1509
  remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1432
1510
  }
1433
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1511
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1512
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1434
1513
  }
1435
1514
  function calculateMetadataGasForTxCreate({
1436
1515
  gasCosts,
@@ -1452,6 +1531,10 @@ function calculateMetadataGasForTxScript({
1452
1531
  }) {
1453
1532
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1454
1533
  }
1534
+ var calculateGasFee = (params) => {
1535
+ const { gas, gasPrice, priceFactor, tip } = params;
1536
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
1537
+ };
1455
1538
 
1456
1539
  // src/providers/utils/json.ts
1457
1540
  import { hexlify as hexlify5 } from "@fuel-ts/utils";
@@ -1596,7 +1679,7 @@ var witnessify = (value) => {
1596
1679
  // src/providers/transaction-request/transaction-request.ts
1597
1680
  var BaseTransactionRequest = class {
1598
1681
  /** Gas price for transaction */
1599
- gasPrice;
1682
+ tip;
1600
1683
  /** Block until which tx cannot be included */
1601
1684
  maturity;
1602
1685
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1609,38 +1692,34 @@ var BaseTransactionRequest = class {
1609
1692
  outputs = [];
1610
1693
  /** List of witnesses */
1611
1694
  witnesses = [];
1612
- /** Base asset ID - should be fetched from the chain */
1613
- baseAssetId = ZeroBytes324;
1614
1695
  /**
1615
1696
  * Constructor for initializing a base transaction request.
1616
1697
  *
1617
1698
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1618
1699
  */
1619
1700
  constructor({
1620
- gasPrice,
1701
+ tip,
1621
1702
  maturity,
1622
1703
  maxFee,
1623
1704
  witnessLimit,
1624
1705
  inputs,
1625
1706
  outputs,
1626
- witnesses,
1627
- baseAssetId
1707
+ witnesses
1628
1708
  } = {}) {
1629
- this.gasPrice = bn7(gasPrice);
1709
+ this.tip = bn7(tip);
1630
1710
  this.maturity = maturity ?? 0;
1631
1711
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1632
1712
  this.maxFee = maxFee ? bn7(maxFee) : void 0;
1633
1713
  this.inputs = inputs ?? [];
1634
1714
  this.outputs = outputs ?? [];
1635
1715
  this.witnesses = witnesses ?? [];
1636
- this.baseAssetId = baseAssetId ?? ZeroBytes324;
1637
1716
  }
1638
1717
  static getPolicyMeta(req) {
1639
1718
  let policyTypes = 0;
1640
1719
  const policies = [];
1641
- if (req.gasPrice) {
1642
- policyTypes += PolicyType.GasPrice;
1643
- policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
1720
+ if (req.tip) {
1721
+ policyTypes += PolicyType.Tip;
1722
+ policies.push({ data: req.tip, type: PolicyType.Tip });
1644
1723
  }
1645
1724
  if (req.witnessLimit) {
1646
1725
  policyTypes += PolicyType.WitnessLimit;
@@ -1827,10 +1906,10 @@ var BaseTransactionRequest = class {
1827
1906
  * @param predicate - Predicate bytes.
1828
1907
  * @param predicateData - Predicate data bytes.
1829
1908
  */
1830
- addCoinInput(coin, predicate) {
1909
+ addCoinInput(coin) {
1831
1910
  const { assetId, owner, amount } = coin;
1832
1911
  let witnessIndex;
1833
- if (predicate) {
1912
+ if (coin.predicate) {
1834
1913
  witnessIndex = 0;
1835
1914
  } else {
1836
1915
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1845,9 +1924,7 @@ var BaseTransactionRequest = class {
1845
1924
  amount,
1846
1925
  assetId,
1847
1926
  txPointer: "0x00000000000000000000000000000000",
1848
- witnessIndex,
1849
- predicate: predicate?.bytes,
1850
- predicateData: predicate?.predicateDataBytes
1927
+ witnessIndex
1851
1928
  };
1852
1929
  this.pushInput(input);
1853
1930
  this.addChangeOutput(owner, assetId);
@@ -1858,11 +1935,13 @@ var BaseTransactionRequest = class {
1858
1935
  *
1859
1936
  * @param message - Message resource.
1860
1937
  * @param predicate - Predicate bytes.
1938
+ * @param predicateData - Predicate data bytes.
1861
1939
  */
1862
- addMessageInput(message, predicate) {
1940
+ addMessageInput(message) {
1863
1941
  const { recipient, sender, amount } = message;
1942
+ const assetId = BaseAssetId2;
1864
1943
  let witnessIndex;
1865
- if (predicate) {
1944
+ if (message.predicate) {
1866
1945
  witnessIndex = 0;
1867
1946
  } else {
1868
1947
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1876,12 +1955,10 @@ var BaseTransactionRequest = class {
1876
1955
  sender: sender.toB256(),
1877
1956
  recipient: recipient.toB256(),
1878
1957
  amount,
1879
- witnessIndex,
1880
- predicate: predicate?.bytes,
1881
- predicateData: predicate?.predicateDataBytes
1958
+ witnessIndex
1882
1959
  };
1883
1960
  this.pushInput(input);
1884
- this.addChangeOutput(recipient, this.baseAssetId);
1961
+ this.addChangeOutput(recipient, assetId);
1885
1962
  }
1886
1963
  /**
1887
1964
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -1909,32 +1986,6 @@ var BaseTransactionRequest = class {
1909
1986
  resources.forEach((resource) => this.addResource(resource));
1910
1987
  return this;
1911
1988
  }
1912
- /**
1913
- * Adds multiple resources to the transaction by adding coin/message inputs and change
1914
- * outputs from the related assetIds.
1915
- *
1916
- * @param resources - The resources to add.
1917
- * @returns This transaction.
1918
- */
1919
- addPredicateResource(resource, predicate) {
1920
- if (isCoin(resource)) {
1921
- this.addCoinInput(resource, predicate);
1922
- } else {
1923
- this.addMessageInput(resource, predicate);
1924
- }
1925
- return this;
1926
- }
1927
- /**
1928
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
1929
- * from the related assetIds.
1930
- *
1931
- * @param resources - The resources to add.
1932
- * @returns This transaction.
1933
- */
1934
- addPredicateResources(resources, predicate) {
1935
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1936
- return this;
1937
- }
1938
1989
  /**
1939
1990
  * Adds a coin output to the transaction.
1940
1991
  *
@@ -1942,12 +1993,12 @@ var BaseTransactionRequest = class {
1942
1993
  * @param amount - Amount of coin.
1943
1994
  * @param assetId - Asset ID of coin.
1944
1995
  */
1945
- addCoinOutput(to, amount, assetId) {
1996
+ addCoinOutput(to, amount, assetId = BaseAssetId2) {
1946
1997
  this.pushOutput({
1947
1998
  type: OutputType2.Coin,
1948
1999
  to: addressify(to).toB256(),
1949
2000
  amount,
1950
- assetId: assetId ?? this.baseAssetId
2001
+ assetId
1951
2002
  });
1952
2003
  return this;
1953
2004
  }
@@ -1974,7 +2025,7 @@ var BaseTransactionRequest = class {
1974
2025
  * @param to - Address of the owner.
1975
2026
  * @param assetId - Asset ID of coin.
1976
2027
  */
1977
- addChangeOutput(to, assetId) {
2028
+ addChangeOutput(to, assetId = BaseAssetId2) {
1978
2029
  const changeOutput = this.getChangeOutputs().find(
1979
2030
  (output) => hexlify7(output.assetId) === assetId
1980
2031
  );
@@ -1982,7 +2033,7 @@ var BaseTransactionRequest = class {
1982
2033
  this.pushOutput({
1983
2034
  type: OutputType2.Change,
1984
2035
  to: addressify(to).toB256(),
1985
- assetId: assetId ?? this.baseAssetId
2036
+ assetId
1986
2037
  });
1987
2038
  }
1988
2039
  }
@@ -2014,7 +2065,7 @@ var BaseTransactionRequest = class {
2014
2065
  }
2015
2066
  calculateMaxGas(chainInfo, minGas) {
2016
2067
  const { consensusParameters } = chainInfo;
2017
- const { gasPerByte } = consensusParameters;
2068
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2018
2069
  const witnessesLength = this.toTransaction().witnesses.reduce(
2019
2070
  (acc, wit) => acc + wit.dataLength,
2020
2071
  0
@@ -2023,7 +2074,8 @@ var BaseTransactionRequest = class {
2023
2074
  gasPerByte,
2024
2075
  minGas,
2025
2076
  witnessesLength,
2026
- witnessLimit: this.witnessLimit
2077
+ witnessLimit: this.witnessLimit,
2078
+ maxGasPerTx
2027
2079
  });
2028
2080
  }
2029
2081
  /**
@@ -2033,12 +2085,6 @@ var BaseTransactionRequest = class {
2033
2085
  * @param quantities - CoinQuantity Array.
2034
2086
  */
2035
2087
  fundWithFakeUtxos(quantities, resourcesOwner) {
2036
- let idCounter = 0;
2037
- const generateId = () => {
2038
- const counterString = String(idCounter++);
2039
- const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
2040
- return id;
2041
- };
2042
2088
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2043
2089
  if ("assetId" in input) {
2044
2090
  return input.assetId === assetId;
@@ -2047,24 +2093,27 @@ var BaseTransactionRequest = class {
2047
2093
  });
2048
2094
  const updateAssetInput = (assetId, quantity) => {
2049
2095
  const assetInput = findAssetInput(assetId);
2096
+ let usedQuantity = quantity;
2097
+ if (assetId === BaseAssetId2) {
2098
+ usedQuantity = bn7("1000000000000000000");
2099
+ }
2050
2100
  if (assetInput && "assetId" in assetInput) {
2051
- assetInput.id = generateId();
2052
- assetInput.amount = quantity;
2101
+ assetInput.id = hexlify7(randomBytes(34));
2102
+ assetInput.amount = usedQuantity;
2053
2103
  } else {
2054
2104
  this.addResources([
2055
2105
  {
2056
- id: generateId(),
2057
- amount: quantity,
2106
+ id: hexlify7(randomBytes(34)),
2107
+ amount: usedQuantity,
2058
2108
  assetId,
2059
2109
  owner: resourcesOwner || Address.fromRandom(),
2060
- maturity: 0,
2061
2110
  blockCreated: bn7(1),
2062
2111
  txCreatedIdx: bn7(1)
2063
2112
  }
2064
2113
  ]);
2065
2114
  }
2066
2115
  };
2067
- updateAssetInput(this.baseAssetId, bn7(1e11));
2116
+ updateAssetInput(BaseAssetId2, bn7(1e11));
2068
2117
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2069
2118
  }
2070
2119
  /**
@@ -2089,7 +2138,7 @@ var BaseTransactionRequest = class {
2089
2138
  toJSON() {
2090
2139
  return normalizeJSON(this);
2091
2140
  }
2092
- updatePredicateInputs(inputs) {
2141
+ updatePredicateGasUsed(inputs) {
2093
2142
  this.inputs.forEach((i) => {
2094
2143
  let correspondingInput;
2095
2144
  switch (i.type) {
@@ -2111,6 +2160,15 @@ var BaseTransactionRequest = class {
2111
2160
  }
2112
2161
  });
2113
2162
  }
2163
+ shiftPredicateData() {
2164
+ this.inputs.forEach((input) => {
2165
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2166
+ input.predicateData = input.paddPredicateData(
2167
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2168
+ );
2169
+ }
2170
+ });
2171
+ }
2114
2172
  };
2115
2173
 
2116
2174
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2257,9 +2315,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2257
2315
  return {
2258
2316
  type: TransactionType3.Create,
2259
2317
  ...baseTransaction,
2260
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2261
2318
  bytecodeWitnessIndex,
2262
- storageSlotsCount: storageSlots.length,
2319
+ storageSlotsCount: bn9(storageSlots.length),
2263
2320
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2264
2321
  storageSlots
2265
2322
  };
@@ -2382,8 +2439,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2382
2439
  type: TransactionType4.Script,
2383
2440
  scriptGasLimit: this.gasLimit,
2384
2441
  ...super.getBaseTransaction(),
2385
- scriptLength: script.length,
2386
- scriptDataLength: scriptData.length,
2442
+ scriptLength: bn10(script.length),
2443
+ scriptDataLength: bn10(scriptData.length),
2387
2444
  receiptsRoot: ZeroBytes327,
2388
2445
  script: hexlify10(script),
2389
2446
  scriptData: hexlify10(scriptData)
@@ -2447,7 +2504,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2447
2504
  }
2448
2505
  calculateMaxGas(chainInfo, minGas) {
2449
2506
  const { consensusParameters } = chainInfo;
2450
- const { gasPerByte } = consensusParameters;
2507
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2451
2508
  const witnessesLength = this.toTransaction().witnesses.reduce(
2452
2509
  (acc, wit) => acc + wit.dataLength,
2453
2510
  0
@@ -2457,7 +2514,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2457
2514
  minGas,
2458
2515
  witnessesLength,
2459
2516
  witnessLimit: this.witnessLimit,
2460
- gasLimit: this.gasLimit
2517
+ gasLimit: this.gasLimit,
2518
+ maxGasPerTx
2461
2519
  });
2462
2520
  }
2463
2521
  /**
@@ -2514,7 +2572,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2514
2572
 
2515
2573
  // src/providers/transaction-request/utils.ts
2516
2574
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2517
- import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2575
+ import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2518
2576
  var transactionRequestify = (obj) => {
2519
2577
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2520
2578
  return obj;
@@ -2532,14 +2590,31 @@ var transactionRequestify = (obj) => {
2532
2590
  }
2533
2591
  }
2534
2592
  };
2593
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2594
+ (acc, input) => {
2595
+ if (input.type === InputType5.Coin && input.owner === owner) {
2596
+ acc.utxos.push(input.id);
2597
+ }
2598
+ if (input.type === InputType5.Message && input.recipient === owner) {
2599
+ acc.messages.push(input.nonce);
2600
+ }
2601
+ return acc;
2602
+ },
2603
+ {
2604
+ utxos: [],
2605
+ messages: []
2606
+ }
2607
+ );
2535
2608
 
2536
2609
  // src/providers/transaction-response/transaction-response.ts
2537
2610
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2538
- import { bn as bn14 } from "@fuel-ts/math";
2611
+ import { bn as bn15 } from "@fuel-ts/math";
2539
2612
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2540
2613
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2541
2614
 
2542
2615
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2616
+ import { bn as bn14 } from "@fuel-ts/math";
2617
+ import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2543
2618
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2544
2619
 
2545
2620
  // src/providers/transaction-summary/calculate-transaction-fee.ts
@@ -2548,9 +2623,10 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
2548
2623
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2549
2624
  var calculateTransactionFee = (params) => {
2550
2625
  const {
2551
- gasUsed,
2626
+ gasPrice,
2552
2627
  rawPayload,
2553
- consensusParameters: { gasCosts, feeParams }
2628
+ tip,
2629
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2554
2630
  } = params;
2555
2631
  const gasPerByte = bn11(feeParams.gasPerByte);
2556
2632
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
@@ -2560,8 +2636,7 @@ var calculateTransactionFee = (params) => {
2560
2636
  return {
2561
2637
  fee: bn11(0),
2562
2638
  minFee: bn11(0),
2563
- maxFee: bn11(0),
2564
- feeFromGasUsed: bn11(0)
2639
+ maxFee: bn11(0)
2565
2640
  };
2566
2641
  }
2567
2642
  const { type, witnesses, inputs, policies } = transaction;
@@ -2593,7 +2668,6 @@ var calculateTransactionFee = (params) => {
2593
2668
  metadataGas,
2594
2669
  txBytesSize: transactionBytes.length
2595
2670
  });
2596
- const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2597
2671
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2598
2672
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2599
2673
  const maxGas = getMaxGas({
@@ -2601,17 +2675,25 @@ var calculateTransactionFee = (params) => {
2601
2675
  minGas,
2602
2676
  witnessesLength,
2603
2677
  gasLimit,
2604
- witnessLimit
2678
+ witnessLimit,
2679
+ maxGasPerTx
2680
+ });
2681
+ const minFee = calculateGasFee({
2682
+ gasPrice,
2683
+ gas: minGas,
2684
+ priceFactor: gasPriceFactor,
2685
+ tip
2686
+ });
2687
+ const maxFee = calculateGasFee({
2688
+ gasPrice,
2689
+ gas: maxGas,
2690
+ priceFactor: gasPriceFactor,
2691
+ tip
2605
2692
  });
2606
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2607
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2608
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2609
- const fee = minFee.add(feeFromGasUsed);
2610
2693
  return {
2611
- fee,
2612
2694
  minFee,
2613
2695
  maxFee,
2614
- feeFromGasUsed
2696
+ fee: maxFee
2615
2697
  };
2616
2698
  };
2617
2699
 
@@ -2667,7 +2749,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2667
2749
 
2668
2750
  // src/providers/transaction-summary/input.ts
2669
2751
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2670
- import { InputType as InputType5 } from "@fuel-ts/transactions";
2752
+ import { InputType as InputType6 } from "@fuel-ts/transactions";
2671
2753
  function getInputsByTypes(inputs, types) {
2672
2754
  return inputs.filter((i) => types.includes(i.type));
2673
2755
  }
@@ -2675,16 +2757,16 @@ function getInputsByType(inputs, type) {
2675
2757
  return inputs.filter((i) => i.type === type);
2676
2758
  }
2677
2759
  function getInputsCoin(inputs) {
2678
- return getInputsByType(inputs, InputType5.Coin);
2760
+ return getInputsByType(inputs, InputType6.Coin);
2679
2761
  }
2680
2762
  function getInputsMessage(inputs) {
2681
- return getInputsByType(inputs, InputType5.Message);
2763
+ return getInputsByType(inputs, InputType6.Message);
2682
2764
  }
2683
2765
  function getInputsCoinAndMessage(inputs) {
2684
- return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2766
+ return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2685
2767
  }
2686
2768
  function getInputsContract(inputs) {
2687
- return getInputsByType(inputs, InputType5.Contract);
2769
+ return getInputsByType(inputs, InputType6.Contract);
2688
2770
  }
2689
2771
  function getInputFromAssetId(inputs, assetId) {
2690
2772
  const coinInputs = getInputsCoin(inputs);
@@ -2703,7 +2785,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2703
2785
  if (!contractInput) {
2704
2786
  return void 0;
2705
2787
  }
2706
- if (contractInput.type !== InputType5.Contract) {
2788
+ if (contractInput.type !== InputType6.Contract) {
2707
2789
  throw new FuelError9(
2708
2790
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2709
2791
  `Contract input should be of type 'contract'.`
@@ -2712,10 +2794,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2712
2794
  return contractInput;
2713
2795
  }
2714
2796
  function getInputAccountAddress(input) {
2715
- if (input.type === InputType5.Coin) {
2797
+ if (input.type === InputType6.Coin) {
2716
2798
  return input.owner.toString();
2717
2799
  }
2718
- if (input.type === InputType5.Message) {
2800
+ if (input.type === InputType6.Message) {
2719
2801
  return input.recipient.toString();
2720
2802
  }
2721
2803
  return "";
@@ -3178,7 +3260,9 @@ function assembleTransactionSummary(params) {
3178
3260
  gqlTransactionStatus,
3179
3261
  abiMap = {},
3180
3262
  maxInputs,
3181
- gasCosts
3263
+ gasCosts,
3264
+ maxGasPerTx,
3265
+ gasPrice
3182
3266
  } = params;
3183
3267
  const gasUsed = getGasUsedFromReceipts(receipts);
3184
3268
  const rawPayload = hexlify11(transactionBytes);
@@ -3192,11 +3276,14 @@ function assembleTransactionSummary(params) {
3192
3276
  maxInputs
3193
3277
  });
3194
3278
  const typeName = getTransactionTypeName(transaction.type);
3279
+ const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3195
3280
  const { fee } = calculateTransactionFee({
3196
- gasUsed,
3281
+ gasPrice,
3197
3282
  rawPayload,
3283
+ tip,
3198
3284
  consensusParameters: {
3199
3285
  gasCosts,
3286
+ maxGasPerTx,
3200
3287
  feeParams: {
3201
3288
  gasPerByte,
3202
3289
  gasPriceFactor
@@ -3256,7 +3343,7 @@ var TransactionResponse = class {
3256
3343
  /** Current provider */
3257
3344
  provider;
3258
3345
  /** Gas used on the transaction */
3259
- gasUsed = bn14(0);
3346
+ gasUsed = bn15(0);
3260
3347
  /** The graphql Transaction with receipts object. */
3261
3348
  gqlTransaction;
3262
3349
  abis;
@@ -3334,8 +3421,13 @@ var TransactionResponse = class {
3334
3421
  const decodedTransaction = this.decodeTransaction(
3335
3422
  transaction
3336
3423
  );
3337
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3338
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3424
+ let txReceipts = [];
3425
+ if (transaction?.status && "receipts" in transaction.status) {
3426
+ txReceipts = transaction.status.receipts;
3427
+ }
3428
+ const receipts = txReceipts.map(processGqlReceipt) || [];
3429
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3430
+ const gasPrice = await this.provider.getLatestGasPrice();
3339
3431
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3340
3432
  const transactionSummary = assembleTransactionSummary({
3341
3433
  id: this.id,
@@ -3347,7 +3439,9 @@ var TransactionResponse = class {
3347
3439
  gasPriceFactor,
3348
3440
  abiMap: contractsAbiMap,
3349
3441
  maxInputs,
3350
- gasCosts
3442
+ gasCosts,
3443
+ maxGasPerTx,
3444
+ gasPrice
3351
3445
  });
3352
3446
  return transactionSummary;
3353
3447
  }
@@ -3474,30 +3568,29 @@ var processGqlChain = (chain) => {
3474
3568
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3475
3569
  return {
3476
3570
  name,
3477
- baseChainHeight: bn15(daHeight),
3571
+ baseChainHeight: bn16(daHeight),
3478
3572
  consensusParameters: {
3479
- contractMaxSize: bn15(contractParams.contractMaxSize),
3480
- maxInputs: bn15(txParams.maxInputs),
3481
- maxOutputs: bn15(txParams.maxOutputs),
3482
- maxWitnesses: bn15(txParams.maxWitnesses),
3483
- maxGasPerTx: bn15(txParams.maxGasPerTx),
3484
- maxScriptLength: bn15(scriptParams.maxScriptLength),
3485
- maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3486
- maxStorageSlots: bn15(contractParams.maxStorageSlots),
3487
- maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3488
- maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3489
- maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3490
- gasPriceFactor: bn15(feeParams.gasPriceFactor),
3491
- gasPerByte: bn15(feeParams.gasPerByte),
3492
- maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3493
- chainId: bn15(consensusParameters.chainId),
3494
- baseAssetId: consensusParameters.baseAssetId,
3573
+ contractMaxSize: bn16(contractParams.contractMaxSize),
3574
+ maxInputs: bn16(txParams.maxInputs),
3575
+ maxOutputs: bn16(txParams.maxOutputs),
3576
+ maxWitnesses: bn16(txParams.maxWitnesses),
3577
+ maxGasPerTx: bn16(txParams.maxGasPerTx),
3578
+ maxScriptLength: bn16(scriptParams.maxScriptLength),
3579
+ maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3580
+ maxStorageSlots: bn16(contractParams.maxStorageSlots),
3581
+ maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3582
+ maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3583
+ maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3584
+ gasPriceFactor: bn16(feeParams.gasPriceFactor),
3585
+ gasPerByte: bn16(feeParams.gasPerByte),
3586
+ maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3587
+ chainId: bn16(consensusParameters.chainId),
3495
3588
  gasCosts
3496
3589
  },
3497
3590
  gasCosts,
3498
3591
  latestBlock: {
3499
3592
  id: latestBlock.id,
3500
- height: bn15(latestBlock.header.height),
3593
+ height: bn16(latestBlock.height),
3501
3594
  time: latestBlock.header.time,
3502
3595
  transactions: latestBlock.transactions.map((i) => ({
3503
3596
  id: i.id
@@ -3591,10 +3684,8 @@ var _Provider = class {
3591
3684
  * Returns some helpful parameters related to gas fees.
3592
3685
  */
3593
3686
  getGasConfig() {
3594
- const { minGasPrice } = this.getNode();
3595
3687
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3596
3688
  return {
3597
- minGasPrice,
3598
3689
  maxGasPerTx,
3599
3690
  maxGasPerPredicate,
3600
3691
  gasPriceFactor,
@@ -3692,7 +3783,7 @@ var _Provider = class {
3692
3783
  */
3693
3784
  async getBlockNumber() {
3694
3785
  const { chain } = await this.operations.getChain();
3695
- return bn15(chain.latestBlock.header.height, 10);
3786
+ return bn16(chain.latestBlock.height, 10);
3696
3787
  }
3697
3788
  /**
3698
3789
  * Returns the chain information.
@@ -3702,13 +3793,11 @@ var _Provider = class {
3702
3793
  async fetchNode() {
3703
3794
  const { nodeInfo } = await this.operations.getNodeInfo();
3704
3795
  const processedNodeInfo = {
3705
- maxDepth: bn15(nodeInfo.maxDepth),
3706
- maxTx: bn15(nodeInfo.maxTx),
3707
- minGasPrice: bn15(nodeInfo.minGasPrice),
3796
+ maxDepth: bn16(nodeInfo.maxDepth),
3797
+ maxTx: bn16(nodeInfo.maxTx),
3708
3798
  nodeVersion: nodeInfo.nodeVersion,
3709
3799
  utxoValidation: nodeInfo.utxoValidation,
3710
- vmBacktrace: nodeInfo.vmBacktrace,
3711
- peers: nodeInfo.peers
3800
+ vmBacktrace: nodeInfo.vmBacktrace
3712
3801
  };
3713
3802
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3714
3803
  return processedNodeInfo;
@@ -3734,17 +3823,6 @@ var _Provider = class {
3734
3823
  } = this.getChain();
3735
3824
  return chainId.toNumber();
3736
3825
  }
3737
- /**
3738
- * Returns the base asset ID
3739
- *
3740
- * @returns A promise that resolves to the base asset ID
3741
- */
3742
- getBaseAssetId() {
3743
- const {
3744
- consensusParameters: { baseAssetId }
3745
- } = this.getChain();
3746
- return baseAssetId;
3747
- }
3748
3826
  /**
3749
3827
  * Submits a transaction to the chain to be executed.
3750
3828
  *
@@ -3805,14 +3883,13 @@ var _Provider = class {
3805
3883
  return this.estimateTxDependencies(transactionRequest);
3806
3884
  }
3807
3885
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3808
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3809
- encodedTransaction,
3886
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3887
+ encodedTransactions: encodedTransaction,
3810
3888
  utxoValidation: utxoValidation || false
3811
3889
  });
3812
- const receipts = gqlReceipts.map(processGqlReceipt);
3813
- return {
3814
- receipts
3815
- };
3890
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3891
+ const receipts = rawReceipts.map(processGqlReceipt);
3892
+ return { receipts, dryrunStatus: status };
3816
3893
  }
3817
3894
  /**
3818
3895
  * Verifies whether enough gas is available to complete transaction.
@@ -3838,7 +3915,7 @@ var _Provider = class {
3838
3915
  } = response;
3839
3916
  if (inputs) {
3840
3917
  inputs.forEach((input, index) => {
3841
- if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3918
+ if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
3842
3919
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3843
3920
  }
3844
3921
  });
@@ -3851,9 +3928,6 @@ var _Provider = class {
3851
3928
  * If there are missing variable outputs,
3852
3929
  * `addVariableOutputs` is called on the transaction.
3853
3930
  *
3854
- * @privateRemarks
3855
- * TODO: Investigate support for missing contract IDs
3856
- * TODO: Add support for missing output messages
3857
3931
  *
3858
3932
  * @param transactionRequest - The transaction request object.
3859
3933
  * @returns A promise.
@@ -3866,16 +3940,19 @@ var _Provider = class {
3866
3940
  missingContractIds: []
3867
3941
  };
3868
3942
  }
3869
- await this.estimatePredicates(transactionRequest);
3870
3943
  let receipts = [];
3871
3944
  const missingContractIds = [];
3872
3945
  let outputVariables = 0;
3946
+ let dryrunStatus;
3873
3947
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3874
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3875
- encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3948
+ const {
3949
+ dryRun: [{ receipts: rawReceipts, status }]
3950
+ } = await this.operations.dryRun({
3951
+ encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
3876
3952
  utxoValidation: false
3877
3953
  });
3878
- receipts = gqlReceipts.map(processGqlReceipt);
3954
+ receipts = rawReceipts.map(processGqlReceipt);
3955
+ dryrunStatus = status;
3879
3956
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3880
3957
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3881
3958
  if (hasMissingOutputs) {
@@ -3885,6 +3962,11 @@ var _Provider = class {
3885
3962
  transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3886
3963
  missingContractIds.push(contractId);
3887
3964
  });
3965
+ const { maxFee } = await this.estimateTxGasAndFee({
3966
+ transactionRequest,
3967
+ optimizeGas: false
3968
+ });
3969
+ transactionRequest.maxFee = maxFee;
3888
3970
  } else {
3889
3971
  break;
3890
3972
  }
@@ -3892,7 +3974,133 @@ var _Provider = class {
3892
3974
  return {
3893
3975
  receipts,
3894
3976
  outputVariables,
3895
- missingContractIds
3977
+ missingContractIds,
3978
+ dryrunStatus
3979
+ };
3980
+ }
3981
+ /**
3982
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
3983
+ *
3984
+ * Transactions are dry run in batches. After each dry run, transactions requiring
3985
+ * further modifications are identified. The method iteratively updates these transactions
3986
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
3987
+ *
3988
+ * @param transactionRequests - Array of transaction request objects.
3989
+ * @returns A promise that resolves to an array of results for each transaction.
3990
+ */
3991
+ async estimateMultipleTxDependencies(transactionRequests) {
3992
+ const results = transactionRequests.map(() => ({
3993
+ receipts: [],
3994
+ outputVariables: 0,
3995
+ missingContractIds: [],
3996
+ dryrunStatus: void 0
3997
+ }));
3998
+ const allRequests = clone3(transactionRequests);
3999
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
4000
+ allRequests.forEach((req, index) => {
4001
+ if (req.type === TransactionType8.Script) {
4002
+ serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4003
+ }
4004
+ });
4005
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4006
+ let attempt = 0;
4007
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4008
+ const encodedTransactions = transactionsToProcess.map(
4009
+ (index) => serializedTransactionsMap.get(index)
4010
+ );
4011
+ const dryRunResults = await this.operations.dryRun({
4012
+ encodedTransactions,
4013
+ utxoValidation: false
4014
+ });
4015
+ const nextRoundTransactions = [];
4016
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4017
+ const currentResultIndex = transactionsToProcess[i];
4018
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4019
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4020
+ results[currentResultIndex].dryrunStatus = status;
4021
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4022
+ results[currentResultIndex].receipts
4023
+ );
4024
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4025
+ const requestToProcess = allRequests[currentResultIndex];
4026
+ if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
4027
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
4028
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
4029
+ missingOutputContractIds.forEach(({ contractId }) => {
4030
+ requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
4031
+ results[currentResultIndex].missingContractIds.push(contractId);
4032
+ });
4033
+ const { maxFee } = await this.estimateTxGasAndFee({
4034
+ transactionRequest: requestToProcess,
4035
+ optimizeGas: false
4036
+ });
4037
+ requestToProcess.maxFee = maxFee;
4038
+ serializedTransactionsMap.set(
4039
+ currentResultIndex,
4040
+ hexlify12(requestToProcess.toTransactionBytes())
4041
+ );
4042
+ nextRoundTransactions.push(currentResultIndex);
4043
+ allRequests[currentResultIndex] = requestToProcess;
4044
+ }
4045
+ }
4046
+ transactionsToProcess = nextRoundTransactions;
4047
+ attempt += 1;
4048
+ }
4049
+ return results;
4050
+ }
4051
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4052
+ if (estimateTxDependencies) {
4053
+ return this.estimateMultipleTxDependencies(transactionRequests);
4054
+ }
4055
+ const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4056
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4057
+ encodedTransactions,
4058
+ utxoValidation: utxoValidation || false
4059
+ });
4060
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4061
+ const receipts = rawReceipts.map(processGqlReceipt);
4062
+ return { receipts, dryrunStatus: status };
4063
+ });
4064
+ return results;
4065
+ }
4066
+ async estimateTxGasAndFee(params) {
4067
+ const { transactionRequest, optimizeGas = true } = params;
4068
+ let { gasPrice } = params;
4069
+ const chainInfo = this.getChain();
4070
+ const { gasPriceFactor } = this.getGasConfig();
4071
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4072
+ if (!gasPrice) {
4073
+ gasPrice = await this.estimateGasPrice(10);
4074
+ }
4075
+ const minFee = calculateGasFee({
4076
+ gasPrice: bn16(gasPrice),
4077
+ gas: minGas,
4078
+ priceFactor: gasPriceFactor,
4079
+ tip: transactionRequest.tip
4080
+ }).add(1);
4081
+ let gasLimit = bn16(0);
4082
+ if (transactionRequest.type === TransactionType8.Script) {
4083
+ gasLimit = transactionRequest.gasLimit;
4084
+ if (!optimizeGas) {
4085
+ transactionRequest.gasLimit = minGas;
4086
+ gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4087
+ transactionRequest.gasLimit = gasLimit;
4088
+ }
4089
+ }
4090
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4091
+ const maxFee = calculateGasFee({
4092
+ gasPrice: bn16(gasPrice),
4093
+ gas: maxGas,
4094
+ priceFactor: gasPriceFactor,
4095
+ tip: transactionRequest.tip
4096
+ }).add(1);
4097
+ return {
4098
+ minGas,
4099
+ minFee,
4100
+ maxGas,
4101
+ maxFee,
4102
+ gasPrice,
4103
+ gasLimit
3896
4104
  };
3897
4105
  }
3898
4106
  /**
@@ -3910,15 +4118,17 @@ var _Provider = class {
3910
4118
  if (estimateTxDependencies) {
3911
4119
  return this.estimateTxDependencies(transactionRequest);
3912
4120
  }
3913
- const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3914
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3915
- encodedTransaction,
4121
+ const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4122
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4123
+ encodedTransactions,
3916
4124
  utxoValidation: true
3917
4125
  });
3918
- const receipts = gqlReceipts.map(processGqlReceipt);
3919
- return {
3920
- receipts
3921
- };
4126
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
4127
+ const { id, receipts, status } = dryRunStatus;
4128
+ const processedReceipts = receipts.map(processGqlReceipt);
4129
+ return { id, receipts: processedReceipts, status };
4130
+ });
4131
+ return { receipts: callResult[0].receipts };
3922
4132
  }
3923
4133
  /**
3924
4134
  * Returns a transaction cost to enable user
@@ -3935,80 +4145,80 @@ var _Provider = class {
3935
4145
  * @param tolerance - The tolerance to add on top of the gasUsed.
3936
4146
  * @returns A promise that resolves to the transaction cost object.
3937
4147
  */
3938
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3939
- estimateTxDependencies = true,
3940
- estimatePredicates = true,
3941
- resourcesOwner,
3942
- signatureCallback
3943
- } = {}) {
4148
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3944
4149
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3945
- const chainInfo = this.getChain();
3946
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3947
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
3948
4150
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3949
4151
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3950
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4152
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3951
4153
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3952
- if (estimatePredicates) {
3953
- if (isScriptTransaction) {
3954
- txRequestClone.gasLimit = bn15(0);
3955
- }
3956
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3957
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3958
- }
3959
- await this.estimatePredicates(txRequestClone);
4154
+ txRequestClone.maxFee = bn16(0);
4155
+ if (isScriptTransaction) {
4156
+ txRequestClone.gasLimit = bn16(0);
3960
4157
  }
3961
- if (signatureCallback && isScriptTransaction) {
3962
- await signatureCallback(txRequestClone);
4158
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4159
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3963
4160
  }
3964
- const minGas = txRequestClone.calculateMinGas(chainInfo);
3965
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4161
+ const signedRequest = clone3(txRequestClone);
4162
+ let addedSignatures = 0;
4163
+ if (signatureCallback && isScriptTransaction) {
4164
+ const lengthBefore = signedRequest.witnesses.length;
4165
+ await signatureCallback(signedRequest);
4166
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
4167
+ }
4168
+ await this.estimatePredicates(signedRequest);
4169
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4170
+ transactionRequest: signedRequest,
4171
+ optimizeGas: false
4172
+ });
4173
+ txRequestClone.maxFee = maxFee;
3966
4174
  let receipts = [];
3967
4175
  let missingContractIds = [];
3968
4176
  let outputVariables = 0;
3969
- if (isScriptTransaction && estimateTxDependencies) {
3970
- txRequestClone.gasPrice = bn15(0);
3971
- txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4177
+ let gasUsed = bn16(0);
4178
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4179
+ if (isScriptTransaction) {
4180
+ if (signatureCallback) {
4181
+ await signatureCallback(txRequestClone);
4182
+ }
4183
+ txRequestClone.gasLimit = gasLimit;
3972
4184
  const result = await this.estimateTxDependencies(txRequestClone);
3973
4185
  receipts = result.receipts;
3974
4186
  outputVariables = result.outputVariables;
3975
4187
  missingContractIds = result.missingContractIds;
4188
+ gasUsed = getGasUsedFromReceipts(receipts);
4189
+ txRequestClone.gasLimit = gasUsed;
4190
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4191
+ transactionRequest: txRequestClone,
4192
+ gasPrice
4193
+ }));
3976
4194
  }
3977
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3978
- const usedFee = calculatePriceWithFactor(
3979
- gasUsed,
3980
- gasPrice,
3981
- gasPriceFactor
3982
- ).normalizeZeroToOne();
3983
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3984
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3985
4195
  return {
3986
4196
  requiredQuantities: allQuantities,
3987
4197
  receipts,
3988
4198
  gasUsed,
3989
- minGasPrice,
3990
4199
  gasPrice,
3991
4200
  minGas,
3992
4201
  maxGas,
3993
- usedFee,
3994
4202
  minFee,
3995
4203
  maxFee,
3996
- estimatedInputs: txRequestClone.inputs,
3997
4204
  outputVariables,
3998
- missingContractIds
4205
+ missingContractIds,
4206
+ addedSignatures,
4207
+ estimatedPredicates: txRequestClone.inputs
3999
4208
  };
4000
4209
  }
4001
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4210
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4002
4211
  const ownerAddress = Address2.fromAddressOrString(owner);
4003
4212
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4004
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4213
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
4214
+ quantitiesToContract
4215
+ });
4005
4216
  transactionRequest.addResources(
4006
4217
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4007
4218
  );
4008
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4009
- transactionRequest,
4010
- forwardingQuantities
4011
- );
4219
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4220
+ quantitiesToContract
4221
+ });
4012
4222
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4013
4223
  return {
4014
4224
  resources,
@@ -4030,11 +4240,10 @@ var _Provider = class {
4030
4240
  return coins.map((coin) => ({
4031
4241
  id: coin.utxoId,
4032
4242
  assetId: coin.assetId,
4033
- amount: bn15(coin.amount),
4243
+ amount: bn16(coin.amount),
4034
4244
  owner: Address2.fromAddressOrString(coin.owner),
4035
- maturity: bn15(coin.maturity).toNumber(),
4036
- blockCreated: bn15(coin.blockCreated),
4037
- txCreatedIdx: bn15(coin.txCreatedIdx)
4245
+ blockCreated: bn16(coin.blockCreated),
4246
+ txCreatedIdx: bn16(coin.txCreatedIdx)
4038
4247
  }));
4039
4248
  }
4040
4249
  /**
@@ -4071,9 +4280,9 @@ var _Provider = class {
4071
4280
  switch (coin.__typename) {
4072
4281
  case "MessageCoin":
4073
4282
  return {
4074
- amount: bn15(coin.amount),
4283
+ amount: bn16(coin.amount),
4075
4284
  assetId: coin.assetId,
4076
- daHeight: bn15(coin.daHeight),
4285
+ daHeight: bn16(coin.daHeight),
4077
4286
  sender: Address2.fromAddressOrString(coin.sender),
4078
4287
  recipient: Address2.fromAddressOrString(coin.recipient),
4079
4288
  nonce: coin.nonce
@@ -4081,12 +4290,11 @@ var _Provider = class {
4081
4290
  case "Coin":
4082
4291
  return {
4083
4292
  id: coin.utxoId,
4084
- amount: bn15(coin.amount),
4293
+ amount: bn16(coin.amount),
4085
4294
  assetId: coin.assetId,
4086
4295
  owner: Address2.fromAddressOrString(coin.owner),
4087
- maturity: bn15(coin.maturity).toNumber(),
4088
- blockCreated: bn15(coin.blockCreated),
4089
- txCreatedIdx: bn15(coin.txCreatedIdx)
4296
+ blockCreated: bn16(coin.blockCreated),
4297
+ txCreatedIdx: bn16(coin.txCreatedIdx)
4090
4298
  };
4091
4299
  default:
4092
4300
  return null;
@@ -4103,13 +4311,13 @@ var _Provider = class {
4103
4311
  async getBlock(idOrHeight) {
4104
4312
  let variables;
4105
4313
  if (typeof idOrHeight === "number") {
4106
- variables = { height: bn15(idOrHeight).toString(10) };
4314
+ variables = { height: bn16(idOrHeight).toString(10) };
4107
4315
  } else if (idOrHeight === "latest") {
4108
4316
  variables = { height: (await this.getBlockNumber()).toString(10) };
4109
4317
  } else if (idOrHeight.length === 66) {
4110
4318
  variables = { blockId: idOrHeight };
4111
4319
  } else {
4112
- variables = { blockId: bn15(idOrHeight).toString(10) };
4320
+ variables = { blockId: bn16(idOrHeight).toString(10) };
4113
4321
  }
4114
4322
  const { block } = await this.operations.getBlock(variables);
4115
4323
  if (!block) {
@@ -4117,7 +4325,7 @@ var _Provider = class {
4117
4325
  }
4118
4326
  return {
4119
4327
  id: block.id,
4120
- height: bn15(block.header.height),
4328
+ height: bn16(block.height),
4121
4329
  time: block.header.time,
4122
4330
  transactionIds: block.transactions.map((tx) => tx.id)
4123
4331
  };
@@ -4132,7 +4340,7 @@ var _Provider = class {
4132
4340
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4133
4341
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4134
4342
  id: block.id,
4135
- height: bn15(block.header.height),
4343
+ height: bn16(block.height),
4136
4344
  time: block.header.time,
4137
4345
  transactionIds: block.transactions.map((tx) => tx.id)
4138
4346
  }));
@@ -4147,7 +4355,7 @@ var _Provider = class {
4147
4355
  async getBlockWithTransactions(idOrHeight) {
4148
4356
  let variables;
4149
4357
  if (typeof idOrHeight === "number") {
4150
- variables = { blockHeight: bn15(idOrHeight).toString(10) };
4358
+ variables = { blockHeight: bn16(idOrHeight).toString(10) };
4151
4359
  } else if (idOrHeight === "latest") {
4152
4360
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4153
4361
  } else {
@@ -4159,7 +4367,7 @@ var _Provider = class {
4159
4367
  }
4160
4368
  return {
4161
4369
  id: block.id,
4162
- height: bn15(block.header.height, 10),
4370
+ height: bn16(block.height, 10),
4163
4371
  time: block.header.time,
4164
4372
  transactionIds: block.transactions.map((tx) => tx.id),
4165
4373
  transactions: block.transactions.map(
@@ -4208,7 +4416,7 @@ var _Provider = class {
4208
4416
  contract: Address2.fromAddressOrString(contractId).toB256(),
4209
4417
  asset: hexlify12(assetId)
4210
4418
  });
4211
- return bn15(contractBalance.amount, 10);
4419
+ return bn16(contractBalance.amount, 10);
4212
4420
  }
4213
4421
  /**
4214
4422
  * Returns the balance for the given owner for the given asset ID.
@@ -4222,7 +4430,7 @@ var _Provider = class {
4222
4430
  owner: Address2.fromAddressOrString(owner).toB256(),
4223
4431
  assetId: hexlify12(assetId)
4224
4432
  });
4225
- return bn15(balance.amount, 10);
4433
+ return bn16(balance.amount, 10);
4226
4434
  }
4227
4435
  /**
4228
4436
  * Returns balances for the given owner.
@@ -4240,7 +4448,7 @@ var _Provider = class {
4240
4448
  const balances = result.balances.edges.map((edge) => edge.node);
4241
4449
  return balances.map((balance) => ({
4242
4450
  assetId: balance.assetId,
4243
- amount: bn15(balance.amount)
4451
+ amount: bn16(balance.amount)
4244
4452
  }));
4245
4453
  }
4246
4454
  /**
@@ -4262,15 +4470,15 @@ var _Provider = class {
4262
4470
  sender: message.sender,
4263
4471
  recipient: message.recipient,
4264
4472
  nonce: message.nonce,
4265
- amount: bn15(message.amount),
4473
+ amount: bn16(message.amount),
4266
4474
  data: message.data
4267
4475
  }),
4268
4476
  sender: Address2.fromAddressOrString(message.sender),
4269
4477
  recipient: Address2.fromAddressOrString(message.recipient),
4270
4478
  nonce: message.nonce,
4271
- amount: bn15(message.amount),
4479
+ amount: bn16(message.amount),
4272
4480
  data: InputMessageCoder.decodeData(message.data),
4273
- daHeight: bn15(message.daHeight)
4481
+ daHeight: bn16(message.daHeight)
4274
4482
  }));
4275
4483
  }
4276
4484
  /**
@@ -4323,44 +4531,52 @@ var _Provider = class {
4323
4531
  } = result.messageProof;
4324
4532
  return {
4325
4533
  messageProof: {
4326
- proofIndex: bn15(messageProof.proofIndex),
4534
+ proofIndex: bn16(messageProof.proofIndex),
4327
4535
  proofSet: messageProof.proofSet
4328
4536
  },
4329
4537
  blockProof: {
4330
- proofIndex: bn15(blockProof.proofIndex),
4538
+ proofIndex: bn16(blockProof.proofIndex),
4331
4539
  proofSet: blockProof.proofSet
4332
4540
  },
4333
4541
  messageBlockHeader: {
4334
4542
  id: messageBlockHeader.id,
4335
- daHeight: bn15(messageBlockHeader.daHeight),
4336
- transactionsCount: bn15(messageBlockHeader.transactionsCount),
4543
+ daHeight: bn16(messageBlockHeader.daHeight),
4544
+ transactionsCount: bn16(messageBlockHeader.transactionsCount),
4337
4545
  transactionsRoot: messageBlockHeader.transactionsRoot,
4338
- height: bn15(messageBlockHeader.height),
4546
+ height: bn16(messageBlockHeader.height),
4339
4547
  prevRoot: messageBlockHeader.prevRoot,
4340
4548
  time: messageBlockHeader.time,
4341
4549
  applicationHash: messageBlockHeader.applicationHash,
4342
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4343
- messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4550
+ messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount)
4344
4551
  },
4345
4552
  commitBlockHeader: {
4346
4553
  id: commitBlockHeader.id,
4347
- daHeight: bn15(commitBlockHeader.daHeight),
4348
- transactionsCount: bn15(commitBlockHeader.transactionsCount),
4554
+ daHeight: bn16(commitBlockHeader.daHeight),
4555
+ transactionsCount: bn16(commitBlockHeader.transactionsCount),
4349
4556
  transactionsRoot: commitBlockHeader.transactionsRoot,
4350
- height: bn15(commitBlockHeader.height),
4557
+ height: bn16(commitBlockHeader.height),
4351
4558
  prevRoot: commitBlockHeader.prevRoot,
4352
4559
  time: commitBlockHeader.time,
4353
4560
  applicationHash: commitBlockHeader.applicationHash,
4354
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4355
- messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4561
+ messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount)
4356
4562
  },
4357
4563
  sender: Address2.fromAddressOrString(sender),
4358
4564
  recipient: Address2.fromAddressOrString(recipient),
4359
4565
  nonce,
4360
- amount: bn15(amount),
4566
+ amount: bn16(amount),
4361
4567
  data
4362
4568
  };
4363
4569
  }
4570
+ async getLatestGasPrice() {
4571
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
4572
+ return bn16(latestGasPrice.gasPrice);
4573
+ }
4574
+ async estimateGasPrice(blockHorizon) {
4575
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
4576
+ blockHorizon: String(blockHorizon)
4577
+ });
4578
+ return bn16(estimateGasPrice.gasPrice);
4579
+ }
4364
4580
  /**
4365
4581
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4366
4582
  *
@@ -4380,10 +4596,10 @@ var _Provider = class {
4380
4596
  */
4381
4597
  async produceBlocks(amount, startTime) {
4382
4598
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4383
- blocksToProduce: bn15(amount).toString(10),
4599
+ blocksToProduce: bn16(amount).toString(10),
4384
4600
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4385
4601
  });
4386
- return bn15(latestBlockHeight);
4602
+ return bn16(latestBlockHeight);
4387
4603
  }
4388
4604
  // eslint-disable-next-line @typescript-eslint/require-await
4389
4605
  async getTransactionResponse(transactionId) {
@@ -4397,7 +4613,7 @@ cacheInputs_fn = function(inputs) {
4397
4613
  return;
4398
4614
  }
4399
4615
  inputs.forEach((input) => {
4400
- if (input.type === InputType6.Coin) {
4616
+ if (input.type === InputType7.Coin) {
4401
4617
  this.cache?.set(input.id);
4402
4618
  }
4403
4619
  });
@@ -4407,7 +4623,7 @@ __publicField(Provider, "nodeInfoCache", {});
4407
4623
 
4408
4624
  // src/providers/transaction-summary/get-transaction-summary.ts
4409
4625
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4410
- import { bn as bn16 } from "@fuel-ts/math";
4626
+ import { bn as bn17 } from "@fuel-ts/math";
4411
4627
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4412
4628
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4413
4629
 
@@ -4615,9 +4831,8 @@ var Account = class extends AbstractAccount {
4615
4831
  * @param assetId - The asset ID to check the balance for.
4616
4832
  * @returns A promise that resolves to the balance amount.
4617
4833
  */
4618
- async getBalance(assetId) {
4619
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4620
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4834
+ async getBalance(assetId = BaseAssetId3) {
4835
+ const amount = await this.provider.getBalance(this.address, assetId);
4621
4836
  return amount;
4622
4837
  }
4623
4838
  /**
@@ -4654,37 +4869,33 @@ var Account = class extends AbstractAccount {
4654
4869
  * @param fee - The estimated transaction fee.
4655
4870
  * @returns A promise that resolves when the resources are added to the transaction.
4656
4871
  */
4657
- async fund(request, coinQuantities, fee) {
4658
- const baseAssetId = this.provider.getBaseAssetId();
4659
- const updatedQuantities = addAmountToAsset({
4660
- amount: bn17(fee),
4661
- assetId: baseAssetId,
4662
- coinQuantities
4872
+ async fund(request, params) {
4873
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4874
+ const txRequest = request;
4875
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4876
+ amount: bn18(fee),
4877
+ assetId: BaseAssetId3,
4878
+ coinQuantities: requiredQuantities
4663
4879
  });
4664
4880
  const quantitiesDict = {};
4665
- updatedQuantities.forEach(({ amount, assetId }) => {
4881
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4666
4882
  quantitiesDict[assetId] = {
4667
4883
  required: amount,
4668
- owned: bn17(0)
4884
+ owned: bn18(0)
4669
4885
  };
4670
4886
  });
4671
- const cachedUtxos = [];
4672
- const cachedMessages = [];
4673
- const owner = this.address.toB256();
4674
- request.inputs.forEach((input) => {
4887
+ txRequest.inputs.forEach((input) => {
4675
4888
  const isResource = "amount" in input;
4676
4889
  if (isResource) {
4677
4890
  const isCoin2 = "owner" in input;
4678
4891
  if (isCoin2) {
4679
4892
  const assetId = String(input.assetId);
4680
- if (input.owner === owner && quantitiesDict[assetId]) {
4681
- const amount = bn17(input.amount);
4893
+ if (quantitiesDict[assetId]) {
4894
+ const amount = bn18(input.amount);
4682
4895
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4683
- cachedUtxos.push(input.id);
4684
4896
  }
4685
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4686
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4687
- cachedMessages.push(input.nonce);
4897
+ } else if (input.amount && quantitiesDict[BaseAssetId3]) {
4898
+ quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4688
4899
  }
4689
4900
  }
4690
4901
  });
@@ -4699,12 +4910,23 @@ var Account = class extends AbstractAccount {
4699
4910
  });
4700
4911
  const needsToBeFunded = missingQuantities.length;
4701
4912
  if (needsToBeFunded) {
4702
- const resources = await this.getResourcesToSpend(missingQuantities, {
4703
- messages: cachedMessages,
4704
- utxos: cachedUtxos
4705
- });
4706
- request.addResources(resources);
4913
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4914
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4915
+ txRequest.addResources(resources);
4916
+ }
4917
+ txRequest.shiftPredicateData();
4918
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
4919
+ const requestToBeReEstimate = clone4(txRequest);
4920
+ if (addedSignatures) {
4921
+ Array.from({ length: addedSignatures }).forEach(
4922
+ () => requestToBeReEstimate.addEmptyWitness()
4923
+ );
4707
4924
  }
4925
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
4926
+ transactionRequest: requestToBeReEstimate
4927
+ });
4928
+ txRequest.maxFee = maxFee;
4929
+ return txRequest;
4708
4930
  }
4709
4931
  /**
4710
4932
  * A helper that creates a transfer transaction request and returns it.
@@ -4712,29 +4934,25 @@ var Account = class extends AbstractAccount {
4712
4934
  * @param destination - The address of the destination.
4713
4935
  * @param amount - The amount of coins to transfer.
4714
4936
  * @param assetId - The asset ID of the coins to transfer.
4715
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4937
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4716
4938
  * @returns A promise that resolves to the prepared transaction request.
4717
4939
  */
4718
- async createTransfer(destination, amount, assetId, txParams = {}) {
4719
- const { minGasPrice } = this.provider.getGasConfig();
4720
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4721
- const params = { gasPrice: minGasPrice, ...txParams };
4722
- const request = new ScriptTransactionRequest(params);
4723
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
4724
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4940
+ async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4941
+ const request = new ScriptTransactionRequest(txParams);
4942
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4943
+ const txCost = await this.provider.getTransactionCost(request, {
4725
4944
  estimateTxDependencies: true,
4726
4945
  resourcesOwner: this
4727
4946
  });
4728
- request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4729
- request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4730
- this.validateGas({
4731
- gasUsed,
4732
- gasPrice: request.gasPrice,
4733
- gasLimit: request.gasLimit,
4734
- minGasPrice
4735
- });
4736
- await this.fund(request, requiredQuantities, maxFee);
4737
- request.updatePredicateInputs(estimatedInputs);
4947
+ if ("gasLimit" in txParams) {
4948
+ this.validateGas({
4949
+ gasUsed: txCost.gasUsed,
4950
+ gasLimit: request.gasLimit
4951
+ });
4952
+ }
4953
+ request.gasLimit = txCost.gasUsed;
4954
+ request.maxFee = txCost.maxFee;
4955
+ await this.fund(request, txCost);
4738
4956
  return request;
4739
4957
  }
4740
4958
  /**
@@ -4746,15 +4964,14 @@ var Account = class extends AbstractAccount {
4746
4964
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4747
4965
  * @returns A promise that resolves to the transaction response.
4748
4966
  */
4749
- async transfer(destination, amount, assetId, txParams = {}) {
4750
- if (bn17(amount).lte(0)) {
4967
+ async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4968
+ if (bn18(amount).lte(0)) {
4751
4969
  throw new FuelError15(
4752
4970
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4753
4971
  "Transfer amount must be a positive number."
4754
4972
  );
4755
4973
  }
4756
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4757
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
4974
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
4758
4975
  return this.sendTransaction(request, { estimateTxDependencies: false });
4759
4976
  }
4760
4977
  /**
@@ -4766,40 +4983,38 @@ var Account = class extends AbstractAccount {
4766
4983
  * @param txParams - The optional transaction parameters.
4767
4984
  * @returns A promise that resolves to the transaction response.
4768
4985
  */
4769
- async transferToContract(contractId, amount, assetId, txParams = {}) {
4770
- if (bn17(amount).lte(0)) {
4986
+ async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4987
+ if (bn18(amount).lte(0)) {
4771
4988
  throw new FuelError15(
4772
4989
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4773
4990
  "Transfer amount must be a positive number."
4774
4991
  );
4775
4992
  }
4776
4993
  const contractAddress = Address3.fromAddressOrString(contractId);
4777
- const { minGasPrice } = this.provider.getGasConfig();
4778
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4779
- const params = { gasPrice: minGasPrice, ...txParams };
4780
4994
  const { script, scriptData } = await assembleTransferToContractScript({
4781
4995
  hexlifiedContractId: contractAddress.toB256(),
4782
- amountToTransfer: bn17(amount),
4783
- assetId: assetIdToTransfer
4996
+ amountToTransfer: bn18(amount),
4997
+ assetId
4784
4998
  });
4785
4999
  const request = new ScriptTransactionRequest({
4786
- ...params,
5000
+ ...txParams,
4787
5001
  script,
4788
5002
  scriptData
4789
5003
  });
4790
5004
  request.addContractInputAndOutput(contractAddress);
4791
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4792
- request,
4793
- [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
4794
- );
4795
- request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4796
- this.validateGas({
4797
- gasUsed,
4798
- gasPrice: request.gasPrice,
4799
- gasLimit: request.gasLimit,
4800
- minGasPrice
5005
+ const txCost = await this.provider.getTransactionCost(request, {
5006
+ resourcesOwner: this,
5007
+ quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
4801
5008
  });
4802
- await this.fund(request, requiredQuantities, maxFee);
5009
+ if (txParams.gasLimit) {
5010
+ this.validateGas({
5011
+ gasUsed: txCost.gasUsed,
5012
+ gasLimit: request.gasLimit
5013
+ });
5014
+ }
5015
+ request.gasLimit = txCost.gasUsed;
5016
+ request.maxFee = txCost.maxFee;
5017
+ await this.fund(request, txCost);
4803
5018
  return this.sendTransaction(request);
4804
5019
  }
4805
5020
  /**
@@ -4811,35 +5026,31 @@ var Account = class extends AbstractAccount {
4811
5026
  * @returns A promise that resolves to the transaction response.
4812
5027
  */
4813
5028
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4814
- const { minGasPrice } = this.provider.getGasConfig();
4815
- const baseAssetId = this.provider.getBaseAssetId();
4816
5029
  const recipientAddress = Address3.fromAddressOrString(recipient);
4817
5030
  const recipientDataArray = arrayify14(
4818
5031
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4819
5032
  );
4820
5033
  const amountDataArray = arrayify14(
4821
- "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5034
+ "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
4822
5035
  );
4823
5036
  const script = new Uint8Array([
4824
5037
  ...arrayify14(withdrawScript.bytes),
4825
5038
  ...recipientDataArray,
4826
5039
  ...amountDataArray
4827
5040
  ]);
4828
- const params = { script, gasPrice: minGasPrice, ...txParams };
5041
+ const params = { script, ...txParams };
4829
5042
  const request = new ScriptTransactionRequest(params);
4830
- const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
4831
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4832
- request,
4833
- forwardingQuantities
4834
- );
4835
- request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4836
- this.validateGas({
4837
- gasUsed,
4838
- gasPrice: request.gasPrice,
4839
- gasLimit: request.gasLimit,
4840
- minGasPrice
4841
- });
4842
- await this.fund(request, requiredQuantities, maxFee);
5043
+ const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
5044
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5045
+ if (txParams.gasLimit) {
5046
+ this.validateGas({
5047
+ gasUsed: txCost.gasUsed,
5048
+ gasLimit: request.gasLimit
5049
+ });
5050
+ }
5051
+ request.maxFee = txCost.maxFee;
5052
+ request.gasLimit = txCost.gasUsed;
5053
+ await this.fund(request, txCost);
4843
5054
  return this.sendTransaction(request);
4844
5055
  }
4845
5056
  async signMessage(message) {
@@ -4897,18 +5108,7 @@ var Account = class extends AbstractAccount {
4897
5108
  }
4898
5109
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4899
5110
  }
4900
- validateGas({
4901
- gasUsed,
4902
- gasPrice,
4903
- gasLimit,
4904
- minGasPrice
4905
- }) {
4906
- if (minGasPrice.gt(gasPrice)) {
4907
- throw new FuelError15(
4908
- ErrorCode15.GAS_PRICE_TOO_LOW,
4909
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4910
- );
4911
- }
5111
+ validateGas({ gasUsed, gasLimit }) {
4912
5112
  if (gasUsed.gt(gasLimit)) {
4913
5113
  throw new FuelError15(
4914
5114
  ErrorCode15.GAS_LIMIT_TOO_LOW,
@@ -4920,7 +5120,7 @@ var Account = class extends AbstractAccount {
4920
5120
 
4921
5121
  // src/signer/signer.ts
4922
5122
  import { Address as Address4 } from "@fuel-ts/address";
4923
- import { randomBytes } from "@fuel-ts/crypto";
5123
+ import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
4924
5124
  import { hash } from "@fuel-ts/hasher";
4925
5125
  import { toBytes } from "@fuel-ts/math";
4926
5126
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5013,7 +5213,7 @@ var Signer = class {
5013
5213
  * @returns random 32-byte hashed
5014
5214
  */
5015
5215
  static generatePrivateKey(entropy) {
5016
- return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5216
+ return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5017
5217
  }
5018
5218
  /**
5019
5219
  * Extended publicKey from a compact publicKey
@@ -5032,7 +5232,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5032
5232
  import {
5033
5233
  bufferFromString,
5034
5234
  keccak256,
5035
- randomBytes as randomBytes2,
5235
+ randomBytes as randomBytes3,
5036
5236
  scrypt,
5037
5237
  stringFromBuffer,
5038
5238
  decryptJsonWalletData,
@@ -5055,7 +5255,7 @@ var removeHexPrefix = (hexString) => {
5055
5255
  async function encryptKeystoreWallet(privateKey, address, password) {
5056
5256
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5057
5257
  const ownerAddress = Address5.fromAddressOrString(address);
5058
- const salt = randomBytes2(DEFAULT_KEY_SIZE);
5258
+ const salt = randomBytes3(DEFAULT_KEY_SIZE);
5059
5259
  const key = scrypt({
5060
5260
  password: bufferFromString(password),
5061
5261
  salt,
@@ -5064,7 +5264,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5064
5264
  r: DEFAULT_KDF_PARAMS_R,
5065
5265
  p: DEFAULT_KDF_PARAMS_P
5066
5266
  });
5067
- const iv = randomBytes2(DEFAULT_IV_SIZE);
5267
+ const iv = randomBytes3(DEFAULT_IV_SIZE);
5068
5268
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5069
5269
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5070
5270
  const macHashUint8Array = keccak256(data);
@@ -5200,7 +5400,7 @@ var BaseWalletUnlocked = class extends Account {
5200
5400
  * @param transactionRequestLike - The transaction request to send.
5201
5401
  * @returns A promise that resolves to the TransactionResponse object.
5202
5402
  */
5203
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5403
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5204
5404
  const transactionRequest = transactionRequestify(transactionRequestLike);
5205
5405
  if (estimateTxDependencies) {
5206
5406
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5241,12 +5441,12 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5241
5441
  // src/hdwallet/hdwallet.ts
5242
5442
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5243
5443
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5244
- import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5444
+ import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5245
5445
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5246
5446
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5247
5447
 
5248
5448
  // src/mnemonic/mnemonic.ts
5249
- import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5449
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5250
5450
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5251
5451
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5252
5452
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -7601,7 +7801,7 @@ var Mnemonic = class {
7601
7801
  * @returns A randomly generated mnemonic
7602
7802
  */
7603
7803
  static generate(size = 32, extraEntropy = "") {
7604
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7804
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7605
7805
  return Mnemonic.entropyToMnemonic(entropy);
7606
7806
  }
7607
7807
  };
@@ -7707,7 +7907,7 @@ var HDWallet = class {
7707
7907
  const IR = bytes.slice(32);
7708
7908
  if (privateKey) {
7709
7909
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7710
- const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7910
+ const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
7711
7911
  return new HDWallet({
7712
7912
  privateKey: ki,
7713
7913
  chainCode: IR,
@@ -7972,20 +8172,21 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
7972
8172
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7973
8173
 
7974
8174
  // src/test-utils/seedTestWallet.ts
7975
- import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
8175
+ import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
7976
8176
  var seedTestWallet = async (wallet, quantities) => {
7977
8177
  const genesisWallet = new WalletUnlocked(
7978
- process.env.GENESIS_SECRET || randomBytes4(32),
8178
+ process.env.GENESIS_SECRET || randomBytes5(32),
7979
8179
  wallet.provider
7980
8180
  );
7981
- const resources = await genesisWallet.getResourcesToSpend(quantities);
7982
- const { minGasPrice } = genesisWallet.provider.getGasConfig();
7983
- const request = new ScriptTransactionRequest({
7984
- gasLimit: 1e4,
7985
- gasPrice: minGasPrice
8181
+ const request = new ScriptTransactionRequest();
8182
+ quantities.forEach((quantity) => {
8183
+ const { amount, assetId } = coinQuantityfy(quantity);
8184
+ request.addCoinOutput(wallet.address, amount, assetId);
7986
8185
  });
7987
- request.addResources(resources);
7988
- quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8186
+ const txCost = await genesisWallet.provider.getTransactionCost(request);
8187
+ request.gasLimit = txCost.gasUsed;
8188
+ request.maxFee = txCost.maxFee;
8189
+ await genesisWallet.fund(request, txCost);
7989
8190
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
7990
8191
  };
7991
8192
 
@@ -7999,12 +8200,12 @@ var generateTestWallet = async (provider, quantities) => {
7999
8200
  };
8000
8201
 
8001
8202
  // src/test-utils/launchNode.ts
8002
- import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
8003
- import { toHex as toHex2 } from "@fuel-ts/math";
8004
- import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8203
+ import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8204
+ import { defaultChainConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8005
8205
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
8006
8206
  import { spawn } from "child_process";
8007
8207
  import { randomUUID } from "crypto";
8208
+ import { randomBytes as randomBytes6 } from "ethers";
8008
8209
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
8009
8210
  import os from "os";
8010
8211
  import path from "path";
@@ -8053,12 +8254,12 @@ var launchNode = async ({
8053
8254
  // eslint-disable-next-line no-async-promise-executor
8054
8255
  new Promise(async (resolve, reject) => {
8055
8256
  const remainingArgs = extractRemainingArgs(args, [
8056
- "--chain",
8257
+ "--snapshot",
8057
8258
  "--consensus-key",
8058
8259
  "--db-type",
8059
8260
  "--poa-instant"
8060
8261
  ]);
8061
- const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8262
+ const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8062
8263
  const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
8063
8264
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8064
8265
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
@@ -8077,36 +8278,54 @@ var launchNode = async ({
8077
8278
  let chainConfigPathToUse;
8078
8279
  const prefix = basePath || os.tmpdir();
8079
8280
  const suffix = basePath ? "" : randomUUID();
8080
- const tempDirPath = path.join(prefix, ".fuels", suffix);
8281
+ const tempDirPath = path.join(prefix, ".fuels", suffix, "chainConfigs");
8081
8282
  if (chainConfigPath) {
8082
8283
  chainConfigPathToUse = chainConfigPath;
8083
8284
  } else {
8084
8285
  if (!existsSync(tempDirPath)) {
8085
8286
  mkdirSync(tempDirPath, { recursive: true });
8086
8287
  }
8087
- const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
8088
- let chainConfig = defaultChainConfig;
8288
+ let { stateConfigJson } = defaultChainConfigs;
8289
+ const { chainConfigJson, metadataJson } = defaultChainConfigs;
8290
+ stateConfigJson = {
8291
+ ...stateConfigJson,
8292
+ coins: [
8293
+ ...stateConfigJson.coins.map((coin) => ({
8294
+ ...coin,
8295
+ amount: "18446744073709551615"
8296
+ }))
8297
+ ],
8298
+ messages: stateConfigJson.messages.map((message) => ({
8299
+ ...message,
8300
+ amount: "18446744073709551615"
8301
+ }))
8302
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8303
+ };
8089
8304
  if (!process.env.GENESIS_SECRET) {
8090
8305
  const pk = Signer.generatePrivateKey();
8091
8306
  const signer = new Signer(pk);
8092
8307
  process.env.GENESIS_SECRET = hexlify18(pk);
8093
- chainConfig = {
8094
- ...defaultChainConfig,
8095
- initial_state: {
8096
- ...defaultChainConfig.initial_state,
8097
- coins: [
8098
- ...defaultChainConfig.initial_state.coins,
8099
- {
8100
- owner: signer.address.toHexString(),
8101
- amount: toHex2(1e9),
8102
- asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes329
8103
- }
8104
- ]
8105
- }
8106
- };
8308
+ stateConfigJson.coins.push({
8309
+ tx_id: hexlify18(randomBytes6(34)),
8310
+ owner: signer.address.toHexString(),
8311
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8312
+ amount: "18446744073709551615",
8313
+ asset_id: BaseAssetId4,
8314
+ output_index: 0,
8315
+ tx_pointer_block_height: 0,
8316
+ tx_pointer_tx_idx: 0
8317
+ });
8107
8318
  }
8108
- writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8109
- chainConfigPathToUse = tempChainConfigFilePath;
8319
+ let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8320
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8321
+ fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8322
+ const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8323
+ const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8324
+ const metadataWritePath = path.join(tempDirPath, "metadata.json");
8325
+ writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8326
+ writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8327
+ writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8328
+ chainConfigPathToUse = tempDirPath;
8110
8329
  }
8111
8330
  const child = spawn(
8112
8331
  command,
@@ -8115,10 +8334,10 @@ var launchNode = async ({
8115
8334
  ["--ip", ipToUse],
8116
8335
  ["--port", portToUse],
8117
8336
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8118
- ["--min-gas-price", "0"],
8337
+ ["--min-gas-price", "1"],
8119
8338
  poaInstant ? ["--poa-instant", "true"] : [],
8120
8339
  ["--consensus-key", consensusKey],
8121
- ["--chain", chainConfigPathToUse],
8340
+ ["--snapshot", chainConfigPathToUse],
8122
8341
  "--vm-backtrace",
8123
8342
  "--utxo-validation",
8124
8343
  "--debug",
@@ -8165,10 +8384,9 @@ var launchNode = async ({
8165
8384
  })
8166
8385
  );
8167
8386
  var generateWallets = async (count, provider) => {
8168
- const baseAssetId = provider.getBaseAssetId();
8169
8387
  const wallets = [];
8170
8388
  for (let i = 0; i < count; i += 1) {
8171
- const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8389
+ const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId4]]);
8172
8390
  wallets.push(wallet);
8173
8391
  }
8174
8392
  return wallets;
@@ -8178,7 +8396,7 @@ var launchNodeAndGetWallets = async ({
8178
8396
  walletCount = 10
8179
8397
  } = {}) => {
8180
8398
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8181
- const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8399
+ const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8182
8400
  const wallets = await generateWallets(walletCount, provider);
8183
8401
  const cleanup = () => {
8184
8402
  closeNode();