@fuel-ts/account 0.0.0-rc-1936-20240328132546 → 0.0.0-rc-1895-20240328133917
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 +160 -28
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +572 -483
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +350 -256
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +3 -0
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/types.d.ts +5 -0
- package/dist/providers/transaction-request/types.d.ts.map +1 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +5 -2
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +30 -0
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils.global.js +160 -15
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +532 -438
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +320 -218
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
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_utils31 = 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_configs12 = require("@fuel-ts/address/configs");
|
66
|
+
var import_errors16 = require("@fuel-ts/errors");
|
67
67
|
var import_interfaces = require("@fuel-ts/interfaces");
|
68
|
-
var
|
69
|
-
var
|
68
|
+
var import_math18 = require("@fuel-ts/math");
|
69
|
+
var import_utils28 = 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_errors14 = require("@fuel-ts/errors");
|
110
|
+
var import_math15 = require("@fuel-ts/math");
|
111
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
112
|
+
var import_utils23 = require("@fuel-ts/utils");
|
113
113
|
var import_versions = require("@fuel-ts/versions");
|
114
|
-
var
|
114
|
+
var import_utils24 = 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_configs7 = require("@fuel-ts/address/configs");
|
1188
|
+
var import_math7 = require("@fuel-ts/math");
|
1189
|
+
var import_transactions6 = require("@fuel-ts/transactions");
|
1190
1190
|
var import_utils9 = require("@fuel-ts/utils");
|
1191
1191
|
|
1192
1192
|
// src/providers/resource.ts
|
@@ -1517,6 +1517,68 @@ 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
|
+
if (import_configs6.PANIC_REASONS.includes(status.reason)) {
|
1528
|
+
errorMessage = `${errorMessage}
|
1529
|
+
|
1530
|
+
You can read more about this error at:
|
1531
|
+
|
1532
|
+
${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
|
1533
|
+
}
|
1534
|
+
return errorMessage;
|
1535
|
+
};
|
1536
|
+
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
1537
|
+
var assembleRevertError = (receipts, logs) => {
|
1538
|
+
let errorMessage = "The transaction reverted with an unknown reason.";
|
1539
|
+
const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
|
1540
|
+
if (revertReceipt) {
|
1541
|
+
const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
|
1542
|
+
switch (reasonHex) {
|
1543
|
+
case import_configs6.FAILED_REQUIRE_SIGNAL: {
|
1544
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
|
1545
|
+
break;
|
1546
|
+
}
|
1547
|
+
case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
|
1548
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1549
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
1550
|
+
break;
|
1551
|
+
}
|
1552
|
+
case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
|
1553
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1554
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
1555
|
+
break;
|
1556
|
+
}
|
1557
|
+
case import_configs6.FAILED_ASSERT_SIGNAL:
|
1558
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
1559
|
+
break;
|
1560
|
+
case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
1561
|
+
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1562
|
+
break;
|
1563
|
+
default:
|
1564
|
+
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
1565
|
+
}
|
1566
|
+
}
|
1567
|
+
return errorMessage;
|
1568
|
+
};
|
1569
|
+
var extractTxError = (params) => {
|
1570
|
+
const { receipts, status, logs } = params;
|
1571
|
+
const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
|
1572
|
+
let err = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
1573
|
+
err += `
|
1574
|
+
|
1575
|
+
logs: ${JSON.stringify(logs, null, 2)}`;
|
1576
|
+
err += `
|
1577
|
+
|
1578
|
+
receipts: ${JSON.stringify(receipts, null, 2)}`;
|
1579
|
+
return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, err);
|
1580
|
+
};
|
1581
|
+
|
1520
1582
|
// src/providers/transaction-request/errors.ts
|
1521
1583
|
var NoWitnessAtIndexError = class extends Error {
|
1522
1584
|
constructor(index) {
|
@@ -1567,10 +1629,10 @@ var BaseTransactionRequest = class {
|
|
1567
1629
|
outputs,
|
1568
1630
|
witnesses
|
1569
1631
|
} = {}) {
|
1570
|
-
this.gasPrice = (0,
|
1632
|
+
this.gasPrice = (0, import_math7.bn)(gasPrice);
|
1571
1633
|
this.maturity = maturity ?? 0;
|
1572
|
-
this.witnessLimit = witnessLimit ? (0,
|
1573
|
-
this.maxFee = maxFee ? (0,
|
1634
|
+
this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
|
1635
|
+
this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
|
1574
1636
|
this.inputs = inputs ?? [];
|
1575
1637
|
this.outputs = outputs ?? [];
|
1576
1638
|
this.witnesses = witnesses ?? [];
|
@@ -1579,20 +1641,20 @@ var BaseTransactionRequest = class {
|
|
1579
1641
|
let policyTypes = 0;
|
1580
1642
|
const policies = [];
|
1581
1643
|
if (req.gasPrice) {
|
1582
|
-
policyTypes +=
|
1583
|
-
policies.push({ data: req.gasPrice, type:
|
1644
|
+
policyTypes += import_transactions6.PolicyType.GasPrice;
|
1645
|
+
policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
|
1584
1646
|
}
|
1585
1647
|
if (req.witnessLimit) {
|
1586
|
-
policyTypes +=
|
1587
|
-
policies.push({ data: req.witnessLimit, type:
|
1648
|
+
policyTypes += import_transactions6.PolicyType.WitnessLimit;
|
1649
|
+
policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
|
1588
1650
|
}
|
1589
1651
|
if (req.maturity > 0) {
|
1590
|
-
policyTypes +=
|
1591
|
-
policies.push({ data: req.maturity, type:
|
1652
|
+
policyTypes += import_transactions6.PolicyType.Maturity;
|
1653
|
+
policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
|
1592
1654
|
}
|
1593
1655
|
if (req.maxFee) {
|
1594
|
-
policyTypes +=
|
1595
|
-
policies.push({ data: req.maxFee, type:
|
1656
|
+
policyTypes += import_transactions6.PolicyType.MaxFee;
|
1657
|
+
policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
|
1596
1658
|
}
|
1597
1659
|
return {
|
1598
1660
|
policyTypes,
|
@@ -1626,7 +1688,7 @@ var BaseTransactionRequest = class {
|
|
1626
1688
|
* @returns The transaction bytes.
|
1627
1689
|
*/
|
1628
1690
|
toTransactionBytes() {
|
1629
|
-
return new
|
1691
|
+
return new import_transactions6.TransactionCoder().encode(this.toTransaction());
|
1630
1692
|
}
|
1631
1693
|
/**
|
1632
1694
|
* @hidden
|
@@ -1666,7 +1728,7 @@ var BaseTransactionRequest = class {
|
|
1666
1728
|
* @returns The index of the created witness.
|
1667
1729
|
*/
|
1668
1730
|
addEmptyWitness() {
|
1669
|
-
this.addWitness((0, import_utils9.concat)([
|
1731
|
+
this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
|
1670
1732
|
return this.witnesses.length - 1;
|
1671
1733
|
}
|
1672
1734
|
/**
|
@@ -1717,7 +1779,7 @@ var BaseTransactionRequest = class {
|
|
1717
1779
|
*/
|
1718
1780
|
getCoinInputs() {
|
1719
1781
|
return this.inputs.filter(
|
1720
|
-
(input) => input.type ===
|
1782
|
+
(input) => input.type === import_transactions6.InputType.Coin
|
1721
1783
|
);
|
1722
1784
|
}
|
1723
1785
|
/**
|
@@ -1727,7 +1789,7 @@ var BaseTransactionRequest = class {
|
|
1727
1789
|
*/
|
1728
1790
|
getCoinOutputs() {
|
1729
1791
|
return this.outputs.filter(
|
1730
|
-
(output) => output.type ===
|
1792
|
+
(output) => output.type === import_transactions6.OutputType.Coin
|
1731
1793
|
);
|
1732
1794
|
}
|
1733
1795
|
/**
|
@@ -1737,7 +1799,7 @@ var BaseTransactionRequest = class {
|
|
1737
1799
|
*/
|
1738
1800
|
getChangeOutputs() {
|
1739
1801
|
return this.outputs.filter(
|
1740
|
-
(output) => output.type ===
|
1802
|
+
(output) => output.type === import_transactions6.OutputType.Change
|
1741
1803
|
);
|
1742
1804
|
}
|
1743
1805
|
/**
|
@@ -1749,9 +1811,9 @@ var BaseTransactionRequest = class {
|
|
1749
1811
|
const ownerAddress = (0, import_address.addressify)(owner);
|
1750
1812
|
const found = this.inputs.find((input) => {
|
1751
1813
|
switch (input.type) {
|
1752
|
-
case
|
1814
|
+
case import_transactions6.InputType.Coin:
|
1753
1815
|
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
1754
|
-
case
|
1816
|
+
case import_transactions6.InputType.Message:
|
1755
1817
|
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
1756
1818
|
default:
|
1757
1819
|
return false;
|
@@ -1780,7 +1842,7 @@ var BaseTransactionRequest = class {
|
|
1780
1842
|
}
|
1781
1843
|
const input = {
|
1782
1844
|
...coin,
|
1783
|
-
type:
|
1845
|
+
type: import_transactions6.InputType.Coin,
|
1784
1846
|
owner: owner.toB256(),
|
1785
1847
|
amount,
|
1786
1848
|
assetId,
|
@@ -1802,7 +1864,7 @@ var BaseTransactionRequest = class {
|
|
1802
1864
|
*/
|
1803
1865
|
addMessageInput(message, predicate) {
|
1804
1866
|
const { recipient, sender, amount } = message;
|
1805
|
-
const assetId =
|
1867
|
+
const assetId = import_configs7.BaseAssetId;
|
1806
1868
|
let witnessIndex;
|
1807
1869
|
if (predicate) {
|
1808
1870
|
witnessIndex = 0;
|
@@ -1814,7 +1876,7 @@ var BaseTransactionRequest = class {
|
|
1814
1876
|
}
|
1815
1877
|
const input = {
|
1816
1878
|
...message,
|
1817
|
-
type:
|
1879
|
+
type: import_transactions6.InputType.Message,
|
1818
1880
|
sender: sender.toB256(),
|
1819
1881
|
recipient: recipient.toB256(),
|
1820
1882
|
amount,
|
@@ -1884,9 +1946,9 @@ var BaseTransactionRequest = class {
|
|
1884
1946
|
* @param amount - Amount of coin.
|
1885
1947
|
* @param assetId - Asset ID of coin.
|
1886
1948
|
*/
|
1887
|
-
addCoinOutput(to, amount, assetId =
|
1949
|
+
addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
|
1888
1950
|
this.pushOutput({
|
1889
|
-
type:
|
1951
|
+
type: import_transactions6.OutputType.Coin,
|
1890
1952
|
to: (0, import_address.addressify)(to).toB256(),
|
1891
1953
|
amount,
|
1892
1954
|
assetId
|
@@ -1902,7 +1964,7 @@ var BaseTransactionRequest = class {
|
|
1902
1964
|
addCoinOutputs(to, quantities) {
|
1903
1965
|
quantities.map(coinQuantityfy).forEach((quantity) => {
|
1904
1966
|
this.pushOutput({
|
1905
|
-
type:
|
1967
|
+
type: import_transactions6.OutputType.Coin,
|
1906
1968
|
to: (0, import_address.addressify)(to).toB256(),
|
1907
1969
|
amount: quantity.amount,
|
1908
1970
|
assetId: quantity.assetId
|
@@ -1916,13 +1978,13 @@ var BaseTransactionRequest = class {
|
|
1916
1978
|
* @param to - Address of the owner.
|
1917
1979
|
* @param assetId - Asset ID of coin.
|
1918
1980
|
*/
|
1919
|
-
addChangeOutput(to, assetId =
|
1981
|
+
addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
|
1920
1982
|
const changeOutput = this.getChangeOutputs().find(
|
1921
1983
|
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
1922
1984
|
);
|
1923
1985
|
if (!changeOutput) {
|
1924
1986
|
this.pushOutput({
|
1925
|
-
type:
|
1987
|
+
type: import_transactions6.OutputType.Change,
|
1926
1988
|
to: (0, import_address.addressify)(to).toB256(),
|
1927
1989
|
assetId
|
1928
1990
|
});
|
@@ -1978,7 +2040,7 @@ var BaseTransactionRequest = class {
|
|
1978
2040
|
let idCounter = 0;
|
1979
2041
|
const generateId = () => {
|
1980
2042
|
const counterString = String(idCounter++);
|
1981
|
-
const id =
|
2043
|
+
const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
1982
2044
|
return id;
|
1983
2045
|
};
|
1984
2046
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
@@ -2000,13 +2062,13 @@ var BaseTransactionRequest = class {
|
|
2000
2062
|
assetId,
|
2001
2063
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2002
2064
|
maturity: 0,
|
2003
|
-
blockCreated: (0,
|
2004
|
-
txCreatedIdx: (0,
|
2065
|
+
blockCreated: (0, import_math7.bn)(1),
|
2066
|
+
txCreatedIdx: (0, import_math7.bn)(1)
|
2005
2067
|
}
|
2006
2068
|
]);
|
2007
2069
|
}
|
2008
2070
|
};
|
2009
|
-
updateAssetInput(
|
2071
|
+
updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
|
2010
2072
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2011
2073
|
}
|
2012
2074
|
/**
|
@@ -2017,7 +2079,7 @@ var BaseTransactionRequest = class {
|
|
2017
2079
|
*/
|
2018
2080
|
getCoinOutputsQuantities() {
|
2019
2081
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2020
|
-
amount: (0,
|
2082
|
+
amount: (0, import_math7.bn)(amount),
|
2021
2083
|
assetId: assetId.toString()
|
2022
2084
|
}));
|
2023
2085
|
return coinsQuantities;
|
@@ -2035,18 +2097,18 @@ var BaseTransactionRequest = class {
|
|
2035
2097
|
this.inputs.forEach((i) => {
|
2036
2098
|
let correspondingInput;
|
2037
2099
|
switch (i.type) {
|
2038
|
-
case
|
2039
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2100
|
+
case import_transactions6.InputType.Coin:
|
2101
|
+
correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
|
2040
2102
|
break;
|
2041
|
-
case
|
2103
|
+
case import_transactions6.InputType.Message:
|
2042
2104
|
correspondingInput = inputs.find(
|
2043
|
-
(x) => x.type ===
|
2105
|
+
(x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
|
2044
2106
|
);
|
2045
2107
|
break;
|
2046
2108
|
default:
|
2047
2109
|
return;
|
2048
2110
|
}
|
2049
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0,
|
2111
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2050
2112
|
i.predicate = correspondingInput.predicate;
|
2051
2113
|
i.predicateData = correspondingInput.predicateData;
|
2052
2114
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2056,47 +2118,47 @@ var BaseTransactionRequest = class {
|
|
2056
2118
|
};
|
2057
2119
|
|
2058
2120
|
// src/providers/transaction-request/create-transaction-request.ts
|
2059
|
-
var
|
2060
|
-
var
|
2061
|
-
var
|
2121
|
+
var import_configs9 = require("@fuel-ts/address/configs");
|
2122
|
+
var import_math9 = require("@fuel-ts/math");
|
2123
|
+
var import_transactions8 = require("@fuel-ts/transactions");
|
2062
2124
|
var import_utils13 = require("@fuel-ts/utils");
|
2063
2125
|
|
2064
2126
|
// src/providers/transaction-request/hash-transaction.ts
|
2065
|
-
var
|
2127
|
+
var import_configs8 = require("@fuel-ts/address/configs");
|
2066
2128
|
var import_hasher = require("@fuel-ts/hasher");
|
2067
|
-
var
|
2068
|
-
var
|
2129
|
+
var import_math8 = require("@fuel-ts/math");
|
2130
|
+
var import_transactions7 = require("@fuel-ts/transactions");
|
2069
2131
|
var import_utils11 = require("@fuel-ts/utils");
|
2070
2132
|
var import_ramda2 = require("ramda");
|
2071
2133
|
function hashTransaction(transactionRequest, chainId) {
|
2072
2134
|
const transaction = transactionRequest.toTransaction();
|
2073
|
-
if (transaction.type ===
|
2074
|
-
transaction.receiptsRoot =
|
2135
|
+
if (transaction.type === import_transactions7.TransactionType.Script) {
|
2136
|
+
transaction.receiptsRoot = import_configs8.ZeroBytes32;
|
2075
2137
|
}
|
2076
2138
|
transaction.inputs = transaction.inputs.map((input) => {
|
2077
2139
|
const inputClone = (0, import_ramda2.clone)(input);
|
2078
2140
|
switch (inputClone.type) {
|
2079
|
-
case
|
2141
|
+
case import_transactions7.InputType.Coin: {
|
2080
2142
|
inputClone.txPointer = {
|
2081
2143
|
blockHeight: 0,
|
2082
2144
|
txIndex: 0
|
2083
2145
|
};
|
2084
|
-
inputClone.predicateGasUsed = (0,
|
2146
|
+
inputClone.predicateGasUsed = (0, import_math8.bn)(0);
|
2085
2147
|
return inputClone;
|
2086
2148
|
}
|
2087
|
-
case
|
2088
|
-
inputClone.predicateGasUsed = (0,
|
2149
|
+
case import_transactions7.InputType.Message: {
|
2150
|
+
inputClone.predicateGasUsed = (0, import_math8.bn)(0);
|
2089
2151
|
return inputClone;
|
2090
2152
|
}
|
2091
|
-
case
|
2153
|
+
case import_transactions7.InputType.Contract: {
|
2092
2154
|
inputClone.txPointer = {
|
2093
2155
|
blockHeight: 0,
|
2094
2156
|
txIndex: 0
|
2095
2157
|
};
|
2096
|
-
inputClone.txID =
|
2158
|
+
inputClone.txID = import_configs8.ZeroBytes32;
|
2097
2159
|
inputClone.outputIndex = 0;
|
2098
|
-
inputClone.balanceRoot =
|
2099
|
-
inputClone.stateRoot =
|
2160
|
+
inputClone.balanceRoot = import_configs8.ZeroBytes32;
|
2161
|
+
inputClone.stateRoot = import_configs8.ZeroBytes32;
|
2100
2162
|
return inputClone;
|
2101
2163
|
}
|
2102
2164
|
default:
|
@@ -2106,19 +2168,19 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2106
2168
|
transaction.outputs = transaction.outputs.map((output) => {
|
2107
2169
|
const outputClone = (0, import_ramda2.clone)(output);
|
2108
2170
|
switch (outputClone.type) {
|
2109
|
-
case
|
2110
|
-
outputClone.balanceRoot =
|
2111
|
-
outputClone.stateRoot =
|
2171
|
+
case import_transactions7.OutputType.Contract: {
|
2172
|
+
outputClone.balanceRoot = import_configs8.ZeroBytes32;
|
2173
|
+
outputClone.stateRoot = import_configs8.ZeroBytes32;
|
2112
2174
|
return outputClone;
|
2113
2175
|
}
|
2114
|
-
case
|
2115
|
-
outputClone.amount = (0,
|
2176
|
+
case import_transactions7.OutputType.Change: {
|
2177
|
+
outputClone.amount = (0, import_math8.bn)(0);
|
2116
2178
|
return outputClone;
|
2117
2179
|
}
|
2118
|
-
case
|
2119
|
-
outputClone.to =
|
2120
|
-
outputClone.amount = (0,
|
2121
|
-
outputClone.assetId =
|
2180
|
+
case import_transactions7.OutputType.Variable: {
|
2181
|
+
outputClone.to = import_configs8.ZeroBytes32;
|
2182
|
+
outputClone.amount = (0, import_math8.bn)(0);
|
2183
|
+
outputClone.assetId = import_configs8.ZeroBytes32;
|
2122
2184
|
return outputClone;
|
2123
2185
|
}
|
2124
2186
|
default:
|
@@ -2128,7 +2190,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2128
2190
|
transaction.witnessesCount = 0;
|
2129
2191
|
transaction.witnesses = [];
|
2130
2192
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2131
|
-
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new
|
2193
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
|
2132
2194
|
return (0, import_hasher.sha256)(concatenatedData);
|
2133
2195
|
}
|
2134
2196
|
|
@@ -2164,7 +2226,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2164
2226
|
return new this(obj);
|
2165
2227
|
}
|
2166
2228
|
/** Type of the transaction */
|
2167
|
-
type =
|
2229
|
+
type = import_transactions8.TransactionType.Create;
|
2168
2230
|
/** Witness index of contract bytecode to create */
|
2169
2231
|
bytecodeWitnessIndex;
|
2170
2232
|
/** Salt */
|
@@ -2184,7 +2246,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2184
2246
|
} = {}) {
|
2185
2247
|
super(rest);
|
2186
2248
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2187
|
-
this.salt = (0, import_utils13.hexlify)(salt ??
|
2249
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
|
2188
2250
|
this.storageSlots = [...storageSlots ?? []];
|
2189
2251
|
}
|
2190
2252
|
/**
|
@@ -2197,12 +2259,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2197
2259
|
const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
|
2198
2260
|
const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
|
2199
2261
|
return {
|
2200
|
-
type:
|
2262
|
+
type: import_transactions8.TransactionType.Create,
|
2201
2263
|
...baseTransaction,
|
2202
2264
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2203
2265
|
bytecodeWitnessIndex,
|
2204
2266
|
storageSlotsCount: storageSlots.length,
|
2205
|
-
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) :
|
2267
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
|
2206
2268
|
storageSlots
|
2207
2269
|
};
|
2208
2270
|
}
|
@@ -2213,7 +2275,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2213
2275
|
*/
|
2214
2276
|
getContractCreatedOutputs() {
|
2215
2277
|
return this.outputs.filter(
|
2216
|
-
(output) => output.type ===
|
2278
|
+
(output) => output.type === import_transactions8.OutputType.ContractCreated
|
2217
2279
|
);
|
2218
2280
|
}
|
2219
2281
|
/**
|
@@ -2234,14 +2296,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2234
2296
|
*/
|
2235
2297
|
addContractCreatedOutput(contractId, stateRoot) {
|
2236
2298
|
this.pushOutput({
|
2237
|
-
type:
|
2299
|
+
type: import_transactions8.OutputType.ContractCreated,
|
2238
2300
|
contractId,
|
2239
2301
|
stateRoot
|
2240
2302
|
});
|
2241
2303
|
}
|
2242
2304
|
metadataGas(gasCosts) {
|
2243
2305
|
return calculateMetadataGasForTxCreate({
|
2244
|
-
contractBytesSize: (0,
|
2306
|
+
contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2245
2307
|
gasCosts,
|
2246
2308
|
stateRootSize: this.storageSlots.length,
|
2247
2309
|
txBytesSize: this.byteSize()
|
@@ -2252,9 +2314,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2252
2314
|
// src/providers/transaction-request/script-transaction-request.ts
|
2253
2315
|
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2254
2316
|
var import_address2 = require("@fuel-ts/address");
|
2255
|
-
var
|
2256
|
-
var
|
2257
|
-
var
|
2317
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
2318
|
+
var import_math10 = require("@fuel-ts/math");
|
2319
|
+
var import_transactions9 = require("@fuel-ts/transactions");
|
2258
2320
|
var import_utils15 = require("@fuel-ts/utils");
|
2259
2321
|
|
2260
2322
|
// src/providers/transaction-request/scripts.ts
|
@@ -2292,13 +2354,14 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2292
2354
|
return new this(obj);
|
2293
2355
|
}
|
2294
2356
|
/** Type of the transaction */
|
2295
|
-
type =
|
2357
|
+
type = import_transactions9.TransactionType.Script;
|
2296
2358
|
/** Gas limit for transaction */
|
2297
2359
|
gasLimit;
|
2298
2360
|
/** Script to execute */
|
2299
2361
|
script;
|
2300
2362
|
/** Script input data (parameters) */
|
2301
2363
|
scriptData;
|
2364
|
+
abis;
|
2302
2365
|
/**
|
2303
2366
|
* Constructor for `ScriptTransactionRequest`.
|
2304
2367
|
*
|
@@ -2306,9 +2369,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2306
2369
|
*/
|
2307
2370
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2308
2371
|
super(rest);
|
2309
|
-
this.gasLimit = (0,
|
2372
|
+
this.gasLimit = (0, import_math10.bn)(gasLimit);
|
2310
2373
|
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2311
2374
|
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2375
|
+
this.abis = rest.abis;
|
2312
2376
|
}
|
2313
2377
|
/**
|
2314
2378
|
* Converts the transaction request to a `TransactionScript`.
|
@@ -2319,12 +2383,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2319
2383
|
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2320
2384
|
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2321
2385
|
return {
|
2322
|
-
type:
|
2386
|
+
type: import_transactions9.TransactionType.Script,
|
2323
2387
|
scriptGasLimit: this.gasLimit,
|
2324
2388
|
...super.getBaseTransaction(),
|
2325
2389
|
scriptLength: script.length,
|
2326
2390
|
scriptDataLength: scriptData.length,
|
2327
|
-
receiptsRoot:
|
2391
|
+
receiptsRoot: import_configs10.ZeroBytes32,
|
2328
2392
|
script: (0, import_utils15.hexlify)(script),
|
2329
2393
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2330
2394
|
};
|
@@ -2336,7 +2400,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2336
2400
|
*/
|
2337
2401
|
getContractInputs() {
|
2338
2402
|
return this.inputs.filter(
|
2339
|
-
(input) => input.type ===
|
2403
|
+
(input) => input.type === import_transactions9.InputType.Contract
|
2340
2404
|
);
|
2341
2405
|
}
|
2342
2406
|
/**
|
@@ -2346,7 +2410,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2346
2410
|
*/
|
2347
2411
|
getContractOutputs() {
|
2348
2412
|
return this.outputs.filter(
|
2349
|
-
(output) => output.type ===
|
2413
|
+
(output) => output.type === import_transactions9.OutputType.Contract
|
2350
2414
|
);
|
2351
2415
|
}
|
2352
2416
|
/**
|
@@ -2356,7 +2420,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2356
2420
|
*/
|
2357
2421
|
getVariableOutputs() {
|
2358
2422
|
return this.outputs.filter(
|
2359
|
-
(output) => output.type ===
|
2423
|
+
(output) => output.type === import_transactions9.OutputType.Variable
|
2360
2424
|
);
|
2361
2425
|
}
|
2362
2426
|
/**
|
@@ -2379,7 +2443,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2379
2443
|
let outputsNumber = numberOfVariables;
|
2380
2444
|
while (outputsNumber) {
|
2381
2445
|
this.pushOutput({
|
2382
|
-
type:
|
2446
|
+
type: import_transactions9.OutputType.Variable
|
2383
2447
|
});
|
2384
2448
|
outputsNumber -= 1;
|
2385
2449
|
}
|
@@ -2412,12 +2476,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2412
2476
|
return this;
|
2413
2477
|
}
|
2414
2478
|
const inputIndex = super.pushInput({
|
2415
|
-
type:
|
2479
|
+
type: import_transactions9.InputType.Contract,
|
2416
2480
|
contractId: contractAddress.toB256(),
|
2417
2481
|
txPointer: "0x00000000000000000000000000000000"
|
2418
2482
|
});
|
2419
2483
|
this.pushOutput({
|
2420
|
-
type:
|
2484
|
+
type: import_transactions9.OutputType.Contract,
|
2421
2485
|
inputIndex
|
2422
2486
|
});
|
2423
2487
|
return this;
|
@@ -2453,38 +2517,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2453
2517
|
};
|
2454
2518
|
|
2455
2519
|
// src/providers/transaction-request/utils.ts
|
2456
|
-
var
|
2457
|
-
var
|
2520
|
+
var import_errors9 = require("@fuel-ts/errors");
|
2521
|
+
var import_transactions10 = require("@fuel-ts/transactions");
|
2458
2522
|
var transactionRequestify = (obj) => {
|
2459
2523
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2460
2524
|
return obj;
|
2461
2525
|
}
|
2462
2526
|
const { type } = obj;
|
2463
2527
|
switch (obj.type) {
|
2464
|
-
case
|
2528
|
+
case import_transactions10.TransactionType.Script: {
|
2465
2529
|
return ScriptTransactionRequest.from(obj);
|
2466
2530
|
}
|
2467
|
-
case
|
2531
|
+
case import_transactions10.TransactionType.Create: {
|
2468
2532
|
return CreateTransactionRequest.from(obj);
|
2469
2533
|
}
|
2470
2534
|
default: {
|
2471
|
-
throw new
|
2535
|
+
throw new import_errors9.FuelError(import_errors9.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
|
2472
2536
|
}
|
2473
2537
|
}
|
2474
2538
|
};
|
2475
2539
|
|
2476
2540
|
// src/providers/transaction-response/transaction-response.ts
|
2477
|
-
var
|
2478
|
-
var
|
2479
|
-
var
|
2541
|
+
var import_errors13 = require("@fuel-ts/errors");
|
2542
|
+
var import_math14 = require("@fuel-ts/math");
|
2543
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
2480
2544
|
var import_utils21 = require("@fuel-ts/utils");
|
2481
2545
|
|
2482
2546
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2483
2547
|
var import_utils19 = require("@fuel-ts/utils");
|
2484
2548
|
|
2485
2549
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2486
|
-
var
|
2487
|
-
var
|
2550
|
+
var import_math11 = require("@fuel-ts/math");
|
2551
|
+
var import_transactions11 = require("@fuel-ts/transactions");
|
2488
2552
|
var import_utils16 = require("@fuel-ts/utils");
|
2489
2553
|
var calculateTransactionFee = (params) => {
|
2490
2554
|
const {
|
@@ -2492,24 +2556,24 @@ var calculateTransactionFee = (params) => {
|
|
2492
2556
|
rawPayload,
|
2493
2557
|
consensusParameters: { gasCosts, feeParams }
|
2494
2558
|
} = params;
|
2495
|
-
const gasPerByte = (0,
|
2496
|
-
const gasPriceFactor = (0,
|
2559
|
+
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2560
|
+
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
2497
2561
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2498
|
-
const [transaction] = new
|
2499
|
-
if (transaction.type ===
|
2562
|
+
const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
|
2563
|
+
if (transaction.type === import_transactions11.TransactionType.Mint) {
|
2500
2564
|
return {
|
2501
|
-
fee: (0,
|
2502
|
-
minFee: (0,
|
2503
|
-
maxFee: (0,
|
2504
|
-
feeFromGasUsed: (0,
|
2565
|
+
fee: (0, import_math11.bn)(0),
|
2566
|
+
minFee: (0, import_math11.bn)(0),
|
2567
|
+
maxFee: (0, import_math11.bn)(0),
|
2568
|
+
feeFromGasUsed: (0, import_math11.bn)(0)
|
2505
2569
|
};
|
2506
2570
|
}
|
2507
2571
|
const { type, witnesses, inputs, policies } = transaction;
|
2508
|
-
let metadataGas = (0,
|
2509
|
-
let gasLimit = (0,
|
2510
|
-
if (type ===
|
2572
|
+
let metadataGas = (0, import_math11.bn)(0);
|
2573
|
+
let gasLimit = (0, import_math11.bn)(0);
|
2574
|
+
if (type === import_transactions11.TransactionType.Create) {
|
2511
2575
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2512
|
-
const contractBytesSize = (0,
|
2576
|
+
const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2513
2577
|
metadataGas = calculateMetadataGasForTxCreate({
|
2514
2578
|
contractBytesSize,
|
2515
2579
|
gasCosts,
|
@@ -2528,13 +2592,13 @@ var calculateTransactionFee = (params) => {
|
|
2528
2592
|
}
|
2529
2593
|
const minGas = getMinGas({
|
2530
2594
|
gasCosts,
|
2531
|
-
gasPerByte: (0,
|
2595
|
+
gasPerByte: (0, import_math11.bn)(gasPerByte),
|
2532
2596
|
inputs,
|
2533
2597
|
metadataGas,
|
2534
2598
|
txBytesSize: transactionBytes.length
|
2535
2599
|
});
|
2536
|
-
const gasPrice = (0,
|
2537
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
2600
|
+
const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
|
2601
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
|
2538
2602
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2539
2603
|
const maxGas = getMaxGas({
|
2540
2604
|
gasPerByte,
|
@@ -2556,14 +2620,14 @@ var calculateTransactionFee = (params) => {
|
|
2556
2620
|
};
|
2557
2621
|
|
2558
2622
|
// src/providers/transaction-summary/operations.ts
|
2559
|
-
var
|
2560
|
-
var
|
2561
|
-
var
|
2562
|
-
var
|
2623
|
+
var import_configs11 = require("@fuel-ts/address/configs");
|
2624
|
+
var import_errors11 = require("@fuel-ts/errors");
|
2625
|
+
var import_math13 = require("@fuel-ts/math");
|
2626
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
2563
2627
|
|
2564
2628
|
// src/providers/transaction-summary/call.ts
|
2565
2629
|
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
2566
|
-
var
|
2630
|
+
var import_math12 = require("@fuel-ts/math");
|
2567
2631
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2568
2632
|
const abiInterface = new import_abi_coder2.Interface(abi);
|
2569
2633
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2572,7 +2636,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2572
2636
|
let encodedArgs;
|
2573
2637
|
if (functionFragment.isInputDataPointer) {
|
2574
2638
|
if (rawPayload) {
|
2575
|
-
const argsOffset = (0,
|
2639
|
+
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2576
2640
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2577
2641
|
}
|
2578
2642
|
} else {
|
@@ -2606,8 +2670,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2606
2670
|
};
|
2607
2671
|
|
2608
2672
|
// src/providers/transaction-summary/input.ts
|
2609
|
-
var
|
2610
|
-
var
|
2673
|
+
var import_errors10 = require("@fuel-ts/errors");
|
2674
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
2611
2675
|
function getInputsByTypes(inputs, types) {
|
2612
2676
|
return inputs.filter((i) => types.includes(i.type));
|
2613
2677
|
}
|
@@ -2615,16 +2679,16 @@ function getInputsByType(inputs, type) {
|
|
2615
2679
|
return inputs.filter((i) => i.type === type);
|
2616
2680
|
}
|
2617
2681
|
function getInputsCoin(inputs) {
|
2618
|
-
return getInputsByType(inputs,
|
2682
|
+
return getInputsByType(inputs, import_transactions12.InputType.Coin);
|
2619
2683
|
}
|
2620
2684
|
function getInputsMessage(inputs) {
|
2621
|
-
return getInputsByType(inputs,
|
2685
|
+
return getInputsByType(inputs, import_transactions12.InputType.Message);
|
2622
2686
|
}
|
2623
2687
|
function getInputsCoinAndMessage(inputs) {
|
2624
|
-
return getInputsByTypes(inputs, [
|
2688
|
+
return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
|
2625
2689
|
}
|
2626
2690
|
function getInputsContract(inputs) {
|
2627
|
-
return getInputsByType(inputs,
|
2691
|
+
return getInputsByType(inputs, import_transactions12.InputType.Contract);
|
2628
2692
|
}
|
2629
2693
|
function getInputFromAssetId(inputs, assetId) {
|
2630
2694
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2643,40 +2707,40 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2643
2707
|
if (!contractInput) {
|
2644
2708
|
return void 0;
|
2645
2709
|
}
|
2646
|
-
if (contractInput.type !==
|
2647
|
-
throw new
|
2648
|
-
|
2710
|
+
if (contractInput.type !== import_transactions12.InputType.Contract) {
|
2711
|
+
throw new import_errors10.FuelError(
|
2712
|
+
import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
|
2649
2713
|
`Contract input should be of type 'contract'.`
|
2650
2714
|
);
|
2651
2715
|
}
|
2652
2716
|
return contractInput;
|
2653
2717
|
}
|
2654
2718
|
function getInputAccountAddress(input) {
|
2655
|
-
if (input.type ===
|
2719
|
+
if (input.type === import_transactions12.InputType.Coin) {
|
2656
2720
|
return input.owner.toString();
|
2657
2721
|
}
|
2658
|
-
if (input.type ===
|
2722
|
+
if (input.type === import_transactions12.InputType.Message) {
|
2659
2723
|
return input.recipient.toString();
|
2660
2724
|
}
|
2661
2725
|
return "";
|
2662
2726
|
}
|
2663
2727
|
|
2664
2728
|
// src/providers/transaction-summary/output.ts
|
2665
|
-
var
|
2729
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
2666
2730
|
function getOutputsByType(outputs, type) {
|
2667
2731
|
return outputs.filter((o) => o.type === type);
|
2668
2732
|
}
|
2669
2733
|
function getOutputsContractCreated(outputs) {
|
2670
|
-
return getOutputsByType(outputs,
|
2734
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
|
2671
2735
|
}
|
2672
2736
|
function getOutputsCoin(outputs) {
|
2673
|
-
return getOutputsByType(outputs,
|
2737
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
|
2674
2738
|
}
|
2675
2739
|
function getOutputsChange(outputs) {
|
2676
|
-
return getOutputsByType(outputs,
|
2740
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Change);
|
2677
2741
|
}
|
2678
2742
|
function getOutputsContract(outputs) {
|
2679
|
-
return getOutputsByType(outputs,
|
2743
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
|
2680
2744
|
}
|
2681
2745
|
|
2682
2746
|
// src/providers/transaction-summary/operations.ts
|
@@ -2685,15 +2749,15 @@ function getReceiptsByType(receipts, type) {
|
|
2685
2749
|
}
|
2686
2750
|
function getTransactionTypeName(transactionType) {
|
2687
2751
|
switch (transactionType) {
|
2688
|
-
case
|
2752
|
+
case import_transactions14.TransactionType.Mint:
|
2689
2753
|
return "Mint" /* Mint */;
|
2690
|
-
case
|
2754
|
+
case import_transactions14.TransactionType.Create:
|
2691
2755
|
return "Create" /* Create */;
|
2692
|
-
case
|
2756
|
+
case import_transactions14.TransactionType.Script:
|
2693
2757
|
return "Script" /* Script */;
|
2694
2758
|
default:
|
2695
|
-
throw new
|
2696
|
-
|
2759
|
+
throw new import_errors11.FuelError(
|
2760
|
+
import_errors11.ErrorCode.INVALID_TRANSACTION_TYPE,
|
2697
2761
|
`Invalid transaction type: ${transactionType}.`
|
2698
2762
|
);
|
2699
2763
|
}
|
@@ -2712,10 +2776,10 @@ function isTypeScript(transactionType) {
|
|
2712
2776
|
return isType(transactionType, "Script" /* Script */);
|
2713
2777
|
}
|
2714
2778
|
function getReceiptsCall(receipts) {
|
2715
|
-
return getReceiptsByType(receipts,
|
2779
|
+
return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
|
2716
2780
|
}
|
2717
2781
|
function getReceiptsMessageOut(receipts) {
|
2718
|
-
return getReceiptsByType(receipts,
|
2782
|
+
return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
|
2719
2783
|
}
|
2720
2784
|
var mergeAssets = (op1, op2) => {
|
2721
2785
|
const assets1 = op1.assetsSent || [];
|
@@ -2728,7 +2792,7 @@ var mergeAssets = (op1, op2) => {
|
|
2728
2792
|
if (!matchingAsset) {
|
2729
2793
|
return asset1;
|
2730
2794
|
}
|
2731
|
-
const mergedAmount = (0,
|
2795
|
+
const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
|
2732
2796
|
return { ...asset1, amount: mergedAmount };
|
2733
2797
|
});
|
2734
2798
|
return mergedAssets.concat(filteredAssets);
|
@@ -2854,7 +2918,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
2854
2918
|
const { to: toAddress, assetId, amount } = receipt;
|
2855
2919
|
let { from: fromAddress } = receipt;
|
2856
2920
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
2857
|
-
if (
|
2921
|
+
if (import_configs11.ZeroBytes32 === fromAddress) {
|
2858
2922
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
2859
2923
|
fromAddress = change?.to || fromAddress;
|
2860
2924
|
}
|
@@ -2911,11 +2975,11 @@ function getTransferOperations({
|
|
2911
2975
|
});
|
2912
2976
|
const transferReceipts = getReceiptsByType(
|
2913
2977
|
receipts,
|
2914
|
-
|
2978
|
+
import_transactions14.ReceiptType.Transfer
|
2915
2979
|
);
|
2916
2980
|
const transferOutReceipts = getReceiptsByType(
|
2917
2981
|
receipts,
|
2918
|
-
|
2982
|
+
import_transactions14.ReceiptType.TransferOut
|
2919
2983
|
);
|
2920
2984
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
2921
2985
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3000,17 +3064,17 @@ function getOperations({
|
|
3000
3064
|
}
|
3001
3065
|
|
3002
3066
|
// src/providers/transaction-summary/receipt.ts
|
3003
|
-
var
|
3067
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
3004
3068
|
var processGqlReceipt = (gqlReceipt) => {
|
3005
3069
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3006
3070
|
switch (receipt.type) {
|
3007
|
-
case
|
3071
|
+
case import_transactions15.ReceiptType.ReturnData: {
|
3008
3072
|
return {
|
3009
3073
|
...receipt,
|
3010
3074
|
data: gqlReceipt.data || "0x"
|
3011
3075
|
};
|
3012
3076
|
}
|
3013
|
-
case
|
3077
|
+
case import_transactions15.ReceiptType.LogData: {
|
3014
3078
|
return {
|
3015
3079
|
...receipt,
|
3016
3080
|
data: gqlReceipt.data || "0x"
|
@@ -3023,7 +3087,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3023
3087
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3024
3088
|
const mintedAssets = [];
|
3025
3089
|
receipts.forEach((receipt) => {
|
3026
|
-
if (receipt.type ===
|
3090
|
+
if (receipt.type === import_transactions15.ReceiptType.Mint) {
|
3027
3091
|
mintedAssets.push({
|
3028
3092
|
subId: receipt.subId,
|
3029
3093
|
contractId: receipt.contractId,
|
@@ -3037,7 +3101,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3037
3101
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3038
3102
|
const burnedAssets = [];
|
3039
3103
|
receipts.forEach((receipt) => {
|
3040
|
-
if (receipt.type ===
|
3104
|
+
if (receipt.type === import_transactions15.ReceiptType.Burn) {
|
3041
3105
|
burnedAssets.push({
|
3042
3106
|
subId: receipt.subId,
|
3043
3107
|
contractId: receipt.contractId,
|
@@ -3050,7 +3114,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3050
3114
|
};
|
3051
3115
|
|
3052
3116
|
// src/providers/transaction-summary/status.ts
|
3053
|
-
var
|
3117
|
+
var import_errors12 = require("@fuel-ts/errors");
|
3054
3118
|
var getTransactionStatusName = (gqlStatus) => {
|
3055
3119
|
switch (gqlStatus) {
|
3056
3120
|
case "FailureStatus":
|
@@ -3062,8 +3126,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3062
3126
|
case "SqueezedOutStatus":
|
3063
3127
|
return "squeezedout" /* squeezedout */;
|
3064
3128
|
default:
|
3065
|
-
throw new
|
3066
|
-
|
3129
|
+
throw new import_errors12.FuelError(
|
3130
|
+
import_errors12.ErrorCode.INVALID_TRANSACTION_STATUS,
|
3067
3131
|
`Invalid transaction status: ${gqlStatus}.`
|
3068
3132
|
);
|
3069
3133
|
}
|
@@ -3174,6 +3238,21 @@ function assembleTransactionSummary(params) {
|
|
3174
3238
|
return transactionSummary;
|
3175
3239
|
}
|
3176
3240
|
|
3241
|
+
// src/providers/transaction-response/getDecodedLogs.ts
|
3242
|
+
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
3243
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3244
|
+
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3245
|
+
return receipts.reduce((logs, receipt) => {
|
3246
|
+
if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
|
3247
|
+
const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
|
3248
|
+
const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3249
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3250
|
+
logs.push(decodedLog);
|
3251
|
+
}
|
3252
|
+
return logs;
|
3253
|
+
}, []);
|
3254
|
+
}
|
3255
|
+
|
3177
3256
|
// src/providers/transaction-response/transaction-response.ts
|
3178
3257
|
var TransactionResponse = class {
|
3179
3258
|
/** Transaction ID */
|
@@ -3181,18 +3260,20 @@ var TransactionResponse = class {
|
|
3181
3260
|
/** Current provider */
|
3182
3261
|
provider;
|
3183
3262
|
/** Gas used on the transaction */
|
3184
|
-
gasUsed = (0,
|
3263
|
+
gasUsed = (0, import_math14.bn)(0);
|
3185
3264
|
/** The graphql Transaction with receipts object. */
|
3186
3265
|
gqlTransaction;
|
3266
|
+
abis;
|
3187
3267
|
/**
|
3188
3268
|
* Constructor for `TransactionResponse`.
|
3189
3269
|
*
|
3190
3270
|
* @param id - The transaction ID.
|
3191
3271
|
* @param provider - The provider.
|
3192
3272
|
*/
|
3193
|
-
constructor(id, provider) {
|
3273
|
+
constructor(id, provider, abis) {
|
3194
3274
|
this.id = id;
|
3195
3275
|
this.provider = provider;
|
3276
|
+
this.abis = abis;
|
3196
3277
|
}
|
3197
3278
|
/**
|
3198
3279
|
* Async constructor for `TransactionResponse`. This method can be used to create
|
@@ -3202,8 +3283,8 @@ var TransactionResponse = class {
|
|
3202
3283
|
* @param id - The transaction ID.
|
3203
3284
|
* @param provider - The provider.
|
3204
3285
|
*/
|
3205
|
-
static async create(id, provider) {
|
3206
|
-
const response = new TransactionResponse(id, provider);
|
3286
|
+
static async create(id, provider, abis) {
|
3287
|
+
const response = new TransactionResponse(id, provider, abis);
|
3207
3288
|
await response.fetch();
|
3208
3289
|
return response;
|
3209
3290
|
}
|
@@ -3237,7 +3318,7 @@ var TransactionResponse = class {
|
|
3237
3318
|
* @returns The decoded transaction.
|
3238
3319
|
*/
|
3239
3320
|
decodeTransaction(transactionWithReceipts) {
|
3240
|
-
return new
|
3321
|
+
return new import_transactions17.TransactionCoder().decode(
|
3241
3322
|
(0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
|
3242
3323
|
0
|
3243
3324
|
)?.[0];
|
@@ -3284,8 +3365,8 @@ var TransactionResponse = class {
|
|
3284
3365
|
});
|
3285
3366
|
for await (const { statusChange } of subscription) {
|
3286
3367
|
if (statusChange.type === "SqueezedOutStatus") {
|
3287
|
-
throw new
|
3288
|
-
|
3368
|
+
throw new import_errors13.FuelError(
|
3369
|
+
import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
3289
3370
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
3290
3371
|
);
|
3291
3372
|
}
|
@@ -3307,6 +3388,26 @@ var TransactionResponse = class {
|
|
3307
3388
|
gqlTransaction: this.gqlTransaction,
|
3308
3389
|
...transactionSummary
|
3309
3390
|
};
|
3391
|
+
let logs = [];
|
3392
|
+
if (this.abis) {
|
3393
|
+
logs = getDecodedLogs(
|
3394
|
+
transactionSummary.receipts,
|
3395
|
+
this.abis.main,
|
3396
|
+
this.abis.otherContractsAbis
|
3397
|
+
);
|
3398
|
+
transactionResult.logs = logs;
|
3399
|
+
}
|
3400
|
+
if (transactionResult.isStatusFailure) {
|
3401
|
+
const {
|
3402
|
+
receipts,
|
3403
|
+
gqlTransaction: { status }
|
3404
|
+
} = transactionResult;
|
3405
|
+
throw extractTxError({
|
3406
|
+
receipts,
|
3407
|
+
status,
|
3408
|
+
logs
|
3409
|
+
});
|
3410
|
+
}
|
3310
3411
|
return transactionResult;
|
3311
3412
|
}
|
3312
3413
|
/**
|
@@ -3315,21 +3416,10 @@ var TransactionResponse = class {
|
|
3315
3416
|
* @param contractsAbiMap - The contracts ABI map.
|
3316
3417
|
*/
|
3317
3418
|
async wait(contractsAbiMap) {
|
3318
|
-
|
3319
|
-
if (result.isStatusFailure) {
|
3320
|
-
throw new import_errors12.FuelError(
|
3321
|
-
import_errors12.ErrorCode.TRANSACTION_FAILED,
|
3322
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
3323
|
-
);
|
3324
|
-
}
|
3325
|
-
return result;
|
3419
|
+
return this.waitForResult(contractsAbiMap);
|
3326
3420
|
}
|
3327
3421
|
};
|
3328
3422
|
|
3329
|
-
// src/providers/transaction-response/getDecodedLogs.ts
|
3330
|
-
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
3331
|
-
var import_transactions16 = require("@fuel-ts/transactions");
|
3332
|
-
|
3333
3423
|
// src/providers/utils/auto-retry-fetch.ts
|
3334
3424
|
function getWaitDelay(options, retryAttemptNum) {
|
3335
3425
|
const duration = options.baseDelay ?? 150;
|
@@ -3388,29 +3478,29 @@ var processGqlChain = (chain) => {
|
|
3388
3478
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3389
3479
|
return {
|
3390
3480
|
name,
|
3391
|
-
baseChainHeight: (0,
|
3481
|
+
baseChainHeight: (0, import_math15.bn)(daHeight),
|
3392
3482
|
consensusParameters: {
|
3393
|
-
contractMaxSize: (0,
|
3394
|
-
maxInputs: (0,
|
3395
|
-
maxOutputs: (0,
|
3396
|
-
maxWitnesses: (0,
|
3397
|
-
maxGasPerTx: (0,
|
3398
|
-
maxScriptLength: (0,
|
3399
|
-
maxScriptDataLength: (0,
|
3400
|
-
maxStorageSlots: (0,
|
3401
|
-
maxPredicateLength: (0,
|
3402
|
-
maxPredicateDataLength: (0,
|
3403
|
-
maxGasPerPredicate: (0,
|
3404
|
-
gasPriceFactor: (0,
|
3405
|
-
gasPerByte: (0,
|
3406
|
-
maxMessageDataLength: (0,
|
3407
|
-
chainId: (0,
|
3483
|
+
contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
|
3484
|
+
maxInputs: (0, import_math15.bn)(txParams.maxInputs),
|
3485
|
+
maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
|
3486
|
+
maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
|
3487
|
+
maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
|
3488
|
+
maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
|
3489
|
+
maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
|
3490
|
+
maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
|
3491
|
+
maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
|
3492
|
+
maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
|
3493
|
+
maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
|
3494
|
+
gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
|
3495
|
+
gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
|
3496
|
+
maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
|
3497
|
+
chainId: (0, import_math15.bn)(consensusParameters.chainId),
|
3408
3498
|
gasCosts
|
3409
3499
|
},
|
3410
3500
|
gasCosts,
|
3411
3501
|
latestBlock: {
|
3412
3502
|
id: latestBlock.id,
|
3413
|
-
height: (0,
|
3503
|
+
height: (0, import_math15.bn)(latestBlock.header.height),
|
3414
3504
|
time: latestBlock.header.time,
|
3415
3505
|
transactions: latestBlock.transactions.map((i) => ({
|
3416
3506
|
id: i.id
|
@@ -3480,8 +3570,8 @@ var _Provider = class {
|
|
3480
3570
|
getChain() {
|
3481
3571
|
const chain = _Provider.chainInfoCache[this.url];
|
3482
3572
|
if (!chain) {
|
3483
|
-
throw new
|
3484
|
-
|
3573
|
+
throw new import_errors14.FuelError(
|
3574
|
+
import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
3485
3575
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3486
3576
|
);
|
3487
3577
|
}
|
@@ -3493,8 +3583,8 @@ var _Provider = class {
|
|
3493
3583
|
getNode() {
|
3494
3584
|
const node = _Provider.nodeInfoCache[this.url];
|
3495
3585
|
if (!node) {
|
3496
|
-
throw new
|
3497
|
-
|
3586
|
+
throw new import_errors14.FuelError(
|
3587
|
+
import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
3498
3588
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3499
3589
|
);
|
3500
3590
|
}
|
@@ -3541,8 +3631,8 @@ var _Provider = class {
|
|
3541
3631
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3542
3632
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
3543
3633
|
if (!isMajorSupported || !isMinorSupported) {
|
3544
|
-
throw new
|
3545
|
-
|
3634
|
+
throw new import_errors14.FuelError(
|
3635
|
+
import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
|
3546
3636
|
`Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
|
3547
3637
|
);
|
3548
3638
|
}
|
@@ -3605,7 +3695,7 @@ var _Provider = class {
|
|
3605
3695
|
*/
|
3606
3696
|
async getBlockNumber() {
|
3607
3697
|
const { chain } = await this.operations.getChain();
|
3608
|
-
return (0,
|
3698
|
+
return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
|
3609
3699
|
}
|
3610
3700
|
/**
|
3611
3701
|
* Returns the chain information.
|
@@ -3615,9 +3705,9 @@ var _Provider = class {
|
|
3615
3705
|
async fetchNode() {
|
3616
3706
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3617
3707
|
const processedNodeInfo = {
|
3618
|
-
maxDepth: (0,
|
3619
|
-
maxTx: (0,
|
3620
|
-
minGasPrice: (0,
|
3708
|
+
maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
|
3709
|
+
maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
|
3710
|
+
minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
|
3621
3711
|
nodeVersion: nodeInfo.nodeVersion,
|
3622
3712
|
utxoValidation: nodeInfo.utxoValidation,
|
3623
3713
|
vmBacktrace: nodeInfo.vmBacktrace,
|
@@ -3663,13 +3753,17 @@ var _Provider = class {
|
|
3663
3753
|
if (estimateTxDependencies) {
|
3664
3754
|
await this.estimateTxDependencies(transactionRequest);
|
3665
3755
|
}
|
3666
|
-
const encodedTransaction = (0,
|
3756
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3757
|
+
let abis;
|
3758
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Script) {
|
3759
|
+
abis = transactionRequest.abis;
|
3760
|
+
}
|
3667
3761
|
if (awaitExecution) {
|
3668
3762
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3669
3763
|
for await (const { submitAndAwait } of subscription) {
|
3670
3764
|
if (submitAndAwait.type === "SqueezedOutStatus") {
|
3671
|
-
throw new
|
3672
|
-
|
3765
|
+
throw new import_errors14.FuelError(
|
3766
|
+
import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
3673
3767
|
`Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
|
3674
3768
|
);
|
3675
3769
|
}
|
@@ -3678,14 +3772,14 @@ var _Provider = class {
|
|
3678
3772
|
}
|
3679
3773
|
}
|
3680
3774
|
const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
|
3681
|
-
const response = new TransactionResponse(transactionId2, this);
|
3775
|
+
const response = new TransactionResponse(transactionId2, this, abis);
|
3682
3776
|
await response.fetch();
|
3683
3777
|
return response;
|
3684
3778
|
}
|
3685
3779
|
const {
|
3686
3780
|
submit: { id: transactionId }
|
3687
3781
|
} = await this.operations.submit({ encodedTransaction });
|
3688
|
-
return new TransactionResponse(transactionId, this);
|
3782
|
+
return new TransactionResponse(transactionId, this, abis);
|
3689
3783
|
}
|
3690
3784
|
/**
|
3691
3785
|
* Executes a transaction without actually submitting it to the chain.
|
@@ -3702,7 +3796,7 @@ var _Provider = class {
|
|
3702
3796
|
if (estimateTxDependencies) {
|
3703
3797
|
return this.estimateTxDependencies(transactionRequest);
|
3704
3798
|
}
|
3705
|
-
const encodedTransaction = (0,
|
3799
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3706
3800
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3707
3801
|
encodedTransaction,
|
3708
3802
|
utxoValidation: utxoValidation || false
|
@@ -3721,13 +3815,13 @@ var _Provider = class {
|
|
3721
3815
|
async estimatePredicates(transactionRequest) {
|
3722
3816
|
const shouldEstimatePredicates = Boolean(
|
3723
3817
|
transactionRequest.inputs.find(
|
3724
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
3818
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math15.BN(input.predicateGasUsed).isZero()
|
3725
3819
|
)
|
3726
3820
|
);
|
3727
3821
|
if (!shouldEstimatePredicates) {
|
3728
3822
|
return transactionRequest;
|
3729
3823
|
}
|
3730
|
-
const encodedTransaction = (0,
|
3824
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3731
3825
|
const response = await this.operations.estimatePredicates({
|
3732
3826
|
encodedTransaction
|
3733
3827
|
});
|
@@ -3736,7 +3830,7 @@ var _Provider = class {
|
|
3736
3830
|
} = response;
|
3737
3831
|
if (inputs) {
|
3738
3832
|
inputs.forEach((input, index) => {
|
3739
|
-
if ("predicateGasUsed" in input && (0,
|
3833
|
+
if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
|
3740
3834
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3741
3835
|
}
|
3742
3836
|
});
|
@@ -3757,7 +3851,7 @@ var _Provider = class {
|
|
3757
3851
|
* @returns A promise.
|
3758
3852
|
*/
|
3759
3853
|
async estimateTxDependencies(transactionRequest) {
|
3760
|
-
if (transactionRequest.type ===
|
3854
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Create) {
|
3761
3855
|
return {
|
3762
3856
|
receipts: [],
|
3763
3857
|
outputVariables: 0,
|
@@ -3770,7 +3864,7 @@ var _Provider = class {
|
|
3770
3864
|
let outputVariables = 0;
|
3771
3865
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3772
3866
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3773
|
-
encodedTransaction: (0,
|
3867
|
+
encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
|
3774
3868
|
utxoValidation: false
|
3775
3869
|
});
|
3776
3870
|
receipts = gqlReceipts.map(processGqlReceipt);
|
@@ -3808,7 +3902,7 @@ var _Provider = class {
|
|
3808
3902
|
if (estimateTxDependencies) {
|
3809
3903
|
return this.estimateTxDependencies(transactionRequest);
|
3810
3904
|
}
|
3811
|
-
const encodedTransaction = (0,
|
3905
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3812
3906
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3813
3907
|
encodedTransaction,
|
3814
3908
|
utxoValidation: true
|
@@ -3842,14 +3936,14 @@ var _Provider = class {
|
|
3842
3936
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
3843
3937
|
const chainInfo = this.getChain();
|
3844
3938
|
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
3845
|
-
const gasPrice = (0,
|
3846
|
-
const isScriptTransaction = txRequestClone.type ===
|
3939
|
+
const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
3940
|
+
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
3847
3941
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3848
3942
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
3849
3943
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
3850
3944
|
if (estimatePredicates) {
|
3851
3945
|
if (isScriptTransaction) {
|
3852
|
-
txRequestClone.gasLimit = (0,
|
3946
|
+
txRequestClone.gasLimit = (0, import_math15.bn)(0);
|
3853
3947
|
}
|
3854
3948
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3855
3949
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -3865,8 +3959,8 @@ var _Provider = class {
|
|
3865
3959
|
let missingContractIds = [];
|
3866
3960
|
let outputVariables = 0;
|
3867
3961
|
if (isScriptTransaction && estimateTxDependencies) {
|
3868
|
-
txRequestClone.gasPrice = (0,
|
3869
|
-
txRequestClone.gasLimit = (0,
|
3962
|
+
txRequestClone.gasPrice = (0, import_math15.bn)(0);
|
3963
|
+
txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
3870
3964
|
const result = await this.estimateTxDependencies(txRequestClone);
|
3871
3965
|
receipts = result.receipts;
|
3872
3966
|
outputVariables = result.outputVariables;
|
@@ -3922,17 +4016,17 @@ var _Provider = class {
|
|
3922
4016
|
const result = await this.operations.getCoins({
|
3923
4017
|
first: 10,
|
3924
4018
|
...paginationArgs,
|
3925
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4019
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
3926
4020
|
});
|
3927
4021
|
const coins = result.coins.edges.map((edge) => edge.node);
|
3928
4022
|
return coins.map((coin) => ({
|
3929
4023
|
id: coin.utxoId,
|
3930
4024
|
assetId: coin.assetId,
|
3931
|
-
amount: (0,
|
4025
|
+
amount: (0, import_math15.bn)(coin.amount),
|
3932
4026
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
3933
|
-
maturity: (0,
|
3934
|
-
blockCreated: (0,
|
3935
|
-
txCreatedIdx: (0,
|
4027
|
+
maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
|
4028
|
+
blockCreated: (0, import_math15.bn)(coin.blockCreated),
|
4029
|
+
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
3936
4030
|
}));
|
3937
4031
|
}
|
3938
4032
|
/**
|
@@ -3946,19 +4040,19 @@ var _Provider = class {
|
|
3946
4040
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
3947
4041
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
3948
4042
|
const excludeInput = {
|
3949
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
3950
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4043
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
|
4044
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
|
3951
4045
|
};
|
3952
4046
|
if (this.cache) {
|
3953
4047
|
const uniqueUtxos = new Set(
|
3954
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4048
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
|
3955
4049
|
);
|
3956
4050
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
3957
4051
|
}
|
3958
4052
|
const coinsQuery = {
|
3959
4053
|
owner: ownerAddress.toB256(),
|
3960
4054
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
3961
|
-
assetId: (0,
|
4055
|
+
assetId: (0, import_utils23.hexlify)(assetId),
|
3962
4056
|
amount: amount.toString(10),
|
3963
4057
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
3964
4058
|
})),
|
@@ -3969,9 +4063,9 @@ var _Provider = class {
|
|
3969
4063
|
switch (coin.__typename) {
|
3970
4064
|
case "MessageCoin":
|
3971
4065
|
return {
|
3972
|
-
amount: (0,
|
4066
|
+
amount: (0, import_math15.bn)(coin.amount),
|
3973
4067
|
assetId: coin.assetId,
|
3974
|
-
daHeight: (0,
|
4068
|
+
daHeight: (0, import_math15.bn)(coin.daHeight),
|
3975
4069
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
3976
4070
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
3977
4071
|
nonce: coin.nonce
|
@@ -3979,12 +4073,12 @@ var _Provider = class {
|
|
3979
4073
|
case "Coin":
|
3980
4074
|
return {
|
3981
4075
|
id: coin.utxoId,
|
3982
|
-
amount: (0,
|
4076
|
+
amount: (0, import_math15.bn)(coin.amount),
|
3983
4077
|
assetId: coin.assetId,
|
3984
4078
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
3985
|
-
maturity: (0,
|
3986
|
-
blockCreated: (0,
|
3987
|
-
txCreatedIdx: (0,
|
4079
|
+
maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
|
4080
|
+
blockCreated: (0, import_math15.bn)(coin.blockCreated),
|
4081
|
+
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
3988
4082
|
};
|
3989
4083
|
default:
|
3990
4084
|
return null;
|
@@ -4001,13 +4095,13 @@ var _Provider = class {
|
|
4001
4095
|
async getBlock(idOrHeight) {
|
4002
4096
|
let variables;
|
4003
4097
|
if (typeof idOrHeight === "number") {
|
4004
|
-
variables = { height: (0,
|
4098
|
+
variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
|
4005
4099
|
} else if (idOrHeight === "latest") {
|
4006
4100
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4007
4101
|
} else if (idOrHeight.length === 66) {
|
4008
4102
|
variables = { blockId: idOrHeight };
|
4009
4103
|
} else {
|
4010
|
-
variables = { blockId: (0,
|
4104
|
+
variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
|
4011
4105
|
}
|
4012
4106
|
const { block } = await this.operations.getBlock(variables);
|
4013
4107
|
if (!block) {
|
@@ -4015,7 +4109,7 @@ var _Provider = class {
|
|
4015
4109
|
}
|
4016
4110
|
return {
|
4017
4111
|
id: block.id,
|
4018
|
-
height: (0,
|
4112
|
+
height: (0, import_math15.bn)(block.header.height),
|
4019
4113
|
time: block.header.time,
|
4020
4114
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4021
4115
|
};
|
@@ -4030,7 +4124,7 @@ var _Provider = class {
|
|
4030
4124
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4031
4125
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4032
4126
|
id: block.id,
|
4033
|
-
height: (0,
|
4127
|
+
height: (0, import_math15.bn)(block.header.height),
|
4034
4128
|
time: block.header.time,
|
4035
4129
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4036
4130
|
}));
|
@@ -4045,7 +4139,7 @@ var _Provider = class {
|
|
4045
4139
|
async getBlockWithTransactions(idOrHeight) {
|
4046
4140
|
let variables;
|
4047
4141
|
if (typeof idOrHeight === "number") {
|
4048
|
-
variables = { blockHeight: (0,
|
4142
|
+
variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
|
4049
4143
|
} else if (idOrHeight === "latest") {
|
4050
4144
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4051
4145
|
} else {
|
@@ -4057,11 +4151,11 @@ var _Provider = class {
|
|
4057
4151
|
}
|
4058
4152
|
return {
|
4059
4153
|
id: block.id,
|
4060
|
-
height: (0,
|
4154
|
+
height: (0, import_math15.bn)(block.header.height, 10),
|
4061
4155
|
time: block.header.time,
|
4062
4156
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4063
4157
|
transactions: block.transactions.map(
|
4064
|
-
(tx) => new
|
4158
|
+
(tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
|
4065
4159
|
)
|
4066
4160
|
};
|
4067
4161
|
}
|
@@ -4076,8 +4170,8 @@ var _Provider = class {
|
|
4076
4170
|
if (!transaction) {
|
4077
4171
|
return null;
|
4078
4172
|
}
|
4079
|
-
return new
|
4080
|
-
(0,
|
4173
|
+
return new import_transactions18.TransactionCoder().decode(
|
4174
|
+
(0, import_utils23.arrayify)(transaction.rawPayload),
|
4081
4175
|
0
|
4082
4176
|
)?.[0];
|
4083
4177
|
}
|
@@ -4104,9 +4198,9 @@ var _Provider = class {
|
|
4104
4198
|
async getContractBalance(contractId, assetId) {
|
4105
4199
|
const { contractBalance } = await this.operations.getContractBalance({
|
4106
4200
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4107
|
-
asset: (0,
|
4201
|
+
asset: (0, import_utils23.hexlify)(assetId)
|
4108
4202
|
});
|
4109
|
-
return (0,
|
4203
|
+
return (0, import_math15.bn)(contractBalance.amount, 10);
|
4110
4204
|
}
|
4111
4205
|
/**
|
4112
4206
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4118,9 +4212,9 @@ var _Provider = class {
|
|
4118
4212
|
async getBalance(owner, assetId) {
|
4119
4213
|
const { balance } = await this.operations.getBalance({
|
4120
4214
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4121
|
-
assetId: (0,
|
4215
|
+
assetId: (0, import_utils23.hexlify)(assetId)
|
4122
4216
|
});
|
4123
|
-
return (0,
|
4217
|
+
return (0, import_math15.bn)(balance.amount, 10);
|
4124
4218
|
}
|
4125
4219
|
/**
|
4126
4220
|
* Returns balances for the given owner.
|
@@ -4138,7 +4232,7 @@ var _Provider = class {
|
|
4138
4232
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4139
4233
|
return balances.map((balance) => ({
|
4140
4234
|
assetId: balance.assetId,
|
4141
|
-
amount: (0,
|
4235
|
+
amount: (0, import_math15.bn)(balance.amount)
|
4142
4236
|
}));
|
4143
4237
|
}
|
4144
4238
|
/**
|
@@ -4156,19 +4250,19 @@ var _Provider = class {
|
|
4156
4250
|
});
|
4157
4251
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4158
4252
|
return messages.map((message) => ({
|
4159
|
-
messageId:
|
4253
|
+
messageId: import_transactions18.InputMessageCoder.getMessageId({
|
4160
4254
|
sender: message.sender,
|
4161
4255
|
recipient: message.recipient,
|
4162
4256
|
nonce: message.nonce,
|
4163
|
-
amount: (0,
|
4257
|
+
amount: (0, import_math15.bn)(message.amount),
|
4164
4258
|
data: message.data
|
4165
4259
|
}),
|
4166
4260
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4167
4261
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4168
4262
|
nonce: message.nonce,
|
4169
|
-
amount: (0,
|
4170
|
-
data:
|
4171
|
-
daHeight: (0,
|
4263
|
+
amount: (0, import_math15.bn)(message.amount),
|
4264
|
+
data: import_transactions18.InputMessageCoder.decodeData(message.data),
|
4265
|
+
daHeight: (0, import_math15.bn)(message.daHeight)
|
4172
4266
|
}));
|
4173
4267
|
}
|
4174
4268
|
/**
|
@@ -4186,8 +4280,8 @@ var _Provider = class {
|
|
4186
4280
|
nonce
|
4187
4281
|
};
|
4188
4282
|
if (commitBlockId && commitBlockHeight) {
|
4189
|
-
throw new
|
4190
|
-
|
4283
|
+
throw new import_errors14.FuelError(
|
4284
|
+
import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4191
4285
|
"commitBlockId and commitBlockHeight cannot be used together"
|
4192
4286
|
);
|
4193
4287
|
}
|
@@ -4221,41 +4315,41 @@ var _Provider = class {
|
|
4221
4315
|
} = result.messageProof;
|
4222
4316
|
return {
|
4223
4317
|
messageProof: {
|
4224
|
-
proofIndex: (0,
|
4318
|
+
proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
|
4225
4319
|
proofSet: messageProof.proofSet
|
4226
4320
|
},
|
4227
4321
|
blockProof: {
|
4228
|
-
proofIndex: (0,
|
4322
|
+
proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
|
4229
4323
|
proofSet: blockProof.proofSet
|
4230
4324
|
},
|
4231
4325
|
messageBlockHeader: {
|
4232
4326
|
id: messageBlockHeader.id,
|
4233
|
-
daHeight: (0,
|
4234
|
-
transactionsCount: (0,
|
4327
|
+
daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
|
4328
|
+
transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
|
4235
4329
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4236
|
-
height: (0,
|
4330
|
+
height: (0, import_math15.bn)(messageBlockHeader.height),
|
4237
4331
|
prevRoot: messageBlockHeader.prevRoot,
|
4238
4332
|
time: messageBlockHeader.time,
|
4239
4333
|
applicationHash: messageBlockHeader.applicationHash,
|
4240
4334
|
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4241
|
-
messageReceiptCount: (0,
|
4335
|
+
messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
|
4242
4336
|
},
|
4243
4337
|
commitBlockHeader: {
|
4244
4338
|
id: commitBlockHeader.id,
|
4245
|
-
daHeight: (0,
|
4246
|
-
transactionsCount: (0,
|
4339
|
+
daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
|
4340
|
+
transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
|
4247
4341
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4248
|
-
height: (0,
|
4342
|
+
height: (0, import_math15.bn)(commitBlockHeader.height),
|
4249
4343
|
prevRoot: commitBlockHeader.prevRoot,
|
4250
4344
|
time: commitBlockHeader.time,
|
4251
4345
|
applicationHash: commitBlockHeader.applicationHash,
|
4252
4346
|
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4253
|
-
messageReceiptCount: (0,
|
4347
|
+
messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
|
4254
4348
|
},
|
4255
4349
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4256
4350
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4257
4351
|
nonce,
|
4258
|
-
amount: (0,
|
4352
|
+
amount: (0, import_math15.bn)(amount),
|
4259
4353
|
data
|
4260
4354
|
};
|
4261
4355
|
}
|
@@ -4278,10 +4372,10 @@ var _Provider = class {
|
|
4278
4372
|
*/
|
4279
4373
|
async produceBlocks(amount, startTime) {
|
4280
4374
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4281
|
-
blocksToProduce: (0,
|
4282
|
-
startTimestamp: startTime ?
|
4375
|
+
blocksToProduce: (0, import_math15.bn)(amount).toString(10),
|
4376
|
+
startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4283
4377
|
});
|
4284
|
-
return (0,
|
4378
|
+
return (0, import_math15.bn)(latestBlockHeight);
|
4285
4379
|
}
|
4286
4380
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4287
4381
|
async getTransactionResponse(transactionId) {
|
@@ -4295,7 +4389,7 @@ cacheInputs_fn = function(inputs) {
|
|
4295
4389
|
return;
|
4296
4390
|
}
|
4297
4391
|
inputs.forEach((input) => {
|
4298
|
-
if (input.type ===
|
4392
|
+
if (input.type === import_transactions18.InputType.Coin) {
|
4299
4393
|
this.cache?.set(input.id);
|
4300
4394
|
}
|
4301
4395
|
});
|
@@ -4304,10 +4398,10 @@ __publicField(Provider, "chainInfoCache", {});
|
|
4304
4398
|
__publicField(Provider, "nodeInfoCache", {});
|
4305
4399
|
|
4306
4400
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4307
|
-
var
|
4308
|
-
var
|
4309
|
-
var
|
4310
|
-
var
|
4401
|
+
var import_errors15 = require("@fuel-ts/errors");
|
4402
|
+
var import_math16 = require("@fuel-ts/math");
|
4403
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
4404
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4311
4405
|
|
4312
4406
|
// src/providers/chains.ts
|
4313
4407
|
var CHAIN_IDS = {
|
@@ -4356,17 +4450,17 @@ var assets = [
|
|
4356
4450
|
|
4357
4451
|
// src/utils/formatTransferToContractScriptData.ts
|
4358
4452
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4359
|
-
var
|
4360
|
-
var
|
4453
|
+
var import_math17 = require("@fuel-ts/math");
|
4454
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4361
4455
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4362
4456
|
var formatTransferToContractScriptData = (params) => {
|
4363
4457
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4364
4458
|
const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
|
4365
|
-
const encoded = numberCoder.encode(new
|
4459
|
+
const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
|
4366
4460
|
const scriptData = Uint8Array.from([
|
4367
|
-
...(0,
|
4461
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4368
4462
|
...encoded,
|
4369
|
-
...(0,
|
4463
|
+
...(0, import_utils27.arrayify)(assetId)
|
4370
4464
|
]);
|
4371
4465
|
return scriptData;
|
4372
4466
|
};
|
@@ -4422,7 +4516,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4422
4516
|
*/
|
4423
4517
|
get provider() {
|
4424
4518
|
if (!this._provider) {
|
4425
|
-
throw new
|
4519
|
+
throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
4426
4520
|
}
|
4427
4521
|
return this._provider;
|
4428
4522
|
}
|
@@ -4474,8 +4568,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4474
4568
|
if (!hasNextPage) {
|
4475
4569
|
break;
|
4476
4570
|
}
|
4477
|
-
throw new
|
4478
|
-
|
4571
|
+
throw new import_errors16.FuelError(
|
4572
|
+
import_errors16.ErrorCode.NOT_SUPPORTED,
|
4479
4573
|
`Wallets containing more than ${pageSize} coins exceed the current supported limit.`
|
4480
4574
|
);
|
4481
4575
|
}
|
@@ -4500,8 +4594,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4500
4594
|
if (!hasNextPage) {
|
4501
4595
|
break;
|
4502
4596
|
}
|
4503
|
-
throw new
|
4504
|
-
|
4597
|
+
throw new import_errors16.FuelError(
|
4598
|
+
import_errors16.ErrorCode.NOT_SUPPORTED,
|
4505
4599
|
`Wallets containing more than ${pageSize} messages exceed the current supported limit.`
|
4506
4600
|
);
|
4507
4601
|
}
|
@@ -4513,7 +4607,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4513
4607
|
* @param assetId - The asset ID to check the balance for.
|
4514
4608
|
* @returns A promise that resolves to the balance amount.
|
4515
4609
|
*/
|
4516
|
-
async getBalance(assetId =
|
4610
|
+
async getBalance(assetId = import_configs12.BaseAssetId) {
|
4517
4611
|
const amount = await this.provider.getBalance(this.address, assetId);
|
4518
4612
|
return amount;
|
4519
4613
|
}
|
@@ -4536,8 +4630,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4536
4630
|
if (!hasNextPage) {
|
4537
4631
|
break;
|
4538
4632
|
}
|
4539
|
-
throw new
|
4540
|
-
|
4633
|
+
throw new import_errors16.FuelError(
|
4634
|
+
import_errors16.ErrorCode.NOT_SUPPORTED,
|
4541
4635
|
`Wallets containing more than ${pageSize} balances exceed the current supported limit.`
|
4542
4636
|
);
|
4543
4637
|
}
|
@@ -4553,15 +4647,15 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4553
4647
|
*/
|
4554
4648
|
async fund(request, coinQuantities, fee) {
|
4555
4649
|
const updatedQuantities = addAmountToAsset({
|
4556
|
-
amount: (0,
|
4557
|
-
assetId:
|
4650
|
+
amount: (0, import_math18.bn)(fee),
|
4651
|
+
assetId: import_configs12.BaseAssetId,
|
4558
4652
|
coinQuantities
|
4559
4653
|
});
|
4560
4654
|
const quantitiesDict = {};
|
4561
4655
|
updatedQuantities.forEach(({ amount, assetId }) => {
|
4562
4656
|
quantitiesDict[assetId] = {
|
4563
4657
|
required: amount,
|
4564
|
-
owned: (0,
|
4658
|
+
owned: (0, import_math18.bn)(0)
|
4565
4659
|
};
|
4566
4660
|
});
|
4567
4661
|
const cachedUtxos = [];
|
@@ -4574,12 +4668,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4574
4668
|
if (isCoin2) {
|
4575
4669
|
const assetId = String(input.assetId);
|
4576
4670
|
if (input.owner === owner && quantitiesDict[assetId]) {
|
4577
|
-
const amount = (0,
|
4671
|
+
const amount = (0, import_math18.bn)(input.amount);
|
4578
4672
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4579
4673
|
cachedUtxos.push(input.id);
|
4580
4674
|
}
|
4581
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
4582
|
-
quantitiesDict[
|
4675
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
|
4676
|
+
quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
|
4583
4677
|
cachedMessages.push(input.nonce);
|
4584
4678
|
}
|
4585
4679
|
}
|
@@ -4611,7 +4705,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4611
4705
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4612
4706
|
* @returns A promise that resolves to the prepared transaction request.
|
4613
4707
|
*/
|
4614
|
-
async createTransfer(destination, amount, assetId =
|
4708
|
+
async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4615
4709
|
const { minGasPrice } = this.provider.getGasConfig();
|
4616
4710
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4617
4711
|
const request = new ScriptTransactionRequest(params);
|
@@ -4620,8 +4714,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4620
4714
|
estimateTxDependencies: true,
|
4621
4715
|
resourcesOwner: this
|
4622
4716
|
});
|
4623
|
-
request.gasPrice = (0,
|
4624
|
-
request.gasLimit = (0,
|
4717
|
+
request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
|
4718
|
+
request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
|
4625
4719
|
this.validateGas({
|
4626
4720
|
gasUsed,
|
4627
4721
|
gasPrice: request.gasPrice,
|
@@ -4641,10 +4735,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4641
4735
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4642
4736
|
* @returns A promise that resolves to the transaction response.
|
4643
4737
|
*/
|
4644
|
-
async transfer(destination, amount, assetId =
|
4645
|
-
if ((0,
|
4646
|
-
throw new
|
4647
|
-
|
4738
|
+
async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4739
|
+
if ((0, import_math18.bn)(amount).lte(0)) {
|
4740
|
+
throw new import_errors16.FuelError(
|
4741
|
+
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4648
4742
|
"Transfer amount must be a positive number."
|
4649
4743
|
);
|
4650
4744
|
}
|
@@ -4660,10 +4754,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4660
4754
|
* @param txParams - The optional transaction parameters.
|
4661
4755
|
* @returns A promise that resolves to the transaction response.
|
4662
4756
|
*/
|
4663
|
-
async transferToContract(contractId, amount, assetId =
|
4664
|
-
if ((0,
|
4665
|
-
throw new
|
4666
|
-
|
4757
|
+
async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4758
|
+
if ((0, import_math18.bn)(amount).lte(0)) {
|
4759
|
+
throw new import_errors16.FuelError(
|
4760
|
+
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4667
4761
|
"Transfer amount must be a positive number."
|
4668
4762
|
);
|
4669
4763
|
}
|
@@ -4672,7 +4766,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4672
4766
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4673
4767
|
const { script, scriptData } = await assembleTransferToContractScript({
|
4674
4768
|
hexlifiedContractId: contractAddress.toB256(),
|
4675
|
-
amountToTransfer: (0,
|
4769
|
+
amountToTransfer: (0, import_math18.bn)(amount),
|
4676
4770
|
assetId
|
4677
4771
|
});
|
4678
4772
|
const request = new ScriptTransactionRequest({
|
@@ -4683,9 +4777,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4683
4777
|
request.addContractInputAndOutput(contractAddress);
|
4684
4778
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
4685
4779
|
request,
|
4686
|
-
[{ amount: (0,
|
4780
|
+
[{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
|
4687
4781
|
);
|
4688
|
-
request.gasLimit = (0,
|
4782
|
+
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
4689
4783
|
this.validateGas({
|
4690
4784
|
gasUsed,
|
4691
4785
|
gasPrice: request.gasPrice,
|
@@ -4706,25 +4800,25 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4706
4800
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4707
4801
|
const { minGasPrice } = this.provider.getGasConfig();
|
4708
4802
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
4709
|
-
const recipientDataArray = (0,
|
4803
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
4710
4804
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4711
4805
|
);
|
4712
|
-
const amountDataArray = (0,
|
4713
|
-
"0x".concat((0,
|
4806
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
4807
|
+
"0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
4714
4808
|
);
|
4715
4809
|
const script = new Uint8Array([
|
4716
|
-
...(0,
|
4810
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
4717
4811
|
...recipientDataArray,
|
4718
4812
|
...amountDataArray
|
4719
4813
|
]);
|
4720
4814
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
4721
4815
|
const request = new ScriptTransactionRequest(params);
|
4722
|
-
const forwardingQuantities = [{ amount: (0,
|
4816
|
+
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
|
4723
4817
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
4724
4818
|
request,
|
4725
4819
|
forwardingQuantities
|
4726
4820
|
);
|
4727
|
-
request.gasLimit = (0,
|
4821
|
+
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
4728
4822
|
this.validateGas({
|
4729
4823
|
gasUsed,
|
4730
4824
|
gasPrice: request.gasPrice,
|
@@ -4736,7 +4830,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4736
4830
|
}
|
4737
4831
|
async signMessage(message) {
|
4738
4832
|
if (!this._connector) {
|
4739
|
-
throw new
|
4833
|
+
throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
4740
4834
|
}
|
4741
4835
|
return this._connector.signMessage(this.address.toString(), message);
|
4742
4836
|
}
|
@@ -4748,8 +4842,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4748
4842
|
*/
|
4749
4843
|
async signTransaction(transactionRequestLike) {
|
4750
4844
|
if (!this._connector) {
|
4751
|
-
throw new
|
4752
|
-
|
4845
|
+
throw new import_errors16.FuelError(
|
4846
|
+
import_errors16.ErrorCode.MISSING_CONNECTOR,
|
4753
4847
|
"A connector is required to sign transactions."
|
4754
4848
|
);
|
4755
4849
|
}
|
@@ -4796,14 +4890,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4796
4890
|
minGasPrice
|
4797
4891
|
}) {
|
4798
4892
|
if (minGasPrice.gt(gasPrice)) {
|
4799
|
-
throw new
|
4800
|
-
|
4893
|
+
throw new import_errors16.FuelError(
|
4894
|
+
import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
|
4801
4895
|
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
4802
4896
|
);
|
4803
4897
|
}
|
4804
4898
|
if (gasUsed.gt(gasLimit)) {
|
4805
|
-
throw new
|
4806
|
-
|
4899
|
+
throw new import_errors16.FuelError(
|
4900
|
+
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
4807
4901
|
`Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
|
4808
4902
|
);
|
4809
4903
|
}
|
@@ -4814,8 +4908,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4814
4908
|
var import_address5 = require("@fuel-ts/address");
|
4815
4909
|
var import_crypto = require("@fuel-ts/crypto");
|
4816
4910
|
var import_hasher2 = require("@fuel-ts/hasher");
|
4817
|
-
var
|
4818
|
-
var
|
4911
|
+
var import_math19 = require("@fuel-ts/math");
|
4912
|
+
var import_utils29 = require("@fuel-ts/utils");
|
4819
4913
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
4820
4914
|
var Signer = class {
|
4821
4915
|
address;
|
@@ -4834,10 +4928,10 @@ var Signer = class {
|
|
4834
4928
|
privateKey = `0x${privateKey}`;
|
4835
4929
|
}
|
4836
4930
|
}
|
4837
|
-
const privateKeyBytes = (0,
|
4838
|
-
this.privateKey = (0,
|
4839
|
-
this.publicKey = (0,
|
4840
|
-
this.compressedPublicKey = (0,
|
4931
|
+
const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
|
4932
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
4933
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
4934
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
4841
4935
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
4842
4936
|
}
|
4843
4937
|
/**
|
@@ -4851,11 +4945,11 @@ var Signer = class {
|
|
4851
4945
|
* @returns hashed signature
|
4852
4946
|
*/
|
4853
4947
|
sign(data) {
|
4854
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
4855
|
-
const r = (0,
|
4856
|
-
const s = (0,
|
4948
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
4949
|
+
const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
4950
|
+
const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
4857
4951
|
s[0] |= (signature.recovery || 0) << 7;
|
4858
|
-
return (0,
|
4952
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
4859
4953
|
}
|
4860
4954
|
/**
|
4861
4955
|
* Add point on the current elliptic curve
|
@@ -4864,8 +4958,8 @@ var Signer = class {
|
|
4864
4958
|
* @returns compressed point on the curve
|
4865
4959
|
*/
|
4866
4960
|
addPoint(point) {
|
4867
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4868
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4961
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
4962
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
4869
4963
|
const result = p0.add(p1);
|
4870
4964
|
return `0x${result.toHex(true)}`;
|
4871
4965
|
}
|
@@ -4877,16 +4971,16 @@ var Signer = class {
|
|
4877
4971
|
* @returns public key from signature from the
|
4878
4972
|
*/
|
4879
4973
|
static recoverPublicKey(data, signature) {
|
4880
|
-
const signedMessageBytes = (0,
|
4974
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
4881
4975
|
const r = signedMessageBytes.slice(0, 32);
|
4882
4976
|
const s = signedMessageBytes.slice(32, 64);
|
4883
4977
|
const recoveryParam = (s[0] & 128) >> 7;
|
4884
4978
|
s[0] &= 127;
|
4885
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
4979
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
4886
4980
|
recoveryParam
|
4887
4981
|
);
|
4888
|
-
const publicKey = sig.recoverPublicKey((0,
|
4889
|
-
return (0,
|
4982
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
4983
|
+
return (0, import_utils29.hexlify)(publicKey);
|
4890
4984
|
}
|
4891
4985
|
/**
|
4892
4986
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -4905,7 +4999,7 @@ var Signer = class {
|
|
4905
4999
|
* @returns random 32-byte hashed
|
4906
5000
|
*/
|
4907
5001
|
static generatePrivateKey(entropy) {
|
4908
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5002
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
4909
5003
|
}
|
4910
5004
|
/**
|
4911
5005
|
* Extended publicKey from a compact publicKey
|
@@ -4914,16 +5008,16 @@ var Signer = class {
|
|
4914
5008
|
* @returns extended publicKey
|
4915
5009
|
*/
|
4916
5010
|
static extendPublicKey(publicKey) {
|
4917
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4918
|
-
return (0,
|
5011
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5012
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
4919
5013
|
}
|
4920
5014
|
};
|
4921
5015
|
|
4922
5016
|
// src/wallet/keystore-wallet.ts
|
4923
5017
|
var import_address6 = require("@fuel-ts/address");
|
4924
5018
|
var import_crypto2 = require("@fuel-ts/crypto");
|
4925
|
-
var
|
4926
|
-
var
|
5019
|
+
var import_errors17 = require("@fuel-ts/errors");
|
5020
|
+
var import_utils30 = require("@fuel-ts/utils");
|
4927
5021
|
var import_uuid = require("uuid");
|
4928
5022
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
4929
5023
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5000,13 +5094,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5000
5094
|
const macHashUint8Array = (0, import_crypto2.keccak256)(data);
|
5001
5095
|
const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
|
5002
5096
|
if (mac !== macHash) {
|
5003
|
-
throw new
|
5004
|
-
|
5097
|
+
throw new import_errors17.FuelError(
|
5098
|
+
import_errors17.ErrorCode.INVALID_PASSWORD,
|
5005
5099
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
5006
5100
|
);
|
5007
5101
|
}
|
5008
5102
|
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5009
|
-
const privateKey = (0,
|
5103
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5010
5104
|
return privateKey;
|
5011
5105
|
}
|
5012
5106
|
|
@@ -5051,7 +5145,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5051
5145
|
*/
|
5052
5146
|
async signMessage(message) {
|
5053
5147
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5054
|
-
return (0,
|
5148
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
5055
5149
|
}
|
5056
5150
|
/**
|
5057
5151
|
* Signs a transaction with the wallet's private key.
|
@@ -5064,7 +5158,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5064
5158
|
const chainId = this.provider.getChainId();
|
5065
5159
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5066
5160
|
const signature = await this.signer().sign(hashedTransaction);
|
5067
|
-
return (0,
|
5161
|
+
return (0, import_utils31.hexlify)(signature);
|
5068
5162
|
}
|
5069
5163
|
/**
|
5070
5164
|
* Populates a transaction with the witnesses signature.
|
@@ -5123,17 +5217,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5123
5217
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5124
5218
|
|
5125
5219
|
// src/hdwallet/hdwallet.ts
|
5126
|
-
var
|
5220
|
+
var import_errors20 = require("@fuel-ts/errors");
|
5127
5221
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5128
|
-
var
|
5129
|
-
var
|
5222
|
+
var import_math20 = require("@fuel-ts/math");
|
5223
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5130
5224
|
var import_ethers3 = require("ethers");
|
5131
5225
|
|
5132
5226
|
// src/mnemonic/mnemonic.ts
|
5133
5227
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5134
|
-
var
|
5228
|
+
var import_errors19 = require("@fuel-ts/errors");
|
5135
5229
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5136
|
-
var
|
5230
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5137
5231
|
var import_ethers2 = require("ethers");
|
5138
5232
|
|
5139
5233
|
// src/wordlists/words/english.ts
|
@@ -7189,9 +7283,9 @@ var english = [
|
|
7189
7283
|
];
|
7190
7284
|
|
7191
7285
|
// src/mnemonic/utils.ts
|
7192
|
-
var
|
7286
|
+
var import_errors18 = require("@fuel-ts/errors");
|
7193
7287
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7194
|
-
var
|
7288
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7195
7289
|
function toUtf8Bytes(stri) {
|
7196
7290
|
const str = stri.normalize("NFKD");
|
7197
7291
|
const result = [];
|
@@ -7206,8 +7300,8 @@ function toUtf8Bytes(stri) {
|
|
7206
7300
|
i += 1;
|
7207
7301
|
const c2 = str.charCodeAt(i);
|
7208
7302
|
if (i >= str.length || (c2 & 64512) !== 56320) {
|
7209
|
-
throw new
|
7210
|
-
|
7303
|
+
throw new import_errors18.FuelError(
|
7304
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
7211
7305
|
"Invalid UTF-8 in the input string."
|
7212
7306
|
);
|
7213
7307
|
}
|
@@ -7258,20 +7352,20 @@ function entropyToMnemonicIndices(entropy) {
|
|
7258
7352
|
}
|
7259
7353
|
}
|
7260
7354
|
const checksumBits = entropy.length / 4;
|
7261
|
-
const checksum = (0,
|
7355
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7262
7356
|
indices[indices.length - 1] <<= checksumBits;
|
7263
7357
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7264
7358
|
return indices;
|
7265
7359
|
}
|
7266
7360
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7267
7361
|
const size = Math.ceil(11 * words.length / 8);
|
7268
|
-
const entropy = (0,
|
7362
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
7269
7363
|
let offset = 0;
|
7270
7364
|
for (let i = 0; i < words.length; i += 1) {
|
7271
7365
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
7272
7366
|
if (index === -1) {
|
7273
|
-
throw new
|
7274
|
-
|
7367
|
+
throw new import_errors18.FuelError(
|
7368
|
+
import_errors18.ErrorCode.INVALID_MNEMONIC,
|
7275
7369
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
7276
7370
|
);
|
7277
7371
|
}
|
@@ -7285,10 +7379,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7285
7379
|
const entropyBits = 32 * words.length / 3;
|
7286
7380
|
const checksumBits = words.length / 3;
|
7287
7381
|
const checksumMask = getUpperMask(checksumBits);
|
7288
|
-
const checksum = (0,
|
7382
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7289
7383
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7290
|
-
throw new
|
7291
|
-
|
7384
|
+
throw new import_errors18.FuelError(
|
7385
|
+
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
7292
7386
|
"Checksum validation failed for the provided mnemonic."
|
7293
7387
|
);
|
7294
7388
|
}
|
@@ -7302,16 +7396,16 @@ var TestnetPRV = "0x04358394";
|
|
7302
7396
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
7303
7397
|
function assertWordList(wordlist) {
|
7304
7398
|
if (wordlist.length !== 2048) {
|
7305
|
-
throw new
|
7306
|
-
|
7399
|
+
throw new import_errors19.FuelError(
|
7400
|
+
import_errors19.ErrorCode.INVALID_WORD_LIST,
|
7307
7401
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
7308
7402
|
);
|
7309
7403
|
}
|
7310
7404
|
}
|
7311
7405
|
function assertEntropy(entropy) {
|
7312
7406
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
7313
|
-
throw new
|
7314
|
-
|
7407
|
+
throw new import_errors19.FuelError(
|
7408
|
+
import_errors19.ErrorCode.INVALID_ENTROPY,
|
7315
7409
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
7316
7410
|
);
|
7317
7411
|
}
|
@@ -7321,7 +7415,7 @@ function assertMnemonic(words) {
|
|
7321
7415
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
7322
7416
|
", "
|
7323
7417
|
)}] words, but got ${words.length}.`;
|
7324
|
-
throw new
|
7418
|
+
throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
7325
7419
|
}
|
7326
7420
|
}
|
7327
7421
|
var Mnemonic = class {
|
@@ -7360,7 +7454,7 @@ var Mnemonic = class {
|
|
7360
7454
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7361
7455
|
const words = getWords(phrase);
|
7362
7456
|
assertMnemonic(words);
|
7363
|
-
return (0,
|
7457
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7364
7458
|
}
|
7365
7459
|
/**
|
7366
7460
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7368,7 +7462,7 @@ var Mnemonic = class {
|
|
7368
7462
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7369
7463
|
*/
|
7370
7464
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7371
|
-
const entropyBytes = (0,
|
7465
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
7372
7466
|
assertWordList(wordlist);
|
7373
7467
|
assertEntropy(entropyBytes);
|
7374
7468
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7437,14 +7531,14 @@ var Mnemonic = class {
|
|
7437
7531
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7438
7532
|
*/
|
7439
7533
|
static masterKeysFromSeed(seed) {
|
7440
|
-
const seedArray = (0,
|
7534
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
7441
7535
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7442
|
-
throw new
|
7443
|
-
|
7536
|
+
throw new import_errors19.FuelError(
|
7537
|
+
import_errors19.ErrorCode.INVALID_SEED,
|
7444
7538
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7445
7539
|
);
|
7446
7540
|
}
|
7447
|
-
return (0,
|
7541
|
+
return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
|
7448
7542
|
}
|
7449
7543
|
/**
|
7450
7544
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7455,22 +7549,22 @@ var Mnemonic = class {
|
|
7455
7549
|
*/
|
7456
7550
|
static seedToExtendedKey(seed, testnet = false) {
|
7457
7551
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7458
|
-
const prefix = (0,
|
7552
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7459
7553
|
const depth = "0x00";
|
7460
7554
|
const fingerprint = "0x00000000";
|
7461
7555
|
const index = "0x00000000";
|
7462
7556
|
const chainCode = masterKey.slice(32);
|
7463
7557
|
const privateKey = masterKey.slice(0, 32);
|
7464
|
-
const extendedKey = (0,
|
7558
|
+
const extendedKey = (0, import_utils33.concat)([
|
7465
7559
|
prefix,
|
7466
7560
|
depth,
|
7467
7561
|
fingerprint,
|
7468
7562
|
index,
|
7469
7563
|
chainCode,
|
7470
|
-
(0,
|
7564
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
7471
7565
|
]);
|
7472
7566
|
const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7473
|
-
return (0, import_ethers2.encodeBase58)((0,
|
7567
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7474
7568
|
}
|
7475
7569
|
/**
|
7476
7570
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7485,7 +7579,7 @@ var Mnemonic = class {
|
|
7485
7579
|
* @returns A randomly generated mnemonic
|
7486
7580
|
*/
|
7487
7581
|
static generate(size = 32, extraEntropy = "") {
|
7488
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
7582
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7489
7583
|
return Mnemonic.entropyToMnemonic(entropy);
|
7490
7584
|
}
|
7491
7585
|
};
|
@@ -7493,12 +7587,12 @@ var mnemonic_default = Mnemonic;
|
|
7493
7587
|
|
7494
7588
|
// src/hdwallet/hdwallet.ts
|
7495
7589
|
var HARDENED_INDEX = 2147483648;
|
7496
|
-
var MainnetPRV2 = (0,
|
7497
|
-
var MainnetPUB = (0,
|
7498
|
-
var TestnetPRV2 = (0,
|
7499
|
-
var TestnetPUB = (0,
|
7590
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
7591
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
7592
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
7593
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
7500
7594
|
function base58check(data) {
|
7501
|
-
return (0, import_ethers3.encodeBase58)((0,
|
7595
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7502
7596
|
}
|
7503
7597
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7504
7598
|
if (isPublic) {
|
@@ -7507,17 +7601,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7507
7601
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7508
7602
|
}
|
7509
7603
|
function isPublicExtendedKey(extendedKey) {
|
7510
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7604
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
7511
7605
|
}
|
7512
7606
|
function isValidExtendedKey(extendedKey) {
|
7513
7607
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7514
|
-
(0,
|
7608
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
7515
7609
|
);
|
7516
7610
|
}
|
7517
7611
|
function parsePath(path2, depth = 0) {
|
7518
7612
|
const components = path2.split("/");
|
7519
7613
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
7520
|
-
throw new
|
7614
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
7521
7615
|
}
|
7522
7616
|
if (components[0] === "m") {
|
7523
7617
|
components.shift();
|
@@ -7529,8 +7623,8 @@ function parsePath(path2, depth = 0) {
|
|
7529
7623
|
var HDWallet = class {
|
7530
7624
|
depth = 0;
|
7531
7625
|
index = 0;
|
7532
|
-
fingerprint = (0,
|
7533
|
-
parentFingerprint = (0,
|
7626
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7627
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7534
7628
|
privateKey;
|
7535
7629
|
publicKey;
|
7536
7630
|
chainCode;
|
@@ -7542,16 +7636,16 @@ var HDWallet = class {
|
|
7542
7636
|
constructor(config) {
|
7543
7637
|
if (config.privateKey) {
|
7544
7638
|
const signer = new Signer(config.privateKey);
|
7545
|
-
this.publicKey = (0,
|
7546
|
-
this.privateKey = (0,
|
7639
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
7640
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
7547
7641
|
} else {
|
7548
7642
|
if (!config.publicKey) {
|
7549
|
-
throw new
|
7550
|
-
|
7643
|
+
throw new import_errors20.FuelError(
|
7644
|
+
import_errors20.ErrorCode.HD_WALLET_ERROR,
|
7551
7645
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7552
7646
|
);
|
7553
7647
|
}
|
7554
|
-
this.publicKey = (0,
|
7648
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
7555
7649
|
}
|
7556
7650
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7557
7651
|
this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
@@ -7570,28 +7664,28 @@ var HDWallet = class {
|
|
7570
7664
|
* @returns A new instance of HDWallet on the derived index
|
7571
7665
|
*/
|
7572
7666
|
deriveIndex(index) {
|
7573
|
-
const privateKey = this.privateKey && (0,
|
7574
|
-
const publicKey = (0,
|
7575
|
-
const chainCode = (0,
|
7667
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
7668
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
7669
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
7576
7670
|
const data = new Uint8Array(37);
|
7577
7671
|
if (index & HARDENED_INDEX) {
|
7578
7672
|
if (!privateKey) {
|
7579
|
-
throw new
|
7580
|
-
|
7673
|
+
throw new import_errors20.FuelError(
|
7674
|
+
import_errors20.ErrorCode.HD_WALLET_ERROR,
|
7581
7675
|
"Cannot derive a hardened index without a private Key."
|
7582
7676
|
);
|
7583
7677
|
}
|
7584
7678
|
data.set(privateKey, 1);
|
7585
7679
|
} else {
|
7586
|
-
data.set((0,
|
7680
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
7587
7681
|
}
|
7588
|
-
data.set((0,
|
7589
|
-
const bytes = (0,
|
7682
|
+
data.set((0, import_math20.toBytes)(index, 4), 33);
|
7683
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
|
7590
7684
|
const IL = bytes.slice(0, 32);
|
7591
7685
|
const IR = bytes.slice(32);
|
7592
7686
|
if (privateKey) {
|
7593
7687
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7594
|
-
const ki = (0,
|
7688
|
+
const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
7595
7689
|
return new HDWallet({
|
7596
7690
|
privateKey: ki,
|
7597
7691
|
chainCode: IR,
|
@@ -7600,7 +7694,7 @@ var HDWallet = class {
|
|
7600
7694
|
parentFingerprint: this.fingerprint
|
7601
7695
|
});
|
7602
7696
|
}
|
7603
|
-
const signer = new Signer((0,
|
7697
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
7604
7698
|
const Ki = signer.addPoint(publicKey);
|
7605
7699
|
return new HDWallet({
|
7606
7700
|
publicKey: Ki,
|
@@ -7629,18 +7723,18 @@ var HDWallet = class {
|
|
7629
7723
|
*/
|
7630
7724
|
toExtendedKey(isPublic = false, testnet = false) {
|
7631
7725
|
if (this.depth >= 256) {
|
7632
|
-
throw new
|
7633
|
-
|
7726
|
+
throw new import_errors20.FuelError(
|
7727
|
+
import_errors20.ErrorCode.HD_WALLET_ERROR,
|
7634
7728
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
7635
7729
|
);
|
7636
7730
|
}
|
7637
7731
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7638
|
-
const depth = (0,
|
7732
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
7639
7733
|
const parentFingerprint = this.parentFingerprint;
|
7640
|
-
const index = (0,
|
7734
|
+
const index = (0, import_math20.toHex)(this.index, 4);
|
7641
7735
|
const chainCode = this.chainCode;
|
7642
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
7643
|
-
const extendedKey = (0,
|
7736
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
7737
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7644
7738
|
return base58check(extendedKey);
|
7645
7739
|
}
|
7646
7740
|
/**
|
@@ -7652,34 +7746,34 @@ var HDWallet = class {
|
|
7652
7746
|
static fromSeed(seed) {
|
7653
7747
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7654
7748
|
return new HDWallet({
|
7655
|
-
chainCode: (0,
|
7656
|
-
privateKey: (0,
|
7749
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
7750
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
7657
7751
|
});
|
7658
7752
|
}
|
7659
7753
|
static fromExtendedKey(extendedKey) {
|
7660
7754
|
const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
|
7661
|
-
const bytes = (0,
|
7755
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
7662
7756
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7663
7757
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7664
|
-
throw new
|
7758
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
7665
7759
|
}
|
7666
7760
|
if (!validChecksum) {
|
7667
|
-
throw new
|
7761
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7668
7762
|
}
|
7669
7763
|
const depth = bytes[4];
|
7670
|
-
const parentFingerprint = (0,
|
7671
|
-
const index = parseInt((0,
|
7672
|
-
const chainCode = (0,
|
7764
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
7765
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
7766
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
7673
7767
|
const key = bytes.slice(45, 78);
|
7674
7768
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7675
|
-
throw new
|
7676
|
-
|
7769
|
+
throw new import_errors20.FuelError(
|
7770
|
+
import_errors20.ErrorCode.HD_WALLET_ERROR,
|
7677
7771
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
7678
7772
|
);
|
7679
7773
|
}
|
7680
7774
|
if (isPublicExtendedKey(bytes)) {
|
7681
7775
|
if (key[0] !== 3) {
|
7682
|
-
throw new
|
7776
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
7683
7777
|
}
|
7684
7778
|
return new HDWallet({
|
7685
7779
|
publicKey: key,
|
@@ -7690,7 +7784,7 @@ var HDWallet = class {
|
|
7690
7784
|
});
|
7691
7785
|
}
|
7692
7786
|
if (key[0] !== 0) {
|
7693
|
-
throw new
|
7787
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
7694
7788
|
}
|
7695
7789
|
return new HDWallet({
|
7696
7790
|
privateKey: key.slice(1),
|
@@ -7883,9 +7977,9 @@ var generateTestWallet = async (provider, quantities) => {
|
|
7883
7977
|
};
|
7884
7978
|
|
7885
7979
|
// src/test-utils/launchNode.ts
|
7886
|
-
var
|
7887
|
-
var
|
7888
|
-
var
|
7980
|
+
var import_configs13 = require("@fuel-ts/address/configs");
|
7981
|
+
var import_math21 = require("@fuel-ts/math");
|
7982
|
+
var import_utils36 = require("@fuel-ts/utils");
|
7889
7983
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
7890
7984
|
var import_child_process = require("child_process");
|
7891
7985
|
var import_crypto5 = require("crypto");
|
@@ -7943,7 +8037,7 @@ var launchNode = async ({
|
|
7943
8037
|
"--poa-instant"
|
7944
8038
|
]);
|
7945
8039
|
const chainConfigPath = getFlagValueFromArgs(args, "--chain");
|
7946
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
8040
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
|
7947
8041
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
7948
8042
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
7949
8043
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -7969,21 +8063,21 @@ var launchNode = async ({
|
|
7969
8063
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
7970
8064
|
}
|
7971
8065
|
const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
7972
|
-
let chainConfig =
|
8066
|
+
let chainConfig = import_utils36.defaultChainConfig;
|
7973
8067
|
if (!process.env.GENESIS_SECRET) {
|
7974
8068
|
const pk = Signer.generatePrivateKey();
|
7975
8069
|
const signer = new Signer(pk);
|
7976
|
-
process.env.GENESIS_SECRET = (0,
|
8070
|
+
process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
|
7977
8071
|
chainConfig = {
|
7978
|
-
...
|
8072
|
+
...import_utils36.defaultChainConfig,
|
7979
8073
|
initial_state: {
|
7980
|
-
...
|
8074
|
+
...import_utils36.defaultChainConfig.initial_state,
|
7981
8075
|
coins: [
|
7982
|
-
...
|
8076
|
+
...import_utils36.defaultChainConfig.initial_state.coins,
|
7983
8077
|
{
|
7984
8078
|
owner: signer.address.toHexString(),
|
7985
|
-
amount: (0,
|
7986
|
-
asset_id:
|
8079
|
+
amount: (0, import_math21.toHex)(1e9),
|
8080
|
+
asset_id: import_configs13.BaseAssetId
|
7987
8081
|
}
|
7988
8082
|
]
|
7989
8083
|
}
|
@@ -8051,7 +8145,7 @@ var launchNode = async ({
|
|
8051
8145
|
var generateWallets = async (count, provider) => {
|
8052
8146
|
const wallets = [];
|
8053
8147
|
for (let i = 0; i < count; i += 1) {
|
8054
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
8148
|
+
const wallet = await generateTestWallet(provider, [[1e3, import_configs13.BaseAssetId]]);
|
8055
8149
|
wallets.push(wallet);
|
8056
8150
|
}
|
8057
8151
|
return wallets;
|