@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/index.mjs
CHANGED
@@ -707,7 +707,7 @@ var getAssetsByOwner = /* @__PURE__ */ __name(async (opts) => {
|
|
707
707
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
708
708
|
import { Address as Address4 } from "@fuel-ts/address";
|
709
709
|
import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
|
710
|
-
import { ErrorCode as ErrorCode18, FuelError as
|
710
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
|
711
711
|
import { bn as bn20 } from "@fuel-ts/math";
|
712
712
|
import { InputType as InputType7 } from "@fuel-ts/transactions";
|
713
713
|
import { arrayify as arrayify16, hexlify as hexlify17, isDefined as isDefined3 } from "@fuel-ts/utils";
|
@@ -749,7 +749,7 @@ var addAmountToCoinQuantities = /* @__PURE__ */ __name((params) => {
|
|
749
749
|
|
750
750
|
// src/providers/provider.ts
|
751
751
|
import { Address as Address2, isB256 } from "@fuel-ts/address";
|
752
|
-
import { ErrorCode as ErrorCode16, FuelError as
|
752
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError18 } from "@fuel-ts/errors";
|
753
753
|
import { bn as bn17 } from "@fuel-ts/math";
|
754
754
|
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
755
755
|
import { arrayify as arrayify12, hexlify as hexlify16, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
@@ -758,27 +758,6 @@ import { GraphQLClient } from "graphql-request";
|
|
758
758
|
import gql2 from "graphql-tag";
|
759
759
|
import { clone as clone8 } from "ramda";
|
760
760
|
|
761
|
-
// src/connectors/utils/promises.ts
|
762
|
-
import { FuelError } from "@fuel-ts/errors";
|
763
|
-
function deferPromise() {
|
764
|
-
const defer = {};
|
765
|
-
defer.promise = new Promise((resolve, reject) => {
|
766
|
-
defer.reject = reject;
|
767
|
-
defer.resolve = resolve;
|
768
|
-
});
|
769
|
-
return defer;
|
770
|
-
}
|
771
|
-
__name(deferPromise, "deferPromise");
|
772
|
-
async function withTimeout(promise, timeout = 1050) {
|
773
|
-
const timeoutPromise = new Promise((resolve, reject) => {
|
774
|
-
setTimeout(() => {
|
775
|
-
reject(new FuelError(FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
776
|
-
}, timeout);
|
777
|
-
});
|
778
|
-
return Promise.race([timeoutPromise, promise]);
|
779
|
-
}
|
780
|
-
__name(withTimeout, "withTimeout");
|
781
|
-
|
782
761
|
// src/providers/__generated__/operations.ts
|
783
762
|
import gql from "graphql-tag";
|
784
763
|
var SubmittedStatusFragmentDoc = gql`
|
@@ -1837,14 +1816,14 @@ function getSdk(requester) {
|
|
1837
1816
|
__name(getSdk, "getSdk");
|
1838
1817
|
|
1839
1818
|
// src/providers/fuel-graphql-subscriber.ts
|
1840
|
-
import { ErrorCode as ErrorCode2, FuelError as
|
1819
|
+
import { ErrorCode as ErrorCode2, FuelError as FuelError2 } from "@fuel-ts/errors";
|
1841
1820
|
import { print } from "graphql";
|
1842
1821
|
|
1843
1822
|
// src/providers/utils/handle-gql-error-message.ts
|
1844
|
-
import { ErrorCode, FuelError
|
1823
|
+
import { ErrorCode, FuelError } from "@fuel-ts/errors";
|
1845
1824
|
var mapGqlErrorMessage = /* @__PURE__ */ __name((error) => {
|
1846
1825
|
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)) {
|
1847
|
-
return new
|
1826
|
+
return new FuelError(
|
1848
1827
|
ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
1849
1828
|
`Insufficient funds or too many small value coins. Consider combining UTXOs.`,
|
1850
1829
|
{},
|
@@ -1852,20 +1831,20 @@ var mapGqlErrorMessage = /* @__PURE__ */ __name((error) => {
|
|
1852
1831
|
);
|
1853
1832
|
}
|
1854
1833
|
if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
|
1855
|
-
return new
|
1834
|
+
return new FuelError(
|
1856
1835
|
ErrorCode.ASSET_NOT_FOUND,
|
1857
1836
|
`Asset not found for given asset id.`,
|
1858
1837
|
{},
|
1859
1838
|
error
|
1860
1839
|
);
|
1861
1840
|
}
|
1862
|
-
return new
|
1841
|
+
return new FuelError(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1863
1842
|
}, "mapGqlErrorMessage");
|
1864
1843
|
var mapGqlErrorWithIncompatibleNodeVersion = /* @__PURE__ */ __name((error, incompatibleNodeVersionMessage) => {
|
1865
1844
|
if (!incompatibleNodeVersionMessage) {
|
1866
1845
|
return error;
|
1867
1846
|
}
|
1868
|
-
return new
|
1847
|
+
return new FuelError(
|
1869
1848
|
error.code,
|
1870
1849
|
`${error.message}
|
1871
1850
|
|
@@ -1884,7 +1863,7 @@ var assertGqlResponseHasNoErrors = /* @__PURE__ */ __name((errors, incompatibleN
|
|
1884
1863
|
}
|
1885
1864
|
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
1886
1865
|
throw mapGqlErrorWithIncompatibleNodeVersion(
|
1887
|
-
new
|
1866
|
+
new FuelError(ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1888
1867
|
incompatibleNodeVersionMessage
|
1889
1868
|
);
|
1890
1869
|
}, "assertGqlResponseHasNoErrors");
|
@@ -1940,7 +1919,7 @@ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
|
1940
1919
|
try {
|
1941
1920
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1942
1921
|
} catch (e) {
|
1943
|
-
throw new
|
1922
|
+
throw new FuelError2(
|
1944
1923
|
ErrorCode2.STREAM_PARSING_ERROR,
|
1945
1924
|
`Error while parsing stream data response: ${text}`
|
1946
1925
|
);
|
@@ -1961,13 +1940,13 @@ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
|
1961
1940
|
};
|
1962
1941
|
|
1963
1942
|
// src/providers/resource-cache.ts
|
1964
|
-
import { FuelError as
|
1943
|
+
import { FuelError as FuelError12, ErrorCode as ErrorCode10 } from "@fuel-ts/errors";
|
1965
1944
|
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
1966
1945
|
|
1967
1946
|
// src/providers/transaction-request/input.ts
|
1968
1947
|
import { BYTES_32, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
|
1969
1948
|
import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
1970
|
-
import { ErrorCode as ErrorCode3, FuelError as
|
1949
|
+
import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1971
1950
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1972
1951
|
import { InputType } from "@fuel-ts/transactions";
|
1973
1952
|
import { arrayify, hexlify as hexlify2 } from "@fuel-ts/utils";
|
@@ -2031,7 +2010,7 @@ var inputify = /* @__PURE__ */ __name((value) => {
|
|
2031
2010
|
};
|
2032
2011
|
}
|
2033
2012
|
default: {
|
2034
|
-
throw new
|
2013
|
+
throw new FuelError3(
|
2035
2014
|
ErrorCode3.INVALID_TRANSACTION_INPUT,
|
2036
2015
|
`Invalid transaction input type: ${type}.`
|
2037
2016
|
);
|
@@ -2041,7 +2020,7 @@ var inputify = /* @__PURE__ */ __name((value) => {
|
|
2041
2020
|
|
2042
2021
|
// src/providers/transaction-request/output.ts
|
2043
2022
|
import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
2044
|
-
import { ErrorCode as ErrorCode4, FuelError as
|
2023
|
+
import { ErrorCode as ErrorCode4, FuelError as FuelError4 } from "@fuel-ts/errors";
|
2045
2024
|
import { bn as bn3 } from "@fuel-ts/math";
|
2046
2025
|
import { OutputType } from "@fuel-ts/transactions";
|
2047
2026
|
import { hexlify as hexlify3 } from "@fuel-ts/utils";
|
@@ -2088,7 +2067,7 @@ var outputify = /* @__PURE__ */ __name((value) => {
|
|
2088
2067
|
};
|
2089
2068
|
}
|
2090
2069
|
default: {
|
2091
|
-
throw new
|
2070
|
+
throw new FuelError4(
|
2092
2071
|
ErrorCode4.INVALID_TRANSACTION_INPUT,
|
2093
2072
|
`Invalid transaction output type: ${type}.`
|
2094
2073
|
);
|
@@ -2101,7 +2080,7 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
2101
2080
|
import { Address, addressify } from "@fuel-ts/address";
|
2102
2081
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
2103
2082
|
import { randomBytes } from "@fuel-ts/crypto";
|
2104
|
-
import { FuelError as
|
2083
|
+
import { FuelError as FuelError9 } from "@fuel-ts/errors";
|
2105
2084
|
import { bn as bn8 } from "@fuel-ts/math";
|
2106
2085
|
import {
|
2107
2086
|
PolicyType,
|
@@ -2127,7 +2106,7 @@ import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs
|
|
2127
2106
|
|
2128
2107
|
// src/providers/utils/serialization.ts
|
2129
2108
|
import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
|
2130
|
-
import { ErrorCode as ErrorCode5, FuelError as
|
2109
|
+
import { ErrorCode as ErrorCode5, FuelError as FuelError5 } from "@fuel-ts/errors";
|
2131
2110
|
import { bn as bn4 } from "@fuel-ts/math";
|
2132
2111
|
import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
|
2133
2112
|
import { hexlify as hexlify4, arrayify as arrayify2 } from "@fuel-ts/utils";
|
@@ -2464,7 +2443,7 @@ var deserializeReceipt = /* @__PURE__ */ __name((receipt) => {
|
|
2464
2443
|
return burnReceipt;
|
2465
2444
|
}
|
2466
2445
|
default:
|
2467
|
-
throw new
|
2446
|
+
throw new FuelError5(ErrorCode5.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
2468
2447
|
}
|
2469
2448
|
}, "deserializeReceipt");
|
2470
2449
|
|
@@ -2489,7 +2468,7 @@ var getReceiptsWithMissingData = /* @__PURE__ */ __name((receipts) => receipts.r
|
|
2489
2468
|
var assembleReceiptByType = /* @__PURE__ */ __name((gqlReceipt) => deserializeReceipt(gqlReceipt), "assembleReceiptByType");
|
2490
2469
|
|
2491
2470
|
// src/providers/utils/block-explorer.ts
|
2492
|
-
import { ErrorCode as ErrorCode6, FuelError as
|
2471
|
+
import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/errors";
|
2493
2472
|
var DEFAULT_BLOCK_EXPLORER_URL = "https://app.fuel.network";
|
2494
2473
|
var getPathFromInput = /* @__PURE__ */ __name((key, value) => {
|
2495
2474
|
const pathMap = {
|
@@ -2523,14 +2502,14 @@ var buildBlockExplorerUrl = /* @__PURE__ */ __name((options = {}) => {
|
|
2523
2502
|
}));
|
2524
2503
|
const hasAnyDefinedValues = definedValues.length > 0;
|
2525
2504
|
if (definedValues.length > 1) {
|
2526
|
-
throw new
|
2505
|
+
throw new FuelError6(
|
2527
2506
|
ErrorCode6.ERROR_BUILDING_BLOCK_EXPLORER_URL,
|
2528
2507
|
`Only one of the following can be passed in to buildBlockExplorerUrl: ${customInputParams.map((param) => param.key).join(", ")}.`
|
2529
2508
|
);
|
2530
2509
|
}
|
2531
2510
|
if (path && definedValues.length > 0) {
|
2532
2511
|
const inputKeys = customInputParams.map(({ key }) => key).join(", ");
|
2533
|
-
throw new
|
2512
|
+
throw new FuelError6(
|
2534
2513
|
ErrorCode6.ERROR_BUILDING_BLOCK_EXPLORER_URL,
|
2535
2514
|
`You cannot pass in a path to 'buildBlockExplorerUrl' along with any of the following: ${inputKeys}.`
|
2536
2515
|
);
|
@@ -2732,7 +2711,7 @@ function normalizeJSON(root) {
|
|
2732
2711
|
__name(normalizeJSON, "normalizeJSON");
|
2733
2712
|
|
2734
2713
|
// src/providers/utils/extract-tx-error.ts
|
2735
|
-
import { ErrorCode as ErrorCode7, FuelError as
|
2714
|
+
import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
|
2736
2715
|
import { bn as bn6 } from "@fuel-ts/math";
|
2737
2716
|
import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
|
2738
2717
|
import {
|
@@ -2753,7 +2732,7 @@ You can read more about this error at:
|
|
2753
2732
|
|
2754
2733
|
${PANIC_DOC_URL}#variant.${statusReason}`;
|
2755
2734
|
}
|
2756
|
-
return new
|
2735
|
+
return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2757
2736
|
...metadata,
|
2758
2737
|
reason: statusReason
|
2759
2738
|
});
|
@@ -2794,7 +2773,7 @@ var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
|
|
2794
2773
|
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2795
2774
|
break;
|
2796
2775
|
default:
|
2797
|
-
throw new
|
2776
|
+
throw new FuelError7(
|
2798
2777
|
ErrorCode7.UNKNOWN,
|
2799
2778
|
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2800
2779
|
{
|
@@ -2804,17 +2783,18 @@ var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
|
|
2804
2783
|
);
|
2805
2784
|
}
|
2806
2785
|
}
|
2807
|
-
return new
|
2786
|
+
return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2808
2787
|
...metadata,
|
2809
2788
|
reason
|
2810
2789
|
});
|
2811
2790
|
}, "assembleRevertError");
|
2812
2791
|
var extractTxError = /* @__PURE__ */ __name((params) => {
|
2813
|
-
const { receipts, statusReason, logs } = params;
|
2792
|
+
const { receipts, statusReason, logs, groupedLogs } = params;
|
2814
2793
|
const isPanic = receipts.some(({ type }) => type === ReceiptType4.Panic);
|
2815
2794
|
const isRevert = receipts.some(({ type }) => type === ReceiptType4.Revert);
|
2816
2795
|
const metadata = {
|
2817
2796
|
logs,
|
2797
|
+
groupedLogs,
|
2818
2798
|
receipts,
|
2819
2799
|
panic: isPanic,
|
2820
2800
|
revert: isRevert,
|
@@ -2858,7 +2838,7 @@ var NoWitnessByOwnerError = class extends Error {
|
|
2858
2838
|
};
|
2859
2839
|
|
2860
2840
|
// src/providers/transaction-request/helpers.ts
|
2861
|
-
import { ErrorCode as ErrorCode8, FuelError as
|
2841
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2862
2842
|
import { bn as bn7 } from "@fuel-ts/math";
|
2863
2843
|
import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
|
2864
2844
|
import { hexlify as hexlify6 } from "@fuel-ts/utils";
|
@@ -2931,7 +2911,7 @@ var validateTransactionForAssetBurn = /* @__PURE__ */ __name((baseAssetId, trans
|
|
2931
2911
|
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
2932
2912
|
"Or enable asset burn, upon sending the transaction."
|
2933
2913
|
].join("\n");
|
2934
|
-
throw new
|
2914
|
+
throw new FuelError8(ErrorCode8.ASSET_BURN_DETECTED, message);
|
2935
2915
|
}, "validateTransactionForAssetBurn");
|
2936
2916
|
|
2937
2917
|
// src/providers/transaction-request/witness.ts
|
@@ -3332,7 +3312,7 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
|
|
3332
3312
|
* @hidden
|
3333
3313
|
*/
|
3334
3314
|
metadataGas(_gasCosts) {
|
3335
|
-
throw new
|
3315
|
+
throw new FuelError9(FuelError9.CODES.NOT_IMPLEMENTED, "Not implemented");
|
3336
3316
|
}
|
3337
3317
|
/**
|
3338
3318
|
* @hidden
|
@@ -3971,7 +3951,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3971
3951
|
};
|
3972
3952
|
|
3973
3953
|
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3974
|
-
import { FuelError as
|
3954
|
+
import { FuelError as FuelError10 } from "@fuel-ts/errors";
|
3975
3955
|
import { hash } from "@fuel-ts/hasher";
|
3976
3956
|
import {
|
3977
3957
|
TransactionType as TransactionType5,
|
@@ -4081,7 +4061,7 @@ var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTra
|
|
4081
4061
|
}
|
4082
4062
|
};
|
4083
4063
|
} else {
|
4084
|
-
throw new
|
4064
|
+
throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
4085
4065
|
}
|
4086
4066
|
return {
|
4087
4067
|
type: TransactionType5.Upgrade,
|
@@ -4123,7 +4103,7 @@ var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTra
|
|
4123
4103
|
txBytesSize
|
4124
4104
|
});
|
4125
4105
|
}
|
4126
|
-
throw new
|
4106
|
+
throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
4127
4107
|
}
|
4128
4108
|
};
|
4129
4109
|
|
@@ -4244,7 +4224,7 @@ var AbstractScriptRequest = class {
|
|
4244
4224
|
};
|
4245
4225
|
|
4246
4226
|
// src/providers/transaction-request/utils.ts
|
4247
|
-
import { ErrorCode as ErrorCode9, FuelError as
|
4227
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError11 } from "@fuel-ts/errors";
|
4248
4228
|
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
4249
4229
|
var transactionRequestify = /* @__PURE__ */ __name((obj) => {
|
4250
4230
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
@@ -4268,7 +4248,7 @@ var transactionRequestify = /* @__PURE__ */ __name((obj) => {
|
|
4268
4248
|
return UploadTransactionRequest.from(obj);
|
4269
4249
|
}
|
4270
4250
|
default: {
|
4271
|
-
throw new
|
4251
|
+
throw new FuelError11(
|
4272
4252
|
ErrorCode9.UNSUPPORTED_TRANSACTION_TYPE,
|
4273
4253
|
`Unsupported transaction type: ${type}.`
|
4274
4254
|
);
|
@@ -4291,7 +4271,7 @@ var ResourceCache = class {
|
|
4291
4271
|
constructor(ttl) {
|
4292
4272
|
this.ttl = ttl;
|
4293
4273
|
if (typeof ttl !== "number" || this.ttl <= 0) {
|
4294
|
-
throw new
|
4274
|
+
throw new FuelError12(
|
4295
4275
|
ErrorCode10.INVALID_TTL,
|
4296
4276
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
4297
4277
|
);
|
@@ -4376,7 +4356,7 @@ var ResourceCache = class {
|
|
4376
4356
|
};
|
4377
4357
|
|
4378
4358
|
// src/providers/transaction-response/transaction-response.ts
|
4379
|
-
import { ErrorCode as ErrorCode14, FuelError as
|
4359
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError16 } from "@fuel-ts/errors";
|
4380
4360
|
import { bn as bn16 } from "@fuel-ts/math";
|
4381
4361
|
import { OutputType as OutputType8, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
4382
4362
|
import { arrayify as arrayify11, assertUnreachable } from "@fuel-ts/utils";
|
@@ -4454,12 +4434,12 @@ var calculateTXFeeForSummary = /* @__PURE__ */ __name((params) => {
|
|
4454
4434
|
|
4455
4435
|
// src/providers/transaction-summary/operations.ts
|
4456
4436
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
4457
|
-
import { ErrorCode as ErrorCode12, FuelError as
|
4437
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4458
4438
|
import { bn as bn13 } from "@fuel-ts/math";
|
4459
4439
|
import { ReceiptType as ReceiptType5, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
4460
4440
|
|
4461
4441
|
// src/providers/transaction-summary/input.ts
|
4462
|
-
import { ErrorCode as ErrorCode11, FuelError as
|
4442
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError13 } from "@fuel-ts/errors";
|
4463
4443
|
import { BN } from "@fuel-ts/math";
|
4464
4444
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
4465
4445
|
function getInputsByTypes(inputs, types) {
|
@@ -4539,7 +4519,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
4539
4519
|
return void 0;
|
4540
4520
|
}
|
4541
4521
|
if (contractInput.type !== InputType6.Contract) {
|
4542
|
-
throw new
|
4522
|
+
throw new FuelError13(
|
4543
4523
|
ErrorCode11.INVALID_TRANSACTION_INPUT,
|
4544
4524
|
`Contract input should be of type 'contract'.`
|
4545
4525
|
);
|
@@ -4642,7 +4622,7 @@ function getTransactionTypeName(transactionType) {
|
|
4642
4622
|
case TransactionType9.Upload:
|
4643
4623
|
return "Upload" /* Upload */;
|
4644
4624
|
default:
|
4645
|
-
throw new
|
4625
|
+
throw new FuelError14(
|
4646
4626
|
ErrorCode12.UNSUPPORTED_TRANSACTION_TYPE,
|
4647
4627
|
`Unsupported transaction type: ${transactionType}.`
|
4648
4628
|
);
|
@@ -5057,7 +5037,7 @@ var extractBurnedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
|
5057
5037
|
}, "extractBurnedAssetsFromReceipts");
|
5058
5038
|
|
5059
5039
|
// src/providers/transaction-summary/status.ts
|
5060
|
-
import { ErrorCode as ErrorCode13, FuelError as
|
5040
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError15 } from "@fuel-ts/errors";
|
5061
5041
|
import { bn as bn14 } from "@fuel-ts/math";
|
5062
5042
|
var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
|
5063
5043
|
switch (gqlStatus) {
|
@@ -5070,7 +5050,7 @@ var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
|
|
5070
5050
|
case "SqueezedOutStatus":
|
5071
5051
|
return "squeezedout" /* squeezedout */;
|
5072
5052
|
default:
|
5073
|
-
throw new
|
5053
|
+
throw new FuelError15(
|
5074
5054
|
ErrorCode13.INVALID_TRANSACTION_STATUS,
|
5075
5055
|
`Invalid transaction status: ${gqlStatus}.`
|
5076
5056
|
);
|
@@ -5203,11 +5183,12 @@ function assembleTransactionSummary(params) {
|
|
5203
5183
|
}
|
5204
5184
|
__name(assembleTransactionSummary, "assembleTransactionSummary");
|
5205
5185
|
|
5206
|
-
// src/providers/transaction-response/
|
5186
|
+
// src/providers/transaction-response/getAllDecodedLogs.ts
|
5207
5187
|
import { Interface as Interface2, BigNumberCoder } from "@fuel-ts/abi-coder";
|
5208
5188
|
import { ZeroBytes32 as ZeroBytes3210 } from "@fuel-ts/address/configs";
|
5209
5189
|
import { ReceiptType as ReceiptType7 } from "@fuel-ts/transactions";
|
5210
|
-
function
|
5190
|
+
function getAllDecodedLogs(opts) {
|
5191
|
+
const { receipts, mainAbi, externalAbis = {} } = opts;
|
5211
5192
|
let mainContract = "";
|
5212
5193
|
if (mainAbi.programType === "contract") {
|
5213
5194
|
const firstCallReceipt = receipts.find(
|
@@ -5215,21 +5196,25 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
5215
5196
|
);
|
5216
5197
|
mainContract = firstCallReceipt.to;
|
5217
5198
|
}
|
5218
|
-
return receipts.reduce(
|
5219
|
-
|
5220
|
-
|
5221
|
-
|
5222
|
-
|
5223
|
-
|
5224
|
-
|
5225
|
-
|
5226
|
-
|
5199
|
+
return receipts.reduce(
|
5200
|
+
({ logs, groupedLogs }, receipt) => {
|
5201
|
+
if (receipt.type === ReceiptType7.LogData || receipt.type === ReceiptType7.Log) {
|
5202
|
+
const isLogFromMainAbi = receipt.id === ZeroBytes3210 || mainContract === receipt.id;
|
5203
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
5204
|
+
if (isDecodable) {
|
5205
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface2(mainAbi) : new Interface2(externalAbis[receipt.id]);
|
5206
|
+
const data = receipt.type === ReceiptType7.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
5207
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
5208
|
+
logs.push(decodedLog);
|
5209
|
+
groupedLogs[receipt.id] = [...groupedLogs[receipt.id] || [], decodedLog];
|
5210
|
+
}
|
5227
5211
|
}
|
5228
|
-
|
5229
|
-
|
5230
|
-
|
5212
|
+
return { logs, groupedLogs };
|
5213
|
+
},
|
5214
|
+
{ logs: [], groupedLogs: {} }
|
5215
|
+
);
|
5231
5216
|
}
|
5232
|
-
__name(
|
5217
|
+
__name(getAllDecodedLogs, "getAllDecodedLogs");
|
5233
5218
|
|
5234
5219
|
// src/providers/transaction-response/transaction-response.ts
|
5235
5220
|
function mapGqlOutputsToTxOutputs(outputs) {
|
@@ -5434,7 +5419,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
5434
5419
|
this.status = statusChange;
|
5435
5420
|
if (statusChange.type === "SqueezedOutStatus") {
|
5436
5421
|
this.unsetResourceCache();
|
5437
|
-
throw new
|
5422
|
+
throw new FuelError16(
|
5438
5423
|
ErrorCode14.TRANSACTION_SQUEEZED_OUT,
|
5439
5424
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
5440
5425
|
);
|
@@ -5461,14 +5446,15 @@ var TransactionResponse = class _TransactionResponse {
|
|
5461
5446
|
const transactionResult = {
|
5462
5447
|
...transactionSummary
|
5463
5448
|
};
|
5464
|
-
let logs = [];
|
5449
|
+
let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
|
5465
5450
|
if (this.abis) {
|
5466
|
-
logs =
|
5467
|
-
transactionSummary.receipts,
|
5468
|
-
this.abis.main,
|
5469
|
-
this.abis.otherContractsAbis
|
5470
|
-
);
|
5451
|
+
({ logs, groupedLogs } = getAllDecodedLogs({
|
5452
|
+
receipts: transactionSummary.receipts,
|
5453
|
+
mainAbi: this.abis.main,
|
5454
|
+
externalAbis: this.abis.otherContractsAbis
|
5455
|
+
}));
|
5471
5456
|
transactionResult.logs = logs;
|
5457
|
+
transactionResult.groupedLogs = groupedLogs;
|
5472
5458
|
}
|
5473
5459
|
const { receipts } = transactionResult;
|
5474
5460
|
const status = this.status ?? this.gqlTransaction?.status;
|
@@ -5477,7 +5463,8 @@ var TransactionResponse = class _TransactionResponse {
|
|
5477
5463
|
throw extractTxError({
|
5478
5464
|
receipts,
|
5479
5465
|
statusReason: reason,
|
5480
|
-
logs
|
5466
|
+
logs,
|
5467
|
+
groupedLogs
|
5481
5468
|
});
|
5482
5469
|
}
|
5483
5470
|
return transactionResult;
|
@@ -5505,6 +5492,34 @@ var TransactionResponse = class _TransactionResponse {
|
|
5505
5492
|
}
|
5506
5493
|
};
|
5507
5494
|
|
5495
|
+
// src/providers/transaction-response/getDecodedLogs.ts
|
5496
|
+
import { Interface as Interface3, BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
5497
|
+
import { ZeroBytes32 as ZeroBytes3211 } from "@fuel-ts/address/configs";
|
5498
|
+
import { ReceiptType as ReceiptType8 } from "@fuel-ts/transactions";
|
5499
|
+
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
5500
|
+
let mainContract = "";
|
5501
|
+
if (mainAbi.programType === "contract") {
|
5502
|
+
const firstCallReceipt = receipts.find(
|
5503
|
+
(r) => r.type === ReceiptType8.Call && r.id === ZeroBytes3211
|
5504
|
+
);
|
5505
|
+
mainContract = firstCallReceipt.to;
|
5506
|
+
}
|
5507
|
+
return receipts.reduce((logs, receipt) => {
|
5508
|
+
if (receipt.type === ReceiptType8.LogData || receipt.type === ReceiptType8.Log) {
|
5509
|
+
const isLogFromMainAbi = receipt.id === ZeroBytes3211 || mainContract === receipt.id;
|
5510
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
5511
|
+
if (isDecodable) {
|
5512
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface3(mainAbi) : new Interface3(externalAbis[receipt.id]);
|
5513
|
+
const data = receipt.type === ReceiptType8.Log ? new BigNumberCoder2("u64").encode(receipt.ra) : receipt.data;
|
5514
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
5515
|
+
logs.push(decodedLog);
|
5516
|
+
}
|
5517
|
+
}
|
5518
|
+
return logs;
|
5519
|
+
}, []);
|
5520
|
+
}
|
5521
|
+
__name(getDecodedLogs, "getDecodedLogs");
|
5522
|
+
|
5508
5523
|
// src/providers/utils/auto-retry-fetch.ts
|
5509
5524
|
import { sleep } from "@fuel-ts/utils";
|
5510
5525
|
function getWaitDelay(options, retryAttemptNum) {
|
@@ -5561,30 +5576,30 @@ var adjustResourcesToExclude = /* @__PURE__ */ __name((params) => {
|
|
5561
5576
|
}, "adjustResourcesToExclude");
|
5562
5577
|
|
5563
5578
|
// src/providers/utils/validate-pagination-args.ts
|
5564
|
-
import { FuelError as
|
5579
|
+
import { FuelError as FuelError17, ErrorCode as ErrorCode15 } from "@fuel-ts/errors";
|
5565
5580
|
var validatePaginationArgs = /* @__PURE__ */ __name((params) => {
|
5566
5581
|
const { paginationLimit, inputArgs = {} } = params;
|
5567
5582
|
const { first, last, after, before } = inputArgs;
|
5568
5583
|
if (after && before) {
|
5569
|
-
throw new
|
5584
|
+
throw new FuelError17(
|
5570
5585
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5571
5586
|
'Pagination arguments "after" and "before" cannot be used together'
|
5572
5587
|
);
|
5573
5588
|
}
|
5574
5589
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5575
|
-
throw new
|
5590
|
+
throw new FuelError17(
|
5576
5591
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5577
5592
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5578
5593
|
);
|
5579
5594
|
}
|
5580
5595
|
if (first && before) {
|
5581
|
-
throw new
|
5596
|
+
throw new FuelError17(
|
5582
5597
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5583
5598
|
'The use of pagination argument "first" with "before" is not supported'
|
5584
5599
|
);
|
5585
5600
|
}
|
5586
5601
|
if (last && after) {
|
5587
|
-
throw new
|
5602
|
+
throw new FuelError17(
|
5588
5603
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5589
5604
|
'The use of pagination argument "last" with "after" is not supported'
|
5590
5605
|
);
|
@@ -5700,7 +5715,7 @@ var Provider = class _Provider {
|
|
5700
5715
|
try {
|
5701
5716
|
parsedUrl = new URL(url);
|
5702
5717
|
} catch (error) {
|
5703
|
-
throw new
|
5718
|
+
throw new FuelError18(FuelError18.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
5704
5719
|
}
|
5705
5720
|
const username = parsedUrl.username;
|
5706
5721
|
const password = parsedUrl.password;
|
@@ -5778,39 +5793,52 @@ var Provider = class _Provider {
|
|
5778
5793
|
* @returns A promise that resolves to the Chain and NodeInfo.
|
5779
5794
|
*/
|
5780
5795
|
async fetchChainAndNodeInfo(ignoreCache = false) {
|
5781
|
-
|
5782
|
-
|
5783
|
-
|
5784
|
-
|
5785
|
-
chain
|
5786
|
-
|
5787
|
-
|
5788
|
-
|
5789
|
-
|
5790
|
-
|
5791
|
-
|
5792
|
-
|
5793
|
-
|
5794
|
-
|
5795
|
-
|
5796
|
-
}
|
5797
|
-
const { promise, resolve } = deferPromise();
|
5798
|
-
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
|
5799
|
-
const data = await this.operations.getChainAndNodeInfo();
|
5800
|
-
nodeInfo = deserializeNodeInfo(data.nodeInfo);
|
5801
|
-
chain = deserializeChain(data.chain);
|
5802
|
-
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
5803
|
-
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
5804
|
-
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
5805
|
-
const now = Date.now();
|
5806
|
-
this.consensusParametersTimestamp = now;
|
5807
|
-
resolve(now);
|
5808
|
-
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5796
|
+
const nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
5797
|
+
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
5798
|
+
const hasCache = nodeInfo && chain;
|
5799
|
+
if (hasCache && !ignoreCache) {
|
5800
|
+
return { nodeInfo, chain };
|
5801
|
+
}
|
5802
|
+
const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5803
|
+
if (inflightRequest) {
|
5804
|
+
return inflightRequest.then((data) => {
|
5805
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
5806
|
+
return {
|
5807
|
+
nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
|
5808
|
+
chain: _Provider.chainInfoCache[this.urlWithoutAuth]
|
5809
|
+
};
|
5810
|
+
});
|
5809
5811
|
}
|
5810
|
-
|
5811
|
-
chain,
|
5812
|
-
nodeInfo
|
5813
|
-
|
5812
|
+
const getChainAndNodeInfoFromNetwork = this.operations.getChainAndNodeInfo().then((data) => ({
|
5813
|
+
chain: deserializeChain(data.chain),
|
5814
|
+
nodeInfo: deserializeNodeInfo(data.nodeInfo),
|
5815
|
+
consensusParametersTimestamp: Date.now()
|
5816
|
+
})).then((data) => {
|
5817
|
+
_Provider.setIncompatibleNodeVersionMessage(data.nodeInfo);
|
5818
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = data.chain;
|
5819
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = data.nodeInfo;
|
5820
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
5821
|
+
return data;
|
5822
|
+
}).catch((err) => {
|
5823
|
+
const error = new FuelError18(
|
5824
|
+
FuelError18.CODES.CONNECTION_REFUSED,
|
5825
|
+
"Unable to fetch chain and node info from the network",
|
5826
|
+
{ url: this.urlWithoutAuth },
|
5827
|
+
err
|
5828
|
+
);
|
5829
|
+
error.cause = { code: "ECONNREFUSED" };
|
5830
|
+
throw error;
|
5831
|
+
}).finally(() => {
|
5832
|
+
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5833
|
+
});
|
5834
|
+
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = getChainAndNodeInfoFromNetwork;
|
5835
|
+
return _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth].then((data) => {
|
5836
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
5837
|
+
return {
|
5838
|
+
nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
|
5839
|
+
chain: _Provider.chainInfoCache[this.urlWithoutAuth]
|
5840
|
+
};
|
5841
|
+
});
|
5814
5842
|
}
|
5815
5843
|
/**
|
5816
5844
|
* @hidden
|
@@ -5958,7 +5986,7 @@ var Provider = class _Provider {
|
|
5958
5986
|
async getAssetDetails(assetId) {
|
5959
5987
|
const { assetMetadata } = await this.getNodeFeatures();
|
5960
5988
|
if (!assetMetadata) {
|
5961
|
-
throw new
|
5989
|
+
throw new FuelError18(
|
5962
5990
|
ErrorCode16.UNSUPPORTED_FEATURE,
|
5963
5991
|
"The current node does not supports fetching asset details"
|
5964
5992
|
);
|
@@ -5990,13 +6018,13 @@ var Provider = class _Provider {
|
|
5990
6018
|
}
|
5991
6019
|
} = await this.getChain();
|
5992
6020
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
5993
|
-
throw new
|
6021
|
+
throw new FuelError18(
|
5994
6022
|
ErrorCode16.MAX_INPUTS_EXCEEDED,
|
5995
6023
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
5996
6024
|
);
|
5997
6025
|
}
|
5998
6026
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
5999
|
-
throw new
|
6027
|
+
throw new FuelError18(
|
6000
6028
|
ErrorCode16.MAX_OUTPUTS_EXCEEDED,
|
6001
6029
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
6002
6030
|
);
|
@@ -6699,7 +6727,7 @@ var Provider = class _Provider {
|
|
6699
6727
|
0
|
6700
6728
|
)?.[0];
|
6701
6729
|
} catch (error) {
|
6702
|
-
if (error instanceof
|
6730
|
+
if (error instanceof FuelError18 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
6703
6731
|
console.warn("Unsupported transaction type encountered");
|
6704
6732
|
return null;
|
6705
6733
|
}
|
@@ -6725,7 +6753,7 @@ var Provider = class _Provider {
|
|
6725
6753
|
try {
|
6726
6754
|
return coder.decode(arrayify12(rawPayload), 0)[0];
|
6727
6755
|
} catch (error) {
|
6728
|
-
if (error instanceof
|
6756
|
+
if (error instanceof FuelError18 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
6729
6757
|
console.warn("Unsupported transaction type encountered");
|
6730
6758
|
return null;
|
6731
6759
|
}
|
@@ -6874,7 +6902,7 @@ var Provider = class _Provider {
|
|
6874
6902
|
nonce
|
6875
6903
|
};
|
6876
6904
|
if (commitBlockId && commitBlockHeight) {
|
6877
|
-
throw new
|
6905
|
+
throw new FuelError18(
|
6878
6906
|
ErrorCode16.INVALID_INPUT_PARAMETERS,
|
6879
6907
|
"commitBlockId and commitBlockHeight cannot be used together"
|
6880
6908
|
);
|
@@ -7094,15 +7122,17 @@ var Provider = class _Provider {
|
|
7094
7122
|
extractDryRunError(transactionRequest, receipts, dryRunStatus) {
|
7095
7123
|
const status = dryRunStatus;
|
7096
7124
|
let logs = [];
|
7125
|
+
let groupedLogs = {};
|
7097
7126
|
if (transactionRequest.abis) {
|
7098
|
-
logs =
|
7127
|
+
({ logs, groupedLogs } = getAllDecodedLogs({
|
7099
7128
|
receipts,
|
7100
|
-
transactionRequest.abis.main,
|
7101
|
-
transactionRequest.abis.otherContractsAbis
|
7102
|
-
);
|
7129
|
+
mainAbi: transactionRequest.abis.main,
|
7130
|
+
externalAbis: transactionRequest.abis.otherContractsAbis
|
7131
|
+
}));
|
7103
7132
|
}
|
7104
7133
|
return extractTxError({
|
7105
7134
|
logs,
|
7135
|
+
groupedLogs,
|
7106
7136
|
receipts,
|
7107
7137
|
statusReason: status.reason
|
7108
7138
|
});
|
@@ -7134,7 +7164,7 @@ var Provider = class _Provider {
|
|
7134
7164
|
};
|
7135
7165
|
|
7136
7166
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
7137
|
-
import { ErrorCode as ErrorCode17, FuelError as
|
7167
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
|
7138
7168
|
import { bn as bn18 } from "@fuel-ts/math";
|
7139
7169
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
7140
7170
|
import { arrayify as arrayify13 } from "@fuel-ts/utils";
|
@@ -7144,7 +7174,7 @@ async function getTransactionSummary(params) {
|
|
7144
7174
|
transactionId: id
|
7145
7175
|
});
|
7146
7176
|
if (!gqlTransaction) {
|
7147
|
-
throw new
|
7177
|
+
throw new FuelError19(
|
7148
7178
|
ErrorCode17.TRANSACTION_NOT_FOUND,
|
7149
7179
|
`Transaction not found for given id: ${id}.`
|
7150
7180
|
);
|
@@ -7327,12 +7357,12 @@ var AbstractAccount = class {
|
|
7327
7357
|
};
|
7328
7358
|
|
7329
7359
|
// src/utils/formatTransferToContractScriptData.ts
|
7330
|
-
import { ASSET_ID_LEN, BigNumberCoder as
|
7360
|
+
import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder3, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
|
7331
7361
|
import { Address as Address3 } from "@fuel-ts/address";
|
7332
7362
|
import { arrayify as arrayify15, concat as concat3 } from "@fuel-ts/utils";
|
7333
7363
|
import * as asm from "@fuels/vm-asm";
|
7334
7364
|
var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
|
7335
|
-
const numberCoder = new
|
7365
|
+
const numberCoder = new BigNumberCoder3("u64");
|
7336
7366
|
return transferParams.reduce((acc, transferParam) => {
|
7337
7367
|
const { assetId, amount, contractId } = transferParam;
|
7338
7368
|
const encoded = numberCoder.encode(amount);
|
@@ -7406,7 +7436,7 @@ var Account = class extends AbstractAccount {
|
|
7406
7436
|
*/
|
7407
7437
|
get provider() {
|
7408
7438
|
if (!this._provider) {
|
7409
|
-
throw new
|
7439
|
+
throw new FuelError20(ErrorCode18.MISSING_PROVIDER, "Provider not set");
|
7410
7440
|
}
|
7411
7441
|
return this._provider;
|
7412
7442
|
}
|
@@ -7565,7 +7595,7 @@ var Account = class extends AbstractAccount {
|
|
7565
7595
|
fundingAttempts += 1;
|
7566
7596
|
}
|
7567
7597
|
if (needsToBeFunded) {
|
7568
|
-
throw new
|
7598
|
+
throw new FuelError20(
|
7569
7599
|
ErrorCode18.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
7570
7600
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
7571
7601
|
);
|
@@ -7685,7 +7715,7 @@ var Account = class extends AbstractAccount {
|
|
7685
7715
|
const contractAddress = new Address4(transferParam.contractId);
|
7686
7716
|
const assetId = transferParam.assetId ? hexlify17(transferParam.assetId) : defaultAssetId;
|
7687
7717
|
if (amount.lte(0)) {
|
7688
|
-
throw new
|
7718
|
+
throw new FuelError20(
|
7689
7719
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7690
7720
|
"Transfer amount must be a positive number."
|
7691
7721
|
);
|
@@ -7802,7 +7832,7 @@ var Account = class extends AbstractAccount {
|
|
7802
7832
|
*/
|
7803
7833
|
async signMessage(message) {
|
7804
7834
|
if (!this._connector) {
|
7805
|
-
throw new
|
7835
|
+
throw new FuelError20(ErrorCode18.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7806
7836
|
}
|
7807
7837
|
return this._connector.signMessage(this.address.toString(), message);
|
7808
7838
|
}
|
@@ -7814,7 +7844,7 @@ var Account = class extends AbstractAccount {
|
|
7814
7844
|
*/
|
7815
7845
|
async signTransaction(transactionRequestLike) {
|
7816
7846
|
if (!this._connector) {
|
7817
|
-
throw new
|
7847
|
+
throw new FuelError20(
|
7818
7848
|
ErrorCode18.MISSING_CONNECTOR,
|
7819
7849
|
"A connector is required to sign transactions."
|
7820
7850
|
);
|
@@ -7911,7 +7941,7 @@ var Account = class extends AbstractAccount {
|
|
7911
7941
|
/** @hidden * */
|
7912
7942
|
validateTransferAmount(amount) {
|
7913
7943
|
if (bn20(amount).lte(0)) {
|
7914
|
-
throw new
|
7944
|
+
throw new FuelError20(
|
7915
7945
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7916
7946
|
"Transfer amount must be a positive number."
|
7917
7947
|
);
|
@@ -7941,7 +7971,7 @@ var Account = class extends AbstractAccount {
|
|
7941
7971
|
if (!isDefined3(setGasLimit)) {
|
7942
7972
|
request2.gasLimit = gasUsed;
|
7943
7973
|
} else if (gasUsed.gt(setGasLimit)) {
|
7944
|
-
throw new
|
7974
|
+
throw new FuelError20(
|
7945
7975
|
ErrorCode18.GAS_LIMIT_TOO_LOW,
|
7946
7976
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7947
7977
|
);
|
@@ -7949,7 +7979,7 @@ var Account = class extends AbstractAccount {
|
|
7949
7979
|
if (!isDefined3(setMaxFee)) {
|
7950
7980
|
request2.maxFee = maxFee;
|
7951
7981
|
} else if (maxFee.gt(setMaxFee)) {
|
7952
|
-
throw new
|
7982
|
+
throw new FuelError20(
|
7953
7983
|
ErrorCode18.MAX_FEE_TOO_LOW,
|
7954
7984
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
7955
7985
|
);
|
@@ -8086,7 +8116,7 @@ import {
|
|
8086
8116
|
encryptJsonWalletData,
|
8087
8117
|
randomUUID
|
8088
8118
|
} from "@fuel-ts/crypto";
|
8089
|
-
import { ErrorCode as ErrorCode19, FuelError as
|
8119
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
|
8090
8120
|
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
8091
8121
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
8092
8122
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -8164,7 +8194,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
8164
8194
|
const macHashUint8Array = keccak256(data);
|
8165
8195
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
8166
8196
|
if (mac !== macHash) {
|
8167
|
-
throw new
|
8197
|
+
throw new FuelError21(
|
8168
8198
|
ErrorCode19.INVALID_PASSWORD,
|
8169
8199
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
8170
8200
|
);
|
@@ -8304,14 +8334,14 @@ var BaseWalletUnlocked = class extends Account {
|
|
8304
8334
|
|
8305
8335
|
// src/hdwallet/hdwallet.ts
|
8306
8336
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
8307
|
-
import { ErrorCode as ErrorCode22, FuelError as
|
8337
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8308
8338
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
8309
8339
|
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
8310
8340
|
import { arrayify as arrayify20, hexlify as hexlify22, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
8311
8341
|
|
8312
8342
|
// src/mnemonic/mnemonic.ts
|
8313
8343
|
import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
8314
|
-
import { ErrorCode as ErrorCode21, FuelError as
|
8344
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError23 } from "@fuel-ts/errors";
|
8315
8345
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
8316
8346
|
import { arrayify as arrayify19, hexlify as hexlify21, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
8317
8347
|
|
@@ -10374,7 +10404,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
10374
10404
|
})(Language || {});
|
10375
10405
|
|
10376
10406
|
// src/mnemonic/utils.ts
|
10377
|
-
import { ErrorCode as ErrorCode20, FuelError as
|
10407
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError22 } from "@fuel-ts/errors";
|
10378
10408
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
10379
10409
|
import { arrayify as arrayify18 } from "@fuel-ts/utils";
|
10380
10410
|
function getLowerMask(bits) {
|
@@ -10428,7 +10458,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
10428
10458
|
for (let i = 0; i < words.length; i += 1) {
|
10429
10459
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
10430
10460
|
if (index === -1) {
|
10431
|
-
throw new
|
10461
|
+
throw new FuelError22(
|
10432
10462
|
ErrorCode20.INVALID_MNEMONIC,
|
10433
10463
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
10434
10464
|
);
|
@@ -10445,7 +10475,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
10445
10475
|
const checksumMask = getUpperMask(checksumBits);
|
10446
10476
|
const checksum = arrayify18(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
10447
10477
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
10448
|
-
throw new
|
10478
|
+
throw new FuelError22(
|
10449
10479
|
ErrorCode20.INVALID_CHECKSUM,
|
10450
10480
|
"Checksum validation failed for the provided mnemonic."
|
10451
10481
|
);
|
@@ -10461,7 +10491,7 @@ var TestnetPRV = "0x04358394";
|
|
10461
10491
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
10462
10492
|
function assertWordList(wordlist) {
|
10463
10493
|
if (wordlist.length !== 2048) {
|
10464
|
-
throw new
|
10494
|
+
throw new FuelError23(
|
10465
10495
|
ErrorCode21.INVALID_WORD_LIST,
|
10466
10496
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
10467
10497
|
);
|
@@ -10470,7 +10500,7 @@ function assertWordList(wordlist) {
|
|
10470
10500
|
__name(assertWordList, "assertWordList");
|
10471
10501
|
function assertEntropy(entropy) {
|
10472
10502
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
10473
|
-
throw new
|
10503
|
+
throw new FuelError23(
|
10474
10504
|
ErrorCode21.INVALID_ENTROPY,
|
10475
10505
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
10476
10506
|
);
|
@@ -10482,7 +10512,7 @@ function assertMnemonic(words) {
|
|
10482
10512
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
10483
10513
|
", "
|
10484
10514
|
)}] words, but got ${words.length}.`;
|
10485
|
-
throw new
|
10515
|
+
throw new FuelError23(ErrorCode21.INVALID_MNEMONIC, errorMsg);
|
10486
10516
|
}
|
10487
10517
|
}
|
10488
10518
|
__name(assertMnemonic, "assertMnemonic");
|
@@ -10604,7 +10634,7 @@ var Mnemonic = class _Mnemonic {
|
|
10604
10634
|
static masterKeysFromSeed(seed) {
|
10605
10635
|
const seedArray = arrayify19(seed);
|
10606
10636
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
10607
|
-
throw new
|
10637
|
+
throw new FuelError23(
|
10608
10638
|
ErrorCode21.INVALID_SEED,
|
10609
10639
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
10610
10640
|
);
|
@@ -10686,7 +10716,7 @@ __name(isValidExtendedKey, "isValidExtendedKey");
|
|
10686
10716
|
function parsePath(path, depth = 0) {
|
10687
10717
|
const components = path.split("/");
|
10688
10718
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
10689
|
-
throw new
|
10719
|
+
throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, `invalid path - ${path}`);
|
10690
10720
|
}
|
10691
10721
|
if (components[0] === "m") {
|
10692
10722
|
components.shift();
|
@@ -10719,7 +10749,7 @@ var HDWallet = class _HDWallet {
|
|
10719
10749
|
this.privateKey = hexlify22(config.privateKey);
|
10720
10750
|
} else {
|
10721
10751
|
if (!config.publicKey) {
|
10722
|
-
throw new
|
10752
|
+
throw new FuelError24(
|
10723
10753
|
ErrorCode22.HD_WALLET_ERROR,
|
10724
10754
|
"Both public and private Key cannot be missing. At least one should be provided."
|
10725
10755
|
);
|
@@ -10749,7 +10779,7 @@ var HDWallet = class _HDWallet {
|
|
10749
10779
|
const data = new Uint8Array(37);
|
10750
10780
|
if (index & HARDENED_INDEX) {
|
10751
10781
|
if (!privateKey) {
|
10752
|
-
throw new
|
10782
|
+
throw new FuelError24(
|
10753
10783
|
ErrorCode22.HD_WALLET_ERROR,
|
10754
10784
|
"Cannot derive a hardened index without a private Key."
|
10755
10785
|
);
|
@@ -10802,7 +10832,7 @@ var HDWallet = class _HDWallet {
|
|
10802
10832
|
*/
|
10803
10833
|
toExtendedKey(isPublic = false, testnet = false) {
|
10804
10834
|
if (this.depth >= 256) {
|
10805
|
-
throw new
|
10835
|
+
throw new FuelError24(
|
10806
10836
|
ErrorCode22.HD_WALLET_ERROR,
|
10807
10837
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
10808
10838
|
);
|
@@ -10834,10 +10864,10 @@ var HDWallet = class _HDWallet {
|
|
10834
10864
|
const bytes = arrayify20(decoded);
|
10835
10865
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10836
10866
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10837
|
-
throw new
|
10867
|
+
throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
10838
10868
|
}
|
10839
10869
|
if (!validChecksum) {
|
10840
|
-
throw new
|
10870
|
+
throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10841
10871
|
}
|
10842
10872
|
const depth = bytes[4];
|
10843
10873
|
const parentFingerprint = hexlify22(bytes.slice(5, 9));
|
@@ -10845,14 +10875,14 @@ var HDWallet = class _HDWallet {
|
|
10845
10875
|
const chainCode = hexlify22(bytes.slice(13, 45));
|
10846
10876
|
const key = bytes.slice(45, 78);
|
10847
10877
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10848
|
-
throw new
|
10878
|
+
throw new FuelError24(
|
10849
10879
|
ErrorCode22.HD_WALLET_ERROR,
|
10850
10880
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
10851
10881
|
);
|
10852
10882
|
}
|
10853
10883
|
if (isPublicExtendedKey(bytes)) {
|
10854
10884
|
if (key[0] !== 3) {
|
10855
|
-
throw new
|
10885
|
+
throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, "Invalid public extended key.");
|
10856
10886
|
}
|
10857
10887
|
return new _HDWallet({
|
10858
10888
|
publicKey: key,
|
@@ -10863,7 +10893,7 @@ var HDWallet = class _HDWallet {
|
|
10863
10893
|
});
|
10864
10894
|
}
|
10865
10895
|
if (key[0] !== 0) {
|
10866
|
-
throw new
|
10896
|
+
throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, "Invalid private extended key.");
|
10867
10897
|
}
|
10868
10898
|
return new _HDWallet({
|
10869
10899
|
privateKey: key.slice(1),
|
@@ -11040,7 +11070,7 @@ var Wallet = class {
|
|
11040
11070
|
// src/wallet-manager/wallet-manager.ts
|
11041
11071
|
import { Address as Address9 } from "@fuel-ts/address";
|
11042
11072
|
import { encrypt, decrypt } from "@fuel-ts/crypto";
|
11043
|
-
import { ErrorCode as ErrorCode25, FuelError as
|
11073
|
+
import { ErrorCode as ErrorCode25, FuelError as FuelError27 } from "@fuel-ts/errors";
|
11044
11074
|
import { EventEmitter } from "events";
|
11045
11075
|
|
11046
11076
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -11066,7 +11096,7 @@ var MemoryStorage = class {
|
|
11066
11096
|
|
11067
11097
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
11068
11098
|
import { Address as Address7 } from "@fuel-ts/address";
|
11069
|
-
import { ErrorCode as ErrorCode23, FuelError as
|
11099
|
+
import { ErrorCode as ErrorCode23, FuelError as FuelError25 } from "@fuel-ts/errors";
|
11070
11100
|
var MnemonicVault = class {
|
11071
11101
|
static {
|
11072
11102
|
__name(this, "MnemonicVault");
|
@@ -11125,7 +11155,7 @@ var MnemonicVault = class {
|
|
11125
11155
|
}
|
11126
11156
|
numberOfAccounts += 1;
|
11127
11157
|
} while (numberOfAccounts < this.numberOfAccounts);
|
11128
|
-
throw new
|
11158
|
+
throw new FuelError25(
|
11129
11159
|
ErrorCode23.WALLET_MANAGER_ERROR,
|
11130
11160
|
`Account with address '${address}' not found in derived wallets.`
|
11131
11161
|
);
|
@@ -11138,7 +11168,7 @@ var MnemonicVault = class {
|
|
11138
11168
|
|
11139
11169
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
11140
11170
|
import { Address as Address8 } from "@fuel-ts/address";
|
11141
|
-
import { ErrorCode as ErrorCode24, FuelError as
|
11171
|
+
import { ErrorCode as ErrorCode24, FuelError as FuelError26 } from "@fuel-ts/errors";
|
11142
11172
|
var PrivateKeyVault = class {
|
11143
11173
|
static {
|
11144
11174
|
__name(this, "PrivateKeyVault");
|
@@ -11182,7 +11212,7 @@ var PrivateKeyVault = class {
|
|
11182
11212
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
11183
11213
|
);
|
11184
11214
|
if (!privateKey) {
|
11185
|
-
throw new
|
11215
|
+
throw new FuelError26(
|
11186
11216
|
ErrorCode24.WALLET_MANAGER_ERROR,
|
11187
11217
|
`No private key found for address '${address}'.`
|
11188
11218
|
);
|
@@ -11205,7 +11235,7 @@ var ERROR_MESSAGES = {
|
|
11205
11235
|
};
|
11206
11236
|
function assert(condition, message) {
|
11207
11237
|
if (!condition) {
|
11208
|
-
throw new
|
11238
|
+
throw new FuelError27(ErrorCode25.WALLET_MANAGER_ERROR, message);
|
11209
11239
|
}
|
11210
11240
|
}
|
11211
11241
|
__name(assert, "assert");
|
@@ -11426,29 +11456,29 @@ var WalletManager = class _WalletManager extends EventEmitter {
|
|
11426
11456
|
};
|
11427
11457
|
|
11428
11458
|
// src/wallet-manager/types.ts
|
11429
|
-
import { ErrorCode as ErrorCode26, FuelError as
|
11459
|
+
import { ErrorCode as ErrorCode26, FuelError as FuelError28 } from "@fuel-ts/errors";
|
11430
11460
|
var Vault = class {
|
11431
11461
|
static {
|
11432
11462
|
__name(this, "Vault");
|
11433
11463
|
}
|
11434
11464
|
static type;
|
11435
11465
|
constructor(_options) {
|
11436
|
-
throw new
|
11466
|
+
throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
11437
11467
|
}
|
11438
11468
|
serialize() {
|
11439
|
-
throw new
|
11469
|
+
throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
11440
11470
|
}
|
11441
11471
|
getAccounts() {
|
11442
|
-
throw new
|
11472
|
+
throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
11443
11473
|
}
|
11444
11474
|
addAccount() {
|
11445
|
-
throw new
|
11475
|
+
throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
11446
11476
|
}
|
11447
11477
|
exportAccount(_address) {
|
11448
|
-
throw new
|
11478
|
+
throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
11449
11479
|
}
|
11450
11480
|
getWallet(_address) {
|
11451
|
-
throw new
|
11481
|
+
throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
11452
11482
|
}
|
11453
11483
|
};
|
11454
11484
|
var StorageAbstract = class {
|
@@ -11458,18 +11488,18 @@ var StorageAbstract = class {
|
|
11458
11488
|
};
|
11459
11489
|
|
11460
11490
|
// src/predicate/predicate.ts
|
11461
|
-
import { Interface as
|
11491
|
+
import { Interface as Interface4 } from "@fuel-ts/abi-coder";
|
11462
11492
|
import { Address as Address10 } from "@fuel-ts/address";
|
11463
|
-
import { ErrorCode as ErrorCode28, FuelError as
|
11493
|
+
import { ErrorCode as ErrorCode28, FuelError as FuelError30 } from "@fuel-ts/errors";
|
11464
11494
|
import { arrayify as arrayify23, hexlify as hexlify24 } from "@fuel-ts/utils";
|
11465
11495
|
|
11466
11496
|
// src/utils/deployScriptOrPredicate.ts
|
11467
|
-
import { FuelError as
|
11497
|
+
import { FuelError as FuelError29, ErrorCode as ErrorCode27 } from "@fuel-ts/errors";
|
11468
11498
|
import { bn as bn22 } from "@fuel-ts/math";
|
11469
11499
|
import { arrayify as arrayify21 } from "@fuel-ts/utils";
|
11470
11500
|
|
11471
11501
|
// src/utils/predicate-script-loader-instructions.ts
|
11472
|
-
import { BigNumberCoder as
|
11502
|
+
import { BigNumberCoder as BigNumberCoder4 } from "@fuel-ts/abi-coder";
|
11473
11503
|
import { sha256 as sha2565 } from "@fuel-ts/hasher";
|
11474
11504
|
import { concat as concat7 } from "@fuel-ts/utils";
|
11475
11505
|
import * as asm2 from "@fuels/vm-asm";
|
@@ -11481,12 +11511,12 @@ var WORD_SIZE2 = 8;
|
|
11481
11511
|
var DATA_OFFSET_INDEX = 8;
|
11482
11512
|
var CONFIGURABLE_OFFSET_INDEX = 16;
|
11483
11513
|
function getBytecodeDataOffset(bytecode) {
|
11484
|
-
const [offset] = new
|
11514
|
+
const [offset] = new BigNumberCoder4("u64").decode(bytecode, DATA_OFFSET_INDEX);
|
11485
11515
|
return offset.toNumber();
|
11486
11516
|
}
|
11487
11517
|
__name(getBytecodeDataOffset, "getBytecodeDataOffset");
|
11488
11518
|
function getBytecodeConfigurableOffset(bytecode) {
|
11489
|
-
const [offset] = new
|
11519
|
+
const [offset] = new BigNumberCoder4("u64").decode(bytecode, CONFIGURABLE_OFFSET_INDEX);
|
11490
11520
|
return offset.toNumber();
|
11491
11521
|
}
|
11492
11522
|
__name(getBytecodeConfigurableOffset, "getBytecodeConfigurableOffset");
|
@@ -11631,7 +11661,7 @@ async function fundBlobTx(deployer, blobTxRequest) {
|
|
11631
11661
|
}).add(1);
|
11632
11662
|
totalCost = totalCost.add(minFee);
|
11633
11663
|
if (totalCost.gt(await deployer.getBalance())) {
|
11634
|
-
throw new
|
11664
|
+
throw new FuelError29(ErrorCode27.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
|
11635
11665
|
}
|
11636
11666
|
const txCost = await deployer.getTransactionCost(blobTxRequest);
|
11637
11667
|
blobTxRequest.maxFee = txCost.maxFee;
|
@@ -11684,7 +11714,7 @@ async function deployScriptOrPredicate({
|
|
11684
11714
|
throw new Error();
|
11685
11715
|
}
|
11686
11716
|
} catch (err) {
|
11687
|
-
throw new
|
11717
|
+
throw new FuelError29(ErrorCode27.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
|
11688
11718
|
}
|
11689
11719
|
return loaderInstance;
|
11690
11720
|
}, "waitForResult");
|
@@ -11821,9 +11851,9 @@ var Predicate = class _Predicate extends Account {
|
|
11821
11851
|
*/
|
11822
11852
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
11823
11853
|
let predicateBytes = arrayify23(bytes);
|
11824
|
-
const abiInterface = new
|
11854
|
+
const abiInterface = new Interface4(jsonAbi);
|
11825
11855
|
if (abiInterface.functions.main === void 0) {
|
11826
|
-
throw new
|
11856
|
+
throw new FuelError30(
|
11827
11857
|
ErrorCode28.ABI_MAIN_METHOD_MISSING,
|
11828
11858
|
'Cannot use ABI without "main" function.'
|
11829
11859
|
);
|
@@ -11884,14 +11914,14 @@ var Predicate = class _Predicate extends Account {
|
|
11884
11914
|
const mutatedBytes = bytes;
|
11885
11915
|
try {
|
11886
11916
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
11887
|
-
throw new
|
11917
|
+
throw new FuelError30(
|
11888
11918
|
ErrorCode28.INVALID_CONFIGURABLE_CONSTANTS,
|
11889
11919
|
"Predicate has no configurable constants to be set"
|
11890
11920
|
);
|
11891
11921
|
}
|
11892
11922
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
11893
11923
|
if (!abiInterface?.configurables[key]) {
|
11894
|
-
throw new
|
11924
|
+
throw new FuelError30(
|
11895
11925
|
ErrorCode28.CONFIGURABLE_NOT_FOUND,
|
11896
11926
|
`No configurable constant named '${key}' found in the Predicate`
|
11897
11927
|
);
|
@@ -11901,7 +11931,7 @@ var Predicate = class _Predicate extends Account {
|
|
11901
11931
|
mutatedBytes.set(encoded, offset);
|
11902
11932
|
});
|
11903
11933
|
} catch (err) {
|
11904
|
-
throw new
|
11934
|
+
throw new FuelError30(
|
11905
11935
|
ErrorCode28.INVALID_CONFIGURABLE_CONSTANTS,
|
11906
11936
|
`Error setting configurable constants: ${err.message}.`
|
11907
11937
|
);
|
@@ -11958,7 +11988,7 @@ var Predicate = class _Predicate extends Account {
|
|
11958
11988
|
import { ErrorCode as ErrorCode29, FuelError as FuelError33 } from "@fuel-ts/errors";
|
11959
11989
|
|
11960
11990
|
// src/connectors/fuel-connector.ts
|
11961
|
-
import { FuelError as
|
11991
|
+
import { FuelError as FuelError31 } from "@fuel-ts/errors";
|
11962
11992
|
import { EventEmitter as EventEmitter2 } from "events";
|
11963
11993
|
|
11964
11994
|
// src/connectors/types/connector-types.ts
|
@@ -12039,7 +12069,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12039
12069
|
* @returns Always true.
|
12040
12070
|
*/
|
12041
12071
|
async ping() {
|
12042
|
-
throw new
|
12072
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12043
12073
|
}
|
12044
12074
|
/**
|
12045
12075
|
* Should return the current version of the connector
|
@@ -12048,7 +12078,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12048
12078
|
* @returns boolean - connection status.
|
12049
12079
|
*/
|
12050
12080
|
async version() {
|
12051
|
-
throw new
|
12081
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12052
12082
|
}
|
12053
12083
|
/**
|
12054
12084
|
* Should return true if the connector is connected
|
@@ -12057,7 +12087,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12057
12087
|
* @returns The connection status.
|
12058
12088
|
*/
|
12059
12089
|
async isConnected() {
|
12060
|
-
throw new
|
12090
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12061
12091
|
}
|
12062
12092
|
/**
|
12063
12093
|
* Should return all the accounts authorized for the
|
@@ -12066,7 +12096,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12066
12096
|
* @returns The accounts addresses strings
|
12067
12097
|
*/
|
12068
12098
|
async accounts() {
|
12069
|
-
throw new
|
12099
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12070
12100
|
}
|
12071
12101
|
/**
|
12072
12102
|
* Should start the connection process and return
|
@@ -12078,7 +12108,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12078
12108
|
* @returns boolean - connection status.
|
12079
12109
|
*/
|
12080
12110
|
async connect() {
|
12081
|
-
throw new
|
12111
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12082
12112
|
}
|
12083
12113
|
/**
|
12084
12114
|
* Should disconnect the current connection and
|
@@ -12088,7 +12118,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12088
12118
|
* @returns The connection status.
|
12089
12119
|
*/
|
12090
12120
|
async disconnect() {
|
12091
|
-
throw new
|
12121
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12092
12122
|
}
|
12093
12123
|
/**
|
12094
12124
|
* Should start the sign message process and return
|
@@ -12100,7 +12130,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12100
12130
|
* @returns Message signature
|
12101
12131
|
*/
|
12102
12132
|
async signMessage(_address, _message) {
|
12103
|
-
throw new
|
12133
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12104
12134
|
}
|
12105
12135
|
/**
|
12106
12136
|
* Should start the sign transaction process and return
|
@@ -12112,7 +12142,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12112
12142
|
* @returns Transaction signature
|
12113
12143
|
*/
|
12114
12144
|
async signTransaction(_address, _transaction) {
|
12115
|
-
throw new
|
12145
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12116
12146
|
}
|
12117
12147
|
/**
|
12118
12148
|
* Should start the send transaction process and return
|
@@ -12128,7 +12158,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12128
12158
|
* @returns The transaction id or transaction response
|
12129
12159
|
*/
|
12130
12160
|
async sendTransaction(_address, _transaction, _params) {
|
12131
|
-
throw new
|
12161
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12132
12162
|
}
|
12133
12163
|
/**
|
12134
12164
|
* Should return the current account selected inside the connector, if the account
|
@@ -12139,7 +12169,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12139
12169
|
* @returns The current account selected otherwise null.
|
12140
12170
|
*/
|
12141
12171
|
async currentAccount() {
|
12142
|
-
throw new
|
12172
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12143
12173
|
}
|
12144
12174
|
/**
|
12145
12175
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -12153,7 +12183,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12153
12183
|
* @returns True if the asset was added successfully
|
12154
12184
|
*/
|
12155
12185
|
async addAssets(_assets) {
|
12156
|
-
throw new
|
12186
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12157
12187
|
}
|
12158
12188
|
/**
|
12159
12189
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -12167,7 +12197,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12167
12197
|
* @returns True if the asset was added successfully
|
12168
12198
|
*/
|
12169
12199
|
async addAsset(_asset) {
|
12170
|
-
throw new
|
12200
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12171
12201
|
}
|
12172
12202
|
/**
|
12173
12203
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -12175,7 +12205,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12175
12205
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
12176
12206
|
*/
|
12177
12207
|
async assets() {
|
12178
|
-
throw new
|
12208
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12179
12209
|
}
|
12180
12210
|
/**
|
12181
12211
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -12186,7 +12216,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12186
12216
|
* @returns Return true if the network was added successfully
|
12187
12217
|
*/
|
12188
12218
|
async addNetwork(_networkUrl) {
|
12189
|
-
throw new
|
12219
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12190
12220
|
}
|
12191
12221
|
/**
|
12192
12222
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -12197,7 +12227,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12197
12227
|
* @returns Return true if the network was added successfully
|
12198
12228
|
*/
|
12199
12229
|
async selectNetwork(_network) {
|
12200
|
-
throw new
|
12230
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12201
12231
|
}
|
12202
12232
|
/**
|
12203
12233
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -12205,7 +12235,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12205
12235
|
* @returns Return all the networks added to the connector.
|
12206
12236
|
*/
|
12207
12237
|
async networks() {
|
12208
|
-
throw new
|
12238
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12209
12239
|
}
|
12210
12240
|
/**
|
12211
12241
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -12213,7 +12243,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12213
12243
|
* @returns Return the current network selected inside the connector.
|
12214
12244
|
*/
|
12215
12245
|
async currentNetwork() {
|
12216
|
-
throw new
|
12246
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12217
12247
|
}
|
12218
12248
|
/**
|
12219
12249
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -12223,7 +12253,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12223
12253
|
* @returns Return true if the ABI was added successfully.
|
12224
12254
|
*/
|
12225
12255
|
async addABI(_contractId, _abi) {
|
12226
|
-
throw new
|
12256
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12227
12257
|
}
|
12228
12258
|
/**
|
12229
12259
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -12232,7 +12262,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12232
12262
|
* @returns The ABI if it exists, otherwise return null.
|
12233
12263
|
*/
|
12234
12264
|
async getABI(_id) {
|
12235
|
-
throw new
|
12265
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12236
12266
|
}
|
12237
12267
|
/**
|
12238
12268
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -12241,7 +12271,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
12241
12271
|
* @returns Returns true if the abi exists or false if not.
|
12242
12272
|
*/
|
12243
12273
|
async hasABI(_id) {
|
12244
|
-
throw new
|
12274
|
+
throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12245
12275
|
}
|
12246
12276
|
/**
|
12247
12277
|
* Event listener for the connector.
|
@@ -12286,6 +12316,27 @@ function dispatchFuelConnectorEvent(connector) {
|
|
12286
12316
|
}
|
12287
12317
|
__name(dispatchFuelConnectorEvent, "dispatchFuelConnectorEvent");
|
12288
12318
|
|
12319
|
+
// src/connectors/utils/promises.ts
|
12320
|
+
import { FuelError as FuelError32 } from "@fuel-ts/errors";
|
12321
|
+
function deferPromise() {
|
12322
|
+
const defer = {};
|
12323
|
+
defer.promise = new Promise((resolve, reject) => {
|
12324
|
+
defer.reject = reject;
|
12325
|
+
defer.resolve = resolve;
|
12326
|
+
});
|
12327
|
+
return defer;
|
12328
|
+
}
|
12329
|
+
__name(deferPromise, "deferPromise");
|
12330
|
+
async function withTimeout(promise, timeout = 1050) {
|
12331
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
12332
|
+
setTimeout(() => {
|
12333
|
+
reject(new FuelError32(FuelError32.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
12334
|
+
}, timeout);
|
12335
|
+
});
|
12336
|
+
return Promise.race([timeoutPromise, promise]);
|
12337
|
+
}
|
12338
|
+
__name(withTimeout, "withTimeout");
|
12339
|
+
|
12289
12340
|
// src/connectors/fuel.ts
|
12290
12341
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
12291
12342
|
var PING_CACHE_TIME = 5e3;
|
@@ -12721,6 +12772,7 @@ export {
|
|
12721
12772
|
extractTxError,
|
12722
12773
|
fuelAssetsBaseUrl,
|
12723
12774
|
gasUsedByInputs,
|
12775
|
+
getAllDecodedLogs,
|
12724
12776
|
getAssetAmountInRequestInputs,
|
12725
12777
|
getAssetById,
|
12726
12778
|
getAssetEth,
|