@fuel-ts/account 0.96.1 → 0.97.0

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.
Files changed (40) hide show
  1. package/dist/account.d.ts +6 -0
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.global.js +563 -298
  6. package/dist/index.global.js.map +1 -1
  7. package/dist/index.js +594 -320
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +600 -327
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/predicate/predicate.d.ts +16 -11
  12. package/dist/predicate/predicate.d.ts.map +1 -1
  13. package/dist/providers/__generated__/operations.d.ts +94 -126
  14. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  15. package/dist/providers/provider.d.ts +5 -8
  16. package/dist/providers/provider.d.ts.map +1 -1
  17. package/dist/providers/transaction-request/blob-transaction-request.d.ts +2 -2
  18. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
  19. package/dist/providers/transaction-summary/get-transaction-summary.d.ts +3 -2
  20. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  21. package/dist/providers/transaction-summary/types.d.ts +38 -8
  22. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  23. package/dist/providers/utils/handle-gql-error-message.d.ts +2 -1
  24. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
  25. package/dist/providers/utils/receipts.d.ts.map +1 -1
  26. package/dist/providers/utils/validate-pagination-args.d.ts +9 -0
  27. package/dist/providers/utils/validate-pagination-args.d.ts.map +1 -0
  28. package/dist/test-utils.global.js +302 -237
  29. package/dist/test-utils.global.js.map +1 -1
  30. package/dist/test-utils.js +276 -211
  31. package/dist/test-utils.js.map +1 -1
  32. package/dist/test-utils.mjs +287 -222
  33. package/dist/test-utils.mjs.map +1 -1
  34. package/dist/utils/deployScriptOrPredicate.d.ts +14 -0
  35. package/dist/utils/deployScriptOrPredicate.d.ts.map +1 -0
  36. package/dist/utils/formatTransferToContractScriptData.d.ts +7 -7
  37. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  38. package/dist/utils/predicate-script-loader-instructions.d.ts +9 -0
  39. package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -0
  40. package/package.json +17 -17
package/dist/index.mjs CHANGED
@@ -29,9 +29,9 @@ var __privateMethod = (obj, member, method) => {
29
29
 
30
30
  // src/account.ts
31
31
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
32
- import { Address as Address3 } from "@fuel-ts/address";
32
+ import { Address as Address4 } from "@fuel-ts/address";
33
33
  import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
34
- import { ErrorCode as ErrorCode16, FuelError as FuelError18 } from "@fuel-ts/errors";
34
+ import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
35
35
  import { AbstractAccount } from "@fuel-ts/interfaces";
36
36
  import { bn as bn19 } from "@fuel-ts/math";
37
37
  import { InputType as InputType8 } from "@fuel-ts/transactions";
@@ -75,7 +75,7 @@ var addAmountToCoinQuantities = (params) => {
75
75
 
76
76
  // src/providers/provider.ts
77
77
  import { Address as Address2 } from "@fuel-ts/address";
78
- import { ErrorCode as ErrorCode14, FuelError as FuelError16 } from "@fuel-ts/errors";
78
+ import { ErrorCode as ErrorCode15, FuelError as FuelError17 } from "@fuel-ts/errors";
79
79
  import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
80
80
  import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
81
81
  import { arrayify as arrayify12, hexlify as hexlify15, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
@@ -128,9 +128,6 @@ var ReceiptFragmentDoc = gql`
128
128
  var SuccessStatusFragmentDoc = gql`
129
129
  fragment SuccessStatusFragment on SuccessStatus {
130
130
  type: __typename
131
- block {
132
- id
133
- }
134
131
  time
135
132
  programState {
136
133
  returnType
@@ -143,6 +140,14 @@ var SuccessStatusFragmentDoc = gql`
143
140
  totalFee
144
141
  }
145
142
  ${ReceiptFragmentDoc}`;
143
+ var SuccessStatusWithBlockIdFragmentDoc = gql`
144
+ fragment SuccessStatusWithBlockIdFragment on SuccessStatus {
145
+ ...SuccessStatusFragment
146
+ block {
147
+ id
148
+ }
149
+ }
150
+ ${SuccessStatusFragmentDoc}`;
146
151
  var MalleableTransactionFieldsFragmentDoc = gql`
147
152
  fragment malleableTransactionFieldsFragment on Transaction {
148
153
  receiptsRoot
@@ -187,9 +192,6 @@ var MalleableTransactionFieldsFragmentDoc = gql`
187
192
  var FailureStatusFragmentDoc = gql`
188
193
  fragment FailureStatusFragment on FailureStatus {
189
194
  type: __typename
190
- block {
191
- id
192
- }
193
195
  totalGas
194
196
  totalFee
195
197
  time
@@ -199,6 +201,14 @@ var FailureStatusFragmentDoc = gql`
199
201
  }
200
202
  }
201
203
  ${ReceiptFragmentDoc}`;
204
+ var FailureStatusWithBlockIdFragmentDoc = gql`
205
+ fragment FailureStatusWithBlockIdFragment on FailureStatus {
206
+ ...FailureStatusFragment
207
+ block {
208
+ id
209
+ }
210
+ }
211
+ ${FailureStatusFragmentDoc}`;
202
212
  var SqueezedOutStatusFragmentDoc = gql`
203
213
  fragment SqueezedOutStatusFragment on SqueezedOutStatus {
204
214
  type: __typename
@@ -211,13 +221,13 @@ var TransactionStatusSubscriptionFragmentDoc = gql`
211
221
  ...SubmittedStatusFragment
212
222
  }
213
223
  ... on SuccessStatus {
214
- ...SuccessStatusFragment
224
+ ...SuccessStatusWithBlockIdFragment
215
225
  transaction {
216
226
  ...malleableTransactionFieldsFragment
217
227
  }
218
228
  }
219
229
  ... on FailureStatus {
220
- ...FailureStatusFragment
230
+ ...FailureStatusWithBlockIdFragment
221
231
  transaction {
222
232
  ...malleableTransactionFieldsFragment
223
233
  }
@@ -227,9 +237,9 @@ var TransactionStatusSubscriptionFragmentDoc = gql`
227
237
  }
228
238
  }
229
239
  ${SubmittedStatusFragmentDoc}
230
- ${SuccessStatusFragmentDoc}
240
+ ${SuccessStatusWithBlockIdFragmentDoc}
231
241
  ${MalleableTransactionFieldsFragmentDoc}
232
- ${FailureStatusFragmentDoc}
242
+ ${FailureStatusWithBlockIdFragmentDoc}
233
243
  ${SqueezedOutStatusFragmentDoc}`;
234
244
  var TransactionStatusFragmentDoc = gql`
235
245
  fragment transactionStatusFragment on TransactionStatus {
@@ -259,6 +269,12 @@ var TransactionFragmentDoc = gql`
259
269
  }
260
270
  }
261
271
  ${TransactionStatusFragmentDoc}`;
272
+ var TransactionRawPayloadFragmentDoc = gql`
273
+ fragment transactionRawPayloadFragment on Transaction {
274
+ id
275
+ rawPayload
276
+ }
277
+ `;
262
278
  var InputEstimatePredicatesFragmentDoc = gql`
263
279
  fragment inputEstimatePredicatesFragment on Input {
264
280
  ... on InputCoin {
@@ -346,7 +362,6 @@ var CoinFragmentDoc = gql`
346
362
  fragment coinFragment on Coin {
347
363
  type: __typename
348
364
  utxoId
349
- owner
350
365
  amount
351
366
  assetId
352
367
  blockCreated
@@ -370,10 +385,15 @@ var MessageFragmentDoc = gql`
370
385
  sender
371
386
  recipient
372
387
  data
373
- nonce
374
388
  daHeight
375
389
  }
376
390
  `;
391
+ var GetMessageFragmentDoc = gql`
392
+ fragment getMessageFragment on Message {
393
+ ...messageFragment
394
+ nonce
395
+ }
396
+ ${MessageFragmentDoc}`;
377
397
  var MessageProofFragmentDoc = gql`
378
398
  fragment messageProofFragment on MessageProof {
379
399
  messageProof {
@@ -418,7 +438,6 @@ var MessageProofFragmentDoc = gql`
418
438
  }
419
439
  sender
420
440
  recipient
421
- nonce
422
441
  amount
423
442
  data
424
443
  }
@@ -567,12 +586,6 @@ var RelayedTransactionStatusFragmentDoc = gql`
567
586
  }
568
587
  }
569
588
  `;
570
- var TransactionRawPayloadFragmentDoc = gql`
571
- fragment transactionRawPayload on Transaction {
572
- id
573
- rawPayload
574
- }
575
- `;
576
589
  var GetVersionDocument = gql`
577
590
  query getVersion {
578
591
  nodeInfo {
@@ -615,16 +628,34 @@ var GetTransactionDocument = gql`
615
628
  var GetTransactionWithReceiptsDocument = gql`
616
629
  query getTransactionWithReceipts($transactionId: TransactionId!) {
617
630
  transaction(id: $transactionId) {
618
- ...transactionFragment
631
+ id
632
+ rawPayload
633
+ status {
634
+ ... on SubmittedStatus {
635
+ ...SubmittedStatusFragment
636
+ }
637
+ ... on SuccessStatus {
638
+ ...SuccessStatusWithBlockIdFragment
639
+ }
640
+ ... on FailureStatus {
641
+ ...FailureStatusWithBlockIdFragment
642
+ }
643
+ ... on SqueezedOutStatus {
644
+ ...SqueezedOutStatusFragment
645
+ }
646
+ }
619
647
  }
620
648
  }
621
- ${TransactionFragmentDoc}`;
649
+ ${SubmittedStatusFragmentDoc}
650
+ ${SuccessStatusWithBlockIdFragmentDoc}
651
+ ${FailureStatusWithBlockIdFragmentDoc}
652
+ ${SqueezedOutStatusFragmentDoc}`;
622
653
  var GetTransactionsDocument = gql`
623
654
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
624
655
  transactions(after: $after, before: $before, first: $first, last: $last) {
625
656
  edges {
626
657
  node {
627
- ...transactionFragment
658
+ rawPayload
628
659
  }
629
660
  }
630
661
  pageInfo {
@@ -632,8 +663,7 @@ var GetTransactionsDocument = gql`
632
663
  }
633
664
  }
634
665
  }
635
- ${TransactionFragmentDoc}
636
- ${PageInfoFragmentDoc}`;
666
+ ${PageInfoFragmentDoc}`;
637
667
  var GetTransactionsByOwnerDocument = gql`
638
668
  query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
639
669
  transactionsByOwner(
@@ -692,7 +722,7 @@ var GetBlockWithTransactionsDocument = gql`
692
722
  block(id: $blockId, height: $blockHeight) {
693
723
  ...blockFragment
694
724
  transactions {
695
- ...transactionRawPayload
725
+ ...transactionRawPayloadFragment
696
726
  }
697
727
  }
698
728
  }
@@ -717,6 +747,7 @@ var GetCoinDocument = gql`
717
747
  query getCoin($coinId: UtxoId!) {
718
748
  coin(utxoId: $coinId) {
719
749
  ...coinFragment
750
+ owner
720
751
  }
721
752
  }
722
753
  ${CoinFragmentDoc}`;
@@ -825,13 +856,13 @@ var GetMessagesDocument = gql`
825
856
  }
826
857
  edges {
827
858
  node {
828
- ...messageFragment
859
+ ...getMessageFragment
829
860
  }
830
861
  }
831
862
  }
832
863
  }
833
864
  ${PageInfoFragmentDoc}
834
- ${MessageFragmentDoc}`;
865
+ ${GetMessageFragmentDoc}`;
835
866
  var GetMessageProofDocument = gql`
836
867
  query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
837
868
  messageProof(
@@ -1372,9 +1403,11 @@ function assembleReceiptByType(receipt) {
1372
1403
  const { receiptType } = receipt;
1373
1404
  switch (receiptType) {
1374
1405
  case "CALL" /* Call */: {
1406
+ const id = hexOrZero(receipt.id || receipt.contractId);
1375
1407
  const callReceipt = {
1376
1408
  type: ReceiptType.Call,
1377
- from: hexOrZero(receipt.id || receipt.contractId),
1409
+ id,
1410
+ from: id,
1378
1411
  to: hexOrZero(receipt?.to),
1379
1412
  amount: bn4(receipt.amount),
1380
1413
  assetId: hexOrZero(receipt.assetId),
@@ -1431,24 +1464,36 @@ function assembleReceiptByType(receipt) {
1431
1464
  return revertReceipt;
1432
1465
  }
1433
1466
  case "LOG" /* Log */: {
1467
+ const ra = bn4(receipt.ra);
1468
+ const rb = bn4(receipt.rb);
1469
+ const rc = bn4(receipt.rc);
1470
+ const rd = bn4(receipt.rd);
1434
1471
  const logReceipt = {
1435
1472
  type: ReceiptType.Log,
1436
1473
  id: hexOrZero(receipt.id || receipt.contractId),
1437
- val0: bn4(receipt.ra),
1438
- val1: bn4(receipt.rb),
1439
- val2: bn4(receipt.rc),
1440
- val3: bn4(receipt.rd),
1474
+ ra,
1475
+ rb,
1476
+ rc,
1477
+ rd,
1478
+ val0: ra,
1479
+ val1: rb,
1480
+ val2: rc,
1481
+ val3: rd,
1441
1482
  pc: bn4(receipt.pc),
1442
1483
  is: bn4(receipt.is)
1443
1484
  };
1444
1485
  return logReceipt;
1445
1486
  }
1446
1487
  case "LOG_DATA" /* LogData */: {
1488
+ const ra = bn4(receipt.ra);
1489
+ const rb = bn4(receipt.rb);
1447
1490
  const logDataReceipt = {
1448
1491
  type: ReceiptType.LogData,
1449
1492
  id: hexOrZero(receipt.id || receipt.contractId),
1450
- val0: bn4(receipt.ra),
1451
- val1: bn4(receipt.rb),
1493
+ ra,
1494
+ rb,
1495
+ val0: ra,
1496
+ val1: rb,
1452
1497
  ptr: bn4(receipt.ptr),
1453
1498
  len: bn4(receipt.len),
1454
1499
  digest: hexOrZero(receipt.digest),
@@ -1459,9 +1504,11 @@ function assembleReceiptByType(receipt) {
1459
1504
  return logDataReceipt;
1460
1505
  }
1461
1506
  case "TRANSFER" /* Transfer */: {
1507
+ const id = hexOrZero(receipt.id || receipt.contractId);
1462
1508
  const transferReceipt = {
1463
1509
  type: ReceiptType.Transfer,
1464
- from: hexOrZero(receipt.id || receipt.contractId),
1510
+ id,
1511
+ from: id,
1465
1512
  to: hexOrZero(receipt.toAddress || receipt?.to),
1466
1513
  amount: bn4(receipt.amount),
1467
1514
  assetId: hexOrZero(receipt.assetId),
@@ -1471,9 +1518,11 @@ function assembleReceiptByType(receipt) {
1471
1518
  return transferReceipt;
1472
1519
  }
1473
1520
  case "TRANSFER_OUT" /* TransferOut */: {
1521
+ const id = hexOrZero(receipt.id || receipt.contractId);
1474
1522
  const transferOutReceipt = {
1475
1523
  type: ReceiptType.TransferOut,
1476
- from: hexOrZero(receipt.id || receipt.contractId),
1524
+ id,
1525
+ from: id,
1477
1526
  to: hexOrZero(receipt.toAddress || receipt.to),
1478
1527
  amount: bn4(receipt.amount),
1479
1528
  assetId: hexOrZero(receipt.assetId),
@@ -2543,7 +2592,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2543
2592
  type = TransactionType.Blob;
2544
2593
  /** Blob ID */
2545
2594
  blobId;
2546
- /** Witness index of contract bytecode to create */
2595
+ /** Witness index of the bytecode to create */
2547
2596
  witnessIndex;
2548
2597
  /**
2549
2598
  * Creates an instance `BlobTransactionRequest`.
@@ -3930,14 +3979,14 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3930
3979
  switch (gqlTransactionStatus.type) {
3931
3980
  case "SuccessStatus":
3932
3981
  time = gqlTransactionStatus.time;
3933
- blockId = gqlTransactionStatus.block.id;
3982
+ blockId = gqlTransactionStatus.block?.id;
3934
3983
  isStatusSuccess = true;
3935
3984
  totalFee = bn14(gqlTransactionStatus.totalFee);
3936
3985
  totalGas = bn14(gqlTransactionStatus.totalGas);
3937
3986
  break;
3938
3987
  case "FailureStatus":
3939
3988
  time = gqlTransactionStatus.time;
3940
- blockId = gqlTransactionStatus.block.id;
3989
+ blockId = gqlTransactionStatus.block?.id;
3941
3990
  isStatusFailure = true;
3942
3991
  totalFee = bn14(gqlTransactionStatus.totalFee);
3943
3992
  totalGas = bn14(gqlTransactionStatus.totalGas);
@@ -4248,8 +4297,8 @@ var TransactionResponse = class {
4248
4297
  const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
4249
4298
  transactionId: this.id
4250
4299
  });
4251
- for await (const sub of subscription) {
4252
- const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
4300
+ for await (const sub2 of subscription) {
4301
+ const statusChange = "statusChange" in sub2 ? sub2.statusChange : sub2.submitAndAwaitStatus;
4253
4302
  this.status = statusChange;
4254
4303
  if (statusChange.type === "SqueezedOutStatus") {
4255
4304
  this.unsetResourceCache();
@@ -4372,11 +4421,53 @@ var handleGqlErrorMessage = (errorMessage, rawError) => {
4372
4421
  {},
4373
4422
  rawError
4374
4423
  );
4424
+ case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
4425
+ throw new FuelError15(
4426
+ ErrorCode13.MAX_COINS_REACHED,
4427
+ "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
4428
+ {},
4429
+ rawError
4430
+ );
4375
4431
  default:
4376
4432
  throw new FuelError15(ErrorCode13.INVALID_REQUEST, errorMessage);
4377
4433
  }
4378
4434
  };
4379
4435
 
4436
+ // src/providers/utils/validate-pagination-args.ts
4437
+ import { FuelError as FuelError16, ErrorCode as ErrorCode14 } from "@fuel-ts/errors";
4438
+ var validatePaginationArgs = (params) => {
4439
+ const { paginationLimit, inputArgs = {} } = params;
4440
+ const { first, last, after, before } = inputArgs;
4441
+ if (after && before) {
4442
+ throw new FuelError16(
4443
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4444
+ 'Pagination arguments "after" and "before" cannot be used together'
4445
+ );
4446
+ }
4447
+ if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
4448
+ throw new FuelError16(
4449
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4450
+ `Pagination limit for this query cannot exceed ${paginationLimit} items`
4451
+ );
4452
+ }
4453
+ if (first && before) {
4454
+ throw new FuelError16(
4455
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4456
+ 'The use of pagination argument "first" with "before" is not supported'
4457
+ );
4458
+ }
4459
+ if (last && after) {
4460
+ throw new FuelError16(
4461
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4462
+ 'The use of pagination argument "last" with "after" is not supported'
4463
+ );
4464
+ }
4465
+ if (!first && !last) {
4466
+ inputArgs.first = paginationLimit;
4467
+ }
4468
+ return inputArgs;
4469
+ };
4470
+
4380
4471
  // src/providers/provider.ts
4381
4472
  var MAX_RETRIES = 10;
4382
4473
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
@@ -4521,7 +4612,7 @@ var _Provider = class {
4521
4612
  try {
4522
4613
  parsedUrl = new URL(url);
4523
4614
  } catch (error) {
4524
- throw new FuelError16(FuelError16.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4615
+ throw new FuelError17(FuelError17.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4525
4616
  }
4526
4617
  const username = parsedUrl.username;
4527
4618
  const password = parsedUrl.password;
@@ -4556,8 +4647,8 @@ var _Provider = class {
4556
4647
  getChain() {
4557
4648
  const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4558
4649
  if (!chain) {
4559
- throw new FuelError16(
4560
- ErrorCode14.CHAIN_INFO_CACHE_EMPTY,
4650
+ throw new FuelError17(
4651
+ ErrorCode15.CHAIN_INFO_CACHE_EMPTY,
4561
4652
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4562
4653
  );
4563
4654
  }
@@ -4571,8 +4662,8 @@ var _Provider = class {
4571
4662
  getNode() {
4572
4663
  const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
4573
4664
  if (!node) {
4574
- throw new FuelError16(
4575
- ErrorCode14.NODE_INFO_CACHE_EMPTY,
4665
+ throw new FuelError17(
4666
+ ErrorCode15.NODE_INFO_CACHE_EMPTY,
4576
4667
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4577
4668
  );
4578
4669
  }
@@ -4798,14 +4889,14 @@ Supported fuel-core version: ${supportedVersion}.`
4798
4889
  }
4799
4890
  } = this.getChain();
