@fuel-ts/account 0.0.0-rc-1356-20240520140225 → 0.0.0-rc-2143-20240520152005
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 +9 -7
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +125 -115
- 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 +3 -10
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +122 -465
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +169 -407
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +67 -301
- 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 -29
- package/dist/test-utils/test-message.d.ts.map +0 -1
- package/dist/test-utils/wallet-config.d.ts +0 -55
- 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_math20 = 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_math17 = 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
|
|
@@ -1864,6 +1865,15 @@ function normalizeJSON(root) {
|
|
1864
1865
|
return normalize((0, import_ramda.clone)(root));
|
1865
1866
|
}
|
1866
1867
|
|
1868
|
+
// src/providers/utils/sleep.ts
|
1869
|
+
function sleep(time) {
|
1870
|
+
return new Promise((resolve) => {
|
1871
|
+
setTimeout(() => {
|
1872
|
+
resolve(true);
|
1873
|
+
}, time);
|
1874
|
+
});
|
1875
|
+
}
|
1876
|
+
|
1867
1877
|
// src/providers/utils/extract-tx-error.ts
|
1868
1878
|
var import_errors7 = require("@fuel-ts/errors");
|
1869
1879
|
var import_math6 = require("@fuel-ts/math");
|
@@ -3881,7 +3891,6 @@ var TransactionResponse = class {
|
|
3881
3891
|
};
|
3882
3892
|
|
3883
3893
|
// src/providers/utils/auto-retry-fetch.ts
|
3884
|
-
var import_utils22 = require("@fuel-ts/utils");
|
3885
3894
|
function getWaitDelay(options, retryAttemptNum) {
|
3886
3895
|
const duration = options.baseDelay ?? 150;
|
3887
3896
|
switch (options.backoff) {
|
@@ -3911,7 +3920,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3911
3920
|
throw error;
|
3912
3921
|
}
|
3913
3922
|
const delay = getWaitDelay(options, retryNum);
|
3914
|
-
await
|
3923
|
+
await sleep(delay);
|
3915
3924
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3916
3925
|
}
|
3917
3926
|
};
|
@@ -4251,7 +4260,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4251
4260
|
if (estimateTxDependencies) {
|
4252
4261
|
await this.estimateTxDependencies(transactionRequest);
|
4253
4262
|
}
|
4254
|
-
const encodedTransaction = (0,
|
4263
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4255
4264
|
let abis;
|
4256
4265
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4257
4266
|
abis = transactionRequest.abis;
|
@@ -4294,7 +4303,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4294
4303
|
if (estimateTxDependencies) {
|
4295
4304
|
return this.estimateTxDependencies(transactionRequest);
|
4296
4305
|
}
|
4297
|
-
const encodedTransaction = (0,
|
4306
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4298
4307
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4299
4308
|
encodedTransactions: encodedTransaction,
|
4300
4309
|
utxoValidation: utxoValidation || false
|
@@ -4312,13 +4321,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4312
4321
|
async estimatePredicates(transactionRequest) {
|
4313
4322
|
const shouldEstimatePredicates = Boolean(
|
4314
4323
|
transactionRequest.inputs.find(
|
4315
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4324
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
|
4316
4325
|
)
|
4317
4326
|
);
|
4318
4327
|
if (!shouldEstimatePredicates) {
|
4319
4328
|
return transactionRequest;
|
4320
4329
|
}
|
4321
|
-
const encodedTransaction = (0,
|
4330
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4322
4331
|
const response = await this.operations.estimatePredicates({
|
4323
4332
|
encodedTransaction
|
4324
4333
|
});
|
@@ -4360,7 +4369,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4360
4369
|
const {
|
4361
4370
|
dryRun: [{ receipts: rawReceipts, status }]
|
4362
4371
|
} = await this.operations.dryRun({
|
4363
|
-
encodedTransactions: [(0,
|
4372
|
+
encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
|
4364
4373
|
utxoValidation: false
|
4365
4374
|
});
|
4366
4375
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4410,7 +4419,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4410
4419
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4411
4420
|
allRequests.forEach((req, index) => {
|
4412
4421
|
if (req.type === import_transactions20.TransactionType.Script) {
|
4413
|
-
serializedTransactionsMap.set(index, (0,
|
4422
|
+
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4414
4423
|
}
|
4415
4424
|
});
|
4416
4425
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4446,7 +4455,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4446
4455
|
transactionRequest: request
|
4447
4456
|
});
|
4448
4457
|
request.maxFee = maxFee;
|
4449
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
4458
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
|
4450
4459
|
nextRoundTransactions.push(requestIdx);
|
4451
4460
|
}
|
4452
4461
|
}
|
@@ -4459,7 +4468,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4459
4468
|
if (estimateTxDependencies) {
|
4460
4469
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4461
4470
|
}
|
4462
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
4471
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
|
4463
4472
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4464
4473
|
encodedTransactions,
|
4465
4474
|
utxoValidation: utxoValidation || false
|
@@ -4532,7 +4541,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4532
4541
|
if (estimateTxDependencies) {
|
4533
4542
|
return this.estimateTxDependencies(transactionRequest);
|
4534
4543
|
}
|
4535
|
-
const encodedTransactions = [(0,
|
4544
|
+
const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
|
4536
4545
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4537
4546
|
encodedTransactions,
|
4538
4547
|
utxoValidation: true
|
@@ -4651,7 +4660,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4651
4660
|
const result = await this.operations.getCoins({
|
4652
4661
|
first: 10,
|
4653
4662
|
...paginationArgs,
|
4654
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4663
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4655
4664
|
});
|
4656
4665
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4657
4666
|
return coins.map((coin) => ({
|
@@ -4674,19 +4683,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4674
4683
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4675
4684
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4676
4685
|
const excludeInput = {
|
4677
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4678
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4686
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4687
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4679
4688
|
};
|
4680
4689
|
if (this.cache) {
|
4681
4690
|
const uniqueUtxos = new Set(
|
4682
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4691
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4683
4692
|
);
|
4684
4693
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4685
4694
|
}
|
4686
4695
|
const coinsQuery = {
|
4687
4696
|
owner: ownerAddress.toB256(),
|
4688
4697
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4689
|
-
assetId: (0,
|
4698
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4690
4699
|
amount: amount.toString(10),
|
4691
4700
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4692
4701
|
})),
|
@@ -4788,7 +4797,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4788
4797
|
time: block.header.time,
|
4789
4798
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4790
4799
|
transactions: block.transactions.map(
|
4791
|
-
(tx) => new import_transactions20.TransactionCoder().decode((0,
|
4800
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4792
4801
|
)
|
4793
4802
|
};
|
4794
4803
|
}
|
@@ -4804,7 +4813,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4804
4813
|
return null;
|
4805
4814
|
}
|
4806
4815
|
return new import_transactions20.TransactionCoder().decode(
|
4807
|
-
(0,
|
4816
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4808
4817
|
0
|
4809
4818
|
)?.[0];
|
4810
4819
|
}
|
@@ -4831,7 +4840,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4831
4840
|
async getContractBalance(contractId, assetId) {
|
4832
4841
|
const { contractBalance } = await this.operations.getContractBalance({
|
4833
4842
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4834
|
-
asset: (0,
|
4843
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4835
4844
|
});
|
4836
4845
|
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4837
4846
|
}
|
@@ -4845,7 +4854,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4845
4854
|
async getBalance(owner, assetId) {
|
4846
4855
|
const { balance } = await this.operations.getBalance({
|
4847
4856
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4848
|
-
assetId: (0,
|
4857
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4849
4858
|
});
|
4850
4859
|
return (0, import_math17.bn)(balance.amount, 10);
|
4851
4860
|
}
|
@@ -5022,7 +5031,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5022
5031
|
async produceBlocks(amount, startTime) {
|
5023
5032
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5024
5033
|
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
5025
|
-
startTimestamp: startTime ?
|
5034
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5026
5035
|
});
|
5027
5036
|
return (0, import_math17.bn)(latestBlockHeight);
|
5028
5037
|
}
|
@@ -5088,7 +5097,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
5088
5097
|
var import_errors15 = require("@fuel-ts/errors");
|
5089
5098
|
var import_math18 = require("@fuel-ts/math");
|
5090
5099
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5091
|
-
var
|
5100
|
+
var import_utils25 = require("@fuel-ts/utils");
|
5092
5101
|
async function getTransactionSummary(params) {
|
5093
5102
|
const { id, provider, abiMap } = params;
|
5094
5103
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -5101,7 +5110,7 @@ async function getTransactionSummary(params) {
|
|
5101
5110
|
);
|
5102
5111
|
}
|
5103
5112
|
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
|
5104
|
-
(0,
|
5113
|
+
(0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5105
5114
|
0
|
5106
5115
|
);
|
5107
5116
|
let txReceipts = [];
|
@@ -5121,7 +5130,7 @@ async function getTransactionSummary(params) {
|
|
5121
5130
|
id: gqlTransaction.id,
|
5122
5131
|
receipts,
|
5123
5132
|
transaction: decodedTransaction,
|
5124
|
-
transactionBytes: (0,
|
5133
|
+
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5125
5134
|
gqlTransactionStatus: gqlTransaction.status,
|
5126
5135
|
gasPerByte: (0, import_math18.bn)(gasPerByte),
|
5127
5136
|
gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
|
@@ -5173,7 +5182,7 @@ async function getTransactionsSummaries(params) {
|
|
5173
5182
|
const transactions = edges.map((edge) => {
|
5174
5183
|
const { node: gqlTransaction } = edge;
|
5175
5184
|
const { id, rawPayload, status } = gqlTransaction;
|
5176
|
-
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0,
|
5185
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
|
5177
5186
|
let txReceipts = [];
|
5178
5187
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5179
5188
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5183,7 +5192,7 @@ async function getTransactionsSummaries(params) {
|
|
5183
5192
|
id,
|
5184
5193
|
receipts,
|
5185
5194
|
transaction: decodedTransaction,
|
5186
|
-
transactionBytes: (0,
|
5195
|
+
transactionBytes: (0, import_utils25.arrayify)(rawPayload),
|
5187
5196
|
gqlTransactionStatus: status,
|
5188
5197
|
abiMap,
|
5189
5198
|
gasPerByte,
|
@@ -5333,16 +5342,16 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
5333
5342
|
// src/utils/formatTransferToContractScriptData.ts
|
5334
5343
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5335
5344
|
var import_math19 = require("@fuel-ts/math");
|
5336
|
-
var
|
5345
|
+
var import_utils27 = require("@fuel-ts/utils");
|
5337
5346
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5338
5347
|
var formatTransferToContractScriptData = (params) => {
|
5339
5348
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5340
5349
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5341
5350
|
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
5342
5351
|
const scriptData = Uint8Array.from([
|
5343
|
-
...(0,
|
5352
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
5344
5353
|
...encoded,
|
5345
|
-
...(0,
|
5354
|
+
...(0, import_utils27.arrayify)(assetId)
|
5346
5355
|
]);
|
5347
5356
|
return scriptData;
|
5348
5357
|
};
|
@@ -5713,14 +5722,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5713
5722
|
*/
|
5714
5723
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5715
5724
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5716
|
-
const recipientDataArray = (0,
|
5725
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5717
5726
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5718
5727
|
);
|
5719
|
-
const amountDataArray = (0,
|
5728
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5720
5729
|
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5721
5730
|
);
|
5722
5731
|
const script = new Uint8Array([
|
5723
|
-
...(0,
|
5732
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5724
5733
|
...recipientDataArray,
|
5725
5734
|
...amountDataArray
|
5726
5735
|
]);
|
@@ -5800,7 +5809,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5800
5809
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5801
5810
|
}) {
|
5802
5811
|
const request = transactionRequestify(transactionRequest);
|
5803
|
-
if (!(0,
|
5812
|
+
if (!(0, import_utils28.isDefined)(setGasLimit)) {
|
5804
5813
|
request.gasLimit = gasUsed;
|
5805
5814
|
} else if (gasUsed.gt(setGasLimit)) {
|
5806
5815
|
throw new import_errors16.FuelError(
|
@@ -5808,7 +5817,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5808
5817
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5809
5818
|
);
|
5810
5819
|
}
|
5811
|
-
if (!(0,
|
5820
|
+
if (!(0, import_utils28.isDefined)(setMaxFee)) {
|
5812
5821
|
request.maxFee = maxFee;
|
5813
5822
|
} else if (maxFee.gt(setMaxFee)) {
|
5814
5823
|
throw new import_errors16.FuelError(
|
@@ -5822,14 +5831,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5822
5831
|
|
5823
5832
|
// src/wallet/base-wallet-unlocked.ts
|
5824
5833
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5825
|
-
var
|
5834
|
+
var import_utils31 = require("@fuel-ts/utils");
|
5826
5835
|
|
5827
5836
|
// src/signer/signer.ts
|
5828
5837
|
var import_address5 = require("@fuel-ts/address");
|
5829
5838
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5830
5839
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5831
5840
|
var import_math21 = require("@fuel-ts/math");
|
5832
|
-
var
|
5841
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5833
5842
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5834
5843
|
var Signer = class {
|
5835
5844
|
address;
|
@@ -5849,9 +5858,9 @@ var Signer = class {
|
|
5849
5858
|
}
|
5850
5859
|
}
|
5851
5860
|
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5852
|
-
this.privateKey = (0,
|
5853
|
-
this.publicKey = (0,
|
5854
|
-
this.compressedPublicKey = (0,
|
5861
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5862
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5863
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5855
5864
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5856
5865
|
}
|
5857
5866
|
/**
|
@@ -5865,11 +5874,11 @@ var Signer = class {
|
|
5865
5874
|
* @returns hashed signature
|
5866
5875
|
*/
|
5867
5876
|
sign(data) {
|
5868
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5877
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5869
5878
|
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5870
5879
|
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5871
5880
|
s[0] |= (signature.recovery || 0) << 7;
|
5872
|
-
return (0,
|
5881
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5873
5882
|
}
|
5874
5883
|
/**
|
5875
5884
|
* Add point on the current elliptic curve
|
@@ -5878,8 +5887,8 @@ var Signer = class {
|
|
5878
5887
|
* @returns compressed point on the curve
|
5879
5888
|
*/
|
5880
5889
|
addPoint(point) {
|
5881
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5882
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5890
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5891
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5883
5892
|
const result = p0.add(p1);
|
5884
5893
|
return `0x${result.toHex(true)}`;
|
5885
5894
|
}
|
@@ -5891,16 +5900,16 @@ var Signer = class {
|
|
5891
5900
|
* @returns public key from signature from the
|
5892
5901
|
*/
|
5893
5902
|
static recoverPublicKey(data, signature) {
|
5894
|
-
const signedMessageBytes = (0,
|
5903
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5895
5904
|
const r = signedMessageBytes.slice(0, 32);
|
5896
5905
|
const s = signedMessageBytes.slice(32, 64);
|
5897
5906
|
const recoveryParam = (s[0] & 128) >> 7;
|
5898
5907
|
s[0] &= 127;
|
5899
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5908
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5900
5909
|
recoveryParam
|
5901
5910
|
);
|
5902
|
-
const publicKey = sig.recoverPublicKey((0,
|
5903
|
-
return (0,
|
5911
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5912
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5904
5913
|
}
|
5905
5914
|
/**
|
5906
5915
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5919,7 +5928,7 @@ var Signer = class {
|
|
5919
5928
|
* @returns random 32-byte hashed
|
5920
5929
|
*/
|
5921
5930
|
static generatePrivateKey(entropy) {
|
5922
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5931
|
+
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);
|
5923
5932
|
}
|
5924
5933
|
/**
|
5925
5934
|
* Extended publicKey from a compact publicKey
|
@@ -5928,8 +5937,8 @@ var Signer = class {
|
|
5928
5937
|
* @returns extended publicKey
|
5929
5938
|
*/
|
5930
5939
|
static extendPublicKey(publicKey) {
|
5931
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5932
|
-
return (0,
|
5940
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5941
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5933
5942
|
}
|
5934
5943
|
};
|
5935
5944
|
|
@@ -5937,7 +5946,7 @@ var Signer = class {
|
|
5937
5946
|
var import_address6 = require("@fuel-ts/address");
|
5938
5947
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5939
5948
|
var import_errors17 = require("@fuel-ts/errors");
|
5940
|
-
var
|
5949
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5941
5950
|
var import_uuid = require("uuid");
|
5942
5951
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5943
5952
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6020,7 +6029,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6020
6029
|
);
|
6021
6030
|
}
|
6022
6031
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6023
|
-
const privateKey = (0,
|
6032
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
6024
6033
|
return privateKey;
|
6025
6034
|
}
|
6026
6035
|
|
@@ -6065,7 +6074,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6065
6074
|
*/
|
6066
6075
|
async signMessage(message) {
|
6067
6076
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
6068
|
-
return (0,
|
6077
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
6069
6078
|
}
|
6070
6079
|
/**
|
6071
6080
|
* Signs a transaction with the wallet's private key.
|
@@ -6078,7 +6087,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6078
6087
|
const chainId = this.provider.getChainId();
|
6079
6088
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6080
6089
|
const signature = await this.signer().sign(hashedTransaction);
|
6081
|
-
return (0,
|
6090
|
+
return (0, import_utils31.hexlify)(signature);
|
6082
6091
|
}
|
6083
6092
|
/**
|
6084
6093
|
* Populates a transaction with the witnesses signature.
|
@@ -6141,13 +6150,13 @@ var import_crypto5 = require("@fuel-ts/crypto");
|
|
6141
6150
|
var import_errors20 = require("@fuel-ts/errors");
|
6142
6151
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6143
6152
|
var import_math22 = require("@fuel-ts/math");
|
6144
|
-
var
|
6153
|
+
var import_utils35 = require("@fuel-ts/utils");
|
6145
6154
|
|
6146
6155
|
// src/mnemonic/mnemonic.ts
|
6147
6156
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6148
6157
|
var import_errors19 = require("@fuel-ts/errors");
|
6149
6158
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6150
|
-
var
|
6159
|
+
var import_utils33 = require("@fuel-ts/utils");
|
6151
6160
|
|
6152
6161
|
// src/wordlists/words/english.ts
|
6153
6162
|
var english = [
|
@@ -8210,7 +8219,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8210
8219
|
// src/mnemonic/utils.ts
|
8211
8220
|
var import_errors18 = require("@fuel-ts/errors");
|
8212
8221
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8213
|
-
var
|
8222
|
+
var import_utils32 = require("@fuel-ts/utils");
|
8214
8223
|
function getLowerMask(bits) {
|
8215
8224
|
return (1 << bits) - 1;
|
8216
8225
|
}
|
@@ -8245,14 +8254,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
8245
8254
|
}
|
8246
8255
|
}
|
8247
8256
|
const checksumBits = entropy.length / 4;
|
8248
|
-
const checksum = (0,
|
8257
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8249
8258
|
indices[indices.length - 1] <<= checksumBits;
|
8250
8259
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8251
8260
|
return indices;
|
8252
8261
|
}
|
8253
8262
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8254
8263
|
const size = Math.ceil(11 * words.length / 8);
|
8255
|
-
const entropy = (0,
|
8264
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
8256
8265
|
let offset = 0;
|
8257
8266
|
for (let i = 0; i < words.length; i += 1) {
|
8258
8267
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -8272,7 +8281,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8272
8281
|
const entropyBits = 32 * words.length / 3;
|
8273
8282
|
const checksumBits = words.length / 3;
|
8274
8283
|
const checksumMask = getUpperMask(checksumBits);
|
8275
|
-
const checksum = (0,
|
8284
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8276
8285
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8277
8286
|
throw new import_errors18.FuelError(
|
8278
8287
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -8283,7 +8292,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8283
8292
|
}
|
8284
8293
|
|
8285
8294
|
// src/mnemonic/mnemonic.ts
|
8286
|
-
var MasterSecret = (0,
|
8295
|
+
var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
|
8287
8296
|
var MainnetPRV = "0x0488ade4";
|
8288
8297
|
var TestnetPRV = "0x04358394";
|
8289
8298
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -8347,7 +8356,7 @@ var Mnemonic = class {
|
|
8347
8356
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8348
8357
|
const words = getWords(phrase);
|
8349
8358
|
assertMnemonic(words);
|
8350
|
-
return (0,
|
8359
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8351
8360
|
}
|
8352
8361
|
/**
|
8353
8362
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8355,7 +8364,7 @@ var Mnemonic = class {
|
|
8355
8364
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8356
8365
|
*/
|
8357
8366
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8358
|
-
const entropyBytes = (0,
|
8367
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
8359
8368
|
assertWordList(wordlist);
|
8360
8369
|
assertEntropy(entropyBytes);
|
8361
8370
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8367,8 +8376,8 @@ var Mnemonic = class {
|
|
8367
8376
|
*/
|
8368
8377
|
static mnemonicToSeed(phrase, passphrase = "") {
|
8369
8378
|
assertMnemonic(getWords(phrase));
|
8370
|
-
const phraseBytes = (0,
|
8371
|
-
const salt = (0,
|
8379
|
+
const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
|
8380
|
+
const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
|
8372
8381
|
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8373
8382
|
}
|
8374
8383
|
/**
|
@@ -8424,14 +8433,14 @@ var Mnemonic = class {
|
|
8424
8433
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8425
8434
|
*/
|
8426
8435
|
static masterKeysFromSeed(seed) {
|
8427
|
-
const seedArray = (0,
|
8436
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
8428
8437
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8429
8438
|
throw new import_errors19.FuelError(
|
8430
8439
|
import_errors19.ErrorCode.INVALID_SEED,
|
8431
8440
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8432
8441
|
);
|
8433
8442
|
}
|
8434
|
-
return (0,
|
8443
|
+
return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
8435
8444
|
}
|
8436
8445
|
/**
|
8437
8446
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8442,22 +8451,22 @@ var Mnemonic = class {
|
|
8442
8451
|
*/
|
8443
8452
|
static seedToExtendedKey(seed, testnet = false) {
|
8444
8453
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8445
|
-
const prefix = (0,
|
8454
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8446
8455
|
const depth = "0x00";
|
8447
8456
|
const fingerprint = "0x00000000";
|
8448
8457
|
const index = "0x00000000";
|
8449
8458
|
const chainCode = masterKey.slice(32);
|
8450
8459
|
const privateKey = masterKey.slice(0, 32);
|
8451
|
-
const extendedKey = (0,
|
8460
|
+
const extendedKey = (0, import_utils33.concat)([
|
8452
8461
|
prefix,
|
8453
8462
|
depth,
|
8454
8463
|
fingerprint,
|
8455
8464
|
index,
|
8456
8465
|
chainCode,
|
8457
|
-
(0,
|
8466
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
8458
8467
|
]);
|
8459
|
-
const checksum = (0,
|
8460
|
-
return (0,
|
8468
|
+
const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8469
|
+
return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
8461
8470
|
}
|
8462
8471
|
/**
|
8463
8472
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8472,7 +8481,7 @@ var Mnemonic = class {
|
|
8472
8481
|
* @returns A randomly generated mnemonic
|
8473
8482
|
*/
|
8474
8483
|
static generate(size = 32, extraEntropy = "") {
|
8475
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8484
|
+
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);
|
8476
8485
|
return Mnemonic.entropyToMnemonic(entropy);
|
8477
8486
|
}
|
8478
8487
|
};
|
@@ -8480,12 +8489,12 @@ var mnemonic_default = Mnemonic;
|
|
8480
8489
|
|
8481
8490
|
// src/hdwallet/hdwallet.ts
|
8482
8491
|
var HARDENED_INDEX = 2147483648;
|
8483
|
-
var MainnetPRV2 = (0,
|
8484
|
-
var MainnetPUB = (0,
|
8485
|
-
var TestnetPRV2 = (0,
|
8486
|
-
var TestnetPUB = (0,
|
8492
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8493
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8494
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8495
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8487
8496
|
function base58check(data) {
|
8488
|
-
return (0,
|
8497
|
+
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)]));
|
8489
8498
|
}
|
8490
8499
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8491
8500
|
if (isPublic) {
|
@@ -8494,11 +8503,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8494
8503
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8495
8504
|
}
|
8496
8505
|
function isPublicExtendedKey(extendedKey) {
|
8497
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8506
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
8498
8507
|
}
|
8499
8508
|
function isValidExtendedKey(extendedKey) {
|
8500
8509
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8501
|
-
(0,
|
8510
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
8502
8511
|
);
|
8503
8512
|
}
|
8504
8513
|
function parsePath(path, depth = 0) {
|
@@ -8516,8 +8525,8 @@ function parsePath(path, depth = 0) {
|
|
8516
8525
|
var HDWallet = class {
|
8517
8526
|
depth = 0;
|
8518
8527
|
index = 0;
|
8519
|
-
fingerprint = (0,
|
8520
|
-
parentFingerprint = (0,
|
8528
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8529
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8521
8530
|
privateKey;
|
8522
8531
|
publicKey;
|
8523
8532
|
chainCode;
|
@@ -8529,8 +8538,8 @@ var HDWallet = class {
|
|
8529
8538
|
constructor(config) {
|
8530
8539
|
if (config.privateKey) {
|
8531
8540
|
const signer = new Signer(config.privateKey);
|
8532
|
-
this.publicKey = (0,
|
8533
|
-
this.privateKey = (0,
|
8541
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8542
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
8534
8543
|
} else {
|
8535
8544
|
if (!config.publicKey) {
|
8536
8545
|
throw new import_errors20.FuelError(
|
@@ -8538,10 +8547,10 @@ var HDWallet = class {
|
|
8538
8547
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8539
8548
|
);
|
8540
8549
|
}
|
8541
|
-
this.publicKey = (0,
|
8550
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8542
8551
|
}
|
8543
8552
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8544
|
-
this.fingerprint = (0,
|
8553
|
+
this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8545
8554
|
this.depth = config.depth || this.depth;
|
8546
8555
|
this.index = config.index || this.index;
|
8547
8556
|
this.chainCode = config.chainCode;
|
@@ -8557,9 +8566,9 @@ var HDWallet = class {
|
|
8557
8566
|
* @returns A new instance of HDWallet on the derived index
|
8558
8567
|
*/
|
8559
8568
|
deriveIndex(index) {
|
8560
|
-
const privateKey = this.privateKey && (0,
|
8561
|
-
const publicKey = (0,
|
8562
|
-
const chainCode = (0,
|
8569
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8570
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8571
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8563
8572
|
const data = new Uint8Array(37);
|
8564
8573
|
if (index & HARDENED_INDEX) {
|
8565
8574
|
if (!privateKey) {
|
@@ -8570,10 +8579,10 @@ var HDWallet = class {
|
|
8570
8579
|
}
|
8571
8580
|
data.set(privateKey, 1);
|
8572
8581
|
} else {
|
8573
|
-
data.set((0,
|
8582
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8574
8583
|
}
|
8575
8584
|
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8576
|
-
const bytes = (0,
|
8585
|
+
const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8577
8586
|
const IL = bytes.slice(0, 32);
|
8578
8587
|
const IR = bytes.slice(32);
|
8579
8588
|
if (privateKey) {
|
@@ -8587,7 +8596,7 @@ var HDWallet = class {
|
|
8587
8596
|
parentFingerprint: this.fingerprint
|
8588
8597
|
});
|
8589
8598
|
}
|
8590
|
-
const signer = new Signer((0,
|
8599
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8591
8600
|
const Ki = signer.addPoint(publicKey);
|
8592
8601
|
return new HDWallet({
|
8593
8602
|
publicKey: Ki,
|
@@ -8622,12 +8631,12 @@ var HDWallet = class {
|
|
8622
8631
|
);
|
8623
8632
|
}
|
8624
8633
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8625
|
-
const depth = (0,
|
8634
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8626
8635
|
const parentFingerprint = this.parentFingerprint;
|
8627
8636
|
const index = (0, import_math22.toHex)(this.index, 4);
|
8628
8637
|
const chainCode = this.chainCode;
|
8629
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8630
|
-
const extendedKey = (0,
|
8638
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8639
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8631
8640
|
return base58check(extendedKey);
|
8632
8641
|
}
|
8633
8642
|
/**
|
@@ -8639,13 +8648,13 @@ var HDWallet = class {
|
|
8639
8648
|
static fromSeed(seed) {
|
8640
8649
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8641
8650
|
return new HDWallet({
|
8642
|
-
chainCode: (0,
|
8643
|
-
privateKey: (0,
|
8651
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8652
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8644
8653
|
});
|
8645
8654
|
}
|
8646
8655
|
static fromExtendedKey(extendedKey) {
|
8647
|
-
const decoded = (0,
|
8648
|
-
const bytes = (0,
|
8656
|
+
const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
|
8657
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8649
8658
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8650
8659
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8651
8660
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8654,9 +8663,9 @@ var HDWallet = class {
|
|
8654
8663
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8655
8664
|
}
|
8656
8665
|
const depth = bytes[4];
|
8657
|
-
const parentFingerprint = (0,
|
8658
|
-
const index = parseInt((0,
|
8659
|
-
const chainCode = (0,
|
8666
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8667
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8668
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8660
8669
|
const key = bytes.slice(45, 78);
|
8661
8670
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8662
8671
|
throw new import_errors20.FuelError(
|
@@ -9260,18 +9269,18 @@ var StorageAbstract = class {
|
|
9260
9269
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
9261
9270
|
var import_address10 = require("@fuel-ts/address");
|
9262
9271
|
var import_errors25 = require("@fuel-ts/errors");
|
9263
|
-
var
|
9272
|
+
var import_utils37 = require("@fuel-ts/utils");
|
9264
9273
|
|
9265
9274
|
// src/predicate/utils/getPredicateRoot.ts
|
9266
9275
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9267
9276
|
var import_merkle = require("@fuel-ts/merkle");
|
9268
|
-
var
|
9277
|
+
var import_utils36 = require("@fuel-ts/utils");
|
9269
9278
|
var getPredicateRoot = (bytecode) => {
|
9270
9279
|
const chunkSize = 16 * 1024;
|
9271
|
-
const bytes = (0,
|
9272
|
-
const chunks = (0,
|
9273
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
9274
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9280
|
+
const bytes = (0, import_utils36.arrayify)(bytecode);
|
9281
|
+
const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
|
9282
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
|
9283
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
|
9275
9284
|
return predicateRoot;
|
9276
9285
|
};
|
9277
9286
|
|
@@ -9323,8 +9332,8 @@ var Predicate = class extends Account {
|
|
9323
9332
|
}
|
9324
9333
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9325
9334
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9326
|
-
input.predicate = (0,
|
9327
|
-
input.predicateData = (0,
|
9335
|
+
input.predicate = (0, import_utils37.hexlify)(this.bytes);
|
9336
|
+
input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData());
|
9328
9337
|
input.witnessIndex = 0;
|
9329
9338
|
}
|
9330
9339
|
});
|
@@ -9366,7 +9375,7 @@ var Predicate = class extends Account {
|
|
9366
9375
|
* @returns An object containing the new predicate bytes and interface.
|
9367
9376
|
*/
|
9368
9377
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9369
|
-
let predicateBytes = (0,
|
9378
|
+
let predicateBytes = (0, import_utils37.arrayify)(bytes);
|
9370
9379
|
let abiInterface;
|
9371
9380
|
if (jsonAbi) {
|
9372
9381
|
abiInterface = new import_abi_coder7.Interface(jsonAbi);
|
@@ -9404,7 +9413,7 @@ var Predicate = class extends Account {
|
|
9404
9413
|
);
|
9405
9414
|
return resources.map((resource) => ({
|
9406
9415
|
...resource,
|
9407
|
-
predicate: (0,
|
9416
|
+
predicate: (0, import_utils37.hexlify)(this.bytes)
|
9408
9417
|
}));
|
9409
9418
|
}
|
9410
9419
|
/**
|
@@ -10269,6 +10278,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10269
10278
|
resolveGasDependentCosts,
|
10270
10279
|
resolveIconPaths,
|
10271
10280
|
returnZeroScript,
|
10281
|
+
sleep,
|
10272
10282
|
transactionRequestify,
|
10273
10283
|
urlJoin,
|
10274
10284
|
withTimeout,
|