@fuel-ts/account 0.94.3 → 0.94.5
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 +391 -436
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +345 -195
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +427 -285
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +250 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.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 +36 -3
- 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/transaction-response/transaction-response.d.ts +3 -1
- package/dist/providers/transaction-response/transaction-response.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/providers/utils/receipts.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +235 -286
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +300 -162
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +372 -239
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.js
CHANGED
@@ -173,10 +173,13 @@ __export(src_exports, {
|
|
173
173
|
isCoin: () => isCoin,
|
174
174
|
isInputCoin: () => isInputCoin,
|
175
175
|
isMessage: () => isMessage,
|
176
|
+
isMessageCoin: () => isMessageCoin,
|
176
177
|
isRawCoin: () => isRawCoin,
|
177
178
|
isRawMessage: () => isRawMessage,
|
178
179
|
isRequestInputCoin: () => isRequestInputCoin,
|
180
|
+
isRequestInputCoinOrMessage: () => isRequestInputCoinOrMessage,
|
179
181
|
isRequestInputMessage: () => isRequestInputMessage,
|
182
|
+
isRequestInputMessageWithoutData: () => isRequestInputMessageWithoutData,
|
180
183
|
isRequestInputResource: () => isRequestInputResource,
|
181
184
|
isRequestInputResourceFromOwner: () => isRequestInputResourceFromOwner,
|
182
185
|
isTransactionTypeBlob: () => isTransactionTypeBlob,
|
@@ -208,11 +211,12 @@ module.exports = __toCommonJS(src_exports);
|
|
208
211
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
209
212
|
var import_address4 = require("@fuel-ts/address");
|
210
213
|
var import_crypto2 = require("@fuel-ts/crypto");
|
211
|
-
var
|
214
|
+
var import_errors18 = require("@fuel-ts/errors");
|
212
215
|
var import_interfaces = require("@fuel-ts/interfaces");
|
213
216
|
var import_math21 = require("@fuel-ts/math");
|
217
|
+
var import_transactions22 = require("@fuel-ts/transactions");
|
214
218
|
var import_utils30 = require("@fuel-ts/utils");
|
215
|
-
var
|
219
|
+
var import_ramda7 = require("ramda");
|
216
220
|
|
217
221
|
// src/providers/coin-quantity.ts
|
218
222
|
var import_math = require("@fuel-ts/math");
|
@@ -251,14 +255,15 @@ var addAmountToCoinQuantities = (params) => {
|
|
251
255
|
|
252
256
|
// src/providers/provider.ts
|
253
257
|
var import_address3 = require("@fuel-ts/address");
|
254
|
-
var
|
258
|
+
var import_errors16 = require("@fuel-ts/errors");
|
255
259
|
var import_math18 = require("@fuel-ts/math");
|
256
260
|
var import_transactions20 = require("@fuel-ts/transactions");
|
257
261
|
var import_utils24 = require("@fuel-ts/utils");
|
258
262
|
var import_versions = require("@fuel-ts/versions");
|
259
263
|
var import_utils25 = require("@noble/curves/abstract/utils");
|
260
264
|
var import_graphql_request = require("graphql-request");
|
261
|
-
var
|
265
|
+
var import_graphql_tag2 = __toESM(require("graphql-tag"));
|
266
|
+
var import_ramda6 = require("ramda");
|
262
267
|
|
263
268
|
// src/providers/__generated__/operations.ts
|
264
269
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
@@ -591,6 +596,14 @@ var BlockFragmentDoc = import_graphql_tag.default`
|
|
591
596
|
height
|
592
597
|
header {
|
593
598
|
time
|
599
|
+
daHeight
|
600
|
+
stateTransitionBytecodeVersion
|
601
|
+
transactionsCount
|
602
|
+
transactionsRoot
|
603
|
+
messageOutboxRoot
|
604
|
+
eventInboxRoot
|
605
|
+
prevRoot
|
606
|
+
applicationHash
|
594
607
|
}
|
595
608
|
transactions {
|
596
609
|
id
|
@@ -1198,6 +1211,13 @@ var SubmitAndAwaitDocument = import_graphql_tag.default`
|
|
1198
1211
|
}
|
1199
1212
|
}
|
1200
1213
|
${TransactionStatusSubscriptionFragmentDoc}`;
|
1214
|
+
var SubmitAndAwaitStatusDocument = import_graphql_tag.default`
|
1215
|
+
subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
|
1216
|
+
submitAndAwaitStatus(tx: $encodedTransaction) {
|
1217
|
+
...transactionStatusSubscriptionFragment
|
1218
|
+
}
|
1219
|
+
}
|
1220
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
1201
1221
|
var StatusChangeDocument = import_graphql_tag.default`
|
1202
1222
|
subscription statusChange($transactionId: TransactionId!) {
|
1203
1223
|
statusChange(id: $transactionId) {
|
@@ -1294,6 +1314,9 @@ function getSdk(requester) {
|
|
1294
1314
|
submitAndAwait(variables, options) {
|
1295
1315
|
return requester(SubmitAndAwaitDocument, variables, options);
|
1296
1316
|
},
|
1317
|
+
submitAndAwaitStatus(variables, options) {
|
1318
|
+
return requester(SubmitAndAwaitStatusDocument, variables, options);
|
1319
|
+
},
|
1297
1320
|
statusChange(variables, options) {
|
1298
1321
|
return requester(StatusChangeDocument, variables, options);
|
1299
1322
|
}
|
@@ -1320,7 +1343,9 @@ var _FuelGraphqlSubscriber = class {
|
|
1320
1343
|
Accept: "text/event-stream"
|
1321
1344
|
}
|
1322
1345
|
});
|
1323
|
-
|
1346
|
+
const [errorReader, resultReader] = response.body.tee().map((stream) => stream.getReader());
|
1347
|
+
await new _FuelGraphqlSubscriber(errorReader).next();
|
1348
|
+
return new _FuelGraphqlSubscriber(resultReader);
|
1324
1349
|
}
|
1325
1350
|
events = [];
|
1326
1351
|
parsingLeftover = "";
|
@@ -1363,10 +1388,8 @@ var _FuelGraphqlSubscriber = class {
|
|
1363
1388
|
/**
|
1364
1389
|
* Gets called when `break` is called in a `for-await-of` loop.
|
1365
1390
|
*/
|
1366
|
-
|
1367
|
-
|
1368
|
-
this.stream.releaseLock();
|
1369
|
-
return { done: true, value: void 0 };
|
1391
|
+
return() {
|
1392
|
+
return Promise.resolve({ done: true, value: void 0 });
|
1370
1393
|
}
|
1371
1394
|
[Symbol.asyncIterator]() {
|
1372
1395
|
return this;
|
@@ -1579,6 +1602,9 @@ var import_math8 = require("@fuel-ts/math");
|
|
1579
1602
|
var import_transactions7 = require("@fuel-ts/transactions");
|
1580
1603
|
var import_utils9 = require("@fuel-ts/utils");
|
1581
1604
|
|
1605
|
+
// src/providers/message.ts
|
1606
|
+
var isMessageCoin = (message) => !("data" in message);
|
1607
|
+
|
1582
1608
|
// src/providers/resource.ts
|
1583
1609
|
var isRawCoin = (resource) => "utxoId" in resource;
|
1584
1610
|
var isRawMessage = (resource) => "recipient" in resource;
|
@@ -1737,12 +1763,12 @@ function assembleReceiptByType(receipt) {
|
|
1737
1763
|
const amount = (0, import_math4.bn)(receipt.amount);
|
1738
1764
|
const data = receipt.data ? (0, import_utils5.arrayify)(receipt.data) : Uint8Array.from([]);
|
1739
1765
|
const digest = hexOrZero(receipt.digest);
|
1740
|
-
const messageId = import_transactions3.
|
1766
|
+
const messageId = import_transactions3.InputMessageCoder.getMessageId({
|
1741
1767
|
sender,
|
1742
1768
|
recipient,
|
1743
1769
|
nonce,
|
1744
1770
|
amount,
|
1745
|
-
data
|
1771
|
+
data: (0, import_utils5.hexlify)(data)
|
1746
1772
|
});
|
1747
1773
|
const receiptMessageOut = {
|
1748
1774
|
type: import_transactions3.ReceiptType.MessageOut,
|
@@ -1759,7 +1785,7 @@ function assembleReceiptByType(receipt) {
|
|
1759
1785
|
case "MINT" /* Mint */: {
|
1760
1786
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1761
1787
|
const subId = hexOrZero(receipt.subId);
|
1762
|
-
const assetId = import_transactions3.
|
1788
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1763
1789
|
const mintReceipt = {
|
1764
1790
|
type: import_transactions3.ReceiptType.Mint,
|
1765
1791
|
subId,
|
@@ -1774,7 +1800,7 @@ function assembleReceiptByType(receipt) {
|
|
1774
1800
|
case "BURN" /* Burn */: {
|
1775
1801
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1776
1802
|
const subId = hexOrZero(receipt.subId);
|
1777
|
-
const assetId = import_transactions3.
|
1803
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1778
1804
|
const burnReceipt = {
|
1779
1805
|
type: import_transactions3.ReceiptType.Burn,
|
1780
1806
|
subId,
|
@@ -2015,20 +2041,22 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2015
2041
|
let reason = "";
|
2016
2042
|
if (revertReceipt) {
|
2017
2043
|
const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
|
2044
|
+
const lastLog = logs[logs.length - 1];
|
2045
|
+
const lastButOneLog = logs[logs.length - 2];
|
2018
2046
|
switch (reasonHex) {
|
2019
2047
|
case import_configs5.FAILED_REQUIRE_SIGNAL: {
|
2020
2048
|
reason = "require";
|
2021
|
-
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(
|
2049
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
2022
2050
|
break;
|
2023
2051
|
}
|
2024
2052
|
case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
|
2025
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(
|
2053
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
2026
2054
|
reason = "assert_eq";
|
2027
2055
|
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
2028
2056
|
break;
|
2029
2057
|
}
|
2030
2058
|
case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
|
2031
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(
|
2059
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
2032
2060
|
reason = "assert_ne";
|
2033
2061
|
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
2034
2062
|
break;
|
@@ -2101,7 +2129,9 @@ var import_math7 = require("@fuel-ts/math");
|
|
2101
2129
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2102
2130
|
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
2103
2131
|
var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
|
2104
|
-
var
|
2132
|
+
var isRequestInputMessageWithoutData = (input) => input.type === import_transactions6.InputType.Message && (0, import_math7.bn)(input.data).isZero();
|
2133
|
+
var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
2134
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
|
2105
2135
|
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
2106
2136
|
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
2107
2137
|
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
@@ -2411,7 +2441,7 @@ var BaseTransactionRequest = class {
|
|
2411
2441
|
* @param message - Message resource.
|
2412
2442
|
*/
|
2413
2443
|
addMessageInput(message) {
|
2414
|
-
const { recipient, sender, amount, predicate, nonce,
|
2444
|
+
const { recipient, sender, amount, predicate, nonce, predicateData } = message;
|
2415
2445
|
let witnessIndex;
|
2416
2446
|
if (message.predicate) {
|
2417
2447
|
witnessIndex = 0;
|
@@ -2426,13 +2456,16 @@ var BaseTransactionRequest = class {
|
|
2426
2456
|
type: import_transactions7.InputType.Message,
|
2427
2457
|
sender: sender.toB256(),
|
2428
2458
|
recipient: recipient.toB256(),
|
2459
|
+
data: isMessageCoin(message) ? "0x" : message.data,
|
2429
2460
|
amount,
|
2430
2461
|
witnessIndex,
|
2431
2462
|
predicate,
|
2432
2463
|
predicateData
|
2433
2464
|
};
|
2434
2465
|
this.pushInput(input);
|
2435
|
-
|
2466
|
+
if (isMessageCoin(message)) {
|
2467
|
+
this.addChangeOutput(recipient, message.assetId);
|
2468
|
+
}
|
2436
2469
|
}
|
2437
2470
|
/**
|
2438
2471
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -2564,6 +2597,8 @@ var BaseTransactionRequest = class {
|
|
2564
2597
|
*
|
2565
2598
|
* @param quantities - CoinQuantity Array.
|
2566
2599
|
* @param baseAssetId - The base asset to fund the transaction.
|
2600
|
+
* @deprecated - This method is deprecated and will be removed in future versions.
|
2601
|
+
* Please use `Account.generateFakeResources` along with `this.addResources` instead.
|
2567
2602
|
*/
|
2568
2603
|
fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
|
2569
2604
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
@@ -2632,7 +2667,7 @@ var BaseTransactionRequest = class {
|
|
2632
2667
|
});
|
2633
2668
|
}
|
2634
2669
|
updatePredicateGasUsed(inputs) {
|
2635
|
-
const inputsToExtractGasUsed = inputs.filter(
|
2670
|
+
const inputsToExtractGasUsed = inputs.filter(isRequestInputCoinOrMessage);
|
2636
2671
|
this.inputs.filter(isRequestInputResource).forEach((i) => {
|
2637
2672
|
const owner = getRequestInputResourceOwner(i);
|
2638
2673
|
const correspondingInput = inputsToExtractGasUsed.find(
|
@@ -2648,6 +2683,9 @@ var BaseTransactionRequest = class {
|
|
2648
2683
|
}
|
2649
2684
|
};
|
2650
2685
|
|
2686
|
+
// src/providers/transaction-request/blob-transaction-request.ts
|
2687
|
+
var import_ramda3 = require("ramda");
|
2688
|
+
|
2651
2689
|
// src/providers/transaction-request/hash-transaction.ts
|
2652
2690
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2653
2691
|
var import_hasher = require("@fuel-ts/hasher");
|
@@ -2722,10 +2760,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2722
2760
|
// src/providers/transaction-request/blob-transaction-request.ts
|
2723
2761
|
var BlobTransactionRequest = class extends BaseTransactionRequest {
|
2724
2762
|
static from(obj) {
|
2725
|
-
|
2726
|
-
return obj;
|
2727
|
-
}
|
2728
|
-
return new this(obj);
|
2763
|
+
return new this((0, import_ramda3.clone)(obj));
|
2729
2764
|
}
|
2730
2765
|
/** Type of the transaction */
|
2731
2766
|
type = import_transactions7.TransactionType.Blob;
|
@@ -2788,6 +2823,7 @@ var import_configs8 = require("@fuel-ts/address/configs");
|
|
2788
2823
|
var import_math10 = require("@fuel-ts/math");
|
2789
2824
|
var import_transactions9 = require("@fuel-ts/transactions");
|
2790
2825
|
var import_utils14 = require("@fuel-ts/utils");
|
2826
|
+
var import_ramda4 = require("ramda");
|
2791
2827
|
|
2792
2828
|
// src/providers/transaction-request/storage-slot.ts
|
2793
2829
|
var import_utils13 = require("@fuel-ts/utils");
|
@@ -2815,10 +2851,7 @@ var storageSlotify = (storageSlot) => {
|
|
2815
2851
|
// src/providers/transaction-request/create-transaction-request.ts
|
2816
2852
|
var CreateTransactionRequest = class extends BaseTransactionRequest {
|
2817
2853
|
static from(obj) {
|
2818
|
-
|
2819
|
-
return obj;
|
2820
|
-
}
|
2821
|
-
return new this(obj);
|
2854
|
+
return new this((0, import_ramda4.clone)(obj));
|
2822
2855
|
}
|
2823
2856
|
/** Type of the transaction */
|
2824
2857
|
type = import_transactions9.TransactionType.Create;
|
@@ -2907,6 +2940,7 @@ var import_configs9 = require("@fuel-ts/address/configs");
|
|
2907
2940
|
var import_math11 = require("@fuel-ts/math");
|
2908
2941
|
var import_transactions10 = require("@fuel-ts/transactions");
|
2909
2942
|
var import_utils16 = require("@fuel-ts/utils");
|
2943
|
+
var import_ramda5 = require("ramda");
|
2910
2944
|
|
2911
2945
|
// src/providers/transaction-request/scripts.ts
|
2912
2946
|
var import_utils15 = require("@fuel-ts/utils");
|
@@ -2937,10 +2971,7 @@ var withdrawScript = {
|
|
2937
2971
|
// src/providers/transaction-request/script-transaction-request.ts
|
2938
2972
|
var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
2939
2973
|
static from(obj) {
|
2940
|
-
|
2941
|
-
return obj;
|
2942
|
-
}
|
2943
|
-
return new this(obj);
|
2974
|
+
return new this((0, import_ramda5.clone)(obj));
|
2944
2975
|
}
|
2945
2976
|
/** Type of the transaction */
|
2946
2977
|
type = import_transactions10.TransactionType.Script;
|
@@ -4027,29 +4058,30 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
4027
4058
|
});
|
4028
4059
|
}
|
4029
4060
|
var TransactionResponse = class {
|
4030
|
-
/** Transaction ID */
|
4031
|
-
id;
|
4032
|
-
/** Current provider */
|
4033
|
-
provider;
|
4034
|
-
/** Gas used on the transaction */
|
4035
|
-
gasUsed = (0, import_math17.bn)(0);
|
4036
|
-
/** The graphql Transaction with receipts object. */
|
4037
|
-
gqlTransaction;
|
4038
|
-
request;
|
4039
|
-
status;
|
4040
|
-
abis;
|
4041
4061
|
/**
|
4042
4062
|
* Constructor for `TransactionResponse`.
|
4043
4063
|
*
|
4044
4064
|
* @param tx - The transaction ID or TransactionRequest.
|
4045
4065
|
* @param provider - The provider.
|
4046
4066
|
*/
|
4047
|
-
constructor(tx, provider, abis) {
|
4067
|
+
constructor(tx, provider, abis, submitTxSubscription) {
|
4068
|
+
this.submitTxSubscription = submitTxSubscription;
|
4048
4069
|
this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
|
4049
4070
|
this.provider = provider;
|
4050
4071
|
this.abis = abis;
|
4051
4072
|
this.request = typeof tx === "string" ? void 0 : tx;
|
4052
4073
|
}
|
4074
|
+
/** Transaction ID */
|
4075
|
+
id;
|
4076
|
+
/** Current provider */
|
4077
|
+
provider;
|
4078
|
+
/** Gas used on the transaction */
|
4079
|
+
gasUsed = (0, import_math17.bn)(0);
|
4080
|
+
/** The graphql Transaction with receipts object. */
|
4081
|
+
gqlTransaction;
|
4082
|
+
request;
|
4083
|
+
status;
|
4084
|
+
abis;
|
4053
4085
|
/**
|
4054
4086
|
* Async constructor for `TransactionResponse`. This method can be used to create
|
4055
4087
|
* an instance of `TransactionResponse` and wait for the transaction to be fetched
|
@@ -4182,10 +4214,11 @@ var TransactionResponse = class {
|
|
4182
4214
|
if (status && status !== "SubmittedStatus") {
|
4183
4215
|
return;
|
4184
4216
|
}
|
4185
|
-
const subscription = await this.provider.operations.statusChange({
|
4217
|
+
const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
|
4186
4218
|
transactionId: this.id
|
4187
4219
|
});
|
4188
|
-
for await (const
|
4220
|
+
for await (const sub of subscription) {
|
4221
|
+
const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
|
4189
4222
|
this.status = statusChange;
|
4190
4223
|
if (statusChange.type === "SqueezedOutStatus") {
|
4191
4224
|
this.unsetResourceCache();
|
@@ -4297,6 +4330,22 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4297
4330
|
};
|
4298
4331
|
}
|
4299
4332
|
|
4333
|
+
// src/providers/utils/handle-gql-error-message.ts
|
4334
|
+
var import_errors15 = require("@fuel-ts/errors");
|
4335
|
+
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4336
|
+
switch (errorMessage) {
|
4337
|
+
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4338
|
+
throw new import_errors15.FuelError(
|
4339
|
+
import_errors15.ErrorCode.NOT_ENOUGH_FUNDS,
|
4340
|
+
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4341
|
+
{},
|
4342
|
+
rawError
|
4343
|
+
);
|
4344
|
+
default:
|
4345
|
+
throw new import_errors15.FuelError(import_errors15.ErrorCode.INVALID_REQUEST, errorMessage);
|
4346
|
+
}
|
4347
|
+
};
|
4348
|
+
|
4300
4349
|
// src/providers/provider.ts
|
4301
4350
|
var MAX_RETRIES = 10;
|
4302
4351
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
@@ -4423,6 +4472,17 @@ var _Provider = class {
|
|
4423
4472
|
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
4424
4473
|
}, retryOptions);
|
4425
4474
|
}
|
4475
|
+
static extractBasicAuth(url) {
|
4476
|
+
const parsedUrl = new URL(url);
|
4477
|
+
const username = parsedUrl.username;
|
4478
|
+
const password = parsedUrl.password;
|
4479
|
+
const urlNoBasicAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
|
4480
|
+
if (!(username && password)) {
|
4481
|
+
return { url, auth: void 0 };
|
4482
|
+
}
|
4483
|
+
const auth = `Basic ${btoa(`${username}:${password}`)}`;
|
4484
|
+
return { url: urlNoBasicAuth, auth };
|
4485
|
+
}
|
4426
4486
|
/**
|
4427
4487
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
4428
4488
|
*
|
@@ -4432,7 +4492,17 @@ var _Provider = class {
|
|
4432
4492
|
* @returns A promise that resolves to a Provider instance.
|
4433
4493
|
*/
|
4434
4494
|
static async create(url, options = {}) {
|
4435
|
-
const
|
4495
|
+
const { url: urlToUse, auth } = this.extractBasicAuth(url);
|
4496
|
+
const provider = new _Provider(urlToUse, {
|
4497
|
+
...options,
|
4498
|
+
requestMiddleware: async (request) => {
|
4499
|
+
if (auth && request) {
|
4500
|
+
request.headers ??= {};
|
4501
|
+
request.headers.Authorization = auth;
|
4502
|
+
}
|
4503
|
+
return options.requestMiddleware?.(request) ?? request;
|
4504
|
+
}
|
4505
|
+
});
|
4436
4506
|
await provider.fetchChainAndNodeInfo();
|
4437
4507
|
return provider;
|
4438
4508
|
}
|
@@ -4444,8 +4514,8 @@ var _Provider = class {
|
|
4444
4514
|
getChain() {
|
4445
4515
|
const chain = _Provider.chainInfoCache[this.url];
|
4446
4516
|
if (!chain) {
|
4447
|
-
throw new
|
4448
|
-
|
4517
|
+
throw new import_errors16.FuelError(
|
4518
|
+
import_errors16.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
4449
4519
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4450
4520
|
);
|
4451
4521
|
}
|
@@ -4459,8 +4529,8 @@ var _Provider = class {
|
|
4459
4529
|
getNode() {
|
4460
4530
|
const node = _Provider.nodeInfoCache[this.url];
|
4461
4531
|
if (!node) {
|
4462
|
-
throw new
|
4463
|
-
|
4532
|
+
throw new import_errors16.FuelError(
|
4533
|
+
import_errors16.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
4464
4534
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4465
4535
|
);
|
4466
4536
|
}
|
@@ -4538,10 +4608,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4538
4608
|
if ("response" in response) {
|
4539
4609
|
const graphQlResponse = response.response;
|
4540
4610
|
if (Array.isArray(graphQlResponse?.errors)) {
|
4541
|
-
|
4542
|
-
|
4543
|
-
|
4544
|
-
);
|
4611
|
+
for (const error of graphQlResponse.errors) {
|
4612
|
+
handleGqlErrorMessage(error.message, error);
|
4613
|
+
}
|
4545
4614
|
}
|
4546
4615
|
}
|
4547
4616
|
}
|
@@ -4559,7 +4628,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4559
4628
|
}
|
4560
4629
|
return gqlClient.request(query, vars);
|
4561
4630
|
};
|
4562
|
-
|
4631
|
+
const customOperations = (requester) => ({
|
4632
|
+
getBlobs(variables) {
|
4633
|
+
const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
|
4634
|
+
const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
|
4635
|
+
const updatedVariables = variables.blobIds.reduce(
|
4636
|
+
(acc, blobId, i) => {
|
4637
|
+
acc[`blobId${i}`] = blobId;
|
4638
|
+
return acc;
|
4639
|
+
},
|
4640
|
+
{}
|
4641
|
+
);
|
4642
|
+
const document2 = import_graphql_tag2.default`
|
4643
|
+
query getBlobs(${queryParams}) {
|
4644
|
+
${blobParams}
|
4645
|
+
}
|
4646
|
+
`;
|
4647
|
+
return requester(document2, updatedVariables);
|
4648
|
+
}
|
4649
|
+
});
|
4650
|
+
return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
|
4563
4651
|
}
|
4564
4652
|
/**
|
4565
4653
|
* Returns the version of the connected node.
|
@@ -4634,14 +4722,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4634
4722
|
validateTransaction(tx, consensusParameters) {
|
4635
4723
|
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4636
4724
|
if ((0, import_math18.bn)(tx.inputs.length).gt(maxInputs)) {
|
4637
|
-
throw new
|
4638
|
-
|
4725
|
+
throw new import_errors16.FuelError(
|
4726
|
+
import_errors16.ErrorCode.MAX_INPUTS_EXCEEDED,
|
4639
4727
|
"The transaction exceeds the maximum allowed number of inputs."
|
4640
4728
|
);
|
4641
4729
|
}
|
4642
4730
|
if ((0, import_math18.bn)(tx.outputs.length).gt(maxOutputs)) {
|
4643
|
-
throw new
|
4644
|
-
|
4731
|
+
throw new import_errors16.FuelError(
|
4732
|
+
import_errors16.ErrorCode.MAX_OUTPUTS_EXCEEDED,
|
4645
4733
|
"The transaction exceeds the maximum allowed number of outputs."
|
4646
4734
|
);
|
4647
4735
|
}
|
@@ -4668,11 +4756,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4668
4756
|
if (isTransactionTypeScript(transactionRequest)) {
|
4669
4757
|
abis = transactionRequest.abis;
|
4670
4758
|
}
|
4671
|
-
const {
|
4672
|
-
|
4673
|
-
|
4674
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
|
4675
|
-
return new TransactionResponse(transactionRequest, this, abis);
|
4759
|
+
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
4760
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
|
4761
|
+
return new TransactionResponse(transactionRequest, this, abis, subscription);
|
4676
4762
|
}
|
4677
4763
|
/**
|
4678
4764
|
* Executes a transaction without actually submitting it to the chain.
|
@@ -4802,7 +4888,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4802
4888
|
missingContractIds: [],
|
4803
4889
|
dryRunStatus: void 0
|
4804
4890
|
}));
|
4805
|
-
const allRequests = (0,
|
4891
|
+
const allRequests = (0, import_ramda6.clone)(transactionRequests);
|
4806
4892
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4807
4893
|
allRequests.forEach((req, index) => {
|
4808
4894
|
if (isTransactionTypeScript(req)) {
|
@@ -4962,13 +5048,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4962
5048
|
* @returns A promise that resolves to the transaction cost object.
|
4963
5049
|
*/
|
4964
5050
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
4965
|
-
const txRequestClone = (0,
|
5051
|
+
const txRequestClone = (0, import_ramda6.clone)(transactionRequestify(transactionRequestLike));
|
4966
5052
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4967
5053
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
4968
5054
|
if (isScriptTransaction) {
|
4969
5055
|
txRequestClone.gasLimit = (0, import_math18.bn)(0);
|
4970
5056
|
}
|
4971
|
-
const signedRequest = (0,
|
5057
|
+
const signedRequest = (0, import_ramda6.clone)(txRequestClone);
|
4972
5058
|
let addedSignatures = 0;
|
4973
5059
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
4974
5060
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -5106,6 +5192,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5106
5192
|
}).filter((v) => !!v);
|
5107
5193
|
return coins;
|
5108
5194
|
}
|
5195
|
+
/**
|
5196
|
+
* Returns an array of blobIds that exist on chain, for a given array of blobIds.
|
5197
|
+
*
|
5198
|
+
* @param blobIds - blobIds to check.
|
5199
|
+
* @returns - A promise that resolves to an array of blobIds that exist on chain.
|
5200
|
+
*/
|
5201
|
+
async getBlobs(blobIds) {
|
5202
|
+
const res = await this.operations.getBlobs({ blobIds });
|
5203
|
+
const blobs = [];
|
5204
|
+
Object.keys(res).forEach((key) => {
|
5205
|
+
const val = res[key];
|
5206
|
+
blobs.push(val?.id ?? null);
|
5207
|
+
});
|
5208
|
+
return blobs.filter((v) => v);
|
5209
|
+
}
|
5109
5210
|
/**
|
5110
5211
|
* Returns block matching the given ID or height.
|
5111
5212
|
*
|
@@ -5127,11 +5228,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5127
5228
|
if (!block) {
|
5128
5229
|
return null;
|
5129
5230
|
}
|
5231
|
+
const { header, height, id, transactions } = block;
|
5130
5232
|
return {
|
5131
|
-
id
|
5132
|
-
height: (0, import_math18.bn)(
|
5133
|
-
time:
|
5134
|
-
|
5233
|
+
id,
|
5234
|
+
height: (0, import_math18.bn)(height),
|
5235
|
+
time: header.time,
|
5236
|
+
header: {
|
5237
|
+
applicationHash: header.applicationHash,
|
5238
|
+
daHeight: (0, import_math18.bn)(header.daHeight),
|
5239
|
+
eventInboxRoot: header.eventInboxRoot,
|
5240
|
+
messageOutboxRoot: header.messageOutboxRoot,
|
5241
|
+
prevRoot: header.prevRoot,
|
5242
|
+
stateTransitionBytecodeVersion: header.stateTransitionBytecodeVersion,
|
5243
|
+
transactionsCount: header.transactionsCount,
|
5244
|
+
transactionsRoot: header.transactionsRoot
|
5245
|
+
},
|
5246
|
+
transactionIds: transactions.map((tx) => tx.id)
|
5135
5247
|
};
|
5136
5248
|
}
|
5137
5249
|
/**
|
@@ -5153,6 +5265,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5153
5265
|
id: block.id,
|
5154
5266
|
height: (0, import_math18.bn)(block.height),
|
5155
5267
|
time: block.header.time,
|
5268
|
+
header: {
|
5269
|
+
applicationHash: block.header.applicationHash,
|
5270
|
+
daHeight: (0, import_math18.bn)(block.header.daHeight),
|
5271
|
+
eventInboxRoot: block.header.eventInboxRoot,
|
5272
|
+
messageOutboxRoot: block.header.messageOutboxRoot,
|
5273
|
+
prevRoot: block.header.prevRoot,
|
5274
|
+
stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
|
5275
|
+
transactionsCount: block.header.transactionsCount,
|
5276
|
+
transactionsRoot: block.header.transactionsRoot
|
5277
|
+
},
|
5156
5278
|
transactionIds: block.transactions.map((tx) => tx.id)
|
5157
5279
|
}));
|
5158
5280
|
return { blocks, pageInfo };
|
@@ -5180,6 +5302,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5180
5302
|
id: block.id,
|
5181
5303
|
height: (0, import_math18.bn)(block.height, 10),
|
5182
5304
|
time: block.header.time,
|
5305
|
+
header: {
|
5306
|
+
applicationHash: block.header.applicationHash,
|
5307
|
+
daHeight: (0, import_math18.bn)(block.header.daHeight),
|
5308
|
+
eventInboxRoot: block.header.eventInboxRoot,
|
5309
|
+
messageOutboxRoot: block.header.messageOutboxRoot,
|
5310
|
+
prevRoot: block.header.prevRoot,
|
5311
|
+
stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
|
5312
|
+
transactionsCount: block.header.transactionsCount,
|
5313
|
+
transactionsRoot: block.header.transactionsRoot
|
5314
|
+
},
|
5183
5315
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5184
5316
|
transactions: block.transactions.map(
|
5185
5317
|
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils24.arrayify)(tx.rawPayload), 0)?.[0]
|
@@ -5203,7 +5335,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5203
5335
|
0
|
5204
5336
|
)?.[0];
|
5205
5337
|
} catch (error) {
|
5206
|
-
if (error instanceof
|
5338
|
+
if (error instanceof import_errors16.FuelError && error.code === import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5207
5339
|
console.warn("Unsupported transaction type encountered");
|
5208
5340
|
return null;
|
5209
5341
|
}
|
@@ -5224,7 +5356,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5224
5356
|
try {
|
5225
5357
|
return coder.decode((0, import_utils24.arrayify)(rawPayload), 0)[0];
|
5226
5358
|
} catch (error) {
|
5227
|
-
if (error instanceof
|
5359
|
+
if (error instanceof import_errors16.FuelError && error.code === import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5228
5360
|
console.warn("Unsupported transaction type encountered");
|
5229
5361
|
return null;
|
5230
5362
|
}
|
@@ -5350,8 +5482,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5350
5482
|
nonce
|
5351
5483
|
};
|
5352
5484
|
if (commitBlockId && commitBlockHeight) {
|
5353
|
-
throw new
|
5354
|
-
|
5485
|
+
throw new import_errors16.FuelError(
|
5486
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5355
5487
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5356
5488
|
);
|
5357
5489
|
}
|
@@ -5491,10 +5623,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5491
5623
|
* @returns A promise that resolves to the Message object or null.
|
5492
5624
|
*/
|
5493
5625
|
async getMessageByNonce(nonce) {
|
5494
|
-
const { message } = await this.operations.getMessageByNonce({ nonce });
|
5495
|
-
if (!
|
5626
|
+
const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
|
5627
|
+
if (!rawMessage) {
|
5496
5628
|
return null;
|
5497
5629
|
}
|
5630
|
+
const message = {
|
5631
|
+
messageId: import_transactions20.InputMessageCoder.getMessageId({
|
5632
|
+
sender: rawMessage.sender,
|
5633
|
+
recipient: rawMessage.recipient,
|
5634
|
+
nonce: rawMessage.nonce,
|
5635
|
+
amount: (0, import_math18.bn)(rawMessage.amount),
|
5636
|
+
data: rawMessage.data
|
5637
|
+
}),
|
5638
|
+
sender: import_address3.Address.fromAddressOrString(rawMessage.sender),
|
5639
|
+
recipient: import_address3.Address.fromAddressOrString(rawMessage.recipient),
|
5640
|
+
nonce: rawMessage.nonce,
|
5641
|
+
amount: (0, import_math18.bn)(rawMessage.amount),
|
5642
|
+
data: import_transactions20.InputMessageCoder.decodeData(rawMessage.data),
|
5643
|
+
daHeight: (0, import_math18.bn)(rawMessage.daHeight)
|
5644
|
+
};
|
5498
5645
|
return message;
|
5499
5646
|
}
|
5500
5647
|
/**
|
@@ -5519,26 +5666,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5519
5666
|
const { paginationLimit, inputArgs = {} } = params;
|
5520
5667
|
const { first, last, after, before } = inputArgs;
|
5521
5668
|
if (after && before) {
|
5522
|
-
throw new
|
5523
|
-
|
5669
|
+
throw new import_errors16.FuelError(
|
5670
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5524
5671
|
'Pagination arguments "after" and "before" cannot be used together'
|
5525
5672
|
);
|
5526
5673
|
}
|
5527
5674
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5528
|
-
throw new
|
5529
|
-
|
5675
|
+
throw new import_errors16.FuelError(
|
5676
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5530
5677
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5531
5678
|
);
|
5532
5679
|
}
|
5533
5680
|
if (first && before) {
|
5534
|
-
throw new
|
5535
|
-
|
5681
|
+
throw new import_errors16.FuelError(
|
5682
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5536
5683
|
'The use of pagination argument "first" with "before" is not supported'
|
5537
5684
|
);
|
5538
5685
|
}
|
5539
5686
|
if (last && after) {
|
5540
|
-
throw new
|
5541
|
-
|
5687
|
+
throw new import_errors16.FuelError(
|
5688
|
+
import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5542
5689
|
'The use of pagination argument "last" with "after" is not supported'
|
5543
5690
|
);
|
5544
5691
|
}
|
@@ -5592,7 +5739,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5592
5739
|
__publicField(Provider, "nodeInfoCache", {});
|
5593
5740
|
|
5594
5741
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5595
|
-
var
|
5742
|
+
var import_errors17 = require("@fuel-ts/errors");
|
5596
5743
|
var import_math19 = require("@fuel-ts/math");
|
5597
5744
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5598
5745
|
var import_utils27 = require("@fuel-ts/utils");
|
@@ -5602,8 +5749,8 @@ async function getTransactionSummary(params) {
|
|
5602
5749
|
transactionId: id
|
5603
5750
|
});
|
5604
5751
|
if (!gqlTransaction) {
|
5605
|
-
throw new
|
5606
|
-
|
5752
|
+
throw new import_errors17.FuelError(
|
5753
|
+
import_errors17.ErrorCode.TRANSACTION_NOT_FOUND,
|
5607
5754
|
`Transaction not found for given id: ${id}.`
|
5608
5755
|
);
|
5609
5756
|
}
|
@@ -5929,7 +6076,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5929
6076
|
*/
|
5930
6077
|
get provider() {
|
5931
6078
|
if (!this._provider) {
|
5932
|
-
throw new
|
6079
|
+
throw new import_errors18.FuelError(import_errors18.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
5933
6080
|
}
|
5934
6081
|
return this._provider;
|
5935
6082
|
}
|
@@ -6047,7 +6194,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6047
6194
|
);
|
6048
6195
|
request.addResources(resources);
|
6049
6196
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6050
|
-
const requestToReestimate2 = (0,
|
6197
|
+
const requestToReestimate2 = (0, import_ramda7.clone)(request);
|
6051
6198
|
if (addedSignatures) {
|
6052
6199
|
Array.from({ length: addedSignatures }).forEach(
|
6053
6200
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -6062,7 +6209,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6062
6209
|
gasPrice
|
6063
6210
|
});
|
6064
6211
|
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
6065
|
-
request.inputs,
|
6212
|
+
request.inputs.filter(isRequestInputResource),
|
6066
6213
|
baseAssetId,
|
6067
6214
|
baseAssetId
|
6068
6215
|
);
|
@@ -6080,13 +6227,13 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6080
6227
|
fundingAttempts += 1;
|
6081
6228
|
}
|
6082
6229
|
if (needsToBeFunded) {
|
6083
|
-
throw new
|
6084
|
-
|
6230
|
+
throw new import_errors18.FuelError(
|
6231
|
+
import_errors18.ErrorCode.NOT_ENOUGH_FUNDS,
|
6085
6232
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6086
6233
|
);
|
6087
6234
|
}
|
6088
6235
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6089
|
-
const requestToReestimate = (0,
|
6236
|
+
const requestToReestimate = (0, import_ramda7.clone)(request);
|
6090
6237
|
if (addedSignatures) {
|
6091
6238
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
6092
6239
|
}
|
@@ -6186,8 +6333,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6186
6333
|
*/
|
6187
6334
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6188
6335
|
if ((0, import_math21.bn)(amount).lte(0)) {
|
6189
|
-
throw new
|
6190
|
-
|
6336
|
+
throw new import_errors18.FuelError(
|
6337
|
+
import_errors18.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6191
6338
|
"Transfer amount must be a positive number."
|
6192
6339
|
);
|
6193
6340
|
}
|
@@ -6262,16 +6409,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6262
6409
|
* @returns A promise that resolves to the transaction cost object.
|
6263
6410
|
*/
|
6264
6411
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6265
|
-
const txRequestClone = (0,
|
6412
|
+
const txRequestClone = (0, import_ramda7.clone)(transactionRequestify(transactionRequestLike));
|
6266
6413
|
const baseAssetId = this.provider.getBaseAssetId();
|
6267
6414
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6268
6415
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
6269
6416
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
|
6270
6417
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6271
|
-
if (
|
6418
|
+
if (input.type === import_transactions22.InputType.Coin) {
|
6272
6419
|
return input.assetId === assetId;
|
6273
6420
|
}
|
6274
|
-
if (
|
6421
|
+
if (isRequestInputMessageWithoutData(input)) {
|
6275
6422
|
return baseAssetId === assetId;
|
6276
6423
|
}
|
6277
6424
|
return false;
|
@@ -6313,7 +6460,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6313
6460
|
*/
|
6314
6461
|
async signMessage(message) {
|
6315
6462
|
if (!this._connector) {
|
6316
|
-
throw new
|
6463
|
+
throw new import_errors18.FuelError(import_errors18.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6317
6464
|
}
|
6318
6465
|
return this._connector.signMessage(this.address.toString(), message);
|
6319
6466
|
}
|
@@ -6325,8 +6472,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6325
6472
|
*/
|
6326
6473
|
async signTransaction(transactionRequestLike) {
|
6327
6474
|
if (!this._connector) {
|
6328
|
-
throw new
|
6329
|
-
|
6475
|
+
throw new import_errors18.FuelError(
|
6476
|
+
import_errors18.ErrorCode.MISSING_CONNECTOR,
|
6330
6477
|
"A connector is required to sign transactions."
|
6331
6478
|
);
|
6332
6479
|
}
|
@@ -6385,8 +6532,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6385
6532
|
/** @hidden * */
|
6386
6533
|
validateTransferAmount(amount) {
|
6387
6534
|
if ((0, import_math21.bn)(amount).lte(0)) {
|
6388
|
-
throw new
|
6389
|
-
|
6535
|
+
throw new import_errors18.FuelError(
|
6536
|
+
import_errors18.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6390
6537
|
"Transfer amount must be a positive number."
|
6391
6538
|
);
|
6392
6539
|
}
|
@@ -6415,16 +6562,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6415
6562
|
if (!(0, import_utils30.isDefined)(setGasLimit)) {
|
6416
6563
|
request.gasLimit = gasUsed;
|
6417
6564
|
} else if (gasUsed.gt(setGasLimit)) {
|
6418
|
-
throw new
|
6419
|
-
|
6565
|
+
throw new import_errors18.FuelError(
|
6566
|
+
import_errors18.ErrorCode.GAS_LIMIT_TOO_LOW,
|
6420
6567
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6421
6568
|
);
|
6422
6569
|
}
|
6423
6570
|
if (!(0, import_utils30.isDefined)(setMaxFee)) {
|
6424
6571
|
request.maxFee = maxFee;
|
6425
6572
|
} else if (maxFee.gt(setMaxFee)) {
|
6426
|
-
throw new
|
6427
|
-
|
6573
|
+
throw new import_errors18.FuelError(
|
6574
|
+
import_errors18.ErrorCode.MAX_FEE_TOO_LOW,
|
6428
6575
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6429
6576
|
);
|
6430
6577
|
}
|
@@ -6548,7 +6695,7 @@ var Signer = class {
|
|
6548
6695
|
// src/wallet/keystore-wallet.ts
|
6549
6696
|
var import_address6 = require("@fuel-ts/address");
|
6550
6697
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6551
|
-
var
|
6698
|
+
var import_errors19 = require("@fuel-ts/errors");
|
6552
6699
|
var import_utils32 = require("@fuel-ts/utils");
|
6553
6700
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6554
6701
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6625,8 +6772,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6625
6772
|
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
6626
6773
|
const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
6627
6774
|
if (mac !== macHash) {
|
6628
|
-
throw new
|
6629
|
-
|
6775
|
+
throw new import_errors19.FuelError(
|
6776
|
+
import_errors19.ErrorCode.INVALID_PASSWORD,
|
6630
6777
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6631
6778
|
);
|
6632
6779
|
}
|
@@ -6756,14 +6903,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6756
6903
|
|
6757
6904
|
// src/hdwallet/hdwallet.ts
|
6758
6905
|
var import_crypto6 = require("@fuel-ts/crypto");
|
6759
|
-
var
|
6906
|
+
var import_errors22 = require("@fuel-ts/errors");
|
6760
6907
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6761
6908
|
var import_math23 = require("@fuel-ts/math");
|
6762
6909
|
var import_utils37 = require("@fuel-ts/utils");
|
6763
6910
|
|
6764
6911
|
// src/mnemonic/mnemonic.ts
|
6765
6912
|
var import_crypto5 = require("@fuel-ts/crypto");
|
6766
|
-
var
|
6913
|
+
var import_errors21 = require("@fuel-ts/errors");
|
6767
6914
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6768
6915
|
var import_utils35 = require("@fuel-ts/utils");
|
6769
6916
|
|
@@ -8826,7 +8973,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8826
8973
|
})(Language || {});
|
8827
8974
|
|
8828
8975
|
// src/mnemonic/utils.ts
|
8829
|
-
var
|
8976
|
+
var import_errors20 = require("@fuel-ts/errors");
|
8830
8977
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8831
8978
|
var import_utils34 = require("@fuel-ts/utils");
|
8832
8979
|
function getLowerMask(bits) {
|
@@ -8875,8 +9022,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8875
9022
|
for (let i = 0; i < words.length; i += 1) {
|
8876
9023
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8877
9024
|
if (index === -1) {
|
8878
|
-
throw new
|
8879
|
-
|
9025
|
+
throw new import_errors20.FuelError(
|
9026
|
+
import_errors20.ErrorCode.INVALID_MNEMONIC,
|
8880
9027
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8881
9028
|
);
|
8882
9029
|
}
|
@@ -8892,8 +9039,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8892
9039
|
const checksumMask = getUpperMask(checksumBits);
|
8893
9040
|
const checksum = (0, import_utils34.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8894
9041
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8895
|
-
throw new
|
8896
|
-
|
9042
|
+
throw new import_errors20.FuelError(
|
9043
|
+
import_errors20.ErrorCode.INVALID_CHECKSUM,
|
8897
9044
|
"Checksum validation failed for the provided mnemonic."
|
8898
9045
|
);
|
8899
9046
|
}
|
@@ -8907,16 +9054,16 @@ var TestnetPRV = "0x04358394";
|
|
8907
9054
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8908
9055
|
function assertWordList(wordlist) {
|
8909
9056
|
if (wordlist.length !== 2048) {
|
8910
|
-
throw new
|
8911
|
-
|
9057
|
+
throw new import_errors21.FuelError(
|
9058
|
+
import_errors21.ErrorCode.INVALID_WORD_LIST,
|
8912
9059
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8913
9060
|
);
|
8914
9061
|
}
|
8915
9062
|
}
|
8916
9063
|
function assertEntropy(entropy) {
|
8917
9064
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8918
|
-
throw new
|
8919
|
-
|
9065
|
+
throw new import_errors21.FuelError(
|
9066
|
+
import_errors21.ErrorCode.INVALID_ENTROPY,
|
8920
9067
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8921
9068
|
);
|
8922
9069
|
}
|
@@ -8926,7 +9073,7 @@ function assertMnemonic(words) {
|
|
8926
9073
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8927
9074
|
", "
|
8928
9075
|
)}] words, but got ${words.length}.`;
|
8929
|
-
throw new
|
9076
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
8930
9077
|
}
|
8931
9078
|
}
|
8932
9079
|
var Mnemonic = class {
|
@@ -9044,8 +9191,8 @@ var Mnemonic = class {
|
|
9044
9191
|
static masterKeysFromSeed(seed) {
|
9045
9192
|
const seedArray = (0, import_utils35.arrayify)(seed);
|
9046
9193
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9047
|
-
throw new
|
9048
|
-
|
9194
|
+
throw new import_errors21.FuelError(
|
9195
|
+
import_errors21.ErrorCode.INVALID_SEED,
|
9049
9196
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9050
9197
|
);
|
9051
9198
|
}
|
@@ -9122,7 +9269,7 @@ function isValidExtendedKey(extendedKey) {
|
|
9122
9269
|
function parsePath(path, depth = 0) {
|
9123
9270
|
const components = path.split("/");
|
9124
9271
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9125
|
-
throw new
|
9272
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
|
9126
9273
|
}
|
9127
9274
|
if (components[0] === "m") {
|
9128
9275
|
components.shift();
|
@@ -9151,8 +9298,8 @@ var HDWallet = class {
|
|
9151
9298
|
this.privateKey = (0, import_utils37.hexlify)(config.privateKey);
|
9152
9299
|
} else {
|
9153
9300
|
if (!config.publicKey) {
|
9154
|
-
throw new
|
9155
|
-
|
9301
|
+
throw new import_errors22.FuelError(
|
9302
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9156
9303
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9157
9304
|
);
|
9158
9305
|
}
|
@@ -9181,8 +9328,8 @@ var HDWallet = class {
|
|
9181
9328
|
const data = new Uint8Array(37);
|
9182
9329
|
if (index & HARDENED_INDEX) {
|
9183
9330
|
if (!privateKey) {
|
9184
|
-
throw new
|
9185
|
-
|
9331
|
+
throw new import_errors22.FuelError(
|
9332
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9186
9333
|
"Cannot derive a hardened index without a private Key."
|
9187
9334
|
);
|
9188
9335
|
}
|
@@ -9234,8 +9381,8 @@ var HDWallet = class {
|
|
9234
9381
|
*/
|
9235
9382
|
toExtendedKey(isPublic = false, testnet = false) {
|
9236
9383
|
if (this.depth >= 256) {
|
9237
|
-
throw new
|
9238
|
-
|
9384
|
+
throw new import_errors22.FuelError(
|
9385
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9239
9386
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9240
9387
|
);
|
9241
9388
|
}
|
@@ -9266,10 +9413,10 @@ var HDWallet = class {
|
|
9266
9413
|
const bytes = (0, import_utils37.arrayify)(decoded);
|
9267
9414
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9268
9415
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9269
|
-
throw new
|
9416
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9270
9417
|
}
|
9271
9418
|
if (!validChecksum) {
|
9272
|
-
throw new
|
9419
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9273
9420
|
}
|
9274
9421
|
const depth = bytes[4];
|
9275
9422
|
const parentFingerprint = (0, import_utils37.hexlify)(bytes.slice(5, 9));
|
@@ -9277,14 +9424,14 @@ var HDWallet = class {
|
|
9277
9424
|
const chainCode = (0, import_utils37.hexlify)(bytes.slice(13, 45));
|
9278
9425
|
const key = bytes.slice(45, 78);
|
9279
9426
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9280
|
-
throw new
|
9281
|
-
|
9427
|
+
throw new import_errors22.FuelError(
|
9428
|
+
import_errors22.ErrorCode.HD_WALLET_ERROR,
|
9282
9429
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9283
9430
|
);
|
9284
9431
|
}
|
9285
9432
|
if (isPublicExtendedKey(bytes)) {
|
9286
9433
|
if (key[0] !== 3) {
|
9287
|
-
throw new
|
9434
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
9288
9435
|
}
|
9289
9436
|
return new HDWallet({
|
9290
9437
|
publicKey: key,
|
@@ -9295,7 +9442,7 @@ var HDWallet = class {
|
|
9295
9442
|
});
|
9296
9443
|
}
|
9297
9444
|
if (key[0] !== 0) {
|
9298
|
-
throw new
|
9445
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
9299
9446
|
}
|
9300
9447
|
return new HDWallet({
|
9301
9448
|
privateKey: key.slice(1),
|
@@ -9463,7 +9610,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
9463
9610
|
// src/wallet-manager/wallet-manager.ts
|
9464
9611
|
var import_address9 = require("@fuel-ts/address");
|
9465
9612
|
var import_crypto7 = require("@fuel-ts/crypto");
|
9466
|
-
var
|
9613
|
+
var import_errors25 = require("@fuel-ts/errors");
|
9467
9614
|
var import_events = require("events");
|
9468
9615
|
|
9469
9616
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -9486,7 +9633,7 @@ var MemoryStorage = class {
|
|
9486
9633
|
|
9487
9634
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
9488
9635
|
var import_address7 = require("@fuel-ts/address");
|
9489
|
-
var
|
9636
|
+
var import_errors23 = require("@fuel-ts/errors");
|
9490
9637
|
var _secret;
|
9491
9638
|
var MnemonicVault = class {
|
9492
9639
|
constructor(options) {
|
@@ -9542,8 +9689,8 @@ var MnemonicVault = class {
|
|
9542
9689
|
}
|
9543
9690
|
numberOfAccounts += 1;
|
9544
9691
|
} while (numberOfAccounts < this.numberOfAccounts);
|
9545
|
-
throw new
|
9546
|
-
|
9692
|
+
throw new import_errors23.FuelError(
|
9693
|
+
import_errors23.ErrorCode.WALLET_MANAGER_ERROR,
|
9547
9694
|
`Account with address '${address}' not found in derived wallets.`
|
9548
9695
|
);
|
9549
9696
|
}
|
@@ -9557,7 +9704,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
9557
9704
|
|
9558
9705
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
9559
9706
|
var import_address8 = require("@fuel-ts/address");
|
9560
|
-
var
|
9707
|
+
var import_errors24 = require("@fuel-ts/errors");
|
9561
9708
|
var _privateKeys;
|
9562
9709
|
var PrivateKeyVault = class {
|
9563
9710
|
/**
|
@@ -9598,8 +9745,8 @@ var PrivateKeyVault = class {
|
|
9598
9745
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
9599
9746
|
);
|
9600
9747
|
if (!privateKey) {
|
9601
|
-
throw new
|
9602
|
-
|
9748
|
+
throw new import_errors24.FuelError(
|
9749
|
+
import_errors24.ErrorCode.WALLET_MANAGER_ERROR,
|
9603
9750
|
`No private key found for address '${address}'.`
|
9604
9751
|
);
|
9605
9752
|
}
|
@@ -9623,7 +9770,7 @@ var ERROR_MESSAGES = {
|
|
9623
9770
|
};
|
9624
9771
|
function assert(condition, message) {
|
9625
9772
|
if (!condition) {
|
9626
|
-
throw new
|
9773
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.WALLET_MANAGER_ERROR, message);
|
9627
9774
|
}
|
9628
9775
|
}
|
9629
9776
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -9849,25 +9996,25 @@ deserializeVaults_fn = function(vaults) {
|
|
9849
9996
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
9850
9997
|
|
9851
9998
|
// src/wallet-manager/types.ts
|
9852
|
-
var
|
9999
|
+
var import_errors26 = require("@fuel-ts/errors");
|
9853
10000
|
var Vault = class {
|
9854
10001
|
constructor(_options) {
|
9855
|
-
throw new
|
10002
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9856
10003
|
}
|
9857
10004
|
serialize() {
|
9858
|
-
throw new
|
10005
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9859
10006
|
}
|
9860
10007
|
getAccounts() {
|
9861
|
-
throw new
|
10008
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9862
10009
|
}
|
9863
10010
|
addAccount() {
|
9864
|
-
throw new
|
10011
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9865
10012
|
}
|
9866
10013
|
exportAccount(_address) {
|
9867
|
-
throw new
|
10014
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9868
10015
|
}
|
9869
10016
|
getWallet(_address) {
|
9870
|
-
throw new
|
10017
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9871
10018
|
}
|
9872
10019
|
};
|
9873
10020
|
__publicField(Vault, "type");
|
@@ -9877,7 +10024,7 @@ var StorageAbstract = class {
|
|
9877
10024
|
// src/predicate/predicate.ts
|
9878
10025
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
9879
10026
|
var import_address10 = require("@fuel-ts/address");
|
9880
|
-
var
|
10027
|
+
var import_errors27 = require("@fuel-ts/errors");
|
9881
10028
|
var import_utils39 = require("@fuel-ts/utils");
|
9882
10029
|
|
9883
10030
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9939,7 +10086,7 @@ var Predicate = class extends Account {
|
|
9939
10086
|
if (placeholderIndex !== -1) {
|
9940
10087
|
request.removeWitness(placeholderIndex);
|
9941
10088
|
}
|
9942
|
-
request.inputs.filter(
|
10089
|
+
request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
9943
10090
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9944
10091
|
input.predicate = (0, import_utils39.hexlify)(this.bytes);
|
9945
10092
|
input.predicateData = (0, import_utils39.hexlify)(this.getPredicateData());
|
@@ -9989,8 +10136,8 @@ var Predicate = class extends Account {
|
|
9989
10136
|
if (jsonAbi) {
|
9990
10137
|
abiInterface = new import_abi_coder8.Interface(jsonAbi);
|
9991
10138
|
if (abiInterface.functions.main === void 0) {
|
9992
|
-
throw new
|
9993
|
-
|
10139
|
+
throw new import_errors27.FuelError(
|
10140
|
+
import_errors27.ErrorCode.ABI_MAIN_METHOD_MISSING,
|
9994
10141
|
'Cannot use ABI without "main" function.'
|
9995
10142
|
);
|
9996
10143
|
}
|
@@ -10051,21 +10198,21 @@ var Predicate = class extends Account {
|
|
10051
10198
|
const mutatedBytes = bytes;
|
10052
10199
|
try {
|
10053
10200
|
if (!abiInterface) {
|
10054
|
-
throw new
|
10055
|
-
|
10201
|
+
throw new import_errors27.FuelError(
|
10202
|
+
import_errors27.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10056
10203
|
"Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
|
10057
10204
|
);
|
10058
10205
|
}
|
10059
10206
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
10060
|
-
throw new
|
10061
|
-
|
10207
|
+
throw new import_errors27.FuelError(
|
10208
|
+
import_errors27.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10062
10209
|
"Predicate has no configurable constants to be set"
|
10063
10210
|
);
|
10064
10211
|
}
|
10065
10212
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
10066
10213
|
if (!abiInterface?.configurables[key]) {
|
10067
|
-
throw new
|
10068
|
-
|
10214
|
+
throw new import_errors27.FuelError(
|
10215
|
+
import_errors27.ErrorCode.CONFIGURABLE_NOT_FOUND,
|
10069
10216
|
`No configurable constant named '${key}' found in the Predicate`
|
10070
10217
|
);
|
10071
10218
|
}
|
@@ -10074,8 +10221,8 @@ var Predicate = class extends Account {
|
|
10074
10221
|
mutatedBytes.set(encoded, offset);
|
10075
10222
|
});
|
10076
10223
|
} catch (err) {
|
10077
|
-
throw new
|
10078
|
-
|
10224
|
+
throw new import_errors27.FuelError(
|
10225
|
+
import_errors27.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10079
10226
|
`Error setting configurable constants: ${err.message}.`
|
10080
10227
|
);
|
10081
10228
|
}
|
@@ -10106,10 +10253,10 @@ var Predicate = class extends Account {
|
|
10106
10253
|
};
|
10107
10254
|
|
10108
10255
|
// src/connectors/fuel.ts
|
10109
|
-
var
|
10256
|
+
var import_errors30 = require("@fuel-ts/errors");
|
10110
10257
|
|
10111
10258
|
// src/connectors/fuel-connector.ts
|
10112
|
-
var
|
10259
|
+
var import_errors28 = require("@fuel-ts/errors");
|
10113
10260
|
var import_events2 = require("events");
|
10114
10261
|
|
10115
10262
|
// src/connectors/types/connector-types.ts
|
@@ -10183,7 +10330,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10183
10330
|
* @returns Always true.
|
10184
10331
|
*/
|
10185
10332
|
async ping() {
|
10186
|
-
throw new
|
10333
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10187
10334
|
}
|
10188
10335
|
/**
|
10189
10336
|
* Should return the current version of the connector
|
@@ -10192,7 +10339,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10192
10339
|
* @returns boolean - connection status.
|
10193
10340
|
*/
|
10194
10341
|
async version() {
|
10195
|
-
throw new
|
10342
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10196
10343
|
}
|
10197
10344
|
/**
|
10198
10345
|
* Should return true if the connector is connected
|
@@ -10201,7 +10348,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10201
10348
|
* @returns The connection status.
|
10202
10349
|
*/
|
10203
10350
|
async isConnected() {
|
10204
|
-
throw new
|
10351
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10205
10352
|
}
|
10206
10353
|
/**
|
10207
10354
|
* Should return all the accounts authorized for the
|
@@ -10210,7 +10357,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10210
10357
|
* @returns The accounts addresses strings
|
10211
10358
|
*/
|
10212
10359
|
async accounts() {
|
10213
|
-
throw new
|
10360
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10214
10361
|
}
|
10215
10362
|
/**
|
10216
10363
|
* Should start the connection process and return
|
@@ -10222,7 +10369,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10222
10369
|
* @returns boolean - connection status.
|
10223
10370
|
*/
|
10224
10371
|
async connect() {
|
10225
|
-
throw new
|
10372
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10226
10373
|
}
|
10227
10374
|
/**
|
10228
10375
|
* Should disconnect the current connection and
|
@@ -10232,7 +10379,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10232
10379
|
* @returns The connection status.
|
10233
10380
|
*/
|
10234
10381
|
async disconnect() {
|
10235
|
-
throw new
|
10382
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10236
10383
|
}
|
10237
10384
|
/**
|
10238
10385
|
* Should start the sign message process and return
|
@@ -10244,7 +10391,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10244
10391
|
* @returns Message signature
|
10245
10392
|
*/
|
10246
10393
|
async signMessage(_address, _message) {
|
10247
|
-
throw new
|
10394
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10248
10395
|
}
|
10249
10396
|
/**
|
10250
10397
|
* Should start the sign transaction process and return
|
@@ -10256,7 +10403,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10256
10403
|
* @returns Transaction signature
|
10257
10404
|
*/
|
10258
10405
|
async signTransaction(_address, _transaction) {
|
10259
|
-
throw new
|
10406
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10260
10407
|
}
|
10261
10408
|
/**
|
10262
10409
|
* Should start the send transaction process and return
|
@@ -10272,7 +10419,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10272
10419
|
* @returns The transaction id
|
10273
10420
|
*/
|
10274
10421
|
async sendTransaction(_address, _transaction) {
|
10275
|
-
throw new
|
10422
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10276
10423
|
}
|
10277
10424
|
/**
|
10278
10425
|
* Should return the current account selected inside the connector, if the account
|
@@ -10283,7 +10430,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10283
10430
|
* @returns The current account selected otherwise null.
|
10284
10431
|
*/
|
10285
10432
|
async currentAccount() {
|
10286
|
-
throw new
|
10433
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10287
10434
|
}
|
10288
10435
|
/**
|
10289
10436
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -10297,7 +10444,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10297
10444
|
* @returns True if the asset was added successfully
|
10298
10445
|
*/
|
10299
10446
|
async addAssets(_assets) {
|
10300
|
-
throw new
|
10447
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10301
10448
|
}
|
10302
10449
|
/**
|
10303
10450
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -10311,7 +10458,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10311
10458
|
* @returns True if the asset was added successfully
|
10312
10459
|
*/
|
10313
10460
|
async addAsset(_asset) {
|
10314
|
-
throw new
|
10461
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10315
10462
|
}
|
10316
10463
|
/**
|
10317
10464
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -10319,7 +10466,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10319
10466
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
10320
10467
|
*/
|
10321
10468
|
async assets() {
|
10322
|
-
throw new
|
10469
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10323
10470
|
}
|
10324
10471
|
/**
|
10325
10472
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -10330,7 +10477,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10330
10477
|
* @returns Return true if the network was added successfully
|
10331
10478
|
*/
|
10332
10479
|
async addNetwork(_networkUrl) {
|
10333
|
-
throw new
|
10480
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10334
10481
|
}
|
10335
10482
|
/**
|
10336
10483
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -10341,7 +10488,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10341
10488
|
* @returns Return true if the network was added successfully
|
10342
10489
|
*/
|
10343
10490
|
async selectNetwork(_network) {
|
10344
|
-
throw new
|
10491
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10345
10492
|
}
|
10346
10493
|
/**
|
10347
10494
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -10349,7 +10496,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10349
10496
|
* @returns Return all the networks added to the connector.
|
10350
10497
|
*/
|
10351
10498
|
async networks() {
|
10352
|
-
throw new
|
10499
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10353
10500
|
}
|
10354
10501
|
/**
|
10355
10502
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -10357,7 +10504,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10357
10504
|
* @returns Return the current network selected inside the connector.
|
10358
10505
|
*/
|
10359
10506
|
async currentNetwork() {
|
10360
|
-
throw new
|
10507
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10361
10508
|
}
|
10362
10509
|
/**
|
10363
10510
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -10367,7 +10514,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10367
10514
|
* @returns Return true if the ABI was added successfully.
|
10368
10515
|
*/
|
10369
10516
|
async addABI(_contractId, _abi) {
|
10370
|
-
throw new
|
10517
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10371
10518
|
}
|
10372
10519
|
/**
|
10373
10520
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10376,7 +10523,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10376
10523
|
* @returns The ABI if it exists, otherwise return null.
|
10377
10524
|
*/
|
10378
10525
|
async getABI(_id) {
|
10379
|
-
throw new
|
10526
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10380
10527
|
}
|
10381
10528
|
/**
|
10382
10529
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10385,7 +10532,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10385
10532
|
* @returns Returns true if the abi exists or false if not.
|
10386
10533
|
*/
|
10387
10534
|
async hasABI(_id) {
|
10388
|
-
throw new
|
10535
|
+
throw new import_errors28.FuelError(import_errors28.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10389
10536
|
}
|
10390
10537
|
/**
|
10391
10538
|
* Event listener for the connector.
|
@@ -10429,7 +10576,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
10429
10576
|
}
|
10430
10577
|
|
10431
10578
|
// src/connectors/utils/promises.ts
|
10432
|
-
var
|
10579
|
+
var import_errors29 = require("@fuel-ts/errors");
|
10433
10580
|
function deferPromise() {
|
10434
10581
|
const defer = {};
|
10435
10582
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -10441,7 +10588,7 @@ function deferPromise() {
|
|
10441
10588
|
async function withTimeout(promise, timeout = 1050) {
|
10442
10589
|
const timeoutPromise = new Promise((resolve, reject) => {
|
10443
10590
|
setTimeout(() => {
|
10444
|
-
reject(new
|
10591
|
+
reject(new import_errors29.FuelError(import_errors29.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
10445
10592
|
}, timeout);
|
10446
10593
|
});
|
10447
10594
|
return Promise.race([timeoutPromise, promise]);
|
@@ -10475,7 +10622,7 @@ var _Fuel = class extends FuelConnector {
|
|
10475
10622
|
await this.setDefaultConnector();
|
10476
10623
|
this._targetUnsubscribe = this.setupConnectorListener();
|
10477
10624
|
} catch (error) {
|
10478
|
-
throw new
|
10625
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.INVALID_PROVIDER, "Error initializing Fuel Connector");
|
10479
10626
|
}
|
10480
10627
|
}
|
10481
10628
|
async init() {
|
@@ -10541,8 +10688,8 @@ var _Fuel = class extends FuelConnector {
|
|
10541
10688
|
const hasConnector = await this.hasConnector();
|
10542
10689
|
await this.pingConnector();
|
10543
10690
|
if (!this._currentConnector || !hasConnector) {
|
10544
|
-
throw new
|
10545
|
-
|
10691
|
+
throw new import_errors30.FuelError(
|
10692
|
+
import_errors30.ErrorCode.MISSING_CONNECTOR,
|
10546
10693
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
10547
10694
|
);
|
10548
10695
|
}
|
@@ -10606,7 +10753,7 @@ var _Fuel = class extends FuelConnector {
|
|
10606
10753
|
cacheTime: PING_CACHE_TIME
|
10607
10754
|
})();
|
10608
10755
|
} catch {
|
10609
|
-
throw new
|
10756
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.INVALID_PROVIDER, "Current connector is not available.");
|
10610
10757
|
}
|
10611
10758
|
}
|
10612
10759
|
/**
|
@@ -10755,7 +10902,7 @@ var _Fuel = class extends FuelConnector {
|
|
10755
10902
|
const currentNetwork = await this.currentNetwork();
|
10756
10903
|
provider = await Provider.create(currentNetwork.url);
|
10757
10904
|
} else {
|
10758
|
-
throw new
|
10905
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
|
10759
10906
|
}
|
10760
10907
|
return provider;
|
10761
10908
|
}
|
@@ -10911,10 +11058,13 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10911
11058
|
isCoin,
|
10912
11059
|
isInputCoin,
|
10913
11060
|
isMessage,
|
11061
|
+
isMessageCoin,
|
10914
11062
|
isRawCoin,
|
10915
11063
|
isRawMessage,
|
10916
11064
|
isRequestInputCoin,
|
11065
|
+
isRequestInputCoinOrMessage,
|
10917
11066
|
isRequestInputMessage,
|
11067
|
+
isRequestInputMessageWithoutData,
|
10918
11068
|
isRequestInputResource,
|
10919
11069
|
isRequestInputResourceFromOwner,
|
10920
11070
|
isTransactionTypeBlob,
|