@fuel-ts/account 0.96.1 → 0.97.1

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 (50) hide show
  1. package/dist/account.d.ts +6 -0
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.global.js +1401 -14796
  7. package/dist/index.global.js.map +1 -1
  8. package/dist/index.js +621 -345
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +608 -333
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/predicate/predicate.d.ts +16 -11
  13. package/dist/predicate/predicate.d.ts.map +1 -1
  14. package/dist/providers/__generated__/operations.d.ts +94 -126
  15. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  16. package/dist/providers/provider.d.ts +5 -8
  17. package/dist/providers/provider.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/blob-transaction-request.d.ts +2 -2
  19. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/errors.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -1
  24. package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -1
  25. package/dist/providers/transaction-summary/get-transaction-summary.d.ts +9 -3
  26. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  27. package/dist/providers/transaction-summary/operations.d.ts +21 -3
  28. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  29. package/dist/providers/transaction-summary/types.d.ts +38 -8
  30. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  31. package/dist/providers/utils/handle-gql-error-message.d.ts +2 -1
  32. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
  33. package/dist/providers/utils/receipts.d.ts.map +1 -1
  34. package/dist/providers/utils/validate-pagination-args.d.ts +9 -0
  35. package/dist/providers/utils/validate-pagination-args.d.ts.map +1 -0
  36. package/dist/test-utils/launchNode.d.ts.map +1 -1
  37. package/dist/test-utils.global.js +963 -14555
  38. package/dist/test-utils.global.js.map +1 -1
  39. package/dist/test-utils.js +304 -234
  40. package/dist/test-utils.js.map +1 -1
  41. package/dist/test-utils.mjs +298 -228
  42. package/dist/test-utils.mjs.map +1 -1
  43. package/dist/utils/deployScriptOrPredicate.d.ts +14 -0
  44. package/dist/utils/deployScriptOrPredicate.d.ts.map +1 -0
  45. package/dist/utils/formatTransferToContractScriptData.d.ts +7 -7
  46. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  47. package/dist/utils/predicate-script-loader-instructions.d.ts +9 -0
  48. package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -0
  49. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  50. package/package.json +19 -19
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
  }
@@ -4668,7 +4759,7 @@ Supported fuel-core version: ${supportedVersion}.`
4668
4759
  createOperations() {
4669
4760
  const fetchFn = _Provider.getFetchFn(this.options);
4670
4761
  const gqlClient = new GraphQLClient(this.urlWithoutAuth, {
4671
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
4762
+ fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
4672
4763
  responseMiddleware: (response) => {
4673
4764
  if ("response" in response) {
4674
4765
  const graphQlResponse = response.response;
@@ -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
  }
@@ -4919,7 +5010,8 @@ Supported fuel-core version: ${supportedVersion}.`
4919
5010
  dryRun: [{ receipts: rawReceipts, status }]
4920
5011
  } = await this.operations.dryRun({
4921
5012
  encodedTransactions: [hexlify15(transactionRequest.toTransactionBytes())],
4922
- utxoValidation: false
5013
+ utxoValidation: false,
5014
+ gasPrice: "0"
4923
5015
  });
4924
5016
  receipts = rawReceipts.map(processGqlReceipt);
4925
5017
  dryRunStatus = status;
@@ -4933,7 +5025,8 @@ Supported fuel-core version: ${supportedVersion}.`
4933
5025
  missingContractIds.push(contractId);
4934
5026
  });
4935
5027
  const { maxFee } = await this.estimateTxGasAndFee({
4936
- transactionRequest
5028
+ transactionRequest,
5029
+ gasPrice: bn17(0)
4937
5030
  });
4938
5031
  transactionRequest.maxFee = maxFee;
4939
5032
  } else {
@@ -5069,7 +5162,7 @@ Supported fuel-core version: ${supportedVersion}.`
5069
5162
  const chainInfo = this.getChain();
5070
5163
  const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
5071
5164
  const minGas = transactionRequest.calculateMinGas(chainInfo);
5072
- if (!gasPrice) {
5165
+ if (!isDefined2(gasPrice)) {
5073
5166
  gasPrice = await this.estimateGasPrice(10);
5074
5167
  }
5075
5168
  const minFee = calculateGasFee({
@@ -5218,7 +5311,7 @@ Supported fuel-core version: ${supportedVersion}.`
5218
5311
  const {
5219
5312
  coins: { edges, pageInfo }
5220
5313
  } = await this.operations.getCoins({
5221
- ...this.validatePaginationArgs({
5314
+ ...validatePaginationArgs({
5222
5315
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
5223
5316
  inputArgs: paginationArgs
5224
5317
  }),
@@ -5228,7 +5321,7 @@ Supported fuel-core version: ${supportedVersion}.`
5228
5321
  id: node.utxoId,
5229
5322
  assetId: node.assetId,
5230
5323
  amount: bn17(node.amount),
5231
- owner: Address2.fromAddressOrString(node.owner),
5324
+ owner: ownerAddress,
5232
5325
  blockCreated: bn17(node.blockCreated),
5233
5326
  txCreatedIdx: bn17(node.txCreatedIdx)
5234
5327
  }));
