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