@fuel-ts/account 0.0.0-rc-1889-20240322122653 → 0.0.0-rc-1356-20240322130951
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 +177 -0
- package/dist/account.d.ts.map +1 -0
- package/dist/configs.d.ts +2 -3
- package/dist/configs.d.ts.map +1 -0
- package/dist/connectors/fuel-connector.d.ts +188 -0
- package/dist/connectors/fuel-connector.d.ts.map +1 -0
- package/dist/connectors/fuel.d.ts +133 -0
- package/dist/connectors/fuel.d.ts.map +1 -0
- package/dist/connectors/index.d.ts +5 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/types/connector-metadata.d.ts +12 -0
- package/dist/connectors/types/connector-metadata.d.ts.map +1 -0
- package/dist/connectors/types/connector-types.d.ts +34 -0
- package/dist/connectors/types/connector-types.d.ts.map +1 -0
- package/dist/connectors/types/data-type.d.ts +34 -0
- package/dist/connectors/types/data-type.d.ts.map +1 -0
- package/dist/connectors/types/events.d.ts +111 -0
- package/dist/connectors/types/events.d.ts.map +1 -0
- package/dist/connectors/types/index.d.ts +7 -0
- package/dist/connectors/types/index.d.ts.map +1 -0
- package/dist/connectors/types/local-storage.d.ts +11 -0
- package/dist/connectors/types/local-storage.d.ts.map +1 -0
- package/dist/connectors/types/target-object.d.ts +14 -0
- package/dist/connectors/types/target-object.d.ts.map +1 -0
- package/dist/connectors/utils/cache.d.ts +14 -0
- package/dist/connectors/utils/cache.d.ts.map +1 -0
- package/dist/connectors/utils/dispatch-fuel-connector-event.d.ts +7 -0
- package/dist/connectors/utils/dispatch-fuel-connector-event.d.ts.map +1 -0
- package/dist/connectors/utils/index.d.ts +4 -0
- package/dist/connectors/utils/index.d.ts.map +1 -0
- package/dist/connectors/utils/promises.d.ts +8 -0
- package/dist/connectors/utils/promises.d.ts.map +1 -0
- package/dist/hdwallet/hdwallet.d.ts +58 -0
- package/dist/hdwallet/hdwallet.d.ts.map +1 -0
- package/dist/hdwallet/index.d.ts +2 -0
- package/dist/hdwallet/index.d.ts.map +1 -0
- package/dist/index.d.ts +13 -904
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +461 -394
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +350 -314
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +251 -212
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/index.d.ts +3 -0
- package/dist/mnemonic/index.d.ts.map +1 -0
- package/dist/mnemonic/mnemonic.d.ts +85 -0
- package/dist/mnemonic/mnemonic.d.ts.map +1 -0
- package/dist/mnemonic/utils.d.ts +8 -0
- package/dist/mnemonic/utils.d.ts.map +1 -0
- package/dist/predicate/index.d.ts +3 -0
- package/dist/predicate/index.d.ts.map +1 -0
- package/dist/predicate/predicate.d.ts +94 -0
- package/dist/predicate/predicate.d.ts.map +1 -0
- package/dist/predicate/utils/getPredicateRoot.d.ts +12 -0
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -0
- package/dist/predicate/utils/index.d.ts +2 -0
- package/dist/predicate/utils/index.d.ts.map +1 -0
- package/dist/providers/__generated__/operations.d.ts +3477 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -0
- package/dist/providers/assets/index.d.ts +5 -0
- package/dist/providers/assets/index.d.ts.map +1 -0
- package/dist/providers/assets/types.d.ts +36 -0
- package/dist/providers/assets/types.d.ts.map +1 -0
- package/dist/providers/assets/utils/index.d.ts +4 -0
- package/dist/providers/assets/utils/index.d.ts.map +1 -0
- package/dist/providers/assets/utils/network.d.ts +33 -0
- package/dist/providers/assets/utils/network.d.ts.map +1 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
- package/dist/providers/assets/utils/url.d.ts +2 -0
- package/dist/providers/assets/utils/url.d.ts.map +1 -0
- package/dist/providers/chains.d.ts +11 -0
- package/dist/providers/chains.d.ts.map +1 -0
- package/dist/providers/coin-quantity.d.ts +21 -0
- package/dist/providers/coin-quantity.d.ts.map +1 -0
- package/dist/providers/coin.d.ts +15 -0
- package/dist/providers/coin.d.ts.map +1 -0
- package/dist/providers/fuel-graphql-subscriber.d.ts +23 -0
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -0
- package/dist/providers/index.d.ts +13 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/memory-cache.d.ts +11 -0
- package/dist/providers/memory-cache.d.ts.map +1 -0
- package/dist/providers/message.d.ts +60 -0
- package/dist/providers/message.d.ts.map +1 -0
- package/dist/providers/provider.d.ts +522 -0
- package/dist/providers/provider.d.ts.map +1 -0
- package/dist/providers/resource.d.ts +37 -0
- package/dist/providers/resource.d.ts.map +1 -0
- package/dist/providers/transaction-request/create-transaction-request.d.ts +73 -0
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/errors.d.ts +25 -0
- package/dist/providers/transaction-request/errors.d.ts.map +1 -0
- package/dist/providers/transaction-request/hash-transaction.d.ts +9 -0
- package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -0
- package/dist/providers/transaction-request/index.d.ts +10 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -0
- package/dist/providers/transaction-request/input.d.ts +59 -0
- package/dist/providers/transaction-request/input.d.ts.map +1 -0
- package/dist/providers/transaction-request/output.d.ts +39 -0
- package/dist/providers/transaction-request/output.d.ts.map +1 -0
- package/dist/providers/transaction-request/script-transaction-request.d.ts +106 -0
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/scripts.d.ts +6 -0
- package/dist/providers/transaction-request/scripts.d.ts.map +1 -0
- package/dist/providers/transaction-request/storage-slot.d.ts +10 -0
- package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -0
- package/dist/providers/transaction-request/transaction-request.d.ts +259 -0
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/types.d.ts +10 -0
- package/dist/providers/transaction-request/types.d.ts.map +1 -0
- package/dist/providers/transaction-request/utils.d.ts +4 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -0
- package/dist/providers/transaction-request/witness.d.ts +5 -0
- package/dist/providers/transaction-request/witness.d.ts.map +1 -0
- package/dist/providers/transaction-response/getDecodedLogs.d.ts +5 -0
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -0
- package/dist/providers/transaction-response/index.d.ts +3 -0
- package/dist/providers/transaction-response/index.d.ts.map +1 -0
- package/dist/providers/transaction-response/transaction-response.d.ts +106 -0
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +20 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -0
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +21 -0
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -0
- package/dist/providers/transaction-summary/call.d.ts +18 -0
- package/dist/providers/transaction-summary/call.d.ts.map +1 -0
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts +31 -0
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -0
- package/dist/providers/transaction-summary/index.d.ts +10 -0
- package/dist/providers/transaction-summary/index.d.ts.map +1 -0
- package/dist/providers/transaction-summary/input.d.ts +21 -0
- package/dist/providers/transaction-summary/input.d.ts.map +1 -0
- package/dist/providers/transaction-summary/operations.d.ts +40 -0
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -0
- package/dist/providers/transaction-summary/output.d.ts +15 -0
- package/dist/providers/transaction-summary/output.d.ts.map +1 -0
- package/dist/providers/transaction-summary/receipt.d.ts +7 -0
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -0
- package/dist/providers/transaction-summary/status.d.ts +9 -0
- package/dist/providers/transaction-summary/status.d.ts.map +1 -0
- package/dist/providers/transaction-summary/types.d.ts +146 -0
- package/dist/providers/transaction-summary/types.d.ts.map +1 -0
- package/dist/providers/utils/auto-retry-fetch.d.ts +36 -0
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -0
- package/dist/providers/utils/block-explorer.d.ts +14 -0
- package/dist/providers/utils/block-explorer.d.ts.map +1 -0
- package/dist/providers/utils/gas.d.ts +38 -0
- package/dist/providers/utils/gas.d.ts.map +1 -0
- package/dist/providers/utils/index.d.ts +5 -0
- package/dist/providers/utils/index.d.ts.map +1 -0
- package/dist/providers/utils/json.d.ts +7 -0
- package/dist/providers/utils/json.d.ts.map +1 -0
- package/dist/providers/utils/merge-quantities.d.ts +3 -0
- package/dist/providers/utils/merge-quantities.d.ts.map +1 -0
- package/dist/providers/utils/receipts.d.ts +10 -0
- package/dist/providers/utils/receipts.d.ts.map +1 -0
- package/dist/signer/index.d.ts +2 -0
- package/dist/signer/index.d.ts.map +1 -0
- package/dist/signer/signer.d.ts +64 -0
- package/dist/signer/signer.d.ts.map +1 -0
- package/dist/test-utils/asset-id.d.ts +9 -0
- package/dist/test-utils/asset-id.d.ts.map +1 -0
- package/dist/test-utils/generateTestWallet.d.ts +4 -0
- package/dist/test-utils/generateTestWallet.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +8 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/{test-utils.d.ts → test-utils/launchNode.d.ts} +19 -24
- package/dist/test-utils/launchNode.d.ts.map +1 -0
- package/dist/test-utils/seedTestWallet.d.ts +4 -0
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -0
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +33 -0
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -0
- package/dist/test-utils/test-message.d.ts +28 -0
- package/dist/test-utils/test-message.d.ts.map +1 -0
- package/dist/test-utils/wallet-config.d.ts +49 -0
- package/dist/test-utils/wallet-config.d.ts.map +1 -0
- package/dist/test-utils.global.js +655 -310
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +452 -217
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +357 -124
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +14 -0
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -0
- package/dist/wallet/base-wallet-unlocked.d.ts +73 -0
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -0
- package/dist/wallet/index.d.ts +4 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/keystore-wallet.d.ts +38 -0
- package/dist/wallet/keystore-wallet.d.ts.map +1 -0
- package/dist/wallet/wallet.d.ts +68 -0
- package/dist/wallet/wallet.d.ts.map +1 -0
- package/dist/wallet/wallets.d.ts +76 -0
- package/dist/wallet/wallets.d.ts.map +1 -0
- package/dist/wallet-manager/index.d.ts +6 -0
- package/dist/wallet-manager/index.d.ts.map +1 -0
- package/dist/wallet-manager/storages/memory-storage.d.ts +9 -0
- package/dist/wallet-manager/storages/memory-storage.d.ts.map +1 -0
- package/dist/wallet-manager/types.d.ts +42 -0
- package/dist/wallet-manager/types.d.ts.map +1 -0
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +29 -0
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -0
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts +29 -0
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -0
- package/dist/wallet-manager/wallet-manager.d.ts +104 -0
- package/dist/wallet-manager/wallet-manager.d.ts.map +1 -0
- package/dist/wordlists/index.d.ts +5 -0
- package/dist/wordlists/index.d.ts.map +1 -0
- package/dist/wordlists/words/english.d.ts +2 -0
- package/dist/wordlists/words/english.d.ts.map +1 -0
- package/package.json +26 -21
- package/dist/account-E9nGNf5X.d.mts +0 -3837
- package/dist/account-E9nGNf5X.d.ts +0 -3837
- package/dist/configs.d.mts +0 -3
- package/dist/index.d.mts +0 -904
- package/dist/test-utils.d.mts +0 -66
package/dist/test-utils.mjs
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3
|
+
var __publicField = (obj, key, value) => {
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
5
|
+
return value;
|
6
|
+
};
|
7
|
+
var __accessCheck = (obj, member, msg) => {
|
8
|
+
if (!member.has(obj))
|
9
|
+
throw TypeError("Cannot " + msg);
|
10
|
+
};
|
11
|
+
var __privateAdd = (obj, member, value) => {
|
12
|
+
if (member.has(obj))
|
13
|
+
throw TypeError("Cannot add the same private member more than once");
|
14
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
15
|
+
};
|
16
|
+
var __privateMethod = (obj, member, method) => {
|
17
|
+
__accessCheck(obj, member, "access private method");
|
18
|
+
return method;
|
19
|
+
};
|
20
|
+
|
1
21
|
// src/wallet/base-wallet-unlocked.ts
|
2
22
|
import { hashMessage } from "@fuel-ts/hasher";
|
3
23
|
import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
@@ -871,12 +891,11 @@ function getSdk(requester) {
|
|
871
891
|
// src/providers/fuel-graphql-subscriber.ts
|
872
892
|
import { ErrorCode, FuelError } from "@fuel-ts/errors";
|
873
893
|
import { print } from "graphql";
|
874
|
-
var
|
894
|
+
var _FuelGraphqlSubscriber = class {
|
875
895
|
constructor(options) {
|
876
896
|
this.options = options;
|
877
897
|
}
|
878
898
|
stream;
|
879
|
-
static textDecoder = new TextDecoder();
|
880
899
|
async setStream() {
|
881
900
|
const { url, query, variables, fetchFn } = this.options;
|
882
901
|
const response = await fetchFn(`${url}-sub`, {
|
@@ -936,6 +955,8 @@ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
|
936
955
|
return this;
|
937
956
|
}
|
938
957
|
};
|
958
|
+
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
959
|
+
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
939
960
|
|
940
961
|
// src/providers/memory-cache.ts
|
941
962
|
import { ErrorCode as ErrorCode2, FuelError as FuelError2 } from "@fuel-ts/errors";
|
@@ -1465,15 +1486,6 @@ function normalizeJSON(root) {
|
|
1465
1486
|
return normalize(clone(root));
|
1466
1487
|
}
|
1467
1488
|
|
1468
|
-
// src/providers/utils/sleep.ts
|
1469
|
-
function sleep(time) {
|
1470
|
-
return new Promise((resolve) => {
|
1471
|
-
setTimeout(() => {
|
1472
|
-
resolve(true);
|
1473
|
-
}, time);
|
1474
|
-
});
|
1475
|
-
}
|
1476
|
-
|
1477
1489
|
// src/providers/transaction-request/errors.ts
|
1478
1490
|
var NoWitnessAtIndexError = class extends Error {
|
1479
1491
|
constructor(index) {
|
@@ -1495,7 +1507,7 @@ var witnessify = (value) => {
|
|
1495
1507
|
};
|
1496
1508
|
|
1497
1509
|
// src/providers/transaction-request/transaction-request.ts
|
1498
|
-
var BaseTransactionRequest = class
|
1510
|
+
var BaseTransactionRequest = class {
|
1499
1511
|
/** Gas price for transaction */
|
1500
1512
|
gasPrice;
|
1501
1513
|
/** Block until which tx cannot be included */
|
@@ -1565,7 +1577,7 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
|
|
1565
1577
|
const inputs = this.inputs?.map(inputify) ?? [];
|
1566
1578
|
const outputs = this.outputs?.map(outputify) ?? [];
|
1567
1579
|
const witnesses = this.witnesses?.map(witnessify) ?? [];
|
1568
|
-
const { policyTypes, policies } =
|
1580
|
+
const { policyTypes, policies } = BaseTransactionRequest.getPolicyMeta(this);
|
1569
1581
|
return {
|
1570
1582
|
policyTypes,
|
1571
1583
|
inputs,
|
@@ -3103,7 +3115,7 @@ function assembleTransactionSummary(params) {
|
|
3103
3115
|
}
|
3104
3116
|
|
3105
3117
|
// src/providers/transaction-response/transaction-response.ts
|
3106
|
-
var TransactionResponse = class
|
3118
|
+
var TransactionResponse = class {
|
3107
3119
|
/** Transaction ID */
|
3108
3120
|
id;
|
3109
3121
|
/** Current provider */
|
@@ -3131,7 +3143,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
3131
3143
|
* @param provider - The provider.
|
3132
3144
|
*/
|
3133
3145
|
static async create(id, provider) {
|
3134
|
-
const response = new
|
3146
|
+
const response = new TransactionResponse(id, provider);
|
3135
3147
|
await response.fetch();
|
3136
3148
|
return response;
|
3137
3149
|
}
|
@@ -3259,6 +3271,7 @@ import { BigNumberCoder } from "@fuel-ts/abi-coder";
|
|
3259
3271
|
import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
|
3260
3272
|
|
3261
3273
|
// src/providers/utils/auto-retry-fetch.ts
|
3274
|
+
import { sleep } from "@fuel-ts/utils";
|
3262
3275
|
function getWaitDelay(options, retryAttemptNum) {
|
3263
3276
|
const duration = options.baseDelay ?? 150;
|
3264
3277
|
switch (options.backoff) {
|
@@ -3346,7 +3359,8 @@ var processGqlChain = (chain) => {
|
|
3346
3359
|
}
|
3347
3360
|
};
|
3348
3361
|
};
|
3349
|
-
var
|
3362
|
+
var _cacheInputs, cacheInputs_fn;
|
3363
|
+
var _Provider = class {
|
3350
3364
|
/**
|
3351
3365
|
* Constructor to initialize a Provider.
|
3352
3366
|
*
|
@@ -3357,25 +3371,27 @@ var Provider = class _Provider {
|
|
3357
3371
|
*/
|
3358
3372
|
constructor(url, options = {}) {
|
3359
3373
|
this.url = url;
|
3374
|
+
/**
|
3375
|
+
* @hidden
|
3376
|
+
*/
|
3377
|
+
__privateAdd(this, _cacheInputs);
|
3378
|
+
__publicField(this, "operations");
|
3379
|
+
__publicField(this, "cache");
|
3380
|
+
__publicField(this, "options", {
|
3381
|
+
timeout: void 0,
|
3382
|
+
cacheUtxo: void 0,
|
3383
|
+
fetch: void 0,
|
3384
|
+
retryOptions: void 0
|
3385
|
+
});
|
3360
3386
|
this.options = { ...this.options, ...options };
|
3361
3387
|
this.url = url;
|
3362
3388
|
this.operations = this.createOperations();
|
3363
3389
|
this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
|
3364
3390
|
}
|
3365
|
-
operations;
|
3366
|
-
cache;
|
3367
3391
|
static clearChainAndNodeCaches() {
|
3368
3392
|
_Provider.nodeInfoCache = {};
|
3369
3393
|
_Provider.chainInfoCache = {};
|
3370
3394
|
}
|
3371
|
-
static chainInfoCache = {};
|
3372
|
-
static nodeInfoCache = {};
|
3373
|
-
options = {
|
3374
|
-
timeout: void 0,
|
3375
|
-
cacheUtxo: void 0,
|
3376
|
-
fetch: void 0,
|
3377
|
-
retryOptions: void 0
|
3378
|
-
};
|
3379
3395
|
static getFetchFn(options) {
|
3380
3396
|
const { retryOptions, timeout } = options;
|
3381
3397
|
return autoRetryFetch(async (...args) => {
|
@@ -3572,19 +3588,6 @@ var Provider = class _Provider {
|
|
3572
3588
|
} = this.getChain();
|
3573
3589
|
return chainId.toNumber();
|
3574
3590
|
}
|
3575
|
-
/**
|
3576
|
-
* @hidden
|
3577
|
-
*/
|
3578
|
-
#cacheInputs(inputs) {
|
3579
|
-
if (!this.cache) {
|
3580
|
-
return;
|
3581
|
-
}
|
3582
|
-
inputs.forEach((input) => {
|
3583
|
-
if (input.type === InputType6.Coin) {
|
3584
|
-
this.cache?.set(input.id);
|
3585
|
-
}
|
3586
|
-
});
|
3587
|
-
}
|
3588
3591
|
/**
|
3589
3592
|
* Submits a transaction to the chain to be executed.
|
3590
3593
|
*
|
@@ -3597,7 +3600,7 @@ var Provider = class _Provider {
|
|
3597
3600
|
// #region Provider-sendTransaction
|
3598
3601
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution = false } = {}) {
|
3599
3602
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
3600
|
-
this
|
3603
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs);
|
3601
3604
|
if (estimateTxDependencies) {
|
3602
3605
|
await this.estimateTxDependencies(transactionRequest);
|
3603
3606
|
}
|
@@ -4222,6 +4225,20 @@ var Provider = class _Provider {
|
|
4222
4225
|
return new TransactionResponse(transactionId, this);
|
4223
4226
|
}
|
4224
4227
|
};
|
4228
|
+
var Provider = _Provider;
|
4229
|
+
_cacheInputs = new WeakSet();
|
4230
|
+
cacheInputs_fn = function(inputs) {
|
4231
|
+
if (!this.cache) {
|
4232
|
+
return;
|
4233
|
+
}
|
4234
|
+
inputs.forEach((input) => {
|
4235
|
+
if (input.type === InputType6.Coin) {
|
4236
|
+
this.cache?.set(input.id);
|
4237
|
+
}
|
4238
|
+
});
|
4239
|
+
};
|
4240
|
+
__publicField(Provider, "chainInfoCache", {});
|
4241
|
+
__publicField(Provider, "nodeInfoCache", {});
|
4225
4242
|
|
4226
4243
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4227
4244
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
@@ -4722,7 +4739,7 @@ import { hash } from "@fuel-ts/hasher";
|
|
4722
4739
|
import { toBytes } from "@fuel-ts/math";
|
4723
4740
|
import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
|
4724
4741
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
4725
|
-
var Signer = class
|
4742
|
+
var Signer = class {
|
4726
4743
|
address;
|
4727
4744
|
publicKey;
|
4728
4745
|
compressedPublicKey;
|
@@ -4801,7 +4818,7 @@ var Signer = class _Signer {
|
|
4801
4818
|
* @returns Address from signature
|
4802
4819
|
*/
|
4803
4820
|
static recoverAddress(data, signature) {
|
4804
|
-
return Address4.fromPublicKey(
|
4821
|
+
return Address4.fromPublicKey(Signer.recoverPublicKey(data, signature));
|
4805
4822
|
}
|
4806
4823
|
/**
|
4807
4824
|
* Generate a random privateKey
|
@@ -4925,10 +4942,6 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
4925
4942
|
|
4926
4943
|
// src/wallet/base-wallet-unlocked.ts
|
4927
4944
|
var BaseWalletUnlocked = class extends Account {
|
4928
|
-
/**
|
4929
|
-
* Default HDWallet path.
|
4930
|
-
*/
|
4931
|
-
static defaultPath = "m/44'/1179993420'/0'/0/0";
|
4932
4945
|
/**
|
4933
4946
|
* A function that returns the wallet's signer.
|
4934
4947
|
*/
|
@@ -5034,6 +5047,10 @@ var BaseWalletUnlocked = class extends Account {
|
|
5034
5047
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
5035
5048
|
}
|
5036
5049
|
};
|
5050
|
+
/**
|
5051
|
+
* Default HDWallet path.
|
5052
|
+
*/
|
5053
|
+
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5037
5054
|
|
5038
5055
|
// src/hdwallet/hdwallet.ts
|
5039
5056
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
@@ -7237,7 +7254,7 @@ function assertMnemonic(words) {
|
|
7237
7254
|
throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
|
7238
7255
|
}
|
7239
7256
|
}
|
7240
|
-
var Mnemonic = class
|
7257
|
+
var Mnemonic = class {
|
7241
7258
|
wordlist;
|
7242
7259
|
/**
|
7243
7260
|
*
|
@@ -7254,7 +7271,7 @@ var Mnemonic = class _Mnemonic {
|
|
7254
7271
|
* @returns Entropy hash
|
7255
7272
|
*/
|
7256
7273
|
mnemonicToEntropy(phrase) {
|
7257
|
-
return
|
7274
|
+
return Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
|
7258
7275
|
}
|
7259
7276
|
/**
|
7260
7277
|
*
|
@@ -7262,7 +7279,7 @@ var Mnemonic = class _Mnemonic {
|
|
7262
7279
|
* @returns Mnemonic phrase
|
7263
7280
|
*/
|
7264
7281
|
entropyToMnemonic(entropy) {
|
7265
|
-
return
|
7282
|
+
return Mnemonic.entropyToMnemonic(entropy, this.wordlist);
|
7266
7283
|
}
|
7267
7284
|
/**
|
7268
7285
|
*
|
@@ -7303,8 +7320,8 @@ var Mnemonic = class _Mnemonic {
|
|
7303
7320
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7304
7321
|
*/
|
7305
7322
|
static mnemonicToMasterKeys(phrase, passphrase = "") {
|
7306
|
-
const seed =
|
7307
|
-
return
|
7323
|
+
const seed = Mnemonic.mnemonicToSeed(phrase, passphrase);
|
7324
|
+
return Mnemonic.masterKeysFromSeed(seed);
|
7308
7325
|
}
|
7309
7326
|
/**
|
7310
7327
|
* Validates if given mnemonic is valid
|
@@ -7320,7 +7337,7 @@ var Mnemonic = class _Mnemonic {
|
|
7320
7337
|
return false;
|
7321
7338
|
}
|
7322
7339
|
while (i < words.length) {
|
7323
|
-
if (
|
7340
|
+
if (Mnemonic.binarySearch(words[i]) === false) {
|
7324
7341
|
return false;
|
7325
7342
|
}
|
7326
7343
|
i += 1;
|
@@ -7367,7 +7384,7 @@ var Mnemonic = class _Mnemonic {
|
|
7367
7384
|
* @returns BIP-32 extended private key
|
7368
7385
|
*/
|
7369
7386
|
static seedToExtendedKey(seed, testnet = false) {
|
7370
|
-
const masterKey =
|
7387
|
+
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7371
7388
|
const prefix = arrayify17(testnet ? TestnetPRV : MainnetPRV);
|
7372
7389
|
const depth = "0x00";
|
7373
7390
|
const fingerprint = "0x00000000";
|
@@ -7399,7 +7416,7 @@ var Mnemonic = class _Mnemonic {
|
|
7399
7416
|
*/
|
7400
7417
|
static generate(size = 32, extraEntropy = "") {
|
7401
7418
|
const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
|
7402
|
-
return
|
7419
|
+
return Mnemonic.entropyToMnemonic(entropy);
|
7403
7420
|
}
|
7404
7421
|
};
|
7405
7422
|
var mnemonic_default = Mnemonic;
|
@@ -7439,7 +7456,7 @@ function parsePath(path2, depth = 0) {
|
|
7439
7456
|
(p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
|
7440
7457
|
);
|
7441
7458
|
}
|
7442
|
-
var HDWallet = class
|
7459
|
+
var HDWallet = class {
|
7443
7460
|
depth = 0;
|
7444
7461
|
index = 0;
|
7445
7462
|
fingerprint = hexlify17("0x00000000");
|
@@ -7505,7 +7522,7 @@ var HDWallet = class _HDWallet {
|
|
7505
7522
|
if (privateKey) {
|
7506
7523
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7507
7524
|
const ki = bn17(IL).add(privateKey).mod(N).toBytes(32);
|
7508
|
-
return new
|
7525
|
+
return new HDWallet({
|
7509
7526
|
privateKey: ki,
|
7510
7527
|
chainCode: IR,
|
7511
7528
|
index,
|
@@ -7515,7 +7532,7 @@ var HDWallet = class _HDWallet {
|
|
7515
7532
|
}
|
7516
7533
|
const signer = new Signer(hexlify17(IL));
|
7517
7534
|
const Ki = signer.addPoint(publicKey);
|
7518
|
-
return new
|
7535
|
+
return new HDWallet({
|
7519
7536
|
publicKey: Ki,
|
7520
7537
|
chainCode: IR,
|
7521
7538
|
index,
|
@@ -7564,7 +7581,7 @@ var HDWallet = class _HDWallet {
|
|
7564
7581
|
*/
|
7565
7582
|
static fromSeed(seed) {
|
7566
7583
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7567
|
-
return new
|
7584
|
+
return new HDWallet({
|
7568
7585
|
chainCode: arrayify18(masterKey.slice(32)),
|
7569
7586
|
privateKey: arrayify18(masterKey.slice(0, 32))
|
7570
7587
|
});
|
@@ -7594,7 +7611,7 @@ var HDWallet = class _HDWallet {
|
|
7594
7611
|
if (key[0] !== 3) {
|
7595
7612
|
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
|
7596
7613
|
}
|
7597
|
-
return new
|
7614
|
+
return new HDWallet({
|
7598
7615
|
publicKey: key,
|
7599
7616
|
chainCode,
|
7600
7617
|
index,
|
@@ -7605,7 +7622,7 @@ var HDWallet = class _HDWallet {
|
|
7605
7622
|
if (key[0] !== 0) {
|
7606
7623
|
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
|
7607
7624
|
}
|
7608
|
-
return new
|
7625
|
+
return new HDWallet({
|
7609
7626
|
privateKey: key.slice(1),
|
7610
7627
|
chainCode,
|
7611
7628
|
index,
|
@@ -7628,7 +7645,7 @@ var WalletLocked = class extends Account {
|
|
7628
7645
|
return new WalletUnlocked(privateKey, this._provider);
|
7629
7646
|
}
|
7630
7647
|
};
|
7631
|
-
var WalletUnlocked = class
|
7648
|
+
var WalletUnlocked = class extends BaseWalletUnlocked {
|
7632
7649
|
/**
|
7633
7650
|
* Locks the wallet and returns an instance of WalletLocked.
|
7634
7651
|
*
|
@@ -7646,7 +7663,7 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7646
7663
|
*/
|
7647
7664
|
static generate(generateOptions) {
|
7648
7665
|
const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
|
7649
|
-
return new
|
7666
|
+
return new WalletUnlocked(privateKey, generateOptions?.provider);
|
7650
7667
|
}
|
7651
7668
|
/**
|
7652
7669
|
* Create a Wallet Unlocked from a seed.
|
@@ -7658,8 +7675,8 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7658
7675
|
*/
|
7659
7676
|
static fromSeed(seed, path2, provider) {
|
7660
7677
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
7661
|
-
const childWallet = hdWallet.derivePath(path2 ||
|
7662
|
-
return new
|
7678
|
+
const childWallet = hdWallet.derivePath(path2 || WalletUnlocked.defaultPath);
|
7679
|
+
return new WalletUnlocked(childWallet.privateKey, provider);
|
7663
7680
|
}
|
7664
7681
|
/**
|
7665
7682
|
* Create a Wallet Unlocked from a mnemonic phrase.
|
@@ -7673,8 +7690,8 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7673
7690
|
static fromMnemonic(mnemonic, path2, passphrase, provider) {
|
7674
7691
|
const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
|
7675
7692
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
7676
|
-
const childWallet = hdWallet.derivePath(path2 ||
|
7677
|
-
return new
|
7693
|
+
const childWallet = hdWallet.derivePath(path2 || WalletUnlocked.defaultPath);
|
7694
|
+
return new WalletUnlocked(childWallet.privateKey, provider);
|
7678
7695
|
}
|
7679
7696
|
/**
|
7680
7697
|
* Create a Wallet Unlocked from an extended key.
|
@@ -7685,7 +7702,7 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7685
7702
|
*/
|
7686
7703
|
static fromExtendedKey(extendedKey, provider) {
|
7687
7704
|
const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
|
7688
|
-
return new
|
7705
|
+
return new WalletUnlocked(hdWallet.privateKey, provider);
|
7689
7706
|
}
|
7690
7707
|
/**
|
7691
7708
|
* Create a Wallet Unlocked from an encrypted JSON.
|
@@ -7697,7 +7714,7 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7697
7714
|
*/
|
7698
7715
|
static async fromEncryptedJson(jsonWallet, password, provider) {
|
7699
7716
|
const privateKey = await decryptKeystoreWallet(jsonWallet, password);
|
7700
|
-
return new
|
7717
|
+
return new WalletUnlocked(privateKey, provider);
|
7701
7718
|
}
|
7702
7719
|
};
|
7703
7720
|
|
@@ -7723,50 +7740,50 @@ var Wallet = class {
|
|
7723
7740
|
static fromPrivateKey(privateKey, provider) {
|
7724
7741
|
return new WalletUnlocked(privateKey, provider);
|
7725
7742
|
}
|
7726
|
-
/**
|
7727
|
-
* Generate a new Wallet Unlocked with a random key pair.
|
7728
|
-
*
|
7729
|
-
* @param generateOptions - Options to customize the generation process (optional).
|
7730
|
-
* @returns An unlocked wallet instance.
|
7731
|
-
*/
|
7732
|
-
static generate = WalletUnlocked.generate;
|
7733
|
-
/**
|
7734
|
-
* Create a Wallet Unlocked from a seed.
|
7735
|
-
*
|
7736
|
-
* @param seed - The seed phrase.
|
7737
|
-
* @param provider - A Provider instance (optional).
|
7738
|
-
* @param path - The derivation path (optional).
|
7739
|
-
* @returns An unlocked wallet instance.
|
7740
|
-
*/
|
7741
|
-
static fromSeed = WalletUnlocked.fromSeed;
|
7742
|
-
/**
|
7743
|
-
* Create a Wallet Unlocked from a mnemonic phrase.
|
7744
|
-
*
|
7745
|
-
* @param mnemonic - The mnemonic phrase.
|
7746
|
-
* @param provider - A Provider instance (optional).
|
7747
|
-
* @param path - The derivation path (optional).
|
7748
|
-
* @param passphrase - The passphrase for the mnemonic (optional).
|
7749
|
-
* @returns An unlocked wallet instance.
|
7750
|
-
*/
|
7751
|
-
static fromMnemonic = WalletUnlocked.fromMnemonic;
|
7752
|
-
/**
|
7753
|
-
* Create a Wallet Unlocked from an extended key.
|
7754
|
-
*
|
7755
|
-
* @param extendedKey - The extended key.
|
7756
|
-
* @param provider - A Provider instance (optional).
|
7757
|
-
* @returns An unlocked wallet instance.
|
7758
|
-
*/
|
7759
|
-
static fromExtendedKey = WalletUnlocked.fromExtendedKey;
|
7760
|
-
/**
|
7761
|
-
* Create a Wallet Unlocked from an encrypted JSON.
|
7762
|
-
*
|
7763
|
-
* @param jsonWallet - The encrypted JSON keystore.
|
7764
|
-
* @param password - The password to decrypt the JSON.
|
7765
|
-
* @param provider - A Provider instance (optional).
|
7766
|
-
* @returns An unlocked wallet instance.
|
7767
|
-
*/
|
7768
|
-
static fromEncryptedJson = WalletUnlocked.fromEncryptedJson;
|
7769
7743
|
};
|
7744
|
+
/**
|
7745
|
+
* Generate a new Wallet Unlocked with a random key pair.
|
7746
|
+
*
|
7747
|
+
* @param generateOptions - Options to customize the generation process (optional).
|
7748
|
+
* @returns An unlocked wallet instance.
|
7749
|
+
*/
|
7750
|
+
__publicField(Wallet, "generate", WalletUnlocked.generate);
|
7751
|
+
/**
|
7752
|
+
* Create a Wallet Unlocked from a seed.
|
7753
|
+
*
|
7754
|
+
* @param seed - The seed phrase.
|
7755
|
+
* @param provider - A Provider instance (optional).
|
7756
|
+
* @param path - The derivation path (optional).
|
7757
|
+
* @returns An unlocked wallet instance.
|
7758
|
+
*/
|
7759
|
+
__publicField(Wallet, "fromSeed", WalletUnlocked.fromSeed);
|
7760
|
+
/**
|
7761
|
+
* Create a Wallet Unlocked from a mnemonic phrase.
|
7762
|
+
*
|
7763
|
+
* @param mnemonic - The mnemonic phrase.
|
7764
|
+
* @param provider - A Provider instance (optional).
|
7765
|
+
* @param path - The derivation path (optional).
|
7766
|
+
* @param passphrase - The passphrase for the mnemonic (optional).
|
7767
|
+
* @returns An unlocked wallet instance.
|
7768
|
+
*/
|
7769
|
+
__publicField(Wallet, "fromMnemonic", WalletUnlocked.fromMnemonic);
|
7770
|
+
/**
|
7771
|
+
* Create a Wallet Unlocked from an extended key.
|
7772
|
+
*
|
7773
|
+
* @param extendedKey - The extended key.
|
7774
|
+
* @param provider - A Provider instance (optional).
|
7775
|
+
* @returns An unlocked wallet instance.
|
7776
|
+
*/
|
7777
|
+
__publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
7778
|
+
/**
|
7779
|
+
* Create a Wallet Unlocked from an encrypted JSON.
|
7780
|
+
*
|
7781
|
+
* @param jsonWallet - The encrypted JSON keystore.
|
7782
|
+
* @param password - The password to decrypt the JSON.
|
7783
|
+
* @param provider - A Provider instance (optional).
|
7784
|
+
* @returns An unlocked wallet instance.
|
7785
|
+
*/
|
7786
|
+
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
7770
7787
|
|
7771
7788
|
// src/test-utils/seedTestWallet.ts
|
7772
7789
|
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
@@ -7845,7 +7862,8 @@ var launchNode = async ({
|
|
7845
7862
|
useSystemFuelCore = false,
|
7846
7863
|
loggingEnabled = true,
|
7847
7864
|
debugEnabled = false,
|
7848
|
-
basePath
|
7865
|
+
basePath,
|
7866
|
+
chainConfig = defaultChainConfig
|
7849
7867
|
}) => (
|
7850
7868
|
// eslint-disable-next-line no-async-promise-executor
|
7851
7869
|
new Promise(async (resolve, reject) => {
|
@@ -7882,17 +7900,17 @@ var launchNode = async ({
|
|
7882
7900
|
mkdirSync(tempDirPath, { recursive: true });
|
7883
7901
|
}
|
7884
7902
|
const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
|
7885
|
-
let
|
7903
|
+
let generatedChainConfig = chainConfig;
|
7886
7904
|
if (!process.env.GENESIS_SECRET) {
|
7887
7905
|
const pk = Signer.generatePrivateKey();
|
7888
7906
|
const signer = new Signer(pk);
|
7889
7907
|
process.env.GENESIS_SECRET = hexlify18(pk);
|
7890
|
-
|
7891
|
-
...
|
7908
|
+
generatedChainConfig = {
|
7909
|
+
...generatedChainConfig,
|
7892
7910
|
initial_state: {
|
7893
|
-
...
|
7911
|
+
...generatedChainConfig.initial_state,
|
7894
7912
|
coins: [
|
7895
|
-
...
|
7913
|
+
...generatedChainConfig.initial_state.coins,
|
7896
7914
|
{
|
7897
7915
|
owner: signer.address.toHexString(),
|
7898
7916
|
amount: toHex2(1e9),
|
@@ -7902,7 +7920,7 @@ var launchNode = async ({
|
|
7902
7920
|
}
|
7903
7921
|
};
|
7904
7922
|
}
|
7905
|
-
writeFileSync(tempChainConfigFilePath, JSON.stringify(
|
7923
|
+
writeFileSync(tempChainConfigFilePath, JSON.stringify(generatedChainConfig), "utf8");
|
7906
7924
|
chainConfigPathToUse = tempChainConfigFilePath;
|
7907
7925
|
}
|
7908
7926
|
const child = spawn(
|
@@ -7940,16 +7958,21 @@ var launchNode = async ({
|
|
7940
7958
|
}
|
7941
7959
|
};
|
7942
7960
|
child.stderr.on("data", (chunk) => {
|
7943
|
-
|
7961
|
+
const text = typeof chunk === "string" ? chunk : chunk.toString();
|
7962
|
+
if (text.indexOf(graphQLStartSubstring) !== -1) {
|
7963
|
+
const rows = text.split("\n");
|
7964
|
+
const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
|
7965
|
+
const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
|
7944
7966
|
resolve({
|
7945
7967
|
cleanup: () => killNode(cleanupConfig),
|
7946
|
-
ip:
|
7947
|
-
port:
|
7968
|
+
ip: realIp,
|
7969
|
+
port: realPort,
|
7970
|
+
url: `http://${realIp}:${realPort}/graphql`,
|
7948
7971
|
chainConfigPath: chainConfigPathToUse
|
7949
7972
|
});
|
7950
7973
|
}
|
7951
|
-
if (/error/i.test(
|
7952
|
-
reject(
|
7974
|
+
if (/error/i.test(text)) {
|
7975
|
+
reject(text.toString());
|
7953
7976
|
}
|
7954
7977
|
});
|
7955
7978
|
process.on("exit", () => killNode(cleanupConfig));
|
@@ -7981,11 +8004,221 @@ var launchNodeAndGetWallets = async ({
|
|
7981
8004
|
};
|
7982
8005
|
return { wallets, stop: cleanup, provider };
|
7983
8006
|
};
|
8007
|
+
|
8008
|
+
// src/test-utils/setup-test-provider-and-wallets.ts
|
8009
|
+
import { defaultChainConfig as defaultChainConfig2 } from "@fuel-ts/utils";
|
8010
|
+
import { mergeDeepRight } from "ramda";
|
8011
|
+
|
8012
|
+
// src/test-utils/asset-id.ts
|
8013
|
+
import { BaseAssetId as BaseAssetId5 } from "@fuel-ts/address/configs";
|
8014
|
+
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
8015
|
+
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
8016
|
+
var _AssetId = class {
|
8017
|
+
constructor(value) {
|
8018
|
+
this.value = value;
|
8019
|
+
}
|
8020
|
+
static random() {
|
8021
|
+
return new _AssetId(hexlify19(randomBytes5(32)));
|
8022
|
+
}
|
8023
|
+
};
|
8024
|
+
var AssetId = _AssetId;
|
8025
|
+
__publicField(AssetId, "BaseAssetId", new _AssetId(BaseAssetId5));
|
8026
|
+
__publicField(AssetId, "A", new _AssetId(
|
8027
|
+
"0x0101010101010101010101010101010101010101010101010101010101010101"
|
8028
|
+
));
|
8029
|
+
__publicField(AssetId, "B", new _AssetId(
|
8030
|
+
"0x0202020202020202020202020202020202020202020202020202020202020202"
|
8031
|
+
));
|
8032
|
+
|
8033
|
+
// src/test-utils/wallet-config.ts
|
8034
|
+
import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
|
8035
|
+
import { FuelError as FuelError19 } from "@fuel-ts/errors";
|
8036
|
+
import { toHex as toHex3 } from "@fuel-ts/math";
|
8037
|
+
var WalletConfig = class {
|
8038
|
+
initialState;
|
8039
|
+
options;
|
8040
|
+
wallets;
|
8041
|
+
generateWallets = () => {
|
8042
|
+
const generatedWallets = [];
|
8043
|
+
for (let index = 1; index <= this.options.count; index++) {
|
8044
|
+
generatedWallets.push(new WalletUnlocked(randomBytes6(32)));
|
8045
|
+
}
|
8046
|
+
return generatedWallets;
|
8047
|
+
};
|
8048
|
+
constructor(config) {
|
8049
|
+
WalletConfig.guard(config);
|
8050
|
+
this.options = config;
|
8051
|
+
const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
|
8052
|
+
this.wallets = this.generateWallets();
|
8053
|
+
this.initialState = {
|
8054
|
+
messages: WalletConfig.createMessages(this.wallets, messages),
|
8055
|
+
coins: WalletConfig.createCoins(this.wallets, assets2, coinsPerAsset, amountPerCoin)
|
8056
|
+
};
|
8057
|
+
}
|
8058
|
+
apply(chainConfig) {
|
8059
|
+
return {
|
8060
|
+
...chainConfig,
|
8061
|
+
initial_state: {
|
8062
|
+
...chainConfig?.initial_state,
|
8063
|
+
coins: this.initialState.coins.concat(chainConfig?.initial_state?.coins || []),
|
8064
|
+
messages: this.initialState.messages.concat(chainConfig?.initial_state?.messages ?? [])
|
8065
|
+
}
|
8066
|
+
};
|
8067
|
+
}
|
8068
|
+
static createMessages(wallets, messages) {
|
8069
|
+
return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
|
8070
|
+
}
|
8071
|
+
static createCoins(wallets, assets2, coinsPerAsset, amountPerCoin) {
|
8072
|
+
const coins = [];
|
8073
|
+
let assetIds = [AssetId.BaseAssetId.value];
|
8074
|
+
if (Array.isArray(assets2)) {
|
8075
|
+
assetIds = assetIds.concat(assets2.map((a) => a.value));
|
8076
|
+
} else {
|
8077
|
+
for (let index = 0; index < assets2 - 1; index++) {
|
8078
|
+
assetIds.push(AssetId.random().value);
|
8079
|
+
}
|
8080
|
+
}
|
8081
|
+
wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
|
8082
|
+
assetIds.forEach((assetId) => {
|
8083
|
+
for (let index = 0; index < coinsPerAsset; index++) {
|
8084
|
+
coins.push({
|
8085
|
+
amount: toHex3(amountPerCoin, 8),
|
8086
|
+
asset_id: assetId,
|
8087
|
+
owner: walletAddress
|
8088
|
+
});
|
8089
|
+
}
|
8090
|
+
});
|
8091
|
+
});
|
8092
|
+
return coins;
|
8093
|
+
}
|
8094
|
+
static guard({
|
8095
|
+
count: wallets,
|
8096
|
+
assets: assets2,
|
8097
|
+
coinsPerAsset,
|
8098
|
+
amountPerCoin
|
8099
|
+
}) {
|
8100
|
+
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
8101
|
+
throw new FuelError19(
|
8102
|
+
FuelError19.CODES.INVALID_INPUT_PARAMETERS,
|
8103
|
+
"Number of wallets must be greater than zero."
|
8104
|
+
);
|
8105
|
+
}
|
8106
|
+
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
8107
|
+
throw new FuelError19(
|
8108
|
+
FuelError19.CODES.INVALID_INPUT_PARAMETERS,
|
8109
|
+
"Number of assets per wallet must be greater than zero."
|
8110
|
+
);
|
8111
|
+
}
|
8112
|
+
if (coinsPerAsset <= 0) {
|
8113
|
+
throw new FuelError19(
|
8114
|
+
FuelError19.CODES.INVALID_INPUT_PARAMETERS,
|
8115
|
+
"Number of coins per asset must be greater than zero."
|
8116
|
+
);
|
8117
|
+
}
|
8118
|
+
if (amountPerCoin <= 0) {
|
8119
|
+
throw new FuelError19(
|
8120
|
+
FuelError19.CODES.INVALID_INPUT_PARAMETERS,
|
8121
|
+
"Amount per coin must be greater than zero."
|
8122
|
+
);
|
8123
|
+
}
|
8124
|
+
}
|
8125
|
+
};
|
8126
|
+
|
8127
|
+
// src/test-utils/setup-test-provider-and-wallets.ts
|
8128
|
+
var defaultWalletConfigOptions = {
|
8129
|
+
count: 2,
|
8130
|
+
assets: [AssetId.A, AssetId.B],
|
8131
|
+
coinsPerAsset: 1,
|
8132
|
+
amountPerCoin: 1e10,
|
8133
|
+
messages: []
|
8134
|
+
};
|
8135
|
+
async function setupTestProviderAndWallets({
|
8136
|
+
walletConfig: walletConfigOptions = {},
|
8137
|
+
providerOptions,
|
8138
|
+
nodeOptions = {}
|
8139
|
+
} = {}) {
|
8140
|
+
Symbol.dispose ??= Symbol("Symbol.dispose");
|
8141
|
+
const walletConfig = new WalletConfig({
|
8142
|
+
...defaultWalletConfigOptions,
|
8143
|
+
...walletConfigOptions
|
8144
|
+
});
|
8145
|
+
const { cleanup, url } = await launchNode({
|
8146
|
+
...nodeOptions,
|
8147
|
+
chainConfig: mergeDeepRight(defaultChainConfig2, walletConfig.apply(nodeOptions?.chainConfig)),
|
8148
|
+
port: "0"
|
8149
|
+
});
|
8150
|
+
let provider;
|
8151
|
+
try {
|
8152
|
+
provider = await Provider.create(url, providerOptions);
|
8153
|
+
} catch (err) {
|
8154
|
+
cleanup();
|
8155
|
+
throw err;
|
8156
|
+
}
|
8157
|
+
const wallets = walletConfig.wallets;
|
8158
|
+
wallets.forEach((wallet) => {
|
8159
|
+
wallet.connect(provider);
|
8160
|
+
});
|
8161
|
+
return {
|
8162
|
+
provider,
|
8163
|
+
wallets,
|
8164
|
+
cleanup,
|
8165
|
+
[Symbol.dispose]: cleanup
|
8166
|
+
};
|
8167
|
+
}
|
8168
|
+
|
8169
|
+
// src/test-utils/test-message.ts
|
8170
|
+
import { Address as Address6 } from "@fuel-ts/address";
|
8171
|
+
import { randomBytes as randomBytes7 } from "@fuel-ts/crypto";
|
8172
|
+
import { BN as BN3 } from "@fuel-ts/math";
|
8173
|
+
import { hexlify as hexlify20 } from "@fuel-ts/utils";
|
8174
|
+
var TestMessage = class {
|
8175
|
+
sender;
|
8176
|
+
recipient;
|
8177
|
+
nonce;
|
8178
|
+
amount;
|
8179
|
+
data;
|
8180
|
+
da_height;
|
8181
|
+
/**
|
8182
|
+
* A helper class to create messages for testing purposes.
|
8183
|
+
*
|
8184
|
+
* Used in tandem with `WalletConfig`.
|
8185
|
+
* It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
|
8186
|
+
*/
|
8187
|
+
constructor({
|
8188
|
+
sender = Address6.fromRandom(),
|
8189
|
+
recipient = Address6.fromRandom(),
|
8190
|
+
nonce = hexlify20(randomBytes7(32)),
|
8191
|
+
amount = 1e6,
|
8192
|
+
data = "02",
|
8193
|
+
da_height = "0x00"
|
8194
|
+
} = {}) {
|
8195
|
+
this.sender = sender;
|
8196
|
+
this.recipient = recipient;
|
8197
|
+
this.nonce = nonce;
|
8198
|
+
this.amount = amount;
|
8199
|
+
this.data = data;
|
8200
|
+
this.da_height = da_height;
|
8201
|
+
}
|
8202
|
+
toChainMessage(recipient) {
|
8203
|
+
return {
|
8204
|
+
sender: this.sender.toB256(),
|
8205
|
+
recipient: recipient?.toB256() ?? this.recipient.toB256(),
|
8206
|
+
nonce: this.nonce,
|
8207
|
+
amount: new BN3(this.amount).toHex(8),
|
8208
|
+
data: this.data,
|
8209
|
+
da_height: this.da_height
|
8210
|
+
};
|
8211
|
+
}
|
8212
|
+
};
|
7984
8213
|
export {
|
8214
|
+
AssetId,
|
8215
|
+
TestMessage,
|
8216
|
+
WalletConfig,
|
7985
8217
|
generateTestWallet,
|
7986
8218
|
killNode,
|
7987
8219
|
launchNode,
|
7988
8220
|
launchNodeAndGetWallets,
|
7989
|
-
seedTestWallet
|
8221
|
+
seedTestWallet,
|
8222
|
+
setupTestProviderAndWallets
|
7990
8223
|
};
|
7991
8224
|
//# sourceMappingURL=test-utils.mjs.map
|