@fuel-ts/account 0.96.0 → 0.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account.d.ts +6 -0
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel.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 +639 -310
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +661 -331
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +666 -338
- 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 +108 -126
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +15 -11
- 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-summary/get-transaction-summary.d.ts +3 -2
- package/dist/providers/transaction-summary/get-transaction-summary.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.global.js +376 -248
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +339 -221
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +350 -232
- 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/package.json +17 -17
package/dist/test-utils.mjs
CHANGED
@@ -370,7 +370,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
370
370
|
|
371
371
|
// src/providers/provider.ts
|
372
372
|
import { Address as Address3 } from "@fuel-ts/address";
|
373
|
-
import { ErrorCode as
|
373
|
+
import { ErrorCode as ErrorCode15, FuelError as FuelError18 } from "@fuel-ts/errors";
|
374
374
|
import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
|
375
375
|
import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
376
376
|
import { arrayify as arrayify13, hexlify as hexlify17, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
@@ -423,9 +423,6 @@ var ReceiptFragmentDoc = gql`
|
|
423
423
|
var SuccessStatusFragmentDoc = gql`
|
424
424
|
fragment SuccessStatusFragment on SuccessStatus {
|
425
425
|
type: __typename
|
426
|
-
block {
|
427
|
-
id
|
428
|
-
}
|
429
426
|
time
|
430
427
|
programState {
|
431
428
|
returnType
|
@@ -438,6 +435,14 @@ var SuccessStatusFragmentDoc = gql`
|
|
438
435
|
totalFee
|
439
436
|
}
|
440
437
|
${ReceiptFragmentDoc}`;
|
438
|
+
var SuccessStatusWithBlockIdFragmentDoc = gql`
|
439
|
+
fragment SuccessStatusWithBlockIdFragment on SuccessStatus {
|
440
|
+
...SuccessStatusFragment
|
441
|
+
block {
|
442
|
+
id
|
443
|
+
}
|
444
|
+
}
|
445
|
+
${SuccessStatusFragmentDoc}`;
|
441
446
|
var MalleableTransactionFieldsFragmentDoc = gql`
|
442
447
|
fragment malleableTransactionFieldsFragment on Transaction {
|
443
448
|
receiptsRoot
|
@@ -482,9 +487,6 @@ var MalleableTransactionFieldsFragmentDoc = gql`
|
|
482
487
|
var FailureStatusFragmentDoc = gql`
|
483
488
|
fragment FailureStatusFragment on FailureStatus {
|
484
489
|
type: __typename
|
485
|
-
block {
|
486
|
-
id
|
487
|
-
}
|
488
490
|
totalGas
|
489
491
|
totalFee
|
490
492
|
time
|
@@ -494,6 +496,14 @@ var FailureStatusFragmentDoc = gql`
|
|
494
496
|
}
|
495
497
|
}
|
496
498
|
${ReceiptFragmentDoc}`;
|
499
|
+
var FailureStatusWithBlockIdFragmentDoc = gql`
|
500
|
+
fragment FailureStatusWithBlockIdFragment on FailureStatus {
|
501
|
+
...FailureStatusFragment
|
502
|
+
block {
|
503
|
+
id
|
504
|
+
}
|
505
|
+
}
|
506
|
+
${FailureStatusFragmentDoc}`;
|
497
507
|
var SqueezedOutStatusFragmentDoc = gql`
|
498
508
|
fragment SqueezedOutStatusFragment on SqueezedOutStatus {
|
499
509
|
type: __typename
|
@@ -506,13 +516,13 @@ var TransactionStatusSubscriptionFragmentDoc = gql`
|
|
506
516
|
...SubmittedStatusFragment
|
507
517
|
}
|
508
518
|
... on SuccessStatus {
|
509
|
-
...
|
519
|
+
...SuccessStatusWithBlockIdFragment
|
510
520
|
transaction {
|
511
521
|
...malleableTransactionFieldsFragment
|
512
522
|
}
|
513
523
|
}
|
514
524
|
... on FailureStatus {
|
515
|
-
...
|
525
|
+
...FailureStatusWithBlockIdFragment
|
516
526
|
transaction {
|
517
527
|
...malleableTransactionFieldsFragment
|
518
528
|
}
|
@@ -522,9 +532,9 @@ var TransactionStatusSubscriptionFragmentDoc = gql`
|
|
522
532
|
}
|
523
533
|
}
|
524
534
|
${SubmittedStatusFragmentDoc}
|
525
|
-
${
|
535
|
+
${SuccessStatusWithBlockIdFragmentDoc}
|
526
536
|
${MalleableTransactionFieldsFragmentDoc}
|
527
|
-
${
|
537
|
+
${FailureStatusWithBlockIdFragmentDoc}
|
528
538
|
${SqueezedOutStatusFragmentDoc}`;
|
529
539
|
var TransactionStatusFragmentDoc = gql`
|
530
540
|
fragment transactionStatusFragment on TransactionStatus {
|
@@ -554,6 +564,12 @@ var TransactionFragmentDoc = gql`
|
|
554
564
|
}
|
555
565
|
}
|
556
566
|
${TransactionStatusFragmentDoc}`;
|
567
|
+
var TransactionRawPayloadFragmentDoc = gql`
|
568
|
+
fragment transactionRawPayloadFragment on Transaction {
|
569
|
+
id
|
570
|
+
rawPayload
|
571
|
+
}
|
572
|
+
`;
|
557
573
|
var InputEstimatePredicatesFragmentDoc = gql`
|
558
574
|
fragment inputEstimatePredicatesFragment on Input {
|
559
575
|
... on InputCoin {
|
@@ -641,7 +657,6 @@ var CoinFragmentDoc = gql`
|
|
641
657
|
fragment coinFragment on Coin {
|
642
658
|
type: __typename
|
643
659
|
utxoId
|
644
|
-
owner
|
645
660
|
amount
|
646
661
|
assetId
|
647
662
|
blockCreated
|
@@ -665,10 +680,15 @@ var MessageFragmentDoc = gql`
|
|
665
680
|
sender
|
666
681
|
recipient
|
667
682
|
data
|
668
|
-
nonce
|
669
683
|
daHeight
|
670
684
|
}
|
671
685
|
`;
|
686
|
+
var GetMessageFragmentDoc = gql`
|
687
|
+
fragment getMessageFragment on Message {
|
688
|
+
...messageFragment
|
689
|
+
nonce
|
690
|
+
}
|
691
|
+
${MessageFragmentDoc}`;
|
672
692
|
var MessageProofFragmentDoc = gql`
|
673
693
|
fragment messageProofFragment on MessageProof {
|
674
694
|
messageProof {
|
@@ -713,7 +733,6 @@ var MessageProofFragmentDoc = gql`
|
|
713
733
|
}
|
714
734
|
sender
|
715
735
|
recipient
|
716
|
-
nonce
|
717
736
|
amount
|
718
737
|
data
|
719
738
|
}
|
@@ -862,12 +881,6 @@ var RelayedTransactionStatusFragmentDoc = gql`
|
|
862
881
|
}
|
863
882
|
}
|
864
883
|
`;
|
865
|
-
var TransactionRawPayloadFragmentDoc = gql`
|
866
|
-
fragment transactionRawPayload on Transaction {
|
867
|
-
id
|
868
|
-
rawPayload
|
869
|
-
}
|
870
|
-
`;
|
871
884
|
var GetVersionDocument = gql`
|
872
885
|
query getVersion {
|
873
886
|
nodeInfo {
|
@@ -910,16 +923,34 @@ var GetTransactionDocument = gql`
|
|
910
923
|
var GetTransactionWithReceiptsDocument = gql`
|
911
924
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
912
925
|
transaction(id: $transactionId) {
|
913
|
-
|
926
|
+
id
|
927
|
+
rawPayload
|
928
|
+
status {
|
929
|
+
... on SubmittedStatus {
|
930
|
+
...SubmittedStatusFragment
|
931
|
+
}
|
932
|
+
... on SuccessStatus {
|
933
|
+
...SuccessStatusWithBlockIdFragment
|
934
|
+
}
|
935
|
+
... on FailureStatus {
|
936
|
+
...FailureStatusWithBlockIdFragment
|
937
|
+
}
|
938
|
+
... on SqueezedOutStatus {
|
939
|
+
...SqueezedOutStatusFragment
|
940
|
+
}
|
941
|
+
}
|
914
942
|
}
|
915
943
|
}
|
916
|
-
${
|
944
|
+
${SubmittedStatusFragmentDoc}
|
945
|
+
${SuccessStatusWithBlockIdFragmentDoc}
|
946
|
+
${FailureStatusWithBlockIdFragmentDoc}
|
947
|
+
${SqueezedOutStatusFragmentDoc}`;
|
917
948
|
var GetTransactionsDocument = gql`
|
918
949
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
919
950
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
920
951
|
edges {
|
921
952
|
node {
|
922
|
-
|
953
|
+
rawPayload
|
923
954
|
}
|
924
955
|
}
|
925
956
|
pageInfo {
|
@@ -927,8 +958,7 @@ var GetTransactionsDocument = gql`
|
|
927
958
|
}
|
928
959
|
}
|
929
960
|
}
|
930
|
-
${
|
931
|
-
${PageInfoFragmentDoc}`;
|
961
|
+
${PageInfoFragmentDoc}`;
|
932
962
|
var GetTransactionsByOwnerDocument = gql`
|
933
963
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
934
964
|
transactionsByOwner(
|
@@ -987,7 +1017,7 @@ var GetBlockWithTransactionsDocument = gql`
|
|
987
1017
|
block(id: $blockId, height: $blockHeight) {
|
988
1018
|
...blockFragment
|
989
1019
|
transactions {
|
990
|
-
...
|
1020
|
+
...transactionRawPayloadFragment
|
991
1021
|
}
|
992
1022
|
}
|
993
1023
|
}
|
@@ -1012,6 +1042,7 @@ var GetCoinDocument = gql`
|
|
1012
1042
|
query getCoin($coinId: UtxoId!) {
|
1013
1043
|
coin(utxoId: $coinId) {
|
1014
1044
|
...coinFragment
|
1045
|
+
owner
|
1015
1046
|
}
|
1016
1047
|
}
|
1017
1048
|
${CoinFragmentDoc}`;
|
@@ -1120,13 +1151,13 @@ var GetMessagesDocument = gql`
|
|
1120
1151
|
}
|
1121
1152
|
edges {
|
1122
1153
|
node {
|
1123
|
-
...
|
1154
|
+
...getMessageFragment
|
1124
1155
|
}
|
1125
1156
|
}
|
1126
1157
|
}
|
1127
1158
|
}
|
1128
1159
|
${PageInfoFragmentDoc}
|
1129
|
-
${
|
1160
|
+
${GetMessageFragmentDoc}`;
|
1130
1161
|
var GetMessageProofDocument = gql`
|
1131
1162
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
1132
1163
|
messageProof(
|
@@ -1199,6 +1230,17 @@ var IsUserAccountDocument = gql`
|
|
1199
1230
|
}
|
1200
1231
|
}
|
1201
1232
|
`;
|
1233
|
+
var GetConsensusParametersVersionDocument = gql`
|
1234
|
+
query getConsensusParametersVersion {
|
1235
|
+
chain {
|
1236
|
+
latestBlock {
|
1237
|
+
header {
|
1238
|
+
consensusParametersVersion
|
1239
|
+
}
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
}
|
1243
|
+
`;
|
1202
1244
|
var SubmitAndAwaitDocument = gql`
|
1203
1245
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
1204
1246
|
submitAndAwait(tx: $encodedTransaction) {
|
@@ -1318,6 +1360,9 @@ function getSdk(requester) {
|
|
1318
1360
|
isUserAccount(variables, options) {
|
1319
1361
|
return requester(IsUserAccountDocument, variables, options);
|
1320
1362
|
},
|
1363
|
+
getConsensusParametersVersion(variables, options) {
|
1364
|
+
return requester(GetConsensusParametersVersionDocument, variables, options);
|
1365
|
+
},
|
1321
1366
|
submitAndAwait(variables, options) {
|
1322
1367
|
return requester(SubmitAndAwaitDocument, variables, options);
|
1323
1368
|
},
|
@@ -1650,9 +1695,11 @@ function assembleReceiptByType(receipt) {
|
|
1650
1695
|
const { receiptType } = receipt;
|
1651
1696
|
switch (receiptType) {
|
1652
1697
|
case "CALL" /* Call */: {
|
1698
|
+
const id = hexOrZero(receipt.id || receipt.contractId);
|
1653
1699
|
const callReceipt = {
|
1654
1700
|
type: ReceiptType.Call,
|
1655
|
-
|
1701
|
+
id,
|
1702
|
+
from: id,
|
1656
1703
|
to: hexOrZero(receipt?.to),
|
1657
1704
|
amount: bn4(receipt.amount),
|
1658
1705
|
assetId: hexOrZero(receipt.assetId),
|
@@ -1709,24 +1756,36 @@ function assembleReceiptByType(receipt) {
|
|
1709
1756
|
return revertReceipt;
|
1710
1757
|
}
|
1711
1758
|
case "LOG" /* Log */: {
|
1759
|
+
const ra = bn4(receipt.ra);
|
1760
|
+
const rb = bn4(receipt.rb);
|
1761
|
+
const rc = bn4(receipt.rc);
|
1762
|
+
const rd = bn4(receipt.rd);
|
1712
1763
|
const logReceipt = {
|
1713
1764
|
type: ReceiptType.Log,
|
1714
1765
|
id: hexOrZero(receipt.id || receipt.contractId),
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1766
|
+
ra,
|
1767
|
+
rb,
|
1768
|
+
rc,
|
1769
|
+
rd,
|
1770
|
+
val0: ra,
|
1771
|
+
val1: rb,
|
1772
|
+
val2: rc,
|
1773
|
+
val3: rd,
|
1719
1774
|
pc: bn4(receipt.pc),
|
1720
1775
|
is: bn4(receipt.is)
|
1721
1776
|
};
|
1722
1777
|
return logReceipt;
|
1723
1778
|
}
|
1724
1779
|
case "LOG_DATA" /* LogData */: {
|
1780
|
+
const ra = bn4(receipt.ra);
|
1781
|
+
const rb = bn4(receipt.rb);
|
1725
1782
|
const logDataReceipt = {
|
1726
1783
|
type: ReceiptType.LogData,
|
1727
1784
|
id: hexOrZero(receipt.id || receipt.contractId),
|
1728
|
-
|
1729
|
-
|
1785
|
+
ra,
|
1786
|
+
rb,
|
1787
|
+
val0: ra,
|
1788
|
+
val1: rb,
|
1730
1789
|
ptr: bn4(receipt.ptr),
|
1731
1790
|
len: bn4(receipt.len),
|
1732
1791
|
digest: hexOrZero(receipt.digest),
|
@@ -1737,9 +1796,11 @@ function assembleReceiptByType(receipt) {
|
|
1737
1796
|
return logDataReceipt;
|
1738
1797
|
}
|
1739
1798
|
case "TRANSFER" /* Transfer */: {
|
1799
|
+
const id = hexOrZero(receipt.id || receipt.contractId);
|
1740
1800
|
const transferReceipt = {
|
1741
1801
|
type: ReceiptType.Transfer,
|
1742
|
-
|
1802
|
+
id,
|
1803
|
+
from: id,
|
1743
1804
|
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1744
1805
|
amount: bn4(receipt.amount),
|
1745
1806
|
assetId: hexOrZero(receipt.assetId),
|
@@ -1749,9 +1810,11 @@ function assembleReceiptByType(receipt) {
|
|
1749
1810
|
return transferReceipt;
|
1750
1811
|
}
|
1751
1812
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1813
|
+
const id = hexOrZero(receipt.id || receipt.contractId);
|
1752
1814
|
const transferOutReceipt = {
|
1753
1815
|
type: ReceiptType.TransferOut,
|
1754
|
-
|
1816
|
+
id,
|
1817
|
+
from: id,
|
1755
1818
|
to: hexOrZero(receipt.toAddress || receipt.to),
|
1756
1819
|
amount: bn4(receipt.amount),
|
1757
1820
|
assetId: hexOrZero(receipt.assetId),
|
@@ -2736,7 +2799,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
|
|
2736
2799
|
type = TransactionType.Blob;
|
2737
2800
|
/** Blob ID */
|
2738
2801
|
blobId;
|
2739
|
-
/** Witness index of
|
2802
|
+
/** Witness index of the bytecode to create */
|
2740
2803
|
witnessIndex;
|
2741
2804
|
/**
|
2742
2805
|
* Creates an instance `BlobTransactionRequest`.
|
@@ -4070,14 +4133,14 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
4070
4133
|
switch (gqlTransactionStatus.type) {
|
4071
4134
|
case "SuccessStatus":
|
4072
4135
|
time = gqlTransactionStatus.time;
|
4073
|
-
blockId = gqlTransactionStatus.block
|
4136
|
+
blockId = gqlTransactionStatus.block?.id;
|
4074
4137
|
isStatusSuccess = true;
|
4075
4138
|
totalFee = bn14(gqlTransactionStatus.totalFee);
|
4076
4139
|
totalGas = bn14(gqlTransactionStatus.totalGas);
|
4077
4140
|
break;
|
4078
4141
|
case "FailureStatus":
|
4079
4142
|
time = gqlTransactionStatus.time;
|
4080
|
-
blockId = gqlTransactionStatus.block
|
4143
|
+
blockId = gqlTransactionStatus.block?.id;
|
4081
4144
|
isStatusFailure = true;
|
4082
4145
|
totalFee = bn14(gqlTransactionStatus.totalFee);
|
4083
4146
|
totalGas = bn14(gqlTransactionStatus.totalGas);
|
@@ -4512,17 +4575,60 @@ var handleGqlErrorMessage = (errorMessage, rawError) => {
|
|
4512
4575
|
{},
|
4513
4576
|
rawError
|
4514
4577
|
);
|
4578
|
+
case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
|
4579
|
+
throw new FuelError16(
|
4580
|
+
ErrorCode13.MAX_COINS_REACHED,
|
4581
|
+
"The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
|
4582
|
+
{},
|
4583
|
+
rawError
|
4584
|
+
);
|
4515
4585
|
default:
|
4516
4586
|
throw new FuelError16(ErrorCode13.INVALID_REQUEST, errorMessage);
|
4517
4587
|
}
|
4518
4588
|
};
|
4519
4589
|
|
4590
|
+
// src/providers/utils/validate-pagination-args.ts
|
4591
|
+
import { FuelError as FuelError17, ErrorCode as ErrorCode14 } from "@fuel-ts/errors";
|
4592
|
+
var validatePaginationArgs = (params) => {
|
4593
|
+
const { paginationLimit, inputArgs = {} } = params;
|
4594
|
+
const { first, last, after, before } = inputArgs;
|
4595
|
+
if (after && before) {
|
4596
|
+
throw new FuelError17(
|
4597
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
4598
|
+
'Pagination arguments "after" and "before" cannot be used together'
|
4599
|
+
);
|
4600
|
+
}
|
4601
|
+
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
4602
|
+
throw new FuelError17(
|
4603
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
4604
|
+
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
4605
|
+
);
|
4606
|
+
}
|
4607
|
+
if (first && before) {
|
4608
|
+
throw new FuelError17(
|
4609
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
4610
|
+
'The use of pagination argument "first" with "before" is not supported'
|
4611
|
+
);
|
4612
|
+
}
|
4613
|
+
if (last && after) {
|
4614
|
+
throw new FuelError17(
|
4615
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
4616
|
+
'The use of pagination argument "last" with "after" is not supported'
|
4617
|
+
);
|
4618
|
+
}
|
4619
|
+
if (!first && !last) {
|
4620
|
+
inputArgs.first = paginationLimit;
|
4621
|
+
}
|
4622
|
+
return inputArgs;
|
4623
|
+
};
|
4624
|
+
|
4520
4625
|
// src/providers/provider.ts
|
4521
4626
|
var MAX_RETRIES = 10;
|
4522
4627
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
4523
4628
|
var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
|
4524
4629
|
var BLOCKS_PAGE_SIZE_LIMIT = 5;
|
4525
4630
|
var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
|
4631
|
+
var GAS_USED_MODIFIER = 1.2;
|
4526
4632
|
var processGqlChain = (chain) => {
|
4527
4633
|
const { name, daHeight, consensusParameters } = chain;
|
4528
4634
|
const {
|
@@ -4598,6 +4704,8 @@ var _Provider = class {
|
|
4598
4704
|
__publicField(this, "url");
|
4599
4705
|
/** @hidden */
|
4600
4706
|
__publicField(this, "urlWithoutAuth");
|
4707
|
+
/** @hidden */
|
4708
|
+
__publicField(this, "consensusParametersTimestamp");
|
4601
4709
|
__publicField(this, "options", {
|
4602
4710
|
timeout: void 0,
|
4603
4711
|
resourceCacheTTL: void 0,
|
@@ -4658,7 +4766,7 @@ var _Provider = class {
|
|
4658
4766
|
try {
|
4659
4767
|
parsedUrl = new URL(url);
|
4660
4768
|
} catch (error) {
|
4661
|
-
throw new
|
4769
|
+
throw new FuelError18(FuelError18.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4662
4770
|
}
|
4663
4771
|
const username = parsedUrl.username;
|
4664
4772
|
const password = parsedUrl.password;
|
@@ -4693,8 +4801,8 @@ var _Provider = class {
|
|
4693
4801
|
getChain() {
|
4694
4802
|
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
4695
4803
|
if (!chain) {
|
4696
|
-
throw new
|
4697
|
-
|
4804
|
+
throw new FuelError18(
|
4805
|
+
ErrorCode15.CHAIN_INFO_CACHE_EMPTY,
|
4698
4806
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4699
4807
|
);
|
4700
4808
|
}
|
@@ -4708,8 +4816,8 @@ var _Provider = class {
|
|
4708
4816
|
getNode() {
|
4709
4817
|
const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4710
4818
|
if (!node) {
|
4711
|
-
throw new
|
4712
|
-
|
4819
|
+
throw new FuelError18(
|
4820
|
+
ErrorCode15.NODE_INFO_CACHE_EMPTY,
|
4713
4821
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4714
4822
|
);
|
4715
4823
|
}
|
@@ -4750,16 +4858,19 @@ var _Provider = class {
|
|
4750
4858
|
}
|
4751
4859
|
/**
|
4752
4860
|
* Return the chain and node information.
|
4753
|
-
*
|
4861
|
+
* @param ignoreCache - If true, ignores the cache and re-fetch configs.
|
4754
4862
|
* @returns A promise that resolves to the Chain and NodeInfo.
|
4755
4863
|
*/
|
4756
|
-
async fetchChainAndNodeInfo() {
|
4864
|
+
async fetchChainAndNodeInfo(ignoreCache = false) {
|
4757
4865
|
let nodeInfo;
|
4758
4866
|
let chain;
|
4759
4867
|
try {
|
4868
|
+
if (ignoreCache) {
|
4869
|
+
throw new Error(`Jumps to the catch block andre-fetch`);
|
4870
|
+
}
|
4760
4871
|
nodeInfo = this.getNode();
|
4761
4872
|
chain = this.getChain();
|
4762
|
-
} catch (
|
4873
|
+
} catch (_err) {
|
4763
4874
|
const data = await this.operations.getChainAndNodeInfo();
|
4764
4875
|
nodeInfo = {
|
4765
4876
|
maxDepth: bn17(data.nodeInfo.maxDepth),
|
@@ -4772,6 +4883,7 @@ var _Provider = class {
|
|
4772
4883
|
chain = processGqlChain(data.chain);
|
4773
4884
|
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
4774
4885
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
4886
|
+
this.consensusParametersTimestamp = Date.now();
|
4775
4887
|
}
|
4776
4888
|
return {
|
4777
4889
|
chain,
|
@@ -4921,18 +5033,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4921
5033
|
} = this.getChain();
|
4922
5034
|
return baseAssetId;
|
4923
5035
|
}
|
4924
|
-
|
4925
|
-
|
5036
|
+
/**
|
5037
|
+
* @hidden
|
5038
|
+
*/
|
5039
|
+
validateTransaction(tx) {
|
5040
|
+
const {
|
5041
|
+
consensusParameters: {
|
5042
|
+
txParameters: { maxInputs, maxOutputs }
|
5043
|
+
}
|
5044
|
+
} = this.getChain();
|
4926
5045
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
4927
|
-
throw new
|
4928
|
-
|
4929
|
-
|
5046
|
+
throw new FuelError18(
|
5047
|
+
ErrorCode15.MAX_INPUTS_EXCEEDED,
|
5048
|
+
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
4930
5049
|
);
|
4931
5050
|
}
|
4932
5051
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
4933
|
-
throw new
|
4934
|
-
|
4935
|
-
|
5052
|
+
throw new FuelError18(
|
5053
|
+
ErrorCode15.MAX_OUTPUTS_EXCEEDED,
|
5054
|
+
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
4936
5055
|
);
|
4937
5056
|
}
|
4938
5057
|
}
|
@@ -4951,8 +5070,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4951
5070
|
if (estimateTxDependencies) {
|
4952
5071
|
await this.estimateTxDependencies(transactionRequest);
|
4953
5072
|
}
|
4954
|
-
|
4955
|
-
this.validateTransaction(transactionRequest, consensusParameters);
|
5073
|
+
this.validateTransaction(transactionRequest);
|
4956
5074
|
const encodedTransaction = hexlify17(transactionRequest.toTransactionBytes());
|
4957
5075
|
let abis;
|
4958
5076
|
if (isTransactionTypeScript(transactionRequest)) {
|
@@ -5040,6 +5158,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5040
5158
|
const missingContractIds = [];
|
5041
5159
|
let outputVariables = 0;
|
5042
5160
|
let dryRunStatus;
|
5161
|
+
this.validateTransaction(transactionRequest);
|
5043
5162
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
5044
5163
|
const {
|
5045
5164
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -5162,6 +5281,27 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5162
5281
|
});
|
5163
5282
|
return results;
|
5164
5283
|
}
|
5284
|
+
async autoRefetchConfigs() {
|
5285
|
+
const now = Date.now();
|
5286
|
+
const diff = now - (this.consensusParametersTimestamp ?? 0);
|
5287
|
+
if (diff < 6e4) {
|
5288
|
+
return;
|
5289
|
+
}
|
5290
|
+
const chainInfo = this.getChain();
|
5291
|
+
const {
|
5292
|
+
consensusParameters: { version: previous }
|
5293
|
+
} = chainInfo;
|
5294
|
+
const {
|
5295
|
+
chain: {
|
5296
|
+
latestBlock: {
|
5297
|
+
header: { consensusParametersVersion: current }
|
5298
|
+
}
|
5299
|
+
}
|
5300
|
+
} = await this.operations.getConsensusParametersVersion();
|
5301
|
+
if (previous !== current) {
|
5302
|
+
await this.fetchChainAndNodeInfo(true);
|
5303
|
+
}
|
5304
|
+
}
|
5165
5305
|
/**
|
5166
5306
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
5167
5307
|
* @param transactionRequest - The transaction request object.
|
@@ -5170,6 +5310,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5170
5310
|
async estimateTxGasAndFee(params) {
|
5171
5311
|
const { transactionRequest } = params;
|
5172
5312
|
let { gasPrice } = params;
|
5313
|
+
await this.autoRefetchConfigs();
|
5173
5314
|
const chainInfo = this.getChain();
|
5174
5315
|
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
5175
5316
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
@@ -5283,7 +5424,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5283
5424
|
if (dryRunStatus && "reason" in dryRunStatus) {
|
5284
5425
|
throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
|
5285
5426
|
}
|
5286
|
-
|
5427
|
+
const { maxGasPerTx } = this.getGasConfig();
|
5428
|
+
const pristineGasUsed = getGasUsedFromReceipts(receipts);
|
5429
|
+
gasUsed = bn17(pristineGasUsed.muln(GAS_USED_MODIFIER)).max(maxGasPerTx.sub(minGas));
|
5287
5430
|
txRequestClone.gasLimit = gasUsed;
|
5288
5431
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
5289
5432
|
transactionRequest: txRequestClone,
|
@@ -5320,7 +5463,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5320
5463
|
const {
|
5321
5464
|
coins: { edges, pageInfo }
|
5322
5465
|
} = await this.operations.getCoins({
|
5323
|
-
...
|
5466
|
+
...validatePaginationArgs({
|
5324
5467
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
5325
5468
|
inputArgs: paginationArgs
|
5326
5469
|
}),
|
@@ -5330,7 +5473,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5330
5473
|
id: node.utxoId,
|
5331
5474
|
assetId: node.assetId,
|
5332
5475
|
amount: bn17(node.amount),
|
5333
|
-
owner:
|
5476
|
+
owner: ownerAddress,
|
5334
5477
|
blockCreated: bn17(node.blockCreated),
|
5335
5478
|
txCreatedIdx: bn17(node.txCreatedIdx)
|
5336
5479
|
}));
|
@@ -5384,7 +5527,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5384
5527
|
id: coin.utxoId,
|
5385
5528
|
amount: bn17(coin.amount),
|
5386
5529
|
assetId: coin.assetId,
|
5387
|
-
owner:
|
5530
|
+
owner: ownerAddress,
|
5388
5531
|
blockCreated: bn17(coin.blockCreated),
|
5389
5532
|
txCreatedIdx: bn17(coin.txCreatedIdx)
|
5390
5533
|
};
|
@@ -5459,7 +5602,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5459
5602
|
const {
|
5460
5603
|
blocks: { edges, pageInfo }
|
5461
5604
|
} = await this.operations.getBlocks({
|
5462
|
-
...
|
5605
|
+
...validatePaginationArgs({
|
5463
5606
|
paginationLimit: BLOCKS_PAGE_SIZE_LIMIT,
|
5464
5607
|
inputArgs: params
|
5465
5608
|
})
|
@@ -5538,7 +5681,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5538
5681
|
0
|
5539
5682
|
)?.[0];
|
5540
5683
|
} catch (error) {
|
5541
|
-
if (error instanceof
|
5684
|
+
if (error instanceof FuelError18 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
|
5542
5685
|
console.warn("Unsupported transaction type encountered");
|
5543
5686
|
return null;
|
5544
5687
|
}
|
@@ -5554,7 +5697,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5554
5697
|
const {
|
5555
5698
|
transactions: { edges, pageInfo }
|
5556
5699
|
} = await this.operations.getTransactions({
|
5557
|
-
...
|
5700
|
+
...validatePaginationArgs({
|
5558
5701
|
inputArgs: paginationArgs,
|
5559
5702
|
paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
|
5560
5703
|
})
|
@@ -5564,7 +5707,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5564
5707
|
try {
|
5565
5708
|
return coder.decode(arrayify13(rawPayload), 0)[0];
|
5566
5709
|
} catch (error) {
|
5567
|
-
if (error instanceof
|
5710
|
+
if (error instanceof FuelError18 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
|
5568
5711
|
console.warn("Unsupported transaction type encountered");
|
5569
5712
|
return null;
|
5570
5713
|
}
|
@@ -5649,7 +5792,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5649
5792
|
const {
|
5650
5793
|
messages: { edges, pageInfo }
|
5651
5794
|
} = await this.operations.getMessages({
|
5652
|
-
...
|
5795
|
+
...validatePaginationArgs({
|
5653
5796
|
inputArgs: paginationArgs,
|
5654
5797
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
|
5655
5798
|
}),
|
@@ -5690,8 +5833,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5690
5833
|
nonce
|
5691
5834
|
};
|
5692
5835
|
if (commitBlockId && commitBlockHeight) {
|
5693
|
-
throw new
|
5694
|
-
|
5836
|
+
throw new FuelError18(
|
5837
|
+
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5695
5838
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5696
5839
|
);
|
5697
5840
|
}
|
@@ -5873,13 +6016,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5873
6016
|
messageId: InputMessageCoder2.getMessageId({
|
5874
6017
|
sender: rawMessage.sender,
|
5875
6018
|
recipient: rawMessage.recipient,
|
5876
|
-
nonce
|
6019
|
+
nonce,
|
5877
6020
|
amount: bn17(rawMessage.amount),
|
5878
6021
|
data: rawMessage.data
|
5879
6022
|
}),
|
5880
6023
|
sender: Address3.fromAddressOrString(rawMessage.sender),
|
5881
6024
|
recipient: Address3.fromAddressOrString(rawMessage.recipient),
|
5882
|
-
nonce
|
6025
|
+
nonce,
|
5883
6026
|
amount: bn17(rawMessage.amount),
|
5884
6027
|
data: InputMessageCoder2.decodeData(rawMessage.data),
|
5885
6028
|
daHeight: bn17(rawMessage.daHeight)
|
@@ -5901,41 +6044,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5901
6044
|
}
|
5902
6045
|
return relayedTransactionStatus;
|
5903
6046
|
}
|
5904
|
-
/**
|
5905
|
-
* @hidden
|
5906
|
-
*/
|
5907
|
-
validatePaginationArgs(params) {
|
5908
|
-
const { paginationLimit, inputArgs = {} } = params;
|
5909
|
-
const { first, last, after, before } = inputArgs;
|
5910
|
-
if (after && before) {
|
5911
|
-
throw new FuelError17(
|
5912
|
-
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5913
|
-
'Pagination arguments "after" and "before" cannot be used together'
|
5914
|
-
);
|
5915
|
-
}
|
5916
|
-
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5917
|
-
throw new FuelError17(
|
5918
|
-
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5919
|
-
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5920
|
-
);
|
5921
|
-
}
|
5922
|
-
if (first && before) {
|
5923
|
-
throw new FuelError17(
|
5924
|
-
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5925
|
-
'The use of pagination argument "first" with "before" is not supported'
|
5926
|
-
);
|
5927
|
-
}
|
5928
|
-
if (last && after) {
|
5929
|
-
throw new FuelError17(
|
5930
|
-
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5931
|
-
'The use of pagination argument "last" with "after" is not supported'
|
5932
|
-
);
|
5933
|
-
}
|
5934
|
-
if (!first && !last) {
|
5935
|
-
inputArgs.first = paginationLimit;
|
5936
|
-
}
|
5937
|
-
return inputArgs;
|
5938
|
-
}
|
5939
6047
|
/**
|
5940
6048
|
* @hidden
|
5941
6049
|
*/
|
@@ -5981,7 +6089,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5981
6089
|
__publicField(Provider, "nodeInfoCache", {});
|
5982
6090
|
|
5983
6091
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5984
|
-
import { ErrorCode as
|
6092
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5985
6093
|
import { bn as bn18 } from "@fuel-ts/math";
|
5986
6094
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
5987
6095
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
@@ -6615,7 +6723,7 @@ __publicField(TestAssetId, "B", new _TestAssetId(
|
|
6615
6723
|
|
6616
6724
|
// src/test-utils/wallet-config.ts
|
6617
6725
|
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
6618
|
-
import { FuelError as
|
6726
|
+
import { FuelError as FuelError25 } from "@fuel-ts/errors";
|
6619
6727
|
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify24 } from "@fuel-ts/utils";
|
6620
6728
|
|
6621
6729
|
// src/wallet/base-wallet-unlocked.ts
|
@@ -6624,9 +6732,9 @@ import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
|
6624
6732
|
|
6625
6733
|
// src/account.ts
|
6626
6734
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
6627
|
-
import { Address as
|
6735
|
+
import { Address as Address5 } from "@fuel-ts/address";
|
6628
6736
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
6629
|
-
import { ErrorCode as
|
6737
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
|
6630
6738
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
6631
6739
|
import { bn as bn19 } from "@fuel-ts/math";
|
6632
6740
|
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
@@ -6648,38 +6756,47 @@ var mergeQuantities = (...coinQuantities) => {
|
|
6648
6756
|
};
|
6649
6757
|
|
6650
6758
|
// src/utils/formatTransferToContractScriptData.ts
|
6651
|
-
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
6759
|
+
import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
|
6760
|
+
import { Address as Address4 } from "@fuel-ts/address";
|
6652
6761
|
import { BN as BN3 } from "@fuel-ts/math";
|
6653
|
-
import { arrayify as arrayify15 } from "@fuel-ts/utils";
|
6762
|
+
import { arrayify as arrayify15, concat as concat4 } from "@fuel-ts/utils";
|
6654
6763
|
import * as asm from "@fuels/vm-asm";
|
6655
|
-
var formatTransferToContractScriptData = (
|
6656
|
-
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
6764
|
+
var formatTransferToContractScriptData = (transferParams) => {
|
6657
6765
|
const numberCoder = new BigNumberCoder2("u64");
|
6658
|
-
|
6659
|
-
|
6660
|
-
|
6661
|
-
|
6662
|
-
|
6663
|
-
|
6664
|
-
|
6766
|
+
return transferParams.reduce((acc, transferParam) => {
|
6767
|
+
const { assetId, amount, contractId } = transferParam;
|
6768
|
+
const encoded = numberCoder.encode(new BN3(amount).toNumber());
|
6769
|
+
const scriptData = concat4([
|
6770
|
+
Address4.fromAddressOrString(contractId).toBytes(),
|
6771
|
+
encoded,
|
6772
|
+
arrayify15(assetId)
|
6773
|
+
]);
|
6774
|
+
return concat4([acc, scriptData]);
|
6775
|
+
}, new Uint8Array());
|
6665
6776
|
};
|
6666
|
-
var assembleTransferToContractScript = async (
|
6667
|
-
const scriptData = formatTransferToContractScriptData(
|
6777
|
+
var assembleTransferToContractScript = async (transferParams) => {
|
6778
|
+
const scriptData = formatTransferToContractScriptData(transferParams);
|
6668
6779
|
await asm.initWasm();
|
6669
|
-
|
6670
|
-
|
6671
|
-
|
6672
|
-
|
6673
|
-
|
6674
|
-
|
6675
|
-
|
6676
|
-
|
6677
|
-
|
6678
|
-
|
6679
|
-
|
6680
|
-
|
6681
|
-
|
6682
|
-
|
6780
|
+
let script = new Uint8Array();
|
6781
|
+
transferParams.forEach((_, i) => {
|
6782
|
+
const offset = (CONTRACT_ID_LEN + WORD_SIZE + ASSET_ID_LEN) * i;
|
6783
|
+
script = concat4([
|
6784
|
+
script,
|
6785
|
+
// Load ScriptData into register 0x10.
|
6786
|
+
asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
|
6787
|
+
// Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
|
6788
|
+
asm.addi(17, 16, offset).to_bytes(),
|
6789
|
+
// Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
|
6790
|
+
asm.addi(18, 17, CONTRACT_ID_LEN).to_bytes(),
|
6791
|
+
// Load word to the amount at 0x12 into register 0x13.
|
6792
|
+
asm.lw(19, 18, 0).to_bytes(),
|
6793
|
+
// Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
|
6794
|
+
asm.addi(20, 18, WORD_SIZE).to_bytes(),
|
6795
|
+
// Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
|
6796
|
+
asm.tr(17, 19, 20).to_bytes()
|
6797
|
+
]);
|
6798
|
+
});
|
6799
|
+
script = concat4([script, asm.ret(1).to_bytes()]);
|
6683
6800
|
return { script, scriptData };
|
6684
6801
|
};
|
6685
6802
|
|
@@ -6709,7 +6826,7 @@ var Account = class extends AbstractAccount {
|
|
6709
6826
|
super();
|
6710
6827
|
this._provider = provider;
|
6711
6828
|
this._connector = connector;
|
6712
|
-
this.address =
|
6829
|
+
this.address = Address5.fromDynamicInput(address);
|
6713
6830
|
}
|
6714
6831
|
/**
|
6715
6832
|
* The provider used to interact with the network.
|
@@ -6720,7 +6837,7 @@ var Account = class extends AbstractAccount {
|
|
6720
6837
|
*/
|
6721
6838
|
get provider() {
|
6722
6839
|
if (!this._provider) {
|
6723
|
-
throw new
|
6840
|
+
throw new FuelError20(ErrorCode17.MISSING_PROVIDER, "Provider not set");
|
6724
6841
|
}
|
6725
6842
|
return this._provider;
|
6726
6843
|
}
|
@@ -6871,11 +6988,12 @@ var Account = class extends AbstractAccount {
|
|
6871
6988
|
fundingAttempts += 1;
|
6872
6989
|
}
|
6873
6990
|
if (needsToBeFunded) {
|
6874
|
-
throw new
|
6875
|
-
|
6991
|
+
throw new FuelError20(
|
6992
|
+
ErrorCode17.NOT_ENOUGH_FUNDS,
|
6876
6993
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6877
6994
|
);
|
6878
6995
|
}
|
6996
|
+
this.provider.validateTransaction(request);
|
6879
6997
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6880
6998
|
const requestToReestimate = clone9(request);
|
6881
6999
|
if (addedSignatures) {
|
@@ -6942,7 +7060,7 @@ var Account = class extends AbstractAccount {
|
|
6942
7060
|
const { destination, amount, assetId } = transferParams;
|
6943
7061
|
this.validateTransferAmount(amount);
|
6944
7062
|
request.addCoinOutput(
|
6945
|
-
|
7063
|
+
Address5.fromAddressOrString(destination),
|
6946
7064
|
amount,
|
6947
7065
|
assetId ?? this.provider.getBaseAssetId()
|
6948
7066
|
);
|
@@ -6976,35 +7094,35 @@ var Account = class extends AbstractAccount {
|
|
6976
7094
|
* @returns A promise that resolves to the transaction response.
|
6977
7095
|
*/
|
6978
7096
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6979
|
-
|
6980
|
-
|
6981
|
-
|
6982
|
-
"Transfer amount must be a positive number."
|
6983
|
-
);
|
6984
|
-
}
|
6985
|
-
const contractAddress = Address4.fromAddressOrString(contractId);
|
6986
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
6987
|
-
const { script, scriptData } = await assembleTransferToContractScript({
|
6988
|
-
hexlifiedContractId: contractAddress.toB256(),
|
6989
|
-
amountToTransfer: bn19(amount),
|
6990
|
-
assetId: assetIdToTransfer
|
6991
|
-
});
|
7097
|
+
return this.batchTransferToContracts([{ amount, assetId, contractId }], txParams);
|
7098
|
+
}
|
7099
|
+
async batchTransferToContracts(contractTransferParams, txParams = {}) {
|
6992
7100
|
let request = new ScriptTransactionRequest({
|
6993
|
-
...txParams
|
6994
|
-
script,
|
6995
|
-
scriptData
|
6996
|
-
});
|
6997
|
-
request.addContractInputAndOutput(contractAddress);
|
6998
|
-
const txCost = await this.getTransactionCost(request, {
|
6999
|
-
quantities: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
|
7101
|
+
...txParams
|
7000
7102
|
});
|
7001
|
-
|
7002
|
-
|
7003
|
-
|
7004
|
-
|
7005
|
-
|
7103
|
+
const quantities = [];
|
7104
|
+
const transferParams = contractTransferParams.map((transferParam) => {
|
7105
|
+
const amount = bn19(transferParam.amount);
|
7106
|
+
const contractAddress = Address5.fromAddressOrString(transferParam.contractId);
|
7107
|
+
const assetId = transferParam.assetId ? hexlify19(transferParam.assetId) : this.provider.getBaseAssetId();
|
7108
|
+
if (amount.lte(0)) {
|
7109
|
+
throw new FuelError20(
|
7110
|
+
ErrorCode17.INVALID_TRANSFER_AMOUNT,
|
7111
|
+
"Transfer amount must be a positive number."
|
7112
|
+
);
|
7113
|
+
}
|
7114
|
+
request.addContractInputAndOutput(contractAddress);
|
7115
|
+
quantities.push({ amount, assetId });
|
7116
|
+
return {
|
7117
|
+
amount,
|
7118
|
+
contractId: contractAddress.toB256(),
|
7119
|
+
assetId
|
7120
|
+
};
|
7006
7121
|
});
|
7007
|
-
await
|
7122
|
+
const { script, scriptData } = await assembleTransferToContractScript(transferParams);
|
7123
|
+
request.script = script;
|
7124
|
+
request.scriptData = scriptData;
|
7125
|
+
request = await this.estimateAndFundTransaction(request, txParams, { quantities });
|
7008
7126
|
return this.sendTransaction(request);
|
7009
7127
|
}
|
7010
7128
|
/**
|
@@ -7016,7 +7134,7 @@ var Account = class extends AbstractAccount {
|
|
7016
7134
|
* @returns A promise that resolves to the transaction response.
|
7017
7135
|
*/
|
7018
7136
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
7019
|
-
const recipientAddress =
|
7137
|
+
const recipientAddress = Address5.fromAddressOrString(recipient);
|
7020
7138
|
const recipientDataArray = arrayify16(
|
7021
7139
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
7022
7140
|
);
|
@@ -7104,7 +7222,7 @@ var Account = class extends AbstractAccount {
|
|
7104
7222
|
*/
|
7105
7223
|
async signMessage(message) {
|
7106
7224
|
if (!this._connector) {
|
7107
|
-
throw new
|
7225
|
+
throw new FuelError20(ErrorCode17.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7108
7226
|
}
|
7109
7227
|
return this._connector.signMessage(this.address.toString(), message);
|
7110
7228
|
}
|
@@ -7116,8 +7234,8 @@ var Account = class extends AbstractAccount {
|
|
7116
7234
|
*/
|
7117
7235
|
async signTransaction(transactionRequestLike) {
|
7118
7236
|
if (!this._connector) {
|
7119
|
-
throw new
|
7120
|
-
|
7237
|
+
throw new FuelError20(
|
7238
|
+
ErrorCode17.MISSING_CONNECTOR,
|
7121
7239
|
"A connector is required to sign transactions."
|
7122
7240
|
);
|
7123
7241
|
}
|
@@ -7176,16 +7294,16 @@ var Account = class extends AbstractAccount {
|
|
7176
7294
|
/** @hidden * */
|
7177
7295
|
validateTransferAmount(amount) {
|
7178
7296
|
if (bn19(amount).lte(0)) {
|
7179
|
-
throw new
|
7180
|
-
|
7297
|
+
throw new FuelError20(
|
7298
|
+
ErrorCode17.INVALID_TRANSFER_AMOUNT,
|
7181
7299
|
"Transfer amount must be a positive number."
|
7182
7300
|
);
|
7183
7301
|
}
|
7184
7302
|
}
|
7185
7303
|
/** @hidden * */
|
7186
|
-
async estimateAndFundTransaction(transactionRequest, txParams) {
|
7304
|
+
async estimateAndFundTransaction(transactionRequest, txParams, costParams) {
|
7187
7305
|
let request = transactionRequest;
|
7188
|
-
const txCost = await this.getTransactionCost(request);
|
7306
|
+
const txCost = await this.getTransactionCost(request, costParams);
|
7189
7307
|
request = this.validateGasLimitAndMaxFee({
|
7190
7308
|
transactionRequest: request,
|
7191
7309
|
gasUsed: txCost.gasUsed,
|
@@ -7206,16 +7324,16 @@ var Account = class extends AbstractAccount {
|
|
7206
7324
|
if (!isDefined3(setGasLimit)) {
|
7207
7325
|
request.gasLimit = gasUsed;
|
7208
7326
|
} else if (gasUsed.gt(setGasLimit)) {
|
7209
|
-
throw new
|
7210
|
-
|
7327
|
+
throw new FuelError20(
|
7328
|
+
ErrorCode17.GAS_LIMIT_TOO_LOW,
|
7211
7329
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7212
7330
|
);
|
7213
7331
|
}
|
7214
7332
|
if (!isDefined3(setMaxFee)) {
|
7215
7333
|
request.maxFee = maxFee;
|
7216
7334
|
} else if (maxFee.gt(setMaxFee)) {
|
7217
|
-
throw new
|
7218
|
-
|
7335
|
+
throw new FuelError20(
|
7336
|
+
ErrorCode17.MAX_FEE_TOO_LOW,
|
7219
7337
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
7220
7338
|
);
|
7221
7339
|
}
|
@@ -7224,7 +7342,7 @@ var Account = class extends AbstractAccount {
|
|
7224
7342
|
};
|
7225
7343
|
|
7226
7344
|
// src/wallet/keystore-wallet.ts
|
7227
|
-
import { Address as
|
7345
|
+
import { Address as Address6 } from "@fuel-ts/address";
|
7228
7346
|
import {
|
7229
7347
|
bufferFromString,
|
7230
7348
|
keccak256,
|
@@ -7235,7 +7353,7 @@ import {
|
|
7235
7353
|
encryptJsonWalletData,
|
7236
7354
|
randomUUID as randomUUID2
|
7237
7355
|
} from "@fuel-ts/crypto";
|
7238
|
-
import { ErrorCode as
|
7356
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
|
7239
7357
|
import { hexlify as hexlify20 } from "@fuel-ts/utils";
|
7240
7358
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7241
7359
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -7250,7 +7368,7 @@ var removeHexPrefix = (hexString) => {
|
|
7250
7368
|
};
|
7251
7369
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
7252
7370
|
const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
|
7253
|
-
const ownerAddress =
|
7371
|
+
const ownerAddress = Address6.fromAddressOrString(address);
|
7254
7372
|
const salt = randomBytes6(DEFAULT_KEY_SIZE);
|
7255
7373
|
const key = scrypt({
|
7256
7374
|
password: bufferFromString(password),
|
@@ -7312,8 +7430,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7312
7430
|
const macHashUint8Array = keccak256(data);
|
7313
7431
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
7314
7432
|
if (mac !== macHash) {
|
7315
|
-
throw new
|
7316
|
-
|
7433
|
+
throw new FuelError21(
|
7434
|
+
ErrorCode18.INVALID_PASSWORD,
|
7317
7435
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
7318
7436
|
);
|
7319
7437
|
}
|
@@ -7443,16 +7561,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
7443
7561
|
|
7444
7562
|
// src/hdwallet/hdwallet.ts
|
7445
7563
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
7446
|
-
import { ErrorCode as
|
7564
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
|
7447
7565
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
7448
7566
|
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
7449
|
-
import { arrayify as arrayify19, hexlify as hexlify23, concat as
|
7567
|
+
import { arrayify as arrayify19, hexlify as hexlify23, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
7450
7568
|
|
7451
7569
|
// src/mnemonic/mnemonic.ts
|
7452
7570
|
import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
7453
|
-
import { ErrorCode as
|
7571
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
|
7454
7572
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
7455
|
-
import { arrayify as arrayify18, hexlify as hexlify22, concat as
|
7573
|
+
import { arrayify as arrayify18, hexlify as hexlify22, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
7456
7574
|
|
7457
7575
|
// src/wordlists/words/english.ts
|
7458
7576
|
var english = [
|
@@ -9507,7 +9625,7 @@ var english = [
|
|
9507
9625
|
];
|
9508
9626
|
|
9509
9627
|
// src/mnemonic/utils.ts
|
9510
|
-
import { ErrorCode as
|
9628
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
|
9511
9629
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
9512
9630
|
import { arrayify as arrayify17 } from "@fuel-ts/utils";
|
9513
9631
|
function getLowerMask(bits) {
|
@@ -9556,8 +9674,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9556
9674
|
for (let i = 0; i < words.length; i += 1) {
|
9557
9675
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9558
9676
|
if (index === -1) {
|
9559
|
-
throw new
|
9560
|
-
|
9677
|
+
throw new FuelError22(
|
9678
|
+
ErrorCode19.INVALID_MNEMONIC,
|
9561
9679
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9562
9680
|
);
|
9563
9681
|
}
|
@@ -9573,8 +9691,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9573
9691
|
const checksumMask = getUpperMask(checksumBits);
|
9574
9692
|
const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9575
9693
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9576
|
-
throw new
|
9577
|
-
|
9694
|
+
throw new FuelError22(
|
9695
|
+
ErrorCode19.INVALID_CHECKSUM,
|
9578
9696
|
"Checksum validation failed for the provided mnemonic."
|
9579
9697
|
);
|
9580
9698
|
}
|
@@ -9588,16 +9706,16 @@ var TestnetPRV = "0x04358394";
|
|
9588
9706
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9589
9707
|
function assertWordList(wordlist) {
|
9590
9708
|
if (wordlist.length !== 2048) {
|
9591
|
-
throw new
|
9592
|
-
|
9709
|
+
throw new FuelError23(
|
9710
|
+
ErrorCode20.INVALID_WORD_LIST,
|
9593
9711
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9594
9712
|
);
|
9595
9713
|
}
|
9596
9714
|
}
|
9597
9715
|
function assertEntropy(entropy) {
|
9598
9716
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9599
|
-
throw new
|
9600
|
-
|
9717
|
+
throw new FuelError23(
|
9718
|
+
ErrorCode20.INVALID_ENTROPY,
|
9601
9719
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9602
9720
|
);
|
9603
9721
|
}
|
@@ -9607,7 +9725,7 @@ function assertMnemonic(words) {
|
|
9607
9725
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9608
9726
|
", "
|
9609
9727
|
)}] words, but got ${words.length}.`;
|
9610
|
-
throw new
|
9728
|
+
throw new FuelError23(ErrorCode20.INVALID_MNEMONIC, errorMsg);
|
9611
9729
|
}
|
9612
9730
|
}
|
9613
9731
|
var Mnemonic = class {
|
@@ -9725,8 +9843,8 @@ var Mnemonic = class {
|
|
9725
9843
|
static masterKeysFromSeed(seed) {
|
9726
9844
|
const seedArray = arrayify18(seed);
|
9727
9845
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9728
|
-
throw new
|
9729
|
-
|
9846
|
+
throw new FuelError23(
|
9847
|
+
ErrorCode20.INVALID_SEED,
|
9730
9848
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9731
9849
|
);
|
9732
9850
|
}
|
@@ -9747,16 +9865,16 @@ var Mnemonic = class {
|
|
9747
9865
|
const index = "0x00000000";
|
9748
9866
|
const chainCode = masterKey.slice(32);
|
9749
9867
|
const privateKey = masterKey.slice(0, 32);
|
9750
|
-
const extendedKey =
|
9868
|
+
const extendedKey = concat5([
|
9751
9869
|
prefix,
|
9752
9870
|
depth,
|
9753
9871
|
fingerprint,
|
9754
9872
|
index,
|
9755
9873
|
chainCode,
|
9756
|
-
|
9874
|
+
concat5(["0x00", privateKey])
|
9757
9875
|
]);
|
9758
9876
|
const checksum = dataSlice(sha2563(sha2563(extendedKey)), 0, 4);
|
9759
|
-
return encodeBase58(
|
9877
|
+
return encodeBase58(concat5([extendedKey, checksum]));
|
9760
9878
|
}
|
9761
9879
|
/**
|
9762
9880
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -9771,7 +9889,7 @@ var Mnemonic = class {
|
|
9771
9889
|
* @returns A randomly generated mnemonic
|
9772
9890
|
*/
|
9773
9891
|
static generate(size = 32, extraEntropy = "") {
|
9774
|
-
const entropy = extraEntropy ? sha2563(
|
9892
|
+
const entropy = extraEntropy ? sha2563(concat5([randomBytes7(size), arrayify18(extraEntropy)])) : randomBytes7(size);
|
9775
9893
|
return Mnemonic.entropyToMnemonic(entropy);
|
9776
9894
|
}
|
9777
9895
|
};
|
@@ -9784,7 +9902,7 @@ var MainnetPUB = hexlify23("0x0488b21e");
|
|
9784
9902
|
var TestnetPRV2 = hexlify23("0x04358394");
|
9785
9903
|
var TestnetPUB = hexlify23("0x043587cf");
|
9786
9904
|
function base58check(data) {
|
9787
|
-
return encodeBase582(
|
9905
|
+
return encodeBase582(concat6([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
9788
9906
|
}
|
9789
9907
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
9790
9908
|
if (isPublic) {
|
@@ -9803,7 +9921,7 @@ function isValidExtendedKey(extendedKey) {
|
|
9803
9921
|
function parsePath(path2, depth = 0) {
|
9804
9922
|
const components = path2.split("/");
|
9805
9923
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9806
|
-
throw new
|
9924
|
+
throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9807
9925
|
}
|
9808
9926
|
if (components[0] === "m") {
|
9809
9927
|
components.shift();
|
@@ -9832,8 +9950,8 @@ var HDWallet = class {
|
|
9832
9950
|
this.privateKey = hexlify23(config.privateKey);
|
9833
9951
|
} else {
|
9834
9952
|
if (!config.publicKey) {
|
9835
|
-
throw new
|
9836
|
-
|
9953
|
+
throw new FuelError24(
|
9954
|
+
ErrorCode21.HD_WALLET_ERROR,
|
9837
9955
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9838
9956
|
);
|
9839
9957
|
}
|
@@ -9862,8 +9980,8 @@ var HDWallet = class {
|
|
9862
9980
|
const data = new Uint8Array(37);
|
9863
9981
|
if (index & HARDENED_INDEX) {
|
9864
9982
|
if (!privateKey) {
|
9865
|
-
throw new
|
9866
|
-
|
9983
|
+
throw new FuelError24(
|
9984
|
+
ErrorCode21.HD_WALLET_ERROR,
|
9867
9985
|
"Cannot derive a hardened index without a private Key."
|
9868
9986
|
);
|
9869
9987
|
}
|
@@ -9915,8 +10033,8 @@ var HDWallet = class {
|
|
9915
10033
|
*/
|
9916
10034
|
toExtendedKey(isPublic = false, testnet = false) {
|
9917
10035
|
if (this.depth >= 256) {
|
9918
|
-
throw new
|
9919
|
-
|
10036
|
+
throw new FuelError24(
|
10037
|
+
ErrorCode21.HD_WALLET_ERROR,
|
9920
10038
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9921
10039
|
);
|
9922
10040
|
}
|
@@ -9925,8 +10043,8 @@ var HDWallet = class {
|
|
9925
10043
|
const parentFingerprint = this.parentFingerprint;
|
9926
10044
|
const index = toHex(this.index, 4);
|
9927
10045
|
const chainCode = this.chainCode;
|
9928
|
-
const key = this.privateKey != null && !isPublic ?
|
9929
|
-
const extendedKey = arrayify19(
|
10046
|
+
const key = this.privateKey != null && !isPublic ? concat6(["0x00", this.privateKey]) : this.publicKey;
|
10047
|
+
const extendedKey = arrayify19(concat6([prefix, depth, parentFingerprint, index, chainCode, key]));
|
9930
10048
|
return base58check(extendedKey);
|
9931
10049
|
}
|
9932
10050
|
/**
|
@@ -9947,10 +10065,10 @@ var HDWallet = class {
|
|
9947
10065
|
const bytes = arrayify19(decoded);
|
9948
10066
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9949
10067
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9950
|
-
throw new
|
10068
|
+
throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9951
10069
|
}
|
9952
10070
|
if (!validChecksum) {
|
9953
|
-
throw new
|
10071
|
+
throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9954
10072
|
}
|
9955
10073
|
const depth = bytes[4];
|
9956
10074
|
const parentFingerprint = hexlify23(bytes.slice(5, 9));
|
@@ -9958,14 +10076,14 @@ var HDWallet = class {
|
|
9958
10076
|
const chainCode = hexlify23(bytes.slice(13, 45));
|
9959
10077
|
const key = bytes.slice(45, 78);
|
9960
10078
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9961
|
-
throw new
|
9962
|
-
|
10079
|
+
throw new FuelError24(
|
10080
|
+
ErrorCode21.HD_WALLET_ERROR,
|
9963
10081
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9964
10082
|
);
|
9965
10083
|
}
|
9966
10084
|
if (isPublicExtendedKey(bytes)) {
|
9967
10085
|
if (key[0] !== 3) {
|
9968
|
-
throw new
|
10086
|
+
throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Invalid public extended key.");
|
9969
10087
|
}
|
9970
10088
|
return new HDWallet({
|
9971
10089
|
publicKey: key,
|
@@ -9976,7 +10094,7 @@ var HDWallet = class {
|
|
9976
10094
|
});
|
9977
10095
|
}
|
9978
10096
|
if (key[0] !== 0) {
|
9979
|
-
throw new
|
10097
|
+
throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Invalid private extended key.");
|
9980
10098
|
}
|
9981
10099
|
return new HDWallet({
|
9982
10100
|
privateKey: key.slice(1),
|
@@ -10220,26 +10338,26 @@ var WalletsConfig = class {
|
|
10220
10338
|
amountPerCoin
|
10221
10339
|
}) {
|
10222
10340
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
10223
|
-
throw new
|
10224
|
-
|
10341
|
+
throw new FuelError25(
|
10342
|
+
FuelError25.CODES.INVALID_INPUT_PARAMETERS,
|
10225
10343
|
"Number of wallets must be greater than zero."
|
10226
10344
|
);
|
10227
10345
|
}
|
10228
10346
|
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
10229
|
-
throw new
|
10230
|
-
|
10347
|
+
throw new FuelError25(
|
10348
|
+
FuelError25.CODES.INVALID_INPUT_PARAMETERS,
|
10231
10349
|
"Number of assets per wallet must be greater than zero."
|
10232
10350
|
);
|
10233
10351
|
}
|
10234
10352
|
if (coinsPerAsset <= 0) {
|
10235
|
-
throw new
|
10236
|
-
|
10353
|
+
throw new FuelError25(
|
10354
|
+
FuelError25.CODES.INVALID_INPUT_PARAMETERS,
|
10237
10355
|
"Number of coins per asset must be greater than zero."
|
10238
10356
|
);
|
10239
10357
|
}
|
10240
10358
|
if (amountPerCoin < 0) {
|
10241
|
-
throw new
|
10242
|
-
|
10359
|
+
throw new FuelError25(
|
10360
|
+
FuelError25.CODES.INVALID_INPUT_PARAMETERS,
|
10243
10361
|
"Amount per coin must be greater than or equal to zero."
|
10244
10362
|
);
|
10245
10363
|
}
|
@@ -10310,7 +10428,7 @@ async function setupTestProviderAndWallets({
|
|
10310
10428
|
}
|
10311
10429
|
|
10312
10430
|
// src/test-utils/test-message.ts
|
10313
|
-
import { Address as
|
10431
|
+
import { Address as Address7 } from "@fuel-ts/address";
|
10314
10432
|
import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
|
10315
10433
|
import { bn as bn21 } from "@fuel-ts/math";
|
10316
10434
|
import { hexlify as hexlify25 } from "@fuel-ts/utils";
|
@@ -10328,8 +10446,8 @@ var TestMessage = class {
|
|
10328
10446
|
* It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
|
10329
10447
|
*/
|
10330
10448
|
constructor({
|
10331
|
-
sender =
|
10332
|
-
recipient =
|
10449
|
+
sender = Address7.fromRandom(),
|
10450
|
+
recipient = Address7.fromRandom(),
|
10333
10451
|
nonce = hexlify25(randomBytes9(32)),
|
10334
10452
|
amount = 1e6,
|
10335
10453
|
data = "",
|