@fuel-ts/account 0.89.2 → 0.90.0
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/account.d.ts +8 -0
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts +3 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +4 -2
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +10 -4
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +7 -3
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +3328 -3275
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +217 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +121 -72
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +8 -0
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +58 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/chains.d.ts +1 -1
- package/dist/providers/provider.d.ts +12 -2
- package/dist/providers/provider.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/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.d.ts +8 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.global.js +2275 -1900
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +491 -210
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +398 -121
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +1 -1
- package/package.json +18 -17
- package/dist/providers/utils/sleep.d.ts +0 -3
- package/dist/providers/utils/sleep.d.ts.map +0 -1
- package/dist/test-utils/index.d.ts +0 -4
- package/dist/test-utils/index.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,
|
@@ -195,11 +194,13 @@ __export(src_exports, {
|
|
195
194
|
module.exports = __toCommonJS(src_exports);
|
196
195
|
|
197
196
|
// src/account.ts
|
197
|
+
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
198
198
|
var import_address4 = require("@fuel-ts/address");
|
199
|
+
var import_crypto2 = require("@fuel-ts/crypto");
|
199
200
|
var import_errors16 = require("@fuel-ts/errors");
|
200
201
|
var import_interfaces = require("@fuel-ts/interfaces");
|
201
202
|
var import_math20 = require("@fuel-ts/math");
|
202
|
-
var
|
203
|
+
var import_utils29 = require("@fuel-ts/utils");
|
203
204
|
var import_ramda4 = require("ramda");
|
204
205
|
|
205
206
|
// src/providers/coin-quantity.ts
|
@@ -242,9 +243,9 @@ var import_address3 = require("@fuel-ts/address");
|
|
242
243
|
var import_errors14 = require("@fuel-ts/errors");
|
243
244
|
var import_math17 = require("@fuel-ts/math");
|
244
245
|
var import_transactions20 = require("@fuel-ts/transactions");
|
245
|
-
var
|
246
|
+
var import_utils23 = require("@fuel-ts/utils");
|
246
247
|
var import_versions = require("@fuel-ts/versions");
|
247
|
-
var
|
248
|
+
var import_utils24 = require("@noble/curves/abstract/utils");
|
248
249
|
var import_graphql_request = require("graphql-request");
|
249
250
|
var import_ramda3 = require("ramda");
|
250
251
|
|
@@ -469,6 +470,7 @@ var MessageProofFragmentDoc = import_graphql_tag.default`
|
|
469
470
|
proofIndex
|
470
471
|
}
|
471
472
|
messageBlockHeader {
|
473
|
+
version
|
472
474
|
id
|
473
475
|
daHeight
|
474
476
|
consensusParametersVersion
|
@@ -484,6 +486,7 @@ var MessageProofFragmentDoc = import_graphql_tag.default`
|
|
484
486
|
applicationHash
|
485
487
|
}
|
486
488
|
commitBlockHeader {
|
489
|
+
version
|
487
490
|
id
|
488
491
|
daHeight
|
489
492
|
consensusParametersVersion
|
@@ -670,6 +673,9 @@ var GasCostsFragmentDoc = import_graphql_tag.default`
|
|
670
673
|
wqmm
|
671
674
|
xor
|
672
675
|
xori
|
676
|
+
alocDependentCost {
|
677
|
+
...DependentCostFragment
|
678
|
+
}
|
673
679
|
call {
|
674
680
|
...DependentCostFragment
|
675
681
|
}
|
@@ -854,9 +860,13 @@ var GetTransactionsDocument = import_graphql_tag.default`
|
|
854
860
|
...transactionFragment
|
855
861
|
}
|
856
862
|
}
|
863
|
+
pageInfo {
|
864
|
+
...pageInfoFragment
|
865
|
+
}
|
857
866
|
}
|
858
867
|
}
|
859
|
-
${TransactionFragmentDoc}
|
868
|
+
${TransactionFragmentDoc}
|
869
|
+
${PageInfoFragmentDoc}`;
|
860
870
|
var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
861
871
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
862
872
|
transactionsByOwner(
|
@@ -1048,8 +1058,12 @@ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
|
|
1048
1058
|
}
|
1049
1059
|
${RelayedTransactionStatusFragmentDoc}`;
|
1050
1060
|
var DryRunDocument = import_graphql_tag.default`
|
1051
|
-
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
1052
|
-
dryRun(
|
1061
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean, $gasPrice: U64) {
|
1062
|
+
dryRun(
|
1063
|
+
txs: $encodedTransactions
|
1064
|
+
utxoValidation: $utxoValidation
|
1065
|
+
gasPrice: $gasPrice
|
1066
|
+
) {
|
1053
1067
|
...dryRunTransactionExecutionStatusFragment
|
1054
1068
|
}
|
1055
1069
|
}
|
@@ -1865,15 +1879,6 @@ function normalizeJSON(root) {
|
|
1865
1879
|
return normalize((0, import_ramda.clone)(root));
|
1866
1880
|
}
|
1867
1881
|
|
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
1882
|
// src/providers/utils/extract-tx-error.ts
|
1878
1883
|
var import_errors7 = require("@fuel-ts/errors");
|
1879
1884
|
var import_math6 = require("@fuel-ts/math");
|
@@ -3895,6 +3900,7 @@ var TransactionResponse = class {
|
|
3895
3900
|
};
|
3896
3901
|
|
3897
3902
|
// src/providers/utils/auto-retry-fetch.ts
|
3903
|
+
var import_utils22 = require("@fuel-ts/utils");
|
3898
3904
|
function getWaitDelay(options, retryAttemptNum) {
|
3899
3905
|
const duration = options.baseDelay ?? 150;
|
3900
3906
|
switch (options.backoff) {
|
@@ -3924,7 +3930,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3924
3930
|
throw error;
|
3925
3931
|
}
|
3926
3932
|
const delay = getWaitDelay(options, retryNum);
|
3927
|
-
await sleep(delay);
|
3933
|
+
await (0, import_utils22.sleep)(delay);
|
3928
3934
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3929
3935
|
}
|
3930
3936
|
};
|
@@ -4283,7 +4289,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4283
4289
|
if (estimateTxDependencies) {
|
4284
4290
|
await this.estimateTxDependencies(transactionRequest);
|
4285
4291
|
}
|
4286
|
-
const encodedTransaction = (0,
|
4292
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4287
4293
|
let abis;
|
4288
4294
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4289
4295
|
abis = transactionRequest.abis;
|
@@ -4321,12 +4327,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4321
4327
|
* @param sendTransactionParams - The provider call parameters (optional).
|
4322
4328
|
* @returns A promise that resolves to the call result object.
|
4323
4329
|
*/
|
4324
|
-
async
|
4330
|
+
async dryRun(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4325
4331
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4326
4332
|
if (estimateTxDependencies) {
|
4327
4333
|
return this.estimateTxDependencies(transactionRequest);
|
4328
4334
|
}
|
4329
|
-
const encodedTransaction = (0,
|
4335
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4330
4336
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4331
4337
|
encodedTransactions: encodedTransaction,
|
4332
4338
|
utxoValidation: utxoValidation || false
|
@@ -4346,13 +4352,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4346
4352
|
async estimatePredicates(transactionRequest) {
|
4347
4353
|
const shouldEstimatePredicates = Boolean(
|
4348
4354
|
transactionRequest.inputs.find(
|
4349
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4355
|
+
(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
4356
|
)
|
4351
4357
|
);
|
4352
4358
|
if (!shouldEstimatePredicates) {
|
4353
4359
|
return transactionRequest;
|
4354
4360
|
}
|
4355
|
-
const encodedTransaction = (0,
|
4361
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4356
4362
|
const response = await this.operations.estimatePredicates({
|
4357
4363
|
encodedTransaction
|
4358
4364
|
});
|
@@ -4393,7 +4399,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4393
4399
|
const {
|
4394
4400
|
dryRun: [{ receipts: rawReceipts, status }]
|
4395
4401
|
} = await this.operations.dryRun({
|
4396
|
-
encodedTransactions: [(0,
|
4402
|
+
encodedTransactions: [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())],
|
4397
4403
|
utxoValidation: false
|
4398
4404
|
});
|
4399
4405
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4443,7 +4449,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4443
4449
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4444
4450
|
allRequests.forEach((req, index) => {
|
4445
4451
|
if (req.type === import_transactions20.TransactionType.Script) {
|
4446
|
-
serializedTransactionsMap.set(index, (0,
|
4452
|
+
serializedTransactionsMap.set(index, (0, import_utils23.hexlify)(req.toTransactionBytes()));
|
4447
4453
|
}
|
4448
4454
|
});
|
4449
4455
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4479,7 +4485,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4479
4485
|
transactionRequest: request
|
4480
4486
|
});
|
4481
4487
|
request.maxFee = maxFee;
|
4482
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
4488
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils23.hexlify)(request.toTransactionBytes()));
|
4483
4489
|
nextRoundTransactions.push(requestIdx);
|
4484
4490
|
}
|
4485
4491
|
}
|
@@ -4500,7 +4506,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4500
4506
|
if (estimateTxDependencies) {
|
4501
4507
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4502
4508
|
}
|
4503
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
4509
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils23.hexlify)(tx.toTransactionBytes()));
|
4504
4510
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4505
4511
|
encodedTransactions,
|
4506
4512
|
utxoValidation: utxoValidation || false
|
@@ -4574,7 +4580,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4574
4580
|
if (estimateTxDependencies) {
|
4575
4581
|
return this.estimateTxDependencies(transactionRequest);
|
4576
4582
|
}
|
4577
|
-
const encodedTransactions = [(0,
|
4583
|
+
const encodedTransactions = [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())];
|
4578
4584
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4579
4585
|
encodedTransactions,
|
4580
4586
|
utxoValidation: true
|
@@ -4703,7 +4709,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4703
4709
|
const result = await this.operations.getCoins({
|
4704
4710
|
first: 10,
|
4705
4711
|
...paginationArgs,
|
4706
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4712
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
4707
4713
|
});
|
4708
4714
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4709
4715
|
return coins.map((coin) => ({
|
@@ -4726,19 +4732,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4726
4732
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4727
4733
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4728
4734
|
const excludeInput = {
|
4729
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4730
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4735
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
|
4736
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
|
4731
4737
|
};
|
4732
4738
|
if (this.cache) {
|
4733
4739
|
const uniqueUtxos = new Set(
|
4734
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4740
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
|
4735
4741
|
);
|
4736
4742
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4737
4743
|
}
|
4738
4744
|
const coinsQuery = {
|
4739
4745
|
owner: ownerAddress.toB256(),
|
4740
4746
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4741
|
-
assetId: (0,
|
4747
|
+
assetId: (0, import_utils23.hexlify)(assetId),
|
4742
4748
|
amount: amount.toString(10),
|
4743
4749
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4744
4750
|
})),
|
@@ -4840,7 +4846,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4840
4846
|
time: block.header.time,
|
4841
4847
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4842
4848
|
transactions: block.transactions.map(
|
4843
|
-
(tx) => new import_transactions20.TransactionCoder().decode((0,
|
4849
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
|
4844
4850
|
)
|
4845
4851
|
};
|
4846
4852
|
}
|
@@ -4856,10 +4862,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4856
4862
|
return null;
|
4857
4863
|
}
|
4858
4864
|
return new import_transactions20.TransactionCoder().decode(
|
4859
|
-
(0,
|
4865
|
+
(0, import_utils23.arrayify)(transaction.rawPayload),
|
4860
4866
|
0
|
4861
4867
|
)?.[0];
|
4862
4868
|
}
|
4869
|
+
/**
|
4870
|
+
* Retrieves transactions based on the provided pagination arguments.
|
4871
|
+
* @param paginationArgs - The pagination arguments for retrieving transactions.
|
4872
|
+
* @returns A promise that resolves to an object containing the retrieved transactions and pagination information.
|
4873
|
+
*/
|
4874
|
+
async getTransactions(paginationArgs) {
|
4875
|
+
const {
|
4876
|
+
transactions: { edges, pageInfo }
|
4877
|
+
} = await this.operations.getTransactions(paginationArgs);
|
4878
|
+
const coder = new import_transactions20.TransactionCoder();
|
4879
|
+
const transactions = edges.map(
|
4880
|
+
({ node: { rawPayload } }) => coder.decode((0, import_utils23.arrayify)(rawPayload), 0)[0]
|
4881
|
+
);
|
4882
|
+
return { transactions, pageInfo };
|
4883
|
+
}
|
4863
4884
|
/**
|
4864
4885
|
* Get deployed contract with the given ID.
|
4865
4886
|
*
|
@@ -4883,7 +4904,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4883
4904
|
async getContractBalance(contractId, assetId) {
|
4884
4905
|
const { contractBalance } = await this.operations.getContractBalance({
|
4885
4906
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4886
|
-
asset: (0,
|
4907
|
+
asset: (0, import_utils23.hexlify)(assetId)
|
4887
4908
|
});
|
4888
4909
|
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4889
4910
|
}
|
@@ -4897,7 +4918,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4897
4918
|
async getBalance(owner, assetId) {
|
4898
4919
|
const { balance } = await this.operations.getBalance({
|
4899
4920
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4900
|
-
assetId: (0,
|
4921
|
+
assetId: (0, import_utils23.hexlify)(assetId)
|
4901
4922
|
});
|
4902
4923
|
return (0, import_math17.bn)(balance.amount, 10);
|
4903
4924
|
}
|
@@ -5085,7 +5106,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5085
5106
|
async produceBlocks(amount, startTime) {
|
5086
5107
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5087
5108
|
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
5088
|
-
startTimestamp: startTime ?
|
5109
|
+
startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5089
5110
|
});
|
5090
5111
|
return (0, import_math17.bn)(latestBlockHeight);
|
5091
5112
|
}
|
@@ -5168,7 +5189,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
5168
5189
|
var import_errors15 = require("@fuel-ts/errors");
|
5169
5190
|
var import_math18 = require("@fuel-ts/math");
|
5170
5191
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5171
|
-
var
|
5192
|
+
var import_utils26 = require("@fuel-ts/utils");
|
5172
5193
|
async function getTransactionSummary(params) {
|
5173
5194
|
const { id, provider, abiMap } = params;
|
5174
5195
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -5181,7 +5202,7 @@ async function getTransactionSummary(params) {
|
|
5181
5202
|
);
|
5182
5203
|
}
|
5183
5204
|
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
|
5184
|
-
(0,
|
5205
|
+
(0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
5185
5206
|
0
|
5186
5207
|
);
|
5187
5208
|
let txReceipts = [];
|
@@ -5202,7 +5223,7 @@ async function getTransactionSummary(params) {
|
|
5202
5223
|
id: gqlTransaction.id,
|
5203
5224
|
receipts,
|
5204
5225
|
transaction: decodedTransaction,
|
5205
|
-
transactionBytes: (0,
|
5226
|
+
transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
5206
5227
|
gqlTransactionStatus: gqlTransaction.status,
|
5207
5228
|
gasPerByte: (0, import_math18.bn)(gasPerByte),
|
5208
5229
|
gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
|
@@ -5220,7 +5241,7 @@ async function getTransactionSummary(params) {
|
|
5220
5241
|
}
|
5221
5242
|
async function getTransactionSummaryFromRequest(params) {
|
5222
5243
|
const { provider, transactionRequest, abiMap } = params;
|
5223
|
-
const { receipts } = await provider.
|
5244
|
+
const { receipts } = await provider.dryRun(transactionRequest);
|
5224
5245
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
5225
5246
|
const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
|
5226
5247
|
const transaction = transactionRequest.toTransaction();
|
@@ -5258,7 +5279,7 @@ async function getTransactionsSummaries(params) {
|
|
5258
5279
|
const transactions = edges.map((edge) => {
|
5259
5280
|
const { node: gqlTransaction } = edge;
|
5260
5281
|
const { id, rawPayload, status } = gqlTransaction;
|
5261
|
-
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0,
|
5282
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
|
5262
5283
|
let txReceipts = [];
|
5263
5284
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5264
5285
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5268,7 +5289,7 @@ async function getTransactionsSummaries(params) {
|
|
5268
5289
|
id,
|
5269
5290
|
receipts,
|
5270
5291
|
transaction: decodedTransaction,
|
5271
|
-
transactionBytes: (0,
|
5292
|
+
transactionBytes: (0, import_utils26.arrayify)(rawPayload),
|
5272
5293
|
gqlTransactionStatus: status,
|
5273
5294
|
abiMap,
|
5274
5295
|
gasPerByte,
|
@@ -5298,8 +5319,8 @@ var CHAIN_IDS = {
|
|
5298
5319
|
foundry: 31337
|
5299
5320
|
},
|
5300
5321
|
fuel: {
|
5301
|
-
|
5302
|
-
|
5322
|
+
devnet: 0,
|
5323
|
+
testnet: 0
|
5303
5324
|
}
|
5304
5325
|
};
|
5305
5326
|
|
@@ -5309,7 +5330,7 @@ var getDefaultChainId = (networkType) => {
|
|
5309
5330
|
return CHAIN_IDS.eth.sepolia;
|
5310
5331
|
}
|
5311
5332
|
if (networkType === "fuel") {
|
5312
|
-
return CHAIN_IDS.fuel.
|
5333
|
+
return CHAIN_IDS.fuel.testnet;
|
5313
5334
|
}
|
5314
5335
|
return void 0;
|
5315
5336
|
};
|
@@ -5401,15 +5422,15 @@ var rawAssets = [
|
|
5401
5422
|
},
|
5402
5423
|
{
|
5403
5424
|
type: "fuel",
|
5404
|
-
chainId: CHAIN_IDS.fuel.
|
5425
|
+
chainId: CHAIN_IDS.fuel.devnet,
|
5405
5426
|
decimals: 9,
|
5406
|
-
assetId: "
|
5427
|
+
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
5407
5428
|
},
|
5408
5429
|
{
|
5409
5430
|
type: "fuel",
|
5410
|
-
chainId: CHAIN_IDS.fuel.
|
5431
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
5411
5432
|
decimals: 9,
|
5412
|
-
assetId: "
|
5433
|
+
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
5413
5434
|
}
|
5414
5435
|
]
|
5415
5436
|
}
|
@@ -5419,16 +5440,16 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
5419
5440
|
// src/utils/formatTransferToContractScriptData.ts
|
5420
5441
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5421
5442
|
var import_math19 = require("@fuel-ts/math");
|
5422
|
-
var
|
5443
|
+
var import_utils28 = require("@fuel-ts/utils");
|
5423
5444
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5424
5445
|
var formatTransferToContractScriptData = (params) => {
|
5425
5446
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5426
5447
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5427
5448
|
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
5428
5449
|
const scriptData = Uint8Array.from([
|
5429
|
-
...(0,
|
5450
|
+
...(0, import_utils28.arrayify)(hexlifiedContractId),
|
5430
5451
|
...encoded,
|
5431
|
-
...(0,
|
5452
|
+
...(0, import_utils28.arrayify)(assetId)
|
5432
5453
|
]);
|
5433
5454
|
return scriptData;
|
5434
5455
|
};
|
@@ -5833,14 +5854,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5833
5854
|
*/
|
5834
5855
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5835
5856
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5836
|
-
const recipientDataArray = (0,
|
5857
|
+
const recipientDataArray = (0, import_utils29.arrayify)(
|
5837
5858
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5838
5859
|
);
|
5839
|
-
const amountDataArray = (0,
|
5860
|
+
const amountDataArray = (0, import_utils29.arrayify)(
|
5840
5861
|
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5841
5862
|
);
|
5842
5863
|
const script = new Uint8Array([
|
5843
|
-
...(0,
|
5864
|
+
...(0, import_utils29.arrayify)(withdrawScript.bytes),
|
5844
5865
|
...recipientDataArray,
|
5845
5866
|
...amountDataArray
|
5846
5867
|
]);
|
@@ -5923,6 +5944,21 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5923
5944
|
}
|
5924
5945
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5925
5946
|
}
|
5947
|
+
/**
|
5948
|
+
* Generates an array of fake resources based on the provided coins.
|
5949
|
+
*
|
5950
|
+
* @param coins - An array of `FakeResources` objects representing the coins.
|
5951
|
+
* @returns An array of `Resource` objects with generated properties.
|
5952
|
+
*/
|
5953
|
+
generateFakeResources(coins) {
|
5954
|
+
return coins.map((coin) => ({
|
5955
|
+
id: (0, import_utils29.hexlify)((0, import_crypto2.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
5956
|
+
owner: this.address,
|
5957
|
+
blockCreated: (0, import_math20.bn)(1),
|
5958
|
+
txCreatedIdx: (0, import_math20.bn)(1),
|
5959
|
+
...coin
|
5960
|
+
}));
|
5961
|
+
}
|
5926
5962
|
/** @hidden * */
|
5927
5963
|
validateTransferAmount(amount) {
|
5928
5964
|
if ((0, import_math20.bn)(amount).lte(0)) {
|
@@ -5955,7 +5991,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5955
5991
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5956
5992
|
}) {
|
5957
5993
|
const request = transactionRequestify(transactionRequest);
|
5958
|
-
if (!(0,
|
5994
|
+
if (!(0, import_utils29.isDefined)(setGasLimit)) {
|
5959
5995
|
request.gasLimit = gasUsed;
|
5960
5996
|
} else if (gasUsed.gt(setGasLimit)) {
|
5961
5997
|
throw new import_errors16.FuelError(
|
@@ -5963,7 +5999,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5963
5999
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5964
6000
|
);
|
5965
6001
|
}
|
5966
|
-
if (!(0,
|
6002
|
+
if (!(0, import_utils29.isDefined)(setMaxFee)) {
|
5967
6003
|
request.maxFee = maxFee;
|
5968
6004
|
} else if (maxFee.gt(setMaxFee)) {
|
5969
6005
|
throw new import_errors16.FuelError(
|
@@ -5977,14 +6013,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5977
6013
|
|
5978
6014
|
// src/wallet/base-wallet-unlocked.ts
|
5979
6015
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5980
|
-
var
|
6016
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5981
6017
|
|
5982
6018
|
// src/signer/signer.ts
|
5983
6019
|
var import_address5 = require("@fuel-ts/address");
|
5984
|
-
var
|
6020
|
+
var import_crypto3 = require("@fuel-ts/crypto");
|
5985
6021
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5986
6022
|
var import_math21 = require("@fuel-ts/math");
|
5987
|
-
var
|
6023
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5988
6024
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5989
6025
|
var Signer = class {
|
5990
6026
|
address;
|
@@ -6004,9 +6040,9 @@ var Signer = class {
|
|
6004
6040
|
}
|
6005
6041
|
}
|
6006
6042
|
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
6007
|
-
this.privateKey = (0,
|
6008
|
-
this.publicKey = (0,
|
6009
|
-
this.compressedPublicKey = (0,
|
6043
|
+
this.privateKey = (0, import_utils30.hexlify)(privateKeyBytes);
|
6044
|
+
this.publicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
6045
|
+
this.compressedPublicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
6010
6046
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
6011
6047
|
}
|
6012
6048
|
/**
|
@@ -6020,11 +6056,11 @@ var Signer = class {
|
|
6020
6056
|
* @returns hashed signature
|
6021
6057
|
*/
|
6022
6058
|
sign(data) {
|
6023
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
6059
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils30.arrayify)(data), (0, import_utils30.arrayify)(this.privateKey));
|
6024
6060
|
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
6025
6061
|
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
6026
6062
|
s[0] |= (signature.recovery || 0) << 7;
|
6027
|
-
return (0,
|
6063
|
+
return (0, import_utils30.hexlify)((0, import_utils30.concat)([r, s]));
|
6028
6064
|
}
|
6029
6065
|
/**
|
6030
6066
|
* Add point on the current elliptic curve
|
@@ -6033,8 +6069,8 @@ var Signer = class {
|
|
6033
6069
|
* @returns compressed point on the curve
|
6034
6070
|
*/
|
6035
6071
|
addPoint(point) {
|
6036
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6037
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6072
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(this.compressedPublicKey));
|
6073
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(point));
|
6038
6074
|
const result = p0.add(p1);
|
6039
6075
|
return `0x${result.toHex(true)}`;
|
6040
6076
|
}
|
@@ -6046,16 +6082,16 @@ var Signer = class {
|
|
6046
6082
|
* @returns public key from signature from the
|
6047
6083
|
*/
|
6048
6084
|
static recoverPublicKey(data, signature) {
|
6049
|
-
const signedMessageBytes = (0,
|
6085
|
+
const signedMessageBytes = (0, import_utils30.arrayify)(signature);
|
6050
6086
|
const r = signedMessageBytes.slice(0, 32);
|
6051
6087
|
const s = signedMessageBytes.slice(32, 64);
|
6052
6088
|
const recoveryParam = (s[0] & 128) >> 7;
|
6053
6089
|
s[0] &= 127;
|
6054
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
6090
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils30.hexlify)(r)), BigInt((0, import_utils30.hexlify)(s))).addRecoveryBit(
|
6055
6091
|
recoveryParam
|
6056
6092
|
);
|
6057
|
-
const publicKey = sig.recoverPublicKey((0,
|
6058
|
-
return (0,
|
6093
|
+
const publicKey = sig.recoverPublicKey((0, import_utils30.arrayify)(data)).toRawBytes(false).slice(1);
|
6094
|
+
return (0, import_utils30.hexlify)(publicKey);
|
6059
6095
|
}
|
6060
6096
|
/**
|
6061
6097
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -6074,7 +6110,7 @@ var Signer = class {
|
|
6074
6110
|
* @returns random 32-byte hashed
|
6075
6111
|
*/
|
6076
6112
|
static generatePrivateKey(entropy) {
|
6077
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
6113
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils30.concat)([(0, import_crypto3.randomBytes)(32), (0, import_utils30.arrayify)(entropy)])) : (0, import_crypto3.randomBytes)(32);
|
6078
6114
|
}
|
6079
6115
|
/**
|
6080
6116
|
* Extended publicKey from a compact publicKey
|
@@ -6083,16 +6119,16 @@ var Signer = class {
|
|
6083
6119
|
* @returns extended publicKey
|
6084
6120
|
*/
|
6085
6121
|
static extendPublicKey(publicKey) {
|
6086
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6087
|
-
return (0,
|
6122
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(publicKey));
|
6123
|
+
return (0, import_utils30.hexlify)(point.toRawBytes(false).slice(1));
|
6088
6124
|
}
|
6089
6125
|
};
|
6090
6126
|
|
6091
6127
|
// src/wallet/keystore-wallet.ts
|
6092
6128
|
var import_address6 = require("@fuel-ts/address");
|
6093
|
-
var
|
6129
|
+
var import_crypto4 = require("@fuel-ts/crypto");
|
6094
6130
|
var import_errors17 = require("@fuel-ts/errors");
|
6095
|
-
var
|
6131
|
+
var import_utils31 = require("@fuel-ts/utils");
|
6096
6132
|
var import_uuid = require("uuid");
|
6097
6133
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6098
6134
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6106,22 +6142,22 @@ var removeHexPrefix = (hexString) => {
|
|
6106
6142
|
return hexString;
|
6107
6143
|
};
|
6108
6144
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
6109
|
-
const privateKeyBuffer = (0,
|
6145
|
+
const privateKeyBuffer = (0, import_crypto4.bufferFromString)(removeHexPrefix(privateKey), "hex");
|
6110
6146
|
const ownerAddress = import_address6.Address.fromAddressOrString(address);
|
6111
|
-
const salt = (0,
|
6112
|
-
const key = (0,
|
6113
|
-
password: (0,
|
6147
|
+
const salt = (0, import_crypto4.randomBytes)(DEFAULT_KEY_SIZE);
|
6148
|
+
const key = (0, import_crypto4.scrypt)({
|
6149
|
+
password: (0, import_crypto4.bufferFromString)(password),
|
6114
6150
|
salt,
|
6115
6151
|
dklen: DEFAULT_KEY_SIZE,
|
6116
6152
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
6117
6153
|
r: DEFAULT_KDF_PARAMS_R,
|
6118
6154
|
p: DEFAULT_KDF_PARAMS_P
|
6119
6155
|
});
|
6120
|
-
const iv = (0,
|
6121
|
-
const ciphertext = await (0,
|
6156
|
+
const iv = (0, import_crypto4.randomBytes)(DEFAULT_IV_SIZE);
|
6157
|
+
const ciphertext = await (0, import_crypto4.encryptJsonWalletData)(privateKeyBuffer, key, iv);
|
6122
6158
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
|
6123
|
-
const macHashUint8Array = (0,
|
6124
|
-
const mac = (0,
|
6159
|
+
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
6160
|
+
const mac = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
6125
6161
|
const keystore = {
|
6126
6162
|
id: (0, import_uuid.v4)(),
|
6127
6163
|
version: 3,
|
@@ -6129,15 +6165,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
6129
6165
|
crypto: {
|
6130
6166
|
cipher: "aes-128-ctr",
|
6131
6167
|
mac,
|
6132
|
-
cipherparams: { iv: (0,
|
6133
|
-
ciphertext: (0,
|
6168
|
+
cipherparams: { iv: (0, import_crypto4.stringFromBuffer)(iv, "hex") },
|
6169
|
+
ciphertext: (0, import_crypto4.stringFromBuffer)(ciphertext, "hex"),
|
6134
6170
|
kdf: "scrypt",
|
6135
6171
|
kdfparams: {
|
6136
6172
|
dklen: DEFAULT_KEY_SIZE,
|
6137
6173
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
6138
6174
|
p: DEFAULT_KDF_PARAMS_P,
|
6139
6175
|
r: DEFAULT_KDF_PARAMS_R,
|
6140
|
-
salt: (0,
|
6176
|
+
salt: (0, import_crypto4.stringFromBuffer)(salt, "hex")
|
6141
6177
|
}
|
6142
6178
|
}
|
6143
6179
|
};
|
@@ -6153,11 +6189,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6153
6189
|
kdfparams: { dklen, n, r, p, salt }
|
6154
6190
|
}
|
6155
6191
|
} = keystoreWallet;
|
6156
|
-
const ciphertextBuffer = (0,
|
6157
|
-
const ivBuffer = (0,
|
6158
|
-
const saltBuffer = (0,
|
6159
|
-
const passwordBuffer = (0,
|
6160
|
-
const key = (0,
|
6192
|
+
const ciphertextBuffer = (0, import_crypto4.bufferFromString)(ciphertext, "hex");
|
6193
|
+
const ivBuffer = (0, import_crypto4.bufferFromString)(iv, "hex");
|
6194
|
+
const saltBuffer = (0, import_crypto4.bufferFromString)(salt, "hex");
|
6195
|
+
const passwordBuffer = (0, import_crypto4.bufferFromString)(password);
|
6196
|
+
const key = (0, import_crypto4.scrypt)({
|
6161
6197
|
password: passwordBuffer,
|
6162
6198
|
salt: saltBuffer,
|
6163
6199
|
n,
|
@@ -6166,16 +6202,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6166
6202
|
dklen
|
6167
6203
|
});
|
6168
6204
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
|
6169
|
-
const macHashUint8Array = (0,
|
6170
|
-
const macHash = (0,
|
6205
|
+
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
6206
|
+
const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
6171
6207
|
if (mac !== macHash) {
|
6172
6208
|
throw new import_errors17.FuelError(
|
6173
6209
|
import_errors17.ErrorCode.INVALID_PASSWORD,
|
6174
6210
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6175
6211
|
);
|
6176
6212
|
}
|
6177
|
-
const buffer = await (0,
|
6178
|
-
const privateKey = (0,
|
6213
|
+
const buffer = await (0, import_crypto4.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6214
|
+
const privateKey = (0, import_utils31.hexlify)(buffer);
|
6179
6215
|
return privateKey;
|
6180
6216
|
}
|
6181
6217
|
|
@@ -6220,7 +6256,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6220
6256
|
*/
|
6221
6257
|
async signMessage(message) {
|
6222
6258
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
6223
|
-
return (0,
|
6259
|
+
return (0, import_utils32.hexlify)(signedMessage);
|
6224
6260
|
}
|
6225
6261
|
/**
|
6226
6262
|
* Signs a transaction with the wallet's private key.
|
@@ -6233,7 +6269,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6233
6269
|
const chainId = this.provider.getChainId();
|
6234
6270
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6235
6271
|
const signature = await this.signer().sign(hashedTransaction);
|
6236
|
-
return (0,
|
6272
|
+
return (0, import_utils32.hexlify)(signature);
|
6237
6273
|
}
|
6238
6274
|
/**
|
6239
6275
|
* Populates a transaction with the witnesses signature.
|
@@ -6266,7 +6302,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6266
6302
|
);
|
6267
6303
|
}
|
6268
6304
|
/**
|
6269
|
-
* Populates the witness signature for a transaction and sends a call to the network using `provider.
|
6305
|
+
* Populates the witness signature for a transaction and sends a call to the network using `provider.dryRun`.
|
6270
6306
|
*
|
6271
6307
|
* @param transactionRequestLike - The transaction request to simulate.
|
6272
6308
|
* @returns A promise that resolves to the CallResult object.
|
@@ -6276,7 +6312,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6276
6312
|
if (estimateTxDependencies) {
|
6277
6313
|
await this.provider.estimateTxDependencies(transactionRequest);
|
6278
6314
|
}
|
6279
|
-
return this.provider.
|
6315
|
+
return this.provider.dryRun(
|
6280
6316
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
6281
6317
|
{
|
6282
6318
|
utxoValidation: true,
|
@@ -6300,17 +6336,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
6300
6336
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
6301
6337
|
|
6302
6338
|
// src/hdwallet/hdwallet.ts
|
6303
|
-
var
|
6339
|
+
var import_crypto6 = require("@fuel-ts/crypto");
|
6304
6340
|
var import_errors20 = require("@fuel-ts/errors");
|
6305
6341
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6306
6342
|
var import_math22 = require("@fuel-ts/math");
|
6307
|
-
var
|
6343
|
+
var import_utils36 = require("@fuel-ts/utils");
|
6308
6344
|
|
6309
6345
|
// src/mnemonic/mnemonic.ts
|
6310
|
-
var
|
6346
|
+
var import_crypto5 = require("@fuel-ts/crypto");
|
6311
6347
|
var import_errors19 = require("@fuel-ts/errors");
|
6312
6348
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6313
|
-
var
|
6349
|
+
var import_utils34 = require("@fuel-ts/utils");
|
6314
6350
|
|
6315
6351
|
// src/wordlists/words/english.ts
|
6316
6352
|
var english = [
|
@@ -8373,7 +8409,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8373
8409
|
// src/mnemonic/utils.ts
|
8374
8410
|
var import_errors18 = require("@fuel-ts/errors");
|
8375
8411
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8376
|
-
var
|
8412
|
+
var import_utils33 = require("@fuel-ts/utils");
|
8377
8413
|
function getLowerMask(bits) {
|
8378
8414
|
return (1 << bits) - 1;
|
8379
8415
|
}
|
@@ -8408,14 +8444,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
8408
8444
|
}
|
8409
8445
|
}
|
8410
8446
|
const checksumBits = entropy.length / 4;
|
8411
|
-
const checksum = (0,
|
8447
|
+
const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8412
8448
|
indices[indices.length - 1] <<= checksumBits;
|
8413
8449
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8414
8450
|
return indices;
|
8415
8451
|
}
|
8416
8452
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8417
8453
|
const size = Math.ceil(11 * words.length / 8);
|
8418
|
-
const entropy = (0,
|
8454
|
+
const entropy = (0, import_utils33.arrayify)(new Uint8Array(size));
|
8419
8455
|
let offset = 0;
|
8420
8456
|
for (let i = 0; i < words.length; i += 1) {
|
8421
8457
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -8435,7 +8471,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8435
8471
|
const entropyBits = 32 * words.length / 3;
|
8436
8472
|
const checksumBits = words.length / 3;
|
8437
8473
|
const checksumMask = getUpperMask(checksumBits);
|
8438
|
-
const checksum = (0,
|
8474
|
+
const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8439
8475
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8440
8476
|
throw new import_errors18.FuelError(
|
8441
8477
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -8446,7 +8482,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8446
8482
|
}
|
8447
8483
|
|
8448
8484
|
// src/mnemonic/mnemonic.ts
|
8449
|
-
var MasterSecret = (0,
|
8485
|
+
var MasterSecret = (0, import_utils34.toUtf8Bytes)("Bitcoin seed");
|
8450
8486
|
var MainnetPRV = "0x0488ade4";
|
8451
8487
|
var TestnetPRV = "0x04358394";
|
8452
8488
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -8510,7 +8546,7 @@ var Mnemonic = class {
|
|
8510
8546
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8511
8547
|
const words = getWords(phrase);
|
8512
8548
|
assertMnemonic(words);
|
8513
|
-
return (0,
|
8549
|
+
return (0, import_utils34.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8514
8550
|
}
|
8515
8551
|
/**
|
8516
8552
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8518,7 +8554,7 @@ var Mnemonic = class {
|
|
8518
8554
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8519
8555
|
*/
|
8520
8556
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8521
|
-
const entropyBytes = (0,
|
8557
|
+
const entropyBytes = (0, import_utils34.arrayify)(entropy);
|
8522
8558
|
assertWordList(wordlist);
|
8523
8559
|
assertEntropy(entropyBytes);
|
8524
8560
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8530,9 +8566,9 @@ var Mnemonic = class {
|
|
8530
8566
|
*/
|
8531
8567
|
static mnemonicToSeed(phrase, passphrase = "") {
|
8532
8568
|
assertMnemonic(getWords(phrase));
|
8533
|
-
const phraseBytes = (0,
|
8534
|
-
const salt = (0,
|
8535
|
-
return (0,
|
8569
|
+
const phraseBytes = (0, import_utils34.toUtf8Bytes)(getPhrase(phrase));
|
8570
|
+
const salt = (0, import_utils34.toUtf8Bytes)(`mnemonic${passphrase}`);
|
8571
|
+
return (0, import_crypto5.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8536
8572
|
}
|
8537
8573
|
/**
|
8538
8574
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -8587,14 +8623,14 @@ var Mnemonic = class {
|
|
8587
8623
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8588
8624
|
*/
|
8589
8625
|
static masterKeysFromSeed(seed) {
|
8590
|
-
const seedArray = (0,
|
8626
|
+
const seedArray = (0, import_utils34.arrayify)(seed);
|
8591
8627
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8592
8628
|
throw new import_errors19.FuelError(
|
8593
8629
|
import_errors19.ErrorCode.INVALID_SEED,
|
8594
8630
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8595
8631
|
);
|
8596
8632
|
}
|
8597
|
-
return (0,
|
8633
|
+
return (0, import_utils34.arrayify)((0, import_crypto5.computeHmac)("sha512", MasterSecret, seedArray));
|
8598
8634
|
}
|
8599
8635
|
/**
|
8600
8636
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8605,22 +8641,22 @@ var Mnemonic = class {
|
|
8605
8641
|
*/
|
8606
8642
|
static seedToExtendedKey(seed, testnet = false) {
|
8607
8643
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8608
|
-
const prefix = (0,
|
8644
|
+
const prefix = (0, import_utils34.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8609
8645
|
const depth = "0x00";
|
8610
8646
|
const fingerprint = "0x00000000";
|
8611
8647
|
const index = "0x00000000";
|
8612
8648
|
const chainCode = masterKey.slice(32);
|
8613
8649
|
const privateKey = masterKey.slice(0, 32);
|
8614
|
-
const extendedKey = (0,
|
8650
|
+
const extendedKey = (0, import_utils34.concat)([
|
8615
8651
|
prefix,
|
8616
8652
|
depth,
|
8617
8653
|
fingerprint,
|
8618
8654
|
index,
|
8619
8655
|
chainCode,
|
8620
|
-
(0,
|
8656
|
+
(0, import_utils34.concat)(["0x00", privateKey])
|
8621
8657
|
]);
|
8622
|
-
const checksum = (0,
|
8623
|
-
return (0,
|
8658
|
+
const checksum = (0, import_utils34.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8659
|
+
return (0, import_utils34.encodeBase58)((0, import_utils34.concat)([extendedKey, checksum]));
|
8624
8660
|
}
|
8625
8661
|
/**
|
8626
8662
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8635,7 +8671,7 @@ var Mnemonic = class {
|
|
8635
8671
|
* @returns A randomly generated mnemonic
|
8636
8672
|
*/
|
8637
8673
|
static generate(size = 32, extraEntropy = "") {
|
8638
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8674
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils34.concat)([(0, import_crypto5.randomBytes)(size), (0, import_utils34.arrayify)(extraEntropy)])) : (0, import_crypto5.randomBytes)(size);
|
8639
8675
|
return Mnemonic.entropyToMnemonic(entropy);
|
8640
8676
|
}
|
8641
8677
|
};
|
@@ -8643,12 +8679,12 @@ var mnemonic_default = Mnemonic;
|
|
8643
8679
|
|
8644
8680
|
// src/hdwallet/hdwallet.ts
|
8645
8681
|
var HARDENED_INDEX = 2147483648;
|
8646
|
-
var MainnetPRV2 = (0,
|
8647
|
-
var MainnetPUB = (0,
|
8648
|
-
var TestnetPRV2 = (0,
|
8649
|
-
var TestnetPUB = (0,
|
8682
|
+
var MainnetPRV2 = (0, import_utils36.hexlify)("0x0488ade4");
|
8683
|
+
var MainnetPUB = (0, import_utils36.hexlify)("0x0488b21e");
|
8684
|
+
var TestnetPRV2 = (0, import_utils36.hexlify)("0x04358394");
|
8685
|
+
var TestnetPUB = (0, import_utils36.hexlify)("0x043587cf");
|
8650
8686
|
function base58check(data) {
|
8651
|
-
return (0,
|
8687
|
+
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
8688
|
}
|
8653
8689
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8654
8690
|
if (isPublic) {
|
@@ -8657,11 +8693,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8657
8693
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8658
8694
|
}
|
8659
8695
|
function isPublicExtendedKey(extendedKey) {
|
8660
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8696
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils36.hexlify)(extendedKey.slice(0, 4)));
|
8661
8697
|
}
|
8662
8698
|
function isValidExtendedKey(extendedKey) {
|
8663
8699
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8664
|
-
(0,
|
8700
|
+
(0, import_utils36.hexlify)(extendedKey.slice(0, 4))
|
8665
8701
|
);
|
8666
8702
|
}
|
8667
8703
|
function parsePath(path, depth = 0) {
|
@@ -8679,8 +8715,8 @@ function parsePath(path, depth = 0) {
|
|
8679
8715
|
var HDWallet = class {
|
8680
8716
|
depth = 0;
|
8681
8717
|
index = 0;
|
8682
|
-
fingerprint = (0,
|
8683
|
-
parentFingerprint = (0,
|
8718
|
+
fingerprint = (0, import_utils36.hexlify)("0x00000000");
|
8719
|
+
parentFingerprint = (0, import_utils36.hexlify)("0x00000000");
|
8684
8720
|
privateKey;
|
8685
8721
|
publicKey;
|
8686
8722
|
chainCode;
|
@@ -8692,8 +8728,8 @@ var HDWallet = class {
|
|
8692
8728
|
constructor(config) {
|
8693
8729
|
if (config.privateKey) {
|
8694
8730
|
const signer = new Signer(config.privateKey);
|
8695
|
-
this.publicKey = (0,
|
8696
|
-
this.privateKey = (0,
|
8731
|
+
this.publicKey = (0, import_utils36.hexlify)(signer.compressedPublicKey);
|
8732
|
+
this.privateKey = (0, import_utils36.hexlify)(config.privateKey);
|
8697
8733
|
} else {
|
8698
8734
|
if (!config.publicKey) {
|
8699
8735
|
throw new import_errors20.FuelError(
|
@@ -8701,10 +8737,10 @@ var HDWallet = class {
|
|
8701
8737
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8702
8738
|
);
|
8703
8739
|
}
|
8704
|
-
this.publicKey = (0,
|
8740
|
+
this.publicKey = (0, import_utils36.hexlify)(config.publicKey);
|
8705
8741
|
}
|
8706
8742
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8707
|
-
this.fingerprint = (0,
|
8743
|
+
this.fingerprint = (0, import_utils36.dataSlice)((0, import_crypto6.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8708
8744
|
this.depth = config.depth || this.depth;
|
8709
8745
|
this.index = config.index || this.index;
|
8710
8746
|
this.chainCode = config.chainCode;
|
@@ -8720,9 +8756,9 @@ var HDWallet = class {
|
|
8720
8756
|
* @returns A new instance of HDWallet on the derived index
|
8721
8757
|
*/
|
8722
8758
|
deriveIndex(index) {
|
8723
|
-
const privateKey = this.privateKey && (0,
|
8724
|
-
const publicKey = (0,
|
8725
|
-
const chainCode = (0,
|
8759
|
+
const privateKey = this.privateKey && (0, import_utils36.arrayify)(this.privateKey);
|
8760
|
+
const publicKey = (0, import_utils36.arrayify)(this.publicKey);
|
8761
|
+
const chainCode = (0, import_utils36.arrayify)(this.chainCode);
|
8726
8762
|
const data = new Uint8Array(37);
|
8727
8763
|
if (index & HARDENED_INDEX) {
|
8728
8764
|
if (!privateKey) {
|
@@ -8733,10 +8769,10 @@ var HDWallet = class {
|
|
8733
8769
|
}
|
8734
8770
|
data.set(privateKey, 1);
|
8735
8771
|
} else {
|
8736
|
-
data.set((0,
|
8772
|
+
data.set((0, import_utils36.arrayify)(this.publicKey));
|
8737
8773
|
}
|
8738
8774
|
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8739
|
-
const bytes = (0,
|
8775
|
+
const bytes = (0, import_utils36.arrayify)((0, import_crypto6.computeHmac)("sha512", chainCode, data));
|
8740
8776
|
const IL = bytes.slice(0, 32);
|
8741
8777
|
const IR = bytes.slice(32);
|
8742
8778
|
if (privateKey) {
|
@@ -8750,7 +8786,7 @@ var HDWallet = class {
|
|
8750
8786
|
parentFingerprint: this.fingerprint
|
8751
8787
|
});
|
8752
8788
|
}
|
8753
|
-
const signer = new Signer((0,
|
8789
|
+
const signer = new Signer((0, import_utils36.hexlify)(IL));
|
8754
8790
|
const Ki = signer.addPoint(publicKey);
|
8755
8791
|
return new HDWallet({
|
8756
8792
|
publicKey: Ki,
|
@@ -8785,12 +8821,12 @@ var HDWallet = class {
|
|
8785
8821
|
);
|
8786
8822
|
}
|
8787
8823
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8788
|
-
const depth = (0,
|
8824
|
+
const depth = (0, import_utils36.hexlify)(Uint8Array.from([this.depth]));
|
8789
8825
|
const parentFingerprint = this.parentFingerprint;
|
8790
8826
|
const index = (0, import_math22.toHex)(this.index, 4);
|
8791
8827
|
const chainCode = this.chainCode;
|
8792
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8793
|
-
const extendedKey = (0,
|
8828
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils36.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8829
|
+
const extendedKey = (0, import_utils36.arrayify)((0, import_utils36.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8794
8830
|
return base58check(extendedKey);
|
8795
8831
|
}
|
8796
8832
|
/**
|
@@ -8802,13 +8838,13 @@ var HDWallet = class {
|
|
8802
8838
|
static fromSeed(seed) {
|
8803
8839
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8804
8840
|
return new HDWallet({
|
8805
|
-
chainCode: (0,
|
8806
|
-
privateKey: (0,
|
8841
|
+
chainCode: (0, import_utils36.arrayify)(masterKey.slice(32)),
|
8842
|
+
privateKey: (0, import_utils36.arrayify)(masterKey.slice(0, 32))
|
8807
8843
|
});
|
8808
8844
|
}
|
8809
8845
|
static fromExtendedKey(extendedKey) {
|
8810
|
-
const decoded = (0,
|
8811
|
-
const bytes = (0,
|
8846
|
+
const decoded = (0, import_utils36.hexlify)((0, import_math22.toBytes)((0, import_utils36.decodeBase58)(extendedKey)));
|
8847
|
+
const bytes = (0, import_utils36.arrayify)(decoded);
|
8812
8848
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8813
8849
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8814
8850
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8817,9 +8853,9 @@ var HDWallet = class {
|
|
8817
8853
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8818
8854
|
}
|
8819
8855
|
const depth = bytes[4];
|
8820
|
-
const parentFingerprint = (0,
|
8821
|
-
const index = parseInt((0,
|
8822
|
-
const chainCode = (0,
|
8856
|
+
const parentFingerprint = (0, import_utils36.hexlify)(bytes.slice(5, 9));
|
8857
|
+
const index = parseInt((0, import_utils36.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8858
|
+
const chainCode = (0, import_utils36.hexlify)(bytes.slice(13, 45));
|
8823
8859
|
const key = bytes.slice(45, 78);
|
8824
8860
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8825
8861
|
throw new import_errors20.FuelError(
|
@@ -9007,7 +9043,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
9007
9043
|
|
9008
9044
|
// src/wallet-manager/wallet-manager.ts
|
9009
9045
|
var import_address9 = require("@fuel-ts/address");
|
9010
|
-
var
|
9046
|
+
var import_crypto7 = require("@fuel-ts/crypto");
|
9011
9047
|
var import_errors23 = require("@fuel-ts/errors");
|
9012
9048
|
var import_events = require("events");
|
9013
9049
|
|
@@ -9335,7 +9371,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
9335
9371
|
await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
|
9336
9372
|
const data = await this.storage.getItem(this.STORAGE_KEY);
|
9337
9373
|
if (data) {
|
9338
|
-
const state = await (0,
|
9374
|
+
const state = await (0, import_crypto7.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
|
9339
9375
|
__privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
|
9340
9376
|
}
|
9341
9377
|
}
|
@@ -9344,7 +9380,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
9344
9380
|
*/
|
9345
9381
|
async saveState() {
|
9346
9382
|
await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
|
9347
|
-
const encryptedData = await (0,
|
9383
|
+
const encryptedData = await (0, import_crypto7.encrypt)(__privateGet(this, _passphrase), {
|
9348
9384
|
vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
|
9349
9385
|
});
|
9350
9386
|
await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
|
@@ -9420,21 +9456,21 @@ var StorageAbstract = class {
|
|
9420
9456
|
};
|
9421
9457
|
|
9422
9458
|
// src/predicate/predicate.ts
|
9423
|
-
var
|
9459
|
+
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
9424
9460
|
var import_address10 = require("@fuel-ts/address");
|
9425
9461
|
var import_errors25 = require("@fuel-ts/errors");
|
9426
|
-
var
|
9462
|
+
var import_utils38 = require("@fuel-ts/utils");
|
9427
9463
|
|
9428
9464
|
// src/predicate/utils/getPredicateRoot.ts
|
9429
9465
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9430
9466
|
var import_merkle = require("@fuel-ts/merkle");
|
9431
|
-
var
|
9467
|
+
var import_utils37 = require("@fuel-ts/utils");
|
9432
9468
|
var getPredicateRoot = (bytecode) => {
|
9433
9469
|
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,
|
9470
|
+
const bytes = (0, import_utils37.arrayify)(bytecode);
|
9471
|
+
const chunks = (0, import_utils37.chunkAndPadBytes)(bytes, chunkSize);
|
9472
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils37.hexlify)(c)));
|
9473
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils37.concat)(["0x4655454C", codeRoot]));
|
9438
9474
|
return predicateRoot;
|
9439
9475
|
};
|
9440
9476
|
|
@@ -9486,8 +9522,8 @@ var Predicate = class extends Account {
|
|
9486
9522
|
}
|
9487
9523
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9488
9524
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9489
|
-
input.predicate = (0,
|
9490
|
-
input.predicateData = (0,
|
9525
|
+
input.predicate = (0, import_utils38.hexlify)(this.bytes);
|
9526
|
+
input.predicateData = (0, import_utils38.hexlify)(this.getPredicateData());
|
9491
9527
|
input.witnessIndex = 0;
|
9492
9528
|
}
|
9493
9529
|
});
|
@@ -9529,10 +9565,10 @@ var Predicate = class extends Account {
|
|
9529
9565
|
* @returns An object containing the new predicate bytes and interface.
|
9530
9566
|
*/
|
9531
9567
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9532
|
-
let predicateBytes = (0,
|
9568
|
+
let predicateBytes = (0, import_utils38.arrayify)(bytes);
|
9533
9569
|
let abiInterface;
|
9534
9570
|
if (jsonAbi) {
|
9535
|
-
abiInterface = new
|
9571
|
+
abiInterface = new import_abi_coder8.Interface(jsonAbi);
|
9536
9572
|
if (abiInterface.functions.main === void 0) {
|
9537
9573
|
throw new import_errors25.FuelError(
|
9538
9574
|
import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,
|
@@ -9567,8 +9603,21 @@ var Predicate = class extends Account {
|
|
9567
9603
|
);
|
9568
9604
|
return resources.map((resource) => ({
|
9569
9605
|
...resource,
|
9570
|
-
predicate: (0,
|
9571
|
-
predicateData: (0,
|
9606
|
+
predicate: (0, import_utils38.hexlify)(this.bytes),
|
9607
|
+
predicateData: (0, import_utils38.hexlify)(this.getPredicateData())
|
9608
|
+
}));
|
9609
|
+
}
|
9610
|
+
/**
|
9611
|
+
* Generates an array of fake resources based on the provided coins.
|
9612
|
+
*
|
9613
|
+
* @param coins - An array of `FakeResources` objects representing the coins.
|
9614
|
+
* @returns An array of `Resource` objects with generated properties.
|
9615
|
+
*/
|
9616
|
+
generateFakeResources(coins) {
|
9617
|
+
return super.generateFakeResources(coins).map((coin) => ({
|
9618
|
+
...coin,
|
9619
|
+
predicate: (0, import_utils38.hexlify)(this.bytes),
|
9620
|
+
predicateData: (0, import_utils38.hexlify)(this.getPredicateData())
|
9572
9621
|
}));
|
9573
9622
|
}
|
9574
9623
|
/**
|
@@ -10433,7 +10482,6 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10433
10482
|
resolveGasDependentCosts,
|
10434
10483
|
resolveIconPaths,
|
10435
10484
|
returnZeroScript,
|
10436
|
-
sleep,
|
10437
10485
|
transactionRequestify,
|
10438
10486
|
urlJoin,
|
10439
10487
|
withTimeout,
|