@fuel-ts/account 0.0.0-rc-1976-20240410103621 → 0.0.0-rc-2034-20240410113328
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/account.d.ts.map +1 -1
- package/dist/index.global.js +113 -90
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +132 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -84
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +2 -2
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +15 -9
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -5
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +116 -94
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +132 -128
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +91 -87
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/test-utils.js
CHANGED
@@ -62,12 +62,14 @@ 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 import_configs12 = require("@fuel-ts/address/configs");
|
65
66
|
var import_errors16 = require("@fuel-ts/errors");
|
66
67
|
var import_interfaces = require("@fuel-ts/interfaces");
|
67
68
|
var import_math18 = require("@fuel-ts/math");
|
68
69
|
var import_utils28 = require("@fuel-ts/utils");
|
69
70
|
|
70
71
|
// src/providers/coin-quantity.ts
|
72
|
+
var import_configs = require("@fuel-ts/address/configs");
|
71
73
|
var import_math = require("@fuel-ts/math");
|
72
74
|
var import_utils = require("@fuel-ts/utils");
|
73
75
|
var coinQuantityfy = (coinQuantityLike) => {
|
@@ -76,11 +78,11 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
76
78
|
let max2;
|
77
79
|
if (Array.isArray(coinQuantityLike)) {
|
78
80
|
amount = coinQuantityLike[0];
|
79
|
-
assetId = coinQuantityLike[1];
|
80
|
-
max2 = coinQuantityLike[2];
|
81
|
+
assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
|
82
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
81
83
|
} else {
|
82
84
|
amount = coinQuantityLike.amount;
|
83
|
-
assetId = coinQuantityLike.assetId;
|
85
|
+
assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
|
84
86
|
max2 = coinQuantityLike.max ?? void 0;
|
85
87
|
}
|
86
88
|
const bnAmount = (0, import_math.bn)(amount);
|
@@ -110,7 +112,7 @@ var import_transactions18 = require("@fuel-ts/transactions");
|
|
110
112
|
var import_utils23 = require("@fuel-ts/utils");
|
111
113
|
var import_versions = require("@fuel-ts/versions");
|
112
114
|
var import_utils24 = require("@noble/curves/abstract/utils");
|
113
|
-
var
|
115
|
+
var import_ethers2 = require("ethers");
|
114
116
|
var import_graphql_request = require("graphql-request");
|
115
117
|
var import_ramda3 = require("ramda");
|
116
118
|
|
@@ -1049,7 +1051,7 @@ var MemoryCache = class {
|
|
1049
1051
|
};
|
1050
1052
|
|
1051
1053
|
// src/providers/transaction-request/input.ts
|
1052
|
-
var
|
1054
|
+
var import_configs2 = require("@fuel-ts/address/configs");
|
1053
1055
|
var import_errors3 = require("@fuel-ts/errors");
|
1054
1056
|
var import_math2 = require("@fuel-ts/math");
|
1055
1057
|
var import_transactions = require("@fuel-ts/transactions");
|
@@ -1063,7 +1065,7 @@ var inputify = (value) => {
|
|
1063
1065
|
return {
|
1064
1066
|
type: import_transactions.InputType.Coin,
|
1065
1067
|
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
|
1066
|
-
outputIndex: (0, import_utils3.arrayify)(value.id)
|
1068
|
+
outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 33)),
|
1067
1069
|
owner: (0, import_utils3.hexlify)(value.owner),
|
1068
1070
|
amount: (0, import_math2.bn)(value.amount),
|
1069
1071
|
assetId: (0, import_utils3.hexlify)(value.assetId),
|
@@ -1083,10 +1085,10 @@ var inputify = (value) => {
|
|
1083
1085
|
case import_transactions.InputType.Contract: {
|
1084
1086
|
return {
|
1085
1087
|
type: import_transactions.InputType.Contract,
|
1086
|
-
txID:
|
1088
|
+
txID: import_configs2.ZeroBytes32,
|
1087
1089
|
outputIndex: 0,
|
1088
|
-
balanceRoot:
|
1089
|
-
stateRoot:
|
1090
|
+
balanceRoot: import_configs2.ZeroBytes32,
|
1091
|
+
stateRoot: import_configs2.ZeroBytes32,
|
1090
1092
|
txPointer: {
|
1091
1093
|
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1092
1094
|
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
@@ -1124,7 +1126,7 @@ var inputify = (value) => {
|
|
1124
1126
|
};
|
1125
1127
|
|
1126
1128
|
// src/providers/transaction-request/output.ts
|
1127
|
-
var
|
1129
|
+
var import_configs3 = require("@fuel-ts/address/configs");
|
1128
1130
|
var import_errors4 = require("@fuel-ts/errors");
|
1129
1131
|
var import_math3 = require("@fuel-ts/math");
|
1130
1132
|
var import_transactions2 = require("@fuel-ts/transactions");
|
@@ -1144,8 +1146,8 @@ var outputify = (value) => {
|
|
1144
1146
|
return {
|
1145
1147
|
type: import_transactions2.OutputType.Contract,
|
1146
1148
|
inputIndex: value.inputIndex,
|
1147
|
-
balanceRoot:
|
1148
|
-
stateRoot:
|
1149
|
+
balanceRoot: import_configs3.ZeroBytes32,
|
1150
|
+
stateRoot: import_configs3.ZeroBytes32
|
1149
1151
|
};
|
1150
1152
|
}
|
1151
1153
|
case import_transactions2.OutputType.Change: {
|
@@ -1159,9 +1161,9 @@ var outputify = (value) => {
|
|
1159
1161
|
case import_transactions2.OutputType.Variable: {
|
1160
1162
|
return {
|
1161
1163
|
type: import_transactions2.OutputType.Variable,
|
1162
|
-
to:
|
1164
|
+
to: import_configs3.ZeroBytes32,
|
1163
1165
|
amount: (0, import_math3.bn)(0),
|
1164
|
-
assetId:
|
1166
|
+
assetId: import_configs3.ZeroBytes32
|
1165
1167
|
};
|
1166
1168
|
}
|
1167
1169
|
case import_transactions2.OutputType.ContractCreated: {
|
@@ -1182,22 +1184,23 @@ var outputify = (value) => {
|
|
1182
1184
|
|
1183
1185
|
// src/providers/transaction-request/transaction-request.ts
|
1184
1186
|
var import_address = require("@fuel-ts/address");
|
1185
|
-
var
|
1187
|
+
var import_configs7 = require("@fuel-ts/address/configs");
|
1186
1188
|
var import_math7 = require("@fuel-ts/math");
|
1187
1189
|
var import_transactions6 = require("@fuel-ts/transactions");
|
1188
1190
|
var import_utils9 = require("@fuel-ts/utils");
|
1191
|
+
var import_ethers = require("ethers");
|
1189
1192
|
|
1190
1193
|
// src/providers/resource.ts
|
1191
1194
|
var isCoin = (resource) => "id" in resource;
|
1192
1195
|
|
1193
1196
|
// src/providers/utils/receipts.ts
|
1194
|
-
var
|
1197
|
+
var import_configs4 = require("@fuel-ts/address/configs");
|
1195
1198
|
var import_errors5 = require("@fuel-ts/errors");
|
1196
1199
|
var import_math4 = require("@fuel-ts/math");
|
1197
1200
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1198
|
-
var
|
1201
|
+
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1199
1202
|
var import_utils5 = require("@fuel-ts/utils");
|
1200
|
-
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") ===
|
1203
|
+
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1201
1204
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1202
1205
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
1203
1206
|
(memo, receipt) => {
|
@@ -1214,7 +1217,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
|
1214
1217
|
missingOutputContractIds: []
|
1215
1218
|
}
|
1216
1219
|
);
|
1217
|
-
var hexOrZero = (hex) => hex ||
|
1220
|
+
var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
|
1218
1221
|
function assembleReceiptByType(receipt) {
|
1219
1222
|
const { receiptType } = receipt;
|
1220
1223
|
switch (receiptType) {
|
@@ -1519,16 +1522,16 @@ function sleep(time) {
|
|
1519
1522
|
var import_errors7 = require("@fuel-ts/errors");
|
1520
1523
|
var import_math6 = require("@fuel-ts/math");
|
1521
1524
|
var import_transactions5 = require("@fuel-ts/transactions");
|
1522
|
-
var
|
1525
|
+
var import_configs6 = require("@fuel-ts/transactions/configs");
|
1523
1526
|
var assemblePanicError = (status) => {
|
1524
1527
|
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
1525
1528
|
const reason = status.reason;
|
1526
|
-
if (
|
1529
|
+
if (import_configs6.PANIC_REASONS.includes(status.reason)) {
|
1527
1530
|
errorMessage = `${errorMessage}
|
1528
1531
|
|
1529
1532
|
You can read more about this error at:
|
1530
1533
|
|
1531
|
-
${
|
1534
|
+
${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
|
1532
1535
|
}
|
1533
1536
|
return { errorMessage, reason };
|
1534
1537
|
};
|
@@ -1540,28 +1543,28 @@ var assembleRevertError = (receipts, logs) => {
|
|
1540
1543
|
if (revertReceipt) {
|
1541
1544
|
const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
|
1542
1545
|
switch (reasonHex) {
|
1543
|
-
case
|
1546
|
+
case import_configs6.FAILED_REQUIRE_SIGNAL: {
|
1544
1547
|
reason = "require";
|
1545
1548
|
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
|
1546
1549
|
break;
|
1547
1550
|
}
|
1548
|
-
case
|
1551
|
+
case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
|
1549
1552
|
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1550
1553
|
reason = "assert_eq";
|
1551
1554
|
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
1552
1555
|
break;
|
1553
1556
|
}
|
1554
|
-
case
|
1557
|
+
case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
|
1555
1558
|
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1556
1559
|
reason = "assert_ne";
|
1557
1560
|
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
1558
1561
|
break;
|
1559
1562
|
}
|
1560
|
-
case
|
1563
|
+
case import_configs6.FAILED_ASSERT_SIGNAL:
|
1561
1564
|
reason = "assert";
|
1562
1565
|
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
1563
1566
|
break;
|
1564
|
-
case
|
1567
|
+
case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
1565
1568
|
reason = "MissingOutputChange";
|
1566
1569
|
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1567
1570
|
break;
|
@@ -1623,8 +1626,6 @@ var BaseTransactionRequest = class {
|
|
1623
1626
|
outputs = [];
|
1624
1627
|
/** List of witnesses */
|
1625
1628
|
witnesses = [];
|
1626
|
-
/** Base asset ID - should be fetched from the chain */
|
1627
|
-
baseAssetId = import_configs6.ZeroBytes32;
|
1628
1629
|
/**
|
1629
1630
|
* Constructor for initializing a base transaction request.
|
1630
1631
|
*
|
@@ -1637,8 +1638,7 @@ var BaseTransactionRequest = class {
|
|
1637
1638
|
witnessLimit,
|
1638
1639
|
inputs,
|
1639
1640
|
outputs,
|
1640
|
-
witnesses
|
1641
|
-
baseAssetId
|
1641
|
+
witnesses
|
1642
1642
|
} = {}) {
|
1643
1643
|
this.gasPrice = (0, import_math7.bn)(gasPrice);
|
1644
1644
|
this.maturity = maturity ?? 0;
|
@@ -1647,7 +1647,6 @@ var BaseTransactionRequest = class {
|
|
1647
1647
|
this.inputs = inputs ?? [];
|
1648
1648
|
this.outputs = outputs ?? [];
|
1649
1649
|
this.witnesses = witnesses ?? [];
|
1650
|
-
this.baseAssetId = baseAssetId ?? import_configs6.ZeroBytes32;
|
1651
1650
|
}
|
1652
1651
|
static getPolicyMeta(req) {
|
1653
1652
|
let policyTypes = 0;
|
@@ -1740,7 +1739,7 @@ var BaseTransactionRequest = class {
|
|
1740
1739
|
* @returns The index of the created witness.
|
1741
1740
|
*/
|
1742
1741
|
addEmptyWitness() {
|
1743
|
-
this.addWitness((0, import_utils9.concat)([
|
1742
|
+
this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
|
1744
1743
|
return this.witnesses.length - 1;
|
1745
1744
|
}
|
1746
1745
|
/**
|
@@ -1872,9 +1871,11 @@ var BaseTransactionRequest = class {
|
|
1872
1871
|
*
|
1873
1872
|
* @param message - Message resource.
|
1874
1873
|
* @param predicate - Predicate bytes.
|
1874
|
+
* @param predicateData - Predicate data bytes.
|
1875
1875
|
*/
|
1876
1876
|
addMessageInput(message, predicate) {
|
1877
1877
|
const { recipient, sender, amount } = message;
|
1878
|
+
const assetId = import_configs7.BaseAssetId;
|
1878
1879
|
let witnessIndex;
|
1879
1880
|
if (predicate) {
|
1880
1881
|
witnessIndex = 0;
|
@@ -1895,7 +1896,7 @@ var BaseTransactionRequest = class {
|
|
1895
1896
|
predicateData: predicate?.predicateDataBytes
|
1896
1897
|
};
|
1897
1898
|
this.pushInput(input);
|
1898
|
-
this.addChangeOutput(recipient,
|
1899
|
+
this.addChangeOutput(recipient, assetId);
|
1899
1900
|
}
|
1900
1901
|
/**
|
1901
1902
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -1956,12 +1957,12 @@ var BaseTransactionRequest = class {
|
|
1956
1957
|
* @param amount - Amount of coin.
|
1957
1958
|
* @param assetId - Asset ID of coin.
|
1958
1959
|
*/
|
1959
|
-
addCoinOutput(to, amount, assetId) {
|
1960
|
+
addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
|
1960
1961
|
this.pushOutput({
|
1961
1962
|
type: import_transactions6.OutputType.Coin,
|
1962
1963
|
to: (0, import_address.addressify)(to).toB256(),
|
1963
1964
|
amount,
|
1964
|
-
assetId
|
1965
|
+
assetId
|
1965
1966
|
});
|
1966
1967
|
return this;
|
1967
1968
|
}
|
@@ -1988,7 +1989,7 @@ var BaseTransactionRequest = class {
|
|
1988
1989
|
* @param to - Address of the owner.
|
1989
1990
|
* @param assetId - Asset ID of coin.
|
1990
1991
|
*/
|
1991
|
-
addChangeOutput(to, assetId) {
|
1992
|
+
addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
|
1992
1993
|
const changeOutput = this.getChangeOutputs().find(
|
1993
1994
|
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
1994
1995
|
);
|
@@ -1996,7 +1997,7 @@ var BaseTransactionRequest = class {
|
|
1996
1997
|
this.pushOutput({
|
1997
1998
|
type: import_transactions6.OutputType.Change,
|
1998
1999
|
to: (0, import_address.addressify)(to).toB256(),
|
1999
|
-
assetId
|
2000
|
+
assetId
|
2000
2001
|
});
|
2001
2002
|
}
|
2002
2003
|
}
|
@@ -2047,12 +2048,6 @@ var BaseTransactionRequest = class {
|
|
2047
2048
|
* @param quantities - CoinQuantity Array.
|
2048
2049
|
*/
|
2049
2050
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
2050
|
-
let idCounter = 0;
|
2051
|
-
const generateId = () => {
|
2052
|
-
const counterString = String(idCounter++);
|
2053
|
-
const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
2054
|
-
return id;
|
2055
|
-
};
|
2056
2051
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
2057
2052
|
if ("assetId" in input) {
|
2058
2053
|
return input.assetId === assetId;
|
@@ -2062,12 +2057,12 @@ var BaseTransactionRequest = class {
|
|
2062
2057
|
const updateAssetInput = (assetId, quantity) => {
|
2063
2058
|
const assetInput = findAssetInput(assetId);
|
2064
2059
|
if (assetInput && "assetId" in assetInput) {
|
2065
|
-
assetInput.id =
|
2060
|
+
assetInput.id = (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(33));
|
2066
2061
|
assetInput.amount = quantity;
|
2067
2062
|
} else {
|
2068
2063
|
this.addResources([
|
2069
2064
|
{
|
2070
|
-
id:
|
2065
|
+
id: (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(33)),
|
2071
2066
|
amount: quantity,
|
2072
2067
|
assetId,
|
2073
2068
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
@@ -2078,7 +2073,7 @@ var BaseTransactionRequest = class {
|
|
2078
2073
|
]);
|
2079
2074
|
}
|
2080
2075
|
};
|
2081
|
-
updateAssetInput(
|
2076
|
+
updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
|
2082
2077
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2083
2078
|
}
|
2084
2079
|
/**
|
@@ -2128,13 +2123,13 @@ var BaseTransactionRequest = class {
|
|
2128
2123
|
};
|
2129
2124
|
|
2130
2125
|
// src/providers/transaction-request/create-transaction-request.ts
|
2131
|
-
var
|
2126
|
+
var import_configs9 = require("@fuel-ts/address/configs");
|
2132
2127
|
var import_math9 = require("@fuel-ts/math");
|
2133
2128
|
var import_transactions8 = require("@fuel-ts/transactions");
|
2134
2129
|
var import_utils13 = require("@fuel-ts/utils");
|
2135
2130
|
|
2136
2131
|
// src/providers/transaction-request/hash-transaction.ts
|
2137
|
-
var
|
2132
|
+
var import_configs8 = require("@fuel-ts/address/configs");
|
2138
2133
|
var import_hasher = require("@fuel-ts/hasher");
|
2139
2134
|
var import_math8 = require("@fuel-ts/math");
|
2140
2135
|
var import_transactions7 = require("@fuel-ts/transactions");
|
@@ -2143,7 +2138,7 @@ var import_ramda2 = require("ramda");
|
|
2143
2138
|
function hashTransaction(transactionRequest, chainId) {
|
2144
2139
|
const transaction = transactionRequest.toTransaction();
|
2145
2140
|
if (transaction.type === import_transactions7.TransactionType.Script) {
|
2146
|
-
transaction.receiptsRoot =
|
2141
|
+
transaction.receiptsRoot = import_configs8.ZeroBytes32;
|
2147
2142
|
}
|
2148
2143
|
transaction.inputs = transaction.inputs.map((input) => {
|
2149
2144
|
const inputClone = (0, import_ramda2.clone)(input);
|
@@ -2165,10 +2160,10 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2165
2160
|
blockHeight: 0,
|
2166
2161
|
txIndex: 0
|
2167
2162
|
};
|
2168
|
-
inputClone.txID =
|
2163
|
+
inputClone.txID = import_configs8.ZeroBytes32;
|
2169
2164
|
inputClone.outputIndex = 0;
|
2170
|
-
inputClone.balanceRoot =
|
2171
|
-
inputClone.stateRoot =
|
2165
|
+
inputClone.balanceRoot = import_configs8.ZeroBytes32;
|
2166
|
+
inputClone.stateRoot = import_configs8.ZeroBytes32;
|
2172
2167
|
return inputClone;
|
2173
2168
|
}
|
2174
2169
|
default:
|
@@ -2179,8 +2174,8 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2179
2174
|
const outputClone = (0, import_ramda2.clone)(output);
|
2180
2175
|
switch (outputClone.type) {
|
2181
2176
|
case import_transactions7.OutputType.Contract: {
|
2182
|
-
outputClone.balanceRoot =
|
2183
|
-
outputClone.stateRoot =
|
2177
|
+
outputClone.balanceRoot = import_configs8.ZeroBytes32;
|
2178
|
+
outputClone.stateRoot = import_configs8.ZeroBytes32;
|
2184
2179
|
return outputClone;
|
2185
2180
|
}
|
2186
2181
|
case import_transactions7.OutputType.Change: {
|
@@ -2188,9 +2183,9 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2188
2183
|
return outputClone;
|
2189
2184
|
}
|
2190
2185
|
case import_transactions7.OutputType.Variable: {
|
2191
|
-
outputClone.to =
|
2186
|
+
outputClone.to = import_configs8.ZeroBytes32;
|
2192
2187
|
outputClone.amount = (0, import_math8.bn)(0);
|
2193
|
-
outputClone.assetId =
|
2188
|
+
outputClone.assetId = import_configs8.ZeroBytes32;
|
2194
2189
|
return outputClone;
|
2195
2190
|
}
|
2196
2191
|
default:
|
@@ -2256,7 +2251,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2256
2251
|
} = {}) {
|
2257
2252
|
super(rest);
|
2258
2253
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2259
|
-
this.salt = (0, import_utils13.hexlify)(salt ??
|
2254
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
|
2260
2255
|
this.storageSlots = [...storageSlots ?? []];
|
2261
2256
|
}
|
2262
2257
|
/**
|
@@ -2274,7 +2269,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2274
2269
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2275
2270
|
bytecodeWitnessIndex,
|
2276
2271
|
storageSlotsCount: storageSlots.length,
|
2277
|
-
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) :
|
2272
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
|
2278
2273
|
storageSlots
|
2279
2274
|
};
|
2280
2275
|
}
|
@@ -2324,7 +2319,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2324
2319
|
// src/providers/transaction-request/script-transaction-request.ts
|
2325
2320
|
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2326
2321
|
var import_address2 = require("@fuel-ts/address");
|
2327
|
-
var
|
2322
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
2328
2323
|
var import_math10 = require("@fuel-ts/math");
|
2329
2324
|
var import_transactions9 = require("@fuel-ts/transactions");
|
2330
2325
|
var import_utils15 = require("@fuel-ts/utils");
|
@@ -2398,7 +2393,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2398
2393
|
...super.getBaseTransaction(),
|
2399
2394
|
scriptLength: script.length,
|
2400
2395
|
scriptDataLength: scriptData.length,
|
2401
|
-
receiptsRoot:
|
2396
|
+
receiptsRoot: import_configs10.ZeroBytes32,
|
2402
2397
|
script: (0, import_utils15.hexlify)(script),
|
2403
2398
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2404
2399
|
};
|
@@ -2630,7 +2625,7 @@ var calculateTransactionFee = (params) => {
|
|
2630
2625
|
};
|
2631
2626
|
|
2632
2627
|
// src/providers/transaction-summary/operations.ts
|
2633
|
-
var
|
2628
|
+
var import_configs11 = require("@fuel-ts/address/configs");
|
2634
2629
|
var import_errors11 = require("@fuel-ts/errors");
|
2635
2630
|
var import_math13 = require("@fuel-ts/math");
|
2636
2631
|
var import_transactions14 = require("@fuel-ts/transactions");
|
@@ -2928,7 +2923,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
2928
2923
|
const { to: toAddress, assetId, amount } = receipt;
|
2929
2924
|
let { from: fromAddress } = receipt;
|
2930
2925
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
2931
|
-
if (
|
2926
|
+
if (import_configs11.ZeroBytes32 === fromAddress) {
|
2932
2927
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
2933
2928
|
fromAddress = change?.to || fromAddress;
|
2934
2929
|
}
|
@@ -3505,7 +3500,6 @@ var processGqlChain = (chain) => {
|
|
3505
3500
|
gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
|
3506
3501
|
maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
|
3507
3502
|
chainId: (0, import_math15.bn)(consensusParameters.chainId),
|
3508
|
-
baseAssetId: consensusParameters.baseAssetId,
|
3509
3503
|
gasCosts
|
3510
3504
|
},
|
3511
3505
|
gasCosts,
|
@@ -3696,7 +3690,7 @@ var _Provider = class {
|
|
3696
3690
|
name,
|
3697
3691
|
consensusParameters: { chainId }
|
3698
3692
|
} = await this.getChain();
|
3699
|
-
const network = new
|
3693
|
+
const network = new import_ethers2.Network(name, chainId.toNumber());
|
3700
3694
|
return Promise.resolve(network);
|
3701
3695
|
}
|
3702
3696
|
/**
|
@@ -3748,17 +3742,6 @@ var _Provider = class {
|
|
3748
3742
|
} = this.getChain();
|
3749
3743
|
return chainId.toNumber();
|
3750
3744
|
}
|
3751
|
-
/**
|
3752
|
-
* Returns the base asset ID
|
3753
|
-
*
|
3754
|
-
* @returns A promise that resolves to the base asset ID
|
3755
|
-
*/
|
3756
|
-
getBaseAssetId() {
|
3757
|
-
const {
|
3758
|
-
consensusParameters: { baseAssetId }
|
3759
|
-
} = this.getChain();
|
3760
|
-
return baseAssetId;
|
3761
|
-
}
|
3762
3745
|
/**
|
3763
3746
|
* Submits a transaction to the chain to be executed.
|
3764
3747
|
*
|
@@ -3909,6 +3892,37 @@ var _Provider = class {
|
|
3909
3892
|
missingContractIds
|
3910
3893
|
};
|
3911
3894
|
}
|
3895
|
+
/**
|
3896
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
3897
|
+
* @param transactionRequest - The transaction request object.
|
3898
|
+
* @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
|
3899
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
3900
|
+
*/
|
3901
|
+
estimateTxGasAndFee(params) {
|
3902
|
+
const { transactionRequest } = params;
|
3903
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
3904
|
+
const chainInfo = this.getChain();
|
3905
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
3906
|
+
transactionRequest.gasPrice = gasPrice;
|
3907
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
3908
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3909
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Script) {
|
3910
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
3911
|
+
transactionRequest.gasLimit = minGas;
|
3912
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
3913
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
3914
|
+
);
|
3915
|
+
}
|
3916
|
+
}
|
3917
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
3918
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3919
|
+
return {
|
3920
|
+
minGas,
|
3921
|
+
minFee,
|
3922
|
+
maxGas,
|
3923
|
+
maxFee
|
3924
|
+
};
|
3925
|
+
}
|
3912
3926
|
/**
|
3913
3927
|
* Executes a signed transaction without applying the states changes
|
3914
3928
|
* on the chain.
|
@@ -3956,17 +3970,16 @@ var _Provider = class {
|
|
3956
3970
|
signatureCallback
|
3957
3971
|
} = {}) {
|
3958
3972
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
3959
|
-
const
|
3960
|
-
const
|
3961
|
-
const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
3973
|
+
const { minGasPrice } = this.getGasConfig();
|
3974
|
+
const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
3962
3975
|
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
3963
3976
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3964
3977
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
3965
3978
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
3979
|
+
if (isScriptTransaction) {
|
3980
|
+
txRequestClone.gasLimit = (0, import_math15.bn)(0);
|
3981
|
+
}
|
3966
3982
|
if (estimatePredicates) {
|
3967
|
-
if (isScriptTransaction) {
|
3968
|
-
txRequestClone.gasLimit = (0, import_math15.bn)(0);
|
3969
|
-
}
|
3970
3983
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3971
3984
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3972
3985
|
}
|
@@ -3975,36 +3988,34 @@ var _Provider = class {
|
|
3975
3988
|
if (signatureCallback && isScriptTransaction) {
|
3976
3989
|
await signatureCallback(txRequestClone);
|
3977
3990
|
}
|
3978
|
-
|
3979
|
-
|
3991
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
3992
|
+
transactionRequest: txRequestClone
|
3993
|
+
});
|
3980
3994
|
let receipts = [];
|
3981
3995
|
let missingContractIds = [];
|
3982
3996
|
let outputVariables = 0;
|
3997
|
+
let gasUsed = (0, import_math15.bn)(0);
|
3983
3998
|
if (isScriptTransaction && estimateTxDependencies) {
|
3984
3999
|
txRequestClone.gasPrice = (0, import_math15.bn)(0);
|
3985
|
-
txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
3986
4000
|
const result = await this.estimateTxDependencies(txRequestClone);
|
3987
4001
|
receipts = result.receipts;
|
3988
4002
|
outputVariables = result.outputVariables;
|
3989
4003
|
missingContractIds = result.missingContractIds;
|
4004
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4005
|
+
txRequestClone.gasLimit = gasUsed;
|
4006
|
+
txRequestClone.gasPrice = setGasPrice;
|
4007
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4008
|
+
transactionRequest: txRequestClone
|
4009
|
+
}));
|
3990
4010
|
}
|
3991
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
3992
|
-
const usedFee = calculatePriceWithFactor(
|
3993
|
-
gasUsed,
|
3994
|
-
gasPrice,
|
3995
|
-
gasPriceFactor
|
3996
|
-
).normalizeZeroToOne();
|
3997
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3998
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3999
4011
|
return {
|
4000
4012
|
requiredQuantities: allQuantities,
|
4001
4013
|
receipts,
|
4002
4014
|
gasUsed,
|
4003
4015
|
minGasPrice,
|
4004
|
-
gasPrice,
|
4016
|
+
gasPrice: setGasPrice,
|
4005
4017
|
minGas,
|
4006
4018
|
maxGas,
|
4007
|
-
usedFee,
|
4008
4019
|
minFee,
|
4009
4020
|
maxFee,
|
4010
4021
|
estimatedInputs: txRequestClone.inputs,
|
@@ -4629,9 +4640,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4629
4640
|
* @param assetId - The asset ID to check the balance for.
|
4630
4641
|
* @returns A promise that resolves to the balance amount.
|
4631
4642
|
*/
|
4632
|
-
async getBalance(assetId) {
|
4633
|
-
const
|
4634
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
4643
|
+
async getBalance(assetId = import_configs12.BaseAssetId) {
|
4644
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
4635
4645
|
return amount;
|
4636
4646
|
}
|
4637
4647
|
/**
|
@@ -4669,10 +4679,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4669
4679
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4670
4680
|
*/
|
4671
4681
|
async fund(request, coinQuantities, fee) {
|
4672
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
4673
4682
|
const updatedQuantities = addAmountToAsset({
|
4674
4683
|
amount: (0, import_math18.bn)(fee),
|
4675
|
-
assetId:
|
4684
|
+
assetId: import_configs12.BaseAssetId,
|
4676
4685
|
coinQuantities
|
4677
4686
|
});
|
4678
4687
|
const quantitiesDict = {};
|
@@ -4696,8 +4705,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4696
4705
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4697
4706
|
cachedUtxos.push(input.id);
|
4698
4707
|
}
|
4699
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
4700
|
-
quantitiesDict[
|
4708
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
|
4709
|
+
quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
|
4701
4710
|
cachedMessages.push(input.nonce);
|
4702
4711
|
}
|
4703
4712
|
}
|
@@ -4729,12 +4738,11 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4729
4738
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4730
4739
|
* @returns A promise that resolves to the prepared transaction request.
|
4731
4740
|
*/
|
4732
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
4741
|
+
async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4733
4742
|
const { minGasPrice } = this.provider.getGasConfig();
|
4734
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4735
4743
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4736
4744
|
const request = new ScriptTransactionRequest(params);
|
4737
|
-
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount,
|
4745
|
+
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
|
4738
4746
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4739
4747
|
estimateTxDependencies: true,
|
4740
4748
|
resourcesOwner: this
|
@@ -4760,15 +4768,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4760
4768
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4761
4769
|
* @returns A promise that resolves to the transaction response.
|
4762
4770
|
*/
|
4763
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
4771
|
+
async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4764
4772
|
if ((0, import_math18.bn)(amount).lte(0)) {
|
4765
4773
|
throw new import_errors16.FuelError(
|
4766
4774
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4767
4775
|
"Transfer amount must be a positive number."
|
4768
4776
|
);
|
4769
4777
|
}
|
4770
|
-
const
|
4771
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
4778
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
4772
4779
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
4773
4780
|
}
|
4774
4781
|
/**
|
@@ -4780,7 +4787,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4780
4787
|
* @param txParams - The optional transaction parameters.
|
4781
4788
|
* @returns A promise that resolves to the transaction response.
|
4782
4789
|
*/
|
4783
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
4790
|
+
async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4784
4791
|
if ((0, import_math18.bn)(amount).lte(0)) {
|
4785
4792
|
throw new import_errors16.FuelError(
|
4786
4793
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -4789,12 +4796,11 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4789
4796
|
}
|
4790
4797
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
4791
4798
|
const { minGasPrice } = this.provider.getGasConfig();
|
4792
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4793
4799
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4794
4800
|
const { script, scriptData } = await assembleTransferToContractScript({
|
4795
4801
|
hexlifiedContractId: contractAddress.toB256(),
|
4796
4802
|
amountToTransfer: (0, import_math18.bn)(amount),
|
4797
|
-
assetId
|
4803
|
+
assetId
|
4798
4804
|
});
|
4799
4805
|
const request = new ScriptTransactionRequest({
|
4800
4806
|
...params,
|
@@ -4804,7 +4810,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4804
4810
|
request.addContractInputAndOutput(contractAddress);
|
4805
4811
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
4806
4812
|
request,
|
4807
|
-
[{ amount: (0, import_math18.bn)(amount), assetId: String(
|
4813
|
+
[{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
|
4808
4814
|
);
|
4809
4815
|
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
4810
4816
|
this.validateGas({
|
@@ -4826,7 +4832,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4826
4832
|
*/
|
4827
4833
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4828
4834
|
const { minGasPrice } = this.provider.getGasConfig();
|
4829
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
4830
4835
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
4831
4836
|
const recipientDataArray = (0, import_utils28.arrayify)(
|
4832
4837
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -4841,7 +4846,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4841
4846
|
]);
|
4842
4847
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
4843
4848
|
const request = new ScriptTransactionRequest(params);
|
4844
|
-
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId:
|
4849
|
+
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
|
4845
4850
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
4846
4851
|
request,
|
4847
4852
|
forwardingQuantities
|
@@ -5249,14 +5254,14 @@ var import_errors20 = require("@fuel-ts/errors");
|
|
5249
5254
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5250
5255
|
var import_math20 = require("@fuel-ts/math");
|
5251
5256
|
var import_utils35 = require("@fuel-ts/utils");
|
5252
|
-
var
|
5257
|
+
var import_ethers4 = require("ethers");
|
5253
5258
|
|
5254
5259
|
// src/mnemonic/mnemonic.ts
|
5255
5260
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5256
5261
|
var import_errors19 = require("@fuel-ts/errors");
|
5257
5262
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5258
5263
|
var import_utils33 = require("@fuel-ts/utils");
|
5259
|
-
var
|
5264
|
+
var import_ethers3 = require("ethers");
|
5260
5265
|
|
5261
5266
|
// src/wordlists/words/english.ts
|
5262
5267
|
var english = [
|
@@ -7504,7 +7509,7 @@ var Mnemonic = class {
|
|
7504
7509
|
assertMnemonic(getWords(phrase));
|
7505
7510
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7506
7511
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7507
|
-
return (0,
|
7512
|
+
return (0, import_ethers3.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7508
7513
|
}
|
7509
7514
|
/**
|
7510
7515
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7566,7 +7571,7 @@ var Mnemonic = class {
|
|
7566
7571
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7567
7572
|
);
|
7568
7573
|
}
|
7569
|
-
return (0, import_utils33.arrayify)((0,
|
7574
|
+
return (0, import_utils33.arrayify)((0, import_ethers3.computeHmac)("sha512", MasterSecret, seedArray));
|
7570
7575
|
}
|
7571
7576
|
/**
|
7572
7577
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7591,8 +7596,8 @@ var Mnemonic = class {
|
|
7591
7596
|
chainCode,
|
7592
7597
|
(0, import_utils33.concat)(["0x00", privateKey])
|
7593
7598
|
]);
|
7594
|
-
const checksum = (0,
|
7595
|
-
return (0,
|
7599
|
+
const checksum = (0, import_ethers3.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7600
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7596
7601
|
}
|
7597
7602
|
/**
|
7598
7603
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7620,7 +7625,7 @@ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
|
7620
7625
|
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
7621
7626
|
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
7622
7627
|
function base58check(data) {
|
7623
|
-
return (0,
|
7628
|
+
return (0, import_ethers4.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers4.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7624
7629
|
}
|
7625
7630
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7626
7631
|
if (isPublic) {
|
@@ -7676,7 +7681,7 @@ var HDWallet = class {
|
|
7676
7681
|
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
7677
7682
|
}
|
7678
7683
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7679
|
-
this.fingerprint = (0,
|
7684
|
+
this.fingerprint = (0, import_ethers4.dataSlice)((0, import_ethers4.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
7680
7685
|
this.depth = config.depth || this.depth;
|
7681
7686
|
this.index = config.index || this.index;
|
7682
7687
|
this.chainCode = config.chainCode;
|
@@ -7708,7 +7713,7 @@ var HDWallet = class {
|
|
7708
7713
|
data.set((0, import_utils35.arrayify)(this.publicKey));
|
7709
7714
|
}
|
7710
7715
|
data.set((0, import_math20.toBytes)(index, 4), 33);
|
7711
|
-
const bytes = (0, import_utils35.arrayify)((0,
|
7716
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers4.computeHmac)("sha512", chainCode, data));
|
7712
7717
|
const IL = bytes.slice(0, 32);
|
7713
7718
|
const IR = bytes.slice(32);
|
7714
7719
|
if (privateKey) {
|
@@ -7779,7 +7784,7 @@ var HDWallet = class {
|
|
7779
7784
|
});
|
7780
7785
|
}
|
7781
7786
|
static fromExtendedKey(extendedKey) {
|
7782
|
-
const decoded = (0,
|
7787
|
+
const decoded = (0, import_ethers4.toBeHex)((0, import_ethers4.decodeBase58)(extendedKey));
|
7783
7788
|
const bytes = (0, import_utils35.arrayify)(decoded);
|
7784
7789
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7785
7790
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -8005,7 +8010,7 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8005
8010
|
};
|
8006
8011
|
|
8007
8012
|
// src/test-utils/launchNode.ts
|
8008
|
-
var
|
8013
|
+
var import_configs13 = require("@fuel-ts/address/configs");
|
8009
8014
|
var import_math21 = require("@fuel-ts/math");
|
8010
8015
|
var import_utils36 = require("@fuel-ts/utils");
|
8011
8016
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
@@ -8105,7 +8110,7 @@ var launchNode = async ({
|
|
8105
8110
|
{
|
8106
8111
|
owner: signer.address.toHexString(),
|
8107
8112
|
amount: (0, import_math21.toHex)(1e9),
|
8108
|
-
asset_id:
|
8113
|
+
asset_id: import_configs13.BaseAssetId
|
8109
8114
|
}
|
8110
8115
|
]
|
8111
8116
|
}
|
@@ -8171,10 +8176,9 @@ var launchNode = async ({
|
|
8171
8176
|
})
|
8172
8177
|
);
|
8173
8178
|
var generateWallets = async (count, provider) => {
|
8174
|
-
const baseAssetId = provider.getBaseAssetId();
|
8175
8179
|
const wallets = [];
|
8176
8180
|
for (let i = 0; i < count; i += 1) {
|
8177
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
8181
|
+
const wallet = await generateTestWallet(provider, [[1e3, import_configs13.BaseAssetId]]);
|
8178
8182
|
wallets.push(wallet);
|
8179
8183
|
}
|
8180
8184
|
return wallets;
|