@@ -5282,7 +5375,7 @@ Supported fuel-core version: ${supportedVersion}.`
5282
5375
  id: coin.utxoId,
5283
5376
  amount: bn17(coin.amount),
5284
5377
  assetId: coin.assetId,
5285
- owner: Address2.fromAddressOrString(coin.owner),
5378
+ owner: ownerAddress,
5286
5379
  blockCreated: bn17(coin.blockCreated),
5287
5380
  txCreatedIdx: bn17(coin.txCreatedIdx)
5288
5381
  };
@@ -5357,7 +5450,7 @@ Supported fuel-core version: ${supportedVersion}.`
5357
5450
  const {
5358
5451
  blocks: { edges, pageInfo }
5359
5452
  } = await this.operations.getBlocks({
5360
- ...this.validatePaginationArgs({
5453
+ ...validatePaginationArgs({
5361
5454
  paginationLimit: BLOCKS_PAGE_SIZE_LIMIT,
5362
5455
  inputArgs: params
5363
5456
  })
@@ -5436,7 +5529,7 @@ Supported fuel-core version: ${supportedVersion}.`
5436
5529
  0
5437
5530
  )?.[0];
5438
5531
  } catch (error) {
5439
- if (error instanceof FuelError16 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5532
+ if (error instanceof FuelError17 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5440
5533
  console.warn("Unsupported transaction type encountered");
5441
5534
  return null;
5442
5535
  }
@@ -5452,7 +5545,7 @@ Supported fuel-core version: ${supportedVersion}.`
5452
5545
  const {
5453
5546
  transactions: { edges, pageInfo }
5454
5547
  } = await this.operations.getTransactions({
5455
- ...this.validatePaginationArgs({
5548
+ ...validatePaginationArgs({
5456
5549
  inputArgs: paginationArgs,
5457
5550
  paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
5458
5551
  })
@@ -5462,7 +5555,7 @@ Supported fuel-core version: ${supportedVersion}.`
5462
5555
  try {
5463
5556
  return coder.decode(arrayify12(rawPayload), 0)[0];
5464
5557
  } catch (error) {
5465
- if (error instanceof FuelError16 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5558
+ if (error instanceof FuelError17 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5466
5559
  console.warn("Unsupported transaction type encountered");
5467
5560
  return null;
5468
5561
  }
@@ -5547,7 +5640,7 @@ Supported fuel-core version: ${supportedVersion}.`
5547
5640
  const {
5548
5641
  messages: { edges, pageInfo }
5549
5642
  } = await this.operations.getMessages({
5550
- ...this.validatePaginationArgs({
5643
+ ...validatePaginationArgs({
5551
5644
  inputArgs: paginationArgs,
5552
5645
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
5553
5646
  }),
@@ -5588,8 +5681,8 @@ Supported fuel-core version: ${supportedVersion}.`
5588
5681
  nonce
5589
5682
  };
5590
5683
  if (commitBlockId && commitBlockHeight) {
5591
- throw new FuelError16(
5592
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5684
+ throw new FuelError17(
5685
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
5593
5686
  "commitBlockId and commitBlockHeight cannot be used together"
5594
5687
  );
5595
5688
  }
@@ -5771,13 +5864,13 @@ Supported fuel-core version: ${supportedVersion}.`
5771
5864
  messageId: InputMessageCoder2.getMessageId({
5772
5865
  sender: rawMessage.sender,
5773
5866
  recipient: rawMessage.recipient,
5774
- nonce: rawMessage.nonce,
5867
+ nonce,
5775
5868
  amount: bn17(rawMessage.amount),
5776
5869
  data: rawMessage.data
5777
5870
  }),
5778
5871
  sender: Address2.fromAddressOrString(rawMessage.sender),
5779
5872
  recipient: Address2.fromAddressOrString(rawMessage.recipient),
5780
- nonce: rawMessage.nonce,
5873
+ nonce,
5781
5874
  amount: bn17(rawMessage.amount),
5782
5875
  data: InputMessageCoder2.decodeData(rawMessage.data),
5783
5876
  daHeight: bn17(rawMessage.daHeight)
@@ -5799,41 +5892,6 @@ Supported fuel-core version: ${supportedVersion}.`
5799
5892
  }
5800
5893
  return relayedTransactionStatus;
5801
5894
  }
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
5895
  /**
5838
5896
  * @hidden
5839
5897
  */
@@ -5879,7 +5937,7 @@ __publicField(Provider, "chainInfoCache", {});
5879
5937
  __publicField(Provider, "nodeInfoCache", {});
5880
5938
 
5881
5939
  // src/providers/transaction-summary/get-transaction-summary.ts
5882
- import { ErrorCode as ErrorCode15, FuelError as FuelError17 } from "@fuel-ts/errors";
5940
+ import { ErrorCode as ErrorCode16, FuelError as FuelError18 } from "@fuel-ts/errors";
5883
5941
  import { bn as bn18 } from "@fuel-ts/math";
5884
5942
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
5885
5943
  import { arrayify as arrayify13 } from "@fuel-ts/utils";
@@ -5889,8 +5947,8 @@ async function getTransactionSummary(params) {
5889
5947
  transactionId: id
5890
5948
  });
5891
5949
  if (!gqlTransaction) {
5892
- throw new FuelError17(
5893
- ErrorCode15.TRANSACTION_NOT_FOUND,
5950
+ throw new FuelError18(
5951
+ ErrorCode16.TRANSACTION_NOT_FOUND,
5894
5952
  `Transaction not found for given id: ${id}.`
5895
5953
  );
5896
5954
  }
@@ -5958,7 +6016,15 @@ async function getTransactionSummaryFromRequest(params) {
5958
6016
  }
5959
6017
  async function getTransactionsSummaries(params) {
5960
6018
  const { filters, provider, abiMap } = params;
5961
- const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
6019
+ const { owner, ...inputArgs } = filters;
6020
+ const validPaginationParams = validatePaginationArgs({
6021
+ inputArgs,
6022
+ paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
6023
+ });
6024
+ const { transactionsByOwner } = await provider.operations.getTransactionsByOwner({
6025
+ ...validPaginationParams,
6026
+ owner
6027
+ });
5962
6028
  const { edges, pageInfo } = transactionsByOwner;
5963
6029
  const {
5964
6030
  consensusParameters: {
@@ -6677,38 +6743,46 @@ var mergeQuantities = (...coinQuantities) => {
6677
6743
  };
6678
6744
 
6679
6745
  // src/utils/formatTransferToContractScriptData.ts
6680
- import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
6681
- import { BN as BN3 } from "@fuel-ts/math";
6682
- import { arrayify as arrayify14 } from "@fuel-ts/utils";
6746
+ import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
6747
+ import { Address as Address3 } from "@fuel-ts/address";
6748
+ import { arrayify as arrayify14, concat as concat3 } from "@fuel-ts/utils";
6683
6749
  import * as asm from "@fuels/vm-asm";
6684
- var formatTransferToContractScriptData = (params) => {
6685
- const { assetId, amountToTransfer, hexlifiedContractId } = params;
6750
+ var formatTransferToContractScriptData = (transferParams) => {
6686
6751
  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;
6752
+ return transferParams.reduce((acc, transferParam) => {
6753
+ const { assetId, amount, contractId } = transferParam;
6754
+ const encoded = numberCoder.encode(amount);
6755
+ const scriptData = concat3([
6756
+ Address3.fromAddressOrString(contractId).toBytes(),
6757
+ encoded,
6758
+ arrayify14(assetId)
6759
+ ]);
6760
+ return concat3([acc, scriptData]);
6761
+ }, new Uint8Array());
6694
6762
  };
6695
- var assembleTransferToContractScript = async (params) => {
6696
- const scriptData = formatTransferToContractScriptData(params);
6763
+ var assembleTransferToContractScript = async (transferParams) => {
6764
+ const scriptData = formatTransferToContractScriptData(transferParams);
6697
6765
  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
- ]);
6766
+ let script = new Uint8Array();
6767
+ transferParams.forEach((_, i) => {
6768
+ const offset = (CONTRACT_ID_LEN + WORD_SIZE + ASSET_ID_LEN) * i;
6769
+ script = concat3([
6770
+ script,
6771
+ // Load ScriptData into register 0x10.
6772
+ asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
6773
+ // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
6774
+ asm.addi(17, 16, offset).to_bytes(),
6775
+ // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
6776
+ asm.addi(18, 17, CONTRACT_ID_LEN).to_bytes(),
6777
+ // Load word to the amount at 0x12 into register 0x13.
6778
+ asm.lw(19, 18, 0).to_bytes(),
6779
+ // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
6780
+ asm.addi(20, 18, WORD_SIZE).to_bytes(),
6781
+ // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
6782
+ asm.tr(17, 19, 20).to_bytes()
6783
+ ]);
6784
+ });
6785
+ script = concat3([script, asm.ret(1).to_bytes()]);
6712
6786
  return { script, scriptData };
6713
6787
  };
6714
6788
 
@@ -6738,7 +6812,7 @@ var Account = class extends AbstractAccount {
6738
6812
  super();
6739
6813
  this._provider = provider;
6740
6814
  this._connector = connector;
6741
- this.address = Address3.fromDynamicInput(address);
6815
+ this.address = Address4.fromDynamicInput(address);
6742
6816
  }
6743
6817
  /**
6744
6818
  * The provider used to interact with the network.
@@ -6749,7 +6823,7 @@ var Account = class extends AbstractAccount {
6749
6823
  */
6750
6824
  get provider() {
6751
6825
  if (!this._provider) {
6752
- throw new FuelError18(ErrorCode16.MISSING_PROVIDER, "Provider not set");
6826
+ throw new FuelError19(ErrorCode17.MISSING_PROVIDER, "Provider not set");
6753
6827
  }
6754
6828
  return this._provider;
6755
6829
  }
@@ -6900,8 +6974,8 @@ var Account = class extends AbstractAccount {
6900
6974
  fundingAttempts += 1;
6901
6975
  }
6902
6976
  if (needsToBeFunded) {
6903
- throw new FuelError18(
6904
- ErrorCode16.NOT_ENOUGH_FUNDS,
6977
+ throw new FuelError19(
6978
+ ErrorCode17.NOT_ENOUGH_FUNDS,
6905
6979
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
6906
6980
  );
6907
6981
  }
@@ -6915,7 +6989,8 @@ var Account = class extends AbstractAccount {
6915
6989
  return request;
6916
6990
  }
6917
6991
  const { maxFee } = await this.provider.estimateTxGasAndFee({
6918
- transactionRequest: requestToReestimate
6992
+ transactionRequest: requestToReestimate,
6993
+ gasPrice
6919
6994
  });
6920
6995
  request.maxFee = maxFee;
6921
6996
  return request;
@@ -6972,7 +7047,7 @@ var Account = class extends AbstractAccount {
6972
7047
  const { destination, amount, assetId } = transferParams;
6973
7048
  this.validateTransferAmount(amount);
6974
7049
  request.addCoinOutput(
6975
- Address3.fromAddressOrString(destination),
7050
+ Address4.fromAddressOrString(destination),
6976
7051
  amount,
6977
7052
  assetId ?? this.provider.getBaseAssetId()
6978
7053
  );
@@ -7006,35 +7081,35 @@ var Account = class extends AbstractAccount {
7006
7081
  * @returns A promise that resolves to the transaction response.
7007
7082
  */
7008
7083
  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
- });
7084
+ return this.batchTransferToContracts([{ amount, assetId, contractId }], txParams);
7085
+ }
7086
+ async batchTransferToContracts(contractTransferParams, txParams = {}) {
7022
7087
  let request = new ScriptTransactionRequest({
7023
- ...txParams,
7024
- script,
7025
- scriptData
7088
+ ...txParams
7026
7089
  });
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
7090
+ const quantities = [];
7091
+ const transferParams = contractTransferParams.map((transferParam) => {
7092
+ const amount = bn19(transferParam.amount);
7093
+ const contractAddress = Address4.fromAddressOrString(transferParam.contractId);
7094
+ const assetId = transferParam.assetId ? hexlify16(transferParam.assetId) : this.provider.getBaseAssetId();
7095
+ if (amount.lte(0)) {
7096
+ throw new FuelError19(
7097
+ ErrorCode17.INVALID_TRANSFER_AMOUNT,
7098
+ "Transfer amount must be a positive number."
7099
+ );
7100
+ }
7101
+ request.addContractInputAndOutput(contractAddress);
7102
+ quantities.push({ amount, assetId });
7103
+ return {
7104
+ amount,
7105
+ contractId: contractAddress.toB256(),
7106
+ assetId
7107
+ };
7036
7108
  });
7037
- await this.fund(request, txCost);
7109
+ const { script, scriptData } = await assembleTransferToContractScript(transferParams);
7110
+ request.script = script;
7111
+ request.scriptData = scriptData;
7112
+ request = await this.estimateAndFundTransaction(request, txParams, { quantities });
7038
7113
  return this.sendTransaction(request);
7039
7114
  }
7040
7115
  /**
@@ -7046,7 +7121,7 @@ var Account = class extends AbstractAccount {
7046
7121
  * @returns A promise that resolves to the transaction response.
7047
7122
  */
7048
7123
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
7049
- const recipientAddress = Address3.fromAddressOrString(recipient);
7124
+ const recipientAddress = Address4.fromAddressOrString(recipient);
7050
7125
  const recipientDataArray = arrayify15(
7051
7126
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
7052
7127
  );
@@ -7134,7 +7209,7 @@ var Account = class extends AbstractAccount {
7134
7209
  */
7135
7210
  async signMessage(message) {
7136
7211
  if (!this._connector) {
7137
- throw new FuelError18(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
7212
+ throw new FuelError19(ErrorCode17.MISSING_CONNECTOR, "A connector is required to sign messages.");
7138
7213
  }
7139
7214
  return this._connector.signMessage(this.address.toString(), message);
7140
7215
  }
@@ -7146,8 +7221,8 @@ var Account = class extends AbstractAccount {
7146
7221
  */
7147
7222
  async signTransaction(transactionRequestLike) {
7148
7223
  if (!this._connector) {
7149
- throw new FuelError18(
7150
- ErrorCode16.MISSING_CONNECTOR,
7224
+ throw new FuelError19(
7225
+ ErrorCode17.MISSING_CONNECTOR,
7151
7226
  "A connector is required to sign transactions."
7152
7227
  );
7153
7228
  }
@@ -7206,16 +7281,16 @@ var Account = class extends AbstractAccount {
7206
7281
  /** @hidden * */
7207
7282
  validateTransferAmount(amount) {
7208
7283
  if (bn19(amount).lte(0)) {
7209
- throw new FuelError18(
7210
- ErrorCode16.INVALID_TRANSFER_AMOUNT,
7284
+ throw new FuelError19(
7285
+ ErrorCode17.INVALID_TRANSFER_AMOUNT,
7211
7286
  "Transfer amount must be a positive number."
7212
7287
  );
7213
7288
  }
7214
7289
  }
7215
7290
  /** @hidden * */
7216
- async estimateAndFundTransaction(transactionRequest, txParams) {
7291
+ async estimateAndFundTransaction(transactionRequest, txParams, costParams) {
7217
7292
  let request = transactionRequest;
7218
- const txCost = await this.getTransactionCost(request);
7293
+ const txCost = await this.getTransactionCost(request, costParams);
7219
7294
  request = this.validateGasLimitAndMaxFee({
7220
7295
  transactionRequest: request,
7221
7296
  gasUsed: txCost.gasUsed,
@@ -7236,16 +7311,16 @@ var Account = class extends AbstractAccount {
7236
7311
  if (!isDefined3(setGasLimit)) {
7237
7312
  request.gasLimit = gasUsed;
7238
7313
  } else if (gasUsed.gt(setGasLimit)) {
7239
- throw new FuelError18(
7240
- ErrorCode16.GAS_LIMIT_TOO_LOW,
7314
+ throw new FuelError19(
7315
+ ErrorCode17.GAS_LIMIT_TOO_LOW,
7241
7316
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7242
7317
  );
7243
7318
  }
7244
7319
  if (!isDefined3(setMaxFee)) {
7245
7320
  request.maxFee = maxFee;
7246
7321
  } else if (maxFee.gt(setMaxFee)) {
7247
- throw new FuelError18(
7248
- ErrorCode16.MAX_FEE_TOO_LOW,
7322
+ throw new FuelError19(
7323
+ ErrorCode17.MAX_FEE_TOO_LOW,
7249
7324
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
7250
7325
  );
7251
7326
  }
@@ -7258,11 +7333,11 @@ import { hashMessage } from "@fuel-ts/hasher";
7258
7333
  import { hexlify as hexlify19 } from "@fuel-ts/utils";
7259
7334
 
7260
7335
  // src/signer/signer.ts
7261
- import { Address as Address4 } from "@fuel-ts/address";
7336
+ import { Address as Address5 } from "@fuel-ts/address";
7262
7337
  import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
7263
7338
  import { hash as hash2 } from "@fuel-ts/hasher";
7264
7339
  import { toBytes } from "@fuel-ts/math";
7265
- import { hexlify as hexlify17, concat as concat3, arrayify as arrayify16 } from "@fuel-ts/utils";
7340
+ import { hexlify as hexlify17, concat as concat4, arrayify as arrayify16 } from "@fuel-ts/utils";
7266
7341
  import { secp256k1 } from "@noble/curves/secp256k1";
7267
7342
  var Signer = class {
7268
7343
  address;
@@ -7285,7 +7360,7 @@ var Signer = class {
7285
7360
  this.privateKey = hexlify17(privateKeyBytes);
7286
7361
  this.publicKey = hexlify17(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
7287
7362
  this.compressedPublicKey = hexlify17(secp256k1.getPublicKey(privateKeyBytes, true));
7288
- this.address = Address4.fromPublicKey(this.publicKey);
7363
+ this.address = Address5.fromPublicKey(this.publicKey);
7289
7364
  }
7290
7365
  /**
7291
7366
  * Sign data using the Signer instance
@@ -7302,7 +7377,7 @@ var Signer = class {
7302
7377
  const r = toBytes(`0x${signature.r.toString(16)}`, 32);
7303
7378
  const s = toBytes(`0x${signature.s.toString(16)}`, 32);
7304
7379
  s[0] |= (signature.recovery || 0) << 7;
7305
- return hexlify17(concat3([r, s]));
7380
+ return hexlify17(concat4([r, s]));
7306
7381
  }
7307
7382
  /**
7308
7383
  * Add point on the current elliptic curve
@@ -7343,7 +7418,7 @@ var Signer = class {
7343
7418
  * @returns Address from signature
7344
7419
  */
7345
7420
  static recoverAddress(data, signature) {
7346
- return Address4.fromPublicKey(Signer.recoverPublicKey(data, signature));
7421
+ return Address5.fromPublicKey(Signer.recoverPublicKey(data, signature));
7347
7422
  }
7348
7423
  /**
7349
7424
  * Generate a random privateKey
@@ -7352,7 +7427,7 @@ var Signer = class {
7352
7427
  * @returns random 32-byte hashed
7353
7428
  */
7354
7429
  static generatePrivateKey(entropy) {
7355
- return entropy ? hash2(concat3([randomBytes3(32), arrayify16(entropy)])) : randomBytes3(32);
7430
+ return entropy ? hash2(concat4([randomBytes3(32), arrayify16(entropy)])) : randomBytes3(32);
7356
7431
  }
7357
7432
  /**
7358
7433
  * Extended publicKey from a compact publicKey
@@ -7367,7 +7442,7 @@ var Signer = class {
7367
7442
  };
7368
7443
 
7369
7444
  // src/wallet/keystore-wallet.ts
7370
- import { Address as Address5 } from "@fuel-ts/address";
7445
+ import { Address as Address6 } from "@fuel-ts/address";
7371
7446
  import {
7372
7447
  bufferFromString,
7373
7448
  keccak256,
@@ -7378,7 +7453,7 @@ import {
7378
7453
  encryptJsonWalletData,
7379
7454
  randomUUID
7380
7455
  } from "@fuel-ts/crypto";
7381
- import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
7456
+ import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
7382
7457
  import { hexlify as hexlify18 } from "@fuel-ts/utils";
7383
7458
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7384
7459
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -7393,7 +7468,7 @@ var removeHexPrefix = (hexString) => {
7393
7468
  };
7394
7469
  async function encryptKeystoreWallet(privateKey, address, password) {
7395
7470
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
7396
- const ownerAddress = Address5.fromAddressOrString(address);
7471
+ const ownerAddress = Address6.fromAddressOrString(address);
7397
7472
  const salt = randomBytes4(DEFAULT_KEY_SIZE);
7398
7473
  const key = scrypt({
7399
7474
  password: bufferFromString(password),
@@ -7455,8 +7530,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7455
7530
  const macHashUint8Array = keccak256(data);
7456
7531
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
7457
7532
  if (mac !== macHash) {
7458
- throw new FuelError19(
7459
- ErrorCode17.INVALID_PASSWORD,
7533
+ throw new FuelError20(
7534
+ ErrorCode18.INVALID_PASSWORD,
7460
7535
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
7461
7536
  );
7462
7537
  }
@@ -7586,16 +7661,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7586
7661
 
7587
7662
  // src/hdwallet/hdwallet.ts
7588
7663
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
7589
- import { ErrorCode as ErrorCode20, FuelError as FuelError22 } from "@fuel-ts/errors";
7664
+ import { ErrorCode as ErrorCode21, FuelError as FuelError23 } from "@fuel-ts/errors";
7590
7665
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
7591
7666
  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";
7667
+ import { arrayify as arrayify19, hexlify as hexlify21, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
7593
7668
 
7594
7669
  // src/mnemonic/mnemonic.ts
7595
7670
  import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
7596
- import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
7671
+ import { ErrorCode as ErrorCode20, FuelError as FuelError22 } from "@fuel-ts/errors";
7597
7672
  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";
7673
+ import { arrayify as arrayify18, hexlify as hexlify20, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
7599
7674
 
7600
7675
  // src/wordlists/words/english.ts
7601
7676
  var english = [
@@ -9656,7 +9731,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
9656
9731
  })(Language || {});
9657
9732
 
9658
9733
  // src/mnemonic/utils.ts
9659
- import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
9734
+ import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
9660
9735
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
9661
9736
  import { arrayify as arrayify17 } from "@fuel-ts/utils";
9662
9737
  function getLowerMask(bits) {
@@ -9705,8 +9780,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9705
9780
  for (let i = 0; i < words.length; i += 1) {
9706
9781
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9707
9782
  if (index === -1) {
9708
- throw new FuelError20(
9709
- ErrorCode18.INVALID_MNEMONIC,
9783
+ throw new FuelError21(
9784
+ ErrorCode19.INVALID_MNEMONIC,
9710
9785
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9711
9786
  );
9712
9787
  }
@@ -9722,8 +9797,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9722
9797
  const checksumMask = getUpperMask(checksumBits);
9723
9798
  const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9724
9799
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9725
- throw new FuelError20(
9726
- ErrorCode18.INVALID_CHECKSUM,
9800
+ throw new FuelError21(
9801
+ ErrorCode19.INVALID_CHECKSUM,
9727
9802
  "Checksum validation failed for the provided mnemonic."
9728
9803
  );
9729
9804
  }
@@ -9737,16 +9812,16 @@ var TestnetPRV = "0x04358394";
9737
9812
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9738
9813
  function assertWordList(wordlist) {
9739
9814
  if (wordlist.length !== 2048) {
9740
- throw new FuelError21(
9741
- ErrorCode19.INVALID_WORD_LIST,
9815
+ throw new FuelError22(
9816
+ ErrorCode20.INVALID_WORD_LIST,
9742
9817
  `Expected word list length of 2048, but got ${wordlist.length}.`
9743
9818
  );
9744
9819
  }
9745
9820
  }
9746
9821
  function assertEntropy(entropy) {
9747
9822
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9748
- throw new FuelError21(
9749
- ErrorCode19.INVALID_ENTROPY,
9823
+ throw new FuelError22(
9824
+ ErrorCode20.INVALID_ENTROPY,
9750
9825
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9751
9826
  );
9752
9827
  }
@@ -9756,7 +9831,7 @@ function assertMnemonic(words) {
9756
9831
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9757
9832
  ", "
9758
9833
  )}] words, but got ${words.length}.`;
9759
- throw new FuelError21(ErrorCode19.INVALID_MNEMONIC, errorMsg);
9834
+ throw new FuelError22(ErrorCode20.INVALID_MNEMONIC, errorMsg);
9760
9835
  }
9761
9836
  }
9762
9837
  var Mnemonic = class {
@@ -9874,8 +9949,8 @@ var Mnemonic = class {
9874
9949
  static masterKeysFromSeed(seed) {
9875
9950
  const seedArray = arrayify18(seed);
9876
9951
  if (seedArray.length < 16 || seedArray.length > 64) {
9877
- throw new FuelError21(
9878
- ErrorCode19.INVALID_SEED,
9952
+ throw new FuelError22(
9953
+ ErrorCode20.INVALID_SEED,
9879
9954
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9880
9955
  );
9881
9956
  }
@@ -9896,16 +9971,16 @@ var Mnemonic = class {
9896
9971
  const index = "0x00000000";
9897
9972
  const chainCode = masterKey.slice(32);
9898
9973
  const privateKey = masterKey.slice(0, 32);
9899
- const extendedKey = concat4([
9974
+ const extendedKey = concat5([
9900
9975
  prefix,
9901
9976
  depth,
9902
9977
  fingerprint,
9903
9978
  index,
9904
9979
  chainCode,
9905
- concat4(["0x00", privateKey])
9980
+ concat5(["0x00", privateKey])
9906
9981
  ]);
9907
9982
  const checksum = dataSlice(sha2563(sha2563(extendedKey)), 0, 4);
9908
- return encodeBase58(concat4([extendedKey, checksum]));
9983
+ return encodeBase58(concat5([extendedKey, checksum]));
9909
9984
  }
9910
9985
  /**
9911
9986
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -9920,7 +9995,7 @@ var Mnemonic = class {
9920
9995
  * @returns A randomly generated mnemonic
9921
9996
  */
9922
9997
  static generate(size = 32, extraEntropy = "") {
9923
- const entropy = extraEntropy ? sha2563(concat4([randomBytes5(size), arrayify18(extraEntropy)])) : randomBytes5(size);
9998
+ const entropy = extraEntropy ? sha2563(concat5([randomBytes5(size), arrayify18(extraEntropy)])) : randomBytes5(size);
9924
9999
  return Mnemonic.entropyToMnemonic(entropy);
9925
10000
  }
9926
10001
  };
@@ -9933,7 +10008,7 @@ var MainnetPUB = hexlify21("0x0488b21e");
9933
10008
  var TestnetPRV2 = hexlify21("0x04358394");
9934
10009
  var TestnetPUB = hexlify21("0x043587cf");
9935
10010
  function base58check(data) {
9936
- return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
10011
+ return encodeBase582(concat6([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
9937
10012
  }
9938
10013
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
9939
10014
  if (isPublic) {
@@ -9952,7 +10027,7 @@ function isValidExtendedKey(extendedKey) {
9952
10027
  function parsePath(path, depth = 0) {
9953
10028
  const components = path.split("/");
9954
10029
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
9955
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path}`);
10030
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, `invalid path - ${path}`);
9956
10031
  }
9957
10032
  if (components[0] === "m") {
9958
10033
  components.shift();
@@ -9981,8 +10056,8 @@ var HDWallet = class {
9981
10056
  this.privateKey = hexlify21(config.privateKey);
9982
10057
  } else {
9983
10058
  if (!config.publicKey) {
9984
- throw new FuelError22(
9985
- ErrorCode20.HD_WALLET_ERROR,
10059
+ throw new FuelError23(
10060
+ ErrorCode21.HD_WALLET_ERROR,
9986
10061
  "Both public and private Key cannot be missing. At least one should be provided."
9987
10062
  );
9988
10063
  }
@@ -10011,8 +10086,8 @@ var HDWallet = class {
10011
10086
  const data = new Uint8Array(37);
10012
10087
  if (index & HARDENED_INDEX) {
10013
10088
  if (!privateKey) {
10014
- throw new FuelError22(
10015
- ErrorCode20.HD_WALLET_ERROR,
10089
+ throw new FuelError23(
10090
+ ErrorCode21.HD_WALLET_ERROR,
10016
10091
  "Cannot derive a hardened index without a private Key."
10017
10092
  );
10018
10093
  }
@@ -10064,8 +10139,8 @@ var HDWallet = class {
10064
10139
  */
10065
10140
  toExtendedKey(isPublic = false, testnet = false) {
10066
10141
  if (this.depth >= 256) {
10067
- throw new FuelError22(
10068
- ErrorCode20.HD_WALLET_ERROR,
10142
+ throw new FuelError23(
10143
+ ErrorCode21.HD_WALLET_ERROR,
10069
10144
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
10070
10145
  );
10071
10146
  }
@@ -10074,8 +10149,8 @@ var HDWallet = class {
10074
10149
  const parentFingerprint = this.parentFingerprint;
10075
10150
  const index = toHex(this.index, 4);
10076
10151
  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]));
10152
+ const key = this.privateKey != null && !isPublic ? concat6(["0x00", this.privateKey]) : this.publicKey;
10153
+ const extendedKey = arrayify19(concat6([prefix, depth, parentFingerprint, index, chainCode, key]));
10079
10154
  return base58check(extendedKey);
10080
10155
  }
10081
10156
  /**
@@ -10096,10 +10171,10 @@ var HDWallet = class {
10096
10171
  const bytes = arrayify19(decoded);
10097
10172
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10098
10173
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10099
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10174
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10100
10175
  }
10101
10176
  if (!validChecksum) {
10102
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10177
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10103
10178
  }
10104
10179
  const depth = bytes[4];
10105
10180
  const parentFingerprint = hexlify21(bytes.slice(5, 9));
@@ -10107,14 +10182,14 @@ var HDWallet = class {
10107
10182
  const chainCode = hexlify21(bytes.slice(13, 45));
10108
10183
  const key = bytes.slice(45, 78);
10109
10184
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10110
- throw new FuelError22(
10111
- ErrorCode20.HD_WALLET_ERROR,
10185
+ throw new FuelError23(
10186
+ ErrorCode21.HD_WALLET_ERROR,
10112
10187
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
10113
10188
  );
10114
10189
  }
10115
10190
  if (isPublicExtendedKey(bytes)) {
10116
10191
  if (key[0] !== 3) {
10117
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
10192
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Invalid public extended key.");
10118
10193
  }
10119
10194
  return new HDWallet({
10120
10195
  publicKey: key,
@@ -10125,7 +10200,7 @@ var HDWallet = class {
10125
10200
  });
10126
10201
  }
10127
10202
  if (key[0] !== 0) {
10128
- throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
10203
+ throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Invalid private extended key.");
10129
10204
  }
10130
10205
  return new HDWallet({
10131
10206
  privateKey: key.slice(1),
@@ -10291,9 +10366,9 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
10291
10366
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
10292
10367
 
10293
10368
  // src/wallet-manager/wallet-manager.ts
10294
- import { Address as Address8 } from "@fuel-ts/address";
10369
+ import { Address as Address9 } from "@fuel-ts/address";
10295
10370
  import { encrypt, decrypt } from "@fuel-ts/crypto";
10296
- import { ErrorCode as ErrorCode23, FuelError as FuelError25 } from "@fuel-ts/errors";
10371
+ import { ErrorCode as ErrorCode24, FuelError as FuelError26 } from "@fuel-ts/errors";
10297
10372
  import { EventEmitter } from "events";
10298
10373
 
10299
10374
  // src/wallet-manager/storages/memory-storage.ts
@@ -10315,8 +10390,8 @@ var MemoryStorage = class {
10315
10390
  };
10316
10391
 
10317
10392
  // 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";
10393
+ import { Address as Address7 } from "@fuel-ts/address";
10394
+ import { ErrorCode as ErrorCode22, FuelError as FuelError24 } from "@fuel-ts/errors";
10320
10395
  var _secret;
10321
10396
  var MnemonicVault = class {
10322
10397
  constructor(options) {
@@ -10364,7 +10439,7 @@ var MnemonicVault = class {
10364
10439
  }
10365
10440
  exportAccount(address) {
10366
10441
  let numberOfAccounts = 0;
10367
- const ownerAddress = Address6.fromAddressOrString(address);
10442
+ const ownerAddress = Address7.fromAddressOrString(address);
10368
10443
  do {
10369
10444
  const wallet = Wallet.fromMnemonic(__privateGet(this, _secret), this.getDerivePath(numberOfAccounts));
10370
10445
  if (wallet.address.equals(ownerAddress)) {
@@ -10372,8 +10447,8 @@ var MnemonicVault = class {
10372
10447
  }
10373
10448
  numberOfAccounts += 1;
10374
10449
  } while (numberOfAccounts < this.numberOfAccounts);
10375
- throw new FuelError23(
10376
- ErrorCode21.WALLET_MANAGER_ERROR,
10450
+ throw new FuelError24(
10451
+ ErrorCode22.WALLET_MANAGER_ERROR,
10377
10452
  `Account with address '${address}' not found in derived wallets.`
10378
10453
  );
10379
10454
  }
@@ -10386,8 +10461,8 @@ _secret = new WeakMap();
10386
10461
  __publicField(MnemonicVault, "type", "mnemonic");
10387
10462
 
10388
10463
  // 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";
10464
+ import { Address as Address8 } from "@fuel-ts/address";
10465
+ import { ErrorCode as ErrorCode23, FuelError as FuelError25 } from "@fuel-ts/errors";
10391
10466
  var _privateKeys;
10392
10467
  var PrivateKeyVault = class {
10393
10468
  /**
@@ -10423,13 +10498,13 @@ var PrivateKeyVault = class {
10423
10498
  return this.getPublicAccount(wallet.privateKey);
10424
10499
  }
10425
10500
  exportAccount(address) {
10426
- const ownerAddress = Address7.fromAddressOrString(address);
10501
+ const ownerAddress = Address8.fromAddressOrString(address);
10427
10502
  const privateKey = __privateGet(this, _privateKeys).find(
10428
10503
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
10429
10504
  );
10430
10505
  if (!privateKey) {
10431
- throw new FuelError24(
10432
- ErrorCode22.WALLET_MANAGER_ERROR,
10506
+ throw new FuelError25(
10507
+ ErrorCode23.WALLET_MANAGER_ERROR,
10433
10508
  `No private key found for address '${address}'.`
10434
10509
  );
10435
10510
  }
@@ -10453,7 +10528,7 @@ var ERROR_MESSAGES = {
10453
10528
  };
10454
10529
  function assert(condition, message) {
10455
10530
  if (!condition) {
10456
- throw new FuelError25(ErrorCode23.WALLET_MANAGER_ERROR, message);
10531
+ throw new FuelError26(ErrorCode24.WALLET_MANAGER_ERROR, message);
10457
10532
  }
10458
10533
  }
10459
10534
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -10521,7 +10596,7 @@ var _WalletManager = class extends EventEmitter {
10521
10596
  * Create a Wallet instance for the specific account
10522
10597
  */
10523
10598
  getWallet(address) {
10524
- const ownerAddress = Address8.fromAddressOrString(address);
10599
+ const ownerAddress = Address9.fromAddressOrString(address);
10525
10600
  const vaultState = __privateGet(this, _vaults).find(
10526
10601
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
10527
10602
  );
@@ -10532,7 +10607,7 @@ var _WalletManager = class extends EventEmitter {
10532
10607
  * Export specific account privateKey
10533
10608
  */
10534
10609
  exportPrivateKey(address) {
10535
- const ownerAddress = Address8.fromAddressOrString(address);
10610
+ const ownerAddress = Address9.fromAddressOrString(address);
10536
10611
  assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
10537
10612
  const vaultState = __privateGet(this, _vaults).find(
10538
10613
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
@@ -10679,25 +10754,25 @@ deserializeVaults_fn = function(vaults) {
10679
10754
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
10680
10755
 
10681
10756
  // src/wallet-manager/types.ts
10682
- import { ErrorCode as ErrorCode24, FuelError as FuelError26 } from "@fuel-ts/errors";
10757
+ import { ErrorCode as ErrorCode25, FuelError as FuelError27 } from "@fuel-ts/errors";
10683
10758
  var Vault = class {
10684
10759
  constructor(_options) {
10685
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10760
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10686
10761
  }
10687
10762
  serialize() {
10688
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10763
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10689
10764
  }
10690
10765
  getAccounts() {
10691
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10766
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10692
10767
  }
10693
10768
  addAccount() {
10694
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10769
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10695
10770
  }
10696
10771
  exportAccount(_address) {
10697
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10772
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10698
10773
  }
10699
10774
  getWallet(_address) {
10700
- throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
10775
+ throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10701
10776
  }
10702
10777
  };
10703
10778
  __publicField(Vault, "type");
@@ -10706,35 +10781,237 @@ var StorageAbstract = class {
10706
10781
 
10707
10782
  // src/predicate/predicate.ts
10708
10783
  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";
10784
+ import { Address as Address10 } from "@fuel-ts/address";
10785
+ import { ErrorCode as ErrorCode27, FuelError as FuelError29 } from "@fuel-ts/errors";
10786
+ import { arrayify as arrayify22, hexlify as hexlify23 } from "@fuel-ts/utils";
10712
10787
 
10713
- // src/predicate/utils/getPredicateRoot.ts
10788
+ // src/utils/deployScriptOrPredicate.ts
10789
+ import { FuelError as FuelError28, ErrorCode as ErrorCode26 } from "@fuel-ts/errors";
10714
10790
  import { hash as hash3 } from "@fuel-ts/hasher";
10791
+ import { bn as bn21 } from "@fuel-ts/math";
10792
+ import { arrayify as arrayify20 } from "@fuel-ts/utils";
10793
+
10794
+ // src/utils/predicate-script-loader-instructions.ts
10795
+ import { concat as concat7 } from "@fuel-ts/utils";
10796
+ import * as asm2 from "@fuels/vm-asm";
10797
+ var BLOB_ID_SIZE = 32;
10798
+ var REG_ADDRESS_OF_DATA_AFTER_CODE = 16;
10799
+ var REG_START_OF_LOADED_CODE = 17;
10800
+ var REG_GENERAL_USE = 18;
10801
+ var WORD_SIZE2 = 8;
10802
+ function getDataOffset(binary) {
10803
+ const OFFSET_INDEX = 8;
10804
+ const dataView = new DataView(binary.buffer, OFFSET_INDEX, 8);
10805
+ const dataOffset = dataView.getBigUint64(0, false);
10806
+ return Number(dataOffset);
10807
+ }
10808
+ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
10809
+ const { RegId, Instruction } = asm2;
10810
+ const REG_PC = RegId.pc().to_u8();
10811
+ const REG_SP = RegId.sp().to_u8();
10812
+ const REG_IS = RegId.is().to_u8();
10813
+ const getInstructions = (numOfInstructions2) => [
10814
+ // 1. Load the blob content into memory
10815
+ // Find the start of the hardcoded blob ID, which is located after the loader code ends.
10816
+ asm2.move_(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_PC),
10817
+ // hold the address of the blob ID.
10818
+ asm2.addi(
10819
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10820
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10821
+ numOfInstructions2 * Instruction.size()
10822
+ ),
10823
+ // The code is going to be loaded from the current value of SP onwards, save
10824
+ // the location into REG_START_OF_LOADED_CODE so we can jump into it at the end.
10825
+ asm2.move_(REG_START_OF_LOADED_CODE, REG_SP),
10826
+ // REG_GENERAL_USE to hold the size of the blob.
10827
+ asm2.bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE),
10828
+ // Push the blob contents onto the stack.
10829
+ asm2.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1),
10830
+ // Move on to the data section length
10831
+ asm2.addi(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_ADDRESS_OF_DATA_AFTER_CODE, BLOB_ID_SIZE),
10832
+ // load the size of the data section into REG_GENERAL_USE
10833
+ asm2.lw(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE, 0),
10834
+ // after we have read the length of the data section, we move the pointer to the actual
10835
+ // data by skipping WORD_SIZE bytes.
10836
+ asm2.addi(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_ADDRESS_OF_DATA_AFTER_CODE, WORD_SIZE2),
10837
+ // load the data section of the executable
10838
+ asm2.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 2),
10839
+ // Jump into the memory where the contract is loaded.
10840
+ // What follows is called _jmp_mem by the sway compiler.
10841
+ // Subtract the address contained in IS because jmp will add it back.
10842
+ asm2.sub(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, REG_IS),
10843
+ // jmp will multiply by 4, so we need to divide to cancel that out.
10844
+ asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
10845
+ // Jump to the start of the contract we loaded.
10846
+ asm2.jmp(REG_START_OF_LOADED_CODE)
10847
+ ];
10848
+ const getInstructionsNoDataSection = (numOfInstructions2) => [
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
+ // 1. Load the blob content into memory
10852
+ // Find the start of the hardcoded blob ID, which is located after the loader code ends.
10853
+ asm2.move_(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_PC),
10854
+ // hold the address of the blob ID.
10855
+ asm2.addi(
10856
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10857
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10858
+ numOfInstructions2 * Instruction.size()
10859
+ ),
10860
+ // The code is going to be loaded from the current value of SP onwards, save
10861
+ // the location into REG_START_OF_LOADED_CODE so we can jump into it at the end.
10862
+ asm2.move_(REG_START_OF_LOADED_CODE, REG_SP),
10863
+ // REG_GENERAL_USE to hold the size of the blob.
10864
+ asm2.bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE),
10865
+ // Push the blob contents onto the stack.
10866
+ asm2.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1),
10867
+ // Jump into the memory where the contract is loaded.
10868
+ // What follows is called _jmp_mem by the sway compiler.
10869
+ // Subtract the address contained in IS because jmp will add it back.
10870
+ asm2.sub(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, REG_IS),
10871
+ // jmp will multiply by 4, so we need to divide to cancel that out.
10872
+ asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
10873
+ // Jump to the start of the contract we loaded.
10874
+ asm2.jmp(REG_START_OF_LOADED_CODE)
10875
+ ];
10876
+ const offset = getDataOffset(originalBinary);
10877
+ if (originalBinary.length < offset) {
10878
+ throw new Error(
10879
+ `Data section offset is out of bounds, offset: ${offset}, binary length: ${originalBinary.length}`
10880
+ );
10881
+ }
10882
+ const dataSection = originalBinary.slice(offset);
10883
+ if (dataSection.length > 0) {
10884
+ const numOfInstructions2 = getInstructions(0).length;
10885
+ if (numOfInstructions2 > 65535) {
10886
+ throw new Error("Too many instructions, exceeding u16::MAX.");
10887
+ }
10888
+ const instructionBytes2 = new Uint8Array(
10889
+ getInstructions(numOfInstructions2).flatMap(
10890
+ (instruction) => Array.from(instruction.to_bytes())
10891
+ )
10892
+ );
10893
+ const blobBytes2 = new Uint8Array(blobId);
10894
+ const dataSectionLenBytes = new Uint8Array(8);
10895
+ const dataView = new DataView(dataSectionLenBytes.buffer);
10896
+ dataView.setBigUint64(0, BigInt(dataSection.length), false);
10897
+ const loaderBytecode2 = new Uint8Array([
10898
+ ...instructionBytes2,
10899
+ ...blobBytes2,
10900
+ ...dataSectionLenBytes
10901
+ ]);
10902
+ return {
10903
+ loaderBytecode: concat7([loaderBytecode2, dataSection]),
10904
+ blobOffset: loaderBytecode2.length
10905
+ };
10906
+ }
10907
+ const numOfInstructions = getInstructionsNoDataSection(0).length;
10908
+ if (numOfInstructions > 65535) {
10909
+ throw new Error("Too many instructions, exceeding u16::MAX.");
10910
+ }
10911
+ const instructionBytes = new Uint8Array(
10912
+ getInstructionsNoDataSection(numOfInstructions).flatMap(
10913
+ (instruction) => Array.from(instruction.to_bytes())
10914
+ )
10915
+ );
10916
+ const blobBytes = new Uint8Array(blobId);
10917
+ const loaderBytecode = new Uint8Array([...instructionBytes, ...blobBytes]);
10918
+ return { loaderBytecode };
10919
+ }
10920
+
10921
+ // src/utils/deployScriptOrPredicate.ts
10922
+ async function fundBlobTx(deployer, blobTxRequest) {
10923
+ let totalCost = bn21(0);
10924
+ const chainInfo = deployer.provider.getChain();
10925
+ const gasPrice = await deployer.provider.estimateGasPrice(10);
10926
+ const priceFactor = chainInfo.consensusParameters.feeParameters.gasPriceFactor;
10927
+ const minGas = blobTxRequest.calculateMinGas(chainInfo);
10928
+ const minFee = calculateGasFee({
10929
+ gasPrice,
10930
+ gas: minGas,
10931
+ priceFactor,
10932
+ tip: blobTxRequest.tip
10933
+ }).add(1);
10934
+ totalCost = totalCost.add(minFee);
10935
+ if (totalCost.gt(await deployer.getBalance())) {
10936
+ throw new FuelError28(ErrorCode26.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
10937
+ }
10938
+ const txCost = await deployer.getTransactionCost(blobTxRequest);
10939
+ blobTxRequest.maxFee = txCost.maxFee;
10940
+ return deployer.fund(blobTxRequest, txCost);
10941
+ }
10942
+ function adjustConfigurableOffsets(jsonAbi, configurableOffsetDiff) {
10943
+ const { configurables: readOnlyConfigurables } = jsonAbi;
10944
+ const configurables = [];
10945
+ readOnlyConfigurables.forEach((config) => {
10946
+ configurables.push({ ...config, offset: config.offset - configurableOffsetDiff });
10947
+ });
10948
+ return { ...jsonAbi, configurables };
10949
+ }
10950
+ async function deployScriptOrPredicate({
10951
+ deployer,
10952
+ bytecode,
10953
+ abi,
10954
+ loaderInstanceCallback
10955
+ }) {
10956
+ const dataSectionOffset = getDataOffset(arrayify20(bytecode));
10957
+ const byteCodeWithoutDataSection = bytecode.slice(0, dataSectionOffset);
10958
+ const blobId = hash3(byteCodeWithoutDataSection);
10959
+ const blobTxRequest = new BlobTransactionRequest({
10960
+ blobId,
10961
+ witnessIndex: 0,
10962
+ witnesses: [byteCodeWithoutDataSection]
10963
+ });
10964
+ const { loaderBytecode, blobOffset } = getPredicateScriptLoaderInstructions(
10965
+ arrayify20(bytecode),
10966
+ arrayify20(blobId)
10967
+ );
10968
+ const configurableOffsetDiff = byteCodeWithoutDataSection.length - (blobOffset || 0);
10969
+ const newAbi = adjustConfigurableOffsets(abi, configurableOffsetDiff);
10970
+ const blobExists = (await deployer.provider.getBlobs([blobId])).length > 0;
10971
+ const loaderInstance = loaderInstanceCallback(loaderBytecode, newAbi);
10972
+ if (blobExists) {
10973
+ return {
10974
+ waitForResult: () => Promise.resolve(loaderInstance),
10975
+ blobId
10976
+ };
10977
+ }
10978
+ const fundedBlobRequest = await fundBlobTx(deployer, blobTxRequest);
10979
+ const waitForResult = async () => {
10980
+ try {
10981
+ const blobTx = await deployer.sendTransaction(fundedBlobRequest);
10982
+ const result = await blobTx.waitForResult();
10983
+ if (result.status !== "success" /* success */) {
10984
+ throw new Error();
10985
+ }
10986
+ } catch (err) {
10987
+ throw new FuelError28(ErrorCode26.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
10988
+ }
10989
+ return loaderInstance;
10990
+ };
10991
+ return {
10992
+ waitForResult,
10993
+ blobId
10994
+ };
10995
+ }
10996
+
10997
+ // src/predicate/utils/getPredicateRoot.ts
10998
+ import { hash as hash4 } from "@fuel-ts/hasher";
10715
10999
  import { calcRoot } from "@fuel-ts/merkle";
10716
- import { chunkAndPadBytes, hexlify as hexlify22, concat as concat6, arrayify as arrayify20 } from "@fuel-ts/utils";
11000
+ import { chunkAndPadBytes, hexlify as hexlify22, concat as concat8, arrayify as arrayify21 } from "@fuel-ts/utils";
10717
11001
  var getPredicateRoot = (bytecode) => {
10718
11002
  const chunkSize = 16 * 1024;
10719
- const bytes = arrayify20(bytecode);
11003
+ const bytes = arrayify21(bytecode);
10720
11004
  const chunks = chunkAndPadBytes(bytes, chunkSize);
10721
11005
  const codeRoot = calcRoot(chunks.map((c) => hexlify22(c)));
10722
- const predicateRoot = hash3(concat6(["0x4655454C", codeRoot]));
11006
+ const predicateRoot = hash4(concat8(["0x4655454C", codeRoot]));
10723
11007
  return predicateRoot;
10724
11008
  };
10725
11009
 
10726
11010
  // 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
11011
  var Predicate = class extends Account {
10734
11012
  bytes;
10735
11013
  predicateData = [];
10736
11014
  interface;
10737
- loaderBytecode = "";
10738
11015
  /**
10739
11016
  * Creates an instance of the Predicate class.
10740
11017
  *
@@ -10749,24 +11026,17 @@ var Predicate = class extends Account {
10749
11026
  abi,
10750
11027
  provider,
10751
11028
  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 = ""
11029
+ configurableConstants
10759
11030
  }) {
10760
11031
  const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
10761
11032
  bytecode,
10762
11033
  abi,
10763
11034
  configurableConstants
10764
11035
  );
10765
- const address = Address9.fromB256(getPredicateRoot(predicateBytes));
11036
+ const address = Address10.fromB256(getPredicateRoot(predicateBytes));
10766
11037
  super(address, provider);
10767
11038
  this.bytes = predicateBytes;
10768
11039
  this.interface = predicateInterface;
10769
- this.loaderBytecode = loaderBytecode;
10770
11040
  if (data !== void 0 && data.length > 0) {
10771
11041
  this.predicateData = data;
10772
11042
  }
@@ -10828,16 +11098,13 @@ var Predicate = class extends Account {
10828
11098
  * @returns An object containing the new predicate bytes and interface.
10829
11099
  */
10830
11100
  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
- }
11101
+ let predicateBytes = arrayify22(bytes);
11102
+ const abiInterface = new Interface4(jsonAbi);
11103
+ if (abiInterface.functions.main === void 0) {
11104
+ throw new FuelError29(
11105
+ ErrorCode27.ABI_MAIN_METHOD_MISSING,
11106
+ 'Cannot use ABI without "main" function.'
11107
+ );
10841
11108
  }
10842
11109
  if (configurableConstants && Object.keys(configurableConstants).length) {
10843
11110
  predicateBytes = Predicate.setConfigurableConstants(
@@ -10891,25 +11158,19 @@ var Predicate = class extends Account {
10891
11158
  * @param abiInterface - The ABI interface of the predicate.
10892
11159
  * @returns The mutated bytes with the configurable constants set.
10893
11160
  */
10894
- static setConfigurableConstants(bytes, configurableConstants, abiInterface, loaderBytecode) {
11161
+ static setConfigurableConstants(bytes, configurableConstants, abiInterface) {
10895
11162
  const mutatedBytes = bytes;
10896
11163
  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
11164
  if (Object.keys(abiInterface.configurables).length === 0) {
10904
- throw new FuelError27(
10905
- ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
11165
+ throw new FuelError29(
11166
+ ErrorCode27.INVALID_CONFIGURABLE_CONSTANTS,
10906
11167
  "Predicate has no configurable constants to be set"
10907
11168
  );
10908
11169
  }
10909
11170
  Object.entries(configurableConstants).forEach(([key, value]) => {
10910
11171
  if (!abiInterface?.configurables[key]) {
10911
- throw new FuelError27(
10912
- ErrorCode25.CONFIGURABLE_NOT_FOUND,
11172
+ throw new FuelError29(
11173
+ ErrorCode27.CONFIGURABLE_NOT_FOUND,
10913
11174
  `No configurable constant named '${key}' found in the Predicate`
10914
11175
  );
10915
11176
  }
@@ -10917,18 +11178,9 @@ var Predicate = class extends Account {
10917
11178
  const encoded = abiInterface.encodeConfigurable(key, value);
10918
11179
  mutatedBytes.set(encoded, offset);
10919
11180
  });
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
11181
  } catch (err) {
10930
- throw new FuelError27(
10931
- ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
11182
+ throw new FuelError29(
11183
+ ErrorCode27.INVALID_CONFIGURABLE_CONSTANTS,
10932
11184
  `Error setting configurable constants: ${err.message}.`
10933
11185
  );
10934
11186
  }
@@ -10956,13 +11208,35 @@ var Predicate = class extends Account {
10956
11208
  }
10957
11209
  return index;
10958
11210
  }
11211
+ /**
11212
+ *
11213
+ * @param account - The account used to pay the deployment costs.
11214
+ * @returns The _blobId_ and a _waitForResult_ callback that returns the deployed predicate
11215
+ * once the blob deployment transaction finishes.
11216
+ *
11217
+ * The returned loader predicate will have the same configurable constants
11218
+ * as the original predicate which was used to generate the loader predicate.
11219
+ */
11220
+ async deploy(account) {
11221
+ return deployScriptOrPredicate({
11222
+ deployer: account,
11223
+ abi: this.interface.jsonAbi,
11224
+ bytecode: this.bytes,
11225
+ loaderInstanceCallback: (loaderBytecode, newAbi) => new Predicate({
11226
+ bytecode: loaderBytecode,
11227
+ abi: newAbi,
11228
+ provider: this.provider,
11229
+ data: this.predicateData
11230
+ })
11231
+ });
11232
+ }
10959
11233
  };
10960
11234
 
10961
11235
  // src/connectors/fuel.ts
10962
- import { ErrorCode as ErrorCode26, FuelError as FuelError30 } from "@fuel-ts/errors";
11236
+ import { ErrorCode as ErrorCode28, FuelError as FuelError32 } from "@fuel-ts/errors";
10963
11237
 
10964
11238
  // src/connectors/fuel-connector.ts
10965
- import { FuelError as FuelError28 } from "@fuel-ts/errors";
11239
+ import { FuelError as FuelError30 } from "@fuel-ts/errors";
10966
11240
  import { EventEmitter as EventEmitter2 } from "events";
10967
11241
 
10968
11242
  // src/connectors/types/connector-types.ts
@@ -11037,7 +11311,7 @@ var FuelConnector = class extends EventEmitter2 {
11037
11311
  * @returns Always true.
11038
11312
  */
11039
11313
  async ping() {
11040
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11314
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11041
11315
  }
11042
11316
  /**
11043
11317
  * Should return the current version of the connector
@@ -11046,7 +11320,7 @@ var FuelConnector = class extends EventEmitter2 {
11046
11320
  * @returns boolean - connection status.
11047
11321
  */
11048
11322
  async version() {
11049
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11323
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11050
11324
  }
11051
11325
  /**
11052
11326
  * Should return true if the connector is connected
@@ -11055,7 +11329,7 @@ var FuelConnector = class extends EventEmitter2 {
11055
11329
  * @returns The connection status.
11056
11330
  */
11057
11331
  async isConnected() {
11058
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11332
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11059
11333
  }
11060
11334
  /**
11061
11335
  * Should return all the accounts authorized for the
@@ -11064,7 +11338,7 @@ var FuelConnector = class extends EventEmitter2 {
11064
11338
  * @returns The accounts addresses strings
11065
11339
  */
11066
11340
  async accounts() {
11067
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11341
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11068
11342
  }
11069
11343
  /**
11070
11344
  * Should start the connection process and return
@@ -11076,7 +11350,7 @@ var FuelConnector = class extends EventEmitter2 {
11076
11350
  * @returns boolean - connection status.
11077
11351
  */
11078
11352
  async connect() {
11079
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11353
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11080
11354
  }
11081
11355
  /**
11082
11356
  * Should disconnect the current connection and
@@ -11086,7 +11360,7 @@ var FuelConnector = class extends EventEmitter2 {
11086
11360
  * @returns The connection status.
11087
11361
  */
11088
11362
  async disconnect() {
11089
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11363
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11090
11364
  }
11091
11365
  /**
11092
11366
  * Should start the sign message process and return
@@ -11098,7 +11372,7 @@ var FuelConnector = class extends EventEmitter2 {
11098
11372
  * @returns Message signature
11099
11373
  */
11100
11374
  async signMessage(_address, _message) {
11101
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11375
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11102
11376
  }
11103
11377
  /**
11104
11378
  * Should start the sign transaction process and return
@@ -11110,7 +11384,7 @@ var FuelConnector = class extends EventEmitter2 {
11110
11384
  * @returns Transaction signature
11111
11385
  */
11112
11386
  async signTransaction(_address, _transaction) {
11113
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11387
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11114
11388
  }
11115
11389
  /**
11116
11390
  * Should start the send transaction process and return
@@ -11126,7 +11400,7 @@ var FuelConnector = class extends EventEmitter2 {
11126
11400
  * @returns The transaction id
11127
11401
  */
11128
11402
  async sendTransaction(_address, _transaction) {
11129
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11403
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11130
11404
  }
11131
11405
  /**
11132
11406
  * Should return the current account selected inside the connector, if the account
@@ -11137,7 +11411,7 @@ var FuelConnector = class extends EventEmitter2 {
11137
11411
  * @returns The current account selected otherwise null.
11138
11412
  */
11139
11413
  async currentAccount() {
11140
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11414
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11141
11415
  }
11142
11416
  /**
11143
11417
  * Should add the assets metadata to the connector and return true if the asset
@@ -11151,7 +11425,7 @@ var FuelConnector = class extends EventEmitter2 {
11151
11425
  * @returns True if the asset was added successfully
11152
11426
  */
11153
11427
  async addAssets(_assets) {
11154
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11428
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11155
11429
  }
11156
11430
  /**
11157
11431
  * Should add the asset metadata to the connector and return true if the asset
@@ -11165,7 +11439,7 @@ var FuelConnector = class extends EventEmitter2 {
11165
11439
  * @returns True if the asset was added successfully
11166
11440
  */
11167
11441
  async addAsset(_asset) {
11168
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11442
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11169
11443
  }
11170
11444
  /**
11171
11445
  * Should return all the assets added to the connector. If a connection is already established.
@@ -11173,7 +11447,7 @@ var FuelConnector = class extends EventEmitter2 {
11173
11447
  * @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
11174
11448
  */
11175
11449
  async assets() {
11176
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11450
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11177
11451
  }
11178
11452
  /**
11179
11453
  * Should start the add network process and return true if the network was added successfully.
@@ -11184,7 +11458,7 @@ var FuelConnector = class extends EventEmitter2 {
11184
11458
  * @returns Return true if the network was added successfully
11185
11459
  */
11186
11460
  async addNetwork(_networkUrl) {
11187
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11461
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11188
11462
  }
11189
11463
  /**
11190
11464
  * Should start the select network process and return true if the network has change successfully.
@@ -11195,7 +11469,7 @@ var FuelConnector = class extends EventEmitter2 {
11195
11469
  * @returns Return true if the network was added successfully
11196
11470
  */
11197
11471
  async selectNetwork(_network) {
11198
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11472
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11199
11473
  }
11200
11474
  /**
11201
11475
  * Should return all the networks available from the connector. If the connection is already established.
@@ -11203,7 +11477,7 @@ var FuelConnector = class extends EventEmitter2 {
11203
11477
  * @returns Return all the networks added to the connector.
11204
11478
  */
11205
11479
  async networks() {
11206
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11480
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11207
11481
  }
11208
11482
  /**
11209
11483
  * Should return the current network selected inside the connector. Even if the connection is not established.
@@ -11211,7 +11485,7 @@ var FuelConnector = class extends EventEmitter2 {
11211
11485
  * @returns Return the current network selected inside the connector.
11212
11486
  */
11213
11487
  async currentNetwork() {
11214
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11488
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11215
11489
  }
11216
11490
  /**
11217
11491
  * Should add the ABI to the connector and return true if the ABI was added successfully.
@@ -11221,7 +11495,7 @@ var FuelConnector = class extends EventEmitter2 {
11221
11495
  * @returns Return true if the ABI was added successfully.
11222
11496
  */
11223
11497
  async addABI(_contractId, _abi) {
11224
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11498
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11225
11499
  }
11226
11500
  /**
11227
11501
  * Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
@@ -11230,7 +11504,7 @@ var FuelConnector = class extends EventEmitter2 {
11230
11504
  * @returns The ABI if it exists, otherwise return null.
11231
11505
  */
11232
11506
  async getABI(_id) {
11233
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11507
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11234
11508
  }
11235
11509
  /**
11236
11510
  * Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
@@ -11239,7 +11513,7 @@ var FuelConnector = class extends EventEmitter2 {
11239
11513
  * @returns Returns true if the abi exists or false if not.
11240
11514
  */
11241
11515
  async hasABI(_id) {
11242
- throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11516
+ throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11243
11517
  }
11244
11518
  /**
11245
11519
  * Event listener for the connector.
@@ -11283,7 +11557,7 @@ function dispatchFuelConnectorEvent(connector) {
11283
11557
  }
11284
11558
 
11285
11559
  // src/connectors/utils/promises.ts
11286
- import { FuelError as FuelError29 } from "@fuel-ts/errors";
11560
+ import { FuelError as FuelError31 } from "@fuel-ts/errors";
11287
11561
  function deferPromise() {
11288
11562
  const defer = {};
11289
11563
  defer.promise = new Promise((resolve, reject) => {
@@ -11295,7 +11569,7 @@ function deferPromise() {
11295
11569
  async function withTimeout(promise, timeout = 1050) {
11296
11570
  const timeoutPromise = new Promise((resolve, reject) => {
11297
11571
  setTimeout(() => {
11298
- reject(new FuelError29(FuelError29.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
11572
+ reject(new FuelError31(FuelError31.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
11299
11573
  }, timeout);
11300
11574
  });
11301
11575
  return Promise.race([timeoutPromise, promise]);
@@ -11330,7 +11604,7 @@ var _Fuel = class extends FuelConnector {
11330
11604
  this._targetUnsubscribe = this.setupConnectorListener();
11331
11605
  await connectResponse;
11332
11606
  } catch (error) {
11333
- throw new FuelError30(ErrorCode26.INVALID_PROVIDER, "Error initializing Fuel Connector");
11607
+ throw new FuelError32(ErrorCode28.INVALID_PROVIDER, "Error initializing Fuel Connector");
11334
11608
  }
11335
11609
  }
11336
11610
  async init() {
@@ -11396,8 +11670,8 @@ var _Fuel = class extends FuelConnector {
11396
11670
  const hasConnector = await this.hasConnector();
11397
11671
  await this.pingConnector();
11398
11672
  if (!this._currentConnector || !hasConnector) {
11399
- throw new FuelError30(
11400
- ErrorCode26.MISSING_CONNECTOR,
11673
+ throw new FuelError32(
11674
+ ErrorCode28.MISSING_CONNECTOR,
11401
11675
  `No connector selected for calling ${method}. Use hasConnector before executing other methods.`
11402
11676
  );
11403
11677
  }
@@ -11461,7 +11735,7 @@ var _Fuel = class extends FuelConnector {
11461
11735
  cacheTime: PING_CACHE_TIME
11462
11736
  })();
11463
11737
  } catch {
11464
- throw new FuelError30(ErrorCode26.INVALID_PROVIDER, "Current connector is not available.");
11738
+ throw new FuelError32(ErrorCode28.INVALID_PROVIDER, "Current connector is not available.");
11465
11739
  }
11466
11740
  }
11467
11741
  /**
@@ -11610,7 +11884,7 @@ var _Fuel = class extends FuelConnector {
11610
11884
  const currentNetwork = await this.currentNetwork();
11611
11885
  provider = await Provider.create(currentNetwork.url);
11612
11886
  } else {
11613
- throw new FuelError30(ErrorCode26.INVALID_PROVIDER, "Provider is not valid.");
11887
+ throw new FuelError32(ErrorCode28.INVALID_PROVIDER, "Provider is not valid.");
11614
11888
  }
11615
11889
  return provider;
11616
11890
  }
@@ -11717,6 +11991,7 @@ export {
11717
11991
  calculateTXFeeForSummary,
11718
11992
  coinQuantityfy,
11719
11993
  deferPromise,
11994
+ deployScriptOrPredicate,
11720
11995
  dispatchFuelConnectorEvent,
11721
11996
  english,
11722
11997
  extractBurnedAssetsFromReceipts,