@fuel-ts/account 0.0.0-rc-1815-20240322115843 → 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 +390 -515
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +207 -309
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +207 -311
- 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 +294 -381
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +107 -174
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +107 -176
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +21 -25
- package/dist/account.d.ts +0 -184
- package/dist/account.d.ts.map +0 -1
- package/dist/configs.d.ts.map +0 -1
- package/dist/connectors/fuel-connector.d.ts +0 -198
- 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 -278
- 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/index.js
CHANGED
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
9
8
|
var __export = (target, all) => {
|
10
9
|
for (var name in all)
|
11
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -27,32 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
27
26
|
mod
|
28
27
|
));
|
29
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
30
|
-
var __publicField = (obj, key, value) => {
|
31
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
32
|
-
return value;
|
33
|
-
};
|
34
|
-
var __accessCheck = (obj, member, msg) => {
|
35
|
-
if (!member.has(obj))
|
36
|
-
throw TypeError("Cannot " + msg);
|
37
|
-
};
|
38
|
-
var __privateGet = (obj, member, getter) => {
|
39
|
-
__accessCheck(obj, member, "read from private field");
|
40
|
-
return getter ? getter.call(obj) : member.get(obj);
|
41
|
-
};
|
42
|
-
var __privateAdd = (obj, member, value) => {
|
43
|
-
if (member.has(obj))
|
44
|
-
throw TypeError("Cannot add the same private member more than once");
|
45
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
46
|
-
};
|
47
|
-
var __privateSet = (obj, member, value, setter) => {
|
48
|
-
__accessCheck(obj, member, "write to private field");
|
49
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
50
|
-
return value;
|
51
|
-
};
|
52
|
-
var __privateMethod = (obj, member, method) => {
|
53
|
-
__accessCheck(obj, member, "access private method");
|
54
|
-
return method;
|
55
|
-
};
|
56
29
|
|
57
30
|
// src/index.ts
|
58
31
|
var src_exports = {};
|
@@ -1043,11 +1016,12 @@ function getSdk(requester) {
|
|
1043
1016
|
// src/providers/fuel-graphql-subscriber.ts
|
1044
1017
|
var import_errors = require("@fuel-ts/errors");
|
1045
1018
|
var import_graphql = require("graphql");
|
1046
|
-
var
|
1019
|
+
var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
1047
1020
|
constructor(options) {
|
1048
1021
|
this.options = options;
|
1049
1022
|
}
|
1050
1023
|
stream;
|
1024
|
+
static textDecoder = new TextDecoder();
|
1051
1025
|
async setStream() {
|
1052
1026
|
const { url, query, variables, fetchFn } = this.options;
|
1053
1027
|
const response = await fetchFn(`${url}-sub`, {
|
@@ -1107,8 +1081,6 @@ var _FuelGraphqlSubscriber = class {
|
|
1107
1081
|
return this;
|
1108
1082
|
}
|
1109
1083
|
};
|
1110
|
-
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
1111
|
-
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1112
1084
|
|
1113
1085
|
// src/providers/memory-cache.ts
|
1114
1086
|
var import_errors2 = require("@fuel-ts/errors");
|
@@ -1731,7 +1703,7 @@ var witnessify = (value) => {
|
|
1731
1703
|
};
|
1732
1704
|
|
1733
1705
|
// src/providers/transaction-request/transaction-request.ts
|
1734
|
-
var BaseTransactionRequest = class {
|
1706
|
+
var BaseTransactionRequest = class _BaseTransactionRequest {
|
1735
1707
|
/** Gas price for transaction */
|
1736
1708
|
gasPrice;
|
1737
1709
|
/** Block until which tx cannot be included */
|
@@ -1801,7 +1773,7 @@ var BaseTransactionRequest = class {
|
|
1801
1773
|
const inputs = this.inputs?.map(inputify) ?? [];
|
1802
1774
|
const outputs = this.outputs?.map(outputify) ?? [];
|
1803
1775
|
const witnesses = this.witnesses?.map(witnessify) ?? [];
|
1804
|
-
const { policyTypes, policies } =
|
1776
|
+
const { policyTypes, policies } = _BaseTransactionRequest.getPolicyMeta(this);
|
1805
1777
|
return {
|
1806
1778
|
policyTypes,
|
1807
1779
|
inputs,
|
@@ -1839,27 +1811,13 @@ var BaseTransactionRequest = class {
|
|
1839
1811
|
this.outputs.push(output);
|
1840
1812
|
return this.outputs.length - 1;
|
1841
1813
|
}
|
1842
|
-
/**
|
1843
|
-
* @hidden
|
1844
|
-
*
|
1845
|
-
* Pushes a witness to the list and returns the index
|
1846
|
-
*
|
1847
|
-
* @param signature - The signature to add to the witness.
|
1848
|
-
* @returns The index of the created witness.
|
1849
|
-
*/
|
1850
|
-
addWitness(signature) {
|
1851
|
-
this.witnesses.push(signature);
|
1852
|
-
return this.witnesses.length - 1;
|
1853
|
-
}
|
1854
1814
|
/**
|
1855
1815
|
* @hidden
|
1856
1816
|
*
|
1857
1817
|
* Creates an empty witness without any side effects and returns the index
|
1858
|
-
*
|
1859
|
-
* @returns The index of the created witness.
|
1860
1818
|
*/
|
1861
|
-
|
1862
|
-
this.
|
1819
|
+
createWitness() {
|
1820
|
+
this.witnesses.push((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1863
1821
|
return this.witnesses.length - 1;
|
1864
1822
|
}
|
1865
1823
|
/**
|
@@ -1888,21 +1846,6 @@ var BaseTransactionRequest = class {
|
|
1888
1846
|
}
|
1889
1847
|
this.witnesses[index] = witness;
|
1890
1848
|
}
|
1891
|
-
/**
|
1892
|
-
* Helper function to add an external signature to the transaction.
|
1893
|
-
*
|
1894
|
-
* @param account - The account/s to sign to the transaction.
|
1895
|
-
* @returns The transaction with the signature witness added.
|
1896
|
-
*/
|
1897
|
-
async addAccountWitnesses(account) {
|
1898
|
-
const accounts = Array.isArray(account) ? account : [account];
|
1899
|
-
await Promise.all(
|
1900
|
-
accounts.map(async (acc) => {
|
1901
|
-
this.addWitness(await acc.signTransaction(this));
|
1902
|
-
})
|
1903
|
-
);
|
1904
|
-
return this;
|
1905
|
-
}
|
1906
1849
|
/**
|
1907
1850
|
* Gets the coin inputs for a transaction.
|
1908
1851
|
*
|
@@ -1968,7 +1911,7 @@ var BaseTransactionRequest = class {
|
|
1968
1911
|
} else {
|
1969
1912
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
1970
1913
|
if (typeof witnessIndex !== "number") {
|
1971
|
-
witnessIndex = this.
|
1914
|
+
witnessIndex = this.createWitness();
|
1972
1915
|
}
|
1973
1916
|
}
|
1974
1917
|
const input = {
|
@@ -2002,7 +1945,7 @@ var BaseTransactionRequest = class {
|
|
2002
1945
|
} else {
|
2003
1946
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
2004
1947
|
if (typeof witnessIndex !== "number") {
|
2005
|
-
witnessIndex = this.
|
1948
|
+
witnessIndex = this.createWitness();
|
2006
1949
|
}
|
2007
1950
|
}
|
2008
1951
|
const input = {
|
@@ -3415,7 +3358,7 @@ function assembleTransactionSummary(params) {
|
|
3415
3358
|
}
|
3416
3359
|
|
3417
3360
|
// src/providers/transaction-response/transaction-response.ts
|
3418
|
-
var TransactionResponse = class {
|
3361
|
+
var TransactionResponse = class _TransactionResponse {
|
3419
3362
|
/** Transaction ID */
|
3420
3363
|
id;
|
3421
3364
|
/** Current provider */
|
@@ -3443,7 +3386,7 @@ var TransactionResponse = class {
|
|
3443
3386
|
* @param provider - The provider.
|
3444
3387
|
*/
|
3445
3388
|
static async create(id, provider) {
|
3446
|
-
const response = new
|
3389
|
+
const response = new _TransactionResponse(id, provider);
|
3447
3390
|
await response.fetch();
|
3448
3391
|
return response;
|
3449
3392
|
}
|
@@ -3671,8 +3614,7 @@ var processGqlChain = (chain) => {
|
|
3671
3614
|
}
|
3672
3615
|
};
|
3673
3616
|
};
|
3674
|
-
var
|
3675
|
-
var _Provider = class {
|
3617
|
+
var Provider = class _Provider {
|
3676
3618
|
/**
|
3677
3619
|
* Constructor to initialize a Provider.
|
3678
3620
|
*
|
@@ -3683,27 +3625,25 @@ var _Provider = class {
|
|
3683
3625
|
*/
|
3684
3626
|
constructor(url, options = {}) {
|
3685
3627
|
this.url = url;
|
3686
|
-
/**
|
3687
|
-
* @hidden
|
3688
|
-
*/
|
3689
|
-
__privateAdd(this, _cacheInputs);
|
3690
|
-
__publicField(this, "operations");
|
3691
|
-
__publicField(this, "cache");
|
3692
|
-
__publicField(this, "options", {
|
3693
|
-
timeout: void 0,
|
3694
|
-
cacheUtxo: void 0,
|
3695
|
-
fetch: void 0,
|
3696
|
-
retryOptions: void 0
|
3697
|
-
});
|
3698
3628
|
this.options = { ...this.options, ...options };
|
3699
3629
|
this.url = url;
|
3700
3630
|
this.operations = this.createOperations();
|
3701
3631
|
this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
|
3702
3632
|
}
|
3633
|
+
operations;
|
3634
|
+
cache;
|
3703
3635
|
static clearChainAndNodeCaches() {
|
3704
3636
|
_Provider.nodeInfoCache = {};
|
3705
3637
|
_Provider.chainInfoCache = {};
|
3706
3638
|
}
|
3639
|
+
static chainInfoCache = {};
|
3640
|
+
static nodeInfoCache = {};
|
3641
|
+
options = {
|
3642
|
+
timeout: void 0,
|
3643
|
+
cacheUtxo: void 0,
|
3644
|
+
fetch: void 0,
|
3645
|
+
retryOptions: void 0
|
3646
|
+
};
|
3707
3647
|
static getFetchFn(options) {
|
3708
3648
|
const { retryOptions, timeout } = options;
|
3709
3649
|
return autoRetryFetch(async (...args) => {
|
@@ -3900,6 +3840,19 @@ var _Provider = class {
|
|
3900
3840
|
} = this.getChain();
|
3901
3841
|
return chainId.toNumber();
|
3902
3842
|
}
|
3843
|
+
/**
|
3844
|
+
* @hidden
|
3845
|
+
*/
|
3846
|
+
#cacheInputs(inputs) {
|
3847
|
+
if (!this.cache) {
|
3848
|
+
return;
|
3849
|
+
}
|
3850
|
+
inputs.forEach((input) => {
|
3851
|
+
if (input.type === import_transactions17.InputType.Coin) {
|
3852
|
+
this.cache?.set(input.id);
|
3853
|
+
}
|
3854
|
+
});
|
3855
|
+
}
|
3903
3856
|
/**
|
3904
3857
|
* Submits a transaction to the chain to be executed.
|
3905
3858
|
*
|
@@ -3912,7 +3865,7 @@ var _Provider = class {
|
|
3912
3865
|
// #region Provider-sendTransaction
|
3913
3866
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution = false } = {}) {
|
3914
3867
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
3915
|
-
|
3868
|
+
this.#cacheInputs(transactionRequest.inputs);
|
3916
3869
|
if (estimateTxDependencies) {
|
3917
3870
|
await this.estimateTxDependencies(transactionRequest);
|
3918
3871
|
}
|
@@ -4537,20 +4490,6 @@ var _Provider = class {
|
|
4537
4490
|
return new TransactionResponse(transactionId, this);
|
4538
4491
|
}
|
4539
4492
|
};
|
4540
|
-
var Provider = _Provider;
|
4541
|
-
_cacheInputs = new WeakSet();
|
4542
|
-
cacheInputs_fn = function(inputs) {
|
4543
|
-
if (!this.cache) {
|
4544
|
-
return;
|
4545
|
-
}
|
4546
|
-
inputs.forEach((input) => {
|
4547
|
-
if (input.type === import_transactions17.InputType.Coin) {
|
4548
|
-
this.cache?.set(input.id);
|
4549
|
-
}
|
4550
|
-
});
|
4551
|
-
};
|
4552
|
-
__publicField(Provider, "chainInfoCache", {});
|
4553
|
-
__publicField(Provider, "nodeInfoCache", {});
|
4554
4493
|
|
4555
4494
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4556
4495
|
var import_errors14 = require("@fuel-ts/errors");
|
@@ -5155,21 +5094,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5155
5094
|
}
|
5156
5095
|
return this._connector.signMessage(this.address.toString(), message);
|
5157
5096
|
}
|
5158
|
-
/**
|
5159
|
-
* Signs a transaction with the wallet's private key.
|
5160
|
-
*
|
5161
|
-
* @param transactionRequestLike - The transaction request to sign.
|
5162
|
-
* @returns A promise that resolves to the signature of the transaction.
|
5163
|
-
*/
|
5164
|
-
async signTransaction(transactionRequestLike) {
|
5165
|
-
if (!this._connector) {
|
5166
|
-
throw new import_errors15.FuelError(
|
5167
|
-
import_errors15.ErrorCode.MISSING_CONNECTOR,
|
5168
|
-
"A connector is required to sign transactions."
|
5169
|
-
);
|
5170
|
-
}
|
5171
|
-
return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
|
5172
|
-
}
|
5173
5097
|
/**
|
5174
5098
|
* Sends a transaction to the network.
|
5175
5099
|
*
|
@@ -5236,7 +5160,7 @@ var import_hasher2 = require("@fuel-ts/hasher");
|
|
5236
5160
|
var import_math18 = require("@fuel-ts/math");
|
5237
5161
|
var import_utils28 = require("@fuel-ts/utils");
|
5238
5162
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5239
|
-
var Signer = class {
|
5163
|
+
var Signer = class _Signer {
|
5240
5164
|
address;
|
5241
5165
|
publicKey;
|
5242
5166
|
compressedPublicKey;
|
@@ -5315,7 +5239,7 @@ var Signer = class {
|
|
5315
5239
|
* @returns Address from signature
|
5316
5240
|
*/
|
5317
5241
|
static recoverAddress(data, signature) {
|
5318
|
-
return import_address5.Address.fromPublicKey(
|
5242
|
+
return import_address5.Address.fromPublicKey(_Signer.recoverPublicKey(data, signature));
|
5319
5243
|
}
|
5320
5244
|
/**
|
5321
5245
|
* Generate a random privateKey
|
@@ -5431,6 +5355,10 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5431
5355
|
|
5432
5356
|
// src/wallet/base-wallet-unlocked.ts
|
5433
5357
|
var BaseWalletUnlocked = class extends Account {
|
5358
|
+
/**
|
5359
|
+
* Default HDWallet path.
|
5360
|
+
*/
|
5361
|
+
static defaultPath = "m/44'/1179993420'/0'/0/0";
|
5434
5362
|
/**
|
5435
5363
|
* A function that returns the wallet's signer.
|
5436
5364
|
*/
|
@@ -5480,7 +5408,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5480
5408
|
*/
|
5481
5409
|
async signTransaction(transactionRequestLike) {
|
5482
5410
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5483
|
-
const chainId = this.provider.
|
5411
|
+
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
5484
5412
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5485
5413
|
const signature = await this.signer().sign(hashedTransaction);
|
5486
5414
|
return (0, import_utils30.hexlify)(signature);
|
@@ -5536,10 +5464,6 @@ var BaseWalletUnlocked = class extends Account {
|
|
5536
5464
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
5537
5465
|
}
|
5538
5466
|
};
|
5539
|
-
/**
|
5540
|
-
* Default HDWallet path.
|
5541
|
-
*/
|
5542
|
-
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5543
5467
|
|
5544
5468
|
// src/hdwallet/hdwallet.ts
|
5545
5469
|
var import_errors19 = require("@fuel-ts/errors");
|
@@ -7749,7 +7673,7 @@ function assertMnemonic(words) {
|
|
7749
7673
|
throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
7750
7674
|
}
|
7751
7675
|
}
|
7752
|
-
var Mnemonic = class {
|
7676
|
+
var Mnemonic = class _Mnemonic {
|
7753
7677
|
wordlist;
|
7754
7678
|
/**
|
7755
7679
|
*
|
@@ -7766,7 +7690,7 @@ var Mnemonic = class {
|
|
7766
7690
|
* @returns Entropy hash
|
7767
7691
|
*/
|
7768
7692
|
mnemonicToEntropy(phrase) {
|
7769
|
-
return
|
7693
|
+
return _Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
|
7770
7694
|
}
|
7771
7695
|
/**
|
7772
7696
|
*
|
@@ -7774,7 +7698,7 @@ var Mnemonic = class {
|
|
7774
7698
|
* @returns Mnemonic phrase
|
7775
7699
|
*/
|
7776
7700
|
entropyToMnemonic(entropy) {
|
7777
|
-
return
|
7701
|
+
return _Mnemonic.entropyToMnemonic(entropy, this.wordlist);
|
7778
7702
|
}
|
7779
7703
|
/**
|
7780
7704
|
*
|
@@ -7815,8 +7739,8 @@ var Mnemonic = class {
|
|
7815
7739
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7816
7740
|
*/
|
7817
7741
|
static mnemonicToMasterKeys(phrase, passphrase = "") {
|
7818
|
-
const seed =
|
7819
|
-
return
|
7742
|
+
const seed = _Mnemonic.mnemonicToSeed(phrase, passphrase);
|
7743
|
+
return _Mnemonic.masterKeysFromSeed(seed);
|
7820
7744
|
}
|
7821
7745
|
/**
|
7822
7746
|
* Validates if given mnemonic is valid
|
@@ -7832,7 +7756,7 @@ var Mnemonic = class {
|
|
7832
7756
|
return false;
|
7833
7757
|
}
|
7834
7758
|
while (i < words.length) {
|
7835
|
-
if (
|
7759
|
+
if (_Mnemonic.binarySearch(words[i]) === false) {
|
7836
7760
|
return false;
|
7837
7761
|
}
|
7838
7762
|
i += 1;
|
@@ -7879,7 +7803,7 @@ var Mnemonic = class {
|
|
7879
7803
|
* @returns BIP-32 extended private key
|
7880
7804
|
*/
|
7881
7805
|
static seedToExtendedKey(seed, testnet = false) {
|
7882
|
-
const masterKey =
|
7806
|
+
const masterKey = _Mnemonic.masterKeysFromSeed(seed);
|
7883
7807
|
const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7884
7808
|
const depth = "0x00";
|
7885
7809
|
const fingerprint = "0x00000000";
|
@@ -7911,7 +7835,7 @@ var Mnemonic = class {
|
|
7911
7835
|
*/
|
7912
7836
|
static generate(size = 32, extraEntropy = "") {
|
7913
7837
|
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7914
|
-
return
|
7838
|
+
return _Mnemonic.entropyToMnemonic(entropy);
|
7915
7839
|
}
|
7916
7840
|
};
|
7917
7841
|
var mnemonic_default = Mnemonic;
|
@@ -7951,7 +7875,7 @@ function parsePath(path, depth = 0) {
|
|
7951
7875
|
(p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
|
7952
7876
|
);
|
7953
7877
|
}
|
7954
|
-
var HDWallet = class {
|
7878
|
+
var HDWallet = class _HDWallet {
|
7955
7879
|
depth = 0;
|
7956
7880
|
index = 0;
|
7957
7881
|
fingerprint = (0, import_utils34.hexlify)("0x00000000");
|
@@ -8017,7 +7941,7 @@ var HDWallet = class {
|
|
8017
7941
|
if (privateKey) {
|
8018
7942
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8019
7943
|
const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8020
|
-
return new
|
7944
|
+
return new _HDWallet({
|
8021
7945
|
privateKey: ki,
|
8022
7946
|
chainCode: IR,
|
8023
7947
|
index,
|
@@ -8027,7 +7951,7 @@ var HDWallet = class {
|
|
8027
7951
|
}
|
8028
7952
|
const signer = new Signer((0, import_utils34.hexlify)(IL));
|
8029
7953
|
const Ki = signer.addPoint(publicKey);
|
8030
|
-
return new
|
7954
|
+
return new _HDWallet({
|
8031
7955
|
publicKey: Ki,
|
8032
7956
|
chainCode: IR,
|
8033
7957
|
index,
|
@@ -8076,7 +8000,7 @@ var HDWallet = class {
|
|
8076
8000
|
*/
|
8077
8001
|
static fromSeed(seed) {
|
8078
8002
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8079
|
-
return new
|
8003
|
+
return new _HDWallet({
|
8080
8004
|
chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
|
8081
8005
|
privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
|
8082
8006
|
});
|
@@ -8106,7 +8030,7 @@ var HDWallet = class {
|
|
8106
8030
|
if (key[0] !== 3) {
|
8107
8031
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
8108
8032
|
}
|
8109
|
-
return new
|
8033
|
+
return new _HDWallet({
|
8110
8034
|
publicKey: key,
|
8111
8035
|
chainCode,
|
8112
8036
|
index,
|
@@ -8117,7 +8041,7 @@ var HDWallet = class {
|
|
8117
8041
|
if (key[0] !== 0) {
|
8118
8042
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
8119
8043
|
}
|
8120
|
-
return new
|
8044
|
+
return new _HDWallet({
|
8121
8045
|
privateKey: key.slice(1),
|
8122
8046
|
chainCode,
|
8123
8047
|
index,
|
@@ -8140,7 +8064,7 @@ var WalletLocked = class extends Account {
|
|
8140
8064
|
return new WalletUnlocked(privateKey, this._provider);
|
8141
8065
|
}
|
8142
8066
|
};
|
8143
|
-
var WalletUnlocked = class extends BaseWalletUnlocked {
|
8067
|
+
var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
8144
8068
|
/**
|
8145
8069
|
* Locks the wallet and returns an instance of WalletLocked.
|
8146
8070
|
*
|
@@ -8158,7 +8082,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8158
8082
|
*/
|
8159
8083
|
static generate(generateOptions) {
|
8160
8084
|
const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
|
8161
|
-
return new
|
8085
|
+
return new _WalletUnlocked(privateKey, generateOptions?.provider);
|
8162
8086
|
}
|
8163
8087
|
/**
|
8164
8088
|
* Create a Wallet Unlocked from a seed.
|
@@ -8170,8 +8094,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8170
8094
|
*/
|
8171
8095
|
static fromSeed(seed, path, provider) {
|
8172
8096
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
8173
|
-
const childWallet = hdWallet.derivePath(path ||
|
8174
|
-
return new
|
8097
|
+
const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
|
8098
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
8175
8099
|
}
|
8176
8100
|
/**
|
8177
8101
|
* Create a Wallet Unlocked from a mnemonic phrase.
|
@@ -8185,8 +8109,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8185
8109
|
static fromMnemonic(mnemonic, path, passphrase, provider) {
|
8186
8110
|
const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
|
8187
8111
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
8188
|
-
const childWallet = hdWallet.derivePath(path ||
|
8189
|
-
return new
|
8112
|
+
const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
|
8113
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
8190
8114
|
}
|
8191
8115
|
/**
|
8192
8116
|
* Create a Wallet Unlocked from an extended key.
|
@@ -8197,7 +8121,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8197
8121
|
*/
|
8198
8122
|
static fromExtendedKey(extendedKey, provider) {
|
8199
8123
|
const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
|
8200
|
-
return new
|
8124
|
+
return new _WalletUnlocked(hdWallet.privateKey, provider);
|
8201
8125
|
}
|
8202
8126
|
/**
|
8203
8127
|
* Create a Wallet Unlocked from an encrypted JSON.
|
@@ -8209,7 +8133,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8209
8133
|
*/
|
8210
8134
|
static async fromEncryptedJson(jsonWallet, password, provider) {
|
8211
8135
|
const privateKey = await decryptKeystoreWallet(jsonWallet, password);
|
8212
|
-
return new
|
8136
|
+
return new _WalletUnlocked(privateKey, provider);
|
8213
8137
|
}
|
8214
8138
|
};
|
8215
8139
|
|
@@ -8235,50 +8159,50 @@ var Wallet = class {
|
|
8235
8159
|
static fromPrivateKey(privateKey, provider) {
|
8236
8160
|
return new WalletUnlocked(privateKey, provider);
|
8237
8161
|
}
|
8162
|
+
/**
|
8163
|
+
* Generate a new Wallet Unlocked with a random key pair.
|
8164
|
+
*
|
8165
|
+
* @param generateOptions - Options to customize the generation process (optional).
|
8166
|
+
* @returns An unlocked wallet instance.
|
8167
|
+
*/
|
8168
|
+
static generate = WalletUnlocked.generate;
|
8169
|
+
/**
|
8170
|
+
* Create a Wallet Unlocked from a seed.
|
8171
|
+
*
|
8172
|
+
* @param seed - The seed phrase.
|
8173
|
+
* @param provider - A Provider instance (optional).
|
8174
|
+
* @param path - The derivation path (optional).
|
8175
|
+
* @returns An unlocked wallet instance.
|
8176
|
+
*/
|
8177
|
+
static fromSeed = WalletUnlocked.fromSeed;
|
8178
|
+
/**
|
8179
|
+
* Create a Wallet Unlocked from a mnemonic phrase.
|
8180
|
+
*
|
8181
|
+
* @param mnemonic - The mnemonic phrase.
|
8182
|
+
* @param provider - A Provider instance (optional).
|
8183
|
+
* @param path - The derivation path (optional).
|
8184
|
+
* @param passphrase - The passphrase for the mnemonic (optional).
|
8185
|
+
* @returns An unlocked wallet instance.
|
8186
|
+
*/
|
8187
|
+
static fromMnemonic = WalletUnlocked.fromMnemonic;
|
8188
|
+
/**
|
8189
|
+
* Create a Wallet Unlocked from an extended key.
|
8190
|
+
*
|
8191
|
+
* @param extendedKey - The extended key.
|
8192
|
+
* @param provider - A Provider instance (optional).
|
8193
|
+
* @returns An unlocked wallet instance.
|
8194
|
+
*/
|
8195
|
+
static fromExtendedKey = WalletUnlocked.fromExtendedKey;
|
8196
|
+
/**
|
8197
|
+
* Create a Wallet Unlocked from an encrypted JSON.
|
8198
|
+
*
|
8199
|
+
* @param jsonWallet - The encrypted JSON keystore.
|
8200
|
+
* @param password - The password to decrypt the JSON.
|
8201
|
+
* @param provider - A Provider instance (optional).
|
8202
|
+
* @returns An unlocked wallet instance.
|
8203
|
+
*/
|
8204
|
+
static fromEncryptedJson = WalletUnlocked.fromEncryptedJson;
|
8238
8205
|
};
|
8239
|
-
/**
|
8240
|
-
* Generate a new Wallet Unlocked with a random key pair.
|
8241
|
-
*
|
8242
|
-
* @param generateOptions - Options to customize the generation process (optional).
|
8243
|
-
* @returns An unlocked wallet instance.
|
8244
|
-
*/
|
8245
|
-
__publicField(Wallet, "generate", WalletUnlocked.generate);
|
8246
|
-
/**
|
8247
|
-
* Create a Wallet Unlocked from a seed.
|
8248
|
-
*
|
8249
|
-
* @param seed - The seed phrase.
|
8250
|
-
* @param provider - A Provider instance (optional).
|
8251
|
-
* @param path - The derivation path (optional).
|
8252
|
-
* @returns An unlocked wallet instance.
|
8253
|
-
*/
|
8254
|
-
__publicField(Wallet, "fromSeed", WalletUnlocked.fromSeed);
|
8255
|
-
/**
|
8256
|
-
* Create a Wallet Unlocked from a mnemonic phrase.
|
8257
|
-
*
|
8258
|
-
* @param mnemonic - The mnemonic phrase.
|
8259
|
-
* @param provider - A Provider instance (optional).
|
8260
|
-
* @param path - The derivation path (optional).
|
8261
|
-
* @param passphrase - The passphrase for the mnemonic (optional).
|
8262
|
-
* @returns An unlocked wallet instance.
|
8263
|
-
*/
|
8264
|
-
__publicField(Wallet, "fromMnemonic", WalletUnlocked.fromMnemonic);
|
8265
|
-
/**
|
8266
|
-
* Create a Wallet Unlocked from an extended key.
|
8267
|
-
*
|
8268
|
-
* @param extendedKey - The extended key.
|
8269
|
-
* @param provider - A Provider instance (optional).
|
8270
|
-
* @returns An unlocked wallet instance.
|
8271
|
-
*/
|
8272
|
-
__publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
8273
|
-
/**
|
8274
|
-
* Create a Wallet Unlocked from an encrypted JSON.
|
8275
|
-
*
|
8276
|
-
* @param jsonWallet - The encrypted JSON keystore.
|
8277
|
-
* @param password - The password to decrypt the JSON.
|
8278
|
-
* @param provider - A Provider instance (optional).
|
8279
|
-
* @returns An unlocked wallet instance.
|
8280
|
-
*/
|
8281
|
-
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
8282
8206
|
|
8283
8207
|
// src/wallet-manager/wallet-manager.ts
|
8284
8208
|
var import_address9 = require("@fuel-ts/address");
|
@@ -8307,14 +8231,14 @@ var MemoryStorage = class {
|
|
8307
8231
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
8308
8232
|
var import_address7 = require("@fuel-ts/address");
|
8309
8233
|
var import_errors20 = require("@fuel-ts/errors");
|
8310
|
-
var _secret;
|
8311
8234
|
var MnemonicVault = class {
|
8235
|
+
static type = "mnemonic";
|
8236
|
+
#secret;
|
8237
|
+
pathKey = "{}";
|
8238
|
+
rootPath = `m/44'/1179993420'/${this.pathKey}'/0/0`;
|
8239
|
+
numberOfAccounts = 0;
|
8312
8240
|
constructor(options) {
|
8313
|
-
|
8314
|
-
__publicField(this, "pathKey", "{}");
|
8315
|
-
__publicField(this, "rootPath", `m/44'/1179993420'/${this.pathKey}'/0/0`);
|
8316
|
-
__publicField(this, "numberOfAccounts", 0);
|
8317
|
-
__privateSet(this, _secret, options.secret || mnemonic_default.generate());
|
8241
|
+
this.#secret = options.secret || mnemonic_default.generate();
|
8318
8242
|
this.rootPath = options.rootPath || this.rootPath;
|
8319
8243
|
this.numberOfAccounts = options.numberOfAccounts || 1;
|
8320
8244
|
}
|
@@ -8326,7 +8250,7 @@ var MnemonicVault = class {
|
|
8326
8250
|
}
|
8327
8251
|
serialize() {
|
8328
8252
|
return {
|
8329
|
-
secret:
|
8253
|
+
secret: this.#secret,
|
8330
8254
|
rootPath: this.rootPath,
|
8331
8255
|
numberOfAccounts: this.numberOfAccounts
|
8332
8256
|
};
|
@@ -8335,7 +8259,7 @@ var MnemonicVault = class {
|
|
8335
8259
|
const accounts = [];
|
8336
8260
|
let numberOfAccounts = 0;
|
8337
8261
|
do {
|
8338
|
-
const wallet = Wallet.fromMnemonic(
|
8262
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
|
8339
8263
|
accounts.push({
|
8340
8264
|
publicKey: wallet.publicKey,
|
8341
8265
|
address: wallet.address
|
@@ -8346,7 +8270,7 @@ var MnemonicVault = class {
|
|
8346
8270
|
}
|
8347
8271
|
addAccount() {
|
8348
8272
|
this.numberOfAccounts += 1;
|
8349
|
-
const wallet = Wallet.fromMnemonic(
|
8273
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(this.numberOfAccounts - 1));
|
8350
8274
|
return {
|
8351
8275
|
publicKey: wallet.publicKey,
|
8352
8276
|
address: wallet.address
|
@@ -8356,7 +8280,7 @@ var MnemonicVault = class {
|
|
8356
8280
|
let numberOfAccounts = 0;
|
8357
8281
|
const ownerAddress = import_address7.Address.fromAddressOrString(address);
|
8358
8282
|
do {
|
8359
|
-
const wallet = Wallet.fromMnemonic(
|
8283
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
|
8360
8284
|
if (wallet.address.equals(ownerAddress)) {
|
8361
8285
|
return wallet.privateKey;
|
8362
8286
|
}
|
@@ -8372,29 +8296,27 @@ var MnemonicVault = class {
|
|
8372
8296
|
return Wallet.fromPrivateKey(privateKey);
|
8373
8297
|
}
|
8374
8298
|
};
|
8375
|
-
_secret = new WeakMap();
|
8376
|
-
__publicField(MnemonicVault, "type", "mnemonic");
|
8377
8299
|
|
8378
8300
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
8379
8301
|
var import_address8 = require("@fuel-ts/address");
|
8380
8302
|
var import_errors21 = require("@fuel-ts/errors");
|
8381
|
-
var _privateKeys;
|
8382
8303
|
var PrivateKeyVault = class {
|
8304
|
+
static type = "privateKey";
|
8305
|
+
#privateKeys = [];
|
8383
8306
|
/**
|
8384
8307
|
* If privateKey vault is initialized with a secretKey, it creates
|
8385
8308
|
* one account with the fallowing secret
|
8386
8309
|
*/
|
8387
8310
|
constructor(options = {}) {
|
8388
|
-
__privateAdd(this, _privateKeys, []);
|
8389
8311
|
if (options.secret) {
|
8390
|
-
|
8312
|
+
this.#privateKeys = [options.secret];
|
8391
8313
|
} else {
|
8392
|
-
|
8314
|
+
this.#privateKeys = options.accounts || [Wallet.generate().privateKey];
|
8393
8315
|
}
|
8394
8316
|
}
|
8395
8317
|
serialize() {
|
8396
8318
|
return {
|
8397
|
-
accounts:
|
8319
|
+
accounts: this.#privateKeys
|
8398
8320
|
};
|
8399
8321
|
}
|
8400
8322
|
getPublicAccount(privateKey) {
|
@@ -8405,16 +8327,16 @@ var PrivateKeyVault = class {
|
|
8405
8327
|
};
|
8406
8328
|
}
|
8407
8329
|
getAccounts() {
|
8408
|
-
return
|
8330
|
+
return this.#privateKeys.map((pk) => this.getPublicAccount(pk));
|
8409
8331
|
}
|
8410
8332
|
addAccount() {
|
8411
8333
|
const wallet = Wallet.generate();
|
8412
|
-
|
8334
|
+
this.#privateKeys.push(wallet.privateKey);
|
8413
8335
|
return this.getPublicAccount(wallet.privateKey);
|
8414
8336
|
}
|
8415
8337
|
exportAccount(address) {
|
8416
8338
|
const ownerAddress = import_address8.Address.fromAddressOrString(address);
|
8417
|
-
const privateKey =
|
8339
|
+
const privateKey = this.#privateKeys.find(
|
8418
8340
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
8419
8341
|
);
|
8420
8342
|
if (!privateKey) {
|
@@ -8430,8 +8352,6 @@ var PrivateKeyVault = class {
|
|
8430
8352
|
return Wallet.fromPrivateKey(privateKey);
|
8431
8353
|
}
|
8432
8354
|
};
|
8433
|
-
_privateKeys = new WeakMap();
|
8434
|
-
__publicField(PrivateKeyVault, "type", "privateKey");
|
8435
8355
|
|
8436
8356
|
// src/wallet-manager/wallet-manager.ts
|
8437
8357
|
var ERROR_MESSAGES = {
|
@@ -8446,46 +8366,43 @@ function assert(condition, message) {
|
|
8446
8366
|
throw new import_errors22.FuelError(import_errors22.ErrorCode.WALLET_MANAGER_ERROR, message);
|
8447
8367
|
}
|
8448
8368
|
}
|
8449
|
-
var
|
8450
|
-
|
8369
|
+
var WalletManager = class _WalletManager extends import_events.EventEmitter {
|
8370
|
+
/**
|
8371
|
+
* Vaults
|
8372
|
+
*
|
8373
|
+
* Vaults are responsible to store secret keys and return an `Wallet` instance,
|
8374
|
+
* to interact with the network.
|
8375
|
+
*
|
8376
|
+
* Each vault has access to its own state
|
8377
|
+
*
|
8378
|
+
*/
|
8379
|
+
static Vaults = [MnemonicVault, PrivateKeyVault];
|
8380
|
+
/**
|
8381
|
+
* Storage
|
8382
|
+
*
|
8383
|
+
* Persistent encrypted data. `The default storage works only on memory`.
|
8384
|
+
*/
|
8385
|
+
storage = new MemoryStorage();
|
8386
|
+
/* Key name passed to the storage */
|
8387
|
+
STORAGE_KEY = "WalletManager";
|
8388
|
+
// `This variables are only accessible from inside the class`
|
8389
|
+
#vaults = [];
|
8390
|
+
#passphrase = "";
|
8391
|
+
#isLocked = true;
|
8451
8392
|
constructor(options) {
|
8452
8393
|
super();
|
8453
|
-
/**
|
8454
|
-
* Serialize all vaults to store
|
8455
|
-
*
|
8456
|
-
* `This is only accessible from inside the class`
|
8457
|
-
*/
|
8458
|
-
__privateAdd(this, _serializeVaults);
|
8459
|
-
/**
|
8460
|
-
* Deserialize all vaults to state
|
8461
|
-
*
|
8462
|
-
* `This is only accessible from inside the class`
|
8463
|
-
*/
|
8464
|
-
__privateAdd(this, _deserializeVaults);
|
8465
|
-
/**
|
8466
|
-
* Storage
|
8467
|
-
*
|
8468
|
-
* Persistent encrypted data. `The default storage works only on memory`.
|
8469
|
-
*/
|
8470
|
-
__publicField(this, "storage", new MemoryStorage());
|
8471
|
-
/* Key name passed to the storage */
|
8472
|
-
__publicField(this, "STORAGE_KEY", "WalletManager");
|
8473
|
-
// `This variables are only accessible from inside the class`
|
8474
|
-
__privateAdd(this, _vaults, []);
|
8475
|
-
__privateAdd(this, _passphrase, "");
|
8476
|
-
__privateAdd(this, _isLocked, true);
|
8477
8394
|
this.storage = options?.storage || this.storage;
|
8478
8395
|
}
|
8479
8396
|
get isLocked() {
|
8480
|
-
return
|
8397
|
+
return this.#isLocked;
|
8481
8398
|
}
|
8482
8399
|
/**
|
8483
8400
|
* Return the vault serialized object containing all the privateKeys,
|
8484
8401
|
* the format of the return depends on the Vault type.
|
8485
8402
|
*/
|
8486
8403
|
exportVault(vaultId) {
|
8487
|
-
assert(!
|
8488
|
-
const vaultState =
|
8404
|
+
assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
8405
|
+
const vaultState = this.#vaults.find((_, idx) => idx === vaultId);
|
8489
8406
|
assert(vaultState, ERROR_MESSAGES.vault_not_found);
|
8490
8407
|
return vaultState.vault.serialize();
|
8491
8408
|
}
|
@@ -8493,7 +8410,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8493
8410
|
* List all vaults on the Wallet Manager, this function not return secret's
|
8494
8411
|
*/
|
8495
8412
|
getVaults() {
|
8496
|
-
return
|
8413
|
+
return this.#vaults.map((v, idx) => ({
|
8497
8414
|
title: v.title,
|
8498
8415
|
type: v.type,
|
8499
8416
|
vaultId: idx
|
@@ -8503,7 +8420,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8503
8420
|
* List all accounts on the Wallet Manager not vault information is revealed
|
8504
8421
|
*/
|
8505
8422
|
getAccounts() {
|
8506
|
-
return
|
8423
|
+
return this.#vaults.flatMap(
|
8507
8424
|
(vaultState, vaultId) => vaultState.vault.getAccounts().map((account) => ({ ...account, vaultId }))
|
8508
8425
|
);
|
8509
8426
|
}
|
@@ -8512,7 +8429,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8512
8429
|
*/
|
8513
8430
|
getWallet(address) {
|
8514
8431
|
const ownerAddress = import_address9.Address.fromAddressOrString(address);
|
8515
|
-
const vaultState =
|
8432
|
+
const vaultState = this.#vaults.find(
|
8516
8433
|
(vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
|
8517
8434
|
);
|
8518
8435
|
assert(vaultState, ERROR_MESSAGES.address_not_found);
|
@@ -8523,8 +8440,8 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8523
8440
|
*/
|
8524
8441
|
exportPrivateKey(address) {
|
8525
8442
|
const ownerAddress = import_address9.Address.fromAddressOrString(address);
|
8526
|
-
assert(!
|
8527
|
-
const vaultState =
|
8443
|
+
assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
8444
|
+
const vaultState = this.#vaults.find(
|
8528
8445
|
(vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
|
8529
8446
|
);
|
8530
8447
|
assert(vaultState, ERROR_MESSAGES.address_not_found);
|
@@ -8536,7 +8453,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8536
8453
|
*/
|
8537
8454
|
async addAccount(options) {
|
8538
8455
|
await this.loadState();
|
8539
|
-
const vaultState =
|
8456
|
+
const vaultState = this.#vaults[options?.vaultId || 0];
|
8540
8457
|
await assert(vaultState, ERROR_MESSAGES.vault_not_found);
|
8541
8458
|
const account = vaultState.vault.addAccount();
|
8542
8459
|
await this.saveState();
|
@@ -8547,7 +8464,7 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8547
8464
|
* created by the vault.
|
8548
8465
|
*/
|
8549
8466
|
async removeVault(index) {
|
8550
|
-
|
8467
|
+
this.#vaults.splice(index, 1);
|
8551
8468
|
await this.saveState();
|
8552
8469
|
}
|
8553
8470
|
/**
|
@@ -8558,11 +8475,11 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8558
8475
|
await this.loadState();
|
8559
8476
|
const Vault2 = this.getVaultClass(vaultConfig.type);
|
8560
8477
|
const vault = new Vault2(vaultConfig);
|
8561
|
-
|
8478
|
+
this.#vaults = this.#vaults.concat({
|
8562
8479
|
title: vaultConfig.title,
|
8563
8480
|
type: vaultConfig.type,
|
8564
8481
|
vault
|
8565
|
-
})
|
8482
|
+
});
|
8566
8483
|
await this.saveState();
|
8567
8484
|
}
|
8568
8485
|
/**
|
@@ -8570,9 +8487,9 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8570
8487
|
* secrets.
|
8571
8488
|
*/
|
8572
8489
|
lock() {
|
8573
|
-
|
8574
|
-
|
8575
|
-
|
8490
|
+
this.#isLocked = true;
|
8491
|
+
this.#vaults = [];
|
8492
|
+
this.#passphrase = "";
|
8576
8493
|
this.emit("lock");
|
8577
8494
|
}
|
8578
8495
|
/**
|
@@ -8580,8 +8497,8 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8580
8497
|
* Vaults with secrets are not unlocked or instantiated on this moment.
|
8581
8498
|
*/
|
8582
8499
|
async unlock(passphrase) {
|
8583
|
-
|
8584
|
-
|
8500
|
+
this.#passphrase = passphrase;
|
8501
|
+
this.#isLocked = false;
|
8585
8502
|
try {
|
8586
8503
|
await this.loadState();
|
8587
8504
|
this.emit("unlock");
|
@@ -8594,9 +8511,9 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8594
8511
|
* Update WalletManager encryption passphrase
|
8595
8512
|
*/
|
8596
8513
|
async updatePassphrase(oldpass, newpass) {
|
8597
|
-
const isLocked =
|
8514
|
+
const isLocked = this.#isLocked;
|
8598
8515
|
await this.unlock(oldpass);
|
8599
|
-
|
8516
|
+
this.#passphrase = newpass;
|
8600
8517
|
await this.saveState();
|
8601
8518
|
await this.loadState();
|
8602
8519
|
if (isLocked) {
|
@@ -8607,24 +8524,51 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8607
8524
|
* Retrieve and decrypt WalletManager state from storage
|
8608
8525
|
*/
|
8609
8526
|
async loadState() {
|
8610
|
-
await assert(!
|
8527
|
+
await assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
8611
8528
|
const data = await this.storage.getItem(this.STORAGE_KEY);
|
8612
8529
|
if (data) {
|
8613
|
-
const state = await (0, import_crypto4.decrypt)(
|
8614
|
-
|
8530
|
+
const state = await (0, import_crypto4.decrypt)(this.#passphrase, JSON.parse(data));
|
8531
|
+
this.#vaults = this.#deserializeVaults(state.vaults);
|
8615
8532
|
}
|
8616
8533
|
}
|
8617
8534
|
/**
|
8618
8535
|
* Store encrypted WalletManager state on storage
|
8619
8536
|
*/
|
8620
8537
|
async saveState() {
|
8621
|
-
await assert(!
|
8622
|
-
const encryptedData = await (0, import_crypto4.encrypt)(
|
8623
|
-
vaults:
|
8538
|
+
await assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
8539
|
+
const encryptedData = await (0, import_crypto4.encrypt)(this.#passphrase, {
|
8540
|
+
vaults: this.#serializeVaults(this.#vaults)
|
8624
8541
|
});
|
8625
8542
|
await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
|
8626
8543
|
this.emit("update");
|
8627
8544
|
}
|
8545
|
+
/**
|
8546
|
+
* Serialize all vaults to store
|
8547
|
+
*
|
8548
|
+
* `This is only accessible from inside the class`
|
8549
|
+
*/
|
8550
|
+
#serializeVaults(vaults) {
|
8551
|
+
return vaults.map(({ title, type, vault }) => ({
|
8552
|
+
title,
|
8553
|
+
type,
|
8554
|
+
data: vault.serialize()
|
8555
|
+
}));
|
8556
|
+
}
|
8557
|
+
/**
|
8558
|
+
* Deserialize all vaults to state
|
8559
|
+
*
|
8560
|
+
* `This is only accessible from inside the class`
|
8561
|
+
*/
|
8562
|
+
#deserializeVaults(vaults) {
|
8563
|
+
return vaults.map(({ title, type, data: vaultConfig }) => {
|
8564
|
+
const VaultClass = this.getVaultClass(type);
|
8565
|
+
return {
|
8566
|
+
title,
|
8567
|
+
type,
|
8568
|
+
vault: new VaultClass(vaultConfig)
|
8569
|
+
};
|
8570
|
+
});
|
8571
|
+
}
|
8628
8572
|
/**
|
8629
8573
|
* Return a instantiable Class reference from `WalletManager.Vaults` supported list.
|
8630
8574
|
*/
|
@@ -8634,43 +8578,11 @@ var _WalletManager = class extends import_events.EventEmitter {
|
|
8634
8578
|
return VaultClass;
|
8635
8579
|
}
|
8636
8580
|
};
|
8637
|
-
var WalletManager = _WalletManager;
|
8638
|
-
_vaults = new WeakMap();
|
8639
|
-
_passphrase = new WeakMap();
|
8640
|
-
_isLocked = new WeakMap();
|
8641
|
-
_serializeVaults = new WeakSet();
|
8642
|
-
serializeVaults_fn = function(vaults) {
|
8643
|
-
return vaults.map(({ title, type, vault }) => ({
|
8644
|
-
title,
|
8645
|
-
type,
|
8646
|
-
data: vault.serialize()
|
8647
|
-
}));
|
8648
|
-
};
|
8649
|
-
_deserializeVaults = new WeakSet();
|
8650
|
-
deserializeVaults_fn = function(vaults) {
|
8651
|
-
return vaults.map(({ title, type, data: vaultConfig }) => {
|
8652
|
-
const VaultClass = this.getVaultClass(type);
|
8653
|
-
return {
|
8654
|
-
title,
|
8655
|
-
type,
|
8656
|
-
vault: new VaultClass(vaultConfig)
|
8657
|
-
};
|
8658
|
-
});
|
8659
|
-
};
|
8660
|
-
/**
|
8661
|
-
* Vaults
|
8662
|
-
*
|
8663
|
-
* Vaults are responsible to store secret keys and return an `Wallet` instance,
|
8664
|
-
* to interact with the network.
|
8665
|
-
*
|
8666
|
-
* Each vault has access to its own state
|
8667
|
-
*
|
8668
|
-
*/
|
8669
|
-
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
8670
8581
|
|
8671
8582
|
// src/wallet-manager/types.ts
|
8672
8583
|
var import_errors23 = require("@fuel-ts/errors");
|
8673
8584
|
var Vault = class {
|
8585
|
+
static type;
|
8674
8586
|
constructor(_options) {
|
8675
8587
|
throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
8676
8588
|
}
|
@@ -8690,7 +8602,6 @@ var Vault = class {
|
|
8690
8602
|
throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
8691
8603
|
}
|
8692
8604
|
};
|
8693
|
-
__publicField(Vault, "type");
|
8694
8605
|
var StorageAbstract = class {
|
8695
8606
|
};
|
8696
8607
|
|
@@ -8716,7 +8627,7 @@ var getPredicateRoot = (bytecode) => {
|
|
8716
8627
|
};
|
8717
8628
|
|
8718
8629
|
// src/predicate/predicate.ts
|
8719
|
-
var Predicate = class extends Account {
|
8630
|
+
var Predicate = class _Predicate extends Account {
|
8720
8631
|
bytes;
|
8721
8632
|
predicateDataBytes = Uint8Array.from([]);
|
8722
8633
|
predicateData = [];
|
@@ -8737,7 +8648,7 @@ var Predicate = class extends Account {
|
|
8737
8648
|
inputData,
|
8738
8649
|
configurableConstants
|
8739
8650
|
}) {
|
8740
|
-
const { predicateBytes, predicateInterface } =
|
8651
|
+
const { predicateBytes, predicateInterface } = _Predicate.processPredicateData(
|
8741
8652
|
bytecode,
|
8742
8653
|
abi,
|
8743
8654
|
configurableConstants
|
@@ -8833,7 +8744,7 @@ var Predicate = class extends Account {
|
|
8833
8744
|
}
|
8834
8745
|
}
|
8835
8746
|
if (configurableConstants && Object.keys(configurableConstants).length) {
|
8836
|
-
predicateBytes =
|
8747
|
+
predicateBytes = _Predicate.setConfigurableConstants(
|
8837
8748
|
predicateBytes,
|
8838
8749
|
configurableConstants,
|
8839
8750
|
abiInterface
|
@@ -9021,18 +8932,6 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9021
8932
|
async signMessage(_address, _message) {
|
9022
8933
|
throw new Error("Method not implemented.");
|
9023
8934
|
}
|
9024
|
-
/**
|
9025
|
-
* Should start the sign transaction process and return
|
9026
|
-
* the signed transaction.
|
9027
|
-
*
|
9028
|
-
* @param address - The address to sign the transaction
|
9029
|
-
* @param transaction - The transaction to sign
|
9030
|
-
*
|
9031
|
-
* @returns Transaction signature
|
9032
|
-
*/
|
9033
|
-
async signTransaction(_address, _transaction) {
|
9034
|
-
throw new Error("Method not implemented.");
|
9035
|
-
}
|
9036
8935
|
/**
|
9037
8936
|
* Should start the send transaction process and return
|
9038
8937
|
* the transaction id submitted to the network.
|
@@ -9225,7 +9124,9 @@ async function withTimeout(promise, timeout = 1050) {
|
|
9225
9124
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
9226
9125
|
var PING_CACHE_TIME = 5e3;
|
9227
9126
|
var { warn } = console;
|
9228
|
-
var
|
9127
|
+
var Fuel = class _Fuel extends FuelConnector {
|
9128
|
+
static STORAGE_KEY = "fuel-current-connector";
|
9129
|
+
static defaultConfig = {};
|
9229
9130
|
_storage = null;
|
9230
9131
|
_connectors = [];
|
9231
9132
|
_targetObject = null;
|
@@ -9550,9 +9451,6 @@ var _Fuel = class extends FuelConnector {
|
|
9550
9451
|
await this.clean();
|
9551
9452
|
}
|
9552
9453
|
};
|
9553
|
-
var Fuel = _Fuel;
|
9554
|
-
__publicField(Fuel, "STORAGE_KEY", "fuel-current-connector");
|
9555
|
-
__publicField(Fuel, "defaultConfig", {});
|
9556
9454
|
// Annotate the CommonJS export names for ESM import in node:
|
9557
9455
|
0 && (module.exports = {
|
9558
9456
|
Account,
|