@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.
- package/dist/account.d.ts +6 -0
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +1401 -14796
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +621 -345
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +608 -333
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +16 -11
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +94 -126
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +5 -8
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/blob-transaction-request.d.ts +2 -2
- package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/errors.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts +9 -3
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +21 -3
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +38 -8
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/handle-gql-error-message.d.ts +2 -1
- package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/providers/utils/validate-pagination-args.d.ts +9 -0
- package/dist/providers/utils/validate-pagination-args.d.ts.map +1 -0
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +963 -14555
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +304 -234
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +298 -228
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/deployScriptOrPredicate.d.ts +14 -0
- package/dist/utils/deployScriptOrPredicate.d.ts.map +1 -0
- package/dist/utils/formatTransferToContractScriptData.d.ts +7 -7
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/utils/predicate-script-loader-instructions.d.ts +9 -0
- package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -0
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +19 -19
package/dist/test-utils.js
CHANGED
@@ -329,6 +329,8 @@ var launchNode = async ({
|
|
329
329
|
console.log(
|
330
330
|
`fuel-core node under pid ${child.pid} does not exist. The node might have been killed before cleanup was called. Exiting cleanly.`
|
331
331
|
);
|
332
|
+
} else if (error.message.includes("pid must be a positive integer")) {
|
333
|
+
process.kill(+child.pid);
|
332
334
|
} else {
|
333
335
|
throw e;
|
334
336
|
}
|
@@ -357,6 +359,7 @@ var launchNode = async ({
|
|
357
359
|
reject(new import_errors.FuelError(import_errors.FuelError.CODES.NODE_LAUNCH_FAILED, text));
|
358
360
|
}
|
359
361
|
});
|
362
|
+
process.setMaxListeners(100);
|
360
363
|
process.on("exit", cleanup);
|
361
364
|
process.on("SIGINT", cleanup);
|
362
365
|
process.on("SIGUSR1", cleanup);
|
@@ -408,7 +411,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
408
411
|
|
409
412
|
// src/providers/provider.ts
|
410
413
|
var import_address4 = require("@fuel-ts/address");
|
411
|
-
var
|
414
|
+
var import_errors19 = require("@fuel-ts/errors");
|
412
415
|
var import_math19 = require("@fuel-ts/math");
|
413
416
|
var import_transactions22 = require("@fuel-ts/transactions");
|
414
417
|
var import_utils30 = require("@fuel-ts/utils");
|
@@ -461,9 +464,6 @@ var ReceiptFragmentDoc = import_graphql_tag.default`
|
|
461
464
|
var SuccessStatusFragmentDoc = import_graphql_tag.default`
|
462
465
|
fragment SuccessStatusFragment on SuccessStatus {
|
463
466
|
type: __typename
|
464
|
-
block {
|
465
|
-
id
|
466
|
-
}
|
467
467
|
time
|
468
468
|
programState {
|
469
469
|
returnType
|
@@ -476,6 +476,14 @@ var SuccessStatusFragmentDoc = import_graphql_tag.default`
|
|
476
476
|
totalFee
|
477
477
|
}
|
478
478
|
${ReceiptFragmentDoc}`;
|
479
|
+
var SuccessStatusWithBlockIdFragmentDoc = import_graphql_tag.default`
|
480
|
+
fragment SuccessStatusWithBlockIdFragment on SuccessStatus {
|
481
|
+
...SuccessStatusFragment
|
482
|
+
block {
|
483
|
+
id
|
484
|
+
}
|
485
|
+
}
|
486
|
+
${SuccessStatusFragmentDoc}`;
|
479
487
|
var MalleableTransactionFieldsFragmentDoc = import_graphql_tag.default`
|
480
488
|
fragment malleableTransactionFieldsFragment on Transaction {
|
481
489
|
receiptsRoot
|
@@ -520,9 +528,6 @@ var MalleableTransactionFieldsFragmentDoc = import_graphql_tag.default`
|
|
520
528
|
var FailureStatusFragmentDoc = import_graphql_tag.default`
|
521
529
|
fragment FailureStatusFragment on FailureStatus {
|
522
530
|
type: __typename
|
523
|
-
block {
|
524
|
-
id
|
525
|
-
}
|
526
531
|
totalGas
|
527
532
|
totalFee
|
528
533
|
time
|
@@ -532,6 +537,14 @@ var FailureStatusFragmentDoc = import_graphql_tag.default`
|
|
532
537
|
}
|
533
538
|
}
|
534
539
|
${ReceiptFragmentDoc}`;
|
540
|
+
var FailureStatusWithBlockIdFragmentDoc = import_graphql_tag.default`
|
541
|
+
fragment FailureStatusWithBlockIdFragment on FailureStatus {
|
542
|
+
...FailureStatusFragment
|
543
|
+
block {
|
544
|
+
id
|
545
|
+
}
|
546
|
+
}
|
547
|
+
${FailureStatusFragmentDoc}`;
|
535
548
|
var SqueezedOutStatusFragmentDoc = import_graphql_tag.default`
|
536
549
|
fragment SqueezedOutStatusFragment on SqueezedOutStatus {
|
537
550
|
type: __typename
|
@@ -544,13 +557,13 @@ var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
|
|
544
557
|
...SubmittedStatusFragment
|
545
558
|
}
|
546
559
|
... on SuccessStatus {
|
547
|
-
...
|
560
|
+
...SuccessStatusWithBlockIdFragment
|
548
561
|
transaction {
|
549
562
|
...malleableTransactionFieldsFragment
|
550
563
|
}
|
551
564
|
}
|
552
565
|
... on FailureStatus {
|
553
|
-
...
|
566
|
+
...FailureStatusWithBlockIdFragment
|
554
567
|
transaction {
|
555
568
|
...malleableTransactionFieldsFragment
|
556
569
|
}
|
@@ -560,9 +573,9 @@ var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
|
|
560
573
|
}
|
561
574
|
}
|
562
575
|
${SubmittedStatusFragmentDoc}
|
563
|
-
${
|
576
|
+
${SuccessStatusWithBlockIdFragmentDoc}
|
564
577
|
${MalleableTransactionFieldsFragmentDoc}
|
565
|
-
${
|
578
|
+
${FailureStatusWithBlockIdFragmentDoc}
|
566
579
|
${SqueezedOutStatusFragmentDoc}`;
|
567
580
|
var TransactionStatusFragmentDoc = import_graphql_tag.default`
|
568
581
|
fragment transactionStatusFragment on TransactionStatus {
|
@@ -592,6 +605,12 @@ var TransactionFragmentDoc = import_graphql_tag.default`
|
|
592
605
|
}
|
593
606
|
}
|
594
607
|
${TransactionStatusFragmentDoc}`;
|
608
|
+
var TransactionRawPayloadFragmentDoc = import_graphql_tag.default`
|
609
|
+
fragment transactionRawPayloadFragment on Transaction {
|
610
|
+
id
|
611
|
+
rawPayload
|
612
|
+
}
|
613
|
+
`;
|
595
614
|
var InputEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
596
615
|
fragment inputEstimatePredicatesFragment on Input {
|
597
616
|
... on InputCoin {
|
@@ -679,7 +698,6 @@ var CoinFragmentDoc = import_graphql_tag.default`
|
|
679
698
|
fragment coinFragment on Coin {
|
680
699
|
type: __typename
|
681
700
|
utxoId
|
682
|
-
owner
|
683
701
|
amount
|
684
702
|
assetId
|
685
703
|
blockCreated
|
@@ -703,10 +721,15 @@ var MessageFragmentDoc = import_graphql_tag.default`
|
|
703
721
|
sender
|
704
722
|
recipient
|
705
723
|
data
|
706
|
-
nonce
|
707
724
|
daHeight
|
708
725
|
}
|
709
726
|
`;
|
727
|
+
var GetMessageFragmentDoc = import_graphql_tag.default`
|
728
|
+
fragment getMessageFragment on Message {
|
729
|
+
...messageFragment
|
730
|
+
nonce
|
731
|
+
}
|
732
|
+
${MessageFragmentDoc}`;
|
710
733
|
var MessageProofFragmentDoc = import_graphql_tag.default`
|
711
734
|
fragment messageProofFragment on MessageProof {
|
712
735
|
messageProof {
|
@@ -751,7 +774,6 @@ var MessageProofFragmentDoc = import_graphql_tag.default`
|
|
751
774
|
}
|
752
775
|
sender
|
753
776
|
recipient
|
754
|
-
nonce
|
755
777
|
amount
|
756
778
|
data
|
757
779
|
}
|
@@ -900,12 +922,6 @@ var RelayedTransactionStatusFragmentDoc = import_graphql_tag.default`
|
|
900
922
|
}
|
901
923
|
}
|
902
924
|
`;
|
903
|
-
var TransactionRawPayloadFragmentDoc = import_graphql_tag.default`
|
904
|
-
fragment transactionRawPayload on Transaction {
|
905
|
-
id
|
906
|
-
rawPayload
|
907
|
-
}
|
908
|
-
`;
|
909
925
|
var GetVersionDocument = import_graphql_tag.default`
|
910
926
|
query getVersion {
|
911
927
|
nodeInfo {
|
@@ -948,16 +964,34 @@ var GetTransactionDocument = import_graphql_tag.default`
|
|
948
964
|
var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
|
949
965
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
950
966
|
transaction(id: $transactionId) {
|
951
|
-
|
967
|
+
id
|
968
|
+
rawPayload
|
969
|
+
status {
|
970
|
+
... on SubmittedStatus {
|
971
|
+
...SubmittedStatusFragment
|
972
|
+
}
|
973
|
+
... on SuccessStatus {
|
974
|
+
...SuccessStatusWithBlockIdFragment
|
975
|
+
}
|
976
|
+
... on FailureStatus {
|
977
|
+
...FailureStatusWithBlockIdFragment
|
978
|
+
}
|
979
|
+
... on SqueezedOutStatus {
|
980
|
+
...SqueezedOutStatusFragment
|
981
|
+
}
|
982
|
+
}
|
952
983
|
}
|
953
984
|
}
|
954
|
-
${
|
985
|
+
${SubmittedStatusFragmentDoc}
|
986
|
+
${SuccessStatusWithBlockIdFragmentDoc}
|
987
|
+
${FailureStatusWithBlockIdFragmentDoc}
|
988
|
+
${SqueezedOutStatusFragmentDoc}`;
|
955
989
|
var GetTransactionsDocument = import_graphql_tag.default`
|
956
990
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
957
991
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
958
992
|
edges {
|
959
993
|
node {
|
960
|
-
|
994
|
+
rawPayload
|
961
995
|
}
|
962
996
|
}
|
963
997
|
pageInfo {
|
@@ -965,8 +999,7 @@ var GetTransactionsDocument = import_graphql_tag.default`
|
|
965
999
|
}
|
966
1000
|
}
|
967
1001
|
}
|
968
|
-
${
|
969
|
-
${PageInfoFragmentDoc}`;
|
1002
|
+
${PageInfoFragmentDoc}`;
|
970
1003
|
var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
971
1004
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
972
1005
|
transactionsByOwner(
|
@@ -1025,7 +1058,7 @@ var GetBlockWithTransactionsDocument = import_graphql_tag.default`
|
|
1025
1058
|
block(id: $blockId, height: $blockHeight) {
|
1026
1059
|
...blockFragment
|
1027
1060
|
transactions {
|
1028
|
-
...
|
1061
|
+
...transactionRawPayloadFragment
|
1029
1062
|
}
|
1030
1063
|
}
|
1031
1064
|
}
|
@@ -1050,6 +1083,7 @@ var GetCoinDocument = import_graphql_tag.default`
|
|
1050
1083
|
query getCoin($coinId: UtxoId!) {
|
1051
1084
|
coin(utxoId: $coinId) {
|
1052
1085
|
...coinFragment
|
1086
|
+
owner
|
1053
1087
|
}
|
1054
1088
|
}
|
1055
1089
|
${CoinFragmentDoc}`;
|
@@ -1158,13 +1192,13 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
1158
1192
|
}
|
1159
1193
|
edges {
|
1160
1194
|
node {
|
1161
|
-
...
|
1195
|
+
...getMessageFragment
|
1162
1196
|
}
|
1163
1197
|
}
|
1164
1198
|
}
|
1165
1199
|
}
|
1166
1200
|
${PageInfoFragmentDoc}
|
1167
|
-
${
|
1201
|
+
${GetMessageFragmentDoc}`;
|
1168
1202
|
var GetMessageProofDocument = import_graphql_tag.default`
|
1169
1203
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
1170
1204
|
messageProof(
|
@@ -1696,9 +1730,11 @@ function assembleReceiptByType(receipt) {
|
|
1696
1730
|
const { receiptType } = receipt;
|
1697
1731
|
switch (receiptType) {
|
1698
1732
|
case "CALL" /* Call */: {
|
1733
|
+
const id = hexOrZero(receipt.id || receipt.contractId);
|
1699
1734
|
const callReceipt = {
|
1700
1735
|
type: import_transactions3.ReceiptType.Call,
|
1701
|
-
|
1736
|
+
id,
|
1737
|
+
from: id,
|
1702
1738
|
to: hexOrZero(receipt?.to),
|
1703
1739
|
amount: (0, import_math5.bn)(receipt.amount),
|
1704
1740
|
assetId: hexOrZero(receipt.assetId),
|
@@ -1755,24 +1791,36 @@ function assembleReceiptByType(receipt) {
|
|
1755
1791
|
return revertReceipt;
|
1756
1792
|
}
|
1757
1793
|
case "LOG" /* Log */: {
|
1794
|
+
const ra = (0, import_math5.bn)(receipt.ra);
|
1795
|
+
const rb = (0, import_math5.bn)(receipt.rb);
|
1796
|
+
const rc = (0, import_math5.bn)(receipt.rc);
|
1797
|
+
const rd = (0, import_math5.bn)(receipt.rd);
|
1758
1798
|
const logReceipt = {
|
1759
1799
|
type: import_transactions3.ReceiptType.Log,
|
1760
1800
|
id: hexOrZero(receipt.id || receipt.contractId),
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1801
|
+
ra,
|
1802
|
+
rb,
|
1803
|
+
rc,
|
1804
|
+
rd,
|
1805
|
+
val0: ra,
|
1806
|
+
val1: rb,
|
1807
|
+
val2: rc,
|
1808
|
+
val3: rd,
|
1765
1809
|
pc: (0, import_math5.bn)(receipt.pc),
|
1766
1810
|
is: (0, import_math5.bn)(receipt.is)
|
1767
1811
|
};
|
1768
1812
|
return logReceipt;
|
1769
1813
|
}
|
1770
1814
|
case "LOG_DATA" /* LogData */: {
|
1815
|
+
const ra = (0, import_math5.bn)(receipt.ra);
|
1816
|
+
const rb = (0, import_math5.bn)(receipt.rb);
|
1771
1817
|
const logDataReceipt = {
|
1772
1818
|
type: import_transactions3.ReceiptType.LogData,
|
1773
1819
|
id: hexOrZero(receipt.id || receipt.contractId),
|
1774
|
-
|
1775
|
-
|
1820
|
+
ra,
|
1821
|
+
rb,
|
1822
|
+
val0: ra,
|
1823
|
+
val1: rb,
|
1776
1824
|
ptr: (0, import_math5.bn)(receipt.ptr),
|
1777
1825
|
len: (0, import_math5.bn)(receipt.len),
|
1778
1826
|
digest: hexOrZero(receipt.digest),
|
@@ -1783,9 +1831,11 @@ function assembleReceiptByType(receipt) {
|
|
1783
1831
|
return logDataReceipt;
|
1784
1832
|
}
|
1785
1833
|
case "TRANSFER" /* Transfer */: {
|
1834
|
+
const id = hexOrZero(receipt.id || receipt.contractId);
|
1786
1835
|
const transferReceipt = {
|
1787
1836
|
type: import_transactions3.ReceiptType.Transfer,
|
1788
|
-
|
1837
|
+
id,
|
1838
|
+
from: id,
|
1789
1839
|
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1790
1840
|
amount: (0, import_math5.bn)(receipt.amount),
|
1791
1841
|
assetId: hexOrZero(receipt.assetId),
|
@@ -1795,9 +1845,11 @@ function assembleReceiptByType(receipt) {
|
|
1795
1845
|
return transferReceipt;
|
1796
1846
|
}
|
1797
1847
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1848
|
+
const id = hexOrZero(receipt.id || receipt.contractId);
|
1798
1849
|
const transferOutReceipt = {
|
1799
1850
|
type: import_transactions3.ReceiptType.TransferOut,
|
1800
|
-
|
1851
|
+
id,
|
1852
|
+
from: id,
|
1801
1853
|
to: hexOrZero(receipt.toAddress || receipt.to),
|
1802
1854
|
amount: (0, import_math5.bn)(receipt.amount),
|
1803
1855
|
assetId: hexOrZero(receipt.assetId),
|
@@ -2774,7 +2826,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
|
|
2774
2826
|
type = import_transactions7.TransactionType.Blob;
|
2775
2827
|
/** Blob ID */
|
2776
2828
|
blobId;
|
2777
|
-
/** Witness index of
|
2829
|
+
/** Witness index of the bytecode to create */
|
2778
2830
|
witnessIndex;
|
2779
2831
|
/**
|
2780
2832
|
* Creates an instance `BlobTransactionRequest`.
|
@@ -4105,14 +4157,14 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
4105
4157
|
switch (gqlTransactionStatus.type) {
|
4106
4158
|
case "SuccessStatus":
|
4107
4159
|
time = gqlTransactionStatus.time;
|
4108
|
-
blockId = gqlTransactionStatus.block
|
4160
|
+
blockId = gqlTransactionStatus.block?.id;
|
4109
4161
|
isStatusSuccess = true;
|
4110
4162
|
totalFee = (0, import_math16.bn)(gqlTransactionStatus.totalFee);
|
4111
4163
|
totalGas = (0, import_math16.bn)(gqlTransactionStatus.totalGas);
|
4112
4164
|
break;
|
4113
4165
|
case "FailureStatus":
|
4114
4166
|
time = gqlTransactionStatus.time;
|
4115
|
-
blockId = gqlTransactionStatus.block
|
4167
|
+
blockId = gqlTransactionStatus.block?.id;
|
4116
4168
|
isStatusFailure = true;
|
4117
4169
|
totalFee = (0, import_math16.bn)(gqlTransactionStatus.totalFee);
|
4118
4170
|
totalGas = (0, import_math16.bn)(gqlTransactionStatus.totalGas);
|
@@ -4547,11 +4599,53 @@ var handleGqlErrorMessage = (errorMessage, rawError) => {
|
|
4547
4599
|
{},
|
4548
4600
|
rawError
|
4549
4601
|
);
|
4602
|
+
case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
|
4603
|
+
throw new import_errors17.FuelError(
|
4604
|
+
import_errors17.ErrorCode.MAX_COINS_REACHED,
|
4605
|
+
"The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
|
4606
|
+
{},
|
4607
|
+
rawError
|
4608
|
+
);
|
4550
4609
|
default:
|
4551
4610
|
throw new import_errors17.FuelError(import_errors17.ErrorCode.INVALID_REQUEST, errorMessage);
|
4552
4611
|
}
|
4553
4612
|
};
|
4554
4613
|
|
4614
|
+
// src/providers/utils/validate-pagination-args.ts
|
4615
|
+
var import_errors18 = require("@fuel-ts/errors");
|
4616
|
+
var validatePaginationArgs = (params) => {
|
4617
|
+
const { paginationLimit, inputArgs = {} } = params;
|
4618
|
+
const { first, last, after, before } = inputArgs;
|
4619
|
+
if (after && before) {
|
4620
|
+
throw new import_errors18.FuelError(
|
4621
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4622
|
+
'Pagination arguments "after" and "before" cannot be used together'
|
4623
|
+
);
|
4624
|
+
}
|
4625
|
+
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
4626
|
+
throw new import_errors18.FuelError(
|
4627
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4628
|
+
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
4629
|
+
);
|
4630
|
+
}
|
4631
|
+
if (first && before) {
|
4632
|
+
throw new import_errors18.FuelError(
|
4633
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4634
|
+
'The use of pagination argument "first" with "before" is not supported'
|
4635
|
+
);
|
4636
|
+
}
|
4637
|
+
if (last && after) {
|
4638
|
+
throw new import_errors18.FuelError(
|
4639
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4640
|
+
'The use of pagination argument "last" with "after" is not supported'
|
4641
|
+
);
|
4642
|
+
}
|
4643
|
+
if (!first && !last) {
|
4644
|
+
inputArgs.first = paginationLimit;
|
4645
|
+
}
|
4646
|
+
return inputArgs;
|
4647
|
+
};
|
4648
|
+
|
4555
4649
|
// src/providers/provider.ts
|
4556
4650
|
var MAX_RETRIES = 10;
|
4557
4651
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
@@ -4696,7 +4790,7 @@ var _Provider = class {
|
|
4696
4790
|
try {
|
4697
4791
|
parsedUrl = new URL(url);
|
4698
4792
|
} catch (error) {
|
4699
|
-
throw new
|
4793
|
+
throw new import_errors19.FuelError(import_errors19.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4700
4794
|
}
|
4701
4795
|
const username = parsedUrl.username;
|
4702
4796
|
const password = parsedUrl.password;
|
@@ -4731,8 +4825,8 @@ var _Provider = class {
|
|
4731
4825
|
getChain() {
|
4732
4826
|
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
4733
4827
|
if (!chain) {
|
4734
|
-
throw new
|
4735
|
-
|
4828
|
+
throw new import_errors19.FuelError(
|
4829
|
+
import_errors19.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
4736
4830
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4737
4831
|
);
|
4738
4832
|
}
|
@@ -4746,8 +4840,8 @@ var _Provider = class {
|
|
4746
4840
|
getNode() {
|
4747
4841
|
const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4748
4842
|
if (!node) {
|
4749
|
-
throw new
|
4750
|
-
|
4843
|
+
throw new import_errors19.FuelError(
|
4844
|
+
import_errors19.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
4751
4845
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4752
4846
|
);
|
4753
4847
|
}
|
@@ -4843,7 +4937,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4843
4937
|
createOperations() {
|
4844
4938
|
const fetchFn = _Provider.getFetchFn(this.options);
|
4845
4939
|
const gqlClient = new import_graphql_request.GraphQLClient(this.urlWithoutAuth, {
|
4846
|
-
fetch: (
|
4940
|
+
fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
|
4847
4941
|
responseMiddleware: (response) => {
|
4848
4942
|
if ("response" in response) {
|
4849
4943
|
const graphQlResponse = response.response;
|
@@ -4973,14 +5067,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4973
5067
|
}
|
4974
5068
|
} = this.getChain();
|
4975
5069
|
if ((0, import_math19.bn)(tx.inputs.length).gt(maxInputs)) {
|
4976
|
-
throw new
|
4977
|
-
|
5070
|
+
throw new import_errors19.FuelError(
|
5071
|
+
import_errors19.ErrorCode.MAX_INPUTS_EXCEEDED,
|
4978
5072
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
4979
5073
|
);
|
4980
5074
|
}
|
4981
5075
|
if ((0, import_math19.bn)(tx.outputs.length).gt(maxOutputs)) {
|
4982
|
-
throw new
|
4983
|
-
|
5076
|
+
throw new import_errors19.FuelError(
|
5077
|
+
import_errors19.ErrorCode.MAX_OUTPUTS_EXCEEDED,
|
4984
5078
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
4985
5079
|
);
|
4986
5080
|
}
|
@@ -5094,7 +5188,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5094
5188
|
dryRun: [{ receipts: rawReceipts, status }]
|
5095
5189
|
} = await this.operations.dryRun({
|
5096
5190
|
encodedTransactions: [(0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())],
|
5097
|
-
utxoValidation: false
|
5191
|
+
utxoValidation: false,
|
5192
|
+
gasPrice: "0"
|
5098
5193
|
});
|
5099
5194
|
receipts = rawReceipts.map(processGqlReceipt);
|
5100
5195
|
dryRunStatus = status;
|
@@ -5108,7 +5203,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5108
5203
|
missingContractIds.push(contractId);
|
5109
5204
|
});
|
5110
5205
|
const { maxFee } = await this.estimateTxGasAndFee({
|
5111
|
-
transactionRequest
|
5206
|
+
transactionRequest,
|
5207
|
+
gasPrice: (0, import_math19.bn)(0)
|
5112
5208
|
});
|
5113
5209
|
transactionRequest.maxFee = maxFee;
|
5114
5210
|
} else {
|
@@ -5244,7 +5340,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5244
5340
|
const chainInfo = this.getChain();
|
5245
5341
|
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
5246
5342
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
5247
|
-
if (!gasPrice) {
|
5343
|
+
if (!(0, import_utils30.isDefined)(gasPrice)) {
|
5248
5344
|
gasPrice = await this.estimateGasPrice(10);
|
5249
5345
|
}
|
5250
5346
|
const minFee = calculateGasFee({
|
@@ -5393,7 +5489,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5393
5489
|
const {
|
5394
5490
|
coins: { edges, pageInfo }
|
5395
5491
|
} = await this.operations.getCoins({
|
5396
|
-
...
|
5492
|
+
...validatePaginationArgs({
|
5397
5493
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
5398
5494
|
inputArgs: paginationArgs
|
5399
5495
|
}),
|
@@ -5403,7 +5499,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5403
5499
|
id: node.utxoId,
|
5404
5500
|
assetId: node.assetId,
|
5405
5501
|
amount: (0, import_math19.bn)(node.amount),
|
5406
|
-
owner:
|
5502
|
+
owner: ownerAddress,
|
5407
5503
|
blockCreated: (0, import_math19.bn)(node.blockCreated),
|
5408
5504
|
txCreatedIdx: (0, import_math19.bn)(node.txCreatedIdx)
|
5409
5505
|
}));
|
@@ -5457,7 +5553,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5457
5553
|
id: coin.utxoId,
|
5458
5554
|
amount: (0, import_math19.bn)(coin.amount),
|
5459
5555
|
assetId: coin.assetId,
|
5460
|
-
owner:
|
5556
|
+
owner: ownerAddress,
|
5461
5557
|
blockCreated: (0, import_math19.bn)(coin.blockCreated),
|
5462
5558
|
txCreatedIdx: (0, import_math19.bn)(coin.txCreatedIdx)
|
5463
5559
|
};
|
@@ -5532,7 +5628,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5532
5628
|
const {
|
5533
5629
|
blocks: { edges, pageInfo }
|
5534
5630
|
} = await this.operations.getBlocks({
|
5535
|
-
...
|
5631
|
+
...validatePaginationArgs({
|
5536
5632
|
paginationLimit: BLOCKS_PAGE_SIZE_LIMIT,
|
5537
5633
|
inputArgs: params
|
5538
5634
|
})
|
@@ -5611,7 +5707,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5611
5707
|
0
|
5612
5708
|
)?.[0];
|
5613
5709
|
} catch (error) {
|
5614
|
-
if (error instanceof
|
5710
|
+
if (error instanceof import_errors19.FuelError && error.code === import_errors19.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5615
5711
|
console.warn("Unsupported transaction type encountered");
|
5616
5712
|
return null;
|
5617
5713
|
}
|
@@ -5627,7 +5723,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5627
5723
|
const {
|
5628
5724
|
transactions: { edges, pageInfo }
|
5629
5725
|
} = await this.operations.getTransactions({
|
5630
|
-
...
|
5726
|
+
...validatePaginationArgs({
|
5631
5727
|
inputArgs: paginationArgs,
|
5632
5728
|
paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
|
5633
5729
|
})
|
@@ -5637,7 +5733,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5637
5733
|
try {
|
5638
5734
|
return coder.decode((0, import_utils30.arrayify)(rawPayload), 0)[0];
|
5639
5735
|
} catch (error) {
|
5640
|
-
if (error instanceof
|
5736
|
+
if (error instanceof import_errors19.FuelError && error.code === import_errors19.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5641
5737
|
console.warn("Unsupported transaction type encountered");
|
5642
5738
|
return null;
|
5643
5739
|
}
|
@@ -5722,7 +5818,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5722
5818
|
const {
|
5723
5819
|
messages: { edges, pageInfo }
|
5724
5820
|
} = await this.operations.getMessages({
|
5725
|
-
...
|
5821
|
+
...validatePaginationArgs({
|
5726
5822
|
inputArgs: paginationArgs,
|
5727
5823
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
|
5728
5824
|
}),
|
@@ -5763,8 +5859,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5763
5859
|
nonce
|
5764
5860
|
};
|
5765
5861
|
if (commitBlockId && commitBlockHeight) {
|
5766
|
-
throw new
|
5767
|
-
|
5862
|
+
throw new import_errors19.FuelError(
|
5863
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5768
5864
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5769
5865
|
);
|
5770
5866
|
}
|
@@ -5946,13 +6042,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5946
6042
|
messageId: import_transactions22.InputMessageCoder.getMessageId({
|
5947
6043
|
sender: rawMessage.sender,
|
5948
6044
|
recipient: rawMessage.recipient,
|
5949
|
-
nonce
|
6045
|
+
nonce,
|
5950
6046
|
amount: (0, import_math19.bn)(rawMessage.amount),
|
5951
6047
|
data: rawMessage.data
|
5952
6048
|
}),
|
5953
6049
|
sender: import_address4.Address.fromAddressOrString(rawMessage.sender),
|
5954
6050
|
recipient: import_address4.Address.fromAddressOrString(rawMessage.recipient),
|
5955
|
-
nonce
|
6051
|
+
nonce,
|
5956
6052
|
amount: (0, import_math19.bn)(rawMessage.amount),
|
5957
6053
|
data: import_transactions22.InputMessageCoder.decodeData(rawMessage.data),
|
5958
6054
|
daHeight: (0, import_math19.bn)(rawMessage.daHeight)
|
@@ -5974,41 +6070,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5974
6070
|
}
|
5975
6071
|
return relayedTransactionStatus;
|
5976
6072
|
}
|
5977
|
-
/**
|
5978
|
-
* @hidden
|
5979
|
-
*/
|
5980
|
-
validatePaginationArgs(params) {
|
5981
|
-
const { paginationLimit, inputArgs = {} } = params;
|
5982
|
-
const { first, last, after, before } = inputArgs;
|
5983
|
-
if (after && before) {
|
5984
|
-
throw new import_errors18.FuelError(
|
5985
|
-
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5986
|
-
'Pagination arguments "after" and "before" cannot be used together'
|
5987
|
-
);
|
5988
|
-
}
|
5989
|
-
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5990
|
-
throw new import_errors18.FuelError(
|
5991
|
-
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5992
|
-
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5993
|
-
);
|
5994
|
-
}
|
5995
|
-
if (first && before) {
|
5996
|
-
throw new import_errors18.FuelError(
|
5997
|
-
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5998
|
-
'The use of pagination argument "first" with "before" is not supported'
|
5999
|
-
);
|
6000
|
-
}
|
6001
|
-
if (last && after) {
|
6002
|
-
throw new import_errors18.FuelError(
|
6003
|
-
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
6004
|
-
'The use of pagination argument "last" with "after" is not supported'
|
6005
|
-
);
|
6006
|
-
}
|
6007
|
-
if (!first && !last) {
|
6008
|
-
inputArgs.first = paginationLimit;
|
6009
|
-
}
|
6010
|
-
return inputArgs;
|
6011
|
-
}
|
6012
6073
|
/**
|
6013
6074
|
* @hidden
|
6014
6075
|
*/
|
@@ -6054,7 +6115,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
6054
6115
|
__publicField(Provider, "nodeInfoCache", {});
|
6055
6116
|
|
6056
6117
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6057
|
-
var
|
6118
|
+
var import_errors20 = require("@fuel-ts/errors");
|
6058
6119
|
var import_math20 = require("@fuel-ts/math");
|
6059
6120
|
var import_transactions23 = require("@fuel-ts/transactions");
|
6060
6121
|
var import_utils33 = require("@fuel-ts/utils");
|
@@ -6688,7 +6749,7 @@ __publicField(TestAssetId, "B", new _TestAssetId(
|
|
6688
6749
|
|
6689
6750
|
// src/test-utils/wallet-config.ts
|
6690
6751
|
var import_crypto9 = require("@fuel-ts/crypto");
|
6691
|
-
var
|
6752
|
+
var import_errors26 = require("@fuel-ts/errors");
|
6692
6753
|
var import_utils44 = require("@fuel-ts/utils");
|
6693
6754
|
|
6694
6755
|
// src/wallet/base-wallet-unlocked.ts
|
@@ -6697,11 +6758,11 @@ var import_utils39 = require("@fuel-ts/utils");
|
|
6697
6758
|
|
6698
6759
|
// src/account.ts
|
6699
6760
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
6700
|
-
var
|
6761
|
+
var import_address6 = require("@fuel-ts/address");
|
6701
6762
|
var import_crypto5 = require("@fuel-ts/crypto");
|
6702
|
-
var
|
6763
|
+
var import_errors21 = require("@fuel-ts/errors");
|
6703
6764
|
var import_interfaces = require("@fuel-ts/interfaces");
|
6704
|
-
var
|
6765
|
+
var import_math21 = require("@fuel-ts/math");
|
6705
6766
|
var import_transactions24 = require("@fuel-ts/transactions");
|
6706
6767
|
var import_utils37 = require("@fuel-ts/utils");
|
6707
6768
|
var import_ramda9 = require("ramda");
|
@@ -6722,37 +6783,45 @@ var mergeQuantities = (...coinQuantities) => {
|
|
6722
6783
|
|
6723
6784
|
// src/utils/formatTransferToContractScriptData.ts
|
6724
6785
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
6725
|
-
var
|
6786
|
+
var import_address5 = require("@fuel-ts/address");
|
6726
6787
|
var import_utils36 = require("@fuel-ts/utils");
|
6727
6788
|
var asm = __toESM(require("@fuels/vm-asm"));
|
6728
|
-
var formatTransferToContractScriptData = (
|
6729
|
-
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
6789
|
+
var formatTransferToContractScriptData = (transferParams) => {
|
6730
6790
|
const numberCoder = new import_abi_coder7.BigNumberCoder("u64");
|
6731
|
-
|
6732
|
-
|
6733
|
-
|
6734
|
-
|
6735
|
-
|
6736
|
-
|
6737
|
-
|
6791
|
+
return transferParams.reduce((acc, transferParam) => {
|
6792
|
+
const { assetId, amount, contractId } = transferParam;
|
6793
|
+
const encoded = numberCoder.encode(amount);
|
6794
|
+
const scriptData = (0, import_utils36.concat)([
|
6795
|
+
import_address5.Address.fromAddressOrString(contractId).toBytes(),
|
6796
|
+
encoded,
|
6797
|
+
(0, import_utils36.arrayify)(assetId)
|
6798
|
+
]);
|
6799
|
+
return (0, import_utils36.concat)([acc, scriptData]);
|
6800
|
+
}, new Uint8Array());
|
6738
6801
|
};
|
6739
|
-
var assembleTransferToContractScript = async (
|
6740
|
-
const scriptData = formatTransferToContractScriptData(
|
6802
|
+
var assembleTransferToContractScript = async (transferParams) => {
|
6803
|
+
const scriptData = formatTransferToContractScriptData(transferParams);
|
6741
6804
|
await asm.initWasm();
|
6742
|
-
|
6743
|
-
|
6744
|
-
|
6745
|
-
|
6746
|
-
|
6747
|
-
|
6748
|
-
|
6749
|
-
|
6750
|
-
|
6751
|
-
|
6752
|
-
|
6753
|
-
|
6754
|
-
|
6755
|
-
|
6805
|
+
let script = new Uint8Array();
|
6806
|
+
transferParams.forEach((_, i) => {
|
6807
|
+
const offset = (import_abi_coder7.CONTRACT_ID_LEN + import_abi_coder7.WORD_SIZE + import_abi_coder7.ASSET_ID_LEN) * i;
|
6808
|
+
script = (0, import_utils36.concat)([
|
6809
|
+
script,
|
6810
|
+
// Load ScriptData into register 0x10.
|
6811
|
+
asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
|
6812
|
+
// Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
|
6813
|
+
asm.addi(17, 16, offset).to_bytes(),
|
6814
|
+
// Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
|
6815
|
+
asm.addi(18, 17, import_abi_coder7.CONTRACT_ID_LEN).to_bytes(),
|
6816
|
+
// Load word to the amount at 0x12 into register 0x13.
|
6817
|
+
asm.lw(19, 18, 0).to_bytes(),
|
6818
|
+
// Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
|
6819
|
+
asm.addi(20, 18, import_abi_coder7.WORD_SIZE).to_bytes(),
|
6820
|
+
// Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
|
6821
|
+
asm.tr(17, 19, 20).to_bytes()
|
6822
|
+
]);
|
6823
|
+
});
|
6824
|
+
script = (0, import_utils36.concat)([script, asm.ret(1).to_bytes()]);
|
6756
6825
|
return { script, scriptData };
|
6757
6826
|
};
|
6758
6827
|
|
@@ -6782,7 +6851,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6782
6851
|
super();
|
6783
6852
|
this._provider = provider;
|
6784
6853
|
this._connector = connector;
|
6785
|
-
this.address =
|
6854
|
+
this.address = import_address6.Address.fromDynamicInput(address);
|
6786
6855
|
}
|
6787
6856
|
/**
|
6788
6857
|
* The provider used to interact with the network.
|
@@ -6793,7 +6862,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6793
6862
|
*/
|
6794
6863
|
get provider() {
|
6795
6864
|
if (!this._provider) {
|
6796
|
-
throw new
|
6865
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
6797
6866
|
}
|
6798
6867
|
return this._provider;
|
6799
6868
|
}
|
@@ -6873,9 +6942,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6873
6942
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
|
6874
6943
|
const fee = request.maxFee;
|
6875
6944
|
const baseAssetId = this.provider.getBaseAssetId();
|
6876
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0,
|
6945
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
|
6877
6946
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
6878
|
-
amount: (0,
|
6947
|
+
amount: (0, import_math21.bn)(fee),
|
6879
6948
|
assetId: baseAssetId,
|
6880
6949
|
coinQuantities: requiredQuantities
|
6881
6950
|
});
|
@@ -6883,7 +6952,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6883
6952
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
6884
6953
|
quantitiesDict[assetId] = {
|
6885
6954
|
required: amount,
|
6886
|
-
owned: (0,
|
6955
|
+
owned: (0, import_math21.bn)(0)
|
6887
6956
|
};
|
6888
6957
|
});
|
6889
6958
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -6944,8 +7013,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6944
7013
|
fundingAttempts += 1;
|
6945
7014
|
}
|
6946
7015
|
if (needsToBeFunded) {
|
6947
|
-
throw new
|
6948
|
-
|
7016
|
+
throw new import_errors21.FuelError(
|
7017
|
+
import_errors21.ErrorCode.NOT_ENOUGH_FUNDS,
|
6949
7018
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6950
7019
|
);
|
6951
7020
|
}
|
@@ -6959,7 +7028,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6959
7028
|
return request;
|
6960
7029
|
}
|
6961
7030
|
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
6962
|
-
transactionRequest: requestToReestimate
|
7031
|
+
transactionRequest: requestToReestimate,
|
7032
|
+
gasPrice
|
6963
7033
|
});
|
6964
7034
|
request.maxFee = maxFee;
|
6965
7035
|
return request;
|
@@ -7016,7 +7086,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7016
7086
|
const { destination, amount, assetId } = transferParams;
|
7017
7087
|
this.validateTransferAmount(amount);
|
7018
7088
|
request.addCoinOutput(
|
7019
|
-
|
7089
|
+
import_address6.Address.fromAddressOrString(destination),
|
7020
7090
|
amount,
|
7021
7091
|
assetId ?? this.provider.getBaseAssetId()
|
7022
7092
|
);
|
@@ -7050,35 +7120,35 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7050
7120
|
* @returns A promise that resolves to the transaction response.
|
7051
7121
|
*/
|
7052
7122
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
7053
|
-
|
7054
|
-
|
7055
|
-
|
7056
|
-
"Transfer amount must be a positive number."
|
7057
|
-
);
|
7058
|
-
}
|
7059
|
-
const contractAddress = import_address5.Address.fromAddressOrString(contractId);
|
7060
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
7061
|
-
const { script, scriptData } = await assembleTransferToContractScript({
|
7062
|
-
hexlifiedContractId: contractAddress.toB256(),
|
7063
|
-
amountToTransfer: (0, import_math22.bn)(amount),
|
7064
|
-
assetId: assetIdToTransfer
|
7065
|
-
});
|
7123
|
+
return this.batchTransferToContracts([{ amount, assetId, contractId }], txParams);
|
7124
|
+
}
|
7125
|
+
async batchTransferToContracts(contractTransferParams, txParams = {}) {
|
7066
7126
|
let request = new ScriptTransactionRequest({
|
7067
|
-
...txParams
|
7068
|
-
script,
|
7069
|
-
scriptData
|
7070
|
-
});
|
7071
|
-
request.addContractInputAndOutput(contractAddress);
|
7072
|
-
const txCost = await this.getTransactionCost(request, {
|
7073
|
-
quantities: [{ amount: (0, import_math22.bn)(amount), assetId: String(assetIdToTransfer) }]
|
7127
|
+
...txParams
|
7074
7128
|
});
|
7075
|
-
|
7076
|
-
|
7077
|
-
|
7078
|
-
|
7079
|
-
|
7129
|
+
const quantities = [];
|
7130
|
+
const transferParams = contractTransferParams.map((transferParam) => {
|
7131
|
+
const amount = (0, import_math21.bn)(transferParam.amount);
|
7132
|
+
const contractAddress = import_address6.Address.fromAddressOrString(transferParam.contractId);
|
7133
|
+
const assetId = transferParam.assetId ? (0, import_utils37.hexlify)(transferParam.assetId) : this.provider.getBaseAssetId();
|
7134
|
+
if (amount.lte(0)) {
|
7135
|
+
throw new import_errors21.FuelError(
|
7136
|
+
import_errors21.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
7137
|
+
"Transfer amount must be a positive number."
|
7138
|
+
);
|
7139
|
+
}
|
7140
|
+
request.addContractInputAndOutput(contractAddress);
|
7141
|
+
quantities.push({ amount, assetId });
|
7142
|
+
return {
|
7143
|
+
amount,
|
7144
|
+
contractId: contractAddress.toB256(),
|
7145
|
+
assetId
|
7146
|
+
};
|
7080
7147
|
});
|
7081
|
-
await
|
7148
|
+
const { script, scriptData } = await assembleTransferToContractScript(transferParams);
|
7149
|
+
request.script = script;
|
7150
|
+
request.scriptData = scriptData;
|
7151
|
+
request = await this.estimateAndFundTransaction(request, txParams, { quantities });
|
7082
7152
|
return this.sendTransaction(request);
|
7083
7153
|
}
|
7084
7154
|
/**
|
@@ -7090,12 +7160,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7090
7160
|
* @returns A promise that resolves to the transaction response.
|
7091
7161
|
*/
|
7092
7162
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
7093
|
-
const recipientAddress =
|
7163
|
+
const recipientAddress = import_address6.Address.fromAddressOrString(recipient);
|
7094
7164
|
const recipientDataArray = (0, import_utils37.arrayify)(
|
7095
7165
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
7096
7166
|
);
|
7097
7167
|
const amountDataArray = (0, import_utils37.arrayify)(
|
7098
|
-
"0x".concat((0,
|
7168
|
+
"0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
7099
7169
|
);
|
7100
7170
|
const script = new Uint8Array([
|
7101
7171
|
...(0, import_utils37.arrayify)(withdrawScript.bytes),
|
@@ -7105,7 +7175,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7105
7175
|
const params = { script, ...txParams };
|
7106
7176
|
const baseAssetId = this.provider.getBaseAssetId();
|
7107
7177
|
let request = new ScriptTransactionRequest(params);
|
7108
|
-
const quantities = [{ amount: (0,
|
7178
|
+
const quantities = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
|
7109
7179
|
const txCost = await this.getTransactionCost(request, { quantities });
|
7110
7180
|
request = this.validateGasLimitAndMaxFee({
|
7111
7181
|
transactionRequest: request,
|
@@ -7131,7 +7201,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7131
7201
|
const baseAssetId = this.provider.getBaseAssetId();
|
7132
7202
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
7133
7203
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
7134
|
-
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0,
|
7204
|
+
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
|
7135
7205
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
7136
7206
|
if (input.type === import_transactions24.InputType.Coin) {
|
7137
7207
|
return input.assetId === assetId;
|
@@ -7178,7 +7248,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7178
7248
|
*/
|
7179
7249
|
async signMessage(message) {
|
7180
7250
|
if (!this._connector) {
|
7181
|
-
throw new
|
7251
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7182
7252
|
}
|
7183
7253
|
return this._connector.signMessage(this.address.toString(), message);
|
7184
7254
|
}
|
@@ -7190,8 +7260,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7190
7260
|
*/
|
7191
7261
|
async signTransaction(transactionRequestLike) {
|
7192
7262
|
if (!this._connector) {
|
7193
|
-
throw new
|
7194
|
-
|
7263
|
+
throw new import_errors21.FuelError(
|
7264
|
+
import_errors21.ErrorCode.MISSING_CONNECTOR,
|
7195
7265
|
"A connector is required to sign transactions."
|
7196
7266
|
);
|
7197
7267
|
}
|
@@ -7242,24 +7312,24 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7242
7312
|
return coins.map((coin) => ({
|
7243
7313
|
id: (0, import_utils37.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
|
7244
7314
|
owner: this.address,
|
7245
|
-
blockCreated: (0,
|
7246
|
-
txCreatedIdx: (0,
|
7315
|
+
blockCreated: (0, import_math21.bn)(1),
|
7316
|
+
txCreatedIdx: (0, import_math21.bn)(1),
|
7247
7317
|
...coin
|
7248
7318
|
}));
|
7249
7319
|
}
|
7250
7320
|
/** @hidden * */
|
7251
7321
|
validateTransferAmount(amount) {
|
7252
|
-
if ((0,
|
7253
|
-
throw new
|
7254
|
-
|
7322
|
+
if ((0, import_math21.bn)(amount).lte(0)) {
|
7323
|
+
throw new import_errors21.FuelError(
|
7324
|
+
import_errors21.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
7255
7325
|
"Transfer amount must be a positive number."
|
7256
7326
|
);
|
7257
7327
|
}
|
7258
7328
|
}
|
7259
7329
|
/** @hidden * */
|
7260
|
-
async estimateAndFundTransaction(transactionRequest, txParams) {
|
7330
|
+
async estimateAndFundTransaction(transactionRequest, txParams, costParams) {
|
7261
7331
|
let request = transactionRequest;
|
7262
|
-
const txCost = await this.getTransactionCost(request);
|
7332
|
+
const txCost = await this.getTransactionCost(request, costParams);
|
7263
7333
|
request = this.validateGasLimitAndMaxFee({
|
7264
7334
|
transactionRequest: request,
|
7265
7335
|
gasUsed: txCost.gasUsed,
|
@@ -7280,16 +7350,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7280
7350
|
if (!(0, import_utils37.isDefined)(setGasLimit)) {
|
7281
7351
|
request.gasLimit = gasUsed;
|
7282
7352
|
} else if (gasUsed.gt(setGasLimit)) {
|
7283
|
-
throw new
|
7284
|
-
|
7353
|
+
throw new import_errors21.FuelError(
|
7354
|
+
import_errors21.ErrorCode.GAS_LIMIT_TOO_LOW,
|
7285
7355
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7286
7356
|
);
|
7287
7357
|
}
|
7288
7358
|
if (!(0, import_utils37.isDefined)(setMaxFee)) {
|
7289
7359
|
request.maxFee = maxFee;
|
7290
7360
|
} else if (maxFee.gt(setMaxFee)) {
|
7291
|
-
throw new
|
7292
|
-
|
7361
|
+
throw new import_errors21.FuelError(
|
7362
|
+
import_errors21.ErrorCode.MAX_FEE_TOO_LOW,
|
7293
7363
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
7294
7364
|
);
|
7295
7365
|
}
|
@@ -7298,9 +7368,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7298
7368
|
};
|
7299
7369
|
|
7300
7370
|
// src/wallet/keystore-wallet.ts
|
7301
|
-
var
|
7371
|
+
var import_address7 = require("@fuel-ts/address");
|
7302
7372
|
var import_crypto6 = require("@fuel-ts/crypto");
|
7303
|
-
var
|
7373
|
+
var import_errors22 = require("@fuel-ts/errors");
|
7304
7374
|
var import_utils38 = require("@fuel-ts/utils");
|
7305
7375
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7306
7376
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -7315,7 +7385,7 @@ var removeHexPrefix = (hexString) => {
|
|
7315
7385
|
};
|
7316
7386
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
7317
7387
|
const privateKeyBuffer = (0, import_crypto6.bufferFromString)(removeHexPrefix(privateKey), "hex");
|
7318
|
-
const ownerAddress =
|
7388
|
+
const ownerAddress = import_address7.Address.fromAddressOrString(address);
|
7319
7389
|
const salt = (0, import_crypto6.randomBytes)(DEFAULT_KEY_SIZE);
|
7320
7390
|
const key = (0, import_crypto6.scrypt)({
|
7321
7391
|
password: (0, import_crypto6.bufferFromString)(password),
|
@@ -7377,8 +7447,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7377
7447
|
const macHashUint8Array = (0, import_crypto6.keccak256)(data);
|
7378
7448
|
const macHash = (0, import_crypto6.stringFromBuffer)(macHashUint8Array, "hex");
|
7379
7449
|
if (mac !== macHash) {
|
7380
|
-
throw new
|
7381
|
-
|
7450
|
+
throw new import_errors22.FuelError(
|
7451
|
+
import_errors22.ErrorCode.INVALID_PASSWORD,
|
7382
7452
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
7383
7453
|
);
|
7384
7454
|
}
|
@@ -7508,14 +7578,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
7508
7578
|
|
7509
7579
|
// src/hdwallet/hdwallet.ts
|
7510
7580
|
var import_crypto8 = require("@fuel-ts/crypto");
|
7511
|
-
var
|
7581
|
+
var import_errors25 = require("@fuel-ts/errors");
|
7512
7582
|
var import_hasher7 = require("@fuel-ts/hasher");
|
7513
|
-
var
|
7583
|
+
var import_math22 = require("@fuel-ts/math");
|
7514
7584
|
var import_utils43 = require("@fuel-ts/utils");
|
7515
7585
|
|
7516
7586
|
// src/mnemonic/mnemonic.ts
|
7517
7587
|
var import_crypto7 = require("@fuel-ts/crypto");
|
7518
|
-
var
|
7588
|
+
var import_errors24 = require("@fuel-ts/errors");
|
7519
7589
|
var import_hasher6 = require("@fuel-ts/hasher");
|
7520
7590
|
var import_utils41 = require("@fuel-ts/utils");
|
7521
7591
|
|
@@ -9572,7 +9642,7 @@ var english = [
|
|
9572
9642
|
];
|
9573
9643
|
|
9574
9644
|
// src/mnemonic/utils.ts
|
9575
|
-
var
|
9645
|
+
var import_errors23 = require("@fuel-ts/errors");
|
9576
9646
|
var import_hasher5 = require("@fuel-ts/hasher");
|
9577
9647
|
var import_utils40 = require("@fuel-ts/utils");
|
9578
9648
|
function getLowerMask(bits) {
|
@@ -9621,8 +9691,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9621
9691
|
for (let i = 0; i < words.length; i += 1) {
|
9622
9692
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9623
9693
|
if (index === -1) {
|
9624
|
-
throw new
|
9625
|
-
|
9694
|
+
throw new import_errors23.FuelError(
|
9695
|
+
import_errors23.ErrorCode.INVALID_MNEMONIC,
|
9626
9696
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9627
9697
|
);
|
9628
9698
|
}
|
@@ -9638,8 +9708,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9638
9708
|
const checksumMask = getUpperMask(checksumBits);
|
9639
9709
|
const checksum = (0, import_utils40.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9640
9710
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9641
|
-
throw new
|
9642
|
-
|
9711
|
+
throw new import_errors23.FuelError(
|
9712
|
+
import_errors23.ErrorCode.INVALID_CHECKSUM,
|
9643
9713
|
"Checksum validation failed for the provided mnemonic."
|
9644
9714
|
);
|
9645
9715
|
}
|
@@ -9653,16 +9723,16 @@ var TestnetPRV = "0x04358394";
|
|
9653
9723
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9654
9724
|
function assertWordList(wordlist) {
|
9655
9725
|
if (wordlist.length !== 2048) {
|
9656
|
-
throw new
|
9657
|
-
|
9726
|
+
throw new import_errors24.FuelError(
|
9727
|
+
import_errors24.ErrorCode.INVALID_WORD_LIST,
|
9658
9728
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9659
9729
|
);
|
9660
9730
|
}
|
9661
9731
|
}
|
9662
9732
|
function assertEntropy(entropy) {
|
9663
9733
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9664
|
-
throw new
|
9665
|
-
|
9734
|
+
throw new import_errors24.FuelError(
|
9735
|
+
import_errors24.ErrorCode.INVALID_ENTROPY,
|
9666
9736
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9667
9737
|
);
|
9668
9738
|
}
|
@@ -9672,7 +9742,7 @@ function assertMnemonic(words) {
|
|
9672
9742
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9673
9743
|
", "
|
9674
9744
|
)}] words, but got ${words.length}.`;
|
9675
|
-
throw new
|
9745
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
9676
9746
|
}
|
9677
9747
|
}
|
9678
9748
|
var Mnemonic = class {
|
@@ -9790,8 +9860,8 @@ var Mnemonic = class {
|
|
9790
9860
|
static masterKeysFromSeed(seed) {
|
9791
9861
|
const seedArray = (0, import_utils41.arrayify)(seed);
|
9792
9862
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9793
|
-
throw new
|
9794
|
-
|
9863
|
+
throw new import_errors24.FuelError(
|
9864
|
+
import_errors24.ErrorCode.INVALID_SEED,
|
9795
9865
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9796
9866
|
);
|
9797
9867
|
}
|
@@ -9868,7 +9938,7 @@ function isValidExtendedKey(extendedKey) {
|
|
9868
9938
|
function parsePath(path2, depth = 0) {
|
9869
9939
|
const components = path2.split("/");
|
9870
9940
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9871
|
-
throw new
|
9941
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9872
9942
|
}
|
9873
9943
|
if (components[0] === "m") {
|
9874
9944
|
components.shift();
|
@@ -9897,8 +9967,8 @@ var HDWallet = class {
|
|
9897
9967
|
this.privateKey = (0, import_utils43.hexlify)(config.privateKey);
|
9898
9968
|
} else {
|
9899
9969
|
if (!config.publicKey) {
|
9900
|
-
throw new
|
9901
|
-
|
9970
|
+
throw new import_errors25.FuelError(
|
9971
|
+
import_errors25.ErrorCode.HD_WALLET_ERROR,
|
9902
9972
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9903
9973
|
);
|
9904
9974
|
}
|
@@ -9927,8 +9997,8 @@ var HDWallet = class {
|
|
9927
9997
|
const data = new Uint8Array(37);
|
9928
9998
|
if (index & HARDENED_INDEX) {
|
9929
9999
|
if (!privateKey) {
|
9930
|
-
throw new
|
9931
|
-
|
10000
|
+
throw new import_errors25.FuelError(
|
10001
|
+
import_errors25.ErrorCode.HD_WALLET_ERROR,
|
9932
10002
|
"Cannot derive a hardened index without a private Key."
|
9933
10003
|
);
|
9934
10004
|
}
|
@@ -9936,13 +10006,13 @@ var HDWallet = class {
|
|
9936
10006
|
} else {
|
9937
10007
|
data.set((0, import_utils43.arrayify)(this.publicKey));
|
9938
10008
|
}
|
9939
|
-
data.set((0,
|
10009
|
+
data.set((0, import_math22.toBytes)(index, 4), 33);
|
9940
10010
|
const bytes = (0, import_utils43.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
|
9941
10011
|
const IL = bytes.slice(0, 32);
|
9942
10012
|
const IR = bytes.slice(32);
|
9943
10013
|
if (privateKey) {
|
9944
10014
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
9945
|
-
const ki = (0,
|
10015
|
+
const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
9946
10016
|
return new HDWallet({
|
9947
10017
|
privateKey: ki,
|
9948
10018
|
chainCode: IR,
|
@@ -9980,15 +10050,15 @@ var HDWallet = class {
|
|
9980
10050
|
*/
|
9981
10051
|
toExtendedKey(isPublic = false, testnet = false) {
|
9982
10052
|
if (this.depth >= 256) {
|
9983
|
-
throw new
|
9984
|
-
|
10053
|
+
throw new import_errors25.FuelError(
|
10054
|
+
import_errors25.ErrorCode.HD_WALLET_ERROR,
|
9985
10055
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9986
10056
|
);
|
9987
10057
|
}
|
9988
10058
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
9989
10059
|
const depth = (0, import_utils43.hexlify)(Uint8Array.from([this.depth]));
|
9990
10060
|
const parentFingerprint = this.parentFingerprint;
|
9991
|
-
const index = (0,
|
10061
|
+
const index = (0, import_math22.toHex)(this.index, 4);
|
9992
10062
|
const chainCode = this.chainCode;
|
9993
10063
|
const key = this.privateKey != null && !isPublic ? (0, import_utils43.concat)(["0x00", this.privateKey]) : this.publicKey;
|
9994
10064
|
const extendedKey = (0, import_utils43.arrayify)((0, import_utils43.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
@@ -10008,14 +10078,14 @@ var HDWallet = class {
|
|
10008
10078
|
});
|
10009
10079
|
}
|
10010
10080
|
static fromExtendedKey(extendedKey) {
|
10011
|
-
const decoded = (0, import_utils43.hexlify)((0,
|
10081
|
+
const decoded = (0, import_utils43.hexlify)((0, import_math22.toBytes)((0, import_utils43.decodeBase58)(extendedKey)));
|
10012
10082
|
const bytes = (0, import_utils43.arrayify)(decoded);
|
10013
10083
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10014
10084
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10015
|
-
throw new
|
10085
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
10016
10086
|
}
|
10017
10087
|
if (!validChecksum) {
|
10018
|
-
throw new
|
10088
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10019
10089
|
}
|
10020
10090
|
const depth = bytes[4];
|
10021
10091
|
const parentFingerprint = (0, import_utils43.hexlify)(bytes.slice(5, 9));
|
@@ -10023,14 +10093,14 @@ var HDWallet = class {
|
|
10023
10093
|
const chainCode = (0, import_utils43.hexlify)(bytes.slice(13, 45));
|
10024
10094
|
const key = bytes.slice(45, 78);
|
10025
10095
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10026
|
-
throw new
|
10027
|
-
|
10096
|
+
throw new import_errors25.FuelError(
|
10097
|
+
import_errors25.ErrorCode.HD_WALLET_ERROR,
|
10028
10098
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
10029
10099
|
);
|
10030
10100
|
}
|
10031
10101
|
if (isPublicExtendedKey(bytes)) {
|
10032
10102
|
if (key[0] !== 3) {
|
10033
|
-
throw new
|
10103
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
10034
10104
|
}
|
10035
10105
|
return new HDWallet({
|
10036
10106
|
publicKey: key,
|
@@ -10041,7 +10111,7 @@ var HDWallet = class {
|
|
10041
10111
|
});
|
10042
10112
|
}
|
10043
10113
|
if (key[0] !== 0) {
|
10044
|
-
throw new
|
10114
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
10045
10115
|
}
|
10046
10116
|
return new HDWallet({
|
10047
10117
|
privateKey: key.slice(1),
|
@@ -10285,26 +10355,26 @@ var WalletsConfig = class {
|
|
10285
10355
|
amountPerCoin
|
10286
10356
|
}) {
|
10287
10357
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
10288
|
-
throw new
|
10289
|
-
|
10358
|
+
throw new import_errors26.FuelError(
|
10359
|
+
import_errors26.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10290
10360
|
"Number of wallets must be greater than zero."
|
10291
10361
|
);
|
10292
10362
|
}
|
10293
10363
|
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
10294
|
-
throw new
|
10295
|
-
|
10364
|
+
throw new import_errors26.FuelError(
|
10365
|
+
import_errors26.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10296
10366
|
"Number of assets per wallet must be greater than zero."
|
10297
10367
|
);
|
10298
10368
|
}
|
10299
10369
|
if (coinsPerAsset <= 0) {
|
10300
|
-
throw new
|
10301
|
-
|
10370
|
+
throw new import_errors26.FuelError(
|
10371
|
+
import_errors26.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10302
10372
|
"Number of coins per asset must be greater than zero."
|
10303
10373
|
);
|
10304
10374
|
}
|
10305
10375
|
if (amountPerCoin < 0) {
|
10306
|
-
throw new
|
10307
|
-
|
10376
|
+
throw new import_errors26.FuelError(
|
10377
|
+
import_errors26.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10308
10378
|
"Amount per coin must be greater than or equal to zero."
|
10309
10379
|
);
|
10310
10380
|
}
|
@@ -10375,9 +10445,9 @@ async function setupTestProviderAndWallets({
|
|
10375
10445
|
}
|
10376
10446
|
|
10377
10447
|
// src/test-utils/test-message.ts
|
10378
|
-
var
|
10448
|
+
var import_address8 = require("@fuel-ts/address");
|
10379
10449
|
var import_crypto10 = require("@fuel-ts/crypto");
|
10380
|
-
var
|
10450
|
+
var import_math23 = require("@fuel-ts/math");
|
10381
10451
|
var import_utils46 = require("@fuel-ts/utils");
|
10382
10452
|
var TestMessage = class {
|
10383
10453
|
sender;
|
@@ -10393,8 +10463,8 @@ var TestMessage = class {
|
|
10393
10463
|
* It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
|
10394
10464
|
*/
|
10395
10465
|
constructor({
|
10396
|
-
sender =
|
10397
|
-
recipient =
|
10466
|
+
sender = import_address8.Address.fromRandom(),
|
10467
|
+
recipient = import_address8.Address.fromRandom(),
|
10398
10468
|
nonce = (0, import_utils46.hexlify)((0, import_crypto10.randomBytes)(32)),
|
10399
10469
|
amount = 1e6,
|
10400
10470
|
data = "",
|
@@ -10414,7 +10484,7 @@ var TestMessage = class {
|
|
10414
10484
|
sender: this.sender.toB256(),
|
10415
10485
|
recipient: recipient?.toB256() ?? this.recipient.toB256(),
|
10416
10486
|
nonce: this.nonce,
|
10417
|
-
amount: (0,
|
10487
|
+
amount: (0, import_math23.bn)(this.amount).toNumber(),
|
10418
10488
|
data,
|
10419
10489
|
da_height: this.da_height
|
10420
10490
|
};
|