4800
4891
  if (bn17(tx.inputs.length).gt(maxInputs)) {
4801
- throw new FuelError16(
4802
- ErrorCode14.MAX_INPUTS_EXCEEDED,
4892
+ throw new FuelError17(
4893
+ ErrorCode15.MAX_INPUTS_EXCEEDED,
4803
4894
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
4804
4895
  );
4805
4896
  }
4806
4897
  if (bn17(tx.outputs.length).gt(maxOutputs)) {
4807
- throw new FuelError16(
4808
- ErrorCode14.MAX_OUTPUTS_EXCEEDED,
4898
+ throw new FuelError17(
4899
+ ErrorCode15.MAX_OUTPUTS_EXCEEDED,
4809
4900
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
4810
4901
  );
4811
4902
  }
@@ -5218,7 +5309,7 @@ Supported fuel-core version: ${supportedVersion}.`
5218
5309
  const {
5219
5310
  coins: { edges, pageInfo }
5220
5311
  } = await this.operations.getCoins({
5221
- ...this.validatePaginationArgs({
5312
+ ...validatePaginationArgs({
5222
5313
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
5223
5314
  inputArgs: paginationArgs
5224
5315
  }),
@@ -5228,7 +5319,7 @@ Supported fuel-core version: ${supportedVersion}.`
5228
5319
  id: node.utxoId,
5229
5320
  assetId: node.assetId,
5230
5321
  amount: bn17(node.amount),
5231
- owner: Address2.fromAddressOrString(node.owner),
5322
+ owner: ownerAddress,
5232
5323
  blockCreated: bn17(node.blockCreated),
5233
5324
  txCreatedIdx: bn17(node.txCreatedIdx)
5234
5325
  }));
