@fuel-ts/account 0.0.0-rc-1895-20240404023124 → 0.0.0-rc-1832-20240404064601
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.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/index.global.js +84 -177
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +468 -551
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +240 -328
- package/dist/index.mjs.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +0 -1
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils.global.js +84 -177
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +434 -511
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +213 -298
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/providers/utils/extract-tx-error.d.ts +0 -36
- package/dist/providers/utils/extract-tx-error.d.ts.map +0 -1
package/dist/test-utils.js
CHANGED
@@ -58,15 +58,15 @@ module.exports = __toCommonJS(test_utils_exports);
|
|
58
58
|
|
59
59
|
// src/wallet/base-wallet-unlocked.ts
|
60
60
|
var import_hasher3 = require("@fuel-ts/hasher");
|
61
|
-
var
|
61
|
+
var import_utils30 = require("@fuel-ts/utils");
|
62
62
|
|
63
63
|
// src/account.ts
|
64
64
|
var import_address4 = require("@fuel-ts/address");
|
65
|
-
var
|
66
|
-
var
|
65
|
+
var import_configs11 = require("@fuel-ts/address/configs");
|
66
|
+
var import_errors15 = require("@fuel-ts/errors");
|
67
67
|
var import_interfaces = require("@fuel-ts/interfaces");
|
68
|
-
var
|
69
|
-
var
|
68
|
+
var import_math17 = require("@fuel-ts/math");
|
69
|
+
var import_utils27 = require("@fuel-ts/utils");
|
70
70
|
|
71
71
|
// src/providers/coin-quantity.ts
|
72
72
|
var import_configs = require("@fuel-ts/address/configs");
|
@@ -106,12 +106,12 @@ var addAmountToAsset = (params) => {
|
|
106
106
|
|
107
107
|
// src/providers/provider.ts
|
108
108
|
var import_address3 = require("@fuel-ts/address");
|
109
|
-
var
|
110
|
-
var
|
111
|
-
var
|
112
|
-
var
|
109
|
+
var import_errors13 = require("@fuel-ts/errors");
|
110
|
+
var import_math14 = require("@fuel-ts/math");
|
111
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
112
|
+
var import_utils22 = require("@fuel-ts/utils");
|
113
113
|
var import_versions = require("@fuel-ts/versions");
|
114
|
-
var
|
114
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
115
115
|
var import_ethers = require("ethers");
|
116
116
|
var import_graphql_request = require("graphql-request");
|
117
117
|
var import_ramda3 = require("ramda");
|
@@ -1184,9 +1184,9 @@ var outputify = (value) => {
|
|
1184
1184
|
|
1185
1185
|
// src/providers/transaction-request/transaction-request.ts
|
1186
1186
|
var import_address = require("@fuel-ts/address");
|
1187
|
-
var
|
1188
|
-
var
|
1189
|
-
var
|
1187
|
+
var import_configs6 = require("@fuel-ts/address/configs");
|
1188
|
+
var import_math6 = require("@fuel-ts/math");
|
1189
|
+
var import_transactions5 = require("@fuel-ts/transactions");
|
1190
1190
|
var import_utils9 = require("@fuel-ts/utils");
|
1191
1191
|
|
1192
1192
|
// src/providers/resource.ts
|
@@ -1517,78 +1517,6 @@ function sleep(time) {
|
|
1517
1517
|
});
|
1518
1518
|
}
|
1519
1519
|
|
1520
|
-
// src/providers/utils/extract-tx-error.ts
|
1521
|
-
var import_errors7 = require("@fuel-ts/errors");
|
1522
|
-
var import_math6 = require("@fuel-ts/math");
|
1523
|
-
var import_transactions5 = require("@fuel-ts/transactions");
|
1524
|
-
var import_configs6 = require("@fuel-ts/transactions/configs");
|
1525
|
-
var assemblePanicError = (status) => {
|
1526
|
-
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
1527
|
-
const reason = status.reason;
|
1528
|
-
if (import_configs6.PANIC_REASONS.includes(status.reason)) {
|
1529
|
-
errorMessage = `${errorMessage}
|
1530
|
-
|
1531
|
-
You can read more about this error at:
|
1532
|
-
|
1533
|
-
${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
|
1534
|
-
}
|
1535
|
-
return { errorMessage, reason };
|
1536
|
-
};
|
1537
|
-
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
1538
|
-
var assembleRevertError = (receipts, logs) => {
|
1539
|
-
let errorMessage = "The transaction reverted with an unknown reason.";
|
1540
|
-
const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
|
1541
|
-
let reason = "";
|
1542
|
-
if (revertReceipt) {
|
1543
|
-
const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
|
1544
|
-
switch (reasonHex) {
|
1545
|
-
case import_configs6.FAILED_REQUIRE_SIGNAL: {
|
1546
|
-
reason = "require";
|
1547
|
-
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
|
1548
|
-
break;
|
1549
|
-
}
|
1550
|
-
case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
|
1551
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1552
|
-
reason = "assert_eq";
|
1553
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
1554
|
-
break;
|
1555
|
-
}
|
1556
|
-
case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
|
1557
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1558
|
-
reason = "assert_ne";
|
1559
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
1560
|
-
break;
|
1561
|
-
}
|
1562
|
-
case import_configs6.FAILED_ASSERT_SIGNAL:
|
1563
|
-
reason = "assert";
|
1564
|
-
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
1565
|
-
break;
|
1566
|
-
case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
1567
|
-
reason = "MissingOutputChange";
|
1568
|
-
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1569
|
-
break;
|
1570
|
-
default:
|
1571
|
-
reason = "unknown";
|
1572
|
-
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
1573
|
-
}
|
1574
|
-
}
|
1575
|
-
return { errorMessage, reason };
|
1576
|
-
};
|
1577
|
-
var extractTxError = (params) => {
|
1578
|
-
const { receipts, status, logs } = params;
|
1579
|
-
const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
|
1580
|
-
const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
|
1581
|
-
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
1582
|
-
const metadata = {
|
1583
|
-
logs,
|
1584
|
-
receipts,
|
1585
|
-
panic: isPanic,
|
1586
|
-
revert: isRevert,
|
1587
|
-
reason
|
1588
|
-
};
|
1589
|
-
return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
1590
|
-
};
|
1591
|
-
|
1592
1520
|
// src/providers/transaction-request/errors.ts
|
1593
1521
|
var NoWitnessAtIndexError = class extends Error {
|
1594
1522
|
constructor(index) {
|
@@ -1639,10 +1567,10 @@ var BaseTransactionRequest = class {
|
|
1639
1567
|
outputs,
|
1640
1568
|
witnesses
|
1641
1569
|
} = {}) {
|
1642
|
-
this.gasPrice = (0,
|
1570
|
+
this.gasPrice = (0, import_math6.bn)(gasPrice);
|
1643
1571
|
this.maturity = maturity ?? 0;
|
1644
|
-
this.witnessLimit = witnessLimit ? (0,
|
1645
|
-
this.maxFee = maxFee ? (0,
|
1572
|
+
this.witnessLimit = witnessLimit ? (0, import_math6.bn)(witnessLimit) : void 0;
|
1573
|
+
this.maxFee = maxFee ? (0, import_math6.bn)(maxFee) : void 0;
|
1646
1574
|
this.inputs = inputs ?? [];
|
1647
1575
|
this.outputs = outputs ?? [];
|
1648
1576
|
this.witnesses = witnesses ?? [];
|
@@ -1651,20 +1579,20 @@ var BaseTransactionRequest = class {
|
|
1651
1579
|
let policyTypes = 0;
|
1652
1580
|
const policies = [];
|
1653
1581
|
if (req.gasPrice) {
|
1654
|
-
policyTypes +=
|
1655
|
-
policies.push({ data: req.gasPrice, type:
|
1582
|
+
policyTypes += import_transactions5.PolicyType.GasPrice;
|
1583
|
+
policies.push({ data: req.gasPrice, type: import_transactions5.PolicyType.GasPrice });
|
1656
1584
|
}
|
1657
1585
|
if (req.witnessLimit) {
|
1658
|
-
policyTypes +=
|
1659
|
-
policies.push({ data: req.witnessLimit, type:
|
1586
|
+
policyTypes += import_transactions5.PolicyType.WitnessLimit;
|
1587
|
+
policies.push({ data: req.witnessLimit, type: import_transactions5.PolicyType.WitnessLimit });
|
1660
1588
|
}
|
1661
1589
|
if (req.maturity > 0) {
|
1662
|
-
policyTypes +=
|
1663
|
-
policies.push({ data: req.maturity, type:
|
1590
|
+
policyTypes += import_transactions5.PolicyType.Maturity;
|
1591
|
+
policies.push({ data: req.maturity, type: import_transactions5.PolicyType.Maturity });
|
1664
1592
|
}
|
1665
1593
|
if (req.maxFee) {
|
1666
|
-
policyTypes +=
|
1667
|
-
policies.push({ data: req.maxFee, type:
|
1594
|
+
policyTypes += import_transactions5.PolicyType.MaxFee;
|
1595
|
+
policies.push({ data: req.maxFee, type: import_transactions5.PolicyType.MaxFee });
|
1668
1596
|
}
|
1669
1597
|
return {
|
1670
1598
|
policyTypes,
|
@@ -1698,7 +1626,7 @@ var BaseTransactionRequest = class {
|
|
1698
1626
|
* @returns The transaction bytes.
|
1699
1627
|
*/
|
1700
1628
|
toTransactionBytes() {
|
1701
|
-
return new
|
1629
|
+
return new import_transactions5.TransactionCoder().encode(this.toTransaction());
|
1702
1630
|
}
|
1703
1631
|
/**
|
1704
1632
|
* @hidden
|
@@ -1738,7 +1666,7 @@ var BaseTransactionRequest = class {
|
|
1738
1666
|
* @returns The index of the created witness.
|
1739
1667
|
*/
|
1740
1668
|
addEmptyWitness() {
|
1741
|
-
this.addWitness((0, import_utils9.concat)([
|
1669
|
+
this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1742
1670
|
return this.witnesses.length - 1;
|
1743
1671
|
}
|
1744
1672
|
/**
|
@@ -1789,7 +1717,7 @@ var BaseTransactionRequest = class {
|
|
1789
1717
|
*/
|
1790
1718
|
getCoinInputs() {
|
1791
1719
|
return this.inputs.filter(
|
1792
|
-
(input) => input.type ===
|
1720
|
+
(input) => input.type === import_transactions5.InputType.Coin
|
1793
1721
|
);
|
1794
1722
|
}
|
1795
1723
|
/**
|
@@ -1799,7 +1727,7 @@ var BaseTransactionRequest = class {
|
|
1799
1727
|
*/
|
1800
1728
|
getCoinOutputs() {
|
1801
1729
|
return this.outputs.filter(
|
1802
|
-
(output) => output.type ===
|
1730
|
+
(output) => output.type === import_transactions5.OutputType.Coin
|
1803
1731
|
);
|
1804
1732
|
}
|
1805
1733
|
/**
|
@@ -1809,7 +1737,7 @@ var BaseTransactionRequest = class {
|
|
1809
1737
|
*/
|
1810
1738
|
getChangeOutputs() {
|
1811
1739
|
return this.outputs.filter(
|
1812
|
-
(output) => output.type ===
|
1740
|
+
(output) => output.type === import_transactions5.OutputType.Change
|
1813
1741
|
);
|
1814
1742
|
}
|
1815
1743
|
/**
|
@@ -1821,9 +1749,9 @@ var BaseTransactionRequest = class {
|
|
1821
1749
|
const ownerAddress = (0, import_address.addressify)(owner);
|
1822
1750
|
const found = this.inputs.find((input) => {
|
1823
1751
|
switch (input.type) {
|
1824
|
-
case
|
1752
|
+
case import_transactions5.InputType.Coin:
|
1825
1753
|
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
1826
|
-
case
|
1754
|
+
case import_transactions5.InputType.Message:
|
1827
1755
|
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
1828
1756
|
default:
|
1829
1757
|
return false;
|
@@ -1852,7 +1780,7 @@ var BaseTransactionRequest = class {
|
|
1852
1780
|
}
|
1853
1781
|
const input = {
|
1854
1782
|
...coin,
|
1855
|
-
type:
|
1783
|
+
type: import_transactions5.InputType.Coin,
|
1856
1784
|
owner: owner.toB256(),
|
1857
1785
|
amount,
|
1858
1786
|
assetId,
|
@@ -1874,7 +1802,7 @@ var BaseTransactionRequest = class {
|
|
1874
1802
|
*/
|
1875
1803
|
addMessageInput(message, predicate) {
|
1876
1804
|
const { recipient, sender, amount } = message;
|
1877
|
-
const assetId =
|
1805
|
+
const assetId = import_configs6.BaseAssetId;
|
1878
1806
|
let witnessIndex;
|
1879
1807
|
if (predicate) {
|
1880
1808
|
witnessIndex = 0;
|
@@ -1886,7 +1814,7 @@ var BaseTransactionRequest = class {
|
|
1886
1814
|
}
|
1887
1815
|
const input = {
|
1888
1816
|
...message,
|
1889
|
-
type:
|
1817
|
+
type: import_transactions5.InputType.Message,
|
1890
1818
|
sender: sender.toB256(),
|
1891
1819
|
recipient: recipient.toB256(),
|
1892
1820
|
amount,
|
@@ -1956,9 +1884,9 @@ var BaseTransactionRequest = class {
|
|
1956
1884
|
* @param amount - Amount of coin.
|
1957
1885
|
* @param assetId - Asset ID of coin.
|
1958
1886
|
*/
|
1959
|
-
addCoinOutput(to, amount, assetId =
|
1887
|
+
addCoinOutput(to, amount, assetId = import_configs6.BaseAssetId) {
|
1960
1888
|
this.pushOutput({
|
1961
|
-
type:
|
1889
|
+
type: import_transactions5.OutputType.Coin,
|
1962
1890
|
to: (0, import_address.addressify)(to).toB256(),
|
1963
1891
|
amount,
|
1964
1892
|
assetId
|
@@ -1974,7 +1902,7 @@ var BaseTransactionRequest = class {
|
|
1974
1902
|
addCoinOutputs(to, quantities) {
|
1975
1903
|
quantities.map(coinQuantityfy).forEach((quantity) => {
|
1976
1904
|
this.pushOutput({
|
1977
|
-
type:
|
1905
|
+
type: import_transactions5.OutputType.Coin,
|
1978
1906
|
to: (0, import_address.addressify)(to).toB256(),
|
1979
1907
|
amount: quantity.amount,
|
1980
1908
|
assetId: quantity.assetId
|
@@ -1988,13 +1916,13 @@ var BaseTransactionRequest = class {
|
|
1988
1916
|
* @param to - Address of the owner.
|
1989
1917
|
* @param assetId - Asset ID of coin.
|
1990
1918
|
*/
|
1991
|
-
addChangeOutput(to, assetId =
|
1919
|
+
addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
|
1992
1920
|
const changeOutput = this.getChangeOutputs().find(
|
1993
1921
|
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
1994
1922
|
);
|
1995
1923
|
if (!changeOutput) {
|
1996
1924
|
this.pushOutput({
|
1997
|
-
type:
|
1925
|
+
type: import_transactions5.OutputType.Change,
|
1998
1926
|
to: (0, import_address.addressify)(to).toB256(),
|
1999
1927
|
assetId
|
2000
1928
|
});
|
@@ -2050,7 +1978,7 @@ var BaseTransactionRequest = class {
|
|
2050
1978
|
let idCounter = 0;
|
2051
1979
|
const generateId = () => {
|
2052
1980
|
const counterString = String(idCounter++);
|
2053
|
-
const id =
|
1981
|
+
const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
2054
1982
|
return id;
|
2055
1983
|
};
|
2056
1984
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
@@ -2072,13 +2000,13 @@ var BaseTransactionRequest = class {
|
|
2072
2000
|
assetId,
|
2073
2001
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2074
2002
|
maturity: 0,
|
2075
|
-
blockCreated: (0,
|
2076
|
-
txCreatedIdx: (0,
|
2003
|
+
blockCreated: (0, import_math6.bn)(1),
|
2004
|
+
txCreatedIdx: (0, import_math6.bn)(1)
|
2077
2005
|
}
|
2078
2006
|
]);
|
2079
2007
|
}
|
2080
2008
|
};
|
2081
|
-
updateAssetInput(
|
2009
|
+
updateAssetInput(import_configs6.BaseAssetId, (0, import_math6.bn)(1e11));
|
2082
2010
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2083
2011
|
}
|
2084
2012
|
/**
|
@@ -2089,7 +2017,7 @@ var BaseTransactionRequest = class {
|
|
2089
2017
|
*/
|
2090
2018
|
getCoinOutputsQuantities() {
|
2091
2019
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2092
|
-
amount: (0,
|
2020
|
+
amount: (0, import_math6.bn)(amount),
|
2093
2021
|
assetId: assetId.toString()
|
2094
2022
|
}));
|
2095
2023
|
return coinsQuantities;
|
@@ -2107,18 +2035,18 @@ var BaseTransactionRequest = class {
|
|
2107
2035
|
this.inputs.forEach((i) => {
|
2108
2036
|
let correspondingInput;
|
2109
2037
|
switch (i.type) {
|
2110
|
-
case
|
2111
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2038
|
+
case import_transactions5.InputType.Coin:
|
2039
|
+
correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
|
2112
2040
|
break;
|
2113
|
-
case
|
2041
|
+
case import_transactions5.InputType.Message:
|
2114
2042
|
correspondingInput = inputs.find(
|
2115
|
-
(x) => x.type ===
|
2043
|
+
(x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
|
2116
2044
|
);
|
2117
2045
|
break;
|
2118
2046
|
default:
|
2119
2047
|
return;
|
2120
2048
|
}
|
2121
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0,
|
2049
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2122
2050
|
i.predicate = correspondingInput.predicate;
|
2123
2051
|
i.predicateData = correspondingInput.predicateData;
|
2124
2052
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2128,47 +2056,47 @@ var BaseTransactionRequest = class {
|
|
2128
2056
|
};
|
2129
2057
|
|
2130
2058
|
// src/providers/transaction-request/create-transaction-request.ts
|
2131
|
-
var
|
2132
|
-
var
|
2133
|
-
var
|
2059
|
+
var import_configs8 = require("@fuel-ts/address/configs");
|
2060
|
+
var import_math8 = require("@fuel-ts/math");
|
2061
|
+
var import_transactions7 = require("@fuel-ts/transactions");
|
2134
2062
|
var import_utils13 = require("@fuel-ts/utils");
|
2135
2063
|
|
2136
2064
|
// src/providers/transaction-request/hash-transaction.ts
|
2137
|
-
var
|
2065
|
+
var import_configs7 = require("@fuel-ts/address/configs");
|
2138
2066
|
var import_hasher = require("@fuel-ts/hasher");
|
2139
|
-
var
|
2140
|
-
var
|
2067
|
+
var import_math7 = require("@fuel-ts/math");
|
2068
|
+
var import_transactions6 = require("@fuel-ts/transactions");
|
2141
2069
|
var import_utils11 = require("@fuel-ts/utils");
|
2142
2070
|
var import_ramda2 = require("ramda");
|
2143
2071
|
function hashTransaction(transactionRequest, chainId) {
|
2144
2072
|
const transaction = transactionRequest.toTransaction();
|
2145
|
-
if (transaction.type ===
|
2146
|
-
transaction.receiptsRoot =
|
2073
|
+
if (transaction.type === import_transactions6.TransactionType.Script) {
|
2074
|
+
transaction.receiptsRoot = import_configs7.ZeroBytes32;
|
2147
2075
|
}
|
2148
2076
|
transaction.inputs = transaction.inputs.map((input) => {
|
2149
2077
|
const inputClone = (0, import_ramda2.clone)(input);
|
2150
2078
|
switch (inputClone.type) {
|
2151
|
-
case
|
2079
|
+
case import_transactions6.InputType.Coin: {
|
2152
2080
|
inputClone.txPointer = {
|
2153
2081
|
blockHeight: 0,
|
2154
2082
|
txIndex: 0
|
2155
2083
|
};
|
2156
|
-
inputClone.predicateGasUsed = (0,
|
2084
|
+
inputClone.predicateGasUsed = (0, import_math7.bn)(0);
|
2157
2085
|
return inputClone;
|
2158
2086
|
}
|
2159
|
-
case
|
2160
|
-
inputClone.predicateGasUsed = (0,
|
2087
|
+
case import_transactions6.InputType.Message: {
|
2088
|
+
inputClone.predicateGasUsed = (0, import_math7.bn)(0);
|
2161
2089
|
return inputClone;
|
2162
2090
|
}
|
2163
|
-
case
|
2091
|
+
case import_transactions6.InputType.Contract: {
|
2164
2092
|
inputClone.txPointer = {
|
2165
2093
|
blockHeight: 0,
|
2166
2094
|
txIndex: 0
|
2167
2095
|
};
|
2168
|
-
inputClone.txID =
|
2096
|
+
inputClone.txID = import_configs7.ZeroBytes32;
|
2169
2097
|
inputClone.outputIndex = 0;
|
2170
|
-
inputClone.balanceRoot =
|
2171
|
-
inputClone.stateRoot =
|
2098
|
+
inputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2099
|
+
inputClone.stateRoot = import_configs7.ZeroBytes32;
|
2172
2100
|
return inputClone;
|
2173
2101
|
}
|
2174
2102
|
default:
|
@@ -2178,19 +2106,19 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2178
2106
|
transaction.outputs = transaction.outputs.map((output) => {
|
2179
2107
|
const outputClone = (0, import_ramda2.clone)(output);
|
2180
2108
|
switch (outputClone.type) {
|
2181
|
-
case
|
2182
|
-
outputClone.balanceRoot =
|
2183
|
-
outputClone.stateRoot =
|
2109
|
+
case import_transactions6.OutputType.Contract: {
|
2110
|
+
outputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2111
|
+
outputClone.stateRoot = import_configs7.ZeroBytes32;
|
2184
2112
|
return outputClone;
|
2185
2113
|
}
|
2186
|
-
case
|
2187
|
-
outputClone.amount = (0,
|
2114
|
+
case import_transactions6.OutputType.Change: {
|
2115
|
+
outputClone.amount = (0, import_math7.bn)(0);
|
2188
2116
|
return outputClone;
|
2189
2117
|
}
|
2190
|
-
case
|
2191
|
-
outputClone.to =
|
2192
|
-
outputClone.amount = (0,
|
2193
|
-
outputClone.assetId =
|
2118
|
+
case import_transactions6.OutputType.Variable: {
|
2119
|
+
outputClone.to = import_configs7.ZeroBytes32;
|
2120
|
+
outputClone.amount = (0, import_math7.bn)(0);
|
2121
|
+
outputClone.assetId = import_configs7.ZeroBytes32;
|
2194
2122
|
return outputClone;
|
2195
2123
|
}
|
2196
2124
|
default:
|
@@ -2200,7 +2128,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2200
2128
|
transaction.witnessesCount = 0;
|
2201
2129
|
transaction.witnesses = [];
|
2202
2130
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2203
|
-
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new
|
2131
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
|
2204
2132
|
return (0, import_hasher.sha256)(concatenatedData);
|
2205
2133
|
}
|
2206
2134
|
|
@@ -2236,7 +2164,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2236
2164
|
return new this(obj);
|
2237
2165
|
}
|
2238
2166
|
/** Type of the transaction */
|
2239
|
-
type =
|
2167
|
+
type = import_transactions7.TransactionType.Create;
|
2240
2168
|
/** Witness index of contract bytecode to create */
|
2241
2169
|
bytecodeWitnessIndex;
|
2242
2170
|
/** Salt */
|
@@ -2256,7 +2184,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2256
2184
|
} = {}) {
|
2257
2185
|
super(rest);
|
2258
2186
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2259
|
-
this.salt = (0, import_utils13.hexlify)(salt ??
|
2187
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
|
2260
2188
|
this.storageSlots = [...storageSlots ?? []];
|
2261
2189
|
}
|
2262
2190
|
/**
|
@@ -2269,12 +2197,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2269
2197
|
const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
|
2270
2198
|
const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
|
2271
2199
|
return {
|
2272
|
-
type:
|
2200
|
+
type: import_transactions7.TransactionType.Create,
|
2273
2201
|
...baseTransaction,
|
2274
2202
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2275
2203
|
bytecodeWitnessIndex,
|
2276
2204
|
storageSlotsCount: storageSlots.length,
|
2277
|
-
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) :
|
2205
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2278
2206
|
storageSlots
|
2279
2207
|
};
|
2280
2208
|
}
|
@@ -2285,7 +2213,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2285
2213
|
*/
|
2286
2214
|
getContractCreatedOutputs() {
|
2287
2215
|
return this.outputs.filter(
|
2288
|
-
(output) => output.type ===
|
2216
|
+
(output) => output.type === import_transactions7.OutputType.ContractCreated
|
2289
2217
|
);
|
2290
2218
|
}
|
2291
2219
|
/**
|
@@ -2306,14 +2234,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2306
2234
|
*/
|
2307
2235
|
addContractCreatedOutput(contractId, stateRoot) {
|
2308
2236
|
this.pushOutput({
|
2309
|
-
type:
|
2237
|
+
type: import_transactions7.OutputType.ContractCreated,
|
2310
2238
|
contractId,
|
2311
2239
|
stateRoot
|
2312
2240
|
});
|
2313
2241
|
}
|
2314
2242
|
metadataGas(gasCosts) {
|
2315
2243
|
return calculateMetadataGasForTxCreate({
|
2316
|
-
contractBytesSize: (0,
|
2244
|
+
contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2317
2245
|
gasCosts,
|
2318
2246
|
stateRootSize: this.storageSlots.length,
|
2319
2247
|
txBytesSize: this.byteSize()
|
@@ -2324,9 +2252,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2324
2252
|
// src/providers/transaction-request/script-transaction-request.ts
|
2325
2253
|
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2326
2254
|
var import_address2 = require("@fuel-ts/address");
|
2327
|
-
var
|
2328
|
-
var
|
2329
|
-
var
|
2255
|
+
var import_configs9 = require("@fuel-ts/address/configs");
|
2256
|
+
var import_math9 = require("@fuel-ts/math");
|
2257
|
+
var import_transactions8 = require("@fuel-ts/transactions");
|
2330
2258
|
var import_utils15 = require("@fuel-ts/utils");
|
2331
2259
|
|
2332
2260
|
// src/providers/transaction-request/scripts.ts
|
@@ -2364,7 +2292,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2364
2292
|
return new this(obj);
|
2365
2293
|
}
|
2366
2294
|
/** Type of the transaction */
|
2367
|
-
type =
|
2295
|
+
type = import_transactions8.TransactionType.Script;
|
2368
2296
|
/** Gas limit for transaction */
|
2369
2297
|
gasLimit;
|
2370
2298
|
/** Script to execute */
|
@@ -2379,7 +2307,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2379
2307
|
*/
|
2380
2308
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2381
2309
|
super(rest);
|
2382
|
-
this.gasLimit = (0,
|
2310
|
+
this.gasLimit = (0, import_math9.bn)(gasLimit);
|
2383
2311
|
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2384
2312
|
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2385
2313
|
this.abis = rest.abis;
|
@@ -2393,12 +2321,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2393
2321
|
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2394
2322
|
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2395
2323
|
return {
|
2396
|
-
type:
|
2324
|
+
type: import_transactions8.TransactionType.Script,
|
2397
2325
|
scriptGasLimit: this.gasLimit,
|
2398
2326
|
...super.getBaseTransaction(),
|
2399
2327
|
scriptLength: script.length,
|
2400
2328
|
scriptDataLength: scriptData.length,
|
2401
|
-
receiptsRoot:
|
2329
|
+
receiptsRoot: import_configs9.ZeroBytes32,
|
2402
2330
|
script: (0, import_utils15.hexlify)(script),
|
2403
2331
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2404
2332
|
};
|
@@ -2410,7 +2338,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2410
2338
|
*/
|
2411
2339
|
getContractInputs() {
|
2412
2340
|
return this.inputs.filter(
|
2413
|
-
(input) => input.type ===
|
2341
|
+
(input) => input.type === import_transactions8.InputType.Contract
|
2414
2342
|
);
|
2415
2343
|
}
|
2416
2344
|
/**
|
@@ -2420,7 +2348,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2420
2348
|
*/
|
2421
2349
|
getContractOutputs() {
|
2422
2350
|
return this.outputs.filter(
|
2423
|
-
(output) => output.type ===
|
2351
|
+
(output) => output.type === import_transactions8.OutputType.Contract
|
2424
2352
|
);
|
2425
2353
|
}
|
2426
2354
|
/**
|
@@ -2430,7 +2358,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2430
2358
|
*/
|
2431
2359
|
getVariableOutputs() {
|
2432
2360
|
return this.outputs.filter(
|
2433
|
-
(output) => output.type ===
|
2361
|
+
(output) => output.type === import_transactions8.OutputType.Variable
|
2434
2362
|
);
|
2435
2363
|
}
|
2436
2364
|
/**
|
@@ -2453,7 +2381,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2453
2381
|
let outputsNumber = numberOfVariables;
|
2454
2382
|
while (outputsNumber) {
|
2455
2383
|
this.pushOutput({
|
2456
|
-
type:
|
2384
|
+
type: import_transactions8.OutputType.Variable
|
2457
2385
|
});
|
2458
2386
|
outputsNumber -= 1;
|
2459
2387
|
}
|
@@ -2486,12 +2414,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2486
2414
|
return this;
|
2487
2415
|
}
|
2488
2416
|
const inputIndex = super.pushInput({
|
2489
|
-
type:
|
2417
|
+
type: import_transactions8.InputType.Contract,
|
2490
2418
|
contractId: contractAddress.toB256(),
|
2491
2419
|
txPointer: "0x00000000000000000000000000000000"
|
2492
2420
|
});
|
2493
2421
|
this.pushOutput({
|
2494
|
-
type:
|
2422
|
+
type: import_transactions8.OutputType.Contract,
|
2495
2423
|
inputIndex
|
2496
2424
|
});
|
2497
2425
|
return this;
|
@@ -2527,38 +2455,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2527
2455
|
};
|
2528
2456
|
|
2529
2457
|
// src/providers/transaction-request/utils.ts
|
2530
|
-
var
|
2531
|
-
var
|
2458
|
+
var import_errors8 = require("@fuel-ts/errors");
|
2459
|
+
var import_transactions9 = require("@fuel-ts/transactions");
|
2532
2460
|
var transactionRequestify = (obj) => {
|
2533
2461
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2534
2462
|
return obj;
|
2535
2463
|
}
|
2536
2464
|
const { type } = obj;
|
2537
2465
|
switch (obj.type) {
|
2538
|
-
case
|
2466
|
+
case import_transactions9.TransactionType.Script: {
|
2539
2467
|
return ScriptTransactionRequest.from(obj);
|
2540
2468
|
}
|
2541
|
-
case
|
2469
|
+
case import_transactions9.TransactionType.Create: {
|
2542
2470
|
return CreateTransactionRequest.from(obj);
|
2543
2471
|
}
|
2544
2472
|
default: {
|
2545
|
-
throw new
|
2473
|
+
throw new import_errors8.FuelError(import_errors8.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
|
2546
2474
|
}
|
2547
2475
|
}
|
2548
2476
|
};
|
2549
2477
|
|
2550
2478
|
// src/providers/transaction-response/transaction-response.ts
|
2551
|
-
var
|
2552
|
-
var
|
2553
|
-
var
|
2479
|
+
var import_errors12 = require("@fuel-ts/errors");
|
2480
|
+
var import_math13 = require("@fuel-ts/math");
|
2481
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
2554
2482
|
var import_utils21 = require("@fuel-ts/utils");
|
2555
2483
|
|
2556
2484
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2557
2485
|
var import_utils19 = require("@fuel-ts/utils");
|
2558
2486
|
|
2559
2487
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2560
|
-
var
|
2561
|
-
var
|
2488
|
+
var import_math10 = require("@fuel-ts/math");
|
2489
|
+
var import_transactions10 = require("@fuel-ts/transactions");
|
2562
2490
|
var import_utils16 = require("@fuel-ts/utils");
|
2563
2491
|
var calculateTransactionFee = (params) => {
|
2564
2492
|
const {
|
@@ -2566,24 +2494,24 @@ var calculateTransactionFee = (params) => {
|
|
2566
2494
|
rawPayload,
|
2567
2495
|
consensusParameters: { gasCosts, feeParams }
|
2568
2496
|
} = params;
|
2569
|
-
const gasPerByte = (0,
|
2570
|
-
const gasPriceFactor = (0,
|
2497
|
+
const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
|
2498
|
+
const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
|
2571
2499
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2572
|
-
const [transaction] = new
|
2573
|
-
if (transaction.type ===
|
2500
|
+
const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
|
2501
|
+
if (transaction.type === import_transactions10.TransactionType.Mint) {
|
2574
2502
|
return {
|
2575
|
-
fee: (0,
|
2576
|
-
minFee: (0,
|
2577
|
-
maxFee: (0,
|
2578
|
-
feeFromGasUsed: (0,
|
2503
|
+
fee: (0, import_math10.bn)(0),
|
2504
|
+
minFee: (0, import_math10.bn)(0),
|
2505
|
+
maxFee: (0, import_math10.bn)(0),
|
2506
|
+
feeFromGasUsed: (0, import_math10.bn)(0)
|
2579
2507
|
};
|
2580
2508
|
}
|
2581
2509
|
const { type, witnesses, inputs, policies } = transaction;
|
2582
|
-
let metadataGas = (0,
|
2583
|
-
let gasLimit = (0,
|
2584
|
-
if (type ===
|
2510
|
+
let metadataGas = (0, import_math10.bn)(0);
|
2511
|
+
let gasLimit = (0, import_math10.bn)(0);
|
2512
|
+
if (type === import_transactions10.TransactionType.Create) {
|
2585
2513
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2586
|
-
const contractBytesSize = (0,
|
2514
|
+
const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2587
2515
|
metadataGas = calculateMetadataGasForTxCreate({
|
2588
2516
|
contractBytesSize,
|
2589
2517
|
gasCosts,
|
@@ -2602,13 +2530,13 @@ var calculateTransactionFee = (params) => {
|
|
2602
2530
|
}
|
2603
2531
|
const minGas = getMinGas({
|
2604
2532
|
gasCosts,
|
2605
|
-
gasPerByte: (0,
|
2533
|
+
gasPerByte: (0, import_math10.bn)(gasPerByte),
|
2606
2534
|
inputs,
|
2607
2535
|
metadataGas,
|
2608
2536
|
txBytesSize: transactionBytes.length
|
2609
2537
|
});
|
2610
|
-
const gasPrice = (0,
|
2611
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
2538
|
+
const gasPrice = (0, import_math10.bn)(policies.find((policy) => policy.type === import_transactions10.PolicyType.GasPrice)?.data);
|
2539
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions10.PolicyType.WitnessLimit)?.data;
|
2612
2540
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2613
2541
|
const maxGas = getMaxGas({
|
2614
2542
|
gasPerByte,
|
@@ -2630,14 +2558,14 @@ var calculateTransactionFee = (params) => {
|
|
2630
2558
|
};
|
2631
2559
|
|
2632
2560
|
// src/providers/transaction-summary/operations.ts
|
2633
|
-
var
|
2634
|
-
var
|
2635
|
-
var
|
2636
|
-
var
|
2561
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
2562
|
+
var import_errors10 = require("@fuel-ts/errors");
|
2563
|
+
var import_math12 = require("@fuel-ts/math");
|
2564
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
2637
2565
|
|
2638
2566
|
// src/providers/transaction-summary/call.ts
|
2639
2567
|
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
2640
|
-
var
|
2568
|
+
var import_math11 = require("@fuel-ts/math");
|
2641
2569
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2642
2570
|
const abiInterface = new import_abi_coder2.Interface(abi);
|
2643
2571
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2646,7 +2574,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2646
2574
|
let encodedArgs;
|
2647
2575
|
if (functionFragment.isInputDataPointer) {
|
2648
2576
|
if (rawPayload) {
|
2649
|
-
const argsOffset = (0,
|
2577
|
+
const argsOffset = (0, import_math11.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2650
2578
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2651
2579
|
}
|
2652
2580
|
} else {
|
@@ -2680,8 +2608,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2680
2608
|
};
|
2681
2609
|
|
2682
2610
|
// src/providers/transaction-summary/input.ts
|
2683
|
-
var
|
2684
|
-
var
|
2611
|
+
var import_errors9 = require("@fuel-ts/errors");
|
2612
|
+
var import_transactions11 = require("@fuel-ts/transactions");
|
2685
2613
|
function getInputsByTypes(inputs, types) {
|
2686
2614
|
return inputs.filter((i) => types.includes(i.type));
|
2687
2615
|
}
|
@@ -2689,16 +2617,16 @@ function getInputsByType(inputs, type) {
|
|
2689
2617
|
return inputs.filter((i) => i.type === type);
|
2690
2618
|
}
|
2691
2619
|
function getInputsCoin(inputs) {
|
2692
|
-
return getInputsByType(inputs,
|
2620
|
+
return getInputsByType(inputs, import_transactions11.InputType.Coin);
|
2693
2621
|
}
|
2694
2622
|
function getInputsMessage(inputs) {
|
2695
|
-
return getInputsByType(inputs,
|
2623
|
+
return getInputsByType(inputs, import_transactions11.InputType.Message);
|
2696
2624
|
}
|
2697
2625
|
function getInputsCoinAndMessage(inputs) {
|
2698
|
-
return getInputsByTypes(inputs, [
|
2626
|
+
return getInputsByTypes(inputs, [import_transactions11.InputType.Coin, import_transactions11.InputType.Message]);
|
2699
2627
|
}
|
2700
2628
|
function getInputsContract(inputs) {
|
2701
|
-
return getInputsByType(inputs,
|
2629
|
+
return getInputsByType(inputs, import_transactions11.InputType.Contract);
|
2702
2630
|
}
|
2703
2631
|
function getInputFromAssetId(inputs, assetId) {
|
2704
2632
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2717,40 +2645,40 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2717
2645
|
if (!contractInput) {
|
2718
2646
|
return void 0;
|
2719
2647
|
}
|
2720
|
-
if (contractInput.type !==
|
2721
|
-
throw new
|
2722
|
-
|
2648
|
+
if (contractInput.type !== import_transactions11.InputType.Contract) {
|
2649
|
+
throw new import_errors9.FuelError(
|
2650
|
+
import_errors9.ErrorCode.INVALID_TRANSACTION_INPUT,
|
2723
2651
|
`Contract input should be of type 'contract'.`
|
2724
2652
|
);
|
2725
2653
|
}
|
2726
2654
|
return contractInput;
|
2727
2655
|
}
|
2728
2656
|
function getInputAccountAddress(input) {
|
2729
|
-
if (input.type ===
|
2657
|
+
if (input.type === import_transactions11.InputType.Coin) {
|
2730
2658
|
return input.owner.toString();
|
2731
2659
|
}
|
2732
|
-
if (input.type ===
|
2660
|
+
if (input.type === import_transactions11.InputType.Message) {
|
2733
2661
|
return input.recipient.toString();
|
2734
2662
|
}
|
2735
2663
|
return "";
|
2736
2664
|
}
|
2737
2665
|
|
2738
2666
|
// src/providers/transaction-summary/output.ts
|
2739
|
-
var
|
2667
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
2740
2668
|
function getOutputsByType(outputs, type) {
|
2741
2669
|
return outputs.filter((o) => o.type === type);
|
2742
2670
|
}
|
2743
2671
|
function getOutputsContractCreated(outputs) {
|
2744
|
-
return getOutputsByType(outputs,
|
2672
|
+
return getOutputsByType(outputs, import_transactions12.OutputType.ContractCreated);
|
2745
2673
|
}
|
2746
2674
|
function getOutputsCoin(outputs) {
|
2747
|
-
return getOutputsByType(outputs,
|
2675
|
+
return getOutputsByType(outputs, import_transactions12.OutputType.Coin);
|
2748
2676
|
}
|
2749
2677
|
function getOutputsChange(outputs) {
|
2750
|
-
return getOutputsByType(outputs,
|
2678
|
+
return getOutputsByType(outputs, import_transactions12.OutputType.Change);
|
2751
2679
|
}
|
2752
2680
|
function getOutputsContract(outputs) {
|
2753
|
-
return getOutputsByType(outputs,
|
2681
|
+
return getOutputsByType(outputs, import_transactions12.OutputType.Contract);
|
2754
2682
|
}
|
2755
2683
|
|
2756
2684
|
// src/providers/transaction-summary/operations.ts
|
@@ -2759,15 +2687,15 @@ function getReceiptsByType(receipts, type) {
|
|
2759
2687
|
}
|
2760
2688
|
function getTransactionTypeName(transactionType) {
|
2761
2689
|
switch (transactionType) {
|
2762
|
-
case
|
2690
|
+
case import_transactions13.TransactionType.Mint:
|
2763
2691
|
return "Mint" /* Mint */;
|
2764
|
-
case
|
2692
|
+
case import_transactions13.TransactionType.Create:
|
2765
2693
|
return "Create" /* Create */;
|
2766
|
-
case
|
2694
|
+
case import_transactions13.TransactionType.Script:
|
2767
2695
|
return "Script" /* Script */;
|
2768
2696
|
default:
|
2769
|
-
throw new
|
2770
|
-
|
2697
|
+
throw new import_errors10.FuelError(
|
2698
|
+
import_errors10.ErrorCode.INVALID_TRANSACTION_TYPE,
|
2771
2699
|
`Invalid transaction type: ${transactionType}.`
|
2772
2700
|
);
|
2773
2701
|
}
|
@@ -2786,10 +2714,10 @@ function isTypeScript(transactionType) {
|
|
2786
2714
|
return isType(transactionType, "Script" /* Script */);
|
2787
2715
|
}
|
2788
2716
|
function getReceiptsCall(receipts) {
|
2789
|
-
return getReceiptsByType(receipts,
|
2717
|
+
return getReceiptsByType(receipts, import_transactions13.ReceiptType.Call);
|
2790
2718
|
}
|
2791
2719
|
function getReceiptsMessageOut(receipts) {
|
2792
|
-
return getReceiptsByType(receipts,
|
2720
|
+
return getReceiptsByType(receipts, import_transactions13.ReceiptType.MessageOut);
|
2793
2721
|
}
|
2794
2722
|
var mergeAssets = (op1, op2) => {
|
2795
2723
|
const assets1 = op1.assetsSent || [];
|
@@ -2802,7 +2730,7 @@ var mergeAssets = (op1, op2) => {
|
|
2802
2730
|
if (!matchingAsset) {
|
2803
2731
|
return asset1;
|
2804
2732
|
}
|
2805
|
-
const mergedAmount = (0,
|
2733
|
+
const mergedAmount = (0, import_math12.bn)(asset1.amount).add(matchingAsset.amount);
|
2806
2734
|
return { ...asset1, amount: mergedAmount };
|
2807
2735
|
});
|
2808
2736
|
return mergedAssets.concat(filteredAssets);
|
@@ -2928,7 +2856,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
2928
2856
|
const { to: toAddress, assetId, amount } = receipt;
|
2929
2857
|
let { from: fromAddress } = receipt;
|
2930
2858
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
2931
|
-
if (
|
2859
|
+
if (import_configs10.ZeroBytes32 === fromAddress) {
|
2932
2860
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
2933
2861
|
fromAddress = change?.to || fromAddress;
|
2934
2862
|
}
|
@@ -2985,11 +2913,11 @@ function getTransferOperations({
|
|
2985
2913
|
});
|
2986
2914
|
const transferReceipts = getReceiptsByType(
|
2987
2915
|
receipts,
|
2988
|
-
|
2916
|
+
import_transactions13.ReceiptType.Transfer
|
2989
2917
|
);
|
2990
2918
|
const transferOutReceipts = getReceiptsByType(
|
2991
2919
|
receipts,
|
2992
|
-
|
2920
|
+
import_transactions13.ReceiptType.TransferOut
|
2993
2921
|
);
|
2994
2922
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
2995
2923
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3074,17 +3002,17 @@ function getOperations({
|
|
3074
3002
|
}
|
3075
3003
|
|
3076
3004
|
// src/providers/transaction-summary/receipt.ts
|
3077
|
-
var
|
3005
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
3078
3006
|
var processGqlReceipt = (gqlReceipt) => {
|
3079
3007
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3080
3008
|
switch (receipt.type) {
|
3081
|
-
case
|
3009
|
+
case import_transactions14.ReceiptType.ReturnData: {
|
3082
3010
|
return {
|
3083
3011
|
...receipt,
|
3084
3012
|
data: gqlReceipt.data || "0x"
|
3085
3013
|
};
|
3086
3014
|
}
|
3087
|
-
case
|
3015
|
+
case import_transactions14.ReceiptType.LogData: {
|
3088
3016
|
return {
|
3089
3017
|
...receipt,
|
3090
3018
|
data: gqlReceipt.data || "0x"
|
@@ -3097,7 +3025,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3097
3025
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3098
3026
|
const mintedAssets = [];
|
3099
3027
|
receipts.forEach((receipt) => {
|
3100
|
-
if (receipt.type ===
|
3028
|
+
if (receipt.type === import_transactions14.ReceiptType.Mint) {
|
3101
3029
|
mintedAssets.push({
|
3102
3030
|
subId: receipt.subId,
|
3103
3031
|
contractId: receipt.contractId,
|
@@ -3111,7 +3039,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3111
3039
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3112
3040
|
const burnedAssets = [];
|
3113
3041
|
receipts.forEach((receipt) => {
|
3114
|
-
if (receipt.type ===
|
3042
|
+
if (receipt.type === import_transactions14.ReceiptType.Burn) {
|
3115
3043
|
burnedAssets.push({
|
3116
3044
|
subId: receipt.subId,
|
3117
3045
|
contractId: receipt.contractId,
|
@@ -3124,7 +3052,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3124
3052
|
};
|
3125
3053
|
|
3126
3054
|
// src/providers/transaction-summary/status.ts
|
3127
|
-
var
|
3055
|
+
var import_errors11 = require("@fuel-ts/errors");
|
3128
3056
|
var getTransactionStatusName = (gqlStatus) => {
|
3129
3057
|
switch (gqlStatus) {
|
3130
3058
|
case "FailureStatus":
|
@@ -3136,8 +3064,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3136
3064
|
case "SqueezedOutStatus":
|
3137
3065
|
return "squeezedout" /* squeezedout */;
|
3138
3066
|
default:
|
3139
|
-
throw new
|
3140
|
-
|
3067
|
+
throw new import_errors11.FuelError(
|
3068
|
+
import_errors11.ErrorCode.INVALID_TRANSACTION_STATUS,
|
3141
3069
|
`Invalid transaction status: ${gqlStatus}.`
|
3142
3070
|
);
|
3143
3071
|
}
|
@@ -3250,12 +3178,12 @@ function assembleTransactionSummary(params) {
|
|
3250
3178
|
|
3251
3179
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3252
3180
|
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
3253
|
-
var
|
3181
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
3254
3182
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3255
3183
|
return receipts.reduce((logs, receipt) => {
|
3256
|
-
if (receipt.type ===
|
3184
|
+
if (receipt.type === import_transactions15.ReceiptType.LogData || receipt.type === import_transactions15.ReceiptType.Log) {
|
3257
3185
|
const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
|
3258
|
-
const data = receipt.type ===
|
3186
|
+
const data = receipt.type === import_transactions15.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3259
3187
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3260
3188
|
logs.push(decodedLog);
|
3261
3189
|
}
|
@@ -3270,7 +3198,7 @@ var TransactionResponse = class {
|
|
3270
3198
|
/** Current provider */
|
3271
3199
|
provider;
|
3272
3200
|
/** Gas used on the transaction */
|
3273
|
-
gasUsed = (0,
|
3201
|
+
gasUsed = (0, import_math13.bn)(0);
|
3274
3202
|
/** The graphql Transaction with receipts object. */
|
3275
3203
|
gqlTransaction;
|
3276
3204
|
abis;
|
@@ -3328,7 +3256,7 @@ var TransactionResponse = class {
|
|
3328
3256
|
* @returns The decoded transaction.
|
3329
3257
|
*/
|
3330
3258
|
decodeTransaction(transactionWithReceipts) {
|
3331
|
-
return new
|
3259
|
+
return new import_transactions16.TransactionCoder().decode(
|
3332
3260
|
(0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
|
3333
3261
|
0
|
3334
3262
|
)?.[0];
|
@@ -3375,8 +3303,8 @@ var TransactionResponse = class {
|
|
3375
3303
|
});
|
3376
3304
|
for await (const { statusChange } of subscription) {
|
3377
3305
|
if (statusChange.type === "SqueezedOutStatus") {
|
3378
|
-
throw new
|
3379
|
-
|
3306
|
+
throw new import_errors12.FuelError(
|
3307
|
+
import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
3380
3308
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
3381
3309
|
);
|
3382
3310
|
}
|
@@ -3398,26 +3326,14 @@ var TransactionResponse = class {
|
|
3398
3326
|
gqlTransaction: this.gqlTransaction,
|
3399
3327
|
...transactionSummary
|
3400
3328
|
};
|
3401
|
-
let logs = [];
|
3402
3329
|
if (this.abis) {
|
3403
|
-
logs = getDecodedLogs(
|
3330
|
+
const logs = getDecodedLogs(
|
3404
3331
|
transactionSummary.receipts,
|
3405
3332
|
this.abis.main,
|
3406
3333
|
this.abis.otherContractsAbis
|
3407
3334
|
);
|
3408
3335
|
transactionResult.logs = logs;
|
3409
3336
|
}
|
3410
|
-
if (transactionResult.isStatusFailure) {
|
3411
|
-
const {
|
3412
|
-
receipts,
|
3413
|
-
gqlTransaction: { status }
|
3414
|
-
} = transactionResult;
|
3415
|
-
throw extractTxError({
|
3416
|
-
receipts,
|
3417
|
-
status,
|
3418
|
-
logs
|
3419
|
-
});
|
3420
|
-
}
|
3421
3337
|
return transactionResult;
|
3422
3338
|
}
|
3423
3339
|
/**
|
@@ -3426,7 +3342,14 @@ var TransactionResponse = class {
|
|
3426
3342
|
* @param contractsAbiMap - The contracts ABI map.
|
3427
3343
|
*/
|
3428
3344
|
async wait(contractsAbiMap) {
|
3429
|
-
|
3345
|
+
const result = await this.waitForResult(contractsAbiMap);
|
3346
|
+
if (result.isStatusFailure) {
|
3347
|
+
throw new import_errors12.FuelError(
|
3348
|
+
import_errors12.ErrorCode.TRANSACTION_FAILED,
|
3349
|
+
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
3350
|
+
);
|
3351
|
+
}
|
3352
|
+
return result;
|
3430
3353
|
}
|
3431
3354
|
};
|
3432
3355
|
|
@@ -3488,29 +3411,29 @@ var processGqlChain = (chain) => {
|
|
3488
3411
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3489
3412
|
return {
|
3490
3413
|
name,
|
3491
|
-
baseChainHeight: (0,
|
3414
|
+
baseChainHeight: (0, import_math14.bn)(daHeight),
|
3492
3415
|
consensusParameters: {
|
3493
|
-
contractMaxSize: (0,
|
3494
|
-
maxInputs: (0,
|
3495
|
-
maxOutputs: (0,
|
3496
|
-
maxWitnesses: (0,
|
3497
|
-
maxGasPerTx: (0,
|
3498
|
-
maxScriptLength: (0,
|
3499
|
-
maxScriptDataLength: (0,
|
3500
|
-
maxStorageSlots: (0,
|
3501
|
-
maxPredicateLength: (0,
|
3502
|
-
maxPredicateDataLength: (0,
|
3503
|
-
maxGasPerPredicate: (0,
|
3504
|
-
gasPriceFactor: (0,
|
3505
|
-
gasPerByte: (0,
|
3506
|
-
maxMessageDataLength: (0,
|
3507
|
-
chainId: (0,
|
3416
|
+
contractMaxSize: (0, import_math14.bn)(contractParams.contractMaxSize),
|
3417
|
+
maxInputs: (0, import_math14.bn)(txParams.maxInputs),
|
3418
|
+
maxOutputs: (0, import_math14.bn)(txParams.maxOutputs),
|
3419
|
+
maxWitnesses: (0, import_math14.bn)(txParams.maxWitnesses),
|
3420
|
+
maxGasPerTx: (0, import_math14.bn)(txParams.maxGasPerTx),
|
3421
|
+
maxScriptLength: (0, import_math14.bn)(scriptParams.maxScriptLength),
|
3422
|
+
maxScriptDataLength: (0, import_math14.bn)(scriptParams.maxScriptDataLength),
|
3423
|
+
maxStorageSlots: (0, import_math14.bn)(contractParams.maxStorageSlots),
|
3424
|
+
maxPredicateLength: (0, import_math14.bn)(predicateParams.maxPredicateLength),
|
3425
|
+
maxPredicateDataLength: (0, import_math14.bn)(predicateParams.maxPredicateDataLength),
|
3426
|
+
maxGasPerPredicate: (0, import_math14.bn)(predicateParams.maxGasPerPredicate),
|
3427
|
+
gasPriceFactor: (0, import_math14.bn)(feeParams.gasPriceFactor),
|
3428
|
+
gasPerByte: (0, import_math14.bn)(feeParams.gasPerByte),
|
3429
|
+
maxMessageDataLength: (0, import_math14.bn)(predicateParams.maxMessageDataLength),
|
3430
|
+
chainId: (0, import_math14.bn)(consensusParameters.chainId),
|
3508
3431
|
gasCosts
|
3509
3432
|
},
|
3510
3433
|
gasCosts,
|
3511
3434
|
latestBlock: {
|
3512
3435
|
id: latestBlock.id,
|
3513
|
-
height: (0,
|
3436
|
+
height: (0, import_math14.bn)(latestBlock.header.height),
|
3514
3437
|
time: latestBlock.header.time,
|
3515
3438
|
transactions: latestBlock.transactions.map((i) => ({
|
3516
3439
|
id: i.id
|
@@ -3580,8 +3503,8 @@ var _Provider = class {
|
|
3580
3503
|
getChain() {
|
3581
3504
|
const chain = _Provider.chainInfoCache[this.url];
|
3582
3505
|
if (!chain) {
|
3583
|
-
throw new
|
3584
|
-
|
3506
|
+
throw new import_errors13.FuelError(
|
3507
|
+
import_errors13.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
3585
3508
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3586
3509
|
);
|
3587
3510
|
}
|
@@ -3593,8 +3516,8 @@ var _Provider = class {
|
|
3593
3516
|
getNode() {
|
3594
3517
|
const node = _Provider.nodeInfoCache[this.url];
|
3595
3518
|
if (!node) {
|
3596
|
-
throw new
|
3597
|
-
|
3519
|
+
throw new import_errors13.FuelError(
|
3520
|
+
import_errors13.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
3598
3521
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3599
3522
|
);
|
3600
3523
|
}
|
@@ -3641,8 +3564,8 @@ var _Provider = class {
|
|
3641
3564
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3642
3565
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
3643
3566
|
if (!isMajorSupported || !isMinorSupported) {
|
3644
|
-
throw new
|
3645
|
-
|
3567
|
+
throw new import_errors13.FuelError(
|
3568
|
+
import_errors13.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
|
3646
3569
|
`Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
|
3647
3570
|
);
|
3648
3571
|
}
|
@@ -3705,7 +3628,7 @@ var _Provider = class {
|
|
3705
3628
|
*/
|
3706
3629
|
async getBlockNumber() {
|
3707
3630
|
const { chain } = await this.operations.getChain();
|
3708
|
-
return (0,
|
3631
|
+
return (0, import_math14.bn)(chain.latestBlock.header.height, 10);
|
3709
3632
|
}
|
3710
3633
|
/**
|
3711
3634
|
* Returns the chain information.
|
@@ -3715,9 +3638,9 @@ var _Provider = class {
|
|
3715
3638
|
async fetchNode() {
|
3716
3639
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3717
3640
|
const processedNodeInfo = {
|
3718
|
-
maxDepth: (0,
|
3719
|
-
maxTx: (0,
|
3720
|
-
minGasPrice: (0,
|
3641
|
+
maxDepth: (0, import_math14.bn)(nodeInfo.maxDepth),
|
3642
|
+
maxTx: (0, import_math14.bn)(nodeInfo.maxTx),
|
3643
|
+
minGasPrice: (0, import_math14.bn)(nodeInfo.minGasPrice),
|
3721
3644
|
nodeVersion: nodeInfo.nodeVersion,
|
3722
3645
|
utxoValidation: nodeInfo.utxoValidation,
|
3723
3646
|
vmBacktrace: nodeInfo.vmBacktrace,
|
@@ -3763,17 +3686,17 @@ var _Provider = class {
|
|
3763
3686
|
if (estimateTxDependencies) {
|
3764
3687
|
await this.estimateTxDependencies(transactionRequest);
|
3765
3688
|
}
|
3766
|
-
const encodedTransaction = (0,
|
3689
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3767
3690
|
let abis;
|
3768
|
-
if (transactionRequest.type ===
|
3691
|
+
if (transactionRequest.type === import_transactions17.TransactionType.Script) {
|
3769
3692
|
abis = transactionRequest.abis;
|
3770
3693
|
}
|
3771
3694
|
if (awaitExecution) {
|
3772
3695
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3773
3696
|
for await (const { submitAndAwait } of subscription) {
|
3774
3697
|
if (submitAndAwait.type === "SqueezedOutStatus") {
|
3775
|
-
throw new
|
3776
|
-
|
3698
|
+
throw new import_errors13.FuelError(
|
3699
|
+
import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
3777
3700
|
`Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
|
3778
3701
|
);
|
3779
3702
|
}
|
@@ -3806,7 +3729,7 @@ var _Provider = class {
|
|
3806
3729
|
if (estimateTxDependencies) {
|
3807
3730
|
return this.estimateTxDependencies(transactionRequest);
|
3808
3731
|
}
|
3809
|
-
const encodedTransaction = (0,
|
3732
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3810
3733
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3811
3734
|
encodedTransaction,
|
3812
3735
|
utxoValidation: utxoValidation || false
|
@@ -3825,13 +3748,13 @@ var _Provider = class {
|
|
3825
3748
|
async estimatePredicates(transactionRequest) {
|
3826
3749
|
const shouldEstimatePredicates = Boolean(
|
3827
3750
|
transactionRequest.inputs.find(
|
3828
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
3751
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
|
3829
3752
|
)
|
3830
3753
|
);
|
3831
3754
|
if (!shouldEstimatePredicates) {
|
3832
3755
|
return transactionRequest;
|
3833
3756
|
}
|
3834
|
-
const encodedTransaction = (0,
|
3757
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3835
3758
|
const response = await this.operations.estimatePredicates({
|
3836
3759
|
encodedTransaction
|
3837
3760
|
});
|
@@ -3840,7 +3763,7 @@ var _Provider = class {
|
|
3840
3763
|
} = response;
|
3841
3764
|
if (inputs) {
|
3842
3765
|
inputs.forEach((input, index) => {
|
3843
|
-
if ("predicateGasUsed" in input && (0,
|
3766
|
+
if ("predicateGasUsed" in input && (0, import_math14.bn)(input.predicateGasUsed).gt(0)) {
|
3844
3767
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3845
3768
|
}
|
3846
3769
|
});
|
@@ -3861,7 +3784,7 @@ var _Provider = class {
|
|
3861
3784
|
* @returns A promise.
|
3862
3785
|
*/
|
3863
3786
|
async estimateTxDependencies(transactionRequest) {
|
3864
|
-
if (transactionRequest.type ===
|
3787
|
+
if (transactionRequest.type === import_transactions17.TransactionType.Create) {
|
3865
3788
|
return {
|
3866
3789
|
receipts: [],
|
3867
3790
|
outputVariables: 0,
|
@@ -3874,7 +3797,7 @@ var _Provider = class {
|
|
3874
3797
|
let outputVariables = 0;
|
3875
3798
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3876
3799
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3877
|
-
encodedTransaction: (0,
|
3800
|
+
encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
|
3878
3801
|
utxoValidation: false
|
3879
3802
|
});
|
3880
3803
|
receipts = gqlReceipts.map(processGqlReceipt);
|
@@ -3912,7 +3835,7 @@ var _Provider = class {
|
|
3912
3835
|
if (estimateTxDependencies) {
|
3913
3836
|
return this.estimateTxDependencies(transactionRequest);
|
3914
3837
|
}
|
3915
|
-
const encodedTransaction = (0,
|
3838
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3916
3839
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3917
3840
|
encodedTransaction,
|
3918
3841
|
utxoValidation: true
|
@@ -3946,14 +3869,14 @@ var _Provider = class {
|
|
3946
3869
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
3947
3870
|
const chainInfo = this.getChain();
|
3948
3871
|
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
3949
|
-
const gasPrice = (0,
|
3950
|
-
const isScriptTransaction = txRequestClone.type ===
|
3872
|
+
const gasPrice = (0, import_math14.max)(txRequestClone.gasPrice, minGasPrice);
|
3873
|
+
const isScriptTransaction = txRequestClone.type === import_transactions17.TransactionType.Script;
|
3951
3874
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3952
3875
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
3953
3876
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
3954
3877
|
if (estimatePredicates) {
|
3955
3878
|
if (isScriptTransaction) {
|
3956
|
-
txRequestClone.gasLimit = (0,
|
3879
|
+
txRequestClone.gasLimit = (0, import_math14.bn)(0);
|
3957
3880
|
}
|
3958
3881
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3959
3882
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -3969,8 +3892,8 @@ var _Provider = class {
|
|
3969
3892
|
let missingContractIds = [];
|
3970
3893
|
let outputVariables = 0;
|
3971
3894
|
if (isScriptTransaction && estimateTxDependencies) {
|
3972
|
-
txRequestClone.gasPrice = (0,
|
3973
|
-
txRequestClone.gasLimit = (0,
|
3895
|
+
txRequestClone.gasPrice = (0, import_math14.bn)(0);
|
3896
|
+
txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
3974
3897
|
const result = await this.estimateTxDependencies(txRequestClone);
|
3975
3898
|
receipts = result.receipts;
|
3976
3899
|
outputVariables = result.outputVariables;
|
@@ -4026,17 +3949,17 @@ var _Provider = class {
|
|
4026
3949
|
const result = await this.operations.getCoins({
|
4027
3950
|
first: 10,
|
4028
3951
|
...paginationArgs,
|
4029
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
3952
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4030
3953
|
});
|
4031
3954
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4032
3955
|
return coins.map((coin) => ({
|
4033
3956
|
id: coin.utxoId,
|
4034
3957
|
assetId: coin.assetId,
|
4035
|
-
amount: (0,
|
3958
|
+
amount: (0, import_math14.bn)(coin.amount),
|
4036
3959
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4037
|
-
maturity: (0,
|
4038
|
-
blockCreated: (0,
|
4039
|
-
txCreatedIdx: (0,
|
3960
|
+
maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
|
3961
|
+
blockCreated: (0, import_math14.bn)(coin.blockCreated),
|
3962
|
+
txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
|
4040
3963
|
}));
|
4041
3964
|
}
|
4042
3965
|
/**
|
@@ -4050,19 +3973,19 @@ var _Provider = class {
|
|
4050
3973
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4051
3974
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4052
3975
|
const excludeInput = {
|
4053
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4054
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
3976
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
3977
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4055
3978
|
};
|
4056
3979
|
if (this.cache) {
|
4057
3980
|
const uniqueUtxos = new Set(
|
4058
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
3981
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4059
3982
|
);
|
4060
3983
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4061
3984
|
}
|
4062
3985
|
const coinsQuery = {
|
4063
3986
|
owner: ownerAddress.toB256(),
|
4064
3987
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4065
|
-
assetId: (0,
|
3988
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4066
3989
|
amount: amount.toString(10),
|
4067
3990
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4068
3991
|
})),
|
@@ -4073,9 +3996,9 @@ var _Provider = class {
|
|
4073
3996
|
switch (coin.__typename) {
|
4074
3997
|
case "MessageCoin":
|
4075
3998
|
return {
|
4076
|
-
amount: (0,
|
3999
|
+
amount: (0, import_math14.bn)(coin.amount),
|
4077
4000
|
assetId: coin.assetId,
|
4078
|
-
daHeight: (0,
|
4001
|
+
daHeight: (0, import_math14.bn)(coin.daHeight),
|
4079
4002
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4080
4003
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4081
4004
|
nonce: coin.nonce
|
@@ -4083,12 +4006,12 @@ var _Provider = class {
|
|
4083
4006
|
case "Coin":
|
4084
4007
|
return {
|
4085
4008
|
id: coin.utxoId,
|
4086
|
-
amount: (0,
|
4009
|
+
amount: (0, import_math14.bn)(coin.amount),
|
4087
4010
|
assetId: coin.assetId,
|
4088
4011
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4089
|
-
maturity: (0,
|
4090
|
-
blockCreated: (0,
|
4091
|
-
txCreatedIdx: (0,
|
4012
|
+
maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
|
4013
|
+
blockCreated: (0, import_math14.bn)(coin.blockCreated),
|
4014
|
+
txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
|
4092
4015
|
};
|
4093
4016
|
default:
|
4094
4017
|
return null;
|
@@ -4105,13 +4028,13 @@ var _Provider = class {
|
|
4105
4028
|
async getBlock(idOrHeight) {
|
4106
4029
|
let variables;
|
4107
4030
|
if (typeof idOrHeight === "number") {
|
4108
|
-
variables = { height: (0,
|
4031
|
+
variables = { height: (0, import_math14.bn)(idOrHeight).toString(10) };
|
4109
4032
|
} else if (idOrHeight === "latest") {
|
4110
4033
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4111
4034
|
} else if (idOrHeight.length === 66) {
|
4112
4035
|
variables = { blockId: idOrHeight };
|
4113
4036
|
} else {
|
4114
|
-
variables = { blockId: (0,
|
4037
|
+
variables = { blockId: (0, import_math14.bn)(idOrHeight).toString(10) };
|
4115
4038
|
}
|
4116
4039
|
const { block } = await this.operations.getBlock(variables);
|
4117
4040
|
if (!block) {
|
@@ -4119,7 +4042,7 @@ var _Provider = class {
|
|
4119
4042
|
}
|
4120
4043
|
return {
|
4121
4044
|
id: block.id,
|
4122
|
-
height: (0,
|
4045
|
+
height: (0, import_math14.bn)(block.header.height),
|
4123
4046
|
time: block.header.time,
|
4124
4047
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4125
4048
|
};
|
@@ -4134,7 +4057,7 @@ var _Provider = class {
|
|
4134
4057
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4135
4058
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4136
4059
|
id: block.id,
|
4137
|
-
height: (0,
|
4060
|
+
height: (0, import_math14.bn)(block.header.height),
|
4138
4061
|
time: block.header.time,
|
4139
4062
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4140
4063
|
}));
|
@@ -4149,7 +4072,7 @@ var _Provider = class {
|
|
4149
4072
|
async getBlockWithTransactions(idOrHeight) {
|
4150
4073
|
let variables;
|
4151
4074
|
if (typeof idOrHeight === "number") {
|
4152
|
-
variables = { blockHeight: (0,
|
4075
|
+
variables = { blockHeight: (0, import_math14.bn)(idOrHeight).toString(10) };
|
4153
4076
|
} else if (idOrHeight === "latest") {
|
4154
4077
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4155
4078
|
} else {
|
@@ -4161,11 +4084,11 @@ var _Provider = class {
|
|
4161
4084
|
}
|
4162
4085
|
return {
|
4163
4086
|
id: block.id,
|
4164
|
-
height: (0,
|
4087
|
+
height: (0, import_math14.bn)(block.header.height, 10),
|
4165
4088
|
time: block.header.time,
|
4166
4089
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4167
4090
|
transactions: block.transactions.map(
|
4168
|
-
(tx) => new
|
4091
|
+
(tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4169
4092
|
)
|
4170
4093
|
};
|
4171
4094
|
}
|
@@ -4180,8 +4103,8 @@ var _Provider = class {
|
|
4180
4103
|
if (!transaction) {
|
4181
4104
|
return null;
|
4182
4105
|
}
|
4183
|
-
return new
|
4184
|
-
(0,
|
4106
|
+
return new import_transactions17.TransactionCoder().decode(
|
4107
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4185
4108
|
0
|
4186
4109
|
)?.[0];
|
4187
4110
|
}
|
@@ -4208,9 +4131,9 @@ var _Provider = class {
|
|
4208
4131
|
async getContractBalance(contractId, assetId) {
|
4209
4132
|
const { contractBalance } = await this.operations.getContractBalance({
|
4210
4133
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4211
|
-
asset: (0,
|
4134
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4212
4135
|
});
|
4213
|
-
return (0,
|
4136
|
+
return (0, import_math14.bn)(contractBalance.amount, 10);
|
4214
4137
|
}
|
4215
4138
|
/**
|
4216
4139
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4222,9 +4145,9 @@ var _Provider = class {
|
|
4222
4145
|
async getBalance(owner, assetId) {
|
4223
4146
|
const { balance } = await this.operations.getBalance({
|
4224
4147
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4225
|
-
assetId: (0,
|
4148
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4226
4149
|
});
|
4227
|
-
return (0,
|
4150
|
+
return (0, import_math14.bn)(balance.amount, 10);
|
4228
4151
|
}
|
4229
4152
|
/**
|
4230
4153
|
* Returns balances for the given owner.
|
@@ -4242,7 +4165,7 @@ var _Provider = class {
|
|
4242
4165
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4243
4166
|
return balances.map((balance) => ({
|
4244
4167
|
assetId: balance.assetId,
|
4245
|
-
amount: (0,
|
4168
|
+
amount: (0, import_math14.bn)(balance.amount)
|
4246
4169
|
}));
|
4247
4170
|
}
|
4248
4171
|
/**
|
@@ -4260,19 +4183,19 @@ var _Provider = class {
|
|
4260
4183
|
});
|
4261
4184
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4262
4185
|
return messages.map((message) => ({
|
4263
|
-
messageId:
|
4186
|
+
messageId: import_transactions17.InputMessageCoder.getMessageId({
|
4264
4187
|
sender: message.sender,
|
4265
4188
|
recipient: message.recipient,
|
4266
4189
|
nonce: message.nonce,
|
4267
|
-
amount: (0,
|
4190
|
+
amount: (0, import_math14.bn)(message.amount),
|
4268
4191
|
data: message.data
|
4269
4192
|
}),
|
4270
4193
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4271
4194
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4272
4195
|
nonce: message.nonce,
|
4273
|
-
amount: (0,
|
4274
|
-
data:
|
4275
|
-
daHeight: (0,
|
4196
|
+
amount: (0, import_math14.bn)(message.amount),
|
4197
|
+
data: import_transactions17.InputMessageCoder.decodeData(message.data),
|
4198
|
+
daHeight: (0, import_math14.bn)(message.daHeight)
|
4276
4199
|
}));
|
4277
4200
|
}
|
4278
4201
|
/**
|
@@ -4290,8 +4213,8 @@ var _Provider = class {
|
|
4290
4213
|
nonce
|
4291
4214
|
};
|
4292
4215
|
if (commitBlockId && commitBlockHeight) {
|
4293
|
-
throw new
|
4294
|
-
|
4216
|
+
throw new import_errors13.FuelError(
|
4217
|
+
import_errors13.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4295
4218
|
"commitBlockId and commitBlockHeight cannot be used together"
|
4296
4219
|
);
|
4297
4220
|
}
|
@@ -4325,41 +4248,41 @@ var _Provider = class {
|
|
4325
4248
|
} = result.messageProof;
|
4326
4249
|
return {
|
4327
4250
|
messageProof: {
|
4328
|
-
proofIndex: (0,
|
4251
|
+
proofIndex: (0, import_math14.bn)(messageProof.proofIndex),
|
4329
4252
|
proofSet: messageProof.proofSet
|
4330
4253
|
},
|
4331
4254
|
blockProof: {
|
4332
|
-
proofIndex: (0,
|
4255
|
+
proofIndex: (0, import_math14.bn)(blockProof.proofIndex),
|
4333
4256
|
proofSet: blockProof.proofSet
|
4334
4257
|
},
|
4335
4258
|
messageBlockHeader: {
|
4336
4259
|
id: messageBlockHeader.id,
|
4337
|
-
daHeight: (0,
|
4338
|
-
transactionsCount: (0,
|
4260
|
+
daHeight: (0, import_math14.bn)(messageBlockHeader.daHeight),
|
4261
|
+
transactionsCount: (0, import_math14.bn)(messageBlockHeader.transactionsCount),
|
4339
4262
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4340
|
-
height: (0,
|
4263
|
+
height: (0, import_math14.bn)(messageBlockHeader.height),
|
4341
4264
|
prevRoot: messageBlockHeader.prevRoot,
|
4342
4265
|
time: messageBlockHeader.time,
|
4343
4266
|
applicationHash: messageBlockHeader.applicationHash,
|
4344
4267
|
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4345
|
-
messageReceiptCount: (0,
|
4268
|
+
messageReceiptCount: (0, import_math14.bn)(messageBlockHeader.messageReceiptCount)
|
4346
4269
|
},
|
4347
4270
|
commitBlockHeader: {
|
4348
4271
|
id: commitBlockHeader.id,
|
4349
|
-
daHeight: (0,
|
4350
|
-
transactionsCount: (0,
|
4272
|
+
daHeight: (0, import_math14.bn)(commitBlockHeader.daHeight),
|
4273
|
+
transactionsCount: (0, import_math14.bn)(commitBlockHeader.transactionsCount),
|
4351
4274
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4352
|
-
height: (0,
|
4275
|
+
height: (0, import_math14.bn)(commitBlockHeader.height),
|
4353
4276
|
prevRoot: commitBlockHeader.prevRoot,
|
4354
4277
|
time: commitBlockHeader.time,
|
4355
4278
|
applicationHash: commitBlockHeader.applicationHash,
|
4356
4279
|
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4357
|
-
messageReceiptCount: (0,
|
4280
|
+
messageReceiptCount: (0, import_math14.bn)(commitBlockHeader.messageReceiptCount)
|
4358
4281
|
},
|
4359
4282
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4360
4283
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4361
4284
|
nonce,
|
4362
|
-
amount: (0,
|
4285
|
+
amount: (0, import_math14.bn)(amount),
|
4363
4286
|
data
|
4364
4287
|
};
|
4365
4288
|
}
|
@@ -4382,10 +4305,10 @@ var _Provider = class {
|
|
4382
4305
|
*/
|
4383
4306
|
async produceBlocks(amount, startTime) {
|
4384
4307
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4385
|
-
blocksToProduce: (0,
|
4386
|
-
startTimestamp: startTime ?
|
4308
|
+
blocksToProduce: (0, import_math14.bn)(amount).toString(10),
|
4309
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4387
4310
|
});
|
4388
|
-
return (0,
|
4311
|
+
return (0, import_math14.bn)(latestBlockHeight);
|
4389
4312
|
}
|
4390
4313
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4391
4314
|
async getTransactionResponse(transactionId) {
|
@@ -4399,7 +4322,7 @@ cacheInputs_fn = function(inputs) {
|
|
4399
4322
|
return;
|
4400
4323
|
}
|
4401
4324
|
inputs.forEach((input) => {
|
4402
|
-
if (input.type ===
|
4325
|
+
if (input.type === import_transactions17.InputType.Coin) {
|
4403
4326
|
this.cache?.set(input.id);
|
4404
4327
|
}
|
4405
4328
|
});
|
@@ -4408,10 +4331,10 @@ __publicField(Provider, "chainInfoCache", {});
|
|
4408
4331
|
__publicField(Provider, "nodeInfoCache", {});
|
4409
4332
|
|
4410
4333
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4411
|
-
var
|
4412
|
-
var
|
4413
|
-
var
|
4414
|
-
var
|
4334
|
+
var import_errors14 = require("@fuel-ts/errors");
|
4335
|
+
var import_math15 = require("@fuel-ts/math");
|
4336
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
4337
|
+
var import_utils25 = require("@fuel-ts/utils");
|
4415
4338
|
|
4416
4339
|
// src/providers/chains.ts
|
4417
4340
|
var CHAIN_IDS = {
|
@@ -4460,17 +4383,17 @@ var assets = [
|
|
4460
4383
|
|
4461
4384
|
// src/utils/formatTransferToContractScriptData.ts
|
4462
4385
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4463
|
-
var
|
4464
|
-
var
|
4386
|
+
var import_math16 = require("@fuel-ts/math");
|
4387
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4465
4388
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4466
4389
|
var formatTransferToContractScriptData = (params) => {
|
4467
4390
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4468
4391
|
const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
|
4469
|
-
const encoded = numberCoder.encode(new
|
4392
|
+
const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
|
4470
4393
|
const scriptData = Uint8Array.from([
|
4471
|
-
...(0,
|
4394
|
+
...(0, import_utils26.arrayify)(hexlifiedContractId),
|
4472
4395
|
...encoded,
|
4473
|
-
...(0,
|
4396
|
+
...(0, import_utils26.arrayify)(assetId)
|
4474
4397
|
]);
|
4475
4398
|
return scriptData;
|
4476
4399
|
};
|
@@ -4526,7 +4449,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4526
4449
|
*/
|
4527
4450
|
get provider() {
|
4528
4451
|
if (!this._provider) {
|
4529
|
-
throw new
|
4452
|
+
throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
4530
4453
|
}
|
4531
4454
|
return this._provider;
|
4532
4455
|
}
|
@@ -4578,8 +4501,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4578
4501
|
if (!hasNextPage) {
|
4579
4502
|
break;
|
4580
4503
|
}
|
4581
|
-
throw new
|
4582
|
-
|
4504
|
+
throw new import_errors15.FuelError(
|
4505
|
+
import_errors15.ErrorCode.NOT_SUPPORTED,
|
4583
4506
|
`Wallets containing more than ${pageSize} coins exceed the current supported limit.`
|
4584
4507
|
);
|
4585
4508
|
}
|
@@ -4604,8 +4527,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4604
4527
|
if (!hasNextPage) {
|
4605
4528
|
break;
|
4606
4529
|
}
|
4607
|
-
throw new
|
4608
|
-
|
4530
|
+
throw new import_errors15.FuelError(
|
4531
|
+
import_errors15.ErrorCode.NOT_SUPPORTED,
|
4609
4532
|
`Wallets containing more than ${pageSize} messages exceed the current supported limit.`
|
4610
4533
|
);
|
4611
4534
|
}
|
@@ -4617,7 +4540,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4617
4540
|
* @param assetId - The asset ID to check the balance for.
|
4618
4541
|
* @returns A promise that resolves to the balance amount.
|
4619
4542
|
*/
|
4620
|
-
async getBalance(assetId =
|
4543
|
+
async getBalance(assetId = import_configs11.BaseAssetId) {
|
4621
4544
|
const amount = await this.provider.getBalance(this.address, assetId);
|
4622
4545
|
return amount;
|
4623
4546
|
}
|
@@ -4640,8 +4563,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4640
4563
|
if (!hasNextPage) {
|
4641
4564
|
break;
|
4642
4565
|
}
|
4643
|
-
throw new
|
4644
|
-
|
4566
|
+
throw new import_errors15.FuelError(
|
4567
|
+
import_errors15.ErrorCode.NOT_SUPPORTED,
|
4645
4568
|
`Wallets containing more than ${pageSize} balances exceed the current supported limit.`
|
4646
4569
|
);
|
4647
4570
|
}
|
@@ -4657,15 +4580,15 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4657
4580
|
*/
|
4658
4581
|
async fund(request, coinQuantities, fee) {
|
4659
4582
|
const updatedQuantities = addAmountToAsset({
|
4660
|
-
amount: (0,
|
4661
|
-
assetId:
|
4583
|
+
amount: (0, import_math17.bn)(fee),
|
4584
|
+
assetId: import_configs11.BaseAssetId,
|
4662
4585
|
coinQuantities
|
4663
4586
|
});
|
4664
4587
|
const quantitiesDict = {};
|
4665
4588
|
updatedQuantities.forEach(({ amount, assetId }) => {
|
4666
4589
|
quantitiesDict[assetId] = {
|
4667
4590
|
required: amount,
|
4668
|
-
owned: (0,
|
4591
|
+
owned: (0, import_math17.bn)(0)
|
4669
4592
|
};
|
4670
4593
|
});
|
4671
4594
|
const cachedUtxos = [];
|
@@ -4678,12 +4601,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4678
4601
|
if (isCoin2) {
|
4679
4602
|
const assetId = String(input.assetId);
|
4680
4603
|
if (input.owner === owner && quantitiesDict[assetId]) {
|
4681
|
-
const amount = (0,
|
4604
|
+
const amount = (0, import_math17.bn)(input.amount);
|
4682
4605
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4683
4606
|
cachedUtxos.push(input.id);
|
4684
4607
|
}
|
4685
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
4686
|
-
quantitiesDict[
|
4608
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[import_configs11.BaseAssetId]) {
|
4609
|
+
quantitiesDict[import_configs11.BaseAssetId].owned = quantitiesDict[import_configs11.BaseAssetId].owned.add(input.amount);
|
4687
4610
|
cachedMessages.push(input.nonce);
|
4688
4611
|
}
|
4689
4612
|
}
|
@@ -4715,7 +4638,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4715
4638
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4716
4639
|
* @returns A promise that resolves to the prepared transaction request.
|
4717
4640
|
*/
|
4718
|
-
async createTransfer(destination, amount, assetId =
|
4641
|
+
async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
|
4719
4642
|
const { minGasPrice } = this.provider.getGasConfig();
|
4720
4643
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4721
4644
|
const request = new ScriptTransactionRequest(params);
|
@@ -4724,8 +4647,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4724
4647
|
estimateTxDependencies: true,
|
4725
4648
|
resourcesOwner: this
|
4726
4649
|
});
|
4727
|
-
request.gasPrice = (0,
|
4728
|
-
request.gasLimit = (0,
|
4650
|
+
request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
|
4651
|
+
request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
|
4729
4652
|
this.validateGas({
|
4730
4653
|
gasUsed,
|
4731
4654
|
gasPrice: request.gasPrice,
|
@@ -4745,10 +4668,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4745
4668
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4746
4669
|
* @returns A promise that resolves to the transaction response.
|
4747
4670
|
*/
|
4748
|
-
async transfer(destination, amount, assetId =
|
4749
|
-
if ((0,
|
4750
|
-
throw new
|
4751
|
-
|
4671
|
+
async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
|
4672
|
+
if ((0, import_math17.bn)(amount).lte(0)) {
|
4673
|
+
throw new import_errors15.FuelError(
|
4674
|
+
import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4752
4675
|
"Transfer amount must be a positive number."
|
4753
4676
|
);
|
4754
4677
|
}
|
@@ -4764,10 +4687,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4764
4687
|
* @param txParams - The optional transaction parameters.
|
4765
4688
|
* @returns A promise that resolves to the transaction response.
|
4766
4689
|
*/
|
4767
|
-
async transferToContract(contractId, amount, assetId =
|
4768
|
-
if ((0,
|
4769
|
-
throw new
|
4770
|
-
|
4690
|
+
async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
|
4691
|
+
if ((0, import_math17.bn)(amount).lte(0)) {
|
4692
|
+
throw new import_errors15.FuelError(
|
4693
|
+
import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4771
4694
|
"Transfer amount must be a positive number."
|
4772
4695
|
);
|
4773
4696
|
}
|
@@ -4776,7 +4699,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4776
4699
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4777
4700
|
const { script, scriptData } = await assembleTransferToContractScript({
|
4778
4701
|
hexlifiedContractId: contractAddress.toB256(),
|
4779
|
-
amountToTransfer: (0,
|
4702
|
+
amountToTransfer: (0, import_math17.bn)(amount),
|
4780
4703
|
assetId
|
4781
4704
|
});
|
4782
4705
|
const request = new ScriptTransactionRequest({
|
@@ -4787,9 +4710,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4787
4710
|
request.addContractInputAndOutput(contractAddress);
|
4788
4711
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
4789
4712
|
request,
|
4790
|
-
[{ amount: (0,
|
4713
|
+
[{ amount: (0, import_math17.bn)(amount), assetId: String(assetId) }]
|
4791
4714
|
);
|
4792
|
-
request.gasLimit = (0,
|
4715
|
+
request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
|
4793
4716
|
this.validateGas({
|
4794
4717
|
gasUsed,
|
4795
4718
|
gasPrice: request.gasPrice,
|
@@ -4810,25 +4733,25 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4810
4733
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4811
4734
|
const { minGasPrice } = this.provider.getGasConfig();
|
4812
4735
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
4813
|
-
const recipientDataArray = (0,
|
4736
|
+
const recipientDataArray = (0, import_utils27.arrayify)(
|
4814
4737
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4815
4738
|
);
|
4816
|
-
const amountDataArray = (0,
|
4817
|
-
"0x".concat((0,
|
4739
|
+
const amountDataArray = (0, import_utils27.arrayify)(
|
4740
|
+
"0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
4818
4741
|
);
|
4819
4742
|
const script = new Uint8Array([
|
4820
|
-
...(0,
|
4743
|
+
...(0, import_utils27.arrayify)(withdrawScript.bytes),
|
4821
4744
|
...recipientDataArray,
|
4822
4745
|
...amountDataArray
|
4823
4746
|
]);
|
4824
4747
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
4825
4748
|
const request = new ScriptTransactionRequest(params);
|
4826
|
-
const forwardingQuantities = [{ amount: (0,
|
4749
|
+
const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
|
4827
4750
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
4828
4751
|
request,
|
4829
4752
|
forwardingQuantities
|
4830
4753
|
);
|
4831
|
-
request.gasLimit = (0,
|
4754
|
+
request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
|
4832
4755
|
this.validateGas({
|
4833
4756
|
gasUsed,
|
4834
4757
|
gasPrice: request.gasPrice,
|
@@ -4840,7 +4763,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4840
4763
|
}
|
4841
4764
|
async signMessage(message) {
|
4842
4765
|
if (!this._connector) {
|
4843
|
-
throw new
|
4766
|
+
throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
4844
4767
|
}
|
4845
4768
|
return this._connector.signMessage(this.address.toString(), message);
|
4846
4769
|
}
|
@@ -4852,8 +4775,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4852
4775
|
*/
|
4853
4776
|
async signTransaction(transactionRequestLike) {
|
4854
4777
|
if (!this._connector) {
|
4855
|
-
throw new
|
4856
|
-
|
4778
|
+
throw new import_errors15.FuelError(
|
4779
|
+
import_errors15.ErrorCode.MISSING_CONNECTOR,
|
4857
4780
|
"A connector is required to sign transactions."
|
4858
4781
|
);
|
4859
4782
|
}
|
@@ -4900,14 +4823,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4900
4823
|
minGasPrice
|
4901
4824
|
}) {
|
4902
4825
|
if (minGasPrice.gt(gasPrice)) {
|
4903
|
-
throw new
|
4904
|
-
|
4826
|
+
throw new import_errors15.FuelError(
|
4827
|
+
import_errors15.ErrorCode.GAS_PRICE_TOO_LOW,
|
4905
4828
|
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
4906
4829
|
);
|
4907
4830
|
}
|
4908
4831
|
if (gasUsed.gt(gasLimit)) {
|
4909
|
-
throw new
|
4910
|
-
|
4832
|
+
throw new import_errors15.FuelError(
|
4833
|
+
import_errors15.ErrorCode.GAS_LIMIT_TOO_LOW,
|
4911
4834
|
`Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
|
4912
4835
|
);
|
4913
4836
|
}
|
@@ -4918,8 +4841,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4918
4841
|
var import_address5 = require("@fuel-ts/address");
|
4919
4842
|
var import_crypto = require("@fuel-ts/crypto");
|
4920
4843
|
var import_hasher2 = require("@fuel-ts/hasher");
|
4921
|
-
var
|
4922
|
-
var
|
4844
|
+
var import_math18 = require("@fuel-ts/math");
|
4845
|
+
var import_utils28 = require("@fuel-ts/utils");
|
4923
4846
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
4924
4847
|
var Signer = class {
|
4925
4848
|
address;
|
@@ -4938,10 +4861,10 @@ var Signer = class {
|
|
4938
4861
|
privateKey = `0x${privateKey}`;
|
4939
4862
|
}
|
4940
4863
|
}
|
4941
|
-
const privateKeyBytes = (0,
|
4942
|
-
this.privateKey = (0,
|
4943
|
-
this.publicKey = (0,
|
4944
|
-
this.compressedPublicKey = (0,
|
4864
|
+
const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
|
4865
|
+
this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
|
4866
|
+
this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
4867
|
+
this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
4945
4868
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
4946
4869
|
}
|
4947
4870
|
/**
|
@@ -4955,11 +4878,11 @@ var Signer = class {
|
|
4955
4878
|
* @returns hashed signature
|
4956
4879
|
*/
|
4957
4880
|
sign(data) {
|
4958
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
4959
|
-
const r = (0,
|
4960
|
-
const s = (0,
|
4881
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
|
4882
|
+
const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
4883
|
+
const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
4961
4884
|
s[0] |= (signature.recovery || 0) << 7;
|
4962
|
-
return (0,
|
4885
|
+
return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
|
4963
4886
|
}
|
4964
4887
|
/**
|
4965
4888
|
* Add point on the current elliptic curve
|
@@ -4968,8 +4891,8 @@ var Signer = class {
|
|
4968
4891
|
* @returns compressed point on the curve
|
4969
4892
|
*/
|
4970
4893
|
addPoint(point) {
|
4971
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4972
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4894
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
|
4895
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
|
4973
4896
|
const result = p0.add(p1);
|
4974
4897
|
return `0x${result.toHex(true)}`;
|
4975
4898
|
}
|
@@ -4981,16 +4904,16 @@ var Signer = class {
|
|
4981
4904
|
* @returns public key from signature from the
|
4982
4905
|
*/
|
4983
4906
|
static recoverPublicKey(data, signature) {
|
4984
|
-
const signedMessageBytes = (0,
|
4907
|
+
const signedMessageBytes = (0, import_utils28.arrayify)(signature);
|
4985
4908
|
const r = signedMessageBytes.slice(0, 32);
|
4986
4909
|
const s = signedMessageBytes.slice(32, 64);
|
4987
4910
|
const recoveryParam = (s[0] & 128) >> 7;
|
4988
4911
|
s[0] &= 127;
|
4989
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
4912
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
|
4990
4913
|
recoveryParam
|
4991
4914
|
);
|
4992
|
-
const publicKey = sig.recoverPublicKey((0,
|
4993
|
-
return (0,
|
4915
|
+
const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
|
4916
|
+
return (0, import_utils28.hexlify)(publicKey);
|
4994
4917
|
}
|
4995
4918
|
/**
|
4996
4919
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5009,7 +4932,7 @@ var Signer = class {
|
|
5009
4932
|
* @returns random 32-byte hashed
|
5010
4933
|
*/
|
5011
4934
|
static generatePrivateKey(entropy) {
|
5012
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
4935
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
5013
4936
|
}
|
5014
4937
|
/**
|
5015
4938
|
* Extended publicKey from a compact publicKey
|
@@ -5018,16 +4941,16 @@ var Signer = class {
|
|
5018
4941
|
* @returns extended publicKey
|
5019
4942
|
*/
|
5020
4943
|
static extendPublicKey(publicKey) {
|
5021
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5022
|
-
return (0,
|
4944
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
|
4945
|
+
return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
|
5023
4946
|
}
|
5024
4947
|
};
|
5025
4948
|
|
5026
4949
|
// src/wallet/keystore-wallet.ts
|
5027
4950
|
var import_address6 = require("@fuel-ts/address");
|
5028
4951
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5029
|
-
var
|
5030
|
-
var
|
4952
|
+
var import_errors16 = require("@fuel-ts/errors");
|
4953
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5031
4954
|
var import_uuid = require("uuid");
|
5032
4955
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5033
4956
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5104,13 +5027,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5104
5027
|
const macHashUint8Array = (0, import_crypto2.keccak256)(data);
|
5105
5028
|
const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
|
5106
5029
|
if (mac !== macHash) {
|
5107
|
-
throw new
|
5108
|
-
|
5030
|
+
throw new import_errors16.FuelError(
|
5031
|
+
import_errors16.ErrorCode.INVALID_PASSWORD,
|
5109
5032
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
5110
5033
|
);
|
5111
5034
|
}
|
5112
5035
|
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5113
|
-
const privateKey = (0,
|
5036
|
+
const privateKey = (0, import_utils29.hexlify)(buffer);
|
5114
5037
|
return privateKey;
|
5115
5038
|
}
|
5116
5039
|
|
@@ -5155,7 +5078,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5155
5078
|
*/
|
5156
5079
|
async signMessage(message) {
|
5157
5080
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5158
|
-
return (0,
|
5081
|
+
return (0, import_utils30.hexlify)(signedMessage);
|
5159
5082
|
}
|
5160
5083
|
/**
|
5161
5084
|
* Signs a transaction with the wallet's private key.
|
@@ -5168,7 +5091,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5168
5091
|
const chainId = this.provider.getChainId();
|
5169
5092
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5170
5093
|
const signature = await this.signer().sign(hashedTransaction);
|
5171
|
-
return (0,
|
5094
|
+
return (0, import_utils30.hexlify)(signature);
|
5172
5095
|
}
|
5173
5096
|
/**
|
5174
5097
|
* Populates a transaction with the witnesses signature.
|
@@ -5227,17 +5150,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5227
5150
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5228
5151
|
|
5229
5152
|
// src/hdwallet/hdwallet.ts
|
5230
|
-
var
|
5153
|
+
var import_errors19 = require("@fuel-ts/errors");
|
5231
5154
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5232
|
-
var
|
5233
|
-
var
|
5155
|
+
var import_math19 = require("@fuel-ts/math");
|
5156
|
+
var import_utils34 = require("@fuel-ts/utils");
|
5234
5157
|
var import_ethers3 = require("ethers");
|
5235
5158
|
|
5236
5159
|
// src/mnemonic/mnemonic.ts
|
5237
5160
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5238
|
-
var
|
5161
|
+
var import_errors18 = require("@fuel-ts/errors");
|
5239
5162
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5240
|
-
var
|
5163
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5241
5164
|
var import_ethers2 = require("ethers");
|
5242
5165
|
|
5243
5166
|
// src/wordlists/words/english.ts
|
@@ -7293,9 +7216,9 @@ var english = [
|
|
7293
7216
|
];
|
7294
7217
|
|
7295
7218
|
// src/mnemonic/utils.ts
|
7296
|
-
var
|
7219
|
+
var import_errors17 = require("@fuel-ts/errors");
|
7297
7220
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7298
|
-
var
|
7221
|
+
var import_utils31 = require("@fuel-ts/utils");
|
7299
7222
|
function toUtf8Bytes(stri) {
|
7300
7223
|
const str = stri.normalize("NFKD");
|
7301
7224
|
const result = [];
|
@@ -7310,8 +7233,8 @@ function toUtf8Bytes(stri) {
|
|
7310
7233
|
i += 1;
|
7311
7234
|
const c2 = str.charCodeAt(i);
|
7312
7235
|
if (i >= str.length || (c2 & 64512) !== 56320) {
|
7313
|
-
throw new
|
7314
|
-
|
7236
|
+
throw new import_errors17.FuelError(
|
7237
|
+
import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
|
7315
7238
|
"Invalid UTF-8 in the input string."
|
7316
7239
|
);
|
7317
7240
|
}
|
@@ -7362,20 +7285,20 @@ function entropyToMnemonicIndices(entropy) {
|
|
7362
7285
|
}
|
7363
7286
|
}
|
7364
7287
|
const checksumBits = entropy.length / 4;
|
7365
|
-
const checksum = (0,
|
7288
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7366
7289
|
indices[indices.length - 1] <<= checksumBits;
|
7367
7290
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7368
7291
|
return indices;
|
7369
7292
|
}
|
7370
7293
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7371
7294
|
const size = Math.ceil(11 * words.length / 8);
|
7372
|
-
const entropy = (0,
|
7295
|
+
const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
|
7373
7296
|
let offset = 0;
|
7374
7297
|
for (let i = 0; i < words.length; i += 1) {
|
7375
7298
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
7376
7299
|
if (index === -1) {
|
7377
|
-
throw new
|
7378
|
-
|
7300
|
+
throw new import_errors17.FuelError(
|
7301
|
+
import_errors17.ErrorCode.INVALID_MNEMONIC,
|
7379
7302
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
7380
7303
|
);
|
7381
7304
|
}
|
@@ -7389,10 +7312,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7389
7312
|
const entropyBits = 32 * words.length / 3;
|
7390
7313
|
const checksumBits = words.length / 3;
|
7391
7314
|
const checksumMask = getUpperMask(checksumBits);
|
7392
|
-
const checksum = (0,
|
7315
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7393
7316
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7394
|
-
throw new
|
7395
|
-
|
7317
|
+
throw new import_errors17.FuelError(
|
7318
|
+
import_errors17.ErrorCode.INVALID_CHECKSUM,
|
7396
7319
|
"Checksum validation failed for the provided mnemonic."
|
7397
7320
|
);
|
7398
7321
|
}
|
@@ -7406,16 +7329,16 @@ var TestnetPRV = "0x04358394";
|
|
7406
7329
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
7407
7330
|
function assertWordList(wordlist) {
|
7408
7331
|
if (wordlist.length !== 2048) {
|
7409
|
-
throw new
|
7410
|
-
|
7332
|
+
throw new import_errors18.FuelError(
|
7333
|
+
import_errors18.ErrorCode.INVALID_WORD_LIST,
|
7411
7334
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
7412
7335
|
);
|
7413
7336
|
}
|
7414
7337
|
}
|
7415
7338
|
function assertEntropy(entropy) {
|
7416
7339
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
7417
|
-
throw new
|
7418
|
-
|
7340
|
+
throw new import_errors18.FuelError(
|
7341
|
+
import_errors18.ErrorCode.INVALID_ENTROPY,
|
7419
7342
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
7420
7343
|
);
|
7421
7344
|
}
|
@@ -7425,7 +7348,7 @@ function assertMnemonic(words) {
|
|
7425
7348
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
7426
7349
|
", "
|
7427
7350
|
)}] words, but got ${words.length}.`;
|
7428
|
-
throw new
|
7351
|
+
throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
7429
7352
|
}
|
7430
7353
|
}
|
7431
7354
|
var Mnemonic = class {
|
@@ -7464,7 +7387,7 @@ var Mnemonic = class {
|
|
7464
7387
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7465
7388
|
const words = getWords(phrase);
|
7466
7389
|
assertMnemonic(words);
|
7467
|
-
return (0,
|
7390
|
+
return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7468
7391
|
}
|
7469
7392
|
/**
|
7470
7393
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7472,7 +7395,7 @@ var Mnemonic = class {
|
|
7472
7395
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7473
7396
|
*/
|
7474
7397
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7475
|
-
const entropyBytes = (0,
|
7398
|
+
const entropyBytes = (0, import_utils32.arrayify)(entropy);
|
7476
7399
|
assertWordList(wordlist);
|
7477
7400
|
assertEntropy(entropyBytes);
|
7478
7401
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7541,14 +7464,14 @@ var Mnemonic = class {
|
|
7541
7464
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7542
7465
|
*/
|
7543
7466
|
static masterKeysFromSeed(seed) {
|
7544
|
-
const seedArray = (0,
|
7467
|
+
const seedArray = (0, import_utils32.arrayify)(seed);
|
7545
7468
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7546
|
-
throw new
|
7547
|
-
|
7469
|
+
throw new import_errors18.FuelError(
|
7470
|
+
import_errors18.ErrorCode.INVALID_SEED,
|
7548
7471
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7549
7472
|
);
|
7550
7473
|
}
|
7551
|
-
return (0,
|
7474
|
+
return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
|
7552
7475
|
}
|
7553
7476
|
/**
|
7554
7477
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7559,22 +7482,22 @@ var Mnemonic = class {
|
|
7559
7482
|
*/
|
7560
7483
|
static seedToExtendedKey(seed, testnet = false) {
|
7561
7484
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7562
|
-
const prefix = (0,
|
7485
|
+
const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7563
7486
|
const depth = "0x00";
|
7564
7487
|
const fingerprint = "0x00000000";
|
7565
7488
|
const index = "0x00000000";
|
7566
7489
|
const chainCode = masterKey.slice(32);
|
7567
7490
|
const privateKey = masterKey.slice(0, 32);
|
7568
|
-
const extendedKey = (0,
|
7491
|
+
const extendedKey = (0, import_utils32.concat)([
|
7569
7492
|
prefix,
|
7570
7493
|
depth,
|
7571
7494
|
fingerprint,
|
7572
7495
|
index,
|
7573
7496
|
chainCode,
|
7574
|
-
(0,
|
7497
|
+
(0, import_utils32.concat)(["0x00", privateKey])
|
7575
7498
|
]);
|
7576
7499
|
const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7577
|
-
return (0, import_ethers2.encodeBase58)((0,
|
7500
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
|
7578
7501
|
}
|
7579
7502
|
/**
|
7580
7503
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7589,7 +7512,7 @@ var Mnemonic = class {
|
|
7589
7512
|
* @returns A randomly generated mnemonic
|
7590
7513
|
*/
|
7591
7514
|
static generate(size = 32, extraEntropy = "") {
|
7592
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
7515
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7593
7516
|
return Mnemonic.entropyToMnemonic(entropy);
|
7594
7517
|
}
|
7595
7518
|
};
|
@@ -7597,12 +7520,12 @@ var mnemonic_default = Mnemonic;
|
|
7597
7520
|
|
7598
7521
|
// src/hdwallet/hdwallet.ts
|
7599
7522
|
var HARDENED_INDEX = 2147483648;
|
7600
|
-
var MainnetPRV2 = (0,
|
7601
|
-
var MainnetPUB = (0,
|
7602
|
-
var TestnetPRV2 = (0,
|
7603
|
-
var TestnetPUB = (0,
|
7523
|
+
var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
|
7524
|
+
var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
|
7525
|
+
var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
|
7526
|
+
var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
|
7604
7527
|
function base58check(data) {
|
7605
|
-
return (0, import_ethers3.encodeBase58)((0,
|
7528
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7606
7529
|
}
|
7607
7530
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7608
7531
|
if (isPublic) {
|
@@ -7611,17 +7534,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7611
7534
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7612
7535
|
}
|
7613
7536
|
function isPublicExtendedKey(extendedKey) {
|
7614
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7537
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
|
7615
7538
|
}
|
7616
7539
|
function isValidExtendedKey(extendedKey) {
|
7617
7540
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7618
|
-
(0,
|
7541
|
+
(0, import_utils34.hexlify)(extendedKey.slice(0, 4))
|
7619
7542
|
);
|
7620
7543
|
}
|
7621
7544
|
function parsePath(path2, depth = 0) {
|
7622
7545
|
const components = path2.split("/");
|
7623
7546
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
7624
|
-
throw new
|
7547
|
+
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
7625
7548
|
}
|
7626
7549
|
if (components[0] === "m") {
|
7627
7550
|
components.shift();
|
@@ -7633,8 +7556,8 @@ function parsePath(path2, depth = 0) {
|
|
7633
7556
|
var HDWallet = class {
|
7634
7557
|
depth = 0;
|
7635
7558
|
index = 0;
|
7636
|
-
fingerprint = (0,
|
7637
|
-
parentFingerprint = (0,
|
7559
|
+
fingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7560
|
+
parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7638
7561
|
privateKey;
|
7639
7562
|
publicKey;
|
7640
7563
|
chainCode;
|
@@ -7646,16 +7569,16 @@ var HDWallet = class {
|
|
7646
7569
|
constructor(config) {
|
7647
7570
|
if (config.privateKey) {
|
7648
7571
|
const signer = new Signer(config.privateKey);
|
7649
|
-
this.publicKey = (0,
|
7650
|
-
this.privateKey = (0,
|
7572
|
+
this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
|
7573
|
+
this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
|
7651
7574
|
} else {
|
7652
7575
|
if (!config.publicKey) {
|
7653
|
-
throw new
|
7654
|
-
|
7576
|
+
throw new import_errors19.FuelError(
|
7577
|
+
import_errors19.ErrorCode.HD_WALLET_ERROR,
|
7655
7578
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7656
7579
|
);
|
7657
7580
|
}
|
7658
|
-
this.publicKey = (0,
|
7581
|
+
this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
|
7659
7582
|
}
|
7660
7583
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7661
7584
|
this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
@@ -7674,28 +7597,28 @@ var HDWallet = class {
|
|
7674
7597
|
* @returns A new instance of HDWallet on the derived index
|
7675
7598
|
*/
|
7676
7599
|
deriveIndex(index) {
|
7677
|
-
const privateKey = this.privateKey && (0,
|
7678
|
-
const publicKey = (0,
|
7679
|
-
const chainCode = (0,
|
7600
|
+
const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
|
7601
|
+
const publicKey = (0, import_utils34.arrayify)(this.publicKey);
|
7602
|
+
const chainCode = (0, import_utils34.arrayify)(this.chainCode);
|
7680
7603
|
const data = new Uint8Array(37);
|
7681
7604
|
if (index & HARDENED_INDEX) {
|
7682
7605
|
if (!privateKey) {
|
7683
|
-
throw new
|
7684
|
-
|
7606
|
+
throw new import_errors19.FuelError(
|
7607
|
+
import_errors19.ErrorCode.HD_WALLET_ERROR,
|
7685
7608
|
"Cannot derive a hardened index without a private Key."
|
7686
7609
|
);
|
7687
7610
|
}
|
7688
7611
|
data.set(privateKey, 1);
|
7689
7612
|
} else {
|
7690
|
-
data.set((0,
|
7613
|
+
data.set((0, import_utils34.arrayify)(this.publicKey));
|
7691
7614
|
}
|
7692
|
-
data.set((0,
|
7693
|
-
const bytes = (0,
|
7615
|
+
data.set((0, import_math19.toBytes)(index, 4), 33);
|
7616
|
+
const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
|
7694
7617
|
const IL = bytes.slice(0, 32);
|
7695
7618
|
const IR = bytes.slice(32);
|
7696
7619
|
if (privateKey) {
|
7697
7620
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7698
|
-
const ki = (0,
|
7621
|
+
const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
7699
7622
|
return new HDWallet({
|
7700
7623
|
privateKey: ki,
|
7701
7624
|
chainCode: IR,
|
@@ -7704,7 +7627,7 @@ var HDWallet = class {
|
|
7704
7627
|
parentFingerprint: this.fingerprint
|
7705
7628
|
});
|
7706
7629
|
}
|
7707
|
-
const signer = new Signer((0,
|
7630
|
+
const signer = new Signer((0, import_utils34.hexlify)(IL));
|
7708
7631
|
const Ki = signer.addPoint(publicKey);
|
7709
7632
|
return new HDWallet({
|
7710
7633
|
publicKey: Ki,
|
@@ -7733,18 +7656,18 @@ var HDWallet = class {
|
|
7733
7656
|
*/
|
7734
7657
|
toExtendedKey(isPublic = false, testnet = false) {
|
7735
7658
|
if (this.depth >= 256) {
|
7736
|
-
throw new
|
7737
|
-
|
7659
|
+
throw new import_errors19.FuelError(
|
7660
|
+
import_errors19.ErrorCode.HD_WALLET_ERROR,
|
7738
7661
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
7739
7662
|
);
|
7740
7663
|
}
|
7741
7664
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7742
|
-
const depth = (0,
|
7665
|
+
const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
|
7743
7666
|
const parentFingerprint = this.parentFingerprint;
|
7744
|
-
const index = (0,
|
7667
|
+
const index = (0, import_math19.toHex)(this.index, 4);
|
7745
7668
|
const chainCode = this.chainCode;
|
7746
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
7747
|
-
const extendedKey = (0,
|
7669
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
|
7670
|
+
const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7748
7671
|
return base58check(extendedKey);
|
7749
7672
|
}
|
7750
7673
|
/**
|
@@ -7756,34 +7679,34 @@ var HDWallet = class {
|
|
7756
7679
|
static fromSeed(seed) {
|
7757
7680
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7758
7681
|
return new HDWallet({
|
7759
|
-
chainCode: (0,
|
7760
|
-
privateKey: (0,
|
7682
|
+
chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
|
7683
|
+
privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
|
7761
7684
|
});
|
7762
7685
|
}
|
7763
7686
|
static fromExtendedKey(extendedKey) {
|
7764
7687
|
const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
|
7765
|
-
const bytes = (0,
|
7688
|
+
const bytes = (0, import_utils34.arrayify)(decoded);
|
7766
7689
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7767
7690
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7768
|
-
throw new
|
7691
|
+
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
7769
7692
|
}
|
7770
7693
|
if (!validChecksum) {
|
7771
|
-
throw new
|
7694
|
+
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7772
7695
|
}
|
7773
7696
|
const depth = bytes[4];
|
7774
|
-
const parentFingerprint = (0,
|
7775
|
-
const index = parseInt((0,
|
7776
|
-
const chainCode = (0,
|
7697
|
+
const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
|
7698
|
+
const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
7699
|
+
const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
|
7777
7700
|
const key = bytes.slice(45, 78);
|
7778
7701
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7779
|
-
throw new
|
7780
|
-
|
7702
|
+
throw new import_errors19.FuelError(
|
7703
|
+
import_errors19.ErrorCode.HD_WALLET_ERROR,
|
7781
7704
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
7782
7705
|
);
|
7783
7706
|
}
|
7784
7707
|
if (isPublicExtendedKey(bytes)) {
|
7785
7708
|
if (key[0] !== 3) {
|
7786
|
-
throw new
|
7709
|
+
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
7787
7710
|
}
|
7788
7711
|
return new HDWallet({
|
7789
7712
|
publicKey: key,
|
@@ -7794,7 +7717,7 @@ var HDWallet = class {
|
|
7794
7717
|
});
|
7795
7718
|
}
|
7796
7719
|
if (key[0] !== 0) {
|
7797
|
-
throw new
|
7720
|
+
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
7798
7721
|
}
|
7799
7722
|
return new HDWallet({
|
7800
7723
|
privateKey: key.slice(1),
|
@@ -7987,9 +7910,9 @@ var generateTestWallet = async (provider, quantities) => {
|
|
7987
7910
|
};
|
7988
7911
|
|
7989
7912
|
// src/test-utils/launchNode.ts
|
7990
|
-
var
|
7991
|
-
var
|
7992
|
-
var
|
7913
|
+
var import_configs12 = require("@fuel-ts/address/configs");
|
7914
|
+
var import_math20 = require("@fuel-ts/math");
|
7915
|
+
var import_utils35 = require("@fuel-ts/utils");
|
7993
7916
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
7994
7917
|
var import_child_process = require("child_process");
|
7995
7918
|
var import_crypto5 = require("crypto");
|
@@ -8047,7 +7970,7 @@ var launchNode = async ({
|
|
8047
7970
|
"--poa-instant"
|
8048
7971
|
]);
|
8049
7972
|
const chainConfigPath = getFlagValueFromArgs(args, "--chain");
|
8050
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
7973
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
|
8051
7974
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8052
7975
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
8053
7976
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -8073,21 +7996,21 @@ var launchNode = async ({
|
|
8073
7996
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
8074
7997
|
}
|
8075
7998
|
const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
8076
|
-
let chainConfig =
|
7999
|
+
let chainConfig = import_utils35.defaultChainConfig;
|
8077
8000
|
if (!process.env.GENESIS_SECRET) {
|
8078
8001
|
const pk = Signer.generatePrivateKey();
|
8079
8002
|
const signer = new Signer(pk);
|
8080
|
-
process.env.GENESIS_SECRET = (0,
|
8003
|
+
process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
|
8081
8004
|
chainConfig = {
|
8082
|
-
...
|
8005
|
+
...import_utils35.defaultChainConfig,
|
8083
8006
|
initial_state: {
|
8084
|
-
...
|
8007
|
+
...import_utils35.defaultChainConfig.initial_state,
|
8085
8008
|
coins: [
|
8086
|
-
...
|
8009
|
+
...import_utils35.defaultChainConfig.initial_state.coins,
|
8087
8010
|
{
|
8088
8011
|
owner: signer.address.toHexString(),
|
8089
|
-
amount: (0,
|
8090
|
-
asset_id:
|
8012
|
+
amount: (0, import_math20.toHex)(1e9),
|
8013
|
+
asset_id: import_configs12.BaseAssetId
|
8091
8014
|
}
|
8092
8015
|
]
|
8093
8016
|
}
|
@@ -8155,7 +8078,7 @@ var launchNode = async ({
|
|
8155
8078
|
var generateWallets = async (count, provider) => {
|
8156
8079
|
const wallets = [];
|
8157
8080
|
for (let i = 0; i < count; i += 1) {
|
8158
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
8081
|
+
const wallet = await generateTestWallet(provider, [[1e3, import_configs12.BaseAssetId]]);
|
8159
8082
|
wallets.push(wallet);
|
8160
8083
|
}
|
8161
8084
|
return wallets;
|