@fuel-ts/account 0.0.0-rc-1356-20240515091838 → 0.0.0-rc-2143-20240515092103
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 +4 -9
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +2409 -508
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +169 -402
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +67 -296
- 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 -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
|
|
@@ -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");
|
@@ -3882,7 +3892,6 @@ var TransactionResponse = class {
|
|
3882
3892
|
};
|
3883
3893
|
|
3884
3894
|
// src/providers/utils/auto-retry-fetch.ts
|
3885
|
-
var import_utils22 = require("@fuel-ts/utils");
|
3886
3895
|
function getWaitDelay(options, retryAttemptNum) {
|
3887
3896
|
const duration = options.baseDelay ?? 150;
|
3888
3897
|
switch (options.backoff) {
|
@@ -3912,7 +3921,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3912
3921
|
throw error;
|
3913
3922
|
}
|
3914
3923
|
const delay = getWaitDelay(options, retryNum);
|
3915
|
-
await
|
3924
|
+
await sleep(delay);
|
3916
3925
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3917
3926
|
}
|
3918
3927
|
};
|
@@ -4252,7 +4261,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4252
4261
|
if (estimateTxDependencies) {
|
4253
4262
|
await this.estimateTxDependencies(transactionRequest);
|
4254
4263
|
}
|
4255
|
-
const encodedTransaction = (0,
|
4264
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4256
4265
|
let abis;
|
4257
4266
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4258
4267
|
abis = transactionRequest.abis;
|
@@ -4295,7 +4304,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4295
4304
|
if (estimateTxDependencies) {
|
4296
4305
|
return this.estimateTxDependencies(transactionRequest);
|
4297
4306
|
}
|
4298
|
-
const encodedTransaction = (0,
|
4307
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4299
4308
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4300
4309
|
encodedTransactions: encodedTransaction,
|
4301
4310
|
utxoValidation: utxoValidation || false
|
@@ -4313,13 +4322,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4313
4322
|
async estimatePredicates(transactionRequest) {
|
4314
4323
|
const shouldEstimatePredicates = Boolean(
|
4315
4324
|
transactionRequest.inputs.find(
|
4316
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4325
|
+
(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()
|
4317
4326
|
)
|
4318
4327
|
);
|
4319
4328
|
if (!shouldEstimatePredicates) {
|
4320
4329
|
return transactionRequest;
|
4321
4330
|
}
|
4322
|
-
const encodedTransaction = (0,
|
4331
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4323
4332
|
const response = await this.operations.estimatePredicates({
|
4324
4333
|
encodedTransaction
|
4325
4334
|
});
|
@@ -4361,7 +4370,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4361
4370
|
const {
|
4362
4371
|
dryRun: [{ receipts: rawReceipts, status }]
|
4363
4372
|
} = await this.operations.dryRun({
|
4364
|
-
encodedTransactions: [(0,
|
4373
|
+
encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
|
4365
4374
|
utxoValidation: false
|
4366
4375
|
});
|
4367
4376
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4411,7 +4420,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4411
4420
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4412
4421
|
allRequests.forEach((req, index) => {
|
4413
4422
|
if (req.type === import_transactions20.TransactionType.Script) {
|
4414
|
-
serializedTransactionsMap.set(index, (0,
|
4423
|
+
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4415
4424
|
}
|
4416
4425
|
});
|
4417
4426
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4447,7 +4456,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4447
4456
|
transactionRequest: request
|
4448
4457
|
});
|
4449
4458
|
request.maxFee = maxFee;
|
4450
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
4459
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
|
4451
4460
|
nextRoundTransactions.push(requestIdx);
|
4452
4461
|
}
|
4453
4462
|
}
|
@@ -4460,7 +4469,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4460
4469
|
if (estimateTxDependencies) {
|
4461
4470
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4462
4471
|
}
|
4463
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
4472
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
|
4464
4473
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4465
4474
|
encodedTransactions,
|
4466
4475
|
utxoValidation: utxoValidation || false
|
@@ -4533,7 +4542,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4533
4542
|
if (estimateTxDependencies) {
|
4534
4543
|
return this.estimateTxDependencies(transactionRequest);
|
4535
4544
|
}
|
4536
|
-
const encodedTransactions = [(0,
|
4545
|
+
const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
|
4537
4546
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4538
4547
|
encodedTransactions,
|
4539
4548
|
utxoValidation: true
|
@@ -4649,7 +4658,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4649
4658
|
const result = await this.operations.getCoins({
|
4650
4659
|
first: 10,
|
4651
4660
|
...paginationArgs,
|
4652
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4661
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4653
4662
|
});
|
4654
4663
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4655
4664
|
return coins.map((coin) => ({
|
@@ -4672,19 +4681,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4672
4681
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4673
4682
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4674
4683
|
const excludeInput = {
|
4675
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4676
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4684
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4685
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4677
4686
|
};
|
4678
4687
|
if (this.cache) {
|
4679
4688
|
const uniqueUtxos = new Set(
|
4680
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4689
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4681
4690
|
);
|
4682
4691
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4683
4692
|
}
|
4684
4693
|
const coinsQuery = {
|
4685
4694
|
owner: ownerAddress.toB256(),
|
4686
4695
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4687
|
-
assetId: (0,
|
4696
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4688
4697
|
amount: amount.toString(10),
|
4689
4698
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4690
4699
|
})),
|
@@ -4786,7 +4795,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4786
4795
|
time: block.header.time,
|
4787
4796
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4788
4797
|
transactions: block.transactions.map(
|
4789
|
-
(tx) => new import_transactions20.TransactionCoder().decode((0,
|
4798
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4790
4799
|
)
|
4791
4800
|
};
|
4792
4801
|
}
|
@@ -4802,7 +4811,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4802
4811
|
return null;
|
4803
4812
|
}
|
4804
4813
|
return new import_transactions20.TransactionCoder().decode(
|
4805
|
-
(0,
|
4814
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4806
4815
|
0
|
4807
4816
|
)?.[0];
|
4808
4817
|
}
|
@@ -4829,7 +4838,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4829
4838
|
async getContractBalance(contractId, assetId) {
|
4830
4839
|
const { contractBalance } = await this.operations.getContractBalance({
|
4831
4840
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4832
|
-
asset: (0,
|
4841
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4833
4842
|
});
|
4834
4843
|
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4835
4844
|
}
|
@@ -4843,7 +4852,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4843
4852
|
async getBalance(owner, assetId) {
|
4844
4853
|
const { balance } = await this.operations.getBalance({
|
4845
4854
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4846
|
-
assetId: (0,
|
4855
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4847
4856
|
});
|
4848
4857
|
return (0, import_math17.bn)(balance.amount, 10);
|
4849
4858
|
}
|
@@ -5020,7 +5029,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5020
5029
|
async produceBlocks(amount, startTime) {
|
5021
5030
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5022
5031
|
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
5023
|
-
startTimestamp: startTime ?
|
5032
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5024
5033
|
});
|
5025
5034
|
return (0, import_math17.bn)(latestBlockHeight);
|
5026
5035
|
}
|
@@ -5070,7 +5079,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
5070
5079
|
var import_errors15 = require("@fuel-ts/errors");
|
5071
5080
|
var import_math18 = require("@fuel-ts/math");
|
5072
5081
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5073
|
-
var
|
5082
|
+
var import_utils25 = require("@fuel-ts/utils");
|
5074
5083
|
async function getTransactionSummary(params) {
|
5075
5084
|
const { id, provider, abiMap } = params;
|
5076
5085
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -5083,7 +5092,7 @@ async function getTransactionSummary(params) {
|
|
5083
5092
|
);
|
5084
5093
|
}
|
5085
5094
|
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
|
5086
|
-
(0,
|
5095
|
+
(0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5087
5096
|
0
|
5088
5097
|
);
|
5089
5098
|
let txReceipts = [];
|
@@ -5103,7 +5112,7 @@ async function getTransactionSummary(params) {
|
|
5103
5112
|
id: gqlTransaction.id,
|
5104
5113
|
receipts,
|
5105
5114
|
transaction: decodedTransaction,
|
5106
|
-
transactionBytes: (0,
|
5115
|
+
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5107
5116
|
gqlTransactionStatus: gqlTransaction.status,
|
5108
5117
|
gasPerByte: (0, import_math18.bn)(gasPerByte),
|
5109
5118
|
gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
|
@@ -5155,7 +5164,7 @@ async function getTransactionsSummaries(params) {
|
|
5155
5164
|
const transactions = edges.map((edge) => {
|
5156
5165
|
const { node: gqlTransaction } = edge;
|
5157
5166
|
const { id, rawPayload, status } = gqlTransaction;
|
5158
|
-
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0,
|
5167
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
|
5159
5168
|
let txReceipts = [];
|
5160
5169
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5161
5170
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5165,7 +5174,7 @@ async function getTransactionsSummaries(params) {
|
|
5165
5174
|
id,
|
5166
5175
|
receipts,
|
5167
5176
|
transaction: decodedTransaction,
|
5168
|
-
transactionBytes: (0,
|
5177
|
+
transactionBytes: (0, import_utils25.arrayify)(rawPayload),
|
5169
5178
|
gqlTransactionStatus: status,
|
5170
5179
|
abiMap,
|
5171
5180
|
gasPerByte,
|
@@ -5315,16 +5324,16 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
5315
5324
|
// src/utils/formatTransferToContractScriptData.ts
|
5316
5325
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5317
5326
|
var import_math19 = require("@fuel-ts/math");
|
5318
|
-
var
|
5327
|
+
var import_utils27 = require("@fuel-ts/utils");
|
5319
5328
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5320
5329
|
var formatTransferToContractScriptData = (params) => {
|
5321
5330
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5322
5331
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5323
5332
|
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
5324
5333
|
const scriptData = Uint8Array.from([
|
5325
|
-
...(0,
|
5334
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
5326
5335
|
...encoded,
|
5327
|
-
...(0,
|
5336
|
+
...(0, import_utils27.arrayify)(assetId)
|
5328
5337
|
]);
|
5329
5338
|
return scriptData;
|
5330
5339
|
};
|
@@ -5695,14 +5704,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5695
5704
|
*/
|
5696
5705
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5697
5706
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5698
|
-
const recipientDataArray = (0,
|
5707
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5699
5708
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5700
5709
|
);
|
5701
|
-
const amountDataArray = (0,
|
5710
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5702
5711
|
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5703
5712
|
);
|
5704
5713
|
const script = new Uint8Array([
|
5705
|
-
...(0,
|
5714
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5706
5715
|
...recipientDataArray,
|
5707
5716
|
...amountDataArray
|
5708
5717
|
]);
|
@@ -5782,7 +5791,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5782
5791
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5783
5792
|
}) {
|
5784
5793
|
const request = transactionRequestify(transactionRequest);
|
5785
|
-
if (!(0,
|
5794
|
+
if (!(0, import_utils28.isDefined)(setGasLimit)) {
|
5786
5795
|
request.gasLimit = gasUsed;
|
5787
5796
|
} else if (gasUsed.gt(setGasLimit)) {
|
5788
5797
|
throw new import_errors16.FuelError(
|
@@ -5790,7 +5799,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5790
5799
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5791
5800
|
);
|
5792
5801
|
}
|
5793
|
-
if (!(0,
|
5802
|
+
if (!(0, import_utils28.isDefined)(setMaxFee)) {
|
5794
5803
|
request.maxFee = maxFee;
|
5795
5804
|
} else if (maxFee.gt(setMaxFee)) {
|
5796
5805
|
throw new import_errors16.FuelError(
|
@@ -5804,14 +5813,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5804
5813
|
|
5805
5814
|
// src/wallet/base-wallet-unlocked.ts
|
5806
5815
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5807
|
-
var
|
5816
|
+
var import_utils31 = require("@fuel-ts/utils");
|
5808
5817
|
|
5809
5818
|
// src/signer/signer.ts
|
5810
5819
|
var import_address5 = require("@fuel-ts/address");
|
5811
5820
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5812
5821
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5813
5822
|
var import_math21 = require("@fuel-ts/math");
|
5814
|
-
var
|
5823
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5815
5824
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5816
5825
|
var Signer = class {
|
5817
5826
|
address;
|
@@ -5831,9 +5840,9 @@ var Signer = class {
|
|
5831
5840
|
}
|
5832
5841
|
}
|
5833
5842
|
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5834
|
-
this.privateKey = (0,
|
5835
|
-
this.publicKey = (0,
|
5836
|
-
this.compressedPublicKey = (0,
|
5843
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5844
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5845
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5837
5846
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5838
5847
|
}
|
5839
5848
|
/**
|
@@ -5847,11 +5856,11 @@ var Signer = class {
|
|
5847
5856
|
* @returns hashed signature
|
5848
5857
|
*/
|
5849
5858
|
sign(data) {
|
5850
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5859
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5851
5860
|
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5852
5861
|
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5853
5862
|
s[0] |= (signature.recovery || 0) << 7;
|
5854
|
-
return (0,
|
5863
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5855
5864
|
}
|
5856
5865
|
/**
|
5857
5866
|
* Add point on the current elliptic curve
|
@@ -5860,8 +5869,8 @@ var Signer = class {
|
|
5860
5869
|
* @returns compressed point on the curve
|
5861
5870
|
*/
|
5862
5871
|
addPoint(point) {
|
5863
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5864
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5872
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5873
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5865
5874
|
const result = p0.add(p1);
|
5866
5875
|
return `0x${result.toHex(true)}`;
|
5867
5876
|
}
|
@@ -5873,16 +5882,16 @@ var Signer = class {
|
|
5873
5882
|
* @returns public key from signature from the
|
5874
5883
|
*/
|
5875
5884
|
static recoverPublicKey(data, signature) {
|
5876
|
-
const signedMessageBytes = (0,
|
5885
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5877
5886
|
const r = signedMessageBytes.slice(0, 32);
|
5878
5887
|
const s = signedMessageBytes.slice(32, 64);
|
5879
5888
|
const recoveryParam = (s[0] & 128) >> 7;
|
5880
5889
|
s[0] &= 127;
|
5881
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5890
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5882
5891
|
recoveryParam
|
5883
5892
|
);
|
5884
|
-
const publicKey = sig.recoverPublicKey((0,
|
5885
|
-
return (0,
|
5893
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5894
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5886
5895
|
}
|
5887
5896
|
/**
|
5888
5897
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5901,7 +5910,7 @@ var Signer = class {
|
|
5901
5910
|
* @returns random 32-byte hashed
|
5902
5911
|
*/
|
5903
5912
|
static generatePrivateKey(entropy) {
|
5904
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5913
|
+
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);
|
5905
5914
|
}
|
5906
5915
|
/**
|
5907
5916
|
* Extended publicKey from a compact publicKey
|
@@ -5910,8 +5919,8 @@ var Signer = class {
|
|
5910
5919
|
* @returns extended publicKey
|
5911
5920
|
*/
|
5912
5921
|
static extendPublicKey(publicKey) {
|
5913
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5914
|
-
return (0,
|
5922
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5923
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5915
5924
|
}
|
5916
5925
|
};
|
5917
5926
|
|
@@ -5919,7 +5928,7 @@ var Signer = class {
|
|
5919
5928
|
var import_address6 = require("@fuel-ts/address");
|
5920
5929
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5921
5930
|
var import_errors17 = require("@fuel-ts/errors");
|
5922
|
-
var
|
5931
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5923
5932
|
var import_uuid = require("uuid");
|
5924
5933
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5925
5934
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6002,7 +6011,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6002
6011
|
);
|
6003
6012
|
}
|
6004
6013
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6005
|
-
const privateKey = (0,
|
6014
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
6006
6015
|
return privateKey;
|
6007
6016
|
}
|
6008
6017
|
|
@@ -6047,7 +6056,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6047
6056
|
*/
|
6048
6057
|
async signMessage(message) {
|
6049
6058
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
6050
|
-
return (0,
|
6059
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
6051
6060
|
}
|
6052
6061
|
/**
|
6053
6062
|
* Signs a transaction with the wallet's private key.
|
@@ -6060,7 +6069,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6060
6069
|
const chainId = this.provider.getChainId();
|
6061
6070
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6062
6071
|
const signature = await this.signer().sign(hashedTransaction);
|
6063
|
-
return (0,
|
6072
|
+
return (0, import_utils31.hexlify)(signature);
|
6064
6073
|
}
|
6065
6074
|
/**
|
6066
6075
|
* Populates a transaction with the witnesses signature.
|
@@ -6123,13 +6132,13 @@ var import_crypto5 = require("@fuel-ts/crypto");
|
|
6123
6132
|
var import_errors20 = require("@fuel-ts/errors");
|
6124
6133
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6125
6134
|
var import_math22 = require("@fuel-ts/math");
|
6126
|
-
var
|
6135
|
+
var import_utils35 = require("@fuel-ts/utils");
|
6127
6136
|
|
6128
6137
|
// src/mnemonic/mnemonic.ts
|
6129
6138
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6130
6139
|
var import_errors19 = require("@fuel-ts/errors");
|
6131
6140
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6132
|
-
var
|
6141
|
+
var import_utils33 = require("@fuel-ts/utils");
|
6133
6142
|
|
6134
6143
|
// src/wordlists/words/english.ts
|
6135
6144
|
var english = [
|
@@ -8192,7 +8201,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8192
8201
|
// src/mnemonic/utils.ts
|
8193
8202
|
var import_errors18 = require("@fuel-ts/errors");
|
8194
8203
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8195
|
-
var
|
8204
|
+
var import_utils32 = require("@fuel-ts/utils");
|
8196
8205
|
function getLowerMask(bits) {
|
8197
8206
|
return (1 << bits) - 1;
|
8198
8207
|
}
|
@@ -8227,14 +8236,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
8227
8236
|
}
|
8228
8237
|
}
|
8229
8238
|
const checksumBits = entropy.length / 4;
|
8230
|
-
const checksum = (0,
|
8239
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8231
8240
|
indices[indices.length - 1] <<= checksumBits;
|
8232
8241
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8233
8242
|
return indices;
|
8234
8243
|
}
|
8235
8244
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8236
8245
|
const size = Math.ceil(11 * words.length / 8);
|
8237
|
-
const entropy = (0,
|
8246
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
8238
8247
|
let offset = 0;
|
8239
8248
|
for (let i = 0; i < words.length; i += 1) {
|
8240
8249
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -8254,7 +8263,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8254
8263
|
const entropyBits = 32 * words.length / 3;
|
8255
8264
|
const checksumBits = words.length / 3;
|
8256
8265
|
const checksumMask = getUpperMask(checksumBits);
|
8257
|
-
const checksum = (0,
|
8266
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8258
8267
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8259
8268
|
throw new import_errors18.FuelError(
|
8260
8269
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -8265,7 +8274,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8265
8274
|
}
|
8266
8275
|
|
8267
8276
|
// src/mnemonic/mnemonic.ts
|
8268
|
-
var MasterSecret = (0,
|
8277
|
+
var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
|
8269
8278
|
var MainnetPRV = "0x0488ade4";
|
8270
8279
|
var TestnetPRV = "0x04358394";
|
8271
8280
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -8329,7 +8338,7 @@ var Mnemonic = class {
|
|
8329
8338
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8330
8339
|
const words = getWords(phrase);
|
8331
8340
|
assertMnemonic(words);
|
8332
|
-
return (0,
|
8341
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8333
8342
|
}
|
8334
8343
|
/**
|
8335
8344
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8337,7 +8346,7 @@ var Mnemonic = class {
|
|
8337
8346
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8338
8347
|
*/
|
8339
8348
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8340
|
-
const entropyBytes = (0,
|
8349
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
8341
8350
|
assertWordList(wordlist);
|
8342
8351
|
assertEntropy(entropyBytes);
|
8343
8352
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8349,8 +8358,8 @@ var Mnemonic = class {
|
|
8349
8358
|
*/
|
8350
8359
|
static mnemonicToSeed(phrase, passphrase = "") {
|
8351
8360
|
assertMnemonic(getWords(phrase));
|
8352
|
-
const phraseBytes = (0,
|
8353
|
-
const salt = (0,
|
8361
|
+
const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
|
8362
|
+
const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
|
8354
8363
|
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8355
8364
|
}
|
8356
8365
|
/**
|
@@ -8406,14 +8415,14 @@ var Mnemonic = class {
|
|
8406
8415
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8407
8416
|
*/
|
8408
8417
|
static masterKeysFromSeed(seed) {
|
8409
|
-
const seedArray = (0,
|
8418
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
8410
8419
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8411
8420
|
throw new import_errors19.FuelError(
|
8412
8421
|
import_errors19.ErrorCode.INVALID_SEED,
|
8413
8422
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8414
8423
|
);
|
8415
8424
|
}
|
8416
|
-
return (0,
|
8425
|
+
return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
8417
8426
|
}
|
8418
8427
|
/**
|
8419
8428
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8424,22 +8433,22 @@ var Mnemonic = class {
|
|
8424
8433
|
*/
|
8425
8434
|
static seedToExtendedKey(seed, testnet = false) {
|
8426
8435
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8427
|
-
const prefix = (0,
|
8436
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8428
8437
|
const depth = "0x00";
|
8429
8438
|
const fingerprint = "0x00000000";
|
8430
8439
|
const index = "0x00000000";
|
8431
8440
|
const chainCode = masterKey.slice(32);
|
8432
8441
|
const privateKey = masterKey.slice(0, 32);
|
8433
|
-
const extendedKey = (0,
|
8442
|
+
const extendedKey = (0, import_utils33.concat)([
|
8434
8443
|
prefix,
|
8435
8444
|
depth,
|
8436
8445
|
fingerprint,
|
8437
8446
|
index,
|
8438
8447
|
chainCode,
|
8439
|
-
(0,
|
8448
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
8440
8449
|
]);
|
8441
|
-
const checksum = (0,
|
8442
|
-
return (0,
|
8450
|
+
const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8451
|
+
return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
8443
8452
|
}
|
8444
8453
|
/**
|
8445
8454
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8454,7 +8463,7 @@ var Mnemonic = class {
|
|
8454
8463
|
* @returns A randomly generated mnemonic
|
8455
8464
|
*/
|
8456
8465
|
static generate(size = 32, extraEntropy = "") {
|
8457
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8466
|
+
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);
|
8458
8467
|
return Mnemonic.entropyToMnemonic(entropy);
|
8459
8468
|
}
|
8460
8469
|
};
|
@@ -8462,12 +8471,12 @@ var mnemonic_default = Mnemonic;
|
|
8462
8471
|
|
8463
8472
|
// src/hdwallet/hdwallet.ts
|
8464
8473
|
var HARDENED_INDEX = 2147483648;
|
8465
|
-
var MainnetPRV2 = (0,
|
8466
|
-
var MainnetPUB = (0,
|
8467
|
-
var TestnetPRV2 = (0,
|
8468
|
-
var TestnetPUB = (0,
|
8474
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8475
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8476
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8477
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8469
8478
|
function base58check(data) {
|
8470
|
-
return (0,
|
8479
|
+
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)]));
|
8471
8480
|
}
|
8472
8481
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8473
8482
|
if (isPublic) {
|
@@ -8476,11 +8485,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8476
8485
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8477
8486
|
}
|
8478
8487
|
function isPublicExtendedKey(extendedKey) {
|
8479
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8488
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
8480
8489
|
}
|
8481
8490
|
function isValidExtendedKey(extendedKey) {
|
8482
8491
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8483
|
-
(0,
|
8492
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
8484
8493
|
);
|
8485
8494
|
}
|
8486
8495
|
function parsePath(path, depth = 0) {
|
@@ -8498,8 +8507,8 @@ function parsePath(path, depth = 0) {
|
|
8498
8507
|
var HDWallet = class {
|
8499
8508
|
depth = 0;
|
8500
8509
|
index = 0;
|
8501
|
-
fingerprint = (0,
|
8502
|
-
parentFingerprint = (0,
|
8510
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8511
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8503
8512
|
privateKey;
|
8504
8513
|
publicKey;
|
8505
8514
|
chainCode;
|
@@ -8511,8 +8520,8 @@ var HDWallet = class {
|
|
8511
8520
|
constructor(config) {
|
8512
8521
|
if (config.privateKey) {
|
8513
8522
|
const signer = new Signer(config.privateKey);
|
8514
|
-
this.publicKey = (0,
|
8515
|
-
this.privateKey = (0,
|
8523
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8524
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
8516
8525
|
} else {
|
8517
8526
|
if (!config.publicKey) {
|
8518
8527
|
throw new import_errors20.FuelError(
|
@@ -8520,10 +8529,10 @@ var HDWallet = class {
|
|
8520
8529
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8521
8530
|
);
|
8522
8531
|
}
|
8523
|
-
this.publicKey = (0,
|
8532
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8524
8533
|
}
|
8525
8534
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8526
|
-
this.fingerprint = (0,
|
8535
|
+
this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8527
8536
|
this.depth = config.depth || this.depth;
|
8528
8537
|
this.index = config.index || this.index;
|
8529
8538
|
this.chainCode = config.chainCode;
|
@@ -8539,9 +8548,9 @@ var HDWallet = class {
|
|
8539
8548
|
* @returns A new instance of HDWallet on the derived index
|
8540
8549
|
*/
|
8541
8550
|
deriveIndex(index) {
|
8542
|
-
const privateKey = this.privateKey && (0,
|
8543
|
-
const publicKey = (0,
|
8544
|
-
const chainCode = (0,
|
8551
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8552
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8553
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8545
8554
|
const data = new Uint8Array(37);
|
8546
8555
|
if (index & HARDENED_INDEX) {
|
8547
8556
|
if (!privateKey) {
|
@@ -8552,10 +8561,10 @@ var HDWallet = class {
|
|
8552
8561
|
}
|
8553
8562
|
data.set(privateKey, 1);
|
8554
8563
|
} else {
|
8555
|
-
data.set((0,
|
8564
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8556
8565
|
}
|
8557
8566
|
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8558
|
-
const bytes = (0,
|
8567
|
+
const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8559
8568
|
const IL = bytes.slice(0, 32);
|
8560
8569
|
const IR = bytes.slice(32);
|
8561
8570
|
if (privateKey) {
|
@@ -8569,7 +8578,7 @@ var HDWallet = class {
|
|
8569
8578
|
parentFingerprint: this.fingerprint
|
8570
8579
|
});
|
8571
8580
|
}
|
8572
|
-
const signer = new Signer((0,
|
8581
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8573
8582
|
const Ki = signer.addPoint(publicKey);
|
8574
8583
|
return new HDWallet({
|
8575
8584
|
publicKey: Ki,
|
@@ -8604,12 +8613,12 @@ var HDWallet = class {
|
|
8604
8613
|
);
|
8605
8614
|
}
|
8606
8615
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8607
|
-
const depth = (0,
|
8616
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8608
8617
|
const parentFingerprint = this.parentFingerprint;
|
8609
8618
|
const index = (0, import_math22.toHex)(this.index, 4);
|
8610
8619
|
const chainCode = this.chainCode;
|
8611
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8612
|
-
const extendedKey = (0,
|
8620
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8621
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8613
8622
|
return base58check(extendedKey);
|
8614
8623
|
}
|
8615
8624
|
/**
|
@@ -8621,13 +8630,13 @@ var HDWallet = class {
|
|
8621
8630
|
static fromSeed(seed) {
|
8622
8631
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8623
8632
|
return new HDWallet({
|
8624
|
-
chainCode: (0,
|
8625
|
-
privateKey: (0,
|
8633
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8634
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8626
8635
|
});
|
8627
8636
|
}
|
8628
8637
|
static fromExtendedKey(extendedKey) {
|
8629
|
-
const decoded = (0,
|
8630
|
-
const bytes = (0,
|
8638
|
+
const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
|
8639
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8631
8640
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8632
8641
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8633
8642
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8636,9 +8645,9 @@ var HDWallet = class {
|
|
8636
8645
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8637
8646
|
}
|
8638
8647
|
const depth = bytes[4];
|
8639
|
-
const parentFingerprint = (0,
|
8640
|
-
const index = parseInt((0,
|
8641
|
-
const chainCode = (0,
|
8648
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8649
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8650
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8642
8651
|
const key = bytes.slice(45, 78);
|
8643
8652
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8644
8653
|
throw new import_errors20.FuelError(
|
@@ -9242,18 +9251,18 @@ var StorageAbstract = class {
|
|
9242
9251
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
9243
9252
|
var import_address10 = require("@fuel-ts/address");
|
9244
9253
|
var import_errors25 = require("@fuel-ts/errors");
|
9245
|
-
var
|
9254
|
+
var import_utils37 = require("@fuel-ts/utils");
|
9246
9255
|
|
9247
9256
|
// src/predicate/utils/getPredicateRoot.ts
|
9248
9257
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9249
9258
|
var import_merkle = require("@fuel-ts/merkle");
|
9250
|
-
var
|
9259
|
+
var import_utils36 = require("@fuel-ts/utils");
|
9251
9260
|
var getPredicateRoot = (bytecode) => {
|
9252
9261
|
const chunkSize = 16 * 1024;
|
9253
|
-
const bytes = (0,
|
9254
|
-
const chunks = (0,
|
9255
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
9256
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9262
|
+
const bytes = (0, import_utils36.arrayify)(bytecode);
|
9263
|
+
const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
|
9264
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
|
9265
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
|
9257
9266
|
return predicateRoot;
|
9258
9267
|
};
|
9259
9268
|
|
@@ -9305,8 +9314,8 @@ var Predicate = class extends Account {
|
|
9305
9314
|
}
|
9306
9315
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9307
9316
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9308
|
-
input.predicate = (0,
|
9309
|
-
input.predicateData = (0,
|
9317
|
+
input.predicate = (0, import_utils37.hexlify)(this.bytes);
|
9318
|
+
input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData());
|
9310
9319
|
input.witnessIndex = 0;
|
9311
9320
|
}
|
9312
9321
|
});
|
@@ -9348,7 +9357,7 @@ var Predicate = class extends Account {
|
|
9348
9357
|
* @returns An object containing the new predicate bytes and interface.
|
9349
9358
|
*/
|
9350
9359
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9351
|
-
let predicateBytes = (0,
|
9360
|
+
let predicateBytes = (0, import_utils37.arrayify)(bytes);
|
9352
9361
|
let abiInterface;
|
9353
9362
|
if (jsonAbi) {
|
9354
9363
|
abiInterface = new import_abi_coder7.Interface(jsonAbi);
|
@@ -9386,7 +9395,7 @@ var Predicate = class extends Account {
|
|
9386
9395
|
);
|
9387
9396
|
return resources.map((resource) => ({
|
9388
9397
|
...resource,
|
9389
|
-
predicate: (0,
|
9398
|
+
predicate: (0, import_utils37.hexlify)(this.bytes)
|
9390
9399
|
}));
|
9391
9400
|
}
|
9392
9401
|
/**
|
@@ -10251,6 +10260,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10251
10260
|
resolveGasDependentCosts,
|
10252
10261
|
resolveIconPaths,
|
10253
10262
|
returnZeroScript,
|
10263
|
+
sleep,
|
10254
10264
|
transactionRequestify,
|
10255
10265
|
urlJoin,
|
10256
10266
|
withTimeout,
|