@fuel-ts/account 0.0.0-rc-2395-20240528075431 → 0.0.0-rc-1356-20240528093309
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 +17 -30
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +126 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -31
- package/dist/index.mjs.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +2 -4
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +0 -1
- package/dist/providers/transaction-summary/types.d.ts.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 +401 -79
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +410 -179
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +304 -77
- 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");
|
@@ -3265,12 +3255,12 @@ function getReceiptsTransferOut(receipts) {
|
|
3265
3255
|
}
|
3266
3256
|
function getWithdrawFromFuelOperations({
|
3267
3257
|
inputs,
|
3268
|
-
receipts
|
3269
|
-
assetId
|
3258
|
+
receipts
|
3270
3259
|
}) {
|
3271
3260
|
const messageOutReceipts = getReceiptsMessageOut(receipts);
|
3272
3261
|
const withdrawFromFuelOperations = messageOutReceipts.reduce(
|
3273
3262
|
(prevWithdrawFromFuelOps, receipt) => {
|
3263
|
+
const assetId = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
3274
3264
|
const input = getInputFromAssetId(inputs, assetId);
|
3275
3265
|
if (input) {
|
3276
3266
|
const inputAddress = getInputAccountAddress(input);
|
@@ -3484,8 +3474,7 @@ function getOperations({
|
|
3484
3474
|
receipts,
|
3485
3475
|
abiMap,
|
3486
3476
|
rawPayload,
|
3487
|
-
maxInputs
|
3488
|
-
assetId
|
3477
|
+
maxInputs
|
3489
3478
|
}) {
|
3490
3479
|
if (isTypeCreate(transactionType)) {
|
3491
3480
|
return [
|
@@ -3504,7 +3493,7 @@ function getOperations({
|
|
3504
3493
|
rawPayload,
|
3505
3494
|
maxInputs
|
3506
3495
|
}),
|
3507
|
-
...getWithdrawFromFuelOperations({ inputs, receipts
|
3496
|
+
...getWithdrawFromFuelOperations({ inputs, receipts })
|
3508
3497
|
];
|
3509
3498
|
}
|
3510
3499
|
return [...getPayProducerOperations(outputs)];
|
@@ -3640,8 +3629,7 @@ function assembleTransactionSummary(params) {
|
|
3640
3629
|
maxInputs,
|
3641
3630
|
gasCosts,
|
3642
3631
|
maxGasPerTx,
|
3643
|
-
gasPrice
|
3644
|
-
assetId
|
3632
|
+
gasPrice
|
3645
3633
|
} = params;
|
3646
3634
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3647
3635
|
const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
|
@@ -3652,8 +3640,7 @@ function assembleTransactionSummary(params) {
|
|
3652
3640
|
receipts,
|
3653
3641
|
rawPayload,
|
3654
3642
|
abiMap,
|
3655
|
-
maxInputs
|
3656
|
-
assetId
|
3643
|
+
maxInputs
|
3657
3644
|
});
|
3658
3645
|
const typeName = getTransactionTypeName(transaction.type);
|
3659
3646
|
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
@@ -3813,7 +3800,6 @@ var TransactionResponse = class {
|
|
3813
3800
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3814
3801
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3815
3802
|
const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
|
3816
|
-
const assetId = this.provider.getBaseAssetId();
|
3817
3803
|
const transactionSummary = assembleTransactionSummary({
|
3818
3804
|
id: this.id,
|
3819
3805
|
receipts,
|
@@ -3826,8 +3812,7 @@ var TransactionResponse = class {
|
|
3826
3812
|
maxInputs,
|
3827
3813
|
gasCosts,
|
3828
3814
|
maxGasPerTx,
|
3829
|
-
gasPrice
|
3830
|
-
assetId
|
3815
|
+
gasPrice
|
3831
3816
|
});
|
3832
3817
|
return transactionSummary;
|
3833
3818
|
}
|
@@ -3895,6 +3880,7 @@ var TransactionResponse = class {
|
|
3895
3880
|
};
|
3896
3881
|
|
3897
3882
|
// src/providers/utils/auto-retry-fetch.ts
|
3883
|
+
var import_utils22 = require("@fuel-ts/utils");
|
3898
3884
|
function getWaitDelay(options, retryAttemptNum) {
|
3899
3885
|
const duration = options.baseDelay ?? 150;
|
3900
3886
|
switch (options.backoff) {
|
@@ -3924,7 +3910,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3924
3910
|
throw error;
|
3925
3911
|
}
|
3926
3912
|
const delay = getWaitDelay(options, retryNum);
|
3927
|
-
await sleep(delay);
|
3913
|
+
await (0, import_utils22.sleep)(delay);
|
3928
3914
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3929
3915
|
}
|
3930
3916
|
};
|
@@ -4283,7 +4269,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4283
4269
|
if (estimateTxDependencies) {
|
4284
4270
|
await this.estimateTxDependencies(transactionRequest);
|
4285
4271
|
}
|
4286
|
-
const encodedTransaction = (0,
|
4272
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4287
4273
|
let abis;
|
4288
4274
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4289
4275
|
abis = transactionRequest.abis;
|
@@ -4326,7 +4312,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4326
4312
|
if (estimateTxDependencies) {
|
4327
4313
|
return this.estimateTxDependencies(transactionRequest);
|
4328
4314
|
}
|
4329
|
-
const encodedTransaction = (0,
|
4315
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4330
4316
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4331
4317
|
encodedTransactions: encodedTransaction,
|
4332
4318
|
utxoValidation: utxoValidation || false
|
@@ -4346,13 +4332,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4346
4332
|
async estimatePredicates(transactionRequest) {
|
4347
4333
|
const shouldEstimatePredicates = Boolean(
|
4348
4334
|
transactionRequest.inputs.find(
|
4349
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4335
|
+
(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()
|
4350
4336
|
)
|
4351
4337
|
);
|
4352
4338
|
if (!shouldEstimatePredicates) {
|
4353
4339
|
return transactionRequest;
|
4354
4340
|
}
|
4355
|
-
const encodedTransaction = (0,
|
4341
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4356
4342
|
const response = await this.operations.estimatePredicates({
|
4357
4343
|
encodedTransaction
|
4358
4344
|
});
|
@@ -4393,7 +4379,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4393
4379
|
const {
|
4394
4380
|
dryRun: [{ receipts: rawReceipts, status }]
|
4395
4381
|
} = await this.operations.dryRun({
|
4396
|
-
encodedTransactions: [(0,
|
4382
|
+
encodedTransactions: [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())],
|
4397
4383
|
utxoValidation: false
|
4398
4384
|
});
|
4399
4385
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4443,7 +4429,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4443
4429
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4444
4430
|
allRequests.forEach((req, index) => {
|
4445
4431
|
if (req.type === import_transactions20.TransactionType.Script) {
|
4446
|
-
serializedTransactionsMap.set(index, (0,
|
4432
|
+
serializedTransactionsMap.set(index, (0, import_utils23.hexlify)(req.toTransactionBytes()));
|
4447
4433
|
}
|
4448
4434
|
});
|
4449
4435
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4479,7 +4465,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4479
4465
|
transactionRequest: request
|
4480
4466
|
});
|
4481
4467
|
request.maxFee = maxFee;
|
4482
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
4468
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils23.hexlify)(request.toTransactionBytes()));
|
4483
4469
|
nextRoundTransactions.push(requestIdx);
|
4484
4470
|
}
|
4485
4471
|
}
|
@@ -4500,7 +4486,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4500
4486
|
if (estimateTxDependencies) {
|
4501
4487
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4502
4488
|
}
|
4503
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
4489
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils23.hexlify)(tx.toTransactionBytes()));
|
4504
4490
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4505
4491
|
encodedTransactions,
|
4506
4492
|
utxoValidation: utxoValidation || false
|
@@ -4574,7 +4560,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4574
4560
|
if (estimateTxDependencies) {
|
4575
4561
|
return this.estimateTxDependencies(transactionRequest);
|
4576
4562
|
}
|
4577
|
-
const encodedTransactions = [(0,
|
4563
|
+
const encodedTransactions = [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())];
|
4578
4564
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4579
4565
|
encodedTransactions,
|
4580
4566
|
utxoValidation: true
|
@@ -4703,7 +4689,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4703
4689
|
const result = await this.operations.getCoins({
|
4704
4690
|
first: 10,
|
4705
4691
|
...paginationArgs,
|
4706
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4692
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
4707
4693
|
});
|
4708
4694
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4709
4695
|
return coins.map((coin) => ({
|
@@ -4726,19 +4712,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4726
4712
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4727
4713
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4728
4714
|
const excludeInput = {
|
4729
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4730
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4715
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
|
4716
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
|
4731
4717
|
};
|
4732
4718
|
if (this.cache) {
|
4733
4719
|
const uniqueUtxos = new Set(
|
4734
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4720
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
|
4735
4721
|
);
|
4736
4722
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4737
4723
|
}
|
4738
4724
|
const coinsQuery = {
|
4739
4725
|
owner: ownerAddress.toB256(),
|
4740
4726
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4741
|
-
assetId: (0,
|
4727
|
+
assetId: (0, import_utils23.hexlify)(assetId),
|
4742
4728
|
amount: amount.toString(10),
|
4743
4729
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4744
4730
|
})),
|
@@ -4840,7 +4826,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4840
4826
|
time: block.header.time,
|
4841
4827
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4842
4828
|
transactions: block.transactions.map(
|
4843
|
-
(tx) => new import_transactions20.TransactionCoder().decode((0,
|
4829
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
|
4844
4830
|
)
|
4845
4831
|
};
|
4846
4832
|
}
|
@@ -4856,7 +4842,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4856
4842
|
return null;
|
4857
4843
|
}
|
4858
4844
|
return new import_transactions20.TransactionCoder().decode(
|
4859
|
-
(0,
|
4845
|
+
(0, import_utils23.arrayify)(transaction.rawPayload),
|
4860
4846
|
0
|
4861
4847
|
)?.[0];
|
4862
4848
|
}
|
@@ -4883,7 +4869,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4883
4869
|
async getContractBalance(contractId, assetId) {
|
4884
4870
|
const { contractBalance } = await this.operations.getContractBalance({
|
4885
4871
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4886
|
-
asset: (0,
|
4872
|
+
asset: (0, import_utils23.hexlify)(assetId)
|
4887
4873
|
});
|
4888
4874
|
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4889
4875
|
}
|
@@ -4897,7 +4883,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4897
4883
|
async getBalance(owner, assetId) {
|
4898
4884
|
const { balance } = await this.operations.getBalance({
|
4899
4885
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4900
|
-
assetId: (0,
|
4886
|
+
assetId: (0, import_utils23.hexlify)(assetId)
|
4901
4887
|
});
|
4902
4888
|
return (0, import_math17.bn)(balance.amount, 10);
|
4903
4889
|
}
|
@@ -5085,7 +5071,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5085
5071
|
async produceBlocks(amount, startTime) {
|
5086
5072
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5087
5073
|
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
5088
|
-
startTimestamp: startTime ?
|
5074
|
+
startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5089
5075
|
});
|
5090
5076
|
return (0, import_math17.bn)(latestBlockHeight);
|
5091
5077
|
}
|
@@ -5168,7 +5154,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
5168
5154
|
var import_errors15 = require("@fuel-ts/errors");
|
5169
5155
|
var import_math18 = require("@fuel-ts/math");
|
5170
5156
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5171
|
-
var
|
5157
|
+
var import_utils26 = require("@fuel-ts/utils");
|
5172
5158
|
async function getTransactionSummary(params) {
|
5173
5159
|
const { id, provider, abiMap } = params;
|
5174
5160
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -5181,7 +5167,7 @@ async function getTransactionSummary(params) {
|
|
5181
5167
|
);
|
5182
5168
|
}
|
5183
5169
|
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
|
5184
|
-
(0,
|
5170
|
+
(0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
5185
5171
|
0
|
5186
5172
|
);
|
5187
5173
|
let txReceipts = [];
|
@@ -5197,12 +5183,11 @@ async function getTransactionSummary(params) {
|
|
5197
5183
|
}
|
5198
5184
|
} = provider.getChain();
|
5199
5185
|
const gasPrice = await provider.getLatestGasPrice();
|
5200
|
-
const assetId = provider.getBaseAssetId();
|
5201
5186
|
const transactionInfo = assembleTransactionSummary({
|
5202
5187
|
id: gqlTransaction.id,
|
5203
5188
|
receipts,
|
5204
5189
|
transaction: decodedTransaction,
|
5205
|
-
transactionBytes: (0,
|
5190
|
+
transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
5206
5191
|
gqlTransactionStatus: gqlTransaction.status,
|
5207
5192
|
gasPerByte: (0, import_math18.bn)(gasPerByte),
|
5208
5193
|
gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
|
@@ -5210,8 +5195,7 @@ async function getTransactionSummary(params) {
|
|
5210
5195
|
maxInputs,
|
5211
5196
|
gasCosts,
|
5212
5197
|
maxGasPerTx,
|
5213
|
-
gasPrice
|
5214
|
-
assetId
|
5198
|
+
gasPrice
|
5215
5199
|
});
|
5216
5200
|
return {
|
5217
5201
|
gqlTransaction,
|
@@ -5226,7 +5210,6 @@ async function getTransactionSummaryFromRequest(params) {
|
|
5226
5210
|
const transaction = transactionRequest.toTransaction();
|
5227
5211
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
5228
5212
|
const gasPrice = await provider.getLatestGasPrice();
|
5229
|
-
const assetId = provider.getBaseAssetId();
|
5230
5213
|
const transactionSummary = assembleTransactionSummary({
|
5231
5214
|
receipts,
|
5232
5215
|
transaction,
|
@@ -5237,8 +5220,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
5237
5220
|
maxInputs,
|
5238
5221
|
gasCosts,
|
5239
5222
|
maxGasPerTx,
|
5240
|
-
gasPrice
|
5241
|
-
assetId
|
5223
|
+
gasPrice
|
5242
5224
|
});
|
5243
5225
|
return transactionSummary;
|
5244
5226
|
}
|
@@ -5254,11 +5236,10 @@ async function getTransactionsSummaries(params) {
|
|
5254
5236
|
}
|
5255
5237
|
} = provider.getChain();
|
5256
5238
|
const gasPrice = await provider.getLatestGasPrice();
|
5257
|
-
const assetId = provider.getBaseAssetId();
|
5258
5239
|
const transactions = edges.map((edge) => {
|
5259
5240
|
const { node: gqlTransaction } = edge;
|
5260
5241
|
const { id, rawPayload, status } = gqlTransaction;
|
5261
|
-
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0,
|
5242
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
|
5262
5243
|
let txReceipts = [];
|
5263
5244
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5264
5245
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5268,7 +5249,7 @@ async function getTransactionsSummaries(params) {
|
|
5268
5249
|
id,
|
5269
5250
|
receipts,
|
5270
5251
|
transaction: decodedTransaction,
|
5271
|
-
transactionBytes: (0,
|
5252
|
+
transactionBytes: (0, import_utils26.arrayify)(rawPayload),
|
5272
5253
|
gqlTransactionStatus: status,
|
5273
5254
|
abiMap,
|
5274
5255
|
gasPerByte,
|
@@ -5276,8 +5257,7 @@ async function getTransactionsSummaries(params) {
|
|
5276
5257
|
maxInputs,
|
5277
5258
|
gasCosts,
|
5278
5259
|
maxGasPerTx,
|
5279
|
-
gasPrice
|
5280
|
-
assetId
|
5260
|
+
gasPrice
|
5281
5261
|
});
|
5282
5262
|
const output = {
|
5283
5263
|
gqlTransaction,
|
@@ -5419,16 +5399,16 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
5419
5399
|
// src/utils/formatTransferToContractScriptData.ts
|
5420
5400
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5421
5401
|
var import_math19 = require("@fuel-ts/math");
|
5422
|
-
var
|
5402
|
+
var import_utils28 = require("@fuel-ts/utils");
|
5423
5403
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5424
5404
|
var formatTransferToContractScriptData = (params) => {
|
5425
5405
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5426
5406
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5427
5407
|
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
5428
5408
|
const scriptData = Uint8Array.from([
|
5429
|
-
...(0,
|
5409
|
+
...(0, import_utils28.arrayify)(hexlifiedContractId),
|
5430
5410
|
...encoded,
|
5431
|
-
...(0,
|
5411
|
+
...(0, import_utils28.arrayify)(assetId)
|
5432
5412
|
]);
|
5433
5413
|
return scriptData;
|
5434
5414
|
};
|
@@ -5833,14 +5813,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5833
5813
|
*/
|
5834
5814
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5835
5815
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5836
|
-
const recipientDataArray = (0,
|
5816
|
+
const recipientDataArray = (0, import_utils29.arrayify)(
|
5837
5817
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5838
5818
|
);
|
5839
|
-
const amountDataArray = (0,
|
5819
|
+
const amountDataArray = (0, import_utils29.arrayify)(
|
5840
5820
|
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5841
5821
|
);
|
5842
5822
|
const script = new Uint8Array([
|
5843
|
-
...(0,
|
5823
|
+
...(0, import_utils29.arrayify)(withdrawScript.bytes),
|
5844
5824
|
...recipientDataArray,
|
5845
5825
|
...amountDataArray
|
5846
5826
|
]);
|
@@ -5955,7 +5935,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5955
5935
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5956
5936
|
}) {
|
5957
5937
|
const request = transactionRequestify(transactionRequest);
|
5958
|
-
if (!(0,
|
5938
|
+
if (!(0, import_utils29.isDefined)(setGasLimit)) {
|
5959
5939
|
request.gasLimit = gasUsed;
|
5960
5940
|
} else if (gasUsed.gt(setGasLimit)) {
|
5961
5941
|
throw new import_errors16.FuelError(
|
@@ -5963,7 +5943,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5963
5943
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5964
5944
|
);
|
5965
5945
|
}
|
5966
|
-
if (!(0,
|
5946
|
+
if (!(0, import_utils29.isDefined)(setMaxFee)) {
|
5967
5947
|
request.maxFee = maxFee;
|
5968
5948
|
} else if (maxFee.gt(setMaxFee)) {
|
5969
5949
|
throw new import_errors16.FuelError(
|
@@ -5977,14 +5957,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5977
5957
|
|
5978
5958
|
// src/wallet/base-wallet-unlocked.ts
|
5979
5959
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5980
|
-
var
|
5960
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5981
5961
|
|
5982
5962
|
// src/signer/signer.ts
|
5983
5963
|
var import_address5 = require("@fuel-ts/address");
|
5984
5964
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5985
5965
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5986
5966
|
var import_math21 = require("@fuel-ts/math");
|
5987
|
-
var
|
5967
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5988
5968
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5989
5969
|
var Signer = class {
|
5990
5970
|
address;
|
@@ -6004,9 +5984,9 @@ var Signer = class {
|
|
6004
5984
|
}
|
6005
5985
|
}
|
6006
5986
|
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
6007
|
-
this.privateKey = (0,
|
6008
|
-
this.publicKey = (0,
|
6009
|
-
this.compressedPublicKey = (0,
|
5987
|
+
this.privateKey = (0, import_utils30.hexlify)(privateKeyBytes);
|
5988
|
+
this.publicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5989
|
+
this.compressedPublicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
6010
5990
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
6011
5991
|
}
|
6012
5992
|
/**
|
@@ -6020,11 +6000,11 @@ var Signer = class {
|
|
6020
6000
|
* @returns hashed signature
|
6021
6001
|
*/
|
6022
6002
|
sign(data) {
|
6023
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
6003
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils30.arrayify)(data), (0, import_utils30.arrayify)(this.privateKey));
|
6024
6004
|
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
6025
6005
|
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
6026
6006
|
s[0] |= (signature.recovery || 0) << 7;
|
6027
|
-
return (0,
|
6007
|
+
return (0, import_utils30.hexlify)((0, import_utils30.concat)([r, s]));
|
6028
6008
|
}
|
6029
6009
|
/**
|
6030
6010
|
* Add point on the current elliptic curve
|
@@ -6033,8 +6013,8 @@ var Signer = class {
|
|
6033
6013
|
* @returns compressed point on the curve
|
6034
6014
|
*/
|
6035
6015
|
addPoint(point) {
|
6036
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6037
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6016
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(this.compressedPublicKey));
|
6017
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(point));
|
6038
6018
|
const result = p0.add(p1);
|
6039
6019
|
return `0x${result.toHex(true)}`;
|
6040
6020
|
}
|
@@ -6046,16 +6026,16 @@ var Signer = class {
|
|
6046
6026
|
* @returns public key from signature from the
|
6047
6027
|
*/
|
6048
6028
|
static recoverPublicKey(data, signature) {
|
6049
|
-
const signedMessageBytes = (0,
|
6029
|
+
const signedMessageBytes = (0, import_utils30.arrayify)(signature);
|
6050
6030
|
const r = signedMessageBytes.slice(0, 32);
|
6051
6031
|
const s = signedMessageBytes.slice(32, 64);
|
6052
6032
|
const recoveryParam = (s[0] & 128) >> 7;
|
6053
6033
|
s[0] &= 127;
|
6054
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
6034
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils30.hexlify)(r)), BigInt((0, import_utils30.hexlify)(s))).addRecoveryBit(
|
6055
6035
|
recoveryParam
|
6056
6036
|
);
|
6057
|
-
const publicKey = sig.recoverPublicKey((0,
|
6058
|
-
return (0,
|
6037
|
+
const publicKey = sig.recoverPublicKey((0, import_utils30.arrayify)(data)).toRawBytes(false).slice(1);
|
6038
|
+
return (0, import_utils30.hexlify)(publicKey);
|
6059
6039
|
}
|
6060
6040
|
/**
|
6061
6041
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -6074,7 +6054,7 @@ var Signer = class {
|
|
6074
6054
|
* @returns random 32-byte hashed
|
6075
6055
|
*/
|
6076
6056
|
static generatePrivateKey(entropy) {
|
6077
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
6057
|
+
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);
|
6078
6058
|
}
|
6079
6059
|
/**
|
6080
6060
|
* Extended publicKey from a compact publicKey
|
@@ -6083,8 +6063,8 @@ var Signer = class {
|
|
6083
6063
|
* @returns extended publicKey
|
6084
6064
|
*/
|
6085
6065
|
static extendPublicKey(publicKey) {
|
6086
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6087
|
-
return (0,
|
6066
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(publicKey));
|
6067
|
+
return (0, import_utils30.hexlify)(point.toRawBytes(false).slice(1));
|
6088
6068
|
}
|
6089
6069
|
};
|
6090
6070
|
|
@@ -6092,7 +6072,7 @@ var Signer = class {
|
|
6092
6072
|
var import_address6 = require("@fuel-ts/address");
|
6093
6073
|
var import_crypto3 = require("@fuel-ts/crypto");
|
6094
6074
|
var import_errors17 = require("@fuel-ts/errors");
|
6095
|
-
var
|
6075
|
+
var import_utils31 = require("@fuel-ts/utils");
|
6096
6076
|
var import_uuid = require("uuid");
|
6097
6077
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6098
6078
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6175,7 +6155,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6175
6155
|
);
|
6176
6156
|
}
|
6177
6157
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6178
|
-
const privateKey = (0,
|
6158
|
+
const privateKey = (0, import_utils31.hexlify)(buffer);
|
6179
6159
|
return privateKey;
|
6180
6160
|
}
|
6181
6161
|
|
@@ -6220,7 +6200,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6220
6200
|
*/
|
6221
6201
|
async signMessage(message) {
|
6222
6202
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
6223
|
-
return (0,
|
6203
|
+
return (0, import_utils32.hexlify)(signedMessage);
|
6224
6204
|
}
|
6225
6205
|
/**
|
6226
6206
|
* Signs a transaction with the wallet's private key.
|
@@ -6233,7 +6213,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6233
6213
|
const chainId = this.provider.getChainId();
|
6234
6214
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6235
6215
|
const signature = await this.signer().sign(hashedTransaction);
|
6236
|
-
return (0,
|
6216
|
+
return (0, import_utils32.hexlify)(signature);
|
6237
6217
|
}
|
6238
6218
|
/**
|
6239
6219
|
* Populates a transaction with the witnesses signature.
|
@@ -6304,13 +6284,13 @@ var import_crypto5 = require("@fuel-ts/crypto");
|
|
6304
6284
|
var import_errors20 = require("@fuel-ts/errors");
|
6305
6285
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6306
6286
|
var import_math22 = require("@fuel-ts/math");
|
6307
|
-
var
|
6287
|
+
var import_utils36 = require("@fuel-ts/utils");
|
6308
6288
|
|
6309
6289
|
// src/mnemonic/mnemonic.ts
|
6310
6290
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6311
6291
|
var import_errors19 = require("@fuel-ts/errors");
|
6312
6292
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6313
|
-
var
|
6293
|
+
var import_utils34 = require("@fuel-ts/utils");
|
6314
6294
|
|
6315
6295
|
// src/wordlists/words/english.ts
|
6316
6296
|
var english = [
|
@@ -8373,7 +8353,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8373
8353
|
// src/mnemonic/utils.ts
|
8374
8354
|
var import_errors18 = require("@fuel-ts/errors");
|
8375
8355
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8376
|
-
var
|
8356
|
+
var import_utils33 = require("@fuel-ts/utils");
|
8377
8357
|
function getLowerMask(bits) {
|
8378
8358
|
return (1 << bits) - 1;
|
8379
8359
|
}
|
@@ -8408,14 +8388,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
8408
8388
|
}
|
8409
8389
|
}
|
8410
8390
|
const checksumBits = entropy.length / 4;
|
8411
|
-
const checksum = (0,
|
8391
|
+
const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8412
8392
|
indices[indices.length - 1] <<= checksumBits;
|
8413
8393
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8414
8394
|
return indices;
|
8415
8395
|
}
|
8416
8396
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8417
8397
|
const size = Math.ceil(11 * words.length / 8);
|
8418
|
-
const entropy = (0,
|
8398
|
+
const entropy = (0, import_utils33.arrayify)(new Uint8Array(size));
|
8419
8399
|
let offset = 0;
|
8420
8400
|
for (let i = 0; i < words.length; i += 1) {
|
8421
8401
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -8435,7 +8415,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8435
8415
|
const entropyBits = 32 * words.length / 3;
|
8436
8416
|
const checksumBits = words.length / 3;
|
8437
8417
|
const checksumMask = getUpperMask(checksumBits);
|
8438
|
-
const checksum = (0,
|
8418
|
+
const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8439
8419
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8440
8420
|
throw new import_errors18.FuelError(
|
8441
8421
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -8446,7 +8426,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8446
8426
|
}
|
8447
8427
|
|
8448
8428
|
// src/mnemonic/mnemonic.ts
|
8449
|
-
var MasterSecret = (0,
|
8429
|
+
var MasterSecret = (0, import_utils34.toUtf8Bytes)("Bitcoin seed");
|
8450
8430
|
var MainnetPRV = "0x0488ade4";
|
8451
8431
|
var TestnetPRV = "0x04358394";
|
8452
8432
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -8510,7 +8490,7 @@ var Mnemonic = class {
|
|
8510
8490
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8511
8491
|
const words = getWords(phrase);
|
8512
8492
|
assertMnemonic(words);
|
8513
|
-
return (0,
|
8493
|
+
return (0, import_utils34.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8514
8494
|
}
|
8515
8495
|
/**
|
8516
8496
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8518,7 +8498,7 @@ var Mnemonic = class {
|
|
8518
8498
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8519
8499
|
*/
|
8520
8500
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8521
|
-
const entropyBytes = (0,
|
8501
|
+
const entropyBytes = (0, import_utils34.arrayify)(entropy);
|
8522
8502
|
assertWordList(wordlist);
|
8523
8503
|
assertEntropy(entropyBytes);
|
8524
8504
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8530,8 +8510,8 @@ var Mnemonic = class {
|
|
8530
8510
|
*/
|
8531
8511
|
static mnemonicToSeed(phrase, passphrase = "") {
|
8532
8512
|
assertMnemonic(getWords(phrase));
|
8533
|
-
const phraseBytes = (0,
|
8534
|
-
const salt = (0,
|
8513
|
+
const phraseBytes = (0, import_utils34.toUtf8Bytes)(getPhrase(phrase));
|
8514
|
+
const salt = (0, import_utils34.toUtf8Bytes)(`mnemonic${passphrase}`);
|
8535
8515
|
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8536
8516
|
}
|
8537
8517
|
/**
|
@@ -8587,14 +8567,14 @@ var Mnemonic = class {
|
|
8587
8567
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8588
8568
|
*/
|
8589
8569
|
static masterKeysFromSeed(seed) {
|
8590
|
-
const seedArray = (0,
|
8570
|
+
const seedArray = (0, import_utils34.arrayify)(seed);
|
8591
8571
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8592
8572
|
throw new import_errors19.FuelError(
|
8593
8573
|
import_errors19.ErrorCode.INVALID_SEED,
|
8594
8574
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8595
8575
|
);
|
8596
8576
|
}
|
8597
|
-
return (0,
|
8577
|
+
return (0, import_utils34.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
8598
8578
|
}
|
8599
8579
|
/**
|
8600
8580
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8605,22 +8585,22 @@ var Mnemonic = class {
|
|
8605
8585
|
*/
|
8606
8586
|
static seedToExtendedKey(seed, testnet = false) {
|
8607
8587
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8608
|
-
const prefix = (0,
|
8588
|
+
const prefix = (0, import_utils34.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8609
8589
|
const depth = "0x00";
|
8610
8590
|
const fingerprint = "0x00000000";
|
8611
8591
|
const index = "0x00000000";
|
8612
8592
|
const chainCode = masterKey.slice(32);
|
8613
8593
|
const privateKey = masterKey.slice(0, 32);
|
8614
|
-
const extendedKey = (0,
|
8594
|
+
const extendedKey = (0, import_utils34.concat)([
|
8615
8595
|
prefix,
|
8616
8596
|
depth,
|
8617
8597
|
fingerprint,
|
8618
8598
|
index,
|
8619
8599
|
chainCode,
|
8620
|
-
(0,
|
8600
|
+
(0, import_utils34.concat)(["0x00", privateKey])
|
8621
8601
|
]);
|
8622
|
-
const checksum = (0,
|
8623
|
-
return (0,
|
8602
|
+
const checksum = (0, import_utils34.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8603
|
+
return (0, import_utils34.encodeBase58)((0, import_utils34.concat)([extendedKey, checksum]));
|
8624
8604
|
}
|
8625
8605
|
/**
|
8626
8606
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8635,7 +8615,7 @@ var Mnemonic = class {
|
|
8635
8615
|
* @returns A randomly generated mnemonic
|
8636
8616
|
*/
|
8637
8617
|
static generate(size = 32, extraEntropy = "") {
|
8638
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8618
|
+
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);
|
8639
8619
|
return Mnemonic.entropyToMnemonic(entropy);
|
8640
8620
|
}
|
8641
8621
|
};
|
@@ -8643,12 +8623,12 @@ var mnemonic_default = Mnemonic;
|
|
8643
8623
|
|
8644
8624
|
// src/hdwallet/hdwallet.ts
|
8645
8625
|
var HARDENED_INDEX = 2147483648;
|
8646
|
-
var MainnetPRV2 = (0,
|
8647
|
-
var MainnetPUB = (0,
|
8648
|
-
var TestnetPRV2 = (0,
|
8649
|
-
var TestnetPUB = (0,
|
8626
|
+
var MainnetPRV2 = (0, import_utils36.hexlify)("0x0488ade4");
|
8627
|
+
var MainnetPUB = (0, import_utils36.hexlify)("0x0488b21e");
|
8628
|
+
var TestnetPRV2 = (0, import_utils36.hexlify)("0x04358394");
|
8629
|
+
var TestnetPUB = (0, import_utils36.hexlify)("0x043587cf");
|
8650
8630
|
function base58check(data) {
|
8651
|
-
return (0,
|
8631
|
+
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)]));
|
8652
8632
|
}
|
8653
8633
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8654
8634
|
if (isPublic) {
|
@@ -8657,11 +8637,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8657
8637
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8658
8638
|
}
|
8659
8639
|
function isPublicExtendedKey(extendedKey) {
|
8660
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8640
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils36.hexlify)(extendedKey.slice(0, 4)));
|
8661
8641
|
}
|
8662
8642
|
function isValidExtendedKey(extendedKey) {
|
8663
8643
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8664
|
-
(0,
|
8644
|
+
(0, import_utils36.hexlify)(extendedKey.slice(0, 4))
|
8665
8645
|
);
|
8666
8646
|
}
|
8667
8647
|
function parsePath(path, depth = 0) {
|
@@ -8679,8 +8659,8 @@ function parsePath(path, depth = 0) {
|
|
8679
8659
|
var HDWallet = class {
|
8680
8660
|
depth = 0;
|
8681
8661
|
index = 0;
|
8682
|
-
fingerprint = (0,
|
8683
|
-
parentFingerprint = (0,
|
8662
|
+
fingerprint = (0, import_utils36.hexlify)("0x00000000");
|
8663
|
+
parentFingerprint = (0, import_utils36.hexlify)("0x00000000");
|
8684
8664
|
privateKey;
|
8685
8665
|
publicKey;
|
8686
8666
|
chainCode;
|
@@ -8692,8 +8672,8 @@ var HDWallet = class {
|
|
8692
8672
|
constructor(config) {
|
8693
8673
|
if (config.privateKey) {
|
8694
8674
|
const signer = new Signer(config.privateKey);
|
8695
|
-
this.publicKey = (0,
|
8696
|
-
this.privateKey = (0,
|
8675
|
+
this.publicKey = (0, import_utils36.hexlify)(signer.compressedPublicKey);
|
8676
|
+
this.privateKey = (0, import_utils36.hexlify)(config.privateKey);
|
8697
8677
|
} else {
|
8698
8678
|
if (!config.publicKey) {
|
8699
8679
|
throw new import_errors20.FuelError(
|
@@ -8701,10 +8681,10 @@ var HDWallet = class {
|
|
8701
8681
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8702
8682
|
);
|
8703
8683
|
}
|
8704
|
-
this.publicKey = (0,
|
8684
|
+
this.publicKey = (0, import_utils36.hexlify)(config.publicKey);
|
8705
8685
|
}
|
8706
8686
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8707
|
-
this.fingerprint = (0,
|
8687
|
+
this.fingerprint = (0, import_utils36.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8708
8688
|
this.depth = config.depth || this.depth;
|
8709
8689
|
this.index = config.index || this.index;
|
8710
8690
|
this.chainCode = config.chainCode;
|
@@ -8720,9 +8700,9 @@ var HDWallet = class {
|
|
8720
8700
|
* @returns A new instance of HDWallet on the derived index
|
8721
8701
|
*/
|
8722
8702
|
deriveIndex(index) {
|
8723
|
-
const privateKey = this.privateKey && (0,
|
8724
|
-
const publicKey = (0,
|
8725
|
-
const chainCode = (0,
|
8703
|
+
const privateKey = this.privateKey && (0, import_utils36.arrayify)(this.privateKey);
|
8704
|
+
const publicKey = (0, import_utils36.arrayify)(this.publicKey);
|
8705
|
+
const chainCode = (0, import_utils36.arrayify)(this.chainCode);
|
8726
8706
|
const data = new Uint8Array(37);
|
8727
8707
|
if (index & HARDENED_INDEX) {
|
8728
8708
|
if (!privateKey) {
|
@@ -8733,10 +8713,10 @@ var HDWallet = class {
|
|
8733
8713
|
}
|
8734
8714
|
data.set(privateKey, 1);
|
8735
8715
|
} else {
|
8736
|
-
data.set((0,
|
8716
|
+
data.set((0, import_utils36.arrayify)(this.publicKey));
|
8737
8717
|
}
|
8738
8718
|
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8739
|
-
const bytes = (0,
|
8719
|
+
const bytes = (0, import_utils36.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8740
8720
|
const IL = bytes.slice(0, 32);
|
8741
8721
|
const IR = bytes.slice(32);
|
8742
8722
|
if (privateKey) {
|
@@ -8750,7 +8730,7 @@ var HDWallet = class {
|
|
8750
8730
|
parentFingerprint: this.fingerprint
|
8751
8731
|
});
|
8752
8732
|
}
|
8753
|
-
const signer = new Signer((0,
|
8733
|
+
const signer = new Signer((0, import_utils36.hexlify)(IL));
|
8754
8734
|
const Ki = signer.addPoint(publicKey);
|
8755
8735
|
return new HDWallet({
|
8756
8736
|
publicKey: Ki,
|
@@ -8785,12 +8765,12 @@ var HDWallet = class {
|
|
8785
8765
|
);
|
8786
8766
|
}
|
8787
8767
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8788
|
-
const depth = (0,
|
8768
|
+
const depth = (0, import_utils36.hexlify)(Uint8Array.from([this.depth]));
|
8789
8769
|
const parentFingerprint = this.parentFingerprint;
|
8790
8770
|
const index = (0, import_math22.toHex)(this.index, 4);
|
8791
8771
|
const chainCode = this.chainCode;
|
8792
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8793
|
-
const extendedKey = (0,
|
8772
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils36.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8773
|
+
const extendedKey = (0, import_utils36.arrayify)((0, import_utils36.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8794
8774
|
return base58check(extendedKey);
|
8795
8775
|
}
|
8796
8776
|
/**
|
@@ -8802,13 +8782,13 @@ var HDWallet = class {
|
|
8802
8782
|
static fromSeed(seed) {
|
8803
8783
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8804
8784
|
return new HDWallet({
|
8805
|
-
chainCode: (0,
|
8806
|
-
privateKey: (0,
|
8785
|
+
chainCode: (0, import_utils36.arrayify)(masterKey.slice(32)),
|
8786
|
+
privateKey: (0, import_utils36.arrayify)(masterKey.slice(0, 32))
|
8807
8787
|
});
|
8808
8788
|
}
|
8809
8789
|
static fromExtendedKey(extendedKey) {
|
8810
|
-
const decoded = (0,
|
8811
|
-
const bytes = (0,
|
8790
|
+
const decoded = (0, import_utils36.hexlify)((0, import_math22.toBytes)((0, import_utils36.decodeBase58)(extendedKey)));
|
8791
|
+
const bytes = (0, import_utils36.arrayify)(decoded);
|
8812
8792
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8813
8793
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8814
8794
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8817,9 +8797,9 @@ var HDWallet = class {
|
|
8817
8797
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8818
8798
|
}
|
8819
8799
|
const depth = bytes[4];
|
8820
|
-
const parentFingerprint = (0,
|
8821
|
-
const index = parseInt((0,
|
8822
|
-
const chainCode = (0,
|
8800
|
+
const parentFingerprint = (0, import_utils36.hexlify)(bytes.slice(5, 9));
|
8801
|
+
const index = parseInt((0, import_utils36.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8802
|
+
const chainCode = (0, import_utils36.hexlify)(bytes.slice(13, 45));
|
8823
8803
|
const key = bytes.slice(45, 78);
|
8824
8804
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8825
8805
|
throw new import_errors20.FuelError(
|
@@ -9423,18 +9403,18 @@ var StorageAbstract = class {
|
|
9423
9403
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
9424
9404
|
var import_address10 = require("@fuel-ts/address");
|
9425
9405
|
var import_errors25 = require("@fuel-ts/errors");
|
9426
|
-
var
|
9406
|
+
var import_utils38 = require("@fuel-ts/utils");
|
9427
9407
|
|
9428
9408
|
// src/predicate/utils/getPredicateRoot.ts
|
9429
9409
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9430
9410
|
var import_merkle = require("@fuel-ts/merkle");
|
9431
|
-
var
|
9411
|
+
var import_utils37 = require("@fuel-ts/utils");
|
9432
9412
|
var getPredicateRoot = (bytecode) => {
|
9433
9413
|
const chunkSize = 16 * 1024;
|
9434
|
-
const bytes = (0,
|
9435
|
-
const chunks = (0,
|
9436
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
9437
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9414
|
+
const bytes = (0, import_utils37.arrayify)(bytecode);
|
9415
|
+
const chunks = (0, import_utils37.chunkAndPadBytes)(bytes, chunkSize);
|
9416
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils37.hexlify)(c)));
|
9417
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils37.concat)(["0x4655454C", codeRoot]));
|
9438
9418
|
return predicateRoot;
|
9439
9419
|
};
|
9440
9420
|
|
@@ -9486,8 +9466,8 @@ var Predicate = class extends Account {
|
|
9486
9466
|
}
|
9487
9467
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9488
9468
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9489
|
-
input.predicate = (0,
|
9490
|
-
input.predicateData = (0,
|
9469
|
+
input.predicate = (0, import_utils38.hexlify)(this.bytes);
|
9470
|
+
input.predicateData = (0, import_utils38.hexlify)(this.getPredicateData());
|
9491
9471
|
input.witnessIndex = 0;
|
9492
9472
|
}
|
9493
9473
|
});
|
@@ -9529,7 +9509,7 @@ var Predicate = class extends Account {
|
|
9529
9509
|
* @returns An object containing the new predicate bytes and interface.
|
9530
9510
|
*/
|
9531
9511
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9532
|
-
let predicateBytes = (0,
|
9512
|
+
let predicateBytes = (0, import_utils38.arrayify)(bytes);
|
9533
9513
|
let abiInterface;
|
9534
9514
|
if (jsonAbi) {
|
9535
9515
|
abiInterface = new import_abi_coder7.Interface(jsonAbi);
|
@@ -9567,8 +9547,8 @@ var Predicate = class extends Account {
|
|
9567
9547
|
);
|
9568
9548
|
return resources.map((resource) => ({
|
9569
9549
|
...resource,
|
9570
|
-
predicate: (0,
|
9571
|
-
predicateData: (0,
|
9550
|
+
predicate: (0, import_utils38.hexlify)(this.bytes),
|
9551
|
+
predicateData: (0, import_utils38.hexlify)(this.getPredicateData())
|
9572
9552
|
}));
|
9573
9553
|
}
|
9574
9554
|
/**
|
@@ -10433,7 +10413,6 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10433
10413
|
resolveGasDependentCosts,
|
10434
10414
|
resolveIconPaths,
|
10435
10415
|
returnZeroScript,
|
10436
|
-
sleep,
|
10437
10416
|
transactionRequestify,
|
10438
10417
|
urlJoin,
|
10439
10418
|
withTimeout,
|