@fuel-ts/account 0.100.1 → 0.100.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +3744 -1865
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +678 -529
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +678 -530
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +17 -1
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +14 -14
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/utils/serialization.d.ts.map +1 -1
- package/dist/test-utils.global.js +3188 -1718
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +495 -374
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +496 -375
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +14 -14
package/dist/test-utils.mjs
CHANGED
@@ -1,22 +1,5 @@
|
|
1
1
|
var __defProp = Object.defineProperty;
|
2
|
-
var
|
3
|
-
var __publicField = (obj, key, value) => {
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
5
|
-
return value;
|
6
|
-
};
|
7
|
-
var __accessCheck = (obj, member, msg) => {
|
8
|
-
if (!member.has(obj))
|
9
|
-
throw TypeError("Cannot " + msg);
|
10
|
-
};
|
11
|
-
var __privateAdd = (obj, member, value) => {
|
12
|
-
if (member.has(obj))
|
13
|
-
throw TypeError("Cannot add the same private member more than once");
|
14
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
15
|
-
};
|
16
|
-
var __privateMethod = (obj, member, method) => {
|
17
|
-
__accessCheck(obj, member, "access private method");
|
18
|
-
return method;
|
19
|
-
};
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
20
3
|
|
21
4
|
// src/test-utils/launchNode.ts
|
22
5
|
import { BYTES_32 } from "@fuel-ts/abi-coder";
|
@@ -34,7 +17,10 @@ import { hash } from "@fuel-ts/hasher";
|
|
34
17
|
import { toBytes } from "@fuel-ts/math";
|
35
18
|
import { hexlify, concat, arrayify } from "@fuel-ts/utils";
|
36
19
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
37
|
-
var Signer = class {
|
20
|
+
var Signer = class _Signer {
|
21
|
+
static {
|
22
|
+
__name(this, "Signer");
|
23
|
+
}
|
38
24
|
address;
|
39
25
|
publicKey;
|
40
26
|
compressedPublicKey;
|
@@ -113,7 +99,7 @@ var Signer = class {
|
|
113
99
|
* @returns Address from signature
|
114
100
|
*/
|
115
101
|
static recoverAddress(data, signature) {
|
116
|
-
return new Address(
|
102
|
+
return new Address(_Signer.recoverPublicKey(data, signature));
|
117
103
|
}
|
118
104
|
/**
|
119
105
|
* Generate a random privateKey
|
@@ -137,14 +123,14 @@ var Signer = class {
|
|
137
123
|
};
|
138
124
|
|
139
125
|
// src/test-utils/launchNode.ts
|
140
|
-
var getFlagValueFromArgs = (args, flag) => {
|
126
|
+
var getFlagValueFromArgs = /* @__PURE__ */ __name((args, flag) => {
|
141
127
|
const flagIndex = args.indexOf(flag);
|
142
128
|
if (flagIndex === -1) {
|
143
129
|
return void 0;
|
144
130
|
}
|
145
131
|
return args[flagIndex + 1];
|
146
|
-
};
|
147
|
-
var extractRemainingArgs = (args, flagsToRemove) => {
|
132
|
+
}, "getFlagValueFromArgs");
|
133
|
+
var extractRemainingArgs = /* @__PURE__ */ __name((args, flagsToRemove) => {
|
148
134
|
const newArgs = [...args];
|
149
135
|
flagsToRemove.forEach((flag) => {
|
150
136
|
const flagIndex = newArgs.indexOf(flag);
|
@@ -153,7 +139,7 @@ var extractRemainingArgs = (args, flagsToRemove) => {
|
|
153
139
|
}
|
154
140
|
});
|
155
141
|
return newArgs;
|
156
|
-
};
|
142
|
+
}, "extractRemainingArgs");
|
157
143
|
function getFinalStateConfigJSON({
|
158
144
|
stateConfig,
|
159
145
|
chainConfig,
|
@@ -212,7 +198,8 @@ function getFinalStateConfigJSON({
|
|
212
198
|
const regexMakeNumber = /("amount":)"(\d+)"/gm;
|
213
199
|
return json.replace(regexMakeNumber, "$1$2");
|
214
200
|
}
|
215
|
-
|
201
|
+
__name(getFinalStateConfigJSON, "getFinalStateConfigJSON");
|
202
|
+
var launchNode = /* @__PURE__ */ __name(async ({
|
216
203
|
ip,
|
217
204
|
port,
|
218
205
|
args = [],
|
@@ -298,18 +285,18 @@ var launchNode = async ({
|
|
298
285
|
console.log(chunk.toString());
|
299
286
|
});
|
300
287
|
}
|
301
|
-
const removeChildListeners = () => {
|
288
|
+
const removeChildListeners = /* @__PURE__ */ __name(() => {
|
302
289
|
child.stderr.removeAllListeners();
|
303
|
-
};
|
304
|
-
const removeTempDir = () => {
|
290
|
+
}, "removeChildListeners");
|
291
|
+
const removeTempDir = /* @__PURE__ */ __name(() => {
|
305
292
|
if (existsSync(tempDir)) {
|
306
293
|
rmSync(tempDir, { recursive: true });
|
307
294
|
}
|
308
|
-
};
|
295
|
+
}, "removeTempDir");
|
309
296
|
const childState = {
|
310
297
|
isDead: false
|
311
298
|
};
|
312
|
-
const cleanup = () => {
|
299
|
+
const cleanup = /* @__PURE__ */ __name(() => {
|
313
300
|
if (childState.isDead) {
|
314
301
|
return;
|
315
302
|
}
|
@@ -334,7 +321,7 @@ var launchNode = async ({
|
|
334
321
|
console.error("No PID available for the child process, unable to kill launched node");
|
335
322
|
}
|
336
323
|
removeTempDir();
|
337
|
-
};
|
324
|
+
}, "cleanup");
|
338
325
|
child.stderr.on("data", (chunk) => {
|
339
326
|
const text = typeof chunk === "string" ? chunk : chunk.toString();
|
340
327
|
if (text.indexOf(graphQLStartSubstring) !== -1) {
|
@@ -375,7 +362,7 @@ var launchNode = async ({
|
|
375
362
|
reject(err);
|
376
363
|
});
|
377
364
|
})
|
378
|
-
);
|
365
|
+
), "launchNode");
|
379
366
|
|
380
367
|
// src/test-utils/setup-test-provider-and-wallets.ts
|
381
368
|
import { defaultSnapshotConfigs as defaultSnapshotConfigs3 } from "@fuel-ts/utils";
|
@@ -384,7 +371,7 @@ import { mergeDeepRight } from "ramda";
|
|
384
371
|
// src/providers/coin-quantity.ts
|
385
372
|
import { bn } from "@fuel-ts/math";
|
386
373
|
import { hexlify as hexlify3 } from "@fuel-ts/utils";
|
387
|
-
var coinQuantityfy = (coinQuantityLike) => {
|
374
|
+
var coinQuantityfy = /* @__PURE__ */ __name((coinQuantityLike) => {
|
388
375
|
let assetId;
|
389
376
|
let amount;
|
390
377
|
let max;
|
@@ -402,8 +389,8 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
402
389
|
amount: bn(amount),
|
403
390
|
max: max ? bn(max) : void 0
|
404
391
|
};
|
405
|
-
};
|
406
|
-
var addAmountToCoinQuantities = (params) => {
|
392
|
+
}, "coinQuantityfy");
|
393
|
+
var addAmountToCoinQuantities = /* @__PURE__ */ __name((params) => {
|
407
394
|
const { amount, assetId } = params;
|
408
395
|
const coinQuantities = [...params.coinQuantities];
|
409
396
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -413,7 +400,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
413
400
|
coinQuantities.push({ assetId, amount });
|
414
401
|
}
|
415
402
|
return coinQuantities;
|
416
|
-
};
|
403
|
+
}, "addAmountToCoinQuantities");
|
417
404
|
|
418
405
|
// src/providers/provider.ts
|
419
406
|
import { Address as Address3, isB256 } from "@fuel-ts/address";
|
@@ -421,7 +408,7 @@ import { ErrorCode as ErrorCode16, FuelError as FuelError20 } from "@fuel-ts/err
|
|
421
408
|
import { bn as bn17 } from "@fuel-ts/math";
|
422
409
|
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
423
410
|
import { arrayify as arrayify13, hexlify as hexlify18, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
424
|
-
import { checkFuelCoreVersionCompatibility,
|
411
|
+
import { checkFuelCoreVersionCompatibility, versions } from "@fuel-ts/versions";
|
425
412
|
import { GraphQLClient } from "graphql-request";
|
426
413
|
import gql2 from "graphql-tag";
|
427
414
|
import { clone as clone8 } from "ramda";
|
@@ -436,6 +423,7 @@ function deferPromise() {
|
|
436
423
|
});
|
437
424
|
return defer;
|
438
425
|
}
|
426
|
+
__name(deferPromise, "deferPromise");
|
439
427
|
|
440
428
|
// src/providers/__generated__/operations.ts
|
441
429
|
import gql from "graphql-tag";
|
@@ -928,6 +916,11 @@ var NodeInfoFragmentDoc = gql`
|
|
928
916
|
maxTx
|
929
917
|
maxDepth
|
930
918
|
nodeVersion
|
919
|
+
indexation {
|
920
|
+
balances
|
921
|
+
coinsToSpend
|
922
|
+
assetMetadata
|
923
|
+
}
|
931
924
|
}
|
932
925
|
`;
|
933
926
|
var RelayedTransactionStatusFragmentDoc = gql`
|
@@ -1209,7 +1202,7 @@ var GetBalancesDocument = gql`
|
|
1209
1202
|
}
|
1210
1203
|
`;
|
1211
1204
|
var GetBalancesV2Document = gql`
|
1212
|
-
query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
1205
|
+
query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int, $supportsPagination: Boolean!) {
|
1213
1206
|
balances(
|
1214
1207
|
filter: $filter
|
1215
1208
|
after: $after
|
@@ -1217,7 +1210,7 @@ var GetBalancesV2Document = gql`
|
|
1217
1210
|
first: $first
|
1218
1211
|
last: $last
|
1219
1212
|
) {
|
1220
|
-
pageInfo {
|
1213
|
+
pageInfo @include(if: $supportsPagination) {
|
1221
1214
|
...pageInfoFragment
|
1222
1215
|
}
|
1223
1216
|
edges {
|
@@ -1487,6 +1480,7 @@ function getSdk(requester) {
|
|
1487
1480
|
}
|
1488
1481
|
};
|
1489
1482
|
}
|
1483
|
+
__name(getSdk, "getSdk");
|
1490
1484
|
|
1491
1485
|
// src/providers/fuel-graphql-subscriber.ts
|
1492
1486
|
import { ErrorCode as ErrorCode2, FuelError as FuelError4 } from "@fuel-ts/errors";
|
@@ -1494,7 +1488,7 @@ import { print } from "graphql";
|
|
1494
1488
|
|
1495
1489
|
// src/providers/utils/handle-gql-error-message.ts
|
1496
1490
|
import { ErrorCode, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1497
|
-
var mapGqlErrorMessage = (error) => {
|
1491
|
+
var mapGqlErrorMessage = /* @__PURE__ */ __name((error) => {
|
1498
1492
|
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)) {
|
1499
1493
|
return new FuelError3(
|
1500
1494
|
ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
@@ -1512,8 +1506,8 @@ var mapGqlErrorMessage = (error) => {
|
|
1512
1506
|
);
|
1513
1507
|
}
|
1514
1508
|
return new FuelError3(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1515
|
-
};
|
1516
|
-
var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
|
1509
|
+
}, "mapGqlErrorMessage");
|
1510
|
+
var mapGqlErrorWithIncompatibleNodeVersion = /* @__PURE__ */ __name((error, incompatibleNodeVersionMessage) => {
|
1517
1511
|
if (!incompatibleNodeVersionMessage) {
|
1518
1512
|
return error;
|
1519
1513
|
}
|
@@ -1525,8 +1519,8 @@ ${incompatibleNodeVersionMessage}`,
|
|
1525
1519
|
error.metadata,
|
1526
1520
|
error.rawError
|
1527
1521
|
);
|
1528
|
-
};
|
1529
|
-
var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = false) => {
|
1522
|
+
}, "mapGqlErrorWithIncompatibleNodeVersion");
|
1523
|
+
var assertGqlResponseHasNoErrors = /* @__PURE__ */ __name((errors, incompatibleNodeVersionMessage = false) => {
|
1530
1524
|
if (!Array.isArray(errors)) {
|
1531
1525
|
return;
|
1532
1526
|
}
|
@@ -1539,13 +1533,18 @@ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = fal
|
|
1539
1533
|
new FuelError3(ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1540
1534
|
incompatibleNodeVersionMessage
|
1541
1535
|
);
|
1542
|
-
};
|
1536
|
+
}, "assertGqlResponseHasNoErrors");
|
1543
1537
|
|
1544
1538
|
// src/providers/fuel-graphql-subscriber.ts
|
1545
|
-
var
|
1539
|
+
var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
1546
1540
|
constructor(stream) {
|
1547
1541
|
this.stream = stream;
|
1548
1542
|
}
|
1543
|
+
static {
|
1544
|
+
__name(this, "FuelGraphqlSubscriber");
|
1545
|
+
}
|
1546
|
+
static incompatibleNodeVersionMessage = false;
|
1547
|
+
static textDecoder = new TextDecoder();
|
1549
1548
|
static async create(options) {
|
1550
1549
|
const { url, query, variables, fetchFn } = options;
|
1551
1550
|
const response = await fetchFn(`${url}-sub`, {
|
@@ -1606,9 +1605,6 @@ var _FuelGraphqlSubscriber = class {
|
|
1606
1605
|
return this;
|
1607
1606
|
}
|
1608
1607
|
};
|
1609
|
-
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
1610
|
-
__publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
|
1611
|
-
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1612
1608
|
|
1613
1609
|
// src/providers/resource-cache.ts
|
1614
1610
|
import { FuelError as FuelError14, ErrorCode as ErrorCode10 } from "@fuel-ts/errors";
|
@@ -1621,7 +1617,7 @@ import { ErrorCode as ErrorCode3, FuelError as FuelError5 } from "@fuel-ts/error
|
|
1621
1617
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1622
1618
|
import { InputType } from "@fuel-ts/transactions";
|
1623
1619
|
import { arrayify as arrayify2, hexlify as hexlify4 } from "@fuel-ts/utils";
|
1624
|
-
var inputify = (value) => {
|
1620
|
+
var inputify = /* @__PURE__ */ __name((value) => {
|
1625
1621
|
const { type } = value;
|
1626
1622
|
switch (value.type) {
|
1627
1623
|
case InputType.Coin: {
|
@@ -1687,7 +1683,7 @@ var inputify = (value) => {
|
|
1687
1683
|
);
|
1688
1684
|
}
|
1689
1685
|
}
|
1690
|
-
};
|
1686
|
+
}, "inputify");
|
1691
1687
|
|
1692
1688
|
// src/providers/transaction-request/output.ts
|
1693
1689
|
import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
@@ -1695,7 +1691,7 @@ import { ErrorCode as ErrorCode4, FuelError as FuelError6 } from "@fuel-ts/error
|
|
1695
1691
|
import { bn as bn3 } from "@fuel-ts/math";
|
1696
1692
|
import { OutputType } from "@fuel-ts/transactions";
|
1697
1693
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
1698
|
-
var outputify = (value) => {
|
1694
|
+
var outputify = /* @__PURE__ */ __name((value) => {
|
1699
1695
|
const { type } = value;
|
1700
1696
|
switch (type) {
|
1701
1697
|
case OutputType.Coin: {
|
@@ -1744,7 +1740,7 @@ var outputify = (value) => {
|
|
1744
1740
|
);
|
1745
1741
|
}
|
1746
1742
|
}
|
1747
|
-
};
|
1743
|
+
}, "outputify");
|
1748
1744
|
|
1749
1745
|
// src/providers/transaction-request/transaction-request.ts
|
1750
1746
|
import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
@@ -1763,10 +1759,10 @@ import {
|
|
1763
1759
|
import { concat as concat2, hexlify as hexlify10, isDefined } from "@fuel-ts/utils";
|
1764
1760
|
|
1765
1761
|
// src/providers/message.ts
|
1766
|
-
var isMessageCoin = (message) => !("data" in message);
|
1762
|
+
var isMessageCoin = /* @__PURE__ */ __name((message) => !("data" in message), "isMessageCoin");
|
1767
1763
|
|
1768
1764
|
// src/providers/resource.ts
|
1769
|
-
var isCoin = (resource) => "id" in resource;
|
1765
|
+
var isCoin = /* @__PURE__ */ __name((resource) => "id" in resource, "isCoin");
|
1770
1766
|
|
1771
1767
|
// src/providers/utils/receipts.ts
|
1772
1768
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
@@ -1778,7 +1774,7 @@ import { ErrorCode as ErrorCode5, FuelError as FuelError7 } from "@fuel-ts/error
|
|
1778
1774
|
import { bn as bn4 } from "@fuel-ts/math";
|
1779
1775
|
import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
|
1780
1776
|
import { hexlify as hexlify6, arrayify as arrayify3 } from "@fuel-ts/utils";
|
1781
|
-
var deserializeChain = (chain) => {
|
1777
|
+
var deserializeChain = /* @__PURE__ */ __name((chain) => {
|
1782
1778
|
const { name, daHeight, consensusParameters } = chain;
|
1783
1779
|
const {
|
1784
1780
|
contractParams,
|
@@ -1832,8 +1828,8 @@ var deserializeChain = (chain) => {
|
|
1832
1828
|
gasCosts
|
1833
1829
|
}
|
1834
1830
|
};
|
1835
|
-
};
|
1836
|
-
var serializeChain = (chain) => {
|
1831
|
+
}, "deserializeChain");
|
1832
|
+
var serializeChain = /* @__PURE__ */ __name((chain) => {
|
1837
1833
|
const { name, baseChainHeight, consensusParameters } = chain;
|
1838
1834
|
const {
|
1839
1835
|
contractParameters,
|
@@ -1887,39 +1883,41 @@ var serializeChain = (chain) => {
|
|
1887
1883
|
gasCosts
|
1888
1884
|
}
|
1889
1885
|
};
|
1890
|
-
};
|
1891
|
-
var deserializeNodeInfo = (nodeInfo) => {
|
1892
|
-
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
1886
|
+
}, "serializeChain");
|
1887
|
+
var deserializeNodeInfo = /* @__PURE__ */ __name((nodeInfo) => {
|
1888
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace, indexation } = nodeInfo;
|
1893
1889
|
return {
|
1894
1890
|
maxDepth: bn4(maxDepth),
|
1895
1891
|
maxTx: bn4(maxTx),
|
1896
1892
|
nodeVersion,
|
1897
1893
|
utxoValidation,
|
1898
|
-
vmBacktrace
|
1894
|
+
vmBacktrace,
|
1895
|
+
indexation
|
1899
1896
|
};
|
1900
|
-
};
|
1901
|
-
var serializeNodeInfo = (nodeInfo) => {
|
1902
|
-
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
1897
|
+
}, "deserializeNodeInfo");
|
1898
|
+
var serializeNodeInfo = /* @__PURE__ */ __name((nodeInfo) => {
|
1899
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace, indexation } = nodeInfo;
|
1903
1900
|
return {
|
1904
1901
|
maxDepth: maxDepth.toString(),
|
1905
1902
|
maxTx: maxTx.toString(),
|
1906
1903
|
nodeVersion,
|
1907
1904
|
utxoValidation,
|
1908
|
-
vmBacktrace
|
1905
|
+
vmBacktrace,
|
1906
|
+
indexation
|
1909
1907
|
};
|
1910
|
-
};
|
1911
|
-
var deserializeProviderCache = (cache2) => ({
|
1908
|
+
}, "serializeNodeInfo");
|
1909
|
+
var deserializeProviderCache = /* @__PURE__ */ __name((cache2) => ({
|
1912
1910
|
consensusParametersTimestamp: cache2.consensusParametersTimestamp,
|
1913
1911
|
chain: deserializeChain(cache2.chain),
|
1914
1912
|
nodeInfo: deserializeNodeInfo(cache2.nodeInfo)
|
1915
|
-
});
|
1916
|
-
var serializeProviderCache = async (provider) => ({
|
1913
|
+
}), "deserializeProviderCache");
|
1914
|
+
var serializeProviderCache = /* @__PURE__ */ __name(async (provider) => ({
|
1917
1915
|
consensusParametersTimestamp: provider.consensusParametersTimestamp,
|
1918
1916
|
chain: serializeChain(await provider.getChain()),
|
1919
1917
|
nodeInfo: serializeNodeInfo(await provider.getNode())
|
1920
|
-
});
|
1921
|
-
var hexOrZero = (hex) => hex || ZeroBytes323;
|
1922
|
-
var deserializeReceipt = (receipt) => {
|
1918
|
+
}), "serializeProviderCache");
|
1919
|
+
var hexOrZero = /* @__PURE__ */ __name((hex) => hex || ZeroBytes323, "hexOrZero");
|
1920
|
+
var deserializeReceipt = /* @__PURE__ */ __name((receipt) => {
|
1923
1921
|
const { receiptType } = receipt;
|
1924
1922
|
switch (receiptType) {
|
1925
1923
|
case "CALL" /* Call */: {
|
@@ -2111,12 +2109,12 @@ var deserializeReceipt = (receipt) => {
|
|
2111
2109
|
default:
|
2112
2110
|
throw new FuelError7(ErrorCode5.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
2113
2111
|
}
|
2114
|
-
};
|
2112
|
+
}, "deserializeReceipt");
|
2115
2113
|
|
2116
2114
|
// src/providers/utils/receipts.ts
|
2117
|
-
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType2.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
2118
|
-
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType2.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
2119
|
-
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
2115
|
+
var doesReceiptHaveMissingOutputVariables = /* @__PURE__ */ __name((receipt) => receipt.type === ReceiptType2.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL, "doesReceiptHaveMissingOutputVariables");
|
2116
|
+
var doesReceiptHaveMissingContractId = /* @__PURE__ */ __name((receipt) => receipt.type === ReceiptType2.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000", "doesReceiptHaveMissingContractId");
|
2117
|
+
var getReceiptsWithMissingData = /* @__PURE__ */ __name((receipts) => receipts.reduce(
|
2120
2118
|
(memo, receipt) => {
|
2121
2119
|
if (doesReceiptHaveMissingOutputVariables(receipt)) {
|
2122
2120
|
memo.missingOutputVariables.push(receipt);
|
@@ -2130,7 +2128,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
|
2130
2128
|
missingOutputVariables: [],
|
2131
2129
|
missingOutputContractIds: []
|
2132
2130
|
}
|
2133
|
-
);
|
2131
|
+
), "getReceiptsWithMissingData");
|
2134
2132
|
|
2135
2133
|
// src/providers/utils/block-explorer.ts
|
2136
2134
|
import { ErrorCode as ErrorCode6, FuelError as FuelError8 } from "@fuel-ts/errors";
|
@@ -2139,13 +2137,13 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError8 } from "@fuel-ts/error
|
|
2139
2137
|
import { bn as bn5 } from "@fuel-ts/math";
|
2140
2138
|
import { ReceiptType as ReceiptType3 } from "@fuel-ts/transactions";
|
2141
2139
|
import { arrayify as arrayify4 } from "@fuel-ts/utils";
|
2142
|
-
var getGasUsedFromReceipts = (receipts) => {
|
2140
|
+
var getGasUsedFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
2143
2141
|
const scriptResult = receipts.filter(
|
2144
2142
|
(receipt) => receipt.type === ReceiptType3.ScriptResult
|
2145
2143
|
);
|
2146
2144
|
const gasUsed = scriptResult.reduce((prev, receipt) => prev.add(receipt.gasUsed), bn5(0));
|
2147
2145
|
return gasUsed;
|
2148
|
-
};
|
2146
|
+
}, "getGasUsedFromReceipts");
|
2149
2147
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
2150
2148
|
const base = bn5(gasDependentCost.base);
|
2151
2149
|
let dependentValue = bn5(0);
|
@@ -2156,6 +2154,7 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
2156
2154
|
}
|
2157
2155
|
return base.add(dependentValue);
|
2158
2156
|
}
|
2157
|
+
__name(resolveGasDependentCosts, "resolveGasDependentCosts");
|
2159
2158
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
2160
2159
|
const witnessCache = [];
|
2161
2160
|
const chargeableInputs = inputs.filter((input) => {
|
@@ -2182,6 +2181,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
|
2182
2181
|
}, bn5(0));
|
2183
2182
|
return totalGas;
|
2184
2183
|
}
|
2184
|
+
__name(gasUsedByInputs, "gasUsedByInputs");
|
2185
2185
|
function getMinGas(params) {
|
2186
2186
|
const { gasCosts, gasPerByte, inputs, metadataGas, txBytesSize } = params;
|
2187
2187
|
const vmInitGas = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
@@ -2190,6 +2190,7 @@ function getMinGas(params) {
|
|
2190
2190
|
const minGas = vmInitGas.add(bytesGas).add(inputsGas).add(metadataGas).maxU64();
|
2191
2191
|
return minGas;
|
2192
2192
|
}
|
2193
|
+
__name(getMinGas, "getMinGas");
|
2193
2194
|
function getMaxGas(params) {
|
2194
2195
|
const {
|
2195
2196
|
gasPerByte,
|
@@ -2206,6 +2207,7 @@ function getMaxGas(params) {
|
|
2206
2207
|
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
2207
2208
|
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
2208
2209
|
}
|
2210
|
+
__name(getMaxGas, "getMaxGas");
|
2209
2211
|
function calculateMetadataGasForTxCreate({
|
2210
2212
|
gasCosts,
|
2211
2213
|
stateRootSize,
|
@@ -2220,12 +2222,14 @@ function calculateMetadataGasForTxCreate({
|
|
2220
2222
|
const metadataGas = contractRootGas.add(stateRootGas).add(txIdGas).add(contractIdGas);
|
2221
2223
|
return metadataGas.maxU64();
|
2222
2224
|
}
|
2225
|
+
__name(calculateMetadataGasForTxCreate, "calculateMetadataGasForTxCreate");
|
2223
2226
|
function calculateMetadataGasForTxScript({
|
2224
2227
|
gasCosts,
|
2225
2228
|
txBytesSize
|
2226
2229
|
}) {
|
2227
2230
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2228
2231
|
}
|
2232
|
+
__name(calculateMetadataGasForTxScript, "calculateMetadataGasForTxScript");
|
2229
2233
|
function calculateMetadataGasForTxBlob({
|
2230
2234
|
gasCosts,
|
2231
2235
|
txBytesSize,
|
@@ -2235,6 +2239,7 @@ function calculateMetadataGasForTxBlob({
|
|
2235
2239
|
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
2236
2240
|
return txId.add(blobLen);
|
2237
2241
|
}
|
2242
|
+
__name(calculateMetadataGasForTxBlob, "calculateMetadataGasForTxBlob");
|
2238
2243
|
function calculateMetadataGasForTxUpgrade({
|
2239
2244
|
gasCosts,
|
2240
2245
|
txBytesSize,
|
@@ -2247,6 +2252,7 @@ function calculateMetadataGasForTxUpgrade({
|
|
2247
2252
|
}
|
2248
2253
|
return txId;
|
2249
2254
|
}
|
2255
|
+
__name(calculateMetadataGasForTxUpgrade, "calculateMetadataGasForTxUpgrade");
|
2250
2256
|
function calculateMetadataGasForTxUpload({
|
2251
2257
|
gasCosts,
|
2252
2258
|
txBytesSize,
|
@@ -2260,6 +2266,7 @@ function calculateMetadataGasForTxUpload({
|
|
2260
2266
|
txId.add(subsectionsLen);
|
2261
2267
|
return txId;
|
2262
2268
|
}
|
2269
|
+
__name(calculateMetadataGasForTxUpload, "calculateMetadataGasForTxUpload");
|
2263
2270
|
function calculateMinGasForTxUpload({
|
2264
2271
|
gasCosts,
|
2265
2272
|
baseMinGas,
|
@@ -2268,10 +2275,11 @@ function calculateMinGasForTxUpload({
|
|
2268
2275
|
const additionalStoragePerByte = bn5(gasCosts.newStoragePerByte).mul(subsectionSize);
|
2269
2276
|
return bn5(baseMinGas).add(additionalStoragePerByte);
|
2270
2277
|
}
|
2271
|
-
|
2278
|
+
__name(calculateMinGasForTxUpload, "calculateMinGasForTxUpload");
|
2279
|
+
var calculateGasFee = /* @__PURE__ */ __name((params) => {
|
2272
2280
|
const { gas, gasPrice, priceFactor, tip } = params;
|
2273
2281
|
return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
|
2274
|
-
};
|
2282
|
+
}, "calculateGasFee");
|
2275
2283
|
|
2276
2284
|
// src/providers/utils/json.ts
|
2277
2285
|
import { hexlify as hexlify7 } from "@fuel-ts/utils";
|
@@ -2300,9 +2308,11 @@ function normalize(object) {
|
|
2300
2308
|
});
|
2301
2309
|
return object;
|
2302
2310
|
}
|
2311
|
+
__name(normalize, "normalize");
|
2303
2312
|
function normalizeJSON(root) {
|
2304
2313
|
return normalize(clone(root));
|
2305
2314
|
}
|
2315
|
+
__name(normalizeJSON, "normalizeJSON");
|
2306
2316
|
|
2307
2317
|
// src/providers/utils/extract-tx-error.ts
|
2308
2318
|
import { ErrorCode as ErrorCode7, FuelError as FuelError9 } from "@fuel-ts/errors";
|
@@ -2317,7 +2327,7 @@ import {
|
|
2317
2327
|
PANIC_REASONS,
|
2318
2328
|
PANIC_DOC_URL
|
2319
2329
|
} from "@fuel-ts/transactions/configs";
|
2320
|
-
var assemblePanicError = (statusReason, metadata) => {
|
2330
|
+
var assemblePanicError = /* @__PURE__ */ __name((statusReason, metadata) => {
|
2321
2331
|
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
2322
2332
|
if (PANIC_REASONS.includes(statusReason)) {
|
2323
2333
|
errorMessage = `${errorMessage}
|
@@ -2330,9 +2340,9 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
2330
2340
|
...metadata,
|
2331
2341
|
reason: statusReason
|
2332
2342
|
});
|
2333
|
-
};
|
2334
|
-
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
2335
|
-
var assembleRevertError = (receipts, logs, metadata) => {
|
2343
|
+
}, "assemblePanicError");
|
2344
|
+
var stringify = /* @__PURE__ */ __name((obj) => JSON.stringify(obj, null, 2), "stringify");
|
2345
|
+
var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
|
2336
2346
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
2337
2347
|
const revertReceipt = receipts.find(({ type }) => type === ReceiptType4.Revert);
|
2338
2348
|
let reason = "";
|
@@ -2381,8 +2391,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2381
2391
|
...metadata,
|
2382
2392
|
reason
|
2383
2393
|
});
|
2384
|
-
};
|
2385
|
-
var extractTxError = (params) => {
|
2394
|
+
}, "assembleRevertError");
|
2395
|
+
var extractTxError = /* @__PURE__ */ __name((params) => {
|
2386
2396
|
const { receipts, statusReason, logs } = params;
|
2387
2397
|
const isPanic = receipts.some(({ type }) => type === ReceiptType4.Panic);
|
2388
2398
|
const isRevert = receipts.some(({ type }) => type === ReceiptType4.Revert);
|
@@ -2397,7 +2407,7 @@ var extractTxError = (params) => {
|
|
2397
2407
|
return assemblePanicError(statusReason, metadata);
|
2398
2408
|
}
|
2399
2409
|
return assembleRevertError(receipts, logs, metadata);
|
2400
|
-
};
|
2410
|
+
}, "extractTxError");
|
2401
2411
|
|
2402
2412
|
// src/providers/transaction-request/errors.ts
|
2403
2413
|
var NoWitnessAtIndexError = class extends Error {
|
@@ -2406,6 +2416,9 @@ var NoWitnessAtIndexError = class extends Error {
|
|
2406
2416
|
this.index = index;
|
2407
2417
|
this.message = `Witness at index "${index}" was not found`;
|
2408
2418
|
}
|
2419
|
+
static {
|
2420
|
+
__name(this, "NoWitnessAtIndexError");
|
2421
|
+
}
|
2409
2422
|
name = "NoWitnessAtIndexError";
|
2410
2423
|
};
|
2411
2424
|
|
@@ -2414,15 +2427,15 @@ import { ErrorCode as ErrorCode8, FuelError as FuelError10 } from "@fuel-ts/erro
|
|
2414
2427
|
import { bn as bn7 } from "@fuel-ts/math";
|
2415
2428
|
import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
|
2416
2429
|
import { hexlify as hexlify8 } from "@fuel-ts/utils";
|
2417
|
-
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
2418
|
-
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
2419
|
-
var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
|
2420
|
-
var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
2421
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
|
2422
|
-
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
2423
|
-
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
2424
|
-
var isPredicate = (input) => isRequestInputCoinOrMessage(input) && !!input.predicate && hexlify8(input.predicate) !== "0x";
|
2425
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
2430
|
+
var isRequestInputCoin = /* @__PURE__ */ __name((input) => input.type === InputType2.Coin, "isRequestInputCoin");
|
2431
|
+
var isRequestInputMessage = /* @__PURE__ */ __name((input) => input.type === InputType2.Message, "isRequestInputMessage");
|
2432
|
+
var isRequestInputMessageWithoutData = /* @__PURE__ */ __name((input) => input.type === InputType2.Message && bn7(input.data).isZero(), "isRequestInputMessageWithoutData");
|
2433
|
+
var isRequestInputCoinOrMessage = /* @__PURE__ */ __name((input) => isRequestInputCoin(input) || isRequestInputMessage(input), "isRequestInputCoinOrMessage");
|
2434
|
+
var isRequestInputResource = /* @__PURE__ */ __name((input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input), "isRequestInputResource");
|
2435
|
+
var getRequestInputResourceOwner = /* @__PURE__ */ __name((input) => isRequestInputCoin(input) ? input.owner : input.recipient, "getRequestInputResourceOwner");
|
2436
|
+
var isRequestInputResourceFromOwner = /* @__PURE__ */ __name((input, owner) => getRequestInputResourceOwner(input) === owner.toB256(), "isRequestInputResourceFromOwner");
|
2437
|
+
var isPredicate = /* @__PURE__ */ __name((input) => isRequestInputCoinOrMessage(input) && !!input.predicate && hexlify8(input.predicate) !== "0x", "isPredicate");
|
2438
|
+
var getAssetAmountInRequestInputs = /* @__PURE__ */ __name((inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
2426
2439
|
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
2427
2440
|
return acc.add(input.amount);
|
2428
2441
|
}
|
@@ -2430,8 +2443,8 @@ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filte
|
|
2430
2443
|
return acc.add(input.amount);
|
2431
2444
|
}
|
2432
2445
|
return acc;
|
2433
|
-
}, bn7(0));
|
2434
|
-
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
2446
|
+
}, bn7(0)), "getAssetAmountInRequestInputs");
|
2447
|
+
var cacheRequestInputsResourcesFromOwner = /* @__PURE__ */ __name((inputs, owner) => inputs.reduce(
|
2435
2448
|
(acc, input) => {
|
2436
2449
|
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
2437
2450
|
acc.utxos.push(input.id);
|
@@ -2444,8 +2457,8 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
|
2444
2457
|
utxos: [],
|
2445
2458
|
messages: []
|
2446
2459
|
}
|
2447
|
-
);
|
2448
|
-
var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
|
2460
|
+
), "cacheRequestInputsResourcesFromOwner");
|
2461
|
+
var getBurnableAssetCount = /* @__PURE__ */ __name((baseAssetId, transactionRequest) => {
|
2449
2462
|
const { inputs, outputs } = transactionRequest;
|
2450
2463
|
const coinInputs = new Set(inputs.filter(isRequestInputCoin).map((input) => input.assetId));
|
2451
2464
|
if (inputs.some((i) => isRequestInputMessage(i) && bn7(i.amount).gt(0))) {
|
@@ -2456,8 +2469,8 @@ var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
|
|
2456
2469
|
);
|
2457
2470
|
const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
|
2458
2471
|
return difference.size;
|
2459
|
-
};
|
2460
|
-
var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAssetBurn = false) => {
|
2472
|
+
}, "getBurnableAssetCount");
|
2473
|
+
var validateTransactionForAssetBurn = /* @__PURE__ */ __name((baseAssetId, transactionRequest, enableAssetBurn = false) => {
|
2461
2474
|
if (enableAssetBurn === true) {
|
2462
2475
|
return;
|
2463
2476
|
}
|
@@ -2470,20 +2483,23 @@ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAs
|
|
2470
2483
|
"Or enable asset burn, upon sending the transaction."
|
2471
2484
|
].join("\n");
|
2472
2485
|
throw new FuelError10(ErrorCode8.ASSET_BURN_DETECTED, message);
|
2473
|
-
};
|
2486
|
+
}, "validateTransactionForAssetBurn");
|
2474
2487
|
|
2475
2488
|
// src/providers/transaction-request/witness.ts
|
2476
2489
|
import { arrayify as arrayify5, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2477
|
-
var witnessify = (value) => {
|
2490
|
+
var witnessify = /* @__PURE__ */ __name((value) => {
|
2478
2491
|
const data = arrayify5(value);
|
2479
2492
|
return {
|
2480
2493
|
data: hexlify9(data),
|
2481
2494
|
dataLength: data.length
|
2482
2495
|
};
|
2483
|
-
};
|
2496
|
+
}, "witnessify");
|
2484
2497
|
|
2485
2498
|
// src/providers/transaction-request/transaction-request.ts
|
2486
|
-
var BaseTransactionRequest = class {
|
2499
|
+
var BaseTransactionRequest = class _BaseTransactionRequest {
|
2500
|
+
static {
|
2501
|
+
__name(this, "BaseTransactionRequest");
|
2502
|
+
}
|
2487
2503
|
/** Gas price for transaction */
|
2488
2504
|
tip;
|
2489
2505
|
/** Block until which tx cannot be included */
|
@@ -2566,7 +2582,7 @@ var BaseTransactionRequest = class {
|
|
2566
2582
|
const inputs = this.inputs?.map(inputify) ?? [];
|
2567
2583
|
const outputs = this.outputs?.map(outputify) ?? [];
|
2568
2584
|
const witnesses = this.witnesses?.map(witnessify) ?? [];
|
2569
|
-
const { policyTypes, policies } =
|
2585
|
+
const { policyTypes, policies } = _BaseTransactionRequest.getPolicyMeta(this);
|
2570
2586
|
return {
|
2571
2587
|
policyTypes,
|
2572
2588
|
inputs,
|
@@ -2914,13 +2930,13 @@ var BaseTransactionRequest = class {
|
|
2914
2930
|
* Please use `Account.generateFakeResources` along with `this.addResources` instead.
|
2915
2931
|
*/
|
2916
2932
|
fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
|
2917
|
-
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
2933
|
+
const findAssetInput = /* @__PURE__ */ __name((assetId) => this.inputs.find((input) => {
|
2918
2934
|
if ("assetId" in input) {
|
2919
2935
|
return input.assetId === assetId;
|
2920
2936
|
}
|
2921
2937
|
return false;
|
2922
|
-
});
|
2923
|
-
const updateAssetInput = (assetId, quantity) => {
|
2938
|
+
}), "findAssetInput");
|
2939
|
+
const updateAssetInput = /* @__PURE__ */ __name((assetId, quantity) => {
|
2924
2940
|
const assetInput = findAssetInput(assetId);
|
2925
2941
|
let usedQuantity = quantity;
|
2926
2942
|
if (assetId === baseAssetId) {
|
@@ -2941,7 +2957,7 @@ var BaseTransactionRequest = class {
|
|
2941
2957
|
}
|
2942
2958
|
]);
|
2943
2959
|
}
|
2944
|
-
};
|
2960
|
+
}, "updateAssetInput");
|
2945
2961
|
updateAssetInput(baseAssetId, bn8(1e11));
|
2946
2962
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2947
2963
|
return this;
|
@@ -3029,6 +3045,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3029
3045
|
transaction.inputs = transaction.inputs.map((input) => {
|
3030
3046
|
const inputClone = clone2(input);
|
3031
3047
|
switch (inputClone.type) {
|
3048
|
+
// Zero out on signing: txPointer, predicateGasUsed
|
3032
3049
|
case InputType4.Coin: {
|
3033
3050
|
inputClone.txPointer = {
|
3034
3051
|
blockHeight: 0,
|
@@ -3037,10 +3054,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3037
3054
|
inputClone.predicateGasUsed = bn9(0);
|
3038
3055
|
return inputClone;
|
3039
3056
|
}
|
3057
|
+
// Zero out on signing: predicateGasUsed
|
3040
3058
|
case InputType4.Message: {
|
3041
3059
|
inputClone.predicateGasUsed = bn9(0);
|
3042
3060
|
return inputClone;
|
3043
3061
|
}
|
3062
|
+
// Zero out on signing: txID, outputIndex, balanceRoot, stateRoot, and txPointer
|
3044
3063
|
case InputType4.Contract: {
|
3045
3064
|
inputClone.txPointer = {
|
3046
3065
|
blockHeight: 0,
|
@@ -3059,15 +3078,18 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3059
3078
|
transaction.outputs = transaction.outputs.map((output) => {
|
3060
3079
|
const outputClone = clone2(output);
|
3061
3080
|
switch (outputClone.type) {
|
3081
|
+
// Zero out on signing: balanceRoot, stateRoot
|
3062
3082
|
case OutputType4.Contract: {
|
3063
3083
|
outputClone.balanceRoot = ZeroBytes325;
|
3064
3084
|
outputClone.stateRoot = ZeroBytes325;
|
3065
3085
|
return outputClone;
|
3066
3086
|
}
|
3087
|
+
// Zero out on signing: amount
|
3067
3088
|
case OutputType4.Change: {
|
3068
3089
|
outputClone.amount = bn9(0);
|
3069
3090
|
return outputClone;
|
3070
3091
|
}
|
3092
|
+
// Zero out on signing: amount, to and assetId
|
3071
3093
|
case OutputType4.Variable: {
|
3072
3094
|
outputClone.to = ZeroBytes325;
|
3073
3095
|
outputClone.amount = bn9(0);
|
@@ -3084,9 +3106,13 @@ function hashTransaction(transactionRequest, chainId) {
|
|
3084
3106
|
const concatenatedData = concat3([chainIdBytes, new TransactionCoder2().encode(transaction)]);
|
3085
3107
|
return sha256(concatenatedData);
|
3086
3108
|
}
|
3109
|
+
__name(hashTransaction, "hashTransaction");
|
3087
3110
|
|
3088
3111
|
// src/providers/transaction-request/blob-transaction-request.ts
|
3089
3112
|
var BlobTransactionRequest = class extends BaseTransactionRequest {
|
3113
|
+
static {
|
3114
|
+
__name(this, "BlobTransactionRequest");
|
3115
|
+
}
|
3090
3116
|
static from(obj) {
|
3091
3117
|
return new this(clone3(obj));
|
3092
3118
|
}
|
@@ -3155,12 +3181,12 @@ import { clone as clone4 } from "ramda";
|
|
3155
3181
|
|
3156
3182
|
// src/providers/transaction-request/storage-slot.ts
|
3157
3183
|
import { arrayify as arrayify6, hexlify as hexlify11 } from "@fuel-ts/utils";
|
3158
|
-
var getStorageValue = (value) => {
|
3184
|
+
var getStorageValue = /* @__PURE__ */ __name((value) => {
|
3159
3185
|
const v = new Uint8Array(32);
|
3160
3186
|
v.set(arrayify6(value));
|
3161
3187
|
return v;
|
3162
|
-
};
|
3163
|
-
var storageSlotify = (storageSlot) => {
|
3188
|
+
}, "getStorageValue");
|
3189
|
+
var storageSlotify = /* @__PURE__ */ __name((storageSlot) => {
|
3164
3190
|
let key;
|
3165
3191
|
let value;
|
3166
3192
|
if (Array.isArray(storageSlot)) {
|
@@ -3174,10 +3200,13 @@ var storageSlotify = (storageSlot) => {
|
|
3174
3200
|
key: hexlify11(key),
|
3175
3201
|
value: hexlify11(getStorageValue(value))
|
3176
3202
|
};
|
3177
|
-
};
|
3203
|
+
}, "storageSlotify");
|
3178
3204
|
|
3179
3205
|
// src/providers/transaction-request/create-transaction-request.ts
|
3180
3206
|
var CreateTransactionRequest = class extends BaseTransactionRequest {
|
3207
|
+
static {
|
3208
|
+
__name(this, "CreateTransactionRequest");
|
3209
|
+
}
|
3181
3210
|
static from(obj) {
|
3182
3211
|
return new this(clone4(obj));
|
3183
3212
|
}
|
@@ -3279,7 +3308,7 @@ var returnZeroScript = {
|
|
3279
3308
|
*/
|
3280
3309
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
3281
3310
|
bytes: arrayify8("0x24000000"),
|
3282
|
-
encodeScriptData: () => new Uint8Array(0)
|
3311
|
+
encodeScriptData: /* @__PURE__ */ __name(() => new Uint8Array(0), "encodeScriptData")
|
3283
3312
|
};
|
3284
3313
|
var withdrawScript = {
|
3285
3314
|
/*
|
@@ -3293,11 +3322,14 @@ var withdrawScript = {
|
|
3293
3322
|
*/
|
3294
3323
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
3295
3324
|
bytes: arrayify8("0x5040C0105D44C0064C40001124000000"),
|
3296
|
-
encodeScriptData: () => new Uint8Array(0)
|
3325
|
+
encodeScriptData: /* @__PURE__ */ __name(() => new Uint8Array(0), "encodeScriptData")
|
3297
3326
|
};
|
3298
3327
|
|
3299
3328
|
// src/providers/transaction-request/script-transaction-request.ts
|
3300
3329
|
var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
3330
|
+
static {
|
3331
|
+
__name(this, "ScriptTransactionRequest");
|
3332
|
+
}
|
3301
3333
|
static from(obj) {
|
3302
3334
|
return new this(clone5(obj));
|
3303
3335
|
}
|
@@ -3498,9 +3530,12 @@ import {
|
|
3498
3530
|
} from "@fuel-ts/transactions";
|
3499
3531
|
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
3500
3532
|
import { clone as clone6 } from "ramda";
|
3501
|
-
var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
3533
|
+
var UpgradeTransactionRequest = class _UpgradeTransactionRequest extends BaseTransactionRequest {
|
3534
|
+
static {
|
3535
|
+
__name(this, "UpgradeTransactionRequest");
|
3536
|
+
}
|
3502
3537
|
static from(obj) {
|
3503
|
-
if (obj instanceof
|
3538
|
+
if (obj instanceof _UpgradeTransactionRequest) {
|
3504
3539
|
return obj;
|
3505
3540
|
}
|
3506
3541
|
return new this(clone6(obj));
|
@@ -3648,9 +3683,12 @@ import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
|
3648
3683
|
import { TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
3649
3684
|
import { arrayify as arrayify10, hexlify as hexlify15 } from "@fuel-ts/utils";
|
3650
3685
|
import { clone as clone7 } from "ramda";
|
3651
|
-
var UploadTransactionRequest = class extends BaseTransactionRequest {
|
3686
|
+
var UploadTransactionRequest = class _UploadTransactionRequest extends BaseTransactionRequest {
|
3687
|
+
static {
|
3688
|
+
__name(this, "UploadTransactionRequest");
|
3689
|
+
}
|
3652
3690
|
static from(obj) {
|
3653
|
-
if (obj instanceof
|
3691
|
+
if (obj instanceof _UploadTransactionRequest) {
|
3654
3692
|
return obj;
|
3655
3693
|
}
|
3656
3694
|
return new this(clone7(obj));
|
@@ -3752,7 +3790,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
|
|
3752
3790
|
// src/providers/transaction-request/utils.ts
|
3753
3791
|
import { ErrorCode as ErrorCode9, FuelError as FuelError13 } from "@fuel-ts/errors";
|
3754
3792
|
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
3755
|
-
var transactionRequestify = (obj) => {
|
3793
|
+
var transactionRequestify = /* @__PURE__ */ __name((obj) => {
|
3756
3794
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
3757
3795
|
return obj;
|
3758
3796
|
}
|
@@ -3780,13 +3818,16 @@ var transactionRequestify = (obj) => {
|
|
3780
3818
|
);
|
3781
3819
|
}
|
3782
3820
|
}
|
3783
|
-
};
|
3784
|
-
var isTransactionTypeScript = (request) => request.type === TransactionType7.Script;
|
3785
|
-
var isTransactionTypeCreate = (request) => request.type === TransactionType7.Create;
|
3821
|
+
}, "transactionRequestify");
|
3822
|
+
var isTransactionTypeScript = /* @__PURE__ */ __name((request) => request.type === TransactionType7.Script, "isTransactionTypeScript");
|
3823
|
+
var isTransactionTypeCreate = /* @__PURE__ */ __name((request) => request.type === TransactionType7.Create, "isTransactionTypeCreate");
|
3786
3824
|
|
3787
3825
|
// src/providers/resource-cache.ts
|
3788
3826
|
var cache = /* @__PURE__ */ new Map();
|
3789
3827
|
var ResourceCache = class {
|
3828
|
+
static {
|
3829
|
+
__name(this, "ResourceCache");
|
3830
|
+
}
|
3790
3831
|
ttl;
|
3791
3832
|
constructor(ttl) {
|
3792
3833
|
this.ttl = ttl;
|
@@ -3890,7 +3931,7 @@ import { DateTime, hexlify as hexlify17 } from "@fuel-ts/utils";
|
|
3890
3931
|
import { bn as bn12 } from "@fuel-ts/math";
|
3891
3932
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType8 } from "@fuel-ts/transactions";
|
3892
3933
|
import { arrayify as arrayify11 } from "@fuel-ts/utils";
|
3893
|
-
var calculateTXFeeForSummary = (params) => {
|
3934
|
+
var calculateTXFeeForSummary = /* @__PURE__ */ __name((params) => {
|
3894
3935
|
const {
|
3895
3936
|
gasPrice,
|
3896
3937
|
rawPayload,
|
@@ -3950,7 +3991,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
3950
3991
|
tip
|
3951
3992
|
});
|
3952
3993
|
return maxFee;
|
3953
|
-
};
|
3994
|
+
}, "calculateTXFeeForSummary");
|
3954
3995
|
|
3955
3996
|
// src/providers/transaction-summary/operations.ts
|
3956
3997
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
@@ -3965,28 +4006,36 @@ import { InputType as InputType6 } from "@fuel-ts/transactions";
|
|
3965
4006
|
function getInputsByTypes(inputs, types) {
|
3966
4007
|
return inputs.filter((i) => types.includes(i.type));
|
3967
4008
|
}
|
4009
|
+
__name(getInputsByTypes, "getInputsByTypes");
|
3968
4010
|
function getInputsByType(inputs, type) {
|
3969
4011
|
return inputs.filter((i) => i.type === type);
|
3970
4012
|
}
|
4013
|
+
__name(getInputsByType, "getInputsByType");
|
3971
4014
|
function getInputsCoin(inputs) {
|
3972
4015
|
return getInputsByType(inputs, InputType6.Coin);
|
3973
4016
|
}
|
4017
|
+
__name(getInputsCoin, "getInputsCoin");
|
3974
4018
|
function getInputsMessage(inputs) {
|
3975
4019
|
return getInputsByType(inputs, InputType6.Message);
|
3976
4020
|
}
|
4021
|
+
__name(getInputsMessage, "getInputsMessage");
|
3977
4022
|
function getInputsCoinAndMessage(inputs) {
|
3978
4023
|
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
3979
4024
|
}
|
4025
|
+
__name(getInputsCoinAndMessage, "getInputsCoinAndMessage");
|
3980
4026
|
function isInputCoin(input) {
|
3981
4027
|
return input.type === InputType6.Coin;
|
3982
4028
|
}
|
4029
|
+
__name(isInputCoin, "isInputCoin");
|
3983
4030
|
function getInputsContract(inputs) {
|
3984
4031
|
return getInputsByType(inputs, InputType6.Contract);
|
3985
4032
|
}
|
4033
|
+
__name(getInputsContract, "getInputsContract");
|
3986
4034
|
function findCoinInput(inputs, assetId) {
|
3987
4035
|
const coinInputs = getInputsCoin(inputs);
|
3988
4036
|
return coinInputs.find((i) => i.assetId === assetId);
|
3989
4037
|
}
|
4038
|
+
__name(findCoinInput, "findCoinInput");
|
3990
4039
|
function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
|
3991
4040
|
const aggregated = /* @__PURE__ */ new Map();
|
3992
4041
|
getInputsCoinAndMessage(inputs).forEach((input) => {
|
@@ -4006,9 +4055,11 @@ function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
|
|
4006
4055
|
});
|
4007
4056
|
return aggregated;
|
4008
4057
|
}
|
4058
|
+
__name(aggregateInputsAmountsByAssetAndOwner, "aggregateInputsAmountsByAssetAndOwner");
|
4009
4059
|
function findMessageInput(inputs) {
|
4010
4060
|
return getInputsMessage(inputs)?.[0];
|
4011
4061
|
}
|
4062
|
+
__name(findMessageInput, "findMessageInput");
|
4012
4063
|
function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
|
4013
4064
|
const coinInput = findCoinInput(inputs, assetId);
|
4014
4065
|
if (coinInput) {
|
@@ -4019,6 +4070,7 @@ function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
|
|
4019
4070
|
}
|
4020
4071
|
return void 0;
|
4021
4072
|
}
|
4073
|
+
__name(getInputFromAssetId, "getInputFromAssetId");
|
4022
4074
|
function getInputContractFromIndex(inputs, inputIndex) {
|
4023
4075
|
if (inputIndex == null) {
|
4024
4076
|
return void 0;
|
@@ -4035,6 +4087,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
4035
4087
|
}
|
4036
4088
|
return contractInput;
|
4037
4089
|
}
|
4090
|
+
__name(getInputContractFromIndex, "getInputContractFromIndex");
|
4038
4091
|
function getInputAccountAddress(input) {
|
4039
4092
|
if (input.type === InputType6.Coin) {
|
4040
4093
|
return input.owner.toString();
|
@@ -4044,29 +4097,36 @@ function getInputAccountAddress(input) {
|
|
4044
4097
|
}
|
4045
4098
|
return "";
|
4046
4099
|
}
|
4100
|
+
__name(getInputAccountAddress, "getInputAccountAddress");
|
4047
4101
|
|
4048
4102
|
// src/providers/transaction-summary/output.ts
|
4049
4103
|
import { OutputType as OutputType7 } from "@fuel-ts/transactions";
|
4050
4104
|
function getOutputsByType(outputs, type) {
|
4051
4105
|
return outputs.filter((o) => o.type === type);
|
4052
4106
|
}
|
4107
|
+
__name(getOutputsByType, "getOutputsByType");
|
4053
4108
|
function getOutputsContractCreated(outputs) {
|
4054
4109
|
return getOutputsByType(outputs, OutputType7.ContractCreated);
|
4055
4110
|
}
|
4111
|
+
__name(getOutputsContractCreated, "getOutputsContractCreated");
|
4056
4112
|
function getOutputsCoin(outputs) {
|
4057
4113
|
return getOutputsByType(outputs, OutputType7.Coin);
|
4058
4114
|
}
|
4115
|
+
__name(getOutputsCoin, "getOutputsCoin");
|
4059
4116
|
function getOutputsChange(outputs) {
|
4060
4117
|
return getOutputsByType(outputs, OutputType7.Change);
|
4061
4118
|
}
|
4119
|
+
__name(getOutputsChange, "getOutputsChange");
|
4062
4120
|
function getOutputsContract(outputs) {
|
4063
4121
|
return getOutputsByType(outputs, OutputType7.Contract);
|
4064
4122
|
}
|
4123
|
+
__name(getOutputsContract, "getOutputsContract");
|
4065
4124
|
|
4066
4125
|
// src/providers/transaction-summary/operations.ts
|
4067
4126
|
function getReceiptsByType(receipts, type) {
|
4068
4127
|
return (receipts ?? []).filter((r) => r.type === type);
|
4069
4128
|
}
|
4129
|
+
__name(getReceiptsByType, "getReceiptsByType");
|
4070
4130
|
function getTransactionTypeName(transactionType) {
|
4071
4131
|
switch (transactionType) {
|
4072
4132
|
case TransactionType9.Mint:
|
@@ -4088,34 +4148,44 @@ function getTransactionTypeName(transactionType) {
|
|
4088
4148
|
);
|
4089
4149
|
}
|
4090
4150
|
}
|
4151
|
+
__name(getTransactionTypeName, "getTransactionTypeName");
|
4091
4152
|
function isType(transactionType, type) {
|
4092
4153
|
const txType = getTransactionTypeName(transactionType);
|
4093
4154
|
return txType === type;
|
4094
4155
|
}
|
4156
|
+
__name(isType, "isType");
|
4095
4157
|
function isTypeMint(transactionType) {
|
4096
4158
|
return isType(transactionType, "Mint" /* Mint */);
|
4097
4159
|
}
|
4160
|
+
__name(isTypeMint, "isTypeMint");
|
4098
4161
|
function isTypeCreate(transactionType) {
|
4099
4162
|
return isType(transactionType, "Create" /* Create */);
|
4100
4163
|
}
|
4164
|
+
__name(isTypeCreate, "isTypeCreate");
|
4101
4165
|
function isTypeScript(transactionType) {
|
4102
4166
|
return isType(transactionType, "Script" /* Script */);
|
4103
4167
|
}
|
4168
|
+
__name(isTypeScript, "isTypeScript");
|
4104
4169
|
function isTypeUpgrade(transactionType) {
|
4105
4170
|
return isType(transactionType, "Upgrade" /* Upgrade */);
|
4106
4171
|
}
|
4172
|
+
__name(isTypeUpgrade, "isTypeUpgrade");
|
4107
4173
|
function isTypeUpload(transactionType) {
|
4108
4174
|
return isType(transactionType, "Upload" /* Upload */);
|
4109
4175
|
}
|
4176
|
+
__name(isTypeUpload, "isTypeUpload");
|
4110
4177
|
function isTypeBlob(transactionType) {
|
4111
4178
|
return isType(transactionType, "Blob" /* Blob */);
|
4112
4179
|
}
|
4180
|
+
__name(isTypeBlob, "isTypeBlob");
|
4113
4181
|
function getReceiptsCall(receipts) {
|
4114
4182
|
return getReceiptsByType(receipts, ReceiptType5.Call);
|
4115
4183
|
}
|
4184
|
+
__name(getReceiptsCall, "getReceiptsCall");
|
4116
4185
|
function getReceiptsMessageOut(receipts) {
|
4117
4186
|
return getReceiptsByType(receipts, ReceiptType5.MessageOut);
|
4118
4187
|
}
|
4188
|
+
__name(getReceiptsMessageOut, "getReceiptsMessageOut");
|
4119
4189
|
function mergeAssets(op1, op2) {
|
4120
4190
|
const assets1 = op1.assetsSent || [];
|
4121
4191
|
const assets2 = op2.assetsSent || [];
|
@@ -4133,21 +4203,25 @@ function mergeAssets(op1, op2) {
|
|
4133
4203
|
});
|
4134
4204
|
return Array.from(assetMap.values());
|
4135
4205
|
}
|
4206
|
+
__name(mergeAssets, "mergeAssets");
|
4136
4207
|
function isSameOperation(a, b) {
|
4137
4208
|
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;
|
4138
4209
|
}
|
4210
|
+
__name(isSameOperation, "isSameOperation");
|
4139
4211
|
function mergeAssetsSent(existing, toAdd) {
|
4140
4212
|
if (!toAdd.assetsSent?.length) {
|
4141
4213
|
return existing.assetsSent;
|
4142
4214
|
}
|
4143
4215
|
return existing.assetsSent?.length ? mergeAssets(existing, toAdd) : toAdd.assetsSent;
|
4144
4216
|
}
|
4217
|
+
__name(mergeAssetsSent, "mergeAssetsSent");
|
4145
4218
|
function mergeCalls(existing, toAdd) {
|
4146
4219
|
if (!toAdd.calls?.length) {
|
4147
4220
|
return existing.calls;
|
4148
4221
|
}
|
4149
4222
|
return [...existing.calls || [], ...toAdd.calls];
|
4150
4223
|
}
|
4224
|
+
__name(mergeCalls, "mergeCalls");
|
4151
4225
|
function mergeOperations(existing, toAdd) {
|
4152
4226
|
return {
|
4153
4227
|
...existing,
|
@@ -4159,6 +4233,7 @@ function mergeOperations(existing, toAdd) {
|
|
4159
4233
|
]
|
4160
4234
|
};
|
4161
4235
|
}
|
4236
|
+
__name(mergeOperations, "mergeOperations");
|
4162
4237
|
function addOperation(operations, toAdd) {
|
4163
4238
|
const existingIndex = operations.findIndex((op) => isSameOperation(op, toAdd));
|
4164
4239
|
if (existingIndex === -1) {
|
@@ -4166,6 +4241,7 @@ function addOperation(operations, toAdd) {
|
|
4166
4241
|
}
|
4167
4242
|
return operations.map((op, index) => index === existingIndex ? mergeOperations(op, toAdd) : op);
|
4168
4243
|
}
|
4244
|
+
__name(addOperation, "addOperation");
|
4169
4245
|
function getWithdrawFromFuelOperations({
|
4170
4246
|
inputs,
|
4171
4247
|
receipts,
|
@@ -4204,6 +4280,7 @@ function getWithdrawFromFuelOperations({
|
|
4204
4280
|
);
|
4205
4281
|
return withdrawFromFuelOperations;
|
4206
4282
|
}
|
4283
|
+
__name(getWithdrawFromFuelOperations, "getWithdrawFromFuelOperations");
|
4207
4284
|
function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
|
4208
4285
|
const abi = abiMap?.[contractInput.contractID];
|
4209
4286
|
if (!abi) {
|
@@ -4211,6 +4288,7 @@ function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInpu
|
|
4211
4288
|
}
|
4212
4289
|
return [];
|
4213
4290
|
}
|
4291
|
+
__name(getContractCalls, "getContractCalls");
|
4214
4292
|
function getAssetsSent(receipt) {
|
4215
4293
|
return receipt.amount?.isZero() ? void 0 : [
|
4216
4294
|
{
|
@@ -4219,6 +4297,7 @@ function getAssetsSent(receipt) {
|
|
4219
4297
|
}
|
4220
4298
|
];
|
4221
4299
|
}
|
4300
|
+
__name(getAssetsSent, "getAssetsSent");
|
4222
4301
|
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
4223
4302
|
const assetId = receipt.assetId === ZeroBytes329 ? baseAssetId : receipt.assetId;
|
4224
4303
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
@@ -4244,6 +4323,7 @@ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload,
|
|
4244
4323
|
}
|
4245
4324
|
];
|
4246
4325
|
}
|
4326
|
+
__name(processCallReceipt, "processCallReceipt");
|
4247
4327
|
function getContractCallOperations({
|
4248
4328
|
inputs,
|
4249
4329
|
outputs,
|
@@ -4273,6 +4353,7 @@ function getContractCallOperations({
|
|
4273
4353
|
);
|
4274
4354
|
});
|
4275
4355
|
}
|
4356
|
+
__name(getContractCallOperations, "getContractCallOperations");
|
4276
4357
|
function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
|
4277
4358
|
const { to: toAddress, assetId, amount } = receipt;
|
4278
4359
|
let { id: fromAddress } = receipt;
|
@@ -4301,6 +4382,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
4301
4382
|
receipts: [receipt]
|
4302
4383
|
};
|
4303
4384
|
}
|
4385
|
+
__name(extractTransferOperationFromReceipt, "extractTransferOperationFromReceipt");
|
4304
4386
|
function getTransferOperations({
|
4305
4387
|
inputs,
|
4306
4388
|
outputs,
|
@@ -4355,6 +4437,7 @@ function getTransferOperations({
|
|
4355
4437
|
});
|
4356
4438
|
return operations;
|
4357
4439
|
}
|
4440
|
+
__name(getTransferOperations, "getTransferOperations");
|
4358
4441
|
function getPayProducerOperations(outputs) {
|
4359
4442
|
const coinOutputs = getOutputsCoin(outputs);
|
4360
4443
|
const payProducerOperations = coinOutputs.reduce((prev, output) => {
|
@@ -4379,6 +4462,7 @@ function getPayProducerOperations(outputs) {
|
|
4379
4462
|
}, []);
|
4380
4463
|
return payProducerOperations;
|
4381
4464
|
}
|
4465
|
+
__name(getPayProducerOperations, "getPayProducerOperations");
|
4382
4466
|
function getContractCreatedOperations({ inputs, outputs }) {
|
4383
4467
|
const contractCreatedOutputs = getOutputsContractCreated(outputs);
|
4384
4468
|
const input = getInputsCoinAndMessage(inputs)[0];
|
@@ -4399,6 +4483,7 @@ function getContractCreatedOperations({ inputs, outputs }) {
|
|
4399
4483
|
}, []);
|
4400
4484
|
return contractCreatedOperations;
|
4401
4485
|
}
|
4486
|
+
__name(getContractCreatedOperations, "getContractCreatedOperations");
|
4402
4487
|
function getOperations({
|
4403
4488
|
transactionType,
|
4404
4489
|
inputs,
|
@@ -4429,10 +4514,11 @@ function getOperations({
|
|
4429
4514
|
}
|
4430
4515
|
return [...getPayProducerOperations(outputs)];
|
4431
4516
|
}
|
4517
|
+
__name(getOperations, "getOperations");
|
4432
4518
|
|
4433
4519
|
// src/providers/transaction-summary/receipt.ts
|
4434
4520
|
import { ReceiptType as ReceiptType6 } from "@fuel-ts/transactions";
|
4435
|
-
var extractMintedAssetsFromReceipts = (receipts) => {
|
4521
|
+
var extractMintedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
4436
4522
|
const mintedAssets = [];
|
4437
4523
|
receipts.forEach((receipt) => {
|
4438
4524
|
if (receipt.type === ReceiptType6.Mint) {
|
@@ -4445,8 +4531,8 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
4445
4531
|
}
|
4446
4532
|
});
|
4447
4533
|
return mintedAssets;
|
4448
|
-
};
|
4449
|
-
var extractBurnedAssetsFromReceipts = (receipts) => {
|
4534
|
+
}, "extractMintedAssetsFromReceipts");
|
4535
|
+
var extractBurnedAssetsFromReceipts = /* @__PURE__ */ __name((receipts) => {
|
4450
4536
|
const burnedAssets = [];
|
4451
4537
|
receipts.forEach((receipt) => {
|
4452
4538
|
if (receipt.type === ReceiptType6.Burn) {
|
@@ -4459,12 +4545,12 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
4459
4545
|
}
|
4460
4546
|
});
|
4461
4547
|
return burnedAssets;
|
4462
|
-
};
|
4548
|
+
}, "extractBurnedAssetsFromReceipts");
|
4463
4549
|
|
4464
4550
|
// src/providers/transaction-summary/status.ts
|
4465
4551
|
import { ErrorCode as ErrorCode13, FuelError as FuelError17 } from "@fuel-ts/errors";
|
4466
4552
|
import { bn as bn14 } from "@fuel-ts/math";
|
4467
|
-
var getTransactionStatusName = (gqlStatus) => {
|
4553
|
+
var getTransactionStatusName = /* @__PURE__ */ __name((gqlStatus) => {
|
4468
4554
|
switch (gqlStatus) {
|
4469
4555
|
case "FailureStatus":
|
4470
4556
|
return "failure" /* failure */;
|
@@ -4480,8 +4566,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
4480
4566
|
`Invalid transaction status: ${gqlStatus}.`
|
4481
4567
|
);
|
4482
4568
|
}
|
4483
|
-
};
|
4484
|
-
var processGraphqlStatus = (gqlTransactionStatus) => {
|
4569
|
+
}, "getTransactionStatusName");
|
4570
|
+
var processGraphqlStatus = /* @__PURE__ */ __name((gqlTransactionStatus) => {
|
4485
4571
|
let time;
|
4486
4572
|
let blockId;
|
4487
4573
|
let status;
|
@@ -4525,8 +4611,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
4525
4611
|
isStatusPending
|
4526
4612
|
};
|
4527
4613
|
return processedGraphqlStatus;
|
4528
|
-
};
|
4529
|
-
var getTotalFeeFromStatus = (status) => status && "totalFee" in status ? bn14(status.totalFee) : void 0;
|
4614
|
+
}, "processGraphqlStatus");
|
4615
|
+
var getTotalFeeFromStatus = /* @__PURE__ */ __name((status) => status && "totalFee" in status ? bn14(status.totalFee) : void 0, "getTotalFeeFromStatus");
|
4530
4616
|
|
4531
4617
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
4532
4618
|
function assembleTransactionSummary(params) {
|
@@ -4606,6 +4692,7 @@ function assembleTransactionSummary(params) {
|
|
4606
4692
|
};
|
4607
4693
|
return transactionSummary;
|
4608
4694
|
}
|
4695
|
+
__name(assembleTransactionSummary, "assembleTransactionSummary");
|
4609
4696
|
|
4610
4697
|
// src/providers/transaction-response/getDecodedLogs.ts
|
4611
4698
|
import { Interface as Interface2, BigNumberCoder } from "@fuel-ts/abi-coder";
|
@@ -4633,6 +4720,7 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
4633
4720
|
return logs;
|
4634
4721
|
}, []);
|
4635
4722
|
}
|
4723
|
+
__name(getDecodedLogs, "getDecodedLogs");
|
4636
4724
|
|
4637
4725
|
// src/providers/transaction-response/transaction-response.ts
|
4638
4726
|
function mapGqlOutputsToTxOutputs(outputs) {
|
@@ -4665,7 +4753,8 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
4665
4753
|
}
|
4666
4754
|
});
|
4667
4755
|
}
|
4668
|
-
|
4756
|
+
__name(mapGqlOutputsToTxOutputs, "mapGqlOutputsToTxOutputs");
|
4757
|
+
var TransactionResponse = class _TransactionResponse {
|
4669
4758
|
/**
|
4670
4759
|
* Constructor for `TransactionResponse`.
|
4671
4760
|
*
|
@@ -4680,6 +4769,9 @@ var TransactionResponse = class {
|
|
4680
4769
|
this.request = typeof tx === "string" ? void 0 : tx;
|
4681
4770
|
this.waitForResult = this.waitForResult.bind(this);
|
4682
4771
|
}
|
4772
|
+
static {
|
4773
|
+
__name(this, "TransactionResponse");
|
4774
|
+
}
|
4683
4775
|
/** Transaction ID */
|
4684
4776
|
id;
|
4685
4777
|
/** Current provider */
|
@@ -4701,7 +4793,7 @@ var TransactionResponse = class {
|
|
4701
4793
|
*/
|
4702
4794
|
static async create(id, provider, abis) {
|
4703
4795
|
const chainId = await provider.getChainId();
|
4704
|
-
const response = new
|
4796
|
+
const response = new _TransactionResponse(id, provider, chainId, abis);
|
4705
4797
|
await response.fetch();
|
4706
4798
|
return response;
|
4707
4799
|
}
|
@@ -4918,6 +5010,7 @@ function getWaitDelay(options, retryAttemptNum) {
|
|
4918
5010
|
return 2 ** (retryAttemptNum - 1) * duration;
|
4919
5011
|
}
|
4920
5012
|
}
|
5013
|
+
__name(getWaitDelay, "getWaitDelay");
|
4921
5014
|
function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
4922
5015
|
if (options === void 0) {
|
4923
5016
|
return fetchFn;
|
@@ -4940,9 +5033,10 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4940
5033
|
}
|
4941
5034
|
};
|
4942
5035
|
}
|
5036
|
+
__name(autoRetryFetch, "autoRetryFetch");
|
4943
5037
|
|
4944
5038
|
// src/providers/utils/helpers.ts
|
4945
|
-
var adjustResourcesToExclude = (params) => {
|
5039
|
+
var adjustResourcesToExclude = /* @__PURE__ */ __name((params) => {
|
4946
5040
|
const { userInput, cached, maxInputs } = params;
|
4947
5041
|
const final = { ...userInput };
|
4948
5042
|
let total = final.utxos.length + final.messages.length;
|
@@ -4955,11 +5049,11 @@ var adjustResourcesToExclude = (params) => {
|
|
4955
5049
|
final.messages = [...final.messages, ...cached.messages.slice(0, maxInputs - total)];
|
4956
5050
|
}
|
4957
5051
|
return final;
|
4958
|
-
};
|
5052
|
+
}, "adjustResourcesToExclude");
|
4959
5053
|
|
4960
5054
|
// src/providers/utils/validate-pagination-args.ts
|
4961
5055
|
import { FuelError as FuelError19, ErrorCode as ErrorCode15 } from "@fuel-ts/errors";
|
4962
|
-
var validatePaginationArgs = (params) => {
|
5056
|
+
var validatePaginationArgs = /* @__PURE__ */ __name((params) => {
|
4963
5057
|
const { paginationLimit, inputArgs = {} } = params;
|
4964
5058
|
const { first, last, after, before } = inputArgs;
|
4965
5059
|
if (after && before) {
|
@@ -4990,18 +5084,71 @@ var validatePaginationArgs = (params) => {
|
|
4990
5084
|
inputArgs.first = paginationLimit;
|
4991
5085
|
}
|
4992
5086
|
return inputArgs;
|
4993
|
-
};
|
5087
|
+
}, "validatePaginationArgs");
|
4994
5088
|
|
4995
5089
|
// src/providers/provider.ts
|
4996
5090
|
var MAX_RETRIES = 10;
|
4997
5091
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
4998
5092
|
var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
|
4999
5093
|
var BALANCES_PAGE_SIZE_LIMIT = 100;
|
5094
|
+
var NON_PAGINATED_BALANCES_SIZE = 1e4;
|
5000
5095
|
var BLOCKS_PAGE_SIZE_LIMIT = 5;
|
5001
5096
|
var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
|
5002
5097
|
var GAS_USED_MODIFIER = 1.2;
|
5003
|
-
var
|
5004
|
-
|
5098
|
+
var Provider = class _Provider {
|
5099
|
+
static {
|
5100
|
+
__name(this, "Provider");
|
5101
|
+
}
|
5102
|
+
operations;
|
5103
|
+
cache;
|
5104
|
+
/** @hidden */
|
5105
|
+
static clearChainAndNodeCaches() {
|
5106
|
+
_Provider.inflightFetchChainAndNodeInfoRequests = {};
|
5107
|
+
_Provider.nodeInfoCache = {};
|
5108
|
+
_Provider.chainInfoCache = {};
|
5109
|
+
}
|
5110
|
+
/** @hidden */
|
5111
|
+
url;
|
5112
|
+
/** @hidden */
|
5113
|
+
urlWithoutAuth;
|
5114
|
+
/** @hidden */
|
5115
|
+
static inflightFetchChainAndNodeInfoRequests = {};
|
5116
|
+
/** @hidden */
|
5117
|
+
static chainInfoCache = {};
|
5118
|
+
/** @hidden */
|
5119
|
+
static nodeInfoCache = {};
|
5120
|
+
/** @hidden */
|
5121
|
+
static incompatibleNodeVersionMessage = "";
|
5122
|
+
/** @hidden */
|
5123
|
+
consensusParametersTimestamp;
|
5124
|
+
options = {
|
5125
|
+
timeout: void 0,
|
5126
|
+
resourceCacheTTL: void 0,
|
5127
|
+
fetch: void 0,
|
5128
|
+
retryOptions: void 0,
|
5129
|
+
headers: void 0,
|
5130
|
+
cache: void 0
|
5131
|
+
};
|
5132
|
+
/**
|
5133
|
+
* @hidden
|
5134
|
+
*/
|
5135
|
+
static getFetchFn(options) {
|
5136
|
+
const { retryOptions, timeout, headers } = options;
|
5137
|
+
return autoRetryFetch(async (...args) => {
|
5138
|
+
const url = args[0];
|
5139
|
+
const request = args[1];
|
5140
|
+
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
5141
|
+
let fullRequest = {
|
5142
|
+
...request,
|
5143
|
+
signal,
|
5144
|
+
headers: { ...request?.headers, ...headers }
|
5145
|
+
};
|
5146
|
+
if (options.requestMiddleware) {
|
5147
|
+
fullRequest = await options.requestMiddleware(fullRequest);
|
5148
|
+
}
|
5149
|
+
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
5150
|
+
}, retryOptions);
|
5151
|
+
}
|
5005
5152
|
/**
|
5006
5153
|
* Constructor to initialize a Provider.
|
5007
5154
|
*
|
@@ -5010,31 +5157,6 @@ var _Provider = class {
|
|
5010
5157
|
* @hidden
|
5011
5158
|
*/
|
5012
5159
|
constructor(url, options = {}) {
|
5013
|
-
/**
|
5014
|
-
* @hidden
|
5015
|
-
*/
|
5016
|
-
__privateAdd(this, _cacheInputs);
|
5017
|
-
__publicField(this, "operations");
|
5018
|
-
__publicField(this, "cache");
|
5019
|
-
/** @hidden */
|
5020
|
-
__publicField(this, "url");
|
5021
|
-
/** @hidden */
|
5022
|
-
__publicField(this, "urlWithoutAuth");
|
5023
|
-
/** @hidden */
|
5024
|
-
__publicField(this, "features", {
|
5025
|
-
balancePagination: false,
|
5026
|
-
amount128: false
|
5027
|
-
});
|
5028
|
-
/** @hidden */
|
5029
|
-
__publicField(this, "consensusParametersTimestamp");
|
5030
|
-
__publicField(this, "options", {
|
5031
|
-
timeout: void 0,
|
5032
|
-
resourceCacheTTL: void 0,
|
5033
|
-
fetch: void 0,
|
5034
|
-
retryOptions: void 0,
|
5035
|
-
headers: void 0,
|
5036
|
-
cache: void 0
|
5037
|
-
});
|
5038
5160
|
const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
|
5039
5161
|
this.url = rawUrl;
|
5040
5162
|
this.urlWithoutAuth = urlWithoutAuth;
|
@@ -5064,32 +5186,6 @@ var _Provider = class {
|
|
5064
5186
|
this.cache = new ResourceCache(DEFAULT_RESOURCE_CACHE_TTL);
|
5065
5187
|
}
|
5066
5188
|
}
|
5067
|
-
/** @hidden */
|
5068
|
-
static clearChainAndNodeCaches() {
|
5069
|
-
_Provider.inflightFetchChainAndNodeInfoRequests = {};
|
5070
|
-
_Provider.nodeInfoCache = {};
|
5071
|
-
_Provider.chainInfoCache = {};
|
5072
|
-
}
|
5073
|
-
/**
|
5074
|
-
* @hidden
|
5075
|
-
*/
|
5076
|
-
static getFetchFn(options) {
|
5077
|
-
const { retryOptions, timeout, headers } = options;
|
5078
|
-
return autoRetryFetch(async (...args) => {
|
5079
|
-
const url = args[0];
|
5080
|
-
const request = args[1];
|
5081
|
-
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
5082
|
-
let fullRequest = {
|
5083
|
-
...request,
|
5084
|
-
signal,
|
5085
|
-
headers: { ...request?.headers, ...headers }
|
5086
|
-
};
|
5087
|
-
if (options.requestMiddleware) {
|
5088
|
-
fullRequest = await options.requestMiddleware(fullRequest);
|
5089
|
-
}
|
5090
|
-
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
5091
|
-
}, retryOptions);
|
5092
|
-
}
|
5093
5189
|
static extractBasicAuth(url) {
|
5094
5190
|
let parsedUrl;
|
5095
5191
|
try {
|
@@ -5113,8 +5209,7 @@ var _Provider = class {
|
|
5113
5209
|
* Initialize Provider async stuff
|
5114
5210
|
*/
|
5115
5211
|
async init() {
|
5116
|
-
|
5117
|
-
this.setupFeatures(nodeInfo.nodeVersion);
|
5212
|
+
await this.fetchChainAndNodeInfo();
|
5118
5213
|
return this;
|
5119
5214
|
}
|
5120
5215
|
/**
|
@@ -5231,8 +5326,8 @@ var _Provider = class {
|
|
5231
5326
|
createOperations() {
|
5232
5327
|
const fetchFn = _Provider.getFetchFn(this.options);
|
5233
5328
|
const gqlClient = new GraphQLClient(this.urlWithoutAuth, {
|
5234
|
-
fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
|
5235
|
-
responseMiddleware: (response) => {
|
5329
|
+
fetch: /* @__PURE__ */ __name((input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options), "fetch"),
|
5330
|
+
responseMiddleware: /* @__PURE__ */ __name((response) => {
|
5236
5331
|
if ("response" in response) {
|
5237
5332
|
const graphQlResponse = response.response;
|
5238
5333
|
assertGqlResponseHasNoErrors(
|
@@ -5240,22 +5335,22 @@ var _Provider = class {
|
|
5240
5335
|
_Provider.incompatibleNodeVersionMessage
|
5241
5336
|
);
|
5242
5337
|
}
|
5243
|
-
}
|
5338
|
+
}, "responseMiddleware")
|
5244
5339
|
});
|
5245
|
-
const executeQuery = (query, vars) => {
|
5340
|
+
const executeQuery = /* @__PURE__ */ __name((query, vars) => {
|
5246
5341
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
5247
5342
|
const isSubscription = opDefinition?.operation === "subscription";
|
5248
5343
|
if (isSubscription) {
|
5249
5344
|
return FuelGraphqlSubscriber.create({
|
5250
5345
|
url: this.urlWithoutAuth,
|
5251
5346
|
query,
|
5252
|
-
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
5347
|
+
fetchFn: /* @__PURE__ */ __name((url, requestInit) => fetchFn(url, requestInit, this.options), "fetchFn"),
|
5253
5348
|
variables: vars
|
5254
5349
|
});
|
5255
5350
|
}
|
5256
5351
|
return gqlClient.request(query, vars);
|
5257
|
-
};
|
5258
|
-
const customOperations = (requester) => ({
|
5352
|
+
}, "executeQuery");
|
5353
|
+
const customOperations = /* @__PURE__ */ __name((requester) => ({
|
5259
5354
|
getBlobs(variables) {
|
5260
5355
|
const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
|
5261
5356
|
const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
|
@@ -5273,18 +5368,9 @@ var _Provider = class {
|
|
5273
5368
|
`;
|
5274
5369
|
return requester(document, updatedVariables);
|
5275
5370
|
}
|
5276
|
-
});
|
5371
|
+
}), "customOperations");
|
5277
5372
|
return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
|
5278
5373
|
}
|
5279
|
-
/**
|
5280
|
-
* @hidden
|
5281
|
-
*/
|
5282
|
-
setupFeatures(nodeVersion) {
|
5283
|
-
if (gte(nodeVersion, "0.41.0")) {
|
5284
|
-
this.features.balancePagination = true;
|
5285
|
-
this.features.amount128 = true;
|
5286
|
-
}
|
5287
|
-
}
|
5288
5374
|
/**
|
5289
5375
|
* Returns the version of the connected node.
|
5290
5376
|
*
|
@@ -5361,6 +5447,13 @@ var _Provider = class {
|
|
5361
5447
|
* @returns A promise that resolves to an object containing the asset details.
|
5362
5448
|
*/
|
5363
5449
|
async getAssetDetails(assetId) {
|
5450
|
+
const { assetMetadata } = await this.getNodeFeatures();
|
5451
|
+
if (!assetMetadata) {
|
5452
|
+
throw new FuelError20(
|
5453
|
+
ErrorCode16.UNSUPPORTED_FEATURE,
|
5454
|
+
"The current node does not supports fetching asset details"
|
5455
|
+
);
|
5456
|
+
}
|
5364
5457
|
const { assetDetails } = await this.operations.getAssetDetails({ assetId });
|
5365
5458
|
const { contractId, subId, totalSupply } = assetDetails;
|
5366
5459
|
return {
|
@@ -5369,6 +5462,15 @@ var _Provider = class {
|
|
5369
5462
|
totalSupply: bn17(totalSupply)
|
5370
5463
|
};
|
5371
5464
|
}
|
5465
|
+
/**
|
5466
|
+
* @hidden
|
5467
|
+
*/
|
5468
|
+
#cacheInputs(inputs, transactionId) {
|
5469
|
+
if (!this.cache) {
|
5470
|
+
return;
|
5471
|
+
}
|
5472
|
+
this.cache.set(transactionId, inputs);
|
5473
|
+
}
|
5372
5474
|
/**
|
5373
5475
|
* @hidden
|
5374
5476
|
*/
|
@@ -5418,7 +5520,10 @@ var _Provider = class {
|
|
5418
5520
|
abis = transactionRequest.abis;
|
5419
5521
|
}
|
5420
5522
|
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
5421
|
-
|
5523
|
+
this.#cacheInputs(
|
5524
|
+
transactionRequest.inputs,
|
5525
|
+
transactionRequest.getTransactionId(await this.getChainId())
|
5526
|
+
);
|
5422
5527
|
const chainId = await this.getChainId();
|
5423
5528
|
return new TransactionResponse(transactionRequest, this, chainId, abis, subscription);
|
5424
5529
|
}
|
@@ -6170,18 +6275,9 @@ var _Provider = class {
|
|
6170
6275
|
* @returns A promise that resolves to the balance.
|
6171
6276
|
*/
|
6172
6277
|
async getBalance(owner, assetId) {
|
6173
|
-
const ownerStr = new Address3(owner).toB256();
|
6174
|
-
const assetIdStr = hexlify18(assetId);
|
6175
|
-
if (!this.features.amount128) {
|
6176
|
-
const { balance: balance2 } = await this.operations.getBalance({
|
6177
|
-
owner: ownerStr,
|
6178
|
-
assetId: assetIdStr
|
6179
|
-
});
|
6180
|
-
return bn17(balance2.amount, 10);
|
6181
|
-
}
|
6182
6278
|
const { balance } = await this.operations.getBalanceV2({
|
6183
|
-
owner:
|
6184
|
-
assetId:
|
6279
|
+
owner: new Address3(owner).toB256(),
|
6280
|
+
assetId: hexlify18(assetId)
|
6185
6281
|
});
|
6186
6282
|
return bn17(balance.amountU128, 10);
|
6187
6283
|
}
|
@@ -6193,49 +6289,29 @@ var _Provider = class {
|
|
6193
6289
|
* @returns A promise that resolves to the balances.
|
6194
6290
|
*/
|
6195
6291
|
async getBalances(owner, paginationArgs) {
|
6196
|
-
|
6197
|
-
|
6292
|
+
let args = { first: NON_PAGINATED_BALANCES_SIZE };
|
6293
|
+
const { balancesPagination: supportsPagination } = await this.getNodeFeatures();
|
6294
|
+
if (supportsPagination) {
|
6295
|
+
args = validatePaginationArgs({
|
6296
|
+
inputArgs: paginationArgs,
|
6297
|
+
paginationLimit: BALANCES_PAGE_SIZE_LIMIT
|
6298
|
+
});
|
6198
6299
|
}
|
6199
|
-
return this.getBalancesV2(owner, paginationArgs);
|
6200
|
-
}
|
6201
|
-
/**
|
6202
|
-
* @hidden
|
6203
|
-
*/
|
6204
|
-
async getBalancesV1(owner, _paginationArgs) {
|
6205
|
-
const {
|
6206
|
-
balances: { edges }
|
6207
|
-
} = await this.operations.getBalances({
|
6208
|
-
/**
|
6209
|
-
* The query parameters for this method were designed to support pagination,
|
6210
|
-
* but the current Fuel-Core implementation does not support pagination yet.
|
6211
|
-
*/
|
6212
|
-
first: 1e4,
|
6213
|
-
filter: { owner: new Address3(owner).toB256() }
|
6214
|
-
});
|
6215
|
-
const balances = edges.map(({ node }) => ({
|
6216
|
-
assetId: node.assetId,
|
6217
|
-
amount: bn17(node.amount)
|
6218
|
-
}));
|
6219
|
-
return { balances };
|
6220
|
-
}
|
6221
|
-
/**
|
6222
|
-
* @hidden
|
6223
|
-
*/
|
6224
|
-
async getBalancesV2(owner, paginationArgs) {
|
6225
6300
|
const {
|
6226
6301
|
balances: { edges, pageInfo }
|
6227
6302
|
} = await this.operations.getBalancesV2({
|
6228
|
-
...
|
6229
|
-
|
6230
|
-
|
6231
|
-
}),
|
6232
|
-
filter: { owner: new Address3(owner).toB256() }
|
6303
|
+
...args,
|
6304
|
+
filter: { owner: new Address3(owner).toB256() },
|
6305
|
+
supportsPagination
|
6233
6306
|
});
|
6234
6307
|
const balances = edges.map(({ node }) => ({
|
6235
6308
|
assetId: node.assetId,
|
6236
6309
|
amount: bn17(node.amountU128)
|
6237
6310
|
}));
|
6238
|
-
return {
|
6311
|
+
return {
|
6312
|
+
balances,
|
6313
|
+
...supportsPagination ? { pageInfo } : {}
|
6314
|
+
};
|
6239
6315
|
}
|
6240
6316
|
/**
|
6241
6317
|
* Returns message for the given address.
|
@@ -6522,6 +6598,17 @@ var _Provider = class {
|
|
6522
6598
|
statusReason: status.reason
|
6523
6599
|
});
|
6524
6600
|
}
|
6601
|
+
/**
|
6602
|
+
* @hidden
|
6603
|
+
*/
|
6604
|
+
async getNodeFeatures() {
|
6605
|
+
const { indexation } = await this.getNode();
|
6606
|
+
return {
|
6607
|
+
assetMetadata: Boolean(indexation?.assetMetadata),
|
6608
|
+
balancesPagination: Boolean(indexation?.balances),
|
6609
|
+
coinsToSpend: Boolean(indexation?.coinsToSpend)
|
6610
|
+
};
|
6611
|
+
}
|
6525
6612
|
/**
|
6526
6613
|
* @hidden
|
6527
6614
|
*/
|
@@ -6536,22 +6623,6 @@ var _Provider = class {
|
|
6536
6623
|
return transactionRequest;
|
6537
6624
|
}
|
6538
6625
|
};
|
6539
|
-
var Provider = _Provider;
|
6540
|
-
_cacheInputs = new WeakSet();
|
6541
|
-
cacheInputs_fn = function(inputs, transactionId) {
|
6542
|
-
if (!this.cache) {
|
6543
|
-
return;
|
6544
|
-
}
|
6545
|
-
this.cache.set(transactionId, inputs);
|
6546
|
-
};
|
6547
|
-
/** @hidden */
|
6548
|
-
__publicField(Provider, "inflightFetchChainAndNodeInfoRequests", {});
|
6549
|
-
/** @hidden */
|
6550
|
-
__publicField(Provider, "chainInfoCache", {});
|
6551
|
-
/** @hidden */
|
6552
|
-
__publicField(Provider, "nodeInfoCache", {});
|
6553
|
-
/** @hidden */
|
6554
|
-
__publicField(Provider, "incompatibleNodeVersionMessage", "");
|
6555
6626
|
|
6556
6627
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6557
6628
|
import { ErrorCode as ErrorCode17, FuelError as FuelError21 } from "@fuel-ts/errors";
|
@@ -6567,10 +6638,19 @@ import { arrayify as arrayify15 } from "@fuel-ts/utils";
|
|
6567
6638
|
// src/test-utils/test-asset-id.ts
|
6568
6639
|
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
6569
6640
|
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
6570
|
-
var
|
6641
|
+
var TestAssetId = class _TestAssetId {
|
6571
6642
|
constructor(value) {
|
6572
6643
|
this.value = value;
|
6573
6644
|
}
|
6645
|
+
static {
|
6646
|
+
__name(this, "TestAssetId");
|
6647
|
+
}
|
6648
|
+
static A = new _TestAssetId(
|
6649
|
+
"0x0101010101010101010101010101010101010101010101010101010101010101"
|
6650
|
+
);
|
6651
|
+
static B = new _TestAssetId(
|
6652
|
+
"0x0202020202020202020202020202020202020202020202020202020202020202"
|
6653
|
+
);
|
6574
6654
|
static random(count = 1) {
|
6575
6655
|
const assetIds = [];
|
6576
6656
|
for (let i = 0; i < count; i++) {
|
@@ -6579,13 +6659,6 @@ var _TestAssetId = class {
|
|
6579
6659
|
return assetIds;
|
6580
6660
|
}
|
6581
6661
|
};
|
6582
|
-
var TestAssetId = _TestAssetId;
|
6583
|
-
__publicField(TestAssetId, "A", new _TestAssetId(
|
6584
|
-
"0x0101010101010101010101010101010101010101010101010101010101010101"
|
6585
|
-
));
|
6586
|
-
__publicField(TestAssetId, "B", new _TestAssetId(
|
6587
|
-
"0x0202020202020202020202020202020202020202020202020202020202020202"
|
6588
|
-
));
|
6589
6662
|
|
6590
6663
|
// src/test-utils/wallet-config.ts
|
6591
6664
|
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
@@ -6608,7 +6681,7 @@ import { arrayify as arrayify17, hexlify as hexlify20, isDefined as isDefined3 }
|
|
6608
6681
|
import { clone as clone9 } from "ramda";
|
6609
6682
|
|
6610
6683
|
// src/providers/utils/merge-quantities.ts
|
6611
|
-
var mergeQuantities = (...coinQuantities) => {
|
6684
|
+
var mergeQuantities = /* @__PURE__ */ __name((...coinQuantities) => {
|
6612
6685
|
const resultMap = {};
|
6613
6686
|
function addToMap({ amount, assetId }) {
|
6614
6687
|
if (resultMap[assetId]) {
|
@@ -6617,12 +6690,16 @@ var mergeQuantities = (...coinQuantities) => {
|
|
6617
6690
|
resultMap[assetId] = amount;
|
6618
6691
|
}
|
6619
6692
|
}
|
6693
|
+
__name(addToMap, "addToMap");
|
6620
6694
|
coinQuantities.forEach((arr) => arr.forEach(addToMap));
|
6621
6695
|
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
6622
|
-
};
|
6696
|
+
}, "mergeQuantities");
|
6623
6697
|
|
6624
6698
|
// src/types.ts
|
6625
6699
|
var AbstractAccount = class {
|
6700
|
+
static {
|
6701
|
+
__name(this, "AbstractAccount");
|
6702
|
+
}
|
6626
6703
|
};
|
6627
6704
|
|
6628
6705
|
// src/utils/formatTransferToContractScriptData.ts
|
@@ -6630,7 +6707,7 @@ import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_
|
|
6630
6707
|
import { Address as Address4 } from "@fuel-ts/address";
|
6631
6708
|
import { arrayify as arrayify16, concat as concat4 } from "@fuel-ts/utils";
|
6632
6709
|
import * as asm from "@fuels/vm-asm";
|
6633
|
-
var formatTransferToContractScriptData = (transferParams) => {
|
6710
|
+
var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
|
6634
6711
|
const numberCoder = new BigNumberCoder2("u64");
|
6635
6712
|
return transferParams.reduce((acc, transferParam) => {
|
6636
6713
|
const { assetId, amount, contractId } = transferParam;
|
@@ -6638,8 +6715,8 @@ var formatTransferToContractScriptData = (transferParams) => {
|
|
6638
6715
|
const scriptData = concat4([new Address4(contractId).toBytes(), encoded, arrayify16(assetId)]);
|
6639
6716
|
return concat4([acc, scriptData]);
|
6640
6717
|
}, new Uint8Array());
|
6641
|
-
};
|
6642
|
-
var assembleTransferToContractScript = async (transferParams) => {
|
6718
|
+
}, "formatTransferToContractScriptData");
|
6719
|
+
var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferParams) => {
|
6643
6720
|
const scriptData = formatTransferToContractScriptData(transferParams);
|
6644
6721
|
await asm.initWasm();
|
6645
6722
|
let script = new Uint8Array();
|
@@ -6663,11 +6740,14 @@ var assembleTransferToContractScript = async (transferParams) => {
|
|
6663
6740
|
});
|
6664
6741
|
script = concat4([script, asm.ret(1).to_bytes()]);
|
6665
6742
|
return { script, scriptData };
|
6666
|
-
};
|
6743
|
+
}, "assembleTransferToContractScript");
|
6667
6744
|
|
6668
6745
|
// src/account.ts
|
6669
6746
|
var MAX_FUNDING_ATTEMPTS = 5;
|
6670
6747
|
var Account = class extends AbstractAccount {
|
6748
|
+
static {
|
6749
|
+
__name(this, "Account");
|
6750
|
+
}
|
6671
6751
|
/**
|
6672
6752
|
* The address associated with the account.
|
6673
6753
|
*/
|
@@ -7051,7 +7131,7 @@ var Account = class extends AbstractAccount {
|
|
7051
7131
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
7052
7132
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
7053
7133
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn20("100000000000000000") }];
|
7054
|
-
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
7134
|
+
const findAssetInput = /* @__PURE__ */ __name((assetId) => txRequestClone.inputs.find((input) => {
|
7055
7135
|
if (input.type === InputType7.Coin) {
|
7056
7136
|
return input.assetId === assetId;
|
7057
7137
|
}
|
@@ -7059,8 +7139,8 @@ var Account = class extends AbstractAccount {
|
|
7059
7139
|
return baseAssetId === assetId;
|
7060
7140
|
}
|
7061
7141
|
return false;
|
7062
|
-
});
|
7063
|
-
const updateAssetInput = (assetId, quantity) => {
|
7142
|
+
}), "findAssetInput");
|
7143
|
+
const updateAssetInput = /* @__PURE__ */ __name((assetId, quantity) => {
|
7064
7144
|
const assetInput = findAssetInput(assetId);
|
7065
7145
|
const usedQuantity = quantity;
|
7066
7146
|
if (assetInput && "amount" in assetInput) {
|
@@ -7075,7 +7155,7 @@ var Account = class extends AbstractAccount {
|
|
7075
7155
|
])
|
7076
7156
|
);
|
7077
7157
|
}
|
7078
|
-
};
|
7158
|
+
}, "updateAssetInput");
|
7079
7159
|
mergeQuantities(requiredQuantities, transactionFeeForDryRun).forEach(
|
7080
7160
|
({ amount, assetId }) => updateAssetInput(assetId, amount)
|
7081
7161
|
);
|
@@ -7273,12 +7353,12 @@ var DEFAULT_KDF_PARAMS_R = 8;
|
|
7273
7353
|
var DEFAULT_KDF_PARAMS_P = 1;
|
7274
7354
|
var DEFAULT_KEY_SIZE = 32;
|
7275
7355
|
var DEFAULT_IV_SIZE = 16;
|
7276
|
-
var removeHexPrefix = (hexString) => {
|
7356
|
+
var removeHexPrefix = /* @__PURE__ */ __name((hexString) => {
|
7277
7357
|
if (/^0x/.test(hexString)) {
|
7278
7358
|
return hexString.slice(2);
|
7279
7359
|
}
|
7280
7360
|
return hexString;
|
7281
|
-
};
|
7361
|
+
}, "removeHexPrefix");
|
7282
7362
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
7283
7363
|
const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
|
7284
7364
|
const ownerAddress = new Address6(address);
|
@@ -7317,6 +7397,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
7317
7397
|
};
|
7318
7398
|
return JSON.stringify(keystore);
|
7319
7399
|
}
|
7400
|
+
__name(encryptKeystoreWallet, "encryptKeystoreWallet");
|
7320
7401
|
async function decryptKeystoreWallet(jsonWallet, password) {
|
7321
7402
|
const keystoreWallet = JSON.parse(jsonWallet);
|
7322
7403
|
const {
|
@@ -7352,9 +7433,17 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7352
7433
|
const privateKey = hexlify21(buffer);
|
7353
7434
|
return privateKey;
|
7354
7435
|
}
|
7436
|
+
__name(decryptKeystoreWallet, "decryptKeystoreWallet");
|
7355
7437
|
|
7356
7438
|
// src/wallet/base-wallet-unlocked.ts
|
7357
7439
|
var BaseWalletUnlocked = class extends Account {
|
7440
|
+
static {
|
7441
|
+
__name(this, "BaseWalletUnlocked");
|
7442
|
+
}
|
7443
|
+
/**
|
7444
|
+
* Default HDWallet path.
|
7445
|
+
*/
|
7446
|
+
static defaultPath = "m/44'/1179993420'/0'/0/0";
|
7358
7447
|
/**
|
7359
7448
|
* A function that returns the wallet's signer.
|
7360
7449
|
*/
|
@@ -7472,10 +7561,6 @@ var BaseWalletUnlocked = class extends Account {
|
|
7472
7561
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
7473
7562
|
}
|
7474
7563
|
};
|
7475
|
-
/**
|
7476
|
-
* Default HDWallet path.
|
7477
|
-
*/
|
7478
|
-
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
7479
7564
|
|
7480
7565
|
// src/hdwallet/hdwallet.ts
|
7481
7566
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
@@ -9549,21 +9634,25 @@ import { arrayify as arrayify18 } from "@fuel-ts/utils";
|
|
9549
9634
|
function getLowerMask(bits) {
|
9550
9635
|
return (1 << bits) - 1;
|
9551
9636
|
}
|
9637
|
+
__name(getLowerMask, "getLowerMask");
|
9552
9638
|
function getUpperMask(bits) {
|
9553
9639
|
return (1 << bits) - 1 << 8 - bits;
|
9554
9640
|
}
|
9641
|
+
__name(getUpperMask, "getUpperMask");
|
9555
9642
|
function getWords(mnemonic) {
|
9556
9643
|
if (!Array.isArray(mnemonic)) {
|
9557
9644
|
return mnemonic.split(/\s+/);
|
9558
9645
|
}
|
9559
9646
|
return mnemonic;
|
9560
9647
|
}
|
9648
|
+
__name(getWords, "getWords");
|
9561
9649
|
function getPhrase(mnemonic) {
|
9562
9650
|
if (Array.isArray(mnemonic)) {
|
9563
9651
|
return mnemonic.join(" ");
|
9564
9652
|
}
|
9565
9653
|
return mnemonic;
|
9566
9654
|
}
|
9655
|
+
__name(getPhrase, "getPhrase");
|
9567
9656
|
function entropyToMnemonicIndices(entropy) {
|
9568
9657
|
const indices = [0];
|
9569
9658
|
let remainingBits = 11;
|
@@ -9585,6 +9674,7 @@ function entropyToMnemonicIndices(entropy) {
|
|
9585
9674
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
9586
9675
|
return indices;
|
9587
9676
|
}
|
9677
|
+
__name(entropyToMnemonicIndices, "entropyToMnemonicIndices");
|
9588
9678
|
function mnemonicWordsToEntropy(words, wordlist) {
|
9589
9679
|
const size = Math.ceil(11 * words.length / 8);
|
9590
9680
|
const entropy = arrayify18(new Uint8Array(size));
|
@@ -9616,6 +9706,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9616
9706
|
}
|
9617
9707
|
return entropy.slice(0, entropyBits / 8);
|
9618
9708
|
}
|
9709
|
+
__name(mnemonicWordsToEntropy, "mnemonicWordsToEntropy");
|
9619
9710
|
|
9620
9711
|
// src/mnemonic/mnemonic.ts
|
9621
9712
|
var MasterSecret = toUtf8Bytes("Bitcoin seed");
|
@@ -9630,6 +9721,7 @@ function assertWordList(wordlist) {
|
|
9630
9721
|
);
|
9631
9722
|
}
|
9632
9723
|
}
|
9724
|
+
__name(assertWordList, "assertWordList");
|
9633
9725
|
function assertEntropy(entropy) {
|
9634
9726
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9635
9727
|
throw new FuelError25(
|
@@ -9638,6 +9730,7 @@ function assertEntropy(entropy) {
|
|
9638
9730
|
);
|
9639
9731
|
}
|
9640
9732
|
}
|
9733
|
+
__name(assertEntropy, "assertEntropy");
|
9641
9734
|
function assertMnemonic(words) {
|
9642
9735
|
if (!MNEMONIC_SIZES.includes(words.length)) {
|
9643
9736
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
@@ -9646,7 +9739,11 @@ function assertMnemonic(words) {
|
|
9646
9739
|
throw new FuelError25(ErrorCode21.INVALID_MNEMONIC, errorMsg);
|
9647
9740
|
}
|
9648
9741
|
}
|
9649
|
-
|
9742
|
+
__name(assertMnemonic, "assertMnemonic");
|
9743
|
+
var Mnemonic = class _Mnemonic {
|
9744
|
+
static {
|
9745
|
+
__name(this, "Mnemonic");
|
9746
|
+
}
|
9650
9747
|
wordlist;
|
9651
9748
|
/**
|
9652
9749
|
*
|
@@ -9663,7 +9760,7 @@ var Mnemonic = class {
|
|
9663
9760
|
* @returns Entropy hash
|
9664
9761
|
*/
|
9665
9762
|
mnemonicToEntropy(phrase) {
|
9666
|
-
return
|
9763
|
+
return _Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
|
9667
9764
|
}
|
9668
9765
|
/**
|
9669
9766
|
*
|
@@ -9671,7 +9768,7 @@ var Mnemonic = class {
|
|
9671
9768
|
* @returns Mnemonic phrase
|
9672
9769
|
*/
|
9673
9770
|
entropyToMnemonic(entropy) {
|
9674
|
-
return
|
9771
|
+
return _Mnemonic.entropyToMnemonic(entropy, this.wordlist);
|
9675
9772
|
}
|
9676
9773
|
/**
|
9677
9774
|
*
|
@@ -9712,8 +9809,8 @@ var Mnemonic = class {
|
|
9712
9809
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9713
9810
|
*/
|
9714
9811
|
static mnemonicToMasterKeys(phrase, passphrase = "") {
|
9715
|
-
const seed =
|
9716
|
-
return
|
9812
|
+
const seed = _Mnemonic.mnemonicToSeed(phrase, passphrase);
|
9813
|
+
return _Mnemonic.masterKeysFromSeed(seed);
|
9717
9814
|
}
|
9718
9815
|
/**
|
9719
9816
|
* Validates if given mnemonic is valid
|
@@ -9729,7 +9826,7 @@ var Mnemonic = class {
|
|
9729
9826
|
return false;
|
9730
9827
|
}
|
9731
9828
|
while (i < words.length) {
|
9732
|
-
if (
|
9829
|
+
if (_Mnemonic.binarySearch(words[i]) === false) {
|
9733
9830
|
return false;
|
9734
9831
|
}
|
9735
9832
|
i += 1;
|
@@ -9776,7 +9873,7 @@ var Mnemonic = class {
|
|
9776
9873
|
* @returns BIP-32 extended private key
|
9777
9874
|
*/
|
9778
9875
|
static seedToExtendedKey(seed, testnet = false) {
|
9779
|
-
const masterKey =
|
9876
|
+
const masterKey = _Mnemonic.masterKeysFromSeed(seed);
|
9780
9877
|
const prefix = arrayify19(testnet ? TestnetPRV : MainnetPRV);
|
9781
9878
|
const depth = "0x00";
|
9782
9879
|
const fingerprint = "0x00000000";
|
@@ -9808,7 +9905,7 @@ var Mnemonic = class {
|
|
9808
9905
|
*/
|
9809
9906
|
static generate(size = 32, extraEntropy = "") {
|
9810
9907
|
const entropy = extraEntropy ? sha2563(concat5([randomBytes7(size), arrayify19(extraEntropy)])) : randomBytes7(size);
|
9811
|
-
return
|
9908
|
+
return _Mnemonic.entropyToMnemonic(entropy);
|
9812
9909
|
}
|
9813
9910
|
};
|
9814
9911
|
var mnemonic_default = Mnemonic;
|
@@ -9822,20 +9919,24 @@ var TestnetPUB = hexlify24("0x043587cf");
|
|
9822
9919
|
function base58check(data) {
|
9823
9920
|
return encodeBase582(concat6([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
9824
9921
|
}
|
9922
|
+
__name(base58check, "base58check");
|
9825
9923
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
9826
9924
|
if (isPublic) {
|
9827
9925
|
return testnet ? TestnetPUB : MainnetPUB;
|
9828
9926
|
}
|
9829
9927
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
9830
9928
|
}
|
9929
|
+
__name(getExtendedKeyPrefix, "getExtendedKeyPrefix");
|
9831
9930
|
function isPublicExtendedKey(extendedKey) {
|
9832
9931
|
return [MainnetPUB, TestnetPUB].includes(hexlify24(extendedKey.slice(0, 4)));
|
9833
9932
|
}
|
9933
|
+
__name(isPublicExtendedKey, "isPublicExtendedKey");
|
9834
9934
|
function isValidExtendedKey(extendedKey) {
|
9835
9935
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
9836
9936
|
hexlify24(extendedKey.slice(0, 4))
|
9837
9937
|
);
|
9838
9938
|
}
|
9939
|
+
__name(isValidExtendedKey, "isValidExtendedKey");
|
9839
9940
|
function parsePath(path2, depth = 0) {
|
9840
9941
|
const components = path2.split("/");
|
9841
9942
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
@@ -9848,7 +9949,11 @@ function parsePath(path2, depth = 0) {
|
|
9848
9949
|
(p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
|
9849
9950
|
);
|
9850
9951
|
}
|
9851
|
-
|
9952
|
+
__name(parsePath, "parsePath");
|
9953
|
+
var HDWallet = class _HDWallet {
|
9954
|
+
static {
|
9955
|
+
__name(this, "HDWallet");
|
9956
|
+
}
|
9852
9957
|
depth = 0;
|
9853
9958
|
index = 0;
|
9854
9959
|
fingerprint = hexlify24("0x00000000");
|
@@ -9914,7 +10019,7 @@ var HDWallet = class {
|
|
9914
10019
|
if (privateKey) {
|
9915
10020
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
9916
10021
|
const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
|
9917
|
-
return new
|
10022
|
+
return new _HDWallet({
|
9918
10023
|
privateKey: ki,
|
9919
10024
|
chainCode: IR,
|
9920
10025
|
index,
|
@@ -9924,7 +10029,7 @@ var HDWallet = class {
|
|
9924
10029
|
}
|
9925
10030
|
const signer = new Signer(hexlify24(IL));
|
9926
10031
|
const Ki = signer.addPoint(publicKey);
|
9927
|
-
return new
|
10032
|
+
return new _HDWallet({
|
9928
10033
|
publicKey: Ki,
|
9929
10034
|
chainCode: IR,
|
9930
10035
|
index,
|
@@ -9973,7 +10078,7 @@ var HDWallet = class {
|
|
9973
10078
|
*/
|
9974
10079
|
static fromSeed(seed) {
|
9975
10080
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
9976
|
-
return new
|
10081
|
+
return new _HDWallet({
|
9977
10082
|
chainCode: arrayify20(masterKey.slice(32)),
|
9978
10083
|
privateKey: arrayify20(masterKey.slice(0, 32))
|
9979
10084
|
});
|
@@ -10003,7 +10108,7 @@ var HDWallet = class {
|
|
10003
10108
|
if (key[0] !== 3) {
|
10004
10109
|
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Invalid public extended key.");
|
10005
10110
|
}
|
10006
|
-
return new
|
10111
|
+
return new _HDWallet({
|
10007
10112
|
publicKey: key,
|
10008
10113
|
chainCode,
|
10009
10114
|
index,
|
@@ -10014,7 +10119,7 @@ var HDWallet = class {
|
|
10014
10119
|
if (key[0] !== 0) {
|
10015
10120
|
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Invalid private extended key.");
|
10016
10121
|
}
|
10017
|
-
return new
|
10122
|
+
return new _HDWallet({
|
10018
10123
|
privateKey: key.slice(1),
|
10019
10124
|
chainCode,
|
10020
10125
|
index,
|
@@ -10027,6 +10132,9 @@ var hdwallet_default = HDWallet;
|
|
10027
10132
|
|
10028
10133
|
// src/wallet/wallets.ts
|
10029
10134
|
var WalletLocked = class extends Account {
|
10135
|
+
static {
|
10136
|
+
__name(this, "WalletLocked");
|
10137
|
+
}
|
10030
10138
|
/**
|
10031
10139
|
* Unlocks the wallet using the provided private key and returns an instance of WalletUnlocked.
|
10032
10140
|
*
|
@@ -10037,7 +10145,10 @@ var WalletLocked = class extends Account {
|
|
10037
10145
|
return new WalletUnlocked(privateKey, this._provider);
|
10038
10146
|
}
|
10039
10147
|
};
|
10040
|
-
var WalletUnlocked = class extends BaseWalletUnlocked {
|
10148
|
+
var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
10149
|
+
static {
|
10150
|
+
__name(this, "WalletUnlocked");
|
10151
|
+
}
|
10041
10152
|
/**
|
10042
10153
|
* Locks the wallet and returns an instance of WalletLocked.
|
10043
10154
|
*
|
@@ -10055,7 +10166,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10055
10166
|
*/
|
10056
10167
|
static generate(generateOptions) {
|
10057
10168
|
const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
|
10058
|
-
return new
|
10169
|
+
return new _WalletUnlocked(privateKey, generateOptions?.provider);
|
10059
10170
|
}
|
10060
10171
|
/**
|
10061
10172
|
* Create a Wallet Unlocked from a seed.
|
@@ -10067,8 +10178,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10067
10178
|
*/
|
10068
10179
|
static fromSeed(seed, path2, provider) {
|
10069
10180
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
10070
|
-
const childWallet = hdWallet.derivePath(path2 ||
|
10071
|
-
return new
|
10181
|
+
const childWallet = hdWallet.derivePath(path2 || _WalletUnlocked.defaultPath);
|
10182
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
10072
10183
|
}
|
10073
10184
|
/**
|
10074
10185
|
* Create a Wallet Unlocked from a mnemonic phrase.
|
@@ -10082,8 +10193,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10082
10193
|
static fromMnemonic(mnemonic, path2, passphrase, provider) {
|
10083
10194
|
const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
|
10084
10195
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
10085
|
-
const childWallet = hdWallet.derivePath(path2 ||
|
10086
|
-
return new
|
10196
|
+
const childWallet = hdWallet.derivePath(path2 || _WalletUnlocked.defaultPath);
|
10197
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
10087
10198
|
}
|
10088
10199
|
/**
|
10089
10200
|
* Create a Wallet Unlocked from an extended key.
|
@@ -10094,7 +10205,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10094
10205
|
*/
|
10095
10206
|
static fromExtendedKey(extendedKey, provider) {
|
10096
10207
|
const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
|
10097
|
-
return new
|
10208
|
+
return new _WalletUnlocked(hdWallet.privateKey, provider);
|
10098
10209
|
}
|
10099
10210
|
/**
|
10100
10211
|
* Create a Wallet Unlocked from an encrypted JSON.
|
@@ -10106,12 +10217,15 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
10106
10217
|
*/
|
10107
10218
|
static async fromEncryptedJson(jsonWallet, password, provider) {
|
10108
10219
|
const privateKey = await decryptKeystoreWallet(jsonWallet, password);
|
10109
|
-
return new
|
10220
|
+
return new _WalletUnlocked(privateKey, provider);
|
10110
10221
|
}
|
10111
10222
|
};
|
10112
10223
|
|
10113
10224
|
// src/wallet/wallet.ts
|
10114
10225
|
var Wallet = class {
|
10226
|
+
static {
|
10227
|
+
__name(this, "Wallet");
|
10228
|
+
}
|
10115
10229
|
/**
|
10116
10230
|
* Creates a locked wallet instance from an address and a provider.
|
10117
10231
|
*
|
@@ -10132,71 +10246,74 @@ var Wallet = class {
|
|
10132
10246
|
static fromPrivateKey(privateKey, provider) {
|
10133
10247
|
return new WalletUnlocked(privateKey, provider);
|
10134
10248
|
}
|
10249
|
+
/**
|
10250
|
+
* Generate a new Wallet Unlocked with a random key pair.
|
10251
|
+
*
|
10252
|
+
* @param generateOptions - Options to customize the generation process (optional).
|
10253
|
+
* @returns An unlocked wallet instance.
|
10254
|
+
*/
|
10255
|
+
static generate = WalletUnlocked.generate;
|
10256
|
+
/**
|
10257
|
+
* Create a Wallet Unlocked from a seed.
|
10258
|
+
*
|
10259
|
+
* @param seed - The seed phrase.
|
10260
|
+
* @param provider - A Provider instance (optional).
|
10261
|
+
* @param path - The derivation path (optional).
|
10262
|
+
* @returns An unlocked wallet instance.
|
10263
|
+
*/
|
10264
|
+
static fromSeed = WalletUnlocked.fromSeed;
|
10265
|
+
/**
|
10266
|
+
* Create a Wallet Unlocked from a mnemonic phrase.
|
10267
|
+
*
|
10268
|
+
* @param mnemonic - The mnemonic phrase.
|
10269
|
+
* @param provider - A Provider instance (optional).
|
10270
|
+
* @param path - The derivation path (optional).
|
10271
|
+
* @param passphrase - The passphrase for the mnemonic (optional).
|
10272
|
+
* @returns An unlocked wallet instance.
|
10273
|
+
*/
|
10274
|
+
static fromMnemonic = WalletUnlocked.fromMnemonic;
|
10275
|
+
/**
|
10276
|
+
* Create a Wallet Unlocked from an extended key.
|
10277
|
+
*
|
10278
|
+
* @param extendedKey - The extended key.
|
10279
|
+
* @param provider - A Provider instance (optional).
|
10280
|
+
* @returns An unlocked wallet instance.
|
10281
|
+
*/
|
10282
|
+
static fromExtendedKey = WalletUnlocked.fromExtendedKey;
|
10283
|
+
/**
|
10284
|
+
* Create a Wallet Unlocked from an encrypted JSON.
|
10285
|
+
*
|
10286
|
+
* @param jsonWallet - The encrypted JSON keystore.
|
10287
|
+
* @param password - The password to decrypt the JSON.
|
10288
|
+
* @param provider - A Provider instance (optional).
|
10289
|
+
* @returns An unlocked wallet instance.
|
10290
|
+
*/
|
10291
|
+
static fromEncryptedJson = WalletUnlocked.fromEncryptedJson;
|
10135
10292
|
};
|
10136
|
-
/**
|
10137
|
-
* Generate a new Wallet Unlocked with a random key pair.
|
10138
|
-
*
|
10139
|
-
* @param generateOptions - Options to customize the generation process (optional).
|
10140
|
-
* @returns An unlocked wallet instance.
|
10141
|
-
*/
|
10142
|
-
__publicField(Wallet, "generate", WalletUnlocked.generate);
|
10143
|
-
/**
|
10144
|
-
* Create a Wallet Unlocked from a seed.
|
10145
|
-
*
|
10146
|
-
* @param seed - The seed phrase.
|
10147
|
-
* @param provider - A Provider instance (optional).
|
10148
|
-
* @param path - The derivation path (optional).
|
10149
|
-
* @returns An unlocked wallet instance.
|
10150
|
-
*/
|
10151
|
-
__publicField(Wallet, "fromSeed", WalletUnlocked.fromSeed);
|
10152
|
-
/**
|
10153
|
-
* Create a Wallet Unlocked from a mnemonic phrase.
|
10154
|
-
*
|
10155
|
-
* @param mnemonic - The mnemonic phrase.
|
10156
|
-
* @param provider - A Provider instance (optional).
|
10157
|
-
* @param path - The derivation path (optional).
|
10158
|
-
* @param passphrase - The passphrase for the mnemonic (optional).
|
10159
|
-
* @returns An unlocked wallet instance.
|
10160
|
-
*/
|
10161
|
-
__publicField(Wallet, "fromMnemonic", WalletUnlocked.fromMnemonic);
|
10162
|
-
/**
|
10163
|
-
* Create a Wallet Unlocked from an extended key.
|
10164
|
-
*
|
10165
|
-
* @param extendedKey - The extended key.
|
10166
|
-
* @param provider - A Provider instance (optional).
|
10167
|
-
* @returns An unlocked wallet instance.
|
10168
|
-
*/
|
10169
|
-
__publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
10170
|
-
/**
|
10171
|
-
* Create a Wallet Unlocked from an encrypted JSON.
|
10172
|
-
*
|
10173
|
-
* @param jsonWallet - The encrypted JSON keystore.
|
10174
|
-
* @param password - The password to decrypt the JSON.
|
10175
|
-
* @param provider - A Provider instance (optional).
|
10176
|
-
* @returns An unlocked wallet instance.
|
10177
|
-
*/
|
10178
|
-
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
10179
10293
|
|
10180
10294
|
// src/test-utils/wallet-config.ts
|
10181
|
-
var WalletsConfig = class {
|
10295
|
+
var WalletsConfig = class _WalletsConfig {
|
10296
|
+
static {
|
10297
|
+
__name(this, "WalletsConfig");
|
10298
|
+
}
|
10182
10299
|
initialState;
|
10183
10300
|
options;
|
10184
10301
|
wallets;
|
10185
|
-
generateWallets = () => {
|
10302
|
+
generateWallets = /* @__PURE__ */ __name(() => {
|
10186
10303
|
const generatedWallets = [];
|
10187
10304
|
for (let index = 1; index <= this.options.count; index++) {
|
10188
10305
|
generatedWallets.push(new WalletUnlocked(randomBytes8(32)));
|
10189
10306
|
}
|
10190
10307
|
return generatedWallets;
|
10191
|
-
};
|
10308
|
+
}, "generateWallets");
|
10192
10309
|
constructor(baseAssetId, config) {
|
10193
|
-
|
10310
|
+
_WalletsConfig.validate(config);
|
10194
10311
|
this.options = config;
|
10195
10312
|
const { assets, coinsPerAsset, amountPerCoin, messages } = this.options;
|
10196
10313
|
this.wallets = this.generateWallets();
|
10197
10314
|
this.initialState = {
|
10198
|
-
messages:
|
10199
|
-
coins:
|
10315
|
+
messages: _WalletsConfig.createMessages(this.wallets, messages),
|
10316
|
+
coins: _WalletsConfig.createCoins(
|
10200
10317
|
this.wallets,
|
10201
10318
|
baseAssetId,
|
10202
10319
|
assets,
|
@@ -10318,9 +10435,9 @@ async function setupTestProviderAndWallets({
|
|
10318
10435
|
if (launchNodeServerPort) {
|
10319
10436
|
const serverUrl = `http://localhost:${launchNodeServerPort}`;
|
10320
10437
|
url = await (await fetch(serverUrl, { method: "POST", body: JSON.stringify(launchNodeOptions) })).text();
|
10321
|
-
cleanup = () => {
|
10438
|
+
cleanup = /* @__PURE__ */ __name(() => {
|
10322
10439
|
fetch(`${serverUrl}/cleanup/${url}`);
|
10323
|
-
};
|
10440
|
+
}, "cleanup");
|
10324
10441
|
} else {
|
10325
10442
|
const settings = await launchNode(launchNodeOptions);
|
10326
10443
|
url = settings.url;
|
@@ -10345,6 +10462,7 @@ async function setupTestProviderAndWallets({
|
|
10345
10462
|
[Symbol.dispose]: cleanup
|
10346
10463
|
};
|
10347
10464
|
}
|
10465
|
+
__name(setupTestProviderAndWallets, "setupTestProviderAndWallets");
|
10348
10466
|
|
10349
10467
|
// src/test-utils/test-message.ts
|
10350
10468
|
import { Address as Address7 } from "@fuel-ts/address";
|
@@ -10352,6 +10470,9 @@ import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
|
|
10352
10470
|
import { bn as bn23 } from "@fuel-ts/math";
|
10353
10471
|
import { hexlify as hexlify26 } from "@fuel-ts/utils";
|
10354
10472
|
var TestMessage = class {
|
10473
|
+
static {
|
10474
|
+
__name(this, "TestMessage");
|
10475
|
+
}
|
10355
10476
|
sender;
|
10356
10477
|
recipient;
|
10357
10478
|
nonce;
|