@fuel-ts/account 0.100.1 → 0.100.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
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,
@@ -141,6 +116,7 @@ __export(src_exports, {
141
116
  extractTxError: () => extractTxError,
142
117
  fuelAssetsBaseUrl: () => fuelAssetsBaseUrl,
143
118
  gasUsedByInputs: () => gasUsedByInputs,
119
+ getAllDecodedLogs: () => getAllDecodedLogs,
144
120
  getAssetAmountInRequestInputs: () => getAssetAmountInRequestInputs,
145
121
  getAssetById: () => getAssetById,
146
122
  getAssetEth: () => getAssetEth,
@@ -253,7 +229,7 @@ var CHAIN_IDS = {
253
229
  };
254
230
 
255
231
  // src/assets/utils/network.ts
256
- var getDefaultChainId = (networkType) => {
232
+ var getDefaultChainId = /* @__PURE__ */ __name((networkType) => {
257
233
  if (networkType === "ethereum") {
258
234
  return CHAIN_IDS.eth.sepolia;
259
235
  }
@@ -261,8 +237,8 @@ var getDefaultChainId = (networkType) => {
261
237
  return CHAIN_IDS.fuel.testnet;
262
238
  }
263
239
  return void 0;
264
- };
265
- var getAssetNetwork = ({
240
+ }, "getDefaultChainId");
241
+ var getAssetNetwork = /* @__PURE__ */ __name(({
266
242
  asset,
267
243
  chainId,
268
244
  networkType
@@ -271,8 +247,8 @@ var getAssetNetwork = ({
271
247
  (item) => item.chainId === chainId && item.type === networkType
272
248
  );
273
249
  return network;
274
- };
275
- var getAssetWithNetwork = ({
250
+ }, "getAssetNetwork");
251
+ var getAssetWithNetwork = /* @__PURE__ */ __name(({
276
252
  asset,
277
253
  chainId,
278
254
  networkType
@@ -294,22 +270,22 @@ var getAssetWithNetwork = ({
294
270
  ...assetRest,
295
271
  ...assetNetwork
296
272
  };
297
- };
298
- var getAssetEth = (asset, chainId) => getAssetWithNetwork({
273
+ }, "getAssetWithNetwork");
274
+ var getAssetEth = /* @__PURE__ */ __name((asset, chainId) => getAssetWithNetwork({
299
275
  asset,
300
276
  networkType: "ethereum",
301
277
  chainId
302
- });
303
- var getAssetFuel = (asset, chainId) => getAssetWithNetwork({
278
+ }), "getAssetEth");
279
+ var getAssetFuel = /* @__PURE__ */ __name((asset, chainId) => getAssetWithNetwork({
304
280
  asset,
305
281
  networkType: "fuel",
306
282
  chainId
307
- });
283
+ }), "getAssetFuel");
308
284
 
309
285
  // src/assets/utils/url.ts
310
286
  var DELIMITER_PATH = "/";
311
287
  var trimRegex = /^\/|\/$/g;
312
- var trimPath = (path = "") => path.replace(trimRegex, "");
288
+ var trimPath = /* @__PURE__ */ __name((path = "") => path.replace(trimRegex, ""), "trimPath");
313
289
  function urlJoin(baseUrl, ...paths) {
314
290
  const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
315
291
  const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
@@ -319,6 +295,7 @@ function urlJoin(baseUrl, ...paths) {
319
295
  }
320
296
  return allPaths.join(DELIMITER_PATH);
321
297
  }
298
+ __name(urlJoin, "urlJoin");
322
299
 
323
300
  // src/assets/utils/resolveIconPaths.ts
324
301
  function resolveIconPaths(assets2, basePath = "./") {
@@ -327,6 +304,7 @@ function resolveIconPaths(assets2, basePath = "./") {
327
304
  icon: urlJoin(basePath, asset.icon)
328
305
  }));
329
306
  }
307
+ __name(resolveIconPaths, "resolveIconPaths");
330
308
 
331
309
  // src/assets/utils/fuelAssetsBaseUrl.ts
332
310
  var fuelAssetsBaseUrl = "https://assets.fuel.network/providers/";
@@ -901,7 +879,7 @@ var networks = {
901
879
  mainnet: "https://mainnet-explorer.fuel.network",
902
880
  testnet: "https://explorer-indexer-testnet.fuel.network"
903
881
  };
904
- var request = async (url, slug) => {
882
+ var request = /* @__PURE__ */ __name(async (url, slug) => {
905
883
  const response = await fetch(`${url}${slug}`, {
906
884
  headers: {
907
885
  "Content-Type": "application/json",
@@ -913,20 +891,20 @@ var request = async (url, slug) => {
913
891
  } catch (error) {
914
892
  return null;
915
893
  }
916
- };
917
- var buildQueryString = (parameters) => {
894
+ }, "request");
895
+ var buildQueryString = /* @__PURE__ */ __name((parameters) => {
918
896
  const query = new URLSearchParams();
919
897
  Object.entries(parameters).forEach(([key, value]) => {
920
898
  query.set(key, value.toString());
921
899
  });
922
900
  return query.size > 0 ? `?${query.toString()}` : "";
923
- };
924
- var getAssetById = (opts) => {
901
+ }, "buildQueryString");
902
+ var getAssetById = /* @__PURE__ */ __name((opts) => {
925
903
  const { network = "mainnet", assetId } = opts;
926
904
  const url = networks[network];
927
905
  return request(url, `/assets/${assetId}`);
928
- };
929
- var getAssetsByOwner = async (opts) => {
906
+ }, "getAssetById");
907
+ var getAssetsByOwner = /* @__PURE__ */ __name(async (opts) => {
930
908
  const { network = "mainnet", owner, pagination = { last: 10 } } = opts;
931
909
  const url = networks[network];
932
910
  const { last } = pagination;
@@ -936,22 +914,22 @@ var getAssetsByOwner = async (opts) => {
936
914
  return { data: [], pageInfo: { count: 0 } };
937
915
  }
938
916
  return response;
939
- };
917
+ }, "getAssetsByOwner");
940
918
 
941
919
  // src/account.ts
942
- var import_abi_coder6 = require("@fuel-ts/abi-coder");
920
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
943
921
  var import_address5 = require("@fuel-ts/address");
944
922
  var import_crypto2 = require("@fuel-ts/crypto");
945
- var import_errors22 = require("@fuel-ts/errors");
923
+ var import_errors21 = require("@fuel-ts/errors");
946
924
  var import_math21 = require("@fuel-ts/math");
947
- var import_transactions26 = require("@fuel-ts/transactions");
925
+ var import_transactions27 = require("@fuel-ts/transactions");
948
926
  var import_utils34 = require("@fuel-ts/utils");
949
927
  var import_ramda9 = require("ramda");
950
928
 
951
929
  // src/providers/coin-quantity.ts
952
930
  var import_math = require("@fuel-ts/math");
953
931
  var import_utils2 = require("@fuel-ts/utils");
954
- var coinQuantityfy = (coinQuantityLike) => {
932
+ var coinQuantityfy = /* @__PURE__ */ __name((coinQuantityLike) => {
955
933
  let assetId;
956
934
  let amount;
957
935
  let max;
@@ -969,8 +947,8 @@ var coinQuantityfy = (coinQuantityLike) => {
969
947
  amount: (0, import_math.bn)(amount),
970
948
  max: max ? (0, import_math.bn)(max) : void 0
971
949
  };
972
- };
973
- var addAmountToCoinQuantities = (params) => {
950
+ }, "coinQuantityfy");
951
+ var addAmountToCoinQuantities = /* @__PURE__ */ __name((params) => {
974
952
  const { amount, assetId } = params;
975
953
  const coinQuantities = [...params.coinQuantities];
976
954
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -980,38 +958,19 @@ var addAmountToCoinQuantities = (params) => {
980
958
  coinQuantities.push({ assetId, amount });
981
959
  }
982
960
  return coinQuantities;
983
- };
961
+ }, "addAmountToCoinQuantities");
984
962
 
985
963
  // src/providers/provider.ts
986
964
  var import_address3 = require("@fuel-ts/address");
987
- var import_errors20 = require("@fuel-ts/errors");
965
+ var import_errors19 = require("@fuel-ts/errors");
988
966
  var import_math18 = require("@fuel-ts/math");
989
- var import_transactions23 = require("@fuel-ts/transactions");
967
+ var import_transactions24 = require("@fuel-ts/transactions");
990
968
  var import_utils29 = require("@fuel-ts/utils");
991
969
  var import_versions = require("@fuel-ts/versions");
992
970
  var import_graphql_request = require("graphql-request");
993
971
  var import_graphql_tag2 = __toESM(require("graphql-tag"));
994
972
  var import_ramda8 = require("ramda");
995
973
 
996
- // src/connectors/utils/promises.ts
997
- var import_errors = require("@fuel-ts/errors");
998
- function deferPromise() {
999
- const defer = {};
1000
- defer.promise = new Promise((resolve, reject) => {
1001
- defer.reject = reject;
1002
- defer.resolve = resolve;
1003
- });
1004
- return defer;
1005
- }
1006
- async function withTimeout(promise, timeout = 1050) {
1007
- const timeoutPromise = new Promise((resolve, reject) => {
1008
- setTimeout(() => {
1009
- reject(new import_errors.FuelError(import_errors.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
1010
- }, timeout);
1011
- });
1012
- return Promise.race([timeoutPromise, promise]);
1013
- }
1014
-
1015
974
  // src/providers/__generated__/operations.ts
1016
975
  var import_graphql_tag = __toESM(require("graphql-tag"));
1017
976
  var SubmittedStatusFragmentDoc = import_graphql_tag.default`
@@ -1503,6 +1462,11 @@ var NodeInfoFragmentDoc = import_graphql_tag.default`
1503
1462
  maxTx
1504
1463
  maxDepth
1505
1464
  nodeVersion
1465
+ indexation {
1466
+ balances
1467
+ coinsToSpend
1468
+ assetMetadata
1469
+ }
1506
1470
  }
1507
1471
  `;
1508
1472
  var RelayedTransactionStatusFragmentDoc = import_graphql_tag.default`
@@ -1784,7 +1748,7 @@ var GetBalancesDocument = import_graphql_tag.default`
1784
1748
  }
1785
1749
  `;
1786
1750
  var GetBalancesV2Document = import_graphql_tag.default`
1787
- query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
1751
+ query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int, $supportsPagination: Boolean!) {
1788
1752
  balances(
1789
1753
  filter: $filter
1790
1754
  after: $after
@@ -1792,7 +1756,7 @@ var GetBalancesV2Document = import_graphql_tag.default`
1792
1756
  first: $first
1793
1757
  last: $last
1794
1758
  ) {
1795
- pageInfo {
1759
+ pageInfo @include(if: $supportsPagination) {
1796
1760
  ...pageInfoFragment
1797
1761
  }
1798
1762
  edges {
@@ -2062,37 +2026,38 @@ function getSdk(requester) {
2062
2026
  }
2063
2027
  };
2064
2028
  }
2029
+ __name(getSdk, "getSdk");
2065
2030
 
2066
2031
  // src/providers/fuel-graphql-subscriber.ts
2067
- var import_errors3 = require("@fuel-ts/errors");
2032
+ var import_errors2 = require("@fuel-ts/errors");
2068
2033
  var import_graphql = require("graphql");
2069
2034
 
2070
2035
  // src/providers/utils/handle-gql-error-message.ts
2071
- var import_errors2 = require("@fuel-ts/errors");
2072
- var mapGqlErrorMessage = (error) => {
2036
+ var import_errors = require("@fuel-ts/errors");
2037
+ var mapGqlErrorMessage = /* @__PURE__ */ __name((error) => {
2073
2038
  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
- return new import_errors2.FuelError(
2075
- import_errors2.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
2039
+ return new import_errors.FuelError(
2040
+ import_errors.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
2076
2041
  `Insufficient funds or too many small value coins. Consider combining UTXOs.`,
2077
2042
  {},
2078
2043
  error
2079
2044
  );
2080
2045
  }
2081
2046
  if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
2082
- return new import_errors2.FuelError(
2083
- import_errors2.ErrorCode.ASSET_NOT_FOUND,
2047
+ return new import_errors.FuelError(
2048
+ import_errors.ErrorCode.ASSET_NOT_FOUND,
2084
2049
  `Asset not found for given asset id.`,
2085
2050
  {},
2086
2051
  error
2087
2052
  );
2088
2053
  }
2089
- return new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, error.message, {}, error);
2090
- };
2091
- var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
2054
+ return new import_errors.FuelError(import_errors.ErrorCode.INVALID_REQUEST, error.message, {}, error);
2055
+ }, "mapGqlErrorMessage");
2056
+ var mapGqlErrorWithIncompatibleNodeVersion = /* @__PURE__ */ __name((error, incompatibleNodeVersionMessage) => {
2092
2057
  if (!incompatibleNodeVersionMessage) {
2093
2058
  return error;
2094
2059
  }
2095
- return new import_errors2.FuelError(
2060
+ return new import_errors.FuelError(
2096
2061
  error.code,
2097
2062
  `${error.message}
2098
2063
 
@@ -2100,8 +2065,8 @@ ${incompatibleNodeVersionMessage}`,
2100
2065
  error.metadata,
2101
2066
  error.rawError
2102
2067
  );
2103
- };
2104
- var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = false) => {
2068
+ }, "mapGqlErrorWithIncompatibleNodeVersion");
2069
+ var assertGqlResponseHasNoErrors = /* @__PURE__ */ __name((errors, incompatibleNodeVersionMessage = false) => {
2105
2070
  if (!Array.isArray(errors)) {
2106
2071
  return;
2107
2072
  }
@@ -2111,16 +2076,21 @@ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = fal
2111
2076
  }
2112
2077
  const errorMessage = mappedErrors.map((err) => err.message).join("\n");
2113
2078
  throw mapGqlErrorWithIncompatibleNodeVersion(
2114
- new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
2079
+ new import_errors.FuelError(import_errors.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
2115
2080
  incompatibleNodeVersionMessage
2116
2081
  );
2117
- };
2082
+ }, "assertGqlResponseHasNoErrors");
2118
2083
 
2119
2084
  // src/providers/fuel-graphql-subscriber.ts
2120
- var _FuelGraphqlSubscriber = class {
2085
+ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
2121
2086
  constructor(stream) {
2122
2087
  this.stream = stream;
2123
2088
  }
2089
+ static {
2090
+ __name(this, "FuelGraphqlSubscriber");
2091
+ }
2092
+ static incompatibleNodeVersionMessage = false;
2093
+ static textDecoder = new TextDecoder();
2124
2094
  static async create(options) {
2125
2095
  const { url, query, variables, fetchFn } = options;
2126
2096
  const response = await fetchFn(`${url}-sub`, {
@@ -2162,8 +2132,8 @@ var _FuelGraphqlSubscriber = class {
2162
2132
  try {
2163
2133
  this.events.push(JSON.parse(match.replace(/^data:/, "")));
2164
2134
  } catch (e) {
2165
- throw new import_errors3.FuelError(
2166
- import_errors3.ErrorCode.STREAM_PARSING_ERROR,
2135
+ throw new import_errors2.FuelError(
2136
+ import_errors2.ErrorCode.STREAM_PARSING_ERROR,
2167
2137
  `Error while parsing stream data response: ${text}`
2168
2138
  );
2169
2139
  }
@@ -2181,22 +2151,19 @@ var _FuelGraphqlSubscriber = class {
2181
2151
  return this;
2182
2152
  }
2183
2153
  };
2184
- var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
2185
- __publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
2186
- __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
2187
2154
 
2188
2155
  // src/providers/resource-cache.ts
2189
- var import_errors14 = require("@fuel-ts/errors");
2156
+ var import_errors13 = require("@fuel-ts/errors");
2190
2157
  var import_utils22 = require("@fuel-ts/utils");
2191
2158
 
2192
2159
  // src/providers/transaction-request/input.ts
2193
2160
  var import_abi_coder = require("@fuel-ts/abi-coder");
2194
2161
  var import_configs = require("@fuel-ts/address/configs");
2195
- var import_errors4 = require("@fuel-ts/errors");
2162
+ var import_errors3 = require("@fuel-ts/errors");
2196
2163
  var import_math2 = require("@fuel-ts/math");
2197
2164
  var import_transactions = require("@fuel-ts/transactions");
2198
2165
  var import_utils3 = require("@fuel-ts/utils");
2199
- var inputify = (value) => {
2166
+ var inputify = /* @__PURE__ */ __name((value) => {
2200
2167
  const { type } = value;
2201
2168
  switch (value.type) {
2202
2169
  case import_transactions.InputType.Coin: {
@@ -2256,21 +2223,21 @@ var inputify = (value) => {
2256
2223
  };
2257
2224
  }
2258
2225
  default: {
2259
- throw new import_errors4.FuelError(
2260
- import_errors4.ErrorCode.INVALID_TRANSACTION_INPUT,
2226
+ throw new import_errors3.FuelError(
2227
+ import_errors3.ErrorCode.INVALID_TRANSACTION_INPUT,
2261
2228
  `Invalid transaction input type: ${type}.`
2262
2229
  );
2263
2230
  }
2264
2231
  }
2265
- };
2232
+ }, "inputify");
2266
2233
 
2267
2234
  // src/providers/transaction-request/output.ts
2268
2235
  var import_configs2 = require("@fuel-ts/address/configs");
2269
- var import_errors5 = require("@fuel-ts/errors");
2236
+ var import_errors4 = require("@fuel-ts/errors");
2270
2237
  var import_math3 = require("@fuel-ts/math");
2271
2238
  var import_transactions2 = require("@fuel-ts/transactions");
2272
2239
  var import_utils4 = require("@fuel-ts/utils");
2273
- var outputify = (value) => {
2240
+ var outputify = /* @__PURE__ */ __name((value) => {
2274
2241
  const { type } = value;
2275
2242
  switch (type) {
2276
2243
  case import_transactions2.OutputType.Coin: {
@@ -2313,32 +2280,32 @@ var outputify = (value) => {
2313
2280
  };
2314
2281
  }
2315
2282
  default: {
2316
- throw new import_errors5.FuelError(
2317
- import_errors5.ErrorCode.INVALID_TRANSACTION_INPUT,
2283
+ throw new import_errors4.FuelError(
2284
+ import_errors4.ErrorCode.INVALID_TRANSACTION_INPUT,
2318
2285
  `Invalid transaction output type: ${type}.`
2319
2286
  );
2320
2287
  }
2321
2288
  }
2322
- };
2289
+ }, "outputify");
2323
2290
 
2324
2291
  // src/providers/transaction-request/transaction-request.ts
2325
2292
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
2326
2293
  var import_address = require("@fuel-ts/address");
2327
2294
  var import_configs6 = require("@fuel-ts/address/configs");
2328
2295
  var import_crypto = require("@fuel-ts/crypto");
2329
- var import_errors10 = require("@fuel-ts/errors");
2296
+ var import_errors9 = require("@fuel-ts/errors");
2330
2297
  var import_math8 = require("@fuel-ts/math");
2331
2298
  var import_transactions8 = require("@fuel-ts/transactions");
2332
2299
  var import_utils10 = require("@fuel-ts/utils");
2333
2300
 
2334
2301
  // src/providers/message.ts
2335
- var isMessageCoin = (message) => !("data" in message);
2302
+ var isMessageCoin = /* @__PURE__ */ __name((message) => !("data" in message), "isMessageCoin");
2336
2303
 
2337
2304
  // 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;
2305
+ var isRawCoin = /* @__PURE__ */ __name((resource) => "utxoId" in resource, "isRawCoin");
2306
+ var isRawMessage = /* @__PURE__ */ __name((resource) => "recipient" in resource, "isRawMessage");
2307
+ var isCoin = /* @__PURE__ */ __name((resource) => "id" in resource, "isCoin");
2308
+ var isMessage = /* @__PURE__ */ __name((resource) => "recipient" in resource, "isMessage");
2342
2309
 
2343
2310
  // src/providers/utils/receipts.ts
2344
2311
  var import_transactions4 = require("@fuel-ts/transactions");
@@ -2346,11 +2313,11 @@ var import_configs4 = require("@fuel-ts/transactions/configs");
2346
2313
 
2347
2314
  // src/providers/utils/serialization.ts
2348
2315
  var import_configs3 = require("@fuel-ts/address/configs");
2349
- var import_errors6 = require("@fuel-ts/errors");
2316
+ var import_errors5 = require("@fuel-ts/errors");
2350
2317
  var import_math4 = require("@fuel-ts/math");
2351
2318
  var import_transactions3 = require("@fuel-ts/transactions");
2352
2319
  var import_utils5 = require("@fuel-ts/utils");
2353
- var deserializeChain = (chain) => {
2320
+ var deserializeChain = /* @__PURE__ */ __name((chain) => {
2354
2321
  const { name, daHeight, consensusParameters } = chain;
2355
2322
  const {
2356
2323
  contractParams,
@@ -2404,8 +2371,8 @@ var deserializeChain = (chain) => {
2404
2371
  gasCosts
2405
2372
  }
2406
2373
  };
2407
- };
2408
- var serializeChain = (chain) => {
2374
+ }, "deserializeChain");
2375
+ var serializeChain = /* @__PURE__ */ __name((chain) => {
2409
2376
  const { name, baseChainHeight, consensusParameters } = chain;
2410
2377
  const {
2411
2378
  contractParameters,
@@ -2459,39 +2426,41 @@ var serializeChain = (chain) => {
2459
2426
  gasCosts
2460
2427
  }
2461
2428
  };
2462
- };
2463
- var deserializeNodeInfo = (nodeInfo) => {
2464
- const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
2429
+ }, "serializeChain");
2430
+ var deserializeNodeInfo = /* @__PURE__ */ __name((nodeInfo) => {
2431
+ const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace, indexation } = nodeInfo;
2465
2432
  return {
2466
2433
  maxDepth: (0, import_math4.bn)(maxDepth),
2467
2434
  maxTx: (0, import_math4.bn)(maxTx),
2468
2435
  nodeVersion,
2469
2436
  utxoValidation,
2470
- vmBacktrace
2437
+ vmBacktrace,
2438
+ indexation
2471
2439
  };
2472
- };
2473
- var serializeNodeInfo = (nodeInfo) => {
2474
- const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
2440
+ }, "deserializeNodeInfo");
2441
+ var serializeNodeInfo = /* @__PURE__ */ __name((nodeInfo) => {
2442
+ const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace, indexation } = nodeInfo;
2475
2443
  return {
2476
2444
  maxDepth: maxDepth.toString(),
2477
2445
  maxTx: maxTx.toString(),
2478
2446
  nodeVersion,
2479
2447
  utxoValidation,
2480
- vmBacktrace
2448
+ vmBacktrace,
2449
+ indexation
2481
2450
  };
2482
- };
2483
- var deserializeProviderCache = (cache2) => ({
2451
+ }, "serializeNodeInfo");
2452
+ var deserializeProviderCache = /* @__PURE__ */ __name((cache2) => ({
2484
2453
  consensusParametersTimestamp: cache2.consensusParametersTimestamp,
2485
2454
  chain: deserializeChain(cache2.chain),
2486
2455
  nodeInfo: deserializeNodeInfo(cache2.nodeInfo)
2487
- });
2488
- var serializeProviderCache = async (provider) => ({
2456
+ }), "deserializeProviderCache");
2457
+ var serializeProviderCache = /* @__PURE__ */ __name(async (provider) => ({
2489
2458
  consensusParametersTimestamp: provider.consensusParametersTimestamp,
2490
2459
  chain: serializeChain(await provider.getChain()),
2491
2460
  nodeInfo: serializeNodeInfo(await provider.getNode())
2492
- });
2493
- var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
2494
- var deserializeReceipt = (receipt) => {
2461
+ }), "serializeProviderCache");
2462
+ var hexOrZero = /* @__PURE__ */ __name((hex) => hex || import_configs3.ZeroBytes32, "hexOrZero");
2463
+ var deserializeReceipt = /* @__PURE__ */ __name((receipt) => {
2495
2464
  const { receiptType } = receipt;
2496
2465
  switch (receiptType) {
2497
2466
  case "CALL" /* Call */: {
@@ -2681,14 +2650,14 @@ var deserializeReceipt = (receipt) => {
2681
2650
  return burnReceipt;
2682
2651
  }
2683
2652
  default:
2684
- throw new import_errors6.FuelError(import_errors6.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
2653
+ throw new import_errors5.FuelError(import_errors5.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
2685
2654
  }
2686
- };
2655
+ }, "deserializeReceipt");
2687
2656
 
2688
2657
  // 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(
2658
+ var doesReceiptHaveMissingOutputVariables = /* @__PURE__ */ __name((receipt) => receipt.type === import_transactions4.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL, "doesReceiptHaveMissingOutputVariables");
2659
+ var doesReceiptHaveMissingContractId = /* @__PURE__ */ __name((receipt) => receipt.type === import_transactions4.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000", "doesReceiptHaveMissingContractId");
2660
+ var getReceiptsWithMissingData = /* @__PURE__ */ __name((receipts) => receipts.reduce(
2692
2661
  (memo, receipt) => {
2693
2662
  if (doesReceiptHaveMissingOutputVariables(receipt)) {
2694
2663
  memo.missingOutputVariables.push(receipt);
@@ -2702,13 +2671,13 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
2702
2671
  missingOutputVariables: [],
2703
2672
  missingOutputContractIds: []
2704
2673
  }
2705
- );
2706
- var assembleReceiptByType = (gqlReceipt) => deserializeReceipt(gqlReceipt);
2674
+ ), "getReceiptsWithMissingData");
2675
+ var assembleReceiptByType = /* @__PURE__ */ __name((gqlReceipt) => deserializeReceipt(gqlReceipt), "assembleReceiptByType");
2707
2676
 
2708
2677
  // src/providers/utils/block-explorer.ts
2709
- var import_errors7 = require("@fuel-ts/errors");
2678
+ var import_errors6 = require("@fuel-ts/errors");
2710
2679
  var DEFAULT_BLOCK_EXPLORER_URL = "https://app.fuel.network";
2711
- var getPathFromInput = (key, value) => {
2680
+ var getPathFromInput = /* @__PURE__ */ __name((key, value) => {
2712
2681
  const pathMap = {
2713
2682
  address: `address`,
2714
2683
  txId: `transaction`,
@@ -2716,8 +2685,8 @@ var getPathFromInput = (key, value) => {
2716
2685
  };
2717
2686
  const path = pathMap[key] || key;
2718
2687
  return `${path}/${value}`;
2719
- };
2720
- var buildBlockExplorerUrl = (options = {}) => {
2688
+ }, "getPathFromInput");
2689
+ var buildBlockExplorerUrl = /* @__PURE__ */ __name((options = {}) => {
2721
2690
  const { blockExplorerUrl, path, providerUrl, address, txId, blockNumber } = options;
2722
2691
  const explorerUrl = blockExplorerUrl || DEFAULT_BLOCK_EXPLORER_URL;
2723
2692
  const customInputParams = [
@@ -2740,15 +2709,15 @@ var buildBlockExplorerUrl = (options = {}) => {
2740
2709
  }));
2741
2710
  const hasAnyDefinedValues = definedValues.length > 0;
2742
2711
  if (definedValues.length > 1) {
2743
- throw new import_errors7.FuelError(
2744
- import_errors7.ErrorCode.ERROR_BUILDING_BLOCK_EXPLORER_URL,
2712
+ throw new import_errors6.FuelError(
2713
+ import_errors6.ErrorCode.ERROR_BUILDING_BLOCK_EXPLORER_URL,
2745
2714
  `Only one of the following can be passed in to buildBlockExplorerUrl: ${customInputParams.map((param) => param.key).join(", ")}.`
2746
2715
  );
2747
2716
  }
2748
2717
  if (path && definedValues.length > 0) {
2749
2718
  const inputKeys = customInputParams.map(({ key }) => key).join(", ");
2750
- throw new import_errors7.FuelError(
2751
- import_errors7.ErrorCode.ERROR_BUILDING_BLOCK_EXPLORER_URL,
2719
+ throw new import_errors6.FuelError(
2720
+ import_errors6.ErrorCode.ERROR_BUILDING_BLOCK_EXPLORER_URL,
2752
2721
  `You cannot pass in a path to 'buildBlockExplorerUrl' along with any of the following: ${inputKeys}.`
2753
2722
  );
2754
2723
  }
@@ -2765,19 +2734,19 @@ var buildBlockExplorerUrl = (options = {}) => {
2765
2734
  const providerUrlProtocol = cleanProviderUrl?.match(/^https?:\/\//) ? "" : "https://";
2766
2735
  const url = `${protocol}${cleanBlockExplorerUrl}/${cleanPath}${encodedProviderUrl ? `?providerUrl=${providerUrlProtocol}${encodedProviderUrl}` : ""}`;
2767
2736
  return url;
2768
- };
2737
+ }, "buildBlockExplorerUrl");
2769
2738
 
2770
2739
  // src/providers/utils/gas.ts
2771
2740
  var import_math5 = require("@fuel-ts/math");
2772
2741
  var import_transactions5 = require("@fuel-ts/transactions");
2773
2742
  var import_utils6 = require("@fuel-ts/utils");
2774
- var getGasUsedFromReceipts = (receipts) => {
2743
+ var getGasUsedFromReceipts = /* @__PURE__ */ __name((receipts) => {
2775
2744
  const scriptResult = receipts.filter(
2776
2745
  (receipt) => receipt.type === import_transactions5.ReceiptType.ScriptResult
2777
2746
  );
2778
2747
  const gasUsed = scriptResult.reduce((prev, receipt) => prev.add(receipt.gasUsed), (0, import_math5.bn)(0));
2779
2748
  return gasUsed;
2780
- };
2749
+ }, "getGasUsedFromReceipts");
2781
2750
  function resolveGasDependentCosts(byteSize, gasDependentCost) {
2782
2751
  const base = (0, import_math5.bn)(gasDependentCost.base);
2783
2752
  let dependentValue = (0, import_math5.bn)(0);
@@ -2788,6 +2757,7 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
2788
2757
  }
2789
2758
  return base.add(dependentValue);
2790
2759
  }
2760
+ __name(resolveGasDependentCosts, "resolveGasDependentCosts");
2791
2761
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
2792
2762
  const witnessCache = [];
2793
2763
  const chargeableInputs = inputs.filter((input) => {
@@ -2814,6 +2784,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
2814
2784
  }, (0, import_math5.bn)(0));
2815
2785
  return totalGas;
2816
2786
  }
2787
+ __name(gasUsedByInputs, "gasUsedByInputs");
2817
2788
  function getMinGas(params) {
2818
2789
  const { gasCosts, gasPerByte, inputs, metadataGas, txBytesSize } = params;
2819
2790
  const vmInitGas = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
@@ -2822,6 +2793,7 @@ function getMinGas(params) {
2822
2793
  const minGas = vmInitGas.add(bytesGas).add(inputsGas).add(metadataGas).maxU64();
2823
2794
  return minGas;
2824
2795
  }
2796
+ __name(getMinGas, "getMinGas");
2825
2797
  function getMaxGas(params) {
2826
2798
  const {
2827
2799
  gasPerByte,
@@ -2838,6 +2810,7 @@ function getMaxGas(params) {
2838
2810
  const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
2839
2811
  return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
2840
2812
  }
2813
+ __name(getMaxGas, "getMaxGas");
2841
2814
  function calculateMetadataGasForTxCreate({
2842
2815
  gasCosts,
2843
2816
  stateRootSize,
@@ -2852,12 +2825,14 @@ function calculateMetadataGasForTxCreate({
2852
2825
  const metadataGas = contractRootGas.add(stateRootGas).add(txIdGas).add(contractIdGas);
2853
2826
  return metadataGas.maxU64();
2854
2827
  }
2828
+ __name(calculateMetadataGasForTxCreate, "calculateMetadataGasForTxCreate");
2855
2829
  function calculateMetadataGasForTxScript({
2856
2830
  gasCosts,
2857
2831
  txBytesSize
2858
2832
  }) {
2859
2833
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
2860
2834
  }
2835
+ __name(calculateMetadataGasForTxScript, "calculateMetadataGasForTxScript");
2861
2836
  function calculateMetadataGasForTxBlob({
2862
2837
  gasCosts,
2863
2838
  txBytesSize,
@@ -2867,6 +2842,7 @@ function calculateMetadataGasForTxBlob({
2867
2842
  const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
2868
2843
  return txId.add(blobLen);
2869
2844
  }
2845
+ __name(calculateMetadataGasForTxBlob, "calculateMetadataGasForTxBlob");
2870
2846
  function calculateMetadataGasForTxUpgrade({
2871
2847
  gasCosts,
2872
2848
  txBytesSize,
@@ -2879,6 +2855,7 @@ function calculateMetadataGasForTxUpgrade({
2879
2855
  }
2880
2856
  return txId;
2881
2857
  }
2858
+ __name(calculateMetadataGasForTxUpgrade, "calculateMetadataGasForTxUpgrade");
2882
2859
  function calculateMetadataGasForTxUpload({
2883
2860
  gasCosts,
2884
2861
  txBytesSize,
@@ -2892,6 +2869,7 @@ function calculateMetadataGasForTxUpload({
2892
2869
  txId.add(subsectionsLen);
2893
2870
  return txId;
2894
2871
  }
2872
+ __name(calculateMetadataGasForTxUpload, "calculateMetadataGasForTxUpload");
2895
2873
  function calculateMinGasForTxUpload({
2896
2874
  gasCosts,
2897
2875
  baseMinGas,
@@ -2900,10 +2878,11 @@ function calculateMinGasForTxUpload({
2900
2878
  const additionalStoragePerByte = (0, import_math5.bn)(gasCosts.newStoragePerByte).mul(subsectionSize);
2901
2879
  return (0, import_math5.bn)(baseMinGas).add(additionalStoragePerByte);
2902
2880
  }
2903
- var calculateGasFee = (params) => {
2881
+ __name(calculateMinGasForTxUpload, "calculateMinGasForTxUpload");
2882
+ var calculateGasFee = /* @__PURE__ */ __name((params) => {
2904
2883
  const { gas, gasPrice, priceFactor, tip } = params;
2905
2884
  return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
2906
- };
2885
+ }, "calculateGasFee");
2907
2886
 
2908
2887
  // src/providers/utils/json.ts
2909
2888
  var import_utils7 = require("@fuel-ts/utils");
@@ -2932,16 +2911,18 @@ function normalize(object) {
2932
2911
  });
2933
2912
  return object;
2934
2913
  }
2914
+ __name(normalize, "normalize");
2935
2915
  function normalizeJSON(root) {
2936
2916
  return normalize((0, import_ramda.clone)(root));
2937
2917
  }
2918
+ __name(normalizeJSON, "normalizeJSON");
2938
2919
 
2939
2920
  // src/providers/utils/extract-tx-error.ts
2940
- var import_errors8 = require("@fuel-ts/errors");
2921
+ var import_errors7 = require("@fuel-ts/errors");
2941
2922
  var import_math6 = require("@fuel-ts/math");
2942
2923
  var import_transactions6 = require("@fuel-ts/transactions");
2943
2924
  var import_configs5 = require("@fuel-ts/transactions/configs");
2944
- var assemblePanicError = (statusReason, metadata) => {
2925
+ var assemblePanicError = /* @__PURE__ */ __name((statusReason, metadata) => {
2945
2926
  let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
2946
2927
  if (import_configs5.PANIC_REASONS.includes(statusReason)) {
2947
2928
  errorMessage = `${errorMessage}
@@ -2950,13 +2931,13 @@ You can read more about this error at:
2950
2931
 
2951
2932
  ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
2952
2933
  }
2953
- return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2934
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2954
2935
  ...metadata,
2955
2936
  reason: statusReason
2956
2937
  });
2957
- };
2958
- var stringify = (obj) => JSON.stringify(obj, null, 2);
2959
- var assembleRevertError = (receipts, logs, metadata) => {
2938
+ }, "assemblePanicError");
2939
+ var stringify = /* @__PURE__ */ __name((obj) => JSON.stringify(obj, null, 2), "stringify");
2940
+ var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
2960
2941
  let errorMessage = "The transaction reverted with an unknown reason.";
2961
2942
  const revertReceipt = receipts.find(({ type }) => type === import_transactions6.ReceiptType.Revert);
2962
2943
  let reason = "";
@@ -2991,8 +2972,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
2991
2972
  errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
2992
2973
  break;
2993
2974
  default:
2994
- throw new import_errors8.FuelError(
2995
- import_errors8.ErrorCode.UNKNOWN,
2975
+ throw new import_errors7.FuelError(
2976
+ import_errors7.ErrorCode.UNKNOWN,
2996
2977
  `The transaction reverted with an unknown reason: ${revertReceipt.val}`,
2997
2978
  {
2998
2979
  ...metadata,
@@ -3001,17 +2982,18 @@ var assembleRevertError = (receipts, logs, metadata) => {
3001
2982
  );
3002
2983
  }
3003
2984
  }
3004
- return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2985
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, {
3005
2986
  ...metadata,
3006
2987
  reason
3007
2988
  });
3008
- };
3009
- var extractTxError = (params) => {
3010
- const { receipts, statusReason, logs } = params;
2989
+ }, "assembleRevertError");
2990
+ var extractTxError = /* @__PURE__ */ __name((params) => {
2991
+ const { receipts, statusReason, logs, groupedLogs } = params;
3011
2992
  const isPanic = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Panic);
3012
2993
  const isRevert = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Revert);
3013
2994
  const metadata = {
3014
2995
  logs,
2996
+ groupedLogs,
3015
2997
  receipts,
3016
2998
  panic: isPanic,
3017
2999
  revert: isRevert,
@@ -3021,10 +3003,13 @@ var extractTxError = (params) => {
3021
3003
  return assemblePanicError(statusReason, metadata);
3022
3004
  }
3023
3005
  return assembleRevertError(receipts, logs, metadata);
3024
- };
3006
+ }, "extractTxError");
3025
3007
 
3026
3008
  // src/providers/transaction-request/errors.ts
3027
3009
  var ChangeOutputCollisionError = class extends Error {
3010
+ static {
3011
+ __name(this, "ChangeOutputCollisionError");
3012
+ }
3028
3013
  name = "ChangeOutputCollisionError";
3029
3014
  message = 'A ChangeOutput with the same "assetId" already exists for a different "to" address';
3030
3015
  };
@@ -3034,6 +3019,9 @@ var NoWitnessAtIndexError = class extends Error {
3034
3019
  this.index = index;
3035
3020
  this.message = `Witness at index "${index}" was not found`;
3036
3021
  }
3022
+ static {
3023
+ __name(this, "NoWitnessAtIndexError");
3024
+ }
3037
3025
  name = "NoWitnessAtIndexError";
3038
3026
  };
3039
3027
  var NoWitnessByOwnerError = class extends Error {
@@ -3042,23 +3030,26 @@ var NoWitnessByOwnerError = class extends Error {
3042
3030
  this.owner = owner;
3043
3031
  this.message = `A witness for the given owner "${owner}" was not found`;
3044
3032
  }
3033
+ static {
3034
+ __name(this, "NoWitnessByOwnerError");
3035
+ }
3045
3036
  name = "NoWitnessByOwnerError";
3046
3037
  };
3047
3038
 
3048
3039
  // src/providers/transaction-request/helpers.ts
3049
- var import_errors9 = require("@fuel-ts/errors");
3040
+ var import_errors8 = require("@fuel-ts/errors");
3050
3041
  var import_math7 = require("@fuel-ts/math");
3051
3042
  var import_transactions7 = require("@fuel-ts/transactions");
3052
3043
  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) => {
3044
+ var isRequestInputCoin = /* @__PURE__ */ __name((input) => input.type === import_transactions7.InputType.Coin, "isRequestInputCoin");
3045
+ var isRequestInputMessage = /* @__PURE__ */ __name((input) => input.type === import_transactions7.InputType.Message, "isRequestInputMessage");
3046
+ var isRequestInputMessageWithoutData = /* @__PURE__ */ __name((input) => input.type === import_transactions7.InputType.Message && (0, import_math7.bn)(input.data).isZero(), "isRequestInputMessageWithoutData");
3047
+ var isRequestInputCoinOrMessage = /* @__PURE__ */ __name((input) => isRequestInputCoin(input) || isRequestInputMessage(input), "isRequestInputCoinOrMessage");
3048
+ var isRequestInputResource = /* @__PURE__ */ __name((input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input), "isRequestInputResource");
3049
+ var getRequestInputResourceOwner = /* @__PURE__ */ __name((input) => isRequestInputCoin(input) ? input.owner : input.recipient, "getRequestInputResourceOwner");
3050
+ var isRequestInputResourceFromOwner = /* @__PURE__ */ __name((input, owner) => getRequestInputResourceOwner(input) === owner.toB256(), "isRequestInputResourceFromOwner");
3051
+ var isPredicate = /* @__PURE__ */ __name((input) => isRequestInputCoinOrMessage(input) && !!input.predicate && (0, import_utils8.hexlify)(input.predicate) !== "0x", "isPredicate");
3052
+ var getAssetAmountInRequestInputs = /* @__PURE__ */ __name((inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
3062
3053
  if (isRequestInputCoin(input) && input.assetId === assetId) {
3063
3054
  return acc.add(input.amount);
3064
3055
  }
@@ -3066,8 +3057,8 @@ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filte
3066
3057
  return acc.add(input.amount);
3067
3058
  }
3068
3059
  return acc;
3069
- }, (0, import_math7.bn)(0));
3070
- var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
3060
+ }, (0, import_math7.bn)(0)), "getAssetAmountInRequestInputs");
3061
+ var cacheRequestInputsResources = /* @__PURE__ */ __name((inputs) => inputs.filter(isRequestInputResource).reduce(
3071
3062
  (cache2, input) => {
3072
3063
  if (isRequestInputCoin(input)) {
3073
3064
  cache2.utxos.push(input.id);
@@ -3080,8 +3071,8 @@ var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResour
3080
3071
  utxos: [],
3081
3072
  messages: []
3082
3073
  }
3083
- );
3084
- var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
3074
+ ), "cacheRequestInputsResources");
3075
+ var cacheRequestInputsResourcesFromOwner = /* @__PURE__ */ __name((inputs, owner) => inputs.reduce(
3085
3076
  (acc, input) => {
3086
3077
  if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
3087
3078
  acc.utxos.push(input.id);
@@ -3094,8 +3085,8 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
3094
3085
  utxos: [],
3095
3086
  messages: []
3096
3087
  }
3097
- );
3098
- var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
3088
+ ), "cacheRequestInputsResourcesFromOwner");
3089
+ var getBurnableAssetCount = /* @__PURE__ */ __name((baseAssetId, transactionRequest) => {
3099
3090
  const { inputs, outputs } = transactionRequest;
3100
3091
  const coinInputs = new Set(inputs.filter(isRequestInputCoin).map((input) => input.assetId));
3101
3092
  if (inputs.some((i) => isRequestInputMessage(i) && (0, import_math7.bn)(i.amount).gt(0))) {
@@ -3106,8 +3097,8 @@ var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
3106
3097
  );
3107
3098
  const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
3108
3099
  return difference.size;
3109
- };
3110
- var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAssetBurn = false) => {
3100
+ }, "getBurnableAssetCount");
3101
+ var validateTransactionForAssetBurn = /* @__PURE__ */ __name((baseAssetId, transactionRequest, enableAssetBurn = false) => {
3111
3102
  if (enableAssetBurn === true) {
3112
3103
  return;
3113
3104
  }
@@ -3119,21 +3110,24 @@ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAs
3119
3110
  "Add the relevant change outputs to the transaction to avoid burning assets.",
3120
3111
  "Or enable asset burn, upon sending the transaction."
3121
3112
  ].join("\n");
3122
- throw new import_errors9.FuelError(import_errors9.ErrorCode.ASSET_BURN_DETECTED, message);
3123
- };
3113
+ throw new import_errors8.FuelError(import_errors8.ErrorCode.ASSET_BURN_DETECTED, message);
3114
+ }, "validateTransactionForAssetBurn");
3124
3115
 
3125
3116
  // src/providers/transaction-request/witness.ts
3126
3117
  var import_utils9 = require("@fuel-ts/utils");
3127
- var witnessify = (value) => {
3118
+ var witnessify = /* @__PURE__ */ __name((value) => {
3128
3119
  const data = (0, import_utils9.arrayify)(value);
3129
3120
  return {
3130
3121
  data: (0, import_utils9.hexlify)(data),
3131
3122
  dataLength: data.length
3132
3123
  };
3133
- };
3124
+ }, "witnessify");
3134
3125
 
3135
3126
  // src/providers/transaction-request/transaction-request.ts
3136
- var BaseTransactionRequest = class {
3127
+ var BaseTransactionRequest = class _BaseTransactionRequest {
3128
+ static {
3129
+ __name(this, "BaseTransactionRequest");
3130
+ }
3137
3131
  /** Gas price for transaction */
3138
3132
  tip;
3139
3133
  /** Block until which tx cannot be included */
@@ -3216,7 +3210,7 @@ var BaseTransactionRequest = class {
3216
3210
  const inputs = this.inputs?.map(inputify) ?? [];
3217
3211
  const outputs = this.outputs?.map(outputify) ?? [];
3218
3212
  const witnesses = this.witnesses?.map(witnessify) ?? [];
3219
- const { policyTypes, policies } = BaseTransactionRequest.getPolicyMeta(this);
3213
+ const { policyTypes, policies } = _BaseTransactionRequest.getPolicyMeta(this);
3220
3214
  return {
3221
3215
  policyTypes,
3222
3216
  inputs,
@@ -3517,7 +3511,7 @@ var BaseTransactionRequest = class {
3517
3511
  * @hidden
3518
3512
  */
3519
3513
  metadataGas(_gasCosts) {
3520
- throw new import_errors10.FuelError(import_errors10.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
3514
+ throw new import_errors9.FuelError(import_errors9.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
3521
3515
  }
3522
3516
  /**
3523
3517
  * @hidden
@@ -3564,13 +3558,13 @@ var BaseTransactionRequest = class {
3564
3558
  * Please use `Account.generateFakeResources` along with `this.addResources` instead.
3565
3559
  */
3566
3560
  fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
3567
- const findAssetInput = (assetId) => this.inputs.find((input) => {
3561
+ const findAssetInput = /* @__PURE__ */ __name((assetId) => this.inputs.find((input) => {
3568
3562
  if ("assetId" in input) {
3569
3563
  return input.assetId === assetId;
3570
3564
  }
3571
3565
  return false;
3572
- });
3573
- const updateAssetInput = (assetId, quantity) => {
3566
+ }), "findAssetInput");
3567
+ const updateAssetInput = /* @__PURE__ */ __name((assetId, quantity) => {
3574
3568
  const assetInput = findAssetInput(assetId);
3575
3569
  let usedQuantity = quantity;
3576
3570
  if (assetId === baseAssetId) {
@@ -3591,7 +3585,7 @@ var BaseTransactionRequest = class {
3591
3585
  }
3592
3586
  ]);
3593
3587
  }
3594
- };
3588
+ }, "updateAssetInput");
3595
3589
  updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
3596
3590
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
3597
3591
  return this;
@@ -3679,6 +3673,7 @@ function hashTransaction(transactionRequest, chainId) {
3679
3673
  transaction.inputs = transaction.inputs.map((input) => {
3680
3674
  const inputClone = (0, import_ramda2.clone)(input);
3681
3675
  switch (inputClone.type) {
3676
+ // Zero out on signing: txPointer, predicateGasUsed
3682
3677
  case import_transactions9.InputType.Coin: {
3683
3678
  inputClone.txPointer = {
3684
3679
  blockHeight: 0,
@@ -3687,10 +3682,12 @@ function hashTransaction(transactionRequest, chainId) {
3687
3682
  inputClone.predicateGasUsed = (0, import_math9.bn)(0);
3688
3683
  return inputClone;
3689
3684
  }
3685
+ // Zero out on signing: predicateGasUsed
3690
3686
  case import_transactions9.InputType.Message: {
3691
3687
  inputClone.predicateGasUsed = (0, import_math9.bn)(0);
3692
3688
  return inputClone;
3693
3689
  }
3690
+ // Zero out on signing: txID, outputIndex, balanceRoot, stateRoot, and txPointer
3694
3691
  case import_transactions9.InputType.Contract: {
3695
3692
  inputClone.txPointer = {
3696
3693
  blockHeight: 0,
@@ -3709,15 +3706,18 @@ function hashTransaction(transactionRequest, chainId) {
3709
3706
  transaction.outputs = transaction.outputs.map((output) => {
3710
3707
  const outputClone = (0, import_ramda2.clone)(output);
3711
3708
  switch (outputClone.type) {
3709
+ // Zero out on signing: balanceRoot, stateRoot
3712
3710
  case import_transactions9.OutputType.Contract: {
3713
3711
  outputClone.balanceRoot = import_configs7.ZeroBytes32;
3714
3712
  outputClone.stateRoot = import_configs7.ZeroBytes32;
3715
3713
  return outputClone;
3716
3714
  }
3715
+ // Zero out on signing: amount
3717
3716
  case import_transactions9.OutputType.Change: {
3718
3717
  outputClone.amount = (0, import_math9.bn)(0);
3719
3718
  return outputClone;
3720
3719
  }
3720
+ // Zero out on signing: amount, to and assetId
3721
3721
  case import_transactions9.OutputType.Variable: {
3722
3722
  outputClone.to = import_configs7.ZeroBytes32;
3723
3723
  outputClone.amount = (0, import_math9.bn)(0);
@@ -3734,9 +3734,13 @@ function hashTransaction(transactionRequest, chainId) {
3734
3734
  const concatenatedData = (0, import_utils12.concat)([chainIdBytes, new import_transactions9.TransactionCoder().encode(transaction)]);
3735
3735
  return (0, import_hasher.sha256)(concatenatedData);
3736
3736
  }
3737
+ __name(hashTransaction, "hashTransaction");
3737
3738
 
3738
3739
  // src/providers/transaction-request/blob-transaction-request.ts
3739
3740
  var BlobTransactionRequest = class extends BaseTransactionRequest {
3741
+ static {
3742
+ __name(this, "BlobTransactionRequest");
3743
+ }
3740
3744
  static from(obj) {
3741
3745
  return new this((0, import_ramda3.clone)(obj));
3742
3746
  }
@@ -3805,12 +3809,12 @@ var import_ramda4 = require("ramda");
3805
3809
 
3806
3810
  // src/providers/transaction-request/storage-slot.ts
3807
3811
  var import_utils14 = require("@fuel-ts/utils");
3808
- var getStorageValue = (value) => {
3812
+ var getStorageValue = /* @__PURE__ */ __name((value) => {
3809
3813
  const v = new Uint8Array(32);
3810
3814
  v.set((0, import_utils14.arrayify)(value));
3811
3815
  return v;
3812
- };
3813
- var storageSlotify = (storageSlot) => {
3816
+ }, "getStorageValue");
3817
+ var storageSlotify = /* @__PURE__ */ __name((storageSlot) => {
3814
3818
  let key;
3815
3819
  let value;
3816
3820
  if (Array.isArray(storageSlot)) {
@@ -3824,10 +3828,13 @@ var storageSlotify = (storageSlot) => {
3824
3828
  key: (0, import_utils14.hexlify)(key),
3825
3829
  value: (0, import_utils14.hexlify)(getStorageValue(value))
3826
3830
  };
3827
- };
3831
+ }, "storageSlotify");
3828
3832
 
3829
3833
  // src/providers/transaction-request/create-transaction-request.ts
3830
3834
  var CreateTransactionRequest = class extends BaseTransactionRequest {
3835
+ static {
3836
+ __name(this, "CreateTransactionRequest");
3837
+ }
3831
3838
  static from(obj) {
3832
3839
  return new this((0, import_ramda4.clone)(obj));
3833
3840
  }
@@ -3929,7 +3936,7 @@ var returnZeroScript = {
3929
3936
  */
3930
3937
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
3931
3938
  bytes: (0, import_utils16.arrayify)("0x24000000"),
3932
- encodeScriptData: () => new Uint8Array(0)
3939
+ encodeScriptData: /* @__PURE__ */ __name(() => new Uint8Array(0), "encodeScriptData")
3933
3940
  };
3934
3941
  var withdrawScript = {
3935
3942
  /*
@@ -3943,11 +3950,14 @@ var withdrawScript = {
3943
3950
  */
3944
3951
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
3945
3952
  bytes: (0, import_utils16.arrayify)("0x5040C0105D44C0064C40001124000000"),
3946
- encodeScriptData: () => new Uint8Array(0)
3953
+ encodeScriptData: /* @__PURE__ */ __name(() => new Uint8Array(0), "encodeScriptData")
3947
3954
  };
3948
3955
 
3949
3956
  // src/providers/transaction-request/script-transaction-request.ts
3950
3957
  var ScriptTransactionRequest = class extends BaseTransactionRequest {
3958
+ static {
3959
+ __name(this, "ScriptTransactionRequest");
3960
+ }
3951
3961
  static from(obj) {
3952
3962
  return new this((0, import_ramda5.clone)(obj));
3953
3963
  }
@@ -4140,14 +4150,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
4140
4150
  };
4141
4151
 
4142
4152
  // src/providers/transaction-request/upgrade-transaction-request.ts
4143
- var import_errors12 = require("@fuel-ts/errors");
4153
+ var import_errors11 = require("@fuel-ts/errors");
4144
4154
  var import_hasher2 = require("@fuel-ts/hasher");
4145
4155
  var import_transactions12 = require("@fuel-ts/transactions");
4146
4156
  var import_utils18 = require("@fuel-ts/utils");
4147
4157
  var import_ramda6 = require("ramda");
4148
- var UpgradeTransactionRequest = class extends BaseTransactionRequest {
4158
+ var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTransactionRequest {
4159
+ static {
4160
+ __name(this, "UpgradeTransactionRequest");
4161
+ }
4149
4162
  static from(obj) {
4150
- if (obj instanceof UpgradeTransactionRequest) {
4163
+ if (obj instanceof _UpgradeTransactionRequest) {
4151
4164
  return obj;
4152
4165
  }
4153
4166
  return new this((0, import_ramda6.clone)(obj));
@@ -4244,7 +4257,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
4244
4257
  }
4245
4258
  };
4246
4259
  } else {
4247
- throw new import_errors12.FuelError(import_errors12.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
4260
+ throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
4248
4261
  }
4249
4262
  return {
4250
4263
  type: import_transactions12.TransactionType.Upgrade,
@@ -4286,7 +4299,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
4286
4299
  txBytesSize
4287
4300
  });
4288
4301
  }
4289
- throw new import_errors12.FuelError(import_errors12.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
4302
+ throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
4290
4303
  }
4291
4304
  };
4292
4305
 
@@ -4295,9 +4308,12 @@ var import_configs10 = require("@fuel-ts/address/configs");
4295
4308
  var import_transactions13 = require("@fuel-ts/transactions");
4296
4309
  var import_utils20 = require("@fuel-ts/utils");
4297
4310
  var import_ramda7 = require("ramda");
4298
- var UploadTransactionRequest = class extends BaseTransactionRequest {
4311
+ var UploadTransactionRequest = class _UploadTransactionRequest extends BaseTransactionRequest {
4312
+ static {
4313
+ __name(this, "UploadTransactionRequest");
4314
+ }
4299
4315
  static from(obj) {
4300
- if (obj instanceof UploadTransactionRequest) {
4316
+ if (obj instanceof _UploadTransactionRequest) {
4301
4317
  return obj;
4302
4318
  }
4303
4319
  return new this((0, import_ramda7.clone)(obj));
@@ -4398,12 +4414,15 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
4398
4414
 
4399
4415
  // src/providers/transaction-request/types.ts
4400
4416
  var AbstractScriptRequest = class {
4417
+ static {
4418
+ __name(this, "AbstractScriptRequest");
4419
+ }
4401
4420
  };
4402
4421
 
4403
4422
  // src/providers/transaction-request/utils.ts
4404
- var import_errors13 = require("@fuel-ts/errors");
4423
+ var import_errors12 = require("@fuel-ts/errors");
4405
4424
  var import_transactions14 = require("@fuel-ts/transactions");
4406
- var transactionRequestify = (obj) => {
4425
+ var transactionRequestify = /* @__PURE__ */ __name((obj) => {
4407
4426
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
4408
4427
  return obj;
4409
4428
  }
@@ -4425,28 +4444,31 @@ var transactionRequestify = (obj) => {
4425
4444
  return UploadTransactionRequest.from(obj);
4426
4445
  }
4427
4446
  default: {
4428
- throw new import_errors13.FuelError(
4429
- import_errors13.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
4447
+ throw new import_errors12.FuelError(
4448
+ import_errors12.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
4430
4449
  `Unsupported transaction type: ${type}.`
4431
4450
  );
4432
4451
  }
4433
4452
  }
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;
4453
+ }, "transactionRequestify");
4454
+ var isTransactionTypeScript = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Script, "isTransactionTypeScript");
4455
+ var isTransactionTypeCreate = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Create, "isTransactionTypeCreate");
4456
+ var isTransactionTypeBlob = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Blob, "isTransactionTypeBlob");
4457
+ var isTransactionTypeUpgrade = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Upgrade, "isTransactionTypeUpgrade");
4458
+ var isTransactionTypeUpload = /* @__PURE__ */ __name((request2) => request2.type === import_transactions14.TransactionType.Upload, "isTransactionTypeUpload");
4440
4459
 
4441
4460
  // src/providers/resource-cache.ts
4442
4461
  var cache = /* @__PURE__ */ new Map();
4443
4462
  var ResourceCache = class {
4463
+ static {
4464
+ __name(this, "ResourceCache");
4465
+ }
4444
4466
  ttl;
4445
4467
  constructor(ttl) {
4446
4468
  this.ttl = ttl;
4447
4469
  if (typeof ttl !== "number" || this.ttl <= 0) {
4448
- throw new import_errors14.FuelError(
4449
- import_errors14.ErrorCode.INVALID_TTL,
4470
+ throw new import_errors13.FuelError(
4471
+ import_errors13.ErrorCode.INVALID_TTL,
4450
4472
  `Invalid TTL: ${this.ttl}. Use a value greater than zero.`
4451
4473
  );
4452
4474
  }
@@ -4530,7 +4552,7 @@ var ResourceCache = class {
4530
4552
  };
4531
4553
 
4532
4554
  // src/providers/transaction-response/transaction-response.ts
4533
- var import_errors18 = require("@fuel-ts/errors");
4555
+ var import_errors17 = require("@fuel-ts/errors");
4534
4556
  var import_math17 = require("@fuel-ts/math");
4535
4557
  var import_transactions22 = require("@fuel-ts/transactions");
4536
4558
  var import_utils26 = require("@fuel-ts/utils");
@@ -4544,7 +4566,7 @@ var import_utils24 = require("@fuel-ts/utils");
4544
4566
  var import_math12 = require("@fuel-ts/math");
4545
4567
  var import_transactions15 = require("@fuel-ts/transactions");
4546
4568
  var import_utils23 = require("@fuel-ts/utils");
4547
- var calculateTXFeeForSummary = (params) => {
4569
+ var calculateTXFeeForSummary = /* @__PURE__ */ __name((params) => {
4548
4570
  const {
4549
4571
  gasPrice,
4550
4572
  rawPayload,
@@ -4604,43 +4626,51 @@ var calculateTXFeeForSummary = (params) => {
4604
4626
  tip
4605
4627
  });
4606
4628
  return maxFee;
4607
- };
4629
+ }, "calculateTXFeeForSummary");
4608
4630
 
4609
4631
  // src/providers/transaction-summary/operations.ts
4610
4632
  var import_configs11 = require("@fuel-ts/address/configs");
4611
- var import_errors16 = require("@fuel-ts/errors");
4633
+ var import_errors15 = require("@fuel-ts/errors");
4612
4634
  var import_math14 = require("@fuel-ts/math");
4613
4635
  var import_transactions18 = require("@fuel-ts/transactions");
4614
4636
 
4615
4637
  // src/providers/transaction-summary/input.ts
4616
- var import_errors15 = require("@fuel-ts/errors");
4638
+ var import_errors14 = require("@fuel-ts/errors");
4617
4639
  var import_math13 = require("@fuel-ts/math");
4618
4640
  var import_transactions16 = require("@fuel-ts/transactions");
4619
4641
  function getInputsByTypes(inputs, types) {
4620
4642
  return inputs.filter((i) => types.includes(i.type));
4621
4643
  }
4644
+ __name(getInputsByTypes, "getInputsByTypes");
4622
4645
  function getInputsByType(inputs, type) {
4623
4646
  return inputs.filter((i) => i.type === type);
4624
4647
  }
4648
+ __name(getInputsByType, "getInputsByType");
4625
4649
  function getInputsCoin(inputs) {
4626
4650
  return getInputsByType(inputs, import_transactions16.InputType.Coin);
4627
4651
  }
4652
+ __name(getInputsCoin, "getInputsCoin");
4628
4653
  function getInputsMessage(inputs) {
4629
4654
  return getInputsByType(inputs, import_transactions16.InputType.Message);
4630
4655
  }
4656
+ __name(getInputsMessage, "getInputsMessage");
4631
4657
  function getInputsCoinAndMessage(inputs) {
4632
4658
  return getInputsByTypes(inputs, [import_transactions16.InputType.Coin, import_transactions16.InputType.Message]);
4633
4659
  }
4660
+ __name(getInputsCoinAndMessage, "getInputsCoinAndMessage");
4634
4661
  function isInputCoin(input) {
4635
4662
  return input.type === import_transactions16.InputType.Coin;
4636
4663
  }
4664
+ __name(isInputCoin, "isInputCoin");
4637
4665
  function getInputsContract(inputs) {
4638
4666
  return getInputsByType(inputs, import_transactions16.InputType.Contract);
4639
4667
  }
4668
+ __name(getInputsContract, "getInputsContract");
4640
4669
  function findCoinInput(inputs, assetId) {
4641
4670
  const coinInputs = getInputsCoin(inputs);
4642
4671
  return coinInputs.find((i) => i.assetId === assetId);
4643
4672
  }
4673
+ __name(findCoinInput, "findCoinInput");
4644
4674
  function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
4645
4675
  const aggregated = /* @__PURE__ */ new Map();
4646
4676
  getInputsCoinAndMessage(inputs).forEach((input) => {
@@ -4660,9 +4690,11 @@ function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
4660
4690
  });
4661
4691
  return aggregated;
4662
4692
  }
4693
+ __name(aggregateInputsAmountsByAssetAndOwner, "aggregateInputsAmountsByAssetAndOwner");
4663
4694
  function findMessageInput(inputs) {
4664
4695
  return getInputsMessage(inputs)?.[0];
4665
4696
  }
4697
+ __name(findMessageInput, "findMessageInput");
4666
4698
  function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
4667
4699
  const coinInput = findCoinInput(inputs, assetId);
4668
4700
  if (coinInput) {
@@ -4673,6 +4705,7 @@ function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
4673
4705
  }
4674
4706
  return void 0;
4675
4707
  }
4708
+ __name(getInputFromAssetId, "getInputFromAssetId");
4676
4709
  function getInputContractFromIndex(inputs, inputIndex) {
4677
4710
  if (inputIndex == null) {
4678
4711
  return void 0;
@@ -4682,13 +4715,14 @@ function getInputContractFromIndex(inputs, inputIndex) {
4682
4715
  return void 0;
4683
4716
  }
4684
4717
  if (contractInput.type !== import_transactions16.InputType.Contract) {
4685
- throw new import_errors15.FuelError(
4686
- import_errors15.ErrorCode.INVALID_TRANSACTION_INPUT,
4718
+ throw new import_errors14.FuelError(
4719
+ import_errors14.ErrorCode.INVALID_TRANSACTION_INPUT,
4687
4720
  `Contract input should be of type 'contract'.`
4688
4721
  );
4689
4722
  }
4690
4723
  return contractInput;
4691
4724
  }
4725
+ __name(getInputContractFromIndex, "getInputContractFromIndex");
4692
4726
  function getInputAccountAddress(input) {
4693
4727
  if (input.type === import_transactions16.InputType.Coin) {
4694
4728
  return input.owner.toString();
@@ -4698,27 +4732,34 @@ function getInputAccountAddress(input) {
4698
4732
  }
4699
4733
  return "";
4700
4734
  }
4735
+ __name(getInputAccountAddress, "getInputAccountAddress");
4701
4736
 
4702
4737
  // src/providers/transaction-summary/output.ts
4703
4738
  var import_transactions17 = require("@fuel-ts/transactions");
4704
4739
  function getOutputsByType(outputs, type) {
4705
4740
  return outputs.filter((o) => o.type === type);
4706
4741
  }
4742
+ __name(getOutputsByType, "getOutputsByType");
4707
4743
  function getOutputsContractCreated(outputs) {
4708
4744
  return getOutputsByType(outputs, import_transactions17.OutputType.ContractCreated);
4709
4745
  }
4746
+ __name(getOutputsContractCreated, "getOutputsContractCreated");
4710
4747
  function getOutputsCoin(outputs) {
4711
4748
  return getOutputsByType(outputs, import_transactions17.OutputType.Coin);
4712
4749
  }
4750
+ __name(getOutputsCoin, "getOutputsCoin");
4713
4751
  function getOutputsChange(outputs) {
4714
4752
  return getOutputsByType(outputs, import_transactions17.OutputType.Change);
4715
4753
  }
4754
+ __name(getOutputsChange, "getOutputsChange");
4716
4755
  function getOutputsContract(outputs) {
4717
4756
  return getOutputsByType(outputs, import_transactions17.OutputType.Contract);
4718
4757
  }
4758
+ __name(getOutputsContract, "getOutputsContract");
4719
4759
  function getOutputsVariable(outputs) {
4720
4760
  return getOutputsByType(outputs, import_transactions17.OutputType.Variable);
4721
4761
  }
4762
+ __name(getOutputsVariable, "getOutputsVariable");
4722
4763
 
4723
4764
  // src/providers/transaction-summary/types.ts
4724
4765
  var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
@@ -4761,6 +4802,7 @@ var ChainName = /* @__PURE__ */ ((ChainName2) => {
4761
4802
  function getReceiptsByType(receipts, type) {
4762
4803
  return (receipts ?? []).filter((r) => r.type === type);
4763
4804
  }
4805
+ __name(getReceiptsByType, "getReceiptsByType");
4764
4806
  function getTransactionTypeName(transactionType) {
4765
4807
  switch (transactionType) {
4766
4808
  case import_transactions18.TransactionType.Mint:
@@ -4776,43 +4818,54 @@ function getTransactionTypeName(transactionType) {
4776
4818
  case import_transactions18.TransactionType.Upload:
4777
4819
  return "Upload" /* Upload */;
4778
4820
  default:
4779
- throw new import_errors16.FuelError(
4780
- import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
4821
+ throw new import_errors15.FuelError(
4822
+ import_errors15.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
4781
4823
  `Unsupported transaction type: ${transactionType}.`
4782
4824
  );
4783
4825
  }
4784
4826
  }
4827
+ __name(getTransactionTypeName, "getTransactionTypeName");
4785
4828
  function isType(transactionType, type) {
4786
4829
  const txType = getTransactionTypeName(transactionType);
4787
4830
  return txType === type;
4788
4831
  }
4832
+ __name(isType, "isType");
4789
4833
  function isTypeMint(transactionType) {
4790
4834
  return isType(transactionType, "Mint" /* Mint */);
4791
4835
  }
4836
+ __name(isTypeMint, "isTypeMint");
4792
4837
  function isTypeCreate(transactionType) {
4793
4838
  return isType(transactionType, "Create" /* Create */);
4794
4839
  }
4840
+ __name(isTypeCreate, "isTypeCreate");
4795
4841
  function isTypeScript(transactionType) {
4796
4842
  return isType(transactionType, "Script" /* Script */);
4797
4843
  }
4844
+ __name(isTypeScript, "isTypeScript");
4798
4845
  function isTypeUpgrade(transactionType) {
4799
4846
  return isType(transactionType, "Upgrade" /* Upgrade */);
4800
4847
  }
4848
+ __name(isTypeUpgrade, "isTypeUpgrade");
4801
4849
  function isTypeUpload(transactionType) {
4802
4850
  return isType(transactionType, "Upload" /* Upload */);
4803
4851
  }
4852
+ __name(isTypeUpload, "isTypeUpload");
4804
4853
  function isTypeBlob(transactionType) {
4805
4854
  return isType(transactionType, "Blob" /* Blob */);
4806
4855
  }
4856
+ __name(isTypeBlob, "isTypeBlob");
4807
4857
  function hasSameAssetId(a) {
4808
4858
  return (b) => a.assetId === b.assetId;
4809
4859
  }
4860
+ __name(hasSameAssetId, "hasSameAssetId");
4810
4861
  function getReceiptsCall(receipts) {
4811
4862
  return getReceiptsByType(receipts, import_transactions18.ReceiptType.Call);
4812
4863
  }
4864
+ __name(getReceiptsCall, "getReceiptsCall");
4813
4865
  function getReceiptsMessageOut(receipts) {
4814
4866
  return getReceiptsByType(receipts, import_transactions18.ReceiptType.MessageOut);
4815
4867
  }
4868
+ __name(getReceiptsMessageOut, "getReceiptsMessageOut");
4816
4869
  function mergeAssets(op1, op2) {
4817
4870
  const assets1 = op1.assetsSent || [];
4818
4871
  const assets2 = op2.assetsSent || [];
@@ -4830,21 +4883,25 @@ function mergeAssets(op1, op2) {
4830
4883
  });
4831
4884
  return Array.from(assetMap.values());
4832
4885
  }
4886
+ __name(mergeAssets, "mergeAssets");
4833
4887
  function isSameOperation(a, b) {
4834
4888
  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
4889
  }
4890
+ __name(isSameOperation, "isSameOperation");
4836
4891
  function mergeAssetsSent(existing, toAdd) {
4837
4892
  if (!toAdd.assetsSent?.length) {
4838
4893
  return existing.assetsSent;
4839
4894
  }
4840
4895
  return existing.assetsSent?.length ? mergeAssets(existing, toAdd) : toAdd.assetsSent;
4841
4896
  }
4897
+ __name(mergeAssetsSent, "mergeAssetsSent");
4842
4898
  function mergeCalls(existing, toAdd) {
4843
4899
  if (!toAdd.calls?.length) {
4844
4900
  return existing.calls;
4845
4901
  }
4846
4902
  return [...existing.calls || [], ...toAdd.calls];
4847
4903
  }
4904
+ __name(mergeCalls, "mergeCalls");
4848
4905
  function mergeOperations(existing, toAdd) {
4849
4906
  return {
4850
4907
  ...existing,
@@ -4856,6 +4913,7 @@ function mergeOperations(existing, toAdd) {
4856
4913
  ]
4857
4914
  };
4858
4915
  }
4916
+ __name(mergeOperations, "mergeOperations");
4859
4917
  function addOperation(operations, toAdd) {
4860
4918
  const existingIndex = operations.findIndex((op) => isSameOperation(op, toAdd));
4861
4919
  if (existingIndex === -1) {
@@ -4863,9 +4921,11 @@ function addOperation(operations, toAdd) {
4863
4921
  }
4864
4922
  return operations.map((op, index) => index === existingIndex ? mergeOperations(op, toAdd) : op);
4865
4923
  }
4924
+ __name(addOperation, "addOperation");
4866
4925
  function getReceiptsTransferOut(receipts) {
4867
4926
  return getReceiptsByType(receipts, import_transactions18.ReceiptType.TransferOut);
4868
4927
  }
4928
+ __name(getReceiptsTransferOut, "getReceiptsTransferOut");
4869
4929
  function getWithdrawFromFuelOperations({
4870
4930
  inputs,
4871
4931
  receipts,
@@ -4904,6 +4964,7 @@ function getWithdrawFromFuelOperations({
4904
4964
  );
4905
4965
  return withdrawFromFuelOperations;
4906
4966
  }
4967
+ __name(getWithdrawFromFuelOperations, "getWithdrawFromFuelOperations");
4907
4968
  function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
4908
4969
  const abi = abiMap?.[contractInput.contractID];
4909
4970
  if (!abi) {
@@ -4911,6 +4972,7 @@ function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInpu
4911
4972
  }
4912
4973
  return [];
4913
4974
  }
4975
+ __name(getContractCalls, "getContractCalls");
4914
4976
  function getAssetsSent(receipt) {
4915
4977
  return receipt.amount?.isZero() ? void 0 : [
4916
4978
  {
@@ -4919,6 +4981,7 @@ function getAssetsSent(receipt) {
4919
4981
  }
4920
4982
  ];
4921
4983
  }
4984
+ __name(getAssetsSent, "getAssetsSent");
4922
4985
  function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
4923
4986
  const assetId = receipt.assetId === import_configs11.ZeroBytes32 ? baseAssetId : receipt.assetId;
4924
4987
  const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
@@ -4944,6 +5007,7 @@ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload,
4944
5007
  }
4945
5008
  ];
4946
5009
  }
5010
+ __name(processCallReceipt, "processCallReceipt");
4947
5011
  function getContractCallOperations({
4948
5012
  inputs,
4949
5013
  outputs,
@@ -4973,6 +5037,7 @@ function getContractCallOperations({
4973
5037
  );
4974
5038
  });
4975
5039
  }
5040
+ __name(getContractCallOperations, "getContractCallOperations");
4976
5041
  function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
4977
5042
  const { to: toAddress, assetId, amount } = receipt;
4978
5043
  let { id: fromAddress } = receipt;
@@ -5001,6 +5066,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
5001
5066
  receipts: [receipt]
5002
5067
  };
5003
5068
  }
5069
+ __name(extractTransferOperationFromReceipt, "extractTransferOperationFromReceipt");
5004
5070
  function getTransferOperations({
5005
5071
  inputs,
5006
5072
  outputs,
@@ -5055,6 +5121,7 @@ function getTransferOperations({
5055
5121
  });
5056
5122
  return operations;
5057
5123
  }
5124
+ __name(getTransferOperations, "getTransferOperations");
5058
5125
  function getPayProducerOperations(outputs) {
5059
5126
  const coinOutputs = getOutputsCoin(outputs);
5060
5127
  const payProducerOperations = coinOutputs.reduce((prev, output) => {
@@ -5079,6 +5146,7 @@ function getPayProducerOperations(outputs) {
5079
5146
  }, []);
5080
5147
  return payProducerOperations;
5081
5148
  }
5149
+ __name(getPayProducerOperations, "getPayProducerOperations");
5082
5150
  function getContractCreatedOperations({ inputs, outputs }) {
5083
5151
  const contractCreatedOutputs = getOutputsContractCreated(outputs);
5084
5152
  const input = getInputsCoinAndMessage(inputs)[0];
@@ -5099,6 +5167,7 @@ function getContractCreatedOperations({ inputs, outputs }) {
5099
5167
  }, []);
5100
5168
  return contractCreatedOperations;
5101
5169
  }
5170
+ __name(getContractCreatedOperations, "getContractCreatedOperations");
5102
5171
  function getOperations({
5103
5172
  transactionType,
5104
5173
  inputs,
@@ -5129,11 +5198,12 @@ function getOperations({
5129
5198
  }
5130
5199
  return [...getPayProducerOperations(outputs)];
5131
5200
  }
5201
+ __name(getOperations, "getOperations");
5132
5202
 
5133
5203
  // src/providers/transaction-summary/receipt.ts
5134
5204
  var import_transactions19 = require("@fuel-ts/transactions");
5135
- var processGqlReceipt = (gqlReceipt) => deserializeReceipt(gqlReceipt);
5136
- var extractMintedAssetsFromReceipts = (receipts) => {
5205
+ var processGqlReceipt = /* @__PURE__ */ __name((gqlReceipt) => deserializeReceipt(gqlReceipt), "processGqlReceipt");
5206
+ var extractMintedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
5137
5207
  const mintedAssets = [];
5138
5208
  receipts.forEach((receipt) => {
5139
5209
  if (receipt.type === import_transactions19.ReceiptType.Mint) {
@@ -5146,8 +5216,8 @@ var extractMintedAssetsFromReceipts = (receipts) => {
5146
5216
  }
5147
5217
  });
5148
5218
  return mintedAssets;
5149
- };
5150
- var extractBurnedAssetsFromReceipts = (receipts) => {
5219
+ }, "extractMintedAssetsFromReceipts");
5220
+ var extractBurnedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
5151
5221
  const burnedAssets = [];
5152
5222
  receipts.forEach((receipt) => {
5153
5223
  if (receipt.type === import_transactions19.ReceiptType.Burn) {
@@ -5160,12 +5230,12 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
5160
5230
  }
5161
5231
  });
5162
5232
  return burnedAssets;
5163
- };
5233
+ }, "extractBurnedAssetsFromReceipts");
5164
5234
 
5165
5235
  // src/providers/transaction-summary/status.ts
5166
- var import_errors17 = require("@fuel-ts/errors");
5236
+ var import_errors16 = require("@fuel-ts/errors");
5167
5237
  var import_math15 = require("@fuel-ts/math");
5168
- var getTransactionStatusName = (gqlStatus) => {
5238
+ var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
5169
5239
  switch (gqlStatus) {
5170
5240
  case "FailureStatus":
5171
5241
  return "failure" /* failure */;
@@ -5176,13 +5246,13 @@ var getTransactionStatusName = (gqlStatus) => {
5176
5246
  case "SqueezedOutStatus":
5177
5247
  return "squeezedout" /* squeezedout */;
5178
5248
  default:
5179
- throw new import_errors17.FuelError(
5180
- import_errors17.ErrorCode.INVALID_TRANSACTION_STATUS,
5249
+ throw new import_errors16.FuelError(
5250
+ import_errors16.ErrorCode.INVALID_TRANSACTION_STATUS,
5181
5251
  `Invalid transaction status: ${gqlStatus}.`
5182
5252
  );
5183
5253
  }
5184
- };
5185
- var processGraphqlStatus = (gqlTransactionStatus) => {
5254
+ }, "getTransactionStatusName");
5255
+ var processGraphqlStatus = /* @__PURE__ */ __name((gqlTransactionStatus) => {
5186
5256
  let time;
5187
5257
  let blockId;
5188
5258
  let status;
@@ -5226,8 +5296,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
5226
5296
  isStatusPending
5227
5297
  };
5228
5298
  return processedGraphqlStatus;
5229
- };
5230
- var getTotalFeeFromStatus = (status) => status && "totalFee" in status ? (0, import_math15.bn)(status.totalFee) : void 0;
5299
+ }, "processGraphqlStatus");
5300
+ var getTotalFeeFromStatus = /* @__PURE__ */ __name((status) => status && "totalFee" in status ? (0, import_math15.bn)(status.totalFee) : void 0, "getTotalFeeFromStatus");
5231
5301
 
5232
5302
  // src/providers/transaction-summary/assemble-transaction-summary.ts
5233
5303
  function assembleTransactionSummary(params) {
@@ -5307,12 +5377,14 @@ function assembleTransactionSummary(params) {
5307
5377
  };
5308
5378
  return transactionSummary;
5309
5379
  }
5380
+ __name(assembleTransactionSummary, "assembleTransactionSummary");
5310
5381
 
5311
- // src/providers/transaction-response/getDecodedLogs.ts
5382
+ // src/providers/transaction-response/getAllDecodedLogs.ts
5312
5383
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
5313
5384
  var import_configs12 = require("@fuel-ts/address/configs");
5314
5385
  var import_transactions21 = require("@fuel-ts/transactions");
5315
- function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
5386
+ function getAllDecodedLogs(opts) {
5387
+ const { receipts, mainAbi, externalAbis = {} } = opts;
5316
5388
  let mainContract = "";
5317
5389
  if (mainAbi.programType === "contract") {
5318
5390
  const firstCallReceipt = receipts.find(
@@ -5320,20 +5392,25 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
5320
5392
  );
5321
5393
  mainContract = firstCallReceipt.to;
5322
5394
  }
5323
- return receipts.reduce((logs, receipt) => {
5324
- if (receipt.type === import_transactions21.ReceiptType.LogData || receipt.type === import_transactions21.ReceiptType.Log) {
5325
- const isLogFromMainAbi = receipt.id === import_configs12.ZeroBytes32 || mainContract === receipt.id;
5326
- const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
5327
- if (isDecodable) {
5328
- const interfaceToUse = isLogFromMainAbi ? new import_abi_coder4.Interface(mainAbi) : new import_abi_coder4.Interface(externalAbis[receipt.id]);
5329
- const data = receipt.type === import_transactions21.ReceiptType.Log ? new import_abi_coder4.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
5330
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
5331
- logs.push(decodedLog);
5395
+ return receipts.reduce(
5396
+ ({ logs, groupedLogs }, receipt) => {
5397
+ if (receipt.type === import_transactions21.ReceiptType.LogData || receipt.type === import_transactions21.ReceiptType.Log) {
5398
+ const isLogFromMainAbi = receipt.id === import_configs12.ZeroBytes32 || mainContract === receipt.id;
5399
+ const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
5400
+ if (isDecodable) {
5401
+ const interfaceToUse = isLogFromMainAbi ? new import_abi_coder4.Interface(mainAbi) : new import_abi_coder4.Interface(externalAbis[receipt.id]);
5402
+ const data = receipt.type === import_transactions21.ReceiptType.Log ? new import_abi_coder4.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
5403
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
5404
+ logs.push(decodedLog);
5405
+ groupedLogs[receipt.id] = [...groupedLogs[receipt.id] || [], decodedLog];
5406
+ }
5332
5407
  }
5333
- }
5334
- return logs;
5335
- }, []);
5408
+ return { logs, groupedLogs };
5409
+ },
5410
+ { logs: [], groupedLogs: {} }
5411
+ );
5336
5412
  }
5413
+ __name(getAllDecodedLogs, "getAllDecodedLogs");
5337
5414
 
5338
5415
  // src/providers/transaction-response/transaction-response.ts
5339
5416
  function mapGqlOutputsToTxOutputs(outputs) {
@@ -5366,7 +5443,8 @@ function mapGqlOutputsToTxOutputs(outputs) {
5366
5443
  }
5367
5444
  });
5368
5445
  }
5369
- var TransactionResponse = class {
5446
+ __name(mapGqlOutputsToTxOutputs, "mapGqlOutputsToTxOutputs");
5447
+ var TransactionResponse = class _TransactionResponse {
5370
5448
  /**
5371
5449
  * Constructor for `TransactionResponse`.
5372
5450
  *
@@ -5381,6 +5459,9 @@ var TransactionResponse = class {
5381
5459
  this.request = typeof tx === "string" ? void 0 : tx;
5382
5460
  this.waitForResult = this.waitForResult.bind(this);
5383
5461
  }
5462
+ static {
5463
+ __name(this, "TransactionResponse");
5464
+ }
5384
5465
  /** Transaction ID */
5385
5466
  id;
5386
5467
  /** Current provider */
@@ -5402,7 +5483,7 @@ var TransactionResponse = class {
5402
5483
  */
5403
5484
  static async create(id, provider, abis) {
5404
5485
  const chainId = await provider.getChainId();
5405
- const response = new TransactionResponse(id, provider, chainId, abis);
5486
+ const response = new _TransactionResponse(id, provider, chainId, abis);
5406
5487
  await response.fetch();
5407
5488
  return response;
5408
5489
  }
@@ -5534,8 +5615,8 @@ var TransactionResponse = class {
5534
5615
  this.status = statusChange;
5535
5616
  if (statusChange.type === "SqueezedOutStatus") {
5536
5617
  this.unsetResourceCache();
5537
- throw new import_errors18.FuelError(
5538
- import_errors18.ErrorCode.TRANSACTION_SQUEEZED_OUT,
5618
+ throw new import_errors17.FuelError(
5619
+ import_errors17.ErrorCode.TRANSACTION_SQUEEZED_OUT,
5539
5620
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
5540
5621
  );
5541
5622
  }
@@ -5561,14 +5642,15 @@ var TransactionResponse = class {
5561
5642
  const transactionResult = {
5562
5643
  ...transactionSummary
5563
5644
  };
5564
- let logs = [];
5645
+ let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
5565
5646
  if (this.abis) {
5566
- logs = getDecodedLogs(
5567
- transactionSummary.receipts,
5568
- this.abis.main,
5569
- this.abis.otherContractsAbis
5570
- );
5647
+ ({ logs, groupedLogs } = getAllDecodedLogs({
5648
+ receipts: transactionSummary.receipts,
5649
+ mainAbi: this.abis.main,
5650
+ externalAbis: this.abis.otherContractsAbis
5651
+ }));
5571
5652
  transactionResult.logs = logs;
5653
+ transactionResult.groupedLogs = groupedLogs;
5572
5654
  }
5573
5655
  const { receipts } = transactionResult;
5574
5656
  const status = this.status ?? this.gqlTransaction?.status;
@@ -5577,7 +5659,8 @@ var TransactionResponse = class {
5577
5659
  throw extractTxError({
5578
5660
  receipts,
5579
5661
  statusReason: reason,
5580
- logs
5662
+ logs,
5663
+ groupedLogs
5581
5664
  });
5582
5665
  }
5583
5666
  return transactionResult;
@@ -5605,6 +5688,34 @@ var TransactionResponse = class {
5605
5688
  }
5606
5689
  };
5607
5690
 
5691
+ // src/providers/transaction-response/getDecodedLogs.ts
5692
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
5693
+ var import_configs13 = require("@fuel-ts/address/configs");
5694
+ var import_transactions23 = require("@fuel-ts/transactions");
5695
+ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
5696
+ let mainContract = "";
5697
+ if (mainAbi.programType === "contract") {
5698
+ const firstCallReceipt = receipts.find(
5699
+ (r) => r.type === import_transactions23.ReceiptType.Call && r.id === import_configs13.ZeroBytes32
5700
+ );
5701
+ mainContract = firstCallReceipt.to;
5702
+ }
5703
+ return receipts.reduce((logs, receipt) => {
5704
+ if (receipt.type === import_transactions23.ReceiptType.LogData || receipt.type === import_transactions23.ReceiptType.Log) {
5705
+ const isLogFromMainAbi = receipt.id === import_configs13.ZeroBytes32 || mainContract === receipt.id;
5706
+ const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
5707
+ if (isDecodable) {
5708
+ const interfaceToUse = isLogFromMainAbi ? new import_abi_coder5.Interface(mainAbi) : new import_abi_coder5.Interface(externalAbis[receipt.id]);
5709
+ const data = receipt.type === import_transactions23.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
5710
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
5711
+ logs.push(decodedLog);
5712
+ }
5713
+ }
5714
+ return logs;
5715
+ }, []);
5716
+ }
5717
+ __name(getDecodedLogs, "getDecodedLogs");
5718
+
5608
5719
  // src/providers/utils/auto-retry-fetch.ts
5609
5720
  var import_utils28 = require("@fuel-ts/utils");
5610
5721
  function getWaitDelay(options, retryAttemptNum) {
@@ -5619,6 +5730,7 @@ function getWaitDelay(options, retryAttemptNum) {
5619
5730
  return 2 ** (retryAttemptNum - 1) * duration;
5620
5731
  }
5621
5732
  }
5733
+ __name(getWaitDelay, "getWaitDelay");
5622
5734
  function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
5623
5735
  if (options === void 0) {
5624
5736
  return fetchFn;
@@ -5641,9 +5753,10 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
5641
5753
  }
5642
5754
  };
5643
5755
  }
5756
+ __name(autoRetryFetch, "autoRetryFetch");
5644
5757
 
5645
5758
  // src/providers/utils/helpers.ts
5646
- var adjustResourcesToExclude = (params) => {
5759
+ var adjustResourcesToExclude = /* @__PURE__ */ __name((params) => {
5647
5760
  const { userInput, cached, maxInputs } = params;
5648
5761
  const final = { ...userInput };
5649
5762
  let total = final.utxos.length + final.messages.length;
@@ -5656,34 +5769,34 @@ var adjustResourcesToExclude = (params) => {
5656
5769
  final.messages = [...final.messages, ...cached.messages.slice(0, maxInputs - total)];
5657
5770
  }
5658
5771
  return final;
5659
- };
5772
+ }, "adjustResourcesToExclude");
5660
5773
 
5661
5774
  // src/providers/utils/validate-pagination-args.ts
5662
- var import_errors19 = require("@fuel-ts/errors");
5663
- var validatePaginationArgs = (params) => {
5775
+ var import_errors18 = require("@fuel-ts/errors");
5776
+ var validatePaginationArgs = /* @__PURE__ */ __name((params) => {
5664
5777
  const { paginationLimit, inputArgs = {} } = params;
5665
5778
  const { first, last, after, before } = inputArgs;
5666
5779
  if (after && before) {
5667
- throw new import_errors19.FuelError(
5668
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
5780
+ throw new import_errors18.FuelError(
5781
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
5669
5782
  'Pagination arguments "after" and "before" cannot be used together'
5670
5783
  );
5671
5784
  }
5672
5785
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
5673
- throw new import_errors19.FuelError(
5674
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
5786
+ throw new import_errors18.FuelError(
5787
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
5675
5788
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
5676
5789
  );
5677
5790
  }
5678
5791
  if (first && before) {
5679
- throw new import_errors19.FuelError(
5680
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
5792
+ throw new import_errors18.FuelError(
5793
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
5681
5794
  'The use of pagination argument "first" with "before" is not supported'
5682
5795
  );
5683
5796
  }
5684
5797
  if (last && after) {
5685
- throw new import_errors19.FuelError(
5686
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
5798
+ throw new import_errors18.FuelError(
5799
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
5687
5800
  'The use of pagination argument "last" with "after" is not supported'
5688
5801
  );
5689
5802
  }
@@ -5691,18 +5804,71 @@ var validatePaginationArgs = (params) => {
5691
5804
  inputArgs.first = paginationLimit;
5692
5805
  }
5693
5806
  return inputArgs;
5694
- };
5807
+ }, "validatePaginationArgs");
5695
5808
 
5696
5809
  // src/providers/provider.ts
5697
5810
  var MAX_RETRIES = 10;
5698
5811
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
5699
5812
  var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
5700
5813
  var BALANCES_PAGE_SIZE_LIMIT = 100;
5814
+ var NON_PAGINATED_BALANCES_SIZE = 1e4;
5701
5815
  var BLOCKS_PAGE_SIZE_LIMIT = 5;
5702
5816
  var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
5703
5817
  var GAS_USED_MODIFIER = 1.2;
5704
- var _cacheInputs, cacheInputs_fn;
5705
- var _Provider = class {
5818
+ var Provider = class _Provider {
5819
+ static {
5820
+ __name(this, "Provider");
5821
+ }
5822
+ operations;
5823
+ cache;
5824
+ /** @hidden */
5825
+ static clearChainAndNodeCaches() {
5826
+ _Provider.inflightFetchChainAndNodeInfoRequests = {};
5827
+ _Provider.nodeInfoCache = {};
5828
+ _Provider.chainInfoCache = {};
5829
+ }
5830
+ /** @hidden */
5831
+ url;
5832
+ /** @hidden */
5833
+ urlWithoutAuth;
5834
+ /** @hidden */
5835
+ static inflightFetchChainAndNodeInfoRequests = {};
5836
+ /** @hidden */
5837
+ static chainInfoCache = {};
5838
+ /** @hidden */
5839
+ static nodeInfoCache = {};
5840
+ /** @hidden */
5841
+ static incompatibleNodeVersionMessage = "";
5842
+ /** @hidden */
5843
+ consensusParametersTimestamp;
5844
+ options = {
5845
+ timeout: void 0,
5846
+ resourceCacheTTL: void 0,
5847
+ fetch: void 0,
5848
+ retryOptions: void 0,
5849
+ headers: void 0,
5850
+ cache: void 0
5851
+ };
5852
+ /**
5853
+ * @hidden
5854
+ */
5855
+ static getFetchFn(options) {
5856
+ const { retryOptions, timeout, headers } = options;
5857
+ return autoRetryFetch(async (...args) => {
5858
+ const url = args[0];
5859
+ const request2 = args[1];
5860
+ const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
5861
+ let fullRequest = {
5862
+ ...request2,
5863
+ signal,
5864
+ headers: { ...request2?.headers, ...headers }
5865
+ };
5866
+ if (options.requestMiddleware) {
5867
+ fullRequest = await options.requestMiddleware(fullRequest);
5868
+ }
5869
+ return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
5870
+ }, retryOptions);
5871
+ }
5706
5872
  /**
5707
5873
  * Constructor to initialize a Provider.
5708
5874
  *
@@ -5711,31 +5877,6 @@ var _Provider = class {
5711
5877
  * @hidden
5712
5878
  */
5713
5879
  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
5880
  const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
5740
5881
  this.url = rawUrl;
5741
5882
  this.urlWithoutAuth = urlWithoutAuth;
@@ -5765,38 +5906,12 @@ var _Provider = class {
5765
5906
  this.cache = new ResourceCache(DEFAULT_RESOURCE_CACHE_TTL);
5766
5907
  }
5767
5908
  }
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
5909
  static extractBasicAuth(url) {
5795
5910
  let parsedUrl;
5796
5911
  try {
5797
5912
  parsedUrl = new URL(url);
5798
5913
  } catch (error) {
5799
- throw new import_errors20.FuelError(import_errors20.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
5914
+ throw new import_errors19.FuelError(import_errors19.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
5800
5915
  }
5801
5916
  const username = parsedUrl.username;
5802
5917
  const password = parsedUrl.password;
@@ -5814,8 +5929,7 @@ var _Provider = class {
5814
5929
  * Initialize Provider async stuff
5815
5930
  */
5816
5931
  async init() {
5817
- const { nodeInfo } = await this.fetchChainAndNodeInfo();
5818
- this.setupFeatures(nodeInfo.nodeVersion);
5932
+ await this.fetchChainAndNodeInfo();
5819
5933
  return this;
5820
5934
  }
5821
5935
  /**
@@ -5875,39 +5989,52 @@ var _Provider = class {
5875
5989
  * @returns A promise that resolves to the Chain and NodeInfo.
5876
5990
  */
5877
5991
  async fetchChainAndNodeInfo(ignoreCache = false) {
5878
- let nodeInfo;
5879
- let chain;
5880
- try {
5881
- nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
5882
- chain = _Provider.chainInfoCache[this.urlWithoutAuth];
5883
- const noCache = !nodeInfo || !chain;
5884
- if (ignoreCache || noCache) {
5885
- throw new Error(`Jumps to the catch block and re-fetch`);
5886
- }
5887
- } catch (_err) {
5888
- const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
5889
- if (inflightRequest) {
5890
- const now2 = await inflightRequest;
5891
- this.consensusParametersTimestamp = now2;
5892
- return this.fetchChainAndNodeInfo();
5893
- }
5894
- const { promise, resolve } = deferPromise();
5895
- _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
5896
- const data = await this.operations.getChainAndNodeInfo();
5897
- nodeInfo = deserializeNodeInfo(data.nodeInfo);
5898
- chain = deserializeChain(data.chain);
5899
- _Provider.setIncompatibleNodeVersionMessage(nodeInfo);
5900
- _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
5901
- _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
5902
- const now = Date.now();
5903
- this.consensusParametersTimestamp = now;
5904
- resolve(now);
5905
- delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
5992
+ const nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
5993
+ const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
5994
+ const hasCache = nodeInfo && chain;
5995
+ if (hasCache && !ignoreCache) {
5996
+ return { nodeInfo, chain };
5997
+ }
5998
+ const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
5999
+ if (inflightRequest) {
6000
+ return inflightRequest.then((data) => {
6001
+ this.consensusParametersTimestamp = data.consensusParametersTimestamp;
6002
+ return {
6003
+ nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
6004
+ chain: _Provider.chainInfoCache[this.urlWithoutAuth]
6005
+ };
6006
+ });
5906
6007
  }
5907
- return {
5908
- chain,
5909
- nodeInfo
5910
- };
6008
+ const getChainAndNodeInfoFromNetwork = this.operations.getChainAndNodeInfo().then((data) => ({
6009
+ chain: deserializeChain(data.chain),
6010
+ nodeInfo: deserializeNodeInfo(data.nodeInfo),
6011
+ consensusParametersTimestamp: Date.now()
6012
+ })).then((data) => {
6013
+ _Provider.setIncompatibleNodeVersionMessage(data.nodeInfo);
6014
+ _Provider.chainInfoCache[this.urlWithoutAuth] = data.chain;
6015
+ _Provider.nodeInfoCache[this.urlWithoutAuth] = data.nodeInfo;
6016
+ this.consensusParametersTimestamp = data.consensusParametersTimestamp;
6017
+ return data;
6018
+ }).catch((err) => {
6019
+ const error = new import_errors19.FuelError(
6020
+ import_errors19.FuelError.CODES.CONNECTION_REFUSED,
6021
+ "Unable to fetch chain and node info from the network",
6022
+ { url: this.urlWithoutAuth },
6023
+ err
6024
+ );
6025
+ error.cause = { code: "ECONNREFUSED" };
6026
+ throw error;
6027
+ }).finally(() => {
6028
+ delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
6029
+ });
6030
+ _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = getChainAndNodeInfoFromNetwork;
6031
+ return _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth].then((data) => {
6032
+ this.consensusParametersTimestamp = data.consensusParametersTimestamp;
6033
+ return {
6034
+ nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
6035
+ chain: _Provider.chainInfoCache[this.urlWithoutAuth]
6036
+ };
6037
+ });
5911
6038
  }
5912
6039
  /**
5913
6040
  * @hidden
@@ -5932,8 +6059,8 @@ var _Provider = class {
5932
6059
  createOperations() {
5933
6060
  const fetchFn = _Provider.getFetchFn(this.options);
5934
6061
  const gqlClient = new import_graphql_request.GraphQLClient(this.urlWithoutAuth, {
5935
- fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
5936
- responseMiddleware: (response) => {
6062
+ fetch: /* @__PURE__ */ __name((input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options), "fetch"),
6063
+ responseMiddleware: /* @__PURE__ */ __name((response) => {
5937
6064
  if ("response" in response) {
5938
6065
  const graphQlResponse = response.response;
5939
6066
  assertGqlResponseHasNoErrors(
@@ -5941,22 +6068,22 @@ var _Provider = class {
5941
6068
  _Provider.incompatibleNodeVersionMessage
5942
6069
  );
5943
6070
  }
5944
- }
6071
+ }, "responseMiddleware")
5945
6072
  });
5946
- const executeQuery = (query, vars) => {
6073
+ const executeQuery = /* @__PURE__ */ __name((query, vars) => {
5947
6074
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
5948
6075
  const isSubscription = opDefinition?.operation === "subscription";
5949
6076
  if (isSubscription) {
5950
6077
  return FuelGraphqlSubscriber.create({
5951
6078
  url: this.urlWithoutAuth,
5952
6079
  query,
5953
- fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
6080
+ fetchFn: /* @__PURE__ */ __name((url, requestInit) => fetchFn(url, requestInit, this.options), "fetchFn"),
5954
6081
  variables: vars
5955
6082
  });
5956
6083
  }
5957
6084
  return gqlClient.request(query, vars);
5958
- };
5959
- const customOperations = (requester) => ({
6085
+ }, "executeQuery");
6086
+ const customOperations = /* @__PURE__ */ __name((requester) => ({
5960
6087
  getBlobs(variables) {
5961
6088
  const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
5962
6089
  const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
@@ -5974,18 +6101,9 @@ var _Provider = class {
5974
6101
  `;
5975
6102
  return requester(document2, updatedVariables);
5976
6103
  }
5977
- });
6104
+ }), "customOperations");
5978
6105
  return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
5979
6106
  }
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
6107
  /**
5990
6108
  * Returns the version of the connected node.
5991
6109
  *
@@ -6062,6 +6180,13 @@ var _Provider = class {
6062
6180
  * @returns A promise that resolves to an object containing the asset details.
6063
6181
  */
6064
6182
  async getAssetDetails(assetId) {
6183
+ const { assetMetadata } = await this.getNodeFeatures();
6184
+ if (!assetMetadata) {
6185
+ throw new import_errors19.FuelError(
6186
+ import_errors19.ErrorCode.UNSUPPORTED_FEATURE,
6187
+ "The current node does not supports fetching asset details"
6188
+ );
6189
+ }
6065
6190
  const { assetDetails } = await this.operations.getAssetDetails({ assetId });
6066
6191
  const { contractId, subId, totalSupply } = assetDetails;
6067
6192
  return {
@@ -6070,6 +6195,15 @@ var _Provider = class {
6070
6195
  totalSupply: (0, import_math18.bn)(totalSupply)
6071
6196
  };
6072
6197
  }
6198
+ /**
6199
+ * @hidden
6200
+ */
6201
+ #cacheInputs(inputs, transactionId) {
6202
+ if (!this.cache) {
6203
+ return;
6204
+ }
6205
+ this.cache.set(transactionId, inputs);
6206
+ }
6073
6207
  /**
6074
6208
  * @hidden
6075
6209
  */
@@ -6080,14 +6214,14 @@ var _Provider = class {
6080
6214
  }
6081
6215
  } = await this.getChain();
6082
6216
  if ((0, import_math18.bn)(tx.inputs.length).gt(maxInputs)) {
6083
- throw new import_errors20.FuelError(
6084
- import_errors20.ErrorCode.MAX_INPUTS_EXCEEDED,
6217
+ throw new import_errors19.FuelError(
6218
+ import_errors19.ErrorCode.MAX_INPUTS_EXCEEDED,
6085
6219
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
6086
6220
  );
6087
6221
  }
6088
6222
  if ((0, import_math18.bn)(tx.outputs.length).gt(maxOutputs)) {
6089
- throw new import_errors20.FuelError(
6090
- import_errors20.ErrorCode.MAX_OUTPUTS_EXCEEDED,
6223
+ throw new import_errors19.FuelError(
6224
+ import_errors19.ErrorCode.MAX_OUTPUTS_EXCEEDED,
6091
6225
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
6092
6226
  );
6093
6227
  }
@@ -6119,7 +6253,10 @@ var _Provider = class {
6119
6253
  abis = transactionRequest.abis;
6120
6254
  }
6121
6255
  const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
6122
- __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(await this.getChainId()));
6256
+ this.#cacheInputs(
6257
+ transactionRequest.inputs,
6258
+ transactionRequest.getTransactionId(await this.getChainId())
6259
+ );
6123
6260
  const chainId = await this.getChainId();
6124
6261
  return new TransactionResponse(transactionRequest, this, chainId, abis, subscription);
6125
6262
  }
@@ -6765,7 +6902,7 @@ var _Provider = class {
6765
6902
  },
6766
6903
  transactionIds: block.transactions.map((tx) => tx.id),
6767
6904
  transactions: block.transactions.map(
6768
- (tx) => new import_transactions23.TransactionCoder().decode((0, import_utils29.arrayify)(tx.rawPayload), 0)?.[0]
6905
+ (tx) => new import_transactions24.TransactionCoder().decode((0, import_utils29.arrayify)(tx.rawPayload), 0)?.[0]
6769
6906
  )
6770
6907
  };
6771
6908
  }
@@ -6781,12 +6918,12 @@ var _Provider = class {
6781
6918
  return null;
6782
6919
  }
6783
6920
  try {
6784
- return new import_transactions23.TransactionCoder().decode(
6921
+ return new import_transactions24.TransactionCoder().decode(
6785
6922
  (0, import_utils29.arrayify)(transaction.rawPayload),
6786
6923
  0
6787
6924
  )?.[0];
6788
6925
  } catch (error) {
6789
- if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6926
+ if (error instanceof import_errors19.FuelError && error.code === import_errors19.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6790
6927
  console.warn("Unsupported transaction type encountered");
6791
6928
  return null;
6792
6929
  }
@@ -6807,12 +6944,12 @@ var _Provider = class {
6807
6944
  paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
6808
6945
  })
6809
6946
  });
6810
- const coder = new import_transactions23.TransactionCoder();
6947
+ const coder = new import_transactions24.TransactionCoder();
6811
6948
  const transactions = edges.map(({ node: { rawPayload } }) => {
6812
6949
  try {
6813
6950
  return coder.decode((0, import_utils29.arrayify)(rawPayload), 0)[0];
6814
6951
  } catch (error) {
6815
- if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6952
+ if (error instanceof import_errors19.FuelError && error.code === import_errors19.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6816
6953
  console.warn("Unsupported transaction type encountered");
6817
6954
  return null;
6818
6955
  }
@@ -6871,18 +7008,9 @@ var _Provider = class {
6871
7008
  * @returns A promise that resolves to the balance.
6872
7009
  */
6873
7010
  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
7011
  const { balance } = await this.operations.getBalanceV2({
6884
- owner: ownerStr,
6885
- assetId: assetIdStr
7012
+ owner: new import_address3.Address(owner).toB256(),
7013
+ assetId: (0, import_utils29.hexlify)(assetId)
6886
7014
  });
6887
7015
  return (0, import_math18.bn)(balance.amountU128, 10);
6888
7016
  }
@@ -6894,49 +7022,29 @@ var _Provider = class {
6894
7022
  * @returns A promise that resolves to the balances.
6895
7023
  */
6896
7024
  async getBalances(owner, paginationArgs) {
6897
- if (!this.features.balancePagination) {
6898
- return this.getBalancesV1(owner, paginationArgs);
7025
+ let args = { first: NON_PAGINATED_BALANCES_SIZE };
7026
+ const { balancesPagination: supportsPagination } = await this.getNodeFeatures();
7027
+ if (supportsPagination) {
7028
+ args = validatePaginationArgs({
7029
+ inputArgs: paginationArgs,
7030
+ paginationLimit: BALANCES_PAGE_SIZE_LIMIT
7031
+ });
6899
7032
  }
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
7033
  const {
6927
7034
  balances: { edges, pageInfo }
6928
7035
  } = await this.operations.getBalancesV2({
6929
- ...validatePaginationArgs({
6930
- inputArgs: paginationArgs,
6931
- paginationLimit: BALANCES_PAGE_SIZE_LIMIT
6932
- }),
6933
- filter: { owner: new import_address3.Address(owner).toB256() }
7036
+ ...args,
7037
+ filter: { owner: new import_address3.Address(owner).toB256() },
7038
+ supportsPagination
6934
7039
  });
6935
7040
  const balances = edges.map(({ node }) => ({
6936
7041
  assetId: node.assetId,
6937
7042
  amount: (0, import_math18.bn)(node.amountU128)
6938
7043
  }));
6939
- return { balances, pageInfo };
7044
+ return {
7045
+ balances,
7046
+ ...supportsPagination ? { pageInfo } : {}
7047
+ };
6940
7048
  }
6941
7049
  /**
6942
7050
  * Returns message for the given address.
@@ -6956,7 +7064,7 @@ var _Provider = class {
6956
7064
  owner: new import_address3.Address(address).toB256()
6957
7065
  });
6958
7066
  const messages = edges.map(({ node }) => ({
6959
- messageId: import_transactions23.InputMessageCoder.getMessageId({
7067
+ messageId: import_transactions24.InputMessageCoder.getMessageId({
6960
7068
  sender: node.sender,
6961
7069
  recipient: node.recipient,
6962
7070
  nonce: node.nonce,
@@ -6967,7 +7075,7 @@ var _Provider = class {
6967
7075
  recipient: new import_address3.Address(node.recipient),
6968
7076
  nonce: node.nonce,
6969
7077
  amount: (0, import_math18.bn)(node.amount),
6970
- data: import_transactions23.InputMessageCoder.decodeData(node.data),
7078
+ data: import_transactions24.InputMessageCoder.decodeData(node.data),
6971
7079
  daHeight: (0, import_math18.bn)(node.daHeight)
6972
7080
  }));
6973
7081
  return {
@@ -6990,8 +7098,8 @@ var _Provider = class {
6990
7098
  nonce
6991
7099
  };
6992
7100
  if (commitBlockId && commitBlockHeight) {
6993
- throw new import_errors20.FuelError(
6994
- import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
7101
+ throw new import_errors19.FuelError(
7102
+ import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
6995
7103
  "commitBlockId and commitBlockHeight cannot be used together"
6996
7104
  );
6997
7105
  }
@@ -7173,7 +7281,7 @@ var _Provider = class {
7173
7281
  return null;
7174
7282
  }
7175
7283
  const message = {
7176
- messageId: import_transactions23.InputMessageCoder.getMessageId({
7284
+ messageId: import_transactions24.InputMessageCoder.getMessageId({
7177
7285
  sender: rawMessage.sender,
7178
7286
  recipient: rawMessage.recipient,
7179
7287
  nonce,
@@ -7184,7 +7292,7 @@ var _Provider = class {
7184
7292
  recipient: new import_address3.Address(rawMessage.recipient),
7185
7293
  nonce,
7186
7294
  amount: (0, import_math18.bn)(rawMessage.amount),
7187
- data: import_transactions23.InputMessageCoder.decodeData(rawMessage.data),
7295
+ data: import_transactions24.InputMessageCoder.decodeData(rawMessage.data),
7188
7296
  daHeight: (0, import_math18.bn)(rawMessage.daHeight)
7189
7297
  };
7190
7298
  return message;
@@ -7210,19 +7318,32 @@ var _Provider = class {
7210
7318
  extractDryRunError(transactionRequest, receipts, dryRunStatus) {
7211
7319
  const status = dryRunStatus;
7212
7320
  let logs = [];
7321
+ let groupedLogs = {};
7213
7322
  if (transactionRequest.abis) {
7214
- logs = getDecodedLogs(
7323
+ ({ logs, groupedLogs } = getAllDecodedLogs({
7215
7324
  receipts,
7216
- transactionRequest.abis.main,
7217
- transactionRequest.abis.otherContractsAbis
7218
- );
7325
+ mainAbi: transactionRequest.abis.main,
7326
+ externalAbis: transactionRequest.abis.otherContractsAbis
7327
+ }));
7219
7328
  }
7220
7329
  return extractTxError({
7221
7330
  logs,
7331
+ groupedLogs,
7222
7332
  receipts,
7223
7333
  statusReason: status.reason
7224
7334
  });
7225
7335
  }
7336
+ /**
7337
+ * @hidden
7338
+ */
7339
+ async getNodeFeatures() {
7340
+ const { indexation } = await this.getNode();
7341
+ return {
7342
+ assetMetadata: Boolean(indexation?.assetMetadata),
7343
+ balancesPagination: Boolean(indexation?.balances),
7344
+ coinsToSpend: Boolean(indexation?.coinsToSpend)
7345
+ };
7346
+ }
7226
7347
  /**
7227
7348
  * @hidden
7228
7349
  */
@@ -7237,27 +7358,11 @@ var _Provider = class {
7237
7358
  return transactionRequest;
7238
7359
  }
7239
7360
  };
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
7361
 
7257
7362
  // src/providers/transaction-summary/get-transaction-summary.ts
7258
- var import_errors21 = require("@fuel-ts/errors");
7363
+ var import_errors20 = require("@fuel-ts/errors");
7259
7364
  var import_math19 = require("@fuel-ts/math");
7260
- var import_transactions24 = require("@fuel-ts/transactions");
7365
+ var import_transactions25 = require("@fuel-ts/transactions");
7261
7366
  var import_utils31 = require("@fuel-ts/utils");
7262
7367
  async function getTransactionSummary(params) {
7263
7368
  const { id, provider, abiMap } = params;
@@ -7265,12 +7370,12 @@ async function getTransactionSummary(params) {
7265
7370
  transactionId: id
7266
7371
  });
7267
7372
  if (!gqlTransaction) {
7268
- throw new import_errors21.FuelError(
7269
- import_errors21.ErrorCode.TRANSACTION_NOT_FOUND,
7373
+ throw new import_errors20.FuelError(
7374
+ import_errors20.ErrorCode.TRANSACTION_NOT_FOUND,
7270
7375
  `Transaction not found for given id: ${id}.`
7271
7376
  );
7272
7377
  }
7273
- const [decodedTransaction] = new import_transactions24.TransactionCoder().decode(
7378
+ const [decodedTransaction] = new import_transactions25.TransactionCoder().decode(
7274
7379
  (0, import_utils31.arrayify)(gqlTransaction.rawPayload),
7275
7380
  0
7276
7381
  );
@@ -7308,6 +7413,7 @@ async function getTransactionSummary(params) {
7308
7413
  ...transactionInfo
7309
7414
  };
7310
7415
  }
7416
+ __name(getTransactionSummary, "getTransactionSummary");
7311
7417
  async function getTransactionSummaryFromRequest(params) {
7312
7418
  const { provider, transactionRequest, abiMap } = params;
7313
7419
  const { receipts } = await provider.dryRun(transactionRequest);
@@ -7333,6 +7439,7 @@ async function getTransactionSummaryFromRequest(params) {
7333
7439
  });
7334
7440
  return transactionSummary;
7335
7441
  }
7442
+ __name(getTransactionSummaryFromRequest, "getTransactionSummaryFromRequest");
7336
7443
  async function getTransactionsSummaries(params) {
7337
7444
  const { filters, provider, abiMap } = params;
7338
7445
  const { owner, ...inputArgs } = filters;
@@ -7357,7 +7464,7 @@ async function getTransactionsSummaries(params) {
7357
7464
  const transactions = edges.map((edge) => {
7358
7465
  const { node: gqlTransaction } = edge;
7359
7466
  const { id, rawPayload, status } = gqlTransaction;
7360
- const [decodedTransaction] = new import_transactions24.TransactionCoder().decode((0, import_utils31.arrayify)(rawPayload), 0);
7467
+ const [decodedTransaction] = new import_transactions25.TransactionCoder().decode((0, import_utils31.arrayify)(rawPayload), 0);
7361
7468
  let txReceipts = [];
7362
7469
  if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
7363
7470
  txReceipts = gqlTransaction.status.receipts;
@@ -7388,12 +7495,13 @@ async function getTransactionsSummaries(params) {
7388
7495
  pageInfo
7389
7496
  };
7390
7497
  }
7498
+ __name(getTransactionsSummaries, "getTransactionsSummaries");
7391
7499
 
7392
7500
  // src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
7393
7501
  var import_math20 = require("@fuel-ts/math");
7394
- var import_transactions25 = require("@fuel-ts/transactions");
7502
+ var import_transactions26 = require("@fuel-ts/transactions");
7395
7503
  var import_utils32 = require("@fuel-ts/utils");
7396
- var assembleTransactionSummaryFromJson = async (opts) => {
7504
+ var assembleTransactionSummaryFromJson = /* @__PURE__ */ __name(async (opts) => {
7397
7505
  const { provider, transactionSummary } = opts;
7398
7506
  const { id, transactionBytes, gasPrice, receipts } = transactionSummary;
7399
7507
  const {
@@ -7405,7 +7513,7 @@ var assembleTransactionSummaryFromJson = async (opts) => {
7405
7513
  }
7406
7514
  } = await provider.getChain();
7407
7515
  const deserializedTransactionBytes = (0, import_utils32.arrayify)(transactionBytes);
7408
- const [transaction] = new import_transactions25.TransactionCoder().decode(deserializedTransactionBytes, 0);
7516
+ const [transaction] = new import_transactions26.TransactionCoder().decode(deserializedTransactionBytes, 0);
7409
7517
  return assembleTransactionSummary({
7410
7518
  id,
7411
7519
  transaction,
@@ -7420,10 +7528,10 @@ var assembleTransactionSummaryFromJson = async (opts) => {
7420
7528
  gasPerByte,
7421
7529
  gasPriceFactor
7422
7530
  });
7423
- };
7531
+ }, "assembleTransactionSummaryFromJson");
7424
7532
 
7425
7533
  // src/providers/utils/merge-quantities.ts
7426
- var mergeQuantities = (...coinQuantities) => {
7534
+ var mergeQuantities = /* @__PURE__ */ __name((...coinQuantities) => {
7427
7535
  const resultMap = {};
7428
7536
  function addToMap({ amount, assetId }) {
7429
7537
  if (resultMap[assetId]) {
@@ -7432,34 +7540,38 @@ var mergeQuantities = (...coinQuantities) => {
7432
7540
  resultMap[assetId] = amount;
7433
7541
  }
7434
7542
  }
7543
+ __name(addToMap, "addToMap");
7435
7544
  coinQuantities.forEach((arr) => arr.forEach(addToMap));
7436
7545
  return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
7437
- };
7546
+ }, "mergeQuantities");
7438
7547
 
7439
7548
  // src/types.ts
7440
7549
  var AbstractAccount = class {
7550
+ static {
7551
+ __name(this, "AbstractAccount");
7552
+ }
7441
7553
  };
7442
7554
 
7443
7555
  // src/utils/formatTransferToContractScriptData.ts
7444
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
7556
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
7445
7557
  var import_address4 = require("@fuel-ts/address");
7446
7558
  var import_utils33 = require("@fuel-ts/utils");
7447
7559
  var asm = __toESM(require("@fuels/vm-asm"));
7448
- var formatTransferToContractScriptData = (transferParams) => {
7449
- const numberCoder = new import_abi_coder5.BigNumberCoder("u64");
7560
+ var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
7561
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
7450
7562
  return transferParams.reduce((acc, transferParam) => {
7451
7563
  const { assetId, amount, contractId } = transferParam;
7452
7564
  const encoded = numberCoder.encode(amount);
7453
7565
  const scriptData = (0, import_utils33.concat)([new import_address4.Address(contractId).toBytes(), encoded, (0, import_utils33.arrayify)(assetId)]);
7454
7566
  return (0, import_utils33.concat)([acc, scriptData]);
7455
7567
  }, new Uint8Array());
7456
- };
7457
- var assembleTransferToContractScript = async (transferParams) => {
7568
+ }, "formatTransferToContractScriptData");
7569
+ var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferParams) => {
7458
7570
  const scriptData = formatTransferToContractScriptData(transferParams);
7459
7571
  await asm.initWasm();
7460
7572
  let script = new Uint8Array();
7461
7573
  transferParams.forEach((_, i) => {
7462
- const offset = (import_abi_coder5.CONTRACT_ID_LEN + import_abi_coder5.WORD_SIZE + import_abi_coder5.ASSET_ID_LEN) * i;
7574
+ const offset = (import_abi_coder6.CONTRACT_ID_LEN + import_abi_coder6.WORD_SIZE + import_abi_coder6.ASSET_ID_LEN) * i;
7463
7575
  script = (0, import_utils33.concat)([
7464
7576
  script,
7465
7577
  // Load ScriptData into register 0x10.
@@ -7467,22 +7579,25 @@ var assembleTransferToContractScript = async (transferParams) => {
7467
7579
  // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
7468
7580
  asm.addi(17, 16, offset).to_bytes(),
7469
7581
  // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
7470
- asm.addi(18, 17, import_abi_coder5.CONTRACT_ID_LEN).to_bytes(),
7582
+ asm.addi(18, 17, import_abi_coder6.CONTRACT_ID_LEN).to_bytes(),
7471
7583
  // Load word to the amount at 0x12 into register 0x13.
7472
7584
  asm.lw(19, 18, 0).to_bytes(),
7473
7585
  // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
7474
- asm.addi(20, 18, import_abi_coder5.WORD_SIZE).to_bytes(),
7586
+ asm.addi(20, 18, import_abi_coder6.WORD_SIZE).to_bytes(),
7475
7587
  // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
7476
7588
  asm.tr(17, 19, 20).to_bytes()
7477
7589
  ]);
7478
7590
  });
7479
7591
  script = (0, import_utils33.concat)([script, asm.ret(1).to_bytes()]);
7480
7592
  return { script, scriptData };
7481
- };
7593
+ }, "assembleTransferToContractScript");
7482
7594
 
7483
7595
  // src/account.ts
7484
7596
  var MAX_FUNDING_ATTEMPTS = 5;
7485
7597
  var Account = class extends AbstractAccount {
7598
+ static {
7599
+ __name(this, "Account");
7600
+ }
7486
7601
  /**
7487
7602
  * The address associated with the account.
7488
7603
  */
@@ -7517,7 +7632,7 @@ var Account = class extends AbstractAccount {
7517
7632
  */
7518
7633
  get provider() {
7519
7634
  if (!this._provider) {
7520
- throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_PROVIDER, "Provider not set");
7635
+ throw new import_errors21.FuelError(import_errors21.ErrorCode.MISSING_PROVIDER, "Provider not set");
7521
7636
  }
7522
7637
  return this._provider;
7523
7638
  }
@@ -7676,8 +7791,8 @@ var Account = class extends AbstractAccount {
7676
7791
  fundingAttempts += 1;
7677
7792
  }
7678
7793
  if (needsToBeFunded) {
7679
- throw new import_errors22.FuelError(
7680
- import_errors22.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
7794
+ throw new import_errors21.FuelError(
7795
+ import_errors21.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
7681
7796
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
7682
7797
  );
7683
7798
  }
@@ -7796,8 +7911,8 @@ var Account = class extends AbstractAccount {
7796
7911
  const contractAddress = new import_address5.Address(transferParam.contractId);
7797
7912
  const assetId = transferParam.assetId ? (0, import_utils34.hexlify)(transferParam.assetId) : defaultAssetId;
7798
7913
  if (amount.lte(0)) {
7799
- throw new import_errors22.FuelError(
7800
- import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
7914
+ throw new import_errors21.FuelError(
7915
+ import_errors21.ErrorCode.INVALID_TRANSFER_AMOUNT,
7801
7916
  "Transfer amount must be a positive number."
7802
7917
  );
7803
7918
  }
@@ -7866,16 +7981,16 @@ var Account = class extends AbstractAccount {
7866
7981
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
7867
7982
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
7868
7983
  const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
7869
- const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
7870
- if (input.type === import_transactions26.InputType.Coin) {
7984
+ const findAssetInput = /* @__PURE__ */ __name((assetId) => txRequestClone.inputs.find((input) => {
7985
+ if (input.type === import_transactions27.InputType.Coin) {
7871
7986
  return input.assetId === assetId;
7872
7987
  }
7873
7988
  if (isRequestInputMessageWithoutData(input)) {
7874
7989
  return baseAssetId === assetId;
7875
7990
  }
7876
7991
  return false;
7877
- });
7878
- const updateAssetInput = (assetId, quantity) => {
7992
+ }), "findAssetInput");
7993
+ const updateAssetInput = /* @__PURE__ */ __name((assetId, quantity) => {
7879
7994
  const assetInput = findAssetInput(assetId);
7880
7995
  const usedQuantity = quantity;
7881
7996
  if (assetInput && "amount" in assetInput) {
@@ -7890,7 +8005,7 @@ var Account = class extends AbstractAccount {
7890
8005
  ])
7891
8006
  );
7892
8007
  }
7893
- };
8008
+ }, "updateAssetInput");
7894
8009
  mergeQuantities(requiredQuantities, transactionFeeForDryRun).forEach(
7895
8010
  ({ amount, assetId }) => updateAssetInput(assetId, amount)
7896
8011
  );
@@ -7913,7 +8028,7 @@ var Account = class extends AbstractAccount {
7913
8028
  */
7914
8029
  async signMessage(message) {
7915
8030
  if (!this._connector) {
7916
- throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
8031
+ throw new import_errors21.FuelError(import_errors21.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
7917
8032
  }
7918
8033
  return this._connector.signMessage(this.address.toString(), message);
7919
8034
  }
@@ -7925,8 +8040,8 @@ var Account = class extends AbstractAccount {
7925
8040
  */
7926
8041
  async signTransaction(transactionRequestLike) {
7927
8042
  if (!this._connector) {
7928
- throw new import_errors22.FuelError(
7929
- import_errors22.ErrorCode.MISSING_CONNECTOR,
8043
+ throw new import_errors21.FuelError(
8044
+ import_errors21.ErrorCode.MISSING_CONNECTOR,
7930
8045
  "A connector is required to sign transactions."
7931
8046
  );
7932
8047
  }
@@ -7990,7 +8105,7 @@ var Account = class extends AbstractAccount {
7990
8105
  */
7991
8106
  generateFakeResources(coins) {
7992
8107
  return coins.map((coin) => ({
7993
- id: (0, import_utils34.hexlify)((0, import_crypto2.randomBytes)(import_abi_coder6.UTXO_ID_LEN)),
8108
+ id: (0, import_utils34.hexlify)((0, import_crypto2.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
7994
8109
  owner: this.address,
7995
8110
  blockCreated: (0, import_math21.bn)(1),
7996
8111
  txCreatedIdx: (0, import_math21.bn)(1),
@@ -8022,8 +8137,8 @@ var Account = class extends AbstractAccount {
8022
8137
  /** @hidden * */
8023
8138
  validateTransferAmount(amount) {
8024
8139
  if ((0, import_math21.bn)(amount).lte(0)) {
8025
- throw new import_errors22.FuelError(
8026
- import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
8140
+ throw new import_errors21.FuelError(
8141
+ import_errors21.ErrorCode.INVALID_TRANSFER_AMOUNT,
8027
8142
  "Transfer amount must be a positive number."
8028
8143
  );
8029
8144
  }
@@ -8052,16 +8167,16 @@ var Account = class extends AbstractAccount {
8052
8167
  if (!(0, import_utils34.isDefined)(setGasLimit)) {
8053
8168
  request2.gasLimit = gasUsed;
8054
8169
  } else if (gasUsed.gt(setGasLimit)) {
8055
- throw new import_errors22.FuelError(
8056
- import_errors22.ErrorCode.GAS_LIMIT_TOO_LOW,
8170
+ throw new import_errors21.FuelError(
8171
+ import_errors21.ErrorCode.GAS_LIMIT_TOO_LOW,
8057
8172
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
8058
8173
  );
8059
8174
  }
8060
8175
  if (!(0, import_utils34.isDefined)(setMaxFee)) {
8061
8176
  request2.maxFee = maxFee;
8062
8177
  } else if (maxFee.gt(setMaxFee)) {
8063
- throw new import_errors22.FuelError(
8064
- import_errors22.ErrorCode.MAX_FEE_TOO_LOW,
8178
+ throw new import_errors21.FuelError(
8179
+ import_errors21.ErrorCode.MAX_FEE_TOO_LOW,
8065
8180
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
8066
8181
  );
8067
8182
  }
@@ -8080,7 +8195,10 @@ var import_hasher3 = require("@fuel-ts/hasher");
8080
8195
  var import_math22 = require("@fuel-ts/math");
8081
8196
  var import_utils35 = require("@fuel-ts/utils");
8082
8197
  var import_secp256k1 = require("@noble/curves/secp256k1");
8083
- var Signer = class {
8198
+ var Signer = class _Signer {
8199
+ static {
8200
+ __name(this, "Signer");
8201
+ }
8084
8202
  address;
8085
8203
  publicKey;
8086
8204
  compressedPublicKey;
@@ -8159,7 +8277,7 @@ var Signer = class {
8159
8277
  * @returns Address from signature
8160
8278
  */
8161
8279
  static recoverAddress(data, signature) {
8162
- return new import_address6.Address(Signer.recoverPublicKey(data, signature));
8280
+ return new import_address6.Address(_Signer.recoverPublicKey(data, signature));
8163
8281
  }
8164
8282
  /**
8165
8283
  * Generate a random privateKey
@@ -8185,19 +8303,19 @@ var Signer = class {
8185
8303
  // src/wallet/keystore-wallet.ts
8186
8304
  var import_address7 = require("@fuel-ts/address");
8187
8305
  var import_crypto4 = require("@fuel-ts/crypto");
8188
- var import_errors23 = require("@fuel-ts/errors");
8306
+ var import_errors22 = require("@fuel-ts/errors");
8189
8307
  var import_utils36 = require("@fuel-ts/utils");
8190
8308
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
8191
8309
  var DEFAULT_KDF_PARAMS_R = 8;
8192
8310
  var DEFAULT_KDF_PARAMS_P = 1;
8193
8311
  var DEFAULT_KEY_SIZE = 32;
8194
8312
  var DEFAULT_IV_SIZE = 16;
8195
- var removeHexPrefix = (hexString) => {
8313
+ var removeHexPrefix = /* @__PURE__ */ __name((hexString) => {
8196
8314
  if (/^0x/.test(hexString)) {
8197
8315
  return hexString.slice(2);
8198
8316
  }
8199
8317
  return hexString;
8200
- };
8318
+ }, "removeHexPrefix");
8201
8319
  async function encryptKeystoreWallet(privateKey, address, password) {
8202
8320
  const privateKeyBuffer = (0, import_crypto4.bufferFromString)(removeHexPrefix(privateKey), "hex");
8203
8321
  const ownerAddress = new import_address7.Address(address);
@@ -8236,6 +8354,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
8236
8354
  };
8237
8355
  return JSON.stringify(keystore);
8238
8356
  }
8357
+ __name(encryptKeystoreWallet, "encryptKeystoreWallet");
8239
8358
  async function decryptKeystoreWallet(jsonWallet, password) {
8240
8359
  const keystoreWallet = JSON.parse(jsonWallet);
8241
8360
  const {
@@ -8262,8 +8381,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
8262
8381
  const macHashUint8Array = (0, import_crypto4.keccak256)(data);
8263
8382
  const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
8264
8383
  if (mac !== macHash) {
8265
- throw new import_errors23.FuelError(
8266
- import_errors23.ErrorCode.INVALID_PASSWORD,
8384
+ throw new import_errors22.FuelError(
8385
+ import_errors22.ErrorCode.INVALID_PASSWORD,
8267
8386
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
8268
8387
  );
8269
8388
  }
@@ -8271,9 +8390,17 @@ async function decryptKeystoreWallet(jsonWallet, password) {
8271
8390
  const privateKey = (0, import_utils36.hexlify)(buffer);
8272
8391
  return privateKey;
8273
8392
  }
8393
+ __name(decryptKeystoreWallet, "decryptKeystoreWallet");
8274
8394
 
8275
8395
  // src/wallet/base-wallet-unlocked.ts
8276
8396
  var BaseWalletUnlocked = class extends Account {
8397
+ static {
8398
+ __name(this, "BaseWalletUnlocked");
8399
+ }
8400
+ /**
8401
+ * Default HDWallet path.
8402
+ */
8403
+ static defaultPath = "m/44'/1179993420'/0'/0/0";
8277
8404
  /**
8278
8405
  * A function that returns the wallet's signer.
8279
8406
  */
@@ -8391,21 +8518,17 @@ var BaseWalletUnlocked = class extends Account {
8391
8518
  return encryptKeystoreWallet(this.privateKey, this.address, password);
8392
8519
  }
8393
8520
  };
8394
- /**
8395
- * Default HDWallet path.
8396
- */
8397
- __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
8398
8521
 
8399
8522
  // src/hdwallet/hdwallet.ts
8400
8523
  var import_crypto6 = require("@fuel-ts/crypto");
8401
- var import_errors26 = require("@fuel-ts/errors");
8524
+ var import_errors25 = require("@fuel-ts/errors");
8402
8525
  var import_hasher7 = require("@fuel-ts/hasher");
8403
8526
  var import_math23 = require("@fuel-ts/math");
8404
8527
  var import_utils41 = require("@fuel-ts/utils");
8405
8528
 
8406
8529
  // src/mnemonic/mnemonic.ts
8407
8530
  var import_crypto5 = require("@fuel-ts/crypto");
8408
- var import_errors25 = require("@fuel-ts/errors");
8531
+ var import_errors24 = require("@fuel-ts/errors");
8409
8532
  var import_hasher6 = require("@fuel-ts/hasher");
8410
8533
  var import_utils39 = require("@fuel-ts/utils");
8411
8534
 
@@ -10468,27 +10591,31 @@ var Language = /* @__PURE__ */ ((Language2) => {
10468
10591
  })(Language || {});
10469
10592
 
10470
10593
  // src/mnemonic/utils.ts
10471
- var import_errors24 = require("@fuel-ts/errors");
10594
+ var import_errors23 = require("@fuel-ts/errors");
10472
10595
  var import_hasher5 = require("@fuel-ts/hasher");
10473
10596
  var import_utils38 = require("@fuel-ts/utils");
10474
10597
  function getLowerMask(bits) {
10475
10598
  return (1 << bits) - 1;
10476
10599
  }
10600
+ __name(getLowerMask, "getLowerMask");
10477
10601
  function getUpperMask(bits) {
10478
10602
  return (1 << bits) - 1 << 8 - bits;
10479
10603
  }
10604
+ __name(getUpperMask, "getUpperMask");
10480
10605
  function getWords(mnemonic) {
10481
10606
  if (!Array.isArray(mnemonic)) {
10482
10607
  return mnemonic.split(/\s+/);
10483
10608
  }
10484
10609
  return mnemonic;
10485
10610
  }
10611
+ __name(getWords, "getWords");
10486
10612
  function getPhrase(mnemonic) {
10487
10613
  if (Array.isArray(mnemonic)) {
10488
10614
  return mnemonic.join(" ");
10489
10615
  }
10490
10616
  return mnemonic;
10491
10617
  }
10618
+ __name(getPhrase, "getPhrase");
10492
10619
  function entropyToMnemonicIndices(entropy) {
10493
10620
  const indices = [0];
10494
10621
  let remainingBits = 11;
@@ -10510,6 +10637,7 @@ function entropyToMnemonicIndices(entropy) {
10510
10637
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
10511
10638
  return indices;
10512
10639
  }
10640
+ __name(entropyToMnemonicIndices, "entropyToMnemonicIndices");
10513
10641
  function mnemonicWordsToEntropy(words, wordlist) {
10514
10642
  const size = Math.ceil(11 * words.length / 8);
10515
10643
  const entropy = (0, import_utils38.arrayify)(new Uint8Array(size));
@@ -10517,8 +10645,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
10517
10645
  for (let i = 0; i < words.length; i += 1) {
10518
10646
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
10519
10647
  if (index === -1) {
10520
- throw new import_errors24.FuelError(
10521
- import_errors24.ErrorCode.INVALID_MNEMONIC,
10648
+ throw new import_errors23.FuelError(
10649
+ import_errors23.ErrorCode.INVALID_MNEMONIC,
10522
10650
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
10523
10651
  );
10524
10652
  }
@@ -10534,13 +10662,14 @@ function mnemonicWordsToEntropy(words, wordlist) {
10534
10662
  const checksumMask = getUpperMask(checksumBits);
10535
10663
  const checksum = (0, import_utils38.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
10536
10664
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
10537
- throw new import_errors24.FuelError(
10538
- import_errors24.ErrorCode.INVALID_CHECKSUM,
10665
+ throw new import_errors23.FuelError(
10666
+ import_errors23.ErrorCode.INVALID_CHECKSUM,
10539
10667
  "Checksum validation failed for the provided mnemonic."
10540
10668
  );
10541
10669
  }
10542
10670
  return entropy.slice(0, entropyBits / 8);
10543
10671
  }
10672
+ __name(mnemonicWordsToEntropy, "mnemonicWordsToEntropy");
10544
10673
 
10545
10674
  // src/mnemonic/mnemonic.ts
10546
10675
  var MasterSecret = (0, import_utils39.toUtf8Bytes)("Bitcoin seed");
@@ -10549,29 +10678,35 @@ var TestnetPRV = "0x04358394";
10549
10678
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
10550
10679
  function assertWordList(wordlist) {
10551
10680
  if (wordlist.length !== 2048) {
10552
- throw new import_errors25.FuelError(
10553
- import_errors25.ErrorCode.INVALID_WORD_LIST,
10681
+ throw new import_errors24.FuelError(
10682
+ import_errors24.ErrorCode.INVALID_WORD_LIST,
10554
10683
  `Expected word list length of 2048, but got ${wordlist.length}.`
10555
10684
  );
10556
10685
  }
10557
10686
  }
10687
+ __name(assertWordList, "assertWordList");
10558
10688
  function assertEntropy(entropy) {
10559
10689
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
10560
- throw new import_errors25.FuelError(
10561
- import_errors25.ErrorCode.INVALID_ENTROPY,
10690
+ throw new import_errors24.FuelError(
10691
+ import_errors24.ErrorCode.INVALID_ENTROPY,
10562
10692
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
10563
10693
  );
10564
10694
  }
10565
10695
  }
10696
+ __name(assertEntropy, "assertEntropy");
10566
10697
  function assertMnemonic(words) {
10567
10698
  if (!MNEMONIC_SIZES.includes(words.length)) {
10568
10699
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
10569
10700
  ", "
10570
10701
  )}] words, but got ${words.length}.`;
10571
- throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_MNEMONIC, errorMsg);
10702
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.INVALID_MNEMONIC, errorMsg);
10572
10703
  }
10573
10704
  }
10574
- var Mnemonic = class {
10705
+ __name(assertMnemonic, "assertMnemonic");
10706
+ var Mnemonic = class _Mnemonic {
10707
+ static {
10708
+ __name(this, "Mnemonic");
10709
+ }
10575
10710
  wordlist;
10576
10711
  /**
10577
10712
  *
@@ -10588,7 +10723,7 @@ var Mnemonic = class {
10588
10723
  * @returns Entropy hash
10589
10724
  */
10590
10725
  mnemonicToEntropy(phrase) {
10591
- return Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
10726
+ return _Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
10592
10727
  }
10593
10728
  /**
10594
10729
  *
@@ -10596,7 +10731,7 @@ var Mnemonic = class {
10596
10731
  * @returns Mnemonic phrase
10597
10732
  */
10598
10733
  entropyToMnemonic(entropy) {
10599
- return Mnemonic.entropyToMnemonic(entropy, this.wordlist);
10734
+ return _Mnemonic.entropyToMnemonic(entropy, this.wordlist);
10600
10735
  }
10601
10736
  /**
10602
10737
  *
@@ -10637,8 +10772,8 @@ var Mnemonic = class {
10637
10772
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
10638
10773
  */
10639
10774
  static mnemonicToMasterKeys(phrase, passphrase = "") {
10640
- const seed = Mnemonic.mnemonicToSeed(phrase, passphrase);
10641
- return Mnemonic.masterKeysFromSeed(seed);
10775
+ const seed = _Mnemonic.mnemonicToSeed(phrase, passphrase);
10776
+ return _Mnemonic.masterKeysFromSeed(seed);
10642
10777
  }
10643
10778
  /**
10644
10779
  * Validates if given mnemonic is valid
@@ -10654,7 +10789,7 @@ var Mnemonic = class {
10654
10789
  return false;
10655
10790
  }
10656
10791
  while (i < words.length) {
10657
- if (Mnemonic.binarySearch(words[i]) === false) {
10792
+ if (_Mnemonic.binarySearch(words[i]) === false) {
10658
10793
  return false;
10659
10794
  }
10660
10795
  i += 1;
@@ -10686,8 +10821,8 @@ var Mnemonic = class {
10686
10821
  static masterKeysFromSeed(seed) {
10687
10822
  const seedArray = (0, import_utils39.arrayify)(seed);
10688
10823
  if (seedArray.length < 16 || seedArray.length > 64) {
10689
- throw new import_errors25.FuelError(
10690
- import_errors25.ErrorCode.INVALID_SEED,
10824
+ throw new import_errors24.FuelError(
10825
+ import_errors24.ErrorCode.INVALID_SEED,
10691
10826
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
10692
10827
  );
10693
10828
  }
@@ -10701,7 +10836,7 @@ var Mnemonic = class {
10701
10836
  * @returns BIP-32 extended private key
10702
10837
  */
10703
10838
  static seedToExtendedKey(seed, testnet = false) {
10704
- const masterKey = Mnemonic.masterKeysFromSeed(seed);
10839
+ const masterKey = _Mnemonic.masterKeysFromSeed(seed);
10705
10840
  const prefix = (0, import_utils39.arrayify)(testnet ? TestnetPRV : MainnetPRV);
10706
10841
  const depth = "0x00";
10707
10842
  const fingerprint = "0x00000000";
@@ -10733,7 +10868,7 @@ var Mnemonic = class {
10733
10868
  */
10734
10869
  static generate(size = 32, extraEntropy = "") {
10735
10870
  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 Mnemonic.entropyToMnemonic(entropy);
10871
+ return _Mnemonic.entropyToMnemonic(entropy);
10737
10872
  }
10738
10873
  };
10739
10874
  var mnemonic_default = Mnemonic;
@@ -10747,24 +10882,28 @@ var TestnetPUB = (0, import_utils41.hexlify)("0x043587cf");
10747
10882
  function base58check(data) {
10748
10883
  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
10884
  }
10885
+ __name(base58check, "base58check");
10750
10886
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
10751
10887
  if (isPublic) {
10752
10888
  return testnet ? TestnetPUB : MainnetPUB;
10753
10889
  }
10754
10890
  return testnet ? TestnetPRV2 : MainnetPRV2;
10755
10891
  }
10892
+ __name(getExtendedKeyPrefix, "getExtendedKeyPrefix");
10756
10893
  function isPublicExtendedKey(extendedKey) {
10757
10894
  return [MainnetPUB, TestnetPUB].includes((0, import_utils41.hexlify)(extendedKey.slice(0, 4)));
10758
10895
  }
10896
+ __name(isPublicExtendedKey, "isPublicExtendedKey");
10759
10897
  function isValidExtendedKey(extendedKey) {
10760
10898
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
10761
10899
  (0, import_utils41.hexlify)(extendedKey.slice(0, 4))
10762
10900
  );
10763
10901
  }
10902
+ __name(isValidExtendedKey, "isValidExtendedKey");
10764
10903
  function parsePath(path, depth = 0) {
10765
10904
  const components = path.split("/");
10766
10905
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
10767
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
10906
+ throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
10768
10907
  }
10769
10908
  if (components[0] === "m") {
10770
10909
  components.shift();
@@ -10773,7 +10912,11 @@ function parsePath(path, depth = 0) {
10773
10912
  (p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
10774
10913
  );
10775
10914
  }
10776
- var HDWallet = class {
10915
+ __name(parsePath, "parsePath");
10916
+ var HDWallet = class _HDWallet {
10917
+ static {
10918
+ __name(this, "HDWallet");
10919
+ }
10777
10920
  depth = 0;
10778
10921
  index = 0;
10779
10922
  fingerprint = (0, import_utils41.hexlify)("0x00000000");
@@ -10793,8 +10936,8 @@ var HDWallet = class {
10793
10936
  this.privateKey = (0, import_utils41.hexlify)(config.privateKey);
10794
10937
  } else {
10795
10938
  if (!config.publicKey) {
10796
- throw new import_errors26.FuelError(
10797
- import_errors26.ErrorCode.HD_WALLET_ERROR,
10939
+ throw new import_errors25.FuelError(
10940
+ import_errors25.ErrorCode.HD_WALLET_ERROR,
10798
10941
  "Both public and private Key cannot be missing. At least one should be provided."
10799
10942
  );
10800
10943
  }
@@ -10823,8 +10966,8 @@ var HDWallet = class {
10823
10966
  const data = new Uint8Array(37);
10824
10967
  if (index & HARDENED_INDEX) {
10825
10968
  if (!privateKey) {
10826
- throw new import_errors26.FuelError(
10827
- import_errors26.ErrorCode.HD_WALLET_ERROR,
10969
+ throw new import_errors25.FuelError(
10970
+ import_errors25.ErrorCode.HD_WALLET_ERROR,
10828
10971
  "Cannot derive a hardened index without a private Key."
10829
10972
  );
10830
10973
  }
@@ -10839,7 +10982,7 @@ var HDWallet = class {
10839
10982
  if (privateKey) {
10840
10983
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
10841
10984
  const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
10842
- return new HDWallet({
10985
+ return new _HDWallet({
10843
10986
  privateKey: ki,
10844
10987
  chainCode: IR,
10845
10988
  index,
@@ -10849,7 +10992,7 @@ var HDWallet = class {
10849
10992
  }
10850
10993
  const signer = new Signer((0, import_utils41.hexlify)(IL));
10851
10994
  const Ki = signer.addPoint(publicKey);
10852
- return new HDWallet({
10995
+ return new _HDWallet({
10853
10996
  publicKey: Ki,
10854
10997
  chainCode: IR,
10855
10998
  index,
@@ -10876,8 +11019,8 @@ var HDWallet = class {
10876
11019
  */
10877
11020
  toExtendedKey(isPublic = false, testnet = false) {
10878
11021
  if (this.depth >= 256) {
10879
- throw new import_errors26.FuelError(
10880
- import_errors26.ErrorCode.HD_WALLET_ERROR,
11022
+ throw new import_errors25.FuelError(
11023
+ import_errors25.ErrorCode.HD_WALLET_ERROR,
10881
11024
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
10882
11025
  );
10883
11026
  }
@@ -10898,7 +11041,7 @@ var HDWallet = class {
10898
11041
  */
10899
11042
  static fromSeed(seed) {
10900
11043
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
10901
- return new HDWallet({
11044
+ return new _HDWallet({
10902
11045
  chainCode: (0, import_utils41.arrayify)(masterKey.slice(32)),
10903
11046
  privateKey: (0, import_utils41.arrayify)(masterKey.slice(0, 32))
10904
11047
  });
@@ -10908,10 +11051,10 @@ var HDWallet = class {
10908
11051
  const bytes = (0, import_utils41.arrayify)(decoded);
10909
11052
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10910
11053
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10911
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
11054
+ throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10912
11055
  }
10913
11056
  if (!validChecksum) {
10914
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
11057
+ throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10915
11058
  }
10916
11059
  const depth = bytes[4];
10917
11060
  const parentFingerprint = (0, import_utils41.hexlify)(bytes.slice(5, 9));
@@ -10919,16 +11062,16 @@ var HDWallet = class {
10919
11062
  const chainCode = (0, import_utils41.hexlify)(bytes.slice(13, 45));
10920
11063
  const key = bytes.slice(45, 78);
10921
11064
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10922
- throw new import_errors26.FuelError(
10923
- import_errors26.ErrorCode.HD_WALLET_ERROR,
11065
+ throw new import_errors25.FuelError(
11066
+ import_errors25.ErrorCode.HD_WALLET_ERROR,
10924
11067
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
10925
11068
  );
10926
11069
  }
10927
11070
  if (isPublicExtendedKey(bytes)) {
10928
11071
  if (key[0] !== 3) {
10929
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
11072
+ throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
10930
11073
  }
10931
- return new HDWallet({
11074
+ return new _HDWallet({
10932
11075
  publicKey: key,
10933
11076
  chainCode,
10934
11077
  index,
@@ -10937,9 +11080,9 @@ var HDWallet = class {
10937
11080
  });
10938
11081
  }
10939
11082
  if (key[0] !== 0) {
10940
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
11083
+ throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
10941
11084
  }
10942
- return new HDWallet({
11085
+ return new _HDWallet({
10943
11086
  privateKey: key.slice(1),
10944
11087
  chainCode,
10945
11088
  index,
@@ -10952,6 +11095,9 @@ var hdwallet_default = HDWallet;
10952
11095
 
10953
11096
  // src/wallet/wallets.ts
10954
11097
  var WalletLocked = class extends Account {
11098
+ static {
11099
+ __name(this, "WalletLocked");
11100
+ }
10955
11101
  /**
10956
11102
  * Unlocks the wallet using the provided private key and returns an instance of WalletUnlocked.
10957
11103
  *
@@ -10962,7 +11108,10 @@ var WalletLocked = class extends Account {
10962
11108
  return new WalletUnlocked(privateKey, this._provider);
10963
11109
  }
10964
11110
  };
10965
- var WalletUnlocked = class extends BaseWalletUnlocked {
11111
+ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
11112
+ static {
11113
+ __name(this, "WalletUnlocked");
11114
+ }
10966
11115
  /**
10967
11116
  * Locks the wallet and returns an instance of WalletLocked.
10968
11117
  *
@@ -10980,7 +11129,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
10980
11129
  */
10981
11130
  static generate(generateOptions) {
10982
11131
  const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
10983
- return new WalletUnlocked(privateKey, generateOptions?.provider);
11132
+ return new _WalletUnlocked(privateKey, generateOptions?.provider);
10984
11133
  }
10985
11134
  /**
10986
11135
  * Create a Wallet Unlocked from a seed.
@@ -10992,8 +11141,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
10992
11141
  */
10993
11142
  static fromSeed(seed, path, provider) {
10994
11143
  const hdWallet = hdwallet_default.fromSeed(seed);
10995
- const childWallet = hdWallet.derivePath(path || WalletUnlocked.defaultPath);
10996
- return new WalletUnlocked(childWallet.privateKey, provider);
11144
+ const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
11145
+ return new _WalletUnlocked(childWallet.privateKey, provider);
10997
11146
  }
10998
11147
  /**
10999
11148
  * Create a Wallet Unlocked from a mnemonic phrase.
@@ -11007,8 +11156,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
11007
11156
  static fromMnemonic(mnemonic, path, passphrase, provider) {
11008
11157
  const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
11009
11158
  const hdWallet = hdwallet_default.fromSeed(seed);
11010
- const childWallet = hdWallet.derivePath(path || WalletUnlocked.defaultPath);
11011
- return new WalletUnlocked(childWallet.privateKey, provider);
11159
+ const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
11160
+ return new _WalletUnlocked(childWallet.privateKey, provider);
11012
11161
  }
11013
11162
  /**
11014
11163
  * Create a Wallet Unlocked from an extended key.
@@ -11019,7 +11168,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
11019
11168
  */
11020
11169
  static fromExtendedKey(extendedKey, provider) {
11021
11170
  const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
11022
- return new WalletUnlocked(hdWallet.privateKey, provider);
11171
+ return new _WalletUnlocked(hdWallet.privateKey, provider);
11023
11172
  }
11024
11173
  /**
11025
11174
  * Create a Wallet Unlocked from an encrypted JSON.
@@ -11031,12 +11180,15 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
11031
11180
  */
11032
11181
  static async fromEncryptedJson(jsonWallet, password, provider) {
11033
11182
  const privateKey = await decryptKeystoreWallet(jsonWallet, password);
11034
- return new WalletUnlocked(privateKey, provider);
11183
+ return new _WalletUnlocked(privateKey, provider);
11035
11184
  }
11036
11185
  };
11037
11186
 
11038
11187
  // src/wallet/wallet.ts
11039
11188
  var Wallet = class {
11189
+ static {
11190
+ __name(this, "Wallet");
11191
+ }
11040
11192
  /**
11041
11193
  * Creates a locked wallet instance from an address and a provider.
11042
11194
  *
@@ -11057,59 +11209,62 @@ var Wallet = class {
11057
11209
  static fromPrivateKey(privateKey, provider) {
11058
11210
  return new WalletUnlocked(privateKey, provider);
11059
11211
  }
11212
+ /**
11213
+ * Generate a new Wallet Unlocked with a random key pair.
11214
+ *
11215
+ * @param generateOptions - Options to customize the generation process (optional).
11216
+ * @returns An unlocked wallet instance.
11217
+ */
11218
+ static generate = WalletUnlocked.generate;
11219
+ /**
11220
+ * Create a Wallet Unlocked from a seed.
11221
+ *
11222
+ * @param seed - The seed phrase.
11223
+ * @param provider - A Provider instance (optional).
11224
+ * @param path - The derivation path (optional).
11225
+ * @returns An unlocked wallet instance.
11226
+ */
11227
+ static fromSeed = WalletUnlocked.fromSeed;
11228
+ /**
11229
+ * Create a Wallet Unlocked from a mnemonic phrase.
11230
+ *
11231
+ * @param mnemonic - The mnemonic phrase.
11232
+ * @param provider - A Provider instance (optional).
11233
+ * @param path - The derivation path (optional).
11234
+ * @param passphrase - The passphrase for the mnemonic (optional).
11235
+ * @returns An unlocked wallet instance.
11236
+ */
11237
+ static fromMnemonic = WalletUnlocked.fromMnemonic;
11238
+ /**
11239
+ * Create a Wallet Unlocked from an extended key.
11240
+ *
11241
+ * @param extendedKey - The extended key.
11242
+ * @param provider - A Provider instance (optional).
11243
+ * @returns An unlocked wallet instance.
11244
+ */
11245
+ static fromExtendedKey = WalletUnlocked.fromExtendedKey;
11246
+ /**
11247
+ * Create a Wallet Unlocked from an encrypted JSON.
11248
+ *
11249
+ * @param jsonWallet - The encrypted JSON keystore.
11250
+ * @param password - The password to decrypt the JSON.
11251
+ * @param provider - A Provider instance (optional).
11252
+ * @returns An unlocked wallet instance.
11253
+ */
11254
+ static fromEncryptedJson = WalletUnlocked.fromEncryptedJson;
11060
11255
  };
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
11256
 
11105
11257
  // src/wallet-manager/wallet-manager.ts
11106
11258
  var import_address10 = require("@fuel-ts/address");
11107
11259
  var import_crypto7 = require("@fuel-ts/crypto");
11108
- var import_errors29 = require("@fuel-ts/errors");
11260
+ var import_errors28 = require("@fuel-ts/errors");
11109
11261
  var import_events = require("events");
11110
11262
 
11111
11263
  // src/wallet-manager/storages/memory-storage.ts
11112
11264
  var MemoryStorage = class {
11265
+ static {
11266
+ __name(this, "MemoryStorage");
11267
+ }
11113
11268
  storage = /* @__PURE__ */ new Map();
11114
11269
  async getItem(key) {
11115
11270
  const item = await this.storage.get(key);
@@ -11128,15 +11283,18 @@ var MemoryStorage = class {
11128
11283
 
11129
11284
  // src/wallet-manager/vaults/mnemonic-vault.ts
11130
11285
  var import_address8 = require("@fuel-ts/address");
11131
- var import_errors27 = require("@fuel-ts/errors");
11132
- var _secret;
11286
+ var import_errors26 = require("@fuel-ts/errors");
11133
11287
  var MnemonicVault = class {
11288
+ static {
11289
+ __name(this, "MnemonicVault");
11290
+ }
11291
+ static type = "mnemonic";
11292
+ #secret;
11293
+ pathKey = "{}";
11294
+ rootPath = `m/44'/1179993420'/${this.pathKey}'/0/0`;
11295
+ numberOfAccounts = 0;
11134
11296
  constructor(options) {
11135
- __privateAdd(this, _secret, void 0);
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());
11297
+ this.#secret = options.secret || mnemonic_default.generate();
11140
11298
  this.rootPath = options.rootPath || this.rootPath;
11141
11299
  this.numberOfAccounts = options.numberOfAccounts || 1;
11142
11300
  }
@@ -11148,7 +11306,7 @@ var MnemonicVault = class {
11148
11306
  }
11149
11307
  serialize() {
11150
11308
  return {
11151
- secret: __privateGet(this, _secret),
11309
+ secret: this.#secret,
11152
11310
  rootPath: this.rootPath,
11153
11311
  numberOfAccounts: this.numberOfAccounts
11154
11312
  };
@@ -11157,7 +11315,7 @@ var MnemonicVault = class {
11157
11315
  const accounts = [];
11158
11316
  let numberOfAccounts = 0;
11159
11317
  do {
11160
- const wallet = Wallet.fromMnemonic(__privateGet(this, _secret), this.getDerivePath(numberOfAccounts));
11318
+ const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
11161
11319
  accounts.push({
11162
11320
  publicKey: wallet.publicKey,
11163
11321
  address: wallet.address
@@ -11168,7 +11326,7 @@ var MnemonicVault = class {
11168
11326
  }
11169
11327
  addAccount() {
11170
11328
  this.numberOfAccounts += 1;
11171
- const wallet = Wallet.fromMnemonic(__privateGet(this, _secret), this.getDerivePath(this.numberOfAccounts - 1));
11329
+ const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(this.numberOfAccounts - 1));
11172
11330
  return {
11173
11331
  publicKey: wallet.publicKey,
11174
11332
  address: wallet.address
@@ -11178,14 +11336,14 @@ var MnemonicVault = class {
11178
11336
  let numberOfAccounts = 0;
11179
11337
  const ownerAddress = new import_address8.Address(address);
11180
11338
  do {
11181
- const wallet = Wallet.fromMnemonic(__privateGet(this, _secret), this.getDerivePath(numberOfAccounts));
11339
+ const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
11182
11340
  if (wallet.address.equals(ownerAddress)) {
11183
11341
  return wallet.privateKey;
11184
11342
  }
11185
11343
  numberOfAccounts += 1;
11186
11344
  } while (numberOfAccounts < this.numberOfAccounts);
11187
- throw new import_errors27.FuelError(
11188
- import_errors27.ErrorCode.WALLET_MANAGER_ERROR,
11345
+ throw new import_errors26.FuelError(
11346
+ import_errors26.ErrorCode.WALLET_MANAGER_ERROR,
11189
11347
  `Account with address '${address}' not found in derived wallets.`
11190
11348
  );
11191
11349
  }
@@ -11194,29 +11352,30 @@ var MnemonicVault = class {
11194
11352
  return Wallet.fromPrivateKey(privateKey);
11195
11353
  }
11196
11354
  };
11197
- _secret = new WeakMap();
11198
- __publicField(MnemonicVault, "type", "mnemonic");
11199
11355
 
11200
11356
  // src/wallet-manager/vaults/privatekey-vault.ts
11201
11357
  var import_address9 = require("@fuel-ts/address");
11202
- var import_errors28 = require("@fuel-ts/errors");
11203
- var _privateKeys;
11358
+ var import_errors27 = require("@fuel-ts/errors");
11204
11359
  var PrivateKeyVault = class {
11360
+ static {
11361
+ __name(this, "PrivateKeyVault");
11362
+ }
11363
+ static type = "privateKey";
11364
+ #privateKeys = [];
11205
11365
  /**
11206
11366
  * If privateKey vault is initialized with a secretKey, it creates
11207
11367
  * one account with the fallowing secret
11208
11368
  */
11209
11369
  constructor(options = {}) {
11210
- __privateAdd(this, _privateKeys, []);
11211
11370
  if (options.secret) {
11212
- __privateSet(this, _privateKeys, [options.secret]);
11371
+ this.#privateKeys = [options.secret];
11213
11372
  } else {
11214
- __privateSet(this, _privateKeys, options.accounts || [Wallet.generate().privateKey]);
11373
+ this.#privateKeys = options.accounts || [Wallet.generate().privateKey];
11215
11374
  }
11216
11375
  }
11217
11376
  serialize() {
11218
11377
  return {
11219
- accounts: __privateGet(this, _privateKeys)
11378
+ accounts: this.#privateKeys
11220
11379
  };
11221
11380
  }
11222
11381
  getPublicAccount(privateKey) {
@@ -11227,21 +11386,21 @@ var PrivateKeyVault = class {
11227
11386
  };
11228
11387
  }
11229
11388
  getAccounts() {
11230
- return __privateGet(this, _privateKeys).map((pk) => this.getPublicAccount(pk));
11389
+ return this.#privateKeys.map((pk) => this.getPublicAccount(pk));
11231
11390
  }
11232
11391
  addAccount() {
11233
11392
  const wallet = Wallet.generate();
11234
- __privateGet(this, _privateKeys).push(wallet.privateKey);
11393
+ this.#privateKeys.push(wallet.privateKey);
11235
11394
  return this.getPublicAccount(wallet.privateKey);
11236
11395
  }
11237
11396
  exportAccount(address) {
11238
11397
  const ownerAddress = new import_address9.Address(address);
11239
- const privateKey = __privateGet(this, _privateKeys).find(
11398
+ const privateKey = this.#privateKeys.find(
11240
11399
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
11241
11400
  );
11242
11401
  if (!privateKey) {
11243
- throw new import_errors28.FuelError(
11244
- import_errors28.ErrorCode.WALLET_MANAGER_ERROR,
11402
+ throw new import_errors27.FuelError(
11403
+ import_errors27.ErrorCode.WALLET_MANAGER_ERROR,
11245
11404
  `No private key found for address '${address}'.`
11246
11405
  );
11247
11406
  }
@@ -11252,8 +11411,6 @@ var PrivateKeyVault = class {
11252
11411
  return Wallet.fromPrivateKey(privateKey);
11253
11412
  }
11254
11413
  };
11255
- _privateKeys = new WeakMap();
11256
- __publicField(PrivateKeyVault, "type", "privateKey");
11257
11414
 
11258
11415
  // src/wallet-manager/wallet-manager.ts
11259
11416
  var ERROR_MESSAGES = {
@@ -11265,49 +11422,50 @@ var ERROR_MESSAGES = {
11265
11422
  };
11266
11423
  function assert(condition, message) {
11267
11424
  if (!condition) {
11268
- throw new import_errors29.FuelError(import_errors29.ErrorCode.WALLET_MANAGER_ERROR, message);
11425
+ throw new import_errors28.FuelError(import_errors28.ErrorCode.WALLET_MANAGER_ERROR, message);
11269
11426
  }
11270
11427
  }
11271
- var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
11272
- var _WalletManager = class extends import_events.EventEmitter {
11428
+ __name(assert, "assert");
11429
+ var WalletManager = class _WalletManager extends import_events.EventEmitter {
11430
+ static {
11431
+ __name(this, "WalletManager");
11432
+ }
11433
+ /**
11434
+ * Vaults
11435
+ *
11436
+ * Vaults are responsible to store secret keys and return an `Wallet` instance,
11437
+ * to interact with the network.
11438
+ *
11439
+ * Each vault has access to its own state
11440
+ *
11441
+ */
11442
+ static Vaults = [MnemonicVault, PrivateKeyVault];
11443
+ /**
11444
+ * Storage
11445
+ *
11446
+ * Persistent encrypted data. `The default storage works only on memory`.
11447
+ */
11448
+ storage = new MemoryStorage();
11449
+ /* Key name passed to the storage */
11450
+ STORAGE_KEY = "WalletManager";
11451
+ // `This variables are only accessible from inside the class`
11452
+ #vaults = [];
11453
+ #passphrase = "";
11454
+ #isLocked = true;
11273
11455
  constructor(options) {
11274
11456
  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
11457
  this.storage = options?.storage || this.storage;
11300
11458
  }
11301
11459
  get isLocked() {
11302
- return __privateGet(this, _isLocked);
11460
+ return this.#isLocked;
11303
11461
  }
11304
11462
  /**
11305
11463
  * Return the vault serialized object containing all the privateKeys,
11306
11464
  * the format of the return depends on the Vault type.
11307
11465
  */
11308
11466
  exportVault(vaultId) {
11309
- assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
11310
- const vaultState = __privateGet(this, _vaults).find((_, idx) => idx === vaultId);
11467
+ assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
11468
+ const vaultState = this.#vaults.find((_, idx) => idx === vaultId);
11311
11469
  assert(vaultState, ERROR_MESSAGES.vault_not_found);
11312
11470
  return vaultState.vault.serialize();
11313
11471
  }
@@ -11315,7 +11473,7 @@ var _WalletManager = class extends import_events.EventEmitter {
11315
11473
  * List all vaults on the Wallet Manager, this function not return secret's
11316
11474
  */
11317
11475
  getVaults() {
11318
- return __privateGet(this, _vaults).map((v, idx) => ({
11476
+ return this.#vaults.map((v, idx) => ({
11319
11477
  title: v.title,
11320
11478
  type: v.type,
11321
11479
  vaultId: idx
@@ -11325,7 +11483,7 @@ var _WalletManager = class extends import_events.EventEmitter {
11325
11483
  * List all accounts on the Wallet Manager not vault information is revealed
11326
11484
  */
11327
11485
  getAccounts() {
11328
- return __privateGet(this, _vaults).flatMap(
11486
+ return this.#vaults.flatMap(
11329
11487
  (vaultState, vaultId) => vaultState.vault.getAccounts().map((account) => ({ ...account, vaultId }))
11330
11488
  );
11331
11489
  }
@@ -11334,7 +11492,7 @@ var _WalletManager = class extends import_events.EventEmitter {
11334
11492
  */
11335
11493
  getWallet(address) {
11336
11494
  const ownerAddress = new import_address10.Address(address);
11337
- const vaultState = __privateGet(this, _vaults).find(
11495
+ const vaultState = this.#vaults.find(
11338
11496
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
11339
11497
  );
11340
11498
  assert(vaultState, ERROR_MESSAGES.address_not_found);
@@ -11345,8 +11503,8 @@ var _WalletManager = class extends import_events.EventEmitter {
11345
11503
  */
11346
11504
  exportPrivateKey(address) {
11347
11505
  const ownerAddress = new import_address10.Address(address);
11348
- assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
11349
- const vaultState = __privateGet(this, _vaults).find(
11506
+ assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
11507
+ const vaultState = this.#vaults.find(
11350
11508
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
11351
11509
  );
11352
11510
  assert(vaultState, ERROR_MESSAGES.address_not_found);
@@ -11358,7 +11516,7 @@ var _WalletManager = class extends import_events.EventEmitter {
11358
11516
  */
11359
11517
  async addAccount(options) {
11360
11518
  await this.loadState();
11361
- const vaultState = __privateGet(this, _vaults)[options?.vaultId || 0];
11519
+ const vaultState = this.#vaults[options?.vaultId || 0];
11362
11520
  await assert(vaultState, ERROR_MESSAGES.vault_not_found);
11363
11521
  const account = vaultState.vault.addAccount();
11364
11522
  await this.saveState();
@@ -11369,7 +11527,7 @@ var _WalletManager = class extends import_events.EventEmitter {
11369
11527
  * created by the vault.
11370
11528
  */
11371
11529
  async removeVault(index) {
11372
- __privateGet(this, _vaults).splice(index, 1);
11530
+ this.#vaults.splice(index, 1);
11373
11531
  await this.saveState();
11374
11532
  }
11375
11533
  /**
@@ -11380,11 +11538,11 @@ var _WalletManager = class extends import_events.EventEmitter {
11380
11538
  await this.loadState();
11381
11539
  const Vault2 = this.getVaultClass(vaultConfig.type);
11382
11540
  const vault = new Vault2(vaultConfig);
11383
- __privateSet(this, _vaults, __privateGet(this, _vaults).concat({
11541
+ this.#vaults = this.#vaults.concat({
11384
11542
  title: vaultConfig.title,
11385
11543
  type: vaultConfig.type,
11386
11544
  vault
11387
- }));
11545
+ });
11388
11546
  await this.saveState();
11389
11547
  }
11390
11548
  /**
@@ -11392,9 +11550,9 @@ var _WalletManager = class extends import_events.EventEmitter {
11392
11550
  * secrets.
11393
11551
  */
11394
11552
  lock() {
11395
- __privateSet(this, _isLocked, true);
11396
- __privateSet(this, _vaults, []);
11397
- __privateSet(this, _passphrase, "");
11553
+ this.#isLocked = true;
11554
+ this.#vaults = [];
11555
+ this.#passphrase = "";
11398
11556
  this.emit("lock");
11399
11557
  }
11400
11558
  /**
@@ -11402,8 +11560,8 @@ var _WalletManager = class extends import_events.EventEmitter {
11402
11560
  * Vaults with secrets are not unlocked or instantiated on this moment.
11403
11561
  */
11404
11562
  async unlock(passphrase) {
11405
- __privateSet(this, _passphrase, passphrase);
11406
- __privateSet(this, _isLocked, false);
11563
+ this.#passphrase = passphrase;
11564
+ this.#isLocked = false;
11407
11565
  try {
11408
11566
  await this.loadState();
11409
11567
  this.emit("unlock");
@@ -11416,9 +11574,9 @@ var _WalletManager = class extends import_events.EventEmitter {
11416
11574
  * Update WalletManager encryption passphrase
11417
11575
  */
11418
11576
  async updatePassphrase(oldpass, newpass) {
11419
- const isLocked = __privateGet(this, _isLocked);
11577
+ const isLocked = this.#isLocked;
11420
11578
  await this.unlock(oldpass);
11421
- __privateSet(this, _passphrase, newpass);
11579
+ this.#passphrase = newpass;
11422
11580
  await this.saveState();
11423
11581
  await this.loadState();
11424
11582
  if (isLocked) {
@@ -11429,24 +11587,51 @@ var _WalletManager = class extends import_events.EventEmitter {
11429
11587
  * Retrieve and decrypt WalletManager state from storage
11430
11588
  */
11431
11589
  async loadState() {
11432
- await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
11590
+ await assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
11433
11591
  const data = await this.storage.getItem(this.STORAGE_KEY);
11434
11592
  if (data) {
11435
- const state = await (0, import_crypto7.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
11436
- __privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
11593
+ const state = await (0, import_crypto7.decrypt)(this.#passphrase, JSON.parse(data));
11594
+ this.#vaults = this.#deserializeVaults(state.vaults);
11437
11595
  }
11438
11596
  }
11439
11597
  /**
11440
11598
  * Store encrypted WalletManager state on storage
11441
11599
  */
11442
11600
  async saveState() {
11443
- await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
11444
- const encryptedData = await (0, import_crypto7.encrypt)(__privateGet(this, _passphrase), {
11445
- vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
11601
+ await assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
11602
+ const encryptedData = await (0, import_crypto7.encrypt)(this.#passphrase, {
11603
+ vaults: this.#serializeVaults(this.#vaults)
11446
11604
  });
11447
11605
  await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
11448
11606
  this.emit("update");
11449
11607
  }
11608
+ /**
11609
+ * Serialize all vaults to store
11610
+ *
11611
+ * `This is only accessible from inside the class`
11612
+ */
11613
+ #serializeVaults(vaults) {
11614
+ return vaults.map(({ title, type, vault }) => ({
11615
+ title,
11616
+ type,
11617
+ data: vault.serialize()
11618
+ }));
11619
+ }
11620
+ /**
11621
+ * Deserialize all vaults to state
11622
+ *
11623
+ * `This is only accessible from inside the class`
11624
+ */
11625
+ #deserializeVaults(vaults) {
11626
+ return vaults.map(({ title, type, data: vaultConfig }) => {
11627
+ const VaultClass = this.getVaultClass(type);
11628
+ return {
11629
+ title,
11630
+ type,
11631
+ vault: new VaultClass(vaultConfig)
11632
+ };
11633
+ });
11634
+ }
11450
11635
  /**
11451
11636
  * Return a instantiable Class reference from `WalletManager.Vaults` supported list.
11452
11637
  */
@@ -11456,79 +11641,52 @@ var _WalletManager = class extends import_events.EventEmitter {
11456
11641
  return VaultClass;
11457
11642
  }
11458
11643
  };
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
11644
 
11493
11645
  // src/wallet-manager/types.ts
11494
- var import_errors30 = require("@fuel-ts/errors");
11646
+ var import_errors29 = require("@fuel-ts/errors");
11495
11647
  var Vault = class {
11648
+ static {
11649
+ __name(this, "Vault");
11650
+ }
11651
+ static type;
11496
11652
  constructor(_options) {
11497
- throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11653
+ throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11498
11654
  }
11499
11655
  serialize() {
11500
- throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11656
+ throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11501
11657
  }
11502
11658
  getAccounts() {
11503
- throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11659
+ throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11504
11660
  }
11505
11661
  addAccount() {
11506
- throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11662
+ throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11507
11663
  }
11508
11664
  exportAccount(_address) {
11509
- throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11665
+ throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11510
11666
  }
11511
11667
  getWallet(_address) {
11512
- throw new import_errors30.FuelError(import_errors30.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11668
+ throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
11513
11669
  }
11514
11670
  };
11515
- __publicField(Vault, "type");
11516
11671
  var StorageAbstract = class {
11672
+ static {
11673
+ __name(this, "StorageAbstract");
11674
+ }
11517
11675
  };
11518
11676
 
11519
11677
  // src/predicate/predicate.ts
11520
- var import_abi_coder8 = require("@fuel-ts/abi-coder");
11678
+ var import_abi_coder9 = require("@fuel-ts/abi-coder");
11521
11679
  var import_address11 = require("@fuel-ts/address");
11522
- var import_errors32 = require("@fuel-ts/errors");
11680
+ var import_errors31 = require("@fuel-ts/errors");
11523
11681
  var import_utils45 = require("@fuel-ts/utils");
11524
11682
 
11525
11683
  // src/utils/deployScriptOrPredicate.ts
11526
- var import_errors31 = require("@fuel-ts/errors");
11684
+ var import_errors30 = require("@fuel-ts/errors");
11527
11685
  var import_math24 = require("@fuel-ts/math");
11528
11686
  var import_utils43 = require("@fuel-ts/utils");
11529
11687
 
11530
11688
  // src/utils/predicate-script-loader-instructions.ts
11531
- var import_abi_coder7 = require("@fuel-ts/abi-coder");
11689
+ var import_abi_coder8 = require("@fuel-ts/abi-coder");
11532
11690
  var import_hasher8 = require("@fuel-ts/hasher");
11533
11691
  var import_utils42 = require("@fuel-ts/utils");
11534
11692
  var asm2 = __toESM(require("@fuels/vm-asm"));
@@ -11540,29 +11698,33 @@ var WORD_SIZE2 = 8;
11540
11698
  var DATA_OFFSET_INDEX = 8;
11541
11699
  var CONFIGURABLE_OFFSET_INDEX = 16;
11542
11700
  function getBytecodeDataOffset(bytecode) {
11543
- const [offset] = new import_abi_coder7.BigNumberCoder("u64").decode(bytecode, DATA_OFFSET_INDEX);
11701
+ const [offset] = new import_abi_coder8.BigNumberCoder("u64").decode(bytecode, DATA_OFFSET_INDEX);
11544
11702
  return offset.toNumber();
11545
11703
  }
11704
+ __name(getBytecodeDataOffset, "getBytecodeDataOffset");
11546
11705
  function getBytecodeConfigurableOffset(bytecode) {
11547
- const [offset] = new import_abi_coder7.BigNumberCoder("u64").decode(bytecode, CONFIGURABLE_OFFSET_INDEX);
11706
+ const [offset] = new import_abi_coder8.BigNumberCoder("u64").decode(bytecode, CONFIGURABLE_OFFSET_INDEX);
11548
11707
  return offset.toNumber();
11549
11708
  }
11709
+ __name(getBytecodeConfigurableOffset, "getBytecodeConfigurableOffset");
11550
11710
  function getBytecodeId(bytecode) {
11551
11711
  const configurableOffset = getBytecodeConfigurableOffset(bytecode);
11552
11712
  const byteCodeWithoutConfigurableSection = bytecode.slice(0, configurableOffset);
11553
11713
  return (0, import_hasher8.sha256)(byteCodeWithoutConfigurableSection);
11554
11714
  }
11715
+ __name(getBytecodeId, "getBytecodeId");
11555
11716
  function getLegacyBlobId(bytecode) {
11556
11717
  const dataOffset = getBytecodeDataOffset(bytecode);
11557
11718
  const byteCodeWithoutDataSection = bytecode.slice(0, dataOffset);
11558
11719
  return (0, import_hasher8.sha256)(byteCodeWithoutDataSection);
11559
11720
  }
11721
+ __name(getLegacyBlobId, "getLegacyBlobId");
11560
11722
  function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
11561
11723
  const { RegId, Instruction } = asm2;
11562
11724
  const REG_PC = RegId.pc().to_u8();
11563
11725
  const REG_SP = RegId.sp().to_u8();
11564
11726
  const REG_IS = RegId.is().to_u8();
11565
- const getInstructions = (numOfInstructions2) => [
11727
+ const getInstructions = /* @__PURE__ */ __name((numOfInstructions2) => [
11566
11728
  // 1. Load the blob content into memory
11567
11729
  // Find the start of the hardcoded blob ID, which is located after the loader code ends.
11568
11730
  asm2.move_(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_PC),
@@ -11596,8 +11758,8 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
11596
11758
  asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
11597
11759
  // Jump to the start of the contract we loaded.
11598
11760
  asm2.jmp(REG_START_OF_LOADED_CODE)
11599
- ];
11600
- const getInstructionsNoDataSection = (numOfInstructions2) => [
11761
+ ], "getInstructions");
11762
+ const getInstructionsNoDataSection = /* @__PURE__ */ __name((numOfInstructions2) => [
11601
11763
  // 1. Load the blob content into memory
11602
11764
  // Find the start of the hardcoded blob ID, which is located after the loader code ends.
11603
11765
  // 1. Load the blob content into memory
@@ -11624,7 +11786,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
11624
11786
  asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
11625
11787
  // Jump to the start of the contract we loaded.
11626
11788
  asm2.jmp(REG_START_OF_LOADED_CODE)
11627
- ];
11789
+ ], "getInstructionsNoDataSection");
11628
11790
  const offset = getBytecodeConfigurableOffset(originalBinary);
11629
11791
  if (originalBinary.length < offset) {
11630
11792
  throw new Error(
@@ -11669,6 +11831,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
11669
11831
  const loaderBytecode = new Uint8Array([...instructionBytes, ...blobBytes]);
11670
11832
  return { loaderBytecode };
11671
11833
  }
11834
+ __name(getPredicateScriptLoaderInstructions, "getPredicateScriptLoaderInstructions");
11672
11835
 
11673
11836
  // src/utils/deployScriptOrPredicate.ts
11674
11837
  async function fundBlobTx(deployer, blobTxRequest) {
@@ -11685,12 +11848,13 @@ async function fundBlobTx(deployer, blobTxRequest) {
11685
11848
  }).add(1);
11686
11849
  totalCost = totalCost.add(minFee);
11687
11850
  if (totalCost.gt(await deployer.getBalance())) {
11688
- throw new import_errors31.FuelError(import_errors31.ErrorCode.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
11851
+ throw new import_errors30.FuelError(import_errors30.ErrorCode.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
11689
11852
  }
11690
11853
  const txCost = await deployer.getTransactionCost(blobTxRequest);
11691
11854
  blobTxRequest.maxFee = txCost.maxFee;
11692
11855
  return deployer.fund(blobTxRequest, txCost);
11693
11856
  }
11857
+ __name(fundBlobTx, "fundBlobTx");
11694
11858
  function adjustConfigurableOffsets(jsonAbi, configurableOffsetDiff) {
11695
11859
  const { configurables: readOnlyConfigurables } = jsonAbi;
11696
11860
  const configurables = [];
@@ -11699,6 +11863,7 @@ function adjustConfigurableOffsets(jsonAbi, configurableOffsetDiff) {
11699
11863
  });
11700
11864
  return { ...jsonAbi, configurables };
11701
11865
  }
11866
+ __name(adjustConfigurableOffsets, "adjustConfigurableOffsets");
11702
11867
  async function deployScriptOrPredicate({
11703
11868
  deployer,
11704
11869
  bytecode,
@@ -11723,12 +11888,12 @@ async function deployScriptOrPredicate({
11723
11888
  const loaderInstance = loaderInstanceCallback(loaderBytecode, newAbi);
11724
11889
  if (blobExists) {
11725
11890
  return {
11726
- waitForResult: () => Promise.resolve(loaderInstance),
11891
+ waitForResult: /* @__PURE__ */ __name(() => Promise.resolve(loaderInstance), "waitForResult"),
11727
11892
  blobId
11728
11893
  };
11729
11894
  }
11730
11895
  const fundedBlobRequest = await fundBlobTx(deployer, blobTxRequest);
11731
- const waitForResult = async () => {
11896
+ const waitForResult = /* @__PURE__ */ __name(async () => {
11732
11897
  try {
11733
11898
  const blobTx = await deployer.sendTransaction(fundedBlobRequest);
11734
11899
  const result = await blobTx.waitForResult();
@@ -11736,31 +11901,35 @@ async function deployScriptOrPredicate({
11736
11901
  throw new Error();
11737
11902
  }
11738
11903
  } catch (err) {
11739
- throw new import_errors31.FuelError(import_errors31.ErrorCode.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
11904
+ throw new import_errors30.FuelError(import_errors30.ErrorCode.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
11740
11905
  }
11741
11906
  return loaderInstance;
11742
- };
11907
+ }, "waitForResult");
11743
11908
  return {
11744
11909
  waitForResult,
11745
11910
  blobId
11746
11911
  };
11747
11912
  }
11913
+ __name(deployScriptOrPredicate, "deployScriptOrPredicate");
11748
11914
 
11749
11915
  // src/predicate/utils/getPredicateRoot.ts
11750
11916
  var import_hasher9 = require("@fuel-ts/hasher");
11751
11917
  var import_merkle = require("@fuel-ts/merkle");
11752
11918
  var import_utils44 = require("@fuel-ts/utils");
11753
- var getPredicateRoot = (bytecode) => {
11919
+ var getPredicateRoot = /* @__PURE__ */ __name((bytecode) => {
11754
11920
  const chunkSize = 16 * 1024;
11755
11921
  const bytes = (0, import_utils44.arrayify)(bytecode);
11756
11922
  const chunks = (0, import_utils44.chunkAndPadBytes)(bytes, chunkSize);
11757
11923
  const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils44.hexlify)(c)));
11758
11924
  const predicateRoot = (0, import_hasher9.hash)((0, import_utils44.concat)(["0x4655454C", codeRoot]));
11759
11925
  return predicateRoot;
11760
- };
11926
+ }, "getPredicateRoot");
11761
11927
 
11762
11928
  // src/predicate/predicate.ts
11763
- var Predicate = class extends Account {
11929
+ var Predicate = class _Predicate extends Account {
11930
+ static {
11931
+ __name(this, "Predicate");
11932
+ }
11764
11933
  bytes;
11765
11934
  predicateData = [];
11766
11935
  interface;
@@ -11782,7 +11951,7 @@ var Predicate = class extends Account {
11782
11951
  data,
11783
11952
  configurableConstants
11784
11953
  }) {
11785
- const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
11954
+ const { predicateBytes, predicateInterface } = _Predicate.processPredicateData(
11786
11955
  bytecode,
11787
11956
  abi,
11788
11957
  configurableConstants
@@ -11851,7 +12020,7 @@ var Predicate = class extends Account {
11851
12020
  * @returns A new Predicate instance with the same bytecode, ABI and provider but with the ability to set the data and configurable constants.
11852
12021
  */
11853
12022
  toNewInstance(overrides = {}) {
11854
- return new Predicate({
12023
+ return new _Predicate({
11855
12024
  bytecode: this.initialBytecode,
11856
12025
  abi: this.interface.jsonAbi,
11857
12026
  provider: this.provider,
@@ -11869,15 +12038,15 @@ var Predicate = class extends Account {
11869
12038
  */
11870
12039
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
11871
12040
  let predicateBytes = (0, import_utils45.arrayify)(bytes);
11872
- const abiInterface = new import_abi_coder8.Interface(jsonAbi);
12041
+ const abiInterface = new import_abi_coder9.Interface(jsonAbi);
11873
12042
  if (abiInterface.functions.main === void 0) {
11874
- throw new import_errors32.FuelError(
11875
- import_errors32.ErrorCode.ABI_MAIN_METHOD_MISSING,
12043
+ throw new import_errors31.FuelError(
12044
+ import_errors31.ErrorCode.ABI_MAIN_METHOD_MISSING,
11876
12045
  'Cannot use ABI without "main" function.'
11877
12046
  );
11878
12047
  }
11879
12048
  if (configurableConstants && Object.keys(configurableConstants).length) {
11880
- predicateBytes = Predicate.setConfigurableConstants(
12049
+ predicateBytes = _Predicate.setConfigurableConstants(
11881
12050
  predicateBytes,
11882
12051
  configurableConstants,
11883
12052
  abiInterface
@@ -11932,15 +12101,15 @@ var Predicate = class extends Account {
11932
12101
  const mutatedBytes = bytes;
11933
12102
  try {
11934
12103
  if (Object.keys(abiInterface.configurables).length === 0) {
11935
- throw new import_errors32.FuelError(
11936
- import_errors32.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
12104
+ throw new import_errors31.FuelError(
12105
+ import_errors31.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
11937
12106
  "Predicate has no configurable constants to be set"
11938
12107
  );
11939
12108
  }
11940
12109
  Object.entries(configurableConstants).forEach(([key, value]) => {
11941
12110
  if (!abiInterface?.configurables[key]) {
11942
- throw new import_errors32.FuelError(
11943
- import_errors32.ErrorCode.CONFIGURABLE_NOT_FOUND,
12111
+ throw new import_errors31.FuelError(
12112
+ import_errors31.ErrorCode.CONFIGURABLE_NOT_FOUND,
11944
12113
  `No configurable constant named '${key}' found in the Predicate`
11945
12114
  );
11946
12115
  }
@@ -11949,8 +12118,8 @@ var Predicate = class extends Account {
11949
12118
  mutatedBytes.set(encoded, offset);
11950
12119
  });
11951
12120
  } catch (err) {
11952
- throw new import_errors32.FuelError(
11953
- import_errors32.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
12121
+ throw new import_errors31.FuelError(
12122
+ import_errors31.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
11954
12123
  `Error setting configurable constants: ${err.message}.`
11955
12124
  );
11956
12125
  }
@@ -11992,12 +12161,12 @@ var Predicate = class extends Account {
11992
12161
  deployer: account,
11993
12162
  abi: this.interface.jsonAbi,
11994
12163
  bytecode: this.bytes,
11995
- loaderInstanceCallback: (loaderBytecode, newAbi) => new Predicate({
12164
+ loaderInstanceCallback: /* @__PURE__ */ __name((loaderBytecode, newAbi) => new _Predicate({
11996
12165
  bytecode: loaderBytecode,
11997
12166
  abi: newAbi,
11998
12167
  provider: this.provider,
11999
12168
  data: this.predicateData
12000
- })
12169
+ }), "loaderInstanceCallback")
12001
12170
  });
12002
12171
  }
12003
12172
  };
@@ -12006,7 +12175,7 @@ var Predicate = class extends Account {
12006
12175
  var import_errors34 = require("@fuel-ts/errors");
12007
12176
 
12008
12177
  // src/connectors/fuel-connector.ts
12009
- var import_errors33 = require("@fuel-ts/errors");
12178
+ var import_errors32 = require("@fuel-ts/errors");
12010
12179
  var import_events2 = require("events");
12011
12180
 
12012
12181
  // src/connectors/types/connector-types.ts
@@ -12048,6 +12217,9 @@ var FuelConnectorEventType = "FuelConnector";
12048
12217
 
12049
12218
  // src/connectors/types/local-storage.ts
12050
12219
  var LocalStorage = class {
12220
+ static {
12221
+ __name(this, "LocalStorage");
12222
+ }
12051
12223
  storage;
12052
12224
  constructor(localStorage) {
12053
12225
  this.storage = localStorage;
@@ -12068,6 +12240,9 @@ var LocalStorage = class {
12068
12240
 
12069
12241
  // src/connectors/fuel-connector.ts
12070
12242
  var FuelConnector = class extends import_events2.EventEmitter {
12243
+ static {
12244
+ __name(this, "FuelConnector");
12245
+ }
12071
12246
  name = "";
12072
12247
  metadata = {};
12073
12248
  connected = false;
@@ -12081,7 +12256,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12081
12256
  * @returns Always true.
12082
12257
  */
12083
12258
  async ping() {
12084
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12259
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12085
12260
  }
12086
12261
  /**
12087
12262
  * Should return the current version of the connector
@@ -12090,7 +12265,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12090
12265
  * @returns boolean - connection status.
12091
12266
  */
12092
12267
  async version() {
12093
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12268
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12094
12269
  }
12095
12270
  /**
12096
12271
  * Should return true if the connector is connected
@@ -12099,7 +12274,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12099
12274
  * @returns The connection status.
12100
12275
  */
12101
12276
  async isConnected() {
12102
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12277
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12103
12278
  }
12104
12279
  /**
12105
12280
  * Should return all the accounts authorized for the
@@ -12108,7 +12283,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12108
12283
  * @returns The accounts addresses strings
12109
12284
  */
12110
12285
  async accounts() {
12111
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12286
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12112
12287
  }
12113
12288
  /**
12114
12289
  * Should start the connection process and return
@@ -12120,7 +12295,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12120
12295
  * @returns boolean - connection status.
12121
12296
  */
12122
12297
  async connect() {
12123
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12298
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12124
12299
  }
12125
12300
  /**
12126
12301
  * Should disconnect the current connection and
@@ -12130,7 +12305,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12130
12305
  * @returns The connection status.
12131
12306
  */
12132
12307
  async disconnect() {
12133
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12308
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12134
12309
  }
12135
12310
  /**
12136
12311
  * Should start the sign message process and return
@@ -12142,7 +12317,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12142
12317
  * @returns Message signature
12143
12318
  */
12144
12319
  async signMessage(_address, _message) {
12145
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12320
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12146
12321
  }
12147
12322
  /**
12148
12323
  * Should start the sign transaction process and return
@@ -12154,7 +12329,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12154
12329
  * @returns Transaction signature
12155
12330
  */
12156
12331
  async signTransaction(_address, _transaction) {
12157
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12332
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12158
12333
  }
12159
12334
  /**
12160
12335
  * Should start the send transaction process and return
@@ -12170,7 +12345,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12170
12345
  * @returns The transaction id or transaction response
12171
12346
  */
12172
12347
  async sendTransaction(_address, _transaction, _params) {
12173
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12348
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12174
12349
  }
12175
12350
  /**
12176
12351
  * Should return the current account selected inside the connector, if the account
@@ -12181,7 +12356,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12181
12356
  * @returns The current account selected otherwise null.
12182
12357
  */
12183
12358
  async currentAccount() {
12184
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12359
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12185
12360
  }
12186
12361
  /**
12187
12362
  * Should add the assets metadata to the connector and return true if the asset
@@ -12195,7 +12370,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12195
12370
  * @returns True if the asset was added successfully
12196
12371
  */
12197
12372
  async addAssets(_assets) {
12198
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12373
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12199
12374
  }
12200
12375
  /**
12201
12376
  * Should add the asset metadata to the connector and return true if the asset
@@ -12209,7 +12384,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12209
12384
  * @returns True if the asset was added successfully
12210
12385
  */
12211
12386
  async addAsset(_asset) {
12212
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12387
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12213
12388
  }
12214
12389
  /**
12215
12390
  * Should return all the assets added to the connector. If a connection is already established.
@@ -12217,7 +12392,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12217
12392
  * @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
12218
12393
  */
12219
12394
  async assets() {
12220
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12395
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12221
12396
  }
12222
12397
  /**
12223
12398
  * Should start the add network process and return true if the network was added successfully.
@@ -12228,7 +12403,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12228
12403
  * @returns Return true if the network was added successfully
12229
12404
  */
12230
12405
  async addNetwork(_networkUrl) {
12231
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12406
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12232
12407
  }
12233
12408
  /**
12234
12409
  * Should start the select network process and return true if the network has change successfully.
@@ -12239,7 +12414,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12239
12414
  * @returns Return true if the network was added successfully
12240
12415
  */
12241
12416
  async selectNetwork(_network) {
12242
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12417
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12243
12418
  }
12244
12419
  /**
12245
12420
  * Should return all the networks available from the connector. If the connection is already established.
@@ -12247,7 +12422,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12247
12422
  * @returns Return all the networks added to the connector.
12248
12423
  */
12249
12424
  async networks() {
12250
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12425
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12251
12426
  }
12252
12427
  /**
12253
12428
  * Should return the current network selected inside the connector. Even if the connection is not established.
@@ -12255,7 +12430,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12255
12430
  * @returns Return the current network selected inside the connector.
12256
12431
  */
12257
12432
  async currentNetwork() {
12258
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12433
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12259
12434
  }
12260
12435
  /**
12261
12436
  * Should add the ABI to the connector and return true if the ABI was added successfully.
@@ -12265,7 +12440,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12265
12440
  * @returns Return true if the ABI was added successfully.
12266
12441
  */
12267
12442
  async addABI(_contractId, _abi) {
12268
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12443
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12269
12444
  }
12270
12445
  /**
12271
12446
  * Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
@@ -12274,7 +12449,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12274
12449
  * @returns The ABI if it exists, otherwise return null.
12275
12450
  */
12276
12451
  async getABI(_id) {
12277
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12452
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12278
12453
  }
12279
12454
  /**
12280
12455
  * Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
@@ -12283,7 +12458,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
12283
12458
  * @returns Returns true if the abi exists or false if not.
12284
12459
  */
12285
12460
  async hasABI(_id) {
12286
- throw new import_errors33.FuelError(import_errors33.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12461
+ throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
12287
12462
  }
12288
12463
  /**
12289
12464
  * Event listener for the connector.
@@ -12316,6 +12491,7 @@ function cacheFor(fn, { cache: cache2, cacheTime, key }) {
12316
12491
  return result;
12317
12492
  };
12318
12493
  }
12494
+ __name(cacheFor, "cacheFor");
12319
12495
 
12320
12496
  // src/connectors/utils/dispatch-fuel-connector-event.ts
12321
12497
  function dispatchFuelConnectorEvent(connector) {
@@ -12325,18 +12501,45 @@ function dispatchFuelConnectorEvent(connector) {
12325
12501
  })
12326
12502
  );
12327
12503
  }
12504
+ __name(dispatchFuelConnectorEvent, "dispatchFuelConnectorEvent");
12505
+
12506
+ // src/connectors/utils/promises.ts
12507
+ var import_errors33 = require("@fuel-ts/errors");
12508
+ function deferPromise() {
12509
+ const defer = {};
12510
+ defer.promise = new Promise((resolve, reject) => {
12511
+ defer.reject = reject;
12512
+ defer.resolve = resolve;
12513
+ });
12514
+ return defer;
12515
+ }
12516
+ __name(deferPromise, "deferPromise");
12517
+ async function withTimeout(promise, timeout = 1050) {
12518
+ const timeoutPromise = new Promise((resolve, reject) => {
12519
+ setTimeout(() => {
12520
+ reject(new import_errors33.FuelError(import_errors33.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
12521
+ }, timeout);
12522
+ });
12523
+ return Promise.race([timeoutPromise, promise]);
12524
+ }
12525
+ __name(withTimeout, "withTimeout");
12328
12526
 
12329
12527
  // src/connectors/fuel.ts
12330
12528
  var HAS_CONNECTOR_TIMEOUT = 2e3;
12331
12529
  var PING_CACHE_TIME = 5e3;
12332
12530
  var { warn } = console;
12333
- var _Fuel = class extends FuelConnector {
12531
+ var Fuel = class _Fuel extends FuelConnector {
12532
+ static {
12533
+ __name(this, "Fuel");
12534
+ }
12535
+ static STORAGE_KEY = "fuel-current-connector";
12536
+ static defaultConfig = {};
12334
12537
  _storage = null;
12335
12538
  _connectors = [];
12336
12539
  _targetObject = null;
12337
12540
  _unsubscribes = [];
12338
- _targetUnsubscribe = () => {
12339
- };
12541
+ _targetUnsubscribe = /* @__PURE__ */ __name(() => {
12542
+ }, "_targetUnsubscribe");
12340
12543
  _pingCache = {};
12341
12544
  _currentConnector;
12342
12545
  _initializationPromise = null;
@@ -12409,7 +12612,7 @@ var _Fuel = class extends FuelConnector {
12409
12612
  const currentConnector = this._currentConnector;
12410
12613
  this._unsubscribes.map((unSub) => unSub());
12411
12614
  this._unsubscribes = events.map((event) => {
12412
- const handler = (...args) => this.emit(event, ...args);
12615
+ const handler = /* @__PURE__ */ __name((...args) => this.emit(event, ...args), "handler");
12413
12616
  currentConnector.on(event, handler);
12414
12617
  return () => currentConnector.off(event, handler);
12415
12618
  });
@@ -12493,7 +12696,7 @@ var _Fuel = class extends FuelConnector {
12493
12696
  * Setup a listener for the FuelConnector event and add the connector
12494
12697
  * to the list of new connectors.
12495
12698
  */
12496
- setupConnectorListener = () => {
12699
+ setupConnectorListener = /* @__PURE__ */ __name(() => {
12497
12700
  const { _targetObject: targetObject } = this;
12498
12701
  const eventName = FuelConnectorEventType;
12499
12702
  if (targetObject?.on) {
@@ -12503,9 +12706,9 @@ var _Fuel = class extends FuelConnector {
12503
12706
  };
12504
12707
  }
12505
12708
  if (targetObject?.addEventListener) {
12506
- const handler = (e) => {
12709
+ const handler = /* @__PURE__ */ __name((e) => {
12507
12710
  this.addConnector(e.detail);
12508
- };
12711
+ }, "handler");
12509
12712
  targetObject.addEventListener(eventName, handler);
12510
12713
  return () => {
12511
12714
  targetObject.removeEventListener?.(eventName, handler);
@@ -12513,11 +12716,11 @@ var _Fuel = class extends FuelConnector {
12513
12716
  }
12514
12717
  return () => {
12515
12718
  };
12516
- };
12719
+ }, "setupConnectorListener");
12517
12720
  /**
12518
12721
  * Add a new connector to the list of connectors.
12519
12722
  */
12520
- addConnector = async (connector) => {
12723
+ addConnector = /* @__PURE__ */ __name(async (connector) => {
12521
12724
  if (!this.getConnector(connector)) {
12522
12725
  this._connectors.push(connector);
12523
12726
  }
@@ -12528,8 +12731,8 @@ var _Fuel = class extends FuelConnector {
12528
12731
  emitEvents: false
12529
12732
  });
12530
12733
  }
12531
- };
12532
- triggerConnectorEvents = async () => {
12734
+ }, "addConnector");
12735
+ triggerConnectorEvents = /* @__PURE__ */ __name(async () => {
12533
12736
  const [isConnected, networks2, currentNetwork] = await Promise.all([
12534
12737
  this.isConnected(),
12535
12738
  this.networks(),
@@ -12546,14 +12749,14 @@ var _Fuel = class extends FuelConnector {
12546
12749
  this.emit(this.events.accounts, accounts);
12547
12750
  this.emit(this.events.currentAccount, currentAccount);
12548
12751
  }
12549
- };
12752
+ }, "triggerConnectorEvents");
12550
12753
  /**
12551
12754
  * Get a connector from the list of connectors.
12552
12755
  */
12553
- getConnector = (connector) => this._connectors.find((c) => {
12756
+ getConnector = /* @__PURE__ */ __name((connector) => this._connectors.find((c) => {
12554
12757
  const connectorName = typeof connector === "string" ? connector : connector.name;
12555
12758
  return c.name === connectorName || c === connector;
12556
- }) || null;
12759
+ }) || null, "getConnector");
12557
12760
  /**
12558
12761
  * Return the list of connectors with the status of installed and connected.
12559
12762
  */
@@ -12670,9 +12873,6 @@ var _Fuel = class extends FuelConnector {
12670
12873
  await this.clean();
12671
12874
  }
12672
12875
  };
12673
- var Fuel = _Fuel;
12674
- __publicField(Fuel, "STORAGE_KEY", "fuel-current-connector");
12675
- __publicField(Fuel, "defaultConfig", {});
12676
12876
  // Annotate the CommonJS export names for ESM import in node:
12677
12877
  0 && (module.exports = {
12678
12878
  AbstractAccount,
@@ -12702,6 +12902,7 @@ __publicField(Fuel, "defaultConfig", {});
12702
12902
  MemoryStorage,
12703
12903
  Mnemonic,
12704
12904
  MnemonicVault,
12905
+ NON_PAGINATED_BALANCES_SIZE,
12705
12906
  NoWitnessAtIndexError,
12706
12907
  NoWitnessByOwnerError,
12707
12908
  OperationName,
@@ -12759,6 +12960,7 @@ __publicField(Fuel, "defaultConfig", {});
12759
12960
  extractTxError,
12760
12961
  fuelAssetsBaseUrl,
12761
12962
  gasUsedByInputs,
12963
+ getAllDecodedLogs,
12762
12964
  getAssetAmountInRequestInputs,
12763
12965
  getAssetById,
12764
12966
  getAssetEth,