@@ -5282,7 +5373,7 @@ Supported fuel-core version: ${supportedVersion}.`
5282
5373
  id: coin.utxoId,
5283
5374
  amount: bn17(coin.amount),
5284
5375
  assetId: coin.assetId,
5285
- owner: Address2.fromAddressOrString(coin.owner),
5376
+ owner: ownerAddress,
5286
5377
  blockCreated: bn17(coin.blockCreated),
5287
5378
  txCreatedIdx: bn17(coin.txCreatedIdx)
5288
5379
  };
@@ -5357,7 +5448,7 @@ Supported fuel-core version: ${supportedVersion}.`
5357
5448
  const {
5358
5449
  blocks: { edges, pageInfo }
5359
5450
  } = await this.operations.getBlocks({
5360
- ...this.validatePaginationArgs({
5451
+ ...validatePaginationArgs({
5361
5452
  paginationLimit: BLOCKS_PAGE_SIZE_LIMIT,
5362
5453
  inputArgs: params
5363
5454
  })
@@ -5436,7 +5527,7 @@ Supported fuel-core version: ${supportedVersion}.`
5436
5527
  0
5437
5528
  )?.[0];
5438
5529
  } catch (error) {
5439
- if (error instanceof FuelError16 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5530
+ if (error instanceof FuelError17 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5440
5531
  console.warn("Unsupported transaction type encountered");
5441
5532
  return null;
5442
5533
  }
@@ -5452,7 +5543,7 @@ Supported fuel-core version: ${supportedVersion}.`
5452
5543
  const {
5453
5544
  transactions: { edges, pageInfo }
5454
5545
  } = await this.operations.getTransactions({
5455
- ...this.validatePaginationArgs({
5546
+ ...validatePaginationArgs({
5456
5547
  inputArgs: paginationArgs,
5457
5548
  paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
5458
5549
  })
@@ -5462,7 +5553,7 @@ Supported fuel-core version: ${supportedVersion}.`
5462
5553
  try {
5463
5554
  return coder.decode(arrayify12(rawPayload), 0)[0];
5464
5555
  } catch (error) {
5465
- if (error instanceof FuelError16 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5556
+ if (error instanceof FuelError17 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5466
5557
  console.warn("Unsupported transaction type encountered");
5467
5558
  return null;
5468
5559
  }
@@ -5547,7 +5638,7 @@ Supported fuel-core version: ${supportedVersion}.`
5547
5638
  const {
5548
5639
  messages: { edges, pageInfo }
5549
5640
  } = await this.operations.getMessages({
5550
- ...this.validatePaginationArgs({
5641
+ ...validatePaginationArgs({
5551
5642
  inputArgs: paginationArgs,
5552
5643
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
5553
5644
  }),
@@ -5588,8 +5679,8 @@ Supported fuel-core version: ${supportedVersion}.`
5588
5679
  nonce
5589
5680
  };
5590
5681
  if (commitBlockId && commitBlockHeight) {
5591
- throw new FuelError16(
5592
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5682
+ throw new FuelError17(
5683
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
5593
5684
  "commitBlockId and commitBlockHeight cannot be used together"
5594
5685
  );
5595
5686
  }
@@ -5771,13 +5862,13 @@ Supported fuel-core version: ${supportedVersion}.`
5771
5862
  messageId: InputMessageCoder2.getMessageId({
5772
5863
  sender: rawMessage.sender,
5773
5864
  recipient: rawMessage.recipient,
5774
- nonce: rawMessage.nonce,
5865
+ nonce,
5775
5866
  amount: bn17(rawMessage.amount),
5776
5867
  data: rawMessage.data
5777
5868
  }),
5778
5869
  sender: Address2.fromAddressOrString(rawMessage.sender),
5779
5870
  recipient: Address2.fromAddressOrString(rawMessage.recipient),
5780
- nonce: rawMessage.nonce,
5871
+ nonce,
5781
5872
  amount: bn17(rawMessage.amount),
5782
5873
  data: InputMessageCoder2.decodeData(rawMessage.data),
5783
5874
  daHeight: bn17(rawMessage.daHeight)
@@ -5799,41 +5890,6 @@ Supported fuel-core version: ${supportedVersion}.`
5799
5890
  }
5800
5891
  return relayedTransactionStatus;
5801
5892
  }
5802
- /**
5803
- * @hidden
5804
- */
5805
- validatePaginationArgs(params) {
5806
- const { paginationLimit, inputArgs = {} } = params;
5807
- const { first, last, after, before } = inputArgs;
5808
- if (after && before) {
5809
- throw new FuelError16(
5810
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5811
- 'Pagination arguments "after" and "before" cannot be used together'
5812
- );
5813
- }
5814
- if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
5815
- throw new FuelError16(
5816
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5817
- `Pagination limit for this query cannot exceed ${paginationLimit} items`
5818
- );
5819
- }
5820
- if (first && before) {
5821
- throw new FuelError16(
5822
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5823
- 'The use of pagination argument "first" with "before" is not supported'
5824
- );
5825
- }
5826
- if (last && after) {
5827
- throw new FuelError16(
5828
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5829
- 'The use of pagination argument "last" with "after" is not supported'
5830
- );
5831
- }
5832
- if (!first && !last) {
5833
- inputArgs.first = paginationLimit;
5834
- }
5835
- return inputArgs;
5836
- }
5837
5893
  /**
5838
5894
  * @hidden
5839
5895
  */
@@ -5879,7 +5935,7 @@ __publicField(Provider, "chainInfoCache", {});
5879
5935
  __publicField(Provider, "nodeInfoCache", {});
5880
5936
 
5881
5937
  // src/providers/transaction-summary/get-transaction-summary.ts
5882
- import { ErrorCode as ErrorCode15, FuelError as FuelError17 } from "@fuel-ts/errors";
5938
+ import { ErrorCode as ErrorCode16, FuelError as FuelError18 } from "@fuel-ts/errors";
5883
5939
  import { bn as bn18 } from "@fuel-ts/math";
5884
5940
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
5885
5941
  import { arrayify as arrayify13 } from "@fuel-ts/utils";
@@ -5889,8 +5945,8 @@ async function getTransactionSummary(params) {
5889
5945
  transactionId: id
5890
5946
  });
5891
5947
  if (!gqlTransaction) {
5892
- throw new FuelError17(
5893
- ErrorCode15.TRANSACTION_NOT_FOUND,
5948
+ throw new FuelError18(
5949
+ ErrorCode16.TRANSACTION_NOT_FOUND,
5894
5950
  `Transaction not found for given id: ${id}.`
5895
5951
  );
5896
5952
  }
@@ -5958,7 +6014,15 @@ async function getTransactionSummaryFromRequest(params) {
5958
6014
  }
5959
6015
  async function getTransactionsSummaries(params) {
5960
6016
  const { filters, provider, abiMap } = params;
5961
- const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
6017
+ const { owner, ...inputArgs } = filters;
6018
+ const validPaginationParams = validatePaginationArgs({
6019
+ inputArgs,
6020
+ paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
6021
+ });
6022
+ const { transactionsByOwner } = await provider.operations.getTransactionsByOwner({
6023
+ ...validPaginationParams,
6024
+ owner
6025
+ });
5962
6026
  const { edges, pageInfo } = transactionsByOwner;
5963
6027
  const {
5964
6028
  consensusParameters: {
@@ -6677,38 +6741,47 @@ var mergeQuantities = (...coinQuantities) => {
6677
6741
  };
6678
6742
 
6679
6743
  // src/utils/formatTransferToContractScriptData.ts
6680
- import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
6744
+ import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
6745
+ import { Address as Address3 } from "@fuel-ts/address";
6681
6746
  import { BN as BN3 } from "@fuel-ts/math";
6682
- import { arrayify as arrayify14 } from "@fuel-ts/utils";
6747
+ import { arrayify as arrayify14, concat as concat3 } from "@fuel-ts/utils";
6683
6748
  import * as asm from "@fuels/vm-asm";
6684
- var formatTransferToContractScriptData = (params) => {
6685
- const { assetId, amountToTransfer, hexlifiedContractId } = params;
6749
+ var formatTransferToContractScriptData = (transferParams) => {
6686
6750
  const numberCoder = new BigNumberCoder2("u64");
6687
- const encoded = numberCoder.encode(new BN3(amountToTransfer).toNumber());
6688
- const scriptData = Uint8Array.from([
6689
- ...arrayify14(hexlifiedContractId),
6690
- ...encoded,
6691
- ...arrayify14(assetId)
6692
- ]);
6693
- return scriptData;
6751
+ return transferParams.reduce((acc, transferParam) => {
6752
+ const { assetId, amount, contractId } = transferParam;
6753
+ const encoded = numberCoder.encode(new BN3(amount).toNumber());
6754
+ const scriptData = concat3([
6755
+ Address3.fromAddressOrString(contractId).toBytes(),
6756
+ encoded,
6757
+ arrayify14(assetId)
6758
+ ]);
6759
+ return concat3([acc, scriptData]);
6760
+ }, new Uint8Array());
6694
6761
  };
6695
- var assembleTransferToContractScript = async (params) => {
6696
- const scriptData = formatTransferToContractScriptData(params);
6762
+ var assembleTransferToContractScript = async (transferParams) => {
6763
+ const scriptData = formatTransferToContractScriptData(transferParams);
6697
6764
  await asm.initWasm();
6698
- const gtf2 = asm.gtf(16, 0, asm.GTFArgs.ScriptData);
6699
- const addi2 = asm.addi(17, 16, 32);
6700
- const lw2 = asm.lw(18, 17, 0);
6701
- const addi22 = asm.addi(19, 17, 8);
6702
- const tr2 = asm.tr(16, 18, 19);
6703
- const ret2 = asm.ret(1);
6704
- const script = Uint8Array.from([
6705
- ...gtf2.to_bytes(),
6706
- ...addi2.to_bytes(),
6707
- ...lw2.to_bytes(),
6708
- ...addi22.to_bytes(),
6709
- ...tr2.to_bytes(),
6710
- ...ret2.to_bytes()
6711
- ]);
6765
+ let script = new Uint8Array();
6766
+ transferParams.forEach((_, i) => {
6767
+ const offset = (CONTRACT_ID_LEN + WORD_SIZE + ASSET_ID_LEN) * i;
6768
+ script = concat3([
6769
+ script,
6770
+ // Load ScriptData into register 0x10.
6771
+ asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
6772
+ // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
6773
+ asm.addi(17, 16, offset).to_bytes(),
6774
+ // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
6775
+ asm.addi(18, 17, CONTRACT_ID_LEN).to_bytes(),
6776
+ // Load word to the amount at 0x12 into register 0x13.
6777
+ asm.lw(19, 18, 0).to_bytes(),
6778
+ // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
6779
+ asm.addi(20, 18, WORD_SIZE).to_bytes(),
6780
+ // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
6781
+ asm.tr(17, 19, 20).to_bytes()
6782
+ ]);
6783
+ });
6784
+ script = concat3([script, asm.ret(1).to_bytes()]);
6712
6785
  return { script, scriptData };
6713
6786
  };
6714
6787
 
@@ -6738,7 +6811,7 @@ var Account = class extends AbstractAccount {
6738
6811
  super();
6739
6812
  this._provider = provider;
6740
6813
  this._connector = connector;
6741
- this.address = Address3.fromDynamicInput(address);
6814
+ this.address = Address4.fromDynamicInput(address);
6742
6815
  }
6743
6816
  /**
6744
6817
  * The provider used to interact with the network.
@@ -6749,7 +6822,7 @@ var Account = class extends AbstractAccount {
6749
6822
  */
6750
6823
  get provider() {
6751
6824
  if (!this._provider) {
6752
- throw new FuelError18(ErrorCode16.MISSING_PROVIDER, "Provider not set");
6825
+ throw new FuelError19(ErrorCode17.MISSING_PROVIDER, "Provider not set");
6753
6826
  }
6754
6827
  return this._provider;
6755
6828
  }
@@ -6900,8 +6973,8 @@ var Account = class extends AbstractAccount {
6900
6973
  fundingAttempts += 1;
6901
6974
  }
6902
6975
  if (needsToBeFunded) {
6903
- throw new FuelError18(
6904
- ErrorCode16.NOT_ENOUGH_FUNDS,
6976
+ throw new FuelError19(
6977
+ ErrorCode17.NOT_ENOUGH_FUNDS,
6905
6978
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
6906
6979
  );
6907
6980
  }
@@ -6972,7 +7045,7 @@ var Account = class extends AbstractAccount {
6972
7045
  const { destination, amount, assetId } = transferParams;
6973
7046
  this.validateTransferAmount(amount);
6974
7047
  request.addCoinOutput(
6975
- Address3.fromAddressOrString(destination),
7048
+ Address4.fromAddressOrString(destination),
6976
7049
  amount,
6977
7050
  assetId ?? this.provider.getBaseAssetId()
6978
7051
  );
@@ -7006,35 +7079,35 @@ var Account = class extends AbstractAccount {
7006
7079
  * @returns A promise that resolves to the transaction response.
7007
7080
  */
7008
7081
  async transferToContract(contractId, amount, assetId, txParams = {}) {
7009
- if (bn19(amount).lte(0)) {
7010
- throw new FuelError18(
7011
- ErrorCode16.INVALID_TRANSFER_AMOUNT,
7012
- "Transfer amount must be a positive number."
7013
- );
7014
- }
7015
- const contractAddress = Address3.fromAddressOrString(contractId);
7016
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
7017
- const { script, scriptData } = await assembleTransferToContractScript({
7018
- hexlifiedContractId: contractAddress.toB256(),
7019
- amountToTransfer: bn19(amount),
7020
- assetId: assetIdToTransfer
7021
- });
7082
+ return this.batchTransferToContracts([{ amount, assetId, contractId }], txParams);
7083
+ }
7084
+ async batchTransferToContracts(contractTransferParams, txParams = {}) {
7022
7085
  let request = new ScriptTransactionRequest({
7023
- ...txParams,
7024
- script,
7025
- scriptData
7086
+ ...txParams
7026
7087
  });
7027
- request.addContractInputAndOutput(contractAddress);
7028
- const txCost = await this.getTransactionCost(request, {
7029
- quantities: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
7030
- });
7031
- request = this.validateGasLimitAndMaxFee({
7032
- transactionRequest: request,
7033
- gasUsed: txCost.gasUsed,
7034
- maxFee: txCost.maxFee,
7035
- txParams
7088
+ const quantities = [];
7089
+ const transferParams = contractTransferParams.map((transferParam) => {
7090
+ const amount = bn19(transferParam.amount);
7091
+ const contractAddress = Address4.fromAddressOrString(transferParam.contractId);
7092
+ const assetId = transferParam.assetId ? hexlify16(transferParam.assetId) : this.provider.getBaseAssetId();
7093
+ if (amount.lte(0)) {
7094
+ throw new FuelError19(
7095
+ ErrorCode17.INVALID_TRANSFER_AMOUNT,
7096
+ "Transfer amount must be a positive number."
7097
+ );
7098
+ }
7099
+ request.addContractInputAndOutput(contractAddress);
7100
+ quantities.push({ amount, assetId });
7101
+ return {
7102
+ amount,
7103
+ contractId: contractAddress.toB256(),
7104
+ assetId
7105
+ };
7036
7106
  });
7037
- await this.fund(request, txCost);
7107
+ const { script, scriptData } = await assembleTransferToContractScript(transferParams);
7108
+ request.script = script;
7109
+ request.scriptData = scriptData;
7110
+ request = await this.estimateAndFundTransaction(request, txParams, { quantities });
7038
7111
  return this.sendTransaction(request);
7039
7112
  }
7040
7113
  /**
@@ -7046,7 +7119,7 @@ var Account = class extends AbstractAccount {
7046
7119
  * @returns A promise that resolves to the transaction response.
7047
7120
  */
7048
7121
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
7049
- const recipientAddress = Address3.fromAddressOrString(recipient);
7122
+ const recipientAddress = Address4.fromAddressOrString(recipient);
7050
7123
  const recipientDataArray = arrayify15(
7051
7124
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
7052
7125
  );
@@ -7134,7 +7207,7 @@ var Account = class extends AbstractAccount {
7134
7207
  */
7135
7208
  async signMessage(message) {
7136
7209
  if (!this._connector) {
7137
- throw new FuelError18(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
7210
+ throw new FuelError19(ErrorCode17.MISSING_CONNECTOR, "A connector is required to sign messages.");
7138
7211
  }
7139
7212
  return this._connector.signMessage(this.address.toString(), message);
7140
7213
  }
@@ -7146,8 +7219,8 @@ var Account = class extends AbstractAccount {
7146
7219
  */
7147
7220
  async signTransaction(transactionRequestLike) {
7148
7221
  if (!this._connector) {
7149
- throw new FuelError18(
7150
- ErrorCode16.MISSING_CONNECTOR,
7222
+ throw new FuelError19(
7223
+ ErrorCode17.MISSING_CONNECTOR,
7151
7224
  "A connector is required to sign transactions."
7152
7225
  );
7153
7226
  }
@@ -7206,16 +7279,16 @@ var Account = class extends AbstractAccount {
7206
7279
  /** @hidden * */
7207
7280
  validateTransferAmount(amount) {
7208
7281
  if (bn19(amount).lte(0)) {
7209
- throw new FuelError18(
7210
- ErrorCode16.INVALID_TRANSFER_AMOUNT,
7282
+ throw new FuelError19(
7283
+ ErrorCode17.INVALID_TRANSFER_AMOUNT,
7211
7284
  "Transfer amount must be a positive number."
7212
7285
  );
7213
7286
  }
7214
7287
  }
7215
7288
  /** @hidden * */
7216
- async estimateAndFundTransaction(transactionRequest, txParams) {
7289
+ async estimateAndFundTransaction(transactionRequest, txParams, costParams) {
7217
7290
  let request = transactionRequest;
7218
- const txCost = await this.getTransactionCost(request);
7291
+ const txCost = await this.getTransactionCost(request, costParams);
7219
7292
  request = this.validateGasLimitAndMaxFee({
7220
7293
  transactionRequest: request,
7221
7294
  gasUsed: txCost.gasUsed,
@@ -7236,16 +7309,16 @@ var Account = class extends AbstractAccount {
7236
7309
  if (!isDefined3(setGasLimit)) {
7237
7310
  request.gasLimit = gasUsed;
7238
7311
  } else if (gasUsed.gt(setGasLimit)) {
7239
- throw new FuelError18(
7240
- ErrorCode16.GAS_LIMIT_TOO_LOW,
7312
+ throw new FuelError19(
7313
+ ErrorCode17.GAS_LIMIT_TOO_LOW,
7241
7314
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7242
7315
  );
7243
7316
  }
7244
7317
  if (!isDefined3(setMaxFee)) {
7245
7318
  request.maxFee = maxFee;
7246
7319
  } else if (maxFee.gt(setMaxFee)) {
7247
- throw new FuelError18(
7248
- ErrorCode16.MAX_FEE_TOO_LOW,
7320
+ throw new FuelError19(
7321
+ ErrorCode17.MAX_FEE_TOO_LOW,
7249
7322
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
7250
7323
  );
7251
7324
  }
@@ -7258,11 +7331,11 @@ import { hashMessage } from "@fuel-ts/hasher";
7258
7331
  import { hexlify as hexlify19 } from "@fuel-ts/utils";
7259
7332
 
7260
7333
  // src/signer/signer.ts
7261
- import { Address as Address4 } from "@fuel-ts/address";
7334
+ import { Address as Address5 } from "@fuel-ts/address";
7262
7335
  import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
7263
7336
  import { hash as hash2 } from "@fuel-ts/hasher";
7264
7337
  import { toBytes } from "@fuel-ts/math";
7265
- import { hexlify as hexlify17, concat as concat3, arrayify as arrayify16 } from "@fuel-ts/utils";
7338
+ import { hexlify as hexlify17, concat as concat4, arrayify as arrayify16 } from "@fuel-ts/utils";
7266
7339
  import { secp256k1 } from "@noble/curves/secp256k1";
7267
7340
  var Signer = class {
7268
7341
  address;
@@ -7285,7 +7358,7 @@ var Signer = class {
7285
7358
  this.privateKey = hexlify17(privateKeyBytes);
7286
7359
  this.publicKey = hexlify17(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
7287
7360
  this.compressedPublicKey = hexlify17(secp256k1.getPublicKey(privateKeyBytes, true));
7288
- this.address = Address4.fromPublicKey(this.publicKey);
7361
+ this.address = Address5.fromPublicKey(this.publicKey);
7289
7362
  }
7290
7363
  /**
7291
7364
  * Sign data using the Signer instance
@@ -7302,7 +7375,7 @@ var Signer = class {
7302
7375
  const r = toBytes(`0x${signature.r.toString(16)}`, 32);
7303
7376
  const s = toBytes(`0x${signature.s.toString(16)}`, 32);
7304
7377
  s[0] |= (signature.recovery || 0) << 7;
7305
- return hexlify17(concat3([r, s]));
7378
+ return hexlify17(concat4([r, s]));
7306
7379
  }
7307
7380
  /**
7308
7381
  * Add point on the current elliptic curve
@@ -7343,7 +7416,7 @@ var Signer = class {
7343
7416
  * @returns Address from signature
7344
7417
  */
7345
7418
  static recoverAddress(data, signature) {
7346
- return Address4.fromPublicKey(Signer.recoverPublicKey(data, signature));
7419
+ return Address5.fromPublicKey(Signer.recoverPublicKey(data, signature));
7347
7420
  }
7348
7421
  /**
7349
7422
  * Generate a random privateKey
@@ -7352,7 +7425,7 @@ var Signer = class {
7352
7425
  * @returns random 32-byte hashed
7353
7426
  */
7354
7427
  static generatePrivateKey(entropy) {
7355
- return entropy ? hash2(concat3([randomBytes3(32), arrayify16(entropy)])) : randomBytes3(32);
7428
+ return entropy ? hash2(concat4([randomBytes3(32), arrayify16(entropy)])) : randomBytes3(32);
7356
7429
  }
7357
7430
  /**
7358
7431
  * Extended publicKey from a compact publicKey
@@ -7367,7 +7440,7 @@ var Signer = class {
7367
7440
  };
7368
7441
 
7369
7442
  // src/wallet/keystore-wallet.ts
7370
- import { Address as Address5 } from "@fuel-ts/address";
7443
+ import { Address as Address6 } from "@fuel-ts/address";
7371
7444
  import {
7372
7445
  bufferFromString,
7373
7446
  keccak256,
@@ -7378,7 +7451,7 @@ import {
7378
7451
  encryptJsonWalletData,
7379
7452
  randomUUID
7380
7453
  } from "@fuel-ts/crypto";
7381
- import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
7454
+ import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
7382
7455
  import { hexlify as hexlify18 } from "@fuel-ts/utils";
7383
7456
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7384
7457
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -7393,7 +7466,7 @@ var removeHexPrefix = (hexString) => {
7393
7466
  };
7394
7467
  async function encryptKeystoreWallet(privateKey, address, password) {
7395
7468
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
7396
- const ownerAddress = Address5.fromAddressOrString(address);
7469
+ const ownerAddress = Address6.fromAddressOrString(address);
7397
7470
  const salt = randomBytes4(DEFAULT_KEY_SIZE);
7398
7471
  const key = scrypt({
7399
7472
  password: bufferFromString(password),
@@ -7455,8 +7528,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7455
7528
  const macHashUint8Array = keccak256(data);
7456
7529
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
7457
7530
  if (mac !== macHash) {
7458
- throw new FuelError19(
7459
- ErrorCode17.INVALID_PASSWORD,
7531
+ throw new FuelError20(
7532
+ ErrorCode18.INVALID_PASSWORD,
7460
7533
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
7461
7534
  );
7462
7535
  }
@@ -7586,16 +7659,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7586
7659
 
7587
7660
  // src/hdwallet/hdwallet.ts
7588
7661
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
7589
- import { ErrorCode as ErrorCode20, FuelError as FuelError22 } from "@fuel-ts/errors";
7662
+ import { ErrorCode as ErrorCode21, FuelError as FuelError23 } from "@fuel-ts/errors";
7590
7663
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
7591
7664
  import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
7592
- import { arrayify as arrayify19, hexlify as hexlify21, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
7665
+ import { arrayify as arrayify19, hexlify as hexlify21, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
7593
7666
 
7594
7667
  // src/mnemonic/mnemonic.ts
7595
7668
  import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
7596
- import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
7669
+ import { ErrorCode as ErrorCode20, FuelError as FuelError22 } from "@fuel-ts/errors";
7597
7670
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
7598
- import { arrayify as arrayify18, hexlify as hexlify20, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
7671
+ import { arrayify as arrayify18, hexlify as hexlify20, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
7599
7672
 
7600
7673
  // src/wordlists/words/english.ts
7601
7674
  var english = [
@@ -9656,7 +9729,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
9656
9729
  })(Language || {});
9657
9730
 
9658
9731
  // src/mnemonic/utils.ts
9659
- import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
9732
+ import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
9660
9733
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
9661
9734
  import { arrayify as arrayify17 } from "@fuel-ts/utils";
9662
9735
  function getLowerMask(bits) {
@@ -9705,8 +9778,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9705
9778
  for (let i = 0; i < words.length; i += 1) {
9706
9779
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9707
9780
  if (index === -1) {
9708
- throw new FuelError20(
9709
- ErrorCode18.INVALID_MNEMONIC,
9781
+ throw new FuelError21(
9782
+ ErrorCode19.INVALID_MNEMONIC,
9710
9783
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9711
9784
  );
9712
9785
  }
@@ -9722,8 +9795,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9722
9795
  const checksumMask = getUpperMask(checksumBits);
9723
9796
  const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9724
9797
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9725
- throw new FuelError20(
9726
- ErrorCode18.INVALID_CHECKSUM,
9798
+ throw new FuelError21(
9799
+ ErrorCode19.INVALID_CHECKSUM,
9727
9800
  "Checksum validation failed for the provided mnemonic."
9728
9801
  );
9729
9802
  }
@@ -9737,16 +9810,16 @@ var TestnetPRV = "0x04358394";
9737
9810
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9738
9811
  function assertWordList(wordlist) {
9739
9812
  if (wordlist.length !== 2048) {
9740
- throw new FuelError21(
9741
- ErrorCode19.INVALID_WORD_LIST,
9813
+ throw new FuelError22(
9814
+ ErrorCode20.INVALID_WORD_LIST,
9742
9815
  `Expected word list length of 2048, but got ${wordlist.length}.`
9743
9816
  );
9744
9817
  }
9745
9818
  }
9746
9819
  function assertEntropy(entropy) {
9747
9820
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9748
- throw new FuelError21(
9749
- ErrorCode19.INVALID_ENTROPY,
9821
+ throw new FuelError22(
9822
+ ErrorCode20.INVALID_ENTROPY,
9750
9823
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9751
9824
  );
9752
9825
  }
@@ -9756,7 +9829,7 @@ function assertMnemonic(words) {
9756
9829
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9757
9830
  ", "
9758
9831
  )}] words, but got ${words.length}.`;
9759
- throw new FuelError21(ErrorCode19.INVALID_MNEMONIC, errorMsg);
9832
+ throw new FuelError22(ErrorCode20.INVALID_MNEMONIC, errorMsg);
9760
9833
  }
9761
9834
  }
9762
9835
  var Mnemonic = class {
@@ -9874,8 +9947,8 @@ var Mnemonic = class {
9874
9947
  static masterKeysFromSeed(seed) {
9875
9948
  const seedArray = arrayify18(seed);
9876
9949
  if (seedArray.length < 16 || seedArray.length > 64) {
9877
- throw new FuelError21(
9878
- ErrorCode19.INVALID_SEED,
9950
+ throw new FuelError22(
9951
+ ErrorCode20.INVALID_SEED,
9879
9952
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9880
9953
  );
9881
9954
  }
@@ -9896,16 +9969,16 @@ var Mnemonic = class {
9896
9969
  const index = "0x00000000";
9897
9970
  const chainCode = masterKey.slice(32);
9898
9971
  const privateKey = masterKey.slice(0, 32);
9899
- const extendedKey = concat4([
9972
+ const extendedKey = concat5([
9900
9973
  prefix,
9901
9974
  depth,
9902
9975
  fingerprint,
9903
9976
  index,
9904
9977
  chainCode,
9905
- concat4(["0x00", privateKey])
9978
+ concat5(["0x00", privateKey])
9906
9979
  ]);
9907
9980
  const checksum = dataSlice(sha2563(sha2563(extendedKey)), 0, 4);
9908
- return encodeBase58(concat4([extendedKey, checksum]));
9981
+ return encodeBase58(concat5([extendedKey, checksum]));
9909
9982
  }
9910
9983
  /**
9911
9984
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -9920,7 +9993,7 @@ var Mnemonic = class {
9920
9993
  * @returns A randomly generated mnemonic
9921
9994
  */
9922
9995
  static generate(size = 32, extraEntropy = "") {
9923
- const entropy = extraEntropy ? sha2563(concat4([randomBytes5(size), arrayify18(extraEntropy)])) : randomBytes5(size);
9996
+ const entropy = extraEntropy ? sha2563(concat5([randomBytes5(size), arrayify18(extraEntropy)])) : randomBytes5(size);
9924
9997
  return Mnemonic.entropyToMnemonic(entropy);
9925
9998
  }
9926
9999
  };
@@ -9933,7 +10006,7 @@ var MainnetPUB = hexlify21("0x0488b21e");
9933
10006
  var TestnetPRV2 = hexlify21("0x04358394");
9934
10007
  var TestnetPUB = hexlify21("0x043587cf");
9935
10008
  function base58check(data) {
9936
- return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
10009
+ return encodeBase582(concat6([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
9937
10010
  }
9938
10011
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
9939
10012
  if (isPublic) {
@@ -9952,7 +10025,7 @@ function isValidExtendedKey(extendedKey) {
9952
10025
  function parsePath(path, depth = 0) {
9953
10026
  const components = path.split("/");
9954
10027
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
9955
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path}`);
10028
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, `invalid path - ${path}`);
9956
10029
  }
9957
10030
  if (components[0] === "m") {
9958
10031
  components.shift();
@@ -9981,8 +10054,8 @@ var HDWallet = class {
9981
10054
  this.privateKey = hexlify21(config.privateKey);
9982
10055
  } else {
9983
10056
  if (!config.publicKey) {
9984
- throw new FuelError22(
9985
- ErrorCode20.HD_WALLET_ERROR,
10057
+ throw new FuelError23(
10058
+ ErrorCode21.HD_WALLET_ERROR,
9986
10059
  "Both public and private Key cannot be missing. At least one should be provided."
9987
10060
  );
9988
10061
  }
@@ -10011,8 +10084,8 @@ var HDWallet = class {
10011
10084
  const data = new Uint8Array(37);
10012
10085
  if (index & HARDENED_INDEX) {
10013
10086
  if (!privateKey) {
10014
- throw new FuelError22(
10015
- ErrorCode20.HD_WALLET_ERROR,
10087
+ throw new FuelError23(
10088
+ ErrorCode21.HD_WALLET_ERROR,
10016
10089
  "Cannot derive a hardened index without a private Key."
10017
10090
  );
10018
10091
  }
@@ -10064,8 +10137,8 @@ var HDWallet = class {
10064
10137
  */
10065
10138
  toExtendedKey(isPublic = false, testnet = false) {
10066
10139
  if (this.depth >= 256) {
10067
- throw new FuelError22(
10068
- ErrorCode20.HD_WALLET_ERROR,
10140
+ throw new FuelError23(
10141
+ ErrorCode21.HD_WALLET_ERROR,
10069
10142
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
10070
10143
  );
10071
10144
  }
@@ -10074,8 +10147,8 @@ var HDWallet = class {
10074
10147
  const parentFingerprint = this.parentFingerprint;
10075
10148
  const index = toHex(this.index, 4);
10076
10149
  const chainCode = this.chainCode;
10077
- const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
10078
- const extendedKey = arrayify19(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
10150
+ const key = this.privateKey != null && !isPublic ? concat6(["0x00", this.privateKey]) : this.publicKey;
10151
+ const extendedKey = arrayify19(concat6([prefix, depth, parentFingerprint, index, chainCode, key]));
10079
10152
  return base58check(extendedKey);
10080
10153
  }
10081
10154
  /**
@@ -10096,10 +10169,10 @@ var HDWallet = class {
10096
10169
  const bytes = arrayify19(decoded);
10097
10170
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10098
10171
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10099
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10172
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10100
10173
  }
10101
10174
  if (!validChecksum) {
10102
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10175
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10103
10176
  }
10104
10177
  const depth = bytes[4];
10105
10178
  const parentFingerprint = hexlify21(bytes.slice(5, 9));
@@ -10107,14 +10180,14 @@ var HDWallet = class {
10107
10180
  const chainCode = hexlify21(bytes.slice(13, 45));
10108
10181
  const key = bytes.slice(45, 78);
10109
10182
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10110
- throw new FuelError22(
10111
- ErrorCode20.HD_WALLET_ERROR,
10183
+ throw new FuelError23(
10184
+ ErrorCode21.HD_WALLET_ERROR,
10112
10185
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
10113
10186
  );
10114
10187
  }
10115
10188
  if (isPublicExtendedKey(bytes)) {
10116
10189
  if (key[0] !== 3) {
10117
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
10190
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Invalid public extended key.");
10118
10191
  }
10119
10192
  return new HDWallet({
10120
10193
  publicKey: key,
@@ -10125,7 +10198,7 @@ var HDWallet = class {
10125
10198
  });
10126
10199
  }
10127
10200
  if (key[0] !== 0) {
10128
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
10201
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Invalid private extended key.");
10129
10202
  }
10130
10203
  return new HDWallet({
10131
10204
  privateKey: key.slice(1),
@@ -10291,9 +10364,9 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
10291
10364
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
10292
10365
 
10293
10366
  // src/wallet-manager/wallet-manager.ts
10294
- import { Address as Address8 } from "@fuel-ts/address";
10367
+ import { Address as Address9 } from "@fuel-ts/address";
10295
10368
  import { encrypt, decrypt } from "@fuel-ts/crypto";
10296
- import { ErrorCode as ErrorCode23, FuelError as FuelError25 } from "@fuel-ts/errors";
10369
+ import { ErrorCode as ErrorCode24, FuelError as FuelError26 } from "@fuel-ts/errors";
10297
10370
  import { EventEmitter } from "events";
10298
10371
 
10299
10372
  // src/wallet-manager/storages/memory-storage.ts
@@ -10315,8 +10388,8 @@ var MemoryStorage = class {
10315
10388
  };
10316
10389
 
10317
10390
  // src/wallet-manager/vaults/mnemonic-vault.ts
10318
- import { Address as Address6 } from "@fuel-ts/address";
10319
- import { ErrorCode as ErrorCode21, FuelError as FuelError23 } from "@fuel-ts/errors";
10391
+ import { Address as Address7 } from "@fuel-ts/address";
10392
+ import { ErrorCode as ErrorCode22, FuelError as FuelError24 } from "@fuel-ts/errors";
10320
10393
  var _secret;
10321
10394
  var MnemonicVault = class {
10322
10395
  constructor(options) {
@@ -10364,7 +10437,7 @@ var MnemonicVault = class {
10364
10437
  }
10365
10438
  exportAccount(address) {
10366
10439
  let numberOfAccounts = 0;
10367
- const ownerAddress = Address6.fromAddressOrString(address);
10440
+ const ownerAddress = Address7.fromAddressOrString(address);
10368
10441
  do {
10369
10442
  const wallet = Wallet.fromMnemonic(__privateGet(this, _secret), this.getDerivePath(numberOfAccounts));
10370
10443
  if (wallet.address.equals(ownerAddress)) {
@@ -10372,8 +10445,8 @@ var MnemonicVault = class {
10372
10445
  }
10373
10446
  numberOfAccounts += 1;
10374
10447
  } while (numberOfAccounts < this.numberOfAccounts);
10375
- throw new FuelError23(
10376
- ErrorCode21.WALLET_MANAGER_ERROR,
10448
+ throw new FuelError24(
10449
+ ErrorCode22.WALLET_MANAGER_ERROR,
10377
10450
  `Account with address '${address}' not found in derived wallets.`
10378
10451
  );
10379
10452
  }
@@ -10386,8 +10459,8 @@ _secret = new WeakMap();
10386
10459
  __publicField(MnemonicVault, "type", "mnemonic");
10387
10460
 
10388
10461
  // src/wallet-manager/vaults/privatekey-vault.ts
10389
- import { Address as Address7 } from "@fuel-ts/address";
10390
- import { ErrorCode as ErrorCode22, FuelError as FuelError24 } from "@fuel-ts/errors";
10462
+ import { Address as Address8 } from "@fuel-ts/address";
10463
+ import { ErrorCode as ErrorCode23, FuelError as FuelError25 } from "@fuel-ts/errors";
10391
10464
  var _privateKeys;
10392
10465
  var PrivateKeyVault = class {
10393
10466
  /**
@@ -10423,13 +10496,13 @@ var PrivateKeyVault = class {
10423
10496
  return this.getPublicAccount(wallet.privateKey);
10424
10497
  }
10425
10498
  exportAccount(address) {
10426
- const ownerAddress = Address7.fromAddressOrString(address);
10499
+ const ownerAddress = Address8.fromAddressOrString(address);
10427
10500
  const privateKey = __privateGet(this, _privateKeys).find(
10428
10501
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
10429
10502
  );
10430
10503
  if (!privateKey) {
10431
- throw new FuelError24(
10432
- ErrorCode22.WALLET_MANAGER_ERROR,
10504
+ throw new FuelError25(
10505
+ ErrorCode23.WALLET_MANAGER_ERROR,
10433
10506
  `No private key found for address '${address}'.`
10434
10507
  );
10435
10508
  }
@@ -10453,7 +10526,7 @@ var ERROR_MESSAGES = {
10453
10526
  };
10454
10527
  function assert(condition, message) {
10455
10528
  if (!condition) {
10456
- throw new FuelError25(ErrorCode23.WALLET_MANAGER_ERROR, message);
10529
+ throw new FuelError26(ErrorCode24.WALLET_MANAGER_ERROR, message);
10457
10530
  }
10458
10531
  }
10459
10532
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -10521,7 +10594,7 @@ var _WalletManager = class extends EventEmitter {
10521
10594
  * Create a Wallet instance for the specific account
10522
10595
  */
10523
10596
  getWallet(address) {
10524
- const ownerAddress = Address8.fromAddressOrString(address);
10597
+ const ownerAddress = Address9.fromAddressOrString(address);
10525
10598
  const vaultState = __privateGet(this, _vaults).find(
10526
10599
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
10527
10600
  );
@@ -10532,7 +10605,7 @@ var _WalletManager = class extends EventEmitter {
10532
10605
  * Export specific account privateKey
10533
10606
  */
10534
10607
  exportPrivateKey(address) {
10535
- const ownerAddress = Address8.fromAddressOrString(address);
10608
+ const ownerAddress = Address9.fromAddressOrString(address);
10536
10609
  assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
10537
10610
  const vaultState = __privateGet(this, _vaults).find(
10538
10611
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
@@ -10679,25 +10752,25 @@ deserializeVaults_fn = function(vaults) {
10679
10752
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
10680
10753
 
10681
10754
  // src/wallet-manager/types.ts
10682
- import { ErrorCode as ErrorCode24, FuelError as FuelError26 } from "@fuel-ts/errors";
10755
+ import { ErrorCode as ErrorCode25, FuelError as FuelError27 } from "@fuel-ts/errors";
10683
10756
  var Vault = class {
10684
10757
  constructor(_options) {
10685
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10758
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10686
10759
  }
10687
10760
  serialize() {
10688
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10761
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10689
10762
  }
10690
10763
  getAccounts() {
10691
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10764
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10692
10765
  }
10693
10766
  addAccount() {
10694
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10767
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10695
10768
  }
10696
10769
  exportAccount(_address) {
10697
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10770
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10698
10771
  }
10699
10772
  getWallet(_address) {
10700
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10773
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10701
10774
  }
10702
10775
  };
10703
10776
  __publicField(Vault, "type");
@@ -10706,35 +10779,237 @@ var StorageAbstract = class {
10706
10779
 
10707
10780
  // src/predicate/predicate.ts
10708
10781
  import { Interface as Interface4 } from "@fuel-ts/abi-coder";
10709
- import { Address as Address9 } from "@fuel-ts/address";
10710
- import { ErrorCode as ErrorCode25, FuelError as FuelError27 } from "@fuel-ts/errors";
10711
- import { arrayify as arrayify21, hexlify as hexlify23, concat as concat7 } from "@fuel-ts/utils";
10782
+ import { Address as Address10 } from "@fuel-ts/address";
10783
+ import { ErrorCode as ErrorCode27, FuelError as FuelError29 } from "@fuel-ts/errors";
10784
+ import { arrayify as arrayify22, hexlify as hexlify23 } from "@fuel-ts/utils";
10712
10785
 
10713
- // src/predicate/utils/getPredicateRoot.ts
10786
+ // src/utils/deployScriptOrPredicate.ts
10787
+ import { FuelError as FuelError28, ErrorCode as ErrorCode26 } from "@fuel-ts/errors";
10714
10788
  import { hash as hash3 } from "@fuel-ts/hasher";
10789
+ import { bn as bn21 } from "@fuel-ts/math";
10790
+ import { arrayify as arrayify20 } from "@fuel-ts/utils";
10791
+
10792
+ // src/utils/predicate-script-loader-instructions.ts
10793
+ import { concat as concat7 } from "@fuel-ts/utils";
10794
+ import * as asm2 from "@fuels/vm-asm";
10795
+ var BLOB_ID_SIZE = 32;
10796
+ var REG_ADDRESS_OF_DATA_AFTER_CODE = 16;
10797
+ var REG_START_OF_LOADED_CODE = 17;
10798
+ var REG_GENERAL_USE = 18;
10799
+ var WORD_SIZE2 = 8;
10800
+ function getDataOffset(binary) {
10801
+ const OFFSET_INDEX = 8;
10802
+ const dataView = new DataView(binary.buffer, OFFSET_INDEX, 8);
10803
+ const dataOffset = dataView.getBigUint64(0, false);
10804
+ return Number(dataOffset);
10805
+ }
10806
+ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
10807
+ const { RegId, Instruction } = asm2;
10808
+ const REG_PC = RegId.pc().to_u8();
10809
+ const REG_SP = RegId.sp().to_u8();
10810
+ const REG_IS = RegId.is().to_u8();
10811
+ const getInstructions = (numOfInstructions2) => [
10812
+ // 1. Load the blob content into memory
10813
+ // Find the start of the hardcoded blob ID, which is located after the loader code ends.
10814
+ asm2.move_(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_PC),
10815
+ // hold the address of the blob ID.
10816
+ asm2.addi(
10817
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10818
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10819
+ numOfInstructions2 * Instruction.size()
10820
+ ),
10821
+ // The code is going to be loaded from the current value of SP onwards, save
10822
+ // the location into REG_START_OF_LOADED_CODE so we can jump into it at the end.
10823
+ asm2.move_(REG_START_OF_LOADED_CODE, REG_SP),
10824
+ // REG_GENERAL_USE to hold the size of the blob.
10825
+ asm2.bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE),
10826
+ // Push the blob contents onto the stack.
10827
+ asm2.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1),
10828
+ // Move on to the data section length
10829
+ asm2.addi(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_ADDRESS_OF_DATA_AFTER_CODE, BLOB_ID_SIZE),
10830
+ // load the size of the data section into REG_GENERAL_USE
10831
+ asm2.lw(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE, 0),
10832
+ // after we have read the length of the data section, we move the pointer to the actual
10833
+ // data by skipping WORD_SIZE bytes.
10834
+ asm2.addi(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_ADDRESS_OF_DATA_AFTER_CODE, WORD_SIZE2),
10835
+ // load the data section of the executable
10836
+ asm2.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 2),
10837
+ // Jump into the memory where the contract is loaded.
10838
+ // What follows is called _jmp_mem by the sway compiler.
10839
+ // Subtract the address contained in IS because jmp will add it back.
10840
+ asm2.sub(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, REG_IS),
10841
+ // jmp will multiply by 4, so we need to divide to cancel that out.
10842
+ asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
10843
+ // Jump to the start of the contract we loaded.
10844
+ asm2.jmp(REG_START_OF_LOADED_CODE)
10845
+ ];
10846
+ const getInstructionsNoDataSection = (numOfInstructions2) => [
10847
+ // 1. Load the blob content into memory
10848
+ // Find the start of the hardcoded blob ID, which is located after the loader code ends.
10849
+ // 1. Load the blob content into memory
10850
+ // Find the start of the hardcoded blob ID, which is located after the loader code ends.
10851
+ asm2.move_(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_PC),
10852
+ // hold the address of the blob ID.
10853
+ asm2.addi(
10854
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10855
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10856
+ numOfInstructions2 * Instruction.size()
10857
+ ),
10858
+ // The code is going to be loaded from the current value of SP onwards, save
10859
+ // the location into REG_START_OF_LOADED_CODE so we can jump into it at the end.
10860
+ asm2.move_(REG_START_OF_LOADED_CODE, REG_SP),
10861
+ // REG_GENERAL_USE to hold the size of the blob.
10862
+ asm2.bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE),
10863
+ // Push the blob contents onto the stack.
10864
+ asm2.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1),
10865
+ // Jump into the memory where the contract is loaded.
10866
+ // What follows is called _jmp_mem by the sway compiler.
10867
+ // Subtract the address contained in IS because jmp will add it back.
10868
+ asm2.sub(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, REG_IS),
10869
+ // jmp will multiply by 4, so we need to divide to cancel that out.
10870
+ asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
10871
+ // Jump to the start of the contract we loaded.
10872
+ asm2.jmp(REG_START_OF_LOADED_CODE)
10873
+ ];
10874
+ const offset = getDataOffset(originalBinary);
10875
+ if (originalBinary.length < offset) {
10876
+ throw new Error(
10877
+ `Data section offset is out of bounds, offset: ${offset}, binary length: ${originalBinary.length}`
10878
+ );
10879
+ }
10880
+ const dataSection = originalBinary.slice(offset);
10881
+ if (dataSection.length > 0) {
10882
+ const numOfInstructions2 = getInstructions(0).length;
10883
+ if (numOfInstructions2 > 65535) {
10884
+ throw new Error("Too many instructions, exceeding u16::MAX.");
10885
+ }
10886
+ const instructionBytes2 = new Uint8Array(
10887
+ getInstructions(numOfInstructions2).flatMap(
10888
+ (instruction) => Array.from(instruction.to_bytes())
10889
+ )
10890
+ );
10891
+ const blobBytes2 = new Uint8Array(blobId);
10892
+ const dataSectionLenBytes = new Uint8Array(8);
10893
+ const dataView = new DataView(dataSectionLenBytes.buffer);
10894
+ dataView.setBigUint64(0, BigInt(dataSection.length), false);
10895
+ const loaderBytecode2 = new Uint8Array([
10896
+ ...instructionBytes2,
10897
+ ...blobBytes2,
10898
+ ...dataSectionLenBytes
10899
+ ]);
10900
+ return {
10901
+ loaderBytecode: concat7([loaderBytecode2, dataSection]),
10902
+ blobOffset: loaderBytecode2.length
10903
+ };
10904
+ }
10905
+ const numOfInstructions = getInstructionsNoDataSection(0).length;
10906
+ if (numOfInstructions > 65535) {
10907
+ throw new Error("Too many instructions, exceeding u16::MAX.");
10908
+ }
10909
+ const instructionBytes = new Uint8Array(
10910
+ getInstructionsNoDataSection(numOfInstructions).flatMap(
10911
+ (instruction) => Array.from(instruction.to_bytes())
10912
+ )
10913
+ );
10914
+ const blobBytes = new Uint8Array(blobId);
10915
+ const loaderBytecode = new Uint8Array([...instructionBytes, ...blobBytes]);
10916
+ return { loaderBytecode };
10917
+ }
10918
+
10919
+ // src/utils/deployScriptOrPredicate.ts
10920
+ async function fundBlobTx(deployer, blobTxRequest) {
10921
+ let totalCost = bn21(0);
10922
+ const chainInfo = deployer.provider.getChain();
10923
+ const gasPrice = await deployer.provider.estimateGasPrice(10);
10924
+ const priceFactor = chainInfo.consensusParameters.feeParameters.gasPriceFactor;
10925
+ const minGas = blobTxRequest.calculateMinGas(chainInfo);
10926
+ const minFee = calculateGasFee({
10927
+ gasPrice,
10928
+ gas: minGas,
10929
+ priceFactor,
10930
+ tip: blobTxRequest.tip
10931
+ }).add(1);
10932
+ totalCost = totalCost.add(minFee);
10933
+ if (totalCost.gt(await deployer.getBalance())) {
10934
+ throw new FuelError28(ErrorCode26.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
10935
+ }
10936
+ const txCost = await deployer.getTransactionCost(blobTxRequest);
10937
+ blobTxRequest.maxFee = txCost.maxFee;
10938
+ return deployer.fund(blobTxRequest, txCost);
10939
+ }
10940
+ function adjustConfigurableOffsets(jsonAbi, configurableOffsetDiff) {
10941
+ const { configurables: readOnlyConfigurables } = jsonAbi;
10942
+ const configurables = [];
10943
+ readOnlyConfigurables.forEach((config) => {
10944
+ configurables.push({ ...config, offset: config.offset - configurableOffsetDiff });
10945
+ });
10946
+ return { ...jsonAbi, configurables };
10947
+ }
10948
+ async function deployScriptOrPredicate({
10949
+ deployer,
10950
+ bytecode,
10951
+ abi,
10952
+ loaderInstanceCallback
10953
+ }) {
10954
+ const dataSectionOffset = getDataOffset(arrayify20(bytecode));
10955
+ const byteCodeWithoutDataSection = bytecode.slice(0, dataSectionOffset);
10956
+ const blobId = hash3(byteCodeWithoutDataSection);
10957
+ const blobTxRequest = new BlobTransactionRequest({
10958
+ blobId,
10959
+ witnessIndex: 0,
10960
+ witnesses: [byteCodeWithoutDataSection]
10961
+ });
10962
+ const { loaderBytecode, blobOffset } = getPredicateScriptLoaderInstructions(
10963
+ arrayify20(bytecode),
10964
+ arrayify20(blobId)
10965
+ );
10966
+ const configurableOffsetDiff = byteCodeWithoutDataSection.length - (blobOffset || 0);
10967
+ const newAbi = adjustConfigurableOffsets(abi, configurableOffsetDiff);
10968
+ const blobExists = (await deployer.provider.getBlobs([blobId])).length > 0;
10969
+ const loaderInstance = loaderInstanceCallback(loaderBytecode, newAbi);
10970
+ if (blobExists) {
10971
+ return {
10972
+ waitForResult: () => Promise.resolve(loaderInstance),
10973
+ blobId
10974
+ };
10975
+ }
10976
+ const fundedBlobRequest = await fundBlobTx(deployer, blobTxRequest);
10977
+ const waitForResult = async () => {
10978
+ try {
10979
+ const blobTx = await deployer.sendTransaction(fundedBlobRequest);
10980
+ const result = await blobTx.waitForResult();
10981
+ if (result.status !== "success" /* success */) {
10982
+ throw new Error();
10983
+ }
10984
+ } catch (err) {
10985
+ throw new FuelError28(ErrorCode26.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
10986
+ }
10987
+ return loaderInstance;
10988
+ };
10989
+ return {
10990
+ waitForResult,
10991
+ blobId
10992
+ };
10993
+ }
10994
+
10995
+ // src/predicate/utils/getPredicateRoot.ts
10996
+ import { hash as hash4 } from "@fuel-ts/hasher";
10715
10997
  import { calcRoot } from "@fuel-ts/merkle";
10716
- import { chunkAndPadBytes, hexlify as hexlify22, concat as concat6, arrayify as arrayify20 } from "@fuel-ts/utils";
10998
+ import { chunkAndPadBytes, hexlify as hexlify22, concat as concat8, arrayify as arrayify21 } from "@fuel-ts/utils";
10717
10999
  var getPredicateRoot = (bytecode) => {
10718
11000
  const chunkSize = 16 * 1024;
10719
- const bytes = arrayify20(bytecode);
11001
+ const bytes = arrayify21(bytecode);
10720
11002
  const chunks = chunkAndPadBytes(bytes, chunkSize);
10721
11003
  const codeRoot = calcRoot(chunks.map((c) => hexlify22(c)));
10722
- const predicateRoot = hash3(concat6(["0x4655454C", codeRoot]));
11004
+ const predicateRoot = hash4(concat8(["0x4655454C", codeRoot]));
10723
11005
  return predicateRoot;
10724
11006
  };
10725
11007
 
10726
11008
  // src/predicate/predicate.ts
10727
- function getDataOffset(binary) {
10728
- const buffer = binary.buffer.slice(binary.byteOffset + 8, binary.byteOffset + 16);
10729
- const dataView = new DataView(buffer);
10730
- const dataOffset = dataView.getBigUint64(0, false);
10731
- return Number(dataOffset);
10732
- }
10733
11009
  var Predicate = class extends Account {
10734
11010
  bytes;
10735
11011
  predicateData = [];
10736
11012
  interface;
10737
- loaderBytecode = "";
10738
11013
  /**
10739
11014
  * Creates an instance of the Predicate class.
10740
11015
  *
@@ -10749,24 +11024,17 @@ var Predicate = class extends Account {
10749
11024
  abi,
10750
11025
  provider,
10751
11026
  data,
10752
- configurableConstants,
10753
- /**
10754
- * TODO: Implement a getBytes method within the Predicate class. This method should return the loaderBytecode if it is set.
10755
- * The getBytes method should be used in all places where we use this.bytes.
10756
- * Note: Do not set loaderBytecode to a default string here; it should remain undefined when not provided.
10757
- */
10758
- loaderBytecode = ""
11027
+ configurableConstants
10759
11028
  }) {
10760
11029
  const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
10761
11030
  bytecode,
10762
11031
  abi,
10763
11032
  configurableConstants
10764
11033
  );
10765
- const address = Address9.fromB256(getPredicateRoot(predicateBytes));
11034
+ const address = Address10.fromB256(getPredicateRoot(predicateBytes));
10766
11035
  super(address, provider);
10767
11036
  this.bytes = predicateBytes;
10768
11037
  this.interface = predicateInterface;
10769
- this.loaderBytecode = loaderBytecode;
10770
11038
  if (data !== void 0 && data.length > 0) {
10771
11039
  this.predicateData = data;
10772
11040
  }
@@ -10828,16 +11096,13 @@ var Predicate = class extends Account {
10828
11096
  * @returns An object containing the new predicate bytes and interface.
10829
11097
  */
10830
11098
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
10831
- let predicateBytes = arrayify21(bytes);
10832
- let abiInterface;
10833
- if (jsonAbi) {
10834
- abiInterface = new Interface4(jsonAbi);
10835
- if (abiInterface.functions.main === void 0) {
10836
- throw new FuelError27(
10837
- ErrorCode25.ABI_MAIN_METHOD_MISSING,
10838
- 'Cannot use ABI without "main" function.'
10839
- );
10840
- }
11099
+ let predicateBytes = arrayify22(bytes);
11100
+ const abiInterface = new Interface4(jsonAbi);
11101
+ if (abiInterface.functions.main === void 0) {
11102
+ throw new FuelError29(
11103
+ ErrorCode27.ABI_MAIN_METHOD_MISSING,
11104
+ 'Cannot use ABI without "main" function.'
11105
+ );
10841
11106
  }
10842
11107
  if (configurableConstants && Object.keys(configurableConstants).length) {
10843
11108
  predicateBytes = Predicate.setConfigurableConstants(
@@ -10891,25 +11156,19 @@ var Predicate = class extends Account {
10891
11156
  * @param abiInterface - The ABI interface of the predicate.
10892
11157
  * @returns The mutated bytes with the configurable constants set.
10893
11158
  */
10894
- static setConfigurableConstants(bytes, configurableConstants, abiInterface, loaderBytecode) {
11159
+ static setConfigurableConstants(bytes, configurableConstants, abiInterface) {
10895
11160
  const mutatedBytes = bytes;
10896
11161
  try {
10897
- if (!abiInterface) {
10898
- throw new FuelError27(
10899
- ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
10900
- "Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
10901
- );
10902
- }
10903
11162
  if (Object.keys(abiInterface.configurables).length === 0) {
10904
- throw new FuelError27(
10905
- ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
11163
+ throw new FuelError29(
11164
+ ErrorCode27.INVALID_CONFIGURABLE_CONSTANTS,
10906
11165
  "Predicate has no configurable constants to be set"
10907
11166
  );
10908
11167
  }
10909
11168
  Object.entries(configurableConstants).forEach(([key, value]) => {
10910
11169
  if (!abiInterface?.configurables[key]) {
10911
- throw new FuelError27(
10912
- ErrorCode25.CONFIGURABLE_NOT_FOUND,
11170
+ throw new FuelError29(
11171
+ ErrorCode27.CONFIGURABLE_NOT_FOUND,
10913
11172
  `No configurable constant named '${key}' found in the Predicate`
10914
11173
  );
10915
11174
  }
@@ -10917,18 +11176,9 @@ var Predicate = class extends Account {
10917
11176
  const encoded = abiInterface.encodeConfigurable(key, value);
10918
11177
  mutatedBytes.set(encoded, offset);
10919
11178
  });
10920
- if (loaderBytecode) {
10921
- const offset = getDataOffset(bytes);
10922
- const dataSection = mutatedBytes.slice(offset);
10923
- const dataSectionLen = dataSection.length;
10924
- const dataSectionLenBytes = new Uint8Array(8);
10925
- const dataSectionLenDataView = new DataView(dataSectionLenBytes.buffer);
10926
- dataSectionLenDataView.setBigUint64(0, BigInt(dataSectionLen), false);
10927
- mutatedBytes.set(concat7([loaderBytecode, dataSectionLenBytes, dataSection]));
10928
- }
10929
11179
  } catch (err) {
10930
- throw new FuelError27(
10931
- ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
11180
+ throw new FuelError29(
11181
+ ErrorCode27.INVALID_CONFIGURABLE_CONSTANTS,
10932
11182
  `Error setting configurable constants: ${err.message}.`
10933
11183
  );
10934
11184
  }
@@ -10956,13 +11206,35 @@ var Predicate = class extends Account {
10956
11206
  }
10957
11207
  return index;
10958
11208
  }
11209
+ /**
11210
+ *
11211
+ * @param account - The account used to pay the deployment costs.
11212
+ * @returns The _blobId_ and a _waitForResult_ callback that returns the deployed predicate
11213
+ * once the blob deployment transaction finishes.
11214
+ *
11215
+ * The returned loader predicate will have the same configurable constants
11216
+ * as the original predicate which was used to generate the loader predicate.
11217
+ */
11218
+ async deploy(account) {
11219
+ return deployScriptOrPredicate({
11220
+ deployer: account,
11221
+ abi: this.interface.jsonAbi,
11222
+ bytecode: this.bytes,
11223
+ loaderInstanceCallback: (loaderBytecode, newAbi) => new Predicate({
11224
+ bytecode: loaderBytecode,
11225
+ abi: newAbi,
11226
+ provider: this.provider,
11227
+ data: this.predicateData
11228
+ })
11229
+ });
11230
+ }
10959
11231
  };
10960
11232
 
10961
11233
  // src/connectors/fuel.ts
10962
- import { ErrorCode as ErrorCode26, FuelError as FuelError30 } from "@fuel-ts/errors";
11234
+ import { ErrorCode as ErrorCode28, FuelError as FuelError32 } from "@fuel-ts/errors";
10963
11235
 
10964
11236
  // src/connectors/fuel-connector.ts
10965
- import { FuelError as FuelError28 } from "@fuel-ts/errors";
11237
+ import { FuelError as FuelError30 } from "@fuel-ts/errors";
10966
11238
  import { EventEmitter as EventEmitter2 } from "events";
10967
11239
 
10968
11240
  // src/connectors/types/connector-types.ts
@@ -11037,7 +11309,7 @@ var FuelConnector = class extends EventEmitter2 {
11037
11309
  * @returns Always true.
11038
11310
  */
11039
11311
  async ping() {
11040
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11312
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11041
11313
  }
11042
11314
  /**
11043
11315
  * Should return the current version of the connector
@@ -11046,7 +11318,7 @@ var FuelConnector = class extends EventEmitter2 {
11046
11318
  * @returns boolean - connection status.
11047
11319
  */
11048
11320
  async version() {
11049
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11321
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11050
11322
  }
11051
11323
  /**
11052
11324
  * Should return true if the connector is connected
@@ -11055,7 +11327,7 @@ var FuelConnector = class extends EventEmitter2 {
11055
11327
  * @returns The connection status.
11056
11328
  */
11057
11329
  async isConnected() {
11058
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11330
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11059
11331
  }
11060
11332
  /**
11061
11333
  * Should return all the accounts authorized for the
@@ -11064,7 +11336,7 @@ var FuelConnector = class extends EventEmitter2 {
11064
11336
  * @returns The accounts addresses strings
11065
11337
  */
11066
11338
  async accounts() {
11067
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11339
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11068
11340
  }
11069
11341
  /**
11070
11342
  * Should start the connection process and return
@@ -11076,7 +11348,7 @@ var FuelConnector = class extends EventEmitter2 {
11076
11348
  * @returns boolean - connection status.
11077
11349
  */
11078
11350
  async connect() {
11079
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11351
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11080
11352
  }
11081
11353
  /**
11082
11354
  * Should disconnect the current connection and
@@ -11086,7 +11358,7 @@ var FuelConnector = class extends EventEmitter2 {
11086
11358
  * @returns The connection status.
11087
11359
  */
11088
11360
  async disconnect() {
11089
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11361
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11090
11362
  }
11091
11363
  /**
11092
11364
  * Should start the sign message process and return
@@ -11098,7 +11370,7 @@ var FuelConnector = class extends EventEmitter2 {
11098
11370
  * @returns Message signature
11099
11371
  */
11100
11372
  async signMessage(_address, _message) {
11101
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11373
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11102
11374
  }
11103
11375
  /**
11104
11376
  * Should start the sign transaction process and return
@@ -11110,7 +11382,7 @@ var FuelConnector = class extends EventEmitter2 {
11110
11382
  * @returns Transaction signature
11111
11383
  */
11112
11384
  async signTransaction(_address, _transaction) {
11113
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11385
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11114
11386
  }
11115
11387
  /**
11116
11388
  * Should start the send transaction process and return
@@ -11126,7 +11398,7 @@ var FuelConnector = class extends EventEmitter2 {
11126
11398
  * @returns The transaction id
11127
11399
  */
11128
11400
  async sendTransaction(_address, _transaction) {
11129
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11401
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11130
11402
  }
11131
11403
  /**
11132
11404
  * Should return the current account selected inside the connector, if the account
@@ -11137,7 +11409,7 @@ var FuelConnector = class extends EventEmitter2 {
11137
11409
  * @returns The current account selected otherwise null.
11138
11410
  */
11139
11411
  async currentAccount() {
11140
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11412
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11141
11413
  }
11142
11414
  /**
11143
11415
  * Should add the assets metadata to the connector and return true if the asset
@@ -11151,7 +11423,7 @@ var FuelConnector = class extends EventEmitter2 {
11151
11423
  * @returns True if the asset was added successfully
11152
11424
  */
11153
11425
  async addAssets(_assets) {
11154
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11426
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11155
11427
  }
11156
11428
  /**
11157
11429
  * Should add the asset metadata to the connector and return true if the asset
@@ -11165,7 +11437,7 @@ var FuelConnector = class extends EventEmitter2 {
11165
11437
  * @returns True if the asset was added successfully
11166
11438
  */
11167
11439
  async addAsset(_asset) {
11168
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11440
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11169
11441
  }
11170
11442
  /**
11171
11443
  * Should return all the assets added to the connector. If a connection is already established.
@@ -11173,7 +11445,7 @@ var FuelConnector = class extends EventEmitter2 {
11173
11445
  * @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
11174
11446
  */
11175
11447
  async assets() {
11176
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11448
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11177
11449
  }
11178
11450
  /**
11179
11451
  * Should start the add network process and return true if the network was added successfully.
@@ -11184,7 +11456,7 @@ var FuelConnector = class extends EventEmitter2 {
11184
11456
  * @returns Return true if the network was added successfully
11185
11457
  */
11186
11458
  async addNetwork(_networkUrl) {
11187
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11459
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11188
11460
  }
11189
11461
  /**
11190
11462
  * Should start the select network process and return true if the network has change successfully.
@@ -11195,7 +11467,7 @@ var FuelConnector = class extends EventEmitter2 {
11195
11467
  * @returns Return true if the network was added successfully
11196
11468
  */
11197
11469
  async selectNetwork(_network) {
11198
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11470
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11199
11471
  }
11200
11472
  /**
11201
11473
  * Should return all the networks available from the connector. If the connection is already established.
@@ -11203,7 +11475,7 @@ var FuelConnector = class extends EventEmitter2 {
11203
11475
  * @returns Return all the networks added to the connector.
11204
11476
  */
11205
11477
  async networks() {
11206
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11478
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11207
11479
  }
11208
11480
  /**
11209
11481
  * Should return the current network selected inside the connector. Even if the connection is not established.
@@ -11211,7 +11483,7 @@ var FuelConnector = class extends EventEmitter2 {
11211
11483
  * @returns Return the current network selected inside the connector.
11212
11484
  */
11213
11485
  async currentNetwork() {
11214
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11486
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11215
11487
  }
11216
11488
  /**
11217
11489
  * Should add the ABI to the connector and return true if the ABI was added successfully.
@@ -11221,7 +11493,7 @@ var FuelConnector = class extends EventEmitter2 {
11221
11493
  * @returns Return true if the ABI was added successfully.
11222
11494
  */
11223
11495
  async addABI(_contractId, _abi) {
11224
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11496
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11225
11497
  }
11226
11498
  /**
11227
11499
  * Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
@@ -11230,7 +11502,7 @@ var FuelConnector = class extends EventEmitter2 {
11230
11502
  * @returns The ABI if it exists, otherwise return null.
11231
11503
  */
11232
11504
  async getABI(_id) {
11233
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11505
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11234
11506
  }
11235
11507
  /**
11236
11508
  * Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
@@ -11239,7 +11511,7 @@ var FuelConnector = class extends EventEmitter2 {
11239
11511
  * @returns Returns true if the abi exists or false if not.
11240
11512
  */
11241
11513
  async hasABI(_id) {
11242
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11514
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11243
11515
  }
11244
11516
  /**
11245
11517
  * Event listener for the connector.
@@ -11283,7 +11555,7 @@ function dispatchFuelConnectorEvent(connector) {
11283
11555
  }
11284
11556
 
11285
11557
  // src/connectors/utils/promises.ts
11286
- import { FuelError as FuelError29 } from "@fuel-ts/errors";
11558
+ import { FuelError as FuelError31 } from "@fuel-ts/errors";
11287
11559
  function deferPromise() {
11288
11560
  const defer = {};
11289
11561
  defer.promise = new Promise((resolve, reject) => {
@@ -11295,7 +11567,7 @@ function deferPromise() {
11295
11567
  async function withTimeout(promise, timeout = 1050) {
11296
11568
  const timeoutPromise = new Promise((resolve, reject) => {
11297
11569
  setTimeout(() => {
11298
- reject(new FuelError29(FuelError29.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
11570
+ reject(new FuelError31(FuelError31.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
11299
11571
  }, timeout);
11300
11572
  });
11301
11573
  return Promise.race([timeoutPromise, promise]);
@@ -11330,7 +11602,7 @@ var _Fuel = class extends FuelConnector {
11330
11602
  this._targetUnsubscribe = this.setupConnectorListener();
11331
11603
  await connectResponse;
11332
11604
  } catch (error) {
11333
- throw new FuelError30(ErrorCode26.INVALID_PROVIDER, "Error initializing Fuel Connector");
11605
+ throw new FuelError32(ErrorCode28.INVALID_PROVIDER, "Error initializing Fuel Connector");
11334
11606
  }
11335
11607
  }
11336
11608
  async init() {
@@ -11396,8 +11668,8 @@ var _Fuel = class extends FuelConnector {
11396
11668
  const hasConnector = await this.hasConnector();
11397
11669
  await this.pingConnector();
11398
11670
  if (!this._currentConnector || !hasConnector) {
11399
- throw new FuelError30(
11400
- ErrorCode26.MISSING_CONNECTOR,
11671
+ throw new FuelError32(
11672
+ ErrorCode28.MISSING_CONNECTOR,
11401
11673
  `No connector selected for calling ${method}. Use hasConnector before executing other methods.`
11402
11674
  );
11403
11675
  }
@@ -11461,7 +11733,7 @@ var _Fuel = class extends FuelConnector {
11461
11733
  cacheTime: PING_CACHE_TIME
11462
11734
  })();
11463
11735
  } catch {
11464
- throw new FuelError30(ErrorCode26.INVALID_PROVIDER, "Current connector is not available.");
11736
+ throw new FuelError32(ErrorCode28.INVALID_PROVIDER, "Current connector is not available.");
11465
11737
  }
11466
11738
  }
11467
11739
  /**
@@ -11610,7 +11882,7 @@ var _Fuel = class extends FuelConnector {
11610
11882
  const currentNetwork = await this.currentNetwork();
11611
11883
  provider = await Provider.create(currentNetwork.url);
11612
11884
  } else {
11613
- throw new FuelError30(ErrorCode26.INVALID_PROVIDER, "Provider is not valid.");
11885
+ throw new FuelError32(ErrorCode28.INVALID_PROVIDER, "Provider is not valid.");
11614
11886
  }
11615
11887
  return provider;
11616
11888
  }
@@ -11717,6 +11989,7 @@ export {
11717
11989
  calculateTXFeeForSummary,
11718
11990
  coinQuantityfy,
11719
11991
  deferPromise,
11992
+ deployScriptOrPredicate,
11720
11993
  dispatchFuelConnectorEvent,
11721
11994
  english,
11722
11995
  extractBurnedAssetsFromReceipts,