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