@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.mjs
CHANGED
@@ -1,32 +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 __privateGet = (obj, member, getter) => {
|
12
|
-
__accessCheck(obj, member, "read from private field");
|
13
|
-
return getter ? getter.call(obj) : member.get(obj);
|
14
|
-
};
|
15
|
-
var __privateAdd = (obj, member, value) => {
|
16
|
-
if (member.has(obj))
|
17
|
-
throw TypeError("Cannot add the same private member more than once");
|
18
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
19
|
-
};
|
20
|
-
var __privateSet = (obj, member, value, setter) => {
|
21
|
-
__accessCheck(obj, member, "write to private field");
|
22
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
23
|
-
return value;
|
24
|
-
};
|
25
|
-
var __privateMethod = (obj, member, method) => {
|
26
|
-
__accessCheck(obj, member, "access private method");
|
27
|
-
return method;
|
28
|
-
};
|
29
|
-
|
30
1
|
// src/account.ts
|
31
2
|
import { Address as Address3 } from "@fuel-ts/address";
|
32
3
|
import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
@@ -896,11 +867,12 @@ function getSdk(requester) {
|
|
896
867
|
// src/providers/fuel-graphql-subscriber.ts
|
897
868
|
import { ErrorCode, FuelError } from "@fuel-ts/errors";
|
898
869
|
import { print } from "graphql";
|
899
|
-
var
|
870
|
+
var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
900
871
|
constructor(options) {
|
901
872
|
this.options = options;
|
902
873
|
}
|
903
874
|
stream;
|
875
|
+
static textDecoder = new TextDecoder();
|
904
876
|
async setStream() {
|
905
877
|
const { url, query, variables, fetchFn } = this.options;
|
906
878
|
const response = await fetchFn(`${url}-sub`, {
|
@@ -960,8 +932,6 @@ var _FuelGraphqlSubscriber = class {
|
|
960
932
|
return this;
|
961
933
|
}
|
962
934
|
};
|
963
|
-
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
964
|
-
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
965
935
|
|
966
936
|
// src/providers/memory-cache.ts
|
967
937
|
import { ErrorCode as ErrorCode2, FuelError as FuelError2 } from "@fuel-ts/errors";
|
@@ -1595,7 +1565,7 @@ var witnessify = (value) => {
|
|
1595
1565
|
};
|
1596
1566
|
|
1597
1567
|
// src/providers/transaction-request/transaction-request.ts
|
1598
|
-
var BaseTransactionRequest = class {
|
1568
|
+
var BaseTransactionRequest = class _BaseTransactionRequest {
|
1599
1569
|
/** Gas price for transaction */
|
1600
1570
|
gasPrice;
|
1601
1571
|
/** Block until which tx cannot be included */
|
@@ -1665,7 +1635,7 @@ var BaseTransactionRequest = class {
|
|
1665
1635
|
const inputs = this.inputs?.map(inputify) ?? [];
|
1666
1636
|
const outputs = this.outputs?.map(outputify) ?? [];
|
1667
1637
|
const witnesses = this.witnesses?.map(witnessify) ?? [];
|
1668
|
-
const { policyTypes, policies } =
|
1638
|
+
const { policyTypes, policies } = _BaseTransactionRequest.getPolicyMeta(this);
|
1669
1639
|
return {
|
1670
1640
|
policyTypes,
|
1671
1641
|
inputs,
|
@@ -1703,27 +1673,13 @@ var BaseTransactionRequest = class {
|
|
1703
1673
|
this.outputs.push(output);
|
1704
1674
|
return this.outputs.length - 1;
|
1705
1675
|
}
|
1706
|
-
/**
|
1707
|
-
* @hidden
|
1708
|
-
*
|
1709
|
-
* Pushes a witness to the list and returns the index
|
1710
|
-
*
|
1711
|
-
* @param signature - The signature to add to the witness.
|
1712
|
-
* @returns The index of the created witness.
|
1713
|
-
*/
|
1714
|
-
addWitness(signature) {
|
1715
|
-
this.witnesses.push(signature);
|
1716
|
-
return this.witnesses.length - 1;
|
1717
|
-
}
|
1718
1676
|
/**
|
1719
1677
|
* @hidden
|
1720
1678
|
*
|
1721
1679
|
* Creates an empty witness without any side effects and returns the index
|
1722
|
-
*
|
1723
|
-
* @returns The index of the created witness.
|
1724
1680
|
*/
|
1725
|
-
|
1726
|
-
this.
|
1681
|
+
createWitness() {
|
1682
|
+
this.witnesses.push(concat([ZeroBytes324, ZeroBytes324]));
|
1727
1683
|
return this.witnesses.length - 1;
|
1728
1684
|
}
|
1729
1685
|
/**
|
@@ -1752,21 +1708,6 @@ var BaseTransactionRequest = class {
|
|
1752
1708
|
}
|
1753
1709
|
this.witnesses[index] = witness;
|
1754
1710
|
}
|
1755
|
-
/**
|
1756
|
-
* Helper function to add an external signature to the transaction.
|
1757
|
-
*
|
1758
|
-
* @param account - The account/s to sign to the transaction.
|
1759
|
-
* @returns The transaction with the signature witness added.
|
1760
|
-
*/
|
1761
|
-
async addAccountWitnesses(account) {
|
1762
|
-
const accounts = Array.isArray(account) ? account : [account];
|
1763
|
-
await Promise.all(
|
1764
|
-
accounts.map(async (acc) => {
|
1765
|
-
this.addWitness(await acc.signTransaction(this));
|
1766
|
-
})
|
1767
|
-
);
|
1768
|
-
return this;
|
1769
|
-
}
|
1770
1711
|
/**
|
1771
1712
|
* Gets the coin inputs for a transaction.
|
1772
1713
|
*
|
@@ -1832,7 +1773,7 @@ var BaseTransactionRequest = class {
|
|
1832
1773
|
} else {
|
1833
1774
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
1834
1775
|
if (typeof witnessIndex !== "number") {
|
1835
|
-
witnessIndex = this.
|
1776
|
+
witnessIndex = this.createWitness();
|
1836
1777
|
}
|
1837
1778
|
}
|
1838
1779
|
const input = {
|
@@ -1866,7 +1807,7 @@ var BaseTransactionRequest = class {
|
|
1866
1807
|
} else {
|
1867
1808
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
1868
1809
|
if (typeof witnessIndex !== "number") {
|
1869
|
-
witnessIndex = this.
|
1810
|
+
witnessIndex = this.createWitness();
|
1870
1811
|
}
|
1871
1812
|
}
|
1872
1813
|
const input = {
|
@@ -3279,7 +3220,7 @@ function assembleTransactionSummary(params) {
|
|
3279
3220
|
}
|
3280
3221
|
|
3281
3222
|
// src/providers/transaction-response/transaction-response.ts
|
3282
|
-
var TransactionResponse = class {
|
3223
|
+
var TransactionResponse = class _TransactionResponse {
|
3283
3224
|
/** Transaction ID */
|
3284
3225
|
id;
|
3285
3226
|
/** Current provider */
|
@@ -3307,7 +3248,7 @@ var TransactionResponse = class {
|
|
3307
3248
|
* @param provider - The provider.
|
3308
3249
|
*/
|
3309
3250
|
static async create(id, provider) {
|
3310
|
-
const response = new
|
3251
|
+
const response = new _TransactionResponse(id, provider);
|
3311
3252
|
await response.fetch();
|
3312
3253
|
return response;
|
3313
3254
|
}
|
@@ -3535,8 +3476,7 @@ var processGqlChain = (chain) => {
|
|
3535
3476
|
}
|
3536
3477
|
};
|
3537
3478
|
};
|
3538
|
-
var
|
3539
|
-
var _Provider = class {
|
3479
|
+
var Provider = class _Provider {
|
3540
3480
|
/**
|
3541
3481
|
* Constructor to initialize a Provider.
|
3542
3482
|
*
|
@@ -3547,27 +3487,25 @@ var _Provider = class {
|
|
3547
3487
|
*/
|
3548
3488
|
constructor(url, options = {}) {
|
3549
3489
|
this.url = url;
|
3550
|
-
/**
|
3551
|
-
* @hidden
|
3552
|
-
*/
|
3553
|
-
__privateAdd(this, _cacheInputs);
|
3554
|
-
__publicField(this, "operations");
|
3555
|
-
__publicField(this, "cache");
|
3556
|
-
__publicField(this, "options", {
|
3557
|
-
timeout: void 0,
|
3558
|
-
cacheUtxo: void 0,
|
3559
|
-
fetch: void 0,
|
3560
|
-
retryOptions: void 0
|
3561
|
-
});
|
3562
3490
|
this.options = { ...this.options, ...options };
|
3563
3491
|
this.url = url;
|
3564
3492
|
this.operations = this.createOperations();
|
3565
3493
|
this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
|
3566
3494
|
}
|
3495
|
+
operations;
|
3496
|
+
cache;
|
3567
3497
|
static clearChainAndNodeCaches() {
|
3568
3498
|
_Provider.nodeInfoCache = {};
|
3569
3499
|
_Provider.chainInfoCache = {};
|
3570
3500
|
}
|
3501
|
+
static chainInfoCache = {};
|
3502
|
+
static nodeInfoCache = {};
|
3503
|
+
options = {
|
3504
|
+
timeout: void 0,
|
3505
|
+
cacheUtxo: void 0,
|
3506
|
+
fetch: void 0,
|
3507
|
+
retryOptions: void 0
|
3508
|
+
};
|
3571
3509
|
static getFetchFn(options) {
|
3572
3510
|
const { retryOptions, timeout } = options;
|
3573
3511
|
return autoRetryFetch(async (...args) => {
|
@@ -3764,6 +3702,19 @@ var _Provider = class {
|
|
3764
3702
|
} = this.getChain();
|
3765
3703
|
return chainId.toNumber();
|
3766
3704
|
}
|
3705
|
+
/**
|
3706
|
+
* @hidden
|
3707
|
+
*/
|
3708
|
+
#cacheInputs(inputs) {
|
3709
|
+
if (!this.cache) {
|
3710
|
+
return;
|
3711
|
+
}
|
3712
|
+
inputs.forEach((input) => {
|
3713
|
+
if (input.type === InputType6.Coin) {
|
3714
|
+
this.cache?.set(input.id);
|
3715
|
+
}
|
3716
|
+
});
|
3717
|
+
}
|
3767
3718
|
/**
|
3768
3719
|
* Submits a transaction to the chain to be executed.
|
3769
3720
|
*
|
@@ -3776,7 +3727,7 @@ var _Provider = class {
|
|
3776
3727
|
// #region Provider-sendTransaction
|
3777
3728
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution = false } = {}) {
|
3778
3729
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
3779
|
-
|
3730
|
+
this.#cacheInputs(transactionRequest.inputs);
|
3780
3731
|
if (estimateTxDependencies) {
|
3781
3732
|
await this.estimateTxDependencies(transactionRequest);
|
3782
3733
|
}
|
@@ -4401,20 +4352,6 @@ var _Provider = class {
|
|
4401
4352
|
return new TransactionResponse(transactionId, this);
|
4402
4353
|
}
|
4403
4354
|
};
|
4404
|
-
var Provider = _Provider;
|
4405
|
-
_cacheInputs = new WeakSet();
|
4406
|
-
cacheInputs_fn = function(inputs) {
|
4407
|
-
if (!this.cache) {
|
4408
|
-
return;
|
4409
|
-
}
|
4410
|
-
inputs.forEach((input) => {
|
4411
|
-
if (input.type === InputType6.Coin) {
|
4412
|
-
this.cache?.set(input.id);
|
4413
|
-
}
|
4414
|
-
});
|
4415
|
-
};
|
4416
|
-
__publicField(Provider, "chainInfoCache", {});
|
4417
|
-
__publicField(Provider, "nodeInfoCache", {});
|
4418
4355
|
|
4419
4356
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4420
4357
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
@@ -5019,21 +4956,6 @@ var Account = class extends AbstractAccount {
|
|
5019
4956
|
}
|
5020
4957
|
return this._connector.signMessage(this.address.toString(), message);
|
5021
4958
|
}
|
5022
|
-
/**
|
5023
|
-
* Signs a transaction with the wallet's private key.
|
5024
|
-
*
|
5025
|
-
* @param transactionRequestLike - The transaction request to sign.
|
5026
|
-
* @returns A promise that resolves to the signature of the transaction.
|
5027
|
-
*/
|
5028
|
-
async signTransaction(transactionRequestLike) {
|
5029
|
-
if (!this._connector) {
|
5030
|
-
throw new FuelError14(
|
5031
|
-
ErrorCode14.MISSING_CONNECTOR,
|
5032
|
-
"A connector is required to sign transactions."
|
5033
|
-
);
|
5034
|
-
}
|
5035
|
-
return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
|
5036
|
-
}
|
5037
4959
|
/**
|
5038
4960
|
* Sends a transaction to the network.
|
5039
4961
|
*
|
@@ -5100,7 +5022,7 @@ import { hash } from "@fuel-ts/hasher";
|
|
5100
5022
|
import { toBytes } from "@fuel-ts/math";
|
5101
5023
|
import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
|
5102
5024
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
5103
|
-
var Signer = class {
|
5025
|
+
var Signer = class _Signer {
|
5104
5026
|
address;
|
5105
5027
|
publicKey;
|
5106
5028
|
compressedPublicKey;
|
@@ -5179,7 +5101,7 @@ var Signer = class {
|
|
5179
5101
|
* @returns Address from signature
|
5180
5102
|
*/
|
5181
5103
|
static recoverAddress(data, signature) {
|
5182
|
-
return Address4.fromPublicKey(
|
5104
|
+
return Address4.fromPublicKey(_Signer.recoverPublicKey(data, signature));
|
5183
5105
|
}
|
5184
5106
|
/**
|
5185
5107
|
* Generate a random privateKey
|
@@ -5303,6 +5225,10 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5303
5225
|
|
5304
5226
|
// src/wallet/base-wallet-unlocked.ts
|
5305
5227
|
var BaseWalletUnlocked = class extends Account {
|
5228
|
+
/**
|
5229
|
+
* Default HDWallet path.
|
5230
|
+
*/
|
5231
|
+
static defaultPath = "m/44'/1179993420'/0'/0/0";
|
5306
5232
|
/**
|
5307
5233
|
* A function that returns the wallet's signer.
|
5308
5234
|
*/
|
@@ -5352,7 +5278,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5352
5278
|
*/
|
5353
5279
|
async signTransaction(transactionRequestLike) {
|
5354
5280
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5355
|
-
const chainId = this.provider.
|
5281
|
+
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
5356
5282
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5357
5283
|
const signature = await this.signer().sign(hashedTransaction);
|
5358
5284
|
return hexlify15(signature);
|
@@ -5408,10 +5334,6 @@ var BaseWalletUnlocked = class extends Account {
|
|
5408
5334
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
5409
5335
|
}
|
5410
5336
|
};
|
5411
|
-
/**
|
5412
|
-
* Default HDWallet path.
|
5413
|
-
*/
|
5414
|
-
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5415
5337
|
|
5416
5338
|
// src/hdwallet/hdwallet.ts
|
5417
5339
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
@@ -7621,7 +7543,7 @@ function assertMnemonic(words) {
|
|
7621
7543
|
throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
|
7622
7544
|
}
|
7623
7545
|
}
|
7624
|
-
var Mnemonic = class {
|
7546
|
+
var Mnemonic = class _Mnemonic {
|
7625
7547
|
wordlist;
|
7626
7548
|
/**
|
7627
7549
|
*
|
@@ -7638,7 +7560,7 @@ var Mnemonic = class {
|
|
7638
7560
|
* @returns Entropy hash
|
7639
7561
|
*/
|
7640
7562
|
mnemonicToEntropy(phrase) {
|
7641
|
-
return
|
7563
|
+
return _Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
|
7642
7564
|
}
|
7643
7565
|
/**
|
7644
7566
|
*
|
@@ -7646,7 +7568,7 @@ var Mnemonic = class {
|
|
7646
7568
|
* @returns Mnemonic phrase
|
7647
7569
|
*/
|
7648
7570
|
entropyToMnemonic(entropy) {
|
7649
|
-
return
|
7571
|
+
return _Mnemonic.entropyToMnemonic(entropy, this.wordlist);
|
7650
7572
|
}
|
7651
7573
|
/**
|
7652
7574
|
*
|
@@ -7687,8 +7609,8 @@ var Mnemonic = class {
|
|
7687
7609
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7688
7610
|
*/
|
7689
7611
|
static mnemonicToMasterKeys(phrase, passphrase = "") {
|
7690
|
-
const seed =
|
7691
|
-
return
|
7612
|
+
const seed = _Mnemonic.mnemonicToSeed(phrase, passphrase);
|
7613
|
+
return _Mnemonic.masterKeysFromSeed(seed);
|
7692
7614
|
}
|
7693
7615
|
/**
|
7694
7616
|
* Validates if given mnemonic is valid
|
@@ -7704,7 +7626,7 @@ var Mnemonic = class {
|
|
7704
7626
|
return false;
|
7705
7627
|
}
|
7706
7628
|
while (i < words.length) {
|
7707
|
-
if (
|
7629
|
+
if (_Mnemonic.binarySearch(words[i]) === false) {
|
7708
7630
|
return false;
|
7709
7631
|
}
|
7710
7632
|
i += 1;
|
@@ -7751,7 +7673,7 @@ var Mnemonic = class {
|
|
7751
7673
|
* @returns BIP-32 extended private key
|
7752
7674
|
*/
|
7753
7675
|
static seedToExtendedKey(seed, testnet = false) {
|
7754
|
-
const masterKey =
|
7676
|
+
const masterKey = _Mnemonic.masterKeysFromSeed(seed);
|
7755
7677
|
const prefix = arrayify17(testnet ? TestnetPRV : MainnetPRV);
|
7756
7678
|
const depth = "0x00";
|
7757
7679
|
const fingerprint = "0x00000000";
|
@@ -7783,7 +7705,7 @@ var Mnemonic = class {
|
|
7783
7705
|
*/
|
7784
7706
|
static generate(size = 32, extraEntropy = "") {
|
7785
7707
|
const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
|
7786
|
-
return
|
7708
|
+
return _Mnemonic.entropyToMnemonic(entropy);
|
7787
7709
|
}
|
7788
7710
|
};
|
7789
7711
|
var mnemonic_default = Mnemonic;
|
@@ -7823,7 +7745,7 @@ function parsePath(path, depth = 0) {
|
|
7823
7745
|
(p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
|
7824
7746
|
);
|
7825
7747
|
}
|
7826
|
-
var HDWallet = class {
|
7748
|
+
var HDWallet = class _HDWallet {
|
7827
7749
|
depth = 0;
|
7828
7750
|
index = 0;
|
7829
7751
|
fingerprint = hexlify17("0x00000000");
|
@@ -7889,7 +7811,7 @@ var HDWallet = class {
|
|
7889
7811
|
if (privateKey) {
|
7890
7812
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7891
7813
|
const ki = bn17(IL).add(privateKey).mod(N).toBytes(32);
|
7892
|
-
return new
|
7814
|
+
return new _HDWallet({
|
7893
7815
|
privateKey: ki,
|
7894
7816
|
chainCode: IR,
|
7895
7817
|
index,
|
@@ -7899,7 +7821,7 @@ var HDWallet = class {
|
|
7899
7821
|
}
|
7900
7822
|
const signer = new Signer(hexlify17(IL));
|
7901
7823
|
const Ki = signer.addPoint(publicKey);
|
7902
|
-
return new
|
7824
|
+
return new _HDWallet({
|
7903
7825
|
publicKey: Ki,
|
7904
7826
|
chainCode: IR,
|
7905
7827
|
index,
|
@@ -7948,7 +7870,7 @@ var HDWallet = class {
|
|
7948
7870
|
*/
|
7949
7871
|
static fromSeed(seed) {
|
7950
7872
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7951
|
-
return new
|
7873
|
+
return new _HDWallet({
|
7952
7874
|
chainCode: arrayify18(masterKey.slice(32)),
|
7953
7875
|
privateKey: arrayify18(masterKey.slice(0, 32))
|
7954
7876
|
});
|
@@ -7978,7 +7900,7 @@ var HDWallet = class {
|
|
7978
7900
|
if (key[0] !== 3) {
|
7979
7901
|
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
|
7980
7902
|
}
|
7981
|
-
return new
|
7903
|
+
return new _HDWallet({
|
7982
7904
|
publicKey: key,
|
7983
7905
|
chainCode,
|
7984
7906
|
index,
|
@@ -7989,7 +7911,7 @@ var HDWallet = class {
|
|
7989
7911
|
if (key[0] !== 0) {
|
7990
7912
|
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
|
7991
7913
|
}
|
7992
|
-
return new
|
7914
|
+
return new _HDWallet({
|
7993
7915
|
privateKey: key.slice(1),
|
7994
7916
|
chainCode,
|
7995
7917
|
index,
|
@@ -8012,7 +7934,7 @@ var WalletLocked = class extends Account {
|
|
8012
7934
|
return new WalletUnlocked(privateKey, this._provider);
|
8013
7935
|
}
|
8014
7936
|
};
|
8015
|
-
var WalletUnlocked = class extends BaseWalletUnlocked {
|
7937
|
+
var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
8016
7938
|
/**
|
8017
7939
|
* Locks the wallet and returns an instance of WalletLocked.
|
8018
7940
|
*
|
@@ -8030,7 +7952,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8030
7952
|
*/
|
8031
7953
|
static generate(generateOptions) {
|
8032
7954
|
const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
|
8033
|
-
return new
|
7955
|
+
return new _WalletUnlocked(privateKey, generateOptions?.provider);
|
8034
7956
|
}
|
8035
7957
|
/**
|
8036
7958
|
* Create a Wallet Unlocked from a seed.
|
@@ -8042,8 +7964,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8042
7964
|
*/
|
8043
7965
|
static fromSeed(seed, path, provider) {
|
8044
7966
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
8045
|
-
const childWallet = hdWallet.derivePath(path ||
|
8046
|
-
return new
|
7967
|
+
const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
|
7968
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
8047
7969
|
}
|
8048
7970
|
/**
|
8049
7971
|
* Create a Wallet Unlocked from a mnemonic phrase.
|
@@ -8057,8 +7979,8 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8057
7979
|
static fromMnemonic(mnemonic, path, passphrase, provider) {
|
8058
7980
|
const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
|
8059
7981
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
8060
|
-
const childWallet = hdWallet.derivePath(path ||
|
8061
|
-
return new
|
7982
|
+
const childWallet = hdWallet.derivePath(path || _WalletUnlocked.defaultPath);
|
7983
|
+
return new _WalletUnlocked(childWallet.privateKey, provider);
|
8062
7984
|
}
|
8063
7985
|
/**
|
8064
7986
|
* Create a Wallet Unlocked from an extended key.
|
@@ -8069,7 +7991,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8069
7991
|
*/
|
8070
7992
|
static fromExtendedKey(extendedKey, provider) {
|
8071
7993
|
const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
|
8072
|
-
return new
|
7994
|
+
return new _WalletUnlocked(hdWallet.privateKey, provider);
|
8073
7995
|
}
|
8074
7996
|
/**
|
8075
7997
|
* Create a Wallet Unlocked from an encrypted JSON.
|
@@ -8081,7 +8003,7 @@ var WalletUnlocked = class extends BaseWalletUnlocked {
|
|
8081
8003
|
*/
|
8082
8004
|
static async fromEncryptedJson(jsonWallet, password, provider) {
|
8083
8005
|
const privateKey = await decryptKeystoreWallet(jsonWallet, password);
|
8084
|
-
return new
|
8006
|
+
return new _WalletUnlocked(privateKey, provider);
|
8085
8007
|
}
|
8086
8008
|
};
|
8087
8009
|
|
@@ -8107,50 +8029,50 @@ var Wallet = class {
|
|
8107
8029
|
static fromPrivateKey(privateKey, provider) {
|
8108
8030
|
return new WalletUnlocked(privateKey, provider);
|
8109
8031
|
}
|
8032
|
+
/**
|
8033
|
+
* Generate a new Wallet Unlocked with a random key pair.
|
8034
|
+
*
|
8035
|
+
* @param generateOptions - Options to customize the generation process (optional).
|
8036
|
+
* @returns An unlocked wallet instance.
|
8037
|
+
*/
|
8038
|
+
static generate = WalletUnlocked.generate;
|
8039
|
+
/**
|
8040
|
+
* Create a Wallet Unlocked from a seed.
|
8041
|
+
*
|
8042
|
+
* @param seed - The seed phrase.
|
8043
|
+
* @param provider - A Provider instance (optional).
|
8044
|
+
* @param path - The derivation path (optional).
|
8045
|
+
* @returns An unlocked wallet instance.
|
8046
|
+
*/
|
8047
|
+
static fromSeed = WalletUnlocked.fromSeed;
|
8048
|
+
/**
|
8049
|
+
* Create a Wallet Unlocked from a mnemonic phrase.
|
8050
|
+
*
|
8051
|
+
* @param mnemonic - The mnemonic phrase.
|
8052
|
+
* @param provider - A Provider instance (optional).
|
8053
|
+
* @param path - The derivation path (optional).
|
8054
|
+
* @param passphrase - The passphrase for the mnemonic (optional).
|
8055
|
+
* @returns An unlocked wallet instance.
|
8056
|
+
*/
|
8057
|
+
static fromMnemonic = WalletUnlocked.fromMnemonic;
|
8058
|
+
/**
|
8059
|
+
* Create a Wallet Unlocked from an extended key.
|
8060
|
+
*
|
8061
|
+
* @param extendedKey - The extended key.
|
8062
|
+
* @param provider - A Provider instance (optional).
|
8063
|
+
* @returns An unlocked wallet instance.
|
8064
|
+
*/
|
8065
|
+
static fromExtendedKey = WalletUnlocked.fromExtendedKey;
|
8066
|
+
/**
|
8067
|
+
* Create a Wallet Unlocked from an encrypted JSON.
|
8068
|
+
*
|
8069
|
+
* @param jsonWallet - The encrypted JSON keystore.
|
8070
|
+
* @param password - The password to decrypt the JSON.
|
8071
|
+
* @param provider - A Provider instance (optional).
|
8072
|
+
* @returns An unlocked wallet instance.
|
8073
|
+
*/
|
8074
|
+
static fromEncryptedJson = WalletUnlocked.fromEncryptedJson;
|
8110
8075
|
};
|
8111
|
-
/**
|
8112
|
-
* Generate a new Wallet Unlocked with a random key pair.
|
8113
|
-
*
|
8114
|
-
* @param generateOptions - Options to customize the generation process (optional).
|
8115
|
-
* @returns An unlocked wallet instance.
|
8116
|
-
*/
|
8117
|
-
__publicField(Wallet, "generate", WalletUnlocked.generate);
|
8118
|
-
/**
|
8119
|
-
* Create a Wallet Unlocked from a seed.
|
8120
|
-
*
|
8121
|
-
* @param seed - The seed phrase.
|
8122
|
-
* @param provider - A Provider instance (optional).
|
8123
|
-
* @param path - The derivation path (optional).
|
8124
|
-
* @returns An unlocked wallet instance.
|
8125
|
-
*/
|
8126
|
-
__publicField(Wallet, "fromSeed", WalletUnlocked.fromSeed);
|
8127
|
-
/**
|
8128
|
-
* Create a Wallet Unlocked from a mnemonic phrase.
|
8129
|
-
*
|
8130
|
-
* @param mnemonic - The mnemonic phrase.
|
8131
|
-
* @param provider - A Provider instance (optional).
|
8132
|
-
* @param path - The derivation path (optional).
|
8133
|
-
* @param passphrase - The passphrase for the mnemonic (optional).
|
8134
|
-
* @returns An unlocked wallet instance.
|
8135
|
-
*/
|
8136
|
-
__publicField(Wallet, "fromMnemonic", WalletUnlocked.fromMnemonic);
|
8137
|
-
/**
|
8138
|
-
* Create a Wallet Unlocked from an extended key.
|
8139
|
-
*
|
8140
|
-
* @param extendedKey - The extended key.
|
8141
|
-
* @param provider - A Provider instance (optional).
|
8142
|
-
* @returns An unlocked wallet instance.
|
8143
|
-
*/
|
8144
|
-
__publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
8145
|
-
/**
|
8146
|
-
* Create a Wallet Unlocked from an encrypted JSON.
|
8147
|
-
*
|
8148
|
-
* @param jsonWallet - The encrypted JSON keystore.
|
8149
|
-
* @param password - The password to decrypt the JSON.
|
8150
|
-
* @param provider - A Provider instance (optional).
|
8151
|
-
* @returns An unlocked wallet instance.
|
8152
|
-
*/
|
8153
|
-
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
8154
8076
|
|
8155
8077
|
// src/wallet-manager/wallet-manager.ts
|
8156
8078
|
import { Address as Address8 } from "@fuel-ts/address";
|
@@ -8179,14 +8101,14 @@ var MemoryStorage = class {
|
|
8179
8101
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
8180
8102
|
import { Address as Address6 } from "@fuel-ts/address";
|
8181
8103
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
8182
|
-
var _secret;
|
8183
8104
|
var MnemonicVault = class {
|
8105
|
+
static type = "mnemonic";
|
8106
|
+
#secret;
|
8107
|
+
pathKey = "{}";
|
8108
|
+
rootPath = `m/44'/1179993420'/${this.pathKey}'/0/0`;
|
8109
|
+
numberOfAccounts = 0;
|
8184
8110
|
constructor(options) {
|
8185
|
-
|
8186
|
-
__publicField(this, "pathKey", "{}");
|
8187
|
-
__publicField(this, "rootPath", `m/44'/1179993420'/${this.pathKey}'/0/0`);
|
8188
|
-
__publicField(this, "numberOfAccounts", 0);
|
8189
|
-
__privateSet(this, _secret, options.secret || mnemonic_default.generate());
|
8111
|
+
this.#secret = options.secret || mnemonic_default.generate();
|
8190
8112
|
this.rootPath = options.rootPath || this.rootPath;
|
8191
8113
|
this.numberOfAccounts = options.numberOfAccounts || 1;
|
8192
8114
|
}
|
@@ -8198,7 +8120,7 @@ var MnemonicVault = class {
|
|
8198
8120
|
}
|
8199
8121
|
serialize() {
|
8200
8122
|
return {
|
8201
|
-
secret:
|
8123
|
+
secret: this.#secret,
|
8202
8124
|
rootPath: this.rootPath,
|
8203
8125
|
numberOfAccounts: this.numberOfAccounts
|
8204
8126
|
};
|
@@ -8207,7 +8129,7 @@ var MnemonicVault = class {
|
|
8207
8129
|
const accounts = [];
|
8208
8130
|
let numberOfAccounts = 0;
|
8209
8131
|
do {
|
8210
|
-
const wallet = Wallet.fromMnemonic(
|
8132
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
|
8211
8133
|
accounts.push({
|
8212
8134
|
publicKey: wallet.publicKey,
|
8213
8135
|
address: wallet.address
|
@@ -8218,7 +8140,7 @@ var MnemonicVault = class {
|
|
8218
8140
|
}
|
8219
8141
|
addAccount() {
|
8220
8142
|
this.numberOfAccounts += 1;
|
8221
|
-
const wallet = Wallet.fromMnemonic(
|
8143
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(this.numberOfAccounts - 1));
|
8222
8144
|
return {
|
8223
8145
|
publicKey: wallet.publicKey,
|
8224
8146
|
address: wallet.address
|
@@ -8228,7 +8150,7 @@ var MnemonicVault = class {
|
|
8228
8150
|
let numberOfAccounts = 0;
|
8229
8151
|
const ownerAddress = Address6.fromAddressOrString(address);
|
8230
8152
|
do {
|
8231
|
-
const wallet = Wallet.fromMnemonic(
|
8153
|
+
const wallet = Wallet.fromMnemonic(this.#secret, this.getDerivePath(numberOfAccounts));
|
8232
8154
|
if (wallet.address.equals(ownerAddress)) {
|
8233
8155
|
return wallet.privateKey;
|
8234
8156
|
}
|
@@ -8244,29 +8166,27 @@ var MnemonicVault = class {
|
|
8244
8166
|
return Wallet.fromPrivateKey(privateKey);
|
8245
8167
|
}
|
8246
8168
|
};
|
8247
|
-
_secret = new WeakMap();
|
8248
|
-
__publicField(MnemonicVault, "type", "mnemonic");
|
8249
8169
|
|
8250
8170
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
8251
8171
|
import { Address as Address7 } from "@fuel-ts/address";
|
8252
8172
|
import { ErrorCode as ErrorCode20, FuelError as FuelError20 } from "@fuel-ts/errors";
|
8253
|
-
var _privateKeys;
|
8254
8173
|
var PrivateKeyVault = class {
|
8174
|
+
static type = "privateKey";
|
8175
|
+
#privateKeys = [];
|
8255
8176
|
/**
|
8256
8177
|
* If privateKey vault is initialized with a secretKey, it creates
|
8257
8178
|
* one account with the fallowing secret
|
8258
8179
|
*/
|
8259
8180
|
constructor(options = {}) {
|
8260
|
-
__privateAdd(this, _privateKeys, []);
|
8261
8181
|
if (options.secret) {
|
8262
|
-
|
8182
|
+
this.#privateKeys = [options.secret];
|
8263
8183
|
} else {
|
8264
|
-
|
8184
|
+
this.#privateKeys = options.accounts || [Wallet.generate().privateKey];
|
8265
8185
|
}
|
8266
8186
|
}
|
8267
8187
|
serialize() {
|
8268
8188
|
return {
|
8269
|
-
accounts:
|
8189
|
+
accounts: this.#privateKeys
|
8270
8190
|
};
|
8271
8191
|
}
|
8272
8192
|
getPublicAccount(privateKey) {
|
@@ -8277,16 +8197,16 @@ var PrivateKeyVault = class {
|
|
8277
8197
|
};
|
8278
8198
|
}
|
8279
8199
|
getAccounts() {
|
8280
|
-
return
|
8200
|
+
return this.#privateKeys.map((pk) => this.getPublicAccount(pk));
|
8281
8201
|
}
|
8282
8202
|
addAccount() {
|
8283
8203
|
const wallet = Wallet.generate();
|
8284
|
-
|
8204
|
+
this.#privateKeys.push(wallet.privateKey);
|
8285
8205
|
return this.getPublicAccount(wallet.privateKey);
|
8286
8206
|
}
|
8287
8207
|
exportAccount(address) {
|
8288
8208
|
const ownerAddress = Address7.fromAddressOrString(address);
|
8289
|
-
const privateKey =
|
8209
|
+
const privateKey = this.#privateKeys.find(
|
8290
8210
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
8291
8211
|
);
|
8292
8212
|
if (!privateKey) {
|
@@ -8302,8 +8222,6 @@ var PrivateKeyVault = class {
|
|
8302
8222
|
return Wallet.fromPrivateKey(privateKey);
|
8303
8223
|
}
|
8304
8224
|
};
|
8305
|
-
_privateKeys = new WeakMap();
|
8306
|
-
__publicField(PrivateKeyVault, "type", "privateKey");
|
8307
8225
|
|
8308
8226
|
// src/wallet-manager/wallet-manager.ts
|
8309
8227
|
var ERROR_MESSAGES = {
|
@@ -8318,46 +8236,43 @@ function assert(condition, message) {
|
|
8318
8236
|
throw new FuelError21(ErrorCode21.WALLET_MANAGER_ERROR, message);
|
8319
8237
|
}
|
8320
8238
|
}
|
8321
|
-
var
|
8322
|
-
|
8239
|
+
var WalletManager = class _WalletManager extends EventEmitter {
|
8240
|
+
/**
|
8241
|
+
* Vaults
|
8242
|
+
*
|
8243
|
+
* Vaults are responsible to store secret keys and return an `Wallet` instance,
|
8244
|
+
* to interact with the network.
|
8245
|
+
*
|
8246
|
+
* Each vault has access to its own state
|
8247
|
+
*
|
8248
|
+
*/
|
8249
|
+
static Vaults = [MnemonicVault, PrivateKeyVault];
|
8250
|
+
/**
|
8251
|
+
* Storage
|
8252
|
+
*
|
8253
|
+
* Persistent encrypted data. `The default storage works only on memory`.
|
8254
|
+
*/
|
8255
|
+
storage = new MemoryStorage();
|
8256
|
+
/* Key name passed to the storage */
|
8257
|
+
STORAGE_KEY = "WalletManager";
|
8258
|
+
// `This variables are only accessible from inside the class`
|
8259
|
+
#vaults = [];
|
8260
|
+
#passphrase = "";
|
8261
|
+
#isLocked = true;
|
8323
8262
|
constructor(options) {
|
8324
8263
|
super();
|
8325
|
-
/**
|
8326
|
-
* Serialize all vaults to store
|
8327
|
-
*
|
8328
|
-
* `This is only accessible from inside the class`
|
8329
|
-
*/
|
8330
|
-
__privateAdd(this, _serializeVaults);
|
8331
|
-
/**
|
8332
|
-
* Deserialize all vaults to state
|
8333
|
-
*
|
8334
|
-
* `This is only accessible from inside the class`
|
8335
|
-
*/
|
8336
|
-
__privateAdd(this, _deserializeVaults);
|
8337
|
-
/**
|
8338
|
-
* Storage
|
8339
|
-
*
|
8340
|
-
* Persistent encrypted data. `The default storage works only on memory`.
|
8341
|
-
*/
|
8342
|
-
__publicField(this, "storage", new MemoryStorage());
|
8343
|
-
/* Key name passed to the storage */
|
8344
|
-
__publicField(this, "STORAGE_KEY", "WalletManager");
|
8345
|
-
// `This variables are only accessible from inside the class`
|
8346
|
-
__privateAdd(this, _vaults, []);
|
8347
|
-
__privateAdd(this, _passphrase, "");
|
8348
|
-
__privateAdd(this, _isLocked, true);
|
8349
8264
|
this.storage = options?.storage || this.storage;
|
8350
8265
|
}
|
8351
8266
|
get isLocked() {
|
8352
|
-
return
|
8267
|
+
return this.#isLocked;
|
8353
8268
|
}
|
8354
8269
|
/**
|
8355
8270
|
* Return the vault serialized object containing all the privateKeys,
|
8356
8271
|
* the format of the return depends on the Vault type.
|
8357
8272
|
*/
|
8358
8273
|
exportVault(vaultId) {
|
8359
|
-
assert(!
|
8360
|
-
const vaultState =
|
8274
|
+
assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
8275
|
+
const vaultState = this.#vaults.find((_, idx) => idx === vaultId);
|
8361
8276
|
assert(vaultState, ERROR_MESSAGES.vault_not_found);
|
8362
8277
|
return vaultState.vault.serialize();
|
8363
8278
|
}
|
@@ -8365,7 +8280,7 @@ var _WalletManager = class extends EventEmitter {
|
|
8365
8280
|
* List all vaults on the Wallet Manager, this function not return secret's
|
8366
8281
|
*/
|
8367
8282
|
getVaults() {
|
8368
|
-
return
|
8283
|
+
return this.#vaults.map((v, idx) => ({
|
8369
8284
|
title: v.title,
|
8370
8285
|
type: v.type,
|
8371
8286
|
vaultId: idx
|
@@ -8375,7 +8290,7 @@ var _WalletManager = class extends EventEmitter {
|
|
8375
8290
|
* List all accounts on the Wallet Manager not vault information is revealed
|
8376
8291
|
*/
|
8377
8292
|
getAccounts() {
|
8378
|
-
return
|
8293
|
+
return this.#vaults.flatMap(
|
8379
8294
|
(vaultState, vaultId) => vaultState.vault.getAccounts().map((account) => ({ ...account, vaultId }))
|
8380
8295
|
);
|
8381
8296
|
}
|
@@ -8384,7 +8299,7 @@ var _WalletManager = class extends EventEmitter {
|
|
8384
8299
|
*/
|
8385
8300
|
getWallet(address) {
|
8386
8301
|
const ownerAddress = Address8.fromAddressOrString(address);
|
8387
|
-
const vaultState =
|
8302
|
+
const vaultState = this.#vaults.find(
|
8388
8303
|
(vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
|
8389
8304
|
);
|
8390
8305
|
assert(vaultState, ERROR_MESSAGES.address_not_found);
|
@@ -8395,8 +8310,8 @@ var _WalletManager = class extends EventEmitter {
|
|
8395
8310
|
*/
|
8396
8311
|
exportPrivateKey(address) {
|
8397
8312
|
const ownerAddress = Address8.fromAddressOrString(address);
|
8398
|
-
assert(!
|
8399
|
-
const vaultState =
|
8313
|
+
assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
8314
|
+
const vaultState = this.#vaults.find(
|
8400
8315
|
(vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
|
8401
8316
|
);
|
8402
8317
|
assert(vaultState, ERROR_MESSAGES.address_not_found);
|
@@ -8408,7 +8323,7 @@ var _WalletManager = class extends EventEmitter {
|
|
8408
8323
|
*/
|
8409
8324
|
async addAccount(options) {
|
8410
8325
|
await this.loadState();
|
8411
|
-
const vaultState =
|
8326
|
+
const vaultState = this.#vaults[options?.vaultId || 0];
|
8412
8327
|
await assert(vaultState, ERROR_MESSAGES.vault_not_found);
|
8413
8328
|
const account = vaultState.vault.addAccount();
|
8414
8329
|
await this.saveState();
|
@@ -8419,7 +8334,7 @@ var _WalletManager = class extends EventEmitter {
|
|
8419
8334
|
* created by the vault.
|
8420
8335
|
*/
|
8421
8336
|
async removeVault(index) {
|
8422
|
-
|
8337
|
+
this.#vaults.splice(index, 1);
|
8423
8338
|
await this.saveState();
|
8424
8339
|
}
|
8425
8340
|
/**
|
@@ -8430,11 +8345,11 @@ var _WalletManager = class extends EventEmitter {
|
|
8430
8345
|
await this.loadState();
|
8431
8346
|
const Vault2 = this.getVaultClass(vaultConfig.type);
|
8432
8347
|
const vault = new Vault2(vaultConfig);
|
8433
|
-
|
8348
|
+
this.#vaults = this.#vaults.concat({
|
8434
8349
|
title: vaultConfig.title,
|
8435
8350
|
type: vaultConfig.type,
|
8436
8351
|
vault
|
8437
|
-
})
|
8352
|
+
});
|
8438
8353
|
await this.saveState();
|
8439
8354
|
}
|
8440
8355
|
/**
|
@@ -8442,9 +8357,9 @@ var _WalletManager = class extends EventEmitter {
|
|
8442
8357
|
* secrets.
|
8443
8358
|
*/
|
8444
8359
|
lock() {
|
8445
|
-
|
8446
|
-
|
8447
|
-
|
8360
|
+
this.#isLocked = true;
|
8361
|
+
this.#vaults = [];
|
8362
|
+
this.#passphrase = "";
|
8448
8363
|
this.emit("lock");
|
8449
8364
|
}
|
8450
8365
|
/**
|
@@ -8452,8 +8367,8 @@ var _WalletManager = class extends EventEmitter {
|
|
8452
8367
|
* Vaults with secrets are not unlocked or instantiated on this moment.
|
8453
8368
|
*/
|
8454
8369
|
async unlock(passphrase) {
|
8455
|
-
|
8456
|
-
|
8370
|
+
this.#passphrase = passphrase;
|
8371
|
+
this.#isLocked = false;
|
8457
8372
|
try {
|
8458
8373
|
await this.loadState();
|
8459
8374
|
this.emit("unlock");
|
@@ -8466,9 +8381,9 @@ var _WalletManager = class extends EventEmitter {
|
|
8466
8381
|
* Update WalletManager encryption passphrase
|
8467
8382
|
*/
|
8468
8383
|
async updatePassphrase(oldpass, newpass) {
|
8469
|
-
const isLocked =
|
8384
|
+
const isLocked = this.#isLocked;
|
8470
8385
|
await this.unlock(oldpass);
|
8471
|
-
|
8386
|
+
this.#passphrase = newpass;
|
8472
8387
|
await this.saveState();
|
8473
8388
|
await this.loadState();
|
8474
8389
|
if (isLocked) {
|
@@ -8479,24 +8394,51 @@ var _WalletManager = class extends EventEmitter {
|
|
8479
8394
|
* Retrieve and decrypt WalletManager state from storage
|
8480
8395
|
*/
|
8481
8396
|
async loadState() {
|
8482
|
-
await assert(!
|
8397
|
+
await assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
8483
8398
|
const data = await this.storage.getItem(this.STORAGE_KEY);
|
8484
8399
|
if (data) {
|
8485
|
-
const state = await decrypt(
|
8486
|
-
|
8400
|
+
const state = await decrypt(this.#passphrase, JSON.parse(data));
|
8401
|
+
this.#vaults = this.#deserializeVaults(state.vaults);
|
8487
8402
|
}
|
8488
8403
|
}
|
8489
8404
|
/**
|
8490
8405
|
* Store encrypted WalletManager state on storage
|
8491
8406
|
*/
|
8492
8407
|
async saveState() {
|
8493
|
-
await assert(!
|
8494
|
-
const encryptedData = await encrypt(
|
8495
|
-
vaults:
|
8408
|
+
await assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked);
|
8409
|
+
const encryptedData = await encrypt(this.#passphrase, {
|
8410
|
+
vaults: this.#serializeVaults(this.#vaults)
|
8496
8411
|
});
|
8497
8412
|
await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
|
8498
8413
|
this.emit("update");
|
8499
8414
|
}
|
8415
|
+
/**
|
8416
|
+
* Serialize all vaults to store
|
8417
|
+
*
|
8418
|
+
* `This is only accessible from inside the class`
|
8419
|
+
*/
|
8420
|
+
#serializeVaults(vaults) {
|
8421
|
+
return vaults.map(({ title, type, vault }) => ({
|
8422
|
+
title,
|
8423
|
+
type,
|
8424
|
+
data: vault.serialize()
|
8425
|
+
}));
|
8426
|
+
}
|
8427
|
+
/**
|
8428
|
+
* Deserialize all vaults to state
|
8429
|
+
*
|
8430
|
+
* `This is only accessible from inside the class`
|
8431
|
+
*/
|
8432
|
+
#deserializeVaults(vaults) {
|
8433
|
+
return vaults.map(({ title, type, data: vaultConfig }) => {
|
8434
|
+
const VaultClass = this.getVaultClass(type);
|
8435
|
+
return {
|
8436
|
+
title,
|
8437
|
+
type,
|
8438
|
+
vault: new VaultClass(vaultConfig)
|
8439
|
+
};
|
8440
|
+
});
|
8441
|
+
}
|
8500
8442
|
/**
|
8501
8443
|
* Return a instantiable Class reference from `WalletManager.Vaults` supported list.
|
8502
8444
|
*/
|
@@ -8506,43 +8448,11 @@ var _WalletManager = class extends EventEmitter {
|
|
8506
8448
|
return VaultClass;
|
8507
8449
|
}
|
8508
8450
|
};
|
8509
|
-
var WalletManager = _WalletManager;
|
8510
|
-
_vaults = new WeakMap();
|
8511
|
-
_passphrase = new WeakMap();
|
8512
|
-
_isLocked = new WeakMap();
|
8513
|
-
_serializeVaults = new WeakSet();
|
8514
|
-
serializeVaults_fn = function(vaults) {
|
8515
|
-
return vaults.map(({ title, type, vault }) => ({
|
8516
|
-
title,
|
8517
|
-
type,
|
8518
|
-
data: vault.serialize()
|
8519
|
-
}));
|
8520
|
-
};
|
8521
|
-
_deserializeVaults = new WeakSet();
|
8522
|
-
deserializeVaults_fn = function(vaults) {
|
8523
|
-
return vaults.map(({ title, type, data: vaultConfig }) => {
|
8524
|
-
const VaultClass = this.getVaultClass(type);
|
8525
|
-
return {
|
8526
|
-
title,
|
8527
|
-
type,
|
8528
|
-
vault: new VaultClass(vaultConfig)
|
8529
|
-
};
|
8530
|
-
});
|
8531
|
-
};
|
8532
|
-
/**
|
8533
|
-
* Vaults
|
8534
|
-
*
|
8535
|
-
* Vaults are responsible to store secret keys and return an `Wallet` instance,
|
8536
|
-
* to interact with the network.
|
8537
|
-
*
|
8538
|
-
* Each vault has access to its own state
|
8539
|
-
*
|
8540
|
-
*/
|
8541
|
-
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
8542
8451
|
|
8543
8452
|
// src/wallet-manager/types.ts
|
8544
8453
|
import { ErrorCode as ErrorCode22, FuelError as FuelError22 } from "@fuel-ts/errors";
|
8545
8454
|
var Vault = class {
|
8455
|
+
static type;
|
8546
8456
|
constructor(_options) {
|
8547
8457
|
throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
|
8548
8458
|
}
|
@@ -8562,7 +8472,6 @@ var Vault = class {
|
|
8562
8472
|
throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
|
8563
8473
|
}
|
8564
8474
|
};
|
8565
|
-
__publicField(Vault, "type");
|
8566
8475
|
var StorageAbstract = class {
|
8567
8476
|
};
|
8568
8477
|
|
@@ -8594,7 +8503,7 @@ var getPredicateRoot = (bytecode) => {
|
|
8594
8503
|
};
|
8595
8504
|
|
8596
8505
|
// src/predicate/predicate.ts
|
8597
|
-
var Predicate = class extends Account {
|
8506
|
+
var Predicate = class _Predicate extends Account {
|
8598
8507
|
bytes;
|
8599
8508
|
predicateDataBytes = Uint8Array.from([]);
|
8600
8509
|
predicateData = [];
|
@@ -8615,7 +8524,7 @@ var Predicate = class extends Account {
|
|
8615
8524
|
inputData,
|
8616
8525
|
configurableConstants
|
8617
8526
|
}) {
|
8618
|
-
const { predicateBytes, predicateInterface } =
|
8527
|
+
const { predicateBytes, predicateInterface } = _Predicate.processPredicateData(
|
8619
8528
|
bytecode,
|
8620
8529
|
abi,
|
8621
8530
|
configurableConstants
|
@@ -8711,7 +8620,7 @@ var Predicate = class extends Account {
|
|
8711
8620
|
}
|
8712
8621
|
}
|
8713
8622
|
if (configurableConstants && Object.keys(configurableConstants).length) {
|
8714
|
-
predicateBytes =
|
8623
|
+
predicateBytes = _Predicate.setConfigurableConstants(
|
8715
8624
|
predicateBytes,
|
8716
8625
|
configurableConstants,
|
8717
8626
|
abiInterface
|
@@ -8899,18 +8808,6 @@ var FuelConnector = class extends EventEmitter2 {
|
|
8899
8808
|
async signMessage(_address, _message) {
|
8900
8809
|
throw new Error("Method not implemented.");
|
8901
8810
|
}
|
8902
|
-
/**
|
8903
|
-
* Should start the sign transaction process and return
|
8904
|
-
* the signed transaction.
|
8905
|
-
*
|
8906
|
-
* @param address - The address to sign the transaction
|
8907
|
-
* @param transaction - The transaction to sign
|
8908
|
-
*
|
8909
|
-
* @returns Transaction signature
|
8910
|
-
*/
|
8911
|
-
async signTransaction(_address, _transaction) {
|
8912
|
-
throw new Error("Method not implemented.");
|
8913
|
-
}
|
8914
8811
|
/**
|
8915
8812
|
* Should start the send transaction process and return
|
8916
8813
|
* the transaction id submitted to the network.
|
@@ -9103,7 +9000,9 @@ async function withTimeout(promise, timeout = 1050) {
|
|
9103
9000
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
9104
9001
|
var PING_CACHE_TIME = 5e3;
|
9105
9002
|
var { warn } = console;
|
9106
|
-
var
|
9003
|
+
var Fuel = class _Fuel extends FuelConnector {
|
9004
|
+
static STORAGE_KEY = "fuel-current-connector";
|
9005
|
+
static defaultConfig = {};
|
9107
9006
|
_storage = null;
|
9108
9007
|
_connectors = [];
|
9109
9008
|
_targetObject = null;
|
@@ -9428,9 +9327,6 @@ var _Fuel = class extends FuelConnector {
|
|
9428
9327
|
await this.clean();
|
9429
9328
|
}
|
9430
9329
|
};
|
9431
|
-
var Fuel = _Fuel;
|
9432
|
-
__publicField(Fuel, "STORAGE_KEY", "fuel-current-connector");
|
9433
|
-
__publicField(Fuel, "defaultConfig", {});
|
9434
9330
|
export {
|
9435
9331
|
Account,
|
9436
9332
|
AddressType,
|