@fuel-ts/account 0.100.0 → 0.100.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/index.global.js +50 -25
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +220 -194
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -150
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider.d.ts +2 -0
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
- package/dist/test-utils.global.js +42 -7
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +167 -130
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +132 -95
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +14 -14
package/dist/test-utils.mjs
CHANGED
@@ -417,7 +417,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
417
417
|
|
418
418
|
// src/providers/provider.ts
|
419
419
|
import { Address as Address3, isB256 } from "@fuel-ts/address";
|
420
|
-
import { ErrorCode as ErrorCode16, FuelError as
|
420
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError20 } from "@fuel-ts/errors";
|
421
421
|
import { bn as bn17 } from "@fuel-ts/math";
|
422
422
|
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
423
423
|
import { arrayify as arrayify13, hexlify as hexlify18, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
@@ -426,6 +426,17 @@ import { GraphQLClient } from "graphql-request";
|
|
426
426
|
import gql2 from "graphql-tag";
|
427
427
|
import { clone as clone8 } from "ramda";
|
428
428
|
|
429
|
+
// src/connectors/utils/promises.ts
|
430
|
+
import { FuelError as FuelError2 } from "@fuel-ts/errors";
|
431
|
+
function deferPromise() {
|
432
|
+
const defer = {};
|
433
|
+
defer.promise = new Promise((resolve, reject) => {
|
434
|
+
defer.reject = reject;
|
435
|
+
defer.resolve = resolve;
|
436
|
+
});
|
437
|
+
return defer;
|
438
|
+
}
|
439
|
+
|
429
440
|
// src/providers/__generated__/operations.ts
|
430
441
|
import gql from "graphql-tag";
|
431
442
|
var SubmittedStatusFragmentDoc = gql`
|
@@ -1478,14 +1489,14 @@ function getSdk(requester) {
|
|
1478
1489
|
}
|
1479
1490
|
|
1480
1491
|
// src/providers/fuel-graphql-subscriber.ts
|
1481
|
-
import { ErrorCode as ErrorCode2, FuelError as
|
1492
|
+
import { ErrorCode as ErrorCode2, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1482
1493
|
import { print } from "graphql";
|
1483
1494
|
|
1484
1495
|
// src/providers/utils/handle-gql-error-message.ts
|
1485
|
-
import { ErrorCode, FuelError as
|
1496
|
+
import { ErrorCode, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1486
1497
|
var mapGqlErrorMessage = (error) => {
|
1487
1498
|
if (new RegExp("the target cannot be met due to no coins available or exceeding the \\d+ coin limit." /* NOT_ENOUGH_COINS_MAX_COINS */).test(error.message)) {
|
1488
|
-
return new
|
1499
|
+
return new FuelError3(
|
1489
1500
|
ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
1490
1501
|
`Insufficient funds or too many small value coins. Consider combining UTXOs.`,
|
1491
1502
|
{},
|
@@ -1493,20 +1504,20 @@ var mapGqlErrorMessage = (error) => {
|
|
1493
1504
|
);
|
1494
1505
|
}
|
1495
1506
|
if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
|
1496
|
-
return new
|
1507
|
+
return new FuelError3(
|
1497
1508
|
ErrorCode.ASSET_NOT_FOUND,
|
1498
1509
|
`Asset not found for given asset id.`,
|
1499
1510
|
{},
|
1500
1511
|
error
|
1501
1512
|
);
|
1502
1513
|
}
|
1503
|
-
return new
|
1514
|
+
return new FuelError3(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1504
1515
|
};
|
1505
1516
|
var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
|
1506
1517
|
if (!incompatibleNodeVersionMessage) {
|
1507
1518
|
return error;
|
1508
1519
|
}
|
1509
|
-
return new
|
1520
|
+
return new FuelError3(
|
1510
1521
|
error.code,
|
1511
1522
|
`${error.message}
|
1512
1523
|
|
@@ -1525,7 +1536,7 @@ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = fal
|
|
1525
1536
|
}
|
1526
1537
|
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
1527
1538
|
throw mapGqlErrorWithIncompatibleNodeVersion(
|
1528
|
-
new
|
1539
|
+
new FuelError3(ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1529
1540
|
incompatibleNodeVersionMessage
|
1530
1541
|
);
|
1531
1542
|
};
|
@@ -1576,7 +1587,7 @@ var _FuelGraphqlSubscriber = class {
|
|
1576
1587
|
try {
|
1577
1588
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1578
1589
|
} catch (e) {
|
1579
|
-
throw new
|
1590
|
+
throw new FuelError4(
|
1580
1591
|
ErrorCode2.STREAM_PARSING_ERROR,
|
1581
1592
|
`Error while parsing stream data response: ${text}`
|
1582
1593
|
);
|
@@ -1600,13 +1611,13 @@ __publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
|
|
1600
1611
|
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1601
1612
|
|
1602
1613
|
// src/providers/resource-cache.ts
|
1603
|
-
import { FuelError as
|
1614
|
+
import { FuelError as FuelError14, ErrorCode as ErrorCode10 } from "@fuel-ts/errors";
|
1604
1615
|
import { hexlify as hexlify16 } from "@fuel-ts/utils";
|
1605
1616
|
|
1606
1617
|
// src/providers/transaction-request/input.ts
|
1607
1618
|
import { BYTES_32 as BYTES_322, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
|
1608
1619
|
import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
1609
|
-
import { ErrorCode as ErrorCode3, FuelError as
|
1620
|
+
import { ErrorCode as ErrorCode3, FuelError as FuelError5 } from "@fuel-ts/errors";
|
1610
1621
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1611
1622
|
import { InputType } from "@fuel-ts/transactions";
|
1612
1623
|
import { arrayify as arrayify2, hexlify as hexlify4 } from "@fuel-ts/utils";
|
@@ -1670,7 +1681,7 @@ var inputify = (value) => {
|
|
1670
1681
|
};
|
1671
1682
|
}
|
1672
1683
|
default: {
|
1673
|
-
throw new
|
1684
|
+
throw new FuelError5(
|
1674
1685
|
ErrorCode3.INVALID_TRANSACTION_INPUT,
|
1675
1686
|
`Invalid transaction input type: ${type}.`
|
1676
1687
|
);
|
@@ -1680,7 +1691,7 @@ var inputify = (value) => {
|
|
1680
1691
|
|
1681
1692
|
// src/providers/transaction-request/output.ts
|
1682
1693
|
import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
1683
|
-
import { ErrorCode as ErrorCode4, FuelError as
|
1694
|
+
import { ErrorCode as ErrorCode4, FuelError as FuelError6 } from "@fuel-ts/errors";
|
1684
1695
|
import { bn as bn3 } from "@fuel-ts/math";
|
1685
1696
|
import { OutputType } from "@fuel-ts/transactions";
|
1686
1697
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1727,7 +1738,7 @@ var outputify = (value) => {
|
|
1727
1738
|
};
|
1728
1739
|
}
|
1729
1740
|
default: {
|
1730
|
-
throw new
|
1741
|
+
throw new FuelError6(
|
1731
1742
|
ErrorCode4.INVALID_TRANSACTION_INPUT,
|
1732
1743
|
`Invalid transaction output type: ${type}.`
|
1733
1744
|
);
|
@@ -1740,7 +1751,7 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1740
1751
|
import { Address as Address2, addressify } from "@fuel-ts/address";
|
1741
1752
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1742
1753
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
1743
|
-
import { FuelError as
|
1754
|
+
import { FuelError as FuelError11 } from "@fuel-ts/errors";
|
1744
1755
|
import { bn as bn8 } from "@fuel-ts/math";
|
1745
1756
|
import {
|
1746
1757
|
PolicyType,
|
@@ -1763,7 +1774,7 @@ import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs
|
|
1763
1774
|
|
1764
1775
|
// src/providers/utils/serialization.ts
|
1765
1776
|
import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
|
1766
|
-
import { ErrorCode as ErrorCode5, FuelError as
|
1777
|
+
import { ErrorCode as ErrorCode5, FuelError as FuelError7 } from "@fuel-ts/errors";
|
1767
1778
|
import { bn as bn4 } from "@fuel-ts/math";
|
1768
1779
|
import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
|
1769
1780
|
import { hexlify as hexlify6, arrayify as arrayify3 } from "@fuel-ts/utils";
|
@@ -2098,7 +2109,7 @@ var deserializeReceipt = (receipt) => {
|
|
2098
2109
|
return burnReceipt;
|
2099
2110
|
}
|
2100
2111
|
default:
|
2101
|
-
throw new
|
2112
|
+
throw new FuelError7(ErrorCode5.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
2102
2113
|
}
|
2103
2114
|
};
|
2104
2115
|
|
@@ -2122,7 +2133,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
|
2122
2133
|
);
|
2123
2134
|
|
2124
2135
|
// src/providers/utils/block-explorer.ts
|
2125
|
-
import { ErrorCode as ErrorCode6, FuelError as
|
2136
|
+
import { ErrorCode as ErrorCode6, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2126
2137
|
|
2127
2138
|
// src/providers/utils/gas.ts
|
2128
2139
|
import { bn as bn5 } from "@fuel-ts/math";
|
@@ -2294,7 +2305,7 @@ function normalizeJSON(root) {
|
|
2294
2305
|
}
|
2295
2306
|
|
2296
2307
|
// src/providers/utils/extract-tx-error.ts
|
2297
|
-
import { ErrorCode as ErrorCode7, FuelError as
|
2308
|
+
import { ErrorCode as ErrorCode7, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2298
2309
|
import { bn as bn6 } from "@fuel-ts/math";
|
2299
2310
|
import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
|
2300
2311
|
import {
|
@@ -2315,7 +2326,7 @@ You can read more about this error at:
|
|
2315
2326
|
|
2316
2327
|
${PANIC_DOC_URL}#variant.${statusReason}`;
|
2317
2328
|
}
|
2318
|
-
return new
|
2329
|
+
return new FuelError9(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2319
2330
|
...metadata,
|
2320
2331
|
reason: statusReason
|
2321
2332
|
});
|
@@ -2356,7 +2367,7 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2356
2367
|
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2357
2368
|
break;
|
2358
2369
|
default:
|
2359
|
-
throw new
|
2370
|
+
throw new FuelError9(
|
2360
2371
|
ErrorCode7.UNKNOWN,
|
2361
2372
|
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2362
2373
|
{
|
@@ -2366,7 +2377,7 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2366
2377
|
);
|
2367
2378
|
}
|
2368
2379
|
}
|
2369
|
-
return new
|
2380
|
+
return new FuelError9(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2370
2381
|
...metadata,
|
2371
2382
|
reason
|
2372
2383
|
});
|
@@ -2399,7 +2410,7 @@ var NoWitnessAtIndexError = class extends Error {
|
|
2399
2410
|
};
|
2400
2411
|
|
2401
2412
|
// src/providers/transaction-request/helpers.ts
|
2402
|
-
import { ErrorCode as ErrorCode8, FuelError as
|
2413
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError10 } from "@fuel-ts/errors";
|
2403
2414
|
import { bn as bn7 } from "@fuel-ts/math";
|
2404
2415
|
import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
|
2405
2416
|
import { hexlify as hexlify8 } from "@fuel-ts/utils";
|
@@ -2458,7 +2469,7 @@ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAs
|
|
2458
2469
|
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
2459
2470
|
"Or enable asset burn, upon sending the transaction."
|
2460
2471
|
].join("\n");
|
2461
|
-
throw new
|
2472
|
+
throw new FuelError10(ErrorCode8.ASSET_BURN_DETECTED, message);
|
2462
2473
|
};
|
2463
2474
|
|
2464
2475
|
// src/providers/transaction-request/witness.ts
|
@@ -2856,7 +2867,7 @@ var BaseTransactionRequest = class {
|
|
2856
2867
|
* @hidden
|
2857
2868
|
*/
|
2858
2869
|
metadataGas(_gasCosts) {
|
2859
|
-
throw new
|
2870
|
+
throw new FuelError11(FuelError11.CODES.NOT_IMPLEMENTED, "Not implemented");
|
2860
2871
|
}
|
2861
2872
|
/**
|
2862
2873
|
* @hidden
|
@@ -3479,7 +3490,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3479
3490
|
};
|
3480
3491
|
|
3481
3492
|
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3482
|
-
import { FuelError as
|
3493
|
+
import { FuelError as FuelError12 } from "@fuel-ts/errors";
|
3483
3494
|
import { hash as hash2 } from "@fuel-ts/hasher";
|
3484
3495
|
import {
|
3485
3496
|
TransactionType as TransactionType5,
|
@@ -3586,7 +3597,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
3586
3597
|
}
|
3587
3598
|
};
|
3588
3599
|
} else {
|
3589
|
-
throw new
|
3600
|
+
throw new FuelError12(FuelError12.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3590
3601
|
}
|
3591
3602
|
return {
|
3592
3603
|
type: TransactionType5.Upgrade,
|
@@ -3628,7 +3639,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
3628
3639
|
txBytesSize
|
3629
3640
|
});
|
3630
3641
|
}
|
3631
|
-
throw new
|
3642
|
+
throw new FuelError12(FuelError12.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3632
3643
|
}
|
3633
3644
|
};
|
3634
3645
|
|
@@ -3739,7 +3750,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
|
|
3739
3750
|
};
|
3740
3751
|
|
3741
3752
|
// src/providers/transaction-request/utils.ts
|
3742
|
-
import { ErrorCode as ErrorCode9, FuelError as
|
3753
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError13 } from "@fuel-ts/errors";
|
3743
3754
|
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
3744
3755
|
var transactionRequestify = (obj) => {
|
3745
3756
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
@@ -3763,7 +3774,7 @@ var transactionRequestify = (obj) => {
|
|
3763
3774
|
return UploadTransactionRequest.from(obj);
|
3764
3775
|
}
|
3765
3776
|
default: {
|
3766
|
-
throw new
|
3777
|
+
throw new FuelError13(
|
3767
3778
|
ErrorCode9.UNSUPPORTED_TRANSACTION_TYPE,
|
3768
3779
|
`Unsupported transaction type: ${type}.`
|
3769
3780
|
);
|
@@ -3780,7 +3791,7 @@ var ResourceCache = class {
|
|
3780
3791
|
constructor(ttl) {
|
3781
3792
|
this.ttl = ttl;
|
3782
3793
|
if (typeof ttl !== "number" || this.ttl <= 0) {
|
3783
|
-
throw new
|
3794
|
+
throw new FuelError14(
|
3784
3795
|
ErrorCode10.INVALID_TTL,
|
3785
3796
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
3786
3797
|
);
|
@@ -3865,7 +3876,7 @@ var ResourceCache = class {
|
|
3865
3876
|
};
|
3866
3877
|
|
3867
3878
|
// src/providers/transaction-response/transaction-response.ts
|
3868
|
-
import { ErrorCode as ErrorCode14, FuelError as
|
3879
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError18 } from "@fuel-ts/errors";
|
3869
3880
|
import { bn as bn16 } from "@fuel-ts/math";
|
3870
3881
|
import { OutputType as OutputType8, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
3871
3882
|
import { arrayify as arrayify12, assertUnreachable } from "@fuel-ts/utils";
|
@@ -3943,12 +3954,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
3943
3954
|
|
3944
3955
|
// src/providers/transaction-summary/operations.ts
|
3945
3956
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
3946
|
-
import { ErrorCode as ErrorCode12, FuelError as
|
3957
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError16 } from "@fuel-ts/errors";
|
3947
3958
|
import { bn as bn13 } from "@fuel-ts/math";
|
3948
3959
|
import { ReceiptType as ReceiptType5, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
3949
3960
|
|
3950
3961
|
// src/providers/transaction-summary/input.ts
|
3951
|
-
import { ErrorCode as ErrorCode11, FuelError as
|
3962
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError15 } from "@fuel-ts/errors";
|
3952
3963
|
import { BN } from "@fuel-ts/math";
|
3953
3964
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
3954
3965
|
function getInputsByTypes(inputs, types) {
|
@@ -4017,7 +4028,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
4017
4028
|
return void 0;
|
4018
4029
|
}
|
4019
4030
|
if (contractInput.type !== InputType6.Contract) {
|
4020
|
-
throw new
|
4031
|
+
throw new FuelError15(
|
4021
4032
|
ErrorCode11.INVALID_TRANSACTION_INPUT,
|
4022
4033
|
`Contract input should be of type 'contract'.`
|
4023
4034
|
);
|
@@ -4071,7 +4082,7 @@ function getTransactionTypeName(transactionType) {
|
|
4071
4082
|
case TransactionType9.Upload:
|
4072
4083
|
return "Upload" /* Upload */;
|
4073
4084
|
default:
|
4074
|
-
throw new
|
4085
|
+
throw new FuelError16(
|
4075
4086
|
ErrorCode12.UNSUPPORTED_TRANSACTION_TYPE,
|
4076
4087
|
`Unsupported transaction type: ${transactionType}.`
|
4077
4088
|
);
|
@@ -4451,7 +4462,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
4451
4462
|
};
|
4452
4463
|
|
4453
4464
|
// src/providers/transaction-summary/status.ts
|
4454
|
-
import { ErrorCode as ErrorCode13, FuelError as
|
4465
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError17 } from "@fuel-ts/errors";
|
4455
4466
|
import { bn as bn14 } from "@fuel-ts/math";
|
4456
4467
|
var getTransactionStatusName = (gqlStatus) => {
|
4457
4468
|
switch (gqlStatus) {
|
@@ -4464,7 +4475,7 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
4464
4475
|
case "SqueezedOutStatus":
|
4465
4476
|
return "squeezedout" /* squeezedout */;
|
4466
4477
|
default:
|
4467
|
-
throw new
|
4478
|
+
throw new FuelError17(
|
4468
4479
|
ErrorCode13.INVALID_TRANSACTION_STATUS,
|
4469
4480
|
`Invalid transaction status: ${gqlStatus}.`
|
4470
4481
|
);
|
@@ -4598,14 +4609,26 @@ function assembleTransactionSummary(params) {
|
|
4598
4609
|
|
4599
4610
|
// src/providers/transaction-response/getDecodedLogs.ts
|
4600
4611
|
import { Interface as Interface2, BigNumberCoder } from "@fuel-ts/abi-coder";
|
4612
|
+
import { ZeroBytes32 as ZeroBytes3210 } from "@fuel-ts/address/configs";
|
4601
4613
|
import { ReceiptType as ReceiptType7 } from "@fuel-ts/transactions";
|
4602
4614
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
4615
|
+
let mainContract = "";
|
4616
|
+
if (mainAbi.programType === "contract") {
|
4617
|
+
const firstCallReceipt = receipts.find(
|
4618
|
+
(r) => r.type === ReceiptType7.Call && r.id === ZeroBytes3210
|
4619
|
+
);
|
4620
|
+
mainContract = firstCallReceipt.to;
|
4621
|
+
}
|
4603
4622
|
return receipts.reduce((logs, receipt) => {
|
4604
4623
|
if (receipt.type === ReceiptType7.LogData || receipt.type === ReceiptType7.Log) {
|
4605
|
-
const
|
4606
|
-
const
|
4607
|
-
|
4608
|
-
|
4624
|
+
const isLogFromMainAbi = receipt.id === ZeroBytes3210 || mainContract === receipt.id;
|
4625
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
4626
|
+
if (isDecodable) {
|
4627
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface2(mainAbi) : new Interface2(externalAbis[receipt.id]);
|
4628
|
+
const data = receipt.type === ReceiptType7.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
4629
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
4630
|
+
logs.push(decodedLog);
|
4631
|
+
}
|
4609
4632
|
}
|
4610
4633
|
return logs;
|
4611
4634
|
}, []);
|
@@ -4810,7 +4833,7 @@ var TransactionResponse = class {
|
|
4810
4833
|
this.status = statusChange;
|
4811
4834
|
if (statusChange.type === "SqueezedOutStatus") {
|
4812
4835
|
this.unsetResourceCache();
|
4813
|
-
throw new
|
4836
|
+
throw new FuelError18(
|
4814
4837
|
ErrorCode14.TRANSACTION_SQUEEZED_OUT,
|
4815
4838
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4816
4839
|
);
|
@@ -4935,30 +4958,30 @@ var adjustResourcesToExclude = (params) => {
|
|
4935
4958
|
};
|
4936
4959
|
|
4937
4960
|
// src/providers/utils/validate-pagination-args.ts
|
4938
|
-
import { FuelError as
|
4961
|
+
import { FuelError as FuelError19, ErrorCode as ErrorCode15 } from "@fuel-ts/errors";
|
4939
4962
|
var validatePaginationArgs = (params) => {
|
4940
4963
|
const { paginationLimit, inputArgs = {} } = params;
|
4941
4964
|
const { first, last, after, before } = inputArgs;
|
4942
4965
|
if (after && before) {
|
4943
|
-
throw new
|
4966
|
+
throw new FuelError19(
|
4944
4967
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4945
4968
|
'Pagination arguments "after" and "before" cannot be used together'
|
4946
4969
|
);
|
4947
4970
|
}
|
4948
4971
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
4949
|
-
throw new
|
4972
|
+
throw new FuelError19(
|
4950
4973
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4951
4974
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
4952
4975
|
);
|
4953
4976
|
}
|
4954
4977
|
if (first && before) {
|
4955
|
-
throw new
|
4978
|
+
throw new FuelError19(
|
4956
4979
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4957
4980
|
'The use of pagination argument "first" with "before" is not supported'
|
4958
4981
|
);
|
4959
4982
|
}
|
4960
4983
|
if (last && after) {
|
4961
|
-
throw new
|
4984
|
+
throw new FuelError19(
|
4962
4985
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4963
4986
|
'The use of pagination argument "last" with "after" is not supported'
|
4964
4987
|
);
|
@@ -5043,6 +5066,7 @@ var _Provider = class {
|
|
5043
5066
|
}
|
5044
5067
|
/** @hidden */
|
5045
5068
|
static clearChainAndNodeCaches() {
|
5069
|
+
_Provider.inflightFetchChainAndNodeInfoRequests = {};
|
5046
5070
|
_Provider.nodeInfoCache = {};
|
5047
5071
|
_Provider.chainInfoCache = {};
|
5048
5072
|
}
|
@@ -5071,7 +5095,7 @@ var _Provider = class {
|
|
5071
5095
|
try {
|
5072
5096
|
parsedUrl = new URL(url);
|
5073
5097
|
} catch (error) {
|
5074
|
-
throw new
|
5098
|
+
throw new FuelError20(FuelError20.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
5075
5099
|
}
|
5076
5100
|
const username = parsedUrl.username;
|
5077
5101
|
const password = parsedUrl.password;
|
@@ -5160,13 +5184,24 @@ var _Provider = class {
|
|
5160
5184
|
throw new Error(`Jumps to the catch block and re-fetch`);
|
5161
5185
|
}
|
5162
5186
|
} catch (_err) {
|
5187
|
+
const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5188
|
+
if (inflightRequest) {
|
5189
|
+
const now2 = await inflightRequest;
|
5190
|
+
this.consensusParametersTimestamp = now2;
|
5191
|
+
return this.fetchChainAndNodeInfo();
|
5192
|
+
}
|
5193
|
+
const { promise, resolve } = deferPromise();
|
5194
|
+
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
|
5163
5195
|
const data = await this.operations.getChainAndNodeInfo();
|
5164
5196
|
nodeInfo = deserializeNodeInfo(data.nodeInfo);
|
5165
|
-
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
5166
5197
|
chain = deserializeChain(data.chain);
|
5198
|
+
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
5167
5199
|
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
5168
5200
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
5169
|
-
|
5201
|
+
const now = Date.now();
|
5202
|
+
this.consensusParametersTimestamp = now;
|
5203
|
+
resolve(now);
|
5204
|
+
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5170
5205
|
}
|
5171
5206
|
return {
|
5172
5207
|
chain,
|
@@ -5344,13 +5379,13 @@ var _Provider = class {
|
|
5344
5379
|
}
|
5345
5380
|
} = await this.getChain();
|
5346
5381
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
5347
|
-
throw new
|
5382
|
+
throw new FuelError20(
|
5348
5383
|
ErrorCode16.MAX_INPUTS_EXCEEDED,
|
5349
5384
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
5350
5385
|
);
|
5351
5386
|
}
|
5352
5387
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
5353
|
-
throw new
|
5388
|
+
throw new FuelError20(
|
5354
5389
|
ErrorCode16.MAX_OUTPUTS_EXCEEDED,
|
5355
5390
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
5356
5391
|
);
|
@@ -6050,7 +6085,7 @@ var _Provider = class {
|
|
6050
6085
|
0
|
6051
6086
|
)?.[0];
|
6052
6087
|
} catch (error) {
|
6053
|
-
if (error instanceof
|
6088
|
+
if (error instanceof FuelError20 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
6054
6089
|
console.warn("Unsupported transaction type encountered");
|
6055
6090
|
return null;
|
6056
6091
|
}
|
@@ -6076,7 +6111,7 @@ var _Provider = class {
|
|
6076
6111
|
try {
|
6077
6112
|
return coder.decode(arrayify13(rawPayload), 0)[0];
|
6078
6113
|
} catch (error) {
|
6079
|
-
if (error instanceof
|
6114
|
+
if (error instanceof FuelError20 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
6080
6115
|
console.warn("Unsupported transaction type encountered");
|
6081
6116
|
return null;
|
6082
6117
|
}
|
@@ -6254,7 +6289,7 @@ var _Provider = class {
|
|
6254
6289
|
nonce
|
6255
6290
|
};
|
6256
6291
|
if (commitBlockId && commitBlockHeight) {
|
6257
|
-
throw new
|
6292
|
+
throw new FuelError20(
|
6258
6293
|
ErrorCode16.INVALID_INPUT_PARAMETERS,
|
6259
6294
|
"commitBlockId and commitBlockHeight cannot be used together"
|
6260
6295
|
);
|
@@ -6510,6 +6545,8 @@ cacheInputs_fn = function(inputs, transactionId) {
|
|
6510
6545
|
this.cache.set(transactionId, inputs);
|
6511
6546
|
};
|
6512
6547
|
/** @hidden */
|
6548
|
+
__publicField(Provider, "inflightFetchChainAndNodeInfoRequests", {});
|
6549
|
+
/** @hidden */
|
6513
6550
|
__publicField(Provider, "chainInfoCache", {});
|
6514
6551
|
/** @hidden */
|
6515
6552
|
__publicField(Provider, "nodeInfoCache", {});
|
@@ -6517,7 +6554,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
6517
6554
|
__publicField(Provider, "incompatibleNodeVersionMessage", "");
|
6518
6555
|
|
6519
6556
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6520
|
-
import { ErrorCode as ErrorCode17, FuelError as
|
6557
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError21 } from "@fuel-ts/errors";
|
6521
6558
|
import { bn as bn18 } from "@fuel-ts/math";
|
6522
6559
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
6523
6560
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
@@ -6552,7 +6589,7 @@ __publicField(TestAssetId, "B", new _TestAssetId(
|
|
6552
6589
|
|
6553
6590
|
// src/test-utils/wallet-config.ts
|
6554
6591
|
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
6555
|
-
import { FuelError as
|
6592
|
+
import { FuelError as FuelError27 } from "@fuel-ts/errors";
|
6556
6593
|
import { bn as bn22 } from "@fuel-ts/math";
|
6557
6594
|
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify25 } from "@fuel-ts/utils";
|
6558
6595
|
|
@@ -6564,7 +6601,7 @@ import { hexlify as hexlify22 } from "@fuel-ts/utils";
|
|
6564
6601
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
6565
6602
|
import { Address as Address5 } from "@fuel-ts/address";
|
6566
6603
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
6567
|
-
import { ErrorCode as ErrorCode18, FuelError as
|
6604
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError22 } from "@fuel-ts/errors";
|
6568
6605
|
import { bn as bn20 } from "@fuel-ts/math";
|
6569
6606
|
import { InputType as InputType7 } from "@fuel-ts/transactions";
|
6570
6607
|
import { arrayify as arrayify17, hexlify as hexlify20, isDefined as isDefined3 } from "@fuel-ts/utils";
|
@@ -6665,7 +6702,7 @@ var Account = class extends AbstractAccount {
|
|
6665
6702
|
*/
|
6666
6703
|
get provider() {
|
6667
6704
|
if (!this._provider) {
|
6668
|
-
throw new
|
6705
|
+
throw new FuelError22(ErrorCode18.MISSING_PROVIDER, "Provider not set");
|
6669
6706
|
}
|
6670
6707
|
return this._provider;
|
6671
6708
|
}
|
@@ -6824,7 +6861,7 @@ var Account = class extends AbstractAccount {
|
|
6824
6861
|
fundingAttempts += 1;
|
6825
6862
|
}
|
6826
6863
|
if (needsToBeFunded) {
|
6827
|
-
throw new
|
6864
|
+
throw new FuelError22(
|
6828
6865
|
ErrorCode18.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
6829
6866
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6830
6867
|
);
|
@@ -6944,7 +6981,7 @@ var Account = class extends AbstractAccount {
|
|
6944
6981
|
const contractAddress = new Address5(transferParam.contractId);
|
6945
6982
|
const assetId = transferParam.assetId ? hexlify20(transferParam.assetId) : defaultAssetId;
|
6946
6983
|
if (amount.lte(0)) {
|
6947
|
-
throw new
|
6984
|
+
throw new FuelError22(
|
6948
6985
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
6949
6986
|
"Transfer amount must be a positive number."
|
6950
6987
|
);
|
@@ -7061,7 +7098,7 @@ var Account = class extends AbstractAccount {
|
|
7061
7098
|
*/
|
7062
7099
|
async signMessage(message) {
|
7063
7100
|
if (!this._connector) {
|
7064
|
-
throw new
|
7101
|
+
throw new FuelError22(ErrorCode18.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7065
7102
|
}
|
7066
7103
|
return this._connector.signMessage(this.address.toString(), message);
|
7067
7104
|
}
|
@@ -7073,7 +7110,7 @@ var Account = class extends AbstractAccount {
|
|
7073
7110
|
*/
|
7074
7111
|
async signTransaction(transactionRequestLike) {
|
7075
7112
|
if (!this._connector) {
|
7076
|
-
throw new
|
7113
|
+
throw new FuelError22(
|
7077
7114
|
ErrorCode18.MISSING_CONNECTOR,
|
7078
7115
|
"A connector is required to sign transactions."
|
7079
7116
|
);
|
@@ -7170,7 +7207,7 @@ var Account = class extends AbstractAccount {
|
|
7170
7207
|
/** @hidden * */
|
7171
7208
|
validateTransferAmount(amount) {
|
7172
7209
|
if (bn20(amount).lte(0)) {
|
7173
|
-
throw new
|
7210
|
+
throw new FuelError22(
|
7174
7211
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7175
7212
|
"Transfer amount must be a positive number."
|
7176
7213
|
);
|
@@ -7200,7 +7237,7 @@ var Account = class extends AbstractAccount {
|
|
7200
7237
|
if (!isDefined3(setGasLimit)) {
|
7201
7238
|
request.gasLimit = gasUsed;
|
7202
7239
|
} else if (gasUsed.gt(setGasLimit)) {
|
7203
|
-
throw new
|
7240
|
+
throw new FuelError22(
|
7204
7241
|
ErrorCode18.GAS_LIMIT_TOO_LOW,
|
7205
7242
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7206
7243
|
);
|
@@ -7208,7 +7245,7 @@ var Account = class extends AbstractAccount {
|
|
7208
7245
|
if (!isDefined3(setMaxFee)) {
|
7209
7246
|
request.maxFee = maxFee;
|
7210
7247
|
} else if (maxFee.gt(setMaxFee)) {
|
7211
|
-
throw new
|
7248
|
+
throw new FuelError22(
|
7212
7249
|
ErrorCode18.MAX_FEE_TOO_LOW,
|
7213
7250
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
7214
7251
|
);
|
@@ -7229,7 +7266,7 @@ import {
|
|
7229
7266
|
encryptJsonWalletData,
|
7230
7267
|
randomUUID as randomUUID2
|
7231
7268
|
} from "@fuel-ts/crypto";
|
7232
|
-
import { ErrorCode as ErrorCode19, FuelError as
|
7269
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError23 } from "@fuel-ts/errors";
|
7233
7270
|
import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
7234
7271
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7235
7272
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -7306,7 +7343,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7306
7343
|
const macHashUint8Array = keccak256(data);
|
7307
7344
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
7308
7345
|
if (mac !== macHash) {
|
7309
|
-
throw new
|
7346
|
+
throw new FuelError23(
|
7310
7347
|
ErrorCode19.INVALID_PASSWORD,
|
7311
7348
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
7312
7349
|
);
|
@@ -7442,14 +7479,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
7442
7479
|
|
7443
7480
|
// src/hdwallet/hdwallet.ts
|
7444
7481
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
7445
|
-
import { ErrorCode as ErrorCode22, FuelError as
|
7482
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError26 } from "@fuel-ts/errors";
|
7446
7483
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
7447
7484
|
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
7448
7485
|
import { arrayify as arrayify20, hexlify as hexlify24, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
7449
7486
|
|
7450
7487
|
// src/mnemonic/mnemonic.ts
|
7451
7488
|
import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
7452
|
-
import { ErrorCode as ErrorCode21, FuelError as
|
7489
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError25 } from "@fuel-ts/errors";
|
7453
7490
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
7454
7491
|
import { arrayify as arrayify19, hexlify as hexlify23, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
7455
7492
|
|
@@ -9506,7 +9543,7 @@ var english = [
|
|
9506
9543
|
];
|
9507
9544
|
|
9508
9545
|
// src/mnemonic/utils.ts
|
9509
|
-
import { ErrorCode as ErrorCode20, FuelError as
|
9546
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9510
9547
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
9511
9548
|
import { arrayify as arrayify18 } from "@fuel-ts/utils";
|
9512
9549
|
function getLowerMask(bits) {
|
@@ -9555,7 +9592,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9555
9592
|
for (let i = 0; i < words.length; i += 1) {
|
9556
9593
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9557
9594
|
if (index === -1) {
|
9558
|
-
throw new
|
9595
|
+
throw new FuelError24(
|
9559
9596
|
ErrorCode20.INVALID_MNEMONIC,
|
9560
9597
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9561
9598
|
);
|
@@ -9572,7 +9609,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9572
9609
|
const checksumMask = getUpperMask(checksumBits);
|
9573
9610
|
const checksum = arrayify18(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9574
9611
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9575
|
-
throw new
|
9612
|
+
throw new FuelError24(
|
9576
9613
|
ErrorCode20.INVALID_CHECKSUM,
|
9577
9614
|
"Checksum validation failed for the provided mnemonic."
|
9578
9615
|
);
|
@@ -9587,7 +9624,7 @@ var TestnetPRV = "0x04358394";
|
|
9587
9624
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9588
9625
|
function assertWordList(wordlist) {
|
9589
9626
|
if (wordlist.length !== 2048) {
|
9590
|
-
throw new
|
9627
|
+
throw new FuelError25(
|
9591
9628
|
ErrorCode21.INVALID_WORD_LIST,
|
9592
9629
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9593
9630
|
);
|
@@ -9595,7 +9632,7 @@ function assertWordList(wordlist) {
|
|
9595
9632
|
}
|
9596
9633
|
function assertEntropy(entropy) {
|
9597
9634
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9598
|
-
throw new
|
9635
|
+
throw new FuelError25(
|
9599
9636
|
ErrorCode21.INVALID_ENTROPY,
|
9600
9637
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9601
9638
|
);
|
@@ -9606,7 +9643,7 @@ function assertMnemonic(words) {
|
|
9606
9643
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9607
9644
|
", "
|
9608
9645
|
)}] words, but got ${words.length}.`;
|
9609
|
-
throw new
|
9646
|
+
throw new FuelError25(ErrorCode21.INVALID_MNEMONIC, errorMsg);
|
9610
9647
|
}
|
9611
9648
|
}
|
9612
9649
|
var Mnemonic = class {
|
@@ -9724,7 +9761,7 @@ var Mnemonic = class {
|
|
9724
9761
|
static masterKeysFromSeed(seed) {
|
9725
9762
|
const seedArray = arrayify19(seed);
|
9726
9763
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9727
|
-
throw new
|
9764
|
+
throw new FuelError25(
|
9728
9765
|
ErrorCode21.INVALID_SEED,
|
9729
9766
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9730
9767
|
);
|
@@ -9802,7 +9839,7 @@ function isValidExtendedKey(extendedKey) {
|
|
9802
9839
|
function parsePath(path2, depth = 0) {
|
9803
9840
|
const components = path2.split("/");
|
9804
9841
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9805
|
-
throw new
|
9842
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9806
9843
|
}
|
9807
9844
|
if (components[0] === "m") {
|
9808
9845
|
components.shift();
|
@@ -9831,7 +9868,7 @@ var HDWallet = class {
|
|
9831
9868
|
this.privateKey = hexlify24(config.privateKey);
|
9832
9869
|
} else {
|
9833
9870
|
if (!config.publicKey) {
|
9834
|
-
throw new
|
9871
|
+
throw new FuelError26(
|
9835
9872
|
ErrorCode22.HD_WALLET_ERROR,
|
9836
9873
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9837
9874
|
);
|
@@ -9861,7 +9898,7 @@ var HDWallet = class {
|
|
9861
9898
|
const data = new Uint8Array(37);
|
9862
9899
|
if (index & HARDENED_INDEX) {
|
9863
9900
|
if (!privateKey) {
|
9864
|
-
throw new
|
9901
|
+
throw new FuelError26(
|
9865
9902
|
ErrorCode22.HD_WALLET_ERROR,
|
9866
9903
|
"Cannot derive a hardened index without a private Key."
|
9867
9904
|
);
|
@@ -9914,7 +9951,7 @@ var HDWallet = class {
|
|
9914
9951
|
*/
|
9915
9952
|
toExtendedKey(isPublic = false, testnet = false) {
|
9916
9953
|
if (this.depth >= 256) {
|
9917
|
-
throw new
|
9954
|
+
throw new FuelError26(
|
9918
9955
|
ErrorCode22.HD_WALLET_ERROR,
|
9919
9956
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9920
9957
|
);
|
@@ -9946,10 +9983,10 @@ var HDWallet = class {
|
|
9946
9983
|
const bytes = arrayify20(decoded);
|
9947
9984
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9948
9985
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9949
|
-
throw new
|
9986
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9950
9987
|
}
|
9951
9988
|
if (!validChecksum) {
|
9952
|
-
throw new
|
9989
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9953
9990
|
}
|
9954
9991
|
const depth = bytes[4];
|
9955
9992
|
const parentFingerprint = hexlify24(bytes.slice(5, 9));
|
@@ -9957,14 +9994,14 @@ var HDWallet = class {
|
|
9957
9994
|
const chainCode = hexlify24(bytes.slice(13, 45));
|
9958
9995
|
const key = bytes.slice(45, 78);
|
9959
9996
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9960
|
-
throw new
|
9997
|
+
throw new FuelError26(
|
9961
9998
|
ErrorCode22.HD_WALLET_ERROR,
|
9962
9999
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9963
10000
|
);
|
9964
10001
|
}
|
9965
10002
|
if (isPublicExtendedKey(bytes)) {
|
9966
10003
|
if (key[0] !== 3) {
|
9967
|
-
throw new
|
10004
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Invalid public extended key.");
|
9968
10005
|
}
|
9969
10006
|
return new HDWallet({
|
9970
10007
|
publicKey: key,
|
@@ -9975,7 +10012,7 @@ var HDWallet = class {
|
|
9975
10012
|
});
|
9976
10013
|
}
|
9977
10014
|
if (key[0] !== 0) {
|
9978
|
-
throw new
|
10015
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Invalid private extended key.");
|
9979
10016
|
}
|
9980
10017
|
return new HDWallet({
|
9981
10018
|
privateKey: key.slice(1),
|
@@ -10219,26 +10256,26 @@ var WalletsConfig = class {
|
|
10219
10256
|
amountPerCoin
|
10220
10257
|
}) {
|
10221
10258
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
10222
|
-
throw new
|
10223
|
-
|
10259
|
+
throw new FuelError27(
|
10260
|
+
FuelError27.CODES.INVALID_INPUT_PARAMETERS,
|
10224
10261
|
"Number of wallets must be greater than zero."
|
10225
10262
|
);
|
10226
10263
|
}
|
10227
10264
|
if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
|
10228
|
-
throw new
|
10229
|
-
|
10265
|
+
throw new FuelError27(
|
10266
|
+
FuelError27.CODES.INVALID_INPUT_PARAMETERS,
|
10230
10267
|
"Number of assets per wallet must be greater than zero."
|
10231
10268
|
);
|
10232
10269
|
}
|
10233
10270
|
if (coinsPerAsset <= 0) {
|
10234
|
-
throw new
|
10235
|
-
|
10271
|
+
throw new FuelError27(
|
10272
|
+
FuelError27.CODES.INVALID_INPUT_PARAMETERS,
|
10236
10273
|
"Number of coins per asset must be greater than zero."
|
10237
10274
|
);
|
10238
10275
|
}
|
10239
10276
|
if (bn22(amountPerCoin).lt(0)) {
|
10240
|
-
throw new
|
10241
|
-
|
10277
|
+
throw new FuelError27(
|
10278
|
+
FuelError27.CODES.INVALID_INPUT_PARAMETERS,
|
10242
10279
|
"Amount per coin must be greater than or equal to zero."
|
10243
10280
|
);
|
10244
10281
|
}
|