@fuel-ts/account 0.0.0-rc-1866-20240322113439 → 0.0.0-rc-1889-20240322122653
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-E9nGNf5X.d.mts +3837 -0
- package/dist/account-E9nGNf5X.d.ts +3837 -0
- package/dist/configs.d.mts +3 -0
- package/dist/configs.d.ts +3 -2
- package/dist/index.d.mts +904 -0
- package/dist/index.d.ts +904 -13
- package/dist/index.global.js +385 -454
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +202 -248
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -250
- package/dist/index.mjs.map +1 -1
- package/dist/test-utils.d.mts +66 -0
- package/dist/{test-utils/launchNode.d.ts → test-utils.d.ts} +24 -12
- package/dist/test-utils.global.js +289 -332
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +102 -125
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +102 -127
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +21 -25
- package/dist/account.d.ts +0 -177
- package/dist/account.d.ts.map +0 -1
- package/dist/configs.d.ts.map +0 -1
- package/dist/connectors/fuel-connector.d.ts +0 -188
- package/dist/connectors/fuel-connector.d.ts.map +0 -1
- package/dist/connectors/fuel.d.ts +0 -133
- package/dist/connectors/fuel.d.ts.map +0 -1
- package/dist/connectors/index.d.ts +0 -5
- package/dist/connectors/index.d.ts.map +0 -1
- package/dist/connectors/types/connector-metadata.d.ts +0 -12
- package/dist/connectors/types/connector-metadata.d.ts.map +0 -1
- package/dist/connectors/types/connector-types.d.ts +0 -34
- package/dist/connectors/types/connector-types.d.ts.map +0 -1
- package/dist/connectors/types/data-type.d.ts +0 -34
- package/dist/connectors/types/data-type.d.ts.map +0 -1
- package/dist/connectors/types/events.d.ts +0 -111
- package/dist/connectors/types/events.d.ts.map +0 -1
- package/dist/connectors/types/index.d.ts +0 -7
- package/dist/connectors/types/index.d.ts.map +0 -1
- package/dist/connectors/types/local-storage.d.ts +0 -11
- package/dist/connectors/types/local-storage.d.ts.map +0 -1
- package/dist/connectors/types/target-object.d.ts +0 -14
- package/dist/connectors/types/target-object.d.ts.map +0 -1
- package/dist/connectors/utils/cache.d.ts +0 -14
- package/dist/connectors/utils/cache.d.ts.map +0 -1
- package/dist/connectors/utils/dispatch-fuel-connector-event.d.ts +0 -7
- package/dist/connectors/utils/dispatch-fuel-connector-event.d.ts.map +0 -1
- package/dist/connectors/utils/index.d.ts +0 -4
- package/dist/connectors/utils/index.d.ts.map +0 -1
- package/dist/connectors/utils/promises.d.ts +0 -8
- package/dist/connectors/utils/promises.d.ts.map +0 -1
- package/dist/hdwallet/hdwallet.d.ts +0 -58
- package/dist/hdwallet/hdwallet.d.ts.map +0 -1
- package/dist/hdwallet/index.d.ts +0 -2
- package/dist/hdwallet/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/mnemonic/index.d.ts +0 -3
- package/dist/mnemonic/index.d.ts.map +0 -1
- package/dist/mnemonic/mnemonic.d.ts +0 -85
- package/dist/mnemonic/mnemonic.d.ts.map +0 -1
- package/dist/mnemonic/utils.d.ts +0 -8
- package/dist/mnemonic/utils.d.ts.map +0 -1
- package/dist/predicate/index.d.ts +0 -3
- package/dist/predicate/index.d.ts.map +0 -1
- package/dist/predicate/predicate.d.ts +0 -94
- package/dist/predicate/predicate.d.ts.map +0 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts +0 -12
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +0 -1
- package/dist/predicate/utils/index.d.ts +0 -2
- package/dist/predicate/utils/index.d.ts.map +0 -1
- package/dist/providers/__generated__/operations.d.ts +0 -3477
- package/dist/providers/__generated__/operations.d.ts.map +0 -1
- package/dist/providers/assets/index.d.ts +0 -5
- package/dist/providers/assets/index.d.ts.map +0 -1
- package/dist/providers/assets/types.d.ts +0 -36
- package/dist/providers/assets/types.d.ts.map +0 -1
- package/dist/providers/assets/utils/index.d.ts +0 -4
- package/dist/providers/assets/utils/index.d.ts.map +0 -1
- package/dist/providers/assets/utils/network.d.ts +0 -33
- package/dist/providers/assets/utils/network.d.ts.map +0 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +0 -14
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +0 -1
- package/dist/providers/assets/utils/url.d.ts +0 -2
- package/dist/providers/assets/utils/url.d.ts.map +0 -1
- package/dist/providers/chains.d.ts +0 -11
- package/dist/providers/chains.d.ts.map +0 -1
- package/dist/providers/coin-quantity.d.ts +0 -21
- package/dist/providers/coin-quantity.d.ts.map +0 -1
- package/dist/providers/coin.d.ts +0 -15
- package/dist/providers/coin.d.ts.map +0 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +0 -23
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +0 -1
- package/dist/providers/index.d.ts +0 -13
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/memory-cache.d.ts +0 -11
- package/dist/providers/memory-cache.d.ts.map +0 -1
- package/dist/providers/message.d.ts +0 -60
- package/dist/providers/message.d.ts.map +0 -1
- package/dist/providers/provider.d.ts +0 -522
- package/dist/providers/provider.d.ts.map +0 -1
- package/dist/providers/resource.d.ts +0 -37
- package/dist/providers/resource.d.ts.map +0 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +0 -73
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +0 -1
- package/dist/providers/transaction-request/errors.d.ts +0 -25
- package/dist/providers/transaction-request/errors.d.ts.map +0 -1
- package/dist/providers/transaction-request/hash-transaction.d.ts +0 -9
- package/dist/providers/transaction-request/hash-transaction.d.ts.map +0 -1
- package/dist/providers/transaction-request/index.d.ts +0 -10
- package/dist/providers/transaction-request/index.d.ts.map +0 -1
- package/dist/providers/transaction-request/input.d.ts +0 -59
- package/dist/providers/transaction-request/input.d.ts.map +0 -1
- package/dist/providers/transaction-request/output.d.ts +0 -39
- package/dist/providers/transaction-request/output.d.ts.map +0 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +0 -106
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +0 -1
- package/dist/providers/transaction-request/scripts.d.ts +0 -6
- package/dist/providers/transaction-request/scripts.d.ts.map +0 -1
- package/dist/providers/transaction-request/storage-slot.d.ts +0 -10
- package/dist/providers/transaction-request/storage-slot.d.ts.map +0 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +0 -259
- package/dist/providers/transaction-request/transaction-request.d.ts.map +0 -1
- package/dist/providers/transaction-request/types.d.ts +0 -10
- package/dist/providers/transaction-request/types.d.ts.map +0 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -4
- package/dist/providers/transaction-request/utils.d.ts.map +0 -1
- package/dist/providers/transaction-request/witness.d.ts +0 -5
- package/dist/providers/transaction-request/witness.d.ts.map +0 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts +0 -5
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +0 -1
- package/dist/providers/transaction-response/index.d.ts +0 -3
- package/dist/providers/transaction-response/index.d.ts.map +0 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +0 -106
- package/dist/providers/transaction-response/transaction-response.d.ts.map +0 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -20
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +0 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +0 -21
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +0 -1
- package/dist/providers/transaction-summary/call.d.ts +0 -18
- package/dist/providers/transaction-summary/call.d.ts.map +0 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts +0 -31
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +0 -1
- package/dist/providers/transaction-summary/index.d.ts +0 -10
- package/dist/providers/transaction-summary/index.d.ts.map +0 -1
- package/dist/providers/transaction-summary/input.d.ts +0 -21
- package/dist/providers/transaction-summary/input.d.ts.map +0 -1
- package/dist/providers/transaction-summary/operations.d.ts +0 -40
- package/dist/providers/transaction-summary/operations.d.ts.map +0 -1
- package/dist/providers/transaction-summary/output.d.ts +0 -15
- package/dist/providers/transaction-summary/output.d.ts.map +0 -1
- package/dist/providers/transaction-summary/receipt.d.ts +0 -7
- package/dist/providers/transaction-summary/receipt.d.ts.map +0 -1
- package/dist/providers/transaction-summary/status.d.ts +0 -9
- package/dist/providers/transaction-summary/status.d.ts.map +0 -1
- package/dist/providers/transaction-summary/types.d.ts +0 -146
- package/dist/providers/transaction-summary/types.d.ts.map +0 -1
- package/dist/providers/utils/auto-retry-fetch.d.ts +0 -36
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +0 -1
- package/dist/providers/utils/block-explorer.d.ts +0 -14
- package/dist/providers/utils/block-explorer.d.ts.map +0 -1
- package/dist/providers/utils/gas.d.ts +0 -38
- package/dist/providers/utils/gas.d.ts.map +0 -1
- package/dist/providers/utils/index.d.ts +0 -6
- package/dist/providers/utils/index.d.ts.map +0 -1
- package/dist/providers/utils/json.d.ts +0 -7
- package/dist/providers/utils/json.d.ts.map +0 -1
- package/dist/providers/utils/merge-quantities.d.ts +0 -3
- package/dist/providers/utils/merge-quantities.d.ts.map +0 -1
- package/dist/providers/utils/receipts.d.ts +0 -10
- package/dist/providers/utils/receipts.d.ts.map +0 -1
- package/dist/providers/utils/sleep.d.ts +0 -3
- package/dist/providers/utils/sleep.d.ts.map +0 -1
- package/dist/signer/index.d.ts +0 -2
- package/dist/signer/index.d.ts.map +0 -1
- package/dist/signer/signer.d.ts +0 -64
- package/dist/signer/signer.d.ts.map +0 -1
- package/dist/test-utils/generateTestWallet.d.ts +0 -4
- package/dist/test-utils/generateTestWallet.d.ts.map +0 -1
- package/dist/test-utils/index.d.ts +0 -4
- package/dist/test-utils/index.d.ts.map +0 -1
- package/dist/test-utils/launchNode.d.ts.map +0 -1
- package/dist/test-utils/seedTestWallet.d.ts +0 -4
- package/dist/test-utils/seedTestWallet.d.ts.map +0 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +0 -14
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +0 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +0 -73
- package/dist/wallet/base-wallet-unlocked.d.ts.map +0 -1
- package/dist/wallet/index.d.ts +0 -4
- package/dist/wallet/index.d.ts.map +0 -1
- package/dist/wallet/keystore-wallet.d.ts +0 -38
- package/dist/wallet/keystore-wallet.d.ts.map +0 -1
- package/dist/wallet/wallet.d.ts +0 -68
- package/dist/wallet/wallet.d.ts.map +0 -1
- package/dist/wallet/wallets.d.ts +0 -76
- package/dist/wallet/wallets.d.ts.map +0 -1
- package/dist/wallet-manager/index.d.ts +0 -6
- package/dist/wallet-manager/index.d.ts.map +0 -1
- package/dist/wallet-manager/storages/memory-storage.d.ts +0 -9
- package/dist/wallet-manager/storages/memory-storage.d.ts.map +0 -1
- package/dist/wallet-manager/types.d.ts +0 -42
- package/dist/wallet-manager/types.d.ts.map +0 -1
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +0 -29
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +0 -1
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts +0 -29
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +0 -1
- package/dist/wallet-manager/wallet-manager.d.ts +0 -104
- package/dist/wallet-manager/wallet-manager.d.ts.map +0 -1
- package/dist/wordlists/index.d.ts +0 -5
- package/dist/wordlists/index.d.ts.map +0 -1
- package/dist/wordlists/words/english.d.ts +0 -2
- package/dist/wordlists/words/english.d.ts.map +0 -1
package/dist/test-utils.mjs
CHANGED
@@ -1,23 +1,3 @@
|
|
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
|
-
|
21
1
|
// src/wallet/base-wallet-unlocked.ts
|
22
2
|
import { hashMessage } from "@fuel-ts/hasher";
|
23
3
|
import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
@@ -891,11 +871,12 @@ function getSdk(requester) {
|
|
891
871
|
// src/providers/fuel-graphql-subscriber.ts
|
892
872
|
import { ErrorCode, FuelError } from "@fuel-ts/errors";
|
893
873
|
import { print } from "graphql";
|
894
|
-
var
|
874
|
+
var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
895
875
|
constructor(options) {
|
896
876
|
this.options = options;
|
897
877
|
}
|
898
878
|
stream;
|
879
|
+
static textDecoder = new TextDecoder();
|
899
880
|
async setStream() {
|
900
881
|
const { url, query, variables, fetchFn } = this.options;
|
901
882
|
const response = await fetchFn(`${url}-sub`, {
|
@@ -955,8 +936,6 @@ var _FuelGraphqlSubscriber = class {
|
|
955
936
|
return this;
|
956
937
|
}
|
957
938
|
};
|
958
|
-
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
959
|
-
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
960
939
|
|
961
940
|
// src/providers/memory-cache.ts
|
962
941
|
import { ErrorCode as ErrorCode2, FuelError as FuelError2 } from "@fuel-ts/errors";
|
@@ -1516,7 +1495,7 @@ var witnessify = (value) => {
|
|
1516
1495
|
};
|
1517
1496
|
|
1518
1497
|
// src/providers/transaction-request/transaction-request.ts
|
1519
|
-
var BaseTransactionRequest = class {
|
1498
|
+
var BaseTransactionRequest = class _BaseTransactionRequest {
|
1520
1499
|
/** Gas price for transaction */
|
1521
1500
|
gasPrice;
|
1522
1501
|
/** Block until which tx cannot be included */
|
@@ -1586,7 +1565,7 @@ var BaseTransactionRequest = class {
|
|
1586
1565
|
const inputs = this.inputs?.map(inputify) ?? [];
|
1587
1566
|
const outputs = this.outputs?.map(outputify) ?? [];
|
1588
1567
|
const witnesses = this.witnesses?.map(witnessify) ?? [];
|
1589
|
-
const { policyTypes, policies } =
|
1568
|
+
const { policyTypes, policies } = _BaseTransactionRequest.getPolicyMeta(this);
|
1590
1569
|
return {
|
1591
1570
|
policyTypes,
|
1592
1571
|
inputs,
|
@@ -3124,7 +3103,7 @@ function assembleTransactionSummary(params) {
|
|
3124
3103
|
}
|
3125
3104
|
|
3126
3105
|
// src/providers/transaction-response/transaction-response.ts
|
3127
|
-
var TransactionResponse = class {
|
3106
|
+
var TransactionResponse = class _TransactionResponse {
|
3128
3107
|
/** Transaction ID */
|
3129
3108
|
id;
|
3130
3109
|
/** Current provider */
|
@@ -3152,7 +3131,7 @@ var TransactionResponse = class {
|
|
3152
3131
|
* @param provider - The provider.
|
3153
3132
|
*/
|
3154
3133
|
static async create(id, provider) {
|
3155
|
-
const response = new
|
3134
|
+
const response = new _TransactionResponse(id, provider);
|
3156
3135
|
await response.fetch();
|
3157
3136
|
return response;
|
3158
3137
|
}
|
@@ -3367,8 +3346,7 @@ var processGqlChain = (chain) => {
|
|
3367
3346
|
}
|
3368
3347
|
};
|
3369
3348
|
};
|
3370
|
-
var
|
3371
|
-
var _Provider = class {
|
3349
|
+
var Provider = class _Provider {
|
3372
3350
|
/**
|
3373
3351
|
* Constructor to initialize a Provider.
|
3374
3352
|
*
|
@@ -3379,27 +3357,25 @@ var _Provider = class {
|
|
3379
3357
|
*/
|
3380
3358
|
constructor(url, options = {}) {
|
3381
3359
|
this.url = url;
|
3382
|
-
/**
|
3383
|
-
* @hidden
|
3384
|
-
*/
|
3385
|
-
__privateAdd(this, _cacheInputs);
|
3386
|
-
__publicField(this, "operations");
|
3387
|
-
__publicField(this, "cache");
|
3388
|
-
__publicField(this, "options", {
|
3389
|
-
timeout: void 0,
|
3390
|
-
cacheUtxo: void 0,
|
3391
|
-
fetch: void 0,
|
3392
|
-
retryOptions: void 0
|
3393
|
-
});
|
3394
3360
|
this.options = { ...this.options, ...options };
|
3395
3361
|
this.url = url;
|
3396
3362
|
this.operations = this.createOperations();
|
3397
3363
|
this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
|
3398
3364
|
}
|
3365
|
+
operations;
|
3366
|
+
cache;
|
3399
3367
|
static clearChainAndNodeCaches() {
|
3400
3368
|
_Provider.nodeInfoCache = {};
|
3401
3369
|
_Provider.chainInfoCache = {};
|
3402
3370
|
}
|
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
|
+
};
|
3403
3379
|
static getFetchFn(options) {
|
3404
3380
|
const { retryOptions, timeout } = options;
|
3405
3381
|
return autoRetryFetch(async (...args) => {
|
@@ -3596,6 +3572,19 @@ var _Provider = class {
|
|
3596
3572
|
} = this.getChain();
|
3597
3573
|
return chainId.toNumber();
|
3598
3574
|
}
|
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
|
+
}
|
3599
3588
|
/**
|
3600
3589
|
* Submits a transaction to the chain to be executed.
|
3601
3590
|
*
|
@@ -3608,7 +3597,7 @@ var _Provider = class {
|
|
3608
3597
|
// #region Provider-sendTransaction
|
3609
3598
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution = false } = {}) {
|
3610
3599
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
3611
|
-
|
3600
|
+
this.#cacheInputs(transactionRequest.inputs);
|
3612
3601
|
if (estimateTxDependencies) {
|
3613
3602
|
await this.estimateTxDependencies(transactionRequest);
|
3614
3603
|
}
|
@@ -4233,20 +4222,6 @@ var _Provider = class {
|
|
4233
4222
|
return new TransactionResponse(transactionId, this);
|
4234
4223
|
}
|
4235
4224
|
};
|
4236
|
-
var Provider = _Provider;
|
4237
|
-
_cacheInputs = new WeakSet();
|
4238
|
-
cacheInputs_fn = function(inputs) {
|
4239
|
-
if (!this.cache) {
|
4240
|
-
return;
|
4241
|
-
}
|
4242
|
-
inputs.forEach((input) => {
|
4243
|
-
if (input.type === InputType6.Coin) {
|
4244
|
-
this.cache?.set(input.id);
|
4245
|
-
}
|
4246
|
-
});
|
4247
|
-
};
|
4248
|
-
__publicField(Provider, "chainInfoCache", {});
|
4249
|
-
__publicField(Provider, "nodeInfoCache", {});
|
4250
4225
|
|
4251
4226
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4252
4227
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
@@ -4747,7 +4722,7 @@ import { hash } from "@fuel-ts/hasher";
|
|
4747
4722
|
import { toBytes } from "@fuel-ts/math";
|
4748
4723
|
import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
|
4749
4724
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
4750
|
-
var Signer = class {
|
4725
|
+
var Signer = class _Signer {
|
4751
4726
|
address;
|
4752
4727
|
publicKey;
|
4753
4728
|
compressedPublicKey;
|
@@ -4826,7 +4801,7 @@ var Signer = class {
|
|
4826
4801
|
* @returns Address from signature
|
4827
4802
|
*/
|
4828
4803
|
static recoverAddress(data, signature) {
|
4829
|
-
return Address4.fromPublicKey(
|
4804
|
+
return Address4.fromPublicKey(_Signer.recoverPublicKey(data, signature));
|
4830
4805
|
}
|
4831
4806
|
/**
|
4832
4807
|
* Generate a random privateKey
|
@@ -4950,6 +4925,10 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
4950
4925
|
|
4951
4926
|
// src/wallet/base-wallet-unlocked.ts
|
4952
4927
|
var BaseWalletUnlocked = class extends Account {
|
4928
|
+
/**
|
4929
|
+
* Default HDWallet path.
|
4930
|
+
*/
|
4931
|
+
static defaultPath = "m/44'/1179993420'/0'/0/0";
|
4953
4932
|
/**
|
4954
4933
|
* A function that returns the wallet's signer.
|
4955
4934
|
*/
|
@@ -5055,10 +5034,6 @@ var BaseWalletUnlocked = class extends Account {
|
|
5055
5034
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
5056
5035
|
}
|
5057
5036
|
};
|
5058
|
-
/**
|
5059
|
-
* Default HDWallet path.
|
5060
|
-
*/
|
5061
|
-
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5062
5037
|
|
5063
5038
|
// src/hdwallet/hdwallet.ts
|
5064
5039
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
@@ -7262,7 +7237,7 @@ function assertMnemonic(words) {
|
|
7262
7237
|
throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
|
7263
7238
|
}
|
7264
7239
|
}
|
7265
|
-
var Mnemonic = class {
|
7240
|
+
var Mnemonic = class _Mnemonic {
|
7266
7241
|
wordlist;
|
7267
7242
|
/**
|
7268
7243
|
*
|
@@ -7279,7 +7254,7 @@ var Mnemonic = class {
|
|
7279
7254
|
* @returns Entropy hash
|
7280
7255
|
*/
|
7281
7256
|
mnemonicToEntropy(phrase) {
|
7282
|
-
return
|
7257
|
+
return _Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
|
7283
7258
|
}
|
7284
7259
|
/**
|
7285
7260
|
*
|
@@ -7287,7 +7262,7 @@ var Mnemonic = class {
|
|
7287
7262
|
* @returns Mnemonic phrase
|
7288
7263
|
*/
|
7289
7264
|
entropyToMnemonic(entropy) {
|
7290
|
-
return
|
7265
|
+
return _Mnemonic.entropyToMnemonic(entropy, this.wordlist);
|
7291
7266
|
}
|
7292
7267
|
/**
|
7293
7268
|
*
|
@@ -7328,8 +7303,8 @@ var Mnemonic = class {
|
|
7328
7303
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7329
7304
|
*/
|
7330
7305
|
static mnemonicToMasterKeys(phrase, passphrase = "") {
|
7331
|
-
const seed =
|
7332
|
-
return
|
7306
|
+
const seed = _Mnemonic.mnemonicToSeed(phrase, passphrase);
|
7307
|
+
return _Mnemonic.masterKeysFromSeed(seed);
|
7333
7308
|
}
|
7334
7309
|
/**
|
7335
7310
|
* Validates if given mnemonic is valid
|
@@ -7345,7 +7320,7 @@ var Mnemonic = class {
|
|
7345
7320
|
return false;
|
7346
7321
|
}
|
7347
7322
|
while (i < words.length) {
|
7348
|
-
if (
|
7323
|
+
if (_Mnemonic.binarySearch(words[i]) === false) {
|
7349
7324
|
return false;
|
7350
7325
|
}
|
7351
7326
|
i += 1;
|
@@ -7392,7 +7367,7 @@ var Mnemonic = class {
|
|
7392
7367
|
* @returns BIP-32 extended private key
|
7393
7368
|
*/
|
7394
7369
|
static seedToExtendedKey(seed, testnet = false) {
|
7395
|
-
const masterKey =
|
7370
|
+
const masterKey = _Mnemonic.masterKeysFromSeed(seed);
|
7396
7371
|
const prefix = arrayify17(testnet ? TestnetPRV : MainnetPRV);
|
7397
7372
|
const depth = "0x00";
|
7398
7373
|
const fingerprint = "0x00000000";
|
@@ -7424,7 +7399,7 @@ var Mnemonic = class {
|
|
7424
7399
|
*/
|
7425
7400
|
static generate(size = 32, extraEntropy = "") {
|
7426
7401
|
const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
|
7427
|
-
return
|
7402
|
+
return _Mnemonic.entropyToMnemonic(entropy);
|
7428
7403
|
}
|
7429
7404
|
};
|
7430
7405
|
var mnemonic_default = Mnemonic;
|
@@ -7464,7 +7439,7 @@ function parsePath(path2, depth = 0) {
|
|
7464
7439
|
(p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
|
7465
7440
|
);
|
7466
7441
|
}
|
7467
|
-
var HDWallet = class {
|
7442
|
+
var HDWallet = class _HDWallet {
|
7468
7443
|
depth = 0;
|
7469
7444
|
index = 0;
|
7470
7445
|
fingerprint = hexlify17("0x00000000");
|
@@ -7530,7 +7505,7 @@ var HDWallet = class {
|
|
7530
7505
|
if (privateKey) {
|
7531
7506
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7532
7507
|
const ki = bn17(IL).add(privateKey).mod(N).toBytes(32);
|
7533
|
-
return new
|
7508
|
+
return new _HDWallet({
|
7534
7509
|
privateKey: ki,
|
7535
7510
|
chainCode: IR,
|
7536
7511
|
index,
|
@@ -7540,7 +7515,7 @@ var HDWallet = class {
|
|
7540
7515
|
}
|
7541
7516
|
const signer = new Signer(hexlify17(IL));
|
7542
7517
|
const Ki = signer.addPoint(publicKey);
|
7543
|
-
return new
|
7518
|
+
return new _HDWallet({
|
7544
7519
|
publicKey: Ki,
|
7545
7520
|
chainCode: IR,
|
7546
7521
|
index,
|
@@ -7589,7 +7564,7 @@ var HDWallet = class {
|
|
7589
7564
|
*/
|
7590
7565
|
static fromSeed(seed) {
|
7591
7566
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7592
|
-
return new
|
7567
|
+
return new _HDWallet({
|
7593
7568
|
chainCode: arrayify18(masterKey.slice(32)),
|
7594
7569
|
privateKey: arrayify18(masterKey.slice(0, 32))
|
7595
7570
|
});
|
@@ -7619,7 +7594,7 @@ var HDWallet = class {
|
|
7619
7594
|
if (key[0] !== 3) {
|
7620
7595
|
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
|
7621
7596
|
}
|
7622
|
-
return new
|
7597
|
+
return new _HDWallet({
|
7623
7598
|
publicKey: key,
|
7624
7599
|
chainCode,
|
7625
7600
|
index,
|
@@ -7630,7 +7605,7 @@ var HDWallet = class {
|
|
7630
7605
|
if (key[0] !== 0) {
|
7631
7606
|
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
|
7632
7607
|
}
|
7633
|
-
return new
|
7608
|
+
return new _HDWallet({
|
7634
7609
|
privateKey: key.slice(1),
|
7635
7610
|
chainCode,
|
7636
7611
|
index,
|
@@ -7653,7 +7628,7 @@ var WalletLocked = class extends Account {
|
|
7653
7628
|
return new WalletUnlocked(privateKey, this._provider);
|
7654
7629
|
}
|
7655
7630
|
};
|
7656
|
-
var WalletUnlocked = class extends BaseWalletUnlocked {
|
7631
|
+
var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
7657
7632
|
/**
|
7658
7633
|
* Locks the wallet and returns an instance of WalletLocked.
|
7659
7634
|
*
|
@@ -7671,7 +7646,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
7671
7646
|
*/
|
7672
7647
|
static generate(generateOptions) {
|
7673
7648
|
const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
|
7674
|
-
return new
|
7649
|
+
return new _WalletUnlocked(privateKey, generateOptions?.provider);
|
7675
7650
|
}
|
7676
7651
|
/**
|
7677
7652
|
* Create a Wallet Unlocked from a seed.
|
@@ -7683,8 +7658,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
7683
7658
|
*/
|
7684
7659
|
static fromSeed(seed, path2, provider) {
|
7685
7660
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
7686
|
-
const childWallet = hdWallet.derivePath(path2 ||
|
7687
|
-
return new
|
7661
|
+
const childWallet = hdWallet.derivePath(path2 || _WalletUnlocked.defaultPath);
|
7662
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
7688
7663
|
}
|
7689
7664
|
/**
|
7690
7665
|
* Create a Wallet Unlocked from a mnemonic phrase.
|
@@ -7698,8 +7673,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
7698
7673
|
static fromMnemonic(mnemonic, path2, passphrase, provider) {
|
7699
7674
|
const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
|
7700
7675
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
7701
|
-
const childWallet = hdWallet.derivePath(path2 ||
|
7702
|
-
return new
|
7676
|
+
const childWallet = hdWallet.derivePath(path2 || _WalletUnlocked.defaultPath);
|
7677
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
7703
7678
|
}
|
7704
7679
|
/**
|
7705
7680
|
* Create a Wallet Unlocked from an extended key.
|
@@ -7710,7 +7685,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
7710
7685
|
*/
|
7711
7686
|
static fromExtendedKey(extendedKey, provider) {
|
7712
7687
|
const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
|
7713
|
-
return new
|
7688
|
+
return new _WalletUnlocked(hdWallet.privateKey, provider);
|
7714
7689
|
}
|
7715
7690
|
/**
|
7716
7691
|
* Create a Wallet Unlocked from an encrypted JSON.
|
@@ -7722,7 +7697,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
7722
7697
|
*/
|
7723
7698
|
static async fromEncryptedJson(jsonWallet, password, provider) {
|
7724
7699
|
const privateKey = await decryptKeystoreWallet(jsonWallet, password);
|
7725
|
-
return new
|
7700
|
+
return new _WalletUnlocked(privateKey, provider);
|
7726
7701
|
}
|
7727
7702
|
};
|
7728
7703
|
|
@@ -7748,50 +7723,50 @@ var Wallet = class {
|
|
7748
7723
|
static fromPrivateKey(privateKey, provider) {
|
7749
7724
|
return new WalletUnlocked(privateKey, provider);
|
7750
7725
|
}
|
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;
|
7751
7769
|
};
|
7752
|
-
/**
|
7753
|
-
* Generate a new Wallet Unlocked with a random key pair.
|
7754
|
-
*
|
7755
|
-
* @param generateOptions - Options to customize the generation process (optional).
|
7756
|
-
* @returns An unlocked wallet instance.
|
7757
|
-
*/
|
7758
|
-
__publicField(Wallet, "generate", WalletUnlocked.generate);
|
7759
|
-
/**
|
7760
|
-
* Create a Wallet Unlocked from a seed.
|
7761
|
-
*
|
7762
|
-
* @param seed - The seed phrase.
|
7763
|
-
* @param provider - A Provider instance (optional).
|
7764
|
-
* @param path - The derivation path (optional).
|
7765
|
-
* @returns An unlocked wallet instance.
|
7766
|
-
*/
|
7767
|
-
__publicField(Wallet, "fromSeed", WalletUnlocked.fromSeed);
|
7768
|
-
/**
|
7769
|
-
* Create a Wallet Unlocked from a mnemonic phrase.
|
7770
|
-
*
|
7771
|
-
* @param mnemonic - The mnemonic phrase.
|
7772
|
-
* @param provider - A Provider instance (optional).
|
7773
|
-
* @param path - The derivation path (optional).
|
7774
|
-
* @param passphrase - The passphrase for the mnemonic (optional).
|
7775
|
-
* @returns An unlocked wallet instance.
|
7776
|
-
*/
|
7777
|
-
__publicField(Wallet, "fromMnemonic", WalletUnlocked.fromMnemonic);
|
7778
|
-
/**
|
7779
|
-
* Create a Wallet Unlocked from an extended key.
|
7780
|
-
*
|
7781
|
-
* @param extendedKey - The extended key.
|
7782
|
-
* @param provider - A Provider instance (optional).
|
7783
|
-
* @returns An unlocked wallet instance.
|
7784
|
-
*/
|
7785
|
-
__publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
7786
|
-
/**
|
7787
|
-
* Create a Wallet Unlocked from an encrypted JSON.
|
7788
|
-
*
|
7789
|
-
* @param jsonWallet - The encrypted JSON keystore.
|
7790
|
-
* @param password - The password to decrypt the JSON.
|
7791
|
-
* @param provider - A Provider instance (optional).
|
7792
|
-
* @returns An unlocked wallet instance.
|
7793
|
-
*/
|
7794
|
-
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
7795
7770
|
|
7796
7771
|
// src/test-utils/seedTestWallet.ts
|
7797
7772
|
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|