@fuel-ts/account 0.0.0-pr-1784-20240221124858 → 0.0.0-pr-1788-20240222085506
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 +1 -2
- package/dist/account.d.ts.map +1 -1
- package/dist/hdwallet/hdwallet.d.ts +1 -1
- package/dist/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +183 -183
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +188 -188
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -132
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +1 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/memory-cache.d.ts +1 -1
- package/dist/providers/memory-cache.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -2
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +1 -2
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +1 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +1 -1
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/output.d.ts +1 -1
- package/dist/providers/transaction-request/output.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -2
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -3
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/witness.d.ts +1 -1
- package/dist/providers/transaction-request/witness.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/signer/signer.d.ts +1 -1
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +2888 -2888
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +183 -183
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +112 -124
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +1 -2
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/dist/wallet/wallet.d.ts +1 -2
- package/dist/wallet/wallet.d.ts.map +1 -1
- package/dist/wallet/wallets.d.ts +1 -1
- package/dist/wallet/wallets.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/index.js
CHANGED
@@ -191,12 +191,12 @@ var import_configs10 = require("@fuel-ts/address/configs");
|
|
191
191
|
var import_errors15 = require("@fuel-ts/errors");
|
192
192
|
var import_interfaces = require("@fuel-ts/interfaces");
|
193
193
|
var import_math17 = require("@fuel-ts/math");
|
194
|
-
var
|
194
|
+
var import_utils27 = require("@fuel-ts/utils");
|
195
195
|
|
196
196
|
// src/providers/coin-quantity.ts
|
197
197
|
var import_configs = require("@fuel-ts/address/configs");
|
198
198
|
var import_math = require("@fuel-ts/math");
|
199
|
-
var
|
199
|
+
var import_utils = require("@fuel-ts/utils");
|
200
200
|
var coinQuantityfy = (coinQuantityLike) => {
|
201
201
|
let assetId;
|
202
202
|
let amount;
|
@@ -212,7 +212,7 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
212
212
|
}
|
213
213
|
const bnAmount = (0, import_math.bn)(amount);
|
214
214
|
return {
|
215
|
-
assetId: (0,
|
215
|
+
assetId: (0, import_utils.hexlify)(assetId),
|
216
216
|
amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
|
217
217
|
max: max2 ? (0, import_math.bn)(max2) : void 0
|
218
218
|
};
|
@@ -234,10 +234,10 @@ var import_address3 = require("@fuel-ts/address");
|
|
234
234
|
var import_errors13 = require("@fuel-ts/errors");
|
235
235
|
var import_math14 = require("@fuel-ts/math");
|
236
236
|
var import_transactions17 = require("@fuel-ts/transactions");
|
237
|
-
var
|
237
|
+
var import_utils22 = require("@fuel-ts/utils");
|
238
238
|
var import_versions = require("@fuel-ts/versions");
|
239
|
-
var
|
240
|
-
var
|
239
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
240
|
+
var import_ethers2 = require("ethers");
|
241
241
|
var import_graphql_request = require("graphql-request");
|
242
242
|
var import_ramda3 = require("ramda");
|
243
243
|
|
@@ -1110,7 +1110,7 @@ async function* fuelGraphQLSubscriber({
|
|
1110
1110
|
|
1111
1111
|
// src/providers/memory-cache.ts
|
1112
1112
|
var import_errors2 = require("@fuel-ts/errors");
|
1113
|
-
var
|
1113
|
+
var import_utils2 = require("@fuel-ts/utils");
|
1114
1114
|
var cache = {};
|
1115
1115
|
var DEFAULT_TTL_IN_MS = 30 * 1e3;
|
1116
1116
|
var MemoryCache = class {
|
@@ -1125,7 +1125,7 @@ var MemoryCache = class {
|
|
1125
1125
|
}
|
1126
1126
|
}
|
1127
1127
|
get(value, isAutoExpiring = true) {
|
1128
|
-
const key = (0,
|
1128
|
+
const key = (0, import_utils2.hexlify)(value);
|
1129
1129
|
if (cache[key]) {
|
1130
1130
|
if (!isAutoExpiring || cache[key].expires > Date.now()) {
|
1131
1131
|
return cache[key].value;
|
@@ -1136,7 +1136,7 @@ var MemoryCache = class {
|
|
1136
1136
|
}
|
1137
1137
|
set(value) {
|
1138
1138
|
const expiresAt = Date.now() + this.ttl;
|
1139
|
-
const key = (0,
|
1139
|
+
const key = (0, import_utils2.hexlify)(value);
|
1140
1140
|
cache[key] = {
|
1141
1141
|
expires: expiresAt,
|
1142
1142
|
value
|
@@ -1162,7 +1162,7 @@ var MemoryCache = class {
|
|
1162
1162
|
}, []);
|
1163
1163
|
}
|
1164
1164
|
del(value) {
|
1165
|
-
const key = (0,
|
1165
|
+
const key = (0, import_utils2.hexlify)(value);
|
1166
1166
|
delete cache[key];
|
1167
1167
|
}
|
1168
1168
|
};
|
@@ -1172,31 +1172,31 @@ var import_configs2 = require("@fuel-ts/address/configs");
|
|
1172
1172
|
var import_errors3 = require("@fuel-ts/errors");
|
1173
1173
|
var import_math2 = require("@fuel-ts/math");
|
1174
1174
|
var import_transactions = require("@fuel-ts/transactions");
|
1175
|
-
var
|
1175
|
+
var import_utils3 = require("@fuel-ts/utils");
|
1176
1176
|
var inputify = (value) => {
|
1177
1177
|
const { type } = value;
|
1178
1178
|
switch (value.type) {
|
1179
1179
|
case import_transactions.InputType.Coin: {
|
1180
|
-
const predicate = (0,
|
1181
|
-
const predicateData = (0,
|
1180
|
+
const predicate = (0, import_utils3.arrayify)(value.predicate ?? "0x");
|
1181
|
+
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1182
1182
|
return {
|
1183
1183
|
type: import_transactions.InputType.Coin,
|
1184
|
-
txID: (0,
|
1185
|
-
outputIndex: (0,
|
1186
|
-
owner: (0,
|
1184
|
+
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
|
1185
|
+
outputIndex: (0, import_utils3.arrayify)(value.id)[32],
|
1186
|
+
owner: (0, import_utils3.hexlify)(value.owner),
|
1187
1187
|
amount: (0, import_math2.bn)(value.amount),
|
1188
|
-
assetId: (0,
|
1188
|
+
assetId: (0, import_utils3.hexlify)(value.assetId),
|
1189
1189
|
txPointer: {
|
1190
|
-
blockHeight: (0, import_math2.toNumber)((0,
|
1191
|
-
txIndex: (0, import_math2.toNumber)((0,
|
1190
|
+
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1191
|
+
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1192
1192
|
},
|
1193
1193
|
witnessIndex: value.witnessIndex,
|
1194
1194
|
maturity: value.maturity ?? 0,
|
1195
1195
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1196
1196
|
predicateLength: predicate.length,
|
1197
1197
|
predicateDataLength: predicateData.length,
|
1198
|
-
predicate: (0,
|
1199
|
-
predicateData: (0,
|
1198
|
+
predicate: (0, import_utils3.hexlify)(predicate),
|
1199
|
+
predicateData: (0, import_utils3.hexlify)(predicateData)
|
1200
1200
|
};
|
1201
1201
|
}
|
1202
1202
|
case import_transactions.InputType.Contract: {
|
@@ -1207,29 +1207,29 @@ var inputify = (value) => {
|
|
1207
1207
|
balanceRoot: import_configs2.ZeroBytes32,
|
1208
1208
|
stateRoot: import_configs2.ZeroBytes32,
|
1209
1209
|
txPointer: {
|
1210
|
-
blockHeight: (0, import_math2.toNumber)((0,
|
1211
|
-
txIndex: (0, import_math2.toNumber)((0,
|
1210
|
+
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1211
|
+
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1212
1212
|
},
|
1213
|
-
contractID: (0,
|
1213
|
+
contractID: (0, import_utils3.hexlify)(value.contractId)
|
1214
1214
|
};
|
1215
1215
|
}
|
1216
1216
|
case import_transactions.InputType.Message: {
|
1217
|
-
const predicate = (0,
|
1218
|
-
const predicateData = (0,
|
1219
|
-
const data = (0,
|
1217
|
+
const predicate = (0, import_utils3.arrayify)(value.predicate ?? "0x");
|
1218
|
+
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1219
|
+
const data = (0, import_utils3.arrayify)(value.data ?? "0x");
|
1220
1220
|
return {
|
1221
1221
|
type: import_transactions.InputType.Message,
|
1222
|
-
sender: (0,
|
1223
|
-
recipient: (0,
|
1222
|
+
sender: (0, import_utils3.hexlify)(value.sender),
|
1223
|
+
recipient: (0, import_utils3.hexlify)(value.recipient),
|
1224
1224
|
amount: (0, import_math2.bn)(value.amount),
|
1225
|
-
nonce: (0,
|
1225
|
+
nonce: (0, import_utils3.hexlify)(value.nonce),
|
1226
1226
|
witnessIndex: value.witnessIndex,
|
1227
1227
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1228
1228
|
predicateLength: predicate.length,
|
1229
1229
|
predicateDataLength: predicateData.length,
|
1230
|
-
predicate: (0,
|
1231
|
-
predicateData: (0,
|
1232
|
-
data: (0,
|
1230
|
+
predicate: (0, import_utils3.hexlify)(predicate),
|
1231
|
+
predicateData: (0, import_utils3.hexlify)(predicateData),
|
1232
|
+
data: (0, import_utils3.hexlify)(data),
|
1233
1233
|
dataLength: data.length
|
1234
1234
|
};
|
1235
1235
|
}
|
@@ -1247,16 +1247,16 @@ var import_configs3 = require("@fuel-ts/address/configs");
|
|
1247
1247
|
var import_errors4 = require("@fuel-ts/errors");
|
1248
1248
|
var import_math3 = require("@fuel-ts/math");
|
1249
1249
|
var import_transactions2 = require("@fuel-ts/transactions");
|
1250
|
-
var
|
1250
|
+
var import_utils4 = require("@fuel-ts/utils");
|
1251
1251
|
var outputify = (value) => {
|
1252
1252
|
const { type } = value;
|
1253
1253
|
switch (type) {
|
1254
1254
|
case import_transactions2.OutputType.Coin: {
|
1255
1255
|
return {
|
1256
1256
|
type: import_transactions2.OutputType.Coin,
|
1257
|
-
to: (0,
|
1257
|
+
to: (0, import_utils4.hexlify)(value.to),
|
1258
1258
|
amount: (0, import_math3.bn)(value.amount),
|
1259
|
-
assetId: (0,
|
1259
|
+
assetId: (0, import_utils4.hexlify)(value.assetId)
|
1260
1260
|
};
|
1261
1261
|
}
|
1262
1262
|
case import_transactions2.OutputType.Contract: {
|
@@ -1270,9 +1270,9 @@ var outputify = (value) => {
|
|
1270
1270
|
case import_transactions2.OutputType.Change: {
|
1271
1271
|
return {
|
1272
1272
|
type: import_transactions2.OutputType.Change,
|
1273
|
-
to: (0,
|
1273
|
+
to: (0, import_utils4.hexlify)(value.to),
|
1274
1274
|
amount: (0, import_math3.bn)(0),
|
1275
|
-
assetId: (0,
|
1275
|
+
assetId: (0, import_utils4.hexlify)(value.assetId)
|
1276
1276
|
};
|
1277
1277
|
}
|
1278
1278
|
case import_transactions2.OutputType.Variable: {
|
@@ -1286,8 +1286,8 @@ var outputify = (value) => {
|
|
1286
1286
|
case import_transactions2.OutputType.ContractCreated: {
|
1287
1287
|
return {
|
1288
1288
|
type: import_transactions2.OutputType.ContractCreated,
|
1289
|
-
contractId: (0,
|
1290
|
-
stateRoot: (0,
|
1289
|
+
contractId: (0, import_utils4.hexlify)(value.contractId),
|
1290
|
+
stateRoot: (0, import_utils4.hexlify)(value.stateRoot)
|
1291
1291
|
};
|
1292
1292
|
}
|
1293
1293
|
default: {
|
@@ -1304,7 +1304,7 @@ var import_address = require("@fuel-ts/address");
|
|
1304
1304
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1305
1305
|
var import_math6 = require("@fuel-ts/math");
|
1306
1306
|
var import_transactions5 = require("@fuel-ts/transactions");
|
1307
|
-
var
|
1307
|
+
var import_utils9 = require("@fuel-ts/utils");
|
1308
1308
|
|
1309
1309
|
// src/providers/resource.ts
|
1310
1310
|
var isRawCoin = (resource) => "utxoId" in resource;
|
@@ -1318,7 +1318,7 @@ var import_errors5 = require("@fuel-ts/errors");
|
|
1318
1318
|
var import_math4 = require("@fuel-ts/math");
|
1319
1319
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1320
1320
|
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1321
|
-
var
|
1321
|
+
var import_utils5 = require("@fuel-ts/utils");
|
1322
1322
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1323
1323
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1324
1324
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
@@ -1462,7 +1462,7 @@ function assembleReceiptByType(receipt) {
|
|
1462
1462
|
const recipient = hexOrZero(receipt.recipient);
|
1463
1463
|
const nonce = hexOrZero(receipt.nonce);
|
1464
1464
|
const amount = (0, import_math4.bn)(receipt.amount);
|
1465
|
-
const data = receipt.data ? (0,
|
1465
|
+
const data = receipt.data ? (0, import_utils5.arrayify)(receipt.data) : Uint8Array.from([]);
|
1466
1466
|
const digest = hexOrZero(receipt.digest);
|
1467
1467
|
const messageId = import_transactions3.ReceiptMessageOutCoder.getMessageId({
|
1468
1468
|
sender,
|
@@ -1583,7 +1583,7 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1583
1583
|
// src/providers/utils/gas.ts
|
1584
1584
|
var import_math5 = require("@fuel-ts/math");
|
1585
1585
|
var import_transactions4 = require("@fuel-ts/transactions");
|
1586
|
-
var
|
1586
|
+
var import_utils6 = require("@fuel-ts/utils");
|
1587
1587
|
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1588
1588
|
var getGasUsedFromReceipts = (receipts) => {
|
1589
1589
|
const scriptResult = receipts.filter(
|
@@ -1608,9 +1608,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
|
1608
1608
|
const totalGas = inputs.reduce((total, input) => {
|
1609
1609
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1610
1610
|
return total.add(
|
1611
|
-
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
|
1612
|
-
resolveGasDependentCosts((0, import_ethers6.getBytesCopy)(input.predicate).length, gasCosts.contractRoot)
|
1613
|
-
).add((0, import_math5.bn)(input.predicateGasUsed))
|
1611
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
|
1614
1612
|
);
|
1615
1613
|
}
|
1616
1614
|
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
@@ -1659,13 +1657,13 @@ function calculateMetadataGasForTxScript({
|
|
1659
1657
|
}
|
1660
1658
|
|
1661
1659
|
// src/providers/utils/json.ts
|
1662
|
-
var
|
1660
|
+
var import_utils7 = require("@fuel-ts/utils");
|
1663
1661
|
var import_ramda = require("ramda");
|
1664
1662
|
function normalize(object) {
|
1665
1663
|
Object.keys(object).forEach((key) => {
|
1666
1664
|
switch (object[key]?.constructor.name) {
|
1667
1665
|
case "Uint8Array":
|
1668
|
-
object[key] = (0,
|
1666
|
+
object[key] = (0, import_utils7.hexlify)(object[key]);
|
1669
1667
|
break;
|
1670
1668
|
case "Array":
|
1671
1669
|
object[key] = normalize(object[key]);
|
@@ -1725,11 +1723,11 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1725
1723
|
};
|
1726
1724
|
|
1727
1725
|
// src/providers/transaction-request/witness.ts
|
1728
|
-
var
|
1726
|
+
var import_utils8 = require("@fuel-ts/utils");
|
1729
1727
|
var witnessify = (value) => {
|
1730
|
-
const data = (0,
|
1728
|
+
const data = (0, import_utils8.arrayify)(value);
|
1731
1729
|
return {
|
1732
|
-
data: (0,
|
1730
|
+
data: (0, import_utils8.hexlify)(data),
|
1733
1731
|
dataLength: data.length
|
1734
1732
|
};
|
1735
1733
|
};
|
@@ -1849,7 +1847,7 @@ var BaseTransactionRequest = class {
|
|
1849
1847
|
* Creates an empty witness without any side effects and returns the index
|
1850
1848
|
*/
|
1851
1849
|
createWitness() {
|
1852
|
-
this.witnesses.push((0,
|
1850
|
+
this.witnesses.push((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1853
1851
|
return this.witnesses.length - 1;
|
1854
1852
|
}
|
1855
1853
|
/**
|
@@ -1918,9 +1916,9 @@ var BaseTransactionRequest = class {
|
|
1918
1916
|
const found = this.inputs.find((input) => {
|
1919
1917
|
switch (input.type) {
|
1920
1918
|
case import_transactions5.InputType.Coin:
|
1921
|
-
return (0,
|
1919
|
+
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
1922
1920
|
case import_transactions5.InputType.Message:
|
1923
|
-
return (0,
|
1921
|
+
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
1924
1922
|
default:
|
1925
1923
|
return false;
|
1926
1924
|
}
|
@@ -2086,7 +2084,7 @@ var BaseTransactionRequest = class {
|
|
2086
2084
|
*/
|
2087
2085
|
addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
|
2088
2086
|
const changeOutput = this.getChangeOutputs().find(
|
2089
|
-
(output) => (0,
|
2087
|
+
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
2090
2088
|
);
|
2091
2089
|
if (!changeOutput) {
|
2092
2090
|
this.pushOutput({
|
@@ -2229,14 +2227,15 @@ var BaseTransactionRequest = class {
|
|
2229
2227
|
var import_configs8 = require("@fuel-ts/address/configs");
|
2230
2228
|
var import_math8 = require("@fuel-ts/math");
|
2231
2229
|
var import_transactions7 = require("@fuel-ts/transactions");
|
2232
|
-
var
|
2230
|
+
var import_utils13 = require("@fuel-ts/utils");
|
2233
2231
|
|
2234
2232
|
// src/providers/transaction-request/hash-transaction.ts
|
2235
2233
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2236
2234
|
var import_hasher = require("@fuel-ts/hasher");
|
2237
2235
|
var import_math7 = require("@fuel-ts/math");
|
2238
2236
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2239
|
-
var
|
2237
|
+
var import_utils11 = require("@fuel-ts/utils");
|
2238
|
+
var import_ethers = require("ethers");
|
2240
2239
|
var import_ramda2 = require("ramda");
|
2241
2240
|
function hashTransaction(transactionRequest, chainId) {
|
2242
2241
|
const transaction = transactionRequest.toTransaction();
|
@@ -2298,15 +2297,15 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2298
2297
|
transaction.witnessesCount = 0;
|
2299
2298
|
transaction.witnesses = [];
|
2300
2299
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2301
|
-
const concatenatedData = (0,
|
2302
|
-
return (0,
|
2300
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
|
2301
|
+
return (0, import_ethers.sha256)(concatenatedData);
|
2303
2302
|
}
|
2304
2303
|
|
2305
2304
|
// src/providers/transaction-request/storage-slot.ts
|
2306
|
-
var
|
2305
|
+
var import_utils12 = require("@fuel-ts/utils");
|
2307
2306
|
var getStorageValue = (value) => {
|
2308
2307
|
const v = new Uint8Array(32);
|
2309
|
-
v.set((0,
|
2308
|
+
v.set((0, import_utils12.arrayify)(value));
|
2310
2309
|
return v;
|
2311
2310
|
};
|
2312
2311
|
var storageSlotify = (storageSlot) => {
|
@@ -2320,8 +2319,8 @@ var storageSlotify = (storageSlot) => {
|
|
2320
2319
|
value = storageSlot.value;
|
2321
2320
|
}
|
2322
2321
|
return {
|
2323
|
-
key: (0,
|
2324
|
-
value: (0,
|
2322
|
+
key: (0, import_utils12.hexlify)(key),
|
2323
|
+
value: (0, import_utils12.hexlify)(getStorageValue(value))
|
2325
2324
|
};
|
2326
2325
|
};
|
2327
2326
|
|
@@ -2354,7 +2353,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2354
2353
|
} = {}) {
|
2355
2354
|
super(rest);
|
2356
2355
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2357
|
-
this.salt = (0,
|
2356
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
|
2358
2357
|
this.storageSlots = [...storageSlots ?? []];
|
2359
2358
|
}
|
2360
2359
|
/**
|
@@ -2372,7 +2371,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2372
2371
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2373
2372
|
bytecodeWitnessIndex,
|
2374
2373
|
storageSlotsCount: storageSlots.length,
|
2375
|
-
salt: this.salt ? (0,
|
2374
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2376
2375
|
storageSlots
|
2377
2376
|
};
|
2378
2377
|
}
|
@@ -2411,7 +2410,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2411
2410
|
}
|
2412
2411
|
metadataGas(gasCosts) {
|
2413
2412
|
return calculateMetadataGasForTxCreate({
|
2414
|
-
contractBytesSize: (0, import_math8.bn)((0,
|
2413
|
+
contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2415
2414
|
gasCosts,
|
2416
2415
|
stateRootSize: this.storageSlots.length,
|
2417
2416
|
txBytesSize: this.byteSize()
|
@@ -2425,17 +2424,17 @@ var import_address2 = require("@fuel-ts/address");
|
|
2425
2424
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2426
2425
|
var import_math9 = require("@fuel-ts/math");
|
2427
2426
|
var import_transactions8 = require("@fuel-ts/transactions");
|
2428
|
-
var
|
2427
|
+
var import_utils15 = require("@fuel-ts/utils");
|
2429
2428
|
|
2430
2429
|
// src/providers/transaction-request/scripts.ts
|
2431
|
-
var
|
2430
|
+
var import_utils14 = require("@fuel-ts/utils");
|
2432
2431
|
var returnZeroScript = {
|
2433
2432
|
/*
|
2434
2433
|
Opcode::RET(REG_ZERO)
|
2435
2434
|
Opcode::NOOP
|
2436
2435
|
*/
|
2437
2436
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2438
|
-
bytes: (0,
|
2437
|
+
bytes: (0, import_utils14.arrayify)("0x24000000"),
|
2439
2438
|
encodeScriptData: () => new Uint8Array(0)
|
2440
2439
|
};
|
2441
2440
|
var withdrawScript = {
|
@@ -2449,7 +2448,7 @@ var withdrawScript = {
|
|
2449
2448
|
00000000 00000000 [amount value]
|
2450
2449
|
*/
|
2451
2450
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2452
|
-
bytes: (0,
|
2451
|
+
bytes: (0, import_utils14.arrayify)("0x5040C0105D44C0064C40001124000000"),
|
2453
2452
|
encodeScriptData: () => new Uint8Array(0)
|
2454
2453
|
};
|
2455
2454
|
|
@@ -2477,8 +2476,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2477
2476
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2478
2477
|
super(rest);
|
2479
2478
|
this.gasLimit = (0, import_math9.bn)(gasLimit);
|
2480
|
-
this.script = (0,
|
2481
|
-
this.scriptData = (0,
|
2479
|
+
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2480
|
+
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2482
2481
|
}
|
2483
2482
|
/**
|
2484
2483
|
* Converts the transaction request to a `TransactionScript`.
|
@@ -2486,8 +2485,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2486
2485
|
* @returns The transaction script object.
|
2487
2486
|
*/
|
2488
2487
|
toTransaction() {
|
2489
|
-
const script = (0,
|
2490
|
-
const scriptData = (0,
|
2488
|
+
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2489
|
+
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2491
2490
|
return {
|
2492
2491
|
type: import_transactions8.TransactionType.Script,
|
2493
2492
|
scriptGasLimit: this.gasLimit,
|
@@ -2495,8 +2494,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2495
2494
|
scriptLength: script.length,
|
2496
2495
|
scriptDataLength: scriptData.length,
|
2497
2496
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2498
|
-
script: (0,
|
2499
|
-
scriptData: (0,
|
2497
|
+
script: (0, import_utils15.hexlify)(script),
|
2498
|
+
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2500
2499
|
};
|
2501
2500
|
}
|
2502
2501
|
/**
|
@@ -2647,15 +2646,15 @@ var transactionRequestify = (obj) => {
|
|
2647
2646
|
var import_errors12 = require("@fuel-ts/errors");
|
2648
2647
|
var import_math13 = require("@fuel-ts/math");
|
2649
2648
|
var import_transactions15 = require("@fuel-ts/transactions");
|
2650
|
-
var
|
2649
|
+
var import_utils21 = require("@fuel-ts/utils");
|
2651
2650
|
|
2652
2651
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2653
|
-
var
|
2652
|
+
var import_utils19 = require("@fuel-ts/utils");
|
2654
2653
|
|
2655
2654
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2656
2655
|
var import_math10 = require("@fuel-ts/math");
|
2657
2656
|
var import_transactions10 = require("@fuel-ts/transactions");
|
2658
|
-
var
|
2657
|
+
var import_utils16 = require("@fuel-ts/utils");
|
2659
2658
|
var calculateTransactionFee = (params) => {
|
2660
2659
|
const {
|
2661
2660
|
gasUsed,
|
@@ -2664,7 +2663,7 @@ var calculateTransactionFee = (params) => {
|
|
2664
2663
|
} = params;
|
2665
2664
|
const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
|
2666
2665
|
const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
|
2667
|
-
const transactionBytes = (0,
|
2666
|
+
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2668
2667
|
const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
|
2669
2668
|
if (transaction.type === import_transactions10.TransactionType.Mint) {
|
2670
2669
|
return {
|
@@ -2679,7 +2678,7 @@ var calculateTransactionFee = (params) => {
|
|
2679
2678
|
let gasLimit = (0, import_math10.bn)(0);
|
2680
2679
|
if (type === import_transactions10.TransactionType.Create) {
|
2681
2680
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2682
|
-
const contractBytesSize = (0, import_math10.bn)((0,
|
2681
|
+
const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2683
2682
|
metadataGas = calculateMetadataGasForTxCreate({
|
2684
2683
|
contractBytesSize,
|
2685
2684
|
gasCosts,
|
@@ -3367,7 +3366,7 @@ function assembleTransactionSummary(params) {
|
|
3367
3366
|
gasCosts
|
3368
3367
|
} = params;
|
3369
3368
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3370
|
-
const rawPayload = (0,
|
3369
|
+
const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
|
3371
3370
|
const operations = getOperations({
|
3372
3371
|
transactionType: transaction.type,
|
3373
3372
|
inputs: transaction.inputs || [],
|
@@ -3484,7 +3483,7 @@ var TransactionResponse = class {
|
|
3484
3483
|
*/
|
3485
3484
|
decodeTransaction(transactionWithReceipts) {
|
3486
3485
|
return new import_transactions15.TransactionCoder().decode(
|
3487
|
-
(0,
|
3486
|
+
(0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
|
3488
3487
|
0
|
3489
3488
|
)?.[0];
|
3490
3489
|
}
|
@@ -3510,7 +3509,7 @@ var TransactionResponse = class {
|
|
3510
3509
|
id: this.id,
|
3511
3510
|
receipts,
|
3512
3511
|
transaction: decodedTransaction,
|
3513
|
-
transactionBytes: (0,
|
3512
|
+
transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
|
3514
3513
|
gqlTransactionStatus: transaction.status,
|
3515
3514
|
gasPerByte,
|
3516
3515
|
gasPriceFactor,
|
@@ -3845,7 +3844,7 @@ var _Provider = class {
|
|
3845
3844
|
name,
|
3846
3845
|
consensusParameters: { chainId }
|
3847
3846
|
} = await this.getChain();
|
3848
|
-
const network = new
|
3847
|
+
const network = new import_ethers2.Network(name, chainId.toNumber());
|
3849
3848
|
return Promise.resolve(network);
|
3850
3849
|
}
|
3851
3850
|
/**
|
@@ -3913,7 +3912,7 @@ var _Provider = class {
|
|
3913
3912
|
if (estimateTxDependencies) {
|
3914
3913
|
await this.estimateTxDependencies(transactionRequest);
|
3915
3914
|
}
|
3916
|
-
const encodedTransaction = (0,
|
3915
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3917
3916
|
if (awaitExecution) {
|
3918
3917
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3919
3918
|
for await (const { submitAndAwait } of subscription) {
|
@@ -3946,7 +3945,7 @@ var _Provider = class {
|
|
3946
3945
|
if (estimateTxDependencies) {
|
3947
3946
|
return this.estimateTxDependencies(transactionRequest);
|
3948
3947
|
}
|
3949
|
-
const encodedTransaction = (0,
|
3948
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3950
3949
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3951
3950
|
encodedTransaction,
|
3952
3951
|
utxoValidation: utxoValidation || false
|
@@ -3965,13 +3964,13 @@ var _Provider = class {
|
|
3965
3964
|
async estimatePredicates(transactionRequest) {
|
3966
3965
|
const shouldEstimatePredicates = Boolean(
|
3967
3966
|
transactionRequest.inputs.find(
|
3968
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
3967
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
|
3969
3968
|
)
|
3970
3969
|
);
|
3971
3970
|
if (!shouldEstimatePredicates) {
|
3972
3971
|
return transactionRequest;
|
3973
3972
|
}
|
3974
|
-
const encodedTransaction = (0,
|
3973
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3975
3974
|
const response = await this.operations.estimatePredicates({
|
3976
3975
|
encodedTransaction
|
3977
3976
|
});
|
@@ -4010,7 +4009,7 @@ var _Provider = class {
|
|
4010
4009
|
let receipts = [];
|
4011
4010
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4012
4011
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
4013
|
-
encodedTransaction: (0,
|
4012
|
+
encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
|
4014
4013
|
utxoValidation: false
|
4015
4014
|
});
|
4016
4015
|
receipts = gqlReceipts.map(processGqlReceipt);
|
@@ -4044,7 +4043,7 @@ var _Provider = class {
|
|
4044
4043
|
if (estimateTxDependencies) {
|
4045
4044
|
return this.estimateTxDependencies(transactionRequest);
|
4046
4045
|
}
|
4047
|
-
const encodedTransaction = (0,
|
4046
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4048
4047
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
4049
4048
|
encodedTransaction,
|
4050
4049
|
utxoValidation: true
|
@@ -4149,7 +4148,7 @@ var _Provider = class {
|
|
4149
4148
|
const result = await this.operations.getCoins({
|
4150
4149
|
first: 10,
|
4151
4150
|
...paginationArgs,
|
4152
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4151
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4153
4152
|
});
|
4154
4153
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4155
4154
|
return coins.map((coin) => ({
|
@@ -4173,19 +4172,19 @@ var _Provider = class {
|
|
4173
4172
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4174
4173
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4175
4174
|
const excludeInput = {
|
4176
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4177
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4175
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4176
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4178
4177
|
};
|
4179
4178
|
if (this.cache) {
|
4180
4179
|
const uniqueUtxos = new Set(
|
4181
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4180
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4182
4181
|
);
|
4183
4182
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4184
4183
|
}
|
4185
4184
|
const coinsQuery = {
|
4186
4185
|
owner: ownerAddress.toB256(),
|
4187
4186
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4188
|
-
assetId: (0,
|
4187
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4189
4188
|
amount: amount.toString(10),
|
4190
4189
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4191
4190
|
})),
|
@@ -4288,7 +4287,7 @@ var _Provider = class {
|
|
4288
4287
|
time: block.header.time,
|
4289
4288
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4290
4289
|
transactions: block.transactions.map(
|
4291
|
-
(tx) => new import_transactions17.TransactionCoder().decode((0,
|
4290
|
+
(tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4292
4291
|
)
|
4293
4292
|
};
|
4294
4293
|
}
|
@@ -4304,7 +4303,7 @@ var _Provider = class {
|
|
4304
4303
|
return null;
|
4305
4304
|
}
|
4306
4305
|
return new import_transactions17.TransactionCoder().decode(
|
4307
|
-
(0,
|
4306
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4308
4307
|
0
|
4309
4308
|
)?.[0];
|
4310
4309
|
}
|
@@ -4331,7 +4330,7 @@ var _Provider = class {
|
|
4331
4330
|
async getContractBalance(contractId, assetId) {
|
4332
4331
|
const { contractBalance } = await this.operations.getContractBalance({
|
4333
4332
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4334
|
-
asset: (0,
|
4333
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4335
4334
|
});
|
4336
4335
|
return (0, import_math14.bn)(contractBalance.amount, 10);
|
4337
4336
|
}
|
@@ -4345,7 +4344,7 @@ var _Provider = class {
|
|
4345
4344
|
async getBalance(owner, assetId) {
|
4346
4345
|
const { balance } = await this.operations.getBalance({
|
4347
4346
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4348
|
-
assetId: (0,
|
4347
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4349
4348
|
});
|
4350
4349
|
return (0, import_math14.bn)(balance.amount, 10);
|
4351
4350
|
}
|
@@ -4534,7 +4533,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4534
4533
|
var import_errors14 = require("@fuel-ts/errors");
|
4535
4534
|
var import_math15 = require("@fuel-ts/math");
|
4536
4535
|
var import_transactions18 = require("@fuel-ts/transactions");
|
4537
|
-
var
|
4536
|
+
var import_utils25 = require("@fuel-ts/utils");
|
4538
4537
|
async function getTransactionSummary(params) {
|
4539
4538
|
const { id, provider, abiMap } = params;
|
4540
4539
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -4547,7 +4546,7 @@ async function getTransactionSummary(params) {
|
|
4547
4546
|
);
|
4548
4547
|
}
|
4549
4548
|
const [decodedTransaction] = new import_transactions18.TransactionCoder().decode(
|
4550
|
-
(0,
|
4549
|
+
(0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
4551
4550
|
0
|
4552
4551
|
);
|
4553
4552
|
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
@@ -4558,7 +4557,7 @@ async function getTransactionSummary(params) {
|
|
4558
4557
|
id: gqlTransaction.id,
|
4559
4558
|
receipts,
|
4560
4559
|
transaction: decodedTransaction,
|
4561
|
-
transactionBytes: (0,
|
4560
|
+
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
4562
4561
|
gqlTransactionStatus: gqlTransaction.status,
|
4563
4562
|
gasPerByte: (0, import_math15.bn)(gasPerByte),
|
4564
4563
|
gasPriceFactor: (0, import_math15.bn)(gasPriceFactor),
|
@@ -4600,13 +4599,13 @@ async function getTransactionsSummaries(params) {
|
|
4600
4599
|
const transactions = edges.map((edge) => {
|
4601
4600
|
const { node: gqlTransaction } = edge;
|
4602
4601
|
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
4603
|
-
const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0,
|
4602
|
+
const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
|
4604
4603
|
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
4605
4604
|
const transactionSummary = assembleTransactionSummary({
|
4606
4605
|
id,
|
4607
4606
|
receipts,
|
4608
4607
|
transaction: decodedTransaction,
|
4609
|
-
transactionBytes: (0,
|
4608
|
+
transactionBytes: (0, import_utils25.arrayify)(rawPayload),
|
4610
4609
|
gqlTransactionStatus: status,
|
4611
4610
|
abiMap,
|
4612
4611
|
gasPerByte,
|
@@ -4750,16 +4749,16 @@ var assets = [
|
|
4750
4749
|
// src/utils/formatTransferToContractScriptData.ts
|
4751
4750
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4752
4751
|
var import_math16 = require("@fuel-ts/math");
|
4752
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4753
4753
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4754
|
-
var import_ethers20 = require("ethers");
|
4755
4754
|
var formatTransferToContractScriptData = (params) => {
|
4756
4755
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4757
4756
|
const numberCoder = new import_abi_coder4.U64Coder();
|
4758
4757
|
const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
|
4759
4758
|
const scriptData = Uint8Array.from([
|
4760
|
-
...(0,
|
4759
|
+
...(0, import_utils26.arrayify)(hexlifiedContractId),
|
4761
4760
|
...encoded,
|
4762
|
-
...(0,
|
4761
|
+
...(0, import_utils26.arrayify)(assetId)
|
4763
4762
|
]);
|
4764
4763
|
return scriptData;
|
4765
4764
|
};
|
@@ -5087,14 +5086,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5087
5086
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5088
5087
|
const { minGasPrice } = this.provider.getGasConfig();
|
5089
5088
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5090
|
-
const recipientDataArray = (0,
|
5089
|
+
const recipientDataArray = (0, import_utils27.arrayify)(
|
5091
5090
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5092
5091
|
);
|
5093
|
-
const amountDataArray = (0,
|
5092
|
+
const amountDataArray = (0, import_utils27.arrayify)(
|
5094
5093
|
"0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5095
5094
|
);
|
5096
5095
|
const script = new Uint8Array([
|
5097
|
-
...(0,
|
5096
|
+
...(0, import_utils27.arrayify)(withdrawScript.bytes),
|
5098
5097
|
...recipientDataArray,
|
5099
5098
|
...amountDataArray
|
5100
5099
|
]);
|
@@ -5178,14 +5177,15 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5178
5177
|
|
5179
5178
|
// src/wallet/base-wallet-unlocked.ts
|
5180
5179
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5180
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5181
5181
|
|
5182
5182
|
// src/signer/signer.ts
|
5183
5183
|
var import_address5 = require("@fuel-ts/address");
|
5184
5184
|
var import_crypto = require("@fuel-ts/crypto");
|
5185
5185
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5186
5186
|
var import_math18 = require("@fuel-ts/math");
|
5187
|
+
var import_utils28 = require("@fuel-ts/utils");
|
5187
5188
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5188
|
-
var import_ethers22 = require("ethers");
|
5189
5189
|
var Signer = class {
|
5190
5190
|
address;
|
5191
5191
|
publicKey;
|
@@ -5204,9 +5204,9 @@ var Signer = class {
|
|
5204
5204
|
}
|
5205
5205
|
}
|
5206
5206
|
const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
|
5207
|
-
this.privateKey = (0,
|
5208
|
-
this.publicKey = (0,
|
5209
|
-
this.compressedPublicKey = (0,
|
5207
|
+
this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
|
5208
|
+
this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5209
|
+
this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5210
5210
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5211
5211
|
}
|
5212
5212
|
/**
|
@@ -5220,11 +5220,11 @@ var Signer = class {
|
|
5220
5220
|
* @returns hashed signature
|
5221
5221
|
*/
|
5222
5222
|
sign(data) {
|
5223
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5223
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
|
5224
5224
|
const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5225
5225
|
const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5226
5226
|
s[0] |= (signature.recovery || 0) << 7;
|
5227
|
-
return (0,
|
5227
|
+
return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
|
5228
5228
|
}
|
5229
5229
|
/**
|
5230
5230
|
* Add point on the current elliptic curve
|
@@ -5233,8 +5233,8 @@ var Signer = class {
|
|
5233
5233
|
* @returns compressed point on the curve
|
5234
5234
|
*/
|
5235
5235
|
addPoint(point) {
|
5236
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5237
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5236
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
|
5237
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
|
5238
5238
|
const result = p0.add(p1);
|
5239
5239
|
return `0x${result.toHex(true)}`;
|
5240
5240
|
}
|
@@ -5246,16 +5246,16 @@ var Signer = class {
|
|
5246
5246
|
* @returns public key from signature from the
|
5247
5247
|
*/
|
5248
5248
|
static recoverPublicKey(data, signature) {
|
5249
|
-
const signedMessageBytes = (0,
|
5249
|
+
const signedMessageBytes = (0, import_utils28.arrayify)(signature);
|
5250
5250
|
const r = signedMessageBytes.slice(0, 32);
|
5251
5251
|
const s = signedMessageBytes.slice(32, 64);
|
5252
5252
|
const recoveryParam = (s[0] & 128) >> 7;
|
5253
5253
|
s[0] &= 127;
|
5254
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5254
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
|
5255
5255
|
recoveryParam
|
5256
5256
|
);
|
5257
|
-
const publicKey = sig.recoverPublicKey((0,
|
5258
|
-
return (0,
|
5257
|
+
const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
|
5258
|
+
return (0, import_utils28.hexlify)(publicKey);
|
5259
5259
|
}
|
5260
5260
|
/**
|
5261
5261
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5274,7 +5274,7 @@ var Signer = class {
|
|
5274
5274
|
* @returns random 32-byte hashed
|
5275
5275
|
*/
|
5276
5276
|
static generatePrivateKey(entropy) {
|
5277
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5277
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
5278
5278
|
}
|
5279
5279
|
/**
|
5280
5280
|
* Extended publicKey from a compact publicKey
|
@@ -5283,8 +5283,8 @@ var Signer = class {
|
|
5283
5283
|
* @returns extended publicKey
|
5284
5284
|
*/
|
5285
5285
|
static extendPublicKey(publicKey) {
|
5286
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5287
|
-
return (0,
|
5286
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
|
5287
|
+
return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
|
5288
5288
|
}
|
5289
5289
|
};
|
5290
5290
|
|
@@ -5292,7 +5292,7 @@ var Signer = class {
|
|
5292
5292
|
var import_address6 = require("@fuel-ts/address");
|
5293
5293
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5294
5294
|
var import_errors16 = require("@fuel-ts/errors");
|
5295
|
-
var
|
5295
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5296
5296
|
var import_uuid = require("uuid");
|
5297
5297
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5298
5298
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5375,7 +5375,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5375
5375
|
);
|
5376
5376
|
}
|
5377
5377
|
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5378
|
-
const privateKey = (0,
|
5378
|
+
const privateKey = (0, import_utils29.hexlify)(buffer);
|
5379
5379
|
return privateKey;
|
5380
5380
|
}
|
5381
5381
|
|
@@ -5420,7 +5420,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5420
5420
|
*/
|
5421
5421
|
async signMessage(message) {
|
5422
5422
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5423
|
-
return signedMessage;
|
5423
|
+
return (0, import_utils30.hexlify)(signedMessage);
|
5424
5424
|
}
|
5425
5425
|
/**
|
5426
5426
|
* Signs a transaction with the wallet's private key.
|
@@ -5433,7 +5433,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5433
5433
|
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
5434
5434
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5435
5435
|
const signature = await this.signer().sign(hashedTransaction);
|
5436
|
-
return signature;
|
5436
|
+
return (0, import_utils30.hexlify)(signature);
|
5437
5437
|
}
|
5438
5438
|
/**
|
5439
5439
|
* Populates a transaction with the witnesses signature.
|
@@ -5494,12 +5494,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5494
5494
|
// src/hdwallet/hdwallet.ts
|
5495
5495
|
var import_errors19 = require("@fuel-ts/errors");
|
5496
5496
|
var import_math19 = require("@fuel-ts/math");
|
5497
|
-
var
|
5497
|
+
var import_utils34 = require("@fuel-ts/utils");
|
5498
|
+
var import_ethers5 = require("ethers");
|
5498
5499
|
|
5499
5500
|
// src/mnemonic/mnemonic.ts
|
5500
5501
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5501
5502
|
var import_errors18 = require("@fuel-ts/errors");
|
5502
|
-
var
|
5503
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5504
|
+
var import_ethers4 = require("ethers");
|
5503
5505
|
|
5504
5506
|
// src/wordlists/words/english.ts
|
5505
5507
|
var english = [
|
@@ -7561,7 +7563,8 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
7561
7563
|
|
7562
7564
|
// src/mnemonic/utils.ts
|
7563
7565
|
var import_errors17 = require("@fuel-ts/errors");
|
7564
|
-
var
|
7566
|
+
var import_utils31 = require("@fuel-ts/utils");
|
7567
|
+
var import_ethers3 = require("ethers");
|
7565
7568
|
function toUtf8Bytes(stri) {
|
7566
7569
|
const str = stri.normalize("NFKD");
|
7567
7570
|
const result = [];
|
@@ -7628,14 +7631,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7628
7631
|
}
|
7629
7632
|
}
|
7630
7633
|
const checksumBits = entropy.length / 4;
|
7631
|
-
const checksum = (0,
|
7634
|
+
const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7632
7635
|
indices[indices.length - 1] <<= checksumBits;
|
7633
7636
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7634
7637
|
return indices;
|
7635
7638
|
}
|
7636
7639
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7637
7640
|
const size = Math.ceil(11 * words.length / 8);
|
7638
|
-
const entropy = (0,
|
7641
|
+
const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
|
7639
7642
|
let offset = 0;
|
7640
7643
|
for (let i = 0; i < words.length; i += 1) {
|
7641
7644
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7655,7 +7658,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7655
7658
|
const entropyBits = 32 * words.length / 3;
|
7656
7659
|
const checksumBits = words.length / 3;
|
7657
7660
|
const checksumMask = getUpperMask(checksumBits);
|
7658
|
-
const checksum = (0,
|
7661
|
+
const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7659
7662
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7660
7663
|
throw new import_errors17.FuelError(
|
7661
7664
|
import_errors17.ErrorCode.INVALID_CHECKSUM,
|
@@ -7730,7 +7733,7 @@ var Mnemonic = class {
|
|
7730
7733
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7731
7734
|
const words = getWords(phrase);
|
7732
7735
|
assertMnemonic(words);
|
7733
|
-
return (0,
|
7736
|
+
return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7734
7737
|
}
|
7735
7738
|
/**
|
7736
7739
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7738,7 +7741,7 @@ var Mnemonic = class {
|
|
7738
7741
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7739
7742
|
*/
|
7740
7743
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7741
|
-
const entropyBytes = (0,
|
7744
|
+
const entropyBytes = (0, import_utils32.arrayify)(entropy);
|
7742
7745
|
assertWordList(wordlist);
|
7743
7746
|
assertEntropy(entropyBytes);
|
7744
7747
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7752,7 +7755,7 @@ var Mnemonic = class {
|
|
7752
7755
|
assertMnemonic(getWords(phrase));
|
7753
7756
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7754
7757
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7755
|
-
return (0,
|
7758
|
+
return (0, import_ethers4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7756
7759
|
}
|
7757
7760
|
/**
|
7758
7761
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7807,14 +7810,14 @@ var Mnemonic = class {
|
|
7807
7810
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7808
7811
|
*/
|
7809
7812
|
static masterKeysFromSeed(seed) {
|
7810
|
-
const seedArray = (0,
|
7813
|
+
const seedArray = (0, import_utils32.arrayify)(seed);
|
7811
7814
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7812
7815
|
throw new import_errors18.FuelError(
|
7813
7816
|
import_errors18.ErrorCode.INVALID_SEED,
|
7814
7817
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7815
7818
|
);
|
7816
7819
|
}
|
7817
|
-
return (0,
|
7820
|
+
return (0, import_utils32.arrayify)((0, import_ethers4.computeHmac)("sha512", MasterSecret, seedArray));
|
7818
7821
|
}
|
7819
7822
|
/**
|
7820
7823
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7825,22 +7828,22 @@ var Mnemonic = class {
|
|
7825
7828
|
*/
|
7826
7829
|
static seedToExtendedKey(seed, testnet = false) {
|
7827
7830
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7828
|
-
const prefix = (0,
|
7831
|
+
const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7829
7832
|
const depth = "0x00";
|
7830
7833
|
const fingerprint = "0x00000000";
|
7831
7834
|
const index = "0x00000000";
|
7832
7835
|
const chainCode = masterKey.slice(32);
|
7833
7836
|
const privateKey = masterKey.slice(0, 32);
|
7834
|
-
const extendedKey = (0,
|
7837
|
+
const extendedKey = (0, import_utils32.concat)([
|
7835
7838
|
prefix,
|
7836
7839
|
depth,
|
7837
7840
|
fingerprint,
|
7838
7841
|
index,
|
7839
7842
|
chainCode,
|
7840
|
-
(0,
|
7843
|
+
(0, import_utils32.concat)(["0x00", privateKey])
|
7841
7844
|
]);
|
7842
|
-
const checksum = (0,
|
7843
|
-
return (0,
|
7845
|
+
const checksum = (0, import_ethers4.dataSlice)((0, import_ethers4.sha256)((0, import_ethers4.sha256)(extendedKey)), 0, 4);
|
7846
|
+
return (0, import_ethers4.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
|
7844
7847
|
}
|
7845
7848
|
/**
|
7846
7849
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7855,7 +7858,7 @@ var Mnemonic = class {
|
|
7855
7858
|
* @returns A randomly generated mnemonic
|
7856
7859
|
*/
|
7857
7860
|
static generate(size = 32, extraEntropy = "") {
|
7858
|
-
const entropy = extraEntropy ? (0,
|
7861
|
+
const entropy = extraEntropy ? (0, import_ethers4.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7859
7862
|
return Mnemonic.entropyToMnemonic(entropy);
|
7860
7863
|
}
|
7861
7864
|
};
|
@@ -7863,12 +7866,12 @@ var mnemonic_default = Mnemonic;
|
|
7863
7866
|
|
7864
7867
|
// src/hdwallet/hdwallet.ts
|
7865
7868
|
var HARDENED_INDEX = 2147483648;
|
7866
|
-
var MainnetPRV2 = (0,
|
7867
|
-
var MainnetPUB = (0,
|
7868
|
-
var TestnetPRV2 = (0,
|
7869
|
-
var TestnetPUB = (0,
|
7869
|
+
var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
|
7870
|
+
var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
|
7871
|
+
var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
|
7872
|
+
var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
|
7870
7873
|
function base58check(data) {
|
7871
|
-
return (0,
|
7874
|
+
return (0, import_ethers5.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers5.dataSlice)((0, import_ethers5.sha256)((0, import_ethers5.sha256)(data)), 0, 4)]));
|
7872
7875
|
}
|
7873
7876
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7874
7877
|
if (isPublic) {
|
@@ -7877,11 +7880,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7877
7880
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7878
7881
|
}
|
7879
7882
|
function isPublicExtendedKey(extendedKey) {
|
7880
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7883
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
|
7881
7884
|
}
|
7882
7885
|
function isValidExtendedKey(extendedKey) {
|
7883
7886
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7884
|
-
(0,
|
7887
|
+
(0, import_utils34.hexlify)(extendedKey.slice(0, 4))
|
7885
7888
|
);
|
7886
7889
|
}
|
7887
7890
|
function parsePath(path, depth = 0) {
|
@@ -7899,8 +7902,8 @@ function parsePath(path, depth = 0) {
|
|
7899
7902
|
var HDWallet = class {
|
7900
7903
|
depth = 0;
|
7901
7904
|
index = 0;
|
7902
|
-
fingerprint = (0,
|
7903
|
-
parentFingerprint = (0,
|
7905
|
+
fingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7906
|
+
parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7904
7907
|
privateKey;
|
7905
7908
|
publicKey;
|
7906
7909
|
chainCode;
|
@@ -7912,8 +7915,8 @@ var HDWallet = class {
|
|
7912
7915
|
constructor(config) {
|
7913
7916
|
if (config.privateKey) {
|
7914
7917
|
const signer = new Signer(config.privateKey);
|
7915
|
-
this.publicKey = (0,
|
7916
|
-
this.privateKey = (0,
|
7918
|
+
this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
|
7919
|
+
this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
|
7917
7920
|
} else {
|
7918
7921
|
if (!config.publicKey) {
|
7919
7922
|
throw new import_errors19.FuelError(
|
@@ -7921,10 +7924,10 @@ var HDWallet = class {
|
|
7921
7924
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7922
7925
|
);
|
7923
7926
|
}
|
7924
|
-
this.publicKey = (0,
|
7927
|
+
this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
|
7925
7928
|
}
|
7926
7929
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7927
|
-
this.fingerprint = (0,
|
7930
|
+
this.fingerprint = (0, import_ethers5.dataSlice)((0, import_ethers5.ripemd160)((0, import_ethers5.sha256)(this.publicKey)), 0, 4);
|
7928
7931
|
this.depth = config.depth || this.depth;
|
7929
7932
|
this.index = config.index || this.index;
|
7930
7933
|
this.chainCode = config.chainCode;
|
@@ -7940,9 +7943,9 @@ var HDWallet = class {
|
|
7940
7943
|
* @returns A new instance of HDWallet on the derived index
|
7941
7944
|
*/
|
7942
7945
|
deriveIndex(index) {
|
7943
|
-
const privateKey = this.privateKey && (0,
|
7944
|
-
const publicKey = (0,
|
7945
|
-
const chainCode = (0,
|
7946
|
+
const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
|
7947
|
+
const publicKey = (0, import_utils34.arrayify)(this.publicKey);
|
7948
|
+
const chainCode = (0, import_utils34.arrayify)(this.chainCode);
|
7946
7949
|
const data = new Uint8Array(37);
|
7947
7950
|
if (index & HARDENED_INDEX) {
|
7948
7951
|
if (!privateKey) {
|
@@ -7953,10 +7956,10 @@ var HDWallet = class {
|
|
7953
7956
|
}
|
7954
7957
|
data.set(privateKey, 1);
|
7955
7958
|
} else {
|
7956
|
-
data.set((0,
|
7959
|
+
data.set((0, import_utils34.arrayify)(this.publicKey));
|
7957
7960
|
}
|
7958
7961
|
data.set((0, import_math19.toBytes)(index, 4), 33);
|
7959
|
-
const bytes = (0,
|
7962
|
+
const bytes = (0, import_utils34.arrayify)((0, import_ethers5.computeHmac)("sha512", chainCode, data));
|
7960
7963
|
const IL = bytes.slice(0, 32);
|
7961
7964
|
const IR = bytes.slice(32);
|
7962
7965
|
if (privateKey) {
|
@@ -7970,7 +7973,7 @@ var HDWallet = class {
|
|
7970
7973
|
parentFingerprint: this.fingerprint
|
7971
7974
|
});
|
7972
7975
|
}
|
7973
|
-
const signer = new Signer((0,
|
7976
|
+
const signer = new Signer((0, import_utils34.hexlify)(IL));
|
7974
7977
|
const Ki = signer.addPoint(publicKey);
|
7975
7978
|
return new HDWallet({
|
7976
7979
|
publicKey: Ki,
|
@@ -8005,14 +8008,12 @@ var HDWallet = class {
|
|
8005
8008
|
);
|
8006
8009
|
}
|
8007
8010
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8008
|
-
const depth = (0,
|
8011
|
+
const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
|
8009
8012
|
const parentFingerprint = this.parentFingerprint;
|
8010
8013
|
const index = (0, import_math19.toHex)(this.index, 4);
|
8011
8014
|
const chainCode = this.chainCode;
|
8012
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8013
|
-
const extendedKey = (0,
|
8014
|
-
(0, import_ethers26.concat)([prefix, depth, parentFingerprint, index, chainCode, key])
|
8015
|
-
);
|
8015
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8016
|
+
const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8016
8017
|
return base58check(extendedKey);
|
8017
8018
|
}
|
8018
8019
|
/**
|
@@ -8024,13 +8025,13 @@ var HDWallet = class {
|
|
8024
8025
|
static fromSeed(seed) {
|
8025
8026
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8026
8027
|
return new HDWallet({
|
8027
|
-
chainCode: (0,
|
8028
|
-
privateKey: (0,
|
8028
|
+
chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
|
8029
|
+
privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
|
8029
8030
|
});
|
8030
8031
|
}
|
8031
8032
|
static fromExtendedKey(extendedKey) {
|
8032
|
-
const decoded = (0,
|
8033
|
-
const bytes = (0,
|
8033
|
+
const decoded = (0, import_ethers5.toBeHex)((0, import_ethers5.decodeBase58)(extendedKey));
|
8034
|
+
const bytes = (0, import_utils34.arrayify)(decoded);
|
8034
8035
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8035
8036
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8036
8037
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8039,9 +8040,9 @@ var HDWallet = class {
|
|
8039
8040
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8040
8041
|
}
|
8041
8042
|
const depth = bytes[4];
|
8042
|
-
const parentFingerprint = (0,
|
8043
|
-
const index = parseInt((0,
|
8044
|
-
const chainCode = (0,
|
8043
|
+
const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
|
8044
|
+
const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8045
|
+
const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
|
8045
8046
|
const key = bytes.slice(45, 78);
|
8046
8047
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8047
8048
|
throw new import_errors19.FuelError(
|
@@ -8647,19 +8648,18 @@ var import_address10 = require("@fuel-ts/address");
|
|
8647
8648
|
var import_configs11 = require("@fuel-ts/address/configs");
|
8648
8649
|
var import_errors24 = require("@fuel-ts/errors");
|
8649
8650
|
var import_transactions19 = require("@fuel-ts/transactions");
|
8650
|
-
var
|
8651
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8651
8652
|
|
8652
8653
|
// src/predicate/utils/getPredicateRoot.ts
|
8653
8654
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8654
8655
|
var import_merkle = require("@fuel-ts/merkle");
|
8655
|
-
var
|
8656
|
-
var import_ethers27 = require("ethers");
|
8656
|
+
var import_utils35 = require("@fuel-ts/utils");
|
8657
8657
|
var getPredicateRoot = (bytecode) => {
|
8658
8658
|
const chunkSize = 16 * 1024;
|
8659
|
-
const bytes = (0,
|
8660
|
-
const chunks = (0,
|
8661
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
8662
|
-
const predicateRoot = (0, import_hasher4.hash)((0,
|
8659
|
+
const bytes = (0, import_utils35.arrayify)(bytecode);
|
8660
|
+
const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
|
8661
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
|
8662
|
+
const predicateRoot = (0, import_hasher4.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
|
8663
8663
|
return predicateRoot;
|
8664
8664
|
};
|
8665
8665
|
|
@@ -8698,7 +8698,7 @@ var Predicate = class extends Account {
|
|
8698
8698
|
const request = transactionRequestify(transactionRequestLike);
|
8699
8699
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8700
8700
|
request.inputs?.forEach((input) => {
|
8701
|
-
if (input.type === import_transactions19.InputType.Coin && (0,
|
8701
|
+
if (input.type === import_transactions19.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
|
8702
8702
|
input.predicate = this.bytes;
|
8703
8703
|
input.predicateData = this.getPredicateData(policies.length);
|
8704
8704
|
}
|
@@ -8769,7 +8769,7 @@ var Predicate = class extends Account {
|
|
8769
8769
|
* @returns An object containing the new predicate bytes and interface.
|
8770
8770
|
*/
|
8771
8771
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
8772
|
-
let predicateBytes = (0,
|
8772
|
+
let predicateBytes = (0, import_utils36.arrayify)(bytes);
|
8773
8773
|
let abiInterface;
|
8774
8774
|
if (jsonAbi) {
|
8775
8775
|
abiInterface = new import_abi_coder5.Interface(jsonAbi);
|