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