@fuel-ts/account 0.94.2 → 0.94.4
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.
- package/dist/account.d.ts +1 -1
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +376 -277
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +328 -173
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +325 -173
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +81 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/message.d.ts +3 -0
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +27 -2
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +2 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +4 -2
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/providers/utils/handle-gql-error-message.d.ts +6 -0
- package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -0
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +220 -127
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +283 -140
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +281 -138
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/index.js
CHANGED
@@ -173,10 +173,13 @@ __export(src_exports, {
|
|
173
173
|
isCoin: () => isCoin,
|
174
174
|
isInputCoin: () => isInputCoin,
|
175
175
|
isMessage: () => isMessage,
|
176
|
+
isMessageCoin: () => isMessageCoin,
|
176
177
|
isRawCoin: () => isRawCoin,
|
177
178
|
isRawMessage: () => isRawMessage,
|
178
179
|
isRequestInputCoin: () => isRequestInputCoin,
|
180
|
+
isRequestInputCoinOrMessage: () => isRequestInputCoinOrMessage,
|
179
181
|
isRequestInputMessage: () => isRequestInputMessage,
|
182
|
+
isRequestInputMessageWithoutData: () => isRequestInputMessageWithoutData,
|
180
183
|
isRequestInputResource: () => isRequestInputResource,
|
181
184
|
isRequestInputResourceFromOwner: () => isRequestInputResourceFromOwner,
|
182
185
|
isTransactionTypeBlob: () => isTransactionTypeBlob,
|
@@ -208,11 +211,12 @@ module.exports = __toCommonJS(src_exports);
|
|
208
211
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
209
212
|
var import_address4 = require("@fuel-ts/address");
|
210
213
|
var import_crypto2 = require("@fuel-ts/crypto");
|
211
|
-
var
|
214
|
+
var import_errors18 = require("@fuel-ts/errors");
|
212
215
|
var import_interfaces = require("@fuel-ts/interfaces");
|
213
216
|
var import_math21 = require("@fuel-ts/math");
|
217
|
+
var import_transactions22 = require("@fuel-ts/transactions");
|
214
218
|
var import_utils30 = require("@fuel-ts/utils");
|
215
|
-
var
|
219
|
+
var import_ramda7 = require("ramda");
|
216
220
|
|
217
221
|
// src/providers/coin-quantity.ts
|
218
222
|
var import_math = require("@fuel-ts/math");
|
@@ -251,14 +255,15 @@ var addAmountToCoinQuantities = (params) => {
|
|
251
255
|
|
252
256
|
// src/providers/provider.ts
|
253
257
|
var import_address3 = require("@fuel-ts/address");
|
254
|
-
var
|
258
|
+
var import_errors16 = require("@fuel-ts/errors");
|
255
259
|
var import_math18 = require("@fuel-ts/math");
|
256
260
|
var import_transactions20 = require("@fuel-ts/transactions");
|
257
261
|
var import_utils24 = require("@fuel-ts/utils");
|
258
262
|
var import_versions = require("@fuel-ts/versions");
|
259
263
|
var import_utils25 = require("@noble/curves/abstract/utils");
|
260
264
|
var import_graphql_request = require("graphql-request");
|
261
|
-
var
|
265
|
+
var import_graphql_tag2 = __toESM(require("graphql-tag"));
|
266
|
+
var import_ramda6 = require("ramda");
|
262
267
|
|
263
268
|
// src/providers/__generated__/operations.ts
|
264
269
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
@@ -591,6 +596,14 @@ var BlockFragmentDoc = import_graphql_tag.default`
|
|
591
596
|
height
|
592
597
|
header {
|
593
598
|
time
|
599
|
+
daHeight
|
600
|
+
stateTransitionBytecodeVersion
|
601
|
+
transactionsCount
|
602
|
+
transactionsRoot
|
603
|
+
messageOutboxRoot
|
604
|
+
eventInboxRoot
|
605
|
+
prevRoot
|
606
|
+
applicationHash
|
594
607
|
}
|
595
608
|
transactions {
|
596
609
|
id
|
@@ -1579,6 +1592,9 @@ var import_math8 = require("@fuel-ts/math");
|
|
1579
1592
|
var import_transactions7 = require("@fuel-ts/transactions");
|
1580
1593
|
var import_utils9 = require("@fuel-ts/utils");
|
1581
1594
|
|
1595
|
+
// src/providers/message.ts
|
1596
|
+
var isMessageCoin = (message) => !("data" in message);
|
1597
|
+
|
1582
1598
|
// src/providers/resource.ts
|
1583
1599
|
var isRawCoin = (resource) => "utxoId" in resource;
|
1584
1600
|
var isRawMessage = (resource) => "recipient" in resource;
|
@@ -2015,20 +2031,22 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2015
2031
|
let reason = "";
|
2016
2032
|
if (revertReceipt) {
|
2017
2033
|
const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
|
2034
|
+
const lastLog = logs[logs.length - 1];
|
2035
|
+
const lastButOneLog = logs[logs.length - 2];
|
2018
2036
|
switch (reasonHex) {
|
2019
2037
|
case import_configs5.FAILED_REQUIRE_SIGNAL: {
|
2020
2038
|
reason = "require";
|
2021
|
-
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(
|
2039
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
2022
2040
|
break;
|
2023
2041
|
}
|
2024
2042
|
case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
|
2025
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(
|
2043
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
2026
2044
|
reason = "assert_eq";
|
2027
2045
|
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
2028
2046
|
break;
|
2029
2047
|
}
|
2030
2048
|
case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
|
2031
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(
|
2049
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
2032
2050
|
reason = "assert_ne";
|
2033
2051
|
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
2034
2052
|
break;
|
@@ -2101,7 +2119,9 @@ var import_math7 = require("@fuel-ts/math");
|
|
2101
2119
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2102
2120
|
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
2103
2121
|
var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
|
2104
|
-
var
|
2122
|
+
var isRequestInputMessageWithoutData = (input) => input.type === import_transactions6.InputType.Message && (0, import_math7.bn)(input.data).isZero();
|
2123
|
+
var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
2124
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
|
2105
2125
|
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
2106
2126
|
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
2107
2127
|
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
@@ -2411,7 +2431,7 @@ var BaseTransactionRequest = class {
|
|
2411
2431
|
* @param message - Message resource.
|
2412
2432
|
*/
|
2413
2433
|
addMessageInput(message) {
|
2414
|
-
const { recipient, sender, amount, predicate, nonce,
|
2434
|
+
const { recipient, sender, amount, predicate, nonce, predicateData } = message;
|
2415
2435
|
let witnessIndex;
|
2416
2436
|
if (message.predicate) {
|
2417
2437
|
witnessIndex = 0;
|
@@ -2426,13 +2446,16 @@ var BaseTransactionRequest = class {
|
|
2426
2446
|
type: import_transactions7.InputType.Message,
|
2427
2447
|
sender: sender.toB256(),
|
2428
2448
|
recipient: recipient.toB256(),
|
2449
|
+
data: isMessageCoin(message) ? "0x" : message.data,
|
2429
2450
|
amount,
|
2430
2451
|
witnessIndex,
|
2431
2452
|
predicate,
|
2432
2453
|
predicateData
|
2433
2454
|
};
|
2434
2455
|
this.pushInput(input);
|
2435
|
-
|
2456
|
+
if (isMessageCoin(message)) {
|
2457
|
+
this.addChangeOutput(recipient, message.assetId);
|
2458
|
+
}
|
2436
2459
|
}
|
2437
2460
|
/**
|
2438
2461
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -2564,6 +2587,8 @@ var BaseTransactionRequest = class {
|
|
2564
2587
|
*
|
2565
2588
|
* @param quantities - CoinQuantity Array.
|
2566
2589
|
* @param baseAssetId - The base asset to fund the transaction.
|
2590
|
+
* @deprecated - This method is deprecated and will be removed in future versions.
|
2591
|
+
* Please use `Account.generateFakeResources` along with `this.addResources` instead.
|
2567
2592
|
*/
|
2568
2593
|
fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
|
2569
2594
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
@@ -2632,7 +2657,7 @@ var BaseTransactionRequest = class {
|
|
2632
2657
|
});
|
2633
2658
|
}
|
2634
2659
|
updatePredicateGasUsed(inputs) {
|
2635
|
-
const inputsToExtractGasUsed = inputs.filter(
|
2660
|
+
const inputsToExtractGasUsed = inputs.filter(isRequestInputCoinOrMessage);
|
2636
2661
|
this.inputs.filter(isRequestInputResource).forEach((i) => {
|
2637
2662
|
const owner = getRequestInputResourceOwner(i);
|
2638
2663
|
const correspondingInput = inputsToExtractGasUsed.find(
|
@@ -2648,6 +2673,9 @@ var BaseTransactionRequest = class {
|
|
2648
2673
|
}
|
2649
2674
|
};
|
2650
2675
|
|
2676
|
+
// src/providers/transaction-request/blob-transaction-request.ts
|
2677
|
+
var import_ramda3 = require("ramda");
|
2678
|
+
|
2651
2679
|
// src/providers/transaction-request/hash-transaction.ts
|
2652
2680
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2653
2681
|
var import_hasher = require("@fuel-ts/hasher");
|
@@ -2722,10 +2750,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2722
2750
|
// src/providers/transaction-request/blob-transaction-request.ts
|
2723
2751
|
var BlobTransactionRequest = class extends BaseTransactionRequest {
|
2724
2752
|
static from(obj) {
|
2725
|
-
|
2726
|
-
return obj;
|
2727
|
-
}
|
2728
|
-
return new this(obj);
|
2753
|
+
return new this((0, import_ramda3.clone)(obj));
|
2729
2754
|
}
|
2730
2755
|
/** Type of the transaction */
|
2731
2756
|
type = import_transactions7.TransactionType.Blob;
|
@@ -2788,6 +2813,7 @@ var import_configs8 = require("@fuel-ts/address/configs");
|
|
2788
2813
|
var import_math10 = require("@fuel-ts/math");
|
2789
2814
|
var import_transactions9 = require("@fuel-ts/transactions");
|
2790
2815
|
var import_utils14 = require("@fuel-ts/utils");
|
2816
|
+
var import_ramda4 = require("ramda");
|
2791
2817
|
|
2792
2818
|
// src/providers/transaction-request/storage-slot.ts
|
2793
2819
|
var import_utils13 = require("@fuel-ts/utils");
|
@@ -2815,10 +2841,7 @@ var storageSlotify = (storageSlot) => {
|
|
2815
2841
|
// src/providers/transaction-request/create-transaction-request.ts
|
2816
2842
|
var CreateTransactionRequest = class extends BaseTransactionRequest {
|
2817
2843
|
static from(obj) {
|
2818
|
-
|
2819
|
-
return obj;
|
2820
|
-
}
|
2821
|
-
return new this(obj);
|
2844
|
+
return new this((0, import_ramda4.clone)(obj));
|
2822
2845
|
}
|
2823
2846
|
/** Type of the transaction */
|
2824
2847
|
type = import_transactions9.TransactionType.Create;
|
@@ -2907,6 +2930,7 @@ var import_configs9 = require("@fuel-ts/address/configs");
|
|
2907
2930
|
var import_math11 = require("@fuel-ts/math");
|
2908
2931
|
var import_transactions10 = require("@fuel-ts/transactions");
|
2909
2932
|
var import_utils16 = require("@fuel-ts/utils");
|
2933
|
+
var import_ramda5 = require("ramda");
|
2910
2934
|
|
2911
2935
|
// src/providers/transaction-request/scripts.ts
|
2912
2936
|
var import_utils15 = require("@fuel-ts/utils");
|
@@ -2937,10 +2961,7 @@ var withdrawScript = {
|
|
2937
2961
|
// src/providers/transaction-request/script-transaction-request.ts
|
2938
2962
|
var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
2939
2963
|
static from(obj) {
|
2940
|
-
|
2941
|
-
return obj;
|
2942
|
-
}
|
2943
|
-
return new this(obj);
|
2964
|
+
return new this((0, import_ramda5.clone)(obj));
|
2944
2965
|
}
|
2945
2966
|
/** Type of the transaction */
|
2946
2967
|
type = import_transactions10.TransactionType.Script;
|
@@ -4297,6 +4318,22 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4297
4318
|
};
|
4298
4319
|
}
|
4299
4320
|
|
4321
|
+
// src/providers/utils/handle-gql-error-message.ts
|
4322
|
+
var import_errors15 = require("@fuel-ts/errors");
|
4323
|
+
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4324
|
+
switch (errorMessage) {
|
4325
|
+
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4326
|
+
throw new import_errors15.FuelError(
|
4327
|
+
import_errors15.ErrorCode.NOT_ENOUGH_FUNDS,
|
4328
|
+
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4329
|
+
{},
|
4330
|
+
rawError
|
4331
|
+
);
|
4332
|
+
default:
|
4333
|
+
throw new import_errors15.FuelError(import_errors15.ErrorCode.INVALID_REQUEST, errorMessage);
|
4334
|
+
}
|
4335
|
+
};
|
4336
|
+
|
4300
4337
|
// src/providers/provider.ts
|
4301
4338
|
var MAX_RETRIES = 10;
|
4302
4339
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
@@ -4423,6 +4460,17 @@ var _Provider = class {
|
|
4423
4460
|
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
4424
4461
|
}, retryOptions);
|
4425
4462
|
}
|
4463
|
+
static extractBasicAuth(url) {
|
4464
|
+
const parsedUrl = new URL(url);
|
4465
|
+
const username = parsedUrl.username;
|
4466
|
+
const password = parsedUrl.password;
|
4467
|
+
const urlNoBasicAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
|
4468
|
+
if (!(username && password)) {
|
4469
|
+
return { url, auth: void 0 };
|
4470
|
+
}
|
4471
|
+
const auth = `Basic ${btoa(`${username}:${password}`)}`;
|
4472
|
+
return { url: urlNoBasicAuth, auth };
|
4473
|
+
}
|
4426
4474
|
/**
|
4427
4475
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
4428
4476
|
*
|
@@ -4432,7 +4480,17 @@ var _Provider = class {
|
|
4432
4480
|
* @returns A promise that resolves to a Provider instance.
|
4433
4481
|
*/
|
4434
4482
|
static async create(url, options = {}) {
|
4435
|
-
const
|
4483
|
+
const { url: urlToUse, auth } = this.extractBasicAuth(url);
|
4484
|
+
const provider = new _Provider(urlToUse, {
|
4485
|
+
...options,
|
4486
|
+
requestMiddleware: async (request) => {
|
4487
|
+
if (auth) {
|
4488
|
+
request.headers ??= {};
|
4489
|
+
request.headers.Authorization = auth;
|
4490
|
+
}
|
4491
|
+
return options.requestMiddleware?.(request) ?? request;
|
4492
|
+
}
|
4493
|
+
});
|
4436
4494
|
await provider.fetchChainAndNodeInfo();
|
4437
4495
|
return provider;
|
4438
4496
|
}
|
@@ -4444,8 +4502,8 @@ var _Provider = class {
|
|
4444
4502
|
getChain() {
|
4445
4503
|
const chain = _Provider.chainInfoCache[this.url];
|
4446
4504
|
if (!chain) {
|
4447
|
-
throw new
|
4448
|
-
|
4505
|
+
throw new import_errors16.FuelError(
|
4506
|
+
import_errors16.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
4449
4507
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4450
4508
|
);
|
4451
4509
|
}
|
@@ -4459,8 +4517,8 @@ var _Provider = class {
|
|
4459
4517
|
getNode() {
|
4460
4518
|
const node = _Provider.nodeInfoCache[this.url];
|
4461
4519
|
if (!node) {
|
4462
|
-
throw new
|
4463
|
-
|
4520
|
+
throw new import_errors16.FuelError(
|
4521
|
+
import_errors16.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
4464
4522
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4465
4523
|
);
|
4466
4524
|
}
|
@@ -4538,10 +4596,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4538
4596
|
if ("response" in response) {
|
4539
4597
|
const graphQlResponse = response.response;
|
4540
4598
|
if (Array.isArray(graphQlResponse?.errors)) {
|
4541
|
-
|
4542
|
-
|
4543
|
-
|
4544
|
-
);
|
4599
|
+
for (const error of graphQlResponse.errors) {
|
4600
|
+
handleGqlErrorMessage(error.message, error);
|
4601
|
+
}
|
4545
4602
|
}
|
4546
4603
|
}
|
4547
4604
|
}
|
@@ -4559,7 +4616,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4559
4616
|
}
|
4560
4617
|
return gqlClient.request(query, vars);
|
4561
4618
|
};
|
4562
|
-
|
4619
|
+
const customOperations = (requester) => ({
|
4620
|
+
getBlobs(variables) {
|
4621
|
+
const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
|
4622
|
+
const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
|
4623
|
+
const updatedVariables = variables.blobIds.reduce(
|
4624
|
+
(acc, blobId, i) => {
|
4625
|
+
acc[`blobId${i}`] = blobId;
|
4626
|
+
return acc;
|
4627
|
+
},
|
4628
|
+
{}
|
4629
|
+
);
|
4630
|
+
const document2 = import_graphql_tag2.default`
|
4631
|
+
query getBlobs(${queryParams}) {
|
4632
|
+
${blobParams}
|
4633
|
+
}
|
4634
|
+
`;
|
4635
|
+
return requester(document2, updatedVariables);
|
4636
|
+
}
|
4637
|
+
});
|
4638
|
+
return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
|
4563
4639
|
}
|
4564
4640
|
/**
|
4565
4641
|
* Returns the version of the connected node.
|
@@ -4634,14 +4710,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4634
4710
|
validateTransaction(tx, consensusParameters) {
|
4635
4711
|
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4636
4712
|
if ((0, import_math18.bn)(tx.inputs.length).gt(maxInputs)) {
|
4637
|
-
throw new
|
4638
|
-
|
4713
|
+
throw new import_errors16.FuelError(
|
4714
|
+
import_errors16.ErrorCode.MAX_INPUTS_EXCEEDED,
|
4639
4715
|
"The transaction exceeds the maximum allowed number of inputs."
|
4640
4716
|
);
|
4641
4717
|
}
|
4642
4718
|
if ((0, import_math18.bn)(tx.outputs.length).gt(maxOutputs)) {
|
4643
|
-
throw new
|
4644
|
-
|
4719
|
+
throw new import_errors16.FuelError(
|
4720
|
+
import_errors16.ErrorCode.MAX_OUTPUTS_EXCEEDED,
|
4645
4721
|
"The transaction exceeds the maximum allowed number of outputs."
|
4646
4722
|
);
|
4647
4723
|
}
|
@@ -4656,7 +4732,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4656
4732
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
4657
4733
|
* @returns A promise that resolves to the transaction response object.
|
4658
4734
|
*/
|
4659
|
-
// #region Provider-sendTransaction
|
4660
4735
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
4661
4736
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4662
4737
|
if (estimateTxDependencies) {
|
@@ -4803,7 +4878,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4803
4878
|
missingContractIds: [],
|
4804
4879
|
dryRunStatus: void 0
|
4805
4880
|
}));
|
4806
|
-
const allRequests = (0,
|
4881
|
+
const allRequests = (0, import_ramda6.clone)(transactionRequests);
|
4807
4882
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4808
4883
|
allRequests.forEach((req, index) => {
|
4809
4884
|
if (isTransactionTypeScript(req)) {
|
@@ -4963,13 +5038,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4963
5038
|
* @returns A promise that resolves to the transaction cost object.
|
4964
5039
|
*/
|
4965
5040
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
4966
|
-
const txRequestClone = (0,
|
5041
|
+
const txRequestClone = (0, import_ramda6.clone)(transactionRequestify(transactionRequestLike));
|
4967
5042
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4968
5043
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
4969
5044
|
if (isScriptTransaction) {
|
4970
5045
|
txRequestClone.gasLimit = (0, import_math18.bn)(0);
|
4971
5046
|
}
|
4972
|
-
const signedRequest = (0,
|
5047
|
+
const signedRequest = (0, import_ramda6.clone)(txRequestClone);
|
4973
5048
|
let addedSignatures = 0;
|
4974
5049
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
4975
5050
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -5107,6 +5182,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5107
5182
|
}).filter((v) => !!v);
|
5108
5183
|
return coins;
|
5109
5184
|
}
|
5185
|
+
/**
|
5186
|
+
* Returns an array of blobIds that exist on chain, for a given array of blobIds.
|
5187
|
+
*
|
5188
|
+
* @param blobIds - blobIds to check.
|
5189
|
+
* @returns - A promise that resolves to an array of blobIds that exist on chain.
|
5190
|
+
*/
|
5191
|
+
async getBlobs(blobIds) {
|
5192
|
+
const res = await this.operations.getBlobs({ blobIds });
|
5193
|
+
const blobs = [];
|
5194
|
+
Object.keys(res).forEach((key) => {
|
5195
|
+
const val = res[key];
|
5196
|
+
blobs.push(val?.id ?? null);
|
5197
|
+
});
|
5198
|
+
return blobs.filter((v) => v);
|
5199
|
+
}
|
5110
5200
|
/**
|
5111
5201
|
* Returns block matching the given ID or height.
|
5112
5202
|
*
|
@@ -5128,11 +5218,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5128
5218
|
if (!block) {
|
5129
5219
|
return null;
|
5130
5220
|
}
|
5221
|
+
const { header, height, id, transactions } = block;
|
5131
5222
|
return {
|
5132
|
-
id
|
5133
|
-
height: (0, import_math18.bn)(
|
5134
|
-
time:
|
5135
|
-
|
5223
|
+
id,
|
5224
|
+
height: (0, import_math18.bn)(height),
|
5225
|
+
time: header.time,
|
5226
|
+
header: {
|
5227
|
+
applicationHash: header.applicationHash,
|
5228
|
+
daHeight: (0, import_math18.bn)(header.daHeight),
|
5229
|
+
eventInboxRoot: header.eventInboxRoot,
|
5230
|
+
messageOutboxRoot: header.messageOutboxRoot,
|
5231
|
+
prevRoot: header.prevRoot,
|
5232
|
+
stateTransitionBytecodeVersion: header.stateTransitionBytecodeVersion,
|
5233
|
+
transactionsCount: header.transactionsCount,
|
5234
|
+
transactionsRoot: header.transactionsRoot
|
5235
|
+
},
|
5236
|
+
transactionIds: transactions.map((tx) => tx.id)
|
5136
5237
|
};
|
5137
5238
|
}
|
5138
5239
|
/**
|
@@ -5154,6 +5255,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5154
5255
|
id: block.id,
|
5155
5256
|
height: (0, import_math18.bn)(block.height),
|
5156
5257
|
time: block.header.time,
|
5258
|
+
header: {
|
5259
|
+
applicationHash: block.header.applicationHash,
|
5260
|
+
daHeight: (0, import_math18.bn)(block.header.daHeight),
|
5261
|
+
eventInboxRoot: block.header.eventInboxRoot,
|
5262
|
+
messageOutboxRoot: block.header.messageOutboxRoot,
|
5263
|
+
prevRoot: block.header.prevRoot,
|
5264
|
+
stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
|
5265
|
+
transactionsCount: block.header.transactionsCount,
|
5266
|
+
transactionsRoot: block.header.transactionsRoot
|
5267
|
+
},
|
5157
5268
|
transactionIds: block.transactions.map((tx) => tx.id)
|
5158
5269
|
}));
|
5159
5270
|
return { blocks, pageInfo };
|
@@ -5181,6 +5292,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5181
5292
|
id: block.id,
|
5182
5293
|
height: (0, import_math18.bn)(block.height, 10),
|
5183
5294
|
time: block.header.time,
|
5295
|
+
header: {
|
5296
|
+
applicationHash: block.header.applicationHash,
|
5297
|
+
daHeight: (0, import_math18.bn)(block.header.daHeight),
|
5298
|
+
eventInboxRoot: block.header.eventInboxRoot,
|
5299
|
+
messageOutboxRoot: block.header.messageOutboxRoot,
|
5300
|
+
prevRoot: block.header.prevRoot,
|
5301
|
+
stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
|
5302
|
+
transactionsCount: block.header.transactionsCount,
|
5303
|
+
transactionsRoot: block.header.transactionsRoot
|
5304
|
+
},
|
5184
5305
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5185
5306
|
transactions: block.transactions.map(
|
5186
5307
|
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils24.arrayify)(tx.rawPayload), 0)?.[0]
|
@@ -5198,10 +5319,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5198
5319
|
if (!transaction) {
|
5199
5320
|
return null;
|
5200
5321
|
}
|
5201
|
-
|
5202
|
-
|
5203
|
-
|
5204
|
-
|
5322
|
+
try {
|
5323
|
+
return new import_transactions20.TransactionCoder().decode(
|
5324
|
+
(0, import_utils24.arrayify)(transaction.rawPayload),
|
5325
|
+
0
|
5326
|
+
)?.[0];
|
5327
|
+
} catch (error) {
|
5328
|
+
if (error instanceof import_errors16.FuelError && error.code === import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5329
|
+
console.warn("Unsupported transaction type encountered");
|
5330
|
+
return null;
|
5331
|
+
}
|
5332
|
+
throw error;
|
5333
|
+
}
|
5205
5334
|
}
|
5206
5335
|
/**
|
5207
5336
|
* Retrieves transactions based on the provided pagination arguments.
|
@@ -5213,9 +5342,17 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5213
5342
|
transactions: { edges, pageInfo }
|
5214
5343
|
} = await this.operations.getTransactions(paginationArgs);
|
5215
5344
|
const coder = new import_transactions20.TransactionCoder();
|
5216
|
-
const transactions = edges.map(
|
5217
|
-
|
5218
|
-
|
5345
|
+
const transactions = edges.map(({ node: { rawPayload } }) => {
|
5346
|
+
try {
|
5347
|
+
return coder.decode((0, import_utils24.arrayify)(rawPayload), 0)[0];
|
5348
|
+
} catch (error) {
|
5349
|
+
if (error instanceof import_errors16.FuelError && error.code === import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5350
|
+
console.warn("Unsupported transaction type encountered");
|
5351
|
+
return null;
|
5352
|
+
}
|
5353
|
+
throw error;
|
5354
|
+
}
|
5355
|
+
}).filter((tx) => tx !== null);
|
5219
5356
|
return { transactions, pageInfo };
|
5220
5357
|
}
|
5221
5358
|
/**
|
@@ -5335,8 +5472,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5335
5472
|
nonce
|
5336
5473
|
};
|
5337
5474
|
if (commitBlockId && commitBlockHeight) {
|
5338
|
-
throw new
|
5339
|
-
|
5475
|
+
throw new import_errors16.FuelError(
|
5476
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5340
5477
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5341
5478
|
);
|
5342
5479
|
}
|
@@ -5476,10 +5613,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5476
5613
|
* @returns A promise that resolves to the Message object or null.
|
5477
5614
|
*/
|
5478
5615
|
async getMessageByNonce(nonce) {
|
5479
|
-
const { message } = await this.operations.getMessageByNonce({ nonce });
|
5480
|
-
if (!
|
5616
|
+
const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
|
5617
|
+
if (!rawMessage) {
|
5481
5618
|
return null;
|
5482
5619
|
}
|
5620
|
+
const message = {
|
5621
|
+
messageId: import_transactions20.InputMessageCoder.getMessageId({
|
5622
|
+
sender: rawMessage.sender,
|
5623
|
+
recipient: rawMessage.recipient,
|
5624
|
+
nonce: rawMessage.nonce,
|
5625
|
+
amount: (0, import_math18.bn)(rawMessage.amount),
|
5626
|
+
data: rawMessage.data
|
5627
|
+
}),
|
5628
|
+
sender: import_address3.Address.fromAddressOrString(rawMessage.sender),
|
5629
|
+
recipient: import_address3.Address.fromAddressOrString(rawMessage.recipient),
|
5630
|
+
nonce: rawMessage.nonce,
|
5631
|
+
amount: (0, import_math18.bn)(rawMessage.amount),
|
5632
|
+
data: import_transactions20.InputMessageCoder.decodeData(rawMessage.data),
|
5633
|
+
daHeight: (0, import_math18.bn)(rawMessage.daHeight)
|
5634
|
+
};
|
5483
5635
|
return message;
|
5484
5636
|
}
|
5485
5637
|
/**
|
@@ -5504,26 +5656,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5504
5656
|
const { paginationLimit, inputArgs = {} } = params;
|
5505
5657
|
const { first, last, after, before } = inputArgs;
|
5506
5658
|
if (after && before) {
|
5507
|
-
throw new
|
5508
|
-
|
5659
|
+
throw new import_errors16.FuelError(
|
5660
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5509
5661
|
'Pagination arguments "after" and "before" cannot be used together'
|
5510
5662
|
);
|
5511
5663
|
}
|
5512
5664
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5513
|
-
throw new
|
5514
|
-
|
5665
|
+
throw new import_errors16.FuelError(
|
5666
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5515
5667
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5516
5668
|
);
|
5517
5669
|
}
|
5518
5670
|
if (first && before) {
|
5519
|
-
throw new
|
5520
|
-
|
5671
|
+
throw new import_errors16.FuelError(
|
5672
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5521
5673
|
'The use of pagination argument "first" with "before" is not supported'
|
5522
5674
|
);
|
5523
5675
|
}
|
5524
5676
|
if (last && after) {
|
5525
|
-
throw new
|
5526
|
-
|
5677
|
+
throw new import_errors16.FuelError(
|
5678
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5527
5679
|
'The use of pagination argument "last" with "after" is not supported'
|
5528
5680
|
);
|
5529
5681
|
}
|
@@ -5577,7 +5729,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5577
5729
|
__publicField(Provider, "nodeInfoCache", {});
|
5578
5730
|
|
5579
5731
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5580
|
-
var
|
5732
|
+
var import_errors17 = require("@fuel-ts/errors");
|
5581
5733
|
var import_math19 = require("@fuel-ts/math");
|
5582
5734
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5583
5735
|
var import_utils27 = require("@fuel-ts/utils");
|
@@ -5587,8 +5739,8 @@ async function getTransactionSummary(params) {
|
|
5587
5739
|
transactionId: id
|
5588
5740
|
});
|
5589
5741
|
if (!gqlTransaction) {
|
5590
|
-
throw new
|
5591
|
-
|
5742
|
+
throw new import_errors17.FuelError(
|
5743
|
+
import_errors17.ErrorCode.TRANSACTION_NOT_FOUND,
|
5592
5744
|
`Transaction not found for given id: ${id}.`
|
5593
5745
|
);
|
5594
5746
|
}
|
@@ -5914,7 +6066,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5914
6066
|
*/
|
5915
6067
|
get provider() {
|
5916
6068
|
if (!this._provider) {
|
5917
|
-
throw new
|
6069
|
+
throw new import_errors18.FuelError(import_errors18.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
5918
6070
|
}
|
5919
6071
|
return this._provider;
|
5920
6072
|
}
|
@@ -6032,7 +6184,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6032
6184
|
);
|
6033
6185
|
request.addResources(resources);
|
6034
6186
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6035
|
-
const requestToReestimate2 = (0,
|
6187
|
+
const requestToReestimate2 = (0, import_ramda7.clone)(request);
|
6036
6188
|
if (addedSignatures) {
|
6037
6189
|
Array.from({ length: addedSignatures }).forEach(
|
6038
6190
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -6047,7 +6199,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6047
6199
|
gasPrice
|
6048
6200
|
});
|
6049
6201
|
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
6050
|
-
request.inputs,
|
6202
|
+
request.inputs.filter(isRequestInputResource),
|
6051
6203
|
baseAssetId,
|
6052
6204
|
baseAssetId
|
6053
6205
|
);
|
@@ -6065,13 +6217,13 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6065
6217
|
fundingAttempts += 1;
|
6066
6218
|
}
|
6067
6219
|
if (needsToBeFunded) {
|
6068
|
-
throw new
|
6069
|
-
|
6220
|
+
throw new import_errors18.FuelError(
|
6221
|
+
import_errors18.ErrorCode.NOT_ENOUGH_FUNDS,
|
6070
6222
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6071
6223
|
);
|
6072
6224
|
}
|
6073
6225
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6074
|
-
const requestToReestimate = (0,
|
6226
|
+
const requestToReestimate = (0, import_ramda7.clone)(request);
|
6075
6227
|
if (addedSignatures) {
|
6076
6228
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
6077
6229
|
}
|
@@ -6171,8 +6323,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6171
6323
|
*/
|
6172
6324
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6173
6325
|
if ((0, import_math21.bn)(amount).lte(0)) {
|
6174
|
-
throw new
|
6175
|
-
|
6326
|
+
throw new import_errors18.FuelError(
|
6327
|
+
import_errors18.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6176
6328
|
"Transfer amount must be a positive number."
|
6177
6329
|
);
|
6178
6330
|
}
|
@@ -6247,16 +6399,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6247
6399
|
* @returns A promise that resolves to the transaction cost object.
|
6248
6400
|
*/
|
6249
6401
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6250
|
-
const txRequestClone = (0,
|
6402
|
+
const txRequestClone = (0, import_ramda7.clone)(transactionRequestify(transactionRequestLike));
|
6251
6403
|
const baseAssetId = this.provider.getBaseAssetId();
|
6252
6404
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6253
6405
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
6254
6406
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
|
6255
6407
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6256
|
-
if (
|
6408
|
+
if (input.type === import_transactions22.InputType.Coin) {
|
6257
6409
|
return input.assetId === assetId;
|
6258
6410
|
}
|
6259
|
-
if (
|
6411
|
+
if (isRequestInputMessageWithoutData(input)) {
|
6260
6412
|
return baseAssetId === assetId;
|
6261
6413
|
}
|
6262
6414
|
return false;
|
@@ -6298,7 +6450,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6298
6450
|
*/
|
6299
6451
|
async signMessage(message) {
|
6300
6452
|
if (!this._connector) {
|
6301
|
-
throw new
|
6453
|
+
throw new import_errors18.FuelError(import_errors18.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6302
6454
|
}
|
6303
6455
|
return this._connector.signMessage(this.address.toString(), message);
|
6304
6456
|
}
|
@@ -6310,8 +6462,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6310
6462
|
*/
|
6311
6463
|
async signTransaction(transactionRequestLike) {
|
6312
6464
|
if (!this._connector) {
|
6313
|
-
throw new
|
6314
|
-
|
6465
|
+
throw new import_errors18.FuelError(
|
6466
|
+
import_errors18.ErrorCode.MISSING_CONNECTOR,
|
6315
6467
|
"A connector is required to sign transactions."
|
6316
6468
|
);
|
6317
6469
|
}
|
@@ -6370,8 +6522,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6370
6522
|
/** @hidden * */
|
6371
6523
|
validateTransferAmount(amount) {
|
6372
6524
|
if ((0, import_math21.bn)(amount).lte(0)) {
|
6373
|
-
throw new
|
6374
|
-
|
6525
|
+
throw new import_errors18.FuelError(
|
6526
|
+
import_errors18.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6375
6527
|
"Transfer amount must be a positive number."
|
6376
6528
|
);
|
6377
6529
|
}
|
@@ -6400,16 +6552,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6400
6552
|
if (!(0, import_utils30.isDefined)(setGasLimit)) {
|
6401
6553
|
request.gasLimit = gasUsed;
|
6402
6554
|
} else if (gasUsed.gt(setGasLimit)) {
|
6403
|
-
throw new
|
6404
|
-
|
6555
|
+
throw new import_errors18.FuelError(
|
6556
|
+
import_errors18.ErrorCode.GAS_LIMIT_TOO_LOW,
|
6405
6557
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6406
6558
|
);
|
6407
6559
|
}
|
6408
6560
|
if (!(0, import_utils30.isDefined)(setMaxFee)) {
|
6409
6561
|
request.maxFee = maxFee;
|
6410
6562
|
} else if (maxFee.gt(setMaxFee)) {
|
6411
|
-
throw new
|
6412
|
-
|
6563
|
+
throw new import_errors18.FuelError(
|
6564
|
+
import_errors18.ErrorCode.MAX_FEE_TOO_LOW,
|
6413
6565
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6414
6566
|
);
|
6415
6567
|
}
|
@@ -6533,7 +6685,7 @@ var Signer = class {
|
|
6533
6685
|
// src/wallet/keystore-wallet.ts
|
6534
6686
|
var import_address6 = require("@fuel-ts/address");
|
6535
6687
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6536
|
-
var
|
6688
|
+
var import_errors19 = require("@fuel-ts/errors");
|
6537
6689
|
var import_utils32 = require("@fuel-ts/utils");
|
6538
6690
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6539
6691
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6610,8 +6762,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6610
6762
|
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
6611
6763
|
const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
6612
6764
|
if (mac !== macHash) {
|
6613
|
-
throw new
|
6614
|
-
|
6765
|
+
throw new import_errors19.FuelError(
|
6766
|
+
import_errors19.ErrorCode.INVALID_PASSWORD,
|
6615
6767
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6616
6768
|
);
|
6617
6769
|
}
|
@@ -6741,14 +6893,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6741
6893
|
|
6742
6894
|
// src/hdwallet/hdwallet.ts
|
6743
6895
|
var import_crypto6 = require("@fuel-ts/crypto");
|
6744
|
-
var
|
6896
|
+
var import_errors22 = require("@fuel-ts/errors");
|
6745
6897
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6746
6898
|
var import_math23 = require("@fuel-ts/math");
|
6747
6899
|
var import_utils37 = require("@fuel-ts/utils");
|
6748
6900
|
|
6749
6901
|
// src/mnemonic/mnemonic.ts
|
6750
6902
|
var import_crypto5 = require("@fuel-ts/crypto");
|
6751
|
-
var
|
6903
|
+
var import_errors21 = require("@fuel-ts/errors");
|
6752
6904
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6753
6905
|
var import_utils35 = require("@fuel-ts/utils");
|
6754
6906
|
|
@@ -8811,7 +8963,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8811
8963
|
})(Language || {});
|
8812
8964
|
|
8813
8965
|
// src/mnemonic/utils.ts
|
8814
|
-
var
|
8966
|
+
var import_errors20 = require("@fuel-ts/errors");
|
8815
8967
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8816
8968
|
var import_utils34 = require("@fuel-ts/utils");
|
8817
8969
|
function getLowerMask(bits) {
|
@@ -8860,8 +9012,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8860
9012
|
for (let i = 0; i < words.length; i += 1) {
|
8861
9013
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8862
9014
|
if (index === -1) {
|
8863
|
-
throw new
|
8864
|
-
|
9015
|
+
throw new import_errors20.FuelError(
|
9016
|
+
import_errors20.ErrorCode.INVALID_MNEMONIC,
|
8865
9017
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8866
9018
|
);
|
8867
9019
|
}
|
@@ -8877,8 +9029,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8877
9029
|
const checksumMask = getUpperMask(checksumBits);
|
8878
9030
|
const checksum = (0, import_utils34.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8879
9031
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8880
|
-
throw new
|
8881
|
-
|
9032
|
+
throw new import_errors20.FuelError(
|
9033
|
+
import_errors20.ErrorCode.INVALID_CHECKSUM,
|
8882
9034
|
"Checksum validation failed for the provided mnemonic."
|
8883
9035
|
);
|
8884
9036
|
}
|
@@ -8892,16 +9044,16 @@ var TestnetPRV = "0x04358394";
|
|
8892
9044
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8893
9045
|
function assertWordList(wordlist) {
|
8894
9046
|
if (wordlist.length !== 2048) {
|
8895
|
-
throw new
|
8896
|
-
|
9047
|
+
throw new import_errors21.FuelError(
|
9048
|
+
import_errors21.ErrorCode.INVALID_WORD_LIST,
|
8897
9049
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8898
9050
|
);
|
8899
9051
|
}
|
8900
9052
|
}
|
8901
9053
|
function assertEntropy(entropy) {
|
8902
9054
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8903
|
-
throw new
|
8904
|
-
|
9055
|
+
throw new import_errors21.FuelError(
|
9056
|
+
import_errors21.ErrorCode.INVALID_ENTROPY,
|
8905
9057
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8906
9058
|
);
|
8907
9059
|
}
|
@@ -8911,7 +9063,7 @@ function assertMnemonic(words) {
|
|
8911
9063
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8912
9064
|
", "
|
8913
9065
|
)}] words, but got ${words.length}.`;
|
8914
|
-
throw new
|
9066
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
8915
9067
|
}
|
8916
9068
|
}
|
8917
9069
|
var Mnemonic = class {
|
@@ -9029,8 +9181,8 @@ var Mnemonic = class {
|
|
9029
9181
|
static masterKeysFromSeed(seed) {
|
9030
9182
|
const seedArray = (0, import_utils35.arrayify)(seed);
|
9031
9183
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9032
|
-
throw new
|
9033
|
-
|
9184
|
+
throw new import_errors21.FuelError(
|
9185
|
+
import_errors21.ErrorCode.INVALID_SEED,
|
9034
9186
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9035
9187
|
);
|
9036
9188
|
}
|
@@ -9107,7 +9259,7 @@ function isValidExtendedKey(extendedKey) {
|
|
9107
9259
|
function parsePath(path, depth = 0) {
|
9108
9260
|
const components = path.split("/");
|
9109
9261
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9110
|
-
throw new
|
9262
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
|
9111
9263
|
}
|
9112
9264
|
if (components[0] === "m") {
|
9113
9265
|
components.shift();
|
@@ -9136,8 +9288,8 @@ var HDWallet = class {
|
|
9136
9288
|
this.privateKey = (0, import_utils37.hexlify)(config.privateKey);
|
9137
9289
|
} else {
|
9138
9290
|
if (!config.publicKey) {
|
9139
|
-
throw new
|
9140
|
-
|
9291
|
+
throw new import_errors22.FuelError(
|
9292
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9141
9293
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9142
9294
|
);
|
9143
9295
|
}
|
@@ -9166,8 +9318,8 @@ var HDWallet = class {
|
|
9166
9318
|
const data = new Uint8Array(37);
|
9167
9319
|
if (index & HARDENED_INDEX) {
|
9168
9320
|
if (!privateKey) {
|
9169
|
-
throw new
|
9170
|
-
|
9321
|
+
throw new import_errors22.FuelError(
|
9322
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9171
9323
|
"Cannot derive a hardened index without a private Key."
|
9172
9324
|
);
|
9173
9325
|
}
|
@@ -9219,8 +9371,8 @@ var HDWallet = class {
|
|
9219
9371
|
*/
|
9220
9372
|
toExtendedKey(isPublic = false, testnet = false) {
|
9221
9373
|
if (this.depth >= 256) {
|
9222
|
-
throw new
|
9223
|
-
|
9374
|
+
throw new import_errors22.FuelError(
|
9375
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9224
9376
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9225
9377
|
);
|
9226
9378
|
}
|
@@ -9251,10 +9403,10 @@ var HDWallet = class {
|
|
9251
9403
|
const bytes = (0, import_utils37.arrayify)(decoded);
|
9252
9404
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9253
9405
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9254
|
-
throw new
|
9406
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9255
9407
|
}
|
9256
9408
|
if (!validChecksum) {
|
9257
|
-
throw new
|
9409
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9258
9410
|
}
|
9259
9411
|
const depth = bytes[4];
|
9260
9412
|
const parentFingerprint = (0, import_utils37.hexlify)(bytes.slice(5, 9));
|
@@ -9262,14 +9414,14 @@ var HDWallet = class {
|
|
9262
9414
|
const chainCode = (0, import_utils37.hexlify)(bytes.slice(13, 45));
|
9263
9415
|
const key = bytes.slice(45, 78);
|
9264
9416
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9265
|
-
throw new
|
9266
|
-
|
9417
|
+
throw new import_errors22.FuelError(
|
9418
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9267
9419
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9268
9420
|
);
|
9269
9421
|
}
|
9270
9422
|
if (isPublicExtendedKey(bytes)) {
|
9271
9423
|
if (key[0] !== 3) {
|
9272
|
-
throw new
|
9424
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
9273
9425
|
}
|
9274
9426
|
return new HDWallet({
|
9275
9427
|
publicKey: key,
|
@@ -9280,7 +9432,7 @@ var HDWallet = class {
|
|
9280
9432
|
});
|
9281
9433
|
}
|
9282
9434
|
if (key[0] !== 0) {
|
9283
|
-
throw new
|
9435
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
9284
9436
|
}
|
9285
9437
|
return new HDWallet({
|
9286
9438
|
privateKey: key.slice(1),
|
@@ -9448,7 +9600,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
9448
9600
|
// src/wallet-manager/wallet-manager.ts
|
9449
9601
|
var import_address9 = require("@fuel-ts/address");
|
9450
9602
|
var import_crypto7 = require("@fuel-ts/crypto");
|
9451
|
-
var
|
9603
|
+
var import_errors25 = require("@fuel-ts/errors");
|
9452
9604
|
var import_events = require("events");
|
9453
9605
|
|
9454
9606
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -9471,7 +9623,7 @@ var MemoryStorage = class {
|
|
9471
9623
|
|
9472
9624
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
9473
9625
|
var import_address7 = require("@fuel-ts/address");
|
9474
|
-
var
|
9626
|
+
var import_errors23 = require("@fuel-ts/errors");
|
9475
9627
|
var _secret;
|
9476
9628
|
var MnemonicVault = class {
|
9477
9629
|
constructor(options) {
|
@@ -9527,8 +9679,8 @@ var MnemonicVault = class {
|
|
9527
9679
|
}
|
9528
9680
|
numberOfAccounts += 1;
|
9529
9681
|
} while (numberOfAccounts < this.numberOfAccounts);
|
9530
|
-
throw new
|
9531
|
-
|
9682
|
+
throw new import_errors23.FuelError(
|
9683
|
+
import_errors23.ErrorCode.WALLET_MANAGER_ERROR,
|
9532
9684
|
`Account with address '${address}' not found in derived wallets.`
|
9533
9685
|
);
|
9534
9686
|
}
|
@@ -9542,7 +9694,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
9542
9694
|
|
9543
9695
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
9544
9696
|
var import_address8 = require("@fuel-ts/address");
|
9545
|
-
var
|
9697
|
+
var import_errors24 = require("@fuel-ts/errors");
|
9546
9698
|
var _privateKeys;
|
9547
9699
|
var PrivateKeyVault = class {
|
9548
9700
|
/**
|
@@ -9583,8 +9735,8 @@ var PrivateKeyVault = class {
|
|
9583
9735
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
9584
9736
|
);
|
9585
9737
|
if (!privateKey) {
|
9586
|
-
throw new
|
9587
|
-
|
9738
|
+
throw new import_errors24.FuelError(
|
9739
|
+
import_errors24.ErrorCode.WALLET_MANAGER_ERROR,
|
9588
9740
|
`No private key found for address '${address}'.`
|
9589
9741
|
);
|
9590
9742
|
}
|
@@ -9608,7 +9760,7 @@ var ERROR_MESSAGES = {
|
|
9608
9760
|
};
|
9609
9761
|
function assert(condition, message) {
|
9610
9762
|
if (!condition) {
|
9611
|
-
throw new
|
9763
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.WALLET_MANAGER_ERROR, message);
|
9612
9764
|
}
|
9613
9765
|
}
|
9614
9766
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -9834,25 +9986,25 @@ deserializeVaults_fn = function(vaults) {
|
|
9834
9986
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
9835
9987
|
|
9836
9988
|
// src/wallet-manager/types.ts
|
9837
|
-
var
|
9989
|
+
var import_errors26 = require("@fuel-ts/errors");
|
9838
9990
|
var Vault = class {
|
9839
9991
|
constructor(_options) {
|
9840
|
-
throw new
|
9992
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9841
9993
|
}
|
9842
9994
|
serialize() {
|
9843
|
-
throw new
|
9995
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9844
9996
|
}
|
9845
9997
|
getAccounts() {
|
9846
|
-
throw new
|
9998
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9847
9999
|
}
|
9848
10000
|
addAccount() {
|
9849
|
-
throw new
|
10001
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9850
10002
|
}
|
9851
10003
|
exportAccount(_address) {
|
9852
|
-
throw new
|
10004
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9853
10005
|
}
|
9854
10006
|
getWallet(_address) {
|
9855
|
-
throw new
|
10007
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9856
10008
|
}
|
9857
10009
|
};
|
9858
10010
|
__publicField(Vault, "type");
|
@@ -9862,7 +10014,7 @@ var StorageAbstract = class {
|
|
9862
10014
|
// src/predicate/predicate.ts
|
9863
10015
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
9864
10016
|
var import_address10 = require("@fuel-ts/address");
|
9865
|
-
var
|
10017
|
+
var import_errors27 = require("@fuel-ts/errors");
|
9866
10018
|
var import_utils39 = require("@fuel-ts/utils");
|
9867
10019
|
|
9868
10020
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9924,7 +10076,7 @@ var Predicate = class extends Account {
|
|
9924
10076
|
if (placeholderIndex !== -1) {
|
9925
10077
|
request.removeWitness(placeholderIndex);
|
9926
10078
|
}
|
9927
|
-
request.inputs.filter(
|
10079
|
+
request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
9928
10080
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9929
10081
|
input.predicate = (0, import_utils39.hexlify)(this.bytes);
|
9930
10082
|
input.predicateData = (0, import_utils39.hexlify)(this.getPredicateData());
|
@@ -9974,8 +10126,8 @@ var Predicate = class extends Account {
|
|
9974
10126
|
if (jsonAbi) {
|
9975
10127
|
abiInterface = new import_abi_coder8.Interface(jsonAbi);
|
9976
10128
|
if (abiInterface.functions.main === void 0) {
|
9977
|
-
throw new
|
9978
|
-
|
10129
|
+
throw new import_errors27.FuelError(
|
10130
|
+
import_errors27.ErrorCode.ABI_MAIN_METHOD_MISSING,
|
9979
10131
|
'Cannot use ABI without "main" function.'
|
9980
10132
|
);
|
9981
10133
|
}
|
@@ -10036,21 +10188,21 @@ var Predicate = class extends Account {
|
|
10036
10188
|
const mutatedBytes = bytes;
|
10037
10189
|
try {
|
10038
10190
|
if (!abiInterface) {
|
10039
|
-
throw new
|
10040
|
-
|
10191
|
+
throw new import_errors27.FuelError(
|
10192
|
+
import_errors27.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10041
10193
|
"Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
|
10042
10194
|
);
|
10043
10195
|
}
|
10044
10196
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
10045
|
-
throw new
|
10046
|
-
|
10197
|
+
throw new import_errors27.FuelError(
|
10198
|
+
import_errors27.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10047
10199
|
"Predicate has no configurable constants to be set"
|
10048
10200
|
);
|
10049
10201
|
}
|
10050
10202
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
10051
10203
|
if (!abiInterface?.configurables[key]) {
|
10052
|
-
throw new
|
10053
|
-
|
10204
|
+
throw new import_errors27.FuelError(
|
10205
|
+
import_errors27.ErrorCode.CONFIGURABLE_NOT_FOUND,
|
10054
10206
|
`No configurable constant named '${key}' found in the Predicate`
|
10055
10207
|
);
|
10056
10208
|
}
|
@@ -10059,8 +10211,8 @@ var Predicate = class extends Account {
|
|
10059
10211
|
mutatedBytes.set(encoded, offset);
|
10060
10212
|
});
|
10061
10213
|
} catch (err) {
|
10062
|
-
throw new
|
10063
|
-
|
10214
|
+
throw new import_errors27.FuelError(
|
10215
|
+
import_errors27.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10064
10216
|
`Error setting configurable constants: ${err.message}.`
|
10065
10217
|
);
|
10066
10218
|
}
|
@@ -10091,10 +10243,10 @@ var Predicate = class extends Account {
|
|
10091
10243
|
};
|
10092
10244
|
|
10093
10245
|
// src/connectors/fuel.ts
|
10094
|
-
var
|
10246
|
+
var import_errors30 = require("@fuel-ts/errors");
|
10095
10247
|
|
10096
10248
|
// src/connectors/fuel-connector.ts
|
10097
|
-
var
|
10249
|
+
var import_errors28 = require("@fuel-ts/errors");
|
10098
10250
|
var import_events2 = require("events");
|
10099
10251
|
|
10100
10252
|
// src/connectors/types/connector-types.ts
|
@@ -10168,7 +10320,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10168
10320
|
* @returns Always true.
|
10169
10321
|
*/
|
10170
10322
|
async ping() {
|
10171
|
-
throw new
|
10323
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10172
10324
|
}
|
10173
10325
|
/**
|
10174
10326
|
* Should return the current version of the connector
|
@@ -10177,7 +10329,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10177
10329
|
* @returns boolean - connection status.
|
10178
10330
|
*/
|
10179
10331
|
async version() {
|
10180
|
-
throw new
|
10332
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10181
10333
|
}
|
10182
10334
|
/**
|
10183
10335
|
* Should return true if the connector is connected
|
@@ -10186,7 +10338,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10186
10338
|
* @returns The connection status.
|
10187
10339
|
*/
|
10188
10340
|
async isConnected() {
|
10189
|
-
throw new
|
10341
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10190
10342
|
}
|
10191
10343
|
/**
|
10192
10344
|
* Should return all the accounts authorized for the
|
@@ -10195,7 +10347,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10195
10347
|
* @returns The accounts addresses strings
|
10196
10348
|
*/
|
10197
10349
|
async accounts() {
|
10198
|
-
throw new
|
10350
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10199
10351
|
}
|
10200
10352
|
/**
|
10201
10353
|
* Should start the connection process and return
|
@@ -10207,7 +10359,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10207
10359
|
* @returns boolean - connection status.
|
10208
10360
|
*/
|
10209
10361
|
async connect() {
|
10210
|
-
throw new
|
10362
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10211
10363
|
}
|
10212
10364
|
/**
|
10213
10365
|
* Should disconnect the current connection and
|
@@ -10217,7 +10369,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10217
10369
|
* @returns The connection status.
|
10218
10370
|
*/
|
10219
10371
|
async disconnect() {
|
10220
|
-
throw new
|
10372
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10221
10373
|
}
|
10222
10374
|
/**
|
10223
10375
|
* Should start the sign message process and return
|
@@ -10229,7 +10381,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10229
10381
|
* @returns Message signature
|
10230
10382
|
*/
|
10231
10383
|
async signMessage(_address, _message) {
|
10232
|
-
throw new
|
10384
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10233
10385
|
}
|
10234
10386
|
/**
|
10235
10387
|
* Should start the sign transaction process and return
|
@@ -10241,7 +10393,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10241
10393
|
* @returns Transaction signature
|
10242
10394
|
*/
|
10243
10395
|
async signTransaction(_address, _transaction) {
|
10244
|
-
throw new
|
10396
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10245
10397
|
}
|
10246
10398
|
/**
|
10247
10399
|
* Should start the send transaction process and return
|
@@ -10257,7 +10409,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10257
10409
|
* @returns The transaction id
|
10258
10410
|
*/
|
10259
10411
|
async sendTransaction(_address, _transaction) {
|
10260
|
-
throw new
|
10412
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10261
10413
|
}
|
10262
10414
|
/**
|
10263
10415
|
* Should return the current account selected inside the connector, if the account
|
@@ -10268,7 +10420,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10268
10420
|
* @returns The current account selected otherwise null.
|
10269
10421
|
*/
|
10270
10422
|
async currentAccount() {
|
10271
|
-
throw new
|
10423
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10272
10424
|
}
|
10273
10425
|
/**
|
10274
10426
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -10282,7 +10434,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10282
10434
|
* @returns True if the asset was added successfully
|
10283
10435
|
*/
|
10284
10436
|
async addAssets(_assets) {
|
10285
|
-
throw new
|
10437
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10286
10438
|
}
|
10287
10439
|
/**
|
10288
10440
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -10296,7 +10448,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10296
10448
|
* @returns True if the asset was added successfully
|
10297
10449
|
*/
|
10298
10450
|
async addAsset(_asset) {
|
10299
|
-
throw new
|
10451
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10300
10452
|
}
|
10301
10453
|
/**
|
10302
10454
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -10304,7 +10456,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10304
10456
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
10305
10457
|
*/
|
10306
10458
|
async assets() {
|
10307
|
-
throw new
|
10459
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10308
10460
|
}
|
10309
10461
|
/**
|
10310
10462
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -10315,7 +10467,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10315
10467
|
* @returns Return true if the network was added successfully
|
10316
10468
|
*/
|
10317
10469
|
async addNetwork(_networkUrl) {
|
10318
|
-
throw new
|
10470
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10319
10471
|
}
|
10320
10472
|
/**
|
10321
10473
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -10326,7 +10478,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10326
10478
|
* @returns Return true if the network was added successfully
|
10327
10479
|
*/
|
10328
10480
|
async selectNetwork(_network) {
|
10329
|
-
throw new
|
10481
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10330
10482
|
}
|
10331
10483
|
/**
|
10332
10484
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -10334,7 +10486,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10334
10486
|
* @returns Return all the networks added to the connector.
|
10335
10487
|
*/
|
10336
10488
|
async networks() {
|
10337
|
-
throw new
|
10489
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10338
10490
|
}
|
10339
10491
|
/**
|
10340
10492
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -10342,7 +10494,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10342
10494
|
* @returns Return the current network selected inside the connector.
|
10343
10495
|
*/
|
10344
10496
|
async currentNetwork() {
|
10345
|
-
throw new
|
10497
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10346
10498
|
}
|
10347
10499
|
/**
|
10348
10500
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -10352,7 +10504,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10352
10504
|
* @returns Return true if the ABI was added successfully.
|
10353
10505
|
*/
|
10354
10506
|
async addABI(_contractId, _abi) {
|
10355
|
-
throw new
|
10507
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10356
10508
|
}
|
10357
10509
|
/**
|
10358
10510
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10361,7 +10513,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10361
10513
|
* @returns The ABI if it exists, otherwise return null.
|
10362
10514
|
*/
|
10363
10515
|
async getABI(_id) {
|
10364
|
-
throw new
|
10516
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10365
10517
|
}
|
10366
10518
|
/**
|
10367
10519
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10370,7 +10522,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10370
10522
|
* @returns Returns true if the abi exists or false if not.
|
10371
10523
|
*/
|
10372
10524
|
async hasABI(_id) {
|
10373
|
-
throw new
|
10525
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10374
10526
|
}
|
10375
10527
|
/**
|
10376
10528
|
* Event listener for the connector.
|
@@ -10414,7 +10566,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
10414
10566
|
}
|
10415
10567
|
|
10416
10568
|
// src/connectors/utils/promises.ts
|
10417
|
-
var
|
10569
|
+
var import_errors29 = require("@fuel-ts/errors");
|
10418
10570
|
function deferPromise() {
|
10419
10571
|
const defer = {};
|
10420
10572
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -10426,7 +10578,7 @@ function deferPromise() {
|
|
10426
10578
|
async function withTimeout(promise, timeout = 1050) {
|
10427
10579
|
const timeoutPromise = new Promise((resolve, reject) => {
|
10428
10580
|
setTimeout(() => {
|
10429
|
-
reject(new
|
10581
|
+
reject(new import_errors29.FuelError(import_errors29.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
10430
10582
|
}, timeout);
|
10431
10583
|
});
|
10432
10584
|
return Promise.race([timeoutPromise, promise]);
|
@@ -10460,7 +10612,7 @@ var _Fuel = class extends FuelConnector {
|
|
10460
10612
|
await this.setDefaultConnector();
|
10461
10613
|
this._targetUnsubscribe = this.setupConnectorListener();
|
10462
10614
|
} catch (error) {
|
10463
|
-
throw new
|
10615
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.INVALID_PROVIDER, "Error initializing Fuel Connector");
|
10464
10616
|
}
|
10465
10617
|
}
|
10466
10618
|
async init() {
|
@@ -10526,8 +10678,8 @@ var _Fuel = class extends FuelConnector {
|
|
10526
10678
|
const hasConnector = await this.hasConnector();
|
10527
10679
|
await this.pingConnector();
|
10528
10680
|
if (!this._currentConnector || !hasConnector) {
|
10529
|
-
throw new
|
10530
|
-
|
10681
|
+
throw new import_errors30.FuelError(
|
10682
|
+
import_errors30.ErrorCode.MISSING_CONNECTOR,
|
10531
10683
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
10532
10684
|
);
|
10533
10685
|
}
|
@@ -10591,7 +10743,7 @@ var _Fuel = class extends FuelConnector {
|
|
10591
10743
|
cacheTime: PING_CACHE_TIME
|
10592
10744
|
})();
|
10593
10745
|
} catch {
|
10594
|
-
throw new
|
10746
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.INVALID_PROVIDER, "Current connector is not available.");
|
10595
10747
|
}
|
10596
10748
|
}
|
10597
10749
|
/**
|
@@ -10740,7 +10892,7 @@ var _Fuel = class extends FuelConnector {
|
|
10740
10892
|
const currentNetwork = await this.currentNetwork();
|
10741
10893
|
provider = await Provider.create(currentNetwork.url);
|
10742
10894
|
} else {
|
10743
|
-
throw new
|
10895
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
|
10744
10896
|
}
|
10745
10897
|
return provider;
|
10746
10898
|
}
|
@@ -10896,10 +11048,13 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10896
11048
|
isCoin,
|
10897
11049
|
isInputCoin,
|
10898
11050
|
isMessage,
|
11051
|
+
isMessageCoin,
|
10899
11052
|
isRawCoin,
|
10900
11053
|
isRawMessage,
|
10901
11054
|
isRequestInputCoin,
|
11055
|
+
isRequestInputCoinOrMessage,
|
10902
11056
|
isRequestInputMessage,
|
11057
|
+
isRequestInputMessageWithoutData,
|
10903
11058
|
isRequestInputResource,
|
10904
11059
|
isRequestInputResourceFromOwner,
|
10905
11060
|
isTransactionTypeBlob,
|