@fuel-ts/account 0.100.0 → 0.100.2
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 +3790 -1886
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +895 -720
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +851 -677
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +17 -1
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +15 -13
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
- package/dist/providers/utils/serialization.d.ts.map +1 -1
- package/dist/test-utils.global.js +3226 -1721
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +659 -501
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +625 -467
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +14 -14
package/dist/index.js
CHANGED
@@ -5,7 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
9
9
|
var __export = (target, all) => {
|
10
10
|
for (var name in all)
|
11
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -27,32 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
27
27
|
mod
|
28
28
|
));
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
30
|
-
var __publicField = (obj, key, value) => {
|
31
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
32
|
-
return value;
|
33
|
-
};
|
34
|
-
var __accessCheck = (obj, member, msg) => {
|
35
|
-
if (!member.has(obj))
|
36
|
-
throw TypeError("Cannot " + msg);
|
37
|
-
};
|
38
|
-
var __privateGet = (obj, member, getter) => {
|
39
|
-
__accessCheck(obj, member, "read from private field");
|
40
|
-
return getter ? getter.call(obj) : member.get(obj);
|
41
|
-
};
|
42
|
-
var __privateAdd = (obj, member, value) => {
|
43
|
-
if (member.has(obj))
|
44
|
-
throw TypeError("Cannot add the same private member more than once");
|
45
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
46
|
-
};
|
47
|
-
var __privateSet = (obj, member, value, setter) => {
|
48
|
-
__accessCheck(obj, member, "write to private field");
|
49
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
50
|
-
return value;
|
51
|
-
};
|
52
|
-
var __privateMethod = (obj, member, method) => {
|
53
|
-
__accessCheck(obj, member, "access private method");
|
54
|
-
return method;
|
55
|
-
};
|
56
30
|
|
57
31
|
// src/index.ts
|
58
32
|
var src_exports = {};
|
@@ -84,6 +58,7 @@ __export(src_exports, {
|
|
84
58
|
MemoryStorage: () => MemoryStorage,
|
85
59
|
Mnemonic: () => mnemonic_default,
|
86
60
|
MnemonicVault: () => MnemonicVault,
|
61
|
+
NON_PAGINATED_BALANCES_SIZE: () => NON_PAGINATED_BALANCES_SIZE,
|
87
62
|
NoWitnessAtIndexError: () => NoWitnessAtIndexError,
|
88
63
|
NoWitnessByOwnerError: () => NoWitnessByOwnerError,
|
89
64
|
OperationName: () => OperationName,
|
@@ -253,7 +228,7 @@ var CHAIN_IDS = {
|
|
253
228
|
};
|
254
229
|
|
255
230
|
// src/assets/utils/network.ts
|
256
|
-
var getDefaultChainId = (networkType) => {
|
231
|
+
var getDefaultChainId = /* @__PURE__ */ __name((networkType) => {
|
257
232
|
if (networkType === "ethereum") {
|
258
233
|
return CHAIN_IDS.eth.sepolia;
|
259
234
|
}
|
@@ -261,8 +236,8 @@ var getDefaultChainId = (networkType) => {
|
|
261
236
|
return CHAIN_IDS.fuel.testnet;
|
262
237
|
}
|
263
238
|
return void 0;
|
264
|
-
};
|
265
|
-
var getAssetNetwork = ({
|
239
|
+
}, "getDefaultChainId");
|
240
|
+
var getAssetNetwork = /* @__PURE__ */ __name(({
|
266
241
|
asset,
|
267
242
|
chainId,
|
268
243
|
networkType
|
@@ -271,8 +246,8 @@ var getAssetNetwork = ({
|
|
271
246
|
(item) => item.chainId === chainId && item.type === networkType
|
272
247
|
);
|
273
248
|
return network;
|
274
|
-
};
|
275
|
-
var getAssetWithNetwork = ({
|
249
|
+
}, "getAssetNetwork");
|
250
|
+
var getAssetWithNetwork = /* @__PURE__ */ __name(({
|
276
251
|
asset,
|
277
252
|
chainId,
|
278
253
|
networkType
|
@@ -294,22 +269,22 @@ var getAssetWithNetwork = ({
|
|
294
269
|
...assetRest,
|
295
270
|
...assetNetwork
|
296
271
|
};
|
297
|
-
};
|
298
|
-
var getAssetEth = (asset, chainId) => getAssetWithNetwork({
|
272
|
+
}, "getAssetWithNetwork");
|
273
|
+
var getAssetEth = /* @__PURE__ */ __name((asset, chainId) => getAssetWithNetwork({
|
299
274
|
asset,
|
300
275
|
networkType: "ethereum",
|
301
276
|
chainId
|
302
|
-
});
|
303
|
-
var getAssetFuel = (asset, chainId) => getAssetWithNetwork({
|
277
|
+
}), "getAssetEth");
|
278
|
+
var getAssetFuel = /* @__PURE__ */ __name((asset, chainId) => getAssetWithNetwork({
|
304
279
|
asset,
|
305
280
|
networkType: "fuel",
|
306
281
|
chainId
|
307
|
-
});
|
282
|
+
}), "getAssetFuel");
|
308
283
|
|
309
284
|
// src/assets/utils/url.ts
|
310
285
|
var DELIMITER_PATH = "/";
|
311
286
|
var trimRegex = /^\/|\/$/g;
|
312
|
-
var trimPath = (path = "") => path.replace(trimRegex, "");
|
287
|
+
var trimPath = /* @__PURE__ */ __name((path = "") => path.replace(trimRegex, ""), "trimPath");
|
313
288
|
function urlJoin(baseUrl, ...paths) {
|
314
289
|
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
315
290
|
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
@@ -319,6 +294,7 @@ function urlJoin(baseUrl, ...paths) {
|
|
319
294
|
}
|
320
295
|
return allPaths.join(DELIMITER_PATH);
|
321
296
|
}
|
297
|
+
__name(urlJoin, "urlJoin");
|
322
298
|
|
323
299
|
// src/assets/utils/resolveIconPaths.ts
|
324
300
|
function resolveIconPaths(assets2, basePath = "./") {
|
@@ -327,6 +303,7 @@ function resolveIconPaths(assets2, basePath = "./") {
|
|
327
303
|
icon: urlJoin(basePath, asset.icon)
|
328
304
|
}));
|
329
305
|
}
|
306
|
+
__name(resolveIconPaths, "resolveIconPaths");
|
330
307
|
|
331
308
|
// src/assets/utils/fuelAssetsBaseUrl.ts
|
332
309
|
var fuelAssetsBaseUrl = "https://assets.fuel.network/providers/";
|
@@ -901,7 +878,7 @@ var networks = {
|
|
901
878
|
mainnet: "https://mainnet-explorer.fuel.network",
|
902
879
|
testnet: "https://explorer-indexer-testnet.fuel.network"
|
903
880
|
};
|
904
|
-
var request = async (url, slug) => {
|
881
|
+
var request = /* @__PURE__ */ __name(async (url, slug) => {
|
905
882
|
const response = await fetch(`${url}${slug}`, {
|
906
883
|
headers: {
|
907
884
|
"Content-Type": "application/json",
|
@@ -913,20 +890,20 @@ var request = async (url, slug) => {
|
|
913
890
|
} catch (error) {
|
914
891
|
return null;
|
915
892
|
}
|
916
|
-
};
|
917
|
-
var buildQueryString = (parameters) => {
|
893
|
+
}, "request");
|
894
|
+
var buildQueryString = /* @__PURE__ */ __name((parameters) => {
|
918
895
|
const query = new URLSearchParams();
|
919
896
|
Object.entries(parameters).forEach(([key, value]) => {
|
920
897
|
query.set(key, value.toString());
|
921
898
|
});
|
922
899
|
return query.size > 0 ? `?${query.toString()}` : "";
|
923
|
-
};
|
924
|
-
var getAssetById = (opts) => {
|
900
|
+
}, "buildQueryString");
|
901
|
+
var getAssetById = /* @__PURE__ */ __name((opts) => {
|
925
902
|
const { network = "mainnet", assetId } = opts;
|
926
903
|
const url = networks[network];
|
927
904
|
return request(url, `/assets/${assetId}`);
|
928
|
-
};
|
929
|
-
var getAssetsByOwner = async (opts) => {
|
905
|
+
}, "getAssetById");
|
906
|
+
var getAssetsByOwner = /* @__PURE__ */ __name(async (opts) => {
|
930
907
|
const { network = "mainnet", owner, pagination = { last: 10 } } = opts;
|
931
908
|
const url = networks[network];
|
932
909
|
const { last } = pagination;
|
@@ -936,13 +913,13 @@ var getAssetsByOwner = async (opts) => {
|
|
936
913
|
return { data: [], pageInfo: { count: 0 } };
|
937
914
|
}
|
938
915
|
return response;
|
939
|
-
};
|
916
|
+
}, "getAssetsByOwner");
|
940
917
|
|
941
918
|
// src/account.ts
|
942
919
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
943
920
|
var import_address5 = require("@fuel-ts/address");
|
944
921
|
var import_crypto2 = require("@fuel-ts/crypto");
|
945
|
-
var
|
922
|
+
var import_errors22 = require("@fuel-ts/errors");
|
946
923
|
var import_math21 = require("@fuel-ts/math");
|
947
924
|
var import_transactions26 = require("@fuel-ts/transactions");
|
948
925
|
var import_utils34 = require("@fuel-ts/utils");
|
@@ -951,7 +928,7 @@ var import_ramda9 = require("ramda");
|
|
951
928
|
// src/providers/coin-quantity.ts
|
952
929
|
var import_math = require("@fuel-ts/math");
|
953
930
|
var import_utils2 = require("@fuel-ts/utils");
|
954
|
-
var coinQuantityfy = (coinQuantityLike) => {
|
931
|
+
var coinQuantityfy = /* @__PURE__ */ __name((coinQuantityLike) => {
|
955
932
|
let assetId;
|
956
933
|
let amount;
|
957
934
|
let max;
|
@@ -969,8 +946,8 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
969
946
|
amount: (0, import_math.bn)(amount),
|
970
947
|
max: max ? (0, import_math.bn)(max) : void 0
|
971
948
|
};
|
972
|
-
};
|
973
|
-
var addAmountToCoinQuantities = (params) => {
|
949
|
+
}, "coinQuantityfy");
|
950
|
+
var addAmountToCoinQuantities = /* @__PURE__ */ __name((params) => {
|
974
951
|
const { amount, assetId } = params;
|
975
952
|
const coinQuantities = [...params.coinQuantities];
|
976
953
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -980,11 +957,11 @@ var addAmountToCoinQuantities = (params) => {
|
|
980
957
|
coinQuantities.push({ assetId, amount });
|
981
958
|
}
|
982
959
|
return coinQuantities;
|
983
|
-
};
|
960
|
+
}, "addAmountToCoinQuantities");
|
984
961
|
|
985
962
|
// src/providers/provider.ts
|
986
963
|
var import_address3 = require("@fuel-ts/address");
|
987
|
-
var
|
964
|
+
var import_errors20 = require("@fuel-ts/errors");
|
988
965
|
var import_math18 = require("@fuel-ts/math");
|
989
966
|
var import_transactions23 = require("@fuel-ts/transactions");
|
990
967
|
var import_utils29 = require("@fuel-ts/utils");
|
@@ -993,6 +970,27 @@ var import_graphql_request = require("graphql-request");
|
|
993
970
|
var import_graphql_tag2 = __toESM(require("graphql-tag"));
|
994
971
|
var import_ramda8 = require("ramda");
|
995
972
|
|
973
|
+
// src/connectors/utils/promises.ts
|
974
|
+
var import_errors = require("@fuel-ts/errors");
|
975
|
+
function deferPromise() {
|
976
|
+
const defer = {};
|
977
|
+
defer.promise = new Promise((resolve, reject) => {
|
978
|
+
defer.reject = reject;
|
979
|
+
defer.resolve = resolve;
|
980
|
+
});
|
981
|
+
return defer;
|
982
|
+
}
|
983
|
+
__name(deferPromise, "deferPromise");
|
984
|
+
async function withTimeout(promise, timeout = 1050) {
|
985
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
986
|
+
setTimeout(() => {
|
987
|
+
reject(new import_errors.FuelError(import_errors.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
988
|
+
}, timeout);
|
989
|
+
});
|
990
|
+
return Promise.race([timeoutPromise, promise]);
|
991
|
+
}
|
992
|
+
__name(withTimeout, "withTimeout");
|
993
|
+
|
996
994
|
// src/providers/__generated__/operations.ts
|
997
995
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
998
996
|
var SubmittedStatusFragmentDoc = import_graphql_tag.default`
|
@@ -1484,6 +1482,11 @@ var NodeInfoFragmentDoc = import_graphql_tag.default`
|
|
1484
1482
|
maxTx
|
1485
1483
|
maxDepth
|
1486
1484
|
nodeVersion
|
1485
|
+
indexation {
|
1486
|
+
balances
|
1487
|
+
coinsToSpend
|
1488
|
+
assetMetadata
|
1489
|
+
}
|
1487
1490
|
}
|
1488
1491
|
`;
|
1489
1492
|
var RelayedTransactionStatusFragmentDoc = import_graphql_tag.default`
|
@@ -1765,7 +1768,7 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
1765
1768
|
}
|
1766
1769
|
`;
|
1767
1770
|
var GetBalancesV2Document = import_graphql_tag.default`
|
1768
|
-
query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
1771
|
+
query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int, $supportsPagination: Boolean!) {
|
1769
1772
|
balances(
|
1770
1773
|
filter: $filter
|
1771
1774
|
after: $after
|
@@ -1773,7 +1776,7 @@ var GetBalancesV2Document = import_graphql_tag.default`
|
|
1773
1776
|
first: $first
|
1774
1777
|
last: $last
|
1775
1778
|
) {
|
1776
|
-
pageInfo {
|
1779
|
+
pageInfo @include(if: $supportsPagination) {
|
1777
1780
|
...pageInfoFragment
|
1778
1781
|
}
|
1779
1782
|
edges {
|
@@ -2043,37 +2046,38 @@ function getSdk(requester) {
|
|
2043
2046
|
}
|
2044
2047
|
};
|
2045
2048
|
}
|
2049
|
+
__name(getSdk, "getSdk");
|
2046
2050
|
|
2047
2051
|
// src/providers/fuel-graphql-subscriber.ts
|
2048
|
-
var
|
2052
|
+
var import_errors3 = require("@fuel-ts/errors");
|
2049
2053
|
var import_graphql = require("graphql");
|
2050
2054
|
|
2051
2055
|
// src/providers/utils/handle-gql-error-message.ts
|
2052
|
-
var
|
2053
|
-
var mapGqlErrorMessage = (error) => {
|
2056
|
+
var import_errors2 = require("@fuel-ts/errors");
|
2057
|
+
var mapGqlErrorMessage = /* @__PURE__ */ __name((error) => {
|
2054
2058
|
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)) {
|
2055
|
-
return new
|
2056
|
-
|
2059
|
+
return new import_errors2.FuelError(
|
2060
|
+
import_errors2.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
2057
2061
|
`Insufficient funds or too many small value coins. Consider combining UTXOs.`,
|
2058
2062
|
{},
|
2059
2063
|
error
|
2060
2064
|
);
|
2061
2065
|
}
|
2062
2066
|
if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
|
2063
|
-
return new
|
2064
|
-
|
2067
|
+
return new import_errors2.FuelError(
|
2068
|
+
import_errors2.ErrorCode.ASSET_NOT_FOUND,
|
2065
2069
|
`Asset not found for given asset id.`,
|
2066
2070
|
{},
|
2067
2071
|
error
|
2068
2072
|
);
|
2069
2073
|
}
|
2070
|
-
return new
|
2071
|
-
};
|
2072
|
-
var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
|
2074
|
+
return new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
2075
|
+
}, "mapGqlErrorMessage");
|
2076
|
+
var mapGqlErrorWithIncompatibleNodeVersion = /* @__PURE__ */ __name((error, incompatibleNodeVersionMessage) => {
|
2073
2077
|
if (!incompatibleNodeVersionMessage) {
|
2074
2078
|
return error;
|
2075
2079
|
}
|
2076
|
-
return new
|
2080
|
+
return new import_errors2.FuelError(
|
2077
2081
|
error.code,
|
2078
2082
|
`${error.message}
|
2079
2083
|
|
@@ -2081,8 +2085,8 @@ ${incompatibleNodeVersionMessage}`,
|
|
2081
2085
|
error.metadata,
|
2082
2086
|
error.rawError
|
2083
2087
|
);
|
2084
|
-
};
|
2085
|
-
var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = false) => {
|
2088
|
+
}, "mapGqlErrorWithIncompatibleNodeVersion");
|
2089
|
+
var assertGqlResponseHasNoErrors = /* @__PURE__ */ __name((errors, incompatibleNodeVersionMessage = false) => {
|
2086
2090
|
if (!Array.isArray(errors)) {
|
2087
2091
|
return;
|
2088
2092
|
}
|
@@ -2092,16 +2096,21 @@ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = fal
|
|
2092
2096
|
}
|
2093
2097
|
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
2094
2098
|
throw mapGqlErrorWithIncompatibleNodeVersion(
|
2095
|
-
new
|
2099
|
+
new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
2096
2100
|
incompatibleNodeVersionMessage
|
2097
2101
|
);
|
2098
|
-
};
|
2102
|
+
}, "assertGqlResponseHasNoErrors");
|
2099
2103
|
|
2100
2104
|
// src/providers/fuel-graphql-subscriber.ts
|
2101
|
-
var
|
2105
|
+
var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
2102
2106
|
constructor(stream) {
|
2103
2107
|
this.stream = stream;
|
2104
2108
|
}
|
2109
|
+
static {
|
2110
|
+
__name(this, "FuelGraphqlSubscriber");
|
2111
|
+
}
|
2112
|
+
static incompatibleNodeVersionMessage = false;
|
2113
|
+
static textDecoder = new TextDecoder();
|
2105
2114
|
static async create(options) {
|
2106
2115
|
const { url, query, variables, fetchFn } = options;
|
2107
2116
|
const response = await fetchFn(`${url}-sub`, {
|
@@ -2143,8 +2152,8 @@ var _FuelGraphqlSubscriber = class {
|
|
2143
2152
|
try {
|
2144
2153
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
2145
2154
|
} catch (e) {
|
2146
|
-
throw new
|
2147
|
-
|
2155
|
+
throw new import_errors3.FuelError(
|
2156
|
+
import_errors3.ErrorCode.STREAM_PARSING_ERROR,
|
2148
2157
|
`Error while parsing stream data response: ${text}`
|
2149
2158
|
);
|
2150
2159
|
}
|
@@ -2162,22 +2171,19 @@ var _FuelGraphqlSubscriber = class {
|
|
2162
2171
|
return this;
|
2163
2172
|
}
|
2164
2173
|
};
|
2165
|
-
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
2166
|
-
__publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
|
2167
|
-
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
2168
2174
|
|
2169
2175
|
// src/providers/resource-cache.ts
|
2170
|
-
var
|
2176
|
+
var import_errors14 = require("@fuel-ts/errors");
|
2171
2177
|
var import_utils22 = require("@fuel-ts/utils");
|
2172
2178
|
|
2173
2179
|
// src/providers/transaction-request/input.ts
|
2174
2180
|
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2175
2181
|
var import_configs = require("@fuel-ts/address/configs");
|
2176
|
-
var
|
2182
|
+
var import_errors4 = require("@fuel-ts/errors");
|
2177
2183
|
var import_math2 = require("@fuel-ts/math");
|
2178
2184
|
var import_transactions = require("@fuel-ts/transactions");
|
2179
2185
|
var import_utils3 = require("@fuel-ts/utils");
|
2180
|
-
var inputify = (value) => {
|
2186
|
+
var inputify = /* @__PURE__ */ __name((value) => {
|
2181
2187
|
const { type } = value;
|
2182
2188
|
switch (value.type) {
|
2183
2189
|
case import_transactions.InputType.Coin: {
|
@@ -2237,21 +2243,21 @@ var inputify = (value) => {
|
|
2237
2243
|
};
|
2238
2244
|
}
|
2239
2245
|
default: {
|
2240
|
-
throw new
|
2241
|
-
|
2246
|
+
throw new import_errors4.FuelError(
|
2247
|
+
import_errors4.ErrorCode.INVALID_TRANSACTION_INPUT,
|
2242
2248
|
`Invalid transaction input type: ${type}.`
|
2243
2249
|
);
|
2244
2250
|
}
|
2245
2251
|
}
|
2246
|
-
};
|
2252
|
+
}, "inputify");
|
2247
2253
|
|
2248
2254
|
// src/providers/transaction-request/output.ts
|
2249
2255
|
var import_configs2 = require("@fuel-ts/address/configs");
|
2250
|
-
var
|
2256
|
+
var import_errors5 = require("@fuel-ts/errors");
|
2251
2257
|
var import_math3 = require("@fuel-ts/math");
|
2252
2258
|
var import_transactions2 = require("@fuel-ts/transactions");
|
2253
2259
|
var import_utils4 = require("@fuel-ts/utils");
|
2254
|
-
var outputify = (value) => {
|
2260
|
+
var outputify = /* @__PURE__ */ __name((value) => {
|
2255
2261
|
const { type } = value;
|
2256
2262
|
switch (type) {
|
2257
2263
|
case import_transactions2.OutputType.Coin: {
|
@@ -2294,32 +2300,32 @@ var outputify = (value) => {
|
|
2294
2300
|
};
|
2295
2301
|
}
|
2296
2302
|
default: {
|
2297
|
-
throw new
|
2298
|
-
|
2303
|
+
throw new import_errors5.FuelError(
|
2304
|
+
import_errors5.ErrorCode.INVALID_TRANSACTION_INPUT,
|
2299
2305
|
`Invalid transaction output type: ${type}.`
|
2300
2306
|
);
|
2301
2307
|
}
|
2302
2308
|
}
|
2303
|
-
};
|
2309
|
+
}, "outputify");
|
2304
2310
|
|
2305
2311
|
// src/providers/transaction-request/transaction-request.ts
|
2306
2312
|
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
2307
2313
|
var import_address = require("@fuel-ts/address");
|
2308
2314
|
var import_configs6 = require("@fuel-ts/address/configs");
|
2309
2315
|
var import_crypto = require("@fuel-ts/crypto");
|
2310
|
-
var
|
2316
|
+
var import_errors10 = require("@fuel-ts/errors");
|
2311
2317
|
var import_math8 = require("@fuel-ts/math");
|
2312
2318
|
var import_transactions8 = require("@fuel-ts/transactions");
|
2313
2319
|
var import_utils10 = require("@fuel-ts/utils");
|
2314
2320
|
|
2315
2321
|
// src/providers/message.ts
|
2316
|
-
var isMessageCoin = (message) => !("data" in message);
|
2322
|
+
var isMessageCoin = /* @__PURE__ */ __name((message) => !("data" in message), "isMessageCoin");
|
2317
2323
|
|
2318
2324
|
// src/providers/resource.ts
|
2319
|
-
var isRawCoin = (resource) => "utxoId" in resource;
|
2320
|
-
var isRawMessage = (resource) => "recipient" in resource;
|
2321
|
-
var isCoin = (resource) => "id" in resource;
|
2322
|
-
var isMessage = (resource) => "recipient" in resource;
|
2325
|
+
var isRawCoin = /* @__PURE__ */ __name((resource) => "utxoId" in resource, "isRawCoin");
|
2326
|
+
var isRawMessage = /* @__PURE__ */ __name((resource) => "recipient" in resource, "isRawMessage");
|
2327
|
+
var isCoin = /* @__PURE__ */ __name((resource) => "id" in resource, "isCoin");
|
2328
|
+
var isMessage = /* @__PURE__ */ __name((resource) => "recipient" in resource, "isMessage");
|
2323
2329
|
|
2324
2330
|
// src/providers/utils/receipts.ts
|
2325
2331
|
var import_transactions4 = require("@fuel-ts/transactions");
|
@@ -2327,11 +2333,11 @@ var import_configs4 = require("@fuel-ts/transactions/configs");
|
|
2327
2333
|
|
2328
2334
|
// src/providers/utils/serialization.ts
|
2329
2335
|
var import_configs3 = require("@fuel-ts/address/configs");
|
2330
|
-
var
|
2336
|
+
var import_errors6 = require("@fuel-ts/errors");
|
2331
2337
|
var import_math4 = require("@fuel-ts/math");
|
2332
2338
|
var import_transactions3 = require("@fuel-ts/transactions");
|
2333
2339
|
var import_utils5 = require("@fuel-ts/utils");
|
2334
|
-
var deserializeChain = (chain) => {
|
2340
|
+
var deserializeChain = /* @__PURE__ */ __name((chain) => {
|
2335
2341
|
const { name, daHeight, consensusParameters } = chain;
|
2336
2342
|
const {
|
2337
2343
|
contractParams,
|
@@ -2385,8 +2391,8 @@ var deserializeChain = (chain) => {
|
|
2385
2391
|
gasCosts
|
2386
2392
|
}
|
2387
2393
|
};
|
2388
|
-
};
|
2389
|
-
var serializeChain = (chain) => {
|
2394
|
+
}, "deserializeChain");
|
2395
|
+
var serializeChain = /* @__PURE__ */ __name((chain) => {
|
2390
2396
|
const { name, baseChainHeight, consensusParameters } = chain;
|
2391
2397
|
const {
|
2392
2398
|
contractParameters,
|
@@ -2440,39 +2446,41 @@ var serializeChain = (chain) => {
|
|
2440
2446
|
gasCosts
|
2441
2447
|
}
|
2442
2448
|
};
|
2443
|
-
};
|
2444
|
-
var deserializeNodeInfo = (nodeInfo) => {
|
2445
|
-
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
2449
|
+
}, "serializeChain");
|
2450
|
+
var deserializeNodeInfo = /* @__PURE__ */ __name((nodeInfo) => {
|
2451
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace, indexation } = nodeInfo;
|
2446
2452
|
return {
|
2447
2453
|
maxDepth: (0, import_math4.bn)(maxDepth),
|
2448
2454
|
maxTx: (0, import_math4.bn)(maxTx),
|
2449
2455
|
nodeVersion,
|
2450
2456
|
utxoValidation,
|
2451
|
-
vmBacktrace
|
2457
|
+
vmBacktrace,
|
2458
|
+
indexation
|
2452
2459
|
};
|
2453
|
-
};
|
2454
|
-
var serializeNodeInfo = (nodeInfo) => {
|
2455
|
-
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
2460
|
+
}, "deserializeNodeInfo");
|
2461
|
+
var serializeNodeInfo = /* @__PURE__ */ __name((nodeInfo) => {
|
2462
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace, indexation } = nodeInfo;
|
2456
2463
|
return {
|
2457
2464
|
maxDepth: maxDepth.toString(),
|
2458
2465
|
maxTx: maxTx.toString(),
|
2459
2466
|
nodeVersion,
|
2460
2467
|
utxoValidation,
|
2461
|
-
vmBacktrace
|
2468
|
+
vmBacktrace,
|
2469
|
+
indexation
|
2462
2470
|
};
|
2463
|
-
};
|
2464
|
-
var deserializeProviderCache = (cache2) => ({
|
2471
|
+
}, "serializeNodeInfo");
|
2472
|
+
var deserializeProviderCache = /* @__PURE__ */ __name((cache2) => ({
|
2465
2473
|
consensusParametersTimestamp: cache2.consensusParametersTimestamp,
|
2466
2474
|
chain: deserializeChain(cache2.chain),
|
2467
2475
|
nodeInfo: deserializeNodeInfo(cache2.nodeInfo)
|
2468
|
-
});
|
2469
|
-
var serializeProviderCache = async (provider) => ({
|
2476
|
+
}), "deserializeProviderCache");
|
2477
|
+
var serializeProviderCache = /* @__PURE__ */ __name(async (provider) => ({
|
2470
2478
|
consensusParametersTimestamp: provider.consensusParametersTimestamp,
|
2471
2479
|
chain: serializeChain(await provider.getChain()),
|
2472
2480
|
nodeInfo: serializeNodeInfo(await provider.getNode())
|
2473
|
-
});
|
2474
|
-
var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
|
2475
|
-
var deserializeReceipt = (receipt) => {
|
2481
|
+
}), "serializeProviderCache");
|
2482
|
+
var hexOrZero = /* @__PURE__ */ __name((hex) => hex || import_configs3.ZeroBytes32, "hexOrZero");
|
2483
|
+
var deserializeReceipt = /* @__PURE__ */ __name((receipt) => {
|
2476
2484
|
const { receiptType } = receipt;
|
2477
2485
|
switch (receiptType) {
|
2478
2486
|
case "CALL" /* Call */: {
|
@@ -2662,14 +2670,14 @@ var deserializeReceipt = (receipt) => {
|
|
2662
2670
|
return burnReceipt;
|
2663
2671
|
}
|
2664
2672
|
default:
|
2665
|
-
throw new
|
2673
|
+
throw new import_errors6.FuelError(import_errors6.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
2666
2674
|
}
|
2667
|
-
};
|
2675
|
+
}, "deserializeReceipt");
|
2668
2676
|
|
2669
2677
|
// src/providers/utils/receipts.ts
|
2670
|
-
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions4.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
2671
|
-
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions4.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
2672
|
-
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
2678
|
+
var doesReceiptHaveMissingOutputVariables = /* @__PURE__ */ __name((receipt) => receipt.type === import_transactions4.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL, "doesReceiptHaveMissingOutputVariables");
|
2679
|
+
var doesReceiptHaveMissingContractId = /* @__PURE__ */ __name((receipt) => receipt.type === import_transactions4.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000", "doesReceiptHaveMissingContractId");
|
2680
|
+
var getReceiptsWithMissingData = /* @__PURE__ */ __name((receipts) => receipts.reduce(
|
2673
2681
|
(memo, receipt) => {
|
2674
2682
|
if (doesReceiptHaveMissingOutputVariables(receipt)) {
|
2675
2683
|
memo.missingOutputVariables.push(receipt);
|
@@ -2683,13 +2691,13 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
|
2683
2691
|
missingOutputVariables: [],
|
2684
2692
|
missingOutputContractIds: []
|
2685
2693
|
}
|
2686
|
-
);
|
2687
|
-
var assembleReceiptByType = (gqlReceipt) => deserializeReceipt(gqlReceipt);
|
2694
|
+
), "getReceiptsWithMissingData");
|
2695
|
+
var assembleReceiptByType = /* @__PURE__ */ __name((gqlReceipt) => deserializeReceipt(gqlReceipt), "assembleReceiptByType");
|
2688
2696
|
|
2689
2697
|
// src/providers/utils/block-explorer.ts
|
2690
|
-
var
|
2698
|
+
var import_errors7 = require("@fuel-ts/errors");
|
2691
2699
|
var DEFAULT_BLOCK_EXPLORER_URL = "https://app.fuel.network";
|
2692
|
-
var getPathFromInput = (key, value) => {
|
2700
|
+
var getPathFromInput = /* @__PURE__ */ __name((key, value) => {
|
2693
2701
|
const pathMap = {
|
2694
2702
|
address: `address`,
|
2695
2703
|
txId: `transaction`,
|
@@ -2697,8 +2705,8 @@ var getPathFromInput = (key, value) => {
|
|
2697
2705
|
};
|
2698
2706
|
const path = pathMap[key] || key;
|
2699
2707
|
return `${path}/${value}`;
|
2700
|
-
};
|
2701
|
-
var buildBlockExplorerUrl = (options = {}) => {
|
2708
|
+
}, "getPathFromInput");
|
2709
|
+
var buildBlockExplorerUrl = /* @__PURE__ */ __name((options = {}) => {
|
2702
2710
|
const { blockExplorerUrl, path, providerUrl, address, txId, blockNumber } = options;
|
2703
2711
|
const explorerUrl = blockExplorerUrl || DEFAULT_BLOCK_EXPLORER_URL;
|
2704
2712
|
const customInputParams = [
|
@@ -2721,15 +2729,15 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
2721
2729
|
}));
|
2722
2730
|
const hasAnyDefinedValues = definedValues.length > 0;
|
2723
2731
|
if (definedValues.length > 1) {
|
2724
|
-
throw new
|
2725
|
-
|
2732
|
+
throw new import_errors7.FuelError(
|
2733
|
+
import_errors7.ErrorCode.ERROR_BUILDING_BLOCK_EXPLORER_URL,
|
2726
2734
|
`Only one of the following can be passed in to buildBlockExplorerUrl: ${customInputParams.map((param) => param.key).join(", ")}.`
|
2727
2735
|
);
|
2728
2736
|
}
|
2729
2737
|
if (path && definedValues.length > 0) {
|
2730
2738
|
const inputKeys = customInputParams.map(({ key }) => key).join(", ");
|
2731
|
-
throw new
|
2732
|
-
|
2739
|
+
throw new import_errors7.FuelError(
|
2740
|
+
import_errors7.ErrorCode.ERROR_BUILDING_BLOCK_EXPLORER_URL,
|
2733
2741
|
`You cannot pass in a path to 'buildBlockExplorerUrl' along with any of the following: ${inputKeys}.`
|
2734
2742
|
);
|
2735
2743
|
}
|
@@ -2746,19 +2754,19 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
2746
2754
|
const providerUrlProtocol = cleanProviderUrl?.match(/^https?:\/\//) ? "" : "https://";
|
2747
2755
|
const url = `${protocol}${cleanBlockExplorerUrl}/${cleanPath}${encodedProviderUrl ? `?providerUrl=${providerUrlProtocol}${encodedProviderUrl}` : ""}`;
|
2748
2756
|
return url;
|
2749
|
-
};
|
2757
|
+
}, "buildBlockExplorerUrl");
|
2750
2758
|
|
2751
2759
|
// src/providers/utils/gas.ts
|
2752
2760
|
var import_math5 = require("@fuel-ts/math");
|
2753
2761
|
var import_transactions5 = require("@fuel-ts/transactions");
|
2754
2762
|
var import_utils6 = require("@fuel-ts/utils");
|
2755
|
-
var getGasUsedFromReceipts = (receipts) => {
|
2763
|
+
var getGasUsedFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
2756
2764
|
const scriptResult = receipts.filter(
|
2757
2765
|
(receipt) => receipt.type === import_transactions5.ReceiptType.ScriptResult
|
2758
2766
|
);
|
2759
2767
|
const gasUsed = scriptResult.reduce((prev, receipt) => prev.add(receipt.gasUsed), (0, import_math5.bn)(0));
|
2760
2768
|
return gasUsed;
|
2761
|
-
};
|
2769
|
+
}, "getGasUsedFromReceipts");
|
2762
2770
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
2763
2771
|
const base = (0, import_math5.bn)(gasDependentCost.base);
|
2764
2772
|
let dependentValue = (0, import_math5.bn)(0);
|
@@ -2769,6 +2777,7 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
2769
2777
|
}
|
2770
2778
|
return base.add(dependentValue);
|
2771
2779
|
}
|
2780
|
+
__name(resolveGasDependentCosts, "resolveGasDependentCosts");
|
2772
2781
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
2773
2782
|
const witnessCache = [];
|
2774
2783
|
const chargeableInputs = inputs.filter((input) => {
|
@@ -2795,6 +2804,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
|
2795
2804
|
}, (0, import_math5.bn)(0));
|
2796
2805
|
return totalGas;
|
2797
2806
|
}
|
2807
|
+
__name(gasUsedByInputs, "gasUsedByInputs");
|
2798
2808
|
function getMinGas(params) {
|
2799
2809
|
const { gasCosts, gasPerByte, inputs, metadataGas, txBytesSize } = params;
|
2800
2810
|
const vmInitGas = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
@@ -2803,6 +2813,7 @@ function getMinGas(params) {
|
|
2803
2813
|
const minGas = vmInitGas.add(bytesGas).add(inputsGas).add(metadataGas).maxU64();
|
2804
2814
|
return minGas;
|
2805
2815
|
}
|
2816
|
+
__name(getMinGas, "getMinGas");
|
2806
2817
|
function getMaxGas(params) {
|
2807
2818
|
const {
|
2808
2819
|
gasPerByte,
|
@@ -2819,6 +2830,7 @@ function getMaxGas(params) {
|
|
2819
2830
|
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
2820
2831
|
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
2821
2832
|
}
|
2833
|
+
__name(getMaxGas, "getMaxGas");
|
2822
2834
|
function calculateMetadataGasForTxCreate({
|
2823
2835
|
gasCosts,
|
2824
2836
|
stateRootSize,
|
@@ -2833,12 +2845,14 @@ function calculateMetadataGasForTxCreate({
|
|
2833
2845
|
const metadataGas = contractRootGas.add(stateRootGas).add(txIdGas).add(contractIdGas);
|
2834
2846
|
return metadataGas.maxU64();
|
2835
2847
|
}
|
2848
|
+
__name(calculateMetadataGasForTxCreate, "calculateMetadataGasForTxCreate");
|
2836
2849
|
function calculateMetadataGasForTxScript({
|
2837
2850
|
gasCosts,
|
2838
2851
|
txBytesSize
|
2839
2852
|
}) {
|
2840
2853
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2841
2854
|
}
|
2855
|
+
__name(calculateMetadataGasForTxScript, "calculateMetadataGasForTxScript");
|
2842
2856
|
function calculateMetadataGasForTxBlob({
|
2843
2857
|
gasCosts,
|
2844
2858
|
txBytesSize,
|
@@ -2848,6 +2862,7 @@ function calculateMetadataGasForTxBlob({
|
|
2848
2862
|
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
2849
2863
|
return txId.add(blobLen);
|
2850
2864
|
}
|
2865
|
+
__name(calculateMetadataGasForTxBlob, "calculateMetadataGasForTxBlob");
|
2851
2866
|
function calculateMetadataGasForTxUpgrade({
|
2852
2867
|
gasCosts,
|
2853
2868
|
txBytesSize,
|
@@ -2860,6 +2875,7 @@ function calculateMetadataGasForTxUpgrade({
|
|
2860
2875
|
}
|
2861
2876
|
return txId;
|
2862
2877
|
}
|
2878
|
+
__name(calculateMetadataGasForTxUpgrade, "calculateMetadataGasForTxUpgrade");
|
2863
2879
|
function calculateMetadataGasForTxUpload({
|
2864
2880
|
gasCosts,
|
2865
2881
|
txBytesSize,
|
@@ -2873,6 +2889,7 @@ function calculateMetadataGasForTxUpload({
|
|
2873
2889
|
txId.add(subsectionsLen);
|
2874
2890
|
return txId;
|
2875
2891
|
}
|
2892
|
+
__name(calculateMetadataGasForTxUpload, "calculateMetadataGasForTxUpload");
|
2876
2893
|
function calculateMinGasForTxUpload({
|
2877
2894
|
gasCosts,
|
2878
2895
|
baseMinGas,
|
@@ -2881,10 +2898,11 @@ function calculateMinGasForTxUpload({
|
|
2881
2898
|
const additionalStoragePerByte = (0, import_math5.bn)(gasCosts.newStoragePerByte).mul(subsectionSize);
|
2882
2899
|
return (0, import_math5.bn)(baseMinGas).add(additionalStoragePerByte);
|
2883
2900
|
}
|
2884
|
-
|
2901
|
+
__name(calculateMinGasForTxUpload, "calculateMinGasForTxUpload");
|
2902
|
+
var calculateGasFee = /* @__PURE__ */ __name((params) => {
|
2885
2903
|
const { gas, gasPrice, priceFactor, tip } = params;
|
2886
2904
|
return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
|
2887
|
-
};
|
2905
|
+
}, "calculateGasFee");
|
2888
2906
|
|
2889
2907
|
// src/providers/utils/json.ts
|
2890
2908
|
var import_utils7 = require("@fuel-ts/utils");
|
@@ -2913,16 +2931,18 @@ function normalize(object) {
|
|
2913
2931
|
});
|
2914
2932
|
return object;
|
2915
2933
|
}
|
2934
|
+
__name(normalize, "normalize");
|
2916
2935
|
function normalizeJSON(root) {
|
2917
2936
|
return normalize((0, import_ramda.clone)(root));
|
2918
2937
|
}
|
2938
|
+
__name(normalizeJSON, "normalizeJSON");
|
2919
2939
|
|
2920
2940
|
// src/providers/utils/extract-tx-error.ts
|
2921
|
-
var
|
2941
|
+
var import_errors8 = require("@fuel-ts/errors");
|
2922
2942
|
var import_math6 = require("@fuel-ts/math");
|
2923
2943
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2924
2944
|
var import_configs5 = require("@fuel-ts/transactions/configs");
|
2925
|
-
var assemblePanicError = (statusReason, metadata) => {
|
2945
|
+
var assemblePanicError = /* @__PURE__ */ __name((statusReason, metadata) => {
|
2926
2946
|
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
2927
2947
|
if (import_configs5.PANIC_REASONS.includes(statusReason)) {
|
2928
2948
|
errorMessage = `${errorMessage}
|
@@ -2931,13 +2951,13 @@ You can read more about this error at:
|
|
2931
2951
|
|
2932
2952
|
${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
|
2933
2953
|
}
|
2934
|
-
return new
|
2954
|
+
return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
|
2935
2955
|
...metadata,
|
2936
2956
|
reason: statusReason
|
2937
2957
|
});
|
2938
|
-
};
|
2939
|
-
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
2940
|
-
var assembleRevertError = (receipts, logs, metadata) => {
|
2958
|
+
}, "assemblePanicError");
|
2959
|
+
var stringify = /* @__PURE__ */ __name((obj) => JSON.stringify(obj, null, 2), "stringify");
|
2960
|
+
var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
|
2941
2961
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
2942
2962
|
const revertReceipt = receipts.find(({ type }) => type === import_transactions6.ReceiptType.Revert);
|
2943
2963
|
let reason = "";
|
@@ -2972,8 +2992,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2972
2992
|
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2973
2993
|
break;
|
2974
2994
|
default:
|
2975
|
-
throw new
|
2976
|
-
|
2995
|
+
throw new import_errors8.FuelError(
|
2996
|
+
import_errors8.ErrorCode.UNKNOWN,
|
2977
2997
|
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2978
2998
|
{
|
2979
2999
|
...metadata,
|
@@ -2982,12 +3002,12 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2982
3002
|
);
|
2983
3003
|
}
|
2984
3004
|
}
|
2985
|
-
return new
|
3005
|
+
return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
|
2986
3006
|
...metadata,
|
2987
3007
|
reason
|
2988
3008
|
});
|
2989
|
-
};
|
2990
|
-
var extractTxError = (params) => {
|
3009
|
+
}, "assembleRevertError");
|
3010
|
+
var extractTxError = /* @__PURE__ */ __name((params) => {
|
2991
3011
|
const { receipts, statusReason, logs } = params;
|
2992
3012
|
const isPanic = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Panic);
|
2993
3013
|
const isRevert = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Revert);
|
@@ -3002,10 +3022,13 @@ var extractTxError = (params) => {
|
|
3002
3022
|
return assemblePanicError(statusReason, metadata);
|
3003
3023
|
}
|
3004
3024
|
return assembleRevertError(receipts, logs, metadata);
|
3005
|
-
};
|
3025
|
+
}, "extractTxError");
|
3006
3026
|
|
3007
3027
|
// src/providers/transaction-request/errors.ts
|
3008
3028
|
var ChangeOutputCollisionError = class extends Error {
|
3029
|
+
static {
|
3030
|
+
__name(this, "ChangeOutputCollisionError");
|
3031
|
+
}
|
3009
3032
|
name = "ChangeOutputCollisionError";
|
3010
3033
|
message = 'A ChangeOutput with the same "assetId" already exists for a different "to" address';
|
3011
3034
|
};
|
@@ -3015,6 +3038,9 @@ var NoWitnessAtIndexError = class extends Error {
|
|
3015
3038
|
this.index = index;
|
3016
3039
|
this.message = `Witness at index "${index}" was not found`;
|
3017
3040
|
}
|
3041
|
+
static {
|
3042
|
+
__name(this, "NoWitnessAtIndexError");
|
3043
|
+
}
|
3018
3044
|
name = "NoWitnessAtIndexError";
|
3019
3045
|
};
|
3020
3046
|
var NoWitnessByOwnerError = class extends Error {
|
@@ -3023,23 +3049,26 @@ var NoWitnessByOwnerError = class extends Error {
|
|
3023
3049
|
this.owner = owner;
|
3024
3050
|
this.message = `A witness for the given owner "${owner}" was not found`;
|
3025
3051
|
}
|
3052
|
+
static {
|
3053
|
+
__name(this, "NoWitnessByOwnerError");
|
3054
|
+
}
|
3026
3055
|
name = "NoWitnessByOwnerError";
|
3027
3056
|
};
|
3028
3057
|
|
3029
3058
|
// src/providers/transaction-request/helpers.ts
|
3030
|
-
var
|
3059
|
+
var import_errors9 = require("@fuel-ts/errors");
|
3031
3060
|
var import_math7 = require("@fuel-ts/math");
|
3032
3061
|
var import_transactions7 = require("@fuel-ts/transactions");
|
3033
3062
|
var import_utils8 = require("@fuel-ts/utils");
|
3034
|
-
var isRequestInputCoin = (input) => input.type === import_transactions7.InputType.Coin;
|
3035
|
-
var isRequestInputMessage = (input) => input.type === import_transactions7.InputType.Message;
|
3036
|
-
var isRequestInputMessageWithoutData = (input) => input.type === import_transactions7.InputType.Message && (0, import_math7.bn)(input.data).isZero();
|
3037
|
-
var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
3038
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
|
3039
|
-
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
3040
|
-
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
3041
|
-
var isPredicate = (input) => isRequestInputCoinOrMessage(input) && !!input.predicate && (0, import_utils8.hexlify)(input.predicate) !== "0x";
|
3042
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
3063
|
+
var isRequestInputCoin = /* @__PURE__ */ __name((input) => input.type === import_transactions7.InputType.Coin, "isRequestInputCoin");
|
3064
|
+
var isRequestInputMessage = /* @__PURE__ */ __name((input) => input.type === import_transactions7.InputType.Message, "isRequestInputMessage");
|
3065
|
+
var isRequestInputMessageWithoutData = /* @__PURE__ */ __name((input) => input.type === import_transactions7.InputType.Message && (0, import_math7.bn)(input.data).isZero(), "isRequestInputMessageWithoutData");
|
3066
|
+
var isRequestInputCoinOrMessage = /* @__PURE__ */ __name((input) => isRequestInputCoin(input) || isRequestInputMessage(input), "isRequestInputCoinOrMessage");
|
3067
|
+
var isRequestInputResource = /* @__PURE__ */ __name((input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input), "isRequestInputResource");
|
3068
|
+
var getRequestInputResourceOwner = /* @__PURE__ */ __name((input) => isRequestInputCoin(input) ? input.owner : input.recipient, "getRequestInputResourceOwner");
|
3069
|
+
var isRequestInputResourceFromOwner = /* @__PURE__ */ __name((input, owner) => getRequestInputResourceOwner(input) === owner.toB256(), "isRequestInputResourceFromOwner");
|
3070
|
+
var isPredicate = /* @__PURE__ */ __name((input) => isRequestInputCoinOrMessage(input) && !!input.predicate && (0, import_utils8.hexlify)(input.predicate) !== "0x", "isPredicate");
|
3071
|
+
var getAssetAmountInRequestInputs = /* @__PURE__ */ __name((inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
3043
3072
|
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
3044
3073
|
return acc.add(input.amount);
|
3045
3074
|
}
|
@@ -3047,8 +3076,8 @@ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filte
|
|
3047
3076
|
return acc.add(input.amount);
|
3048
3077
|
}
|
3049
3078
|
return acc;
|
3050
|
-
}, (0, import_math7.bn)(0));
|
3051
|
-
var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
|
3079
|
+
}, (0, import_math7.bn)(0)), "getAssetAmountInRequestInputs");
|
3080
|
+
var cacheRequestInputsResources = /* @__PURE__ */ __name((inputs) => inputs.filter(isRequestInputResource).reduce(
|
3052
3081
|
(cache2, input) => {
|
3053
3082
|
if (isRequestInputCoin(input)) {
|
3054
3083
|
cache2.utxos.push(input.id);
|
@@ -3061,8 +3090,8 @@ var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResour
|
|
3061
3090
|
utxos: [],
|
3062
3091
|
messages: []
|
3063
3092
|
}
|
3064
|
-
);
|
3065
|
-
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
3093
|
+
), "cacheRequestInputsResources");
|
3094
|
+
var cacheRequestInputsResourcesFromOwner = /* @__PURE__ */ __name((inputs, owner) => inputs.reduce(
|
3066
3095
|
(acc, input) => {
|
3067
3096
|
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
3068
3097
|
acc.utxos.push(input.id);
|
@@ -3075,8 +3104,8 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
|
3075
3104
|
utxos: [],
|
3076
3105
|
messages: []
|
3077
3106
|
}
|
3078
|
-
);
|
3079
|
-
var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
|
3107
|
+
), "cacheRequestInputsResourcesFromOwner");
|
3108
|
+
var getBurnableAssetCount = /* @__PURE__ */ __name((baseAssetId, transactionRequest) => {
|
3080
3109
|
const { inputs, outputs } = transactionRequest;
|
3081
3110
|
const coinInputs = new Set(inputs.filter(isRequestInputCoin).map((input) => input.assetId));
|
3082
3111
|
if (inputs.some((i) => isRequestInputMessage(i) && (0, import_math7.bn)(i.amount).gt(0))) {
|
@@ -3087,8 +3116,8 @@ var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
|
|
3087
3116
|
);
|
3088
3117
|
const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
|
3089
3118
|
return difference.size;
|
3090
|
-
};
|
3091
|
-
var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAssetBurn = false) => {
|
3119
|
+
}, "getBurnableAssetCount");
|
3120
|
+
var validateTransactionForAssetBurn = /* @__PURE__ */ __name((baseAssetId, transactionRequest, enableAssetBurn = false) => {
|
3092
3121
|
if (enableAssetBurn === true) {
|
3093
3122
|
return;
|
3094
3123
|
}
|
@@ -3100,21 +3129,24 @@ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAs
|
|
3100
3129
|
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
3101
3130
|
"Or enable asset burn, upon sending the transaction."
|
3102
3131
|
].join("\n");
|
3103
|
-
throw new
|
3104
|
-
};
|
3132
|
+
throw new import_errors9.FuelError(import_errors9.ErrorCode.ASSET_BURN_DETECTED, message);
|
3133
|
+
}, "validateTransactionForAssetBurn");
|
3105
3134
|
|
3106
3135
|
// src/providers/transaction-request/witness.ts
|
3107
3136
|
var import_utils9 = require("@fuel-ts/utils");
|
3108
|
-
var witnessify = (value) => {
|
3137
|
+
var witnessify = /* @__PURE__ */ __name((value) => {
|
3109
3138
|
const data = (0, import_utils9.arrayify)(value);
|
3110
3139
|
return {
|
3111
3140
|
data: (0, import_utils9.hexlify)(data),
|
3112
3141
|
dataLength: data.length
|
3113
3142
|
};
|
3114
|
-
};
|
3143
|
+
}, "witnessify");
|
3115
3144
|
|
3116
3145
|
// src/providers/transaction-request/transaction-request.ts
|
3117
|
-
var BaseTransactionRequest = class {
|
3146
|
+
var BaseTransactionRequest = class _BaseTransactionRequest {
|
3147
|
+
static {
|
3148
|
+
__name(this, "BaseTransactionRequest");
|
3149
|
+
}
|
3118
3150
|
/** Gas price for transaction */
|
3119
3151
|
tip;
|
3120
3152
|
/** Block until which tx cannot be included */
|
@@ -3197,7 +3229,7 @@ var BaseTransactionRequest = class {
|
|
3197
3229
|
const inputs = this.inputs?.map(inputify) ?? [];
|
3198
3230
|
const outputs = this.outputs?.map(outputify) ?? [];
|
3199
3231
|
const witnesses = this.witnesses?.map(witnessify) ?? [];
|
3200
|
-
const { policyTypes, policies } =
|
3232
|
+
const { policyTypes, policies } = _BaseTransactionRequest.getPolicyMeta(this);
|
3201
3233
|
return {
|
3202
3234
|
policyTypes,
|
3203
3235
|
inputs,
|
@@ -3498,7 +3530,7 @@ var BaseTransactionRequest = class {
|
|
3498
3530
|
* @hidden
|
3499
3531
|
*/
|
3500
3532
|
metadataGas(_gasCosts) {
|
3501
|
-
throw new
|
3533
|
+
throw new import_errors10.FuelError(import_errors10.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
|
3502
3534
|
}
|
3503
3535
|
/**
|
3504
3536
|
* @hidden
|
@@ -3545,13 +3577,13 @@ var BaseTransactionRequest = class {
|
|
3545
3577
|
* Please use `Account.generateFakeResources` along with `this.addResources` instead.
|
3546
3578
|
*/
|
3547
3579
|
fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
|
3548
|
-
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
3580
|
+
const findAssetInput = /* @__PURE__ */ __name((assetId) => this.inputs.find((input) => {
|
3549
3581
|
if ("assetId" in input) {
|
3550
3582
|
return input.assetId === assetId;
|
3551
3583
|
}
|
3552
3584
|
return false;
|
3553
|
-
});
|
3554
|
-
const updateAssetInput = (assetId, quantity) => {
|
3585
|
+
}), "findAssetInput");
|
3586
|
+
const updateAssetInput = /* @__PURE__ */ __name((assetId, quantity) => {
|
3555
3587
|
const assetInput = findAssetInput(assetId);
|
3556
3588
|
let usedQuantity = quantity;
|
3557
3589
|
if (assetId === baseAssetId) {
|
@@ -3572,7 +3604,7 @@ var BaseTransactionRequest = class {
|
|
3572
3604
|
}
|
3573
3605
|
]);
|
3574
3606
|
}
|
3575
|
-
};
|
3607
|
+
}, "updateAssetInput");
|
3576
3608
|
updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
|
3577
3609
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
3578
3610
|
return this;
|
@@ -3660,6 +3692,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3660
3692
|
transaction.inputs = transaction.inputs.map((input) => {
|
3661
3693
|
const inputClone = (0, import_ramda2.clone)(input);
|
3662
3694
|
switch (inputClone.type) {
|
3695
|
+
// Zero out on signing: txPointer, predicateGasUsed
|
3663
3696
|
case import_transactions9.InputType.Coin: {
|
3664
3697
|
inputClone.txPointer = {
|
3665
3698
|
blockHeight: 0,
|
@@ -3668,10 +3701,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3668
3701
|
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
3669
3702
|
return inputClone;
|
3670
3703
|
}
|
3704
|
+
// Zero out on signing: predicateGasUsed
|
3671
3705
|
case import_transactions9.InputType.Message: {
|
3672
3706
|
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
3673
3707
|
return inputClone;
|
3674
3708
|
}
|
3709
|
+
// Zero out on signing: txID, outputIndex, balanceRoot, stateRoot, and txPointer
|
3675
3710
|
case import_transactions9.InputType.Contract: {
|
3676
3711
|
inputClone.txPointer = {
|
3677
3712
|
blockHeight: 0,
|
@@ -3690,15 +3725,18 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3690
3725
|
transaction.outputs = transaction.outputs.map((output) => {
|
3691
3726
|
const outputClone = (0, import_ramda2.clone)(output);
|
3692
3727
|
switch (outputClone.type) {
|
3728
|
+
// Zero out on signing: balanceRoot, stateRoot
|
3693
3729
|
case import_transactions9.OutputType.Contract: {
|
3694
3730
|
outputClone.balanceRoot = import_configs7.ZeroBytes32;
|
3695
3731
|
outputClone.stateRoot = import_configs7.ZeroBytes32;
|
3696
3732
|
return outputClone;
|
3697
3733
|
}
|
3734
|
+
// Zero out on signing: amount
|
3698
3735
|
case import_transactions9.OutputType.Change: {
|
3699
3736
|
outputClone.amount = (0, import_math9.bn)(0);
|
3700
3737
|
return outputClone;
|
3701
3738
|
}
|
3739
|
+
// Zero out on signing: amount, to and assetId
|
3702
3740
|
case import_transactions9.OutputType.Variable: {
|
3703
3741
|
outputClone.to = import_configs7.ZeroBytes32;
|
3704
3742
|
outputClone.amount = (0, import_math9.bn)(0);
|
@@ -3715,9 +3753,13 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3715
3753
|
const concatenatedData = (0, import_utils12.concat)([chainIdBytes, new import_transactions9.TransactionCoder().encode(transaction)]);
|
3716
3754
|
return (0, import_hasher.sha256)(concatenatedData);
|
3717
3755
|
}
|
3756
|
+
__name(hashTransaction, "hashTransaction");
|
3718
3757
|
|
3719
3758
|
// src/providers/transaction-request/blob-transaction-request.ts
|
3720
3759
|
var BlobTransactionRequest = class extends BaseTransactionRequest {
|
3760
|
+
static {
|
3761
|
+
__name(this, "BlobTransactionRequest");
|
3762
|
+
}
|
3721
3763
|
static from(obj) {
|
3722
3764
|
return new this((0, import_ramda3.clone)(obj));
|
3723
3765
|
}
|
@@ -3786,12 +3828,12 @@ var import_ramda4 = require("ramda");
|
|
3786
3828
|
|
3787
3829
|
// src/providers/transaction-request/storage-slot.ts
|
3788
3830
|
var import_utils14 = require("@fuel-ts/utils");
|
3789
|
-
var getStorageValue = (value) => {
|
3831
|
+
var getStorageValue = /* @__PURE__ */ __name((value) => {
|
3790
3832
|
const v = new Uint8Array(32);
|
3791
3833
|
v.set((0, import_utils14.arrayify)(value));
|
3792
3834
|
return v;
|
3793
|
-
};
|
3794
|
-
var storageSlotify = (storageSlot) => {
|
3835
|
+
}, "getStorageValue");
|
3836
|
+
var storageSlotify = /* @__PURE__ */ __name((storageSlot) => {
|
3795
3837
|
let key;
|
3796
3838
|
let value;
|
3797
3839
|
if (Array.isArray(storageSlot)) {
|
@@ -3805,10 +3847,13 @@ var storageSlotify = (storageSlot) => {
|
|
3805
3847
|
key: (0, import_utils14.hexlify)(key),
|
3806
3848
|
value: (0, import_utils14.hexlify)(getStorageValue(value))
|
3807
3849
|
};
|
3808
|
-
};
|
3850
|
+
}, "storageSlotify");
|
3809
3851
|
|
3810
3852
|
// src/providers/transaction-request/create-transaction-request.ts
|
3811
3853
|
var CreateTransactionRequest = class extends BaseTransactionRequest {
|
3854
|
+
static {
|
3855
|
+
__name(this, "CreateTransactionRequest");
|
3856
|
+
}
|
3812
3857
|
static from(obj) {
|
3813
3858
|
return new this((0, import_ramda4.clone)(obj));
|
3814
3859
|
}
|
@@ -3910,7 +3955,7 @@ var returnZeroScript = {
|
|
3910
3955
|
*/
|
3911
3956
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
3912
3957
|
bytes: (0, import_utils16.arrayify)("0x24000000"),
|
3913
|
-
encodeScriptData: () => new Uint8Array(0)
|
3958
|
+
encodeScriptData: /* @__PURE__ */ __name(() => new Uint8Array(0), "encodeScriptData")
|
3914
3959
|
};
|
3915
3960
|
var withdrawScript = {
|
3916
3961
|
/*
|
@@ -3924,11 +3969,14 @@ var withdrawScript = {
|
|
3924
3969
|
*/
|
3925
3970
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
3926
3971
|
bytes: (0, import_utils16.arrayify)("0x5040C0105D44C0064C40001124000000"),
|
3927
|
-
encodeScriptData: () => new Uint8Array(0)
|
3972
|
+
encodeScriptData: /* @__PURE__ */ __name(() => new Uint8Array(0), "encodeScriptData")
|
3928
3973
|
};
|
3929
3974
|
|
3930
3975
|
// src/providers/transaction-request/script-transaction-request.ts
|
3931
3976
|
var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
3977
|
+
static {
|
3978
|
+
__name(this, "ScriptTransactionRequest");
|
3979
|
+
}
|
3932
3980
|
static from(obj) {
|
3933
3981
|
return new this((0, import_ramda5.clone)(obj));
|
3934
3982
|
}
|
@@ -4121,14 +4169,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
4121
4169
|
};
|
4122
4170
|
|
4123
4171
|
// src/providers/transaction-request/upgrade-transaction-request.ts
|
4124
|
-
var
|
4172
|
+
var import_errors12 = require("@fuel-ts/errors");
|
4125
4173
|
var import_hasher2 = require("@fuel-ts/hasher");
|
4126
4174
|
var import_transactions12 = require("@fuel-ts/transactions");
|
4127
4175
|
var import_utils18 = require("@fuel-ts/utils");
|
4128
4176
|
var import_ramda6 = require("ramda");
|
4129
|
-
var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
4177
|
+
var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTransactionRequest {
|
4178
|
+
static {
|
4179
|
+
__name(this, "UpgradeTransactionRequest");
|
4180
|
+
}
|
4130
4181
|
static from(obj) {
|
4131
|
-
if (obj instanceof
|
4182
|
+
if (obj instanceof _UpgradeTransactionRequest) {
|
4132
4183
|
return obj;
|
4133
4184
|
}
|
4134
4185
|
return new this((0, import_ramda6.clone)(obj));
|
@@ -4225,7 +4276,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
4225
4276
|
}
|
4226
4277
|
};
|
4227
4278
|
} else {
|
4228
|
-
throw new
|
4279
|
+
throw new import_errors12.FuelError(import_errors12.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
4229
4280
|
}
|
4230
4281
|
return {
|
4231
4282
|
type: import_transactions12.TransactionType.Upgrade,
|
@@ -4267,7 +4318,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
4267
4318
|
txBytesSize
|
4268
4319
|
});
|
4269
4320
|
}
|
4270
|
-
throw new
|
4321
|
+
throw new import_errors12.FuelError(import_errors12.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
4271
4322
|
}
|
4272
4323
|
};
|
4273
4324
|
|
@@ -4276,9 +4327,12 @@ var import_configs10 = require("@fuel-ts/address/configs");
|
|
4276
4327
|
var import_transactions13 = require("@fuel-ts/transactions");
|
4277
4328
|
var import_utils20 = require("@fuel-ts/utils");
|
4278
4329
|
var import_ramda7 = require("ramda");
|
4279
|
-
var UploadTransactionRequest = class extends BaseTransactionRequest {
|
4330
|
+
var UploadTransactionRequest = class _UploadTransactionRequest extends BaseTransactionRequest {
|
4331
|
+
static {
|
4332
|
+
__name(this, "UploadTransactionRequest");
|
4333
|
+
}
|
4280
4334
|
static from(obj) {
|
4281
|
-
if (obj instanceof
|
4335
|
+
if (obj instanceof _UploadTransactionRequest) {
|
4282
4336
|
return obj;
|
4283
4337
|
}
|
4284
4338
|
return new this((0, import_ramda7.clone)(obj));
|
@@ -4379,12 +4433,15 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
|
|
4379
4433
|
|
4380
4434
|
// src/providers/transaction-request/types.ts
|
4381
4435
|
var AbstractScriptRequest = class {
|
4436
|
+
static {
|
4437
|
+
__name(this, "AbstractScriptRequest");
|
4438
|
+
}
|
4382
4439
|
};
|
4383
4440
|
|
4384
4441
|
// src/providers/transaction-request/utils.ts
|
4385
|
-
var
|
4442
|
+
var import_errors13 = require("@fuel-ts/errors");
|
4386
4443
|
var import_transactions14 = require("@fuel-ts/transactions");
|
4387
|
-
var transactionRequestify = (obj) => {
|
4444
|
+
var transactionRequestify = /* @__PURE__ */ __name((obj) => {
|
4388
4445
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
4389
4446
|
return obj;
|
4390
4447
|
}
|
@@ -4406,28 +4463,31 @@ var transactionRequestify = (obj) => {
|
|
4406
4463
|
return UploadTransactionRequest.from(obj);
|
4407
4464
|
}
|
4408
4465
|
default: {
|
4409
|
-
throw new
|
4410
|
-
|
4466
|
+
throw new import_errors13.FuelError(
|
4467
|
+
import_errors13.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
4411
4468
|
`Unsupported transaction type: ${type}.`
|
4412
4469
|
);
|
4413
4470
|
}
|
4414
4471
|
}
|
4415
|
-
};
|
4416
|
-
var isTransactionTypeScript = (request2) => request2.type === import_transactions14.TransactionType.Script;
|
4417
|
-
var isTransactionTypeCreate = (request2) => request2.type === import_transactions14.TransactionType.Create;
|
4418
|
-
var isTransactionTypeBlob = (request2) => request2.type === import_transactions14.TransactionType.Blob;
|
4419
|
-
var isTransactionTypeUpgrade = (request2) => request2.type === import_transactions14.TransactionType.Upgrade;
|
4420
|
-
var isTransactionTypeUpload = (request2) => request2.type === import_transactions14.TransactionType.Upload;
|
4472
|
+
}, "transactionRequestify");
|
4473
|
+
var isTransactionTypeScript = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Script, "isTransactionTypeScript");
|
4474
|
+
var isTransactionTypeCreate = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Create, "isTransactionTypeCreate");
|
4475
|
+
var isTransactionTypeBlob = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Blob, "isTransactionTypeBlob");
|
4476
|
+
var isTransactionTypeUpgrade = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Upgrade, "isTransactionTypeUpgrade");
|
4477
|
+
var isTransactionTypeUpload = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Upload, "isTransactionTypeUpload");
|
4421
4478
|
|
4422
4479
|
// src/providers/resource-cache.ts
|
4423
4480
|
var cache = /* @__PURE__ */ new Map();
|
4424
4481
|
var ResourceCache = class {
|
4482
|
+
static {
|
4483
|
+
__name(this, "ResourceCache");
|
4484
|
+
}
|
4425
4485
|
ttl;
|
4426
4486
|
constructor(ttl) {
|
4427
4487
|
this.ttl = ttl;
|
4428
4488
|
if (typeof ttl !== "number" || this.ttl <= 0) {
|
4429
|
-
throw new
|
4430
|
-
|
4489
|
+
throw new import_errors14.FuelError(
|
4490
|
+
import_errors14.ErrorCode.INVALID_TTL,
|
4431
4491
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
4432
4492
|
);
|
4433
4493
|
}
|
@@ -4511,7 +4571,7 @@ var ResourceCache = class {
|
|
4511
4571
|
};
|
4512
4572
|
|
4513
4573
|
// src/providers/transaction-response/transaction-response.ts
|
4514
|
-
var
|
4574
|
+
var import_errors18 = require("@fuel-ts/errors");
|
4515
4575
|
var import_math17 = require("@fuel-ts/math");
|
4516
4576
|
var import_transactions22 = require("@fuel-ts/transactions");
|
4517
4577
|
var import_utils26 = require("@fuel-ts/utils");
|
@@ -4525,7 +4585,7 @@ var import_utils24 = require("@fuel-ts/utils");
|
|
4525
4585
|
var import_math12 = require("@fuel-ts/math");
|
4526
4586
|
var import_transactions15 = require("@fuel-ts/transactions");
|
4527
4587
|
var import_utils23 = require("@fuel-ts/utils");
|
4528
|
-
var calculateTXFeeForSummary = (params) => {
|
4588
|
+
var calculateTXFeeForSummary = /* @__PURE__ */ __name((params) => {
|
4529
4589
|
const {
|
4530
4590
|
gasPrice,
|
4531
4591
|
rawPayload,
|
@@ -4585,43 +4645,51 @@ var calculateTXFeeForSummary = (params) => {
|
|
4585
4645
|
tip
|
4586
4646
|
});
|
4587
4647
|
return maxFee;
|
4588
|
-
};
|
4648
|
+
}, "calculateTXFeeForSummary");
|
4589
4649
|
|
4590
4650
|
// src/providers/transaction-summary/operations.ts
|
4591
4651
|
var import_configs11 = require("@fuel-ts/address/configs");
|
4592
|
-
var
|
4652
|
+
var import_errors16 = require("@fuel-ts/errors");
|
4593
4653
|
var import_math14 = require("@fuel-ts/math");
|
4594
4654
|
var import_transactions18 = require("@fuel-ts/transactions");
|
4595
4655
|
|
4596
4656
|
// src/providers/transaction-summary/input.ts
|
4597
|
-
var
|
4657
|
+
var import_errors15 = require("@fuel-ts/errors");
|
4598
4658
|
var import_math13 = require("@fuel-ts/math");
|
4599
4659
|
var import_transactions16 = require("@fuel-ts/transactions");
|
4600
4660
|
function getInputsByTypes(inputs, types) {
|
4601
4661
|
return inputs.filter((i) => types.includes(i.type));
|
4602
4662
|
}
|
4663
|
+
__name(getInputsByTypes, "getInputsByTypes");
|
4603
4664
|
function getInputsByType(inputs, type) {
|
4604
4665
|
return inputs.filter((i) => i.type === type);
|
4605
4666
|
}
|
4667
|
+
__name(getInputsByType, "getInputsByType");
|
4606
4668
|
function getInputsCoin(inputs) {
|
4607
4669
|
return getInputsByType(inputs, import_transactions16.InputType.Coin);
|
4608
4670
|
}
|
4671
|
+
__name(getInputsCoin, "getInputsCoin");
|
4609
4672
|
function getInputsMessage(inputs) {
|
4610
4673
|
return getInputsByType(inputs, import_transactions16.InputType.Message);
|
4611
4674
|
}
|
4675
|
+
__name(getInputsMessage, "getInputsMessage");
|
4612
4676
|
function getInputsCoinAndMessage(inputs) {
|
4613
4677
|
return getInputsByTypes(inputs, [import_transactions16.InputType.Coin, import_transactions16.InputType.Message]);
|
4614
4678
|
}
|
4679
|
+
__name(getInputsCoinAndMessage, "getInputsCoinAndMessage");
|
4615
4680
|
function isInputCoin(input) {
|
4616
4681
|
return input.type === import_transactions16.InputType.Coin;
|
4617
4682
|
}
|
4683
|
+
__name(isInputCoin, "isInputCoin");
|
4618
4684
|
function getInputsContract(inputs) {
|
4619
4685
|
return getInputsByType(inputs, import_transactions16.InputType.Contract);
|
4620
4686
|
}
|
4687
|
+
__name(getInputsContract, "getInputsContract");
|
4621
4688
|
function findCoinInput(inputs, assetId) {
|
4622
4689
|
const coinInputs = getInputsCoin(inputs);
|
4623
4690
|
return coinInputs.find((i) => i.assetId === assetId);
|
4624
4691
|
}
|
4692
|
+
__name(findCoinInput, "findCoinInput");
|
4625
4693
|
function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
|
4626
4694
|
const aggregated = /* @__PURE__ */ new Map();
|
4627
4695
|
getInputsCoinAndMessage(inputs).forEach((input) => {
|
@@ -4641,9 +4709,11 @@ function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
|
|
4641
4709
|
});
|
4642
4710
|
return aggregated;
|
4643
4711
|
}
|
4712
|
+
__name(aggregateInputsAmountsByAssetAndOwner, "aggregateInputsAmountsByAssetAndOwner");
|
4644
4713
|
function findMessageInput(inputs) {
|
4645
4714
|
return getInputsMessage(inputs)?.[0];
|
4646
4715
|
}
|
4716
|
+
__name(findMessageInput, "findMessageInput");
|
4647
4717
|
function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
|
4648
4718
|
const coinInput = findCoinInput(inputs, assetId);
|
4649
4719
|
if (coinInput) {
|
@@ -4654,6 +4724,7 @@ function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
|
|
4654
4724
|
}
|
4655
4725
|
return void 0;
|
4656
4726
|
}
|
4727
|
+
__name(getInputFromAssetId, "getInputFromAssetId");
|
4657
4728
|
function getInputContractFromIndex(inputs, inputIndex) {
|
4658
4729
|
if (inputIndex == null) {
|
4659
4730
|
return void 0;
|
@@ -4663,13 +4734,14 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
4663
4734
|
return void 0;
|
4664
4735
|
}
|
4665
4736
|
if (contractInput.type !== import_transactions16.InputType.Contract) {
|
4666
|
-
throw new
|
4667
|
-
|
4737
|
+
throw new import_errors15.FuelError(
|
4738
|
+
import_errors15.ErrorCode.INVALID_TRANSACTION_INPUT,
|
4668
4739
|
`Contract input should be of type 'contract'.`
|
4669
4740
|
);
|
4670
4741
|
}
|
4671
4742
|
return contractInput;
|
4672
4743
|
}
|
4744
|
+
__name(getInputContractFromIndex, "getInputContractFromIndex");
|
4673
4745
|
function getInputAccountAddress(input) {
|
4674
4746
|
if (input.type === import_transactions16.InputType.Coin) {
|
4675
4747
|
return input.owner.toString();
|
@@ -4679,27 +4751,34 @@ function getInputAccountAddress(input) {
|
|
4679
4751
|
}
|
4680
4752
|
return "";
|
4681
4753
|
}
|
4754
|
+
__name(getInputAccountAddress, "getInputAccountAddress");
|
4682
4755
|
|
4683
4756
|
// src/providers/transaction-summary/output.ts
|
4684
4757
|
var import_transactions17 = require("@fuel-ts/transactions");
|
4685
4758
|
function getOutputsByType(outputs, type) {
|
4686
4759
|
return outputs.filter((o) => o.type === type);
|
4687
4760
|
}
|
4761
|
+
__name(getOutputsByType, "getOutputsByType");
|
4688
4762
|
function getOutputsContractCreated(outputs) {
|
4689
4763
|
return getOutputsByType(outputs, import_transactions17.OutputType.ContractCreated);
|
4690
4764
|
}
|
4765
|
+
__name(getOutputsContractCreated, "getOutputsContractCreated");
|
4691
4766
|
function getOutputsCoin(outputs) {
|
4692
4767
|
return getOutputsByType(outputs, import_transactions17.OutputType.Coin);
|
4693
4768
|
}
|
4769
|
+
__name(getOutputsCoin, "getOutputsCoin");
|
4694
4770
|
function getOutputsChange(outputs) {
|
4695
4771
|
return getOutputsByType(outputs, import_transactions17.OutputType.Change);
|
4696
4772
|
}
|
4773
|
+
__name(getOutputsChange, "getOutputsChange");
|
4697
4774
|
function getOutputsContract(outputs) {
|
4698
4775
|
return getOutputsByType(outputs, import_transactions17.OutputType.Contract);
|
4699
4776
|
}
|
4777
|
+
__name(getOutputsContract, "getOutputsContract");
|
4700
4778
|
function getOutputsVariable(outputs) {
|
4701
4779
|
return getOutputsByType(outputs, import_transactions17.OutputType.Variable);
|
4702
4780
|
}
|
4781
|
+
__name(getOutputsVariable, "getOutputsVariable");
|
4703
4782
|
|
4704
4783
|
// src/providers/transaction-summary/types.ts
|
4705
4784
|
var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
|
@@ -4742,6 +4821,7 @@ var ChainName = /* @__PURE__ */ ((ChainName2) => {
|
|
4742
4821
|
function getReceiptsByType(receipts, type) {
|
4743
4822
|
return (receipts ?? []).filter((r) => r.type === type);
|
4744
4823
|
}
|
4824
|
+
__name(getReceiptsByType, "getReceiptsByType");
|
4745
4825
|
function getTransactionTypeName(transactionType) {
|
4746
4826
|
switch (transactionType) {
|
4747
4827
|
case import_transactions18.TransactionType.Mint:
|
@@ -4757,43 +4837,54 @@ function getTransactionTypeName(transactionType) {
|
|
4757
4837
|
case import_transactions18.TransactionType.Upload:
|
4758
4838
|
return "Upload" /* Upload */;
|
4759
4839
|
default:
|
4760
|
-
throw new
|
4761
|
-
|
4840
|
+
throw new import_errors16.FuelError(
|
4841
|
+
import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
4762
4842
|
`Unsupported transaction type: ${transactionType}.`
|
4763
4843
|
);
|
4764
4844
|
}
|
4765
4845
|
}
|
4846
|
+
__name(getTransactionTypeName, "getTransactionTypeName");
|
4766
4847
|
function isType(transactionType, type) {
|
4767
4848
|
const txType = getTransactionTypeName(transactionType);
|
4768
4849
|
return txType === type;
|
4769
4850
|
}
|
4851
|
+
__name(isType, "isType");
|
4770
4852
|
function isTypeMint(transactionType) {
|
4771
4853
|
return isType(transactionType, "Mint" /* Mint */);
|
4772
4854
|
}
|
4855
|
+
__name(isTypeMint, "isTypeMint");
|
4773
4856
|
function isTypeCreate(transactionType) {
|
4774
4857
|
return isType(transactionType, "Create" /* Create */);
|
4775
4858
|
}
|
4859
|
+
__name(isTypeCreate, "isTypeCreate");
|
4776
4860
|
function isTypeScript(transactionType) {
|
4777
4861
|
return isType(transactionType, "Script" /* Script */);
|
4778
4862
|
}
|
4863
|
+
__name(isTypeScript, "isTypeScript");
|
4779
4864
|
function isTypeUpgrade(transactionType) {
|
4780
4865
|
return isType(transactionType, "Upgrade" /* Upgrade */);
|
4781
4866
|
}
|
4867
|
+
__name(isTypeUpgrade, "isTypeUpgrade");
|
4782
4868
|
function isTypeUpload(transactionType) {
|
4783
4869
|
return isType(transactionType, "Upload" /* Upload */);
|
4784
4870
|
}
|
4871
|
+
__name(isTypeUpload, "isTypeUpload");
|
4785
4872
|
function isTypeBlob(transactionType) {
|
4786
4873
|
return isType(transactionType, "Blob" /* Blob */);
|
4787
4874
|
}
|
4875
|
+
__name(isTypeBlob, "isTypeBlob");
|
4788
4876
|
function hasSameAssetId(a) {
|
4789
4877
|
return (b) => a.assetId === b.assetId;
|
4790
4878
|
}
|
4879
|
+
__name(hasSameAssetId, "hasSameAssetId");
|
4791
4880
|
function getReceiptsCall(receipts) {
|
4792
4881
|
return getReceiptsByType(receipts, import_transactions18.ReceiptType.Call);
|
4793
4882
|
}
|
4883
|
+
__name(getReceiptsCall, "getReceiptsCall");
|
4794
4884
|
function getReceiptsMessageOut(receipts) {
|
4795
4885
|
return getReceiptsByType(receipts, import_transactions18.ReceiptType.MessageOut);
|
4796
4886
|
}
|
4887
|
+
__name(getReceiptsMessageOut, "getReceiptsMessageOut");
|
4797
4888
|
function mergeAssets(op1, op2) {
|
4798
4889
|
const assets1 = op1.assetsSent || [];
|
4799
4890
|
const assets2 = op2.assetsSent || [];
|
@@ -4811,21 +4902,25 @@ function mergeAssets(op1, op2) {
|
|
4811
4902
|
});
|
4812
4903
|
return Array.from(assetMap.values());
|
4813
4904
|
}
|
4905
|
+
__name(mergeAssets, "mergeAssets");
|
4814
4906
|
function isSameOperation(a, b) {
|
4815
4907
|
return a.name === b.name && a.from?.address === b.from?.address && a.to?.address === b.to?.address && a.from?.type === b.from?.type && a.to?.type === b.to?.type;
|
4816
4908
|
}
|
4909
|
+
__name(isSameOperation, "isSameOperation");
|
4817
4910
|
function mergeAssetsSent(existing, toAdd) {
|
4818
4911
|
if (!toAdd.assetsSent?.length) {
|
4819
4912
|
return existing.assetsSent;
|
4820
4913
|
}
|
4821
4914
|
return existing.assetsSent?.length ? mergeAssets(existing, toAdd) : toAdd.assetsSent;
|
4822
4915
|
}
|
4916
|
+
__name(mergeAssetsSent, "mergeAssetsSent");
|
4823
4917
|
function mergeCalls(existing, toAdd) {
|
4824
4918
|
if (!toAdd.calls?.length) {
|
4825
4919
|
return existing.calls;
|
4826
4920
|
}
|
4827
4921
|
return [...existing.calls || [], ...toAdd.calls];
|
4828
4922
|
}
|
4923
|
+
__name(mergeCalls, "mergeCalls");
|
4829
4924
|
function mergeOperations(existing, toAdd) {
|
4830
4925
|
return {
|
4831
4926
|
...existing,
|
@@ -4837,6 +4932,7 @@ function mergeOperations(existing, toAdd) {
|
|
4837
4932
|
]
|
4838
4933
|
};
|
4839
4934
|
}
|
4935
|
+
__name(mergeOperations, "mergeOperations");
|
4840
4936
|
function addOperation(operations, toAdd) {
|
4841
4937
|
const existingIndex = operations.findIndex((op) => isSameOperation(op, toAdd));
|
4842
4938
|
if (existingIndex === -1) {
|
@@ -4844,9 +4940,11 @@ function addOperation(operations, toAdd) {
|
|
4844
4940
|
}
|
4845
4941
|
return operations.map((op, index) => index === existingIndex ? mergeOperations(op, toAdd) : op);
|
4846
4942
|
}
|
4943
|
+
__name(addOperation, "addOperation");
|
4847
4944
|
function getReceiptsTransferOut(receipts) {
|
4848
4945
|
return getReceiptsByType(receipts, import_transactions18.ReceiptType.TransferOut);
|
4849
4946
|
}
|
4947
|
+
__name(getReceiptsTransferOut, "getReceiptsTransferOut");
|
4850
4948
|
function getWithdrawFromFuelOperations({
|
4851
4949
|
inputs,
|
4852
4950
|
receipts,
|
@@ -4885,6 +4983,7 @@ function getWithdrawFromFuelOperations({
|
|
4885
4983
|
);
|
4886
4984
|
return withdrawFromFuelOperations;
|
4887
4985
|
}
|
4986
|
+
__name(getWithdrawFromFuelOperations, "getWithdrawFromFuelOperations");
|
4888
4987
|
function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
|
4889
4988
|
const abi = abiMap?.[contractInput.contractID];
|
4890
4989
|
if (!abi) {
|
@@ -4892,6 +4991,7 @@ function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInpu
|
|
4892
4991
|
}
|
4893
4992
|
return [];
|
4894
4993
|
}
|
4994
|
+
__name(getContractCalls, "getContractCalls");
|
4895
4995
|
function getAssetsSent(receipt) {
|
4896
4996
|
return receipt.amount?.isZero() ? void 0 : [
|
4897
4997
|
{
|
@@ -4900,6 +5000,7 @@ function getAssetsSent(receipt) {
|
|
4900
5000
|
}
|
4901
5001
|
];
|
4902
5002
|
}
|
5003
|
+
__name(getAssetsSent, "getAssetsSent");
|
4903
5004
|
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
4904
5005
|
const assetId = receipt.assetId === import_configs11.ZeroBytes32 ? baseAssetId : receipt.assetId;
|
4905
5006
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
@@ -4925,6 +5026,7 @@ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload,
|
|
4925
5026
|
}
|
4926
5027
|
];
|
4927
5028
|
}
|
5029
|
+
__name(processCallReceipt, "processCallReceipt");
|
4928
5030
|
function getContractCallOperations({
|
4929
5031
|
inputs,
|
4930
5032
|
outputs,
|
@@ -4954,6 +5056,7 @@ function getContractCallOperations({
|
|
4954
5056
|
);
|
4955
5057
|
});
|
4956
5058
|
}
|
5059
|
+
__name(getContractCallOperations, "getContractCallOperations");
|
4957
5060
|
function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
|
4958
5061
|
const { to: toAddress, assetId, amount } = receipt;
|
4959
5062
|
let { id: fromAddress } = receipt;
|
@@ -4982,6 +5085,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
4982
5085
|
receipts: [receipt]
|
4983
5086
|
};
|
4984
5087
|
}
|
5088
|
+
__name(extractTransferOperationFromReceipt, "extractTransferOperationFromReceipt");
|
4985
5089
|
function getTransferOperations({
|
4986
5090
|
inputs,
|
4987
5091
|
outputs,
|
@@ -5036,6 +5140,7 @@ function getTransferOperations({
|
|
5036
5140
|
});
|
5037
5141
|
return operations;
|
5038
5142
|
}
|
5143
|
+
__name(getTransferOperations, "getTransferOperations");
|
5039
5144
|
function getPayProducerOperations(outputs) {
|
5040
5145
|
const coinOutputs = getOutputsCoin(outputs);
|
5041
5146
|
const payProducerOperations = coinOutputs.reduce((prev, output) => {
|
@@ -5060,6 +5165,7 @@ function getPayProducerOperations(outputs) {
|
|
5060
5165
|
}, []);
|
5061
5166
|
return payProducerOperations;
|
5062
5167
|
}
|
5168
|
+
__name(getPayProducerOperations, "getPayProducerOperations");
|
5063
5169
|
function getContractCreatedOperations({ inputs, outputs }) {
|
5064
5170
|
const contractCreatedOutputs = getOutputsContractCreated(outputs);
|
5065
5171
|
const input = getInputsCoinAndMessage(inputs)[0];
|
@@ -5080,6 +5186,7 @@ function getContractCreatedOperations({ inputs, outputs }) {
|
|
5080
5186
|
}, []);
|
5081
5187
|
return contractCreatedOperations;
|
5082
5188
|
}
|
5189
|
+
__name(getContractCreatedOperations, "getContractCreatedOperations");
|
5083
5190
|
function getOperations({
|
5084
5191
|
transactionType,
|
5085
5192
|
inputs,
|
@@ -5110,11 +5217,12 @@ function getOperations({
|
|
5110
5217
|
}
|
5111
5218
|
return [...getPayProducerOperations(outputs)];
|
5112
5219
|
}
|
5220
|
+
__name(getOperations, "getOperations");
|
5113
5221
|
|
5114
5222
|
// src/providers/transaction-summary/receipt.ts
|
5115
5223
|
var import_transactions19 = require("@fuel-ts/transactions");
|
5116
|
-
var processGqlReceipt = (gqlReceipt) => deserializeReceipt(gqlReceipt);
|
5117
|
-
var extractMintedAssetsFromReceipts = (receipts) => {
|
5224
|
+
var processGqlReceipt = /* @__PURE__ */ __name((gqlReceipt) => deserializeReceipt(gqlReceipt), "processGqlReceipt");
|
5225
|
+
var extractMintedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
5118
5226
|
const mintedAssets = [];
|
5119
5227
|
receipts.forEach((receipt) => {
|
5120
5228
|
if (receipt.type === import_transactions19.ReceiptType.Mint) {
|
@@ -5127,8 +5235,8 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
5127
5235
|
}
|
5128
5236
|
});
|
5129
5237
|
return mintedAssets;
|
5130
|
-
};
|
5131
|
-
var extractBurnedAssetsFromReceipts = (receipts) => {
|
5238
|
+
}, "extractMintedAssetsFromReceipts");
|
5239
|
+
var extractBurnedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
5132
5240
|
const burnedAssets = [];
|
5133
5241
|
receipts.forEach((receipt) => {
|
5134
5242
|
if (receipt.type === import_transactions19.ReceiptType.Burn) {
|
@@ -5141,12 +5249,12 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
5141
5249
|
}
|
5142
5250
|
});
|
5143
5251
|
return burnedAssets;
|
5144
|
-
};
|
5252
|
+
}, "extractBurnedAssetsFromReceipts");
|
5145
5253
|
|
5146
5254
|
// src/providers/transaction-summary/status.ts
|
5147
|
-
var
|
5255
|
+
var import_errors17 = require("@fuel-ts/errors");
|
5148
5256
|
var import_math15 = require("@fuel-ts/math");
|
5149
|
-
var getTransactionStatusName = (gqlStatus) => {
|
5257
|
+
var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
|
5150
5258
|
switch (gqlStatus) {
|
5151
5259
|
case "FailureStatus":
|
5152
5260
|
return "failure" /* failure */;
|
@@ -5157,13 +5265,13 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
5157
5265
|
case "SqueezedOutStatus":
|
5158
5266
|
return "squeezedout" /* squeezedout */;
|
5159
5267
|
default:
|
5160
|
-
throw new
|
5161
|
-
|
5268
|
+
throw new import_errors17.FuelError(
|
5269
|
+
import_errors17.ErrorCode.INVALID_TRANSACTION_STATUS,
|
5162
5270
|
`Invalid transaction status: ${gqlStatus}.`
|
5163
5271
|
);
|
5164
5272
|
}
|
5165
|
-
};
|
5166
|
-
var processGraphqlStatus = (gqlTransactionStatus) => {
|
5273
|
+
}, "getTransactionStatusName");
|
5274
|
+
var processGraphqlStatus = /* @__PURE__ */ __name((gqlTransactionStatus) => {
|
5167
5275
|
let time;
|
5168
5276
|
let blockId;
|
5169
5277
|
let status;
|
@@ -5207,8 +5315,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
5207
5315
|
isStatusPending
|
5208
5316
|
};
|
5209
5317
|
return processedGraphqlStatus;
|
5210
|
-
};
|
5211
|
-
var getTotalFeeFromStatus = (status) => status && "totalFee" in status ? (0, import_math15.bn)(status.totalFee) : void 0;
|
5318
|
+
}, "processGraphqlStatus");
|
5319
|
+
var getTotalFeeFromStatus = /* @__PURE__ */ __name((status) => status && "totalFee" in status ? (0, import_math15.bn)(status.totalFee) : void 0, "getTotalFeeFromStatus");
|
5212
5320
|
|
5213
5321
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
5214
5322
|
function assembleTransactionSummary(params) {
|
@@ -5288,21 +5396,35 @@ function assembleTransactionSummary(params) {
|
|
5288
5396
|
};
|
5289
5397
|
return transactionSummary;
|
5290
5398
|
}
|
5399
|
+
__name(assembleTransactionSummary, "assembleTransactionSummary");
|
5291
5400
|
|
5292
5401
|
// src/providers/transaction-response/getDecodedLogs.ts
|
5293
5402
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
5403
|
+
var import_configs12 = require("@fuel-ts/address/configs");
|
5294
5404
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5295
5405
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
5406
|
+
let mainContract = "";
|
5407
|
+
if (mainAbi.programType === "contract") {
|
5408
|
+
const firstCallReceipt = receipts.find(
|
5409
|
+
(r) => r.type === import_transactions21.ReceiptType.Call && r.id === import_configs12.ZeroBytes32
|
5410
|
+
);
|
5411
|
+
mainContract = firstCallReceipt.to;
|
5412
|
+
}
|
5296
5413
|
return receipts.reduce((logs, receipt) => {
|
5297
5414
|
if (receipt.type === import_transactions21.ReceiptType.LogData || receipt.type === import_transactions21.ReceiptType.Log) {
|
5298
|
-
const
|
5299
|
-
const
|
5300
|
-
|
5301
|
-
|
5415
|
+
const isLogFromMainAbi = receipt.id === import_configs12.ZeroBytes32 || mainContract === receipt.id;
|
5416
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
5417
|
+
if (isDecodable) {
|
5418
|
+
const interfaceToUse = isLogFromMainAbi ? new import_abi_coder4.Interface(mainAbi) : new import_abi_coder4.Interface(externalAbis[receipt.id]);
|
5419
|
+
const data = receipt.type === import_transactions21.ReceiptType.Log ? new import_abi_coder4.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
5420
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
5421
|
+
logs.push(decodedLog);
|
5422
|
+
}
|
5302
5423
|
}
|
5303
5424
|
return logs;
|
5304
5425
|
}, []);
|
5305
5426
|
}
|
5427
|
+
__name(getDecodedLogs, "getDecodedLogs");
|
5306
5428
|
|
5307
5429
|
// src/providers/transaction-response/transaction-response.ts
|
5308
5430
|
function mapGqlOutputsToTxOutputs(outputs) {
|
@@ -5335,7 +5457,8 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
5335
5457
|
}
|
5336
5458
|
});
|
5337
5459
|
}
|
5338
|
-
|
5460
|
+
__name(mapGqlOutputsToTxOutputs, "mapGqlOutputsToTxOutputs");
|
5461
|
+
var TransactionResponse = class _TransactionResponse {
|
5339
5462
|
/**
|
5340
5463
|
* Constructor for `TransactionResponse`.
|
5341
5464
|
*
|
@@ -5350,6 +5473,9 @@ var TransactionResponse = class {
|
|
5350
5473
|
this.request = typeof tx === "string" ? void 0 : tx;
|
5351
5474
|
this.waitForResult = this.waitForResult.bind(this);
|
5352
5475
|
}
|
5476
|
+
static {
|
5477
|
+
__name(this, "TransactionResponse");
|
5478
|
+
}
|
5353
5479
|
/** Transaction ID */
|
5354
5480
|
id;
|
5355
5481
|
/** Current provider */
|
@@ -5371,7 +5497,7 @@ var TransactionResponse = class {
|
|
5371
5497
|
*/
|
5372
5498
|
static async create(id, provider, abis) {
|
5373
5499
|
const chainId = await provider.getChainId();
|
5374
|
-
const response = new
|
5500
|
+
const response = new _TransactionResponse(id, provider, chainId, abis);
|
5375
5501
|
await response.fetch();
|
5376
5502
|
return response;
|
5377
5503
|
}
|
@@ -5503,8 +5629,8 @@ var TransactionResponse = class {
|
|
5503
5629
|
this.status = statusChange;
|
5504
5630
|
if (statusChange.type === "SqueezedOutStatus") {
|
5505
5631
|
this.unsetResourceCache();
|
5506
|
-
throw new
|
5507
|
-
|
5632
|
+
throw new import_errors18.FuelError(
|
5633
|
+
import_errors18.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
5508
5634
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
5509
5635
|
);
|
5510
5636
|
}
|
@@ -5588,6 +5714,7 @@ function getWaitDelay(options, retryAttemptNum) {
|
|
5588
5714
|
return 2 ** (retryAttemptNum - 1) * duration;
|
5589
5715
|
}
|
5590
5716
|
}
|
5717
|
+
__name(getWaitDelay, "getWaitDelay");
|
5591
5718
|
function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
5592
5719
|
if (options === void 0) {
|
5593
5720
|
return fetchFn;
|
@@ -5610,9 +5737,10 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
5610
5737
|
}
|
5611
5738
|
};
|
5612
5739
|
}
|
5740
|
+
__name(autoRetryFetch, "autoRetryFetch");
|
5613
5741
|
|
5614
5742
|
// src/providers/utils/helpers.ts
|
5615
|
-
var adjustResourcesToExclude = (params) => {
|
5743
|
+
var adjustResourcesToExclude = /* @__PURE__ */ __name((params) => {
|
5616
5744
|
const { userInput, cached, maxInputs } = params;
|
5617
5745
|
const final = { ...userInput };
|
5618
5746
|
let total = final.utxos.length + final.messages.length;
|
@@ -5625,34 +5753,34 @@ var adjustResourcesToExclude = (params) => {
|
|
5625
5753
|
final.messages = [...final.messages, ...cached.messages.slice(0, maxInputs - total)];
|
5626
5754
|
}
|
5627
5755
|
return final;
|
5628
|
-
};
|
5756
|
+
}, "adjustResourcesToExclude");
|
5629
5757
|
|
5630
5758
|
// src/providers/utils/validate-pagination-args.ts
|
5631
|
-
var
|
5632
|
-
var validatePaginationArgs = (params) => {
|
5759
|
+
var import_errors19 = require("@fuel-ts/errors");
|
5760
|
+
var validatePaginationArgs = /* @__PURE__ */ __name((params) => {
|
5633
5761
|
const { paginationLimit, inputArgs = {} } = params;
|
5634
5762
|
const { first, last, after, before } = inputArgs;
|
5635
5763
|
if (after && before) {
|
5636
|
-
throw new
|
5637
|
-
|
5764
|
+
throw new import_errors19.FuelError(
|
5765
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5638
5766
|
'Pagination arguments "after" and "before" cannot be used together'
|
5639
5767
|
);
|
5640
5768
|
}
|
5641
5769
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5642
|
-
throw new
|
5643
|
-
|
5770
|
+
throw new import_errors19.FuelError(
|
5771
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5644
5772
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5645
5773
|
);
|
5646
5774
|
}
|
5647
5775
|
if (first && before) {
|
5648
|
-
throw new
|
5649
|
-
|
5776
|
+
throw new import_errors19.FuelError(
|
5777
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5650
5778
|
'The use of pagination argument "first" with "before" is not supported'
|
5651
5779
|
);
|
5652
5780
|
}
|
5653
5781
|
if (last && after) {
|
5654
|
-
throw new
|
5655
|
-
|
5782
|
+
throw new import_errors19.FuelError(
|
5783
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5656
5784
|
'The use of pagination argument "last" with "after" is not supported'
|
5657
5785
|
);
|
5658
5786
|
}
|
@@ -5660,18 +5788,71 @@ var validatePaginationArgs = (params) => {
|
|
5660
5788
|
inputArgs.first = paginationLimit;
|
5661
5789
|
}
|
5662
5790
|
return inputArgs;
|
5663
|
-
};
|
5791
|
+
}, "validatePaginationArgs");
|
5664
5792
|
|
5665
5793
|
// src/providers/provider.ts
|
5666
5794
|
var MAX_RETRIES = 10;
|
5667
5795
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
5668
5796
|
var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
|
5669
5797
|
var BALANCES_PAGE_SIZE_LIMIT = 100;
|
5798
|
+
var NON_PAGINATED_BALANCES_SIZE = 1e4;
|
5670
5799
|
var BLOCKS_PAGE_SIZE_LIMIT = 5;
|
5671
5800
|
var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
|
5672
5801
|
var GAS_USED_MODIFIER = 1.2;
|
5673
|
-
var
|
5674
|
-
|
5802
|
+
var Provider = class _Provider {
|
5803
|
+
static {
|
5804
|
+
__name(this, "Provider");
|
5805
|
+
}
|
5806
|
+
operations;
|
5807
|
+
cache;
|
5808
|
+
/** @hidden */
|
5809
|
+
static clearChainAndNodeCaches() {
|
5810
|
+
_Provider.inflightFetchChainAndNodeInfoRequests = {};
|
5811
|
+
_Provider.nodeInfoCache = {};
|
5812
|
+
_Provider.chainInfoCache = {};
|
5813
|
+
}
|
5814
|
+
/** @hidden */
|
5815
|
+
url;
|
5816
|
+
/** @hidden */
|
5817
|
+
urlWithoutAuth;
|
5818
|
+
/** @hidden */
|
5819
|
+
static inflightFetchChainAndNodeInfoRequests = {};
|
5820
|
+
/** @hidden */
|
5821
|
+
static chainInfoCache = {};
|
5822
|
+
/** @hidden */
|
5823
|
+
static nodeInfoCache = {};
|
5824
|
+
/** @hidden */
|
5825
|
+
static incompatibleNodeVersionMessage = "";
|
5826
|
+
/** @hidden */
|
5827
|
+
consensusParametersTimestamp;
|
5828
|
+
options = {
|
5829
|
+
timeout: void 0,
|
5830
|
+
resourceCacheTTL: void 0,
|
5831
|
+
fetch: void 0,
|
5832
|
+
retryOptions: void 0,
|
5833
|
+
headers: void 0,
|
5834
|
+
cache: void 0
|
5835
|
+
};
|
5836
|
+
/**
|
5837
|
+
* @hidden
|
5838
|
+
*/
|
5839
|
+
static getFetchFn(options) {
|
5840
|
+
const { retryOptions, timeout, headers } = options;
|
5841
|
+
return autoRetryFetch(async (...args) => {
|
5842
|
+
const url = args[0];
|
5843
|
+
const request2 = args[1];
|
5844
|
+
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
5845
|
+
let fullRequest = {
|
5846
|
+
...request2,
|
5847
|
+
signal,
|
5848
|
+
headers: { ...request2?.headers, ...headers }
|
5849
|
+
};
|
5850
|
+
if (options.requestMiddleware) {
|
5851
|
+
fullRequest = await options.requestMiddleware(fullRequest);
|
5852
|
+
}
|
5853
|
+
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
5854
|
+
}, retryOptions);
|
5855
|
+
}
|
5675
5856
|
/**
|
5676
5857
|
* Constructor to initialize a Provider.
|
5677
5858
|
*
|
@@ -5680,31 +5861,6 @@ var _Provider = class {
|
|
5680
5861
|
* @hidden
|
5681
5862
|
*/
|
5682
5863
|
constructor(url, options = {}) {
|
5683
|
-
/**
|
5684
|
-
* @hidden
|
5685
|
-
*/
|
5686
|
-
__privateAdd(this, _cacheInputs);
|
5687
|
-
__publicField(this, "operations");
|
5688
|
-
__publicField(this, "cache");
|
5689
|
-
/** @hidden */
|
5690
|
-
__publicField(this, "url");
|
5691
|
-
/** @hidden */
|
5692
|
-
__publicField(this, "urlWithoutAuth");
|
5693
|
-
/** @hidden */
|
5694
|
-
__publicField(this, "features", {
|
5695
|
-
balancePagination: false,
|
5696
|
-
amount128: false
|
5697
|
-
});
|
5698
|
-
/** @hidden */
|
5699
|
-
__publicField(this, "consensusParametersTimestamp");
|
5700
|
-
__publicField(this, "options", {
|
5701
|
-
timeout: void 0,
|
5702
|
-
resourceCacheTTL: void 0,
|
5703
|
-
fetch: void 0,
|
5704
|
-
retryOptions: void 0,
|
5705
|
-
headers: void 0,
|
5706
|
-
cache: void 0
|
5707
|
-
});
|
5708
5864
|
const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
|
5709
5865
|
this.url = rawUrl;
|
5710
5866
|
this.urlWithoutAuth = urlWithoutAuth;
|
@@ -5734,37 +5890,12 @@ var _Provider = class {
|
|
5734
5890
|
this.cache = new ResourceCache(DEFAULT_RESOURCE_CACHE_TTL);
|
5735
5891
|
}
|
5736
5892
|
}
|
5737
|
-
/** @hidden */
|
5738
|
-
static clearChainAndNodeCaches() {
|
5739
|
-
_Provider.nodeInfoCache = {};
|
5740
|
-
_Provider.chainInfoCache = {};
|
5741
|
-
}
|
5742
|
-
/**
|
5743
|
-
* @hidden
|
5744
|
-
*/
|
5745
|
-
static getFetchFn(options) {
|
5746
|
-
const { retryOptions, timeout, headers } = options;
|
5747
|
-
return autoRetryFetch(async (...args) => {
|
5748
|
-
const url = args[0];
|
5749
|
-
const request2 = args[1];
|
5750
|
-
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
5751
|
-
let fullRequest = {
|
5752
|
-
...request2,
|
5753
|
-
signal,
|
5754
|
-
headers: { ...request2?.headers, ...headers }
|
5755
|
-
};
|
5756
|
-
if (options.requestMiddleware) {
|
5757
|
-
fullRequest = await options.requestMiddleware(fullRequest);
|
5758
|
-
}
|
5759
|
-
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
5760
|
-
}, retryOptions);
|
5761
|
-
}
|
5762
5893
|
static extractBasicAuth(url) {
|
5763
5894
|
let parsedUrl;
|
5764
5895
|
try {
|
5765
5896
|
parsedUrl = new URL(url);
|
5766
5897
|
} catch (error) {
|
5767
|
-
throw new
|
5898
|
+
throw new import_errors20.FuelError(import_errors20.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
5768
5899
|
}
|
5769
5900
|
const username = parsedUrl.username;
|
5770
5901
|
const password = parsedUrl.password;
|
@@ -5782,8 +5913,7 @@ var _Provider = class {
|
|
5782
5913
|
* Initialize Provider async stuff
|
5783
5914
|
*/
|
5784
5915
|
async init() {
|
5785
|
-
|
5786
|
-
this.setupFeatures(nodeInfo.nodeVersion);
|
5916
|
+
await this.fetchChainAndNodeInfo();
|
5787
5917
|
return this;
|
5788
5918
|
}
|
5789
5919
|
/**
|
@@ -5853,13 +5983,24 @@ var _Provider = class {
|
|
5853
5983
|
throw new Error(`Jumps to the catch block and re-fetch`);
|
5854
5984
|
}
|
5855
5985
|
} catch (_err) {
|
5986
|
+
const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5987
|
+
if (inflightRequest) {
|
5988
|
+
const now2 = await inflightRequest;
|
5989
|
+
this.consensusParametersTimestamp = now2;
|
5990
|
+
return this.fetchChainAndNodeInfo();
|
5991
|
+
}
|
5992
|
+
const { promise, resolve } = deferPromise();
|
5993
|
+
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
|
5856
5994
|
const data = await this.operations.getChainAndNodeInfo();
|
5857
5995
|
nodeInfo = deserializeNodeInfo(data.nodeInfo);
|
5858
|
-
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
5859
5996
|
chain = deserializeChain(data.chain);
|
5997
|
+
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
5860
5998
|
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
5861
5999
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
5862
|
-
|
6000
|
+
const now = Date.now();
|
6001
|
+
this.consensusParametersTimestamp = now;
|
6002
|
+
resolve(now);
|
6003
|
+
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5863
6004
|
}
|
5864
6005
|
return {
|
5865
6006
|
chain,
|
@@ -5889,8 +6030,8 @@ var _Provider = class {
|
|
5889
6030
|
createOperations() {
|
5890
6031
|
const fetchFn = _Provider.getFetchFn(this.options);
|
5891
6032
|
const gqlClient = new import_graphql_request.GraphQLClient(this.urlWithoutAuth, {
|
5892
|
-
fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
|
5893
|
-
responseMiddleware: (response) => {
|
6033
|
+
fetch: /* @__PURE__ */ __name((input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options), "fetch"),
|
6034
|
+
responseMiddleware: /* @__PURE__ */ __name((response) => {
|
5894
6035
|
if ("response" in response) {
|
5895
6036
|
const graphQlResponse = response.response;
|
5896
6037
|
assertGqlResponseHasNoErrors(
|
@@ -5898,22 +6039,22 @@ var _Provider = class {
|
|
5898
6039
|
_Provider.incompatibleNodeVersionMessage
|
5899
6040
|
);
|
5900
6041
|
}
|
5901
|
-
}
|
6042
|
+
}, "responseMiddleware")
|
5902
6043
|
});
|
5903
|
-
const executeQuery = (query, vars) => {
|
6044
|
+
const executeQuery = /* @__PURE__ */ __name((query, vars) => {
|
5904
6045
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
5905
6046
|
const isSubscription = opDefinition?.operation === "subscription";
|
5906
6047
|
if (isSubscription) {
|
5907
6048
|
return FuelGraphqlSubscriber.create({
|
5908
6049
|
url: this.urlWithoutAuth,
|
5909
6050
|
query,
|
5910
|
-
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
6051
|
+
fetchFn: /* @__PURE__ */ __name((url, requestInit) => fetchFn(url, requestInit, this.options), "fetchFn"),
|
5911
6052
|
variables: vars
|
5912
6053
|
});
|
5913
6054
|
}
|
5914
6055
|
return gqlClient.request(query, vars);
|
5915
|
-
};
|
5916
|
-
const customOperations = (requester) => ({
|
6056
|
+
}, "executeQuery");
|
6057
|
+
const customOperations = /* @__PURE__ */ __name((requester) => ({
|
5917
6058
|
getBlobs(variables) {
|
5918
6059
|
const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
|
5919
6060
|
const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
|
@@ -5931,18 +6072,9 @@ var _Provider = class {
|
|
5931
6072
|
`;
|
5932
6073
|
return requester(document2, updatedVariables);
|
5933
6074
|
}
|
5934
|
-
});
|
6075
|
+
}), "customOperations");
|
5935
6076
|
return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
|
5936
6077
|
}
|
5937
|
-
/**
|
5938
|
-
* @hidden
|
5939
|
-
*/
|
5940
|
-
setupFeatures(nodeVersion) {
|
5941
|
-
if ((0, import_versions.gte)(nodeVersion, "0.41.0")) {
|
5942
|
-
this.features.balancePagination = true;
|
5943
|
-
this.features.amount128 = true;
|
5944
|
-
}
|
5945
|
-
}
|
5946
6078
|
/**
|
5947
6079
|
* Returns the version of the connected node.
|
5948
6080
|
*
|
@@ -6019,6 +6151,13 @@ var _Provider = class {
|
|
6019
6151
|
* @returns A promise that resolves to an object containing the asset details.
|
6020
6152
|
*/
|
6021
6153
|
async getAssetDetails(assetId) {
|
6154
|
+
const { assetMetadata } = await this.getNodeFeatures();
|
6155
|
+
if (!assetMetadata) {
|
6156
|
+
throw new import_errors20.FuelError(
|
6157
|
+
import_errors20.ErrorCode.UNSUPPORTED_FEATURE,
|
6158
|
+
"The current node does not supports fetching asset details"
|
6159
|
+
);
|
6160
|
+
}
|
6022
6161
|
const { assetDetails } = await this.operations.getAssetDetails({ assetId });
|
6023
6162
|
const { contractId, subId, totalSupply } = assetDetails;
|
6024
6163
|
return {
|
@@ -6027,6 +6166,15 @@ var _Provider = class {
|
|
6027
6166
|
totalSupply: (0, import_math18.bn)(totalSupply)
|
6028
6167
|
};
|
6029
6168
|
}
|
6169
|
+
/**
|
6170
|
+
* @hidden
|
6171
|
+
*/
|
6172
|
+
#cacheInputs(inputs, transactionId) {
|
6173
|
+
if (!this.cache) {
|
6174
|
+
return;
|
6175
|
+
}
|
6176
|
+
this.cache.set(transactionId, inputs);
|
6177
|
+
}
|
6030
6178
|
/**
|
6031
6179
|
* @hidden
|
6032
6180
|
*/
|
@@ -6037,14 +6185,14 @@ var _Provider = class {
|
|
6037
6185
|
}
|
6038
6186
|
} = await this.getChain();
|
6039
6187
|
if ((0, import_math18.bn)(tx.inputs.length).gt(maxInputs)) {
|
6040
|
-
throw new
|
6041
|
-
|
6188
|
+
throw new import_errors20.FuelError(
|
6189
|
+
import_errors20.ErrorCode.MAX_INPUTS_EXCEEDED,
|
6042
6190
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
6043
6191
|
);
|
6044
6192
|
}
|
6045
6193
|
if ((0, import_math18.bn)(tx.outputs.length).gt(maxOutputs)) {
|
6046
|
-
throw new
|
6047
|
-
|
6194
|
+
throw new import_errors20.FuelError(
|
6195
|
+
import_errors20.ErrorCode.MAX_OUTPUTS_EXCEEDED,
|
6048
6196
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
6049
6197
|
);
|
6050
6198
|
}
|
@@ -6076,7 +6224,10 @@ var _Provider = class {
|
|
6076
6224
|
abis = transactionRequest.abis;
|
6077
6225
|
}
|
6078
6226
|
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
6079
|
-
|
6227
|
+
this.#cacheInputs(
|
6228
|
+
transactionRequest.inputs,
|
6229
|
+
transactionRequest.getTransactionId(await this.getChainId())
|
6230
|
+
);
|
6080
6231
|
const chainId = await this.getChainId();
|
6081
6232
|
return new TransactionResponse(transactionRequest, this, chainId, abis, subscription);
|
6082
6233
|
}
|
@@ -6743,7 +6894,7 @@ var _Provider = class {
|
|
6743
6894
|
0
|
6744
6895
|
)?.[0];
|
6745
6896
|
} catch (error) {
|
6746
|
-
if (error instanceof
|
6897
|
+
if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
6747
6898
|
console.warn("Unsupported transaction type encountered");
|
6748
6899
|
return null;
|
6749
6900
|
}
|
@@ -6769,7 +6920,7 @@ var _Provider = class {
|
|
6769
6920
|
try {
|
6770
6921
|
return coder.decode((0, import_utils29.arrayify)(rawPayload), 0)[0];
|
6771
6922
|
} catch (error) {
|
6772
|
-
if (error instanceof
|
6923
|
+
if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
6773
6924
|
console.warn("Unsupported transaction type encountered");
|
6774
6925
|
return null;
|
6775
6926
|
}
|
@@ -6828,18 +6979,9 @@ var _Provider = class {
|
|
6828
6979
|
* @returns A promise that resolves to the balance.
|
6829
6980
|
*/
|
6830
6981
|
async getBalance(owner, assetId) {
|
6831
|
-
const ownerStr = new import_address3.Address(owner).toB256();
|
6832
|
-
const assetIdStr = (0, import_utils29.hexlify)(assetId);
|
6833
|
-
if (!this.features.amount128) {
|
6834
|
-
const { balance: balance2 } = await this.operations.getBalance({
|
6835
|
-
owner: ownerStr,
|
6836
|
-
assetId: assetIdStr
|
6837
|
-
});
|
6838
|
-
return (0, import_math18.bn)(balance2.amount, 10);
|
6839
|
-
}
|
6840
6982
|
const { balance } = await this.operations.getBalanceV2({
|
6841
|
-
owner:
|
6842
|
-
assetId:
|
6983
|
+
owner: new import_address3.Address(owner).toB256(),
|
6984
|
+
assetId: (0, import_utils29.hexlify)(assetId)
|
6843
6985
|
});
|
6844
6986
|
return (0, import_math18.bn)(balance.amountU128, 10);
|
6845
6987
|
}
|
@@ -6851,49 +6993,29 @@ var _Provider = class {
|
|
6851
6993
|
* @returns A promise that resolves to the balances.
|
6852
6994
|
*/
|
6853
6995
|
async getBalances(owner, paginationArgs) {
|
6854
|
-
|
6855
|
-
|
6996
|
+
let args = { first: NON_PAGINATED_BALANCES_SIZE };
|
6997
|
+
const { balancesPagination: supportsPagination } = await this.getNodeFeatures();
|
6998
|
+
if (supportsPagination) {
|
6999
|
+
args = validatePaginationArgs({
|
7000
|
+
inputArgs: paginationArgs,
|
7001
|
+
paginationLimit: BALANCES_PAGE_SIZE_LIMIT
|
7002
|
+
});
|
6856
7003
|
}
|
6857
|
-
return this.getBalancesV2(owner, paginationArgs);
|
6858
|
-
}
|
6859
|
-
/**
|
6860
|
-
* @hidden
|
6861
|
-
*/
|
6862
|
-
async getBalancesV1(owner, _paginationArgs) {
|
6863
|
-
const {
|
6864
|
-
balances: { edges }
|
6865
|
-
} = await this.operations.getBalances({
|
6866
|
-
/**
|
6867
|
-
* The query parameters for this method were designed to support pagination,
|
6868
|
-
* but the current Fuel-Core implementation does not support pagination yet.
|
6869
|
-
*/
|
6870
|
-
first: 1e4,
|
6871
|
-
filter: { owner: new import_address3.Address(owner).toB256() }
|
6872
|
-
});
|
6873
|
-
const balances = edges.map(({ node }) => ({
|
6874
|
-
assetId: node.assetId,
|
6875
|
-
amount: (0, import_math18.bn)(node.amount)
|
6876
|
-
}));
|
6877
|
-
return { balances };
|
6878
|
-
}
|
6879
|
-
/**
|
6880
|
-
* @hidden
|
6881
|
-
*/
|
6882
|
-
async getBalancesV2(owner, paginationArgs) {
|
6883
7004
|
const {
|
6884
7005
|
balances: { edges, pageInfo }
|
6885
7006
|
} = await this.operations.getBalancesV2({
|
6886
|
-
...
|
6887
|
-
|
6888
|
-
|
6889
|
-
}),
|
6890
|
-
filter: { owner: new import_address3.Address(owner).toB256() }
|
7007
|
+
...args,
|
7008
|
+
filter: { owner: new import_address3.Address(owner).toB256() },
|
7009
|
+
supportsPagination
|
6891
7010
|
});
|
6892
7011
|
const balances = edges.map(({ node }) => ({
|
6893
7012
|
assetId: node.assetId,
|
6894
7013
|
amount: (0, import_math18.bn)(node.amountU128)
|
6895
7014
|
}));
|
6896
|
-
return {
|
7015
|
+
return {
|
7016
|
+
balances,
|
7017
|
+
...supportsPagination ? { pageInfo } : {}
|
7018
|
+
};
|
6897
7019
|
}
|
6898
7020
|
/**
|
6899
7021
|
* Returns message for the given address.
|
@@ -6947,8 +7069,8 @@ var _Provider = class {
|
|
6947
7069
|
nonce
|
6948
7070
|
};
|
6949
7071
|
if (commitBlockId && commitBlockHeight) {
|
6950
|
-
throw new
|
6951
|
-
|
7072
|
+
throw new import_errors20.FuelError(
|
7073
|
+
import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
|
6952
7074
|
"commitBlockId and commitBlockHeight cannot be used together"
|
6953
7075
|
);
|
6954
7076
|
}
|
@@ -7180,6 +7302,17 @@ var _Provider = class {
|
|
7180
7302
|
statusReason: status.reason
|
7181
7303
|
});
|
7182
7304
|
}
|
7305
|
+
/**
|
7306
|
+
* @hidden
|
7307
|
+
*/
|
7308
|
+
async getNodeFeatures() {
|
7309
|
+
const { indexation } = await this.getNode();
|
7310
|
+
return {
|
7311
|
+
assetMetadata: Boolean(indexation?.assetMetadata),
|
7312
|
+
balancesPagination: Boolean(indexation?.balances),
|
7313
|
+
coinsToSpend: Boolean(indexation?.coinsToSpend)
|
7314
|
+
};
|
7315
|
+
}
|
7183
7316
|
/**
|
7184
7317
|
* @hidden
|
7185
7318
|
*/
|
@@ -7194,23 +7327,9 @@ var _Provider = class {
|
|
7194
7327
|
return transactionRequest;
|
7195
7328
|
}
|
7196
7329
|
};
|
7197
|
-
var Provider = _Provider;
|
7198
|
-
_cacheInputs = new WeakSet();
|
7199
|
-
cacheInputs_fn = function(inputs, transactionId) {
|
7200
|
-
if (!this.cache) {
|
7201
|
-
return;
|
7202
|
-
}
|
7203
|
-
this.cache.set(transactionId, inputs);
|
7204
|
-
};
|
7205
|
-
/** @hidden */
|
7206
|
-
__publicField(Provider, "chainInfoCache", {});
|
7207
|
-
/** @hidden */
|
7208
|
-
__publicField(Provider, "nodeInfoCache", {});
|
7209
|
-
/** @hidden */
|
7210
|
-
__publicField(Provider, "incompatibleNodeVersionMessage", "");
|
7211
7330
|
|
7212
7331
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
7213
|
-
var
|
7332
|
+
var import_errors21 = require("@fuel-ts/errors");
|
7214
7333
|
var import_math19 = require("@fuel-ts/math");
|
7215
7334
|
var import_transactions24 = require("@fuel-ts/transactions");
|
7216
7335
|
var import_utils31 = require("@fuel-ts/utils");
|
@@ -7220,8 +7339,8 @@ async function getTransactionSummary(params) {
|
|
7220
7339
|
transactionId: id
|
7221
7340
|
});
|
7222
7341
|
if (!gqlTransaction) {
|
7223
|
-
throw new
|
7224
|
-
|
7342
|
+
throw new import_errors21.FuelError(
|
7343
|
+
import_errors21.ErrorCode.TRANSACTION_NOT_FOUND,
|
7225
7344
|
`Transaction not found for given id: ${id}.`
|
7226
7345
|
);
|
7227
7346
|
}
|
@@ -7263,6 +7382,7 @@ async function getTransactionSummary(params) {
|
|
7263
7382
|
...transactionInfo
|
7264
7383
|
};
|
7265
7384
|
}
|
7385
|
+
__name(getTransactionSummary, "getTransactionSummary");
|
7266
7386
|
async function getTransactionSummaryFromRequest(params) {
|
7267
7387
|
const { provider, transactionRequest, abiMap } = params;
|
7268
7388
|
const { receipts } = await provider.dryRun(transactionRequest);
|
@@ -7288,6 +7408,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
7288
7408
|
});
|
7289
7409
|
return transactionSummary;
|
7290
7410
|
}
|
7411
|
+
__name(getTransactionSummaryFromRequest, "getTransactionSummaryFromRequest");
|
7291
7412
|
async function getTransactionsSummaries(params) {
|
7292
7413
|
const { filters, provider, abiMap } = params;
|
7293
7414
|
const { owner, ...inputArgs } = filters;
|
@@ -7343,12 +7464,13 @@ async function getTransactionsSummaries(params) {
|
|
7343
7464
|
pageInfo
|
7344
7465
|
};
|
7345
7466
|
}
|
7467
|
+
__name(getTransactionsSummaries, "getTransactionsSummaries");
|
7346
7468
|
|
7347
7469
|
// src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
|
7348
7470
|
var import_math20 = require("@fuel-ts/math");
|
7349
7471
|
var import_transactions25 = require("@fuel-ts/transactions");
|
7350
7472
|
var import_utils32 = require("@fuel-ts/utils");
|
7351
|
-
var assembleTransactionSummaryFromJson = async (opts) => {
|
7473
|
+
var assembleTransactionSummaryFromJson = /* @__PURE__ */ __name(async (opts) => {
|
7352
7474
|
const { provider, transactionSummary } = opts;
|
7353
7475
|
const { id, transactionBytes, gasPrice, receipts } = transactionSummary;
|
7354
7476
|
const {
|
@@ -7375,10 +7497,10 @@ var assembleTransactionSummaryFromJson = async (opts) => {
|
|
7375
7497
|
gasPerByte,
|
7376
7498
|
gasPriceFactor
|
7377
7499
|
});
|
7378
|
-
};
|
7500
|
+
}, "assembleTransactionSummaryFromJson");
|
7379
7501
|
|
7380
7502
|
// src/providers/utils/merge-quantities.ts
|
7381
|
-
var mergeQuantities = (...coinQuantities) => {
|
7503
|
+
var mergeQuantities = /* @__PURE__ */ __name((...coinQuantities) => {
|
7382
7504
|
const resultMap = {};
|
7383
7505
|
function addToMap({ amount, assetId }) {
|
7384
7506
|
if (resultMap[assetId]) {
|
@@ -7387,12 +7509,16 @@ var mergeQuantities = (...coinQuantities) => {
|
|
7387
7509
|
resultMap[assetId] = amount;
|
7388
7510
|
}
|
7389
7511
|
}
|
7512
|
+
__name(addToMap, "addToMap");
|
7390
7513
|
coinQuantities.forEach((arr) => arr.forEach(addToMap));
|
7391
7514
|
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
7392
|
-
};
|
7515
|
+
}, "mergeQuantities");
|
7393
7516
|
|
7394
7517
|
// src/types.ts
|
7395
7518
|
var AbstractAccount = class {
|
7519
|
+
static {
|
7520
|
+
__name(this, "AbstractAccount");
|
7521
|
+
}
|
7396
7522
|
};
|
7397
7523
|
|
7398
7524
|
// src/utils/formatTransferToContractScriptData.ts
|
@@ -7400,7 +7526,7 @@ var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
|
7400
7526
|
var import_address4 = require("@fuel-ts/address");
|
7401
7527
|
var import_utils33 = require("@fuel-ts/utils");
|
7402
7528
|
var asm = __toESM(require("@fuels/vm-asm"));
|
7403
|
-
var formatTransferToContractScriptData = (transferParams) => {
|
7529
|
+
var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
|
7404
7530
|
const numberCoder = new import_abi_coder5.BigNumberCoder("u64");
|
7405
7531
|
return transferParams.reduce((acc, transferParam) => {
|
7406
7532
|
const { assetId, amount, contractId } = transferParam;
|
@@ -7408,8 +7534,8 @@ var formatTransferToContractScriptData = (transferParams) => {
|
|
7408
7534
|
const scriptData = (0, import_utils33.concat)([new import_address4.Address(contractId).toBytes(), encoded, (0, import_utils33.arrayify)(assetId)]);
|
7409
7535
|
return (0, import_utils33.concat)([acc, scriptData]);
|
7410
7536
|
}, new Uint8Array());
|
7411
|
-
};
|
7412
|
-
var assembleTransferToContractScript = async (transferParams) => {
|
7537
|
+
}, "formatTransferToContractScriptData");
|
7538
|
+
var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferParams) => {
|
7413
7539
|
const scriptData = formatTransferToContractScriptData(transferParams);
|
7414
7540
|
await asm.initWasm();
|
7415
7541
|
let script = new Uint8Array();
|
@@ -7433,11 +7559,14 @@ var assembleTransferToContractScript = async (transferParams) => {
|
|
7433
7559
|
});
|
7434
7560
|
script = (0, import_utils33.concat)([script, asm.ret(1).to_bytes()]);
|
7435
7561
|
return { script, scriptData };
|
7436
|
-
};
|
7562
|
+
}, "assembleTransferToContractScript");
|
7437
7563
|
|
7438
7564
|
// src/account.ts
|
7439
7565
|
var MAX_FUNDING_ATTEMPTS = 5;
|
7440
7566
|
var Account = class extends AbstractAccount {
|
7567
|
+
static {
|
7568
|
+
__name(this, "Account");
|
7569
|
+
}
|
7441
7570
|
/**
|
7442
7571
|
* The address associated with the account.
|
7443
7572
|
*/
|
@@ -7472,7 +7601,7 @@ var Account = class extends AbstractAccount {
|
|
7472
7601
|
*/
|
7473
7602
|
get provider() {
|
7474
7603
|
if (!this._provider) {
|
7475
|
-
throw new
|
7604
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
7476
7605
|
}
|
7477
7606
|
return this._provider;
|
7478
7607
|
}
|
@@ -7631,8 +7760,8 @@ var Account = class extends AbstractAccount {
|
|
7631
7760
|
fundingAttempts += 1;
|
7632
7761
|
}
|
7633
7762
|
if (needsToBeFunded) {
|
7634
|
-
throw new
|
7635
|
-
|
7763
|
+
throw new import_errors22.FuelError(
|
7764
|
+
import_errors22.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
7636
7765
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
7637
7766
|
);
|
7638
7767
|
}
|
@@ -7751,8 +7880,8 @@ var Account = class extends AbstractAccount {
|
|
7751
7880
|
const contractAddress = new import_address5.Address(transferParam.contractId);
|
7752
7881
|
const assetId = transferParam.assetId ? (0, import_utils34.hexlify)(transferParam.assetId) : defaultAssetId;
|
7753
7882
|
if (amount.lte(0)) {
|
7754
|
-
throw new
|
7755
|
-
|
7883
|
+
throw new import_errors22.FuelError(
|
7884
|
+
import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
7756
7885
|
"Transfer amount must be a positive number."
|
7757
7886
|
);
|
7758
7887
|
}
|
@@ -7821,7 +7950,7 @@ var Account = class extends AbstractAccount {
|
|
7821
7950
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
7822
7951
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
7823
7952
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
|
7824
|
-
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
7953
|
+
const findAssetInput = /* @__PURE__ */ __name((assetId) => txRequestClone.inputs.find((input) => {
|
7825
7954
|
if (input.type === import_transactions26.InputType.Coin) {
|
7826
7955
|
return input.assetId === assetId;
|
7827
7956
|
}
|
@@ -7829,8 +7958,8 @@ var Account = class extends AbstractAccount {
|
|
7829
7958
|
return baseAssetId === assetId;
|
7830
7959
|
}
|
7831
7960
|
return false;
|
7832
|
-
});
|
7833
|
-
const updateAssetInput = (assetId, quantity) => {
|
7961
|
+
}), "findAssetInput");
|
7962
|
+
const updateAssetInput = /* @__PURE__ */ __name((assetId, quantity) => {
|
7834
7963
|
const assetInput = findAssetInput(assetId);
|
7835
7964
|
const usedQuantity = quantity;
|
7836
7965
|
if (assetInput && "amount" in assetInput) {
|
@@ -7845,7 +7974,7 @@ var Account = class extends AbstractAccount {
|
|
7845
7974
|
])
|
7846
7975
|
);
|
7847
7976
|
}
|
7848
|
-
};
|
7977
|
+
}, "updateAssetInput");
|
7849
7978
|
mergeQuantities(requiredQuantities, transactionFeeForDryRun).forEach(
|
7850
7979
|
({ amount, assetId }) => updateAssetInput(assetId, amount)
|
7851
7980
|
);
|
@@ -7868,7 +7997,7 @@ var Account = class extends AbstractAccount {
|
|
7868
7997
|
*/
|
7869
7998
|
async signMessage(message) {
|
7870
7999
|
if (!this._connector) {
|
7871
|
-
throw new
|
8000
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7872
8001
|
}
|
7873
8002
|
return this._connector.signMessage(this.address.toString(), message);
|
7874
8003
|
}
|
@@ -7880,8 +8009,8 @@ var Account = class extends AbstractAccount {
|
|
7880
8009
|
*/
|
7881
8010
|
async signTransaction(transactionRequestLike) {
|
7882
8011
|
if (!this._connector) {
|
7883
|
-
throw new
|
7884
|
-
|
8012
|
+
throw new import_errors22.FuelError(
|
8013
|
+
import_errors22.ErrorCode.MISSING_CONNECTOR,
|
7885
8014
|
"A connector is required to sign transactions."
|
7886
8015
|
);
|
7887
8016
|
}
|
@@ -7977,8 +8106,8 @@ var Account = class extends AbstractAccount {
|
|
7977
8106
|
/** @hidden * */
|
7978
8107
|
validateTransferAmount(amount) {
|
7979
8108
|
if ((0, import_math21.bn)(amount).lte(0)) {
|
7980
|
-
throw new
|
7981
|
-
|
8109
|
+
throw new import_errors22.FuelError(
|
8110
|
+
import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
7982
8111
|
"Transfer amount must be a positive number."
|
7983
8112
|
);
|
7984
8113
|
}
|
@@ -8007,16 +8136,16 @@ var Account = class extends AbstractAccount {
|
|
8007
8136
|
if (!(0, import_utils34.isDefined)(setGasLimit)) {
|
8008
8137
|
request2.gasLimit = gasUsed;
|
8009
8138
|
} else if (gasUsed.gt(setGasLimit)) {
|
8010
|
-
throw new
|
8011
|
-
|
8139
|
+
throw new import_errors22.FuelError(
|
8140
|
+
import_errors22.ErrorCode.GAS_LIMIT_TOO_LOW,
|
8012
8141
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
8013
8142
|
);
|
8014
8143
|
}
|
8015
8144
|
if (!(0, import_utils34.isDefined)(setMaxFee)) {
|
8016
8145
|
request2.maxFee = maxFee;
|
8017
8146
|
} else if (maxFee.gt(setMaxFee)) {
|
8018
|
-
throw new
|
8019
|
-
|
8147
|
+
throw new import_errors22.FuelError(
|
8148
|
+
import_errors22.ErrorCode.MAX_FEE_TOO_LOW,
|
8020
8149
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
8021
8150
|
);
|
8022
8151
|
}
|
@@ -8035,7 +8164,10 @@ var import_hasher3 = require("@fuel-ts/hasher");
|
|
8035
8164
|
var import_math22 = require("@fuel-ts/math");
|
8036
8165
|
var import_utils35 = require("@fuel-ts/utils");
|
8037
8166
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
8038
|
-
var Signer = class {
|
8167
|
+
var Signer = class _Signer {
|
8168
|
+
static {
|
8169
|
+
__name(this, "Signer");
|
8170
|
+
}
|
8039
8171
|
address;
|
8040
8172
|
publicKey;
|
8041
8173
|
compressedPublicKey;
|
@@ -8114,7 +8246,7 @@ var Signer = class {
|
|
8114
8246
|
* @returns Address from signature
|
8115
8247
|
*/
|
8116
8248
|
static recoverAddress(data, signature) {
|
8117
|
-
return new import_address6.Address(
|
8249
|
+
return new import_address6.Address(_Signer.recoverPublicKey(data, signature));
|
8118
8250
|
}
|
8119
8251
|
/**
|
8120
8252
|
* Generate a random privateKey
|
@@ -8140,19 +8272,19 @@ var Signer = class {
|
|
8140
8272
|
// src/wallet/keystore-wallet.ts
|
8141
8273
|
var import_address7 = require("@fuel-ts/address");
|
8142
8274
|
var import_crypto4 = require("@fuel-ts/crypto");
|
8143
|
-
var
|
8275
|
+
var import_errors23 = require("@fuel-ts/errors");
|
8144
8276
|
var import_utils36 = require("@fuel-ts/utils");
|
8145
8277
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
8146
8278
|
var DEFAULT_KDF_PARAMS_R = 8;
|
8147
8279
|
var DEFAULT_KDF_PARAMS_P = 1;
|
8148
8280
|
var DEFAULT_KEY_SIZE = 32;
|
8149
8281
|
var DEFAULT_IV_SIZE = 16;
|
8150
|
-
var removeHexPrefix = (hexString) => {
|
8282
|
+
var removeHexPrefix = /* @__PURE__ */ __name((hexString) => {
|
8151
8283
|
if (/^0x/.test(hexString)) {
|
8152
8284
|
return hexString.slice(2);
|
8153
8285
|
}
|
8154
8286
|
return hexString;
|
8155
|
-
};
|
8287
|
+
}, "removeHexPrefix");
|
8156
8288
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
8157
8289
|
const privateKeyBuffer = (0, import_crypto4.bufferFromString)(removeHexPrefix(privateKey), "hex");
|
8158
8290
|
const ownerAddress = new import_address7.Address(address);
|
@@ -8191,6 +8323,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
8191
8323
|
};
|
8192
8324
|
return JSON.stringify(keystore);
|
8193
8325
|
}
|
8326
|
+
__name(encryptKeystoreWallet, "encryptKeystoreWallet");
|
8194
8327
|
async function decryptKeystoreWallet(jsonWallet, password) {
|
8195
8328
|
const keystoreWallet = JSON.parse(jsonWallet);
|
8196
8329
|
const {
|
@@ -8217,8 +8350,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
8217
8350
|
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
8218
8351
|
const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
8219
8352
|
if (mac !== macHash) {
|
8220
|
-
throw new
|
8221
|
-
|
8353
|
+
throw new import_errors23.FuelError(
|
8354
|
+
import_errors23.ErrorCode.INVALID_PASSWORD,
|
8222
8355
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
8223
8356
|
);
|
8224
8357
|
}
|
@@ -8226,9 +8359,17 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
8226
8359
|
const privateKey = (0, import_utils36.hexlify)(buffer);
|
8227
8360
|
return privateKey;
|
8228
8361
|
}
|
8362
|
+
__name(decryptKeystoreWallet, "decryptKeystoreWallet");
|
8229
8363
|
|
8230
8364
|
// src/wallet/base-wallet-unlocked.ts
|
8231
8365
|
var BaseWalletUnlocked = class extends Account {
|
8366
|
+
static {
|
8367
|
+
__name(this, "BaseWalletUnlocked");
|
8368
|
+
}
|
8369
|
+
/**
|
8370
|
+
* Default HDWallet path.
|
8371
|
+
*/
|
8372
|
+
static defaultPath = "m/44'/1179993420'/0'/0/0";
|
8232
8373
|
/**
|
8233
8374
|
* A function that returns the wallet's signer.
|
8234
8375
|
*/
|
@@ -8346,21 +8487,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
8346
8487
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
8347
8488
|
}
|
8348
8489
|
};
|
8349
|
-
/**
|
8350
|
-
* Default HDWallet path.
|
8351
|
-
*/
|
8352
|
-
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
8353
8490
|
|
8354
8491
|
// src/hdwallet/hdwallet.ts
|
8355
8492
|
var import_crypto6 = require("@fuel-ts/crypto");
|
8356
|
-
var
|
8493
|
+
var import_errors26 = require("@fuel-ts/errors");
|
8357
8494
|
var import_hasher7 = require("@fuel-ts/hasher");
|
8358
8495
|
var import_math23 = require("@fuel-ts/math");
|
8359
8496
|
var import_utils41 = require("@fuel-ts/utils");
|
8360
8497
|
|
8361
8498
|
// src/mnemonic/mnemonic.ts
|
8362
8499
|
var import_crypto5 = require("@fuel-ts/crypto");
|
8363
|
-
var
|
8500
|
+
var import_errors25 = require("@fuel-ts/errors");
|
8364
8501
|
var import_hasher6 = require("@fuel-ts/hasher");
|
8365
8502
|
var import_utils39 = require("@fuel-ts/utils");
|
8366
8503
|
|
@@ -10423,27 +10560,31 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
10423
10560
|
})(Language || {});
|
10424
10561
|
|
10425
10562
|
// src/mnemonic/utils.ts
|
10426
|
-
var
|
10563
|
+
var import_errors24 = require("@fuel-ts/errors");
|
10427
10564
|
var import_hasher5 = require("@fuel-ts/hasher");
|
10428
10565
|
var import_utils38 = require("@fuel-ts/utils");
|
10429
10566
|
function getLowerMask(bits) {
|
10430
10567
|
return (1 << bits) - 1;
|
10431
10568
|
}
|
10569
|
+
__name(getLowerMask, "getLowerMask");
|
10432
10570
|
function getUpperMask(bits) {
|
10433
10571
|
return (1 << bits) - 1 << 8 - bits;
|
10434
10572
|
}
|
10573
|
+
__name(getUpperMask, "getUpperMask");
|
10435
10574
|
function getWords(mnemonic) {
|
10436
10575
|
if (!Array.isArray(mnemonic)) {
|
10437
10576
|
return mnemonic.split(/\s+/);
|
10438
10577
|
}
|
10439
10578
|
return mnemonic;
|
10440
10579
|
}
|
10580
|
+
__name(getWords, "getWords");
|
10441
10581
|
function getPhrase(mnemonic) {
|
10442
10582
|
if (Array.isArray(mnemonic)) {
|
10443
10583
|
return mnemonic.join(" ");
|
10444
10584
|
}
|
10445
10585
|
return mnemonic;
|
10446
10586
|
}
|
10587
|
+
__name(getPhrase, "getPhrase");
|
10447
10588
|
function entropyToMnemonicIndices(entropy) {
|
10448
10589
|
const indices = [0];
|
10449
10590
|
let remainingBits = 11;
|
@@ -10465,6 +10606,7 @@ function entropyToMnemonicIndices(entropy) {
|
|
10465
10606
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
10466
10607
|
return indices;
|
10467
10608
|
}
|
10609
|
+
__name(entropyToMnemonicIndices, "entropyToMnemonicIndices");
|
10468
10610
|
function mnemonicWordsToEntropy(words, wordlist) {
|
10469
10611
|
const size = Math.ceil(11 * words.length / 8);
|
10470
10612
|
const entropy = (0, import_utils38.arrayify)(new Uint8Array(size));
|
@@ -10472,8 +10614,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
10472
10614
|
for (let i = 0; i < words.length; i += 1) {
|
10473
10615
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
10474
10616
|
if (index === -1) {
|
10475
|
-
throw new
|
10476
|
-
|
10617
|
+
throw new import_errors24.FuelError(
|
10618
|
+
import_errors24.ErrorCode.INVALID_MNEMONIC,
|
10477
10619
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
10478
10620
|
);
|
10479
10621
|
}
|
@@ -10489,13 +10631,14 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
10489
10631
|
const checksumMask = getUpperMask(checksumBits);
|
10490
10632
|
const checksum = (0, import_utils38.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
10491
10633
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
10492
|
-
throw new
|
10493
|
-
|
10634
|
+
throw new import_errors24.FuelError(
|
10635
|
+
import_errors24.ErrorCode.INVALID_CHECKSUM,
|
10494
10636
|
"Checksum validation failed for the provided mnemonic."
|
10495
10637
|
);
|
10496
10638
|
}
|
10497
10639
|
return entropy.slice(0, entropyBits / 8);
|
10498
10640
|
}
|
10641
|
+
__name(mnemonicWordsToEntropy, "mnemonicWordsToEntropy");
|
10499
10642
|
|
10500
10643
|
// src/mnemonic/mnemonic.ts
|
10501
10644
|
var MasterSecret = (0, import_utils39.toUtf8Bytes)("Bitcoin seed");
|
@@ -10504,29 +10647,35 @@ var TestnetPRV = "0x04358394";
|
|
10504
10647
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
10505
10648
|
function assertWordList(wordlist) {
|
10506
10649
|
if (wordlist.length !== 2048) {
|
10507
|
-
throw new
|
10508
|
-
|
10650
|
+
throw new import_errors25.FuelError(
|
10651
|
+
import_errors25.ErrorCode.INVALID_WORD_LIST,
|
10509
10652
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
10510
10653
|
);
|
10511
10654
|
}
|
10512
10655
|
}
|
10656
|
+
__name(assertWordList, "assertWordList");
|
10513
10657
|
function assertEntropy(entropy) {
|
10514
10658
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
10515
|
-
throw new
|
10516
|
-
|
10659
|
+
throw new import_errors25.FuelError(
|
10660
|
+
import_errors25.ErrorCode.INVALID_ENTROPY,
|
10517
10661
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
10518
10662
|
);
|
10519
10663
|
}
|
10520
10664
|
}
|
10665
|
+
__name(assertEntropy, "assertEntropy");
|
10521
10666
|
function assertMnemonic(words) {
|
10522
10667
|
if (!MNEMONIC_SIZES.includes(words.length)) {
|
10523
10668
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
10524
10669
|
", "
|
10525
10670
|
)}] words, but got ${words.length}.`;
|
10526
|
-
throw new
|
10671
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
10527
10672
|
}
|
10528
10673
|
}
|
10529
|
-
|
10674
|
+
__name(assertMnemonic, "assertMnemonic");
|
10675
|
+
var Mnemonic = class _Mnemonic {
|
10676
|
+
static {
|
10677
|
+
__name(this, "Mnemonic");
|
10678
|
+
}
|
10530
10679
|
wordlist;
|
10531
10680
|
/**
|
10532
10681
|
*
|
@@ -10543,7 +10692,7 @@ var Mnemonic = class {
|
|
10543
10692
|
* @returns Entropy hash
|
10544
10693
|
*/
|
10545
10694
|
mnemonicToEntropy(phrase) {
|
10546
|
-
return
|
10695
|
+
return _Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
|
10547
10696
|
}
|
10548
10697
|
/**
|
10549
10698
|
*
|
@@ -10551,7 +10700,7 @@ var Mnemonic = class {
|
|
10551
10700
|
* @returns Mnemonic phrase
|
10552
10701
|
*/
|
10553
10702
|
entropyToMnemonic(entropy) {
|
10554
|
-
return
|
10703
|
+
return _Mnemonic.entropyToMnemonic(entropy, this.wordlist);
|
10555
10704
|
}
|
10556
10705
|
/**
|
10557
10706
|
*
|
@@ -10592,8 +10741,8 @@ var Mnemonic = class {
|
|
10592
10741
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
10593
10742
|
*/
|
10594
10743
|
static mnemonicToMasterKeys(phrase, passphrase = "") {
|
10595
|
-
const seed =
|
10596
|
-
return
|
10744
|
+
const seed = _Mnemonic.mnemonicToSeed(phrase, passphrase);
|
10745
|
+
return _Mnemonic.masterKeysFromSeed(seed);
|
10597
10746
|
}
|
10598
10747
|
/**
|
10599
10748
|
* Validates if given mnemonic is valid
|
@@ -10609,7 +10758,7 @@ var Mnemonic = class {
|
|
10609
10758
|
return false;
|
10610
10759
|
}
|
10611
10760
|
while (i < words.length) {
|
10612
|
-
if (
|
10761
|
+
if (_Mnemonic.binarySearch(words[i]) === false) {
|
10613
10762
|
return false;
|
10614
10763
|
}
|
10615
10764
|
i += 1;
|
@@ -10641,8 +10790,8 @@ var Mnemonic = class {
|
|
10641
10790
|
static masterKeysFromSeed(seed) {
|
10642
10791
|
const seedArray = (0, import_utils39.arrayify)(seed);
|
10643
10792
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
10644
|
-
throw new
|
10645
|
-
|
10793
|
+
throw new import_errors25.FuelError(
|
10794
|
+
import_errors25.ErrorCode.INVALID_SEED,
|
10646
10795
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
10647
10796
|
);
|
10648
10797
|
}
|
@@ -10656,7 +10805,7 @@ var Mnemonic = class {
|
|
10656
10805
|
* @returns BIP-32 extended private key
|
10657
10806
|
*/
|
10658
10807
|
static seedToExtendedKey(seed, testnet = false) {
|
10659
|
-
const masterKey =
|
10808
|
+
const masterKey = _Mnemonic.masterKeysFromSeed(seed);
|
10660
10809
|
const prefix = (0, import_utils39.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
10661
10810
|
const depth = "0x00";
|
10662
10811
|
const fingerprint = "0x00000000";
|
@@ -10688,7 +10837,7 @@ var Mnemonic = class {
|
|
10688
10837
|
*/
|
10689
10838
|
static generate(size = 32, extraEntropy = "") {
|
10690
10839
|
const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils39.concat)([(0, import_crypto5.randomBytes)(size), (0, import_utils39.arrayify)(extraEntropy)])) : (0, import_crypto5.randomBytes)(size);
|
10691
|
-
return
|
10840
|
+
return _Mnemonic.entropyToMnemonic(entropy);
|
10692
10841
|
}
|
10693
10842
|
};
|
10694
10843
|
var mnemonic_default = Mnemonic;
|
@@ -10702,24 +10851,28 @@ var TestnetPUB = (0, import_utils41.hexlify)("0x043587cf");
|
|
10702
10851
|
function base58check(data) {
|
10703
10852
|
return (0, import_utils41.encodeBase58)((0, import_utils41.concat)([data, (0, import_utils41.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
|
10704
10853
|
}
|
10854
|
+
__name(base58check, "base58check");
|
10705
10855
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
10706
10856
|
if (isPublic) {
|
10707
10857
|
return testnet ? TestnetPUB : MainnetPUB;
|
10708
10858
|
}
|
10709
10859
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
10710
10860
|
}
|
10861
|
+
__name(getExtendedKeyPrefix, "getExtendedKeyPrefix");
|
10711
10862
|
function isPublicExtendedKey(extendedKey) {
|
10712
10863
|
return [MainnetPUB, TestnetPUB].includes((0, import_utils41.hexlify)(extendedKey.slice(0, 4)));
|
10713
10864
|
}
|
10865
|
+
__name(isPublicExtendedKey, "isPublicExtendedKey");
|
10714
10866
|
function isValidExtendedKey(extendedKey) {
|
10715
10867
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
10716
10868
|
(0, import_utils41.hexlify)(extendedKey.slice(0, 4))
|
10717
10869
|
);
|
10718
10870
|
}
|
10871
|
+
__name(isValidExtendedKey, "isValidExtendedKey");
|
10719
10872
|
function parsePath(path, depth = 0) {
|
10720
10873
|
const components = path.split("/");
|
10721
10874
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
10722
|
-
throw new
|
10875
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
|
10723
10876
|
}
|
10724
10877
|
if (components[0] === "m") {
|
10725
10878
|
components.shift();
|
@@ -10728,7 +10881,11 @@ function parsePath(path, depth = 0) {
|
|
10728
10881
|
(p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
|
10729
10882
|
);
|
10730
10883
|
}
|
10731
|
-
|
10884
|
+
__name(parsePath, "parsePath");
|
10885
|
+
var HDWallet = class _HDWallet {
|
10886
|
+
static {
|
10887
|
+
__name(this, "HDWallet");
|
10888
|
+
}
|
10732
10889
|
depth = 0;
|
10733
10890
|
index = 0;
|
10734
10891
|
fingerprint = (0, import_utils41.hexlify)("0x00000000");
|
@@ -10748,8 +10905,8 @@ var HDWallet = class {
|
|
10748
10905
|
this.privateKey = (0, import_utils41.hexlify)(config.privateKey);
|
10749
10906
|
} else {
|
10750
10907
|
if (!config.publicKey) {
|
10751
|
-
throw new
|
10752
|
-
|
10908
|
+
throw new import_errors26.FuelError(
|
10909
|
+
import_errors26.ErrorCode.HD_WALLET_ERROR,
|
10753
10910
|
"Both public and private Key cannot be missing. At least one should be provided."
|
10754
10911
|
);
|
10755
10912
|
}
|
@@ -10778,8 +10935,8 @@ var HDWallet = class {
|
|
10778
10935
|
const data = new Uint8Array(37);
|
10779
10936
|
if (index & HARDENED_INDEX) {
|
10780
10937
|
if (!privateKey) {
|
10781
|
-
throw new
|
10782
|
-
|
10938
|
+
throw new import_errors26.FuelError(
|
10939
|
+
import_errors26.ErrorCode.HD_WALLET_ERROR,
|
10783
10940
|
"Cannot derive a hardened index without a private Key."
|
10784
10941
|
);
|
10785
10942
|
}
|
@@ -10794,7 +10951,7 @@ var HDWallet = class {
|
|
10794
10951
|
if (privateKey) {
|
10795
10952
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
10796
10953
|
const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
10797
|
-
return new
|
10954
|
+
return new _HDWallet({
|
10798
10955
|
privateKey: ki,
|
10799
10956
|
chainCode: IR,
|
10800
10957
|
index,
|
@@ -10804,7 +10961,7 @@ var HDWallet = class {
|
|
10804
10961
|
}
|
10805
10962
|
const signer = new Signer((0, import_utils41.hexlify)(IL));
|
10806
10963
|
const Ki = signer.addPoint(publicKey);
|
10807
|
-
return new
|
10964
|
+
return new _HDWallet({
|
10808
10965
|
publicKey: Ki,
|
10809
10966
|
chainCode: IR,
|
10810
10967
|
index,
|
@@ -10831,8 +10988,8 @@ var HDWallet = class {
|
|
10831
10988
|
*/
|
10832
10989
|
toExtendedKey(isPublic = false, testnet = false) {
|
10833
10990
|
if (this.depth >= 256) {
|
10834
|
-
throw new
|
10835
|
-
|
10991
|
+
throw new import_errors26.FuelError(
|
10992
|
+
import_errors26.ErrorCode.HD_WALLET_ERROR,
|
10836
10993
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
10837
10994
|
);
|
10838
10995
|
}
|
@@ -10853,7 +11010,7 @@ var HDWallet = class {
|
|
10853
11010
|
*/
|
10854
11011
|
static fromSeed(seed) {
|
10855
11012
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
10856
|
-
return new
|
11013
|
+
return new _HDWallet({
|
10857
11014
|
chainCode: (0, import_utils41.arrayify)(masterKey.slice(32)),
|
10858
11015
|
privateKey: (0, import_utils41.arrayify)(masterKey.slice(0, 32))
|
10859
11016
|
});
|
@@ -10863,10 +11020,10 @@ var HDWallet = class {
|
|
10863
11020
|
const bytes = (0, import_utils41.arrayify)(decoded);
|
10864
11021
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10865
11022
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10866
|
-
throw new
|
11023
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
10867
11024
|
}
|
10868
11025
|
if (!validChecksum) {
|
10869
|
-
throw new
|
11026
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10870
11027
|
}
|
10871
11028
|
const depth = bytes[4];
|
10872
11029
|
const parentFingerprint = (0, import_utils41.hexlify)(bytes.slice(5, 9));
|
@@ -10874,16 +11031,16 @@ var HDWallet = class {
|
|
10874
11031
|
const chainCode = (0, import_utils41.hexlify)(bytes.slice(13, 45));
|
10875
11032
|
const key = bytes.slice(45, 78);
|
10876
11033
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10877
|
-
throw new
|
10878
|
-
|
11034
|
+
throw new import_errors26.FuelError(
|
11035
|
+
import_errors26.ErrorCode.HD_WALLET_ERROR,
|
10879
11036
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
10880
11037
|
);
|
10881
11038
|
}
|
10882
11039
|
if (isPublicExtendedKey(bytes)) {
|
10883
11040
|
if (key[0] !== 3) {
|
10884
|
-
throw new
|
11041
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
10885
11042
|
}
|
10886
|
-
return new
|
11043
|
+
return new _HDWallet({
|
10887
11044
|
publicKey: key,
|
10888
11045
|
chainCode,
|
10889
11046
|
index,
|
@@ -10892,9 +11049,9 @@ var HDWallet = class {
|
|
10892
11049
|
});
|
10893
11050
|
}
|
10894
11051
|
if (key[0] !== 0) {
|
10895
|
-
throw new
|
11052
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
10896
11053
|
}
|
10897
|
-
return new
|
11054
|
+
return new _HDWallet({
|
10898
11055
|
privateKey: key.slice(1),
|
10899
11056
|
chainCode,
|
10900
11057
|
index,
|
@@ -10907,6 +11064,9 @@ var hdwallet_default = HDWallet;
|
|
10907
11064
|
|
10908
11065
|
// src/wallet/wallets.ts
|
10909
11066
|
var WalletLocked = class extends Account {
|
11067
|
+
static {
|
11068
|
+
__name(this, "WalletLocked");
|
11069
|
+
}
|
10910
11070
|
/**
|
10911
11071
|
* Unlocks the wallet using the provided private key and returns an instance of WalletUnlocked.
|
10912
11072
|
*
|
@@ -10917,7 +11077,10 @@ var WalletLocked = class extends Account {
|
|
10917
11077
|
return new WalletUnlocked(privateKey, this._provider);
|
10918
11078
|
}
|
10919
11079
|
};
|
10920
|
-
var WalletUnlocked = class extends BaseWalletUnlocked {
|
11080
|
+
var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
11081
|
+
static {
|
11082
|
+
__name(this, "WalletUnlocked");
|
11083
|
+
}
|
10921
11084
|
/**
|
10922
11085
|
* Locks the wallet and returns an instance of WalletLocked.
|
10923
11086
|
*
|
@@ -10935,7 +11098,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10935
11098
|
*/
|
10936
11099
|
static generate(generateOptions) {
|
10937
11100
|
const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
|
10938
|
-
return new
|
11101
|
+
return new _WalletUnlocked(privateKey, generateOptions?.provider);
|
10939
11102
|
}
|
10940
11103
|
/**
|
10941
11104
|
* Create a Wallet Unlocked from a seed.
|
@@ -10947,8 +11110,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10947
11110
|
*/
|
10948
11111
|
static fromSeed(seed, path, provider) {
|
10949
11112
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
10950
|
-
const childWallet = hdWallet.derivePath(path ||
|
10951
|
-
return new
|
11113
|
+
const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
|
11114
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
10952
11115
|
}
|
10953
11116
|
/**
|
10954
11117
|
* Create a Wallet Unlocked from a mnemonic phrase.
|
@@ -10962,8 +11125,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10962
11125
|
static fromMnemonic(mnemonic, path, passphrase, provider) {
|
10963
11126
|
const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
|
10964
11127
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
10965
|
-
const childWallet = hdWallet.derivePath(path ||
|
10966
|
-
return new
|
11128
|
+
const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
|
11129
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
10967
11130
|
}
|
10968
11131
|
/**
|
10969
11132
|
* Create a Wallet Unlocked from an extended key.
|
@@ -10974,7 +11137,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10974
11137
|
*/
|
10975
11138
|
static fromExtendedKey(extendedKey, provider) {
|
10976
11139
|
const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
|
10977
|
-
return new
|
11140
|
+
return new _WalletUnlocked(hdWallet.privateKey, provider);
|
10978
11141
|
}
|
10979
11142
|
/**
|
10980
11143
|
* Create a Wallet Unlocked from an encrypted JSON.
|
@@ -10986,12 +11149,15 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10986
11149
|
*/
|
10987
11150
|
static async fromEncryptedJson(jsonWallet, password, provider) {
|
10988
11151
|
const privateKey = await decryptKeystoreWallet(jsonWallet, password);
|
10989
|
-
return new
|
11152
|
+
return new _WalletUnlocked(privateKey, provider);
|
10990
11153
|
}
|
10991
11154
|
};
|
10992
11155
|
|
10993
11156
|
// src/wallet/wallet.ts
|
10994
11157
|
var Wallet = class {
|
11158
|
+
static {
|
11159
|
+
__name(this, "Wallet");
|
11160
|
+
}
|
10995
11161
|
/**
|
10996
11162
|
* Creates a locked wallet instance from an address and a provider.
|
10997
11163
|
*
|
@@ -11012,59 +11178,62 @@ var Wallet = class {
|
|
11012
11178
|
static fromPrivateKey(privateKey, provider) {
|
11013
11179
|
return new WalletUnlocked(privateKey, provider);
|
11014
11180
|
}
|
11181
|
+
/**
|
11182
|
+
* Generate a new Wallet Unlocked with a random key pair.
|
11183
|
+
*
|
11184
|
+
* @param generateOptions - Options to customize the generation process (optional).
|
11185
|
+
* @returns An unlocked wallet instance.
|
11186
|
+
*/
|
11187
|
+
static generate = WalletUnlocked.generate;
|
11188
|
+
/**
|
11189
|
+
* Create a Wallet Unlocked from a seed.
|
11190
|
+
*
|
11191
|
+
* @param seed - The seed phrase.
|
11192
|
+
* @param provider - A Provider instance (optional).
|
11193
|
+
* @param path - The derivation path (optional).
|
11194
|
+
* @returns An unlocked wallet instance.
|
11195
|
+
*/
|
11196
|
+
static fromSeed = WalletUnlocked.fromSeed;
|
11197
|
+
/**
|
11198
|
+
* Create a Wallet Unlocked from a mnemonic phrase.
|
11199
|
+
*
|
11200
|
+
* @param mnemonic - The mnemonic phrase.
|
11201
|
+
* @param provider - A Provider instance (optional).
|
11202
|
+
* @param path - The derivation path (optional).
|
11203
|
+
* @param passphrase - The passphrase for the mnemonic (optional).
|
11204
|
+
* @returns An unlocked wallet instance.
|
11205
|
+
*/
|
11206
|
+
static fromMnemonic = WalletUnlocked.fromMnemonic;
|
11207
|
+
/**
|
11208
|
+
* Create a Wallet Unlocked from an extended key.
|
11209
|
+
*
|
11210
|
+
* @param extendedKey - The extended key.
|
11211
|
+
* @param provider - A Provider instance (optional).
|
11212
|
+
* @returns An unlocked wallet instance.
|
11213
|
+
*/
|
11214
|
+
static fromExtendedKey = WalletUnlocked.fromExtendedKey;
|
11215
|
+
/**
|
11216
|
+
* Create a Wallet Unlocked from an encrypted JSON.
|
11217
|
+
*
|
11218
|
+
* @param jsonWallet - The encrypted JSON keystore.
|
11219
|
+
* @param password - The password to decrypt the JSON.
|
11220
|
+
* @param provider - A Provider instance (optional).
|
11221
|
+
* @returns An unlocked wallet instance.
|
11222
|
+
*/
|
11223
|
+
static fromEncryptedJson = WalletUnlocked.fromEncryptedJson;
|
11015
11224
|
};
|
11016
|
-
/**
|
11017
|
-
* Generate a new Wallet Unlocked with a random key pair.
|
11018
|
-
*
|
11019
|
-
* @param generateOptions - Options to customize the generation process (optional).
|
11020
|
-
* @returns An unlocked wallet instance.
|
11021
|
-
*/
|
11022
|
-
__publicField(Wallet, "generate", WalletUnlocked.generate);
|
11023
|
-
/**
|
11024
|
-
* Create a Wallet Unlocked from a seed.
|
11025
|
-
*
|
11026
|
-
* @param seed - The seed phrase.
|
11027
|
-
* @param provider - A Provider instance (optional).
|
11028
|
-
* @param path - The derivation path (optional).
|
11029
|
-
* @returns An unlocked wallet instance.
|
11030
|
-
*/
|
11031
|
-
__publicField(Wallet, "fromSeed", WalletUnlocked.fromSeed);
|
11032
|
-
/**
|
11033
|
-
* Create a Wallet Unlocked from a mnemonic phrase.
|
11034
|
-
*
|
11035
|
-
* @param mnemonic - The mnemonic phrase.
|
11036
|
-
* @param provider - A Provider instance (optional).
|
11037
|
-
* @param path - The derivation path (optional).
|
11038
|
-
* @param passphrase - The passphrase for the mnemonic (optional).
|
11039
|
-
* @returns An unlocked wallet instance.
|
11040
|
-
*/
|
11041
|
-
__publicField(Wallet, "fromMnemonic", WalletUnlocked.fromMnemonic);
|
11042
|
-
/**
|
11043
|
-
* Create a Wallet Unlocked from an extended key.
|
11044
|
-
*
|
11045
|
-
* @param extendedKey - The extended key.
|
11046
|
-
* @param provider - A Provider instance (optional).
|
11047
|
-
* @returns An unlocked wallet instance.
|
11048
|
-
*/
|
11049
|
-
__publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
11050
|
-
/**
|
11051
|
-
* Create a Wallet Unlocked from an encrypted JSON.
|
11052
|
-
*
|
11053
|
-
* @param jsonWallet - The encrypted JSON keystore.
|
11054
|
-
* @param password - The password to decrypt the JSON.
|
11055
|
-
* @param provider - A Provider instance (optional).
|
11056
|
-
* @returns An unlocked wallet instance.
|
11057
|
-
*/
|
11058
|
-
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
11059
11225
|
|
11060
11226
|
// src/wallet-manager/wallet-manager.ts
|
11061
11227
|
var import_address10 = require("@fuel-ts/address");
|
11062
11228
|
var import_crypto7 = require("@fuel-ts/crypto");
|
11063
|
-
var
|
11229
|
+
var import_errors29 = require("@fuel-ts/errors");
|
11064
11230
|
var import_events = require("events");
|
11065
11231
|
|
11066
11232
|
// src/wallet-manager/storages/memory-storage.ts
|
11067
11233
|
var MemoryStorage = class {
|
11234
|
+
static {
|
11235
|
+
__name(this, "MemoryStorage");
|
11236
|
+
}
|
11068
11237
|
storage = /* @__PURE__ */ new Map();
|
11069
11238
|
async getItem(key) {
|
11070
11239
|
const item = await this.storage.get(key);
|
@@ -11083,15 +11252,18 @@ var MemoryStorage = class {
|
|
11083
11252
|
|
11084
11253
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
11085
11254
|
var import_address8 = require("@fuel-ts/address");
|
11086
|
-
var
|
11087
|
-
var _secret;
|
11255
|
+
var import_errors27 = require("@fuel-ts/errors");
|
11088
11256
|
var MnemonicVault = class {
|
11257
|
+
static {
|
11258
|
+
__name(this, "MnemonicVault");
|
11259
|
+
}
|
11260
|
+
static type = "mnemonic";
|
11261
|
+
#secret;
|
11262
|
+
pathKey = "{}";
|
11263
|
+
rootPath = `m/44'/1179993420'/${this.pathKey}'/0/0`;
|
11264
|
+
numberOfAccounts = 0;
|
11089
11265
|
constructor(options) {
|
11090
|
-
|
11091
|
-
__publicField(this, "pathKey", "{}");
|
11092
|
-
__publicField(this, "rootPath", `m/44'/1179993420'/${this.pathKey}'/0/0`);
|
11093
|
-
__publicField(this, "numberOfAccounts", 0);
|
11094
|
-
__privateSet(this, _secret, options.secret || mnemonic_default.generate());
|
11266
|
+
this.#secret = options.secret || mnemonic_default.generate();
|
11095
11267
|
this.rootPath = options.rootPath || this.rootPath;
|
11096
11268
|
this.numberOfAccounts = options.numberOfAccounts || 1;
|
11097
11269
|
}
|
@@ -11103,7 +11275,7 @@ var MnemonicVault = class {
|
|
11103
11275
|
}
|
11104
11276
|
serialize() {
|
11105
11277
|
return {
|
11106
|
-
secret:
|
11278
|
+
secret: this.#secret,
|
11107
11279
|
rootPath: this.rootPath,
|
11108
11280
|
numberOfAccounts: this.numberOfAccounts
|
11109
11281
|
};
|
@@ -11112,7 +11284,7 @@ var MnemonicVault = class {
|
|
11112
11284
|
const accounts = [];
|
11113
11285
|
let numberOfAccounts = 0;
|
11114
11286
|
do {
|
11115
|
-
const wallet = Wallet.fromMnemonic(
|
11287
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
|
11116
11288
|
accounts.push({
|
11117
11289
|
publicKey: wallet.publicKey,
|
11118
11290
|
address: wallet.address
|
@@ -11123,7 +11295,7 @@ var MnemonicVault = class {
|
|
11123
11295
|
}
|
11124
11296
|
addAccount() {
|
11125
11297
|
this.numberOfAccounts += 1;
|
11126
|
-
const wallet = Wallet.fromMnemonic(
|
11298
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(this.numberOfAccounts - 1));
|
11127
11299
|
return {
|
11128
11300
|
publicKey: wallet.publicKey,
|
11129
11301
|
address: wallet.address
|
@@ -11133,14 +11305,14 @@ var MnemonicVault = class {
|
|
11133
11305
|
let numberOfAccounts = 0;
|
11134
11306
|
const ownerAddress = new import_address8.Address(address);
|
11135
11307
|
do {
|
11136
|
-
const wallet = Wallet.fromMnemonic(
|
11308
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
|
11137
11309
|
if (wallet.address.equals(ownerAddress)) {
|
11138
11310
|
return wallet.privateKey;
|
11139
11311
|
}
|
11140
11312
|
numberOfAccounts += 1;
|
11141
11313
|
} while (numberOfAccounts < this.numberOfAccounts);
|
11142
|
-
throw new
|
11143
|
-
|
11314
|
+
throw new import_errors27.FuelError(
|
11315
|
+
import_errors27.ErrorCode.WALLET_MANAGER_ERROR,
|
11144
11316
|
`Account with address '${address}' not found in derived wallets.`
|
11145
11317
|
);
|
11146
11318
|
}
|
@@ -11149,29 +11321,30 @@ var MnemonicVault = class {
|
|
11149
11321
|
return Wallet.fromPrivateKey(privateKey);
|
11150
11322
|
}
|
11151
11323
|
};
|
11152
|
-
_secret = new WeakMap();
|
11153
|
-
__publicField(MnemonicVault, "type", "mnemonic");
|
11154
11324
|
|
11155
11325
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
11156
11326
|
var import_address9 = require("@fuel-ts/address");
|
11157
|
-
var
|
11158
|
-
var _privateKeys;
|
11327
|
+
var import_errors28 = require("@fuel-ts/errors");
|
11159
11328
|
var PrivateKeyVault = class {
|
11329
|
+
static {
|
11330
|
+
__name(this, "PrivateKeyVault");
|
11331
|
+
}
|
11332
|
+
static type = "privateKey";
|
11333
|
+
#privateKeys = [];
|
11160
11334
|
/**
|
11161
11335
|
* If privateKey vault is initialized with a secretKey, it creates
|
11162
11336
|
* one account with the fallowing secret
|
11163
11337
|
*/
|
11164
11338
|
constructor(options = {}) {
|
11165
|
-
__privateAdd(this, _privateKeys, []);
|
11166
11339
|
if (options.secret) {
|
11167
|
-
|
11340
|
+
this.#privateKeys = [options.secret];
|
11168
11341
|
} else {
|
11169
|
-
|
11342
|
+
this.#privateKeys = options.accounts || [Wallet.generate().privateKey];
|
11170
11343
|
}
|
11171
11344
|
}
|
11172
11345
|
serialize() {
|
11173
11346
|
return {
|
11174
|
-
accounts:
|
11347
|
+
accounts: this.#privateKeys
|
11175
11348
|
};
|
11176
11349
|
}
|
11177
11350
|
getPublicAccount(privateKey) {
|
@@ -11182,21 +11355,21 @@ var PrivateKeyVault = class {
|
|
11182
11355
|
};
|
11183
11356
|
}
|
11184
11357
|
getAccounts() {
|
11185
|
-
return
|
11358
|
+
return this.#privateKeys.map((pk) => this.getPublicAccount(pk));
|
11186
11359
|
}
|
11187
11360
|
addAccount() {
|
11188
11361
|
const wallet = Wallet.generate();
|
11189
|
-
|
11362
|
+
this.#privateKeys.push(wallet.privateKey);
|
11190
11363
|
return this.getPublicAccount(wallet.privateKey);
|
11191
11364
|
}
|
11192
11365
|
exportAccount(address) {
|
11193
11366
|
const ownerAddress = new import_address9.Address(address);
|
11194
|
-
const privateKey =
|
11367
|
+
const privateKey = this.#privateKeys.find(
|
11195
11368
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
11196
11369
|
);
|
11197
11370
|
if (!privateKey) {
|
11198
|
-
throw new
|
11199
|
-
|
11371
|
+
throw new import_errors28.FuelError(
|
11372
|
+
import_errors28.ErrorCode.WALLET_MANAGER_ERROR,
|
11200
11373
|
`No private key found for address '${address}'.`
|
11201
11374
|
);
|
11202
11375
|
}
|
@@ -11207,8 +11380,6 @@ var PrivateKeyVault = class {
|
|
11207
11380
|
return Wallet.fromPrivateKey(privateKey);
|
11208
11381
|
}
|
11209
11382
|
};
|
11210
|
-
_privateKeys = new WeakMap();
|
11211
|
-
__publicField(PrivateKeyVault, "type", "privateKey");
|
11212
11383
|
|
11213
11384
|
// src/wallet-manager/wallet-manager.ts
|
11214
11385
|
var ERROR_MESSAGES = {
|
@@ -11220,49 +11391,50 @@ var ERROR_MESSAGES = {
|
|
11220
11391
|
};
|
11221
11392
|
function assert(condition, message) {
|
11222
11393
|
if (!condition) {
|
11223
|
-
throw new
|
11394
|
+
throw new import_errors29.FuelError(import_errors29.ErrorCode.WALLET_MANAGER_ERROR, message);
|
11224
11395
|
}
|
11225
11396
|
}
|
11226
|
-
|
11227
|
-
var
|
11397
|
+
__name(assert, "assert");
|
11398
|
+
var WalletManager = class _WalletManager extends import_events.EventEmitter {
|
11399
|
+
static {
|
11400
|
+
__name(this, "WalletManager");
|
11401
|
+
}
|
11402
|
+
/**
|
11403
|
+
* Vaults
|
11404
|
+
*
|
11405
|
+
* Vaults are responsible to store secret keys and return an `Wallet` instance,
|
11406
|
+
* to interact with the network.
|
11407
|
+
*
|
11408
|
+
* Each vault has access to its own state
|
11409
|
+
*
|
11410
|
+
*/
|
11411
|
+
static Vaults = [MnemonicVault, PrivateKeyVault];
|
11412
|
+
/**
|
11413
|
+
* Storage
|
11414
|
+
*
|
11415
|
+
* Persistent encrypted data. `The default storage works only on memory`.
|
11416
|
+
*/
|
11417
|
+
storage = new MemoryStorage();
|
11418
|
+
/* Key name passed to the storage */
|
11419
|
+
STORAGE_KEY = "WalletManager";
|
11420
|
+
// `This variables are only accessible from inside the class`
|
11421
|
+
#vaults = [];
|
11422
|
+
#passphrase = "";
|
11423
|
+
#isLocked = true;
|
11228
11424
|
constructor(options) {
|
11229
11425
|
super();
|
11230
|
-
/**
|
11231
|
-
* Serialize all vaults to store
|
11232
|
-
*
|
11233
|
-
* `This is only accessible from inside the class`
|
11234
|
-
*/
|
11235
|
-
__privateAdd(this, _serializeVaults);
|
11236
|
-
/**
|
11237
|
-
* Deserialize all vaults to state
|
11238
|
-
*
|
11239
|
-
* `This is only accessible from inside the class`
|
11240
|
-
*/
|
11241
|
-
__privateAdd(this, _deserializeVaults);
|
11242
|
-
/**
|
11243
|
-
* Storage
|
11244
|
-
*
|
11245
|
-
* Persistent encrypted data. `The default storage works only on memory`.
|
11246
|
-
*/
|
11247
|
-
__publicField(this, "storage", new MemoryStorage());
|
11248
|
-
/* Key name passed to the storage */
|
11249
|
-
__publicField(this, "STORAGE_KEY", "WalletManager");
|
11250
|
-
// `This variables are only accessible from inside the class`
|
11251
|
-
__privateAdd(this, _vaults, []);
|
11252
|
-
__privateAdd(this, _passphrase, "");
|
11253
|
-
__privateAdd(this, _isLocked, true);
|
11254
11426
|
this.storage = options?.storage || this.storage;
|
11255
11427
|
}
|
11256
11428
|
get isLocked() {
|
11257
|
-
return
|
11429
|
+
return this.#isLocked;
|
11258
11430
|
}
|
11259
11431
|
/**
|
11260
11432
|
* Return the vault serialized object containing all the privateKeys,
|
11261
11433
|
* the format of the return depends on the Vault type.
|
11262
11434
|
*/
|
11263
11435
|
exportVault(vaultId) {
|
11264
|
-
assert(!
|
11265
|
-
const vaultState =
|
11436
|
+
assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
11437
|
+
const vaultState = this.#vaults.find((_, idx) => idx === vaultId);
|
11266
11438
|
assert(vaultState, ERROR_MESSAGES.vault_not_found);
|
11267
11439
|
return vaultState.vault.serialize();
|
11268
11440
|
}
|
@@ -11270,7 +11442,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11270
11442
|
* List all vaults on the Wallet Manager, this function not return secret's
|
11271
11443
|
*/
|
11272
11444
|
getVaults() {
|
11273
|
-
return
|
11445
|
+
return this.#vaults.map((v, idx) => ({
|
11274
11446
|
title: v.title,
|
11275
11447
|
type: v.type,
|
11276
11448
|
vaultId: idx
|
@@ -11280,7 +11452,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11280
11452
|
* List all accounts on the Wallet Manager not vault information is revealed
|
11281
11453
|
*/
|
11282
11454
|
getAccounts() {
|
11283
|
-
return
|
11455
|
+
return this.#vaults.flatMap(
|
11284
11456
|
(vaultState, vaultId) => vaultState.vault.getAccounts().map((account) => ({ ...account, vaultId }))
|
11285
11457
|
);
|
11286
11458
|
}
|
@@ -11289,7 +11461,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11289
11461
|
*/
|
11290
11462
|
getWallet(address) {
|
11291
11463
|
const ownerAddress = new import_address10.Address(address);
|
11292
|
-
const vaultState =
|
11464
|
+
const vaultState = this.#vaults.find(
|
11293
11465
|
(vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
|
11294
11466
|
);
|
11295
11467
|
assert(vaultState, ERROR_MESSAGES.address_not_found);
|
@@ -11300,8 +11472,8 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11300
11472
|
*/
|
11301
11473
|
exportPrivateKey(address) {
|
11302
11474
|
const ownerAddress = new import_address10.Address(address);
|
11303
|
-
assert(!
|
11304
|
-
const vaultState =
|
11475
|
+
assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
11476
|
+
const vaultState = this.#vaults.find(
|
11305
11477
|
(vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
|
11306
11478
|
);
|
11307
11479
|
assert(vaultState, ERROR_MESSAGES.address_not_found);
|
@@ -11313,7 +11485,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11313
11485
|
*/
|
11314
11486
|
async addAccount(options) {
|
11315
11487
|
await this.loadState();
|
11316
|
-
const vaultState =
|
11488
|
+
const vaultState = this.#vaults[options?.vaultId || 0];
|
11317
11489
|
await assert(vaultState, ERROR_MESSAGES.vault_not_found);
|
11318
11490
|
const account = vaultState.vault.addAccount();
|
11319
11491
|
await this.saveState();
|
@@ -11324,7 +11496,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11324
11496
|
* created by the vault.
|
11325
11497
|
*/
|
11326
11498
|
async removeVault(index) {
|
11327
|
-
|
11499
|
+
this.#vaults.splice(index, 1);
|
11328
11500
|
await this.saveState();
|
11329
11501
|
}
|
11330
11502
|
/**
|
@@ -11335,11 +11507,11 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11335
11507
|
await this.loadState();
|
11336
11508
|
const Vault2 = this.getVaultClass(vaultConfig.type);
|
11337
11509
|
const vault = new Vault2(vaultConfig);
|
11338
|
-
|
11510
|
+
this.#vaults = this.#vaults.concat({
|
11339
11511
|
title: vaultConfig.title,
|
11340
11512
|
type: vaultConfig.type,
|
11341
11513
|
vault
|
11342
|
-
})
|
11514
|
+
});
|
11343
11515
|
await this.saveState();
|
11344
11516
|
}
|
11345
11517
|
/**
|
@@ -11347,9 +11519,9 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11347
11519
|
* secrets.
|
11348
11520
|
*/
|
11349
11521
|
lock() {
|
11350
|
-
|
11351
|
-
|
11352
|
-
|
11522
|
+
this.#isLocked = true;
|
11523
|
+
this.#vaults = [];
|
11524
|
+
this.#passphrase = "";
|
11353
11525
|
this.emit("lock");
|
11354
11526
|
}
|
11355
11527
|
/**
|
@@ -11357,8 +11529,8 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11357
11529
|
* Vaults with secrets are not unlocked or instantiated on this moment.
|
11358
11530
|
*/
|
11359
11531
|
async unlock(passphrase) {
|
11360
|
-
|
11361
|
-
|
11532
|
+
this.#passphrase = passphrase;
|
11533
|
+
this.#isLocked = false;
|
11362
11534
|
try {
|
11363
11535
|
await this.loadState();
|
11364
11536
|
this.emit("unlock");
|
@@ -11371,9 +11543,9 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11371
11543
|
* Update WalletManager encryption passphrase
|
11372
11544
|
*/
|
11373
11545
|
async updatePassphrase(oldpass, newpass) {
|
11374
|
-
const isLocked =
|
11546
|
+
const isLocked = this.#isLocked;
|
11375
11547
|
await this.unlock(oldpass);
|
11376
|
-
|
11548
|
+
this.#passphrase = newpass;
|
11377
11549
|
await this.saveState();
|
11378
11550
|
await this.loadState();
|
11379
11551
|
if (isLocked) {
|
@@ -11384,24 +11556,51 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11384
11556
|
* Retrieve and decrypt WalletManager state from storage
|
11385
11557
|
*/
|
11386
11558
|
async loadState() {
|
11387
|
-
await assert(!
|
11559
|
+
await assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
11388
11560
|
const data = await this.storage.getItem(this.STORAGE_KEY);
|
11389
11561
|
if (data) {
|
11390
|
-
const state = await (0, import_crypto7.decrypt)(
|
11391
|
-
|
11562
|
+
const state = await (0, import_crypto7.decrypt)(this.#passphrase, JSON.parse(data));
|
11563
|
+
this.#vaults = this.#deserializeVaults(state.vaults);
|
11392
11564
|
}
|
11393
11565
|
}
|
11394
11566
|
/**
|
11395
11567
|
* Store encrypted WalletManager state on storage
|
11396
11568
|
*/
|
11397
11569
|
async saveState() {
|
11398
|
-
await assert(!
|
11399
|
-
const encryptedData = await (0, import_crypto7.encrypt)(
|
11400
|
-
vaults:
|
11570
|
+
await assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
11571
|
+
const encryptedData = await (0, import_crypto7.encrypt)(this.#passphrase, {
|
11572
|
+
vaults: this.#serializeVaults(this.#vaults)
|
11401
11573
|
});
|
11402
11574
|
await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
|
11403
11575
|
this.emit("update");
|
11404
11576
|
}
|
11577
|
+
/**
|
11578
|
+
* Serialize all vaults to store
|
11579
|
+
*
|
11580
|
+
* `This is only accessible from inside the class`
|
11581
|
+
*/
|
11582
|
+
#serializeVaults(vaults) {
|
11583
|
+
return vaults.map(({ title, type, vault }) => ({
|
11584
|
+
title,
|
11585
|
+
type,
|
11586
|
+
data: vault.serialize()
|
11587
|
+
}));
|
11588
|
+
}
|
11589
|
+
/**
|
11590
|
+
* Deserialize all vaults to state
|
11591
|
+
*
|
11592
|
+
* `This is only accessible from inside the class`
|
11593
|
+
*/
|
11594
|
+
#deserializeVaults(vaults) {
|
11595
|
+
return vaults.map(({ title, type, data: vaultConfig }) => {
|
11596
|
+
const VaultClass = this.getVaultClass(type);
|
11597
|
+
return {
|
11598
|
+
title,
|
11599
|
+
type,
|
11600
|
+
vault: new VaultClass(vaultConfig)
|
11601
|
+
};
|
11602
|
+
});
|
11603
|
+
}
|
11405
11604
|
/**
|
11406
11605
|
* Return a instantiable Class reference from `WalletManager.Vaults` supported list.
|
11407
11606
|
*/
|
@@ -11411,74 +11610,47 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11411
11610
|
return VaultClass;
|
11412
11611
|
}
|
11413
11612
|
};
|
11414
|
-
var WalletManager = _WalletManager;
|
11415
|
-
_vaults = new WeakMap();
|
11416
|
-
_passphrase = new WeakMap();
|
11417
|
-
_isLocked = new WeakMap();
|
11418
|
-
_serializeVaults = new WeakSet();
|
11419
|
-
serializeVaults_fn = function(vaults) {
|
11420
|
-
return vaults.map(({ title, type, vault }) => ({
|
11421
|
-
title,
|
11422
|
-
type,
|
11423
|
-
data: vault.serialize()
|
11424
|
-
}));
|
11425
|
-
};
|
11426
|
-
_deserializeVaults = new WeakSet();
|
11427
|
-
deserializeVaults_fn = function(vaults) {
|
11428
|
-
return vaults.map(({ title, type, data: vaultConfig }) => {
|
11429
|
-
const VaultClass = this.getVaultClass(type);
|
11430
|
-
return {
|
11431
|
-
title,
|
11432
|
-
type,
|
11433
|
-
vault: new VaultClass(vaultConfig)
|
11434
|
-
};
|
11435
|
-
});
|
11436
|
-
};
|
11437
|
-
/**
|
11438
|
-
* Vaults
|
11439
|
-
*
|
11440
|
-
* Vaults are responsible to store secret keys and return an `Wallet` instance,
|
11441
|
-
* to interact with the network.
|
11442
|
-
*
|
11443
|
-
* Each vault has access to its own state
|
11444
|
-
*
|
11445
|
-
*/
|
11446
|
-
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
11447
11613
|
|
11448
11614
|
// src/wallet-manager/types.ts
|
11449
|
-
var
|
11615
|
+
var import_errors30 = require("@fuel-ts/errors");
|
11450
11616
|
var Vault = class {
|
11617
|
+
static {
|
11618
|
+
__name(this, "Vault");
|
11619
|
+
}
|
11620
|
+
static type;
|
11451
11621
|
constructor(_options) {
|
11452
|
-
throw new
|
11622
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
11453
11623
|
}
|
11454
11624
|
serialize() {
|
11455
|
-
throw new
|
11625
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
11456
11626
|
}
|
11457
11627
|
getAccounts() {
|
11458
|
-
throw new
|
11628
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
11459
11629
|
}
|
11460
11630
|
addAccount() {
|
11461
|
-
throw new
|
11631
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
11462
11632
|
}
|
11463
11633
|
exportAccount(_address) {
|
11464
|
-
throw new
|
11634
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
11465
11635
|
}
|
11466
11636
|
getWallet(_address) {
|
11467
|
-
throw new
|
11637
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
11468
11638
|
}
|
11469
11639
|
};
|
11470
|
-
__publicField(Vault, "type");
|
11471
11640
|
var StorageAbstract = class {
|
11641
|
+
static {
|
11642
|
+
__name(this, "StorageAbstract");
|
11643
|
+
}
|
11472
11644
|
};
|
11473
11645
|
|
11474
11646
|
// src/predicate/predicate.ts
|
11475
11647
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
11476
11648
|
var import_address11 = require("@fuel-ts/address");
|
11477
|
-
var
|
11649
|
+
var import_errors32 = require("@fuel-ts/errors");
|
11478
11650
|
var import_utils45 = require("@fuel-ts/utils");
|
11479
11651
|
|
11480
11652
|
// src/utils/deployScriptOrPredicate.ts
|
11481
|
-
var
|
11653
|
+
var import_errors31 = require("@fuel-ts/errors");
|
11482
11654
|
var import_math24 = require("@fuel-ts/math");
|
11483
11655
|
var import_utils43 = require("@fuel-ts/utils");
|
11484
11656
|
|
@@ -11498,26 +11670,30 @@ function getBytecodeDataOffset(bytecode) {
|
|
11498
11670
|
const [offset] = new import_abi_coder7.BigNumberCoder("u64").decode(bytecode, DATA_OFFSET_INDEX);
|
11499
11671
|
return offset.toNumber();
|
11500
11672
|
}
|
11673
|
+
__name(getBytecodeDataOffset, "getBytecodeDataOffset");
|
11501
11674
|
function getBytecodeConfigurableOffset(bytecode) {
|
11502
11675
|
const [offset] = new import_abi_coder7.BigNumberCoder("u64").decode(bytecode, CONFIGURABLE_OFFSET_INDEX);
|
11503
11676
|
return offset.toNumber();
|
11504
11677
|
}
|
11678
|
+
__name(getBytecodeConfigurableOffset, "getBytecodeConfigurableOffset");
|
11505
11679
|
function getBytecodeId(bytecode) {
|
11506
11680
|
const configurableOffset = getBytecodeConfigurableOffset(bytecode);
|
11507
11681
|
const byteCodeWithoutConfigurableSection = bytecode.slice(0, configurableOffset);
|
11508
11682
|
return (0, import_hasher8.sha256)(byteCodeWithoutConfigurableSection);
|
11509
11683
|
}
|
11684
|
+
__name(getBytecodeId, "getBytecodeId");
|
11510
11685
|
function getLegacyBlobId(bytecode) {
|
11511
11686
|
const dataOffset = getBytecodeDataOffset(bytecode);
|
11512
11687
|
const byteCodeWithoutDataSection = bytecode.slice(0, dataOffset);
|
11513
11688
|
return (0, import_hasher8.sha256)(byteCodeWithoutDataSection);
|
11514
11689
|
}
|
11690
|
+
__name(getLegacyBlobId, "getLegacyBlobId");
|
11515
11691
|
function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
11516
11692
|
const { RegId, Instruction } = asm2;
|
11517
11693
|
const REG_PC = RegId.pc().to_u8();
|
11518
11694
|
const REG_SP = RegId.sp().to_u8();
|
11519
11695
|
const REG_IS = RegId.is().to_u8();
|
11520
|
-
const getInstructions = (numOfInstructions2) => [
|
11696
|
+
const getInstructions = /* @__PURE__ */ __name((numOfInstructions2) => [
|
11521
11697
|
// 1. Load the blob content into memory
|
11522
11698
|
// Find the start of the hardcoded blob ID, which is located after the loader code ends.
|
11523
11699
|
asm2.move_(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_PC),
|
@@ -11551,8 +11727,8 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
|
11551
11727
|
asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
|
11552
11728
|
// Jump to the start of the contract we loaded.
|
11553
11729
|
asm2.jmp(REG_START_OF_LOADED_CODE)
|
11554
|
-
];
|
11555
|
-
const getInstructionsNoDataSection = (numOfInstructions2) => [
|
11730
|
+
], "getInstructions");
|
11731
|
+
const getInstructionsNoDataSection = /* @__PURE__ */ __name((numOfInstructions2) => [
|
11556
11732
|
// 1. Load the blob content into memory
|
11557
11733
|
// Find the start of the hardcoded blob ID, which is located after the loader code ends.
|
11558
11734
|
// 1. Load the blob content into memory
|
@@ -11579,7 +11755,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
|
11579
11755
|
asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
|
11580
11756
|
// Jump to the start of the contract we loaded.
|
11581
11757
|
asm2.jmp(REG_START_OF_LOADED_CODE)
|
11582
|
-
];
|
11758
|
+
], "getInstructionsNoDataSection");
|
11583
11759
|
const offset = getBytecodeConfigurableOffset(originalBinary);
|
11584
11760
|
if (originalBinary.length < offset) {
|
11585
11761
|
throw new Error(
|
@@ -11624,6 +11800,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
|
11624
11800
|
const loaderBytecode = new Uint8Array([...instructionBytes, ...blobBytes]);
|
11625
11801
|
return { loaderBytecode };
|
11626
11802
|
}
|
11803
|
+
__name(getPredicateScriptLoaderInstructions, "getPredicateScriptLoaderInstructions");
|
11627
11804
|
|
11628
11805
|
// src/utils/deployScriptOrPredicate.ts
|
11629
11806
|
async function fundBlobTx(deployer, blobTxRequest) {
|
@@ -11640,12 +11817,13 @@ async function fundBlobTx(deployer, blobTxRequest) {
|
|
11640
11817
|
}).add(1);
|
11641
11818
|
totalCost = totalCost.add(minFee);
|
11642
11819
|
if (totalCost.gt(await deployer.getBalance())) {
|
11643
|
-
throw new
|
11820
|
+
throw new import_errors31.FuelError(import_errors31.ErrorCode.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
|
11644
11821
|
}
|
11645
11822
|
const txCost = await deployer.getTransactionCost(blobTxRequest);
|
11646
11823
|
blobTxRequest.maxFee = txCost.maxFee;
|
11647
11824
|
return deployer.fund(blobTxRequest, txCost);
|
11648
11825
|
}
|
11826
|
+
__name(fundBlobTx, "fundBlobTx");
|
11649
11827
|
function adjustConfigurableOffsets(jsonAbi, configurableOffsetDiff) {
|
11650
11828
|
const { configurables: readOnlyConfigurables } = jsonAbi;
|
11651
11829
|
const configurables = [];
|
@@ -11654,6 +11832,7 @@ function adjustConfigurableOffsets(jsonAbi, configurableOffsetDiff) {
|
|
11654
11832
|
});
|
11655
11833
|
return { ...jsonAbi, configurables };
|
11656
11834
|
}
|
11835
|
+
__name(adjustConfigurableOffsets, "adjustConfigurableOffsets");
|
11657
11836
|
async function deployScriptOrPredicate({
|
11658
11837
|
deployer,
|
11659
11838
|
bytecode,
|
@@ -11678,12 +11857,12 @@ async function deployScriptOrPredicate({
|
|
11678
11857
|
const loaderInstance = loaderInstanceCallback(loaderBytecode, newAbi);
|
11679
11858
|
if (blobExists) {
|
11680
11859
|
return {
|
11681
|
-
waitForResult: () => Promise.resolve(loaderInstance),
|
11860
|
+
waitForResult: /* @__PURE__ */ __name(() => Promise.resolve(loaderInstance), "waitForResult"),
|
11682
11861
|
blobId
|
11683
11862
|
};
|
11684
11863
|
}
|
11685
11864
|
const fundedBlobRequest = await fundBlobTx(deployer, blobTxRequest);
|
11686
|
-
const waitForResult = async () => {
|
11865
|
+
const waitForResult = /* @__PURE__ */ __name(async () => {
|
11687
11866
|
try {
|
11688
11867
|
const blobTx = await deployer.sendTransaction(fundedBlobRequest);
|
11689
11868
|
const result = await blobTx.waitForResult();
|
@@ -11691,31 +11870,35 @@ async function deployScriptOrPredicate({
|
|
11691
11870
|
throw new Error();
|
11692
11871
|
}
|
11693
11872
|
} catch (err) {
|
11694
|
-
throw new
|
11873
|
+
throw new import_errors31.FuelError(import_errors31.ErrorCode.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
|
11695
11874
|
}
|
11696
11875
|
return loaderInstance;
|
11697
|
-
};
|
11876
|
+
}, "waitForResult");
|
11698
11877
|
return {
|
11699
11878
|
waitForResult,
|
11700
11879
|
blobId
|
11701
11880
|
};
|
11702
11881
|
}
|
11882
|
+
__name(deployScriptOrPredicate, "deployScriptOrPredicate");
|
11703
11883
|
|
11704
11884
|
// src/predicate/utils/getPredicateRoot.ts
|
11705
11885
|
var import_hasher9 = require("@fuel-ts/hasher");
|
11706
11886
|
var import_merkle = require("@fuel-ts/merkle");
|
11707
11887
|
var import_utils44 = require("@fuel-ts/utils");
|
11708
|
-
var getPredicateRoot = (bytecode) => {
|
11888
|
+
var getPredicateRoot = /* @__PURE__ */ __name((bytecode) => {
|
11709
11889
|
const chunkSize = 16 * 1024;
|
11710
11890
|
const bytes = (0, import_utils44.arrayify)(bytecode);
|
11711
11891
|
const chunks = (0, import_utils44.chunkAndPadBytes)(bytes, chunkSize);
|
11712
11892
|
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils44.hexlify)(c)));
|
11713
11893
|
const predicateRoot = (0, import_hasher9.hash)((0, import_utils44.concat)(["0x4655454C", codeRoot]));
|
11714
11894
|
return predicateRoot;
|
11715
|
-
};
|
11895
|
+
}, "getPredicateRoot");
|
11716
11896
|
|
11717
11897
|
// src/predicate/predicate.ts
|
11718
|
-
var Predicate = class extends Account {
|
11898
|
+
var Predicate = class _Predicate extends Account {
|
11899
|
+
static {
|
11900
|
+
__name(this, "Predicate");
|
11901
|
+
}
|
11719
11902
|
bytes;
|
11720
11903
|
predicateData = [];
|
11721
11904
|
interface;
|
@@ -11737,7 +11920,7 @@ var Predicate = class extends Account {
|
|
11737
11920
|
data,
|
11738
11921
|
configurableConstants
|
11739
11922
|
}) {
|
11740
|
-
const { predicateBytes, predicateInterface } =
|
11923
|
+
const { predicateBytes, predicateInterface } = _Predicate.processPredicateData(
|
11741
11924
|
bytecode,
|
11742
11925
|
abi,
|
11743
11926
|
configurableConstants
|
@@ -11806,7 +11989,7 @@ var Predicate = class extends Account {
|
|
11806
11989
|
* @returns A new Predicate instance with the same bytecode, ABI and provider but with the ability to set the data and configurable constants.
|
11807
11990
|
*/
|
11808
11991
|
toNewInstance(overrides = {}) {
|
11809
|
-
return new
|
11992
|
+
return new _Predicate({
|
11810
11993
|
bytecode: this.initialBytecode,
|
11811
11994
|
abi: this.interface.jsonAbi,
|
11812
11995
|
provider: this.provider,
|
@@ -11826,13 +12009,13 @@ var Predicate = class extends Account {
|
|
11826
12009
|
let predicateBytes = (0, import_utils45.arrayify)(bytes);
|
11827
12010
|
const abiInterface = new import_abi_coder8.Interface(jsonAbi);
|
11828
12011
|
if (abiInterface.functions.main === void 0) {
|
11829
|
-
throw new
|
11830
|
-
|
12012
|
+
throw new import_errors32.FuelError(
|
12013
|
+
import_errors32.ErrorCode.ABI_MAIN_METHOD_MISSING,
|
11831
12014
|
'Cannot use ABI without "main" function.'
|
11832
12015
|
);
|
11833
12016
|
}
|
11834
12017
|
if (configurableConstants && Object.keys(configurableConstants).length) {
|
11835
|
-
predicateBytes =
|
12018
|
+
predicateBytes = _Predicate.setConfigurableConstants(
|
11836
12019
|
predicateBytes,
|
11837
12020
|
configurableConstants,
|
11838
12021
|
abiInterface
|
@@ -11887,15 +12070,15 @@ var Predicate = class extends Account {
|
|
11887
12070
|
const mutatedBytes = bytes;
|
11888
12071
|
try {
|
11889
12072
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
11890
|
-
throw new
|
11891
|
-
|
12073
|
+
throw new import_errors32.FuelError(
|
12074
|
+
import_errors32.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
11892
12075
|
"Predicate has no configurable constants to be set"
|
11893
12076
|
);
|
11894
12077
|
}
|
11895
12078
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
11896
12079
|
if (!abiInterface?.configurables[key]) {
|
11897
|
-
throw new
|
11898
|
-
|
12080
|
+
throw new import_errors32.FuelError(
|
12081
|
+
import_errors32.ErrorCode.CONFIGURABLE_NOT_FOUND,
|
11899
12082
|
`No configurable constant named '${key}' found in the Predicate`
|
11900
12083
|
);
|
11901
12084
|
}
|
@@ -11904,8 +12087,8 @@ var Predicate = class extends Account {
|
|
11904
12087
|
mutatedBytes.set(encoded, offset);
|
11905
12088
|
});
|
11906
12089
|
} catch (err) {
|
11907
|
-
throw new
|
11908
|
-
|
12090
|
+
throw new import_errors32.FuelError(
|
12091
|
+
import_errors32.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
11909
12092
|
`Error setting configurable constants: ${err.message}.`
|
11910
12093
|
);
|
11911
12094
|
}
|
@@ -11947,12 +12130,12 @@ var Predicate = class extends Account {
|
|
11947
12130
|
deployer: account,
|
11948
12131
|
abi: this.interface.jsonAbi,
|
11949
12132
|
bytecode: this.bytes,
|
11950
|
-
loaderInstanceCallback: (loaderBytecode, newAbi) => new
|
12133
|
+
loaderInstanceCallback: /* @__PURE__ */ __name((loaderBytecode, newAbi) => new _Predicate({
|
11951
12134
|
bytecode: loaderBytecode,
|
11952
12135
|
abi: newAbi,
|
11953
12136
|
provider: this.provider,
|
11954
12137
|
data: this.predicateData
|
11955
|
-
})
|
12138
|
+
}), "loaderInstanceCallback")
|
11956
12139
|
});
|
11957
12140
|
}
|
11958
12141
|
};
|
@@ -11961,7 +12144,7 @@ var Predicate = class extends Account {
|
|
11961
12144
|
var import_errors34 = require("@fuel-ts/errors");
|
11962
12145
|
|
11963
12146
|
// src/connectors/fuel-connector.ts
|
11964
|
-
var
|
12147
|
+
var import_errors33 = require("@fuel-ts/errors");
|
11965
12148
|
var import_events2 = require("events");
|
11966
12149
|
|
11967
12150
|
// src/connectors/types/connector-types.ts
|
@@ -12003,6 +12186,9 @@ var FuelConnectorEventType = "FuelConnector";
|
|
12003
12186
|
|
12004
12187
|
// src/connectors/types/local-storage.ts
|
12005
12188
|
var LocalStorage = class {
|
12189
|
+
static {
|
12190
|
+
__name(this, "LocalStorage");
|
12191
|
+
}
|
12006
12192
|
storage;
|
12007
12193
|
constructor(localStorage) {
|
12008
12194
|
this.storage = localStorage;
|
@@ -12023,6 +12209,9 @@ var LocalStorage = class {
|
|
12023
12209
|
|
12024
12210
|
// src/connectors/fuel-connector.ts
|
12025
12211
|
var FuelConnector = class extends import_events2.EventEmitter {
|
12212
|
+
static {
|
12213
|
+
__name(this, "FuelConnector");
|
12214
|
+
}
|
12026
12215
|
name = "";
|
12027
12216
|
metadata = {};
|
12028
12217
|
connected = false;
|
@@ -12036,7 +12225,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12036
12225
|
* @returns Always true.
|
12037
12226
|
*/
|
12038
12227
|
async ping() {
|
12039
|
-
throw new
|
12228
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12040
12229
|
}
|
12041
12230
|
/**
|
12042
12231
|
* Should return the current version of the connector
|
@@ -12045,7 +12234,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12045
12234
|
* @returns boolean - connection status.
|
12046
12235
|
*/
|
12047
12236
|
async version() {
|
12048
|
-
throw new
|
12237
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12049
12238
|
}
|
12050
12239
|
/**
|
12051
12240
|
* Should return true if the connector is connected
|
@@ -12054,7 +12243,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12054
12243
|
* @returns The connection status.
|
12055
12244
|
*/
|
12056
12245
|
async isConnected() {
|
12057
|
-
throw new
|
12246
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12058
12247
|
}
|
12059
12248
|
/**
|
12060
12249
|
* Should return all the accounts authorized for the
|
@@ -12063,7 +12252,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12063
12252
|
* @returns The accounts addresses strings
|
12064
12253
|
*/
|
12065
12254
|
async accounts() {
|
12066
|
-
throw new
|
12255
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12067
12256
|
}
|
12068
12257
|
/**
|
12069
12258
|
* Should start the connection process and return
|
@@ -12075,7 +12264,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12075
12264
|
* @returns boolean - connection status.
|
12076
12265
|
*/
|
12077
12266
|
async connect() {
|
12078
|
-
throw new
|
12267
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12079
12268
|
}
|
12080
12269
|
/**
|
12081
12270
|
* Should disconnect the current connection and
|
@@ -12085,7 +12274,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12085
12274
|
* @returns The connection status.
|
12086
12275
|
*/
|
12087
12276
|
async disconnect() {
|
12088
|
-
throw new
|
12277
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12089
12278
|
}
|
12090
12279
|
/**
|
12091
12280
|
* Should start the sign message process and return
|
@@ -12097,7 +12286,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12097
12286
|
* @returns Message signature
|
12098
12287
|
*/
|
12099
12288
|
async signMessage(_address, _message) {
|
12100
|
-
throw new
|
12289
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12101
12290
|
}
|
12102
12291
|
/**
|
12103
12292
|
* Should start the sign transaction process and return
|
@@ -12109,7 +12298,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12109
12298
|
* @returns Transaction signature
|
12110
12299
|
*/
|
12111
12300
|
async signTransaction(_address, _transaction) {
|
12112
|
-
throw new
|
12301
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12113
12302
|
}
|
12114
12303
|
/**
|
12115
12304
|
* Should start the send transaction process and return
|
@@ -12125,7 +12314,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12125
12314
|
* @returns The transaction id or transaction response
|
12126
12315
|
*/
|
12127
12316
|
async sendTransaction(_address, _transaction, _params) {
|
12128
|
-
throw new
|
12317
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12129
12318
|
}
|
12130
12319
|
/**
|
12131
12320
|
* Should return the current account selected inside the connector, if the account
|
@@ -12136,7 +12325,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12136
12325
|
* @returns The current account selected otherwise null.
|
12137
12326
|
*/
|
12138
12327
|
async currentAccount() {
|
12139
|
-
throw new
|
12328
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12140
12329
|
}
|
12141
12330
|
/**
|
12142
12331
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -12150,7 +12339,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12150
12339
|
* @returns True if the asset was added successfully
|
12151
12340
|
*/
|
12152
12341
|
async addAssets(_assets) {
|
12153
|
-
throw new
|
12342
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12154
12343
|
}
|
12155
12344
|
/**
|
12156
12345
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -12164,7 +12353,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12164
12353
|
* @returns True if the asset was added successfully
|
12165
12354
|
*/
|
12166
12355
|
async addAsset(_asset) {
|
12167
|
-
throw new
|
12356
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12168
12357
|
}
|
12169
12358
|
/**
|
12170
12359
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -12172,7 +12361,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12172
12361
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
12173
12362
|
*/
|
12174
12363
|
async assets() {
|
12175
|
-
throw new
|
12364
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12176
12365
|
}
|
12177
12366
|
/**
|
12178
12367
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -12183,7 +12372,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12183
12372
|
* @returns Return true if the network was added successfully
|
12184
12373
|
*/
|
12185
12374
|
async addNetwork(_networkUrl) {
|
12186
|
-
throw new
|
12375
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12187
12376
|
}
|
12188
12377
|
/**
|
12189
12378
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -12194,7 +12383,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12194
12383
|
* @returns Return true if the network was added successfully
|
12195
12384
|
*/
|
12196
12385
|
async selectNetwork(_network) {
|
12197
|
-
throw new
|
12386
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12198
12387
|
}
|
12199
12388
|
/**
|
12200
12389
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -12202,7 +12391,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12202
12391
|
* @returns Return all the networks added to the connector.
|
12203
12392
|
*/
|
12204
12393
|
async networks() {
|
12205
|
-
throw new
|
12394
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12206
12395
|
}
|
12207
12396
|
/**
|
12208
12397
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -12210,7 +12399,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12210
12399
|
* @returns Return the current network selected inside the connector.
|
12211
12400
|
*/
|
12212
12401
|
async currentNetwork() {
|
12213
|
-
throw new
|
12402
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12214
12403
|
}
|
12215
12404
|
/**
|
12216
12405
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -12220,7 +12409,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12220
12409
|
* @returns Return true if the ABI was added successfully.
|
12221
12410
|
*/
|
12222
12411
|
async addABI(_contractId, _abi) {
|
12223
|
-
throw new
|
12412
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12224
12413
|
}
|
12225
12414
|
/**
|
12226
12415
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -12229,7 +12418,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12229
12418
|
* @returns The ABI if it exists, otherwise return null.
|
12230
12419
|
*/
|
12231
12420
|
async getABI(_id) {
|
12232
|
-
throw new
|
12421
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12233
12422
|
}
|
12234
12423
|
/**
|
12235
12424
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -12238,7 +12427,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
12238
12427
|
* @returns Returns true if the abi exists or false if not.
|
12239
12428
|
*/
|
12240
12429
|
async hasABI(_id) {
|
12241
|
-
throw new
|
12430
|
+
throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
12242
12431
|
}
|
12243
12432
|
/**
|
12244
12433
|
* Event listener for the connector.
|
@@ -12271,6 +12460,7 @@ function cacheFor(fn, { cache: cache2, cacheTime, key }) {
|
|
12271
12460
|
return result;
|
12272
12461
|
};
|
12273
12462
|
}
|
12463
|
+
__name(cacheFor, "cacheFor");
|
12274
12464
|
|
12275
12465
|
// src/connectors/utils/dispatch-fuel-connector-event.ts
|
12276
12466
|
function dispatchFuelConnectorEvent(connector) {
|
@@ -12280,37 +12470,24 @@ function dispatchFuelConnectorEvent(connector) {
|
|
12280
12470
|
})
|
12281
12471
|
);
|
12282
12472
|
}
|
12283
|
-
|
12284
|
-
// src/connectors/utils/promises.ts
|
12285
|
-
var import_errors33 = require("@fuel-ts/errors");
|
12286
|
-
function deferPromise() {
|
12287
|
-
const defer = {};
|
12288
|
-
defer.promise = new Promise((resolve, reject) => {
|
12289
|
-
defer.reject = reject;
|
12290
|
-
defer.resolve = resolve;
|
12291
|
-
});
|
12292
|
-
return defer;
|
12293
|
-
}
|
12294
|
-
async function withTimeout(promise, timeout = 1050) {
|
12295
|
-
const timeoutPromise = new Promise((resolve, reject) => {
|
12296
|
-
setTimeout(() => {
|
12297
|
-
reject(new import_errors33.FuelError(import_errors33.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
12298
|
-
}, timeout);
|
12299
|
-
});
|
12300
|
-
return Promise.race([timeoutPromise, promise]);
|
12301
|
-
}
|
12473
|
+
__name(dispatchFuelConnectorEvent, "dispatchFuelConnectorEvent");
|
12302
12474
|
|
12303
12475
|
// src/connectors/fuel.ts
|
12304
12476
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
12305
12477
|
var PING_CACHE_TIME = 5e3;
|
12306
12478
|
var { warn } = console;
|
12307
|
-
var
|
12479
|
+
var Fuel = class _Fuel extends FuelConnector {
|
12480
|
+
static {
|
12481
|
+
__name(this, "Fuel");
|
12482
|
+
}
|
12483
|
+
static STORAGE_KEY = "fuel-current-connector";
|
12484
|
+
static defaultConfig = {};
|
12308
12485
|
_storage = null;
|
12309
12486
|
_connectors = [];
|
12310
12487
|
_targetObject = null;
|
12311
12488
|
_unsubscribes = [];
|
12312
|
-
_targetUnsubscribe = () => {
|
12313
|
-
};
|
12489
|
+
_targetUnsubscribe = /* @__PURE__ */ __name(() => {
|
12490
|
+
}, "_targetUnsubscribe");
|
12314
12491
|
_pingCache = {};
|
12315
12492
|
_currentConnector;
|
12316
12493
|
_initializationPromise = null;
|
@@ -12383,7 +12560,7 @@ var _Fuel = class extends FuelConnector {
|
|
12383
12560
|
const currentConnector = this._currentConnector;
|
12384
12561
|
this._unsubscribes.map((unSub) => unSub());
|
12385
12562
|
this._unsubscribes = events.map((event) => {
|
12386
|
-
const handler = (...args) => this.emit(event, ...args);
|
12563
|
+
const handler = /* @__PURE__ */ __name((...args) => this.emit(event, ...args), "handler");
|
12387
12564
|
currentConnector.on(event, handler);
|
12388
12565
|
return () => currentConnector.off(event, handler);
|
12389
12566
|
});
|
@@ -12467,7 +12644,7 @@ var _Fuel = class extends FuelConnector {
|
|
12467
12644
|
* Setup a listener for the FuelConnector event and add the connector
|
12468
12645
|
* to the list of new connectors.
|
12469
12646
|
*/
|
12470
|
-
setupConnectorListener = () => {
|
12647
|
+
setupConnectorListener = /* @__PURE__ */ __name(() => {
|
12471
12648
|
const { _targetObject: targetObject } = this;
|
12472
12649
|
const eventName = FuelConnectorEventType;
|
12473
12650
|
if (targetObject?.on) {
|
@@ -12477,9 +12654,9 @@ var _Fuel = class extends FuelConnector {
|
|
12477
12654
|
};
|
12478
12655
|
}
|
12479
12656
|
if (targetObject?.addEventListener) {
|
12480
|
-
const handler = (e) => {
|
12657
|
+
const handler = /* @__PURE__ */ __name((e) => {
|
12481
12658
|
this.addConnector(e.detail);
|
12482
|
-
};
|
12659
|
+
}, "handler");
|
12483
12660
|
targetObject.addEventListener(eventName, handler);
|
12484
12661
|
return () => {
|
12485
12662
|
targetObject.removeEventListener?.(eventName, handler);
|
@@ -12487,11 +12664,11 @@ var _Fuel = class extends FuelConnector {
|
|
12487
12664
|
}
|
12488
12665
|
return () => {
|
12489
12666
|
};
|
12490
|
-
};
|
12667
|
+
}, "setupConnectorListener");
|
12491
12668
|
/**
|
12492
12669
|
* Add a new connector to the list of connectors.
|
12493
12670
|
*/
|
12494
|
-
addConnector = async (connector) => {
|
12671
|
+
addConnector = /* @__PURE__ */ __name(async (connector) => {
|
12495
12672
|
if (!this.getConnector(connector)) {
|
12496
12673
|
this._connectors.push(connector);
|
12497
12674
|
}
|
@@ -12502,8 +12679,8 @@ var _Fuel = class extends FuelConnector {
|
|
12502
12679
|
emitEvents: false
|
12503
12680
|
});
|
12504
12681
|
}
|
12505
|
-
};
|
12506
|
-
triggerConnectorEvents = async () => {
|
12682
|
+
}, "addConnector");
|
12683
|
+
triggerConnectorEvents = /* @__PURE__ */ __name(async () => {
|
12507
12684
|
const [isConnected, networks2, currentNetwork] = await Promise.all([
|
12508
12685
|
this.isConnected(),
|
12509
12686
|
this.networks(),
|
@@ -12520,14 +12697,14 @@ var _Fuel = class extends FuelConnector {
|
|
12520
12697
|
this.emit(this.events.accounts, accounts);
|
12521
12698
|
this.emit(this.events.currentAccount, currentAccount);
|
12522
12699
|
}
|
12523
|
-
};
|
12700
|
+
}, "triggerConnectorEvents");
|
12524
12701
|
/**
|
12525
12702
|
* Get a connector from the list of connectors.
|
12526
12703
|
*/
|
12527
|
-
getConnector = (connector) => this._connectors.find((c) => {
|
12704
|
+
getConnector = /* @__PURE__ */ __name((connector) => this._connectors.find((c) => {
|
12528
12705
|
const connectorName = typeof connector === "string" ? connector : connector.name;
|
12529
12706
|
return c.name === connectorName || c === connector;
|
12530
|
-
}) || null;
|
12707
|
+
}) || null, "getConnector");
|
12531
12708
|
/**
|
12532
12709
|
* Return the list of connectors with the status of installed and connected.
|
12533
12710
|
*/
|
@@ -12644,9 +12821,6 @@ var _Fuel = class extends FuelConnector {
|
|
12644
12821
|
await this.clean();
|
12645
12822
|
}
|
12646
12823
|
};
|
12647
|
-
var Fuel = _Fuel;
|
12648
|
-
__publicField(Fuel, "STORAGE_KEY", "fuel-current-connector");
|
12649
|
-
__publicField(Fuel, "defaultConfig", {});
|
12650
12824
|
// Annotate the CommonJS export names for ESM import in node:
|
12651
12825
|
0 && (module.exports = {
|
12652
12826
|
AbstractAccount,
|
@@ -12676,6 +12850,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
12676
12850
|
MemoryStorage,
|
12677
12851
|
Mnemonic,
|
12678
12852
|
MnemonicVault,
|
12853
|
+
NON_PAGINATED_BALANCES_SIZE,
|
12679
12854
|
NoWitnessAtIndexError,
|
12680
12855
|
NoWitnessByOwnerError,
|
12681
12856
|
OperationName,
|