@fuel-ts/account 0.0.0-rc-2333-20240521114009 → 0.0.0-rc-1356-20240521154745
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 +8 -1
- 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 +395 -67
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +404 -167
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +298 -65
- 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
|
};
|
@@ -5752,14 +5743,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5752
5743
|
*/
|
5753
5744
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5754
5745
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5755
|
-
const recipientDataArray = (0,
|
5746
|
+
const recipientDataArray = (0, import_utils29.arrayify)(
|
5756
5747
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5757
5748
|
);
|
5758
|
-
const amountDataArray = (0,
|
5749
|
+
const amountDataArray = (0, import_utils29.arrayify)(
|
5759
5750
|
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5760
5751
|
);
|
5761
5752
|
const script = new Uint8Array([
|
5762
|
-
...(0,
|
5753
|
+
...(0, import_utils29.arrayify)(withdrawScript.bytes),
|
5763
5754
|
...recipientDataArray,
|
5764
5755
|
...amountDataArray
|
5765
5756
|
]);
|
@@ -5865,7 +5856,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5865
5856
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5866
5857
|
}) {
|
5867
5858
|
const request = transactionRequestify(transactionRequest);
|
5868
|
-
if (!(0,
|
5859
|
+
if (!(0, import_utils29.isDefined)(setGasLimit)) {
|
5869
5860
|
request.gasLimit = gasUsed;
|
5870
5861
|
} else if (gasUsed.gt(setGasLimit)) {
|
5871
5862
|
throw new import_errors16.FuelError(
|
@@ -5873,7 +5864,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5873
5864
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5874
5865
|
);
|
5875
5866
|
}
|
5876
|
-
if (!(0,
|
5867
|
+
if (!(0, import_utils29.isDefined)(setMaxFee)) {
|
5877
5868
|
request.maxFee = maxFee;
|
5878
5869
|
} else if (maxFee.gt(setMaxFee)) {
|
5879
5870
|
throw new import_errors16.FuelError(
|
@@ -5887,14 +5878,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5887
5878
|
|
5888
5879
|
// src/wallet/base-wallet-unlocked.ts
|
5889
5880
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5890
|
-
var
|
5881
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5891
5882
|
|
5892
5883
|
// src/signer/signer.ts
|
5893
5884
|
var import_address5 = require("@fuel-ts/address");
|
5894
5885
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5895
5886
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5896
5887
|
var import_math21 = require("@fuel-ts/math");
|
5897
|
-
var
|
5888
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5898
5889
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5899
5890
|
var Signer = class {
|
5900
5891
|
address;
|
@@ -5914,9 +5905,9 @@ var Signer = class {
|
|
5914
5905
|
}
|
5915
5906
|
}
|
5916
5907
|
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5917
|
-
this.privateKey = (0,
|
5918
|
-
this.publicKey = (0,
|
5919
|
-
this.compressedPublicKey = (0,
|
5908
|
+
this.privateKey = (0, import_utils30.hexlify)(privateKeyBytes);
|
5909
|
+
this.publicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5910
|
+
this.compressedPublicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5920
5911
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5921
5912
|
}
|
5922
5913
|
/**
|
@@ -5930,11 +5921,11 @@ var Signer = class {
|
|
5930
5921
|
* @returns hashed signature
|
5931
5922
|
*/
|
5932
5923
|
sign(data) {
|
5933
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5924
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils30.arrayify)(data), (0, import_utils30.arrayify)(this.privateKey));
|
5934
5925
|
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5935
5926
|
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5936
5927
|
s[0] |= (signature.recovery || 0) << 7;
|
5937
|
-
return (0,
|
5928
|
+
return (0, import_utils30.hexlify)((0, import_utils30.concat)([r, s]));
|
5938
5929
|
}
|
5939
5930
|
/**
|
5940
5931
|
* Add point on the current elliptic curve
|
@@ -5943,8 +5934,8 @@ var Signer = class {
|
|
5943
5934
|
* @returns compressed point on the curve
|
5944
5935
|
*/
|
5945
5936
|
addPoint(point) {
|
5946
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5947
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5937
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(this.compressedPublicKey));
|
5938
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(point));
|
5948
5939
|
const result = p0.add(p1);
|
5949
5940
|
return `0x${result.toHex(true)}`;
|
5950
5941
|
}
|
@@ -5956,16 +5947,16 @@ var Signer = class {
|
|
5956
5947
|
* @returns public key from signature from the
|
5957
5948
|
*/
|
5958
5949
|
static recoverPublicKey(data, signature) {
|
5959
|
-
const signedMessageBytes = (0,
|
5950
|
+
const signedMessageBytes = (0, import_utils30.arrayify)(signature);
|
5960
5951
|
const r = signedMessageBytes.slice(0, 32);
|
5961
5952
|
const s = signedMessageBytes.slice(32, 64);
|
5962
5953
|
const recoveryParam = (s[0] & 128) >> 7;
|
5963
5954
|
s[0] &= 127;
|
5964
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5955
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils30.hexlify)(r)), BigInt((0, import_utils30.hexlify)(s))).addRecoveryBit(
|
5965
5956
|
recoveryParam
|
5966
5957
|
);
|
5967
|
-
const publicKey = sig.recoverPublicKey((0,
|
5968
|
-
return (0,
|
5958
|
+
const publicKey = sig.recoverPublicKey((0, import_utils30.arrayify)(data)).toRawBytes(false).slice(1);
|
5959
|
+
return (0, import_utils30.hexlify)(publicKey);
|
5969
5960
|
}
|
5970
5961
|
/**
|
5971
5962
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5984,7 +5975,7 @@ var Signer = class {
|
|
5984
5975
|
* @returns random 32-byte hashed
|
5985
5976
|
*/
|
5986
5977
|
static generatePrivateKey(entropy) {
|
5987
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5978
|
+
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);
|
5988
5979
|
}
|
5989
5980
|
/**
|
5990
5981
|
* Extended publicKey from a compact publicKey
|
@@ -5993,8 +5984,8 @@ var Signer = class {
|
|
5993
5984
|
* @returns extended publicKey
|
5994
5985
|
*/
|
5995
5986
|
static extendPublicKey(publicKey) {
|
5996
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5997
|
-
return (0,
|
5987
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(publicKey));
|
5988
|
+
return (0, import_utils30.hexlify)(point.toRawBytes(false).slice(1));
|
5998
5989
|
}
|
5999
5990
|
};
|
6000
5991
|
|
@@ -6002,7 +5993,7 @@ var Signer = class {
|
|
6002
5993
|
var import_address6 = require("@fuel-ts/address");
|
6003
5994
|
var import_crypto3 = require("@fuel-ts/crypto");
|
6004
5995
|
var import_errors17 = require("@fuel-ts/errors");
|
6005
|
-
var
|
5996
|
+
var import_utils31 = require("@fuel-ts/utils");
|
6006
5997
|
var import_uuid = require("uuid");
|
6007
5998
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6008
5999
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6085,7 +6076,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6085
6076
|
);
|
6086
6077
|
}
|
6087
6078
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6088
|
-
const privateKey = (0,
|
6079
|
+
const privateKey = (0, import_utils31.hexlify)(buffer);
|
6089
6080
|
return privateKey;
|
6090
6081
|
}
|
6091
6082
|
|
@@ -6130,7 +6121,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6130
6121
|
*/
|
6131
6122
|
async signMessage(message) {
|
6132
6123
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
6133
|
-
return (0,
|
6124
|
+
return (0, import_utils32.hexlify)(signedMessage);
|
6134
6125
|
}
|
6135
6126
|
/**
|
6136
6127
|
* Signs a transaction with the wallet's private key.
|
@@ -6143,7 +6134,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6143
6134
|
const chainId = this.provider.getChainId();
|
6144
6135
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6145
6136
|
const signature = await this.signer().sign(hashedTransaction);
|
6146
|
-
return (0,
|
6137
|
+
return (0, import_utils32.hexlify)(signature);
|
6147
6138
|
}
|
6148
6139
|
/**
|
6149
6140
|
* Populates a transaction with the witnesses signature.
|
@@ -6206,13 +6197,13 @@ var import_crypto5 = require("@fuel-ts/crypto");
|
|
6206
6197
|
var import_errors20 = require("@fuel-ts/errors");
|
6207
6198
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6208
6199
|
var import_math22 = require("@fuel-ts/math");
|
6209
|
-
var
|
6200
|
+
var import_utils36 = require("@fuel-ts/utils");
|
6210
6201
|
|
6211
6202
|
// src/mnemonic/mnemonic.ts
|
6212
6203
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6213
6204
|
var import_errors19 = require("@fuel-ts/errors");
|
6214
6205
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6215
|
-
var
|
6206
|
+
var import_utils34 = require("@fuel-ts/utils");
|
6216
6207
|
|
6217
6208
|
// src/wordlists/words/english.ts
|
6218
6209
|
var english = [
|
@@ -8275,7 +8266,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8275
8266
|
// src/mnemonic/utils.ts
|
8276
8267
|
var import_errors18 = require("@fuel-ts/errors");
|
8277
8268
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8278
|
-
var
|
8269
|
+
var import_utils33 = require("@fuel-ts/utils");
|
8279
8270
|
function getLowerMask(bits) {
|
8280
8271
|
return (1 << bits) - 1;
|
8281
8272
|
}
|
@@ -8310,14 +8301,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
8310
8301
|
}
|
8311
8302
|
}
|
8312
8303
|
const checksumBits = entropy.length / 4;
|
8313
|
-
const checksum = (0,
|
8304
|
+
const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8314
8305
|
indices[indices.length - 1] <<= checksumBits;
|
8315
8306
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8316
8307
|
return indices;
|
8317
8308
|
}
|
8318
8309
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8319
8310
|
const size = Math.ceil(11 * words.length / 8);
|
8320
|
-
const entropy = (0,
|
8311
|
+
const entropy = (0, import_utils33.arrayify)(new Uint8Array(size));
|
8321
8312
|
let offset = 0;
|
8322
8313
|
for (let i = 0; i < words.length; i += 1) {
|
8323
8314
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -8337,7 +8328,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8337
8328
|
const entropyBits = 32 * words.length / 3;
|
8338
8329
|
const checksumBits = words.length / 3;
|
8339
8330
|
const checksumMask = getUpperMask(checksumBits);
|
8340
|
-
const checksum = (0,
|
8331
|
+
const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8341
8332
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8342
8333
|
throw new import_errors18.FuelError(
|
8343
8334
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -8348,7 +8339,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8348
8339
|
}
|
8349
8340
|
|
8350
8341
|
// src/mnemonic/mnemonic.ts
|
8351
|
-
var MasterSecret = (0,
|
8342
|
+
var MasterSecret = (0, import_utils34.toUtf8Bytes)("Bitcoin seed");
|
8352
8343
|
var MainnetPRV = "0x0488ade4";
|
8353
8344
|
var TestnetPRV = "0x04358394";
|
8354
8345
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -8412,7 +8403,7 @@ var Mnemonic = class {
|
|
8412
8403
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8413
8404
|
const words = getWords(phrase);
|
8414
8405
|
assertMnemonic(words);
|
8415
|
-
return (0,
|
8406
|
+
return (0, import_utils34.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8416
8407
|
}
|
8417
8408
|
/**
|
8418
8409
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8420,7 +8411,7 @@ var Mnemonic = class {
|
|
8420
8411
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8421
8412
|
*/
|
8422
8413
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8423
|
-
const entropyBytes = (0,
|
8414
|
+
const entropyBytes = (0, import_utils34.arrayify)(entropy);
|
8424
8415
|
assertWordList(wordlist);
|
8425
8416
|
assertEntropy(entropyBytes);
|
8426
8417
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8432,8 +8423,8 @@ var Mnemonic = class {
|
|
8432
8423
|
*/
|
8433
8424
|
static mnemonicToSeed(phrase, passphrase = "") {
|
8434
8425
|
assertMnemonic(getWords(phrase));
|
8435
|
-
const phraseBytes = (0,
|
8436
|
-
const salt = (0,
|
8426
|
+
const phraseBytes = (0, import_utils34.toUtf8Bytes)(getPhrase(phrase));
|
8427
|
+
const salt = (0, import_utils34.toUtf8Bytes)(`mnemonic${passphrase}`);
|
8437
8428
|
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8438
8429
|
}
|
8439
8430
|
/**
|
@@ -8489,14 +8480,14 @@ var Mnemonic = class {
|
|
8489
8480
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8490
8481
|
*/
|
8491
8482
|
static masterKeysFromSeed(seed) {
|
8492
|
-
const seedArray = (0,
|
8483
|
+
const seedArray = (0, import_utils34.arrayify)(seed);
|
8493
8484
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8494
8485
|
throw new import_errors19.FuelError(
|
8495
8486
|
import_errors19.ErrorCode.INVALID_SEED,
|
8496
8487
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8497
8488
|
);
|
8498
8489
|
}
|
8499
|
-
return (0,
|
8490
|
+
return (0, import_utils34.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
8500
8491
|
}
|
8501
8492
|
/**
|
8502
8493
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8507,22 +8498,22 @@ var Mnemonic = class {
|
|
8507
8498
|
*/
|
8508
8499
|
static seedToExtendedKey(seed, testnet = false) {
|
8509
8500
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8510
|
-
const prefix = (0,
|
8501
|
+
const prefix = (0, import_utils34.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8511
8502
|
const depth = "0x00";
|
8512
8503
|
const fingerprint = "0x00000000";
|
8513
8504
|
const index = "0x00000000";
|
8514
8505
|
const chainCode = masterKey.slice(32);
|
8515
8506
|
const privateKey = masterKey.slice(0, 32);
|
8516
|
-
const extendedKey = (0,
|
8507
|
+
const extendedKey = (0, import_utils34.concat)([
|
8517
8508
|
prefix,
|
8518
8509
|
depth,
|
8519
8510
|
fingerprint,
|
8520
8511
|
index,
|
8521
8512
|
chainCode,
|
8522
|
-
(0,
|
8513
|
+
(0, import_utils34.concat)(["0x00", privateKey])
|
8523
8514
|
]);
|
8524
|
-
const checksum = (0,
|
8525
|
-
return (0,
|
8515
|
+
const checksum = (0, import_utils34.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8516
|
+
return (0, import_utils34.encodeBase58)((0, import_utils34.concat)([extendedKey, checksum]));
|
8526
8517
|
}
|
8527
8518
|
/**
|
8528
8519
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8537,7 +8528,7 @@ var Mnemonic = class {
|
|
8537
8528
|
* @returns A randomly generated mnemonic
|
8538
8529
|
*/
|
8539
8530
|
static generate(size = 32, extraEntropy = "") {
|
8540
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8531
|
+
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);
|
8541
8532
|
return Mnemonic.entropyToMnemonic(entropy);
|
8542
8533
|
}
|
8543
8534
|
};
|
@@ -8545,12 +8536,12 @@ var mnemonic_default = Mnemonic;
|
|
8545
8536
|
|
8546
8537
|
// src/hdwallet/hdwallet.ts
|
8547
8538
|
var HARDENED_INDEX = 2147483648;
|
8548
|
-
var MainnetPRV2 = (0,
|
8549
|
-
var MainnetPUB = (0,
|
8550
|
-
var TestnetPRV2 = (0,
|
8551
|
-
var TestnetPUB = (0,
|
8539
|
+
var MainnetPRV2 = (0, import_utils36.hexlify)("0x0488ade4");
|
8540
|
+
var MainnetPUB = (0, import_utils36.hexlify)("0x0488b21e");
|
8541
|
+
var TestnetPRV2 = (0, import_utils36.hexlify)("0x04358394");
|
8542
|
+
var TestnetPUB = (0, import_utils36.hexlify)("0x043587cf");
|
8552
8543
|
function base58check(data) {
|
8553
|
-
return (0,
|
8544
|
+
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)]));
|
8554
8545
|
}
|
8555
8546
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8556
8547
|
if (isPublic) {
|
@@ -8559,11 +8550,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8559
8550
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8560
8551
|
}
|
8561
8552
|
function isPublicExtendedKey(extendedKey) {
|
8562
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8553
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils36.hexlify)(extendedKey.slice(0, 4)));
|
8563
8554
|
}
|
8564
8555
|
function isValidExtendedKey(extendedKey) {
|
8565
8556
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8566
|
-
(0,
|
8557
|
+
(0, import_utils36.hexlify)(extendedKey.slice(0, 4))
|
8567
8558
|
);
|
8568
8559
|
}
|
8569
8560
|
function parsePath(path, depth = 0) {
|
@@ -8581,8 +8572,8 @@ function parsePath(path, depth = 0) {
|
|
8581
8572
|
var HDWallet = class {
|
8582
8573
|
depth = 0;
|
8583
8574
|
index = 0;
|
8584
|
-
fingerprint = (0,
|
8585
|
-
parentFingerprint = (0,
|
8575
|
+
fingerprint = (0, import_utils36.hexlify)("0x00000000");
|
8576
|
+
parentFingerprint = (0, import_utils36.hexlify)("0x00000000");
|
8586
8577
|
privateKey;
|
8587
8578
|
publicKey;
|
8588
8579
|
chainCode;
|
@@ -8594,8 +8585,8 @@ var HDWallet = class {
|
|
8594
8585
|
constructor(config) {
|
8595
8586
|
if (config.privateKey) {
|
8596
8587
|
const signer = new Signer(config.privateKey);
|
8597
|
-
this.publicKey = (0,
|
8598
|
-
this.privateKey = (0,
|
8588
|
+
this.publicKey = (0, import_utils36.hexlify)(signer.compressedPublicKey);
|
8589
|
+
this.privateKey = (0, import_utils36.hexlify)(config.privateKey);
|
8599
8590
|
} else {
|
8600
8591
|
if (!config.publicKey) {
|
8601
8592
|
throw new import_errors20.FuelError(
|
@@ -8603,10 +8594,10 @@ var HDWallet = class {
|
|
8603
8594
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8604
8595
|
);
|
8605
8596
|
}
|
8606
|
-
this.publicKey = (0,
|
8597
|
+
this.publicKey = (0, import_utils36.hexlify)(config.publicKey);
|
8607
8598
|
}
|
8608
8599
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8609
|
-
this.fingerprint = (0,
|
8600
|
+
this.fingerprint = (0, import_utils36.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8610
8601
|
this.depth = config.depth || this.depth;
|
8611
8602
|
this.index = config.index || this.index;
|
8612
8603
|
this.chainCode = config.chainCode;
|
@@ -8622,9 +8613,9 @@ var HDWallet = class {
|
|
8622
8613
|
* @returns A new instance of HDWallet on the derived index
|
8623
8614
|
*/
|
8624
8615
|
deriveIndex(index) {
|
8625
|
-
const privateKey = this.privateKey && (0,
|
8626
|
-
const publicKey = (0,
|
8627
|
-
const chainCode = (0,
|
8616
|
+
const privateKey = this.privateKey && (0, import_utils36.arrayify)(this.privateKey);
|
8617
|
+
const publicKey = (0, import_utils36.arrayify)(this.publicKey);
|
8618
|
+
const chainCode = (0, import_utils36.arrayify)(this.chainCode);
|
8628
8619
|
const data = new Uint8Array(37);
|
8629
8620
|
if (index & HARDENED_INDEX) {
|
8630
8621
|
if (!privateKey) {
|
@@ -8635,10 +8626,10 @@ var HDWallet = class {
|
|
8635
8626
|
}
|
8636
8627
|
data.set(privateKey, 1);
|
8637
8628
|
} else {
|
8638
|
-
data.set((0,
|
8629
|
+
data.set((0, import_utils36.arrayify)(this.publicKey));
|
8639
8630
|
}
|
8640
8631
|
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8641
|
-
const bytes = (0,
|
8632
|
+
const bytes = (0, import_utils36.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8642
8633
|
const IL = bytes.slice(0, 32);
|
8643
8634
|
const IR = bytes.slice(32);
|
8644
8635
|
if (privateKey) {
|
@@ -8652,7 +8643,7 @@ var HDWallet = class {
|
|
8652
8643
|
parentFingerprint: this.fingerprint
|
8653
8644
|
});
|
8654
8645
|
}
|
8655
|
-
const signer = new Signer((0,
|
8646
|
+
const signer = new Signer((0, import_utils36.hexlify)(IL));
|
8656
8647
|
const Ki = signer.addPoint(publicKey);
|
8657
8648
|
return new HDWallet({
|
8658
8649
|
publicKey: Ki,
|
@@ -8687,12 +8678,12 @@ var HDWallet = class {
|
|
8687
8678
|
);
|
8688
8679
|
}
|
8689
8680
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8690
|
-
const depth = (0,
|
8681
|
+
const depth = (0, import_utils36.hexlify)(Uint8Array.from([this.depth]));
|
8691
8682
|
const parentFingerprint = this.parentFingerprint;
|
8692
8683
|
const index = (0, import_math22.toHex)(this.index, 4);
|
8693
8684
|
const chainCode = this.chainCode;
|
8694
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8695
|
-
const extendedKey = (0,
|
8685
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils36.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8686
|
+
const extendedKey = (0, import_utils36.arrayify)((0, import_utils36.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8696
8687
|
return base58check(extendedKey);
|
8697
8688
|
}
|
8698
8689
|
/**
|
@@ -8704,13 +8695,13 @@ var HDWallet = class {
|
|
8704
8695
|
static fromSeed(seed) {
|
8705
8696
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8706
8697
|
return new HDWallet({
|
8707
|
-
chainCode: (0,
|
8708
|
-
privateKey: (0,
|
8698
|
+
chainCode: (0, import_utils36.arrayify)(masterKey.slice(32)),
|
8699
|
+
privateKey: (0, import_utils36.arrayify)(masterKey.slice(0, 32))
|
8709
8700
|
});
|
8710
8701
|
}
|
8711
8702
|
static fromExtendedKey(extendedKey) {
|
8712
|
-
const decoded = (0,
|
8713
|
-
const bytes = (0,
|
8703
|
+
const decoded = (0, import_utils36.hexlify)((0, import_math22.toBytes)((0, import_utils36.decodeBase58)(extendedKey)));
|
8704
|
+
const bytes = (0, import_utils36.arrayify)(decoded);
|
8714
8705
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8715
8706
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8716
8707
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8719,9 +8710,9 @@ var HDWallet = class {
|
|
8719
8710
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8720
8711
|
}
|
8721
8712
|
const depth = bytes[4];
|
8722
|
-
const parentFingerprint = (0,
|
8723
|
-
const index = parseInt((0,
|
8724
|
-
const chainCode = (0,
|
8713
|
+
const parentFingerprint = (0, import_utils36.hexlify)(bytes.slice(5, 9));
|
8714
|
+
const index = parseInt((0, import_utils36.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8715
|
+
const chainCode = (0, import_utils36.hexlify)(bytes.slice(13, 45));
|
8725
8716
|
const key = bytes.slice(45, 78);
|
8726
8717
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8727
8718
|
throw new import_errors20.FuelError(
|
@@ -9325,18 +9316,18 @@ var StorageAbstract = class {
|
|
9325
9316
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
9326
9317
|
var import_address10 = require("@fuel-ts/address");
|
9327
9318
|
var import_errors25 = require("@fuel-ts/errors");
|
9328
|
-
var
|
9319
|
+
var import_utils38 = require("@fuel-ts/utils");
|
9329
9320
|
|
9330
9321
|
// src/predicate/utils/getPredicateRoot.ts
|
9331
9322
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9332
9323
|
var import_merkle = require("@fuel-ts/merkle");
|
9333
|
-
var
|
9324
|
+
var import_utils37 = require("@fuel-ts/utils");
|
9334
9325
|
var getPredicateRoot = (bytecode) => {
|
9335
9326
|
const chunkSize = 16 * 1024;
|
9336
|
-
const bytes = (0,
|
9337
|
-
const chunks = (0,
|
9338
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
9339
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9327
|
+
const bytes = (0, import_utils37.arrayify)(bytecode);
|
9328
|
+
const chunks = (0, import_utils37.chunkAndPadBytes)(bytes, chunkSize);
|
9329
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils37.hexlify)(c)));
|
9330
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils37.concat)(["0x4655454C", codeRoot]));
|
9340
9331
|
return predicateRoot;
|
9341
9332
|
};
|
9342
9333
|
|
@@ -9388,8 +9379,8 @@ var Predicate = class extends Account {
|
|
9388
9379
|
}
|
9389
9380
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9390
9381
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9391
|
-
input.predicate = (0,
|
9392
|
-
input.predicateData = (0,
|
9382
|
+
input.predicate = (0, import_utils38.hexlify)(this.bytes);
|
9383
|
+
input.predicateData = (0, import_utils38.hexlify)(this.getPredicateData());
|
9393
9384
|
input.witnessIndex = 0;
|
9394
9385
|
}
|
9395
9386
|
});
|
@@ -9431,7 +9422,7 @@ var Predicate = class extends Account {
|
|
9431
9422
|
* @returns An object containing the new predicate bytes and interface.
|
9432
9423
|
*/
|
9433
9424
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9434
|
-
let predicateBytes = (0,
|
9425
|
+
let predicateBytes = (0, import_utils38.arrayify)(bytes);
|
9435
9426
|
let abiInterface;
|
9436
9427
|
if (jsonAbi) {
|
9437
9428
|
abiInterface = new import_abi_coder7.Interface(jsonAbi);
|
@@ -9469,7 +9460,7 @@ var Predicate = class extends Account {
|
|
9469
9460
|
);
|
9470
9461
|
return resources.map((resource) => ({
|
9471
9462
|
...resource,
|
9472
|
-
predicate: (0,
|
9463
|
+
predicate: (0, import_utils38.hexlify)(this.bytes)
|
9473
9464
|
}));
|
9474
9465
|
}
|
9475
9466
|
/**
|
@@ -10334,7 +10325,6 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10334
10325
|
resolveGasDependentCosts,
|
10335
10326
|
resolveIconPaths,
|
10336
10327
|
returnZeroScript,
|
10337
|
-
sleep,
|
10338
10328
|
transactionRequestify,
|
10339
10329
|
urlJoin,
|
10340
10330
|
withTimeout,
|