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