@fuel-ts/account 0.100.2 → 0.100.3
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 +128 -80
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +331 -278
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -213
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-response/getAllDecodedLogs.d.ts +30 -0
- package/dist/providers/transaction-response/getAllDecodedLogs.d.ts.map +1 -0
- package/dist/providers/transaction-response/getDecodedLogs.d.ts +20 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
- package/dist/providers/transaction-response/index.d.ts +1 -0
- package/dist/providers/transaction-response/index.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +3 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +4 -3
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/test-utils.global.js +83 -71
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +232 -216
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +179 -163
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +14 -14
package/dist/test-utils.mjs
CHANGED
@@ -404,7 +404,7 @@ var addAmountToCoinQuantities = /* @__PURE__ */ __name((params) => {
|
|
404
404
|
|
405
405
|
// src/providers/provider.ts
|
406
406
|
import { Address as Address3, isB256 } from "@fuel-ts/address";
|
407
|
-
import { ErrorCode as ErrorCode16, FuelError as
|
407
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
|
408
408
|
import { bn as bn17 } from "@fuel-ts/math";
|
409
409
|
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
410
410
|
import { arrayify as arrayify13, hexlify as hexlify18, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
@@ -413,18 +413,6 @@ import { GraphQLClient } from "graphql-request";
|
|
413
413
|
import gql2 from "graphql-tag";
|
414
414
|
import { clone as clone8 } from "ramda";
|
415
415
|
|
416
|
-
// src/connectors/utils/promises.ts
|
417
|
-
import { FuelError as FuelError2 } from "@fuel-ts/errors";
|
418
|
-
function deferPromise() {
|
419
|
-
const defer = {};
|
420
|
-
defer.promise = new Promise((resolve, reject) => {
|
421
|
-
defer.reject = reject;
|
422
|
-
defer.resolve = resolve;
|
423
|
-
});
|
424
|
-
return defer;
|
425
|
-
}
|
426
|
-
__name(deferPromise, "deferPromise");
|
427
|
-
|
428
416
|
// src/providers/__generated__/operations.ts
|
429
417
|
import gql from "graphql-tag";
|
430
418
|
var SubmittedStatusFragmentDoc = gql`
|
@@ -1483,14 +1471,14 @@ function getSdk(requester) {
|
|
1483
1471
|
__name(getSdk, "getSdk");
|
1484
1472
|
|
1485
1473
|
// src/providers/fuel-graphql-subscriber.ts
|
1486
|
-
import { ErrorCode as ErrorCode2, FuelError as
|
1474
|
+
import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1487
1475
|
import { print } from "graphql";
|
1488
1476
|
|
1489
1477
|
// src/providers/utils/handle-gql-error-message.ts
|
1490
|
-
import { ErrorCode, FuelError as
|
1478
|
+
import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
|
1491
1479
|
var mapGqlErrorMessage = /* @__PURE__ */ __name((error) => {
|
1492
1480
|
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)) {
|
1493
|
-
return new
|
1481
|
+
return new FuelError2(
|
1494
1482
|
ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
1495
1483
|
`Insufficient funds or too many small value coins. Consider combining UTXOs.`,
|
1496
1484
|
{},
|
@@ -1498,20 +1486,20 @@ var mapGqlErrorMessage = /* @__PURE__ */ __name((error) => {
|
|
1498
1486
|
);
|
1499
1487
|
}
|
1500
1488
|
if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
|
1501
|
-
return new
|
1489
|
+
return new FuelError2(
|
1502
1490
|
ErrorCode.ASSET_NOT_FOUND,
|
1503
1491
|
`Asset not found for given asset id.`,
|
1504
1492
|
{},
|
1505
1493
|
error
|
1506
1494
|
);
|
1507
1495
|
}
|
1508
|
-
return new
|
1496
|
+
return new FuelError2(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1509
1497
|
}, "mapGqlErrorMessage");
|
1510
1498
|
var mapGqlErrorWithIncompatibleNodeVersion = /* @__PURE__ */ __name((error, incompatibleNodeVersionMessage) => {
|
1511
1499
|
if (!incompatibleNodeVersionMessage) {
|
1512
1500
|
return error;
|
1513
1501
|
}
|
1514
|
-
return new
|
1502
|
+
return new FuelError2(
|
1515
1503
|
error.code,
|
1516
1504
|
`${error.message}
|
1517
1505
|
|
@@ -1530,7 +1518,7 @@ var assertGqlResponseHasNoErrors = /* @__PURE__ */ __name((errors, incompatibleN
|
|
1530
1518
|
}
|
1531
1519
|
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
1532
1520
|
throw mapGqlErrorWithIncompatibleNodeVersion(
|
1533
|
-
new
|
1521
|
+
new FuelError2(ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1534
1522
|
incompatibleNodeVersionMessage
|
1535
1523
|
);
|
1536
1524
|
}, "assertGqlResponseHasNoErrors");
|
@@ -1586,7 +1574,7 @@ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
|
1586
1574
|
try {
|
1587
1575
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1588
1576
|
} catch (e) {
|
1589
|
-
throw new
|
1577
|
+
throw new FuelError3(
|
1590
1578
|
ErrorCode2.STREAM_PARSING_ERROR,
|
1591
1579
|
`Error while parsing stream data response: ${text}`
|
1592
1580
|
);
|
@@ -1607,13 +1595,13 @@ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
|
1607
1595
|
};
|
1608
1596
|
|
1609
1597
|
// src/providers/resource-cache.ts
|
1610
|
-
import { FuelError as
|
1598
|
+
import { FuelError as FuelError13, ErrorCode as ErrorCode10 } from "@fuel-ts/errors";
|
1611
1599
|
import { hexlify as hexlify16 } from "@fuel-ts/utils";
|
1612
1600
|
|
1613
1601
|
// src/providers/transaction-request/input.ts
|
1614
1602
|
import { BYTES_32 as BYTES_322, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
|
1615
1603
|
import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
1616
|
-
import { ErrorCode as ErrorCode3, FuelError as
|
1604
|
+
import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1617
1605
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1618
1606
|
import { InputType } from "@fuel-ts/transactions";
|
1619
1607
|
import { arrayify as arrayify2, hexlify as hexlify4 } from "@fuel-ts/utils";
|
@@ -1677,7 +1665,7 @@ var inputify = /* @__PURE__ */ __name((value) => {
|
|
1677
1665
|
};
|
1678
1666
|
}
|
1679
1667
|
default: {
|
1680
|
-
throw new
|
1668
|
+
throw new FuelError4(
|
1681
1669
|
ErrorCode3.INVALID_TRANSACTION_INPUT,
|
1682
1670
|
`Invalid transaction input type: ${type}.`
|
1683
1671
|
);
|
@@ -1687,7 +1675,7 @@ var inputify = /* @__PURE__ */ __name((value) => {
|
|
1687
1675
|
|
1688
1676
|
// src/providers/transaction-request/output.ts
|
1689
1677
|
import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
1690
|
-
import { ErrorCode as ErrorCode4, FuelError as
|
1678
|
+
import { ErrorCode as ErrorCode4, FuelError as FuelError5 } from "@fuel-ts/errors";
|
1691
1679
|
import { bn as bn3 } from "@fuel-ts/math";
|
1692
1680
|
import { OutputType } from "@fuel-ts/transactions";
|
1693
1681
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1734,7 +1722,7 @@ var outputify = /* @__PURE__ */ __name((value) => {
|
|
1734
1722
|
};
|
1735
1723
|
}
|
1736
1724
|
default: {
|
1737
|
-
throw new
|
1725
|
+
throw new FuelError5(
|
1738
1726
|
ErrorCode4.INVALID_TRANSACTION_INPUT,
|
1739
1727
|
`Invalid transaction output type: ${type}.`
|
1740
1728
|
);
|
@@ -1747,7 +1735,7 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1747
1735
|
import { Address as Address2, addressify } from "@fuel-ts/address";
|
1748
1736
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1749
1737
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
1750
|
-
import { FuelError as
|
1738
|
+
import { FuelError as FuelError10 } from "@fuel-ts/errors";
|
1751
1739
|
import { bn as bn8 } from "@fuel-ts/math";
|
1752
1740
|
import {
|
1753
1741
|
PolicyType,
|
@@ -1770,7 +1758,7 @@ import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs
|
|
1770
1758
|
|
1771
1759
|
// src/providers/utils/serialization.ts
|
1772
1760
|
import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
|
1773
|
-
import { ErrorCode as ErrorCode5, FuelError as
|
1761
|
+
import { ErrorCode as ErrorCode5, FuelError as FuelError6 } from "@fuel-ts/errors";
|
1774
1762
|
import { bn as bn4 } from "@fuel-ts/math";
|
1775
1763
|
import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
|
1776
1764
|
import { hexlify as hexlify6, arrayify as arrayify3 } from "@fuel-ts/utils";
|
@@ -2107,7 +2095,7 @@ var deserializeReceipt = /* @__PURE__ */ __name((receipt) => {
|
|
2107
2095
|
return burnReceipt;
|
2108
2096
|
}
|
2109
2097
|
default:
|
2110
|
-
throw new
|
2098
|
+
throw new FuelError6(ErrorCode5.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
2111
2099
|
}
|
2112
2100
|
}, "deserializeReceipt");
|
2113
2101
|
|
@@ -2131,7 +2119,7 @@ var getReceiptsWithMissingData = /* @__PURE__ */ __name((receipts) => receipts.r
|
|
2131
2119
|
), "getReceiptsWithMissingData");
|
2132
2120
|
|
2133
2121
|
// src/providers/utils/block-explorer.ts
|
2134
|
-
import { ErrorCode as ErrorCode6, FuelError as
|
2122
|
+
import { ErrorCode as ErrorCode6, FuelError as FuelError7 } from "@fuel-ts/errors";
|
2135
2123
|
|
2136
2124
|
// src/providers/utils/gas.ts
|
2137
2125
|
import { bn as bn5 } from "@fuel-ts/math";
|
@@ -2315,7 +2303,7 @@ function normalizeJSON(root) {
|
|
2315
2303
|
__name(normalizeJSON, "normalizeJSON");
|
2316
2304
|
|
2317
2305
|
// src/providers/utils/extract-tx-error.ts
|
2318
|
-
import { ErrorCode as ErrorCode7, FuelError as
|
2306
|
+
import { ErrorCode as ErrorCode7, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2319
2307
|
import { bn as bn6 } from "@fuel-ts/math";
|
2320
2308
|
import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
|
2321
2309
|
import {
|
@@ -2336,7 +2324,7 @@ You can read more about this error at:
|
|
2336
2324
|
|
2337
2325
|
${PANIC_DOC_URL}#variant.${statusReason}`;
|
2338
2326
|
}
|
2339
|
-
return new
|
2327
|
+
return new FuelError8(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2340
2328
|
...metadata,
|
2341
2329
|
reason: statusReason
|
2342
2330
|
});
|
@@ -2377,7 +2365,7 @@ var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
|
|
2377
2365
|
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2378
2366
|
break;
|
2379
2367
|
default:
|
2380
|
-
throw new
|
2368
|
+
throw new FuelError8(
|
2381
2369
|
ErrorCode7.UNKNOWN,
|
2382
2370
|
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2383
2371
|
{
|
@@ -2387,17 +2375,18 @@ var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
|
|
2387
2375
|
);
|
2388
2376
|
}
|
2389
2377
|
}
|
2390
|
-
return new
|
2378
|
+
return new FuelError8(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2391
2379
|
...metadata,
|
2392
2380
|
reason
|
2393
2381
|
});
|
2394
2382
|
}, "assembleRevertError");
|
2395
2383
|
var extractTxError = /* @__PURE__ */ __name((params) => {
|
2396
|
-
const { receipts, statusReason, logs } = params;
|
2384
|
+
const { receipts, statusReason, logs, groupedLogs } = params;
|
2397
2385
|
const isPanic = receipts.some(({ type }) => type === ReceiptType4.Panic);
|
2398
2386
|
const isRevert = receipts.some(({ type }) => type === ReceiptType4.Revert);
|
2399
2387
|
const metadata = {
|
2400
2388
|
logs,
|
2389
|
+
groupedLogs,
|
2401
2390
|
receipts,
|
2402
2391
|
panic: isPanic,
|
2403
2392
|
revert: isRevert,
|
@@ -2423,7 +2412,7 @@ var NoWitnessAtIndexError = class extends Error {
|
|
2423
2412
|
};
|
2424
2413
|
|
2425
2414
|
// src/providers/transaction-request/helpers.ts
|
2426
|
-
import { ErrorCode as ErrorCode8, FuelError as
|
2415
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2427
2416
|
import { bn as bn7 } from "@fuel-ts/math";
|
2428
2417
|
import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
|
2429
2418
|
import { hexlify as hexlify8 } from "@fuel-ts/utils";
|
@@ -2482,7 +2471,7 @@ var validateTransactionForAssetBurn = /* @__PURE__ */ __name((baseAssetId, trans
|
|
2482
2471
|
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
2483
2472
|
"Or enable asset burn, upon sending the transaction."
|
2484
2473
|
].join("\n");
|
2485
|
-
throw new
|
2474
|
+
throw new FuelError9(ErrorCode8.ASSET_BURN_DETECTED, message);
|
2486
2475
|
}, "validateTransactionForAssetBurn");
|
2487
2476
|
|
2488
2477
|
// src/providers/transaction-request/witness.ts
|
@@ -2883,7 +2872,7 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
|
|
2883
2872
|
* @hidden
|
2884
2873
|
*/
|
2885
2874
|
metadataGas(_gasCosts) {
|
2886
|
-
throw new
|
2875
|
+
throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Not implemented");
|
2887
2876
|
}
|
2888
2877
|
/**
|
2889
2878
|
* @hidden
|
@@ -3522,7 +3511,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3522
3511
|
};
|
3523
3512
|
|
3524
3513
|
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3525
|
-
import { FuelError as
|
3514
|
+
import { FuelError as FuelError11 } from "@fuel-ts/errors";
|
3526
3515
|
import { hash as hash2 } from "@fuel-ts/hasher";
|
3527
3516
|
import {
|
3528
3517
|
TransactionType as TransactionType5,
|
@@ -3632,7 +3621,7 @@ var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTra
|
|
3632
3621
|
}
|
3633
3622
|
};
|
3634
3623
|
} else {
|
3635
|
-
throw new
|
3624
|
+
throw new FuelError11(FuelError11.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3636
3625
|
}
|
3637
3626
|
return {
|
3638
3627
|
type: TransactionType5.Upgrade,
|
@@ -3674,7 +3663,7 @@ var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTra
|
|
3674
3663
|
txBytesSize
|
3675
3664
|
});
|
3676
3665
|
}
|
3677
|
-
throw new
|
3666
|
+
throw new FuelError11(FuelError11.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3678
3667
|
}
|
3679
3668
|
};
|
3680
3669
|
|
@@ -3788,7 +3777,7 @@ var UploadTransactionRequest = class _UploadTransactionRequest extends BaseTrans
|
|
3788
3777
|
};
|
3789
3778
|
|
3790
3779
|
// src/providers/transaction-request/utils.ts
|
3791
|
-
import { ErrorCode as ErrorCode9, FuelError as
|
3780
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError12 } from "@fuel-ts/errors";
|
3792
3781
|
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
3793
3782
|
var transactionRequestify = /* @__PURE__ */ __name((obj) => {
|
3794
3783
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
@@ -3812,7 +3801,7 @@ var transactionRequestify = /* @__PURE__ */ __name((obj) => {
|
|
3812
3801
|
return UploadTransactionRequest.from(obj);
|
3813
3802
|
}
|
3814
3803
|
default: {
|
3815
|
-
throw new
|
3804
|
+
throw new FuelError12(
|
3816
3805
|
ErrorCode9.UNSUPPORTED_TRANSACTION_TYPE,
|
3817
3806
|
`Unsupported transaction type: ${type}.`
|
3818
3807
|
);
|
@@ -3832,7 +3821,7 @@ var ResourceCache = class {
|
|
3832
3821
|
constructor(ttl) {
|
3833
3822
|
this.ttl = ttl;
|
3834
3823
|
if (typeof ttl !== "number" || this.ttl <= 0) {
|
3835
|
-
throw new
|
3824
|
+
throw new FuelError13(
|
3836
3825
|
ErrorCode10.INVALID_TTL,
|
3837
3826
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
3838
3827
|
);
|
@@ -3917,7 +3906,7 @@ var ResourceCache = class {
|
|
3917
3906
|
};
|
3918
3907
|
|
3919
3908
|
// src/providers/transaction-response/transaction-response.ts
|
3920
|
-
import { ErrorCode as ErrorCode14, FuelError as
|
3909
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError17 } from "@fuel-ts/errors";
|
3921
3910
|
import { bn as bn16 } from "@fuel-ts/math";
|
3922
3911
|
import { OutputType as OutputType8, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
3923
3912
|
import { arrayify as arrayify12, assertUnreachable } from "@fuel-ts/utils";
|
@@ -3995,12 +3984,12 @@ var calculateTXFeeForSummary = /* @__PURE__ */ __name((params) => {
|
|
3995
3984
|
|
3996
3985
|
// src/providers/transaction-summary/operations.ts
|
3997
3986
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
3998
|
-
import { ErrorCode as ErrorCode12, FuelError as
|
3987
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError15 } from "@fuel-ts/errors";
|
3999
3988
|
import { bn as bn13 } from "@fuel-ts/math";
|
4000
3989
|
import { ReceiptType as ReceiptType5, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
4001
3990
|
|
4002
3991
|
// src/providers/transaction-summary/input.ts
|
4003
|
-
import { ErrorCode as ErrorCode11, FuelError as
|
3992
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4004
3993
|
import { BN } from "@fuel-ts/math";
|
4005
3994
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
4006
3995
|
function getInputsByTypes(inputs, types) {
|
@@ -4080,7 +4069,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
4080
4069
|
return void 0;
|
4081
4070
|
}
|
4082
4071
|
if (contractInput.type !== InputType6.Contract) {
|
4083
|
-
throw new
|
4072
|
+
throw new FuelError14(
|
4084
4073
|
ErrorCode11.INVALID_TRANSACTION_INPUT,
|
4085
4074
|
`Contract input should be of type 'contract'.`
|
4086
4075
|
);
|
@@ -4142,7 +4131,7 @@ function getTransactionTypeName(transactionType) {
|
|
4142
4131
|
case TransactionType9.Upload:
|
4143
4132
|
return "Upload" /* Upload */;
|
4144
4133
|
default:
|
4145
|
-
throw new
|
4134
|
+
throw new FuelError15(
|
4146
4135
|
ErrorCode12.UNSUPPORTED_TRANSACTION_TYPE,
|
4147
4136
|
`Unsupported transaction type: ${transactionType}.`
|
4148
4137
|
);
|
@@ -4548,7 +4537,7 @@ var extractBurnedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
|
4548
4537
|
}, "extractBurnedAssetsFromReceipts");
|
4549
4538
|
|
4550
4539
|
// src/providers/transaction-summary/status.ts
|
4551
|
-
import { ErrorCode as ErrorCode13, FuelError as
|
4540
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
|
4552
4541
|
import { bn as bn14 } from "@fuel-ts/math";
|
4553
4542
|
var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
|
4554
4543
|
switch (gqlStatus) {
|
@@ -4561,7 +4550,7 @@ var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
|
|
4561
4550
|
case "SqueezedOutStatus":
|
4562
4551
|
return "squeezedout" /* squeezedout */;
|
4563
4552
|
default:
|
4564
|
-
throw new
|
4553
|
+
throw new FuelError16(
|
4565
4554
|
ErrorCode13.INVALID_TRANSACTION_STATUS,
|
4566
4555
|
`Invalid transaction status: ${gqlStatus}.`
|
4567
4556
|
);
|
@@ -4694,11 +4683,12 @@ function assembleTransactionSummary(params) {
|
|
4694
4683
|
}
|
4695
4684
|
__name(assembleTransactionSummary, "assembleTransactionSummary");
|
4696
4685
|
|
4697
|
-
// src/providers/transaction-response/
|
4686
|
+
// src/providers/transaction-response/getAllDecodedLogs.ts
|
4698
4687
|
import { Interface as Interface2, BigNumberCoder } from "@fuel-ts/abi-coder";
|
4699
4688
|
import { ZeroBytes32 as ZeroBytes3210 } from "@fuel-ts/address/configs";
|
4700
4689
|
import { ReceiptType as ReceiptType7 } from "@fuel-ts/transactions";
|
4701
|
-
function
|
4690
|
+
function getAllDecodedLogs(opts) {
|
4691
|
+
const { receipts, mainAbi, externalAbis = {} } = opts;
|
4702
4692
|
let mainContract = "";
|
4703
4693
|
if (mainAbi.programType === "contract") {
|
4704
4694
|
const firstCallReceipt = receipts.find(
|
@@ -4706,21 +4696,25 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
4706
4696
|
);
|
4707
4697
|
mainContract = firstCallReceipt.to;
|
4708
4698
|
}
|
4709
|
-
return receipts.reduce(
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
|
4699
|
+
return receipts.reduce(
|
4700
|
+
({ logs, groupedLogs }, receipt) => {
|
4701
|
+
if (receipt.type === ReceiptType7.LogData || receipt.type === ReceiptType7.Log) {
|
4702
|
+
const isLogFromMainAbi = receipt.id === ZeroBytes3210 || mainContract === receipt.id;
|
4703
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
4704
|
+
if (isDecodable) {
|
4705
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface2(mainAbi) : new Interface2(externalAbis[receipt.id]);
|
4706
|
+
const data = receipt.type === ReceiptType7.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
4707
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
4708
|
+
logs.push(decodedLog);
|
4709
|
+
groupedLogs[receipt.id] = [...groupedLogs[receipt.id] || [], decodedLog];
|
4710
|
+
}
|
4718
4711
|
}
|
4719
|
-
|
4720
|
-
|
4721
|
-
|
4712
|
+
return { logs, groupedLogs };
|
4713
|
+
},
|
4714
|
+
{ logs: [], groupedLogs: {} }
|
4715
|
+
);
|
4722
4716
|
}
|
4723
|
-
__name(
|
4717
|
+
__name(getAllDecodedLogs, "getAllDecodedLogs");
|
4724
4718
|
|
4725
4719
|
// src/providers/transaction-response/transaction-response.ts
|
4726
4720
|
function mapGqlOutputsToTxOutputs(outputs) {
|
@@ -4925,7 +4919,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
4925
4919
|
this.status = statusChange;
|
4926
4920
|
if (statusChange.type === "SqueezedOutStatus") {
|
4927
4921
|
this.unsetResourceCache();
|
4928
|
-
throw new
|
4922
|
+
throw new FuelError17(
|
4929
4923
|
ErrorCode14.TRANSACTION_SQUEEZED_OUT,
|
4930
4924
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4931
4925
|
);
|
@@ -4952,14 +4946,15 @@ var TransactionResponse = class _TransactionResponse {
|
|
4952
4946
|
const transactionResult = {
|
4953
4947
|
...transactionSummary
|
4954
4948
|
};
|
4955
|
-
let logs = [];
|
4949
|
+
let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
|
4956
4950
|
if (this.abis) {
|
4957
|
-
logs =
|
4958
|
-
transactionSummary.receipts,
|
4959
|
-
this.abis.main,
|
4960
|
-
this.abis.otherContractsAbis
|
4961
|
-
);
|
4951
|
+
({ logs, groupedLogs } = getAllDecodedLogs({
|
4952
|
+
receipts: transactionSummary.receipts,
|
4953
|
+
mainAbi: this.abis.main,
|
4954
|
+
externalAbis: this.abis.otherContractsAbis
|
4955
|
+
}));
|
4962
4956
|
transactionResult.logs = logs;
|
4957
|
+
transactionResult.groupedLogs = groupedLogs;
|
4963
4958
|
}
|
4964
4959
|
const { receipts } = transactionResult;
|
4965
4960
|
const status = this.status ?? this.gqlTransaction?.status;
|
@@ -4968,7 +4963,8 @@ var TransactionResponse = class _TransactionResponse {
|
|
4968
4963
|
throw extractTxError({
|
4969
4964
|
receipts,
|
4970
4965
|
statusReason: reason,
|
4971
|
-
logs
|
4966
|
+
logs,
|
4967
|
+
groupedLogs
|
4972
4968
|
});
|
4973
4969
|
}
|
4974
4970
|
return transactionResult;
|
@@ -4996,6 +4992,11 @@ var TransactionResponse = class _TransactionResponse {
|
|
4996
4992
|
}
|
4997
4993
|
};
|
4998
4994
|
|
4995
|
+
// src/providers/transaction-response/getDecodedLogs.ts
|
4996
|
+
import { Interface as Interface3, BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
4997
|
+
import { ZeroBytes32 as ZeroBytes3211 } from "@fuel-ts/address/configs";
|
4998
|
+
import { ReceiptType as ReceiptType8 } from "@fuel-ts/transactions";
|
4999
|
+
|
4999
5000
|
// src/providers/utils/auto-retry-fetch.ts
|
5000
5001
|
import { sleep } from "@fuel-ts/utils";
|
5001
5002
|
function getWaitDelay(options, retryAttemptNum) {
|
@@ -5052,30 +5053,30 @@ var adjustResourcesToExclude = /* @__PURE__ */ __name((params) => {
|
|
5052
5053
|
}, "adjustResourcesToExclude");
|
5053
5054
|
|
5054
5055
|
// src/providers/utils/validate-pagination-args.ts
|
5055
|
-
import { FuelError as
|
5056
|
+
import { FuelError as FuelError18, ErrorCode as ErrorCode15 } from "@fuel-ts/errors";
|
5056
5057
|
var validatePaginationArgs = /* @__PURE__ */ __name((params) => {
|
5057
5058
|
const { paginationLimit, inputArgs = {} } = params;
|
5058
5059
|
const { first, last, after, before } = inputArgs;
|
5059
5060
|
if (after && before) {
|
5060
|
-
throw new
|
5061
|
+
throw new FuelError18(
|
5061
5062
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5062
5063
|
'Pagination arguments "after" and "before" cannot be used together'
|
5063
5064
|
);
|
5064
5065
|
}
|
5065
5066
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5066
|
-
throw new
|
5067
|
+
throw new FuelError18(
|
5067
5068
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5068
5069
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5069
5070
|
);
|
5070
5071
|
}
|
5071
5072
|
if (first && before) {
|
5072
|
-
throw new
|
5073
|
+
throw new FuelError18(
|
5073
5074
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5074
5075
|
'The use of pagination argument "first" with "before" is not supported'
|
5075
5076
|
);
|
5076
5077
|
}
|
5077
5078
|
if (last && after) {
|
5078
|
-
throw new
|
5079
|
+
throw new FuelError18(
|
5079
5080
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5080
5081
|
'The use of pagination argument "last" with "after" is not supported'
|
5081
5082
|
);
|
@@ -5191,7 +5192,7 @@ var Provider = class _Provider {
|
|
5191
5192
|
try {
|
5192
5193
|
parsedUrl = new URL(url);
|
5193
5194
|
} catch (error) {
|
5194
|
-
throw new
|
5195
|
+
throw new FuelError19(FuelError19.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
5195
5196
|
}
|
5196
5197
|
const username = parsedUrl.username;
|
5197
5198
|
const password = parsedUrl.password;
|
@@ -5269,39 +5270,52 @@ var Provider = class _Provider {
|
|
5269
5270
|
* @returns A promise that resolves to the Chain and NodeInfo.
|
5270
5271
|
*/
|
5271
5272
|
async fetchChainAndNodeInfo(ignoreCache = false) {
|
5272
|
-
|
5273
|
-
|
5274
|
-
|
5275
|
-
|
5276
|
-
chain
|
5277
|
-
|
5278
|
-
|
5279
|
-
|
5280
|
-
|
5281
|
-
|
5282
|
-
|
5283
|
-
|
5284
|
-
|
5285
|
-
|
5286
|
-
|
5287
|
-
}
|
5288
|
-
const { promise, resolve } = deferPromise();
|
5289
|
-
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
|
5290
|
-
const data = await this.operations.getChainAndNodeInfo();
|
5291
|
-
nodeInfo = deserializeNodeInfo(data.nodeInfo);
|
5292
|
-
chain = deserializeChain(data.chain);
|
5293
|
-
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
5294
|
-
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
5295
|
-
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
5296
|
-
const now = Date.now();
|
5297
|
-
this.consensusParametersTimestamp = now;
|
5298
|
-
resolve(now);
|
5299
|
-
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5273
|
+
const nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
5274
|
+
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
5275
|
+
const hasCache = nodeInfo && chain;
|
5276
|
+
if (hasCache && !ignoreCache) {
|
5277
|
+
return { nodeInfo, chain };
|
5278
|
+
}
|
5279
|
+
const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5280
|
+
if (inflightRequest) {
|
5281
|
+
return inflightRequest.then((data) => {
|
5282
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
5283
|
+
return {
|
5284
|
+
nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
|
5285
|
+
chain: _Provider.chainInfoCache[this.urlWithoutAuth]
|
5286
|
+
};
|
5287
|
+
});
|
5300
5288
|
}
|
5301
|
-
|
5302
|
-
chain,
|
5303
|
-
nodeInfo
|
5304
|
-
|
5289
|
+
const getChainAndNodeInfoFromNetwork = this.operations.getChainAndNodeInfo().then((data) => ({
|
5290
|
+
chain: deserializeChain(data.chain),
|
5291
|
+
nodeInfo: deserializeNodeInfo(data.nodeInfo),
|
5292
|
+
consensusParametersTimestamp: Date.now()
|
5293
|
+
})).then((data) => {
|
5294
|
+
_Provider.setIncompatibleNodeVersionMessage(data.nodeInfo);
|
5295
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = data.chain;
|
5296
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = data.nodeInfo;
|
5297
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
5298
|
+
return data;
|
5299
|
+
}).catch((err) => {
|
5300
|
+
const error = new FuelError19(
|
5301
|
+
FuelError19.CODES.CONNECTION_REFUSED,
|
5302
|
+
"Unable to fetch chain and node info from the network",
|
5303
|
+
{ url: this.urlWithoutAuth },
|
5304
|
+
err
|
5305
|
+
);
|
5306
|
+
error.cause = { code: "ECONNREFUSED" };
|
5307
|
+
throw error;
|
5308
|
+
}).finally(() => {
|
5309
|
+
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5310
|
+
});
|
5311
|
+
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = getChainAndNodeInfoFromNetwork;
|
5312
|
+
return _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth].then((data) => {
|
5313
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
5314
|
+
return {
|
5315
|
+
nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
|
5316
|
+
chain: _Provider.chainInfoCache[this.urlWithoutAuth]
|
5317
|
+
};
|
5318
|
+
});
|
5305
5319
|
}
|
5306
5320
|
/**
|
5307
5321
|
* @hidden
|
@@ -5449,7 +5463,7 @@ var Provider = class _Provider {
|
|
5449
5463
|
async getAssetDetails(assetId) {
|
5450
5464
|
const { assetMetadata } = await this.getNodeFeatures();
|
5451
5465
|
if (!assetMetadata) {
|
5452
|
-
throw new
|
5466
|
+
throw new FuelError19(
|
5453
5467
|
ErrorCode16.UNSUPPORTED_FEATURE,
|
5454
5468
|
"The current node does not supports fetching asset details"
|
5455
5469
|
);
|
@@ -5481,13 +5495,13 @@ var Provider = class _Provider {
|
|
5481
5495
|
}
|
5482
5496
|
} = await this.getChain();
|
5483
5497
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
5484
|
-
throw new
|
5498
|
+
throw new FuelError19(
|
5485
5499
|
ErrorCode16.MAX_INPUTS_EXCEEDED,
|
5486
5500
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
5487
5501
|
);
|
5488
5502
|
}
|
5489
5503
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
5490
|
-
throw new
|
5504
|
+
throw new FuelError19(
|
5491
5505
|
ErrorCode16.MAX_OUTPUTS_EXCEEDED,
|
5492
5506
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
5493
5507
|
);
|
@@ -6190,7 +6204,7 @@ var Provider = class _Provider {
|
|
6190
6204
|
0
|
6191
6205
|
)?.[0];
|
6192
6206
|
} catch (error) {
|
6193
|
-
if (error instanceof
|
6207
|
+
if (error instanceof FuelError19 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
6194
6208
|
console.warn("Unsupported transaction type encountered");
|
6195
6209
|
return null;
|
6196
6210
|
}
|
@@ -6216,7 +6230,7 @@ var Provider = class _Provider {
|
|
6216
6230
|
try {
|
6217
6231
|
return coder.decode(arrayify13(rawPayload), 0)[0];
|
6218
6232
|
} catch (error) {
|
6219
|
-
if (error instanceof
|
6233
|
+
if (error instanceof FuelError19 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
6220
6234
|
console.warn("Unsupported transaction type encountered");
|
6221
6235
|
return null;
|
6222
6236
|
}
|
@@ -6365,7 +6379,7 @@ var Provider = class _Provider {
|
|
6365
6379
|
nonce
|
6366
6380
|
};
|
6367
6381
|
if (commitBlockId && commitBlockHeight) {
|
6368
|
-
throw new
|
6382
|
+
throw new FuelError19(
|
6369
6383
|
ErrorCode16.INVALID_INPUT_PARAMETERS,
|
6370
6384
|
"commitBlockId and commitBlockHeight cannot be used together"
|
6371
6385
|
);
|
@@ -6585,15 +6599,17 @@ var Provider = class _Provider {
|
|
6585
6599
|
extractDryRunError(transactionRequest, receipts, dryRunStatus) {
|
6586
6600
|
const status = dryRunStatus;
|
6587
6601
|
let logs = [];
|
6602
|
+
let groupedLogs = {};
|
6588
6603
|
if (transactionRequest.abis) {
|
6589
|
-
logs =
|
6604
|
+
({ logs, groupedLogs } = getAllDecodedLogs({
|
6590
6605
|
receipts,
|
6591
|
-
transactionRequest.abis.main,
|
6592
|
-
transactionRequest.abis.otherContractsAbis
|
6593
|
-
);
|
6606
|
+
mainAbi: transactionRequest.abis.main,
|
6607
|
+
externalAbis: transactionRequest.abis.otherContractsAbis
|
6608
|
+
}));
|
6594
6609
|
}
|
6595
6610
|
return extractTxError({
|
6596
6611
|
logs,
|
6612
|
+
groupedLogs,
|
6597
6613
|
receipts,
|
6598
6614
|
statusReason: status.reason
|
6599
6615
|
});
|
@@ -6625,7 +6641,7 @@ var Provider = class _Provider {
|
|
6625
6641
|
};
|
6626
6642
|
|
6627
6643
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6628
|
-
import { ErrorCode as ErrorCode17, FuelError as
|
6644
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
|
6629
6645
|
import { bn as bn18 } from "@fuel-ts/math";
|
6630
6646
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
6631
6647
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
@@ -6662,7 +6678,7 @@ var TestAssetId = class _TestAssetId {
|
|
6662
6678
|
|
6663
6679
|
// src/test-utils/wallet-config.ts
|
6664
6680
|
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
6665
|
-
import { FuelError as
|
6681
|
+
import { FuelError as FuelError26 } from "@fuel-ts/errors";
|
6666
6682
|
import { bn as bn22 } from "@fuel-ts/math";
|
6667
6683
|
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify25 } from "@fuel-ts/utils";
|
6668
6684
|
|
@@ -6674,7 +6690,7 @@ import { hexlify as hexlify22 } from "@fuel-ts/utils";
|
|
6674
6690
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
6675
6691
|
import { Address as Address5 } from "@fuel-ts/address";
|
6676
6692
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
6677
|
-
import { ErrorCode as ErrorCode18, FuelError as
|
6693
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
|
6678
6694
|
import { bn as bn20 } from "@fuel-ts/math";
|
6679
6695
|
import { InputType as InputType7 } from "@fuel-ts/transactions";
|
6680
6696
|
import { arrayify as arrayify17, hexlify as hexlify20, isDefined as isDefined3 } from "@fuel-ts/utils";
|
@@ -6703,12 +6719,12 @@ var AbstractAccount = class {
|
|
6703
6719
|
};
|
6704
6720
|
|
6705
6721
|
// src/utils/formatTransferToContractScriptData.ts
|
6706
|
-
import { ASSET_ID_LEN, BigNumberCoder as
|
6722
|
+
import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder3, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
|
6707
6723
|
import { Address as Address4 } from "@fuel-ts/address";
|
6708
6724
|
import { arrayify as arrayify16, concat as concat4 } from "@fuel-ts/utils";
|
6709
6725
|
import * as asm from "@fuels/vm-asm";
|
6710
6726
|
var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
|
6711
|
-
const numberCoder = new
|
6727
|
+
const numberCoder = new BigNumberCoder3("u64");
|
6712
6728
|
return transferParams.reduce((acc, transferParam) => {
|
6713
6729
|
const { assetId, amount, contractId } = transferParam;
|
6714
6730
|
const encoded = numberCoder.encode(amount);
|
@@ -6782,7 +6798,7 @@ var Account = class extends AbstractAccount {
|
|
6782
6798
|
*/
|
6783
6799
|
get provider() {
|
6784
6800
|
if (!this._provider) {
|
6785
|
-
throw new
|
6801
|
+
throw new FuelError21(ErrorCode18.MISSING_PROVIDER, "Provider not set");
|
6786
6802
|
}
|
6787
6803
|
return this._provider;
|
6788
6804
|
}
|
@@ -6941,7 +6957,7 @@ var Account = class extends AbstractAccount {
|
|
6941
6957
|
fundingAttempts += 1;
|
6942
6958
|
}
|
6943
6959
|
if (needsToBeFunded) {
|
6944
|
-
throw new
|
6960
|
+
throw new FuelError21(
|
6945
6961
|
ErrorCode18.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
6946
6962
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6947
6963
|
);
|
@@ -7061,7 +7077,7 @@ var Account = class extends AbstractAccount {
|
|
7061
7077
|
const contractAddress = new Address5(transferParam.contractId);
|
7062
7078
|
const assetId = transferParam.assetId ? hexlify20(transferParam.assetId) : defaultAssetId;
|
7063
7079
|
if (amount.lte(0)) {
|
7064
|
-
throw new
|
7080
|
+
throw new FuelError21(
|
7065
7081
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7066
7082
|
"Transfer amount must be a positive number."
|
7067
7083
|
);
|
@@ -7178,7 +7194,7 @@ var Account = class extends AbstractAccount {
|
|
7178
7194
|
*/
|
7179
7195
|
async signMessage(message) {
|
7180
7196
|
if (!this._connector) {
|
7181
|
-
throw new
|
7197
|
+
throw new FuelError21(ErrorCode18.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7182
7198
|
}
|
7183
7199
|
return this._connector.signMessage(this.address.toString(), message);
|
7184
7200
|
}
|
@@ -7190,7 +7206,7 @@ var Account = class extends AbstractAccount {
|
|
7190
7206
|
*/
|
7191
7207
|
async signTransaction(transactionRequestLike) {
|
7192
7208
|
if (!this._connector) {
|
7193
|
-
throw new
|
7209
|
+
throw new FuelError21(
|
7194
7210
|
ErrorCode18.MISSING_CONNECTOR,
|
7195
7211
|
"A connector is required to sign transactions."
|
7196
7212
|
);
|
@@ -7287,7 +7303,7 @@ var Account = class extends AbstractAccount {
|
|
7287
7303
|
/** @hidden * */
|
7288
7304
|
validateTransferAmount(amount) {
|
7289
7305
|
if (bn20(amount).lte(0)) {
|
7290
|
-
throw new
|
7306
|
+
throw new FuelError21(
|
7291
7307
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7292
7308
|
"Transfer amount must be a positive number."
|
7293
7309
|
);
|
@@ -7317,7 +7333,7 @@ var Account = class extends AbstractAccount {
|
|
7317
7333
|
if (!isDefined3(setGasLimit)) {
|
7318
7334
|
request.gasLimit = gasUsed;
|
7319
7335
|
} else if (gasUsed.gt(setGasLimit)) {
|
7320
|
-
throw new
|
7336
|
+
throw new FuelError21(
|
7321
7337
|
ErrorCode18.GAS_LIMIT_TOO_LOW,
|
7322
7338
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7323
7339
|
);
|
@@ -7325,7 +7341,7 @@ var Account = class extends AbstractAccount {
|
|
7325
7341
|
if (!isDefined3(setMaxFee)) {
|
7326
7342
|
request.maxFee = maxFee;
|
7327
7343
|
} else if (maxFee.gt(setMaxFee)) {
|
7328
|
-
throw new
|
7344
|
+
throw new FuelError21(
|
7329
7345
|
ErrorCode18.MAX_FEE_TOO_LOW,
|
7330
7346
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
7331
7347
|
);
|
@@ -7346,7 +7362,7 @@ import {
|
|
7346
7362
|
encryptJsonWalletData,
|
7347
7363
|
randomUUID as randomUUID2
|
7348
7364
|
} from "@fuel-ts/crypto";
|
7349
|
-
import { ErrorCode as ErrorCode19, FuelError as
|
7365
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
|
7350
7366
|
import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
7351
7367
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7352
7368
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -7424,7 +7440,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7424
7440
|
const macHashUint8Array = keccak256(data);
|
7425
7441
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
7426
7442
|
if (mac !== macHash) {
|
7427
|
-
throw new
|
7443
|
+
throw new FuelError22(
|
7428
7444
|
ErrorCode19.INVALID_PASSWORD,
|
7429
7445
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
7430
7446
|
);
|
@@ -7564,14 +7580,14 @@ var BaseWalletUnlocked = class extends Account {
|
|
7564
7580
|
|
7565
7581
|
// src/hdwallet/hdwallet.ts
|
7566
7582
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
7567
|
-
import { ErrorCode as ErrorCode22, FuelError as
|
7583
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError25 } from "@fuel-ts/errors";
|
7568
7584
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
7569
7585
|
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
7570
7586
|
import { arrayify as arrayify20, hexlify as hexlify24, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
7571
7587
|
|
7572
7588
|
// src/mnemonic/mnemonic.ts
|
7573
7589
|
import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
7574
|
-
import { ErrorCode as ErrorCode21, FuelError as
|
7590
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
|
7575
7591
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
7576
7592
|
import { arrayify as arrayify19, hexlify as hexlify23, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
7577
7593
|
|
@@ -9628,7 +9644,7 @@ var english = [
|
|
9628
9644
|
];
|
9629
9645
|
|
9630
9646
|
// src/mnemonic/utils.ts
|
9631
|
-
import { ErrorCode as ErrorCode20, FuelError as
|
9647
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
|
9632
9648
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
9633
9649
|
import { arrayify as arrayify18 } from "@fuel-ts/utils";
|
9634
9650
|
function getLowerMask(bits) {
|
@@ -9682,7 +9698,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9682
9698
|
for (let i = 0; i < words.length; i += 1) {
|
9683
9699
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9684
9700
|
if (index === -1) {
|
9685
|
-
throw new
|
9701
|
+
throw new FuelError23(
|
9686
9702
|
ErrorCode20.INVALID_MNEMONIC,
|
9687
9703
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9688
9704
|
);
|
@@ -9699,7 +9715,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9699
9715
|
const checksumMask = getUpperMask(checksumBits);
|
9700
9716
|
const checksum = arrayify18(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9701
9717
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9702
|
-
throw new
|
9718
|
+
throw new FuelError23(
|
9703
9719
|
ErrorCode20.INVALID_CHECKSUM,
|
9704
9720
|
"Checksum validation failed for the provided mnemonic."
|
9705
9721
|
);
|
@@ -9715,7 +9731,7 @@ var TestnetPRV = "0x04358394";
|
|
9715
9731
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9716
9732
|
function assertWordList(wordlist) {
|
9717
9733
|
if (wordlist.length !== 2048) {
|
9718
|
-
throw new
|
9734
|
+
throw new FuelError24(
|
9719
9735
|
ErrorCode21.INVALID_WORD_LIST,
|
9720
9736
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9721
9737
|
);
|
@@ -9724,7 +9740,7 @@ function assertWordList(wordlist) {
|
|
9724
9740
|
__name(assertWordList, "assertWordList");
|
9725
9741
|
function assertEntropy(entropy) {
|
9726
9742
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9727
|
-
throw new
|
9743
|
+
throw new FuelError24(
|
9728
9744
|
ErrorCode21.INVALID_ENTROPY,
|
9729
9745
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9730
9746
|
);
|
@@ -9736,7 +9752,7 @@ function assertMnemonic(words) {
|
|
9736
9752
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9737
9753
|
", "
|
9738
9754
|
)}] words, but got ${words.length}.`;
|
9739
|
-
throw new
|
9755
|
+
throw new FuelError24(ErrorCode21.INVALID_MNEMONIC, errorMsg);
|
9740
9756
|
}
|
9741
9757
|
}
|
9742
9758
|
__name(assertMnemonic, "assertMnemonic");
|
@@ -9858,7 +9874,7 @@ var Mnemonic = class _Mnemonic {
|
|
9858
9874
|
static masterKeysFromSeed(seed) {
|
9859
9875
|
const seedArray = arrayify19(seed);
|
9860
9876
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9861
|
-
throw new
|
9877
|
+
throw new FuelError24(
|
9862
9878
|
ErrorCode21.INVALID_SEED,
|
9863
9879
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9864
9880
|
);
|
@@ -9940,7 +9956,7 @@ __name(isValidExtendedKey, "isValidExtendedKey");
|
|
9940
9956
|
function parsePath(path2, depth = 0) {
|
9941
9957
|
const components = path2.split("/");
|
9942
9958
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9943
|
-
throw new
|
9959
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9944
9960
|
}
|
9945
9961
|
if (components[0] === "m") {
|
9946
9962
|
components.shift();
|
@@ -9973,7 +9989,7 @@ var HDWallet = class _HDWallet {
|
|
9973
9989
|
this.privateKey = hexlify24(config.privateKey);
|
9974
9990
|
} else {
|
9975
9991
|
if (!config.publicKey) {
|
9976
|
-
throw new
|
9992
|
+
throw new FuelError25(
|
9977
9993
|
ErrorCode22.HD_WALLET_ERROR,
|
9978
9994
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9979
9995
|
);
|
@@ -10003,7 +10019,7 @@ var HDWallet = class _HDWallet {
|
|
10003
10019
|
const data = new Uint8Array(37);
|
10004
10020
|
if (index & HARDENED_INDEX) {
|
10005
10021
|
if (!privateKey) {
|
10006
|
-
throw new
|
10022
|
+
throw new FuelError25(
|
10007
10023
|
ErrorCode22.HD_WALLET_ERROR,
|
10008
10024
|
"Cannot derive a hardened index without a private Key."
|
10009
10025
|
);
|
@@ -10056,7 +10072,7 @@ var HDWallet = class _HDWallet {
|
|
10056
10072
|
*/
|
10057
10073
|
toExtendedKey(isPublic = false, testnet = false) {
|
10058
10074
|
if (this.depth >= 256) {
|
10059
|
-
throw new
|
10075
|
+
throw new FuelError25(
|
10060
10076
|
ErrorCode22.HD_WALLET_ERROR,
|
10061
10077
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
10062
10078
|
);
|
@@ -10088,10 +10104,10 @@ var HDWallet = class _HDWallet {
|
|
10088
10104
|
const bytes = arrayify20(decoded);
|
10089
10105
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10090
10106
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10091
|
-
throw new
|
10107
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
10092
10108
|
}
|
10093
10109
|
if (!validChecksum) {
|
10094
|
-
throw new
|
10110
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10095
10111
|
}
|
10096
10112
|
const depth = bytes[4];
|
10097
10113
|
const parentFingerprint = hexlify24(bytes.slice(5, 9));
|
@@ -10099,14 +10115,14 @@ var HDWallet = class _HDWallet {
|
|
10099
10115
|
const chainCode = hexlify24(bytes.slice(13, 45));
|
10100
10116
|
const key = bytes.slice(45, 78);
|
10101
10117
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10102
|
-
throw new
|
10118
|
+
throw new FuelError25(
|
10103
10119
|
ErrorCode22.HD_WALLET_ERROR,
|
10104
10120
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
10105
10121
|
);
|
10106
10122
|
}
|
10107
10123
|
if (isPublicExtendedKey(bytes)) {
|
10108
10124
|
if (key[0] !== 3) {
|
10109
|
-
throw new
|
10125
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Invalid public extended key.");
|
10110
10126
|
}
|
10111
10127
|
return new _HDWallet({
|
10112
10128
|
publicKey: key,
|
@@ -10117,7 +10133,7 @@ var HDWallet = class _HDWallet {
|
|
10117
10133
|
});
|
10118
10134
|
}
|
10119
10135
|
if (key[0] !== 0) {
|
10120
|
-
throw new
|
10136
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Invalid private extended key.");
|
10121
10137
|
}
|
10122
10138
|
return new _HDWallet({
|
10123
10139
|
privateKey: key.slice(1),
|
@@ -10373,26 +10389,26 @@ var WalletsConfig = class _WalletsConfig {
|
|
10373
10389
|
amountPerCoin
|
10374
10390
|
}) {
|
10375
10391
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
10376
|
-
throw new
|
10377
|
-
|
10392
|
+
throw new FuelError26(
|
10393
|
+
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10378
10394
|
"Number of wallets must be greater than zero."
|
10379
10395
|
);
|
10380
10396
|
}
|
10381
10397
|
if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
|
10382
|
-
throw new
|
10383
|
-
|
10398
|
+
throw new FuelError26(
|
10399
|
+
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10384
10400
|
"Number of assets per wallet must be greater than zero."
|
10385
10401
|
);
|
10386
10402
|
}
|
10387
10403
|
if (coinsPerAsset <= 0) {
|
10388
|
-
throw new
|
10389
|
-
|
10404
|
+
throw new FuelError26(
|
10405
|
+
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10390
10406
|
"Number of coins per asset must be greater than zero."
|
10391
10407
|
);
|
10392
10408
|
}
|
10393
10409
|
if (bn22(amountPerCoin).lt(0)) {
|
10394
|
-
throw new
|
10395
|
-
|
10410
|
+
throw new FuelError26(
|
10411
|
+
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10396
10412
|
"Amount per coin must be greater than or equal to zero."
|
10397
10413
|
);
|
10398
10414
|
}
|