@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/index.js
CHANGED
@@ -184,12 +184,14 @@ module.exports = __toCommonJS(src_exports);
|
|
184
184
|
|
185
185
|
// src/account.ts
|
186
186
|
var import_address4 = require("@fuel-ts/address");
|
187
|
+
var import_configs12 = require("@fuel-ts/address/configs");
|
187
188
|
var import_errors16 = require("@fuel-ts/errors");
|
188
189
|
var import_interfaces = require("@fuel-ts/interfaces");
|
189
190
|
var import_math18 = require("@fuel-ts/math");
|
190
191
|
var import_utils28 = require("@fuel-ts/utils");
|
191
192
|
|
192
193
|
// src/providers/coin-quantity.ts
|
194
|
+
var import_configs = require("@fuel-ts/address/configs");
|
193
195
|
var import_math = require("@fuel-ts/math");
|
194
196
|
var import_utils = require("@fuel-ts/utils");
|
195
197
|
var coinQuantityfy = (coinQuantityLike) => {
|
@@ -198,11 +200,11 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
198
200
|
let max2;
|
199
201
|
if (Array.isArray(coinQuantityLike)) {
|
200
202
|
amount = coinQuantityLike[0];
|
201
|
-
assetId = coinQuantityLike[1];
|
202
|
-
max2 = coinQuantityLike[2];
|
203
|
+
assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
|
204
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
203
205
|
} else {
|
204
206
|
amount = coinQuantityLike.amount;
|
205
|
-
assetId = coinQuantityLike.assetId;
|
207
|
+
assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
|
206
208
|
max2 = coinQuantityLike.max ?? void 0;
|
207
209
|
}
|
208
210
|
const bnAmount = (0, import_math.bn)(amount);
|
@@ -232,7 +234,7 @@ var import_transactions18 = require("@fuel-ts/transactions");
|
|
232
234
|
var import_utils23 = require("@fuel-ts/utils");
|
233
235
|
var import_versions = require("@fuel-ts/versions");
|
234
236
|
var import_utils24 = require("@noble/curves/abstract/utils");
|
235
|
-
var
|
237
|
+
var import_ethers2 = require("ethers");
|
236
238
|
var import_graphql_request = require("graphql-request");
|
237
239
|
var import_ramda3 = require("ramda");
|
238
240
|
|
@@ -1171,7 +1173,7 @@ var MemoryCache = class {
|
|
1171
1173
|
};
|
1172
1174
|
|
1173
1175
|
// src/providers/transaction-request/input.ts
|
1174
|
-
var
|
1176
|
+
var import_configs2 = require("@fuel-ts/address/configs");
|
1175
1177
|
var import_errors3 = require("@fuel-ts/errors");
|
1176
1178
|
var import_math2 = require("@fuel-ts/math");
|
1177
1179
|
var import_transactions = require("@fuel-ts/transactions");
|
@@ -1185,7 +1187,7 @@ var inputify = (value) => {
|
|
1185
1187
|
return {
|
1186
1188
|
type: import_transactions.InputType.Coin,
|
1187
1189
|
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
|
1188
|
-
outputIndex: (0, import_utils3.arrayify)(value.id)
|
1190
|
+
outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 33)),
|
1189
1191
|
owner: (0, import_utils3.hexlify)(value.owner),
|
1190
1192
|
amount: (0, import_math2.bn)(value.amount),
|
1191
1193
|
assetId: (0, import_utils3.hexlify)(value.assetId),
|
@@ -1205,10 +1207,10 @@ var inputify = (value) => {
|
|
1205
1207
|
case import_transactions.InputType.Contract: {
|
1206
1208
|
return {
|
1207
1209
|
type: import_transactions.InputType.Contract,
|
1208
|
-
txID:
|
1210
|
+
txID: import_configs2.ZeroBytes32,
|
1209
1211
|
outputIndex: 0,
|
1210
|
-
balanceRoot:
|
1211
|
-
stateRoot:
|
1212
|
+
balanceRoot: import_configs2.ZeroBytes32,
|
1213
|
+
stateRoot: import_configs2.ZeroBytes32,
|
1212
1214
|
txPointer: {
|
1213
1215
|
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1214
1216
|
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
@@ -1246,7 +1248,7 @@ var inputify = (value) => {
|
|
1246
1248
|
};
|
1247
1249
|
|
1248
1250
|
// src/providers/transaction-request/output.ts
|
1249
|
-
var
|
1251
|
+
var import_configs3 = require("@fuel-ts/address/configs");
|
1250
1252
|
var import_errors4 = require("@fuel-ts/errors");
|
1251
1253
|
var import_math3 = require("@fuel-ts/math");
|
1252
1254
|
var import_transactions2 = require("@fuel-ts/transactions");
|
@@ -1266,8 +1268,8 @@ var outputify = (value) => {
|
|
1266
1268
|
return {
|
1267
1269
|
type: import_transactions2.OutputType.Contract,
|
1268
1270
|
inputIndex: value.inputIndex,
|
1269
|
-
balanceRoot:
|
1270
|
-
stateRoot:
|
1271
|
+
balanceRoot: import_configs3.ZeroBytes32,
|
1272
|
+
stateRoot: import_configs3.ZeroBytes32
|
1271
1273
|
};
|
1272
1274
|
}
|
1273
1275
|
case import_transactions2.OutputType.Change: {
|
@@ -1281,9 +1283,9 @@ var outputify = (value) => {
|
|
1281
1283
|
case import_transactions2.OutputType.Variable: {
|
1282
1284
|
return {
|
1283
1285
|
type: import_transactions2.OutputType.Variable,
|
1284
|
-
to:
|
1286
|
+
to: import_configs3.ZeroBytes32,
|
1285
1287
|
amount: (0, import_math3.bn)(0),
|
1286
|
-
assetId:
|
1288
|
+
assetId: import_configs3.ZeroBytes32
|
1287
1289
|
};
|
1288
1290
|
}
|
1289
1291
|
case import_transactions2.OutputType.ContractCreated: {
|
@@ -1304,10 +1306,11 @@ var outputify = (value) => {
|
|
1304
1306
|
|
1305
1307
|
// src/providers/transaction-request/transaction-request.ts
|
1306
1308
|
var import_address = require("@fuel-ts/address");
|
1307
|
-
var
|
1309
|
+
var import_configs7 = require("@fuel-ts/address/configs");
|
1308
1310
|
var import_math7 = require("@fuel-ts/math");
|
1309
1311
|
var import_transactions6 = require("@fuel-ts/transactions");
|
1310
1312
|
var import_utils9 = require("@fuel-ts/utils");
|
1313
|
+
var import_ethers = require("ethers");
|
1311
1314
|
|
1312
1315
|
// src/providers/resource.ts
|
1313
1316
|
var isRawCoin = (resource) => "utxoId" in resource;
|
@@ -1316,13 +1319,13 @@ var isCoin = (resource) => "id" in resource;
|
|
1316
1319
|
var isMessage = (resource) => "recipient" in resource;
|
1317
1320
|
|
1318
1321
|
// src/providers/utils/receipts.ts
|
1319
|
-
var
|
1322
|
+
var import_configs4 = require("@fuel-ts/address/configs");
|
1320
1323
|
var import_errors5 = require("@fuel-ts/errors");
|
1321
1324
|
var import_math4 = require("@fuel-ts/math");
|
1322
1325
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1323
|
-
var
|
1326
|
+
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1324
1327
|
var import_utils5 = require("@fuel-ts/utils");
|
1325
|
-
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") ===
|
1328
|
+
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1326
1329
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1327
1330
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
1328
1331
|
(memo, receipt) => {
|
@@ -1339,7 +1342,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
|
1339
1342
|
missingOutputContractIds: []
|
1340
1343
|
}
|
1341
1344
|
);
|
1342
|
-
var hexOrZero = (hex) => hex ||
|
1345
|
+
var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
|
1343
1346
|
function assembleReceiptByType(receipt) {
|
1344
1347
|
const { receiptType } = receipt;
|
1345
1348
|
switch (receiptType) {
|
@@ -1703,16 +1706,16 @@ function sleep(time) {
|
|
1703
1706
|
var import_errors7 = require("@fuel-ts/errors");
|
1704
1707
|
var import_math6 = require("@fuel-ts/math");
|
1705
1708
|
var import_transactions5 = require("@fuel-ts/transactions");
|
1706
|
-
var
|
1709
|
+
var import_configs6 = require("@fuel-ts/transactions/configs");
|
1707
1710
|
var assemblePanicError = (status) => {
|
1708
1711
|
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
1709
1712
|
const reason = status.reason;
|
1710
|
-
if (
|
1713
|
+
if (import_configs6.PANIC_REASONS.includes(status.reason)) {
|
1711
1714
|
errorMessage = `${errorMessage}
|
1712
1715
|
|
1713
1716
|
You can read more about this error at:
|
1714
1717
|
|
1715
|
-
${
|
1718
|
+
${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
|
1716
1719
|
}
|
1717
1720
|
return { errorMessage, reason };
|
1718
1721
|
};
|
@@ -1724,28 +1727,28 @@ var assembleRevertError = (receipts, logs) => {
|
|
1724
1727
|
if (revertReceipt) {
|
1725
1728
|
const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
|
1726
1729
|
switch (reasonHex) {
|
1727
|
-
case
|
1730
|
+
case import_configs6.FAILED_REQUIRE_SIGNAL: {
|
1728
1731
|
reason = "require";
|
1729
1732
|
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
|
1730
1733
|
break;
|
1731
1734
|
}
|
1732
|
-
case
|
1735
|
+
case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
|
1733
1736
|
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1734
1737
|
reason = "assert_eq";
|
1735
1738
|
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
1736
1739
|
break;
|
1737
1740
|
}
|
1738
|
-
case
|
1741
|
+
case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
|
1739
1742
|
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1740
1743
|
reason = "assert_ne";
|
1741
1744
|
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
1742
1745
|
break;
|
1743
1746
|
}
|
1744
|
-
case
|
1747
|
+
case import_configs6.FAILED_ASSERT_SIGNAL:
|
1745
1748
|
reason = "assert";
|
1746
1749
|
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
1747
1750
|
break;
|
1748
|
-
case
|
1751
|
+
case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
1749
1752
|
reason = "MissingOutputChange";
|
1750
1753
|
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1751
1754
|
break;
|
@@ -1819,8 +1822,6 @@ var BaseTransactionRequest = class {
|
|
1819
1822
|
outputs = [];
|
1820
1823
|
/** List of witnesses */
|
1821
1824
|
witnesses = [];
|
1822
|
-
/** Base asset ID - should be fetched from the chain */
|
1823
|
-
baseAssetId = import_configs6.ZeroBytes32;
|
1824
1825
|
/**
|
1825
1826
|
* Constructor for initializing a base transaction request.
|
1826
1827
|
*
|
@@ -1833,8 +1834,7 @@ var BaseTransactionRequest = class {
|
|
1833
1834
|
witnessLimit,
|
1834
1835
|
inputs,
|
1835
1836
|
outputs,
|
1836
|
-
witnesses
|
1837
|
-
baseAssetId
|
1837
|
+
witnesses
|
1838
1838
|
} = {}) {
|
1839
1839
|
this.gasPrice = (0, import_math7.bn)(gasPrice);
|
1840
1840
|
this.maturity = maturity ?? 0;
|
@@ -1843,7 +1843,6 @@ var BaseTransactionRequest = class {
|
|
1843
1843
|
this.inputs = inputs ?? [];
|
1844
1844
|
this.outputs = outputs ?? [];
|
1845
1845
|
this.witnesses = witnesses ?? [];
|
1846
|
-
this.baseAssetId = baseAssetId ?? import_configs6.ZeroBytes32;
|
1847
1846
|
}
|
1848
1847
|
static getPolicyMeta(req) {
|
1849
1848
|
let policyTypes = 0;
|
@@ -1936,7 +1935,7 @@ var BaseTransactionRequest = class {
|
|
1936
1935
|
* @returns The index of the created witness.
|
1937
1936
|
*/
|
1938
1937
|
addEmptyWitness() {
|
1939
|
-
this.addWitness((0, import_utils9.concat)([
|
1938
|
+
this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
|
1940
1939
|
return this.witnesses.length - 1;
|
1941
1940
|
}
|
1942
1941
|
/**
|
@@ -2068,9 +2067,11 @@ var BaseTransactionRequest = class {
|
|
2068
2067
|
*
|
2069
2068
|
* @param message - Message resource.
|
2070
2069
|
* @param predicate - Predicate bytes.
|
2070
|
+
* @param predicateData - Predicate data bytes.
|
2071
2071
|
*/
|
2072
2072
|
addMessageInput(message, predicate) {
|
2073
2073
|
const { recipient, sender, amount } = message;
|
2074
|
+
const assetId = import_configs7.BaseAssetId;
|
2074
2075
|
let witnessIndex;
|
2075
2076
|
if (predicate) {
|
2076
2077
|
witnessIndex = 0;
|
@@ -2091,7 +2092,7 @@ var BaseTransactionRequest = class {
|
|
2091
2092
|
predicateData: predicate?.predicateDataBytes
|
2092
2093
|
};
|
2093
2094
|
this.pushInput(input);
|
2094
|
-
this.addChangeOutput(recipient,
|
2095
|
+
this.addChangeOutput(recipient, assetId);
|
2095
2096
|
}
|
2096
2097
|
/**
|
2097
2098
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -2152,12 +2153,12 @@ var BaseTransactionRequest = class {
|
|
2152
2153
|
* @param amount - Amount of coin.
|
2153
2154
|
* @param assetId - Asset ID of coin.
|
2154
2155
|
*/
|
2155
|
-
addCoinOutput(to, amount, assetId) {
|
2156
|
+
addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
|
2156
2157
|
this.pushOutput({
|
2157
2158
|
type: import_transactions6.OutputType.Coin,
|
2158
2159
|
to: (0, import_address.addressify)(to).toB256(),
|
2159
2160
|
amount,
|
2160
|
-
assetId
|
2161
|
+
assetId
|
2161
2162
|
});
|
2162
2163
|
return this;
|
2163
2164
|
}
|
@@ -2184,7 +2185,7 @@ var BaseTransactionRequest = class {
|
|
2184
2185
|
* @param to - Address of the owner.
|
2185
2186
|
* @param assetId - Asset ID of coin.
|
2186
2187
|
*/
|
2187
|
-
addChangeOutput(to, assetId) {
|
2188
|
+
addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
|
2188
2189
|
const changeOutput = this.getChangeOutputs().find(
|
2189
2190
|
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
2190
2191
|
);
|
@@ -2192,7 +2193,7 @@ var BaseTransactionRequest = class {
|
|
2192
2193
|
this.pushOutput({
|
2193
2194
|
type: import_transactions6.OutputType.Change,
|
2194
2195
|
to: (0, import_address.addressify)(to).toB256(),
|
2195
|
-
assetId
|
2196
|
+
assetId
|
2196
2197
|
});
|
2197
2198
|
}
|
2198
2199
|
}
|
@@ -2243,12 +2244,6 @@ var BaseTransactionRequest = class {
|
|
2243
2244
|
* @param quantities - CoinQuantity Array.
|
2244
2245
|
*/
|
2245
2246
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
2246
|
-
let idCounter = 0;
|
2247
|
-
const generateId = () => {
|
2248
|
-
const counterString = String(idCounter++);
|
2249
|
-
const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
2250
|
-
return id;
|
2251
|
-
};
|
2252
2247
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
2253
2248
|
if ("assetId" in input) {
|
2254
2249
|
return input.assetId === assetId;
|
@@ -2258,12 +2253,12 @@ var BaseTransactionRequest = class {
|
|
2258
2253
|
const updateAssetInput = (assetId, quantity) => {
|
2259
2254
|
const assetInput = findAssetInput(assetId);
|
2260
2255
|
if (assetInput && "assetId" in assetInput) {
|
2261
|
-
assetInput.id =
|
2256
|
+
assetInput.id = (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(33));
|
2262
2257
|
assetInput.amount = quantity;
|
2263
2258
|
} else {
|
2264
2259
|
this.addResources([
|
2265
2260
|
{
|
2266
|
-
id:
|
2261
|
+
id: (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(33)),
|
2267
2262
|
amount: quantity,
|
2268
2263
|
assetId,
|
2269
2264
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
@@ -2274,7 +2269,7 @@ var BaseTransactionRequest = class {
|
|
2274
2269
|
]);
|
2275
2270
|
}
|
2276
2271
|
};
|
2277
|
-
updateAssetInput(
|
2272
|
+
updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
|
2278
2273
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2279
2274
|
}
|
2280
2275
|
/**
|
@@ -2324,13 +2319,13 @@ var BaseTransactionRequest = class {
|
|
2324
2319
|
};
|
2325
2320
|
|
2326
2321
|
// src/providers/transaction-request/create-transaction-request.ts
|
2327
|
-
var
|
2322
|
+
var import_configs9 = require("@fuel-ts/address/configs");
|
2328
2323
|
var import_math9 = require("@fuel-ts/math");
|
2329
2324
|
var import_transactions8 = require("@fuel-ts/transactions");
|
2330
2325
|
var import_utils13 = require("@fuel-ts/utils");
|
2331
2326
|
|
2332
2327
|
// src/providers/transaction-request/hash-transaction.ts
|
2333
|
-
var
|
2328
|
+
var import_configs8 = require("@fuel-ts/address/configs");
|
2334
2329
|
var import_hasher = require("@fuel-ts/hasher");
|
2335
2330
|
var import_math8 = require("@fuel-ts/math");
|
2336
2331
|
var import_transactions7 = require("@fuel-ts/transactions");
|
@@ -2339,7 +2334,7 @@ var import_ramda2 = require("ramda");
|
|
2339
2334
|
function hashTransaction(transactionRequest, chainId) {
|
2340
2335
|
const transaction = transactionRequest.toTransaction();
|
2341
2336
|
if (transaction.type === import_transactions7.TransactionType.Script) {
|
2342
|
-
transaction.receiptsRoot =
|
2337
|
+
transaction.receiptsRoot = import_configs8.ZeroBytes32;
|
2343
2338
|
}
|
2344
2339
|
transaction.inputs = transaction.inputs.map((input) => {
|
2345
2340
|
const inputClone = (0, import_ramda2.clone)(input);
|
@@ -2361,10 +2356,10 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2361
2356
|
blockHeight: 0,
|
2362
2357
|
txIndex: 0
|
2363
2358
|
};
|
2364
|
-
inputClone.txID =
|
2359
|
+
inputClone.txID = import_configs8.ZeroBytes32;
|
2365
2360
|
inputClone.outputIndex = 0;
|
2366
|
-
inputClone.balanceRoot =
|
2367
|
-
inputClone.stateRoot =
|
2361
|
+
inputClone.balanceRoot = import_configs8.ZeroBytes32;
|
2362
|
+
inputClone.stateRoot = import_configs8.ZeroBytes32;
|
2368
2363
|
return inputClone;
|
2369
2364
|
}
|
2370
2365
|
default:
|
@@ -2375,8 +2370,8 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2375
2370
|
const outputClone = (0, import_ramda2.clone)(output);
|
2376
2371
|
switch (outputClone.type) {
|
2377
2372
|
case import_transactions7.OutputType.Contract: {
|
2378
|
-
outputClone.balanceRoot =
|
2379
|
-
outputClone.stateRoot =
|
2373
|
+
outputClone.balanceRoot = import_configs8.ZeroBytes32;
|
2374
|
+
outputClone.stateRoot = import_configs8.ZeroBytes32;
|
2380
2375
|
return outputClone;
|
2381
2376
|
}
|
2382
2377
|
case import_transactions7.OutputType.Change: {
|
@@ -2384,9 +2379,9 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2384
2379
|
return outputClone;
|
2385
2380
|
}
|
2386
2381
|
case import_transactions7.OutputType.Variable: {
|
2387
|
-
outputClone.to =
|
2382
|
+
outputClone.to = import_configs8.ZeroBytes32;
|
2388
2383
|
outputClone.amount = (0, import_math8.bn)(0);
|
2389
|
-
outputClone.assetId =
|
2384
|
+
outputClone.assetId = import_configs8.ZeroBytes32;
|
2390
2385
|
return outputClone;
|
2391
2386
|
}
|
2392
2387
|
default:
|
@@ -2452,7 +2447,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2452
2447
|
} = {}) {
|
2453
2448
|
super(rest);
|
2454
2449
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2455
|
-
this.salt = (0, import_utils13.hexlify)(salt ??
|
2450
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
|
2456
2451
|
this.storageSlots = [...storageSlots ?? []];
|
2457
2452
|
}
|
2458
2453
|
/**
|
@@ -2470,7 +2465,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2470
2465
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2471
2466
|
bytecodeWitnessIndex,
|
2472
2467
|
storageSlotsCount: storageSlots.length,
|
2473
|
-
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) :
|
2468
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
|
2474
2469
|
storageSlots
|
2475
2470
|
};
|
2476
2471
|
}
|
@@ -2520,7 +2515,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2520
2515
|
// src/providers/transaction-request/script-transaction-request.ts
|
2521
2516
|
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2522
2517
|
var import_address2 = require("@fuel-ts/address");
|
2523
|
-
var
|
2518
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
2524
2519
|
var import_math10 = require("@fuel-ts/math");
|
2525
2520
|
var import_transactions9 = require("@fuel-ts/transactions");
|
2526
2521
|
var import_utils15 = require("@fuel-ts/utils");
|
@@ -2594,7 +2589,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2594
2589
|
...super.getBaseTransaction(),
|
2595
2590
|
scriptLength: script.length,
|
2596
2591
|
scriptDataLength: scriptData.length,
|
2597
|
-
receiptsRoot:
|
2592
|
+
receiptsRoot: import_configs10.ZeroBytes32,
|
2598
2593
|
script: (0, import_utils15.hexlify)(script),
|
2599
2594
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2600
2595
|
};
|
@@ -2826,7 +2821,7 @@ var calculateTransactionFee = (params) => {
|
|
2826
2821
|
};
|
2827
2822
|
|
2828
2823
|
// src/providers/transaction-summary/operations.ts
|
2829
|
-
var
|
2824
|
+
var import_configs11 = require("@fuel-ts/address/configs");
|
2830
2825
|
var import_errors11 = require("@fuel-ts/errors");
|
2831
2826
|
var import_math13 = require("@fuel-ts/math");
|
2832
2827
|
var import_transactions14 = require("@fuel-ts/transactions");
|
@@ -3171,7 +3166,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3171
3166
|
const { to: toAddress, assetId, amount } = receipt;
|
3172
3167
|
let { from: fromAddress } = receipt;
|
3173
3168
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3174
|
-
if (
|
3169
|
+
if (import_configs11.ZeroBytes32 === fromAddress) {
|
3175
3170
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
3176
3171
|
fromAddress = change?.to || fromAddress;
|
3177
3172
|
}
|
@@ -3748,7 +3743,6 @@ var processGqlChain = (chain) => {
|
|
3748
3743
|
gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
|
3749
3744
|
maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
|
3750
3745
|
chainId: (0, import_math15.bn)(consensusParameters.chainId),
|
3751
|
-
baseAssetId: consensusParameters.baseAssetId,
|
3752
3746
|
gasCosts
|
3753
3747
|
},
|
3754
3748
|
gasCosts,
|
@@ -3939,7 +3933,7 @@ var _Provider = class {
|
|
3939
3933
|
name,
|
3940
3934
|
consensusParameters: { chainId }
|
3941
3935
|
} = await this.getChain();
|
3942
|
-
const network = new
|
3936
|
+
const network = new import_ethers2.Network(name, chainId.toNumber());
|
3943
3937
|
return Promise.resolve(network);
|
3944
3938
|
}
|
3945
3939
|
/**
|
@@ -3991,17 +3985,6 @@ var _Provider = class {
|
|
3991
3985
|
} = this.getChain();
|
3992
3986
|
return chainId.toNumber();
|
3993
3987
|
}
|
3994
|
-
/**
|
3995
|
-
* Returns the base asset ID
|
3996
|
-
*
|
3997
|
-
* @returns A promise that resolves to the base asset ID
|
3998
|
-
*/
|
3999
|
-
getBaseAssetId() {
|
4000
|
-
const {
|
4001
|
-
consensusParameters: { baseAssetId }
|
4002
|
-
} = this.getChain();
|
4003
|
-
return baseAssetId;
|
4004
|
-
}
|
4005
3988
|
/**
|
4006
3989
|
* Submits a transaction to the chain to be executed.
|
4007
3990
|
*
|
@@ -4152,6 +4135,37 @@ var _Provider = class {
|
|
4152
4135
|
missingContractIds
|
4153
4136
|
};
|
4154
4137
|
}
|
4138
|
+
/**
|
4139
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
4140
|
+
* @param transactionRequest - The transaction request object.
|
4141
|
+
* @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
|
4142
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4143
|
+
*/
|
4144
|
+
estimateTxGasAndFee(params) {
|
4145
|
+
const { transactionRequest } = params;
|
4146
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4147
|
+
const chainInfo = this.getChain();
|
4148
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
4149
|
+
transactionRequest.gasPrice = gasPrice;
|
4150
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4151
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4152
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Script) {
|
4153
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
4154
|
+
transactionRequest.gasLimit = minGas;
|
4155
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
4156
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
4157
|
+
);
|
4158
|
+
}
|
4159
|
+
}
|
4160
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4161
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4162
|
+
return {
|
4163
|
+
minGas,
|
4164
|
+
minFee,
|
4165
|
+
maxGas,
|
4166
|
+
maxFee
|
4167
|
+
};
|
4168
|
+
}
|
4155
4169
|
/**
|
4156
4170
|
* Executes a signed transaction without applying the states changes
|
4157
4171
|
* on the chain.
|
@@ -4199,17 +4213,16 @@ var _Provider = class {
|
|
4199
4213
|
signatureCallback
|
4200
4214
|
} = {}) {
|
4201
4215
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4202
|
-
const
|
4203
|
-
const
|
4204
|
-
const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
4216
|
+
const { minGasPrice } = this.getGasConfig();
|
4217
|
+
const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
4205
4218
|
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
4206
4219
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4207
4220
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4208
4221
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4222
|
+
if (isScriptTransaction) {
|
4223
|
+
txRequestClone.gasLimit = (0, import_math15.bn)(0);
|
4224
|
+
}
|
4209
4225
|
if (estimatePredicates) {
|
4210
|
-
if (isScriptTransaction) {
|
4211
|
-
txRequestClone.gasLimit = (0, import_math15.bn)(0);
|
4212
|
-
}
|
4213
4226
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4214
4227
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4215
4228
|
}
|
@@ -4218,36 +4231,34 @@ var _Provider = class {
|
|
4218
4231
|
if (signatureCallback && isScriptTransaction) {
|
4219
4232
|
await signatureCallback(txRequestClone);
|
4220
4233
|
}
|
4221
|
-
|
4222
|
-
|
4234
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4235
|
+
transactionRequest: txRequestClone
|
4236
|
+
});
|
4223
4237
|
let receipts = [];
|
4224
4238
|
let missingContractIds = [];
|
4225
4239
|
let outputVariables = 0;
|
4240
|
+
let gasUsed = (0, import_math15.bn)(0);
|
4226
4241
|
if (isScriptTransaction && estimateTxDependencies) {
|
4227
4242
|
txRequestClone.gasPrice = (0, import_math15.bn)(0);
|
4228
|
-
txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
4229
4243
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4230
4244
|
receipts = result.receipts;
|
4231
4245
|
outputVariables = result.outputVariables;
|
4232
4246
|
missingContractIds = result.missingContractIds;
|
4247
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4248
|
+
txRequestClone.gasLimit = gasUsed;
|
4249
|
+
txRequestClone.gasPrice = setGasPrice;
|
4250
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4251
|
+
transactionRequest: txRequestClone
|
4252
|
+
}));
|
4233
4253
|
}
|
4234
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
4235
|
-
const usedFee = calculatePriceWithFactor(
|
4236
|
-
gasUsed,
|
4237
|
-
gasPrice,
|
4238
|
-
gasPriceFactor
|
4239
|
-
).normalizeZeroToOne();
|
4240
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4241
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4242
4254
|
return {
|
4243
4255
|
requiredQuantities: allQuantities,
|
4244
4256
|
receipts,
|
4245
4257
|
gasUsed,
|
4246
4258
|
minGasPrice,
|
4247
|
-
gasPrice,
|
4259
|
+
gasPrice: setGasPrice,
|
4248
4260
|
minGas,
|
4249
4261
|
maxGas,
|
4250
|
-
usedFee,
|
4251
4262
|
minFee,
|
4252
4263
|
maxFee,
|
4253
4264
|
estimatedInputs: txRequestClone.inputs,
|
@@ -5038,9 +5049,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5038
5049
|
* @param assetId - The asset ID to check the balance for.
|
5039
5050
|
* @returns A promise that resolves to the balance amount.
|
5040
5051
|
*/
|
5041
|
-
async getBalance(assetId) {
|
5042
|
-
const
|
5043
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
5052
|
+
async getBalance(assetId = import_configs12.BaseAssetId) {
|
5053
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
5044
5054
|
return amount;
|
5045
5055
|
}
|
5046
5056
|
/**
|
@@ -5078,10 +5088,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5078
5088
|
* @returns A promise that resolves when the resources are added to the transaction.
|
5079
5089
|
*/
|
5080
5090
|
async fund(request, coinQuantities, fee) {
|
5081
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
5082
5091
|
const updatedQuantities = addAmountToAsset({
|
5083
5092
|
amount: (0, import_math18.bn)(fee),
|
5084
|
-
assetId:
|
5093
|
+
assetId: import_configs12.BaseAssetId,
|
5085
5094
|
coinQuantities
|
5086
5095
|
});
|
5087
5096
|
const quantitiesDict = {};
|
@@ -5105,8 +5114,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5105
5114
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
5106
5115
|
cachedUtxos.push(input.id);
|
5107
5116
|
}
|
5108
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
5109
|
-
quantitiesDict[
|
5117
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
|
5118
|
+
quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
|
5110
5119
|
cachedMessages.push(input.nonce);
|
5111
5120
|
}
|
5112
5121
|
}
|
@@ -5138,12 +5147,11 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5138
5147
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5139
5148
|
* @returns A promise that resolves to the prepared transaction request.
|
5140
5149
|
*/
|
5141
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5150
|
+
async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
5142
5151
|
const { minGasPrice } = this.provider.getGasConfig();
|
5143
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5144
5152
|
const params = { gasPrice: minGasPrice, ...txParams };
|
5145
5153
|
const request = new ScriptTransactionRequest(params);
|
5146
|
-
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount,
|
5154
|
+
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
|
5147
5155
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
5148
5156
|
estimateTxDependencies: true,
|
5149
5157
|
resourcesOwner: this
|
@@ -5169,15 +5177,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5169
5177
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5170
5178
|
* @returns A promise that resolves to the transaction response.
|
5171
5179
|
*/
|
5172
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
5180
|
+
async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
5173
5181
|
if ((0, import_math18.bn)(amount).lte(0)) {
|
5174
5182
|
throw new import_errors16.FuelError(
|
5175
5183
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5176
5184
|
"Transfer amount must be a positive number."
|
5177
5185
|
);
|
5178
5186
|
}
|
5179
|
-
const
|
5180
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
5187
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
5181
5188
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
5182
5189
|
}
|
5183
5190
|
/**
|
@@ -5189,7 +5196,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5189
5196
|
* @param txParams - The optional transaction parameters.
|
5190
5197
|
* @returns A promise that resolves to the transaction response.
|
5191
5198
|
*/
|
5192
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5199
|
+
async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
5193
5200
|
if ((0, import_math18.bn)(amount).lte(0)) {
|
5194
5201
|
throw new import_errors16.FuelError(
|
5195
5202
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -5198,12 +5205,11 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5198
5205
|
}
|
5199
5206
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
5200
5207
|
const { minGasPrice } = this.provider.getGasConfig();
|
5201
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5202
5208
|
const params = { gasPrice: minGasPrice, ...txParams };
|
5203
5209
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5204
5210
|
hexlifiedContractId: contractAddress.toB256(),
|
5205
5211
|
amountToTransfer: (0, import_math18.bn)(amount),
|
5206
|
-
assetId
|
5212
|
+
assetId
|
5207
5213
|
});
|
5208
5214
|
const request = new ScriptTransactionRequest({
|
5209
5215
|
...params,
|
@@ -5213,7 +5219,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5213
5219
|
request.addContractInputAndOutput(contractAddress);
|
5214
5220
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
5215
5221
|
request,
|
5216
|
-
[{ amount: (0, import_math18.bn)(amount), assetId: String(
|
5222
|
+
[{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
|
5217
5223
|
);
|
5218
5224
|
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
5219
5225
|
this.validateGas({
|
@@ -5235,7 +5241,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5235
5241
|
*/
|
5236
5242
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5237
5243
|
const { minGasPrice } = this.provider.getGasConfig();
|
5238
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
5239
5244
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5240
5245
|
const recipientDataArray = (0, import_utils28.arrayify)(
|
5241
5246
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -5250,7 +5255,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5250
5255
|
]);
|
5251
5256
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5252
5257
|
const request = new ScriptTransactionRequest(params);
|
5253
|
-
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId:
|
5258
|
+
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
|
5254
5259
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
5255
5260
|
request,
|
5256
5261
|
forwardingQuantities
|
@@ -5662,14 +5667,14 @@ var import_errors20 = require("@fuel-ts/errors");
|
|
5662
5667
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5663
5668
|
var import_math20 = require("@fuel-ts/math");
|
5664
5669
|
var import_utils35 = require("@fuel-ts/utils");
|
5665
|
-
var
|
5670
|
+
var import_ethers4 = require("ethers");
|
5666
5671
|
|
5667
5672
|
// src/mnemonic/mnemonic.ts
|
5668
5673
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5669
5674
|
var import_errors19 = require("@fuel-ts/errors");
|
5670
5675
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5671
5676
|
var import_utils33 = require("@fuel-ts/utils");
|
5672
|
-
var
|
5677
|
+
var import_ethers3 = require("ethers");
|
5673
5678
|
|
5674
5679
|
// src/wordlists/words/english.ts
|
5675
5680
|
var english = [
|
@@ -7923,7 +7928,7 @@ var Mnemonic = class {
|
|
7923
7928
|
assertMnemonic(getWords(phrase));
|
7924
7929
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7925
7930
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7926
|
-
return (0,
|
7931
|
+
return (0, import_ethers3.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7927
7932
|
}
|
7928
7933
|
/**
|
7929
7934
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7985,7 +7990,7 @@ var Mnemonic = class {
|
|
7985
7990
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7986
7991
|
);
|
7987
7992
|
}
|
7988
|
-
return (0, import_utils33.arrayify)((0,
|
7993
|
+
return (0, import_utils33.arrayify)((0, import_ethers3.computeHmac)("sha512", MasterSecret, seedArray));
|
7989
7994
|
}
|
7990
7995
|
/**
|
7991
7996
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8010,8 +8015,8 @@ var Mnemonic = class {
|
|
8010
8015
|
chainCode,
|
8011
8016
|
(0, import_utils33.concat)(["0x00", privateKey])
|
8012
8017
|
]);
|
8013
|
-
const checksum = (0,
|
8014
|
-
return (0,
|
8018
|
+
const checksum = (0, import_ethers3.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8019
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
8015
8020
|
}
|
8016
8021
|
/**
|
8017
8022
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8039,7 +8044,7 @@ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
|
8039
8044
|
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8040
8045
|
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8041
8046
|
function base58check(data) {
|
8042
|
-
return (0,
|
8047
|
+
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)]));
|
8043
8048
|
}
|
8044
8049
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8045
8050
|
if (isPublic) {
|
@@ -8095,7 +8100,7 @@ var HDWallet = class {
|
|
8095
8100
|
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8096
8101
|
}
|
8097
8102
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8098
|
-
this.fingerprint = (0,
|
8103
|
+
this.fingerprint = (0, import_ethers4.dataSlice)((0, import_ethers4.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8099
8104
|
this.depth = config.depth || this.depth;
|
8100
8105
|
this.index = config.index || this.index;
|
8101
8106
|
this.chainCode = config.chainCode;
|
@@ -8127,7 +8132,7 @@ var HDWallet = class {
|
|
8127
8132
|
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8128
8133
|
}
|
8129
8134
|
data.set((0, import_math20.toBytes)(index, 4), 33);
|
8130
|
-
const bytes = (0, import_utils35.arrayify)((0,
|
8135
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers4.computeHmac)("sha512", chainCode, data));
|
8131
8136
|
const IL = bytes.slice(0, 32);
|
8132
8137
|
const IR = bytes.slice(32);
|
8133
8138
|
if (privateKey) {
|
@@ -8198,7 +8203,7 @@ var HDWallet = class {
|
|
8198
8203
|
});
|
8199
8204
|
}
|
8200
8205
|
static fromExtendedKey(extendedKey) {
|
8201
|
-
const decoded = (0,
|
8206
|
+
const decoded = (0, import_ethers4.toBeHex)((0, import_ethers4.decodeBase58)(extendedKey));
|
8202
8207
|
const bytes = (0, import_utils35.arrayify)(decoded);
|
8203
8208
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8204
8209
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -8813,6 +8818,7 @@ var StorageAbstract = class {
|
|
8813
8818
|
// src/predicate/predicate.ts
|
8814
8819
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
8815
8820
|
var import_address10 = require("@fuel-ts/address");
|
8821
|
+
var import_configs13 = require("@fuel-ts/address/configs");
|
8816
8822
|
var import_errors25 = require("@fuel-ts/errors");
|
8817
8823
|
var import_transactions20 = require("@fuel-ts/transactions");
|
8818
8824
|
var import_utils37 = require("@fuel-ts/utils");
|
@@ -8891,9 +8897,8 @@ var Predicate = class extends Account {
|
|
8891
8897
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
8892
8898
|
* @returns A promise that resolves to the prepared transaction request.
|
8893
8899
|
*/
|
8894
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
8895
|
-
const
|
8896
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
8900
|
+
async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
|
8901
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
8897
8902
|
return this.populateTransactionPredicateData(request);
|
8898
8903
|
}
|
8899
8904
|
/**
|