@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.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
|
}
|
@@ -4644,7 +4717,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4644
4717
|
missingContractIds: [],
|
4645
4718
|
dryRunStatus: void 0
|
4646
4719
|
}));
|
4647
|
-
const allRequests =
|
4720
|
+
const allRequests = clone6(transactionRequests);
|
4648
4721
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4649
4722
|
allRequests.forEach((req, index) => {
|
4650
4723
|
if (isTransactionTypeScript(req)) {
|
@@ -4804,13 +4877,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4804
4877
|
* @returns A promise that resolves to the transaction cost object.
|
4805
4878
|
*/
|
4806
4879
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
4807
|
-
const txRequestClone =
|
4880
|
+
const txRequestClone = clone6(transactionRequestify(transactionRequestLike));
|
4808
4881
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4809
4882
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
4810
4883
|
if (isScriptTransaction) {
|
4811
4884
|
txRequestClone.gasLimit = bn17(0);
|
4812
4885
|
}
|
4813
|
-
const signedRequest =
|
4886
|
+
const signedRequest = clone6(txRequestClone);
|
4814
4887
|
let addedSignatures = 0;
|
4815
4888
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
4816
4889
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -4948,6 +5021,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4948
5021
|
}).filter((v) => !!v);
|
4949
5022
|
return coins;
|
4950
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
|
+
}
|
4951
5039
|
/**
|
4952
5040
|
* Returns block matching the given ID or height.
|
4953
5041
|
*
|
@@ -4969,11 +5057,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4969
5057
|
if (!block) {
|
4970
5058
|
return null;
|
4971
5059
|
}
|
5060
|
+
const { header, height, id, transactions } = block;
|
4972
5061
|
return {
|
4973
|
-
id
|
4974
|
-
height: bn17(
|
4975
|
-
time:
|
4976
|
-
|
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)
|
4977
5076
|
};
|
4978
5077
|
}
|
4979
5078
|
/**
|
@@ -4995,6 +5094,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4995
5094
|
id: block.id,
|
4996
5095
|
height: bn17(block.height),
|
4997
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
|
+
},
|
4998
5107
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4999
5108
|
}));
|
5000
5109
|
return { blocks, pageInfo };
|
@@ -5022,6 +5131,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5022
5131
|
id: block.id,
|
5023
5132
|
height: bn17(block.height, 10),
|
5024
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
|
+
},
|
5025
5144
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5026
5145
|
transactions: block.transactions.map(
|
5027
5146
|
(tx) => new TransactionCoder5().decode(arrayify11(tx.rawPayload), 0)?.[0]
|
@@ -5045,7 +5164,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5045
5164
|
0
|
5046
5165
|
)?.[0];
|
5047
5166
|
} catch (error) {
|
5048
|
-
if (error instanceof
|
5167
|
+
if (error instanceof FuelError15 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5049
5168
|
console.warn("Unsupported transaction type encountered");
|
5050
5169
|
return null;
|
5051
5170
|
}
|
@@ -5066,7 +5185,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5066
5185
|
try {
|
5067
5186
|
return coder.decode(arrayify11(rawPayload), 0)[0];
|
5068
5187
|
} catch (error) {
|
5069
|
-
if (error instanceof
|
5188
|
+
if (error instanceof FuelError15 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5070
5189
|
console.warn("Unsupported transaction type encountered");
|
5071
5190
|
return null;
|
5072
5191
|
}
|
@@ -5192,8 +5311,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5192
5311
|
nonce
|
5193
5312
|
};
|
5194
5313
|
if (commitBlockId && commitBlockHeight) {
|
5195
|
-
throw new
|
5196
|
-
|
5314
|
+
throw new FuelError15(
|
5315
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5197
5316
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5198
5317
|
);
|
5199
5318
|
}
|
@@ -5333,10 +5452,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5333
5452
|
* @returns A promise that resolves to the Message object or null.
|
5334
5453
|
*/
|
5335
5454
|
async getMessageByNonce(nonce) {
|
5336
|
-
const { message } = await this.operations.getMessageByNonce({ nonce });
|
5337
|
-
if (!
|
5455
|
+
const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
|
5456
|
+
if (!rawMessage) {
|
5338
5457
|
return null;
|
5339
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
|
+
};
|
5340
5474
|
return message;
|
5341
5475
|
}
|
5342
5476
|
/**
|
@@ -5361,26 +5495,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5361
5495
|
const { paginationLimit, inputArgs = {} } = params;
|
5362
5496
|
const { first, last, after, before } = inputArgs;
|
5363
5497
|
if (after && before) {
|
5364
|
-
throw new
|
5365
|
-
|
5498
|
+
throw new FuelError15(
|
5499
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5366
5500
|
'Pagination arguments "after" and "before" cannot be used together'
|
5367
5501
|
);
|
5368
5502
|
}
|
5369
5503
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5370
|
-
throw new
|
5371
|
-
|
5504
|
+
throw new FuelError15(
|
5505
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5372
5506
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5373
5507
|
);
|
5374
5508
|
}
|
5375
5509
|
if (first && before) {
|
5376
|
-
throw new
|
5377
|
-
|
5510
|
+
throw new FuelError15(
|
5511
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5378
5512
|
'The use of pagination argument "first" with "before" is not supported'
|
5379
5513
|
);
|
5380
5514
|
}
|
5381
5515
|
if (last && after) {
|
5382
|
-
throw new
|
5383
|
-
|
5516
|
+
throw new FuelError15(
|
5517
|
+
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5384
5518
|
'The use of pagination argument "last" with "after" is not supported'
|
5385
5519
|
);
|
5386
5520
|
}
|
@@ -5434,7 +5568,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5434
5568
|
__publicField(Provider, "nodeInfoCache", {});
|
5435
5569
|
|
5436
5570
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5437
|
-
import { ErrorCode as
|
5571
|
+
import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
|
5438
5572
|
import { bn as bn18 } from "@fuel-ts/math";
|
5439
5573
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
5440
5574
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
@@ -5444,8 +5578,8 @@ async function getTransactionSummary(params) {
|
|
5444
5578
|
transactionId: id
|
5445
5579
|
});
|
5446
5580
|
if (!gqlTransaction) {
|
5447
|
-
throw new
|
5448
|
-
|
5581
|
+
throw new FuelError16(
|
5582
|
+
ErrorCode15.TRANSACTION_NOT_FOUND,
|
5449
5583
|
`Transaction not found for given id: ${id}.`
|
5450
5584
|
);
|
5451
5585
|
}
|
@@ -5771,7 +5905,7 @@ var Account = class extends AbstractAccount {
|
|
5771
5905
|
*/
|
5772
5906
|
get provider() {
|
5773
5907
|
if (!this._provider) {
|
5774
|
-
throw new
|
5908
|
+
throw new FuelError17(ErrorCode16.MISSING_PROVIDER, "Provider not set");
|
5775
5909
|
}
|
5776
5910
|
return this._provider;
|
5777
5911
|
}
|
@@ -5889,7 +6023,7 @@ var Account = class extends AbstractAccount {
|
|
5889
6023
|
);
|
5890
6024
|
request.addResources(resources);
|
5891
6025
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5892
|
-
const requestToReestimate2 =
|
6026
|
+
const requestToReestimate2 = clone7(request);
|
5893
6027
|
if (addedSignatures) {
|
5894
6028
|
Array.from({ length: addedSignatures }).forEach(
|
5895
6029
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -5904,7 +6038,7 @@ var Account = class extends AbstractAccount {
|
|
5904
6038
|
gasPrice
|
5905
6039
|
});
|
5906
6040
|
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
5907
|
-
request.inputs,
|
6041
|
+
request.inputs.filter(isRequestInputResource),
|
5908
6042
|
baseAssetId,
|
5909
6043
|
baseAssetId
|
5910
6044
|
);
|
@@ -5922,13 +6056,13 @@ var Account = class extends AbstractAccount {
|
|
5922
6056
|
fundingAttempts += 1;
|
5923
6057
|
}
|
5924
6058
|
if (needsToBeFunded) {
|
5925
|
-
throw new
|
5926
|
-
|
6059
|
+
throw new FuelError17(
|
6060
|
+
ErrorCode16.NOT_ENOUGH_FUNDS,
|
5927
6061
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
5928
6062
|
);
|
5929
6063
|
}
|
5930
6064
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5931
|
-
const requestToReestimate =
|
6065
|
+
const requestToReestimate = clone7(request);
|
5932
6066
|
if (addedSignatures) {
|
5933
6067
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
5934
6068
|
}
|
@@ -6028,8 +6162,8 @@ var Account = class extends AbstractAccount {
|
|
6028
6162
|
*/
|
6029
6163
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6030
6164
|
if (bn19(amount).lte(0)) {
|
6031
|
-
throw new
|
6032
|
-
|
6165
|
+
throw new FuelError17(
|
6166
|
+
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6033
6167
|
"Transfer amount must be a positive number."
|
6034
6168
|
);
|
6035
6169
|
}
|
@@ -6104,16 +6238,16 @@ var Account = class extends AbstractAccount {
|
|
6104
6238
|
* @returns A promise that resolves to the transaction cost object.
|
6105
6239
|
*/
|
6106
6240
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6107
|
-
const txRequestClone =
|
6241
|
+
const txRequestClone = clone7(transactionRequestify(transactionRequestLike));
|
6108
6242
|
const baseAssetId = this.provider.getBaseAssetId();
|
6109
6243
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6110
6244
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
6111
6245
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn19("100000000000000000") }];
|
6112
6246
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6113
|
-
if (
|
6247
|
+
if (input.type === InputType8.Coin) {
|
6114
6248
|
return input.assetId === assetId;
|
6115
6249
|
}
|
6116
|
-
if (
|
6250
|
+
if (isRequestInputMessageWithoutData(input)) {
|
6117
6251
|
return baseAssetId === assetId;
|
6118
6252
|
}
|
6119
6253
|
return false;
|
@@ -6155,7 +6289,7 @@ var Account = class extends AbstractAccount {
|
|
6155
6289
|
*/
|
6156
6290
|
async signMessage(message) {
|
6157
6291
|
if (!this._connector) {
|
6158
|
-
throw new
|
6292
|
+
throw new FuelError17(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6159
6293
|
}
|
6160
6294
|
return this._connector.signMessage(this.address.toString(), message);
|
6161
6295
|
}
|
@@ -6167,8 +6301,8 @@ var Account = class extends AbstractAccount {
|
|
6167
6301
|
*/
|
6168
6302
|
async signTransaction(transactionRequestLike) {
|
6169
6303
|
if (!this._connector) {
|
6170
|
-
throw new
|
6171
|
-
|
6304
|
+
throw new FuelError17(
|
6305
|
+
ErrorCode16.MISSING_CONNECTOR,
|
6172
6306
|
"A connector is required to sign transactions."
|
6173
6307
|
);
|
6174
6308
|
}
|
@@ -6227,8 +6361,8 @@ var Account = class extends AbstractAccount {
|
|
6227
6361
|
/** @hidden * */
|
6228
6362
|
validateTransferAmount(amount) {
|
6229
6363
|
if (bn19(amount).lte(0)) {
|
6230
|
-
throw new
|
6231
|
-
|
6364
|
+
throw new FuelError17(
|
6365
|
+
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6232
6366
|
"Transfer amount must be a positive number."
|
6233
6367
|
);
|
6234
6368
|
}
|
@@ -6257,16 +6391,16 @@ var Account = class extends AbstractAccount {
|
|
6257
6391
|
if (!isDefined3(setGasLimit)) {
|
6258
6392
|
request.gasLimit = gasUsed;
|
6259
6393
|
} else if (gasUsed.gt(setGasLimit)) {
|
6260
|
-
throw new
|
6261
|
-
|
6394
|
+
throw new FuelError17(
|
6395
|
+
ErrorCode16.GAS_LIMIT_TOO_LOW,
|
6262
6396
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6263
6397
|
);
|
6264
6398
|
}
|
6265
6399
|
if (!isDefined3(setMaxFee)) {
|
6266
6400
|
request.maxFee = maxFee;
|
6267
6401
|
} else if (maxFee.gt(setMaxFee)) {
|
6268
|
-
throw new
|
6269
|
-
|
6402
|
+
throw new FuelError17(
|
6403
|
+
ErrorCode16.MAX_FEE_TOO_LOW,
|
6270
6404
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6271
6405
|
);
|
6272
6406
|
}
|
@@ -6399,7 +6533,7 @@ import {
|
|
6399
6533
|
encryptJsonWalletData,
|
6400
6534
|
randomUUID
|
6401
6535
|
} from "@fuel-ts/crypto";
|
6402
|
-
import { ErrorCode as
|
6536
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
|
6403
6537
|
import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
6404
6538
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6405
6539
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6476,8 +6610,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6476
6610
|
const macHashUint8Array = keccak256(data);
|
6477
6611
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
6478
6612
|
if (mac !== macHash) {
|
6479
|
-
throw new
|
6480
|
-
|
6613
|
+
throw new FuelError18(
|
6614
|
+
ErrorCode17.INVALID_PASSWORD,
|
6481
6615
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6482
6616
|
);
|
6483
6617
|
}
|
@@ -6607,14 +6741,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6607
6741
|
|
6608
6742
|
// src/hdwallet/hdwallet.ts
|
6609
6743
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
6610
|
-
import { ErrorCode as
|
6744
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError21 } from "@fuel-ts/errors";
|
6611
6745
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
6612
6746
|
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6613
6747
|
import { arrayify as arrayify18, hexlify as hexlify18, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
6614
6748
|
|
6615
6749
|
// src/mnemonic/mnemonic.ts
|
6616
6750
|
import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
6617
|
-
import { ErrorCode as
|
6751
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError20 } from "@fuel-ts/errors";
|
6618
6752
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
6619
6753
|
import { arrayify as arrayify17, hexlify as hexlify17, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
6620
6754
|
|
@@ -8677,7 +8811,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8677
8811
|
})(Language || {});
|
8678
8812
|
|
8679
8813
|
// src/mnemonic/utils.ts
|
8680
|
-
import { ErrorCode as
|
8814
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError19 } from "@fuel-ts/errors";
|
8681
8815
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
8682
8816
|
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
8683
8817
|
function getLowerMask(bits) {
|
@@ -8726,8 +8860,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8726
8860
|
for (let i = 0; i < words.length; i += 1) {
|
8727
8861
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8728
8862
|
if (index === -1) {
|
8729
|
-
throw new
|
8730
|
-
|
8863
|
+
throw new FuelError19(
|
8864
|
+
ErrorCode18.INVALID_MNEMONIC,
|
8731
8865
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8732
8866
|
);
|
8733
8867
|
}
|
@@ -8743,8 +8877,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8743
8877
|
const checksumMask = getUpperMask(checksumBits);
|
8744
8878
|
const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8745
8879
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8746
|
-
throw new
|
8747
|
-
|
8880
|
+
throw new FuelError19(
|
8881
|
+
ErrorCode18.INVALID_CHECKSUM,
|
8748
8882
|
"Checksum validation failed for the provided mnemonic."
|
8749
8883
|
);
|
8750
8884
|
}
|
@@ -8758,16 +8892,16 @@ var TestnetPRV = "0x04358394";
|
|
8758
8892
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8759
8893
|
function assertWordList(wordlist) {
|
8760
8894
|
if (wordlist.length !== 2048) {
|
8761
|
-
throw new
|
8762
|
-
|
8895
|
+
throw new FuelError20(
|
8896
|
+
ErrorCode19.INVALID_WORD_LIST,
|
8763
8897
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8764
8898
|
);
|
8765
8899
|
}
|
8766
8900
|
}
|
8767
8901
|
function assertEntropy(entropy) {
|
8768
8902
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8769
|
-
throw new
|
8770
|
-
|
8903
|
+
throw new FuelError20(
|
8904
|
+
ErrorCode19.INVALID_ENTROPY,
|
8771
8905
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8772
8906
|
);
|
8773
8907
|
}
|
@@ -8777,7 +8911,7 @@ function assertMnemonic(words) {
|
|
8777
8911
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8778
8912
|
", "
|
8779
8913
|
)}] words, but got ${words.length}.`;
|
8780
|
-
throw new
|
8914
|
+
throw new FuelError20(ErrorCode19.INVALID_MNEMONIC, errorMsg);
|
8781
8915
|
}
|
8782
8916
|
}
|
8783
8917
|
var Mnemonic = class {
|
@@ -8895,8 +9029,8 @@ var Mnemonic = class {
|
|
8895
9029
|
static masterKeysFromSeed(seed) {
|
8896
9030
|
const seedArray = arrayify17(seed);
|
8897
9031
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8898
|
-
throw new
|
8899
|
-
|
9032
|
+
throw new FuelError20(
|
9033
|
+
ErrorCode19.INVALID_SEED,
|
8900
9034
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8901
9035
|
);
|
8902
9036
|
}
|
@@ -8973,7 +9107,7 @@ function isValidExtendedKey(extendedKey) {
|
|
8973
9107
|
function parsePath(path, depth = 0) {
|
8974
9108
|
const components = path.split("/");
|
8975
9109
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
8976
|
-
throw new
|
9110
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path}`);
|
8977
9111
|
}
|
8978
9112
|
if (components[0] === "m") {
|
8979
9113
|
components.shift();
|
@@ -9002,8 +9136,8 @@ var HDWallet = class {
|
|
9002
9136
|
this.privateKey = hexlify18(config.privateKey);
|
9003
9137
|
} else {
|
9004
9138
|
if (!config.publicKey) {
|
9005
|
-
throw new
|
9006
|
-
|
9139
|
+
throw new FuelError21(
|
9140
|
+
ErrorCode20.HD_WALLET_ERROR,
|
9007
9141
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9008
9142
|
);
|
9009
9143
|
}
|
@@ -9032,8 +9166,8 @@ var HDWallet = class {
|
|
9032
9166
|
const data = new Uint8Array(37);
|
9033
9167
|
if (index & HARDENED_INDEX) {
|
9034
9168
|
if (!privateKey) {
|
9035
|
-
throw new
|
9036
|
-
|
9169
|
+
throw new FuelError21(
|
9170
|
+
ErrorCode20.HD_WALLET_ERROR,
|
9037
9171
|
"Cannot derive a hardened index without a private Key."
|
9038
9172
|
);
|
9039
9173
|
}
|
@@ -9085,8 +9219,8 @@ var HDWallet = class {
|
|
9085
9219
|
*/
|
9086
9220
|
toExtendedKey(isPublic = false, testnet = false) {
|
9087
9221
|
if (this.depth >= 256) {
|
9088
|
-
throw new
|
9089
|
-
|
9222
|
+
throw new FuelError21(
|
9223
|
+
ErrorCode20.HD_WALLET_ERROR,
|
9090
9224
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9091
9225
|
);
|
9092
9226
|
}
|
@@ -9117,10 +9251,10 @@ var HDWallet = class {
|
|
9117
9251
|
const bytes = arrayify18(decoded);
|
9118
9252
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9119
9253
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9120
|
-
throw new
|
9254
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9121
9255
|
}
|
9122
9256
|
if (!validChecksum) {
|
9123
|
-
throw new
|
9257
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9124
9258
|
}
|
9125
9259
|
const depth = bytes[4];
|
9126
9260
|
const parentFingerprint = hexlify18(bytes.slice(5, 9));
|
@@ -9128,14 +9262,14 @@ var HDWallet = class {
|
|
9128
9262
|
const chainCode = hexlify18(bytes.slice(13, 45));
|
9129
9263
|
const key = bytes.slice(45, 78);
|
9130
9264
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9131
|
-
throw new
|
9132
|
-
|
9265
|
+
throw new FuelError21(
|
9266
|
+
ErrorCode20.HD_WALLET_ERROR,
|
9133
9267
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9134
9268
|
);
|
9135
9269
|
}
|
9136
9270
|
if (isPublicExtendedKey(bytes)) {
|
9137
9271
|
if (key[0] !== 3) {
|
9138
|
-
throw new
|
9272
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
|
9139
9273
|
}
|
9140
9274
|
return new HDWallet({
|
9141
9275
|
publicKey: key,
|
@@ -9146,7 +9280,7 @@ var HDWallet = class {
|
|
9146
9280
|
});
|
9147
9281
|
}
|
9148
9282
|
if (key[0] !== 0) {
|
9149
|
-
throw new
|
9283
|
+
throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
|
9150
9284
|
}
|
9151
9285
|
return new HDWallet({
|
9152
9286
|
privateKey: key.slice(1),
|
@@ -9314,7 +9448,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
9314
9448
|
// src/wallet-manager/wallet-manager.ts
|
9315
9449
|
import { Address as Address8 } from "@fuel-ts/address";
|
9316
9450
|
import { encrypt, decrypt } from "@fuel-ts/crypto";
|
9317
|
-
import { ErrorCode as
|
9451
|
+
import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9318
9452
|
import { EventEmitter } from "events";
|
9319
9453
|
|
9320
9454
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -9337,7 +9471,7 @@ var MemoryStorage = class {
|
|
9337
9471
|
|
9338
9472
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
9339
9473
|
import { Address as Address6 } from "@fuel-ts/address";
|
9340
|
-
import { ErrorCode as
|
9474
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError22 } from "@fuel-ts/errors";
|
9341
9475
|
var _secret;
|
9342
9476
|
var MnemonicVault = class {
|
9343
9477
|
constructor(options) {
|
@@ -9393,8 +9527,8 @@ var MnemonicVault = class {
|
|
9393
9527
|
}
|
9394
9528
|
numberOfAccounts += 1;
|
9395
9529
|
} while (numberOfAccounts < this.numberOfAccounts);
|
9396
|
-
throw new
|
9397
|
-
|
9530
|
+
throw new FuelError22(
|
9531
|
+
ErrorCode21.WALLET_MANAGER_ERROR,
|
9398
9532
|
`Account with address '${address}' not found in derived wallets.`
|
9399
9533
|
);
|
9400
9534
|
}
|
@@ -9408,7 +9542,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
9408
9542
|
|
9409
9543
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
9410
9544
|
import { Address as Address7 } from "@fuel-ts/address";
|
9411
|
-
import { ErrorCode as
|
9545
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
|
9412
9546
|
var _privateKeys;
|
9413
9547
|
var PrivateKeyVault = class {
|
9414
9548
|
/**
|
@@ -9449,8 +9583,8 @@ var PrivateKeyVault = class {
|
|
9449
9583
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
9450
9584
|
);
|
9451
9585
|
if (!privateKey) {
|
9452
|
-
throw new
|
9453
|
-
|
9586
|
+
throw new FuelError23(
|
9587
|
+
ErrorCode22.WALLET_MANAGER_ERROR,
|
9454
9588
|
`No private key found for address '${address}'.`
|
9455
9589
|
);
|
9456
9590
|
}
|
@@ -9474,7 +9608,7 @@ var ERROR_MESSAGES = {
|
|
9474
9608
|
};
|
9475
9609
|
function assert(condition, message) {
|
9476
9610
|
if (!condition) {
|
9477
|
-
throw new
|
9611
|
+
throw new FuelError24(ErrorCode23.WALLET_MANAGER_ERROR, message);
|
9478
9612
|
}
|
9479
9613
|
}
|
9480
9614
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -9700,25 +9834,25 @@ deserializeVaults_fn = function(vaults) {
|
|
9700
9834
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
9701
9835
|
|
9702
9836
|
// src/wallet-manager/types.ts
|
9703
|
-
import { ErrorCode as
|
9837
|
+
import { ErrorCode as ErrorCode24, FuelError as FuelError25 } from "@fuel-ts/errors";
|
9704
9838
|
var Vault = class {
|
9705
9839
|
constructor(_options) {
|
9706
|
-
throw new
|
9840
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9707
9841
|
}
|
9708
9842
|
serialize() {
|
9709
|
-
throw new
|
9843
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9710
9844
|
}
|
9711
9845
|
getAccounts() {
|
9712
|
-
throw new
|
9846
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9713
9847
|
}
|
9714
9848
|
addAccount() {
|
9715
|
-
throw new
|
9849
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9716
9850
|
}
|
9717
9851
|
exportAccount(_address) {
|
9718
|
-
throw new
|
9852
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9719
9853
|
}
|
9720
9854
|
getWallet(_address) {
|
9721
|
-
throw new
|
9855
|
+
throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9722
9856
|
}
|
9723
9857
|
};
|
9724
9858
|
__publicField(Vault, "type");
|
@@ -9728,7 +9862,7 @@ var StorageAbstract = class {
|
|
9728
9862
|
// src/predicate/predicate.ts
|
9729
9863
|
import { Interface as Interface4 } from "@fuel-ts/abi-coder";
|
9730
9864
|
import { Address as Address9 } from "@fuel-ts/address";
|
9731
|
-
import { ErrorCode as
|
9865
|
+
import { ErrorCode as ErrorCode25, FuelError as FuelError26 } from "@fuel-ts/errors";
|
9732
9866
|
import { arrayify as arrayify20, hexlify as hexlify20 } from "@fuel-ts/utils";
|
9733
9867
|
|
9734
9868
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9790,7 +9924,7 @@ var Predicate = class extends Account {
|
|
9790
9924
|
if (placeholderIndex !== -1) {
|
9791
9925
|
request.removeWitness(placeholderIndex);
|
9792
9926
|
}
|
9793
|
-
request.inputs.filter(
|
9927
|
+
request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
9794
9928
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9795
9929
|
input.predicate = hexlify20(this.bytes);
|
9796
9930
|
input.predicateData = hexlify20(this.getPredicateData());
|
@@ -9840,8 +9974,8 @@ var Predicate = class extends Account {
|
|
9840
9974
|
if (jsonAbi) {
|
9841
9975
|
abiInterface = new Interface4(jsonAbi);
|
9842
9976
|
if (abiInterface.functions.main === void 0) {
|
9843
|
-
throw new
|
9844
|
-
|
9977
|
+
throw new FuelError26(
|
9978
|
+
ErrorCode25.ABI_MAIN_METHOD_MISSING,
|
9845
9979
|
'Cannot use ABI without "main" function.'
|
9846
9980
|
);
|
9847
9981
|
}
|
@@ -9902,21 +10036,21 @@ var Predicate = class extends Account {
|
|
9902
10036
|
const mutatedBytes = bytes;
|
9903
10037
|
try {
|
9904
10038
|
if (!abiInterface) {
|
9905
|
-
throw new
|
9906
|
-
|
10039
|
+
throw new FuelError26(
|
10040
|
+
ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
|
9907
10041
|
"Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
|
9908
10042
|
);
|
9909
10043
|
}
|
9910
10044
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
9911
|
-
throw new
|
9912
|
-
|
10045
|
+
throw new FuelError26(
|
10046
|
+
ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
|
9913
10047
|
"Predicate has no configurable constants to be set"
|
9914
10048
|
);
|
9915
10049
|
}
|
9916
10050
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
9917
10051
|
if (!abiInterface?.configurables[key]) {
|
9918
|
-
throw new
|
9919
|
-
|
10052
|
+
throw new FuelError26(
|
10053
|
+
ErrorCode25.CONFIGURABLE_NOT_FOUND,
|
9920
10054
|
`No configurable constant named '${key}' found in the Predicate`
|
9921
10055
|
);
|
9922
10056
|
}
|
@@ -9925,8 +10059,8 @@ var Predicate = class extends Account {
|
|
9925
10059
|
mutatedBytes.set(encoded, offset);
|
9926
10060
|
});
|
9927
10061
|
} catch (err) {
|
9928
|
-
throw new
|
9929
|
-
|
10062
|
+
throw new FuelError26(
|
10063
|
+
ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
|
9930
10064
|
`Error setting configurable constants: ${err.message}.`
|
9931
10065
|
);
|
9932
10066
|
}
|
@@ -9957,10 +10091,10 @@ var Predicate = class extends Account {
|
|
9957
10091
|
};
|
9958
10092
|
|
9959
10093
|
// src/connectors/fuel.ts
|
9960
|
-
import { ErrorCode as
|
10094
|
+
import { ErrorCode as ErrorCode26, FuelError as FuelError29 } from "@fuel-ts/errors";
|
9961
10095
|
|
9962
10096
|
// src/connectors/fuel-connector.ts
|
9963
|
-
import { FuelError as
|
10097
|
+
import { FuelError as FuelError27 } from "@fuel-ts/errors";
|
9964
10098
|
import { EventEmitter as EventEmitter2 } from "events";
|
9965
10099
|
|
9966
10100
|
// src/connectors/types/connector-types.ts
|
@@ -10034,7 +10168,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10034
10168
|
* @returns Always true.
|
10035
10169
|
*/
|
10036
10170
|
async ping() {
|
10037
|
-
throw new
|
10171
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10038
10172
|
}
|
10039
10173
|
/**
|
10040
10174
|
* Should return the current version of the connector
|
@@ -10043,7 +10177,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10043
10177
|
* @returns boolean - connection status.
|
10044
10178
|
*/
|
10045
10179
|
async version() {
|
10046
|
-
throw new
|
10180
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10047
10181
|
}
|
10048
10182
|
/**
|
10049
10183
|
* Should return true if the connector is connected
|
@@ -10052,7 +10186,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10052
10186
|
* @returns The connection status.
|
10053
10187
|
*/
|
10054
10188
|
async isConnected() {
|
10055
|
-
throw new
|
10189
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10056
10190
|
}
|
10057
10191
|
/**
|
10058
10192
|
* Should return all the accounts authorized for the
|
@@ -10061,7 +10195,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10061
10195
|
* @returns The accounts addresses strings
|
10062
10196
|
*/
|
10063
10197
|
async accounts() {
|
10064
|
-
throw new
|
10198
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10065
10199
|
}
|
10066
10200
|
/**
|
10067
10201
|
* Should start the connection process and return
|
@@ -10073,7 +10207,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10073
10207
|
* @returns boolean - connection status.
|
10074
10208
|
*/
|
10075
10209
|
async connect() {
|
10076
|
-
throw new
|
10210
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10077
10211
|
}
|
10078
10212
|
/**
|
10079
10213
|
* Should disconnect the current connection and
|
@@ -10083,7 +10217,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10083
10217
|
* @returns The connection status.
|
10084
10218
|
*/
|
10085
10219
|
async disconnect() {
|
10086
|
-
throw new
|
10220
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10087
10221
|
}
|
10088
10222
|
/**
|
10089
10223
|
* Should start the sign message process and return
|
@@ -10095,7 +10229,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10095
10229
|
* @returns Message signature
|
10096
10230
|
*/
|
10097
10231
|
async signMessage(_address, _message) {
|
10098
|
-
throw new
|
10232
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10099
10233
|
}
|
10100
10234
|
/**
|
10101
10235
|
* Should start the sign transaction process and return
|
@@ -10107,7 +10241,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10107
10241
|
* @returns Transaction signature
|
10108
10242
|
*/
|
10109
10243
|
async signTransaction(_address, _transaction) {
|
10110
|
-
throw new
|
10244
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10111
10245
|
}
|
10112
10246
|
/**
|
10113
10247
|
* Should start the send transaction process and return
|
@@ -10123,7 +10257,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10123
10257
|
* @returns The transaction id
|
10124
10258
|
*/
|
10125
10259
|
async sendTransaction(_address, _transaction) {
|
10126
|
-
throw new
|
10260
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10127
10261
|
}
|
10128
10262
|
/**
|
10129
10263
|
* Should return the current account selected inside the connector, if the account
|
@@ -10134,7 +10268,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10134
10268
|
* @returns The current account selected otherwise null.
|
10135
10269
|
*/
|
10136
10270
|
async currentAccount() {
|
10137
|
-
throw new
|
10271
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10138
10272
|
}
|
10139
10273
|
/**
|
10140
10274
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -10148,7 +10282,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10148
10282
|
* @returns True if the asset was added successfully
|
10149
10283
|
*/
|
10150
10284
|
async addAssets(_assets) {
|
10151
|
-
throw new
|
10285
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10152
10286
|
}
|
10153
10287
|
/**
|
10154
10288
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -10162,7 +10296,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10162
10296
|
* @returns True if the asset was added successfully
|
10163
10297
|
*/
|
10164
10298
|
async addAsset(_asset) {
|
10165
|
-
throw new
|
10299
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10166
10300
|
}
|
10167
10301
|
/**
|
10168
10302
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -10170,7 +10304,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10170
10304
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
10171
10305
|
*/
|
10172
10306
|
async assets() {
|
10173
|
-
throw new
|
10307
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10174
10308
|
}
|
10175
10309
|
/**
|
10176
10310
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -10181,7 +10315,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10181
10315
|
* @returns Return true if the network was added successfully
|
10182
10316
|
*/
|
10183
10317
|
async addNetwork(_networkUrl) {
|
10184
|
-
throw new
|
10318
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10185
10319
|
}
|
10186
10320
|
/**
|
10187
10321
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -10192,7 +10326,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10192
10326
|
* @returns Return true if the network was added successfully
|
10193
10327
|
*/
|
10194
10328
|
async selectNetwork(_network) {
|
10195
|
-
throw new
|
10329
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10196
10330
|
}
|
10197
10331
|
/**
|
10198
10332
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -10200,7 +10334,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10200
10334
|
* @returns Return all the networks added to the connector.
|
10201
10335
|
*/
|
10202
10336
|
async networks() {
|
10203
|
-
throw new
|
10337
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10204
10338
|
}
|
10205
10339
|
/**
|
10206
10340
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -10208,7 +10342,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10208
10342
|
* @returns Return the current network selected inside the connector.
|
10209
10343
|
*/
|
10210
10344
|
async currentNetwork() {
|
10211
|
-
throw new
|
10345
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10212
10346
|
}
|
10213
10347
|
/**
|
10214
10348
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -10218,7 +10352,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10218
10352
|
* @returns Return true if the ABI was added successfully.
|
10219
10353
|
*/
|
10220
10354
|
async addABI(_contractId, _abi) {
|
10221
|
-
throw new
|
10355
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10222
10356
|
}
|
10223
10357
|
/**
|
10224
10358
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10227,7 +10361,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10227
10361
|
* @returns The ABI if it exists, otherwise return null.
|
10228
10362
|
*/
|
10229
10363
|
async getABI(_id) {
|
10230
|
-
throw new
|
10364
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10231
10365
|
}
|
10232
10366
|
/**
|
10233
10367
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10236,7 +10370,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10236
10370
|
* @returns Returns true if the abi exists or false if not.
|
10237
10371
|
*/
|
10238
10372
|
async hasABI(_id) {
|
10239
|
-
throw new
|
10373
|
+
throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10240
10374
|
}
|
10241
10375
|
/**
|
10242
10376
|
* Event listener for the connector.
|
@@ -10280,7 +10414,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
10280
10414
|
}
|
10281
10415
|
|
10282
10416
|
// src/connectors/utils/promises.ts
|
10283
|
-
import { FuelError as
|
10417
|
+
import { FuelError as FuelError28 } from "@fuel-ts/errors";
|
10284
10418
|
function deferPromise() {
|
10285
10419
|
const defer = {};
|
10286
10420
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -10292,7 +10426,7 @@ function deferPromise() {
|
|
10292
10426
|
async function withTimeout(promise, timeout = 1050) {
|
10293
10427
|
const timeoutPromise = new Promise((resolve, reject) => {
|
10294
10428
|
setTimeout(() => {
|
10295
|
-
reject(new
|
10429
|
+
reject(new FuelError28(FuelError28.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
10296
10430
|
}, timeout);
|
10297
10431
|
});
|
10298
10432
|
return Promise.race([timeoutPromise, promise]);
|
@@ -10326,7 +10460,7 @@ var _Fuel = class extends FuelConnector {
|
|
10326
10460
|
await this.setDefaultConnector();
|
10327
10461
|
this._targetUnsubscribe = this.setupConnectorListener();
|
10328
10462
|
} catch (error) {
|
10329
|
-
throw new
|
10463
|
+
throw new FuelError29(ErrorCode26.INVALID_PROVIDER, "Error initializing Fuel Connector");
|
10330
10464
|
}
|
10331
10465
|
}
|
10332
10466
|
async init() {
|
@@ -10392,8 +10526,8 @@ var _Fuel = class extends FuelConnector {
|
|
10392
10526
|
const hasConnector = await this.hasConnector();
|
10393
10527
|
await this.pingConnector();
|
10394
10528
|
if (!this._currentConnector || !hasConnector) {
|
10395
|
-
throw new
|
10396
|
-
|
10529
|
+
throw new FuelError29(
|
10530
|
+
ErrorCode26.MISSING_CONNECTOR,
|
10397
10531
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
10398
10532
|
);
|
10399
10533
|
}
|
@@ -10457,7 +10591,7 @@ var _Fuel = class extends FuelConnector {
|
|
10457
10591
|
cacheTime: PING_CACHE_TIME
|
10458
10592
|
})();
|
10459
10593
|
} catch {
|
10460
|
-
throw new
|
10594
|
+
throw new FuelError29(ErrorCode26.INVALID_PROVIDER, "Current connector is not available.");
|
10461
10595
|
}
|
10462
10596
|
}
|
10463
10597
|
/**
|
@@ -10606,7 +10740,7 @@ var _Fuel = class extends FuelConnector {
|
|
10606
10740
|
const currentNetwork = await this.currentNetwork();
|
10607
10741
|
provider = await Provider.create(currentNetwork.url);
|
10608
10742
|
} else {
|
10609
|
-
throw new
|
10743
|
+
throw new FuelError29(ErrorCode26.INVALID_PROVIDER, "Provider is not valid.");
|
10610
10744
|
}
|
10611
10745
|
return provider;
|
10612
10746
|
}
|
@@ -10761,10 +10895,13 @@ export {
|
|
10761
10895
|
isCoin,
|
10762
10896
|
isInputCoin,
|
10763
10897
|
isMessage,
|
10898
|
+
isMessageCoin,
|
10764
10899
|
isRawCoin,
|
10765
10900
|
isRawMessage,
|
10766
10901
|
isRequestInputCoin,
|
10902
|
+
isRequestInputCoinOrMessage,
|
10767
10903
|
isRequestInputMessage,
|
10904
|
+
isRequestInputMessageWithoutData,
|
10768
10905
|
isRequestInputResource,
|
10769
10906
|
isRequestInputResourceFromOwner,
|
10770
10907
|
isTransactionTypeBlob,
|