@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.js
CHANGED
@@ -442,27 +442,15 @@ var addAmountToCoinQuantities = /* @__PURE__ */ __name((params) => {
|
|
442
442
|
|
443
443
|
// src/providers/provider.ts
|
444
444
|
var import_address4 = require("@fuel-ts/address");
|
445
|
-
var
|
445
|
+
var import_errors20 = require("@fuel-ts/errors");
|
446
446
|
var import_math19 = require("@fuel-ts/math");
|
447
|
-
var
|
447
|
+
var import_transactions24 = require("@fuel-ts/transactions");
|
448
448
|
var import_utils30 = require("@fuel-ts/utils");
|
449
449
|
var import_versions = require("@fuel-ts/versions");
|
450
450
|
var import_graphql_request = require("graphql-request");
|
451
451
|
var import_graphql_tag2 = __toESM(require("graphql-tag"));
|
452
452
|
var import_ramda8 = require("ramda");
|
453
453
|
|
454
|
-
// src/connectors/utils/promises.ts
|
455
|
-
var import_errors2 = require("@fuel-ts/errors");
|
456
|
-
function deferPromise() {
|
457
|
-
const defer = {};
|
458
|
-
defer.promise = new Promise((resolve, reject) => {
|
459
|
-
defer.reject = reject;
|
460
|
-
defer.resolve = resolve;
|
461
|
-
});
|
462
|
-
return defer;
|
463
|
-
}
|
464
|
-
__name(deferPromise, "deferPromise");
|
465
|
-
|
466
454
|
// src/providers/__generated__/operations.ts
|
467
455
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
468
456
|
var SubmittedStatusFragmentDoc = import_graphql_tag.default`
|
@@ -1521,35 +1509,35 @@ function getSdk(requester) {
|
|
1521
1509
|
__name(getSdk, "getSdk");
|
1522
1510
|
|
1523
1511
|
// src/providers/fuel-graphql-subscriber.ts
|
1524
|
-
var
|
1512
|
+
var import_errors3 = require("@fuel-ts/errors");
|
1525
1513
|
var import_graphql = require("graphql");
|
1526
1514
|
|
1527
1515
|
// src/providers/utils/handle-gql-error-message.ts
|
1528
|
-
var
|
1516
|
+
var import_errors2 = require("@fuel-ts/errors");
|
1529
1517
|
var mapGqlErrorMessage = /* @__PURE__ */ __name((error) => {
|
1530
1518
|
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)) {
|
1531
|
-
return new
|
1532
|
-
|
1519
|
+
return new import_errors2.FuelError(
|
1520
|
+
import_errors2.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
1533
1521
|
`Insufficient funds or too many small value coins. Consider combining UTXOs.`,
|
1534
1522
|
{},
|
1535
1523
|
error
|
1536
1524
|
);
|
1537
1525
|
}
|
1538
1526
|
if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
|
1539
|
-
return new
|
1540
|
-
|
1527
|
+
return new import_errors2.FuelError(
|
1528
|
+
import_errors2.ErrorCode.ASSET_NOT_FOUND,
|
1541
1529
|
`Asset not found for given asset id.`,
|
1542
1530
|
{},
|
1543
1531
|
error
|
1544
1532
|
);
|
1545
1533
|
}
|
1546
|
-
return new
|
1534
|
+
return new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1547
1535
|
}, "mapGqlErrorMessage");
|
1548
1536
|
var mapGqlErrorWithIncompatibleNodeVersion = /* @__PURE__ */ __name((error, incompatibleNodeVersionMessage) => {
|
1549
1537
|
if (!incompatibleNodeVersionMessage) {
|
1550
1538
|
return error;
|
1551
1539
|
}
|
1552
|
-
return new
|
1540
|
+
return new import_errors2.FuelError(
|
1553
1541
|
error.code,
|
1554
1542
|
`${error.message}
|
1555
1543
|
|
@@ -1568,7 +1556,7 @@ var assertGqlResponseHasNoErrors = /* @__PURE__ */ __name((errors, incompatibleN
|
|
1568
1556
|
}
|
1569
1557
|
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
1570
1558
|
throw mapGqlErrorWithIncompatibleNodeVersion(
|
1571
|
-
new
|
1559
|
+
new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1572
1560
|
incompatibleNodeVersionMessage
|
1573
1561
|
);
|
1574
1562
|
}, "assertGqlResponseHasNoErrors");
|
@@ -1624,8 +1612,8 @@ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
|
1624
1612
|
try {
|
1625
1613
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1626
1614
|
} catch (e) {
|
1627
|
-
throw new
|
1628
|
-
|
1615
|
+
throw new import_errors3.FuelError(
|
1616
|
+
import_errors3.ErrorCode.STREAM_PARSING_ERROR,
|
1629
1617
|
`Error while parsing stream data response: ${text}`
|
1630
1618
|
);
|
1631
1619
|
}
|
@@ -1645,13 +1633,13 @@ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
|
1645
1633
|
};
|
1646
1634
|
|
1647
1635
|
// src/providers/resource-cache.ts
|
1648
|
-
var
|
1636
|
+
var import_errors14 = require("@fuel-ts/errors");
|
1649
1637
|
var import_utils23 = require("@fuel-ts/utils");
|
1650
1638
|
|
1651
1639
|
// src/providers/transaction-request/input.ts
|
1652
1640
|
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
1653
1641
|
var import_configs = require("@fuel-ts/address/configs");
|
1654
|
-
var
|
1642
|
+
var import_errors4 = require("@fuel-ts/errors");
|
1655
1643
|
var import_math3 = require("@fuel-ts/math");
|
1656
1644
|
var import_transactions = require("@fuel-ts/transactions");
|
1657
1645
|
var import_utils4 = require("@fuel-ts/utils");
|
@@ -1715,8 +1703,8 @@ var inputify = /* @__PURE__ */ __name((value) => {
|
|
1715
1703
|
};
|
1716
1704
|
}
|
1717
1705
|
default: {
|
1718
|
-
throw new
|
1719
|
-
|
1706
|
+
throw new import_errors4.FuelError(
|
1707
|
+
import_errors4.ErrorCode.INVALID_TRANSACTION_INPUT,
|
1720
1708
|
`Invalid transaction input type: ${type}.`
|
1721
1709
|
);
|
1722
1710
|
}
|
@@ -1725,7 +1713,7 @@ var inputify = /* @__PURE__ */ __name((value) => {
|
|
1725
1713
|
|
1726
1714
|
// src/providers/transaction-request/output.ts
|
1727
1715
|
var import_configs2 = require("@fuel-ts/address/configs");
|
1728
|
-
var
|
1716
|
+
var import_errors5 = require("@fuel-ts/errors");
|
1729
1717
|
var import_math4 = require("@fuel-ts/math");
|
1730
1718
|
var import_transactions2 = require("@fuel-ts/transactions");
|
1731
1719
|
var import_utils5 = require("@fuel-ts/utils");
|
@@ -1772,8 +1760,8 @@ var outputify = /* @__PURE__ */ __name((value) => {
|
|
1772
1760
|
};
|
1773
1761
|
}
|
1774
1762
|
default: {
|
1775
|
-
throw new
|
1776
|
-
|
1763
|
+
throw new import_errors5.FuelError(
|
1764
|
+
import_errors5.ErrorCode.INVALID_TRANSACTION_INPUT,
|
1777
1765
|
`Invalid transaction output type: ${type}.`
|
1778
1766
|
);
|
1779
1767
|
}
|
@@ -1785,7 +1773,7 @@ var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
|
1785
1773
|
var import_address2 = require("@fuel-ts/address");
|
1786
1774
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1787
1775
|
var import_crypto3 = require("@fuel-ts/crypto");
|
1788
|
-
var
|
1776
|
+
var import_errors10 = require("@fuel-ts/errors");
|
1789
1777
|
var import_math9 = require("@fuel-ts/math");
|
1790
1778
|
var import_transactions8 = require("@fuel-ts/transactions");
|
1791
1779
|
var import_utils11 = require("@fuel-ts/utils");
|
@@ -1802,7 +1790,7 @@ var import_configs4 = require("@fuel-ts/transactions/configs");
|
|
1802
1790
|
|
1803
1791
|
// src/providers/utils/serialization.ts
|
1804
1792
|
var import_configs3 = require("@fuel-ts/address/configs");
|
1805
|
-
var
|
1793
|
+
var import_errors6 = require("@fuel-ts/errors");
|
1806
1794
|
var import_math5 = require("@fuel-ts/math");
|
1807
1795
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1808
1796
|
var import_utils6 = require("@fuel-ts/utils");
|
@@ -2139,7 +2127,7 @@ var deserializeReceipt = /* @__PURE__ */ __name((receipt) => {
|
|
2139
2127
|
return burnReceipt;
|
2140
2128
|
}
|
2141
2129
|
default:
|
2142
|
-
throw new
|
2130
|
+
throw new import_errors6.FuelError(import_errors6.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
2143
2131
|
}
|
2144
2132
|
}, "deserializeReceipt");
|
2145
2133
|
|
@@ -2163,7 +2151,7 @@ var getReceiptsWithMissingData = /* @__PURE__ */ __name((receipts) => receipts.r
|
|
2163
2151
|
), "getReceiptsWithMissingData");
|
2164
2152
|
|
2165
2153
|
// src/providers/utils/block-explorer.ts
|
2166
|
-
var
|
2154
|
+
var import_errors7 = require("@fuel-ts/errors");
|
2167
2155
|
|
2168
2156
|
// src/providers/utils/gas.ts
|
2169
2157
|
var import_math6 = require("@fuel-ts/math");
|
@@ -2347,7 +2335,7 @@ function normalizeJSON(root) {
|
|
2347
2335
|
__name(normalizeJSON, "normalizeJSON");
|
2348
2336
|
|
2349
2337
|
// src/providers/utils/extract-tx-error.ts
|
2350
|
-
var
|
2338
|
+
var import_errors8 = require("@fuel-ts/errors");
|
2351
2339
|
var import_math7 = require("@fuel-ts/math");
|
2352
2340
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2353
2341
|
var import_configs5 = require("@fuel-ts/transactions/configs");
|
@@ -2360,7 +2348,7 @@ You can read more about this error at:
|
|
2360
2348
|
|
2361
2349
|
${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
|
2362
2350
|
}
|
2363
|
-
return new
|
2351
|
+
return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
|
2364
2352
|
...metadata,
|
2365
2353
|
reason: statusReason
|
2366
2354
|
});
|
@@ -2401,8 +2389,8 @@ var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
|
|
2401
2389
|
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2402
2390
|
break;
|
2403
2391
|
default:
|
2404
|
-
throw new
|
2405
|
-
|
2392
|
+
throw new import_errors8.FuelError(
|
2393
|
+
import_errors8.ErrorCode.UNKNOWN,
|
2406
2394
|
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2407
2395
|
{
|
2408
2396
|
...metadata,
|
@@ -2411,17 +2399,18 @@ var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
|
|
2411
2399
|
);
|
2412
2400
|
}
|
2413
2401
|
}
|
2414
|
-
return new
|
2402
|
+
return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
|
2415
2403
|
...metadata,
|
2416
2404
|
reason
|
2417
2405
|
});
|
2418
2406
|
}, "assembleRevertError");
|
2419
2407
|
var extractTxError = /* @__PURE__ */ __name((params) => {
|
2420
|
-
const { receipts, statusReason, logs } = params;
|
2408
|
+
const { receipts, statusReason, logs, groupedLogs } = params;
|
2421
2409
|
const isPanic = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Panic);
|
2422
2410
|
const isRevert = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Revert);
|
2423
2411
|
const metadata = {
|
2424
2412
|
logs,
|
2413
|
+
groupedLogs,
|
2425
2414
|
receipts,
|
2426
2415
|
panic: isPanic,
|
2427
2416
|
revert: isRevert,
|
@@ -2447,7 +2436,7 @@ var NoWitnessAtIndexError = class extends Error {
|
|
2447
2436
|
};
|
2448
2437
|
|
2449
2438
|
// src/providers/transaction-request/helpers.ts
|
2450
|
-
var
|
2439
|
+
var import_errors9 = require("@fuel-ts/errors");
|
2451
2440
|
var import_math8 = require("@fuel-ts/math");
|
2452
2441
|
var import_transactions7 = require("@fuel-ts/transactions");
|
2453
2442
|
var import_utils9 = require("@fuel-ts/utils");
|
@@ -2506,7 +2495,7 @@ var validateTransactionForAssetBurn = /* @__PURE__ */ __name((baseAssetId, trans
|
|
2506
2495
|
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
2507
2496
|
"Or enable asset burn, upon sending the transaction."
|
2508
2497
|
].join("\n");
|
2509
|
-
throw new
|
2498
|
+
throw new import_errors9.FuelError(import_errors9.ErrorCode.ASSET_BURN_DETECTED, message);
|
2510
2499
|
}, "validateTransactionForAssetBurn");
|
2511
2500
|
|
2512
2501
|
// src/providers/transaction-request/witness.ts
|
@@ -2907,7 +2896,7 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
|
|
2907
2896
|
* @hidden
|
2908
2897
|
*/
|
2909
2898
|
metadataGas(_gasCosts) {
|
2910
|
-
throw new
|
2899
|
+
throw new import_errors10.FuelError(import_errors10.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
|
2911
2900
|
}
|
2912
2901
|
/**
|
2913
2902
|
* @hidden
|
@@ -3546,7 +3535,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3546
3535
|
};
|
3547
3536
|
|
3548
3537
|
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3549
|
-
var
|
3538
|
+
var import_errors12 = require("@fuel-ts/errors");
|
3550
3539
|
var import_hasher3 = require("@fuel-ts/hasher");
|
3551
3540
|
var import_transactions12 = require("@fuel-ts/transactions");
|
3552
3541
|
var import_utils19 = require("@fuel-ts/utils");
|
@@ -3653,7 +3642,7 @@ var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTra
|
|
3653
3642
|
}
|
3654
3643
|
};
|
3655
3644
|
} else {
|
3656
|
-
throw new
|
3645
|
+
throw new import_errors12.FuelError(import_errors12.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3657
3646
|
}
|
3658
3647
|
return {
|
3659
3648
|
type: import_transactions12.TransactionType.Upgrade,
|
@@ -3695,7 +3684,7 @@ var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTra
|
|
3695
3684
|
txBytesSize
|
3696
3685
|
});
|
3697
3686
|
}
|
3698
|
-
throw new
|
3687
|
+
throw new import_errors12.FuelError(import_errors12.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3699
3688
|
}
|
3700
3689
|
};
|
3701
3690
|
|
@@ -3809,7 +3798,7 @@ var UploadTransactionRequest = class _UploadTransactionRequest extends BaseTrans
|
|
3809
3798
|
};
|
3810
3799
|
|
3811
3800
|
// src/providers/transaction-request/utils.ts
|
3812
|
-
var
|
3801
|
+
var import_errors13 = require("@fuel-ts/errors");
|
3813
3802
|
var import_transactions14 = require("@fuel-ts/transactions");
|
3814
3803
|
var transactionRequestify = /* @__PURE__ */ __name((obj) => {
|
3815
3804
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
@@ -3833,8 +3822,8 @@ var transactionRequestify = /* @__PURE__ */ __name((obj) => {
|
|
3833
3822
|
return UploadTransactionRequest.from(obj);
|
3834
3823
|
}
|
3835
3824
|
default: {
|
3836
|
-
throw new
|
3837
|
-
|
3825
|
+
throw new import_errors13.FuelError(
|
3826
|
+
import_errors13.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3838
3827
|
`Unsupported transaction type: ${type}.`
|
3839
3828
|
);
|
3840
3829
|
}
|
@@ -3853,8 +3842,8 @@ var ResourceCache = class {
|
|
3853
3842
|
constructor(ttl) {
|
3854
3843
|
this.ttl = ttl;
|
3855
3844
|
if (typeof ttl !== "number" || this.ttl <= 0) {
|
3856
|
-
throw new
|
3857
|
-
|
3845
|
+
throw new import_errors14.FuelError(
|
3846
|
+
import_errors14.ErrorCode.INVALID_TTL,
|
3858
3847
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
3859
3848
|
);
|
3860
3849
|
}
|
@@ -3938,7 +3927,7 @@ var ResourceCache = class {
|
|
3938
3927
|
};
|
3939
3928
|
|
3940
3929
|
// src/providers/transaction-response/transaction-response.ts
|
3941
|
-
var
|
3930
|
+
var import_errors18 = require("@fuel-ts/errors");
|
3942
3931
|
var import_math18 = require("@fuel-ts/math");
|
3943
3932
|
var import_transactions22 = require("@fuel-ts/transactions");
|
3944
3933
|
var import_utils27 = require("@fuel-ts/utils");
|
@@ -4016,12 +4005,12 @@ var calculateTXFeeForSummary = /* @__PURE__ */ __name((params) => {
|
|
4016
4005
|
|
4017
4006
|
// src/providers/transaction-summary/operations.ts
|
4018
4007
|
var import_configs11 = require("@fuel-ts/address/configs");
|
4019
|
-
var
|
4008
|
+
var import_errors16 = require("@fuel-ts/errors");
|
4020
4009
|
var import_math15 = require("@fuel-ts/math");
|
4021
4010
|
var import_transactions18 = require("@fuel-ts/transactions");
|
4022
4011
|
|
4023
4012
|
// src/providers/transaction-summary/input.ts
|
4024
|
-
var
|
4013
|
+
var import_errors15 = require("@fuel-ts/errors");
|
4025
4014
|
var import_math14 = require("@fuel-ts/math");
|
4026
4015
|
var import_transactions16 = require("@fuel-ts/transactions");
|
4027
4016
|
function getInputsByTypes(inputs, types) {
|
@@ -4101,8 +4090,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
4101
4090
|
return void 0;
|
4102
4091
|
}
|
4103
4092
|
if (contractInput.type !== import_transactions16.InputType.Contract) {
|
4104
|
-
throw new
|
4105
|
-
|
4093
|
+
throw new import_errors15.FuelError(
|
4094
|
+
import_errors15.ErrorCode.INVALID_TRANSACTION_INPUT,
|
4106
4095
|
`Contract input should be of type 'contract'.`
|
4107
4096
|
);
|
4108
4097
|
}
|
@@ -4163,8 +4152,8 @@ function getTransactionTypeName(transactionType) {
|
|
4163
4152
|
case import_transactions18.TransactionType.Upload:
|
4164
4153
|
return "Upload" /* Upload */;
|
4165
4154
|
default:
|
4166
|
-
throw new
|
4167
|
-
|
4155
|
+
throw new import_errors16.FuelError(
|
4156
|
+
import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
4168
4157
|
`Unsupported transaction type: ${transactionType}.`
|
4169
4158
|
);
|
4170
4159
|
}
|
@@ -4569,7 +4558,7 @@ var extractBurnedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
|
4569
4558
|
}, "extractBurnedAssetsFromReceipts");
|
4570
4559
|
|
4571
4560
|
// src/providers/transaction-summary/status.ts
|
4572
|
-
var
|
4561
|
+
var import_errors17 = require("@fuel-ts/errors");
|
4573
4562
|
var import_math16 = require("@fuel-ts/math");
|
4574
4563
|
var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
|
4575
4564
|
switch (gqlStatus) {
|
@@ -4582,8 +4571,8 @@ var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
|
|
4582
4571
|
case "SqueezedOutStatus":
|
4583
4572
|
return "squeezedout" /* squeezedout */;
|
4584
4573
|
default:
|
4585
|
-
throw new
|
4586
|
-
|
4574
|
+
throw new import_errors17.FuelError(
|
4575
|
+
import_errors17.ErrorCode.INVALID_TRANSACTION_STATUS,
|
4587
4576
|
`Invalid transaction status: ${gqlStatus}.`
|
4588
4577
|
);
|
4589
4578
|
}
|
@@ -4715,11 +4704,12 @@ function assembleTransactionSummary(params) {
|
|
4715
4704
|
}
|
4716
4705
|
__name(assembleTransactionSummary, "assembleTransactionSummary");
|
4717
4706
|
|
4718
|
-
// src/providers/transaction-response/
|
4707
|
+
// src/providers/transaction-response/getAllDecodedLogs.ts
|
4719
4708
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
4720
4709
|
var import_configs12 = require("@fuel-ts/address/configs");
|
4721
4710
|
var import_transactions21 = require("@fuel-ts/transactions");
|
4722
|
-
function
|
4711
|
+
function getAllDecodedLogs(opts) {
|
4712
|
+
const { receipts, mainAbi, externalAbis = {} } = opts;
|
4723
4713
|
let mainContract = "";
|
4724
4714
|
if (mainAbi.programType === "contract") {
|
4725
4715
|
const firstCallReceipt = receipts.find(
|
@@ -4727,21 +4717,25 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
4727
4717
|
);
|
4728
4718
|
mainContract = firstCallReceipt.to;
|
4729
4719
|
}
|
4730
|
-
return receipts.reduce(
|
4731
|
-
|
4732
|
-
|
4733
|
-
|
4734
|
-
|
4735
|
-
|
4736
|
-
|
4737
|
-
|
4738
|
-
|
4720
|
+
return receipts.reduce(
|
4721
|
+
({ logs, groupedLogs }, receipt) => {
|
4722
|
+
if (receipt.type === import_transactions21.ReceiptType.LogData || receipt.type === import_transactions21.ReceiptType.Log) {
|
4723
|
+
const isLogFromMainAbi = receipt.id === import_configs12.ZeroBytes32 || mainContract === receipt.id;
|
4724
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
4725
|
+
if (isDecodable) {
|
4726
|
+
const interfaceToUse = isLogFromMainAbi ? new import_abi_coder5.Interface(mainAbi) : new import_abi_coder5.Interface(externalAbis[receipt.id]);
|
4727
|
+
const data = receipt.type === import_transactions21.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
4728
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
4729
|
+
logs.push(decodedLog);
|
4730
|
+
groupedLogs[receipt.id] = [...groupedLogs[receipt.id] || [], decodedLog];
|
4731
|
+
}
|
4739
4732
|
}
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4733
|
+
return { logs, groupedLogs };
|
4734
|
+
},
|
4735
|
+
{ logs: [], groupedLogs: {} }
|
4736
|
+
);
|
4743
4737
|
}
|
4744
|
-
__name(
|
4738
|
+
__name(getAllDecodedLogs, "getAllDecodedLogs");
|
4745
4739
|
|
4746
4740
|
// src/providers/transaction-response/transaction-response.ts
|
4747
4741
|
function mapGqlOutputsToTxOutputs(outputs) {
|
@@ -4946,8 +4940,8 @@ var TransactionResponse = class _TransactionResponse {
|
|
4946
4940
|
this.status = statusChange;
|
4947
4941
|
if (statusChange.type === "SqueezedOutStatus") {
|
4948
4942
|
this.unsetResourceCache();
|
4949
|
-
throw new
|
4950
|
-
|
4943
|
+
throw new import_errors18.FuelError(
|
4944
|
+
import_errors18.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
4951
4945
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4952
4946
|
);
|
4953
4947
|
}
|
@@ -4973,14 +4967,15 @@ var TransactionResponse = class _TransactionResponse {
|
|
4973
4967
|
const transactionResult = {
|
4974
4968
|
...transactionSummary
|
4975
4969
|
};
|
4976
|
-
let logs = [];
|
4970
|
+
let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
|
4977
4971
|
if (this.abis) {
|
4978
|
-
logs =
|
4979
|
-
transactionSummary.receipts,
|
4980
|
-
this.abis.main,
|
4981
|
-
this.abis.otherContractsAbis
|
4982
|
-
);
|
4972
|
+
({ logs, groupedLogs } = getAllDecodedLogs({
|
4973
|
+
receipts: transactionSummary.receipts,
|
4974
|
+
mainAbi: this.abis.main,
|
4975
|
+
externalAbis: this.abis.otherContractsAbis
|
4976
|
+
}));
|
4983
4977
|
transactionResult.logs = logs;
|
4978
|
+
transactionResult.groupedLogs = groupedLogs;
|
4984
4979
|
}
|
4985
4980
|
const { receipts } = transactionResult;
|
4986
4981
|
const status = this.status ?? this.gqlTransaction?.status;
|
@@ -4989,7 +4984,8 @@ var TransactionResponse = class _TransactionResponse {
|
|
4989
4984
|
throw extractTxError({
|
4990
4985
|
receipts,
|
4991
4986
|
statusReason: reason,
|
4992
|
-
logs
|
4987
|
+
logs,
|
4988
|
+
groupedLogs
|
4993
4989
|
});
|
4994
4990
|
}
|
4995
4991
|
return transactionResult;
|
@@ -5017,6 +5013,11 @@ var TransactionResponse = class _TransactionResponse {
|
|
5017
5013
|
}
|
5018
5014
|
};
|
5019
5015
|
|
5016
|
+
// src/providers/transaction-response/getDecodedLogs.ts
|
5017
|
+
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5018
|
+
var import_configs13 = require("@fuel-ts/address/configs");
|
5019
|
+
var import_transactions23 = require("@fuel-ts/transactions");
|
5020
|
+
|
5020
5021
|
// src/providers/utils/auto-retry-fetch.ts
|
5021
5022
|
var import_utils29 = require("@fuel-ts/utils");
|
5022
5023
|
function getWaitDelay(options, retryAttemptNum) {
|
@@ -5073,31 +5074,31 @@ var adjustResourcesToExclude = /* @__PURE__ */ __name((params) => {
|
|
5073
5074
|
}, "adjustResourcesToExclude");
|
5074
5075
|
|
5075
5076
|
// src/providers/utils/validate-pagination-args.ts
|
5076
|
-
var
|
5077
|
+
var import_errors19 = require("@fuel-ts/errors");
|
5077
5078
|
var validatePaginationArgs = /* @__PURE__ */ __name((params) => {
|
5078
5079
|
const { paginationLimit, inputArgs = {} } = params;
|
5079
5080
|
const { first, last, after, before } = inputArgs;
|
5080
5081
|
if (after && before) {
|
5081
|
-
throw new
|
5082
|
-
|
5082
|
+
throw new import_errors19.FuelError(
|
5083
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5083
5084
|
'Pagination arguments "after" and "before" cannot be used together'
|
5084
5085
|
);
|
5085
5086
|
}
|
5086
5087
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5087
|
-
throw new
|
5088
|
-
|
5088
|
+
throw new import_errors19.FuelError(
|
5089
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5089
5090
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5090
5091
|
);
|
5091
5092
|
}
|
5092
5093
|
if (first && before) {
|
5093
|
-
throw new
|
5094
|
-
|
5094
|
+
throw new import_errors19.FuelError(
|
5095
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5095
5096
|
'The use of pagination argument "first" with "before" is not supported'
|
5096
5097
|
);
|
5097
5098
|
}
|
5098
5099
|
if (last && after) {
|
5099
|
-
throw new
|
5100
|
-
|
5100
|
+
throw new import_errors19.FuelError(
|
5101
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5101
5102
|
'The use of pagination argument "last" with "after" is not supported'
|
5102
5103
|
);
|
5103
5104
|
}
|
@@ -5212,7 +5213,7 @@ var Provider = class _Provider {
|
|
5212
5213
|
try {
|
5213
5214
|
parsedUrl = new URL(url);
|
5214
5215
|
} catch (error) {
|
5215
|
-
throw new
|
5216
|
+
throw new import_errors20.FuelError(import_errors20.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
5216
5217
|
}
|
5217
5218
|
const username = parsedUrl.username;
|
5218
5219
|
const password = parsedUrl.password;
|
@@ -5290,39 +5291,52 @@ var Provider = class _Provider {
|
|
5290
5291
|
* @returns A promise that resolves to the Chain and NodeInfo.
|
5291
5292
|
*/
|
5292
5293
|
async fetchChainAndNodeInfo(ignoreCache = false) {
|
5293
|
-
|
5294
|
-
|
5295
|
-
|
5296
|
-
|
5297
|
-
chain
|
5298
|
-
|
5299
|
-
|
5300
|
-
|
5301
|
-
|
5302
|
-
|
5303
|
-
|
5304
|
-
|
5305
|
-
|
5306
|
-
|
5307
|
-
|
5308
|
-
}
|
5309
|
-
const { promise, resolve } = deferPromise();
|
5310
|
-
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
|
5311
|
-
const data = await this.operations.getChainAndNodeInfo();
|
5312
|
-
nodeInfo = deserializeNodeInfo(data.nodeInfo);
|
5313
|
-
chain = deserializeChain(data.chain);
|
5314
|
-
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
5315
|
-
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
5316
|
-
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
5317
|
-
const now = Date.now();
|
5318
|
-
this.consensusParametersTimestamp = now;
|
5319
|
-
resolve(now);
|
5320
|
-
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5294
|
+
const nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
5295
|
+
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
5296
|
+
const hasCache = nodeInfo && chain;
|
5297
|
+
if (hasCache && !ignoreCache) {
|
5298
|
+
return { nodeInfo, chain };
|
5299
|
+
}
|
5300
|
+
const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5301
|
+
if (inflightRequest) {
|
5302
|
+
return inflightRequest.then((data) => {
|
5303
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
5304
|
+
return {
|
5305
|
+
nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
|
5306
|
+
chain: _Provider.chainInfoCache[this.urlWithoutAuth]
|
5307
|
+
};
|
5308
|
+
});
|
5321
5309
|
}
|
5322
|
-
|
5323
|
-
chain,
|
5324
|
-
nodeInfo
|
5325
|
-
|
5310
|
+
const getChainAndNodeInfoFromNetwork = this.operations.getChainAndNodeInfo().then((data) => ({
|
5311
|
+
chain: deserializeChain(data.chain),
|
5312
|
+
nodeInfo: deserializeNodeInfo(data.nodeInfo),
|
5313
|
+
consensusParametersTimestamp: Date.now()
|
5314
|
+
})).then((data) => {
|
5315
|
+
_Provider.setIncompatibleNodeVersionMessage(data.nodeInfo);
|
5316
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = data.chain;
|
5317
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = data.nodeInfo;
|
5318
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
5319
|
+
return data;
|
5320
|
+
}).catch((err) => {
|
5321
|
+
const error = new import_errors20.FuelError(
|
5322
|
+
import_errors20.FuelError.CODES.CONNECTION_REFUSED,
|
5323
|
+
"Unable to fetch chain and node info from the network",
|
5324
|
+
{ url: this.urlWithoutAuth },
|
5325
|
+
err
|
5326
|
+
);
|
5327
|
+
error.cause = { code: "ECONNREFUSED" };
|
5328
|
+
throw error;
|
5329
|
+
}).finally(() => {
|
5330
|
+
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5331
|
+
});
|
5332
|
+
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = getChainAndNodeInfoFromNetwork;
|
5333
|
+
return _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth].then((data) => {
|
5334
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
5335
|
+
return {
|
5336
|
+
nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
|
5337
|
+
chain: _Provider.chainInfoCache[this.urlWithoutAuth]
|
5338
|
+
};
|
5339
|
+
});
|
5326
5340
|
}
|
5327
5341
|
/**
|
5328
5342
|
* @hidden
|
@@ -5470,8 +5484,8 @@ var Provider = class _Provider {
|
|
5470
5484
|
async getAssetDetails(assetId) {
|
5471
5485
|
const { assetMetadata } = await this.getNodeFeatures();
|
5472
5486
|
if (!assetMetadata) {
|
5473
|
-
throw new
|
5474
|
-
|
5487
|
+
throw new import_errors20.FuelError(
|
5488
|
+
import_errors20.ErrorCode.UNSUPPORTED_FEATURE,
|
5475
5489
|
"The current node does not supports fetching asset details"
|
5476
5490
|
);
|
5477
5491
|
}
|
@@ -5502,14 +5516,14 @@ var Provider = class _Provider {
|
|
5502
5516
|
}
|
5503
5517
|
} = await this.getChain();
|
5504
5518
|
if ((0, import_math19.bn)(tx.inputs.length).gt(maxInputs)) {
|
5505
|
-
throw new
|
5506
|
-
|
5519
|
+
throw new import_errors20.FuelError(
|
5520
|
+
import_errors20.ErrorCode.MAX_INPUTS_EXCEEDED,
|
5507
5521
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
5508
5522
|
);
|
5509
5523
|
}
|
5510
5524
|
if ((0, import_math19.bn)(tx.outputs.length).gt(maxOutputs)) {
|
5511
|
-
throw new
|
5512
|
-
|
5525
|
+
throw new import_errors20.FuelError(
|
5526
|
+
import_errors20.ErrorCode.MAX_OUTPUTS_EXCEEDED,
|
5513
5527
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
5514
5528
|
);
|
5515
5529
|
}
|
@@ -6190,7 +6204,7 @@ var Provider = class _Provider {
|
|
6190
6204
|
},
|
6191
6205
|
transactionIds: block.transactions.map((tx) => tx.id),
|
6192
6206
|
transactions: block.transactions.map(
|
6193
|
-
(tx) => new
|
6207
|
+
(tx) => new import_transactions24.TransactionCoder().decode((0, import_utils30.arrayify)(tx.rawPayload), 0)?.[0]
|
6194
6208
|
)
|
6195
6209
|
};
|
6196
6210
|
}
|
@@ -6206,12 +6220,12 @@ var Provider = class _Provider {
|
|
6206
6220
|
return null;
|
6207
6221
|
}
|
6208
6222
|
try {
|
6209
|
-
return new
|
6223
|
+
return new import_transactions24.TransactionCoder().decode(
|
6210
6224
|
(0, import_utils30.arrayify)(transaction.rawPayload),
|
6211
6225
|
0
|
6212
6226
|
)?.[0];
|
6213
6227
|
} catch (error) {
|
6214
|
-
if (error instanceof
|
6228
|
+
if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
6215
6229
|
console.warn("Unsupported transaction type encountered");
|
6216
6230
|
return null;
|
6217
6231
|
}
|
@@ -6232,12 +6246,12 @@ var Provider = class _Provider {
|
|
6232
6246
|
paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
|
6233
6247
|
})
|
6234
6248
|
});
|
6235
|
-
const coder = new
|
6249
|
+
const coder = new import_transactions24.TransactionCoder();
|
6236
6250
|
const transactions = edges.map(({ node: { rawPayload } }) => {
|
6237
6251
|
try {
|
6238
6252
|
return coder.decode((0, import_utils30.arrayify)(rawPayload), 0)[0];
|
6239
6253
|
} catch (error) {
|
6240
|
-
if (error instanceof
|
6254
|
+
if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
6241
6255
|
console.warn("Unsupported transaction type encountered");
|
6242
6256
|
return null;
|
6243
6257
|
}
|
@@ -6352,7 +6366,7 @@ var Provider = class _Provider {
|
|
6352
6366
|
owner: new import_address4.Address(address).toB256()
|
6353
6367
|
});
|
6354
6368
|
const messages = edges.map(({ node }) => ({
|
6355
|
-
messageId:
|
6369
|
+
messageId: import_transactions24.InputMessageCoder.getMessageId({
|
6356
6370
|
sender: node.sender,
|
6357
6371
|
recipient: node.recipient,
|
6358
6372
|
nonce: node.nonce,
|
@@ -6363,7 +6377,7 @@ var Provider = class _Provider {
|
|
6363
6377
|
recipient: new import_address4.Address(node.recipient),
|
6364
6378
|
nonce: node.nonce,
|
6365
6379
|
amount: (0, import_math19.bn)(node.amount),
|
6366
|
-
data:
|
6380
|
+
data: import_transactions24.InputMessageCoder.decodeData(node.data),
|
6367
6381
|
daHeight: (0, import_math19.bn)(node.daHeight)
|
6368
6382
|
}));
|
6369
6383
|
return {
|
@@ -6386,8 +6400,8 @@ var Provider = class _Provider {
|
|
6386
6400
|
nonce
|
6387
6401
|
};
|
6388
6402
|
if (commitBlockId && commitBlockHeight) {
|
6389
|
-
throw new
|
6390
|
-
|
6403
|
+
throw new import_errors20.FuelError(
|
6404
|
+
import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
|
6391
6405
|
"commitBlockId and commitBlockHeight cannot be used together"
|
6392
6406
|
);
|
6393
6407
|
}
|
@@ -6569,7 +6583,7 @@ var Provider = class _Provider {
|
|
6569
6583
|
return null;
|
6570
6584
|
}
|
6571
6585
|
const message = {
|
6572
|
-
messageId:
|
6586
|
+
messageId: import_transactions24.InputMessageCoder.getMessageId({
|
6573
6587
|
sender: rawMessage.sender,
|
6574
6588
|
recipient: rawMessage.recipient,
|
6575
6589
|
nonce,
|
@@ -6580,7 +6594,7 @@ var Provider = class _Provider {
|
|
6580
6594
|
recipient: new import_address4.Address(rawMessage.recipient),
|
6581
6595
|
nonce,
|
6582
6596
|
amount: (0, import_math19.bn)(rawMessage.amount),
|
6583
|
-
data:
|
6597
|
+
data: import_transactions24.InputMessageCoder.decodeData(rawMessage.data),
|
6584
6598
|
daHeight: (0, import_math19.bn)(rawMessage.daHeight)
|
6585
6599
|
};
|
6586
6600
|
return message;
|
@@ -6606,15 +6620,17 @@ var Provider = class _Provider {
|
|
6606
6620
|
extractDryRunError(transactionRequest, receipts, dryRunStatus) {
|
6607
6621
|
const status = dryRunStatus;
|
6608
6622
|
let logs = [];
|
6623
|
+
let groupedLogs = {};
|
6609
6624
|
if (transactionRequest.abis) {
|
6610
|
-
logs =
|
6625
|
+
({ logs, groupedLogs } = getAllDecodedLogs({
|
6611
6626
|
receipts,
|
6612
|
-
transactionRequest.abis.main,
|
6613
|
-
transactionRequest.abis.otherContractsAbis
|
6614
|
-
);
|
6627
|
+
mainAbi: transactionRequest.abis.main,
|
6628
|
+
externalAbis: transactionRequest.abis.otherContractsAbis
|
6629
|
+
}));
|
6615
6630
|
}
|
6616
6631
|
return extractTxError({
|
6617
6632
|
logs,
|
6633
|
+
groupedLogs,
|
6618
6634
|
receipts,
|
6619
6635
|
statusReason: status.reason
|
6620
6636
|
});
|
@@ -6646,14 +6662,14 @@ var Provider = class _Provider {
|
|
6646
6662
|
};
|
6647
6663
|
|
6648
6664
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6649
|
-
var
|
6665
|
+
var import_errors21 = require("@fuel-ts/errors");
|
6650
6666
|
var import_math20 = require("@fuel-ts/math");
|
6651
|
-
var
|
6667
|
+
var import_transactions25 = require("@fuel-ts/transactions");
|
6652
6668
|
var import_utils32 = require("@fuel-ts/utils");
|
6653
6669
|
|
6654
6670
|
// src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
|
6655
6671
|
var import_math21 = require("@fuel-ts/math");
|
6656
|
-
var
|
6672
|
+
var import_transactions26 = require("@fuel-ts/transactions");
|
6657
6673
|
var import_utils33 = require("@fuel-ts/utils");
|
6658
6674
|
|
6659
6675
|
// src/test-utils/test-asset-id.ts
|
@@ -6683,7 +6699,7 @@ var TestAssetId = class _TestAssetId {
|
|
6683
6699
|
|
6684
6700
|
// src/test-utils/wallet-config.ts
|
6685
6701
|
var import_crypto9 = require("@fuel-ts/crypto");
|
6686
|
-
var
|
6702
|
+
var import_errors27 = require("@fuel-ts/errors");
|
6687
6703
|
var import_math24 = require("@fuel-ts/math");
|
6688
6704
|
var import_utils43 = require("@fuel-ts/utils");
|
6689
6705
|
|
@@ -6692,12 +6708,12 @@ var import_hasher4 = require("@fuel-ts/hasher");
|
|
6692
6708
|
var import_utils38 = require("@fuel-ts/utils");
|
6693
6709
|
|
6694
6710
|
// src/account.ts
|
6695
|
-
var
|
6711
|
+
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
6696
6712
|
var import_address6 = require("@fuel-ts/address");
|
6697
6713
|
var import_crypto5 = require("@fuel-ts/crypto");
|
6698
|
-
var
|
6714
|
+
var import_errors22 = require("@fuel-ts/errors");
|
6699
6715
|
var import_math22 = require("@fuel-ts/math");
|
6700
|
-
var
|
6716
|
+
var import_transactions27 = require("@fuel-ts/transactions");
|
6701
6717
|
var import_utils36 = require("@fuel-ts/utils");
|
6702
6718
|
var import_ramda9 = require("ramda");
|
6703
6719
|
|
@@ -6724,12 +6740,12 @@ var AbstractAccount = class {
|
|
6724
6740
|
};
|
6725
6741
|
|
6726
6742
|
// src/utils/formatTransferToContractScriptData.ts
|
6727
|
-
var
|
6743
|
+
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
6728
6744
|
var import_address5 = require("@fuel-ts/address");
|
6729
6745
|
var import_utils35 = require("@fuel-ts/utils");
|
6730
6746
|
var asm = __toESM(require("@fuels/vm-asm"));
|
6731
6747
|
var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
|
6732
|
-
const numberCoder = new
|
6748
|
+
const numberCoder = new import_abi_coder7.BigNumberCoder("u64");
|
6733
6749
|
return transferParams.reduce((acc, transferParam) => {
|
6734
6750
|
const { assetId, amount, contractId } = transferParam;
|
6735
6751
|
const encoded = numberCoder.encode(amount);
|
@@ -6742,7 +6758,7 @@ var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferPar
|
|
6742
6758
|
await asm.initWasm();
|
6743
6759
|
let script = new Uint8Array();
|
6744
6760
|
transferParams.forEach((_, i) => {
|
6745
|
-
const offset = (
|
6761
|
+
const offset = (import_abi_coder7.CONTRACT_ID_LEN + import_abi_coder7.WORD_SIZE + import_abi_coder7.ASSET_ID_LEN) * i;
|
6746
6762
|
script = (0, import_utils35.concat)([
|
6747
6763
|
script,
|
6748
6764
|
// Load ScriptData into register 0x10.
|
@@ -6750,11 +6766,11 @@ var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferPar
|
|
6750
6766
|
// Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
|
6751
6767
|
asm.addi(17, 16, offset).to_bytes(),
|
6752
6768
|
// Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
|
6753
|
-
asm.addi(18, 17,
|
6769
|
+
asm.addi(18, 17, import_abi_coder7.CONTRACT_ID_LEN).to_bytes(),
|
6754
6770
|
// Load word to the amount at 0x12 into register 0x13.
|
6755
6771
|
asm.lw(19, 18, 0).to_bytes(),
|
6756
6772
|
// Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
|
6757
|
-
asm.addi(20, 18,
|
6773
|
+
asm.addi(20, 18, import_abi_coder7.WORD_SIZE).to_bytes(),
|
6758
6774
|
// Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
|
6759
6775
|
asm.tr(17, 19, 20).to_bytes()
|
6760
6776
|
]);
|
@@ -6803,7 +6819,7 @@ var Account = class extends AbstractAccount {
|
|
6803
6819
|
*/
|
6804
6820
|
get provider() {
|
6805
6821
|
if (!this._provider) {
|
6806
|
-
throw new
|
6822
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
6807
6823
|
}
|
6808
6824
|
return this._provider;
|
6809
6825
|
}
|
@@ -6962,8 +6978,8 @@ var Account = class extends AbstractAccount {
|
|
6962
6978
|
fundingAttempts += 1;
|
6963
6979
|
}
|
6964
6980
|
if (needsToBeFunded) {
|
6965
|
-
throw new
|
6966
|
-
|
6981
|
+
throw new import_errors22.FuelError(
|
6982
|
+
import_errors22.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
6967
6983
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6968
6984
|
);
|
6969
6985
|
}
|
@@ -7082,8 +7098,8 @@ var Account = class extends AbstractAccount {
|
|
7082
7098
|
const contractAddress = new import_address6.Address(transferParam.contractId);
|
7083
7099
|
const assetId = transferParam.assetId ? (0, import_utils36.hexlify)(transferParam.assetId) : defaultAssetId;
|
7084
7100
|
if (amount.lte(0)) {
|
7085
|
-
throw new
|
7086
|
-
|
7101
|
+
throw new import_errors22.FuelError(
|
7102
|
+
import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
7087
7103
|
"Transfer amount must be a positive number."
|
7088
7104
|
);
|
7089
7105
|
}
|
@@ -7153,7 +7169,7 @@ var Account = class extends AbstractAccount {
|
|
7153
7169
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
7154
7170
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math22.bn)("100000000000000000") }];
|
7155
7171
|
const findAssetInput = /* @__PURE__ */ __name((assetId) => txRequestClone.inputs.find((input) => {
|
7156
|
-
if (input.type ===
|
7172
|
+
if (input.type === import_transactions27.InputType.Coin) {
|
7157
7173
|
return input.assetId === assetId;
|
7158
7174
|
}
|
7159
7175
|
if (isRequestInputMessageWithoutData(input)) {
|
@@ -7199,7 +7215,7 @@ var Account = class extends AbstractAccount {
|
|
7199
7215
|
*/
|
7200
7216
|
async signMessage(message) {
|
7201
7217
|
if (!this._connector) {
|
7202
|
-
throw new
|
7218
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7203
7219
|
}
|
7204
7220
|
return this._connector.signMessage(this.address.toString(), message);
|
7205
7221
|
}
|
@@ -7211,8 +7227,8 @@ var Account = class extends AbstractAccount {
|
|
7211
7227
|
*/
|
7212
7228
|
async signTransaction(transactionRequestLike) {
|
7213
7229
|
if (!this._connector) {
|
7214
|
-
throw new
|
7215
|
-
|
7230
|
+
throw new import_errors22.FuelError(
|
7231
|
+
import_errors22.ErrorCode.MISSING_CONNECTOR,
|
7216
7232
|
"A connector is required to sign transactions."
|
7217
7233
|
);
|
7218
7234
|
}
|
@@ -7276,7 +7292,7 @@ var Account = class extends AbstractAccount {
|
|
7276
7292
|
*/
|
7277
7293
|
generateFakeResources(coins) {
|
7278
7294
|
return coins.map((coin) => ({
|
7279
|
-
id: (0, import_utils36.hexlify)((0, import_crypto5.randomBytes)(
|
7295
|
+
id: (0, import_utils36.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
|
7280
7296
|
owner: this.address,
|
7281
7297
|
blockCreated: (0, import_math22.bn)(1),
|
7282
7298
|
txCreatedIdx: (0, import_math22.bn)(1),
|
@@ -7308,8 +7324,8 @@ var Account = class extends AbstractAccount {
|
|
7308
7324
|
/** @hidden * */
|
7309
7325
|
validateTransferAmount(amount) {
|
7310
7326
|
if ((0, import_math22.bn)(amount).lte(0)) {
|
7311
|
-
throw new
|
7312
|
-
|
7327
|
+
throw new import_errors22.FuelError(
|
7328
|
+
import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
7313
7329
|
"Transfer amount must be a positive number."
|
7314
7330
|
);
|
7315
7331
|
}
|
@@ -7338,16 +7354,16 @@ var Account = class extends AbstractAccount {
|
|
7338
7354
|
if (!(0, import_utils36.isDefined)(setGasLimit)) {
|
7339
7355
|
request.gasLimit = gasUsed;
|
7340
7356
|
} else if (gasUsed.gt(setGasLimit)) {
|
7341
|
-
throw new
|
7342
|
-
|
7357
|
+
throw new import_errors22.FuelError(
|
7358
|
+
import_errors22.ErrorCode.GAS_LIMIT_TOO_LOW,
|
7343
7359
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7344
7360
|
);
|
7345
7361
|
}
|
7346
7362
|
if (!(0, import_utils36.isDefined)(setMaxFee)) {
|
7347
7363
|
request.maxFee = maxFee;
|
7348
7364
|
} else if (maxFee.gt(setMaxFee)) {
|
7349
|
-
throw new
|
7350
|
-
|
7365
|
+
throw new import_errors22.FuelError(
|
7366
|
+
import_errors22.ErrorCode.MAX_FEE_TOO_LOW,
|
7351
7367
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
7352
7368
|
);
|
7353
7369
|
}
|
@@ -7358,7 +7374,7 @@ var Account = class extends AbstractAccount {
|
|
7358
7374
|
// src/wallet/keystore-wallet.ts
|
7359
7375
|
var import_address7 = require("@fuel-ts/address");
|
7360
7376
|
var import_crypto6 = require("@fuel-ts/crypto");
|
7361
|
-
var
|
7377
|
+
var import_errors23 = require("@fuel-ts/errors");
|
7362
7378
|
var import_utils37 = require("@fuel-ts/utils");
|
7363
7379
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7364
7380
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -7436,8 +7452,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7436
7452
|
const macHashUint8Array = (0, import_crypto6.keccak256)(data);
|
7437
7453
|
const macHash = (0, import_crypto6.stringFromBuffer)(macHashUint8Array, "hex");
|
7438
7454
|
if (mac !== macHash) {
|
7439
|
-
throw new
|
7440
|
-
|
7455
|
+
throw new import_errors23.FuelError(
|
7456
|
+
import_errors23.ErrorCode.INVALID_PASSWORD,
|
7441
7457
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
7442
7458
|
);
|
7443
7459
|
}
|
@@ -7576,14 +7592,14 @@ var BaseWalletUnlocked = class extends Account {
|
|
7576
7592
|
|
7577
7593
|
// src/hdwallet/hdwallet.ts
|
7578
7594
|
var import_crypto8 = require("@fuel-ts/crypto");
|
7579
|
-
var
|
7595
|
+
var import_errors26 = require("@fuel-ts/errors");
|
7580
7596
|
var import_hasher7 = require("@fuel-ts/hasher");
|
7581
7597
|
var import_math23 = require("@fuel-ts/math");
|
7582
7598
|
var import_utils42 = require("@fuel-ts/utils");
|
7583
7599
|
|
7584
7600
|
// src/mnemonic/mnemonic.ts
|
7585
7601
|
var import_crypto7 = require("@fuel-ts/crypto");
|
7586
|
-
var
|
7602
|
+
var import_errors25 = require("@fuel-ts/errors");
|
7587
7603
|
var import_hasher6 = require("@fuel-ts/hasher");
|
7588
7604
|
var import_utils40 = require("@fuel-ts/utils");
|
7589
7605
|
|
@@ -9640,7 +9656,7 @@ var english = [
|
|
9640
9656
|
];
|
9641
9657
|
|
9642
9658
|
// src/mnemonic/utils.ts
|
9643
|
-
var
|
9659
|
+
var import_errors24 = require("@fuel-ts/errors");
|
9644
9660
|
var import_hasher5 = require("@fuel-ts/hasher");
|
9645
9661
|
var import_utils39 = require("@fuel-ts/utils");
|
9646
9662
|
function getLowerMask(bits) {
|
@@ -9694,8 +9710,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9694
9710
|
for (let i = 0; i < words.length; i += 1) {
|
9695
9711
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9696
9712
|
if (index === -1) {
|
9697
|
-
throw new
|
9698
|
-
|
9713
|
+
throw new import_errors24.FuelError(
|
9714
|
+
import_errors24.ErrorCode.INVALID_MNEMONIC,
|
9699
9715
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9700
9716
|
);
|
9701
9717
|
}
|
@@ -9711,8 +9727,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9711
9727
|
const checksumMask = getUpperMask(checksumBits);
|
9712
9728
|
const checksum = (0, import_utils39.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9713
9729
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9714
|
-
throw new
|
9715
|
-
|
9730
|
+
throw new import_errors24.FuelError(
|
9731
|
+
import_errors24.ErrorCode.INVALID_CHECKSUM,
|
9716
9732
|
"Checksum validation failed for the provided mnemonic."
|
9717
9733
|
);
|
9718
9734
|
}
|
@@ -9727,8 +9743,8 @@ var TestnetPRV = "0x04358394";
|
|
9727
9743
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9728
9744
|
function assertWordList(wordlist) {
|
9729
9745
|
if (wordlist.length !== 2048) {
|
9730
|
-
throw new
|
9731
|
-
|
9746
|
+
throw new import_errors25.FuelError(
|
9747
|
+
import_errors25.ErrorCode.INVALID_WORD_LIST,
|
9732
9748
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9733
9749
|
);
|
9734
9750
|
}
|
@@ -9736,8 +9752,8 @@ function assertWordList(wordlist) {
|
|
9736
9752
|
__name(assertWordList, "assertWordList");
|
9737
9753
|
function assertEntropy(entropy) {
|
9738
9754
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9739
|
-
throw new
|
9740
|
-
|
9755
|
+
throw new import_errors25.FuelError(
|
9756
|
+
import_errors25.ErrorCode.INVALID_ENTROPY,
|
9741
9757
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9742
9758
|
);
|
9743
9759
|
}
|
@@ -9748,7 +9764,7 @@ function assertMnemonic(words) {
|
|
9748
9764
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9749
9765
|
", "
|
9750
9766
|
)}] words, but got ${words.length}.`;
|
9751
|
-
throw new
|
9767
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
9752
9768
|
}
|
9753
9769
|
}
|
9754
9770
|
__name(assertMnemonic, "assertMnemonic");
|
@@ -9870,8 +9886,8 @@ var Mnemonic = class _Mnemonic {
|
|
9870
9886
|
static masterKeysFromSeed(seed) {
|
9871
9887
|
const seedArray = (0, import_utils40.arrayify)(seed);
|
9872
9888
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9873
|
-
throw new
|
9874
|
-
|
9889
|
+
throw new import_errors25.FuelError(
|
9890
|
+
import_errors25.ErrorCode.INVALID_SEED,
|
9875
9891
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9876
9892
|
);
|
9877
9893
|
}
|
@@ -9952,7 +9968,7 @@ __name(isValidExtendedKey, "isValidExtendedKey");
|
|
9952
9968
|
function parsePath(path2, depth = 0) {
|
9953
9969
|
const components = path2.split("/");
|
9954
9970
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9955
|
-
throw new
|
9971
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9956
9972
|
}
|
9957
9973
|
if (components[0] === "m") {
|
9958
9974
|
components.shift();
|
@@ -9985,8 +10001,8 @@ var HDWallet = class _HDWallet {
|
|
9985
10001
|
this.privateKey = (0, import_utils42.hexlify)(config.privateKey);
|
9986
10002
|
} else {
|
9987
10003
|
if (!config.publicKey) {
|
9988
|
-
throw new
|
9989
|
-
|
10004
|
+
throw new import_errors26.FuelError(
|
10005
|
+
import_errors26.ErrorCode.HD_WALLET_ERROR,
|
9990
10006
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9991
10007
|
);
|
9992
10008
|
}
|
@@ -10015,8 +10031,8 @@ var HDWallet = class _HDWallet {
|
|
10015
10031
|
const data = new Uint8Array(37);
|
10016
10032
|
if (index & HARDENED_INDEX) {
|
10017
10033
|
if (!privateKey) {
|
10018
|
-
throw new
|
10019
|
-
|
10034
|
+
throw new import_errors26.FuelError(
|
10035
|
+
import_errors26.ErrorCode.HD_WALLET_ERROR,
|
10020
10036
|
"Cannot derive a hardened index without a private Key."
|
10021
10037
|
);
|
10022
10038
|
}
|
@@ -10068,8 +10084,8 @@ var HDWallet = class _HDWallet {
|
|
10068
10084
|
*/
|
10069
10085
|
toExtendedKey(isPublic = false, testnet = false) {
|
10070
10086
|
if (this.depth >= 256) {
|
10071
|
-
throw new
|
10072
|
-
|
10087
|
+
throw new import_errors26.FuelError(
|
10088
|
+
import_errors26.ErrorCode.HD_WALLET_ERROR,
|
10073
10089
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
10074
10090
|
);
|
10075
10091
|
}
|
@@ -10100,10 +10116,10 @@ var HDWallet = class _HDWallet {
|
|
10100
10116
|
const bytes = (0, import_utils42.arrayify)(decoded);
|
10101
10117
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10102
10118
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10103
|
-
throw new
|
10119
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
10104
10120
|
}
|
10105
10121
|
if (!validChecksum) {
|
10106
|
-
throw new
|
10122
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10107
10123
|
}
|
10108
10124
|
const depth = bytes[4];
|
10109
10125
|
const parentFingerprint = (0, import_utils42.hexlify)(bytes.slice(5, 9));
|
@@ -10111,14 +10127,14 @@ var HDWallet = class _HDWallet {
|
|
10111
10127
|
const chainCode = (0, import_utils42.hexlify)(bytes.slice(13, 45));
|
10112
10128
|
const key = bytes.slice(45, 78);
|
10113
10129
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10114
|
-
throw new
|
10115
|
-
|
10130
|
+
throw new import_errors26.FuelError(
|
10131
|
+
import_errors26.ErrorCode.HD_WALLET_ERROR,
|
10116
10132
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
10117
10133
|
);
|
10118
10134
|
}
|
10119
10135
|
if (isPublicExtendedKey(bytes)) {
|
10120
10136
|
if (key[0] !== 3) {
|
10121
|
-
throw new
|
10137
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
10122
10138
|
}
|
10123
10139
|
return new _HDWallet({
|
10124
10140
|
publicKey: key,
|
@@ -10129,7 +10145,7 @@ var HDWallet = class _HDWallet {
|
|
10129
10145
|
});
|
10130
10146
|
}
|
10131
10147
|
if (key[0] !== 0) {
|
10132
|
-
throw new
|
10148
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
10133
10149
|
}
|
10134
10150
|
return new _HDWallet({
|
10135
10151
|
privateKey: key.slice(1),
|
@@ -10385,26 +10401,26 @@ var WalletsConfig = class _WalletsConfig {
|
|
10385
10401
|
amountPerCoin
|
10386
10402
|
}) {
|
10387
10403
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
10388
|
-
throw new
|
10389
|
-
|
10404
|
+
throw new import_errors27.FuelError(
|
10405
|
+
import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10390
10406
|
"Number of wallets must be greater than zero."
|
10391
10407
|
);
|
10392
10408
|
}
|
10393
10409
|
if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
|
10394
|
-
throw new
|
10395
|
-
|
10410
|
+
throw new import_errors27.FuelError(
|
10411
|
+
import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10396
10412
|
"Number of assets per wallet must be greater than zero."
|
10397
10413
|
);
|
10398
10414
|
}
|
10399
10415
|
if (coinsPerAsset <= 0) {
|
10400
|
-
throw new
|
10401
|
-
|
10416
|
+
throw new import_errors27.FuelError(
|
10417
|
+
import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10402
10418
|
"Number of coins per asset must be greater than zero."
|
10403
10419
|
);
|
10404
10420
|
}
|
10405
10421
|
if ((0, import_math24.bn)(amountPerCoin).lt(0)) {
|
10406
|
-
throw new
|
10407
|
-
|
10422
|
+
throw new import_errors27.FuelError(
|
10423
|
+
import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10408
10424
|
"Amount per coin must be greater than or equal to zero."
|
10409
10425
|
);
|
10410
10426
|
}
|