@fuel-ts/account 0.0.0-rc-2037-20240510180649 → 0.0.0-rc-1356-20240513141855
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/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +1287 -1545
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +118 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -16
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +0 -1
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils/asset-id.d.ts +8 -0
- package/dist/test-utils/asset-id.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +4 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +8 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +33 -0
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -0
- package/dist/test-utils/test-message.d.ts +28 -0
- package/dist/test-utils/test-message.d.ts.map +1 -0
- package/dist/test-utils/wallet-config.d.ts +49 -0
- package/dist/test-utils/wallet-config.d.ts.map +1 -0
- package/dist/test-utils.global.js +1648 -1584
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +400 -172
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +295 -71
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/providers/utils/sleep.d.ts +0 -3
- package/dist/providers/utils/sleep.d.ts.map +0 -1
package/dist/index.js
CHANGED
@@ -186,7 +186,6 @@ __export(src_exports, {
|
|
186
186
|
resolveGasDependentCosts: () => resolveGasDependentCosts,
|
187
187
|
resolveIconPaths: () => resolveIconPaths,
|
188
188
|
returnZeroScript: () => returnZeroScript,
|
189
|
-
sleep: () => sleep,
|
190
189
|
transactionRequestify: () => transactionRequestify,
|
191
190
|
urlJoin: () => urlJoin,
|
192
191
|
withTimeout: () => withTimeout,
|
@@ -199,7 +198,7 @@ var import_address4 = require("@fuel-ts/address");
|
|
199
198
|
var import_errors16 = require("@fuel-ts/errors");
|
200
199
|
var import_interfaces = require("@fuel-ts/interfaces");
|
201
200
|
var import_math21 = require("@fuel-ts/math");
|
202
|
-
var
|
201
|
+
var import_utils29 = require("@fuel-ts/utils");
|
203
202
|
var import_ramda4 = require("ramda");
|
204
203
|
|
205
204
|
// src/providers/coin-quantity.ts
|
@@ -242,9 +241,9 @@ var import_address3 = require("@fuel-ts/address");
|
|
242
241
|
var import_errors14 = require("@fuel-ts/errors");
|
243
242
|
var import_math18 = require("@fuel-ts/math");
|
244
243
|
var import_transactions20 = require("@fuel-ts/transactions");
|
245
|
-
var
|
244
|
+
var import_utils23 = require("@fuel-ts/utils");
|
246
245
|
var import_versions = require("@fuel-ts/versions");
|
247
|
-
var
|
246
|
+
var import_utils24 = require("@noble/curves/abstract/utils");
|
248
247
|
var import_graphql_request = require("graphql-request");
|
249
248
|
var import_ramda3 = require("ramda");
|
250
249
|
|
@@ -1863,15 +1862,6 @@ function normalizeJSON(root) {
|
|
1863
1862
|
return normalize((0, import_ramda.clone)(root));
|
1864
1863
|
}
|
1865
1864
|
|
1866
|
-
// src/providers/utils/sleep.ts
|
1867
|
-
function sleep(time) {
|
1868
|
-
return new Promise((resolve) => {
|
1869
|
-
setTimeout(() => {
|
1870
|
-
resolve(true);
|
1871
|
-
}, time);
|
1872
|
-
});
|
1873
|
-
}
|
1874
|
-
|
1875
1865
|
// src/providers/utils/extract-tx-error.ts
|
1876
1866
|
var import_errors7 = require("@fuel-ts/errors");
|
1877
1867
|
var import_math6 = require("@fuel-ts/math");
|
@@ -3912,6 +3902,7 @@ var TransactionResponse = class {
|
|
3912
3902
|
};
|
3913
3903
|
|
3914
3904
|
// src/providers/utils/auto-retry-fetch.ts
|
3905
|
+
var import_utils22 = require("@fuel-ts/utils");
|
3915
3906
|
function getWaitDelay(options, retryAttemptNum) {
|
3916
3907
|
const duration = options.baseDelay ?? 150;
|
3917
3908
|
switch (options.backoff) {
|
@@ -3941,7 +3932,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3941
3932
|
throw error;
|
3942
3933
|
}
|
3943
3934
|
const delay = getWaitDelay(options, retryNum);
|
3944
|
-
await sleep(delay);
|
3935
|
+
await (0, import_utils22.sleep)(delay);
|
3945
3936
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3946
3937
|
}
|
3947
3938
|
};
|
@@ -4281,7 +4272,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4281
4272
|
if (estimateTxDependencies) {
|
4282
4273
|
await this.estimateTxDependencies(transactionRequest);
|
4283
4274
|
}
|
4284
|
-
const encodedTransaction = (0,
|
4275
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4285
4276
|
let abis;
|
4286
4277
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4287
4278
|
abis = transactionRequest.abis;
|
@@ -4324,7 +4315,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4324
4315
|
if (estimateTxDependencies) {
|
4325
4316
|
return this.estimateTxDependencies(transactionRequest);
|
4326
4317
|
}
|
4327
|
-
const encodedTransaction = (0,
|
4318
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4328
4319
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4329
4320
|
encodedTransactions: encodedTransaction,
|
4330
4321
|
utxoValidation: utxoValidation || false
|
@@ -4342,13 +4333,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4342
4333
|
async estimatePredicates(transactionRequest) {
|
4343
4334
|
const shouldEstimatePredicates = Boolean(
|
4344
4335
|
transactionRequest.inputs.find(
|
4345
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4336
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math18.BN(input.predicateGasUsed).isZero()
|
4346
4337
|
)
|
4347
4338
|
);
|
4348
4339
|
if (!shouldEstimatePredicates) {
|
4349
4340
|
return transactionRequest;
|
4350
4341
|
}
|
4351
|
-
const encodedTransaction = (0,
|
4342
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4352
4343
|
const response = await this.operations.estimatePredicates({
|
4353
4344
|
encodedTransaction
|
4354
4345
|
});
|
@@ -4390,7 +4381,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4390
4381
|
const {
|
4391
4382
|
dryRun: [{ receipts: rawReceipts, status }]
|
4392
4383
|
} = await this.operations.dryRun({
|
4393
|
-
encodedTransactions: [(0,
|
4384
|
+
encodedTransactions: [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())],
|
4394
4385
|
utxoValidation: false
|
4395
4386
|
});
|
4396
4387
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4440,7 +4431,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4440
4431
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4441
4432
|
allRequests.forEach((req, index) => {
|
4442
4433
|
if (req.type === import_transactions20.TransactionType.Script) {
|
4443
|
-
serializedTransactionsMap.set(index, (0,
|
4434
|
+
serializedTransactionsMap.set(index, (0, import_utils23.hexlify)(req.toTransactionBytes()));
|
4444
4435
|
}
|
4445
4436
|
});
|
4446
4437
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4476,7 +4467,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4476
4467
|
transactionRequest: request
|
4477
4468
|
});
|
4478
4469
|
request.maxFee = maxFee;
|
4479
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
4470
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils23.hexlify)(request.toTransactionBytes()));
|
4480
4471
|
nextRoundTransactions.push(requestIdx);
|
4481
4472
|
}
|
4482
4473
|
}
|
@@ -4489,7 +4480,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4489
4480
|
if (estimateTxDependencies) {
|
4490
4481
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4491
4482
|
}
|
4492
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
4483
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils23.hexlify)(tx.toTransactionBytes()));
|
4493
4484
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4494
4485
|
encodedTransactions,
|
4495
4486
|
utxoValidation: utxoValidation || false
|
@@ -4562,7 +4553,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4562
4553
|
if (estimateTxDependencies) {
|
4563
4554
|
return this.estimateTxDependencies(transactionRequest);
|
4564
4555
|
}
|
4565
|
-
const encodedTransactions = [(0,
|
4556
|
+
const encodedTransactions = [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())];
|
4566
4557
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4567
4558
|
encodedTransactions,
|
4568
4559
|
utxoValidation: true
|
@@ -4678,7 +4669,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4678
4669
|
const result = await this.operations.getCoins({
|
4679
4670
|
first: 10,
|
4680
4671
|
...paginationArgs,
|
4681
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4672
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
4682
4673
|
});
|
4683
4674
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4684
4675
|
return coins.map((coin) => ({
|
@@ -4701,19 +4692,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4701
4692
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4702
4693
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4703
4694
|
const excludeInput = {
|
4704
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4705
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4695
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
|
4696
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
|
4706
4697
|
};
|
4707
4698
|
if (this.cache) {
|
4708
4699
|
const uniqueUtxos = new Set(
|
4709
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4700
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
|
4710
4701
|
);
|
4711
4702
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4712
4703
|
}
|
4713
4704
|
const coinsQuery = {
|
4714
4705
|
owner: ownerAddress.toB256(),
|
4715
4706
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4716
|
-
assetId: (0,
|
4707
|
+
assetId: (0, import_utils23.hexlify)(assetId),
|
4717
4708
|
amount: amount.toString(10),
|
4718
4709
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4719
4710
|
})),
|
@@ -4815,7 +4806,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4815
4806
|
time: block.header.time,
|
4816
4807
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4817
4808
|
transactions: block.transactions.map(
|
4818
|
-
(tx) => new import_transactions20.TransactionCoder().decode((0,
|
4809
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
|
4819
4810
|
)
|
4820
4811
|
};
|
4821
4812
|
}
|
@@ -4831,7 +4822,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4831
4822
|
return null;
|
4832
4823
|
}
|
4833
4824
|
return new import_transactions20.TransactionCoder().decode(
|
4834
|
-
(0,
|
4825
|
+
(0, import_utils23.arrayify)(transaction.rawPayload),
|
4835
4826
|
0
|
4836
4827
|
)?.[0];
|
4837
4828
|
}
|
@@ -4858,7 +4849,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4858
4849
|
async getContractBalance(contractId, assetId) {
|
4859
4850
|
const { contractBalance } = await this.operations.getContractBalance({
|
4860
4851
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4861
|
-
asset: (0,
|
4852
|
+
asset: (0, import_utils23.hexlify)(assetId)
|
4862
4853
|
});
|
4863
4854
|
return (0, import_math18.bn)(contractBalance.amount, 10);
|
4864
4855
|
}
|
@@ -4872,7 +4863,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4872
4863
|
async getBalance(owner, assetId) {
|
4873
4864
|
const { balance } = await this.operations.getBalance({
|
4874
4865
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4875
|
-
assetId: (0,
|
4866
|
+
assetId: (0, import_utils23.hexlify)(assetId)
|
4876
4867
|
});
|
4877
4868
|
return (0, import_math18.bn)(balance.amount, 10);
|
4878
4869
|
}
|
@@ -5049,7 +5040,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5049
5040
|
async produceBlocks(amount, startTime) {
|
5050
5041
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5051
5042
|
blocksToProduce: (0, import_math18.bn)(amount).toString(10),
|
5052
|
-
startTimestamp: startTime ?
|
5043
|
+
startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5053
5044
|
});
|
5054
5045
|
return (0, import_math18.bn)(latestBlockHeight);
|
5055
5046
|
}
|
@@ -5099,7 +5090,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
5099
5090
|
var import_errors15 = require("@fuel-ts/errors");
|
5100
5091
|
var import_math19 = require("@fuel-ts/math");
|
5101
5092
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5102
|
-
var
|
5093
|
+
var import_utils26 = require("@fuel-ts/utils");
|
5103
5094
|
async function getTransactionSummary(params) {
|
5104
5095
|
const { id, provider, abiMap } = params;
|
5105
5096
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -5112,7 +5103,7 @@ async function getTransactionSummary(params) {
|
|
5112
5103
|
);
|
5113
5104
|
}
|
5114
5105
|
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
|
5115
|
-
(0,
|
5106
|
+
(0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
5116
5107
|
0
|
5117
5108
|
);
|
5118
5109
|
let txReceipts = [];
|
@@ -5132,7 +5123,7 @@ async function getTransactionSummary(params) {
|
|
5132
5123
|
id: gqlTransaction.id,
|
5133
5124
|
receipts,
|
5134
5125
|
transaction: decodedTransaction,
|
5135
|
-
transactionBytes: (0,
|
5126
|
+
transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
5136
5127
|
gqlTransactionStatus: gqlTransaction.status,
|
5137
5128
|
gasPerByte: (0, import_math19.bn)(gasPerByte),
|
5138
5129
|
gasPriceFactor: (0, import_math19.bn)(gasPriceFactor),
|
@@ -5184,7 +5175,7 @@ async function getTransactionsSummaries(params) {
|
|
5184
5175
|
const transactions = edges.map((edge) => {
|
5185
5176
|
const { node: gqlTransaction } = edge;
|
5186
5177
|
const { id, rawPayload, status } = gqlTransaction;
|
5187
|
-
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0,
|
5178
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
|
5188
5179
|
let txReceipts = [];
|
5189
5180
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5190
5181
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5194,7 +5185,7 @@ async function getTransactionsSummaries(params) {
|
|
5194
5185
|
id,
|
5195
5186
|
receipts,
|
5196
5187
|
transaction: decodedTransaction,
|
5197
|
-
transactionBytes: (0,
|
5188
|
+
transactionBytes: (0, import_utils26.arrayify)(rawPayload),
|
5198
5189
|
gqlTransactionStatus: status,
|
5199
5190
|
abiMap,
|
5200
5191
|
gasPerByte,
|
@@ -5344,16 +5335,16 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
5344
5335
|
// src/utils/formatTransferToContractScriptData.ts
|
5345
5336
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5346
5337
|
var import_math20 = require("@fuel-ts/math");
|
5347
|
-
var
|
5338
|
+
var import_utils28 = require("@fuel-ts/utils");
|
5348
5339
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5349
5340
|
var formatTransferToContractScriptData = (params) => {
|
5350
5341
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5351
5342
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5352
5343
|
const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
|
5353
5344
|
const scriptData = Uint8Array.from([
|
5354
|
-
...(0,
|
5345
|
+
...(0, import_utils28.arrayify)(hexlifiedContractId),
|
5355
5346
|
...encoded,
|
5356
|
-
...(0,
|
5347
|
+
...(0, import_utils28.arrayify)(assetId)
|
5357
5348
|
]);
|
5358
5349
|
return scriptData;
|
5359
5350
|
};
|
@@ -5726,14 +5717,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5726
5717
|
*/
|
5727
5718
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5728
5719
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5729
|
-
const recipientDataArray = (0,
|
5720
|
+
const recipientDataArray = (0, import_utils29.arrayify)(
|
5730
5721
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5731
5722
|
);
|
5732
|
-
const amountDataArray = (0,
|
5723
|
+
const amountDataArray = (0, import_utils29.arrayify)(
|
5733
5724
|
"0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5734
5725
|
);
|
5735
5726
|
const script = new Uint8Array([
|
5736
|
-
...(0,
|
5727
|
+
...(0, import_utils29.arrayify)(withdrawScript.bytes),
|
5737
5728
|
...recipientDataArray,
|
5738
5729
|
...amountDataArray
|
5739
5730
|
]);
|
@@ -5813,7 +5804,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5813
5804
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5814
5805
|
}) {
|
5815
5806
|
const request = transactionRequestify(transactionRequest);
|
5816
|
-
if (!(0,
|
5807
|
+
if (!(0, import_utils29.isDefined)(setGasLimit)) {
|
5817
5808
|
request.gasLimit = gasUsed;
|
5818
5809
|
} else if (gasUsed.gt(setGasLimit)) {
|
5819
5810
|
throw new import_errors16.FuelError(
|
@@ -5821,7 +5812,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5821
5812
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5822
5813
|
);
|
5823
5814
|
}
|
5824
|
-
if (!(0,
|
5815
|
+
if (!(0, import_utils29.isDefined)(setMaxFee)) {
|
5825
5816
|
request.maxFee = maxFee;
|
5826
5817
|
} else if (maxFee.gt(setMaxFee)) {
|
5827
5818
|
throw new import_errors16.FuelError(
|
@@ -5835,14 +5826,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5835
5826
|
|
5836
5827
|
// src/wallet/base-wallet-unlocked.ts
|
5837
5828
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5838
|
-
var
|
5829
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5839
5830
|
|
5840
5831
|
// src/signer/signer.ts
|
5841
5832
|
var import_address5 = require("@fuel-ts/address");
|
5842
5833
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5843
5834
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5844
5835
|
var import_math22 = require("@fuel-ts/math");
|
5845
|
-
var
|
5836
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5846
5837
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5847
5838
|
var Signer = class {
|
5848
5839
|
address;
|
@@ -5862,9 +5853,9 @@ var Signer = class {
|
|
5862
5853
|
}
|
5863
5854
|
}
|
5864
5855
|
const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
|
5865
|
-
this.privateKey = (0,
|
5866
|
-
this.publicKey = (0,
|
5867
|
-
this.compressedPublicKey = (0,
|
5856
|
+
this.privateKey = (0, import_utils30.hexlify)(privateKeyBytes);
|
5857
|
+
this.publicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5858
|
+
this.compressedPublicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5868
5859
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5869
5860
|
}
|
5870
5861
|
/**
|
@@ -5878,11 +5869,11 @@ var Signer = class {
|
|
5878
5869
|
* @returns hashed signature
|
5879
5870
|
*/
|
5880
5871
|
sign(data) {
|
5881
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5872
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils30.arrayify)(data), (0, import_utils30.arrayify)(this.privateKey));
|
5882
5873
|
const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5883
5874
|
const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5884
5875
|
s[0] |= (signature.recovery || 0) << 7;
|
5885
|
-
return (0,
|
5876
|
+
return (0, import_utils30.hexlify)((0, import_utils30.concat)([r, s]));
|
5886
5877
|
}
|
5887
5878
|
/**
|
5888
5879
|
* Add point on the current elliptic curve
|
@@ -5891,8 +5882,8 @@ var Signer = class {
|
|
5891
5882
|
* @returns compressed point on the curve
|
5892
5883
|
*/
|
5893
5884
|
addPoint(point) {
|
5894
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5895
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5885
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(this.compressedPublicKey));
|
5886
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(point));
|
5896
5887
|
const result = p0.add(p1);
|
5897
5888
|
return `0x${result.toHex(true)}`;
|
5898
5889
|
}
|
@@ -5904,16 +5895,16 @@ var Signer = class {
|
|
5904
5895
|
* @returns public key from signature from the
|
5905
5896
|
*/
|
5906
5897
|
static recoverPublicKey(data, signature) {
|
5907
|
-
const signedMessageBytes = (0,
|
5898
|
+
const signedMessageBytes = (0, import_utils30.arrayify)(signature);
|
5908
5899
|
const r = signedMessageBytes.slice(0, 32);
|
5909
5900
|
const s = signedMessageBytes.slice(32, 64);
|
5910
5901
|
const recoveryParam = (s[0] & 128) >> 7;
|
5911
5902
|
s[0] &= 127;
|
5912
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5903
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils30.hexlify)(r)), BigInt((0, import_utils30.hexlify)(s))).addRecoveryBit(
|
5913
5904
|
recoveryParam
|
5914
5905
|
);
|
5915
|
-
const publicKey = sig.recoverPublicKey((0,
|
5916
|
-
return (0,
|
5906
|
+
const publicKey = sig.recoverPublicKey((0, import_utils30.arrayify)(data)).toRawBytes(false).slice(1);
|
5907
|
+
return (0, import_utils30.hexlify)(publicKey);
|
5917
5908
|
}
|
5918
5909
|
/**
|
5919
5910
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5932,7 +5923,7 @@ var Signer = class {
|
|
5932
5923
|
* @returns random 32-byte hashed
|
5933
5924
|
*/
|
5934
5925
|
static generatePrivateKey(entropy) {
|
5935
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5926
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils30.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils30.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
|
5936
5927
|
}
|
5937
5928
|
/**
|
5938
5929
|
* Extended publicKey from a compact publicKey
|
@@ -5941,8 +5932,8 @@ var Signer = class {
|
|
5941
5932
|
* @returns extended publicKey
|
5942
5933
|
*/
|
5943
5934
|
static extendPublicKey(publicKey) {
|
5944
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5945
|
-
return (0,
|
5935
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(publicKey));
|
5936
|
+
return (0, import_utils30.hexlify)(point.toRawBytes(false).slice(1));
|
5946
5937
|
}
|
5947
5938
|
};
|
5948
5939
|
|
@@ -5950,7 +5941,7 @@ var Signer = class {
|
|
5950
5941
|
var import_address6 = require("@fuel-ts/address");
|
5951
5942
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5952
5943
|
var import_errors17 = require("@fuel-ts/errors");
|
5953
|
-
var
|
5944
|
+
var import_utils31 = require("@fuel-ts/utils");
|
5954
5945
|
var import_uuid = require("uuid");
|
5955
5946
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5956
5947
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6033,7 +6024,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6033
6024
|
);
|
6034
6025
|
}
|
6035
6026
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6036
|
-
const privateKey = (0,
|
6027
|
+
const privateKey = (0, import_utils31.hexlify)(buffer);
|
6037
6028
|
return privateKey;
|
6038
6029
|
}
|
6039
6030
|
|
@@ -6078,7 +6069,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6078
6069
|
*/
|
6079
6070
|
async signMessage(message) {
|
6080
6071
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
6081
|
-
return (0,
|
6072
|
+
return (0, import_utils32.hexlify)(signedMessage);
|
6082
6073
|
}
|
6083
6074
|
/**
|
6084
6075
|
* Signs a transaction with the wallet's private key.
|
@@ -6091,7 +6082,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6091
6082
|
const chainId = this.provider.getChainId();
|
6092
6083
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6093
6084
|
const signature = await this.signer().sign(hashedTransaction);
|
6094
|
-
return (0,
|
6085
|
+
return (0, import_utils32.hexlify)(signature);
|
6095
6086
|
}
|
6096
6087
|
/**
|
6097
6088
|
* Populates a transaction with the witnesses signature.
|
@@ -6150,18 +6141,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
6150
6141
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
6151
6142
|
|
6152
6143
|
// src/hdwallet/hdwallet.ts
|
6144
|
+
var import_crypto5 = require("@fuel-ts/crypto");
|
6153
6145
|
var import_errors20 = require("@fuel-ts/errors");
|
6154
6146
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6155
6147
|
var import_math23 = require("@fuel-ts/math");
|
6156
|
-
var
|
6157
|
-
var import_ethers2 = require("ethers");
|
6148
|
+
var import_utils36 = require("@fuel-ts/utils");
|
6158
6149
|
|
6159
6150
|
// src/mnemonic/mnemonic.ts
|
6160
6151
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6161
6152
|
var import_errors19 = require("@fuel-ts/errors");
|
6162
6153
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6163
|
-
var
|
6164
|
-
var import_ethers = require("ethers");
|
6154
|
+
var import_utils34 = require("@fuel-ts/utils");
|
6165
6155
|
|
6166
6156
|
// src/wordlists/words/english.ts
|
6167
6157
|
var english = [
|
@@ -8224,7 +8214,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8224
8214
|
// src/mnemonic/utils.ts
|
8225
8215
|
var import_errors18 = require("@fuel-ts/errors");
|
8226
8216
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8227
|
-
var
|
8217
|
+
var import_utils33 = require("@fuel-ts/utils");
|
8228
8218
|
function toUtf8Bytes(stri) {
|
8229
8219
|
const str = stri.normalize("NFKD");
|
8230
8220
|
const result = [];
|
@@ -8291,14 +8281,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
8291
8281
|
}
|
8292
8282
|
}
|
8293
8283
|
const checksumBits = entropy.length / 4;
|
8294
|
-
const checksum = (0,
|
8284
|
+
const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8295
8285
|
indices[indices.length - 1] <<= checksumBits;
|
8296
8286
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8297
8287
|
return indices;
|
8298
8288
|
}
|
8299
8289
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8300
8290
|
const size = Math.ceil(11 * words.length / 8);
|
8301
|
-
const entropy = (0,
|
8291
|
+
const entropy = (0, import_utils33.arrayify)(new Uint8Array(size));
|
8302
8292
|
let offset = 0;
|
8303
8293
|
for (let i = 0; i < words.length; i += 1) {
|
8304
8294
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -8318,7 +8308,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8318
8308
|
const entropyBits = 32 * words.length / 3;
|
8319
8309
|
const checksumBits = words.length / 3;
|
8320
8310
|
const checksumMask = getUpperMask(checksumBits);
|
8321
|
-
const checksum = (0,
|
8311
|
+
const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8322
8312
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8323
8313
|
throw new import_errors18.FuelError(
|
8324
8314
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -8393,7 +8383,7 @@ var Mnemonic = class {
|
|
8393
8383
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8394
8384
|
const words = getWords(phrase);
|
8395
8385
|
assertMnemonic(words);
|
8396
|
-
return (0,
|
8386
|
+
return (0, import_utils34.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8397
8387
|
}
|
8398
8388
|
/**
|
8399
8389
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8401,7 +8391,7 @@ var Mnemonic = class {
|
|
8401
8391
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8402
8392
|
*/
|
8403
8393
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8404
|
-
const entropyBytes = (0,
|
8394
|
+
const entropyBytes = (0, import_utils34.arrayify)(entropy);
|
8405
8395
|
assertWordList(wordlist);
|
8406
8396
|
assertEntropy(entropyBytes);
|
8407
8397
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8415,7 +8405,7 @@ var Mnemonic = class {
|
|
8415
8405
|
assertMnemonic(getWords(phrase));
|
8416
8406
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
8417
8407
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
8418
|
-
return (0,
|
8408
|
+
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8419
8409
|
}
|
8420
8410
|
/**
|
8421
8411
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -8470,14 +8460,14 @@ var Mnemonic = class {
|
|
8470
8460
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8471
8461
|
*/
|
8472
8462
|
static masterKeysFromSeed(seed) {
|
8473
|
-
const seedArray = (0,
|
8463
|
+
const seedArray = (0, import_utils34.arrayify)(seed);
|
8474
8464
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8475
8465
|
throw new import_errors19.FuelError(
|
8476
8466
|
import_errors19.ErrorCode.INVALID_SEED,
|
8477
8467
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8478
8468
|
);
|
8479
8469
|
}
|
8480
|
-
return (0,
|
8470
|
+
return (0, import_utils34.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
8481
8471
|
}
|
8482
8472
|
/**
|
8483
8473
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8488,22 +8478,22 @@ var Mnemonic = class {
|
|
8488
8478
|
*/
|
8489
8479
|
static seedToExtendedKey(seed, testnet = false) {
|
8490
8480
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8491
|
-
const prefix = (0,
|
8481
|
+
const prefix = (0, import_utils34.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8492
8482
|
const depth = "0x00";
|
8493
8483
|
const fingerprint = "0x00000000";
|
8494
8484
|
const index = "0x00000000";
|
8495
8485
|
const chainCode = masterKey.slice(32);
|
8496
8486
|
const privateKey = masterKey.slice(0, 32);
|
8497
|
-
const extendedKey = (0,
|
8487
|
+
const extendedKey = (0, import_utils34.concat)([
|
8498
8488
|
prefix,
|
8499
8489
|
depth,
|
8500
8490
|
fingerprint,
|
8501
8491
|
index,
|
8502
8492
|
chainCode,
|
8503
|
-
(0,
|
8493
|
+
(0, import_utils34.concat)(["0x00", privateKey])
|
8504
8494
|
]);
|
8505
|
-
const checksum = (0,
|
8506
|
-
return (0,
|
8495
|
+
const checksum = (0, import_utils34.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8496
|
+
return (0, import_utils34.encodeBase58)((0, import_utils34.concat)([extendedKey, checksum]));
|
8507
8497
|
}
|
8508
8498
|
/**
|
8509
8499
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8518,7 +8508,7 @@ var Mnemonic = class {
|
|
8518
8508
|
* @returns A randomly generated mnemonic
|
8519
8509
|
*/
|
8520
8510
|
static generate(size = 32, extraEntropy = "") {
|
8521
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8511
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils34.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils34.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
|
8522
8512
|
return Mnemonic.entropyToMnemonic(entropy);
|
8523
8513
|
}
|
8524
8514
|
};
|
@@ -8526,12 +8516,12 @@ var mnemonic_default = Mnemonic;
|
|
8526
8516
|
|
8527
8517
|
// src/hdwallet/hdwallet.ts
|
8528
8518
|
var HARDENED_INDEX = 2147483648;
|
8529
|
-
var MainnetPRV2 = (0,
|
8530
|
-
var MainnetPUB = (0,
|
8531
|
-
var TestnetPRV2 = (0,
|
8532
|
-
var TestnetPUB = (0,
|
8519
|
+
var MainnetPRV2 = (0, import_utils36.hexlify)("0x0488ade4");
|
8520
|
+
var MainnetPUB = (0, import_utils36.hexlify)("0x0488b21e");
|
8521
|
+
var TestnetPRV2 = (0, import_utils36.hexlify)("0x04358394");
|
8522
|
+
var TestnetPUB = (0, import_utils36.hexlify)("0x043587cf");
|
8533
8523
|
function base58check(data) {
|
8534
|
-
return (0,
|
8524
|
+
return (0, import_utils36.encodeBase58)((0, import_utils36.concat)([data, (0, import_utils36.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
8535
8525
|
}
|
8536
8526
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8537
8527
|
if (isPublic) {
|
@@ -8540,11 +8530,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8540
8530
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8541
8531
|
}
|
8542
8532
|
function isPublicExtendedKey(extendedKey) {
|
8543
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8533
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils36.hexlify)(extendedKey.slice(0, 4)));
|
8544
8534
|
}
|
8545
8535
|
function isValidExtendedKey(extendedKey) {
|
8546
8536
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8547
|
-
(0,
|
8537
|
+
(0, import_utils36.hexlify)(extendedKey.slice(0, 4))
|
8548
8538
|
);
|
8549
8539
|
}
|
8550
8540
|
function parsePath(path, depth = 0) {
|
@@ -8562,8 +8552,8 @@ function parsePath(path, depth = 0) {
|
|
8562
8552
|
var HDWallet = class {
|
8563
8553
|
depth = 0;
|
8564
8554
|
index = 0;
|
8565
|
-
fingerprint = (0,
|
8566
|
-
parentFingerprint = (0,
|
8555
|
+
fingerprint = (0, import_utils36.hexlify)("0x00000000");
|
8556
|
+
parentFingerprint = (0, import_utils36.hexlify)("0x00000000");
|
8567
8557
|
privateKey;
|
8568
8558
|
publicKey;
|
8569
8559
|
chainCode;
|
@@ -8575,8 +8565,8 @@ var HDWallet = class {
|
|
8575
8565
|
constructor(config) {
|
8576
8566
|
if (config.privateKey) {
|
8577
8567
|
const signer = new Signer(config.privateKey);
|
8578
|
-
this.publicKey = (0,
|
8579
|
-
this.privateKey = (0,
|
8568
|
+
this.publicKey = (0, import_utils36.hexlify)(signer.compressedPublicKey);
|
8569
|
+
this.privateKey = (0, import_utils36.hexlify)(config.privateKey);
|
8580
8570
|
} else {
|
8581
8571
|
if (!config.publicKey) {
|
8582
8572
|
throw new import_errors20.FuelError(
|
@@ -8584,10 +8574,10 @@ var HDWallet = class {
|
|
8584
8574
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8585
8575
|
);
|
8586
8576
|
}
|
8587
|
-
this.publicKey = (0,
|
8577
|
+
this.publicKey = (0, import_utils36.hexlify)(config.publicKey);
|
8588
8578
|
}
|
8589
8579
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8590
|
-
this.fingerprint = (0,
|
8580
|
+
this.fingerprint = (0, import_utils36.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8591
8581
|
this.depth = config.depth || this.depth;
|
8592
8582
|
this.index = config.index || this.index;
|
8593
8583
|
this.chainCode = config.chainCode;
|
@@ -8603,9 +8593,9 @@ var HDWallet = class {
|
|
8603
8593
|
* @returns A new instance of HDWallet on the derived index
|
8604
8594
|
*/
|
8605
8595
|
deriveIndex(index) {
|
8606
|
-
const privateKey = this.privateKey && (0,
|
8607
|
-
const publicKey = (0,
|
8608
|
-
const chainCode = (0,
|
8596
|
+
const privateKey = this.privateKey && (0, import_utils36.arrayify)(this.privateKey);
|
8597
|
+
const publicKey = (0, import_utils36.arrayify)(this.publicKey);
|
8598
|
+
const chainCode = (0, import_utils36.arrayify)(this.chainCode);
|
8609
8599
|
const data = new Uint8Array(37);
|
8610
8600
|
if (index & HARDENED_INDEX) {
|
8611
8601
|
if (!privateKey) {
|
@@ -8616,10 +8606,10 @@ var HDWallet = class {
|
|
8616
8606
|
}
|
8617
8607
|
data.set(privateKey, 1);
|
8618
8608
|
} else {
|
8619
|
-
data.set((0,
|
8609
|
+
data.set((0, import_utils36.arrayify)(this.publicKey));
|
8620
8610
|
}
|
8621
8611
|
data.set((0, import_math23.toBytes)(index, 4), 33);
|
8622
|
-
const bytes = (0,
|
8612
|
+
const bytes = (0, import_utils36.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8623
8613
|
const IL = bytes.slice(0, 32);
|
8624
8614
|
const IR = bytes.slice(32);
|
8625
8615
|
if (privateKey) {
|
@@ -8633,7 +8623,7 @@ var HDWallet = class {
|
|
8633
8623
|
parentFingerprint: this.fingerprint
|
8634
8624
|
});
|
8635
8625
|
}
|
8636
|
-
const signer = new Signer((0,
|
8626
|
+
const signer = new Signer((0, import_utils36.hexlify)(IL));
|
8637
8627
|
const Ki = signer.addPoint(publicKey);
|
8638
8628
|
return new HDWallet({
|
8639
8629
|
publicKey: Ki,
|
@@ -8668,12 +8658,12 @@ var HDWallet = class {
|
|
8668
8658
|
);
|
8669
8659
|
}
|
8670
8660
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8671
|
-
const depth = (0,
|
8661
|
+
const depth = (0, import_utils36.hexlify)(Uint8Array.from([this.depth]));
|
8672
8662
|
const parentFingerprint = this.parentFingerprint;
|
8673
8663
|
const index = (0, import_math23.toHex)(this.index, 4);
|
8674
8664
|
const chainCode = this.chainCode;
|
8675
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8676
|
-
const extendedKey = (0,
|
8665
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils36.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8666
|
+
const extendedKey = (0, import_utils36.arrayify)((0, import_utils36.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8677
8667
|
return base58check(extendedKey);
|
8678
8668
|
}
|
8679
8669
|
/**
|
@@ -8685,13 +8675,13 @@ var HDWallet = class {
|
|
8685
8675
|
static fromSeed(seed) {
|
8686
8676
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8687
8677
|
return new HDWallet({
|
8688
|
-
chainCode: (0,
|
8689
|
-
privateKey: (0,
|
8678
|
+
chainCode: (0, import_utils36.arrayify)(masterKey.slice(32)),
|
8679
|
+
privateKey: (0, import_utils36.arrayify)(masterKey.slice(0, 32))
|
8690
8680
|
});
|
8691
8681
|
}
|
8692
8682
|
static fromExtendedKey(extendedKey) {
|
8693
|
-
const decoded = (0,
|
8694
|
-
const bytes = (0,
|
8683
|
+
const decoded = (0, import_utils36.hexlify)((0, import_math23.toBytes)((0, import_utils36.decodeBase58)(extendedKey)));
|
8684
|
+
const bytes = (0, import_utils36.arrayify)(decoded);
|
8695
8685
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8696
8686
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8697
8687
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8700,9 +8690,9 @@ var HDWallet = class {
|
|
8700
8690
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8701
8691
|
}
|
8702
8692
|
const depth = bytes[4];
|
8703
|
-
const parentFingerprint = (0,
|
8704
|
-
const index = parseInt((0,
|
8705
|
-
const chainCode = (0,
|
8693
|
+
const parentFingerprint = (0, import_utils36.hexlify)(bytes.slice(5, 9));
|
8694
|
+
const index = parseInt((0, import_utils36.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8695
|
+
const chainCode = (0, import_utils36.hexlify)(bytes.slice(13, 45));
|
8706
8696
|
const key = bytes.slice(45, 78);
|
8707
8697
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8708
8698
|
throw new import_errors20.FuelError(
|
@@ -8890,7 +8880,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8890
8880
|
|
8891
8881
|
// src/wallet-manager/wallet-manager.ts
|
8892
8882
|
var import_address9 = require("@fuel-ts/address");
|
8893
|
-
var
|
8883
|
+
var import_crypto6 = require("@fuel-ts/crypto");
|
8894
8884
|
var import_errors23 = require("@fuel-ts/errors");
|
8895
8885
|
var import_events = require("events");
|
8896
8886
|
|
@@ -9218,7 +9208,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
9218
9208
|
await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
|
9219
9209
|
const data = await this.storage.getItem(this.STORAGE_KEY);
|
9220
9210
|
if (data) {
|
9221
|
-
const state = await (0,
|
9211
|
+
const state = await (0, import_crypto6.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
|
9222
9212
|
__privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
|
9223
9213
|
}
|
9224
9214
|
}
|
@@ -9227,7 +9217,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
9227
9217
|
*/
|
9228
9218
|
async saveState() {
|
9229
9219
|
await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
|
9230
|
-
const encryptedData = await (0,
|
9220
|
+
const encryptedData = await (0, import_crypto6.encrypt)(__privateGet(this, _passphrase), {
|
9231
9221
|
vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
|
9232
9222
|
});
|
9233
9223
|
await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
|
@@ -9307,18 +9297,18 @@ var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
|
9307
9297
|
var import_address10 = require("@fuel-ts/address");
|
9308
9298
|
var import_errors25 = require("@fuel-ts/errors");
|
9309
9299
|
var import_transactions22 = require("@fuel-ts/transactions");
|
9310
|
-
var
|
9300
|
+
var import_utils38 = require("@fuel-ts/utils");
|
9311
9301
|
|
9312
9302
|
// src/predicate/utils/getPredicateRoot.ts
|
9313
9303
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9314
9304
|
var import_merkle = require("@fuel-ts/merkle");
|
9315
|
-
var
|
9305
|
+
var import_utils37 = require("@fuel-ts/utils");
|
9316
9306
|
var getPredicateRoot = (bytecode) => {
|
9317
9307
|
const chunkSize = 16 * 1024;
|
9318
|
-
const bytes = (0,
|
9319
|
-
const chunks = (0,
|
9320
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
9321
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9308
|
+
const bytes = (0, import_utils37.arrayify)(bytecode);
|
9309
|
+
const chunks = (0, import_utils37.chunkAndPadBytes)(bytes, chunkSize);
|
9310
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils37.hexlify)(c)));
|
9311
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils37.concat)(["0x4655454C", codeRoot]));
|
9322
9312
|
return predicateRoot;
|
9323
9313
|
};
|
9324
9314
|
|
@@ -9371,8 +9361,8 @@ var Predicate = class extends Account {
|
|
9371
9361
|
}
|
9372
9362
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9373
9363
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9374
|
-
input.predicate = (0,
|
9375
|
-
input.predicateData = (0,
|
9364
|
+
input.predicate = (0, import_utils38.hexlify)(this.bytes);
|
9365
|
+
input.predicateData = (0, import_utils38.hexlify)(this.getPredicateData(policies.length));
|
9376
9366
|
input.witnessIndex = 0;
|
9377
9367
|
}
|
9378
9368
|
});
|
@@ -9419,7 +9409,7 @@ var Predicate = class extends Account {
|
|
9419
9409
|
* @returns An object containing the new predicate bytes and interface.
|
9420
9410
|
*/
|
9421
9411
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9422
|
-
let predicateBytes = (0,
|
9412
|
+
let predicateBytes = (0, import_utils38.arrayify)(bytes);
|
9423
9413
|
let abiInterface;
|
9424
9414
|
if (jsonAbi) {
|
9425
9415
|
abiInterface = new import_abi_coder7.Interface(jsonAbi);
|
@@ -9457,8 +9447,8 @@ var Predicate = class extends Account {
|
|
9457
9447
|
);
|
9458
9448
|
return resources.map((resource) => ({
|
9459
9449
|
...resource,
|
9460
|
-
predicate: (0,
|
9461
|
-
padPredicateData: (policiesLength) => (0,
|
9450
|
+
predicate: (0, import_utils38.hexlify)(this.bytes),
|
9451
|
+
padPredicateData: (policiesLength) => (0, import_utils38.hexlify)(this.getPredicateData(policiesLength))
|
9462
9452
|
}));
|
9463
9453
|
}
|
9464
9454
|
/**
|
@@ -10323,7 +10313,6 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10323
10313
|
resolveGasDependentCosts,
|
10324
10314
|
resolveIconPaths,
|
10325
10315
|
returnZeroScript,
|
10326
|
-
sleep,
|
10327
10316
|
transactionRequestify,
|
10328
10317
|
urlJoin,
|
10329
10318
|
withTimeout,
|