@fuel-ts/account 0.0.0-rc-2045-20240415152456 → 0.0.0-rc-1832-20240415161726
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/index.global.js +124 -142
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +75 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -62
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +1 -0
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +2 -13
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils.global.js +125 -144
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +71 -93
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +42 -64
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/test-utils.js
CHANGED
@@ -1051,7 +1051,6 @@ var MemoryCache = class {
|
|
1051
1051
|
};
|
1052
1052
|
|
1053
1053
|
// src/providers/transaction-request/input.ts
|
1054
|
-
var import_abi_coder = require("@fuel-ts/abi-coder");
|
1055
1054
|
var import_configs2 = require("@fuel-ts/address/configs");
|
1056
1055
|
var import_errors3 = require("@fuel-ts/errors");
|
1057
1056
|
var import_math2 = require("@fuel-ts/math");
|
@@ -1065,8 +1064,8 @@ var inputify = (value) => {
|
|
1065
1064
|
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1066
1065
|
return {
|
1067
1066
|
type: import_transactions.InputType.Coin,
|
1068
|
-
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0,
|
1069
|
-
outputIndex: (0,
|
1067
|
+
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
|
1068
|
+
outputIndex: (0, import_utils3.arrayify)(value.id)[32],
|
1070
1069
|
owner: (0, import_utils3.hexlify)(value.owner),
|
1071
1070
|
amount: (0, import_math2.bn)(value.amount),
|
1072
1071
|
assetId: (0, import_utils3.hexlify)(value.assetId),
|
@@ -1184,10 +1183,8 @@ var outputify = (value) => {
|
|
1184
1183
|
};
|
1185
1184
|
|
1186
1185
|
// src/providers/transaction-request/transaction-request.ts
|
1187
|
-
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
1188
1186
|
var import_address = require("@fuel-ts/address");
|
1189
1187
|
var import_configs7 = require("@fuel-ts/address/configs");
|
1190
|
-
var import_crypto = require("@fuel-ts/crypto");
|
1191
1188
|
var import_math7 = require("@fuel-ts/math");
|
1192
1189
|
var import_transactions6 = require("@fuel-ts/transactions");
|
1193
1190
|
var import_utils9 = require("@fuel-ts/utils");
|
@@ -1861,7 +1858,8 @@ var BaseTransactionRequest = class {
|
|
1861
1858
|
assetId,
|
1862
1859
|
txPointer: "0x00000000000000000000000000000000",
|
1863
1860
|
witnessIndex,
|
1864
|
-
predicate: predicate?.bytes
|
1861
|
+
predicate: predicate?.bytes,
|
1862
|
+
predicateData: predicate?.predicateDataBytes
|
1865
1863
|
};
|
1866
1864
|
this.pushInput(input);
|
1867
1865
|
this.addChangeOutput(owner, assetId);
|
@@ -1893,7 +1891,8 @@ var BaseTransactionRequest = class {
|
|
1893
1891
|
recipient: recipient.toB256(),
|
1894
1892
|
amount,
|
1895
1893
|
witnessIndex,
|
1896
|
-
predicate: predicate?.bytes
|
1894
|
+
predicate: predicate?.bytes,
|
1895
|
+
predicateData: predicate?.predicateDataBytes
|
1897
1896
|
};
|
1898
1897
|
this.pushInput(input);
|
1899
1898
|
this.addChangeOutput(recipient, assetId);
|
@@ -2048,6 +2047,12 @@ var BaseTransactionRequest = class {
|
|
2048
2047
|
* @param quantities - CoinQuantity Array.
|
2049
2048
|
*/
|
2050
2049
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
2050
|
+
let idCounter = 0;
|
2051
|
+
const generateId = () => {
|
2052
|
+
const counterString = String(idCounter++);
|
2053
|
+
const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
2054
|
+
return id;
|
2055
|
+
};
|
2051
2056
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
2052
2057
|
if ("assetId" in input) {
|
2053
2058
|
return input.assetId === assetId;
|
@@ -2057,12 +2062,12 @@ var BaseTransactionRequest = class {
|
|
2057
2062
|
const updateAssetInput = (assetId, quantity) => {
|
2058
2063
|
const assetInput = findAssetInput(assetId);
|
2059
2064
|
if (assetInput && "assetId" in assetInput) {
|
2060
|
-
assetInput.id = (
|
2065
|
+
assetInput.id = generateId();
|
2061
2066
|
assetInput.amount = quantity;
|
2062
2067
|
} else {
|
2063
2068
|
this.addResources([
|
2064
2069
|
{
|
2065
|
-
id: (
|
2070
|
+
id: generateId(),
|
2066
2071
|
amount: quantity,
|
2067
2072
|
assetId,
|
2068
2073
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
@@ -2317,7 +2322,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2317
2322
|
};
|
2318
2323
|
|
2319
2324
|
// src/providers/transaction-request/script-transaction-request.ts
|
2320
|
-
var
|
2325
|
+
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2321
2326
|
var import_address2 = require("@fuel-ts/address");
|
2322
2327
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2323
2328
|
var import_math10 = require("@fuel-ts/math");
|
@@ -2509,7 +2514,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2509
2514
|
* @returns The current instance of the `ScriptTransactionRequest`.
|
2510
2515
|
*/
|
2511
2516
|
setData(abi, args) {
|
2512
|
-
const abiInterface = new
|
2517
|
+
const abiInterface = new import_abi_coder.Interface(abi);
|
2513
2518
|
this.scriptData = abiInterface.functions.main.encodeArguments(args);
|
2514
2519
|
return this;
|
2515
2520
|
}
|
@@ -2631,17 +2636,17 @@ var import_math13 = require("@fuel-ts/math");
|
|
2631
2636
|
var import_transactions14 = require("@fuel-ts/transactions");
|
2632
2637
|
|
2633
2638
|
// src/providers/transaction-summary/call.ts
|
2634
|
-
var
|
2639
|
+
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
2635
2640
|
var import_math12 = require("@fuel-ts/math");
|
2636
2641
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2637
|
-
const abiInterface = new
|
2642
|
+
const abiInterface = new import_abi_coder2.Interface(abi);
|
2638
2643
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2639
2644
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2640
2645
|
const inputs = functionFragment.jsonFn.inputs;
|
2641
2646
|
let encodedArgs;
|
2642
2647
|
if (functionFragment.isInputDataPointer) {
|
2643
2648
|
if (rawPayload) {
|
2644
|
-
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0,
|
2649
|
+
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2645
2650
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2646
2651
|
}
|
2647
2652
|
} else {
|
@@ -3244,13 +3249,13 @@ function assembleTransactionSummary(params) {
|
|
3244
3249
|
}
|
3245
3250
|
|
3246
3251
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3247
|
-
var
|
3252
|
+
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
3248
3253
|
var import_transactions16 = require("@fuel-ts/transactions");
|
3249
3254
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3250
3255
|
return receipts.reduce((logs, receipt) => {
|
3251
3256
|
if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
|
3252
|
-
const interfaceToUse = new
|
3253
|
-
const data = receipt.type === import_transactions16.ReceiptType.Log ? new
|
3257
|
+
const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
|
3258
|
+
const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3254
3259
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3255
3260
|
logs.push(decodedLog);
|
3256
3261
|
}
|
@@ -3892,36 +3897,6 @@ var _Provider = class {
|
|
3892
3897
|
missingContractIds
|
3893
3898
|
};
|
3894
3899
|
}
|
3895
|
-
/**
|
3896
|
-
* Estimates the transaction gas and fee based on the provided transaction request.
|
3897
|
-
* @param transactionRequest - The transaction request object.
|
3898
|
-
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
3899
|
-
*/
|
3900
|
-
estimateTxGasAndFee(params) {
|
3901
|
-
const { transactionRequest } = params;
|
3902
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
3903
|
-
const chainInfo = this.getChain();
|
3904
|
-
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
3905
|
-
transactionRequest.gasPrice = gasPrice;
|
3906
|
-
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
3907
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3908
|
-
if (transactionRequest.type === import_transactions18.TransactionType.Script) {
|
3909
|
-
if (transactionRequest.gasLimit.eq(0)) {
|
3910
|
-
transactionRequest.gasLimit = minGas;
|
3911
|
-
transactionRequest.gasLimit = maxGasPerTx.sub(
|
3912
|
-
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
3913
|
-
);
|
3914
|
-
}
|
3915
|
-
}
|
3916
|
-
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
3917
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3918
|
-
return {
|
3919
|
-
minGas,
|
3920
|
-
minFee,
|
3921
|
-
maxGas,
|
3922
|
-
maxFee
|
3923
|
-
};
|
3924
|
-
}
|
3925
3900
|
/**
|
3926
3901
|
* Executes a signed transaction without applying the states changes
|
3927
3902
|
* on the chain.
|
@@ -3969,16 +3944,17 @@ var _Provider = class {
|
|
3969
3944
|
signatureCallback
|
3970
3945
|
} = {}) {
|
3971
3946
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
3972
|
-
const
|
3973
|
-
const
|
3947
|
+
const chainInfo = this.getChain();
|
3948
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
3949
|
+
const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
3974
3950
|
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
3975
3951
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3976
3952
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
3977
3953
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
3978
|
-
if (isScriptTransaction) {
|
3979
|
-
txRequestClone.gasLimit = (0, import_math15.bn)(0);
|
3980
|
-
}
|
3981
3954
|
if (estimatePredicates) {
|
3955
|
+
if (isScriptTransaction) {
|
3956
|
+
txRequestClone.gasLimit = (0, import_math15.bn)(0);
|
3957
|
+
}
|
3982
3958
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3983
3959
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3984
3960
|
}
|
@@ -3987,34 +3963,36 @@ var _Provider = class {
|
|
3987
3963
|
if (signatureCallback && isScriptTransaction) {
|
3988
3964
|
await signatureCallback(txRequestClone);
|
3989
3965
|
}
|
3990
|
-
|
3991
|
-
|
3992
|
-
});
|
3966
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
3967
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
3993
3968
|
let receipts = [];
|
3994
3969
|
let missingContractIds = [];
|
3995
3970
|
let outputVariables = 0;
|
3996
|
-
let gasUsed = (0, import_math15.bn)(0);
|
3997
3971
|
if (isScriptTransaction && estimateTxDependencies) {
|
3998
3972
|
txRequestClone.gasPrice = (0, import_math15.bn)(0);
|
3973
|
+
txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
3999
3974
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4000
3975
|
receipts = result.receipts;
|
4001
3976
|
outputVariables = result.outputVariables;
|
4002
3977
|
missingContractIds = result.missingContractIds;
|
4003
|
-
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4004
|
-
txRequestClone.gasLimit = gasUsed;
|
4005
|
-
txRequestClone.gasPrice = setGasPrice;
|
4006
|
-
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4007
|
-
transactionRequest: txRequestClone
|
4008
|
-
}));
|
4009
3978
|
}
|
3979
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
3980
|
+
const usedFee = calculatePriceWithFactor(
|
3981
|
+
gasUsed,
|
3982
|
+
gasPrice,
|
3983
|
+
gasPriceFactor
|
3984
|
+
).normalizeZeroToOne();
|
3985
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3986
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4010
3987
|
return {
|
4011
3988
|
requiredQuantities: allQuantities,
|
4012
3989
|
receipts,
|
4013
3990
|
gasUsed,
|
4014
3991
|
minGasPrice,
|
4015
|
-
gasPrice
|
3992
|
+
gasPrice,
|
4016
3993
|
minGas,
|
4017
3994
|
maxGas,
|
3995
|
+
usedFee,
|
4018
3996
|
minFee,
|
4019
3997
|
maxFee,
|
4020
3998
|
estimatedInputs: txRequestClone.inputs,
|
@@ -4481,13 +4459,13 @@ var assets = [
|
|
4481
4459
|
];
|
4482
4460
|
|
4483
4461
|
// src/utils/formatTransferToContractScriptData.ts
|
4484
|
-
var
|
4462
|
+
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4485
4463
|
var import_math17 = require("@fuel-ts/math");
|
4486
4464
|
var import_utils27 = require("@fuel-ts/utils");
|
4487
4465
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4488
4466
|
var formatTransferToContractScriptData = (params) => {
|
4489
4467
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4490
|
-
const numberCoder = new
|
4468
|
+
const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
|
4491
4469
|
const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
|
4492
4470
|
const scriptData = Uint8Array.from([
|
4493
4471
|
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
@@ -4938,7 +4916,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4938
4916
|
|
4939
4917
|
// src/signer/signer.ts
|
4940
4918
|
var import_address5 = require("@fuel-ts/address");
|
4941
|
-
var
|
4919
|
+
var import_crypto = require("@fuel-ts/crypto");
|
4942
4920
|
var import_hasher2 = require("@fuel-ts/hasher");
|
4943
4921
|
var import_math19 = require("@fuel-ts/math");
|
4944
4922
|
var import_utils29 = require("@fuel-ts/utils");
|
@@ -5031,7 +5009,7 @@ var Signer = class {
|
|
5031
5009
|
* @returns random 32-byte hashed
|
5032
5010
|
*/
|
5033
5011
|
static generatePrivateKey(entropy) {
|
5034
|
-
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0,
|
5012
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
5035
5013
|
}
|
5036
5014
|
/**
|
5037
5015
|
* Extended publicKey from a compact publicKey
|
@@ -5047,7 +5025,7 @@ var Signer = class {
|
|
5047
5025
|
|
5048
5026
|
// src/wallet/keystore-wallet.ts
|
5049
5027
|
var import_address6 = require("@fuel-ts/address");
|
5050
|
-
var
|
5028
|
+
var import_crypto2 = require("@fuel-ts/crypto");
|
5051
5029
|
var import_errors17 = require("@fuel-ts/errors");
|
5052
5030
|
var import_utils30 = require("@fuel-ts/utils");
|
5053
5031
|
var import_uuid = require("uuid");
|
@@ -5063,22 +5041,22 @@ var removeHexPrefix = (hexString) => {
|
|
5063
5041
|
return hexString;
|
5064
5042
|
};
|
5065
5043
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
5066
|
-
const privateKeyBuffer = (0,
|
5044
|
+
const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
|
5067
5045
|
const ownerAddress = import_address6.Address.fromAddressOrString(address);
|
5068
|
-
const salt = (0,
|
5069
|
-
const key = (0,
|
5070
|
-
password: (0,
|
5046
|
+
const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
|
5047
|
+
const key = (0, import_crypto2.scrypt)({
|
5048
|
+
password: (0, import_crypto2.bufferFromString)(password),
|
5071
5049
|
salt,
|
5072
5050
|
dklen: DEFAULT_KEY_SIZE,
|
5073
5051
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
5074
5052
|
r: DEFAULT_KDF_PARAMS_R,
|
5075
5053
|
p: DEFAULT_KDF_PARAMS_P
|
5076
5054
|
});
|
5077
|
-
const iv = (0,
|
5078
|
-
const ciphertext = await (0,
|
5055
|
+
const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
|
5056
|
+
const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
|
5079
5057
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
|
5080
|
-
const macHashUint8Array = (0,
|
5081
|
-
const mac = (0,
|
5058
|
+
const macHashUint8Array = (0, import_crypto2.keccak256)(data);
|
5059
|
+
const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
|
5082
5060
|
const keystore = {
|
5083
5061
|
id: (0, import_uuid.v4)(),
|
5084
5062
|
version: 3,
|
@@ -5086,15 +5064,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
5086
5064
|
crypto: {
|
5087
5065
|
cipher: "aes-128-ctr",
|
5088
5066
|
mac,
|
5089
|
-
cipherparams: { iv: (0,
|
5090
|
-
ciphertext: (0,
|
5067
|
+
cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
|
5068
|
+
ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
|
5091
5069
|
kdf: "scrypt",
|
5092
5070
|
kdfparams: {
|
5093
5071
|
dklen: DEFAULT_KEY_SIZE,
|
5094
5072
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
5095
5073
|
p: DEFAULT_KDF_PARAMS_P,
|
5096
5074
|
r: DEFAULT_KDF_PARAMS_R,
|
5097
|
-
salt: (0,
|
5075
|
+
salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
|
5098
5076
|
}
|
5099
5077
|
}
|
5100
5078
|
};
|
@@ -5110,11 +5088,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5110
5088
|
kdfparams: { dklen, n, r, p, salt }
|
5111
5089
|
}
|
5112
5090
|
} = keystoreWallet;
|
5113
|
-
const ciphertextBuffer = (0,
|
5114
|
-
const ivBuffer = (0,
|
5115
|
-
const saltBuffer = (0,
|
5116
|
-
const passwordBuffer = (0,
|
5117
|
-
const key = (0,
|
5091
|
+
const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
|
5092
|
+
const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
|
5093
|
+
const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
|
5094
|
+
const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
|
5095
|
+
const key = (0, import_crypto2.scrypt)({
|
5118
5096
|
password: passwordBuffer,
|
5119
5097
|
salt: saltBuffer,
|
5120
5098
|
n,
|
@@ -5123,15 +5101,15 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5123
5101
|
dklen
|
5124
5102
|
});
|
5125
5103
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
|
5126
|
-
const macHashUint8Array = (0,
|
5127
|
-
const macHash = (0,
|
5104
|
+
const macHashUint8Array = (0, import_crypto2.keccak256)(data);
|
5105
|
+
const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
|
5128
5106
|
if (mac !== macHash) {
|
5129
5107
|
throw new import_errors17.FuelError(
|
5130
5108
|
import_errors17.ErrorCode.INVALID_PASSWORD,
|
5131
5109
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
5132
5110
|
);
|
5133
5111
|
}
|
5134
|
-
const buffer = await (0,
|
5112
|
+
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5135
5113
|
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5136
5114
|
return privateKey;
|
5137
5115
|
}
|
@@ -5256,7 +5234,7 @@ var import_utils35 = require("@fuel-ts/utils");
|
|
5256
5234
|
var import_ethers3 = require("ethers");
|
5257
5235
|
|
5258
5236
|
// src/mnemonic/mnemonic.ts
|
5259
|
-
var
|
5237
|
+
var import_crypto3 = require("@fuel-ts/crypto");
|
5260
5238
|
var import_errors19 = require("@fuel-ts/errors");
|
5261
5239
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5262
5240
|
var import_utils33 = require("@fuel-ts/utils");
|
@@ -7611,7 +7589,7 @@ var Mnemonic = class {
|
|
7611
7589
|
* @returns A randomly generated mnemonic
|
7612
7590
|
*/
|
7613
7591
|
static generate(size = 32, extraEntropy = "") {
|
7614
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0,
|
7592
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7615
7593
|
return Mnemonic.entropyToMnemonic(entropy);
|
7616
7594
|
}
|
7617
7595
|
};
|
@@ -7982,10 +7960,10 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
|
7982
7960
|
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
7983
7961
|
|
7984
7962
|
// src/test-utils/seedTestWallet.ts
|
7985
|
-
var
|
7963
|
+
var import_crypto4 = require("@fuel-ts/crypto");
|
7986
7964
|
var seedTestWallet = async (wallet, quantities) => {
|
7987
7965
|
const genesisWallet = new WalletUnlocked(
|
7988
|
-
process.env.GENESIS_SECRET || (0,
|
7966
|
+
process.env.GENESIS_SECRET || (0, import_crypto4.randomBytes)(32),
|
7989
7967
|
wallet.provider
|
7990
7968
|
);
|
7991
7969
|
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
@@ -8014,7 +7992,7 @@ var import_math21 = require("@fuel-ts/math");
|
|
8014
7992
|
var import_utils36 = require("@fuel-ts/utils");
|
8015
7993
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
8016
7994
|
var import_child_process = require("child_process");
|
8017
|
-
var
|
7995
|
+
var import_crypto5 = require("crypto");
|
8018
7996
|
var import_fs = require("fs");
|
8019
7997
|
var import_os = __toESM(require("os"));
|
8020
7998
|
var import_path = __toESM(require("path"));
|
@@ -8086,7 +8064,7 @@ var launchNode = async ({
|
|
8086
8064
|
})).toString();
|
8087
8065
|
let chainConfigPathToUse;
|
8088
8066
|
const prefix = basePath || import_os.default.tmpdir();
|
8089
|
-
const suffix = basePath ? "" : (0,
|
8067
|
+
const suffix = basePath ? "" : (0, import_crypto5.randomUUID)();
|
8090
8068
|
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
|
8091
8069
|
if (chainConfigPath) {
|
8092
8070
|
chainConfigPathToUse = chainConfigPath;
|