@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.mjs
CHANGED
@@ -31,11 +31,12 @@ var __privateMethod = (obj, member, method) => {
|
|
31
31
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
32
32
|
import { Address as Address3 } from "@fuel-ts/address";
|
33
33
|
import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
|
34
|
-
import { ErrorCode as
|
34
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
|
35
35
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
36
36
|
import { bn as bn19 } from "@fuel-ts/math";
|
37
|
+
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
37
38
|
import { arrayify as arrayify14, hexlify as hexlify13, isDefined as isDefined3 } from "@fuel-ts/utils";
|
38
|
-
import { clone as
|
39
|
+
import { clone as clone7 } from "ramda";
|
39
40
|
|
40
41
|
// src/providers/coin-quantity.ts
|
41
42
|
import { bn } from "@fuel-ts/math";
|
@@ -74,14 +75,15 @@ var addAmountToCoinQuantities = (params) => {
|
|
74
75
|
|
75
76
|
// src/providers/provider.ts
|
76
77
|
import { Address as Address2 } from "@fuel-ts/address";
|
77
|
-
import { ErrorCode as
|
78
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
|
78
79
|
import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
|
79
80
|
import { InputType as InputType7, InputMessageCoder, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
80
81
|
import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
81
82
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
82
83
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
83
84
|
import { GraphQLClient } from "graphql-request";
|
84
|
-
import
|
85
|
+
import gql2 from "graphql-tag";
|
86
|
+
import { clone as clone6 } from "ramda";
|
85
87
|
|
86
88
|
// src/providers/__generated__/operations.ts
|
87
89
|
import gql from "graphql-tag";
|
@@ -414,6 +416,14 @@ var BlockFragmentDoc = gql`
|
|
414
416
|
height
|
415
417
|
header {
|
416
418
|
time
|
419
|
+
daHeight
|
420
|
+
stateTransitionBytecodeVersion
|
421
|
+
transactionsCount
|
422
|
+
transactionsRoot
|
423
|
+
messageOutboxRoot
|
424
|
+
eventInboxRoot
|
425
|
+
prevRoot
|
426
|
+
applicationHash
|
417
427
|
}
|
418
428
|
transactions {
|
419
429
|
id
|
@@ -1408,6 +1418,9 @@ import {
|
|
1408
1418
|
} from "@fuel-ts/transactions";
|
1409
1419
|
import { concat, hexlify as hexlify7, isDefined } from "@fuel-ts/utils";
|
1410
1420
|
|
1421
|
+
// src/providers/message.ts
|
1422
|
+
var isMessageCoin = (message) => !("data" in message);
|
1423
|
+
|
1411
1424
|
// src/providers/resource.ts
|
1412
1425
|
var isRawCoin = (resource) => "utxoId" in resource;
|
1413
1426
|
var isRawMessage = (resource) => "recipient" in resource;
|
@@ -1857,20 +1870,22 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
1857
1870
|
let reason = "";
|
1858
1871
|
if (revertReceipt) {
|
1859
1872
|
const reasonHex = bn6(revertReceipt.val).toHex();
|
1873
|
+
const lastLog = logs[logs.length - 1];
|
1874
|
+
const lastButOneLog = logs[logs.length - 2];
|
1860
1875
|
switch (reasonHex) {
|
1861
1876
|
case FAILED_REQUIRE_SIGNAL: {
|
1862
1877
|
reason = "require";
|
1863
|
-
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(
|
1878
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
1864
1879
|
break;
|
1865
1880
|
}
|
1866
1881
|
case FAILED_ASSERT_EQ_SIGNAL: {
|
1867
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(
|
1882
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
1868
1883
|
reason = "assert_eq";
|
1869
1884
|
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
1870
1885
|
break;
|
1871
1886
|
}
|
1872
1887
|
case FAILED_ASSERT_NE_SIGNAL: {
|
1873
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(
|
1888
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
1874
1889
|
reason = "assert_ne";
|
1875
1890
|
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
1876
1891
|
break;
|
@@ -1943,7 +1958,9 @@ import { bn as bn7 } from "@fuel-ts/math";
|
|
1943
1958
|
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1944
1959
|
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1945
1960
|
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1946
|
-
var
|
1961
|
+
var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
|
1962
|
+
var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1963
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
|
1947
1964
|
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
1948
1965
|
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
1949
1966
|
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
@@ -2253,7 +2270,7 @@ var BaseTransactionRequest = class {
|
|
2253
2270
|
* @param message - Message resource.
|
2254
2271
|
*/
|
2255
2272
|
addMessageInput(message) {
|
2256
|
-
const { recipient, sender, amount, predicate, nonce,
|
2273
|
+
const { recipient, sender, amount, predicate, nonce, predicateData } = message;
|
2257
2274
|
let witnessIndex;
|
2258
2275
|
if (message.predicate) {
|
2259
2276
|
witnessIndex = 0;
|
@@ -2268,13 +2285,16 @@ var BaseTransactionRequest = class {
|
|
2268
2285
|
type: InputType3.Message,
|
2269
2286
|
sender: sender.toB256(),
|
2270
2287
|
recipient: recipient.toB256(),
|
2288
|
+
data: isMessageCoin(message) ? "0x" : message.data,
|
2271
2289
|
amount,
|
2272
2290
|
witnessIndex,
|
2273
2291
|
predicate,
|
2274
2292
|
predicateData
|
2275
2293
|
};
|
2276
2294
|
this.pushInput(input);
|
2277
|
-
|
2295
|
+
if (isMessageCoin(message)) {
|
2296
|
+
this.addChangeOutput(recipient, message.assetId);
|
2297
|
+
}
|
2278
2298
|
}
|
2279
2299
|
/**
|
2280
2300
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -2406,6 +2426,8 @@ var BaseTransactionRequest = class {
|
|
2406
2426
|
*
|
2407
2427
|
* @param quantities - CoinQuantity Array.
|
2408
2428
|
* @param baseAssetId - The base asset to fund the transaction.
|
2429
|
+
* @deprecated - This method is deprecated and will be removed in future versions.
|
2430
|
+
* Please use `Account.generateFakeResources` along with `this.addResources` instead.
|
2409
2431
|
*/
|
2410
2432
|
fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
|
2411
2433
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
@@ -2474,7 +2496,7 @@ var BaseTransactionRequest = class {
|
|
2474
2496
|
});
|
2475
2497
|
}
|
2476
2498
|
updatePredicateGasUsed(inputs) {
|
2477
|
-
const inputsToExtractGasUsed = inputs.filter(
|
2499
|
+
const inputsToExtractGasUsed = inputs.filter(isRequestInputCoinOrMessage);
|
2478
2500
|
this.inputs.filter(isRequestInputResource).forEach((i) => {
|
2479
2501
|
const owner = getRequestInputResourceOwner(i);
|
2480
2502
|
const correspondingInput = inputsToExtractGasUsed.find(
|
@@ -2490,6 +2512,9 @@ var BaseTransactionRequest = class {
|
|
2490
2512
|
}
|
2491
2513
|
};
|
2492
2514
|
|
2515
|
+
// src/providers/transaction-request/blob-transaction-request.ts
|
2516
|
+
import { clone as clone3 } from "ramda";
|
2517
|
+
|
2493
2518
|
// src/providers/transaction-request/hash-transaction.ts
|
2494
2519
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2495
2520
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
@@ -2564,10 +2589,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2564
2589
|
// src/providers/transaction-request/blob-transaction-request.ts
|
2565
2590
|
var BlobTransactionRequest = class extends BaseTransactionRequest {
|
2566
2591
|
static from(obj) {
|
2567
|
-
|
2568
|
-
return obj;
|
2569
|
-
}
|
2570
|
-
return new this(obj);
|
2592
|
+
return new this(clone3(obj));
|
2571
2593
|
}
|
2572
2594
|
/** Type of the transaction */
|
2573
2595
|
type = TransactionType.Blob;
|
@@ -2630,6 +2652,7 @@ import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
|
2630
2652
|
import { bn as bn10 } from "@fuel-ts/math";
|
2631
2653
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2632
2654
|
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2655
|
+
import { clone as clone4 } from "ramda";
|
2633
2656
|
|
2634
2657
|
// src/providers/transaction-request/storage-slot.ts
|
2635
2658
|
import { arrayify as arrayify5, hexlify as hexlify8 } from "@fuel-ts/utils";
|
@@ -2657,10 +2680,7 @@ var storageSlotify = (storageSlot) => {
|
|
2657
2680
|
// src/providers/transaction-request/create-transaction-request.ts
|
2658
2681
|
var CreateTransactionRequest = class extends BaseTransactionRequest {
|
2659
2682
|
static from(obj) {
|
2660
|
-
|
2661
|
-
return obj;
|
2662
|
-
}
|
2663
|
-
return new this(obj);
|
2683
|
+
return new this(clone4(obj));
|
2664
2684
|
}
|
2665
2685
|
/** Type of the transaction */
|
2666
2686
|
type = TransactionType3.Create;
|
@@ -2749,6 +2769,7 @@ import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
|
2749
2769
|
import { bn as bn11 } from "@fuel-ts/math";
|
2750
2770
|
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2751
2771
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2772
|
+
import { clone as clone5 } from "ramda";
|
2752
2773
|
|
2753
2774
|
// src/providers/transaction-request/scripts.ts
|
2754
2775
|
import { arrayify as arrayify7 } from "@fuel-ts/utils";
|
@@ -2779,10 +2800,7 @@ var withdrawScript = {
|
|
2779
2800
|
// src/providers/transaction-request/script-transaction-request.ts
|
2780
2801
|
var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
2781
2802
|
static from(obj) {
|
2782
|
-
|
2783
|
-
return obj;
|
2784
|
-
}
|
2785
|
-
return new this(obj);
|
2803
|
+
return new this(clone5(obj));
|
2786
2804
|
}
|
2787
2805
|
/** Type of the transaction */
|
2788
2806
|
type = TransactionType4.Script;
|
@@ -4139,6 +4157,22 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4139
4157
|
};
|
4140
4158
|
}
|
4141
4159
|
|
4160
|
+
// src/providers/utils/handle-gql-error-message.ts
|
4161
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4162
|
+
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4163
|
+
switch (errorMessage) {
|
4164
|
+
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4165
|
+
throw new FuelError14(
|
4166
|
+
ErrorCode13.NOT_ENOUGH_FUNDS,
|
4167
|
+
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4168
|
+
{},
|
4169
|
+
rawError
|
4170
|
+
);
|
4171
|
+
default:
|
4172
|
+
throw new FuelError14(ErrorCode13.INVALID_REQUEST, errorMessage);
|
4173
|
+
}
|
4174
|
+
};
|
4175
|
+
|
4142
4176
|
// src/providers/provider.ts
|
4143
4177
|
var MAX_RETRIES = 10;
|
4144
4178
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
@@ -4265,6 +4299,17 @@ var _Provider = class {
|
|
4265
4299
|
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
4266
4300
|
}, retryOptions);
|
4267
4301
|
}
|
4302
|
+
static extractBasicAuth(url) {
|
4303
|
+
const parsedUrl = new URL(url);
|
4304
|
+
const username = parsedUrl.username;
|
4305
|
+
const password = parsedUrl.password;
|
4306
|
+
const urlNoBasicAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
|
4307
|
+
if (!(username && password)) {
|
4308
|
+
return { url, auth: void 0 };
|
4309
|
+
}
|
4310
|
+
const auth = `Basic ${btoa(`${username}:${password}`)}`;
|
4311
|
+
return { url: urlNoBasicAuth, auth };
|
4312
|
+
}
|
4268
4313
|
/**
|
4269
4314
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
4270
4315
|
*
|
@@ -4274,7 +4319,17 @@ var _Provider = class {
|
|
4274
4319
|
* @returns A promise that resolves to a Provider instance.
|
4275
4320
|
*/
|
4276
4321
|
static async create(url, options = {}) {
|
4277
|
-
const
|
4322
|
+
const { url: urlToUse, auth } = this.extractBasicAuth(url);
|
4323
|
+
const provider = new _Provider(urlToUse, {
|
4324
|
+
...options,
|
4325
|
+
requestMiddleware: async (request) => {
|
4326
|
+
if (auth) {
|
4327
|
+
request.headers ??= {};
|
4328
|
+
request.headers.Authorization = auth;
|
4329
|
+
}
|
4330
|
+
return options.requestMiddleware?.(request) ?? request;
|
4331
|
+
}
|
4332
|
+
});
|
4278
4333
|
await provider.fetchChainAndNodeInfo();
|
4279
4334
|
return provider;
|
4280
4335
|
}
|
@@ -4286,8 +4341,8 @@ var _Provider = class {
|
|
4286
4341
|
getChain() {
|
4287
4342
|
const chain = _Provider.chainInfoCache[this.url];
|
4288
4343
|
if (!chain) {
|
4289
|
-
throw new
|
4290
|
-
|
4344
|
+
throw new FuelError15(
|
4345
|
+
ErrorCode14.CHAIN_INFO_CACHE_EMPTY,
|
4291
4346
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4292
4347
|
);
|
4293
4348
|
}
|
@@ -4301,8 +4356,8 @@ var _Provider = class {
|
|
4301
4356
|
getNode() {
|
4302
4357
|
const node = _Provider.nodeInfoCache[this.url];
|
4303
4358
|
if (!node) {
|
4304
|
-
throw new
|
4305
|
-
|
4359
|
+
throw new FuelError15(
|
4360
|
+
ErrorCode14.NODE_INFO_CACHE_EMPTY,
|
4306
4361
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4307
4362
|
);
|
4308
4363
|
}
|
@@ -4380,10 +4435,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4380
4435
|
if ("response" in response) {
|
4381
4436
|
const graphQlResponse = response.response;
|
4382
4437
|
if (Array.isArray(graphQlResponse?.errors)) {
|
4383
|
-
|
4384
|
-
|
4385
|
-
|
4386
|
-
);
|
4438
|
+
for (const error of graphQlResponse.errors) {
|
4439
|
+
handleGqlErrorMessage(error.message, error);
|
4440
|
+
}
|
4387
4441
|
}
|
4388
4442
|
}
|
4389
4443
|
}
|
@@ -4401,7 +4455,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4401
4455
|
}
|
4402
4456
|
return gqlClient.request(query, vars);
|
4403
4457
|
};
|
4404
|
-
|
4458
|
+
const customOperations = (requester) => ({
|
4459
|
+
getBlobs(variables) {
|
4460
|
+
const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
|
4461
|
+
const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
|
4462
|
+
const updatedVariables = variables.blobIds.reduce(
|
4463
|
+
(acc, blobId, i) => {
|
4464
|
+
acc[`blobId${i}`] = blobId;
|
4465
|
+
return acc;
|
4466
|
+
},
|
4467
|
+
{}
|
4468
|
+
);
|
4469
|
+
const document2 = gql2`
|
4470
|
+
query getBlobs(${queryParams}) {
|
4471
|
+
${blobParams}
|
4472
|
+
}
|
4473
|
+
`;
|
4474
|
+
return requester(document2, updatedVariables);
|
4475
|
+
}
|
4476
|
+
});
|
4477
|
+
return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
|
4405
4478
|
}
|
4406
4479
|
/**
|
4407
4480
|
* Returns the version of the connected node.
|
@@ -4476,14 +4549,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4476
4549
|
validateTransaction(tx, consensusParameters) {
|
4477
4550
|
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4478
4551
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
4479
|
-
throw new
|
4480
|
-
|
4552
|
+
throw new FuelError15(
|
4553
|
+
ErrorCode14.MAX_INPUTS_EXCEEDED,
|
4481
4554
|
"The transaction exceeds the maximum allowed number of inputs."
|
4482
4555
|
);
|
4483
4556
|
}
|
4484
4557
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
4485
|
-
throw new
|
4486
|
-
|
4558
|
+
throw new FuelError15(
|
4559
|
+
ErrorCode14.MAX_OUTPUTS_EXCEEDED,
|
4487
4560
|
"The transaction exceeds the maximum allowed number of outputs."
|
4488
4561
|
);
|
4489
4562
|
}
|
@@ -4498,7 +4571,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4498
4571
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
4499
4572
|
* @returns A promise that resolves to the transaction response object.
|
4500
4573
|
*/
|
4501
|
-
// #region Provider-sendTransaction
|
4502
4574
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
4503
4575
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4504
4576
|
if (estimateTxDependencies) {
|
@@ -4645,7 +4717,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4645
4717
|
missingContractIds: [],
|
4646
4718
|
dryRunStatus: void 0
|
4647
4719
|
}));
|
4648
|
-
const allRequests =
|
4720
|
+
const allRequests = clone6(transactionRequests);
|
4649
4721
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4650
4722
|
allRequests.forEach((req, index) => {
|
4651
4723
|
if (isTransactionTypeScript(req)) {
|
@@ -4805,13 +4877,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4805
4877
|
* @returns A promise that resolves to the transaction cost object.
|
4806
4878
|
*/
|
4807
4879
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
4808
|
-
const txRequestClone =
|
4880
|
+
const txRequestClone = clone6(transactionRequestify(transactionRequestLike));
|
4809
4881
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4810
4882
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
4811
4883
|
if (isScriptTransaction) {
|
4812
4884
|
txRequestClone.gasLimit = bn17(0);
|
4813
4885
|
}
|
4814
|
-
const signedRequest =
|
4886
|
+
const signedRequest = clone6(txRequestClone);
|
4815
4887
|
let addedSignatures = 0;
|
4816
4888
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
4817
4889
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -4949,6 +5021,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4949
5021
|
}).filter((v) => !!v);
|
4950
5022
|
return coins;
|
4951
5023
|
}
|
5024
|
+
/**
|
5025
|
+
* Returns an array of blobIds that exist on chain, for a given array of blobIds.
|
5026
|
+
*
|
5027
|
+
* @param blobIds - blobIds to check.
|
5028
|
+
* @returns - A promise that resolves to an array of blobIds that exist on chain.
|
5029
|
+
*/
|
5030
|
+
async getBlobs(blobIds) {
|
5031
|
+
const res = await this.operations.getBlobs({ blobIds });
|
5032
|
+
const blobs = [];
|
5033
|
+
Object.keys(res).forEach((key) => {
|
5034
|
+
const val = res[key];
|
5035
|
+
blobs.push(val?.id ?? null);
|
5036
|
+
});
|
5037
|
+
return blobs.filter((v) => v);
|
5038
|
+
}
|
4952
5039
|
/**
|
4953
5040
|
* Returns block matching the given ID or height.
|
4954
5041
|
*
|
@@ -4970,11 +5057,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4970
5057
|
if (!block) {
|
4971
5058
|
return null;
|
4972
5059
|
}
|
5060
|
+
const { header, height, id, transactions } = block;
|
4973
5061
|
return {
|
4974
|
-
id
|
4975
|
-
height: bn17(
|
4976
|
-
time:
|
4977
|
-
|
5062
|
+
id,
|
5063
|
+
height: bn17(height),
|
5064
|
+
time: header.time,
|
5065
|
+
header: {
|
5066
|
+
applicationHash: header.applicationHash,
|
5067
|
+
daHeight: bn17(header.daHeight),
|
5068
|
+
eventInboxRoot: header.eventInboxRoot,
|
5069
|
+
messageOutboxRoot: header.messageOutboxRoot,
|
5070
|
+
prevRoot: header.prevRoot,
|
5071
|
+
stateTransitionBytecodeVersion: header.stateTransitionBytecodeVersion,
|
5072
|
+
transactionsCount: header.transactionsCount,
|
5073
|
+
transactionsRoot: header.transactionsRoot
|
5074
|
+
},
|
5075
|
+
transactionIds: transactions.map((tx) => tx.id)
|
4978
5076
|
};
|
4979
5077
|
}
|
4980
5078
|
/**
|
@@ -4996,6 +5094,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4996
5094
|
id: block.id,
|
4997
5095
|
height: bn17(block.height),
|
4998
5096
|
time: block.header.time,
|
5097
|
+
header: {
|
5098
|
+
applicationHash: block.header.applicationHash,
|
5099
|
+
daHeight: bn17(block.header.daHeight),
|
5100
|
+
eventInboxRoot: block.header.eventInboxRoot,
|
5101
|
+
messageOutboxRoot: block.header.messageOutboxRoot,
|
5102
|
+
prevRoot: block.header.prevRoot,
|
5103
|
+
stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
|
5104
|
+
transactionsCount: block.header.transactionsCount,
|
5105
|
+
transactionsRoot: block.header.transactionsRoot
|
5106
|
+
},
|
4999
5107
|
transactionIds: block.transactions.map((tx) => tx.id)
|
5000
5108
|
}));
|
5001
5109
|
return { blocks, pageInfo };
|
@@ -5023,6 +5131,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5023
5131
|
id: block.id,
|
5024
5132
|
height: bn17(block.height, 10),
|
5025
5133
|
time: block.header.time,
|
5134
|
+
header: {
|
5135
|
+
applicationHash: block.header.applicationHash,
|
5136
|
+
daHeight: bn17(block.header.daHeight),
|
5137
|
+
eventInboxRoot: block.header.eventInboxRoot,
|
5138
|
+
messageOutboxRoot: block.header.messageOutboxRoot,
|
5139
|
+
prevRoot: block.header.prevRoot,
|
5140
|
+
stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
|
5141
|
+
transactionsCount: block.header.transactionsCount,
|
5142
|
+
transactionsRoot: block.header.transactionsRoot
|
5143
|
+
},
|
5026
5144
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5027
5145
|
transactions: block.transactions.map(
|
5028
5146
|
(tx) => new TransactionCoder5().decode(arrayify11(tx.rawPayload), 0)?.[0]
|
@@ -5040,10 +5158,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5040
5158
|
if (!transaction) {
|
5041
5159
|
return null;
|
5042
5160
|
}
|
5043
|
-
|
5044
|
-
|
5045
|
-
|
5046
|
-
|
5161
|
+
try {
|
5162
|
+
return new TransactionCoder5().decode(
|
5163
|
+
arrayify11(transaction.rawPayload),
|
5164
|
+
0
|
5165
|
+
)?.[0];
|
5166
|
+
} catch (error) {
|
5167
|
+
if (error instanceof FuelError15 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5168
|
+
console.warn("Unsupported transaction type encountered");
|
5169
|
+
return null;
|
5170
|
+
}
|
5171
|
+
throw error;
|
5172
|
+
}
|
5047
5173
|
}
|
5048
5174
|
/**
|
5049
5175
|
* Retrieves transactions based on the provided pagination arguments.
|
@@ -5055,9 +5181,17 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5055
5181
|
transactions: { edges, pageInfo }
|
5056
5182
|
} = await this.operations.getTransactions(paginationArgs);
|
5057
5183
|
const coder = new TransactionCoder5();
|
5058
|
-
const transactions = edges.map(
|
5059
|
-
|
5060
|
-
|
5184
|
+
const transactions = edges.map(({ node: { rawPayload } }) => {
|
5185
|
+
try {
|
5186
|
+
return coder.decode(arrayify11(rawPayload), 0)[0];
|
5187
|
+
} catch (error) {
|
5188
|
+
if (error instanceof FuelError15 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5189
|
+
console.warn("Unsupported transaction type encountered");
|
5190
|
+
return null;
|
5191
|
+
}
|
5192
|
+
throw error;
|
5193
|
+
}
|
5194
|
+
}).filter((tx) => tx !== null);
|
5061
5195
|
return { transactions, pageInfo };
|
5062
5196
|
}
|
5063
5197
|
/**
|
@@ -5177,8 +5311,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5177
5311
|
nonce
|
5178
5312
|
};
|
5179
5313
|
if (commitBlockId && commitBlockHeight) {
|
5180
|
-
throw new
|
5181
|
-
|
5314
|
+
throw new FuelError15(
|
5315
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5182
5316
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5183
5317
|
);
|
5184
5318
|
}
|
@@ -5318,10 +5452,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5318
5452
|
* @returns A promise that resolves to the Message object or null.
|
5319
5453
|
*/
|
5320
5454
|
async getMessageByNonce(nonce) {
|
5321
|
-
const { message } = await this.operations.getMessageByNonce({ nonce });
|
5322
|
-
if (!
|
5455
|
+
const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
|
5456
|
+
if (!rawMessage) {
|
5323
5457
|
return null;
|
5324
5458
|
}
|
5459
|
+
const message = {
|
5460
|
+
messageId: InputMessageCoder.getMessageId({
|
5461
|
+
sender: rawMessage.sender,
|
5462
|
+
recipient: rawMessage.recipient,
|
5463
|
+
nonce: rawMessage.nonce,
|
5464
|
+
amount: bn17(rawMessage.amount),
|
5465
|
+
data: rawMessage.data
|
5466
|
+
}),
|
5467
|
+
sender: Address2.fromAddressOrString(rawMessage.sender),
|
5468
|
+
recipient: Address2.fromAddressOrString(rawMessage.recipient),
|
5469
|
+
nonce: rawMessage.nonce,
|
5470
|
+
amount: bn17(rawMessage.amount),
|
5471
|
+
data: InputMessageCoder.decodeData(rawMessage.data),
|
5472
|
+
daHeight: bn17(rawMessage.daHeight)
|
5473
|
+
};
|
5325
5474
|
return message;
|
5326
5475
|
}
|
5327
5476
|
/**
|
@@ -5346,26 +5495,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5346
5495
|
const { paginationLimit, inputArgs = {} } = params;
|
5347
5496
|
const { first, last, after, before } = inputArgs;
|
5348
5497
|
if (after && before) {
|
5349
|
-
throw new
|
5350
|
-
|
5498
|
+
throw new FuelError15(
|
5499
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5351
5500
|
'Pagination arguments "after" and "before" cannot be used together'
|
5352
5501
|
);
|
5353
5502
|
}
|
5354
5503
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5355
|
-
throw new
|
5356
|
-
|
5504
|
+
throw new FuelError15(
|
5505
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5357
5506
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5358
5507
|
);
|
5359
5508
|
}
|
5360
5509
|
if (first && before) {
|
5361
|
-
throw new
|
5362
|
-
|
5510
|
+
throw new FuelError15(
|
5511
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5363
5512
|
'The use of pagination argument "first" with "before" is not supported'
|
5364
5513
|
);
|
5365
5514
|
}
|
5366
5515
|
if (last && after) {
|
5367
|
-
throw new
|
5368
|
-
|
5516
|
+
throw new FuelError15(
|
5517
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5369
5518
|
'The use of pagination argument "last" with "after" is not supported'
|
5370
5519
|
);
|
5371
5520
|
}
|
@@ -5419,7 +5568,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5419
5568
|
__publicField(Provider, "nodeInfoCache", {});
|
5420
5569
|
|
5421
5570
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5422
|
-
import { ErrorCode as
|
5571
|
+
import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
|
5423
5572
|
import { bn as bn18 } from "@fuel-ts/math";
|
5424
5573
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
5425
5574
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
@@ -5429,8 +5578,8 @@ async function getTransactionSummary(params) {
|
|
5429
5578
|
transactionId: id
|
5430
5579
|
});
|
5431
5580
|
if (!gqlTransaction) {
|
5432
|
-
throw new
|
5433
|
-
|
5581
|
+
throw new FuelError16(
|
5582
|
+
ErrorCode15.TRANSACTION_NOT_FOUND,
|
5434
5583
|
`Transaction not found for given id: ${id}.`
|
5435
5584
|
);
|
5436
5585
|
}
|
@@ -5756,7 +5905,7 @@ var Account = class extends AbstractAccount {
|
|
5756
5905
|
*/
|
5757
5906
|
get provider() {
|
5758
5907
|
if (!this._provider) {
|
5759
|
-
throw new
|
5908
|
+
throw new FuelError17(ErrorCode16.MISSING_PROVIDER, "Provider not set");
|
5760
5909
|
}
|
5761
5910
|
return this._provider;
|
5762
5911
|
}
|
@@ -5874,7 +6023,7 @@ var Account = class extends AbstractAccount {
|
|
5874
6023
|
);
|
5875
6024
|
request.addResources(resources);
|
5876
6025
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5877
|
-
const requestToReestimate2 =
|
6026
|
+
const requestToReestimate2 = clone7(request);
|
5878
6027
|
if (addedSignatures) {
|
5879
6028
|
Array.from({ length: addedSignatures }).forEach(
|
5880
6029
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -5889,7 +6038,7 @@ var Account = class extends AbstractAccount {
|
|
5889
6038
|
gasPrice
|
5890
6039
|
});
|
5891
6040
|
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
5892
|
-
request.inputs,
|
6041
|
+
request.inputs.filter(isRequestInputResource),
|
5893
6042
|
baseAssetId,
|
5894
6043
|
baseAssetId
|
5895
6044
|
);
|
@@ -5907,13 +6056,13 @@ var Account = class extends AbstractAccount {
|
|
5907
6056
|
fundingAttempts += 1;
|
5908
6057
|
}
|
5909
6058
|
if (needsToBeFunded) {
|
5910
|
-
throw new
|
5911
|
-
|
6059
|
+
throw new FuelError17(
|
6060
|
+
ErrorCode16.NOT_ENOUGH_FUNDS,
|
5912
6061
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
5913
6062
|
);
|
5914
6063
|
}
|
5915
6064
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5916
|
-
const requestToReestimate =
|
6065
|
+
const requestToReestimate = clone7(request);
|
5917
6066
|
if (addedSignatures) {
|
5918
6067
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
5919
6068
|
}
|
@@ -6013,8 +6162,8 @@ var Account = class extends AbstractAccount {
|
|
6013
6162
|
*/
|
6014
6163
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6015
6164
|
if (bn19(amount).lte(0)) {
|
6016
|
-
throw new
|
6017
|
-
|
6165
|
+
throw new FuelError17(
|
6166
|
+
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6018
6167
|
"Transfer amount must be a positive number."
|
6019
6168
|
);
|
6020
6169
|
}
|
@@ -6089,16 +6238,16 @@ var Account = class extends AbstractAccount {
|
|
6089
6238
|
* @returns A promise that resolves to the transaction cost object.
|
6090
6239
|
*/
|
6091
6240
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6092
|
-
const txRequestClone =
|
6241
|
+
const txRequestClone = clone7(transactionRequestify(transactionRequestLike));
|
6093
6242
|
const baseAssetId = this.provider.getBaseAssetId();
|
6094
6243
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6095
6244
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
6096
6245
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn19("100000000000000000") }];
|
6097
6246
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6098
|
-
if (
|
6247
|
+
if (input.type === InputType8.Coin) {
|
6099
6248
|
return input.assetId === assetId;
|
6100
6249
|
}
|
6101
|
-
if (
|
6250
|
+
if (isRequestInputMessageWithoutData(input)) {
|
6102
6251
|
return baseAssetId === assetId;
|
6103
6252
|
}
|
6104
6253
|
return false;
|
@@ -6140,7 +6289,7 @@ var Account = class extends AbstractAccount {
|
|
6140
6289
|
*/
|
6141
6290
|
async signMessage(message) {
|
6142
6291
|
if (!this._connector) {
|
6143
|
-
throw new
|
6292
|
+
throw new FuelError17(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6144
6293
|
}
|
6145
6294
|
return this._connector.signMessage(this.address.toString(), message);
|
6146
6295
|
}
|
@@ -6152,8 +6301,8 @@ var Account = class extends AbstractAccount {
|
|
6152
6301
|
*/
|
6153
6302
|
async signTransaction(transactionRequestLike) {
|
6154
6303
|
if (!this._connector) {
|
6155
|
-
throw new
|
6156
|
-
|
6304
|
+
throw new FuelError17(
|
6305
|
+
ErrorCode16.MISSING_CONNECTOR,
|
6157
6306
|
"A connector is required to sign transactions."
|
6158
6307
|
);
|
6159
6308
|
}
|
@@ -6212,8 +6361,8 @@ var Account = class extends AbstractAccount {
|
|
6212
6361
|
/** @hidden * */
|
6213
6362
|
validateTransferAmount(amount) {
|
6214
6363
|
if (bn19(amount).lte(0)) {
|
6215
|
-
throw new
|
6216
|
-
|
6364
|
+
throw new FuelError17(
|
6365
|
+
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6217
6366
|
"Transfer amount must be a positive number."
|
6218
6367
|
);
|
6219
6368
|
}
|
@@ -6242,16 +6391,16 @@ var Account = class extends AbstractAccount {
|
|
6242
6391
|
if (!isDefined3(setGasLimit)) {
|
6243
6392
|
request.gasLimit = gasUsed;
|
6244
6393
|
} else if (gasUsed.gt(setGasLimit)) {
|
6245
|
-
throw new
|
6246
|
-
|
6394
|
+
throw new FuelError17(
|
6395
|
+
ErrorCode16.GAS_LIMIT_TOO_LOW,
|
6247
6396
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6248
6397
|
);
|
6249
6398
|
}
|
6250
6399
|
if (!isDefined3(setMaxFee)) {
|
6251
6400
|
request.maxFee = maxFee;
|
6252
6401
|
} else if (maxFee.gt(setMaxFee)) {
|
6253
|
-
throw new
|
6254
|
-
|
6402
|
+
throw new FuelError17(
|
6403
|
+
ErrorCode16.MAX_FEE_TOO_LOW,
|
6255
6404
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6256
6405
|
);
|
6257
6406
|
}
|
@@ -6384,7 +6533,7 @@ import {
|
|
6384
6533
|
encryptJsonWalletData,
|
6385
6534
|
randomUUID
|
6386
6535
|
} from "@fuel-ts/crypto";
|
6387
|
-
import { ErrorCode as
|
6536
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
|
6388
6537
|
import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
6389
6538
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6390
6539
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6461,8 +6610,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6461
6610
|
const macHashUint8Array = keccak256(data);
|
6462
6611
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
6463
6612
|
if (mac !== macHash) {
|
6464
|
-
throw new
|
6465
|
-
|
6613
|
+
throw new FuelError18(
|
6614
|
+
ErrorCode17.INVALID_PASSWORD,
|
6466
6615
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6467
6616
|
);
|
6468
6617
|
}
|
@@ -6592,14 +6741,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6592
6741
|
|
6593
6742
|
// src/hdwallet/hdwallet.ts
|
6594
6743
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
6595
|
-
import { ErrorCode as
|
6744
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError21 } from "@fuel-ts/errors";
|
6596
6745
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
6597
6746
|
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6598
6747
|
import { arrayify as arrayify18, hexlify as hexlify18, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
6599
6748
|
|
6600
6749
|
// src/mnemonic/mnemonic.ts
|
6601
6750
|
import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
6602
|
-
import { ErrorCode as
|
6751
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError20 } from "@fuel-ts/errors";
|
6603
6752
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
6604
6753
|
import { arrayify as arrayify17, hexlify as hexlify17, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
6605
6754
|
|
@@ -8662,7 +8811,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8662
8811
|
})(Language || {});
|
8663
8812
|
|
8664
8813
|
// src/mnemonic/utils.ts
|
8665
|
-
import { ErrorCode as
|
8814
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError19 } from "@fuel-ts/errors";
|
8666
8815
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
8667
8816
|
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
8668
8817
|
function getLowerMask(bits) {
|
@@ -8711,8 +8860,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8711
8860
|
for (let i = 0; i < words.length; i += 1) {
|
8712
8861
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8713
8862
|
if (index === -1) {
|
8714
|
-
throw new
|
8715
|
-
|
8863
|
+
throw new FuelError19(
|
8864
|
+
ErrorCode18.INVALID_MNEMONIC,
|
8716
8865
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8717
8866
|
);
|
8718
8867
|
}
|
@@ -8728,8 +8877,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8728
8877
|
const checksumMask = getUpperMask(checksumBits);
|
8729
8878
|
const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8730
8879
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8731
|
-
throw new
|
8732
|
-
|
8880
|
+
throw new FuelError19(
|
8881
|
+
ErrorCode18.INVALID_CHECKSUM,
|
8733
8882
|
"Checksum validation failed for the provided mnemonic."
|
8734
8883
|
);
|
8735
8884
|
}
|
@@ -8743,16 +8892,16 @@ var TestnetPRV = "0x04358394";
|
|
8743
8892
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8744
8893
|
function assertWordList(wordlist) {
|
8745
8894
|
if (wordlist.length !== 2048) {
|
8746
|
-
throw new
|
8747
|
-
|
8895
|
+
throw new FuelError20(
|
8896
|
+
ErrorCode19.INVALID_WORD_LIST,
|
8748
8897
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8749
8898
|
);
|
8750
8899
|
}
|
8751
8900
|
}
|
8752
8901
|
function assertEntropy(entropy) {
|
8753
8902
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8754
|
-
throw new
|
8755
|
-
|
8903
|
+
throw new FuelError20(
|
8904
|
+
ErrorCode19.INVALID_ENTROPY,
|
8756
8905
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8757
8906
|
);
|
8758
8907
|
}
|
@@ -8762,7 +8911,7 @@ function assertMnemonic(words) {
|
|
8762
8911
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8763
8912
|
", "
|
8764
8913
|
)}] words, but got ${words.length}.`;
|
8765
|
-
throw new
|
8914
|
+
throw new FuelError20(ErrorCode19.INVALID_MNEMONIC, errorMsg);
|
8766
8915
|
}
|
8767
8916
|
}
|
8768
8917
|
var Mnemonic = class {
|
@@ -8880,8 +9029,8 @@ var Mnemonic = class {
|
|
8880
9029
|
static masterKeysFromSeed(seed) {
|
8881
9030
|
const seedArray = arrayify17(seed);
|
8882
9031
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8883
|
-
throw new
|
8884
|
-
|
9032
|
+
throw new FuelError20(
|
9033
|
+
ErrorCode19.INVALID_SEED,
|
8885
9034
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8886
9035
|
);
|
8887
9036
|
}
|
@@ -8958,7 +9107,7 @@ function isValidExtendedKey(extendedKey) {
|
|
8958
9107
|
function parsePath(path, depth = 0) {
|
8959
9108
|
const components = path.split("/");
|
8960
9109
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
8961
|
-
throw new
|
9110
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path}`);
|
8962
9111
|
}
|
8963
9112
|
if (components[0] === "m") {
|
8964
9113
|
components.shift();
|
@@ -8987,8 +9136,8 @@ var HDWallet = class {
|
|
8987
9136
|
this.privateKey = hexlify18(config.privateKey);
|
8988
9137
|
} else {
|
8989
9138
|
if (!config.publicKey) {
|
8990
|
-
throw new
|
8991
|
-
|
9139
|
+
throw new FuelError21(
|
9140
|
+
ErrorCode20.HD_WALLET_ERROR,
|
8992
9141
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8993
9142
|
);
|
8994
9143
|
}
|
@@ -9017,8 +9166,8 @@ var HDWallet = class {
|
|
9017
9166
|
const data = new Uint8Array(37);
|
9018
9167
|
if (index & HARDENED_INDEX) {
|
9019
9168
|
if (!privateKey) {
|
9020
|
-
throw new
|
9021
|
-
|
9169
|
+
throw new FuelError21(
|
9170
|
+
ErrorCode20.HD_WALLET_ERROR,
|
9022
9171
|
"Cannot derive a hardened index without a private Key."
|
9023
9172
|
);
|
9024
9173
|
}
|
@@ -9070,8 +9219,8 @@ var HDWallet = class {
|
|
9070
9219
|
*/
|
9071
9220
|
toExtendedKey(isPublic = false, testnet = false) {
|
9072
9221
|
if (this.depth >= 256) {
|
9073
|
-
throw new
|
9074
|
-
|
9222
|
+
throw new FuelError21(
|
9223
|
+
ErrorCode20.HD_WALLET_ERROR,
|
9075
9224
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9076
9225
|
);
|
9077
9226
|
}
|
@@ -9102,10 +9251,10 @@ var HDWallet = class {
|
|
9102
9251
|
const bytes = arrayify18(decoded);
|
9103
9252
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9104
9253
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9105
|
-
throw new
|
9254
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9106
9255
|
}
|
9107
9256
|
if (!validChecksum) {
|
9108
|
-
throw new
|
9257
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9109
9258
|
}
|
9110
9259
|
const depth = bytes[4];
|
9111
9260
|
const parentFingerprint = hexlify18(bytes.slice(5, 9));
|
@@ -9113,14 +9262,14 @@ var HDWallet = class {
|
|
9113
9262
|
const chainCode = hexlify18(bytes.slice(13, 45));
|
9114
9263
|
const key = bytes.slice(45, 78);
|
9115
9264
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9116
|
-
throw new
|
9117
|
-
|
9265
|
+
throw new FuelError21(
|
9266
|
+
ErrorCode20.HD_WALLET_ERROR,
|
9118
9267
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9119
9268
|
);
|
9120
9269
|
}
|
9121
9270
|
if (isPublicExtendedKey(bytes)) {
|
9122
9271
|
if (key[0] !== 3) {
|
9123
|
-
throw new
|
9272
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
|
9124
9273
|
}
|
9125
9274
|
return new HDWallet({
|
9126
9275
|
publicKey: key,
|
@@ -9131,7 +9280,7 @@ var HDWallet = class {
|
|
9131
9280
|
});
|
9132
9281
|
}
|
9133
9282
|
if (key[0] !== 0) {
|
9134
|
-
throw new
|
9283
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
|
9135
9284
|
}
|
9136
9285
|
return new HDWallet({
|
9137
9286
|
privateKey: key.slice(1),
|
@@ -9299,7 +9448,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
9299
9448
|
// src/wallet-manager/wallet-manager.ts
|
9300
9449
|
import { Address as Address8 } from "@fuel-ts/address";
|
9301
9450
|
import { encrypt, decrypt } from "@fuel-ts/crypto";
|
9302
|
-
import { ErrorCode as
|
9451
|
+
import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9303
9452
|
import { EventEmitter } from "events";
|
9304
9453
|
|
9305
9454
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -9322,7 +9471,7 @@ var MemoryStorage = class {
|
|
9322
9471
|
|
9323
9472
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
9324
9473
|
import { Address as Address6 } from "@fuel-ts/address";
|
9325
|
-
import { ErrorCode as
|
9474
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError22 } from "@fuel-ts/errors";
|
9326
9475
|
var _secret;
|
9327
9476
|
var MnemonicVault = class {
|
9328
9477
|
constructor(options) {
|
@@ -9378,8 +9527,8 @@ var MnemonicVault = class {
|
|
9378
9527
|
}
|
9379
9528
|
numberOfAccounts += 1;
|
9380
9529
|
} while (numberOfAccounts < this.numberOfAccounts);
|
9381
|
-
throw new
|
9382
|
-
|
9530
|
+
throw new FuelError22(
|
9531
|
+
ErrorCode21.WALLET_MANAGER_ERROR,
|
9383
9532
|
`Account with address '${address}' not found in derived wallets.`
|
9384
9533
|
);
|
9385
9534
|
}
|
@@ -9393,7 +9542,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
9393
9542
|
|
9394
9543
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
9395
9544
|
import { Address as Address7 } from "@fuel-ts/address";
|
9396
|
-
import { ErrorCode as
|
9545
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
|
9397
9546
|
var _privateKeys;
|
9398
9547
|
var PrivateKeyVault = class {
|
9399
9548
|
/**
|
@@ -9434,8 +9583,8 @@ var PrivateKeyVault = class {
|
|
9434
9583
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
9435
9584
|
);
|
9436
9585
|
if (!privateKey) {
|
9437
|
-
throw new
|
9438
|
-
|
9586
|
+
throw new FuelError23(
|
9587
|
+
ErrorCode22.WALLET_MANAGER_ERROR,
|
9439
9588
|
`No private key found for address '${address}'.`
|
9440
9589
|
);
|
9441
9590
|
}
|
@@ -9459,7 +9608,7 @@ var ERROR_MESSAGES = {
|
|
9459
9608
|
};
|
9460
9609
|
function assert(condition, message) {
|
9461
9610
|
if (!condition) {
|
9462
|
-
throw new
|
9611
|
+
throw new FuelError24(ErrorCode23.WALLET_MANAGER_ERROR, message);
|
9463
9612
|
}
|
9464
9613
|
}
|
9465
9614
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -9685,25 +9834,25 @@ deserializeVaults_fn = function(vaults) {
|
|
9685
9834
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
9686
9835
|
|
9687
9836
|
// src/wallet-manager/types.ts
|
9688
|
-
import { ErrorCode as
|
9837
|
+
import { ErrorCode as ErrorCode24, FuelError as FuelError25 } from "@fuel-ts/errors";
|
9689
9838
|
var Vault = class {
|
9690
9839
|
constructor(_options) {
|
9691
|
-
throw new
|
9840
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9692
9841
|
}
|
9693
9842
|
serialize() {
|
9694
|
-
throw new
|
9843
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9695
9844
|
}
|
9696
9845
|
getAccounts() {
|
9697
|
-
throw new
|
9846
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9698
9847
|
}
|
9699
9848
|
addAccount() {
|
9700
|
-
throw new
|
9849
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9701
9850
|
}
|
9702
9851
|
exportAccount(_address) {
|
9703
|
-
throw new
|
9852
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9704
9853
|
}
|
9705
9854
|
getWallet(_address) {
|
9706
|
-
throw new
|
9855
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9707
9856
|
}
|
9708
9857
|
};
|
9709
9858
|
__publicField(Vault, "type");
|
@@ -9713,7 +9862,7 @@ var StorageAbstract = class {
|
|
9713
9862
|
// src/predicate/predicate.ts
|
9714
9863
|
import { Interface as Interface4 } from "@fuel-ts/abi-coder";
|
9715
9864
|
import { Address as Address9 } from "@fuel-ts/address";
|
9716
|
-
import { ErrorCode as
|
9865
|
+
import { ErrorCode as ErrorCode25, FuelError as FuelError26 } from "@fuel-ts/errors";
|
9717
9866
|
import { arrayify as arrayify20, hexlify as hexlify20 } from "@fuel-ts/utils";
|
9718
9867
|
|
9719
9868
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9775,7 +9924,7 @@ var Predicate = class extends Account {
|
|
9775
9924
|
if (placeholderIndex !== -1) {
|
9776
9925
|
request.removeWitness(placeholderIndex);
|
9777
9926
|
}
|
9778
|
-
request.inputs.filter(
|
9927
|
+
request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
9779
9928
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9780
9929
|
input.predicate = hexlify20(this.bytes);
|
9781
9930
|
input.predicateData = hexlify20(this.getPredicateData());
|
@@ -9825,8 +9974,8 @@ var Predicate = class extends Account {
|
|
9825
9974
|
if (jsonAbi) {
|
9826
9975
|
abiInterface = new Interface4(jsonAbi);
|
9827
9976
|
if (abiInterface.functions.main === void 0) {
|
9828
|
-
throw new
|
9829
|
-
|
9977
|
+
throw new FuelError26(
|
9978
|
+
ErrorCode25.ABI_MAIN_METHOD_MISSING,
|
9830
9979
|
'Cannot use ABI without "main" function.'
|
9831
9980
|
);
|
9832
9981
|
}
|
@@ -9887,21 +10036,21 @@ var Predicate = class extends Account {
|
|
9887
10036
|
const mutatedBytes = bytes;
|
9888
10037
|
try {
|
9889
10038
|
if (!abiInterface) {
|
9890
|
-
throw new
|
9891
|
-
|
10039
|
+
throw new FuelError26(
|
10040
|
+
ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
|
9892
10041
|
"Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
|
9893
10042
|
);
|
9894
10043
|
}
|
9895
10044
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
9896
|
-
throw new
|
9897
|
-
|
10045
|
+
throw new FuelError26(
|
10046
|
+
ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
|
9898
10047
|
"Predicate has no configurable constants to be set"
|
9899
10048
|
);
|
9900
10049
|
}
|
9901
10050
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
9902
10051
|
if (!abiInterface?.configurables[key]) {
|
9903
|
-
throw new
|
9904
|
-
|
10052
|
+
throw new FuelError26(
|
10053
|
+
ErrorCode25.CONFIGURABLE_NOT_FOUND,
|
9905
10054
|
`No configurable constant named '${key}' found in the Predicate`
|
9906
10055
|
);
|
9907
10056
|
}
|
@@ -9910,8 +10059,8 @@ var Predicate = class extends Account {
|
|
9910
10059
|
mutatedBytes.set(encoded, offset);
|
9911
10060
|
});
|
9912
10061
|
} catch (err) {
|
9913
|
-
throw new
|
9914
|
-
|
10062
|
+
throw new FuelError26(
|
10063
|
+
ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
|
9915
10064
|
`Error setting configurable constants: ${err.message}.`
|
9916
10065
|
);
|
9917
10066
|
}
|
@@ -9942,10 +10091,10 @@ var Predicate = class extends Account {
|
|
9942
10091
|
};
|
9943
10092
|
|
9944
10093
|
// src/connectors/fuel.ts
|
9945
|
-
import { ErrorCode as
|
10094
|
+
import { ErrorCode as ErrorCode26, FuelError as FuelError29 } from "@fuel-ts/errors";
|
9946
10095
|
|
9947
10096
|
// src/connectors/fuel-connector.ts
|
9948
|
-
import { FuelError as
|
10097
|
+
import { FuelError as FuelError27 } from "@fuel-ts/errors";
|
9949
10098
|
import { EventEmitter as EventEmitter2 } from "events";
|
9950
10099
|
|
9951
10100
|
// src/connectors/types/connector-types.ts
|
@@ -10019,7 +10168,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10019
10168
|
* @returns Always true.
|
10020
10169
|
*/
|
10021
10170
|
async ping() {
|
10022
|
-
throw new
|
10171
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10023
10172
|
}
|
10024
10173
|
/**
|
10025
10174
|
* Should return the current version of the connector
|
@@ -10028,7 +10177,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10028
10177
|
* @returns boolean - connection status.
|
10029
10178
|
*/
|
10030
10179
|
async version() {
|
10031
|
-
throw new
|
10180
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10032
10181
|
}
|
10033
10182
|
/**
|
10034
10183
|
* Should return true if the connector is connected
|
@@ -10037,7 +10186,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10037
10186
|
* @returns The connection status.
|
10038
10187
|
*/
|
10039
10188
|
async isConnected() {
|
10040
|
-
throw new
|
10189
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10041
10190
|
}
|
10042
10191
|
/**
|
10043
10192
|
* Should return all the accounts authorized for the
|
@@ -10046,7 +10195,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10046
10195
|
* @returns The accounts addresses strings
|
10047
10196
|
*/
|
10048
10197
|
async accounts() {
|
10049
|
-
throw new
|
10198
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10050
10199
|
}
|
10051
10200
|
/**
|
10052
10201
|
* Should start the connection process and return
|
@@ -10058,7 +10207,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10058
10207
|
* @returns boolean - connection status.
|
10059
10208
|
*/
|
10060
10209
|
async connect() {
|
10061
|
-
throw new
|
10210
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10062
10211
|
}
|
10063
10212
|
/**
|
10064
10213
|
* Should disconnect the current connection and
|
@@ -10068,7 +10217,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10068
10217
|
* @returns The connection status.
|
10069
10218
|
*/
|
10070
10219
|
async disconnect() {
|
10071
|
-
throw new
|
10220
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10072
10221
|
}
|
10073
10222
|
/**
|
10074
10223
|
* Should start the sign message process and return
|
@@ -10080,7 +10229,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10080
10229
|
* @returns Message signature
|
10081
10230
|
*/
|
10082
10231
|
async signMessage(_address, _message) {
|
10083
|
-
throw new
|
10232
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10084
10233
|
}
|
10085
10234
|
/**
|
10086
10235
|
* Should start the sign transaction process and return
|
@@ -10092,7 +10241,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10092
10241
|
* @returns Transaction signature
|
10093
10242
|
*/
|
10094
10243
|
async signTransaction(_address, _transaction) {
|
10095
|
-
throw new
|
10244
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10096
10245
|
}
|
10097
10246
|
/**
|
10098
10247
|
* Should start the send transaction process and return
|
@@ -10108,7 +10257,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10108
10257
|
* @returns The transaction id
|
10109
10258
|
*/
|
10110
10259
|
async sendTransaction(_address, _transaction) {
|
10111
|
-
throw new
|
10260
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10112
10261
|
}
|
10113
10262
|
/**
|
10114
10263
|
* Should return the current account selected inside the connector, if the account
|
@@ -10119,7 +10268,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10119
10268
|
* @returns The current account selected otherwise null.
|
10120
10269
|
*/
|
10121
10270
|
async currentAccount() {
|
10122
|
-
throw new
|
10271
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10123
10272
|
}
|
10124
10273
|
/**
|
10125
10274
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -10133,7 +10282,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10133
10282
|
* @returns True if the asset was added successfully
|
10134
10283
|
*/
|
10135
10284
|
async addAssets(_assets) {
|
10136
|
-
throw new
|
10285
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10137
10286
|
}
|
10138
10287
|
/**
|
10139
10288
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -10147,7 +10296,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10147
10296
|
* @returns True if the asset was added successfully
|
10148
10297
|
*/
|
10149
10298
|
async addAsset(_asset) {
|
10150
|
-
throw new
|
10299
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10151
10300
|
}
|
10152
10301
|
/**
|
10153
10302
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -10155,7 +10304,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10155
10304
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
10156
10305
|
*/
|
10157
10306
|
async assets() {
|
10158
|
-
throw new
|
10307
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10159
10308
|
}
|
10160
10309
|
/**
|
10161
10310
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -10166,7 +10315,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10166
10315
|
* @returns Return true if the network was added successfully
|
10167
10316
|
*/
|
10168
10317
|
async addNetwork(_networkUrl) {
|
10169
|
-
throw new
|
10318
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10170
10319
|
}
|
10171
10320
|
/**
|
10172
10321
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -10177,7 +10326,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10177
10326
|
* @returns Return true if the network was added successfully
|
10178
10327
|
*/
|
10179
10328
|
async selectNetwork(_network) {
|
10180
|
-
throw new
|
10329
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10181
10330
|
}
|
10182
10331
|
/**
|
10183
10332
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -10185,7 +10334,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10185
10334
|
* @returns Return all the networks added to the connector.
|
10186
10335
|
*/
|
10187
10336
|
async networks() {
|
10188
|
-
throw new
|
10337
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10189
10338
|
}
|
10190
10339
|
/**
|
10191
10340
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -10193,7 +10342,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10193
10342
|
* @returns Return the current network selected inside the connector.
|
10194
10343
|
*/
|
10195
10344
|
async currentNetwork() {
|
10196
|
-
throw new
|
10345
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10197
10346
|
}
|
10198
10347
|
/**
|
10199
10348
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -10203,7 +10352,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10203
10352
|
* @returns Return true if the ABI was added successfully.
|
10204
10353
|
*/
|
10205
10354
|
async addABI(_contractId, _abi) {
|
10206
|
-
throw new
|
10355
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10207
10356
|
}
|
10208
10357
|
/**
|
10209
10358
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10212,7 +10361,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10212
10361
|
* @returns The ABI if it exists, otherwise return null.
|
10213
10362
|
*/
|
10214
10363
|
async getABI(_id) {
|
10215
|
-
throw new
|
10364
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10216
10365
|
}
|
10217
10366
|
/**
|
10218
10367
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10221,7 +10370,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10221
10370
|
* @returns Returns true if the abi exists or false if not.
|
10222
10371
|
*/
|
10223
10372
|
async hasABI(_id) {
|
10224
|
-
throw new
|
10373
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10225
10374
|
}
|
10226
10375
|
/**
|
10227
10376
|
* Event listener for the connector.
|
@@ -10265,7 +10414,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
10265
10414
|
}
|
10266
10415
|
|
10267
10416
|
// src/connectors/utils/promises.ts
|
10268
|
-
import { FuelError as
|
10417
|
+
import { FuelError as FuelError28 } from "@fuel-ts/errors";
|
10269
10418
|
function deferPromise() {
|
10270
10419
|
const defer = {};
|
10271
10420
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -10277,7 +10426,7 @@ function deferPromise() {
|
|
10277
10426
|
async function withTimeout(promise, timeout = 1050) {
|
10278
10427
|
const timeoutPromise = new Promise((resolve, reject) => {
|
10279
10428
|
setTimeout(() => {
|
10280
|
-
reject(new
|
10429
|
+
reject(new FuelError28(FuelError28.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
10281
10430
|
}, timeout);
|
10282
10431
|
});
|
10283
10432
|
return Promise.race([timeoutPromise, promise]);
|
@@ -10311,7 +10460,7 @@ var _Fuel = class extends FuelConnector {
|
|
10311
10460
|
await this.setDefaultConnector();
|
10312
10461
|
this._targetUnsubscribe = this.setupConnectorListener();
|
10313
10462
|
} catch (error) {
|
10314
|
-
throw new
|
10463
|
+
throw new FuelError29(ErrorCode26.INVALID_PROVIDER, "Error initializing Fuel Connector");
|
10315
10464
|
}
|
10316
10465
|
}
|
10317
10466
|
async init() {
|
@@ -10377,8 +10526,8 @@ var _Fuel = class extends FuelConnector {
|
|
10377
10526
|
const hasConnector = await this.hasConnector();
|
10378
10527
|
await this.pingConnector();
|
10379
10528
|
if (!this._currentConnector || !hasConnector) {
|
10380
|
-
throw new
|
10381
|
-
|
10529
|
+
throw new FuelError29(
|
10530
|
+
ErrorCode26.MISSING_CONNECTOR,
|
10382
10531
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
10383
10532
|
);
|
10384
10533
|
}
|
@@ -10442,7 +10591,7 @@ var _Fuel = class extends FuelConnector {
|
|
10442
10591
|
cacheTime: PING_CACHE_TIME
|
10443
10592
|
})();
|
10444
10593
|
} catch {
|
10445
|
-
throw new
|
10594
|
+
throw new FuelError29(ErrorCode26.INVALID_PROVIDER, "Current connector is not available.");
|
10446
10595
|
}
|
10447
10596
|
}
|
10448
10597
|
/**
|
@@ -10591,7 +10740,7 @@ var _Fuel = class extends FuelConnector {
|
|
10591
10740
|
const currentNetwork = await this.currentNetwork();
|
10592
10741
|
provider = await Provider.create(currentNetwork.url);
|
10593
10742
|
} else {
|
10594
|
-
throw new
|
10743
|
+
throw new FuelError29(ErrorCode26.INVALID_PROVIDER, "Provider is not valid.");
|
10595
10744
|
}
|
10596
10745
|
return provider;
|
10597
10746
|
}
|
@@ -10746,10 +10895,13 @@ export {
|
|
10746
10895
|
isCoin,
|
10747
10896
|
isInputCoin,
|
10748
10897
|
isMessage,
|
10898
|
+
isMessageCoin,
|
10749
10899
|
isRawCoin,
|
10750
10900
|
isRawMessage,
|
10751
10901
|
isRequestInputCoin,
|
10902
|
+
isRequestInputCoinOrMessage,
|
10752
10903
|
isRequestInputMessage,
|
10904
|
+
isRequestInputMessageWithoutData,
|
10753
10905
|
isRequestInputResource,
|
10754
10906
|
isRequestInputResourceFromOwner,
|
10755
10907
|
isTransactionTypeBlob,
|