@fuel-ts/account 0.94.3 → 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.map +1 -1
- package/dist/index.global.js +352 -268
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +307 -167
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +304 -167
- 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 +196 -118
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +262 -134
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +260 -132
- package/dist/test-utils.mjs.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
|
}
|
@@ -4802,7 +4878,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4802
4878
|
missingContractIds: [],
|
4803
4879
|
dryRunStatus: void 0
|
4804
4880
|
}));
|
4805
|
-
const allRequests = (0,
|
4881
|
+
const allRequests = (0, import_ramda6.clone)(transactionRequests);
|
4806
4882
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4807
4883
|
allRequests.forEach((req, index) => {
|
4808
4884
|
if (isTransactionTypeScript(req)) {
|
@@ -4962,13 +5038,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4962
5038
|
* @returns A promise that resolves to the transaction cost object.
|
4963
5039
|
*/
|
4964
5040
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
4965
|
-
const txRequestClone = (0,
|
5041
|
+
const txRequestClone = (0, import_ramda6.clone)(transactionRequestify(transactionRequestLike));
|
4966
5042
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4967
5043
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
4968
5044
|
if (isScriptTransaction) {
|
4969
5045
|
txRequestClone.gasLimit = (0, import_math18.bn)(0);
|
4970
5046
|
}
|
4971
|
-
const signedRequest = (0,
|
5047
|
+
const signedRequest = (0, import_ramda6.clone)(txRequestClone);
|
4972
5048
|
let addedSignatures = 0;
|
4973
5049
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
4974
5050
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -5106,6 +5182,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5106
5182
|
}).filter((v) => !!v);
|
5107
5183
|
return coins;
|
5108
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
|
+
}
|
5109
5200
|
/**
|
5110
5201
|
* Returns block matching the given ID or height.
|
5111
5202
|
*
|
@@ -5127,11 +5218,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5127
5218
|
if (!block) {
|
5128
5219
|
return null;
|
5129
5220
|
}
|
5221
|
+
const { header, height, id, transactions } = block;
|
5130
5222
|
return {
|
5131
|
-
id
|
5132
|
-
height: (0, import_math18.bn)(
|
5133
|
-
time:
|
5134
|
-
|
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)
|
5135
5237
|
};
|
5136
5238
|
}
|
5137
5239
|
/**
|
@@ -5153,6 +5255,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5153
5255
|
id: block.id,
|
5154
5256
|
height: (0, import_math18.bn)(block.height),
|
5155
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
|
+
},
|
5156
5268
|
transactionIds: block.transactions.map((tx) => tx.id)
|
5157
5269
|
}));
|
5158
5270
|
return { blocks, pageInfo };
|
@@ -5180,6 +5292,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5180
5292
|
id: block.id,
|
5181
5293
|
height: (0, import_math18.bn)(block.height, 10),
|
5182
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
|
+
},
|
5183
5305
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5184
5306
|
transactions: block.transactions.map(
|
5185
5307
|
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils24.arrayify)(tx.rawPayload), 0)?.[0]
|
@@ -5203,7 +5325,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5203
5325
|
0
|
5204
5326
|
)?.[0];
|
5205
5327
|
} catch (error) {
|
5206
|
-
if (error instanceof
|
5328
|
+
if (error instanceof import_errors16.FuelError && error.code === import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5207
5329
|
console.warn("Unsupported transaction type encountered");
|
5208
5330
|
return null;
|
5209
5331
|
}
|
@@ -5224,7 +5346,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5224
5346
|
try {
|
5225
5347
|
return coder.decode((0, import_utils24.arrayify)(rawPayload), 0)[0];
|
5226
5348
|
} catch (error) {
|
5227
|
-
if (error instanceof
|
5349
|
+
if (error instanceof import_errors16.FuelError && error.code === import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5228
5350
|
console.warn("Unsupported transaction type encountered");
|
5229
5351
|
return null;
|
5230
5352
|
}
|
@@ -5350,8 +5472,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5350
5472
|
nonce
|
5351
5473
|
};
|
5352
5474
|
if (commitBlockId && commitBlockHeight) {
|
5353
|
-
throw new
|
5354
|
-
|
5475
|
+
throw new import_errors16.FuelError(
|
5476
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5355
5477
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5356
5478
|
);
|
5357
5479
|
}
|
@@ -5491,10 +5613,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5491
5613
|
* @returns A promise that resolves to the Message object or null.
|
5492
5614
|
*/
|
5493
5615
|
async getMessageByNonce(nonce) {
|
5494
|
-
const { message } = await this.operations.getMessageByNonce({ nonce });
|
5495
|
-
if (!
|
5616
|
+
const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
|
5617
|
+
if (!rawMessage) {
|
5496
5618
|
return null;
|
5497
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
|
+
};
|
5498
5635
|
return message;
|
5499
5636
|
}
|
5500
5637
|
/**
|
@@ -5519,26 +5656,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5519
5656
|
const { paginationLimit, inputArgs = {} } = params;
|
5520
5657
|
const { first, last, after, before } = inputArgs;
|
5521
5658
|
if (after && before) {
|
5522
|
-
throw new
|
5523
|
-
|
5659
|
+
throw new import_errors16.FuelError(
|
5660
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5524
5661
|
'Pagination arguments "after" and "before" cannot be used together'
|
5525
5662
|
);
|
5526
5663
|
}
|
5527
5664
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5528
|
-
throw new
|
5529
|
-
|
5665
|
+
throw new import_errors16.FuelError(
|
5666
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5530
5667
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5531
5668
|
);
|
5532
5669
|
}
|
5533
5670
|
if (first && before) {
|
5534
|
-
throw new
|
5535
|
-
|
5671
|
+
throw new import_errors16.FuelError(
|
5672
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5536
5673
|
'The use of pagination argument "first" with "before" is not supported'
|
5537
5674
|
);
|
5538
5675
|
}
|
5539
5676
|
if (last && after) {
|
5540
|
-
throw new
|
5541
|
-
|
5677
|
+
throw new import_errors16.FuelError(
|
5678
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5542
5679
|
'The use of pagination argument "last" with "after" is not supported'
|
5543
5680
|
);
|
5544
5681
|
}
|
@@ -5592,7 +5729,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5592
5729
|
__publicField(Provider, "nodeInfoCache", {});
|
5593
5730
|
|
5594
5731
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5595
|
-
var
|
5732
|
+
var import_errors17 = require("@fuel-ts/errors");
|
5596
5733
|
var import_math19 = require("@fuel-ts/math");
|
5597
5734
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5598
5735
|
var import_utils27 = require("@fuel-ts/utils");
|
@@ -5602,8 +5739,8 @@ async function getTransactionSummary(params) {
|
|
5602
5739
|
transactionId: id
|
5603
5740
|
});
|
5604
5741
|
if (!gqlTransaction) {
|
5605
|
-
throw new
|
5606
|
-
|
5742
|
+
throw new import_errors17.FuelError(
|
5743
|
+
import_errors17.ErrorCode.TRANSACTION_NOT_FOUND,
|
5607
5744
|
`Transaction not found for given id: ${id}.`
|
5608
5745
|
);
|
5609
5746
|
}
|
@@ -5929,7 +6066,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5929
6066
|
*/
|
5930
6067
|
get provider() {
|
5931
6068
|
if (!this._provider) {
|
5932
|
-
throw new
|
6069
|
+
throw new import_errors18.FuelError(import_errors18.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
5933
6070
|
}
|
5934
6071
|
return this._provider;
|
5935
6072
|
}
|
@@ -6047,7 +6184,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6047
6184
|
);
|
6048
6185
|
request.addResources(resources);
|
6049
6186
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6050
|
-
const requestToReestimate2 = (0,
|
6187
|
+
const requestToReestimate2 = (0, import_ramda7.clone)(request);
|
6051
6188
|
if (addedSignatures) {
|
6052
6189
|
Array.from({ length: addedSignatures }).forEach(
|
6053
6190
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -6062,7 +6199,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6062
6199
|
gasPrice
|
6063
6200
|
});
|
6064
6201
|
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
6065
|
-
request.inputs,
|
6202
|
+
request.inputs.filter(isRequestInputResource),
|
6066
6203
|
baseAssetId,
|
6067
6204
|
baseAssetId
|
6068
6205
|
);
|
@@ -6080,13 +6217,13 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6080
6217
|
fundingAttempts += 1;
|
6081
6218
|
}
|
6082
6219
|
if (needsToBeFunded) {
|
6083
|
-
throw new
|
6084
|
-
|
6220
|
+
throw new import_errors18.FuelError(
|
6221
|
+
import_errors18.ErrorCode.NOT_ENOUGH_FUNDS,
|
6085
6222
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6086
6223
|
);
|
6087
6224
|
}
|
6088
6225
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6089
|
-
const requestToReestimate = (0,
|
6226
|
+
const requestToReestimate = (0, import_ramda7.clone)(request);
|
6090
6227
|
if (addedSignatures) {
|
6091
6228
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
6092
6229
|
}
|
@@ -6186,8 +6323,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6186
6323
|
*/
|
6187
6324
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6188
6325
|
if ((0, import_math21.bn)(amount).lte(0)) {
|
6189
|
-
throw new
|
6190
|
-
|
6326
|
+
throw new import_errors18.FuelError(
|
6327
|
+
import_errors18.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6191
6328
|
"Transfer amount must be a positive number."
|
6192
6329
|
);
|
6193
6330
|
}
|
@@ -6262,16 +6399,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6262
6399
|
* @returns A promise that resolves to the transaction cost object.
|
6263
6400
|
*/
|
6264
6401
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6265
|
-
const txRequestClone = (0,
|
6402
|
+
const txRequestClone = (0, import_ramda7.clone)(transactionRequestify(transactionRequestLike));
|
6266
6403
|
const baseAssetId = this.provider.getBaseAssetId();
|
6267
6404
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6268
6405
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
6269
6406
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
|
6270
6407
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6271
|
-
if (
|
6408
|
+
if (input.type === import_transactions22.InputType.Coin) {
|
6272
6409
|
return input.assetId === assetId;
|
6273
6410
|
}
|
6274
|
-
if (
|
6411
|
+
if (isRequestInputMessageWithoutData(input)) {
|
6275
6412
|
return baseAssetId === assetId;
|
6276
6413
|
}
|
6277
6414
|
return false;
|
@@ -6313,7 +6450,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6313
6450
|
*/
|
6314
6451
|
async signMessage(message) {
|
6315
6452
|
if (!this._connector) {
|
6316
|
-
throw new
|
6453
|
+
throw new import_errors18.FuelError(import_errors18.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6317
6454
|
}
|
6318
6455
|
return this._connector.signMessage(this.address.toString(), message);
|
6319
6456
|
}
|
@@ -6325,8 +6462,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6325
6462
|
*/
|
6326
6463
|
async signTransaction(transactionRequestLike) {
|
6327
6464
|
if (!this._connector) {
|
6328
|
-
throw new
|
6329
|
-
|
6465
|
+
throw new import_errors18.FuelError(
|
6466
|
+
import_errors18.ErrorCode.MISSING_CONNECTOR,
|
6330
6467
|
"A connector is required to sign transactions."
|
6331
6468
|
);
|
6332
6469
|
}
|
@@ -6385,8 +6522,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6385
6522
|
/** @hidden * */
|
6386
6523
|
validateTransferAmount(amount) {
|
6387
6524
|
if ((0, import_math21.bn)(amount).lte(0)) {
|
6388
|
-
throw new
|
6389
|
-
|
6525
|
+
throw new import_errors18.FuelError(
|
6526
|
+
import_errors18.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6390
6527
|
"Transfer amount must be a positive number."
|
6391
6528
|
);
|
6392
6529
|
}
|
@@ -6415,16 +6552,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6415
6552
|
if (!(0, import_utils30.isDefined)(setGasLimit)) {
|
6416
6553
|
request.gasLimit = gasUsed;
|
6417
6554
|
} else if (gasUsed.gt(setGasLimit)) {
|
6418
|
-
throw new
|
6419
|
-
|
6555
|
+
throw new import_errors18.FuelError(
|
6556
|
+
import_errors18.ErrorCode.GAS_LIMIT_TOO_LOW,
|
6420
6557
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6421
6558
|
);
|
6422
6559
|
}
|
6423
6560
|
if (!(0, import_utils30.isDefined)(setMaxFee)) {
|
6424
6561
|
request.maxFee = maxFee;
|
6425
6562
|
} else if (maxFee.gt(setMaxFee)) {
|
6426
|
-
throw new
|
6427
|
-
|
6563
|
+
throw new import_errors18.FuelError(
|
6564
|
+
import_errors18.ErrorCode.MAX_FEE_TOO_LOW,
|
6428
6565
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6429
6566
|
);
|
6430
6567
|
}
|
@@ -6548,7 +6685,7 @@ var Signer = class {
|
|
6548
6685
|
// src/wallet/keystore-wallet.ts
|
6549
6686
|
var import_address6 = require("@fuel-ts/address");
|
6550
6687
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6551
|
-
var
|
6688
|
+
var import_errors19 = require("@fuel-ts/errors");
|
6552
6689
|
var import_utils32 = require("@fuel-ts/utils");
|
6553
6690
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6554
6691
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6625,8 +6762,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6625
6762
|
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
6626
6763
|
const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
6627
6764
|
if (mac !== macHash) {
|
6628
|
-
throw new
|
6629
|
-
|
6765
|
+
throw new import_errors19.FuelError(
|
6766
|
+
import_errors19.ErrorCode.INVALID_PASSWORD,
|
6630
6767
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6631
6768
|
);
|
6632
6769
|
}
|
@@ -6756,14 +6893,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6756
6893
|
|
6757
6894
|
// src/hdwallet/hdwallet.ts
|
6758
6895
|
var import_crypto6 = require("@fuel-ts/crypto");
|
6759
|
-
var
|
6896
|
+
var import_errors22 = require("@fuel-ts/errors");
|
6760
6897
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6761
6898
|
var import_math23 = require("@fuel-ts/math");
|
6762
6899
|
var import_utils37 = require("@fuel-ts/utils");
|
6763
6900
|
|
6764
6901
|
// src/mnemonic/mnemonic.ts
|
6765
6902
|
var import_crypto5 = require("@fuel-ts/crypto");
|
6766
|
-
var
|
6903
|
+
var import_errors21 = require("@fuel-ts/errors");
|
6767
6904
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6768
6905
|
var import_utils35 = require("@fuel-ts/utils");
|
6769
6906
|
|
@@ -8826,7 +8963,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8826
8963
|
})(Language || {});
|
8827
8964
|
|
8828
8965
|
// src/mnemonic/utils.ts
|
8829
|
-
var
|
8966
|
+
var import_errors20 = require("@fuel-ts/errors");
|
8830
8967
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8831
8968
|
var import_utils34 = require("@fuel-ts/utils");
|
8832
8969
|
function getLowerMask(bits) {
|
@@ -8875,8 +9012,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8875
9012
|
for (let i = 0; i < words.length; i += 1) {
|
8876
9013
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8877
9014
|
if (index === -1) {
|
8878
|
-
throw new
|
8879
|
-
|
9015
|
+
throw new import_errors20.FuelError(
|
9016
|
+
import_errors20.ErrorCode.INVALID_MNEMONIC,
|
8880
9017
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8881
9018
|
);
|
8882
9019
|
}
|
@@ -8892,8 +9029,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8892
9029
|
const checksumMask = getUpperMask(checksumBits);
|
8893
9030
|
const checksum = (0, import_utils34.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8894
9031
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8895
|
-
throw new
|
8896
|
-
|
9032
|
+
throw new import_errors20.FuelError(
|
9033
|
+
import_errors20.ErrorCode.INVALID_CHECKSUM,
|
8897
9034
|
"Checksum validation failed for the provided mnemonic."
|
8898
9035
|
);
|
8899
9036
|
}
|
@@ -8907,16 +9044,16 @@ var TestnetPRV = "0x04358394";
|
|
8907
9044
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8908
9045
|
function assertWordList(wordlist) {
|
8909
9046
|
if (wordlist.length !== 2048) {
|
8910
|
-
throw new
|
8911
|
-
|
9047
|
+
throw new import_errors21.FuelError(
|
9048
|
+
import_errors21.ErrorCode.INVALID_WORD_LIST,
|
8912
9049
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8913
9050
|
);
|
8914
9051
|
}
|
8915
9052
|
}
|
8916
9053
|
function assertEntropy(entropy) {
|
8917
9054
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8918
|
-
throw new
|
8919
|
-
|
9055
|
+
throw new import_errors21.FuelError(
|
9056
|
+
import_errors21.ErrorCode.INVALID_ENTROPY,
|
8920
9057
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8921
9058
|
);
|
8922
9059
|
}
|
@@ -8926,7 +9063,7 @@ function assertMnemonic(words) {
|
|
8926
9063
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8927
9064
|
", "
|
8928
9065
|
)}] words, but got ${words.length}.`;
|
8929
|
-
throw new
|
9066
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
8930
9067
|
}
|
8931
9068
|
}
|
8932
9069
|
var Mnemonic = class {
|
@@ -9044,8 +9181,8 @@ var Mnemonic = class {
|
|
9044
9181
|
static masterKeysFromSeed(seed) {
|
9045
9182
|
const seedArray = (0, import_utils35.arrayify)(seed);
|
9046
9183
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9047
|
-
throw new
|
9048
|
-
|
9184
|
+
throw new import_errors21.FuelError(
|
9185
|
+
import_errors21.ErrorCode.INVALID_SEED,
|
9049
9186
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9050
9187
|
);
|
9051
9188
|
}
|
@@ -9122,7 +9259,7 @@ function isValidExtendedKey(extendedKey) {
|
|
9122
9259
|
function parsePath(path, depth = 0) {
|
9123
9260
|
const components = path.split("/");
|
9124
9261
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9125
|
-
throw new
|
9262
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
|
9126
9263
|
}
|
9127
9264
|
if (components[0] === "m") {
|
9128
9265
|
components.shift();
|
@@ -9151,8 +9288,8 @@ var HDWallet = class {
|
|
9151
9288
|
this.privateKey = (0, import_utils37.hexlify)(config.privateKey);
|
9152
9289
|
} else {
|
9153
9290
|
if (!config.publicKey) {
|
9154
|
-
throw new
|
9155
|
-
|
9291
|
+
throw new import_errors22.FuelError(
|
9292
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9156
9293
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9157
9294
|
);
|
9158
9295
|
}
|
@@ -9181,8 +9318,8 @@ var HDWallet = class {
|
|
9181
9318
|
const data = new Uint8Array(37);
|
9182
9319
|
if (index & HARDENED_INDEX) {
|
9183
9320
|
if (!privateKey) {
|
9184
|
-
throw new
|
9185
|
-
|
9321
|
+
throw new import_errors22.FuelError(
|
9322
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9186
9323
|
"Cannot derive a hardened index without a private Key."
|
9187
9324
|
);
|
9188
9325
|
}
|
@@ -9234,8 +9371,8 @@ var HDWallet = class {
|
|
9234
9371
|
*/
|
9235
9372
|
toExtendedKey(isPublic = false, testnet = false) {
|
9236
9373
|
if (this.depth >= 256) {
|
9237
|
-
throw new
|
9238
|
-
|
9374
|
+
throw new import_errors22.FuelError(
|
9375
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9239
9376
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9240
9377
|
);
|
9241
9378
|
}
|
@@ -9266,10 +9403,10 @@ var HDWallet = class {
|
|
9266
9403
|
const bytes = (0, import_utils37.arrayify)(decoded);
|
9267
9404
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9268
9405
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9269
|
-
throw new
|
9406
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9270
9407
|
}
|
9271
9408
|
if (!validChecksum) {
|
9272
|
-
throw new
|
9409
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9273
9410
|
}
|
9274
9411
|
const depth = bytes[4];
|
9275
9412
|
const parentFingerprint = (0, import_utils37.hexlify)(bytes.slice(5, 9));
|
@@ -9277,14 +9414,14 @@ var HDWallet = class {
|
|
9277
9414
|
const chainCode = (0, import_utils37.hexlify)(bytes.slice(13, 45));
|
9278
9415
|
const key = bytes.slice(45, 78);
|
9279
9416
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9280
|
-
throw new
|
9281
|
-
|
9417
|
+
throw new import_errors22.FuelError(
|
9418
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9282
9419
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9283
9420
|
);
|
9284
9421
|
}
|
9285
9422
|
if (isPublicExtendedKey(bytes)) {
|
9286
9423
|
if (key[0] !== 3) {
|
9287
|
-
throw new
|
9424
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
9288
9425
|
}
|
9289
9426
|
return new HDWallet({
|
9290
9427
|
publicKey: key,
|
@@ -9295,7 +9432,7 @@ var HDWallet = class {
|
|
9295
9432
|
});
|
9296
9433
|
}
|
9297
9434
|
if (key[0] !== 0) {
|
9298
|
-
throw new
|
9435
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
9299
9436
|
}
|
9300
9437
|
return new HDWallet({
|
9301
9438
|
privateKey: key.slice(1),
|
@@ -9463,7 +9600,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
9463
9600
|
// src/wallet-manager/wallet-manager.ts
|
9464
9601
|
var import_address9 = require("@fuel-ts/address");
|
9465
9602
|
var import_crypto7 = require("@fuel-ts/crypto");
|
9466
|
-
var
|
9603
|
+
var import_errors25 = require("@fuel-ts/errors");
|
9467
9604
|
var import_events = require("events");
|
9468
9605
|
|
9469
9606
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -9486,7 +9623,7 @@ var MemoryStorage = class {
|
|
9486
9623
|
|
9487
9624
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
9488
9625
|
var import_address7 = require("@fuel-ts/address");
|
9489
|
-
var
|
9626
|
+
var import_errors23 = require("@fuel-ts/errors");
|
9490
9627
|
var _secret;
|
9491
9628
|
var MnemonicVault = class {
|
9492
9629
|
constructor(options) {
|
@@ -9542,8 +9679,8 @@ var MnemonicVault = class {
|
|
9542
9679
|
}
|
9543
9680
|
numberOfAccounts += 1;
|
9544
9681
|
} while (numberOfAccounts < this.numberOfAccounts);
|
9545
|
-
throw new
|
9546
|
-
|
9682
|
+
throw new import_errors23.FuelError(
|
9683
|
+
import_errors23.ErrorCode.WALLET_MANAGER_ERROR,
|
9547
9684
|
`Account with address '${address}' not found in derived wallets.`
|
9548
9685
|
);
|
9549
9686
|
}
|
@@ -9557,7 +9694,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
9557
9694
|
|
9558
9695
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
9559
9696
|
var import_address8 = require("@fuel-ts/address");
|
9560
|
-
var
|
9697
|
+
var import_errors24 = require("@fuel-ts/errors");
|
9561
9698
|
var _privateKeys;
|
9562
9699
|
var PrivateKeyVault = class {
|
9563
9700
|
/**
|
@@ -9598,8 +9735,8 @@ var PrivateKeyVault = class {
|
|
9598
9735
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
9599
9736
|
);
|
9600
9737
|
if (!privateKey) {
|
9601
|
-
throw new
|
9602
|
-
|
9738
|
+
throw new import_errors24.FuelError(
|
9739
|
+
import_errors24.ErrorCode.WALLET_MANAGER_ERROR,
|
9603
9740
|
`No private key found for address '${address}'.`
|
9604
9741
|
);
|
9605
9742
|
}
|
@@ -9623,7 +9760,7 @@ var ERROR_MESSAGES = {
|
|
9623
9760
|
};
|
9624
9761
|
function assert(condition, message) {
|
9625
9762
|
if (!condition) {
|
9626
|
-
throw new
|
9763
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.WALLET_MANAGER_ERROR, message);
|
9627
9764
|
}
|
9628
9765
|
}
|
9629
9766
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -9849,25 +9986,25 @@ deserializeVaults_fn = function(vaults) {
|
|
9849
9986
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
9850
9987
|
|
9851
9988
|
// src/wallet-manager/types.ts
|
9852
|
-
var
|
9989
|
+
var import_errors26 = require("@fuel-ts/errors");
|
9853
9990
|
var Vault = class {
|
9854
9991
|
constructor(_options) {
|
9855
|
-
throw new
|
9992
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9856
9993
|
}
|
9857
9994
|
serialize() {
|
9858
|
-
throw new
|
9995
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9859
9996
|
}
|
9860
9997
|
getAccounts() {
|
9861
|
-
throw new
|
9998
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9862
9999
|
}
|
9863
10000
|
addAccount() {
|
9864
|
-
throw new
|
10001
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9865
10002
|
}
|
9866
10003
|
exportAccount(_address) {
|
9867
|
-
throw new
|
10004
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9868
10005
|
}
|
9869
10006
|
getWallet(_address) {
|
9870
|
-
throw new
|
10007
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9871
10008
|
}
|
9872
10009
|
};
|
9873
10010
|
__publicField(Vault, "type");
|
@@ -9877,7 +10014,7 @@ var StorageAbstract = class {
|
|
9877
10014
|
// src/predicate/predicate.ts
|
9878
10015
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
9879
10016
|
var import_address10 = require("@fuel-ts/address");
|
9880
|
-
var
|
10017
|
+
var import_errors27 = require("@fuel-ts/errors");
|
9881
10018
|
var import_utils39 = require("@fuel-ts/utils");
|
9882
10019
|
|
9883
10020
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9939,7 +10076,7 @@ var Predicate = class extends Account {
|
|
9939
10076
|
if (placeholderIndex !== -1) {
|
9940
10077
|
request.removeWitness(placeholderIndex);
|
9941
10078
|
}
|
9942
|
-
request.inputs.filter(
|
10079
|
+
request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
9943
10080
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9944
10081
|
input.predicate = (0, import_utils39.hexlify)(this.bytes);
|
9945
10082
|
input.predicateData = (0, import_utils39.hexlify)(this.getPredicateData());
|
@@ -9989,8 +10126,8 @@ var Predicate = class extends Account {
|
|
9989
10126
|
if (jsonAbi) {
|
9990
10127
|
abiInterface = new import_abi_coder8.Interface(jsonAbi);
|
9991
10128
|
if (abiInterface.functions.main === void 0) {
|
9992
|
-
throw new
|
9993
|
-
|
10129
|
+
throw new import_errors27.FuelError(
|
10130
|
+
import_errors27.ErrorCode.ABI_MAIN_METHOD_MISSING,
|
9994
10131
|
'Cannot use ABI without "main" function.'
|
9995
10132
|
);
|
9996
10133
|
}
|
@@ -10051,21 +10188,21 @@ var Predicate = class extends Account {
|
|
10051
10188
|
const mutatedBytes = bytes;
|
10052
10189
|
try {
|
10053
10190
|
if (!abiInterface) {
|
10054
|
-
throw new
|
10055
|
-
|
10191
|
+
throw new import_errors27.FuelError(
|
10192
|
+
import_errors27.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10056
10193
|
"Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
|
10057
10194
|
);
|
10058
10195
|
}
|
10059
10196
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
10060
|
-
throw new
|
10061
|
-
|
10197
|
+
throw new import_errors27.FuelError(
|
10198
|
+
import_errors27.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10062
10199
|
"Predicate has no configurable constants to be set"
|
10063
10200
|
);
|
10064
10201
|
}
|
10065
10202
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
10066
10203
|
if (!abiInterface?.configurables[key]) {
|
10067
|
-
throw new
|
10068
|
-
|
10204
|
+
throw new import_errors27.FuelError(
|
10205
|
+
import_errors27.ErrorCode.CONFIGURABLE_NOT_FOUND,
|
10069
10206
|
`No configurable constant named '${key}' found in the Predicate`
|
10070
10207
|
);
|
10071
10208
|
}
|
@@ -10074,8 +10211,8 @@ var Predicate = class extends Account {
|
|
10074
10211
|
mutatedBytes.set(encoded, offset);
|
10075
10212
|
});
|
10076
10213
|
} catch (err) {
|
10077
|
-
throw new
|
10078
|
-
|
10214
|
+
throw new import_errors27.FuelError(
|
10215
|
+
import_errors27.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10079
10216
|
`Error setting configurable constants: ${err.message}.`
|
10080
10217
|
);
|
10081
10218
|
}
|
@@ -10106,10 +10243,10 @@ var Predicate = class extends Account {
|
|
10106
10243
|
};
|
10107
10244
|
|
10108
10245
|
// src/connectors/fuel.ts
|
10109
|
-
var
|
10246
|
+
var import_errors30 = require("@fuel-ts/errors");
|
10110
10247
|
|
10111
10248
|
// src/connectors/fuel-connector.ts
|
10112
|
-
var
|
10249
|
+
var import_errors28 = require("@fuel-ts/errors");
|
10113
10250
|
var import_events2 = require("events");
|
10114
10251
|
|
10115
10252
|
// src/connectors/types/connector-types.ts
|
@@ -10183,7 +10320,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10183
10320
|
* @returns Always true.
|
10184
10321
|
*/
|
10185
10322
|
async ping() {
|
10186
|
-
throw new
|
10323
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10187
10324
|
}
|
10188
10325
|
/**
|
10189
10326
|
* Should return the current version of the connector
|
@@ -10192,7 +10329,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10192
10329
|
* @returns boolean - connection status.
|
10193
10330
|
*/
|
10194
10331
|
async version() {
|
10195
|
-
throw new
|
10332
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10196
10333
|
}
|
10197
10334
|
/**
|
10198
10335
|
* Should return true if the connector is connected
|
@@ -10201,7 +10338,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10201
10338
|
* @returns The connection status.
|
10202
10339
|
*/
|
10203
10340
|
async isConnected() {
|
10204
|
-
throw new
|
10341
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10205
10342
|
}
|
10206
10343
|
/**
|
10207
10344
|
* Should return all the accounts authorized for the
|
@@ -10210,7 +10347,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10210
10347
|
* @returns The accounts addresses strings
|
10211
10348
|
*/
|
10212
10349
|
async accounts() {
|
10213
|
-
throw new
|
10350
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10214
10351
|
}
|
10215
10352
|
/**
|
10216
10353
|
* Should start the connection process and return
|
@@ -10222,7 +10359,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10222
10359
|
* @returns boolean - connection status.
|
10223
10360
|
*/
|
10224
10361
|
async connect() {
|
10225
|
-
throw new
|
10362
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10226
10363
|
}
|
10227
10364
|
/**
|
10228
10365
|
* Should disconnect the current connection and
|
@@ -10232,7 +10369,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10232
10369
|
* @returns The connection status.
|
10233
10370
|
*/
|
10234
10371
|
async disconnect() {
|
10235
|
-
throw new
|
10372
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10236
10373
|
}
|
10237
10374
|
/**
|
10238
10375
|
* Should start the sign message process and return
|
@@ -10244,7 +10381,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10244
10381
|
* @returns Message signature
|
10245
10382
|
*/
|
10246
10383
|
async signMessage(_address, _message) {
|
10247
|
-
throw new
|
10384
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10248
10385
|
}
|
10249
10386
|
/**
|
10250
10387
|
* Should start the sign transaction process and return
|
@@ -10256,7 +10393,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10256
10393
|
* @returns Transaction signature
|
10257
10394
|
*/
|
10258
10395
|
async signTransaction(_address, _transaction) {
|
10259
|
-
throw new
|
10396
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10260
10397
|
}
|
10261
10398
|
/**
|
10262
10399
|
* Should start the send transaction process and return
|
@@ -10272,7 +10409,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10272
10409
|
* @returns The transaction id
|
10273
10410
|
*/
|
10274
10411
|
async sendTransaction(_address, _transaction) {
|
10275
|
-
throw new
|
10412
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10276
10413
|
}
|
10277
10414
|
/**
|
10278
10415
|
* Should return the current account selected inside the connector, if the account
|
@@ -10283,7 +10420,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10283
10420
|
* @returns The current account selected otherwise null.
|
10284
10421
|
*/
|
10285
10422
|
async currentAccount() {
|
10286
|
-
throw new
|
10423
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10287
10424
|
}
|
10288
10425
|
/**
|
10289
10426
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -10297,7 +10434,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10297
10434
|
* @returns True if the asset was added successfully
|
10298
10435
|
*/
|
10299
10436
|
async addAssets(_assets) {
|
10300
|
-
throw new
|
10437
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10301
10438
|
}
|
10302
10439
|
/**
|
10303
10440
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -10311,7 +10448,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10311
10448
|
* @returns True if the asset was added successfully
|
10312
10449
|
*/
|
10313
10450
|
async addAsset(_asset) {
|
10314
|
-
throw new
|
10451
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10315
10452
|
}
|
10316
10453
|
/**
|
10317
10454
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -10319,7 +10456,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10319
10456
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
10320
10457
|
*/
|
10321
10458
|
async assets() {
|
10322
|
-
throw new
|
10459
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10323
10460
|
}
|
10324
10461
|
/**
|
10325
10462
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -10330,7 +10467,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10330
10467
|
* @returns Return true if the network was added successfully
|
10331
10468
|
*/
|
10332
10469
|
async addNetwork(_networkUrl) {
|
10333
|
-
throw new
|
10470
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10334
10471
|
}
|
10335
10472
|
/**
|
10336
10473
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -10341,7 +10478,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10341
10478
|
* @returns Return true if the network was added successfully
|
10342
10479
|
*/
|
10343
10480
|
async selectNetwork(_network) {
|
10344
|
-
throw new
|
10481
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10345
10482
|
}
|
10346
10483
|
/**
|
10347
10484
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -10349,7 +10486,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10349
10486
|
* @returns Return all the networks added to the connector.
|
10350
10487
|
*/
|
10351
10488
|
async networks() {
|
10352
|
-
throw new
|
10489
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10353
10490
|
}
|
10354
10491
|
/**
|
10355
10492
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -10357,7 +10494,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10357
10494
|
* @returns Return the current network selected inside the connector.
|
10358
10495
|
*/
|
10359
10496
|
async currentNetwork() {
|
10360
|
-
throw new
|
10497
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10361
10498
|
}
|
10362
10499
|
/**
|
10363
10500
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -10367,7 +10504,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10367
10504
|
* @returns Return true if the ABI was added successfully.
|
10368
10505
|
*/
|
10369
10506
|
async addABI(_contractId, _abi) {
|
10370
|
-
throw new
|
10507
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10371
10508
|
}
|
10372
10509
|
/**
|
10373
10510
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10376,7 +10513,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10376
10513
|
* @returns The ABI if it exists, otherwise return null.
|
10377
10514
|
*/
|
10378
10515
|
async getABI(_id) {
|
10379
|
-
throw new
|
10516
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10380
10517
|
}
|
10381
10518
|
/**
|
10382
10519
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10385,7 +10522,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10385
10522
|
* @returns Returns true if the abi exists or false if not.
|
10386
10523
|
*/
|
10387
10524
|
async hasABI(_id) {
|
10388
|
-
throw new
|
10525
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10389
10526
|
}
|
10390
10527
|
/**
|
10391
10528
|
* Event listener for the connector.
|
@@ -10429,7 +10566,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
10429
10566
|
}
|
10430
10567
|
|
10431
10568
|
// src/connectors/utils/promises.ts
|
10432
|
-
var
|
10569
|
+
var import_errors29 = require("@fuel-ts/errors");
|
10433
10570
|
function deferPromise() {
|
10434
10571
|
const defer = {};
|
10435
10572
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -10441,7 +10578,7 @@ function deferPromise() {
|
|
10441
10578
|
async function withTimeout(promise, timeout = 1050) {
|
10442
10579
|
const timeoutPromise = new Promise((resolve, reject) => {
|
10443
10580
|
setTimeout(() => {
|
10444
|
-
reject(new
|
10581
|
+
reject(new import_errors29.FuelError(import_errors29.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
10445
10582
|
}, timeout);
|
10446
10583
|
});
|
10447
10584
|
return Promise.race([timeoutPromise, promise]);
|
@@ -10475,7 +10612,7 @@ var _Fuel = class extends FuelConnector {
|
|
10475
10612
|
await this.setDefaultConnector();
|
10476
10613
|
this._targetUnsubscribe = this.setupConnectorListener();
|
10477
10614
|
} catch (error) {
|
10478
|
-
throw new
|
10615
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.INVALID_PROVIDER, "Error initializing Fuel Connector");
|
10479
10616
|
}
|
10480
10617
|
}
|
10481
10618
|
async init() {
|
@@ -10541,8 +10678,8 @@ var _Fuel = class extends FuelConnector {
|
|
10541
10678
|
const hasConnector = await this.hasConnector();
|
10542
10679
|
await this.pingConnector();
|
10543
10680
|
if (!this._currentConnector || !hasConnector) {
|
10544
|
-
throw new
|
10545
|
-
|
10681
|
+
throw new import_errors30.FuelError(
|
10682
|
+
import_errors30.ErrorCode.MISSING_CONNECTOR,
|
10546
10683
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
10547
10684
|
);
|
10548
10685
|
}
|
@@ -10606,7 +10743,7 @@ var _Fuel = class extends FuelConnector {
|
|
10606
10743
|
cacheTime: PING_CACHE_TIME
|
10607
10744
|
})();
|
10608
10745
|
} catch {
|
10609
|
-
throw new
|
10746
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.INVALID_PROVIDER, "Current connector is not available.");
|
10610
10747
|
}
|
10611
10748
|
}
|
10612
10749
|
/**
|
@@ -10755,7 +10892,7 @@ var _Fuel = class extends FuelConnector {
|
|
10755
10892
|
const currentNetwork = await this.currentNetwork();
|
10756
10893
|
provider = await Provider.create(currentNetwork.url);
|
10757
10894
|
} else {
|
10758
|
-
throw new
|
10895
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
|
10759
10896
|
}
|
10760
10897
|
return provider;
|
10761
10898
|
}
|
@@ -10911,10 +11048,13 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10911
11048
|
isCoin,
|
10912
11049
|
isInputCoin,
|
10913
11050
|
isMessage,
|
11051
|
+
isMessageCoin,
|
10914
11052
|
isRawCoin,
|
10915
11053
|
isRawMessage,
|
10916
11054
|
isRequestInputCoin,
|
11055
|
+
isRequestInputCoinOrMessage,
|
10917
11056
|
isRequestInputMessage,
|
11057
|
+
isRequestInputMessageWithoutData,
|
10918
11058
|
isRequestInputResource,
|
10919
11059
|
isRequestInputResourceFromOwner,
|
10920
11060
|
isTransactionTypeBlob,
|