@fuel-ts/account 0.100.1 → 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 +3744 -1865
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +678 -529
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +678 -530
- 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 +14 -14
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/utils/serialization.d.ts.map +1 -1
- package/dist/test-utils.global.js +3188 -1718
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +495 -374
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +496 -375
- 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,7 +913,7 @@ 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");
|
@@ -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,7 +957,7 @@ 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");
|
@@ -1003,6 +980,7 @@ function deferPromise() {
|
|
1003
980
|
});
|
1004
981
|
return defer;
|
1005
982
|
}
|
983
|
+
__name(deferPromise, "deferPromise");
|
1006
984
|
async function withTimeout(promise, timeout = 1050) {
|
1007
985
|
const timeoutPromise = new Promise((resolve, reject) => {
|
1008
986
|
setTimeout(() => {
|
@@ -1011,6 +989,7 @@ async function withTimeout(promise, timeout = 1050) {
|
|
1011
989
|
});
|
1012
990
|
return Promise.race([timeoutPromise, promise]);
|
1013
991
|
}
|
992
|
+
__name(withTimeout, "withTimeout");
|
1014
993
|
|
1015
994
|
// src/providers/__generated__/operations.ts
|
1016
995
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
@@ -1503,6 +1482,11 @@ var NodeInfoFragmentDoc = import_graphql_tag.default`
|
|
1503
1482
|
maxTx
|
1504
1483
|
maxDepth
|
1505
1484
|
nodeVersion
|
1485
|
+
indexation {
|
1486
|
+
balances
|
1487
|
+
coinsToSpend
|
1488
|
+
assetMetadata
|
1489
|
+
}
|
1506
1490
|
}
|
1507
1491
|
`;
|
1508
1492
|
var RelayedTransactionStatusFragmentDoc = import_graphql_tag.default`
|
@@ -1784,7 +1768,7 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
1784
1768
|
}
|
1785
1769
|
`;
|
1786
1770
|
var GetBalancesV2Document = import_graphql_tag.default`
|
1787
|
-
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!) {
|
1788
1772
|
balances(
|
1789
1773
|
filter: $filter
|
1790
1774
|
after: $after
|
@@ -1792,7 +1776,7 @@ var GetBalancesV2Document = import_graphql_tag.default`
|
|
1792
1776
|
first: $first
|
1793
1777
|
last: $last
|
1794
1778
|
) {
|
1795
|
-
pageInfo {
|
1779
|
+
pageInfo @include(if: $supportsPagination) {
|
1796
1780
|
...pageInfoFragment
|
1797
1781
|
}
|
1798
1782
|
edges {
|
@@ -2062,6 +2046,7 @@ function getSdk(requester) {
|
|
2062
2046
|
}
|
2063
2047
|
};
|
2064
2048
|
}
|
2049
|
+
__name(getSdk, "getSdk");
|
2065
2050
|
|
2066
2051
|
// src/providers/fuel-graphql-subscriber.ts
|
2067
2052
|
var import_errors3 = require("@fuel-ts/errors");
|
@@ -2069,7 +2054,7 @@ var import_graphql = require("graphql");
|
|
2069
2054
|
|
2070
2055
|
// src/providers/utils/handle-gql-error-message.ts
|
2071
2056
|
var import_errors2 = require("@fuel-ts/errors");
|
2072
|
-
var mapGqlErrorMessage = (error) => {
|
2057
|
+
var mapGqlErrorMessage = /* @__PURE__ */ __name((error) => {
|
2073
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)) {
|
2074
2059
|
return new import_errors2.FuelError(
|
2075
2060
|
import_errors2.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
@@ -2087,8 +2072,8 @@ var mapGqlErrorMessage = (error) => {
|
|
2087
2072
|
);
|
2088
2073
|
}
|
2089
2074
|
return new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
2090
|
-
};
|
2091
|
-
var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
|
2075
|
+
}, "mapGqlErrorMessage");
|
2076
|
+
var mapGqlErrorWithIncompatibleNodeVersion = /* @__PURE__ */ __name((error, incompatibleNodeVersionMessage) => {
|
2092
2077
|
if (!incompatibleNodeVersionMessage) {
|
2093
2078
|
return error;
|
2094
2079
|
}
|
@@ -2100,8 +2085,8 @@ ${incompatibleNodeVersionMessage}`,
|
|
2100
2085
|
error.metadata,
|
2101
2086
|
error.rawError
|
2102
2087
|
);
|
2103
|
-
};
|
2104
|
-
var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = false) => {
|
2088
|
+
}, "mapGqlErrorWithIncompatibleNodeVersion");
|
2089
|
+
var assertGqlResponseHasNoErrors = /* @__PURE__ */ __name((errors, incompatibleNodeVersionMessage = false) => {
|
2105
2090
|
if (!Array.isArray(errors)) {
|
2106
2091
|
return;
|
2107
2092
|
}
|
@@ -2114,13 +2099,18 @@ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = fal
|
|
2114
2099
|
new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
2115
2100
|
incompatibleNodeVersionMessage
|
2116
2101
|
);
|
2117
|
-
};
|
2102
|
+
}, "assertGqlResponseHasNoErrors");
|
2118
2103
|
|
2119
2104
|
// src/providers/fuel-graphql-subscriber.ts
|
2120
|
-
var
|
2105
|
+
var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
2121
2106
|
constructor(stream) {
|
2122
2107
|
this.stream = stream;
|
2123
2108
|
}
|
2109
|
+
static {
|
2110
|
+
__name(this, "FuelGraphqlSubscriber");
|
2111
|
+
}
|
2112
|
+
static incompatibleNodeVersionMessage = false;
|
2113
|
+
static textDecoder = new TextDecoder();
|
2124
2114
|
static async create(options) {
|
2125
2115
|
const { url, query, variables, fetchFn } = options;
|
2126
2116
|
const response = await fetchFn(`${url}-sub`, {
|
@@ -2181,9 +2171,6 @@ var _FuelGraphqlSubscriber = class {
|
|
2181
2171
|
return this;
|
2182
2172
|
}
|
2183
2173
|
};
|
2184
|
-
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
2185
|
-
__publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
|
2186
|
-
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
2187
2174
|
|
2188
2175
|
// src/providers/resource-cache.ts
|
2189
2176
|
var import_errors14 = require("@fuel-ts/errors");
|
@@ -2196,7 +2183,7 @@ var import_errors4 = require("@fuel-ts/errors");
|
|
2196
2183
|
var import_math2 = require("@fuel-ts/math");
|
2197
2184
|
var import_transactions = require("@fuel-ts/transactions");
|
2198
2185
|
var import_utils3 = require("@fuel-ts/utils");
|
2199
|
-
var inputify = (value) => {
|
2186
|
+
var inputify = /* @__PURE__ */ __name((value) => {
|
2200
2187
|
const { type } = value;
|
2201
2188
|
switch (value.type) {
|
2202
2189
|
case import_transactions.InputType.Coin: {
|
@@ -2262,7 +2249,7 @@ var inputify = (value) => {
|
|
2262
2249
|
);
|
2263
2250
|
}
|
2264
2251
|
}
|
2265
|
-
};
|
2252
|
+
}, "inputify");
|
2266
2253
|
|
2267
2254
|
// src/providers/transaction-request/output.ts
|
2268
2255
|
var import_configs2 = require("@fuel-ts/address/configs");
|
@@ -2270,7 +2257,7 @@ var import_errors5 = require("@fuel-ts/errors");
|
|
2270
2257
|
var import_math3 = require("@fuel-ts/math");
|
2271
2258
|
var import_transactions2 = require("@fuel-ts/transactions");
|
2272
2259
|
var import_utils4 = require("@fuel-ts/utils");
|
2273
|
-
var outputify = (value) => {
|
2260
|
+
var outputify = /* @__PURE__ */ __name((value) => {
|
2274
2261
|
const { type } = value;
|
2275
2262
|
switch (type) {
|
2276
2263
|
case import_transactions2.OutputType.Coin: {
|
@@ -2319,7 +2306,7 @@ var outputify = (value) => {
|
|
2319
2306
|
);
|
2320
2307
|
}
|
2321
2308
|
}
|
2322
|
-
};
|
2309
|
+
}, "outputify");
|
2323
2310
|
|
2324
2311
|
// src/providers/transaction-request/transaction-request.ts
|
2325
2312
|
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
@@ -2332,13 +2319,13 @@ var import_transactions8 = require("@fuel-ts/transactions");
|
|
2332
2319
|
var import_utils10 = require("@fuel-ts/utils");
|
2333
2320
|
|
2334
2321
|
// src/providers/message.ts
|
2335
|
-
var isMessageCoin = (message) => !("data" in message);
|
2322
|
+
var isMessageCoin = /* @__PURE__ */ __name((message) => !("data" in message), "isMessageCoin");
|
2336
2323
|
|
2337
2324
|
// src/providers/resource.ts
|
2338
|
-
var isRawCoin = (resource) => "utxoId" in resource;
|
2339
|
-
var isRawMessage = (resource) => "recipient" in resource;
|
2340
|
-
var isCoin = (resource) => "id" in resource;
|
2341
|
-
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");
|
2342
2329
|
|
2343
2330
|
// src/providers/utils/receipts.ts
|
2344
2331
|
var import_transactions4 = require("@fuel-ts/transactions");
|
@@ -2350,7 +2337,7 @@ var import_errors6 = require("@fuel-ts/errors");
|
|
2350
2337
|
var import_math4 = require("@fuel-ts/math");
|
2351
2338
|
var import_transactions3 = require("@fuel-ts/transactions");
|
2352
2339
|
var import_utils5 = require("@fuel-ts/utils");
|
2353
|
-
var deserializeChain = (chain) => {
|
2340
|
+
var deserializeChain = /* @__PURE__ */ __name((chain) => {
|
2354
2341
|
const { name, daHeight, consensusParameters } = chain;
|
2355
2342
|
const {
|
2356
2343
|
contractParams,
|
@@ -2404,8 +2391,8 @@ var deserializeChain = (chain) => {
|
|
2404
2391
|
gasCosts
|
2405
2392
|
}
|
2406
2393
|
};
|
2407
|
-
};
|
2408
|
-
var serializeChain = (chain) => {
|
2394
|
+
}, "deserializeChain");
|
2395
|
+
var serializeChain = /* @__PURE__ */ __name((chain) => {
|
2409
2396
|
const { name, baseChainHeight, consensusParameters } = chain;
|
2410
2397
|
const {
|
2411
2398
|
contractParameters,
|
@@ -2459,39 +2446,41 @@ var serializeChain = (chain) => {
|
|
2459
2446
|
gasCosts
|
2460
2447
|
}
|
2461
2448
|
};
|
2462
|
-
};
|
2463
|
-
var deserializeNodeInfo = (nodeInfo) => {
|
2464
|
-
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
2449
|
+
}, "serializeChain");
|
2450
|
+
var deserializeNodeInfo = /* @__PURE__ */ __name((nodeInfo) => {
|
2451
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace, indexation } = nodeInfo;
|
2465
2452
|
return {
|
2466
2453
|
maxDepth: (0, import_math4.bn)(maxDepth),
|
2467
2454
|
maxTx: (0, import_math4.bn)(maxTx),
|
2468
2455
|
nodeVersion,
|
2469
2456
|
utxoValidation,
|
2470
|
-
vmBacktrace
|
2457
|
+
vmBacktrace,
|
2458
|
+
indexation
|
2471
2459
|
};
|
2472
|
-
};
|
2473
|
-
var serializeNodeInfo = (nodeInfo) => {
|
2474
|
-
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
2460
|
+
}, "deserializeNodeInfo");
|
2461
|
+
var serializeNodeInfo = /* @__PURE__ */ __name((nodeInfo) => {
|
2462
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace, indexation } = nodeInfo;
|
2475
2463
|
return {
|
2476
2464
|
maxDepth: maxDepth.toString(),
|
2477
2465
|
maxTx: maxTx.toString(),
|
2478
2466
|
nodeVersion,
|
2479
2467
|
utxoValidation,
|
2480
|
-
vmBacktrace
|
2468
|
+
vmBacktrace,
|
2469
|
+
indexation
|
2481
2470
|
};
|
2482
|
-
};
|
2483
|
-
var deserializeProviderCache = (cache2) => ({
|
2471
|
+
}, "serializeNodeInfo");
|
2472
|
+
var deserializeProviderCache = /* @__PURE__ */ __name((cache2) => ({
|
2484
2473
|
consensusParametersTimestamp: cache2.consensusParametersTimestamp,
|
2485
2474
|
chain: deserializeChain(cache2.chain),
|
2486
2475
|
nodeInfo: deserializeNodeInfo(cache2.nodeInfo)
|
2487
|
-
});
|
2488
|
-
var serializeProviderCache = async (provider) => ({
|
2476
|
+
}), "deserializeProviderCache");
|
2477
|
+
var serializeProviderCache = /* @__PURE__ */ __name(async (provider) => ({
|
2489
2478
|
consensusParametersTimestamp: provider.consensusParametersTimestamp,
|
2490
2479
|
chain: serializeChain(await provider.getChain()),
|
2491
2480
|
nodeInfo: serializeNodeInfo(await provider.getNode())
|
2492
|
-
});
|
2493
|
-
var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
|
2494
|
-
var deserializeReceipt = (receipt) => {
|
2481
|
+
}), "serializeProviderCache");
|
2482
|
+
var hexOrZero = /* @__PURE__ */ __name((hex) => hex || import_configs3.ZeroBytes32, "hexOrZero");
|
2483
|
+
var deserializeReceipt = /* @__PURE__ */ __name((receipt) => {
|
2495
2484
|
const { receiptType } = receipt;
|
2496
2485
|
switch (receiptType) {
|
2497
2486
|
case "CALL" /* Call */: {
|
@@ -2683,12 +2672,12 @@ var deserializeReceipt = (receipt) => {
|
|
2683
2672
|
default:
|
2684
2673
|
throw new import_errors6.FuelError(import_errors6.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
2685
2674
|
}
|
2686
|
-
};
|
2675
|
+
}, "deserializeReceipt");
|
2687
2676
|
|
2688
2677
|
// src/providers/utils/receipts.ts
|
2689
|
-
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions4.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
2690
|
-
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions4.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
2691
|
-
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(
|
2692
2681
|
(memo, receipt) => {
|
2693
2682
|
if (doesReceiptHaveMissingOutputVariables(receipt)) {
|
2694
2683
|
memo.missingOutputVariables.push(receipt);
|
@@ -2702,13 +2691,13 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
|
2702
2691
|
missingOutputVariables: [],
|
2703
2692
|
missingOutputContractIds: []
|
2704
2693
|
}
|
2705
|
-
);
|
2706
|
-
var assembleReceiptByType = (gqlReceipt) => deserializeReceipt(gqlReceipt);
|
2694
|
+
), "getReceiptsWithMissingData");
|
2695
|
+
var assembleReceiptByType = /* @__PURE__ */ __name((gqlReceipt) => deserializeReceipt(gqlReceipt), "assembleReceiptByType");
|
2707
2696
|
|
2708
2697
|
// src/providers/utils/block-explorer.ts
|
2709
2698
|
var import_errors7 = require("@fuel-ts/errors");
|
2710
2699
|
var DEFAULT_BLOCK_EXPLORER_URL = "https://app.fuel.network";
|
2711
|
-
var getPathFromInput = (key, value) => {
|
2700
|
+
var getPathFromInput = /* @__PURE__ */ __name((key, value) => {
|
2712
2701
|
const pathMap = {
|
2713
2702
|
address: `address`,
|
2714
2703
|
txId: `transaction`,
|
@@ -2716,8 +2705,8 @@ var getPathFromInput = (key, value) => {
|
|
2716
2705
|
};
|
2717
2706
|
const path = pathMap[key] || key;
|
2718
2707
|
return `${path}/${value}`;
|
2719
|
-
};
|
2720
|
-
var buildBlockExplorerUrl = (options = {}) => {
|
2708
|
+
}, "getPathFromInput");
|
2709
|
+
var buildBlockExplorerUrl = /* @__PURE__ */ __name((options = {}) => {
|
2721
2710
|
const { blockExplorerUrl, path, providerUrl, address, txId, blockNumber } = options;
|
2722
2711
|
const explorerUrl = blockExplorerUrl || DEFAULT_BLOCK_EXPLORER_URL;
|
2723
2712
|
const customInputParams = [
|
@@ -2765,19 +2754,19 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
2765
2754
|
const providerUrlProtocol = cleanProviderUrl?.match(/^https?:\/\//) ? "" : "https://";
|
2766
2755
|
const url = `${protocol}${cleanBlockExplorerUrl}/${cleanPath}${encodedProviderUrl ? `?providerUrl=${providerUrlProtocol}${encodedProviderUrl}` : ""}`;
|
2767
2756
|
return url;
|
2768
|
-
};
|
2757
|
+
}, "buildBlockExplorerUrl");
|
2769
2758
|
|
2770
2759
|
// src/providers/utils/gas.ts
|
2771
2760
|
var import_math5 = require("@fuel-ts/math");
|
2772
2761
|
var import_transactions5 = require("@fuel-ts/transactions");
|
2773
2762
|
var import_utils6 = require("@fuel-ts/utils");
|
2774
|
-
var getGasUsedFromReceipts = (receipts) => {
|
2763
|
+
var getGasUsedFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
2775
2764
|
const scriptResult = receipts.filter(
|
2776
2765
|
(receipt) => receipt.type === import_transactions5.ReceiptType.ScriptResult
|
2777
2766
|
);
|
2778
2767
|
const gasUsed = scriptResult.reduce((prev, receipt) => prev.add(receipt.gasUsed), (0, import_math5.bn)(0));
|
2779
2768
|
return gasUsed;
|
2780
|
-
};
|
2769
|
+
}, "getGasUsedFromReceipts");
|
2781
2770
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
2782
2771
|
const base = (0, import_math5.bn)(gasDependentCost.base);
|
2783
2772
|
let dependentValue = (0, import_math5.bn)(0);
|
@@ -2788,6 +2777,7 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
2788
2777
|
}
|
2789
2778
|
return base.add(dependentValue);
|
2790
2779
|
}
|
2780
|
+
__name(resolveGasDependentCosts, "resolveGasDependentCosts");
|
2791
2781
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
2792
2782
|
const witnessCache = [];
|
2793
2783
|
const chargeableInputs = inputs.filter((input) => {
|
@@ -2814,6 +2804,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
|
2814
2804
|
}, (0, import_math5.bn)(0));
|
2815
2805
|
return totalGas;
|
2816
2806
|
}
|
2807
|
+
__name(gasUsedByInputs, "gasUsedByInputs");
|
2817
2808
|
function getMinGas(params) {
|
2818
2809
|
const { gasCosts, gasPerByte, inputs, metadataGas, txBytesSize } = params;
|
2819
2810
|
const vmInitGas = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
@@ -2822,6 +2813,7 @@ function getMinGas(params) {
|
|
2822
2813
|
const minGas = vmInitGas.add(bytesGas).add(inputsGas).add(metadataGas).maxU64();
|
2823
2814
|
return minGas;
|
2824
2815
|
}
|
2816
|
+
__name(getMinGas, "getMinGas");
|
2825
2817
|
function getMaxGas(params) {
|
2826
2818
|
const {
|
2827
2819
|
gasPerByte,
|
@@ -2838,6 +2830,7 @@ function getMaxGas(params) {
|
|
2838
2830
|
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
2839
2831
|
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
2840
2832
|
}
|
2833
|
+
__name(getMaxGas, "getMaxGas");
|
2841
2834
|
function calculateMetadataGasForTxCreate({
|
2842
2835
|
gasCosts,
|
2843
2836
|
stateRootSize,
|
@@ -2852,12 +2845,14 @@ function calculateMetadataGasForTxCreate({
|
|
2852
2845
|
const metadataGas = contractRootGas.add(stateRootGas).add(txIdGas).add(contractIdGas);
|
2853
2846
|
return metadataGas.maxU64();
|
2854
2847
|
}
|
2848
|
+
__name(calculateMetadataGasForTxCreate, "calculateMetadataGasForTxCreate");
|
2855
2849
|
function calculateMetadataGasForTxScript({
|
2856
2850
|
gasCosts,
|
2857
2851
|
txBytesSize
|
2858
2852
|
}) {
|
2859
2853
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2860
2854
|
}
|
2855
|
+
__name(calculateMetadataGasForTxScript, "calculateMetadataGasForTxScript");
|
2861
2856
|
function calculateMetadataGasForTxBlob({
|
2862
2857
|
gasCosts,
|
2863
2858
|
txBytesSize,
|
@@ -2867,6 +2862,7 @@ function calculateMetadataGasForTxBlob({
|
|
2867
2862
|
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
2868
2863
|
return txId.add(blobLen);
|
2869
2864
|
}
|
2865
|
+
__name(calculateMetadataGasForTxBlob, "calculateMetadataGasForTxBlob");
|
2870
2866
|
function calculateMetadataGasForTxUpgrade({
|
2871
2867
|
gasCosts,
|
2872
2868
|
txBytesSize,
|
@@ -2879,6 +2875,7 @@ function calculateMetadataGasForTxUpgrade({
|
|
2879
2875
|
}
|
2880
2876
|
return txId;
|
2881
2877
|
}
|
2878
|
+
__name(calculateMetadataGasForTxUpgrade, "calculateMetadataGasForTxUpgrade");
|
2882
2879
|
function calculateMetadataGasForTxUpload({
|
2883
2880
|
gasCosts,
|
2884
2881
|
txBytesSize,
|
@@ -2892,6 +2889,7 @@ function calculateMetadataGasForTxUpload({
|
|
2892
2889
|
txId.add(subsectionsLen);
|
2893
2890
|
return txId;
|
2894
2891
|
}
|
2892
|
+
__name(calculateMetadataGasForTxUpload, "calculateMetadataGasForTxUpload");
|
2895
2893
|
function calculateMinGasForTxUpload({
|
2896
2894
|
gasCosts,
|
2897
2895
|
baseMinGas,
|
@@ -2900,10 +2898,11 @@ function calculateMinGasForTxUpload({
|
|
2900
2898
|
const additionalStoragePerByte = (0, import_math5.bn)(gasCosts.newStoragePerByte).mul(subsectionSize);
|
2901
2899
|
return (0, import_math5.bn)(baseMinGas).add(additionalStoragePerByte);
|
2902
2900
|
}
|
2903
|
-
|
2901
|
+
__name(calculateMinGasForTxUpload, "calculateMinGasForTxUpload");
|
2902
|
+
var calculateGasFee = /* @__PURE__ */ __name((params) => {
|
2904
2903
|
const { gas, gasPrice, priceFactor, tip } = params;
|
2905
2904
|
return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
|
2906
|
-
};
|
2905
|
+
}, "calculateGasFee");
|
2907
2906
|
|
2908
2907
|
// src/providers/utils/json.ts
|
2909
2908
|
var import_utils7 = require("@fuel-ts/utils");
|
@@ -2932,16 +2931,18 @@ function normalize(object) {
|
|
2932
2931
|
});
|
2933
2932
|
return object;
|
2934
2933
|
}
|
2934
|
+
__name(normalize, "normalize");
|
2935
2935
|
function normalizeJSON(root) {
|
2936
2936
|
return normalize((0, import_ramda.clone)(root));
|
2937
2937
|
}
|
2938
|
+
__name(normalizeJSON, "normalizeJSON");
|
2938
2939
|
|
2939
2940
|
// src/providers/utils/extract-tx-error.ts
|
2940
2941
|
var import_errors8 = require("@fuel-ts/errors");
|
2941
2942
|
var import_math6 = require("@fuel-ts/math");
|
2942
2943
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2943
2944
|
var import_configs5 = require("@fuel-ts/transactions/configs");
|
2944
|
-
var assemblePanicError = (statusReason, metadata) => {
|
2945
|
+
var assemblePanicError = /* @__PURE__ */ __name((statusReason, metadata) => {
|
2945
2946
|
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
2946
2947
|
if (import_configs5.PANIC_REASONS.includes(statusReason)) {
|
2947
2948
|
errorMessage = `${errorMessage}
|
@@ -2954,9 +2955,9 @@ ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
|
|
2954
2955
|
...metadata,
|
2955
2956
|
reason: statusReason
|
2956
2957
|
});
|
2957
|
-
};
|
2958
|
-
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
2959
|
-
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) => {
|
2960
2961
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
2961
2962
|
const revertReceipt = receipts.find(({ type }) => type === import_transactions6.ReceiptType.Revert);
|
2962
2963
|
let reason = "";
|
@@ -3005,8 +3006,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
3005
3006
|
...metadata,
|
3006
3007
|
reason
|
3007
3008
|
});
|
3008
|
-
};
|
3009
|
-
var extractTxError = (params) => {
|
3009
|
+
}, "assembleRevertError");
|
3010
|
+
var extractTxError = /* @__PURE__ */ __name((params) => {
|
3010
3011
|
const { receipts, statusReason, logs } = params;
|
3011
3012
|
const isPanic = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Panic);
|
3012
3013
|
const isRevert = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Revert);
|
@@ -3021,10 +3022,13 @@ var extractTxError = (params) => {
|
|
3021
3022
|
return assemblePanicError(statusReason, metadata);
|
3022
3023
|
}
|
3023
3024
|
return assembleRevertError(receipts, logs, metadata);
|
3024
|
-
};
|
3025
|
+
}, "extractTxError");
|
3025
3026
|
|
3026
3027
|
// src/providers/transaction-request/errors.ts
|
3027
3028
|
var ChangeOutputCollisionError = class extends Error {
|
3029
|
+
static {
|
3030
|
+
__name(this, "ChangeOutputCollisionError");
|
3031
|
+
}
|
3028
3032
|
name = "ChangeOutputCollisionError";
|
3029
3033
|
message = 'A ChangeOutput with the same "assetId" already exists for a different "to" address';
|
3030
3034
|
};
|
@@ -3034,6 +3038,9 @@ var NoWitnessAtIndexError = class extends Error {
|
|
3034
3038
|
this.index = index;
|
3035
3039
|
this.message = `Witness at index "${index}" was not found`;
|
3036
3040
|
}
|
3041
|
+
static {
|
3042
|
+
__name(this, "NoWitnessAtIndexError");
|
3043
|
+
}
|
3037
3044
|
name = "NoWitnessAtIndexError";
|
3038
3045
|
};
|
3039
3046
|
var NoWitnessByOwnerError = class extends Error {
|
@@ -3042,6 +3049,9 @@ var NoWitnessByOwnerError = class extends Error {
|
|
3042
3049
|
this.owner = owner;
|
3043
3050
|
this.message = `A witness for the given owner "${owner}" was not found`;
|
3044
3051
|
}
|
3052
|
+
static {
|
3053
|
+
__name(this, "NoWitnessByOwnerError");
|
3054
|
+
}
|
3045
3055
|
name = "NoWitnessByOwnerError";
|
3046
3056
|
};
|
3047
3057
|
|
@@ -3050,15 +3060,15 @@ var import_errors9 = require("@fuel-ts/errors");
|
|
3050
3060
|
var import_math7 = require("@fuel-ts/math");
|
3051
3061
|
var import_transactions7 = require("@fuel-ts/transactions");
|
3052
3062
|
var import_utils8 = require("@fuel-ts/utils");
|
3053
|
-
var isRequestInputCoin = (input) => input.type === import_transactions7.InputType.Coin;
|
3054
|
-
var isRequestInputMessage = (input) => input.type === import_transactions7.InputType.Message;
|
3055
|
-
var isRequestInputMessageWithoutData = (input) => input.type === import_transactions7.InputType.Message && (0, import_math7.bn)(input.data).isZero();
|
3056
|
-
var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
3057
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
|
3058
|
-
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
3059
|
-
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
3060
|
-
var isPredicate = (input) => isRequestInputCoinOrMessage(input) && !!input.predicate && (0, import_utils8.hexlify)(input.predicate) !== "0x";
|
3061
|
-
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) => {
|
3062
3072
|
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
3063
3073
|
return acc.add(input.amount);
|
3064
3074
|
}
|
@@ -3066,8 +3076,8 @@ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filte
|
|
3066
3076
|
return acc.add(input.amount);
|
3067
3077
|
}
|
3068
3078
|
return acc;
|
3069
|
-
}, (0, import_math7.bn)(0));
|
3070
|
-
var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
|
3079
|
+
}, (0, import_math7.bn)(0)), "getAssetAmountInRequestInputs");
|
3080
|
+
var cacheRequestInputsResources = /* @__PURE__ */ __name((inputs) => inputs.filter(isRequestInputResource).reduce(
|
3071
3081
|
(cache2, input) => {
|
3072
3082
|
if (isRequestInputCoin(input)) {
|
3073
3083
|
cache2.utxos.push(input.id);
|
@@ -3080,8 +3090,8 @@ var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResour
|
|
3080
3090
|
utxos: [],
|
3081
3091
|
messages: []
|
3082
3092
|
}
|
3083
|
-
);
|
3084
|
-
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
3093
|
+
), "cacheRequestInputsResources");
|
3094
|
+
var cacheRequestInputsResourcesFromOwner = /* @__PURE__ */ __name((inputs, owner) => inputs.reduce(
|
3085
3095
|
(acc, input) => {
|
3086
3096
|
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
3087
3097
|
acc.utxos.push(input.id);
|
@@ -3094,8 +3104,8 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
|
3094
3104
|
utxos: [],
|
3095
3105
|
messages: []
|
3096
3106
|
}
|
3097
|
-
);
|
3098
|
-
var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
|
3107
|
+
), "cacheRequestInputsResourcesFromOwner");
|
3108
|
+
var getBurnableAssetCount = /* @__PURE__ */ __name((baseAssetId, transactionRequest) => {
|
3099
3109
|
const { inputs, outputs } = transactionRequest;
|
3100
3110
|
const coinInputs = new Set(inputs.filter(isRequestInputCoin).map((input) => input.assetId));
|
3101
3111
|
if (inputs.some((i) => isRequestInputMessage(i) && (0, import_math7.bn)(i.amount).gt(0))) {
|
@@ -3106,8 +3116,8 @@ var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
|
|
3106
3116
|
);
|
3107
3117
|
const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
|
3108
3118
|
return difference.size;
|
3109
|
-
};
|
3110
|
-
var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAssetBurn = false) => {
|
3119
|
+
}, "getBurnableAssetCount");
|
3120
|
+
var validateTransactionForAssetBurn = /* @__PURE__ */ __name((baseAssetId, transactionRequest, enableAssetBurn = false) => {
|
3111
3121
|
if (enableAssetBurn === true) {
|
3112
3122
|
return;
|
3113
3123
|
}
|
@@ -3120,20 +3130,23 @@ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAs
|
|
3120
3130
|
"Or enable asset burn, upon sending the transaction."
|
3121
3131
|
].join("\n");
|
3122
3132
|
throw new import_errors9.FuelError(import_errors9.ErrorCode.ASSET_BURN_DETECTED, message);
|
3123
|
-
};
|
3133
|
+
}, "validateTransactionForAssetBurn");
|
3124
3134
|
|
3125
3135
|
// src/providers/transaction-request/witness.ts
|
3126
3136
|
var import_utils9 = require("@fuel-ts/utils");
|
3127
|
-
var witnessify = (value) => {
|
3137
|
+
var witnessify = /* @__PURE__ */ __name((value) => {
|
3128
3138
|
const data = (0, import_utils9.arrayify)(value);
|
3129
3139
|
return {
|
3130
3140
|
data: (0, import_utils9.hexlify)(data),
|
3131
3141
|
dataLength: data.length
|
3132
3142
|
};
|
3133
|
-
};
|
3143
|
+
}, "witnessify");
|
3134
3144
|
|
3135
3145
|
// src/providers/transaction-request/transaction-request.ts
|
3136
|
-
var BaseTransactionRequest = class {
|
3146
|
+
var BaseTransactionRequest = class _BaseTransactionRequest {
|
3147
|
+
static {
|
3148
|
+
__name(this, "BaseTransactionRequest");
|
3149
|
+
}
|
3137
3150
|
/** Gas price for transaction */
|
3138
3151
|
tip;
|
3139
3152
|
/** Block until which tx cannot be included */
|
@@ -3216,7 +3229,7 @@ var BaseTransactionRequest = class {
|
|
3216
3229
|
const inputs = this.inputs?.map(inputify) ?? [];
|
3217
3230
|
const outputs = this.outputs?.map(outputify) ?? [];
|
3218
3231
|
const witnesses = this.witnesses?.map(witnessify) ?? [];
|
3219
|
-
const { policyTypes, policies } =
|
3232
|
+
const { policyTypes, policies } = _BaseTransactionRequest.getPolicyMeta(this);
|
3220
3233
|
return {
|
3221
3234
|
policyTypes,
|
3222
3235
|
inputs,
|
@@ -3564,13 +3577,13 @@ var BaseTransactionRequest = class {
|
|
3564
3577
|
* Please use `Account.generateFakeResources` along with `this.addResources` instead.
|
3565
3578
|
*/
|
3566
3579
|
fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
|
3567
|
-
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
3580
|
+
const findAssetInput = /* @__PURE__ */ __name((assetId) => this.inputs.find((input) => {
|
3568
3581
|
if ("assetId" in input) {
|
3569
3582
|
return input.assetId === assetId;
|
3570
3583
|
}
|
3571
3584
|
return false;
|
3572
|
-
});
|
3573
|
-
const updateAssetInput = (assetId, quantity) => {
|
3585
|
+
}), "findAssetInput");
|
3586
|
+
const updateAssetInput = /* @__PURE__ */ __name((assetId, quantity) => {
|
3574
3587
|
const assetInput = findAssetInput(assetId);
|
3575
3588
|
let usedQuantity = quantity;
|
3576
3589
|
if (assetId === baseAssetId) {
|
@@ -3591,7 +3604,7 @@ var BaseTransactionRequest = class {
|
|
3591
3604
|
}
|
3592
3605
|
]);
|
3593
3606
|
}
|
3594
|
-
};
|
3607
|
+
}, "updateAssetInput");
|
3595
3608
|
updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
|
3596
3609
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
3597
3610
|
return this;
|
@@ -3679,6 +3692,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3679
3692
|
transaction.inputs = transaction.inputs.map((input) => {
|
3680
3693
|
const inputClone = (0, import_ramda2.clone)(input);
|
3681
3694
|
switch (inputClone.type) {
|
3695
|
+
// Zero out on signing: txPointer, predicateGasUsed
|
3682
3696
|
case import_transactions9.InputType.Coin: {
|
3683
3697
|
inputClone.txPointer = {
|
3684
3698
|
blockHeight: 0,
|
@@ -3687,10 +3701,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3687
3701
|
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
3688
3702
|
return inputClone;
|
3689
3703
|
}
|
3704
|
+
// Zero out on signing: predicateGasUsed
|
3690
3705
|
case import_transactions9.InputType.Message: {
|
3691
3706
|
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
3692
3707
|
return inputClone;
|
3693
3708
|
}
|
3709
|
+
// Zero out on signing: txID, outputIndex, balanceRoot, stateRoot, and txPointer
|
3694
3710
|
case import_transactions9.InputType.Contract: {
|
3695
3711
|
inputClone.txPointer = {
|
3696
3712
|
blockHeight: 0,
|
@@ -3709,15 +3725,18 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3709
3725
|
transaction.outputs = transaction.outputs.map((output) => {
|
3710
3726
|
const outputClone = (0, import_ramda2.clone)(output);
|
3711
3727
|
switch (outputClone.type) {
|
3728
|
+
// Zero out on signing: balanceRoot, stateRoot
|
3712
3729
|
case import_transactions9.OutputType.Contract: {
|
3713
3730
|
outputClone.balanceRoot = import_configs7.ZeroBytes32;
|
3714
3731
|
outputClone.stateRoot = import_configs7.ZeroBytes32;
|
3715
3732
|
return outputClone;
|
3716
3733
|
}
|
3734
|
+
// Zero out on signing: amount
|
3717
3735
|
case import_transactions9.OutputType.Change: {
|
3718
3736
|
outputClone.amount = (0, import_math9.bn)(0);
|
3719
3737
|
return outputClone;
|
3720
3738
|
}
|
3739
|
+
// Zero out on signing: amount, to and assetId
|
3721
3740
|
case import_transactions9.OutputType.Variable: {
|
3722
3741
|
outputClone.to = import_configs7.ZeroBytes32;
|
3723
3742
|
outputClone.amount = (0, import_math9.bn)(0);
|
@@ -3734,9 +3753,13 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3734
3753
|
const concatenatedData = (0, import_utils12.concat)([chainIdBytes, new import_transactions9.TransactionCoder().encode(transaction)]);
|
3735
3754
|
return (0, import_hasher.sha256)(concatenatedData);
|
3736
3755
|
}
|
3756
|
+
__name(hashTransaction, "hashTransaction");
|
3737
3757
|
|
3738
3758
|
// src/providers/transaction-request/blob-transaction-request.ts
|
3739
3759
|
var BlobTransactionRequest = class extends BaseTransactionRequest {
|
3760
|
+
static {
|
3761
|
+
__name(this, "BlobTransactionRequest");
|
3762
|
+
}
|
3740
3763
|
static from(obj) {
|
3741
3764
|
return new this((0, import_ramda3.clone)(obj));
|
3742
3765
|
}
|
@@ -3805,12 +3828,12 @@ var import_ramda4 = require("ramda");
|
|
3805
3828
|
|
3806
3829
|
// src/providers/transaction-request/storage-slot.ts
|
3807
3830
|
var import_utils14 = require("@fuel-ts/utils");
|
3808
|
-
var getStorageValue = (value) => {
|
3831
|
+
var getStorageValue = /* @__PURE__ */ __name((value) => {
|
3809
3832
|
const v = new Uint8Array(32);
|
3810
3833
|
v.set((0, import_utils14.arrayify)(value));
|
3811
3834
|
return v;
|
3812
|
-
};
|
3813
|
-
var storageSlotify = (storageSlot) => {
|
3835
|
+
}, "getStorageValue");
|
3836
|
+
var storageSlotify = /* @__PURE__ */ __name((storageSlot) => {
|
3814
3837
|
let key;
|
3815
3838
|
let value;
|
3816
3839
|
if (Array.isArray(storageSlot)) {
|
@@ -3824,10 +3847,13 @@ var storageSlotify = (storageSlot) => {
|
|
3824
3847
|
key: (0, import_utils14.hexlify)(key),
|
3825
3848
|
value: (0, import_utils14.hexlify)(getStorageValue(value))
|
3826
3849
|
};
|
3827
|
-
};
|
3850
|
+
}, "storageSlotify");
|
3828
3851
|
|
3829
3852
|
// src/providers/transaction-request/create-transaction-request.ts
|
3830
3853
|
var CreateTransactionRequest = class extends BaseTransactionRequest {
|
3854
|
+
static {
|
3855
|
+
__name(this, "CreateTransactionRequest");
|
3856
|
+
}
|
3831
3857
|
static from(obj) {
|
3832
3858
|
return new this((0, import_ramda4.clone)(obj));
|
3833
3859
|
}
|
@@ -3929,7 +3955,7 @@ var returnZeroScript = {
|
|
3929
3955
|
*/
|
3930
3956
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
3931
3957
|
bytes: (0, import_utils16.arrayify)("0x24000000"),
|
3932
|
-
encodeScriptData: () => new Uint8Array(0)
|
3958
|
+
encodeScriptData: /* @__PURE__ */ __name(() => new Uint8Array(0), "encodeScriptData")
|
3933
3959
|
};
|
3934
3960
|
var withdrawScript = {
|
3935
3961
|
/*
|
@@ -3943,11 +3969,14 @@ var withdrawScript = {
|
|
3943
3969
|
*/
|
3944
3970
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
3945
3971
|
bytes: (0, import_utils16.arrayify)("0x5040C0105D44C0064C40001124000000"),
|
3946
|
-
encodeScriptData: () => new Uint8Array(0)
|
3972
|
+
encodeScriptData: /* @__PURE__ */ __name(() => new Uint8Array(0), "encodeScriptData")
|
3947
3973
|
};
|
3948
3974
|
|
3949
3975
|
// src/providers/transaction-request/script-transaction-request.ts
|
3950
3976
|
var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
3977
|
+
static {
|
3978
|
+
__name(this, "ScriptTransactionRequest");
|
3979
|
+
}
|
3951
3980
|
static from(obj) {
|
3952
3981
|
return new this((0, import_ramda5.clone)(obj));
|
3953
3982
|
}
|
@@ -4145,9 +4174,12 @@ var import_hasher2 = require("@fuel-ts/hasher");
|
|
4145
4174
|
var import_transactions12 = require("@fuel-ts/transactions");
|
4146
4175
|
var import_utils18 = require("@fuel-ts/utils");
|
4147
4176
|
var import_ramda6 = require("ramda");
|
4148
|
-
var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
4177
|
+
var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTransactionRequest {
|
4178
|
+
static {
|
4179
|
+
__name(this, "UpgradeTransactionRequest");
|
4180
|
+
}
|
4149
4181
|
static from(obj) {
|
4150
|
-
if (obj instanceof
|
4182
|
+
if (obj instanceof _UpgradeTransactionRequest) {
|
4151
4183
|
return obj;
|
4152
4184
|
}
|
4153
4185
|
return new this((0, import_ramda6.clone)(obj));
|
@@ -4295,9 +4327,12 @@ var import_configs10 = require("@fuel-ts/address/configs");
|
|
4295
4327
|
var import_transactions13 = require("@fuel-ts/transactions");
|
4296
4328
|
var import_utils20 = require("@fuel-ts/utils");
|
4297
4329
|
var import_ramda7 = require("ramda");
|
4298
|
-
var UploadTransactionRequest = class extends BaseTransactionRequest {
|
4330
|
+
var UploadTransactionRequest = class _UploadTransactionRequest extends BaseTransactionRequest {
|
4331
|
+
static {
|
4332
|
+
__name(this, "UploadTransactionRequest");
|
4333
|
+
}
|
4299
4334
|
static from(obj) {
|
4300
|
-
if (obj instanceof
|
4335
|
+
if (obj instanceof _UploadTransactionRequest) {
|
4301
4336
|
return obj;
|
4302
4337
|
}
|
4303
4338
|
return new this((0, import_ramda7.clone)(obj));
|
@@ -4398,12 +4433,15 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
|
|
4398
4433
|
|
4399
4434
|
// src/providers/transaction-request/types.ts
|
4400
4435
|
var AbstractScriptRequest = class {
|
4436
|
+
static {
|
4437
|
+
__name(this, "AbstractScriptRequest");
|
4438
|
+
}
|
4401
4439
|
};
|
4402
4440
|
|
4403
4441
|
// src/providers/transaction-request/utils.ts
|
4404
4442
|
var import_errors13 = require("@fuel-ts/errors");
|
4405
4443
|
var import_transactions14 = require("@fuel-ts/transactions");
|
4406
|
-
var transactionRequestify = (obj) => {
|
4444
|
+
var transactionRequestify = /* @__PURE__ */ __name((obj) => {
|
4407
4445
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
4408
4446
|
return obj;
|
4409
4447
|
}
|
@@ -4431,16 +4469,19 @@ var transactionRequestify = (obj) => {
|
|
4431
4469
|
);
|
4432
4470
|
}
|
4433
4471
|
}
|
4434
|
-
};
|
4435
|
-
var isTransactionTypeScript = (request2) => request2.type === import_transactions14.TransactionType.Script;
|
4436
|
-
var isTransactionTypeCreate = (request2) => request2.type === import_transactions14.TransactionType.Create;
|
4437
|
-
var isTransactionTypeBlob = (request2) => request2.type === import_transactions14.TransactionType.Blob;
|
4438
|
-
var isTransactionTypeUpgrade = (request2) => request2.type === import_transactions14.TransactionType.Upgrade;
|
4439
|
-
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");
|
4440
4478
|
|
4441
4479
|
// src/providers/resource-cache.ts
|
4442
4480
|
var cache = /* @__PURE__ */ new Map();
|
4443
4481
|
var ResourceCache = class {
|
4482
|
+
static {
|
4483
|
+
__name(this, "ResourceCache");
|
4484
|
+
}
|
4444
4485
|
ttl;
|
4445
4486
|
constructor(ttl) {
|
4446
4487
|
this.ttl = ttl;
|
@@ -4544,7 +4585,7 @@ var import_utils24 = require("@fuel-ts/utils");
|
|
4544
4585
|
var import_math12 = require("@fuel-ts/math");
|
4545
4586
|
var import_transactions15 = require("@fuel-ts/transactions");
|
4546
4587
|
var import_utils23 = require("@fuel-ts/utils");
|
4547
|
-
var calculateTXFeeForSummary = (params) => {
|
4588
|
+
var calculateTXFeeForSummary = /* @__PURE__ */ __name((params) => {
|
4548
4589
|
const {
|
4549
4590
|
gasPrice,
|
4550
4591
|
rawPayload,
|
@@ -4604,7 +4645,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
4604
4645
|
tip
|
4605
4646
|
});
|
4606
4647
|
return maxFee;
|
4607
|
-
};
|
4648
|
+
}, "calculateTXFeeForSummary");
|
4608
4649
|
|
4609
4650
|
// src/providers/transaction-summary/operations.ts
|
4610
4651
|
var import_configs11 = require("@fuel-ts/address/configs");
|
@@ -4619,28 +4660,36 @@ var import_transactions16 = require("@fuel-ts/transactions");
|
|
4619
4660
|
function getInputsByTypes(inputs, types) {
|
4620
4661
|
return inputs.filter((i) => types.includes(i.type));
|
4621
4662
|
}
|
4663
|
+
__name(getInputsByTypes, "getInputsByTypes");
|
4622
4664
|
function getInputsByType(inputs, type) {
|
4623
4665
|
return inputs.filter((i) => i.type === type);
|
4624
4666
|
}
|
4667
|
+
__name(getInputsByType, "getInputsByType");
|
4625
4668
|
function getInputsCoin(inputs) {
|
4626
4669
|
return getInputsByType(inputs, import_transactions16.InputType.Coin);
|
4627
4670
|
}
|
4671
|
+
__name(getInputsCoin, "getInputsCoin");
|
4628
4672
|
function getInputsMessage(inputs) {
|
4629
4673
|
return getInputsByType(inputs, import_transactions16.InputType.Message);
|
4630
4674
|
}
|
4675
|
+
__name(getInputsMessage, "getInputsMessage");
|
4631
4676
|
function getInputsCoinAndMessage(inputs) {
|
4632
4677
|
return getInputsByTypes(inputs, [import_transactions16.InputType.Coin, import_transactions16.InputType.Message]);
|
4633
4678
|
}
|
4679
|
+
__name(getInputsCoinAndMessage, "getInputsCoinAndMessage");
|
4634
4680
|
function isInputCoin(input) {
|
4635
4681
|
return input.type === import_transactions16.InputType.Coin;
|
4636
4682
|
}
|
4683
|
+
__name(isInputCoin, "isInputCoin");
|
4637
4684
|
function getInputsContract(inputs) {
|
4638
4685
|
return getInputsByType(inputs, import_transactions16.InputType.Contract);
|
4639
4686
|
}
|
4687
|
+
__name(getInputsContract, "getInputsContract");
|
4640
4688
|
function findCoinInput(inputs, assetId) {
|
4641
4689
|
const coinInputs = getInputsCoin(inputs);
|
4642
4690
|
return coinInputs.find((i) => i.assetId === assetId);
|
4643
4691
|
}
|
4692
|
+
__name(findCoinInput, "findCoinInput");
|
4644
4693
|
function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
|
4645
4694
|
const aggregated = /* @__PURE__ */ new Map();
|
4646
4695
|
getInputsCoinAndMessage(inputs).forEach((input) => {
|
@@ -4660,9 +4709,11 @@ function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
|
|
4660
4709
|
});
|
4661
4710
|
return aggregated;
|
4662
4711
|
}
|
4712
|
+
__name(aggregateInputsAmountsByAssetAndOwner, "aggregateInputsAmountsByAssetAndOwner");
|
4663
4713
|
function findMessageInput(inputs) {
|
4664
4714
|
return getInputsMessage(inputs)?.[0];
|
4665
4715
|
}
|
4716
|
+
__name(findMessageInput, "findMessageInput");
|
4666
4717
|
function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
|
4667
4718
|
const coinInput = findCoinInput(inputs, assetId);
|
4668
4719
|
if (coinInput) {
|
@@ -4673,6 +4724,7 @@ function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
|
|
4673
4724
|
}
|
4674
4725
|
return void 0;
|
4675
4726
|
}
|
4727
|
+
__name(getInputFromAssetId, "getInputFromAssetId");
|
4676
4728
|
function getInputContractFromIndex(inputs, inputIndex) {
|
4677
4729
|
if (inputIndex == null) {
|
4678
4730
|
return void 0;
|
@@ -4689,6 +4741,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
4689
4741
|
}
|
4690
4742
|
return contractInput;
|
4691
4743
|
}
|
4744
|
+
__name(getInputContractFromIndex, "getInputContractFromIndex");
|
4692
4745
|
function getInputAccountAddress(input) {
|
4693
4746
|
if (input.type === import_transactions16.InputType.Coin) {
|
4694
4747
|
return input.owner.toString();
|
@@ -4698,27 +4751,34 @@ function getInputAccountAddress(input) {
|
|
4698
4751
|
}
|
4699
4752
|
return "";
|
4700
4753
|
}
|
4754
|
+
__name(getInputAccountAddress, "getInputAccountAddress");
|
4701
4755
|
|
4702
4756
|
// src/providers/transaction-summary/output.ts
|
4703
4757
|
var import_transactions17 = require("@fuel-ts/transactions");
|
4704
4758
|
function getOutputsByType(outputs, type) {
|
4705
4759
|
return outputs.filter((o) => o.type === type);
|
4706
4760
|
}
|
4761
|
+
__name(getOutputsByType, "getOutputsByType");
|
4707
4762
|
function getOutputsContractCreated(outputs) {
|
4708
4763
|
return getOutputsByType(outputs, import_transactions17.OutputType.ContractCreated);
|
4709
4764
|
}
|
4765
|
+
__name(getOutputsContractCreated, "getOutputsContractCreated");
|
4710
4766
|
function getOutputsCoin(outputs) {
|
4711
4767
|
return getOutputsByType(outputs, import_transactions17.OutputType.Coin);
|
4712
4768
|
}
|
4769
|
+
__name(getOutputsCoin, "getOutputsCoin");
|
4713
4770
|
function getOutputsChange(outputs) {
|
4714
4771
|
return getOutputsByType(outputs, import_transactions17.OutputType.Change);
|
4715
4772
|
}
|
4773
|
+
__name(getOutputsChange, "getOutputsChange");
|
4716
4774
|
function getOutputsContract(outputs) {
|
4717
4775
|
return getOutputsByType(outputs, import_transactions17.OutputType.Contract);
|
4718
4776
|
}
|
4777
|
+
__name(getOutputsContract, "getOutputsContract");
|
4719
4778
|
function getOutputsVariable(outputs) {
|
4720
4779
|
return getOutputsByType(outputs, import_transactions17.OutputType.Variable);
|
4721
4780
|
}
|
4781
|
+
__name(getOutputsVariable, "getOutputsVariable");
|
4722
4782
|
|
4723
4783
|
// src/providers/transaction-summary/types.ts
|
4724
4784
|
var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
|
@@ -4761,6 +4821,7 @@ var ChainName = /* @__PURE__ */ ((ChainName2) => {
|
|
4761
4821
|
function getReceiptsByType(receipts, type) {
|
4762
4822
|
return (receipts ?? []).filter((r) => r.type === type);
|
4763
4823
|
}
|
4824
|
+
__name(getReceiptsByType, "getReceiptsByType");
|
4764
4825
|
function getTransactionTypeName(transactionType) {
|
4765
4826
|
switch (transactionType) {
|
4766
4827
|
case import_transactions18.TransactionType.Mint:
|
@@ -4782,37 +4843,48 @@ function getTransactionTypeName(transactionType) {
|
|
4782
4843
|
);
|
4783
4844
|
}
|
4784
4845
|
}
|
4846
|
+
__name(getTransactionTypeName, "getTransactionTypeName");
|
4785
4847
|
function isType(transactionType, type) {
|
4786
4848
|
const txType = getTransactionTypeName(transactionType);
|
4787
4849
|
return txType === type;
|
4788
4850
|
}
|
4851
|
+
__name(isType, "isType");
|
4789
4852
|
function isTypeMint(transactionType) {
|
4790
4853
|
return isType(transactionType, "Mint" /* Mint */);
|
4791
4854
|
}
|
4855
|
+
__name(isTypeMint, "isTypeMint");
|
4792
4856
|
function isTypeCreate(transactionType) {
|
4793
4857
|
return isType(transactionType, "Create" /* Create */);
|
4794
4858
|
}
|
4859
|
+
__name(isTypeCreate, "isTypeCreate");
|
4795
4860
|
function isTypeScript(transactionType) {
|
4796
4861
|
return isType(transactionType, "Script" /* Script */);
|
4797
4862
|
}
|
4863
|
+
__name(isTypeScript, "isTypeScript");
|
4798
4864
|
function isTypeUpgrade(transactionType) {
|
4799
4865
|
return isType(transactionType, "Upgrade" /* Upgrade */);
|
4800
4866
|
}
|
4867
|
+
__name(isTypeUpgrade, "isTypeUpgrade");
|
4801
4868
|
function isTypeUpload(transactionType) {
|
4802
4869
|
return isType(transactionType, "Upload" /* Upload */);
|
4803
4870
|
}
|
4871
|
+
__name(isTypeUpload, "isTypeUpload");
|
4804
4872
|
function isTypeBlob(transactionType) {
|
4805
4873
|
return isType(transactionType, "Blob" /* Blob */);
|
4806
4874
|
}
|
4875
|
+
__name(isTypeBlob, "isTypeBlob");
|
4807
4876
|
function hasSameAssetId(a) {
|
4808
4877
|
return (b) => a.assetId === b.assetId;
|
4809
4878
|
}
|
4879
|
+
__name(hasSameAssetId, "hasSameAssetId");
|
4810
4880
|
function getReceiptsCall(receipts) {
|
4811
4881
|
return getReceiptsByType(receipts, import_transactions18.ReceiptType.Call);
|
4812
4882
|
}
|
4883
|
+
__name(getReceiptsCall, "getReceiptsCall");
|
4813
4884
|
function getReceiptsMessageOut(receipts) {
|
4814
4885
|
return getReceiptsByType(receipts, import_transactions18.ReceiptType.MessageOut);
|
4815
4886
|
}
|
4887
|
+
__name(getReceiptsMessageOut, "getReceiptsMessageOut");
|
4816
4888
|
function mergeAssets(op1, op2) {
|
4817
4889
|
const assets1 = op1.assetsSent || [];
|
4818
4890
|
const assets2 = op2.assetsSent || [];
|
@@ -4830,21 +4902,25 @@ function mergeAssets(op1, op2) {
|
|
4830
4902
|
});
|
4831
4903
|
return Array.from(assetMap.values());
|
4832
4904
|
}
|
4905
|
+
__name(mergeAssets, "mergeAssets");
|
4833
4906
|
function isSameOperation(a, b) {
|
4834
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;
|
4835
4908
|
}
|
4909
|
+
__name(isSameOperation, "isSameOperation");
|
4836
4910
|
function mergeAssetsSent(existing, toAdd) {
|
4837
4911
|
if (!toAdd.assetsSent?.length) {
|
4838
4912
|
return existing.assetsSent;
|
4839
4913
|
}
|
4840
4914
|
return existing.assetsSent?.length ? mergeAssets(existing, toAdd) : toAdd.assetsSent;
|
4841
4915
|
}
|
4916
|
+
__name(mergeAssetsSent, "mergeAssetsSent");
|
4842
4917
|
function mergeCalls(existing, toAdd) {
|
4843
4918
|
if (!toAdd.calls?.length) {
|
4844
4919
|
return existing.calls;
|
4845
4920
|
}
|
4846
4921
|
return [...existing.calls || [], ...toAdd.calls];
|
4847
4922
|
}
|
4923
|
+
__name(mergeCalls, "mergeCalls");
|
4848
4924
|
function mergeOperations(existing, toAdd) {
|
4849
4925
|
return {
|
4850
4926
|
...existing,
|
@@ -4856,6 +4932,7 @@ function mergeOperations(existing, toAdd) {
|
|
4856
4932
|
]
|
4857
4933
|
};
|
4858
4934
|
}
|
4935
|
+
__name(mergeOperations, "mergeOperations");
|
4859
4936
|
function addOperation(operations, toAdd) {
|
4860
4937
|
const existingIndex = operations.findIndex((op) => isSameOperation(op, toAdd));
|
4861
4938
|
if (existingIndex === -1) {
|
@@ -4863,9 +4940,11 @@ function addOperation(operations, toAdd) {
|
|
4863
4940
|
}
|
4864
4941
|
return operations.map((op, index) => index === existingIndex ? mergeOperations(op, toAdd) : op);
|
4865
4942
|
}
|
4943
|
+
__name(addOperation, "addOperation");
|
4866
4944
|
function getReceiptsTransferOut(receipts) {
|
4867
4945
|
return getReceiptsByType(receipts, import_transactions18.ReceiptType.TransferOut);
|
4868
4946
|
}
|
4947
|
+
__name(getReceiptsTransferOut, "getReceiptsTransferOut");
|
4869
4948
|
function getWithdrawFromFuelOperations({
|
4870
4949
|
inputs,
|
4871
4950
|
receipts,
|
@@ -4904,6 +4983,7 @@ function getWithdrawFromFuelOperations({
|
|
4904
4983
|
);
|
4905
4984
|
return withdrawFromFuelOperations;
|
4906
4985
|
}
|
4986
|
+
__name(getWithdrawFromFuelOperations, "getWithdrawFromFuelOperations");
|
4907
4987
|
function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
|
4908
4988
|
const abi = abiMap?.[contractInput.contractID];
|
4909
4989
|
if (!abi) {
|
@@ -4911,6 +4991,7 @@ function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInpu
|
|
4911
4991
|
}
|
4912
4992
|
return [];
|
4913
4993
|
}
|
4994
|
+
__name(getContractCalls, "getContractCalls");
|
4914
4995
|
function getAssetsSent(receipt) {
|
4915
4996
|
return receipt.amount?.isZero() ? void 0 : [
|
4916
4997
|
{
|
@@ -4919,6 +5000,7 @@ function getAssetsSent(receipt) {
|
|
4919
5000
|
}
|
4920
5001
|
];
|
4921
5002
|
}
|
5003
|
+
__name(getAssetsSent, "getAssetsSent");
|
4922
5004
|
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
4923
5005
|
const assetId = receipt.assetId === import_configs11.ZeroBytes32 ? baseAssetId : receipt.assetId;
|
4924
5006
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
@@ -4944,6 +5026,7 @@ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload,
|
|
4944
5026
|
}
|
4945
5027
|
];
|
4946
5028
|
}
|
5029
|
+
__name(processCallReceipt, "processCallReceipt");
|
4947
5030
|
function getContractCallOperations({
|
4948
5031
|
inputs,
|
4949
5032
|
outputs,
|
@@ -4973,6 +5056,7 @@ function getContractCallOperations({
|
|
4973
5056
|
);
|
4974
5057
|
});
|
4975
5058
|
}
|
5059
|
+
__name(getContractCallOperations, "getContractCallOperations");
|
4976
5060
|
function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
|
4977
5061
|
const { to: toAddress, assetId, amount } = receipt;
|
4978
5062
|
let { id: fromAddress } = receipt;
|
@@ -5001,6 +5085,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
5001
5085
|
receipts: [receipt]
|
5002
5086
|
};
|
5003
5087
|
}
|
5088
|
+
__name(extractTransferOperationFromReceipt, "extractTransferOperationFromReceipt");
|
5004
5089
|
function getTransferOperations({
|
5005
5090
|
inputs,
|
5006
5091
|
outputs,
|
@@ -5055,6 +5140,7 @@ function getTransferOperations({
|
|
5055
5140
|
});
|
5056
5141
|
return operations;
|
5057
5142
|
}
|
5143
|
+
__name(getTransferOperations, "getTransferOperations");
|
5058
5144
|
function getPayProducerOperations(outputs) {
|
5059
5145
|
const coinOutputs = getOutputsCoin(outputs);
|
5060
5146
|
const payProducerOperations = coinOutputs.reduce((prev, output) => {
|
@@ -5079,6 +5165,7 @@ function getPayProducerOperations(outputs) {
|
|
5079
5165
|
}, []);
|
5080
5166
|
return payProducerOperations;
|
5081
5167
|
}
|
5168
|
+
__name(getPayProducerOperations, "getPayProducerOperations");
|
5082
5169
|
function getContractCreatedOperations({ inputs, outputs }) {
|
5083
5170
|
const contractCreatedOutputs = getOutputsContractCreated(outputs);
|
5084
5171
|
const input = getInputsCoinAndMessage(inputs)[0];
|
@@ -5099,6 +5186,7 @@ function getContractCreatedOperations({ inputs, outputs }) {
|
|
5099
5186
|
}, []);
|
5100
5187
|
return contractCreatedOperations;
|
5101
5188
|
}
|
5189
|
+
__name(getContractCreatedOperations, "getContractCreatedOperations");
|
5102
5190
|
function getOperations({
|
5103
5191
|
transactionType,
|
5104
5192
|
inputs,
|
@@ -5129,11 +5217,12 @@ function getOperations({
|
|
5129
5217
|
}
|
5130
5218
|
return [...getPayProducerOperations(outputs)];
|
5131
5219
|
}
|
5220
|
+
__name(getOperations, "getOperations");
|
5132
5221
|
|
5133
5222
|
// src/providers/transaction-summary/receipt.ts
|
5134
5223
|
var import_transactions19 = require("@fuel-ts/transactions");
|
5135
|
-
var processGqlReceipt = (gqlReceipt) => deserializeReceipt(gqlReceipt);
|
5136
|
-
var extractMintedAssetsFromReceipts = (receipts) => {
|
5224
|
+
var processGqlReceipt = /* @__PURE__ */ __name((gqlReceipt) => deserializeReceipt(gqlReceipt), "processGqlReceipt");
|
5225
|
+
var extractMintedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
5137
5226
|
const mintedAssets = [];
|
5138
5227
|
receipts.forEach((receipt) => {
|
5139
5228
|
if (receipt.type === import_transactions19.ReceiptType.Mint) {
|
@@ -5146,8 +5235,8 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
5146
5235
|
}
|
5147
5236
|
});
|
5148
5237
|
return mintedAssets;
|
5149
|
-
};
|
5150
|
-
var extractBurnedAssetsFromReceipts = (receipts) => {
|
5238
|
+
}, "extractMintedAssetsFromReceipts");
|
5239
|
+
var extractBurnedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
5151
5240
|
const burnedAssets = [];
|
5152
5241
|
receipts.forEach((receipt) => {
|
5153
5242
|
if (receipt.type === import_transactions19.ReceiptType.Burn) {
|
@@ -5160,12 +5249,12 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
5160
5249
|
}
|
5161
5250
|
});
|
5162
5251
|
return burnedAssets;
|
5163
|
-
};
|
5252
|
+
}, "extractBurnedAssetsFromReceipts");
|
5164
5253
|
|
5165
5254
|
// src/providers/transaction-summary/status.ts
|
5166
5255
|
var import_errors17 = require("@fuel-ts/errors");
|
5167
5256
|
var import_math15 = require("@fuel-ts/math");
|
5168
|
-
var getTransactionStatusName = (gqlStatus) => {
|
5257
|
+
var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
|
5169
5258
|
switch (gqlStatus) {
|
5170
5259
|
case "FailureStatus":
|
5171
5260
|
return "failure" /* failure */;
|
@@ -5181,8 +5270,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
5181
5270
|
`Invalid transaction status: ${gqlStatus}.`
|
5182
5271
|
);
|
5183
5272
|
}
|
5184
|
-
};
|
5185
|
-
var processGraphqlStatus = (gqlTransactionStatus) => {
|
5273
|
+
}, "getTransactionStatusName");
|
5274
|
+
var processGraphqlStatus = /* @__PURE__ */ __name((gqlTransactionStatus) => {
|
5186
5275
|
let time;
|
5187
5276
|
let blockId;
|
5188
5277
|
let status;
|
@@ -5226,8 +5315,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
5226
5315
|
isStatusPending
|
5227
5316
|
};
|
5228
5317
|
return processedGraphqlStatus;
|
5229
|
-
};
|
5230
|
-
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");
|
5231
5320
|
|
5232
5321
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
5233
5322
|
function assembleTransactionSummary(params) {
|
@@ -5307,6 +5396,7 @@ function assembleTransactionSummary(params) {
|
|
5307
5396
|
};
|
5308
5397
|
return transactionSummary;
|
5309
5398
|
}
|
5399
|
+
__name(assembleTransactionSummary, "assembleTransactionSummary");
|
5310
5400
|
|
5311
5401
|
// src/providers/transaction-response/getDecodedLogs.ts
|
5312
5402
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
@@ -5334,6 +5424,7 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
5334
5424
|
return logs;
|
5335
5425
|
}, []);
|
5336
5426
|
}
|
5427
|
+
__name(getDecodedLogs, "getDecodedLogs");
|
5337
5428
|
|
5338
5429
|
// src/providers/transaction-response/transaction-response.ts
|
5339
5430
|
function mapGqlOutputsToTxOutputs(outputs) {
|
@@ -5366,7 +5457,8 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
5366
5457
|
}
|
5367
5458
|
});
|
5368
5459
|
}
|
5369
|
-
|
5460
|
+
__name(mapGqlOutputsToTxOutputs, "mapGqlOutputsToTxOutputs");
|
5461
|
+
var TransactionResponse = class _TransactionResponse {
|
5370
5462
|
/**
|
5371
5463
|
* Constructor for `TransactionResponse`.
|
5372
5464
|
*
|
@@ -5381,6 +5473,9 @@ var TransactionResponse = class {
|
|
5381
5473
|
this.request = typeof tx === "string" ? void 0 : tx;
|
5382
5474
|
this.waitForResult = this.waitForResult.bind(this);
|
5383
5475
|
}
|
5476
|
+
static {
|
5477
|
+
__name(this, "TransactionResponse");
|
5478
|
+
}
|
5384
5479
|
/** Transaction ID */
|
5385
5480
|
id;
|
5386
5481
|
/** Current provider */
|
@@ -5402,7 +5497,7 @@ var TransactionResponse = class {
|
|
5402
5497
|
*/
|
5403
5498
|
static async create(id, provider, abis) {
|
5404
5499
|
const chainId = await provider.getChainId();
|
5405
|
-
const response = new
|
5500
|
+
const response = new _TransactionResponse(id, provider, chainId, abis);
|
5406
5501
|
await response.fetch();
|
5407
5502
|
return response;
|
5408
5503
|
}
|
@@ -5619,6 +5714,7 @@ function getWaitDelay(options, retryAttemptNum) {
|
|
5619
5714
|
return 2 ** (retryAttemptNum - 1) * duration;
|
5620
5715
|
}
|
5621
5716
|
}
|
5717
|
+
__name(getWaitDelay, "getWaitDelay");
|
5622
5718
|
function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
5623
5719
|
if (options === void 0) {
|
5624
5720
|
return fetchFn;
|
@@ -5641,9 +5737,10 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
5641
5737
|
}
|
5642
5738
|
};
|
5643
5739
|
}
|
5740
|
+
__name(autoRetryFetch, "autoRetryFetch");
|
5644
5741
|
|
5645
5742
|
// src/providers/utils/helpers.ts
|
5646
|
-
var adjustResourcesToExclude = (params) => {
|
5743
|
+
var adjustResourcesToExclude = /* @__PURE__ */ __name((params) => {
|
5647
5744
|
const { userInput, cached, maxInputs } = params;
|
5648
5745
|
const final = { ...userInput };
|
5649
5746
|
let total = final.utxos.length + final.messages.length;
|
@@ -5656,11 +5753,11 @@ var adjustResourcesToExclude = (params) => {
|
|
5656
5753
|
final.messages = [...final.messages, ...cached.messages.slice(0, maxInputs - total)];
|
5657
5754
|
}
|
5658
5755
|
return final;
|
5659
|
-
};
|
5756
|
+
}, "adjustResourcesToExclude");
|
5660
5757
|
|
5661
5758
|
// src/providers/utils/validate-pagination-args.ts
|
5662
5759
|
var import_errors19 = require("@fuel-ts/errors");
|
5663
|
-
var validatePaginationArgs = (params) => {
|
5760
|
+
var validatePaginationArgs = /* @__PURE__ */ __name((params) => {
|
5664
5761
|
const { paginationLimit, inputArgs = {} } = params;
|
5665
5762
|
const { first, last, after, before } = inputArgs;
|
5666
5763
|
if (after && before) {
|
@@ -5691,18 +5788,71 @@ var validatePaginationArgs = (params) => {
|
|
5691
5788
|
inputArgs.first = paginationLimit;
|
5692
5789
|
}
|
5693
5790
|
return inputArgs;
|
5694
|
-
};
|
5791
|
+
}, "validatePaginationArgs");
|
5695
5792
|
|
5696
5793
|
// src/providers/provider.ts
|
5697
5794
|
var MAX_RETRIES = 10;
|
5698
5795
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
5699
5796
|
var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
|
5700
5797
|
var BALANCES_PAGE_SIZE_LIMIT = 100;
|
5798
|
+
var NON_PAGINATED_BALANCES_SIZE = 1e4;
|
5701
5799
|
var BLOCKS_PAGE_SIZE_LIMIT = 5;
|
5702
5800
|
var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
|
5703
5801
|
var GAS_USED_MODIFIER = 1.2;
|
5704
|
-
var
|
5705
|
-
|
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
|
+
}
|
5706
5856
|
/**
|
5707
5857
|
* Constructor to initialize a Provider.
|
5708
5858
|
*
|
@@ -5711,31 +5861,6 @@ var _Provider = class {
|
|
5711
5861
|
* @hidden
|
5712
5862
|
*/
|
5713
5863
|
constructor(url, options = {}) {
|
5714
|
-
/**
|
5715
|
-
* @hidden
|
5716
|
-
*/
|
5717
|
-
__privateAdd(this, _cacheInputs);
|
5718
|
-
__publicField(this, "operations");
|
5719
|
-
__publicField(this, "cache");
|
5720
|
-
/** @hidden */
|
5721
|
-
__publicField(this, "url");
|
5722
|
-
/** @hidden */
|
5723
|
-
__publicField(this, "urlWithoutAuth");
|
5724
|
-
/** @hidden */
|
5725
|
-
__publicField(this, "features", {
|
5726
|
-
balancePagination: false,
|
5727
|
-
amount128: false
|
5728
|
-
});
|
5729
|
-
/** @hidden */
|
5730
|
-
__publicField(this, "consensusParametersTimestamp");
|
5731
|
-
__publicField(this, "options", {
|
5732
|
-
timeout: void 0,
|
5733
|
-
resourceCacheTTL: void 0,
|
5734
|
-
fetch: void 0,
|
5735
|
-
retryOptions: void 0,
|
5736
|
-
headers: void 0,
|
5737
|
-
cache: void 0
|
5738
|
-
});
|
5739
5864
|
const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
|
5740
5865
|
this.url = rawUrl;
|
5741
5866
|
this.urlWithoutAuth = urlWithoutAuth;
|
@@ -5765,32 +5890,6 @@ var _Provider = class {
|
|
5765
5890
|
this.cache = new ResourceCache(DEFAULT_RESOURCE_CACHE_TTL);
|
5766
5891
|
}
|
5767
5892
|
}
|
5768
|
-
/** @hidden */
|
5769
|
-
static clearChainAndNodeCaches() {
|
5770
|
-
_Provider.inflightFetchChainAndNodeInfoRequests = {};
|
5771
|
-
_Provider.nodeInfoCache = {};
|
5772
|
-
_Provider.chainInfoCache = {};
|
5773
|
-
}
|
5774
|
-
/**
|
5775
|
-
* @hidden
|
5776
|
-
*/
|
5777
|
-
static getFetchFn(options) {
|
5778
|
-
const { retryOptions, timeout, headers } = options;
|
5779
|
-
return autoRetryFetch(async (...args) => {
|
5780
|
-
const url = args[0];
|
5781
|
-
const request2 = args[1];
|
5782
|
-
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
5783
|
-
let fullRequest = {
|
5784
|
-
...request2,
|
5785
|
-
signal,
|
5786
|
-
headers: { ...request2?.headers, ...headers }
|
5787
|
-
};
|
5788
|
-
if (options.requestMiddleware) {
|
5789
|
-
fullRequest = await options.requestMiddleware(fullRequest);
|
5790
|
-
}
|
5791
|
-
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
5792
|
-
}, retryOptions);
|
5793
|
-
}
|
5794
5893
|
static extractBasicAuth(url) {
|
5795
5894
|
let parsedUrl;
|
5796
5895
|
try {
|
@@ -5814,8 +5913,7 @@ var _Provider = class {
|
|
5814
5913
|
* Initialize Provider async stuff
|
5815
5914
|
*/
|
5816
5915
|
async init() {
|
5817
|
-
|
5818
|
-
this.setupFeatures(nodeInfo.nodeVersion);
|
5916
|
+
await this.fetchChainAndNodeInfo();
|
5819
5917
|
return this;
|
5820
5918
|
}
|
5821
5919
|
/**
|
@@ -5932,8 +6030,8 @@ var _Provider = class {
|
|
5932
6030
|
createOperations() {
|
5933
6031
|
const fetchFn = _Provider.getFetchFn(this.options);
|
5934
6032
|
const gqlClient = new import_graphql_request.GraphQLClient(this.urlWithoutAuth, {
|
5935
|
-
fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
|
5936
|
-
responseMiddleware: (response) => {
|
6033
|
+
fetch: /* @__PURE__ */ __name((input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options), "fetch"),
|
6034
|
+
responseMiddleware: /* @__PURE__ */ __name((response) => {
|
5937
6035
|
if ("response" in response) {
|
5938
6036
|
const graphQlResponse = response.response;
|
5939
6037
|
assertGqlResponseHasNoErrors(
|
@@ -5941,22 +6039,22 @@ var _Provider = class {
|
|
5941
6039
|
_Provider.incompatibleNodeVersionMessage
|
5942
6040
|
);
|
5943
6041
|
}
|
5944
|
-
}
|
6042
|
+
}, "responseMiddleware")
|
5945
6043
|
});
|
5946
|
-
const executeQuery = (query, vars) => {
|
6044
|
+
const executeQuery = /* @__PURE__ */ __name((query, vars) => {
|
5947
6045
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
5948
6046
|
const isSubscription = opDefinition?.operation === "subscription";
|
5949
6047
|
if (isSubscription) {
|
5950
6048
|
return FuelGraphqlSubscriber.create({
|
5951
6049
|
url: this.urlWithoutAuth,
|
5952
6050
|
query,
|
5953
|
-
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
6051
|
+
fetchFn: /* @__PURE__ */ __name((url, requestInit) => fetchFn(url, requestInit, this.options), "fetchFn"),
|
5954
6052
|
variables: vars
|
5955
6053
|
});
|
5956
6054
|
}
|
5957
6055
|
return gqlClient.request(query, vars);
|
5958
|
-
};
|
5959
|
-
const customOperations = (requester) => ({
|
6056
|
+
}, "executeQuery");
|
6057
|
+
const customOperations = /* @__PURE__ */ __name((requester) => ({
|
5960
6058
|
getBlobs(variables) {
|
5961
6059
|
const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
|
5962
6060
|
const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
|
@@ -5974,18 +6072,9 @@ var _Provider = class {
|
|
5974
6072
|
`;
|
5975
6073
|
return requester(document2, updatedVariables);
|
5976
6074
|
}
|
5977
|
-
});
|
6075
|
+
}), "customOperations");
|
5978
6076
|
return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
|
5979
6077
|
}
|
5980
|
-
/**
|
5981
|
-
* @hidden
|
5982
|
-
*/
|
5983
|
-
setupFeatures(nodeVersion) {
|
5984
|
-
if ((0, import_versions.gte)(nodeVersion, "0.41.0")) {
|
5985
|
-
this.features.balancePagination = true;
|
5986
|
-
this.features.amount128 = true;
|
5987
|
-
}
|
5988
|
-
}
|
5989
6078
|
/**
|
5990
6079
|
* Returns the version of the connected node.
|
5991
6080
|
*
|
@@ -6062,6 +6151,13 @@ var _Provider = class {
|
|
6062
6151
|
* @returns A promise that resolves to an object containing the asset details.
|
6063
6152
|
*/
|
6064
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
|
+
}
|
6065
6161
|
const { assetDetails } = await this.operations.getAssetDetails({ assetId });
|
6066
6162
|
const { contractId, subId, totalSupply } = assetDetails;
|
6067
6163
|
return {
|
@@ -6070,6 +6166,15 @@ var _Provider = class {
|
|
6070
6166
|
totalSupply: (0, import_math18.bn)(totalSupply)
|
6071
6167
|
};
|
6072
6168
|
}
|
6169
|
+
/**
|
6170
|
+
* @hidden
|
6171
|
+
*/
|
6172
|
+
#cacheInputs(inputs, transactionId) {
|
6173
|
+
if (!this.cache) {
|
6174
|
+
return;
|
6175
|
+
}
|
6176
|
+
this.cache.set(transactionId, inputs);
|
6177
|
+
}
|
6073
6178
|
/**
|
6074
6179
|
* @hidden
|
6075
6180
|
*/
|
@@ -6119,7 +6224,10 @@ var _Provider = class {
|
|
6119
6224
|
abis = transactionRequest.abis;
|
6120
6225
|
}
|
6121
6226
|
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
6122
|
-
|
6227
|
+
this.#cacheInputs(
|
6228
|
+
transactionRequest.inputs,
|
6229
|
+
transactionRequest.getTransactionId(await this.getChainId())
|
6230
|
+
);
|
6123
6231
|
const chainId = await this.getChainId();
|
6124
6232
|
return new TransactionResponse(transactionRequest, this, chainId, abis, subscription);
|
6125
6233
|
}
|
@@ -6871,18 +6979,9 @@ var _Provider = class {
|
|
6871
6979
|
* @returns A promise that resolves to the balance.
|
6872
6980
|
*/
|
6873
6981
|
async getBalance(owner, assetId) {
|
6874
|
-
const ownerStr = new import_address3.Address(owner).toB256();
|
6875
|
-
const assetIdStr = (0, import_utils29.hexlify)(assetId);
|
6876
|
-
if (!this.features.amount128) {
|
6877
|
-
const { balance: balance2 } = await this.operations.getBalance({
|
6878
|
-
owner: ownerStr,
|
6879
|
-
assetId: assetIdStr
|
6880
|
-
});
|
6881
|
-
return (0, import_math18.bn)(balance2.amount, 10);
|
6882
|
-
}
|
6883
6982
|
const { balance } = await this.operations.getBalanceV2({
|
6884
|
-
owner:
|
6885
|
-
assetId:
|
6983
|
+
owner: new import_address3.Address(owner).toB256(),
|
6984
|
+
assetId: (0, import_utils29.hexlify)(assetId)
|
6886
6985
|
});
|
6887
6986
|
return (0, import_math18.bn)(balance.amountU128, 10);
|
6888
6987
|
}
|
@@ -6894,49 +6993,29 @@ var _Provider = class {
|
|
6894
6993
|
* @returns A promise that resolves to the balances.
|
6895
6994
|
*/
|
6896
6995
|
async getBalances(owner, paginationArgs) {
|
6897
|
-
|
6898
|
-
|
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
|
+
});
|
6899
7003
|
}
|
6900
|
-
return this.getBalancesV2(owner, paginationArgs);
|
6901
|
-
}
|
6902
|
-
/**
|
6903
|
-
* @hidden
|
6904
|
-
*/
|
6905
|
-
async getBalancesV1(owner, _paginationArgs) {
|
6906
|
-
const {
|
6907
|
-
balances: { edges }
|
6908
|
-
} = await this.operations.getBalances({
|
6909
|
-
/**
|
6910
|
-
* The query parameters for this method were designed to support pagination,
|
6911
|
-
* but the current Fuel-Core implementation does not support pagination yet.
|
6912
|
-
*/
|
6913
|
-
first: 1e4,
|
6914
|
-
filter: { owner: new import_address3.Address(owner).toB256() }
|
6915
|
-
});
|
6916
|
-
const balances = edges.map(({ node }) => ({
|
6917
|
-
assetId: node.assetId,
|
6918
|
-
amount: (0, import_math18.bn)(node.amount)
|
6919
|
-
}));
|
6920
|
-
return { balances };
|
6921
|
-
}
|
6922
|
-
/**
|
6923
|
-
* @hidden
|
6924
|
-
*/
|
6925
|
-
async getBalancesV2(owner, paginationArgs) {
|
6926
7004
|
const {
|
6927
7005
|
balances: { edges, pageInfo }
|
6928
7006
|
} = await this.operations.getBalancesV2({
|
6929
|
-
...
|
6930
|
-
|
6931
|
-
|
6932
|
-
}),
|
6933
|
-
filter: { owner: new import_address3.Address(owner).toB256() }
|
7007
|
+
...args,
|
7008
|
+
filter: { owner: new import_address3.Address(owner).toB256() },
|
7009
|
+
supportsPagination
|
6934
7010
|
});
|
6935
7011
|
const balances = edges.map(({ node }) => ({
|
6936
7012
|
assetId: node.assetId,
|
6937
7013
|
amount: (0, import_math18.bn)(node.amountU128)
|
6938
7014
|
}));
|
6939
|
-
return {
|
7015
|
+
return {
|
7016
|
+
balances,
|
7017
|
+
...supportsPagination ? { pageInfo } : {}
|
7018
|
+
};
|
6940
7019
|
}
|
6941
7020
|
/**
|
6942
7021
|
* Returns message for the given address.
|
@@ -7223,6 +7302,17 @@ var _Provider = class {
|
|
7223
7302
|
statusReason: status.reason
|
7224
7303
|
});
|
7225
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
|
+
}
|
7226
7316
|
/**
|
7227
7317
|
* @hidden
|
7228
7318
|
*/
|
@@ -7237,22 +7327,6 @@ var _Provider = class {
|
|
7237
7327
|
return transactionRequest;
|
7238
7328
|
}
|
7239
7329
|
};
|
7240
|
-
var Provider = _Provider;
|
7241
|
-
_cacheInputs = new WeakSet();
|
7242
|
-
cacheInputs_fn = function(inputs, transactionId) {
|
7243
|
-
if (!this.cache) {
|
7244
|
-
return;
|
7245
|
-
}
|
7246
|
-
this.cache.set(transactionId, inputs);
|
7247
|
-
};
|
7248
|
-
/** @hidden */
|
7249
|
-
__publicField(Provider, "inflightFetchChainAndNodeInfoRequests", {});
|
7250
|
-
/** @hidden */
|
7251
|
-
__publicField(Provider, "chainInfoCache", {});
|
7252
|
-
/** @hidden */
|
7253
|
-
__publicField(Provider, "nodeInfoCache", {});
|
7254
|
-
/** @hidden */
|
7255
|
-
__publicField(Provider, "incompatibleNodeVersionMessage", "");
|
7256
7330
|
|
7257
7331
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
7258
7332
|
var import_errors21 = require("@fuel-ts/errors");
|
@@ -7308,6 +7382,7 @@ async function getTransactionSummary(params) {
|
|
7308
7382
|
...transactionInfo
|
7309
7383
|
};
|
7310
7384
|
}
|
7385
|
+
__name(getTransactionSummary, "getTransactionSummary");
|
7311
7386
|
async function getTransactionSummaryFromRequest(params) {
|
7312
7387
|
const { provider, transactionRequest, abiMap } = params;
|
7313
7388
|
const { receipts } = await provider.dryRun(transactionRequest);
|
@@ -7333,6 +7408,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
7333
7408
|
});
|
7334
7409
|
return transactionSummary;
|
7335
7410
|
}
|
7411
|
+
__name(getTransactionSummaryFromRequest, "getTransactionSummaryFromRequest");
|
7336
7412
|
async function getTransactionsSummaries(params) {
|
7337
7413
|
const { filters, provider, abiMap } = params;
|
7338
7414
|
const { owner, ...inputArgs } = filters;
|
@@ -7388,12 +7464,13 @@ async function getTransactionsSummaries(params) {
|
|
7388
7464
|
pageInfo
|
7389
7465
|
};
|
7390
7466
|
}
|
7467
|
+
__name(getTransactionsSummaries, "getTransactionsSummaries");
|
7391
7468
|
|
7392
7469
|
// src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
|
7393
7470
|
var import_math20 = require("@fuel-ts/math");
|
7394
7471
|
var import_transactions25 = require("@fuel-ts/transactions");
|
7395
7472
|
var import_utils32 = require("@fuel-ts/utils");
|
7396
|
-
var assembleTransactionSummaryFromJson = async (opts) => {
|
7473
|
+
var assembleTransactionSummaryFromJson = /* @__PURE__ */ __name(async (opts) => {
|
7397
7474
|
const { provider, transactionSummary } = opts;
|
7398
7475
|
const { id, transactionBytes, gasPrice, receipts } = transactionSummary;
|
7399
7476
|
const {
|
@@ -7420,10 +7497,10 @@ var assembleTransactionSummaryFromJson = async (opts) => {
|
|
7420
7497
|
gasPerByte,
|
7421
7498
|
gasPriceFactor
|
7422
7499
|
});
|
7423
|
-
};
|
7500
|
+
}, "assembleTransactionSummaryFromJson");
|
7424
7501
|
|
7425
7502
|
// src/providers/utils/merge-quantities.ts
|
7426
|
-
var mergeQuantities = (...coinQuantities) => {
|
7503
|
+
var mergeQuantities = /* @__PURE__ */ __name((...coinQuantities) => {
|
7427
7504
|
const resultMap = {};
|
7428
7505
|
function addToMap({ amount, assetId }) {
|
7429
7506
|
if (resultMap[assetId]) {
|
@@ -7432,12 +7509,16 @@ var mergeQuantities = (...coinQuantities) => {
|
|
7432
7509
|
resultMap[assetId] = amount;
|
7433
7510
|
}
|
7434
7511
|
}
|
7512
|
+
__name(addToMap, "addToMap");
|
7435
7513
|
coinQuantities.forEach((arr) => arr.forEach(addToMap));
|
7436
7514
|
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
7437
|
-
};
|
7515
|
+
}, "mergeQuantities");
|
7438
7516
|
|
7439
7517
|
// src/types.ts
|
7440
7518
|
var AbstractAccount = class {
|
7519
|
+
static {
|
7520
|
+
__name(this, "AbstractAccount");
|
7521
|
+
}
|
7441
7522
|
};
|
7442
7523
|
|
7443
7524
|
// src/utils/formatTransferToContractScriptData.ts
|
@@ -7445,7 +7526,7 @@ var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
|
7445
7526
|
var import_address4 = require("@fuel-ts/address");
|
7446
7527
|
var import_utils33 = require("@fuel-ts/utils");
|
7447
7528
|
var asm = __toESM(require("@fuels/vm-asm"));
|
7448
|
-
var formatTransferToContractScriptData = (transferParams) => {
|
7529
|
+
var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
|
7449
7530
|
const numberCoder = new import_abi_coder5.BigNumberCoder("u64");
|
7450
7531
|
return transferParams.reduce((acc, transferParam) => {
|
7451
7532
|
const { assetId, amount, contractId } = transferParam;
|
@@ -7453,8 +7534,8 @@ var formatTransferToContractScriptData = (transferParams) => {
|
|
7453
7534
|
const scriptData = (0, import_utils33.concat)([new import_address4.Address(contractId).toBytes(), encoded, (0, import_utils33.arrayify)(assetId)]);
|
7454
7535
|
return (0, import_utils33.concat)([acc, scriptData]);
|
7455
7536
|
}, new Uint8Array());
|
7456
|
-
};
|
7457
|
-
var assembleTransferToContractScript = async (transferParams) => {
|
7537
|
+
}, "formatTransferToContractScriptData");
|
7538
|
+
var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferParams) => {
|
7458
7539
|
const scriptData = formatTransferToContractScriptData(transferParams);
|
7459
7540
|
await asm.initWasm();
|
7460
7541
|
let script = new Uint8Array();
|
@@ -7478,11 +7559,14 @@ var assembleTransferToContractScript = async (transferParams) => {
|
|
7478
7559
|
});
|
7479
7560
|
script = (0, import_utils33.concat)([script, asm.ret(1).to_bytes()]);
|
7480
7561
|
return { script, scriptData };
|
7481
|
-
};
|
7562
|
+
}, "assembleTransferToContractScript");
|
7482
7563
|
|
7483
7564
|
// src/account.ts
|
7484
7565
|
var MAX_FUNDING_ATTEMPTS = 5;
|
7485
7566
|
var Account = class extends AbstractAccount {
|
7567
|
+
static {
|
7568
|
+
__name(this, "Account");
|
7569
|
+
}
|
7486
7570
|
/**
|
7487
7571
|
* The address associated with the account.
|
7488
7572
|
*/
|
@@ -7866,7 +7950,7 @@ var Account = class extends AbstractAccount {
|
|
7866
7950
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
7867
7951
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
7868
7952
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
|
7869
|
-
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
7953
|
+
const findAssetInput = /* @__PURE__ */ __name((assetId) => txRequestClone.inputs.find((input) => {
|
7870
7954
|
if (input.type === import_transactions26.InputType.Coin) {
|
7871
7955
|
return input.assetId === assetId;
|
7872
7956
|
}
|
@@ -7874,8 +7958,8 @@ var Account = class extends AbstractAccount {
|
|
7874
7958
|
return baseAssetId === assetId;
|
7875
7959
|
}
|
7876
7960
|
return false;
|
7877
|
-
});
|
7878
|
-
const updateAssetInput = (assetId, quantity) => {
|
7961
|
+
}), "findAssetInput");
|
7962
|
+
const updateAssetInput = /* @__PURE__ */ __name((assetId, quantity) => {
|
7879
7963
|
const assetInput = findAssetInput(assetId);
|
7880
7964
|
const usedQuantity = quantity;
|
7881
7965
|
if (assetInput && "amount" in assetInput) {
|
@@ -7890,7 +7974,7 @@ var Account = class extends AbstractAccount {
|
|
7890
7974
|
])
|
7891
7975
|
);
|
7892
7976
|
}
|
7893
|
-
};
|
7977
|
+
}, "updateAssetInput");
|
7894
7978
|
mergeQuantities(requiredQuantities, transactionFeeForDryRun).forEach(
|
7895
7979
|
({ amount, assetId }) => updateAssetInput(assetId, amount)
|
7896
7980
|
);
|
@@ -8080,7 +8164,10 @@ var import_hasher3 = require("@fuel-ts/hasher");
|
|
8080
8164
|
var import_math22 = require("@fuel-ts/math");
|
8081
8165
|
var import_utils35 = require("@fuel-ts/utils");
|
8082
8166
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
8083
|
-
var Signer = class {
|
8167
|
+
var Signer = class _Signer {
|
8168
|
+
static {
|
8169
|
+
__name(this, "Signer");
|
8170
|
+
}
|
8084
8171
|
address;
|
8085
8172
|
publicKey;
|
8086
8173
|
compressedPublicKey;
|
@@ -8159,7 +8246,7 @@ var Signer = class {
|
|
8159
8246
|
* @returns Address from signature
|
8160
8247
|
*/
|
8161
8248
|
static recoverAddress(data, signature) {
|
8162
|
-
return new import_address6.Address(
|
8249
|
+
return new import_address6.Address(_Signer.recoverPublicKey(data, signature));
|
8163
8250
|
}
|
8164
8251
|
/**
|
8165
8252
|
* Generate a random privateKey
|
@@ -8192,12 +8279,12 @@ var DEFAULT_KDF_PARAMS_R = 8;
|
|
8192
8279
|
var DEFAULT_KDF_PARAMS_P = 1;
|
8193
8280
|
var DEFAULT_KEY_SIZE = 32;
|
8194
8281
|
var DEFAULT_IV_SIZE = 16;
|
8195
|
-
var removeHexPrefix = (hexString) => {
|
8282
|
+
var removeHexPrefix = /* @__PURE__ */ __name((hexString) => {
|
8196
8283
|
if (/^0x/.test(hexString)) {
|
8197
8284
|
return hexString.slice(2);
|
8198
8285
|
}
|
8199
8286
|
return hexString;
|
8200
|
-
};
|
8287
|
+
}, "removeHexPrefix");
|
8201
8288
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
8202
8289
|
const privateKeyBuffer = (0, import_crypto4.bufferFromString)(removeHexPrefix(privateKey), "hex");
|
8203
8290
|
const ownerAddress = new import_address7.Address(address);
|
@@ -8236,6 +8323,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
8236
8323
|
};
|
8237
8324
|
return JSON.stringify(keystore);
|
8238
8325
|
}
|
8326
|
+
__name(encryptKeystoreWallet, "encryptKeystoreWallet");
|
8239
8327
|
async function decryptKeystoreWallet(jsonWallet, password) {
|
8240
8328
|
const keystoreWallet = JSON.parse(jsonWallet);
|
8241
8329
|
const {
|
@@ -8271,9 +8359,17 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
8271
8359
|
const privateKey = (0, import_utils36.hexlify)(buffer);
|
8272
8360
|
return privateKey;
|
8273
8361
|
}
|
8362
|
+
__name(decryptKeystoreWallet, "decryptKeystoreWallet");
|
8274
8363
|
|
8275
8364
|
// src/wallet/base-wallet-unlocked.ts
|
8276
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";
|
8277
8373
|
/**
|
8278
8374
|
* A function that returns the wallet's signer.
|
8279
8375
|
*/
|
@@ -8391,10 +8487,6 @@ var BaseWalletUnlocked = class extends Account {
|
|
8391
8487
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
8392
8488
|
}
|
8393
8489
|
};
|
8394
|
-
/**
|
8395
|
-
* Default HDWallet path.
|
8396
|
-
*/
|
8397
|
-
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
8398
8490
|
|
8399
8491
|
// src/hdwallet/hdwallet.ts
|
8400
8492
|
var import_crypto6 = require("@fuel-ts/crypto");
|
@@ -10474,21 +10566,25 @@ var import_utils38 = require("@fuel-ts/utils");
|
|
10474
10566
|
function getLowerMask(bits) {
|
10475
10567
|
return (1 << bits) - 1;
|
10476
10568
|
}
|
10569
|
+
__name(getLowerMask, "getLowerMask");
|
10477
10570
|
function getUpperMask(bits) {
|
10478
10571
|
return (1 << bits) - 1 << 8 - bits;
|
10479
10572
|
}
|
10573
|
+
__name(getUpperMask, "getUpperMask");
|
10480
10574
|
function getWords(mnemonic) {
|
10481
10575
|
if (!Array.isArray(mnemonic)) {
|
10482
10576
|
return mnemonic.split(/\s+/);
|
10483
10577
|
}
|
10484
10578
|
return mnemonic;
|
10485
10579
|
}
|
10580
|
+
__name(getWords, "getWords");
|
10486
10581
|
function getPhrase(mnemonic) {
|
10487
10582
|
if (Array.isArray(mnemonic)) {
|
10488
10583
|
return mnemonic.join(" ");
|
10489
10584
|
}
|
10490
10585
|
return mnemonic;
|
10491
10586
|
}
|
10587
|
+
__name(getPhrase, "getPhrase");
|
10492
10588
|
function entropyToMnemonicIndices(entropy) {
|
10493
10589
|
const indices = [0];
|
10494
10590
|
let remainingBits = 11;
|
@@ -10510,6 +10606,7 @@ function entropyToMnemonicIndices(entropy) {
|
|
10510
10606
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
10511
10607
|
return indices;
|
10512
10608
|
}
|
10609
|
+
__name(entropyToMnemonicIndices, "entropyToMnemonicIndices");
|
10513
10610
|
function mnemonicWordsToEntropy(words, wordlist) {
|
10514
10611
|
const size = Math.ceil(11 * words.length / 8);
|
10515
10612
|
const entropy = (0, import_utils38.arrayify)(new Uint8Array(size));
|
@@ -10541,6 +10638,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
10541
10638
|
}
|
10542
10639
|
return entropy.slice(0, entropyBits / 8);
|
10543
10640
|
}
|
10641
|
+
__name(mnemonicWordsToEntropy, "mnemonicWordsToEntropy");
|
10544
10642
|
|
10545
10643
|
// src/mnemonic/mnemonic.ts
|
10546
10644
|
var MasterSecret = (0, import_utils39.toUtf8Bytes)("Bitcoin seed");
|
@@ -10555,6 +10653,7 @@ function assertWordList(wordlist) {
|
|
10555
10653
|
);
|
10556
10654
|
}
|
10557
10655
|
}
|
10656
|
+
__name(assertWordList, "assertWordList");
|
10558
10657
|
function assertEntropy(entropy) {
|
10559
10658
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
10560
10659
|
throw new import_errors25.FuelError(
|
@@ -10563,6 +10662,7 @@ function assertEntropy(entropy) {
|
|
10563
10662
|
);
|
10564
10663
|
}
|
10565
10664
|
}
|
10665
|
+
__name(assertEntropy, "assertEntropy");
|
10566
10666
|
function assertMnemonic(words) {
|
10567
10667
|
if (!MNEMONIC_SIZES.includes(words.length)) {
|
10568
10668
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
@@ -10571,7 +10671,11 @@ function assertMnemonic(words) {
|
|
10571
10671
|
throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
10572
10672
|
}
|
10573
10673
|
}
|
10574
|
-
|
10674
|
+
__name(assertMnemonic, "assertMnemonic");
|
10675
|
+
var Mnemonic = class _Mnemonic {
|
10676
|
+
static {
|
10677
|
+
__name(this, "Mnemonic");
|
10678
|
+
}
|
10575
10679
|
wordlist;
|
10576
10680
|
/**
|
10577
10681
|
*
|
@@ -10588,7 +10692,7 @@ var Mnemonic = class {
|
|
10588
10692
|
* @returns Entropy hash
|
10589
10693
|
*/
|
10590
10694
|
mnemonicToEntropy(phrase) {
|
10591
|
-
return
|
10695
|
+
return _Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
|
10592
10696
|
}
|
10593
10697
|
/**
|
10594
10698
|
*
|
@@ -10596,7 +10700,7 @@ var Mnemonic = class {
|
|
10596
10700
|
* @returns Mnemonic phrase
|
10597
10701
|
*/
|
10598
10702
|
entropyToMnemonic(entropy) {
|
10599
|
-
return
|
10703
|
+
return _Mnemonic.entropyToMnemonic(entropy, this.wordlist);
|
10600
10704
|
}
|
10601
10705
|
/**
|
10602
10706
|
*
|
@@ -10637,8 +10741,8 @@ var Mnemonic = class {
|
|
10637
10741
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
10638
10742
|
*/
|
10639
10743
|
static mnemonicToMasterKeys(phrase, passphrase = "") {
|
10640
|
-
const seed =
|
10641
|
-
return
|
10744
|
+
const seed = _Mnemonic.mnemonicToSeed(phrase, passphrase);
|
10745
|
+
return _Mnemonic.masterKeysFromSeed(seed);
|
10642
10746
|
}
|
10643
10747
|
/**
|
10644
10748
|
* Validates if given mnemonic is valid
|
@@ -10654,7 +10758,7 @@ var Mnemonic = class {
|
|
10654
10758
|
return false;
|
10655
10759
|
}
|
10656
10760
|
while (i < words.length) {
|
10657
|
-
if (
|
10761
|
+
if (_Mnemonic.binarySearch(words[i]) === false) {
|
10658
10762
|
return false;
|
10659
10763
|
}
|
10660
10764
|
i += 1;
|
@@ -10701,7 +10805,7 @@ var Mnemonic = class {
|
|
10701
10805
|
* @returns BIP-32 extended private key
|
10702
10806
|
*/
|
10703
10807
|
static seedToExtendedKey(seed, testnet = false) {
|
10704
|
-
const masterKey =
|
10808
|
+
const masterKey = _Mnemonic.masterKeysFromSeed(seed);
|
10705
10809
|
const prefix = (0, import_utils39.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
10706
10810
|
const depth = "0x00";
|
10707
10811
|
const fingerprint = "0x00000000";
|
@@ -10733,7 +10837,7 @@ var Mnemonic = class {
|
|
10733
10837
|
*/
|
10734
10838
|
static generate(size = 32, extraEntropy = "") {
|
10735
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);
|
10736
|
-
return
|
10840
|
+
return _Mnemonic.entropyToMnemonic(entropy);
|
10737
10841
|
}
|
10738
10842
|
};
|
10739
10843
|
var mnemonic_default = Mnemonic;
|
@@ -10747,20 +10851,24 @@ var TestnetPUB = (0, import_utils41.hexlify)("0x043587cf");
|
|
10747
10851
|
function base58check(data) {
|
10748
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)]));
|
10749
10853
|
}
|
10854
|
+
__name(base58check, "base58check");
|
10750
10855
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
10751
10856
|
if (isPublic) {
|
10752
10857
|
return testnet ? TestnetPUB : MainnetPUB;
|
10753
10858
|
}
|
10754
10859
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
10755
10860
|
}
|
10861
|
+
__name(getExtendedKeyPrefix, "getExtendedKeyPrefix");
|
10756
10862
|
function isPublicExtendedKey(extendedKey) {
|
10757
10863
|
return [MainnetPUB, TestnetPUB].includes((0, import_utils41.hexlify)(extendedKey.slice(0, 4)));
|
10758
10864
|
}
|
10865
|
+
__name(isPublicExtendedKey, "isPublicExtendedKey");
|
10759
10866
|
function isValidExtendedKey(extendedKey) {
|
10760
10867
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
10761
10868
|
(0, import_utils41.hexlify)(extendedKey.slice(0, 4))
|
10762
10869
|
);
|
10763
10870
|
}
|
10871
|
+
__name(isValidExtendedKey, "isValidExtendedKey");
|
10764
10872
|
function parsePath(path, depth = 0) {
|
10765
10873
|
const components = path.split("/");
|
10766
10874
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
@@ -10773,7 +10881,11 @@ function parsePath(path, depth = 0) {
|
|
10773
10881
|
(p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
|
10774
10882
|
);
|
10775
10883
|
}
|
10776
|
-
|
10884
|
+
__name(parsePath, "parsePath");
|
10885
|
+
var HDWallet = class _HDWallet {
|
10886
|
+
static {
|
10887
|
+
__name(this, "HDWallet");
|
10888
|
+
}
|
10777
10889
|
depth = 0;
|
10778
10890
|
index = 0;
|
10779
10891
|
fingerprint = (0, import_utils41.hexlify)("0x00000000");
|
@@ -10839,7 +10951,7 @@ var HDWallet = class {
|
|
10839
10951
|
if (privateKey) {
|
10840
10952
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
10841
10953
|
const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
10842
|
-
return new
|
10954
|
+
return new _HDWallet({
|
10843
10955
|
privateKey: ki,
|
10844
10956
|
chainCode: IR,
|
10845
10957
|
index,
|
@@ -10849,7 +10961,7 @@ var HDWallet = class {
|
|
10849
10961
|
}
|
10850
10962
|
const signer = new Signer((0, import_utils41.hexlify)(IL));
|
10851
10963
|
const Ki = signer.addPoint(publicKey);
|
10852
|
-
return new
|
10964
|
+
return new _HDWallet({
|
10853
10965
|
publicKey: Ki,
|
10854
10966
|
chainCode: IR,
|
10855
10967
|
index,
|
@@ -10898,7 +11010,7 @@ var HDWallet = class {
|
|
10898
11010
|
*/
|
10899
11011
|
static fromSeed(seed) {
|
10900
11012
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
10901
|
-
return new
|
11013
|
+
return new _HDWallet({
|
10902
11014
|
chainCode: (0, import_utils41.arrayify)(masterKey.slice(32)),
|
10903
11015
|
privateKey: (0, import_utils41.arrayify)(masterKey.slice(0, 32))
|
10904
11016
|
});
|
@@ -10928,7 +11040,7 @@ var HDWallet = class {
|
|
10928
11040
|
if (key[0] !== 3) {
|
10929
11041
|
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
10930
11042
|
}
|
10931
|
-
return new
|
11043
|
+
return new _HDWallet({
|
10932
11044
|
publicKey: key,
|
10933
11045
|
chainCode,
|
10934
11046
|
index,
|
@@ -10939,7 +11051,7 @@ var HDWallet = class {
|
|
10939
11051
|
if (key[0] !== 0) {
|
10940
11052
|
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
10941
11053
|
}
|
10942
|
-
return new
|
11054
|
+
return new _HDWallet({
|
10943
11055
|
privateKey: key.slice(1),
|
10944
11056
|
chainCode,
|
10945
11057
|
index,
|
@@ -10952,6 +11064,9 @@ var hdwallet_default = HDWallet;
|
|
10952
11064
|
|
10953
11065
|
// src/wallet/wallets.ts
|
10954
11066
|
var WalletLocked = class extends Account {
|
11067
|
+
static {
|
11068
|
+
__name(this, "WalletLocked");
|
11069
|
+
}
|
10955
11070
|
/**
|
10956
11071
|
* Unlocks the wallet using the provided private key and returns an instance of WalletUnlocked.
|
10957
11072
|
*
|
@@ -10962,7 +11077,10 @@ var WalletLocked = class extends Account {
|
|
10962
11077
|
return new WalletUnlocked(privateKey, this._provider);
|
10963
11078
|
}
|
10964
11079
|
};
|
10965
|
-
var WalletUnlocked = class extends BaseWalletUnlocked {
|
11080
|
+
var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
11081
|
+
static {
|
11082
|
+
__name(this, "WalletUnlocked");
|
11083
|
+
}
|
10966
11084
|
/**
|
10967
11085
|
* Locks the wallet and returns an instance of WalletLocked.
|
10968
11086
|
*
|
@@ -10980,7 +11098,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10980
11098
|
*/
|
10981
11099
|
static generate(generateOptions) {
|
10982
11100
|
const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
|
10983
|
-
return new
|
11101
|
+
return new _WalletUnlocked(privateKey, generateOptions?.provider);
|
10984
11102
|
}
|
10985
11103
|
/**
|
10986
11104
|
* Create a Wallet Unlocked from a seed.
|
@@ -10992,8 +11110,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10992
11110
|
*/
|
10993
11111
|
static fromSeed(seed, path, provider) {
|
10994
11112
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
10995
|
-
const childWallet = hdWallet.derivePath(path ||
|
10996
|
-
return new
|
11113
|
+
const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
|
11114
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
10997
11115
|
}
|
10998
11116
|
/**
|
10999
11117
|
* Create a Wallet Unlocked from a mnemonic phrase.
|
@@ -11007,8 +11125,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
11007
11125
|
static fromMnemonic(mnemonic, path, passphrase, provider) {
|
11008
11126
|
const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
|
11009
11127
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
11010
|
-
const childWallet = hdWallet.derivePath(path ||
|
11011
|
-
return new
|
11128
|
+
const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
|
11129
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
11012
11130
|
}
|
11013
11131
|
/**
|
11014
11132
|
* Create a Wallet Unlocked from an extended key.
|
@@ -11019,7 +11137,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
11019
11137
|
*/
|
11020
11138
|
static fromExtendedKey(extendedKey, provider) {
|
11021
11139
|
const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
|
11022
|
-
return new
|
11140
|
+
return new _WalletUnlocked(hdWallet.privateKey, provider);
|
11023
11141
|
}
|
11024
11142
|
/**
|
11025
11143
|
* Create a Wallet Unlocked from an encrypted JSON.
|
@@ -11031,12 +11149,15 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
11031
11149
|
*/
|
11032
11150
|
static async fromEncryptedJson(jsonWallet, password, provider) {
|
11033
11151
|
const privateKey = await decryptKeystoreWallet(jsonWallet, password);
|
11034
|
-
return new
|
11152
|
+
return new _WalletUnlocked(privateKey, provider);
|
11035
11153
|
}
|
11036
11154
|
};
|
11037
11155
|
|
11038
11156
|
// src/wallet/wallet.ts
|
11039
11157
|
var Wallet = class {
|
11158
|
+
static {
|
11159
|
+
__name(this, "Wallet");
|
11160
|
+
}
|
11040
11161
|
/**
|
11041
11162
|
* Creates a locked wallet instance from an address and a provider.
|
11042
11163
|
*
|
@@ -11057,50 +11178,50 @@ var Wallet = class {
|
|
11057
11178
|
static fromPrivateKey(privateKey, provider) {
|
11058
11179
|
return new WalletUnlocked(privateKey, provider);
|
11059
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;
|
11060
11224
|
};
|
11061
|
-
/**
|
11062
|
-
* Generate a new Wallet Unlocked with a random key pair.
|
11063
|
-
*
|
11064
|
-
* @param generateOptions - Options to customize the generation process (optional).
|
11065
|
-
* @returns An unlocked wallet instance.
|
11066
|
-
*/
|
11067
|
-
__publicField(Wallet, "generate", WalletUnlocked.generate);
|
11068
|
-
/**
|
11069
|
-
* Create a Wallet Unlocked from a seed.
|
11070
|
-
*
|
11071
|
-
* @param seed - The seed phrase.
|
11072
|
-
* @param provider - A Provider instance (optional).
|
11073
|
-
* @param path - The derivation path (optional).
|
11074
|
-
* @returns An unlocked wallet instance.
|
11075
|
-
*/
|
11076
|
-
__publicField(Wallet, "fromSeed", WalletUnlocked.fromSeed);
|
11077
|
-
/**
|
11078
|
-
* Create a Wallet Unlocked from a mnemonic phrase.
|
11079
|
-
*
|
11080
|
-
* @param mnemonic - The mnemonic phrase.
|
11081
|
-
* @param provider - A Provider instance (optional).
|
11082
|
-
* @param path - The derivation path (optional).
|
11083
|
-
* @param passphrase - The passphrase for the mnemonic (optional).
|
11084
|
-
* @returns An unlocked wallet instance.
|
11085
|
-
*/
|
11086
|
-
__publicField(Wallet, "fromMnemonic", WalletUnlocked.fromMnemonic);
|
11087
|
-
/**
|
11088
|
-
* Create a Wallet Unlocked from an extended key.
|
11089
|
-
*
|
11090
|
-
* @param extendedKey - The extended key.
|
11091
|
-
* @param provider - A Provider instance (optional).
|
11092
|
-
* @returns An unlocked wallet instance.
|
11093
|
-
*/
|
11094
|
-
__publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
11095
|
-
/**
|
11096
|
-
* Create a Wallet Unlocked from an encrypted JSON.
|
11097
|
-
*
|
11098
|
-
* @param jsonWallet - The encrypted JSON keystore.
|
11099
|
-
* @param password - The password to decrypt the JSON.
|
11100
|
-
* @param provider - A Provider instance (optional).
|
11101
|
-
* @returns An unlocked wallet instance.
|
11102
|
-
*/
|
11103
|
-
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
11104
11225
|
|
11105
11226
|
// src/wallet-manager/wallet-manager.ts
|
11106
11227
|
var import_address10 = require("@fuel-ts/address");
|
@@ -11110,6 +11231,9 @@ var import_events = require("events");
|
|
11110
11231
|
|
11111
11232
|
// src/wallet-manager/storages/memory-storage.ts
|
11112
11233
|
var MemoryStorage = class {
|
11234
|
+
static {
|
11235
|
+
__name(this, "MemoryStorage");
|
11236
|
+
}
|
11113
11237
|
storage = /* @__PURE__ */ new Map();
|
11114
11238
|
async getItem(key) {
|
11115
11239
|
const item = await this.storage.get(key);
|
@@ -11129,14 +11253,17 @@ var MemoryStorage = class {
|
|
11129
11253
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
11130
11254
|
var import_address8 = require("@fuel-ts/address");
|
11131
11255
|
var import_errors27 = require("@fuel-ts/errors");
|
11132
|
-
var _secret;
|
11133
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;
|
11134
11265
|
constructor(options) {
|
11135
|
-
|
11136
|
-
__publicField(this, "pathKey", "{}");
|
11137
|
-
__publicField(this, "rootPath", `m/44'/1179993420'/${this.pathKey}'/0/0`);
|
11138
|
-
__publicField(this, "numberOfAccounts", 0);
|
11139
|
-
__privateSet(this, _secret, options.secret || mnemonic_default.generate());
|
11266
|
+
this.#secret = options.secret || mnemonic_default.generate();
|
11140
11267
|
this.rootPath = options.rootPath || this.rootPath;
|
11141
11268
|
this.numberOfAccounts = options.numberOfAccounts || 1;
|
11142
11269
|
}
|
@@ -11148,7 +11275,7 @@ var MnemonicVault = class {
|
|
11148
11275
|
}
|
11149
11276
|
serialize() {
|
11150
11277
|
return {
|
11151
|
-
secret:
|
11278
|
+
secret: this.#secret,
|
11152
11279
|
rootPath: this.rootPath,
|
11153
11280
|
numberOfAccounts: this.numberOfAccounts
|
11154
11281
|
};
|
@@ -11157,7 +11284,7 @@ var MnemonicVault = class {
|
|
11157
11284
|
const accounts = [];
|
11158
11285
|
let numberOfAccounts = 0;
|
11159
11286
|
do {
|
11160
|
-
const wallet = Wallet.fromMnemonic(
|
11287
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
|
11161
11288
|
accounts.push({
|
11162
11289
|
publicKey: wallet.publicKey,
|
11163
11290
|
address: wallet.address
|
@@ -11168,7 +11295,7 @@ var MnemonicVault = class {
|
|
11168
11295
|
}
|
11169
11296
|
addAccount() {
|
11170
11297
|
this.numberOfAccounts += 1;
|
11171
|
-
const wallet = Wallet.fromMnemonic(
|
11298
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(this.numberOfAccounts - 1));
|
11172
11299
|
return {
|
11173
11300
|
publicKey: wallet.publicKey,
|
11174
11301
|
address: wallet.address
|
@@ -11178,7 +11305,7 @@ var MnemonicVault = class {
|
|
11178
11305
|
let numberOfAccounts = 0;
|
11179
11306
|
const ownerAddress = new import_address8.Address(address);
|
11180
11307
|
do {
|
11181
|
-
const wallet = Wallet.fromMnemonic(
|
11308
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
|
11182
11309
|
if (wallet.address.equals(ownerAddress)) {
|
11183
11310
|
return wallet.privateKey;
|
11184
11311
|
}
|
@@ -11194,29 +11321,30 @@ var MnemonicVault = class {
|
|
11194
11321
|
return Wallet.fromPrivateKey(privateKey);
|
11195
11322
|
}
|
11196
11323
|
};
|
11197
|
-
_secret = new WeakMap();
|
11198
|
-
__publicField(MnemonicVault, "type", "mnemonic");
|
11199
11324
|
|
11200
11325
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
11201
11326
|
var import_address9 = require("@fuel-ts/address");
|
11202
11327
|
var import_errors28 = require("@fuel-ts/errors");
|
11203
|
-
var _privateKeys;
|
11204
11328
|
var PrivateKeyVault = class {
|
11329
|
+
static {
|
11330
|
+
__name(this, "PrivateKeyVault");
|
11331
|
+
}
|
11332
|
+
static type = "privateKey";
|
11333
|
+
#privateKeys = [];
|
11205
11334
|
/**
|
11206
11335
|
* If privateKey vault is initialized with a secretKey, it creates
|
11207
11336
|
* one account with the fallowing secret
|
11208
11337
|
*/
|
11209
11338
|
constructor(options = {}) {
|
11210
|
-
__privateAdd(this, _privateKeys, []);
|
11211
11339
|
if (options.secret) {
|
11212
|
-
|
11340
|
+
this.#privateKeys = [options.secret];
|
11213
11341
|
} else {
|
11214
|
-
|
11342
|
+
this.#privateKeys = options.accounts || [Wallet.generate().privateKey];
|
11215
11343
|
}
|
11216
11344
|
}
|
11217
11345
|
serialize() {
|
11218
11346
|
return {
|
11219
|
-
accounts:
|
11347
|
+
accounts: this.#privateKeys
|
11220
11348
|
};
|
11221
11349
|
}
|
11222
11350
|
getPublicAccount(privateKey) {
|
@@ -11227,16 +11355,16 @@ var PrivateKeyVault = class {
|
|
11227
11355
|
};
|
11228
11356
|
}
|
11229
11357
|
getAccounts() {
|
11230
|
-
return
|
11358
|
+
return this.#privateKeys.map((pk) => this.getPublicAccount(pk));
|
11231
11359
|
}
|
11232
11360
|
addAccount() {
|
11233
11361
|
const wallet = Wallet.generate();
|
11234
|
-
|
11362
|
+
this.#privateKeys.push(wallet.privateKey);
|
11235
11363
|
return this.getPublicAccount(wallet.privateKey);
|
11236
11364
|
}
|
11237
11365
|
exportAccount(address) {
|
11238
11366
|
const ownerAddress = new import_address9.Address(address);
|
11239
|
-
const privateKey =
|
11367
|
+
const privateKey = this.#privateKeys.find(
|
11240
11368
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
11241
11369
|
);
|
11242
11370
|
if (!privateKey) {
|
@@ -11252,8 +11380,6 @@ var PrivateKeyVault = class {
|
|
11252
11380
|
return Wallet.fromPrivateKey(privateKey);
|
11253
11381
|
}
|
11254
11382
|
};
|
11255
|
-
_privateKeys = new WeakMap();
|
11256
|
-
__publicField(PrivateKeyVault, "type", "privateKey");
|
11257
11383
|
|
11258
11384
|
// src/wallet-manager/wallet-manager.ts
|
11259
11385
|
var ERROR_MESSAGES = {
|
@@ -11268,46 +11394,47 @@ function assert(condition, message) {
|
|
11268
11394
|
throw new import_errors29.FuelError(import_errors29.ErrorCode.WALLET_MANAGER_ERROR, message);
|
11269
11395
|
}
|
11270
11396
|
}
|
11271
|
-
|
11272
|
-
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;
|
11273
11424
|
constructor(options) {
|
11274
11425
|
super();
|
11275
|
-
/**
|
11276
|
-
* Serialize all vaults to store
|
11277
|
-
*
|
11278
|
-
* `This is only accessible from inside the class`
|
11279
|
-
*/
|
11280
|
-
__privateAdd(this, _serializeVaults);
|
11281
|
-
/**
|
11282
|
-
* Deserialize all vaults to state
|
11283
|
-
*
|
11284
|
-
* `This is only accessible from inside the class`
|
11285
|
-
*/
|
11286
|
-
__privateAdd(this, _deserializeVaults);
|
11287
|
-
/**
|
11288
|
-
* Storage
|
11289
|
-
*
|
11290
|
-
* Persistent encrypted data. `The default storage works only on memory`.
|
11291
|
-
*/
|
11292
|
-
__publicField(this, "storage", new MemoryStorage());
|
11293
|
-
/* Key name passed to the storage */
|
11294
|
-
__publicField(this, "STORAGE_KEY", "WalletManager");
|
11295
|
-
// `This variables are only accessible from inside the class`
|
11296
|
-
__privateAdd(this, _vaults, []);
|
11297
|
-
__privateAdd(this, _passphrase, "");
|
11298
|
-
__privateAdd(this, _isLocked, true);
|
11299
11426
|
this.storage = options?.storage || this.storage;
|
11300
11427
|
}
|
11301
11428
|
get isLocked() {
|
11302
|
-
return
|
11429
|
+
return this.#isLocked;
|
11303
11430
|
}
|
11304
11431
|
/**
|
11305
11432
|
* Return the vault serialized object containing all the privateKeys,
|
11306
11433
|
* the format of the return depends on the Vault type.
|
11307
11434
|
*/
|
11308
11435
|
exportVault(vaultId) {
|
11309
|
-
assert(!
|
11310
|
-
const vaultState =
|
11436
|
+
assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
11437
|
+
const vaultState = this.#vaults.find((_, idx) => idx === vaultId);
|
11311
11438
|
assert(vaultState, ERROR_MESSAGES.vault_not_found);
|
11312
11439
|
return vaultState.vault.serialize();
|
11313
11440
|
}
|
@@ -11315,7 +11442,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11315
11442
|
* List all vaults on the Wallet Manager, this function not return secret's
|
11316
11443
|
*/
|
11317
11444
|
getVaults() {
|
11318
|
-
return
|
11445
|
+
return this.#vaults.map((v, idx) => ({
|
11319
11446
|
title: v.title,
|
11320
11447
|
type: v.type,
|
11321
11448
|
vaultId: idx
|
@@ -11325,7 +11452,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11325
11452
|
* List all accounts on the Wallet Manager not vault information is revealed
|
11326
11453
|
*/
|
11327
11454
|
getAccounts() {
|
11328
|
-
return
|
11455
|
+
return this.#vaults.flatMap(
|
11329
11456
|
(vaultState, vaultId) => vaultState.vault.getAccounts().map((account) => ({ ...account, vaultId }))
|
11330
11457
|
);
|
11331
11458
|
}
|
@@ -11334,7 +11461,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11334
11461
|
*/
|
11335
11462
|
getWallet(address) {
|
11336
11463
|
const ownerAddress = new import_address10.Address(address);
|
11337
|
-
const vaultState =
|
11464
|
+
const vaultState = this.#vaults.find(
|
11338
11465
|
(vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
|
11339
11466
|
);
|
11340
11467
|
assert(vaultState, ERROR_MESSAGES.address_not_found);
|
@@ -11345,8 +11472,8 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11345
11472
|
*/
|
11346
11473
|
exportPrivateKey(address) {
|
11347
11474
|
const ownerAddress = new import_address10.Address(address);
|
11348
|
-
assert(!
|
11349
|
-
const vaultState =
|
11475
|
+
assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
11476
|
+
const vaultState = this.#vaults.find(
|
11350
11477
|
(vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
|
11351
11478
|
);
|
11352
11479
|
assert(vaultState, ERROR_MESSAGES.address_not_found);
|
@@ -11358,7 +11485,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11358
11485
|
*/
|
11359
11486
|
async addAccount(options) {
|
11360
11487
|
await this.loadState();
|
11361
|
-
const vaultState =
|
11488
|
+
const vaultState = this.#vaults[options?.vaultId || 0];
|
11362
11489
|
await assert(vaultState, ERROR_MESSAGES.vault_not_found);
|
11363
11490
|
const account = vaultState.vault.addAccount();
|
11364
11491
|
await this.saveState();
|
@@ -11369,7 +11496,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11369
11496
|
* created by the vault.
|
11370
11497
|
*/
|
11371
11498
|
async removeVault(index) {
|
11372
|
-
|
11499
|
+
this.#vaults.splice(index, 1);
|
11373
11500
|
await this.saveState();
|
11374
11501
|
}
|
11375
11502
|
/**
|
@@ -11380,11 +11507,11 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11380
11507
|
await this.loadState();
|
11381
11508
|
const Vault2 = this.getVaultClass(vaultConfig.type);
|
11382
11509
|
const vault = new Vault2(vaultConfig);
|
11383
|
-
|
11510
|
+
this.#vaults = this.#vaults.concat({
|
11384
11511
|
title: vaultConfig.title,
|
11385
11512
|
type: vaultConfig.type,
|
11386
11513
|
vault
|
11387
|
-
})
|
11514
|
+
});
|
11388
11515
|
await this.saveState();
|
11389
11516
|
}
|
11390
11517
|
/**
|
@@ -11392,9 +11519,9 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11392
11519
|
* secrets.
|
11393
11520
|
*/
|
11394
11521
|
lock() {
|
11395
|
-
|
11396
|
-
|
11397
|
-
|
11522
|
+
this.#isLocked = true;
|
11523
|
+
this.#vaults = [];
|
11524
|
+
this.#passphrase = "";
|
11398
11525
|
this.emit("lock");
|
11399
11526
|
}
|
11400
11527
|
/**
|
@@ -11402,8 +11529,8 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11402
11529
|
* Vaults with secrets are not unlocked or instantiated on this moment.
|
11403
11530
|
*/
|
11404
11531
|
async unlock(passphrase) {
|
11405
|
-
|
11406
|
-
|
11532
|
+
this.#passphrase = passphrase;
|
11533
|
+
this.#isLocked = false;
|
11407
11534
|
try {
|
11408
11535
|
await this.loadState();
|
11409
11536
|
this.emit("unlock");
|
@@ -11416,9 +11543,9 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11416
11543
|
* Update WalletManager encryption passphrase
|
11417
11544
|
*/
|
11418
11545
|
async updatePassphrase(oldpass, newpass) {
|
11419
|
-
const isLocked =
|
11546
|
+
const isLocked = this.#isLocked;
|
11420
11547
|
await this.unlock(oldpass);
|
11421
|
-
|
11548
|
+
this.#passphrase = newpass;
|
11422
11549
|
await this.saveState();
|
11423
11550
|
await this.loadState();
|
11424
11551
|
if (isLocked) {
|
@@ -11429,24 +11556,51 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11429
11556
|
* Retrieve and decrypt WalletManager state from storage
|
11430
11557
|
*/
|
11431
11558
|
async loadState() {
|
11432
|
-
await assert(!
|
11559
|
+
await assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
11433
11560
|
const data = await this.storage.getItem(this.STORAGE_KEY);
|
11434
11561
|
if (data) {
|
11435
|
-
const state = await (0, import_crypto7.decrypt)(
|
11436
|
-
|
11562
|
+
const state = await (0, import_crypto7.decrypt)(this.#passphrase, JSON.parse(data));
|
11563
|
+
this.#vaults = this.#deserializeVaults(state.vaults);
|
11437
11564
|
}
|
11438
11565
|
}
|
11439
11566
|
/**
|
11440
11567
|
* Store encrypted WalletManager state on storage
|
11441
11568
|
*/
|
11442
11569
|
async saveState() {
|
11443
|
-
await assert(!
|
11444
|
-
const encryptedData = await (0, import_crypto7.encrypt)(
|
11445
|
-
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)
|
11446
11573
|
});
|
11447
11574
|
await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
|
11448
11575
|
this.emit("update");
|
11449
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
|
+
}
|
11450
11604
|
/**
|
11451
11605
|
* Return a instantiable Class reference from `WalletManager.Vaults` supported list.
|
11452
11606
|
*/
|
@@ -11456,43 +11610,14 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
11456
11610
|
return VaultClass;
|
11457
11611
|
}
|
11458
11612
|
};
|
11459
|
-
var WalletManager = _WalletManager;
|
11460
|
-
_vaults = new WeakMap();
|
11461
|
-
_passphrase = new WeakMap();
|
11462
|
-
_isLocked = new WeakMap();
|
11463
|
-
_serializeVaults = new WeakSet();
|
11464
|
-
serializeVaults_fn = function(vaults) {
|
11465
|
-
return vaults.map(({ title, type, vault }) => ({
|
11466
|
-
title,
|
11467
|
-
type,
|
11468
|
-
data: vault.serialize()
|
11469
|
-
}));
|
11470
|
-
};
|
11471
|
-
_deserializeVaults = new WeakSet();
|
11472
|
-
deserializeVaults_fn = function(vaults) {
|
11473
|
-
return vaults.map(({ title, type, data: vaultConfig }) => {
|
11474
|
-
const VaultClass = this.getVaultClass(type);
|
11475
|
-
return {
|
11476
|
-
title,
|
11477
|
-
type,
|
11478
|
-
vault: new VaultClass(vaultConfig)
|
11479
|
-
};
|
11480
|
-
});
|
11481
|
-
};
|
11482
|
-
/**
|
11483
|
-
* Vaults
|
11484
|
-
*
|
11485
|
-
* Vaults are responsible to store secret keys and return an `Wallet` instance,
|
11486
|
-
* to interact with the network.
|
11487
|
-
*
|
11488
|
-
* Each vault has access to its own state
|
11489
|
-
*
|
11490
|
-
*/
|
11491
|
-
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
11492
11613
|
|
11493
11614
|
// src/wallet-manager/types.ts
|
11494
11615
|
var import_errors30 = require("@fuel-ts/errors");
|
11495
11616
|
var Vault = class {
|
11617
|
+
static {
|
11618
|
+
__name(this, "Vault");
|
11619
|
+
}
|
11620
|
+
static type;
|
11496
11621
|
constructor(_options) {
|
11497
11622
|
throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
11498
11623
|
}
|
@@ -11512,8 +11637,10 @@ var Vault = class {
|
|
11512
11637
|
throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
11513
11638
|
}
|
11514
11639
|
};
|
11515
|
-
__publicField(Vault, "type");
|
11516
11640
|
var StorageAbstract = class {
|
11641
|
+
static {
|
11642
|
+
__name(this, "StorageAbstract");
|
11643
|
+
}
|
11517
11644
|
};
|
11518
11645
|
|
11519
11646
|
// src/predicate/predicate.ts
|
@@ -11543,26 +11670,30 @@ function getBytecodeDataOffset(bytecode) {
|
|
11543
11670
|
const [offset] = new import_abi_coder7.BigNumberCoder("u64").decode(bytecode, DATA_OFFSET_INDEX);
|
11544
11671
|
return offset.toNumber();
|
11545
11672
|
}
|
11673
|
+
__name(getBytecodeDataOffset, "getBytecodeDataOffset");
|
11546
11674
|
function getBytecodeConfigurableOffset(bytecode) {
|
11547
11675
|
const [offset] = new import_abi_coder7.BigNumberCoder("u64").decode(bytecode, CONFIGURABLE_OFFSET_INDEX);
|
11548
11676
|
return offset.toNumber();
|
11549
11677
|
}
|
11678
|
+
__name(getBytecodeConfigurableOffset, "getBytecodeConfigurableOffset");
|
11550
11679
|
function getBytecodeId(bytecode) {
|
11551
11680
|
const configurableOffset = getBytecodeConfigurableOffset(bytecode);
|
11552
11681
|
const byteCodeWithoutConfigurableSection = bytecode.slice(0, configurableOffset);
|
11553
11682
|
return (0, import_hasher8.sha256)(byteCodeWithoutConfigurableSection);
|
11554
11683
|
}
|
11684
|
+
__name(getBytecodeId, "getBytecodeId");
|
11555
11685
|
function getLegacyBlobId(bytecode) {
|
11556
11686
|
const dataOffset = getBytecodeDataOffset(bytecode);
|
11557
11687
|
const byteCodeWithoutDataSection = bytecode.slice(0, dataOffset);
|
11558
11688
|
return (0, import_hasher8.sha256)(byteCodeWithoutDataSection);
|
11559
11689
|
}
|
11690
|
+
__name(getLegacyBlobId, "getLegacyBlobId");
|
11560
11691
|
function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
11561
11692
|
const { RegId, Instruction } = asm2;
|
11562
11693
|
const REG_PC = RegId.pc().to_u8();
|
11563
11694
|
const REG_SP = RegId.sp().to_u8();
|
11564
11695
|
const REG_IS = RegId.is().to_u8();
|
11565
|
-
const getInstructions = (numOfInstructions2) => [
|
11696
|
+
const getInstructions = /* @__PURE__ */ __name((numOfInstructions2) => [
|
11566
11697
|
// 1. Load the blob content into memory
|
11567
11698
|
// Find the start of the hardcoded blob ID, which is located after the loader code ends.
|
11568
11699
|
asm2.move_(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_PC),
|
@@ -11596,8 +11727,8 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
|
11596
11727
|
asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
|
11597
11728
|
// Jump to the start of the contract we loaded.
|
11598
11729
|
asm2.jmp(REG_START_OF_LOADED_CODE)
|
11599
|
-
];
|
11600
|
-
const getInstructionsNoDataSection = (numOfInstructions2) => [
|
11730
|
+
], "getInstructions");
|
11731
|
+
const getInstructionsNoDataSection = /* @__PURE__ */ __name((numOfInstructions2) => [
|
11601
11732
|
// 1. Load the blob content into memory
|
11602
11733
|
// Find the start of the hardcoded blob ID, which is located after the loader code ends.
|
11603
11734
|
// 1. Load the blob content into memory
|
@@ -11624,7 +11755,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
|
11624
11755
|
asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
|
11625
11756
|
// Jump to the start of the contract we loaded.
|
11626
11757
|
asm2.jmp(REG_START_OF_LOADED_CODE)
|
11627
|
-
];
|
11758
|
+
], "getInstructionsNoDataSection");
|
11628
11759
|
const offset = getBytecodeConfigurableOffset(originalBinary);
|
11629
11760
|
if (originalBinary.length < offset) {
|
11630
11761
|
throw new Error(
|
@@ -11669,6 +11800,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
|
11669
11800
|
const loaderBytecode = new Uint8Array([...instructionBytes, ...blobBytes]);
|
11670
11801
|
return { loaderBytecode };
|
11671
11802
|
}
|
11803
|
+
__name(getPredicateScriptLoaderInstructions, "getPredicateScriptLoaderInstructions");
|
11672
11804
|
|
11673
11805
|
// src/utils/deployScriptOrPredicate.ts
|
11674
11806
|
async function fundBlobTx(deployer, blobTxRequest) {
|
@@ -11691,6 +11823,7 @@ async function fundBlobTx(deployer, blobTxRequest) {
|
|
11691
11823
|
blobTxRequest.maxFee = txCost.maxFee;
|
11692
11824
|
return deployer.fund(blobTxRequest, txCost);
|
11693
11825
|
}
|
11826
|
+
__name(fundBlobTx, "fundBlobTx");
|
11694
11827
|
function adjustConfigurableOffsets(jsonAbi, configurableOffsetDiff) {
|
11695
11828
|
const { configurables: readOnlyConfigurables } = jsonAbi;
|
11696
11829
|
const configurables = [];
|
@@ -11699,6 +11832,7 @@ function adjustConfigurableOffsets(jsonAbi, configurableOffsetDiff) {
|
|
11699
11832
|
});
|
11700
11833
|
return { ...jsonAbi, configurables };
|
11701
11834
|
}
|
11835
|
+
__name(adjustConfigurableOffsets, "adjustConfigurableOffsets");
|
11702
11836
|
async function deployScriptOrPredicate({
|
11703
11837
|
deployer,
|
11704
11838
|
bytecode,
|
@@ -11723,12 +11857,12 @@ async function deployScriptOrPredicate({
|
|
11723
11857
|
const loaderInstance = loaderInstanceCallback(loaderBytecode, newAbi);
|
11724
11858
|
if (blobExists) {
|
11725
11859
|
return {
|
11726
|
-
waitForResult: () => Promise.resolve(loaderInstance),
|
11860
|
+
waitForResult: /* @__PURE__ */ __name(() => Promise.resolve(loaderInstance), "waitForResult"),
|
11727
11861
|
blobId
|
11728
11862
|
};
|
11729
11863
|
}
|
11730
11864
|
const fundedBlobRequest = await fundBlobTx(deployer, blobTxRequest);
|
11731
|
-
const waitForResult = async () => {
|
11865
|
+
const waitForResult = /* @__PURE__ */ __name(async () => {
|
11732
11866
|
try {
|
11733
11867
|
const blobTx = await deployer.sendTransaction(fundedBlobRequest);
|
11734
11868
|
const result = await blobTx.waitForResult();
|
@@ -11739,28 +11873,32 @@ async function deployScriptOrPredicate({
|
|
11739
11873
|
throw new import_errors31.FuelError(import_errors31.ErrorCode.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
|
11740
11874
|
}
|
11741
11875
|
return loaderInstance;
|
11742
|
-
};
|
11876
|
+
}, "waitForResult");
|
11743
11877
|
return {
|
11744
11878
|
waitForResult,
|
11745
11879
|
blobId
|
11746
11880
|
};
|
11747
11881
|
}
|
11882
|
+
__name(deployScriptOrPredicate, "deployScriptOrPredicate");
|
11748
11883
|
|
11749
11884
|
// src/predicate/utils/getPredicateRoot.ts
|
11750
11885
|
var import_hasher9 = require("@fuel-ts/hasher");
|
11751
11886
|
var import_merkle = require("@fuel-ts/merkle");
|
11752
11887
|
var import_utils44 = require("@fuel-ts/utils");
|
11753
|
-
var getPredicateRoot = (bytecode) => {
|
11888
|
+
var getPredicateRoot = /* @__PURE__ */ __name((bytecode) => {
|
11754
11889
|
const chunkSize = 16 * 1024;
|
11755
11890
|
const bytes = (0, import_utils44.arrayify)(bytecode);
|
11756
11891
|
const chunks = (0, import_utils44.chunkAndPadBytes)(bytes, chunkSize);
|
11757
11892
|
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils44.hexlify)(c)));
|
11758
11893
|
const predicateRoot = (0, import_hasher9.hash)((0, import_utils44.concat)(["0x4655454C", codeRoot]));
|
11759
11894
|
return predicateRoot;
|
11760
|
-
};
|
11895
|
+
}, "getPredicateRoot");
|
11761
11896
|
|
11762
11897
|
// src/predicate/predicate.ts
|
11763
|
-
var Predicate = class extends Account {
|
11898
|
+
var Predicate = class _Predicate extends Account {
|
11899
|
+
static {
|
11900
|
+
__name(this, "Predicate");
|
11901
|
+
}
|
11764
11902
|
bytes;
|
11765
11903
|
predicateData = [];
|
11766
11904
|
interface;
|
@@ -11782,7 +11920,7 @@ var Predicate = class extends Account {
|
|
11782
11920
|
data,
|
11783
11921
|
configurableConstants
|
11784
11922
|
}) {
|
11785
|
-
const { predicateBytes, predicateInterface } =
|
11923
|
+
const { predicateBytes, predicateInterface } = _Predicate.processPredicateData(
|
11786
11924
|
bytecode,
|
11787
11925
|
abi,
|
11788
11926
|
configurableConstants
|
@@ -11851,7 +11989,7 @@ var Predicate = class extends Account {
|
|
11851
11989
|
* @returns A new Predicate instance with the same bytecode, ABI and provider but with the ability to set the data and configurable constants.
|
11852
11990
|
*/
|
11853
11991
|
toNewInstance(overrides = {}) {
|
11854
|
-
return new
|
11992
|
+
return new _Predicate({
|
11855
11993
|
bytecode: this.initialBytecode,
|
11856
11994
|
abi: this.interface.jsonAbi,
|
11857
11995
|
provider: this.provider,
|
@@ -11877,7 +12015,7 @@ var Predicate = class extends Account {
|
|
11877
12015
|
);
|
11878
12016
|
}
|
11879
12017
|
if (configurableConstants && Object.keys(configurableConstants).length) {
|
11880
|
-
predicateBytes =
|
12018
|
+
predicateBytes = _Predicate.setConfigurableConstants(
|
11881
12019
|
predicateBytes,
|
11882
12020
|
configurableConstants,
|
11883
12021
|
abiInterface
|
@@ -11992,12 +12130,12 @@ var Predicate = class extends Account {
|
|
11992
12130
|
deployer: account,
|
11993
12131
|
abi: this.interface.jsonAbi,
|
11994
12132
|
bytecode: this.bytes,
|
11995
|
-
loaderInstanceCallback: (loaderBytecode, newAbi) => new
|
12133
|
+
loaderInstanceCallback: /* @__PURE__ */ __name((loaderBytecode, newAbi) => new _Predicate({
|
11996
12134
|
bytecode: loaderBytecode,
|
11997
12135
|
abi: newAbi,
|
11998
12136
|
provider: this.provider,
|
11999
12137
|
data: this.predicateData
|
12000
|
-
})
|
12138
|
+
}), "loaderInstanceCallback")
|
12001
12139
|
});
|
12002
12140
|
}
|
12003
12141
|
};
|
@@ -12048,6 +12186,9 @@ var FuelConnectorEventType = "FuelConnector";
|
|
12048
12186
|
|
12049
12187
|
// src/connectors/types/local-storage.ts
|
12050
12188
|
var LocalStorage = class {
|
12189
|
+
static {
|
12190
|
+
__name(this, "LocalStorage");
|
12191
|
+
}
|
12051
12192
|
storage;
|
12052
12193
|
constructor(localStorage) {
|
12053
12194
|
this.storage = localStorage;
|
@@ -12068,6 +12209,9 @@ var LocalStorage = class {
|
|
12068
12209
|
|
12069
12210
|
// src/connectors/fuel-connector.ts
|
12070
12211
|
var FuelConnector = class extends import_events2.EventEmitter {
|
12212
|
+
static {
|
12213
|
+
__name(this, "FuelConnector");
|
12214
|
+
}
|
12071
12215
|
name = "";
|
12072
12216
|
metadata = {};
|
12073
12217
|
connected = false;
|
@@ -12316,6 +12460,7 @@ function cacheFor(fn, { cache: cache2, cacheTime, key }) {
|
|
12316
12460
|
return result;
|
12317
12461
|
};
|
12318
12462
|
}
|
12463
|
+
__name(cacheFor, "cacheFor");
|
12319
12464
|
|
12320
12465
|
// src/connectors/utils/dispatch-fuel-connector-event.ts
|
12321
12466
|
function dispatchFuelConnectorEvent(connector) {
|
@@ -12325,18 +12470,24 @@ function dispatchFuelConnectorEvent(connector) {
|
|
12325
12470
|
})
|
12326
12471
|
);
|
12327
12472
|
}
|
12473
|
+
__name(dispatchFuelConnectorEvent, "dispatchFuelConnectorEvent");
|
12328
12474
|
|
12329
12475
|
// src/connectors/fuel.ts
|
12330
12476
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
12331
12477
|
var PING_CACHE_TIME = 5e3;
|
12332
12478
|
var { warn } = console;
|
12333
|
-
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 = {};
|
12334
12485
|
_storage = null;
|
12335
12486
|
_connectors = [];
|
12336
12487
|
_targetObject = null;
|
12337
12488
|
_unsubscribes = [];
|
12338
|
-
_targetUnsubscribe = () => {
|
12339
|
-
};
|
12489
|
+
_targetUnsubscribe = /* @__PURE__ */ __name(() => {
|
12490
|
+
}, "_targetUnsubscribe");
|
12340
12491
|
_pingCache = {};
|
12341
12492
|
_currentConnector;
|
12342
12493
|
_initializationPromise = null;
|
@@ -12409,7 +12560,7 @@ var _Fuel = class extends FuelConnector {
|
|
12409
12560
|
const currentConnector = this._currentConnector;
|
12410
12561
|
this._unsubscribes.map((unSub) => unSub());
|
12411
12562
|
this._unsubscribes = events.map((event) => {
|
12412
|
-
const handler = (...args) => this.emit(event, ...args);
|
12563
|
+
const handler = /* @__PURE__ */ __name((...args) => this.emit(event, ...args), "handler");
|
12413
12564
|
currentConnector.on(event, handler);
|
12414
12565
|
return () => currentConnector.off(event, handler);
|
12415
12566
|
});
|
@@ -12493,7 +12644,7 @@ var _Fuel = class extends FuelConnector {
|
|
12493
12644
|
* Setup a listener for the FuelConnector event and add the connector
|
12494
12645
|
* to the list of new connectors.
|
12495
12646
|
*/
|
12496
|
-
setupConnectorListener = () => {
|
12647
|
+
setupConnectorListener = /* @__PURE__ */ __name(() => {
|
12497
12648
|
const { _targetObject: targetObject } = this;
|
12498
12649
|
const eventName = FuelConnectorEventType;
|
12499
12650
|
if (targetObject?.on) {
|
@@ -12503,9 +12654,9 @@ var _Fuel = class extends FuelConnector {
|
|
12503
12654
|
};
|
12504
12655
|
}
|
12505
12656
|
if (targetObject?.addEventListener) {
|
12506
|
-
const handler = (e) => {
|
12657
|
+
const handler = /* @__PURE__ */ __name((e) => {
|
12507
12658
|
this.addConnector(e.detail);
|
12508
|
-
};
|
12659
|
+
}, "handler");
|
12509
12660
|
targetObject.addEventListener(eventName, handler);
|
12510
12661
|
return () => {
|
12511
12662
|
targetObject.removeEventListener?.(eventName, handler);
|
@@ -12513,11 +12664,11 @@ var _Fuel = class extends FuelConnector {
|
|
12513
12664
|
}
|
12514
12665
|
return () => {
|
12515
12666
|
};
|
12516
|
-
};
|
12667
|
+
}, "setupConnectorListener");
|
12517
12668
|
/**
|
12518
12669
|
* Add a new connector to the list of connectors.
|
12519
12670
|
*/
|
12520
|
-
addConnector = async (connector) => {
|
12671
|
+
addConnector = /* @__PURE__ */ __name(async (connector) => {
|
12521
12672
|
if (!this.getConnector(connector)) {
|
12522
12673
|
this._connectors.push(connector);
|
12523
12674
|
}
|
@@ -12528,8 +12679,8 @@ var _Fuel = class extends FuelConnector {
|
|
12528
12679
|
emitEvents: false
|
12529
12680
|
});
|
12530
12681
|
}
|
12531
|
-
};
|
12532
|
-
triggerConnectorEvents = async () => {
|
12682
|
+
}, "addConnector");
|
12683
|
+
triggerConnectorEvents = /* @__PURE__ */ __name(async () => {
|
12533
12684
|
const [isConnected, networks2, currentNetwork] = await Promise.all([
|
12534
12685
|
this.isConnected(),
|
12535
12686
|
this.networks(),
|
@@ -12546,14 +12697,14 @@ var _Fuel = class extends FuelConnector {
|
|
12546
12697
|
this.emit(this.events.accounts, accounts);
|
12547
12698
|
this.emit(this.events.currentAccount, currentAccount);
|
12548
12699
|
}
|
12549
|
-
};
|
12700
|
+
}, "triggerConnectorEvents");
|
12550
12701
|
/**
|
12551
12702
|
* Get a connector from the list of connectors.
|
12552
12703
|
*/
|
12553
|
-
getConnector = (connector) => this._connectors.find((c) => {
|
12704
|
+
getConnector = /* @__PURE__ */ __name((connector) => this._connectors.find((c) => {
|
12554
12705
|
const connectorName = typeof connector === "string" ? connector : connector.name;
|
12555
12706
|
return c.name === connectorName || c === connector;
|
12556
|
-
}) || null;
|
12707
|
+
}) || null, "getConnector");
|
12557
12708
|
/**
|
12558
12709
|
* Return the list of connectors with the status of installed and connected.
|
12559
12710
|
*/
|
@@ -12670,9 +12821,6 @@ var _Fuel = class extends FuelConnector {
|
|
12670
12821
|
await this.clean();
|
12671
12822
|
}
|
12672
12823
|
};
|
12673
|
-
var Fuel = _Fuel;
|
12674
|
-
__publicField(Fuel, "STORAGE_KEY", "fuel-current-connector");
|
12675
|
-
__publicField(Fuel, "defaultConfig", {});
|
12676
12824
|
// Annotate the CommonJS export names for ESM import in node:
|
12677
12825
|
0 && (module.exports = {
|
12678
12826
|
AbstractAccount,
|
@@ -12702,6 +12850,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
12702
12850
|
MemoryStorage,
|
12703
12851
|
Mnemonic,
|
12704
12852
|
MnemonicVault,
|
12853
|
+
NON_PAGINATED_BALANCES_SIZE,
|
12705
12854
|
NoWitnessAtIndexError,
|
12706
12855
|
NoWitnessByOwnerError,
|
12707
12856
|
OperationName,
|