@fuel-ts/account 0.75.0 → 0.77.0
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.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/account.d.ts.map +1 -1
- package/dist/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +1002 -2498
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +92 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +156 -140
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts +16 -15
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +47 -38
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/index.d.ts +1 -0
- package/dist/providers/assets/index.d.ts.map +1 -1
- package/dist/providers/assets/types.d.ts +5 -5
- package/dist/providers/assets/types.d.ts.map +1 -1
- package/dist/providers/assets/utils/network.d.ts +4 -4
- package/dist/providers/assets/utils/network.d.ts.map +1 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +24 -15
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/index.d.ts +0 -1
- package/dist/providers/transaction-summary/index.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +0 -1
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils.global.js +976 -2469
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +68 -40
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +113 -93
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/providers/transaction-summary/date.d.ts +0 -3
- package/dist/providers/transaction-summary/date.d.ts.map +0 -1
- package/dist/providers/utils/time.d.ts +0 -40
- package/dist/providers/utils/time.d.ts.map +0 -1
package/dist/test-utils.mjs
CHANGED
@@ -25,7 +25,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
|
25
25
|
// src/account.ts
|
26
26
|
import { Address as Address3 } from "@fuel-ts/address";
|
27
27
|
import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
28
|
-
import { ErrorCode as
|
28
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
29
29
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
30
30
|
import { bn as bn16 } from "@fuel-ts/math";
|
31
31
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
@@ -68,7 +68,7 @@ var addAmountToAsset = (params) => {
|
|
68
68
|
|
69
69
|
// src/providers/provider.ts
|
70
70
|
import { Address as Address2 } from "@fuel-ts/address";
|
71
|
-
import { ErrorCode as
|
71
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
72
72
|
import { BN, bn as bn14, max } from "@fuel-ts/math";
|
73
73
|
import {
|
74
74
|
InputType as InputType6,
|
@@ -76,7 +76,7 @@ import {
|
|
76
76
|
InputMessageCoder,
|
77
77
|
TransactionCoder as TransactionCoder5
|
78
78
|
} from "@fuel-ts/transactions";
|
79
|
-
import { arrayify as arrayify11, hexlify as hexlify12 } from "@fuel-ts/utils";
|
79
|
+
import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
|
80
80
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
81
81
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
82
82
|
import { Network } from "ethers";
|
@@ -144,6 +144,9 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
144
144
|
time
|
145
145
|
reason
|
146
146
|
}
|
147
|
+
... on SqueezedOutStatus {
|
148
|
+
reason
|
149
|
+
}
|
147
150
|
}
|
148
151
|
`;
|
149
152
|
var TransactionFragmentFragmentDoc = gql`
|
@@ -886,7 +889,7 @@ function getSdk(requester) {
|
|
886
889
|
}
|
887
890
|
|
888
891
|
// src/providers/fuel-graphql-subscriber.ts
|
889
|
-
import { FuelError } from "@fuel-ts/errors";
|
892
|
+
import { ErrorCode, FuelError } from "@fuel-ts/errors";
|
890
893
|
import { print } from "graphql";
|
891
894
|
var _FuelGraphqlSubscriber = class {
|
892
895
|
constructor(options) {
|
@@ -921,7 +924,16 @@ var _FuelGraphqlSubscriber = class {
|
|
921
924
|
if (!text.startsWith("data:")) {
|
922
925
|
continue;
|
923
926
|
}
|
924
|
-
|
927
|
+
let data;
|
928
|
+
let errors;
|
929
|
+
try {
|
930
|
+
({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
|
931
|
+
} catch (e) {
|
932
|
+
throw new FuelError(
|
933
|
+
ErrorCode.STREAM_PARSING_ERROR,
|
934
|
+
`Error while parsing stream data response: ${text}`
|
935
|
+
);
|
936
|
+
}
|
925
937
|
if (Array.isArray(errors)) {
|
926
938
|
throw new FuelError(
|
927
939
|
FuelError.CODES.INVALID_REQUEST,
|
@@ -947,7 +959,7 @@ var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
|
947
959
|
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
948
960
|
|
949
961
|
// src/providers/memory-cache.ts
|
950
|
-
import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
|
962
|
+
import { ErrorCode as ErrorCode2, FuelError as FuelError2 } from "@fuel-ts/errors";
|
951
963
|
import { hexlify as hexlify2 } from "@fuel-ts/utils";
|
952
964
|
var cache = {};
|
953
965
|
var DEFAULT_TTL_IN_MS = 30 * 1e3;
|
@@ -957,7 +969,7 @@ var MemoryCache = class {
|
|
957
969
|
this.ttl = ttlInMs;
|
958
970
|
if (typeof ttlInMs !== "number" || this.ttl <= 0) {
|
959
971
|
throw new FuelError2(
|
960
|
-
|
972
|
+
ErrorCode2.INVALID_TTL,
|
961
973
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
962
974
|
);
|
963
975
|
}
|
@@ -1007,7 +1019,7 @@ var MemoryCache = class {
|
|
1007
1019
|
|
1008
1020
|
// src/providers/transaction-request/input.ts
|
1009
1021
|
import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
1010
|
-
import { ErrorCode as
|
1022
|
+
import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1011
1023
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1012
1024
|
import { InputType } from "@fuel-ts/transactions";
|
1013
1025
|
import { arrayify, hexlify as hexlify3 } from "@fuel-ts/utils";
|
@@ -1073,7 +1085,7 @@ var inputify = (value) => {
|
|
1073
1085
|
}
|
1074
1086
|
default: {
|
1075
1087
|
throw new FuelError3(
|
1076
|
-
|
1088
|
+
ErrorCode3.INVALID_TRANSACTION_INPUT,
|
1077
1089
|
`Invalid transaction input type: ${type}.`
|
1078
1090
|
);
|
1079
1091
|
}
|
@@ -1082,7 +1094,7 @@ var inputify = (value) => {
|
|
1082
1094
|
|
1083
1095
|
// src/providers/transaction-request/output.ts
|
1084
1096
|
import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
1085
|
-
import { ErrorCode as
|
1097
|
+
import { ErrorCode as ErrorCode4, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1086
1098
|
import { bn as bn3 } from "@fuel-ts/math";
|
1087
1099
|
import { OutputType } from "@fuel-ts/transactions";
|
1088
1100
|
import { hexlify as hexlify4 } from "@fuel-ts/utils";
|
@@ -1130,7 +1142,7 @@ var outputify = (value) => {
|
|
1130
1142
|
}
|
1131
1143
|
default: {
|
1132
1144
|
throw new FuelError4(
|
1133
|
-
|
1145
|
+
ErrorCode4.INVALID_TRANSACTION_INPUT,
|
1134
1146
|
`Invalid transaction output type: ${type}.`
|
1135
1147
|
);
|
1136
1148
|
}
|
@@ -1155,7 +1167,7 @@ var isCoin = (resource) => "id" in resource;
|
|
1155
1167
|
|
1156
1168
|
// src/providers/utils/receipts.ts
|
1157
1169
|
import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
|
1158
|
-
import { ErrorCode as
|
1170
|
+
import { ErrorCode as ErrorCode5, FuelError as FuelError5 } from "@fuel-ts/errors";
|
1159
1171
|
import { bn as bn4 } from "@fuel-ts/math";
|
1160
1172
|
import {
|
1161
1173
|
ReceiptBurnCoder,
|
@@ -1360,12 +1372,12 @@ function assembleReceiptByType(receipt) {
|
|
1360
1372
|
return burnReceipt;
|
1361
1373
|
}
|
1362
1374
|
default:
|
1363
|
-
throw new FuelError5(
|
1375
|
+
throw new FuelError5(ErrorCode5.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
1364
1376
|
}
|
1365
1377
|
}
|
1366
1378
|
|
1367
1379
|
// src/providers/utils/block-explorer.ts
|
1368
|
-
import { ErrorCode as
|
1380
|
+
import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/errors";
|
1369
1381
|
|
1370
1382
|
// src/providers/utils/gas.ts
|
1371
1383
|
import { bn as bn5 } from "@fuel-ts/math";
|
@@ -1483,9 +1495,6 @@ function sleep(time) {
|
|
1483
1495
|
});
|
1484
1496
|
}
|
1485
1497
|
|
1486
|
-
// src/providers/utils/time.ts
|
1487
|
-
var fromUnixToTai64 = (unixTimestampMs) => (BigInt(unixTimestampMs) + BigInt(2 ** 62) + BigInt(10)).toString();
|
1488
|
-
|
1489
1498
|
// src/providers/transaction-request/errors.ts
|
1490
1499
|
var NoWitnessAtIndexError = class extends Error {
|
1491
1500
|
constructor(index) {
|
@@ -1727,7 +1736,7 @@ var BaseTransactionRequest = class {
|
|
1727
1736
|
txPointer: "0x00000000000000000000000000000000",
|
1728
1737
|
witnessIndex,
|
1729
1738
|
predicate: predicate?.bytes,
|
1730
|
-
predicateData: predicate?.
|
1739
|
+
predicateData: predicate?.predicateDataBytes
|
1731
1740
|
};
|
1732
1741
|
this.pushInput(input);
|
1733
1742
|
this.addChangeOutput(owner, assetId);
|
@@ -1760,7 +1769,7 @@ var BaseTransactionRequest = class {
|
|
1760
1769
|
amount,
|
1761
1770
|
witnessIndex,
|
1762
1771
|
predicate: predicate?.bytes,
|
1763
|
-
predicateData: predicate?.
|
1772
|
+
predicateData: predicate?.predicateDataBytes
|
1764
1773
|
};
|
1765
1774
|
this.pushInput(input);
|
1766
1775
|
this.addChangeOutput(recipient, assetId);
|
@@ -2003,11 +2012,10 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
|
2003
2012
|
|
2004
2013
|
// src/providers/transaction-request/hash-transaction.ts
|
2005
2014
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2006
|
-
import { uint64ToBytesBE } from "@fuel-ts/hasher";
|
2015
|
+
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2007
2016
|
import { bn as bn7 } from "@fuel-ts/math";
|
2008
2017
|
import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2009
2018
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2010
|
-
import { sha256 } from "ethers";
|
2011
2019
|
import { clone as clone2 } from "ramda";
|
2012
2020
|
function hashTransaction(transactionRequest, chainId) {
|
2013
2021
|
const transaction = transactionRequest.toTransaction();
|
@@ -2394,7 +2402,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2394
2402
|
};
|
2395
2403
|
|
2396
2404
|
// src/providers/transaction-request/utils.ts
|
2397
|
-
import { ErrorCode as
|
2405
|
+
import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
|
2398
2406
|
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2399
2407
|
var transactionRequestify = (obj) => {
|
2400
2408
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
@@ -2409,19 +2417,19 @@ var transactionRequestify = (obj) => {
|
|
2409
2417
|
return CreateTransactionRequest.from(obj);
|
2410
2418
|
}
|
2411
2419
|
default: {
|
2412
|
-
throw new FuelError7(
|
2420
|
+
throw new FuelError7(ErrorCode7.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
|
2413
2421
|
}
|
2414
2422
|
}
|
2415
2423
|
};
|
2416
2424
|
|
2417
2425
|
// src/providers/transaction-response/transaction-response.ts
|
2418
|
-
import { ErrorCode as
|
2426
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
2419
2427
|
import { bn as bn13 } from "@fuel-ts/math";
|
2420
2428
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2421
2429
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2422
2430
|
|
2423
2431
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2424
|
-
import { hexlify as hexlify11 } from "@fuel-ts/utils";
|
2432
|
+
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2425
2433
|
|
2426
2434
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2427
2435
|
import { bn as bn10 } from "@fuel-ts/math";
|
@@ -2496,16 +2504,9 @@ var calculateTransactionFee = (params) => {
|
|
2496
2504
|
};
|
2497
2505
|
};
|
2498
2506
|
|
2499
|
-
// src/providers/transaction-summary/date.ts
|
2500
|
-
import { TAI64 } from "tai64";
|
2501
|
-
var fromTai64ToDate = (tai64Timestamp) => {
|
2502
|
-
const timestamp = TAI64.fromString(tai64Timestamp, 10).toUnix();
|
2503
|
-
return new Date(timestamp * 1e3);
|
2504
|
-
};
|
2505
|
-
|
2506
2507
|
// src/providers/transaction-summary/operations.ts
|
2507
2508
|
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
2508
|
-
import { ErrorCode as
|
2509
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2509
2510
|
import { bn as bn12 } from "@fuel-ts/math";
|
2510
2511
|
import { ReceiptType as ReceiptType3, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2511
2512
|
|
@@ -2554,7 +2555,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2554
2555
|
};
|
2555
2556
|
|
2556
2557
|
// src/providers/transaction-summary/input.ts
|
2557
|
-
import { ErrorCode as
|
2558
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2558
2559
|
import { InputType as InputType5 } from "@fuel-ts/transactions";
|
2559
2560
|
function getInputsByTypes(inputs, types) {
|
2560
2561
|
return inputs.filter((i) => types.includes(i.type));
|
@@ -2593,7 +2594,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2593
2594
|
}
|
2594
2595
|
if (contractInput.type !== InputType5.Contract) {
|
2595
2596
|
throw new FuelError8(
|
2596
|
-
|
2597
|
+
ErrorCode8.INVALID_TRANSACTION_INPUT,
|
2597
2598
|
`Contract input should be of type 'contract'.`
|
2598
2599
|
);
|
2599
2600
|
}
|
@@ -2641,7 +2642,7 @@ function getTransactionTypeName(transactionType) {
|
|
2641
2642
|
return "Script" /* Script */;
|
2642
2643
|
default:
|
2643
2644
|
throw new FuelError9(
|
2644
|
-
|
2645
|
+
ErrorCode9.INVALID_TRANSACTION_TYPE,
|
2645
2646
|
`Invalid transaction type: ${transactionType}.`
|
2646
2647
|
);
|
2647
2648
|
}
|
@@ -2998,7 +2999,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
2998
2999
|
};
|
2999
3000
|
|
3000
3001
|
// src/providers/transaction-summary/status.ts
|
3001
|
-
import { ErrorCode as
|
3002
|
+
import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
|
3002
3003
|
var getTransactionStatusName = (gqlStatus) => {
|
3003
3004
|
switch (gqlStatus) {
|
3004
3005
|
case "FailureStatus":
|
@@ -3011,7 +3012,7 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3011
3012
|
return "squeezedout" /* squeezedout */;
|
3012
3013
|
default:
|
3013
3014
|
throw new FuelError10(
|
3014
|
-
|
3015
|
+
ErrorCode10.INVALID_TRANSACTION_STATUS,
|
3015
3016
|
`Invalid transaction status: ${gqlStatus}.`
|
3016
3017
|
);
|
3017
3018
|
}
|
@@ -3096,7 +3097,7 @@ function assembleTransactionSummary(params) {
|
|
3096
3097
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3097
3098
|
let date;
|
3098
3099
|
if (time) {
|
3099
|
-
date =
|
3100
|
+
date = DateTime.fromTai64(time);
|
3100
3101
|
}
|
3101
3102
|
const transactionSummary = {
|
3102
3103
|
id,
|
@@ -3231,6 +3232,12 @@ var TransactionResponse = class {
|
|
3231
3232
|
transactionId: this.id
|
3232
3233
|
});
|
3233
3234
|
for await (const { statusChange } of subscription) {
|
3235
|
+
if (statusChange.type === "SqueezedOutStatus") {
|
3236
|
+
throw new FuelError11(
|
3237
|
+
ErrorCode11.TRANSACTION_SQUEEZED_OUT,
|
3238
|
+
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
3239
|
+
);
|
3240
|
+
}
|
3234
3241
|
if (statusChange.type !== "SubmittedStatus") {
|
3235
3242
|
break;
|
3236
3243
|
}
|
@@ -3260,7 +3267,7 @@ var TransactionResponse = class {
|
|
3260
3267
|
const result = await this.waitForResult(contractsAbiMap);
|
3261
3268
|
if (result.isStatusFailure) {
|
3262
3269
|
throw new FuelError11(
|
3263
|
-
|
3270
|
+
ErrorCode11.TRANSACTION_FAILED,
|
3264
3271
|
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
3265
3272
|
);
|
3266
3273
|
}
|
@@ -3269,7 +3276,7 @@ var TransactionResponse = class {
|
|
3269
3276
|
};
|
3270
3277
|
|
3271
3278
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3272
|
-
import {
|
3279
|
+
import { BigNumberCoder } from "@fuel-ts/abi-coder";
|
3273
3280
|
import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
|
3274
3281
|
|
3275
3282
|
// src/providers/utils/auto-retry-fetch.ts
|
@@ -3395,14 +3402,15 @@ var _Provider = class {
|
|
3395
3402
|
}
|
3396
3403
|
static getFetchFn(options) {
|
3397
3404
|
const { retryOptions, timeout } = options;
|
3398
|
-
return autoRetryFetch((...args) => {
|
3399
|
-
if (options.fetch) {
|
3400
|
-
return options.fetch(...args);
|
3401
|
-
}
|
3405
|
+
return autoRetryFetch(async (...args) => {
|
3402
3406
|
const url = args[0];
|
3403
3407
|
const request = args[1];
|
3404
3408
|
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
3405
|
-
|
3409
|
+
let fullRequest = { ...request, signal };
|
3410
|
+
if (options.requestMiddleware) {
|
3411
|
+
fullRequest = await options.requestMiddleware(fullRequest);
|
3412
|
+
}
|
3413
|
+
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
3406
3414
|
}, retryOptions);
|
3407
3415
|
}
|
3408
3416
|
/**
|
@@ -3422,7 +3430,7 @@ var _Provider = class {
|
|
3422
3430
|
const chain = _Provider.chainInfoCache[this.url];
|
3423
3431
|
if (!chain) {
|
3424
3432
|
throw new FuelError12(
|
3425
|
-
|
3433
|
+
ErrorCode12.CHAIN_INFO_CACHE_EMPTY,
|
3426
3434
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3427
3435
|
);
|
3428
3436
|
}
|
@@ -3435,7 +3443,7 @@ var _Provider = class {
|
|
3435
3443
|
const node = _Provider.nodeInfoCache[this.url];
|
3436
3444
|
if (!node) {
|
3437
3445
|
throw new FuelError12(
|
3438
|
-
|
3446
|
+
ErrorCode12.NODE_INFO_CACHE_EMPTY,
|
3439
3447
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3440
3448
|
);
|
3441
3449
|
}
|
@@ -3608,6 +3616,12 @@ var _Provider = class {
|
|
3608
3616
|
if (awaitExecution) {
|
3609
3617
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3610
3618
|
for await (const { submitAndAwait } of subscription) {
|
3619
|
+
if (submitAndAwait.type === "SqueezedOutStatus") {
|
3620
|
+
throw new FuelError12(
|
3621
|
+
ErrorCode12.TRANSACTION_SQUEEZED_OUT,
|
3622
|
+
`Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
|
3623
|
+
);
|
3624
|
+
}
|
3611
3625
|
if (submitAndAwait.type !== "SubmittedStatus") {
|
3612
3626
|
break;
|
3613
3627
|
}
|
@@ -4118,7 +4132,7 @@ var _Provider = class {
|
|
4118
4132
|
};
|
4119
4133
|
if (commitBlockId && commitBlockHeight) {
|
4120
4134
|
throw new FuelError12(
|
4121
|
-
|
4135
|
+
ErrorCode12.INVALID_INPUT_PARAMETERS,
|
4122
4136
|
"commitBlockId and commitBlockHeight cannot be used together"
|
4123
4137
|
);
|
4124
4138
|
}
|
@@ -4204,13 +4218,13 @@ var _Provider = class {
|
|
4204
4218
|
* Lets you produce blocks with custom timestamps and the block number of the last block produced.
|
4205
4219
|
*
|
4206
4220
|
* @param amount - The amount of blocks to produce
|
4207
|
-
* @param startTime - The UNIX timestamp to set for the first produced block
|
4221
|
+
* @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
|
4208
4222
|
* @returns A promise that resolves to the block number of the last produced block.
|
4209
4223
|
*/
|
4210
4224
|
async produceBlocks(amount, startTime) {
|
4211
4225
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4212
4226
|
blocksToProduce: bn14(amount).toString(10),
|
4213
|
-
startTimestamp: startTime ?
|
4227
|
+
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4214
4228
|
});
|
4215
4229
|
return bn14(latestBlockHeight);
|
4216
4230
|
}
|
@@ -4235,7 +4249,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
4235
4249
|
__publicField(Provider, "nodeInfoCache", {});
|
4236
4250
|
|
4237
4251
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4238
|
-
import { ErrorCode as
|
4252
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
4239
4253
|
import { bn as bn15 } from "@fuel-ts/math";
|
4240
4254
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4241
4255
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
@@ -4286,13 +4300,13 @@ var assets = [
|
|
4286
4300
|
];
|
4287
4301
|
|
4288
4302
|
// src/utils/formatTransferToContractScriptData.ts
|
4289
|
-
import {
|
4303
|
+
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
4290
4304
|
import { BN as BN2 } from "@fuel-ts/math";
|
4291
4305
|
import { arrayify as arrayify13 } from "@fuel-ts/utils";
|
4292
4306
|
import * as asm from "@fuels/vm-asm";
|
4293
4307
|
var formatTransferToContractScriptData = (params) => {
|
4294
4308
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4295
|
-
const numberCoder = new
|
4309
|
+
const numberCoder = new BigNumberCoder2("u64");
|
4296
4310
|
const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
|
4297
4311
|
const scriptData = Uint8Array.from([
|
4298
4312
|
...arrayify13(hexlifiedContractId),
|
@@ -4353,7 +4367,7 @@ var Account = class extends AbstractAccount {
|
|
4353
4367
|
*/
|
4354
4368
|
get provider() {
|
4355
4369
|
if (!this._provider) {
|
4356
|
-
throw new FuelError14(
|
4370
|
+
throw new FuelError14(ErrorCode14.MISSING_PROVIDER, "Provider not set");
|
4357
4371
|
}
|
4358
4372
|
return this._provider;
|
4359
4373
|
}
|
@@ -4406,7 +4420,7 @@ var Account = class extends AbstractAccount {
|
|
4406
4420
|
break;
|
4407
4421
|
}
|
4408
4422
|
throw new FuelError14(
|
4409
|
-
|
4423
|
+
ErrorCode14.NOT_SUPPORTED,
|
4410
4424
|
`Wallets containing more than ${pageSize} coins exceed the current supported limit.`
|
4411
4425
|
);
|
4412
4426
|
}
|
@@ -4432,7 +4446,7 @@ var Account = class extends AbstractAccount {
|
|
4432
4446
|
break;
|
4433
4447
|
}
|
4434
4448
|
throw new FuelError14(
|
4435
|
-
|
4449
|
+
ErrorCode14.NOT_SUPPORTED,
|
4436
4450
|
`Wallets containing more than ${pageSize} messages exceed the current supported limit.`
|
4437
4451
|
);
|
4438
4452
|
}
|
@@ -4468,7 +4482,7 @@ var Account = class extends AbstractAccount {
|
|
4468
4482
|
break;
|
4469
4483
|
}
|
4470
4484
|
throw new FuelError14(
|
4471
|
-
|
4485
|
+
ErrorCode14.NOT_SUPPORTED,
|
4472
4486
|
`Wallets containing more than ${pageSize} balances exceed the current supported limit.`
|
4473
4487
|
);
|
4474
4488
|
}
|
@@ -4573,6 +4587,12 @@ var Account = class extends AbstractAccount {
|
|
4573
4587
|
* @returns A promise that resolves to the transaction response.
|
4574
4588
|
*/
|
4575
4589
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4590
|
+
if (bn16(amount).lte(0)) {
|
4591
|
+
throw new FuelError14(
|
4592
|
+
ErrorCode14.INVALID_TRANSFER_AMOUNT,
|
4593
|
+
"Transfer amount must be a positive number."
|
4594
|
+
);
|
4595
|
+
}
|
4576
4596
|
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
4577
4597
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
4578
4598
|
}
|
@@ -4586,6 +4606,12 @@ var Account = class extends AbstractAccount {
|
|
4586
4606
|
* @returns A promise that resolves to the transaction response.
|
4587
4607
|
*/
|
4588
4608
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
4609
|
+
if (bn16(amount).lte(0)) {
|
4610
|
+
throw new FuelError14(
|
4611
|
+
ErrorCode14.INVALID_TRANSFER_AMOUNT,
|
4612
|
+
"Transfer amount must be a positive number."
|
4613
|
+
);
|
4614
|
+
}
|
4589
4615
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
4590
4616
|
const { minGasPrice } = this.provider.getGasConfig();
|
4591
4617
|
const params = { gasPrice: minGasPrice, ...txParams };
|
@@ -4655,7 +4681,7 @@ var Account = class extends AbstractAccount {
|
|
4655
4681
|
}
|
4656
4682
|
async signMessage(message) {
|
4657
4683
|
if (!this._connector) {
|
4658
|
-
throw new FuelError14(
|
4684
|
+
throw new FuelError14(ErrorCode14.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
4659
4685
|
}
|
4660
4686
|
return this._connector.signMessage(this.address.toString(), message);
|
4661
4687
|
}
|
@@ -4701,13 +4727,13 @@ var Account = class extends AbstractAccount {
|
|
4701
4727
|
}) {
|
4702
4728
|
if (minGasPrice.gt(gasPrice)) {
|
4703
4729
|
throw new FuelError14(
|
4704
|
-
|
4730
|
+
ErrorCode14.GAS_PRICE_TOO_LOW,
|
4705
4731
|
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
4706
4732
|
);
|
4707
4733
|
}
|
4708
4734
|
if (gasUsed.gt(gasLimit)) {
|
4709
4735
|
throw new FuelError14(
|
4710
|
-
|
4736
|
+
ErrorCode14.GAS_LIMIT_TOO_LOW,
|
4711
4737
|
`Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
|
4712
4738
|
);
|
4713
4739
|
}
|
@@ -4834,7 +4860,7 @@ import {
|
|
4834
4860
|
decryptJsonWalletData,
|
4835
4861
|
encryptJsonWalletData
|
4836
4862
|
} from "@fuel-ts/crypto";
|
4837
|
-
import { ErrorCode as
|
4863
|
+
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
4838
4864
|
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
4839
4865
|
import { v4 as uuidv4 } from "uuid";
|
4840
4866
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
@@ -4913,7 +4939,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
4913
4939
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
4914
4940
|
if (mac !== macHash) {
|
4915
4941
|
throw new FuelError15(
|
4916
|
-
|
4942
|
+
ErrorCode15.INVALID_PASSWORD,
|
4917
4943
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
4918
4944
|
);
|
4919
4945
|
}
|
@@ -5035,24 +5061,18 @@ var BaseWalletUnlocked = class extends Account {
|
|
5035
5061
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5036
5062
|
|
5037
5063
|
// src/hdwallet/hdwallet.ts
|
5038
|
-
import { ErrorCode as
|
5064
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5065
|
+
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5039
5066
|
import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5040
5067
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5041
|
-
import {
|
5042
|
-
toBeHex,
|
5043
|
-
dataSlice as dataSlice2,
|
5044
|
-
encodeBase58 as encodeBase582,
|
5045
|
-
decodeBase58,
|
5046
|
-
sha256 as sha2564,
|
5047
|
-
computeHmac as computeHmac2,
|
5048
|
-
ripemd160
|
5049
|
-
} from "ethers";
|
5068
|
+
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5050
5069
|
|
5051
5070
|
// src/mnemonic/mnemonic.ts
|
5052
5071
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
5053
|
-
import { ErrorCode as
|
5072
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
|
5073
|
+
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
5054
5074
|
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
5055
|
-
import { dataSlice, pbkdf2,
|
5075
|
+
import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
|
5056
5076
|
|
5057
5077
|
// src/wordlists/words/english.ts
|
5058
5078
|
var english = [
|
@@ -7107,9 +7127,9 @@ var english = [
|
|
7107
7127
|
];
|
7108
7128
|
|
7109
7129
|
// src/mnemonic/utils.ts
|
7110
|
-
import { ErrorCode as
|
7130
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
|
7131
|
+
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
7111
7132
|
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
7112
|
-
import { sha256 as sha2562 } from "ethers";
|
7113
7133
|
function toUtf8Bytes(stri) {
|
7114
7134
|
const str = stri.normalize("NFKD");
|
7115
7135
|
const result = [];
|
@@ -7125,7 +7145,7 @@ function toUtf8Bytes(stri) {
|
|
7125
7145
|
const c2 = str.charCodeAt(i);
|
7126
7146
|
if (i >= str.length || (c2 & 64512) !== 56320) {
|
7127
7147
|
throw new FuelError16(
|
7128
|
-
|
7148
|
+
ErrorCode16.INVALID_INPUT_PARAMETERS,
|
7129
7149
|
"Invalid UTF-8 in the input string."
|
7130
7150
|
);
|
7131
7151
|
}
|
@@ -7189,7 +7209,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7189
7209
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
7190
7210
|
if (index === -1) {
|
7191
7211
|
throw new FuelError16(
|
7192
|
-
|
7212
|
+
ErrorCode16.INVALID_MNEMONIC,
|
7193
7213
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
7194
7214
|
);
|
7195
7215
|
}
|
@@ -7206,7 +7226,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7206
7226
|
const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7207
7227
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7208
7228
|
throw new FuelError16(
|
7209
|
-
|
7229
|
+
ErrorCode16.INVALID_CHECKSUM,
|
7210
7230
|
"Checksum validation failed for the provided mnemonic."
|
7211
7231
|
);
|
7212
7232
|
}
|
@@ -7221,7 +7241,7 @@ var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
|
7221
7241
|
function assertWordList(wordlist) {
|
7222
7242
|
if (wordlist.length !== 2048) {
|
7223
7243
|
throw new FuelError17(
|
7224
|
-
|
7244
|
+
ErrorCode17.INVALID_WORD_LIST,
|
7225
7245
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
7226
7246
|
);
|
7227
7247
|
}
|
@@ -7229,7 +7249,7 @@ function assertWordList(wordlist) {
|
|
7229
7249
|
function assertEntropy(entropy) {
|
7230
7250
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
7231
7251
|
throw new FuelError17(
|
7232
|
-
|
7252
|
+
ErrorCode17.INVALID_ENTROPY,
|
7233
7253
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
7234
7254
|
);
|
7235
7255
|
}
|
@@ -7239,7 +7259,7 @@ function assertMnemonic(words) {
|
|
7239
7259
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
7240
7260
|
", "
|
7241
7261
|
)}] words, but got ${words.length}.`;
|
7242
|
-
throw new FuelError17(
|
7262
|
+
throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
|
7243
7263
|
}
|
7244
7264
|
}
|
7245
7265
|
var Mnemonic = class {
|
@@ -7358,7 +7378,7 @@ var Mnemonic = class {
|
|
7358
7378
|
const seedArray = arrayify17(seed);
|
7359
7379
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7360
7380
|
throw new FuelError17(
|
7361
|
-
|
7381
|
+
ErrorCode17.INVALID_SEED,
|
7362
7382
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7363
7383
|
);
|
7364
7384
|
}
|
@@ -7435,7 +7455,7 @@ function isValidExtendedKey(extendedKey) {
|
|
7435
7455
|
function parsePath(path2, depth = 0) {
|
7436
7456
|
const components = path2.split("/");
|
7437
7457
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
7438
|
-
throw new FuelError18(
|
7458
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
7439
7459
|
}
|
7440
7460
|
if (components[0] === "m") {
|
7441
7461
|
components.shift();
|
@@ -7465,7 +7485,7 @@ var HDWallet = class {
|
|
7465
7485
|
} else {
|
7466
7486
|
if (!config.publicKey) {
|
7467
7487
|
throw new FuelError18(
|
7468
|
-
|
7488
|
+
ErrorCode18.HD_WALLET_ERROR,
|
7469
7489
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7470
7490
|
);
|
7471
7491
|
}
|
@@ -7495,7 +7515,7 @@ var HDWallet = class {
|
|
7495
7515
|
if (index & HARDENED_INDEX) {
|
7496
7516
|
if (!privateKey) {
|
7497
7517
|
throw new FuelError18(
|
7498
|
-
|
7518
|
+
ErrorCode18.HD_WALLET_ERROR,
|
7499
7519
|
"Cannot derive a hardened index without a private Key."
|
7500
7520
|
);
|
7501
7521
|
}
|
@@ -7548,7 +7568,7 @@ var HDWallet = class {
|
|
7548
7568
|
toExtendedKey(isPublic = false, testnet = false) {
|
7549
7569
|
if (this.depth >= 256) {
|
7550
7570
|
throw new FuelError18(
|
7551
|
-
|
7571
|
+
ErrorCode18.HD_WALLET_ERROR,
|
7552
7572
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
7553
7573
|
);
|
7554
7574
|
}
|
@@ -7579,10 +7599,10 @@ var HDWallet = class {
|
|
7579
7599
|
const bytes = arrayify18(decoded);
|
7580
7600
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7581
7601
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7582
|
-
throw new FuelError18(
|
7602
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
7583
7603
|
}
|
7584
7604
|
if (!validChecksum) {
|
7585
|
-
throw new FuelError18(
|
7605
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7586
7606
|
}
|
7587
7607
|
const depth = bytes[4];
|
7588
7608
|
const parentFingerprint = hexlify17(bytes.slice(5, 9));
|
@@ -7591,13 +7611,13 @@ var HDWallet = class {
|
|
7591
7611
|
const key = bytes.slice(45, 78);
|
7592
7612
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7593
7613
|
throw new FuelError18(
|
7594
|
-
|
7614
|
+
ErrorCode18.HD_WALLET_ERROR,
|
7595
7615
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
7596
7616
|
);
|
7597
7617
|
}
|
7598
7618
|
if (isPublicExtendedKey(bytes)) {
|
7599
7619
|
if (key[0] !== 3) {
|
7600
|
-
throw new FuelError18(
|
7620
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
|
7601
7621
|
}
|
7602
7622
|
return new HDWallet({
|
7603
7623
|
publicKey: key,
|
@@ -7608,7 +7628,7 @@ var HDWallet = class {
|
|
7608
7628
|
});
|
7609
7629
|
}
|
7610
7630
|
if (key[0] !== 0) {
|
7611
|
-
throw new FuelError18(
|
7631
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
|
7612
7632
|
}
|
7613
7633
|
return new HDWallet({
|
7614
7634
|
privateKey: key.slice(1),
|