@turnkey/core 1.0.0-beta.2 → 1.0.0-beta.4
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.
- package/dist/__clients__/core.d.ts +75 -2
- package/dist/__clients__/core.d.ts.map +1 -1
- package/dist/__clients__/core.js +637 -503
- package/dist/__clients__/core.js.map +1 -1
- package/dist/__clients__/core.mjs +640 -506
- package/dist/__clients__/core.mjs.map +1 -1
- package/dist/__generated__/sdk-client-base.d.ts +1 -1
- package/dist/__generated__/sdk-client-base.d.ts.map +1 -1
- package/dist/__generated__/sdk-client-base.js +156 -250
- package/dist/__generated__/sdk-client-base.js.map +1 -1
- package/dist/__generated__/sdk-client-base.mjs +156 -250
- package/dist/__generated__/sdk-client-base.mjs.map +1 -1
- package/dist/__generated__/version.d.ts +1 -1
- package/dist/__generated__/version.js +1 -1
- package/dist/__generated__/version.mjs +1 -1
- package/dist/__types__/base.d.ts +1 -1
- package/dist/__wallet__/base.d.ts +11 -0
- package/dist/__wallet__/base.d.ts.map +1 -1
- package/dist/__wallet__/base.js +12 -1
- package/dist/__wallet__/base.js.map +1 -1
- package/dist/__wallet__/base.mjs +12 -1
- package/dist/__wallet__/base.mjs.map +1 -1
- package/dist/__wallet__/connector.d.ts +31 -4
- package/dist/__wallet__/connector.d.ts.map +1 -1
- package/dist/__wallet__/connector.js +35 -5
- package/dist/__wallet__/connector.js.map +1 -1
- package/dist/__wallet__/connector.mjs +35 -5
- package/dist/__wallet__/connector.mjs.map +1 -1
- package/dist/__wallet__/mobile/manager.d.ts +21 -5
- package/dist/__wallet__/mobile/manager.d.ts.map +1 -1
- package/dist/__wallet__/mobile/manager.js +28 -11
- package/dist/__wallet__/mobile/manager.js.map +1 -1
- package/dist/__wallet__/mobile/manager.mjs +28 -11
- package/dist/__wallet__/mobile/manager.mjs.map +1 -1
- package/dist/__wallet__/stamper.d.ts +73 -2
- package/dist/__wallet__/stamper.d.ts.map +1 -1
- package/dist/__wallet__/stamper.js +79 -13
- package/dist/__wallet__/stamper.js.map +1 -1
- package/dist/__wallet__/stamper.mjs +79 -13
- package/dist/__wallet__/stamper.mjs.map +1 -1
- package/dist/__wallet__/wallet-connect/base.d.ts +99 -19
- package/dist/__wallet__/wallet-connect/base.d.ts.map +1 -1
- package/dist/__wallet__/wallet-connect/base.js +172 -75
- package/dist/__wallet__/wallet-connect/base.js.map +1 -1
- package/dist/__wallet__/wallet-connect/base.mjs +172 -75
- package/dist/__wallet__/wallet-connect/base.mjs.map +1 -1
- package/dist/__wallet__/wallet-connect/client.d.ts +22 -14
- package/dist/__wallet__/wallet-connect/client.d.ts.map +1 -1
- package/dist/__wallet__/wallet-connect/client.js +22 -14
- package/dist/__wallet__/wallet-connect/client.js.map +1 -1
- package/dist/__wallet__/wallet-connect/client.mjs +22 -14
- package/dist/__wallet__/wallet-connect/client.mjs.map +1 -1
- package/dist/__wallet__/web/manager.d.ts +20 -12
- package/dist/__wallet__/web/manager.d.ts.map +1 -1
- package/dist/__wallet__/web/manager.js +29 -21
- package/dist/__wallet__/web/manager.js.map +1 -1
- package/dist/__wallet__/web/manager.mjs +29 -21
- package/dist/__wallet__/web/manager.mjs.map +1 -1
- package/dist/__wallet__/web/native/ethereum.d.ts +45 -11
- package/dist/__wallet__/web/native/ethereum.d.ts.map +1 -1
- package/dist/__wallet__/web/native/ethereum.js +58 -17
- package/dist/__wallet__/web/native/ethereum.js.map +1 -1
- package/dist/__wallet__/web/native/ethereum.mjs +58 -17
- package/dist/__wallet__/web/native/ethereum.mjs.map +1 -1
- package/dist/__wallet__/web/native/solana.d.ts +56 -3
- package/dist/__wallet__/web/native/solana.d.ts.map +1 -1
- package/dist/__wallet__/web/native/solana.js +95 -36
- package/dist/__wallet__/web/native/solana.js.map +1 -1
- package/dist/__wallet__/web/native/solana.mjs +95 -36
- package/dist/__wallet__/web/native/solana.mjs.map +1 -1
- package/dist/utils.d.ts +24 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +54 -0
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +54 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import SignClient from '@walletconnect/sign-client';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* WalletConnectClient is a low-level wrapper around the WalletConnect SignClient.
|
|
5
|
+
*
|
|
6
|
+
* - Used internally by `WalletConnectWallet` to manage connections and sessions.
|
|
7
|
+
* - Handles pairing, approval, session tracking, RPC requests, and disconnects.
|
|
8
|
+
* - Exposes a minimal API for lifecycle control; higher-level logic lives in `WalletConnectWallet`.
|
|
9
|
+
*/
|
|
3
10
|
class WalletConnectClient {
|
|
4
11
|
constructor() {
|
|
5
12
|
// tracks the pending approval callback returned from `connect()`
|
|
@@ -20,12 +27,12 @@ class WalletConnectClient {
|
|
|
20
27
|
/**
|
|
21
28
|
* Initializes the WalletConnect SignClient with your project credentials.
|
|
22
29
|
*
|
|
23
|
-
* - Must be called before
|
|
24
|
-
* - Configures metadata and
|
|
30
|
+
* - Must be called before `pair()`, `approve()`, or `request()`.
|
|
31
|
+
* - Configures app metadata and an optional custom relay server.
|
|
25
32
|
*
|
|
26
33
|
* @param opts.projectId - WalletConnect project ID.
|
|
27
|
-
* @param opts.
|
|
28
|
-
* @param opts.relayUrl - (Optional)
|
|
34
|
+
* @param opts.appMetadata - Metadata about your app (name, URL, icons).
|
|
35
|
+
* @param opts.relayUrl - (Optional) custom relay server URL.
|
|
29
36
|
* @returns A promise that resolves once the client is initialized.
|
|
30
37
|
*/
|
|
31
38
|
async init(opts) {
|
|
@@ -42,12 +49,13 @@ class WalletConnectClient {
|
|
|
42
49
|
/**
|
|
43
50
|
* Initiates a pairing request and returns a URI to be scanned or deep-linked.
|
|
44
51
|
*
|
|
45
|
-
* -
|
|
52
|
+
* - Requires `init()` to have been called.
|
|
53
|
+
* - Must be followed by `approve()` after the wallet approves.
|
|
46
54
|
* - Throws if a pairing is already in progress.
|
|
47
55
|
*
|
|
48
|
-
* @param namespaces -
|
|
56
|
+
* @param namespaces - Optional namespaces requesting capabilities.
|
|
49
57
|
* @returns A WalletConnect URI for the wallet to connect with.
|
|
50
|
-
* @throws {Error} If a pairing is already in progress or URI is
|
|
58
|
+
* @throws {Error} If a pairing is already in progress or no URI is returned.
|
|
51
59
|
*/
|
|
52
60
|
async pair(namespaces) {
|
|
53
61
|
if (this.pendingApproval) {
|
|
@@ -65,10 +73,10 @@ class WalletConnectClient {
|
|
|
65
73
|
/**
|
|
66
74
|
* Completes the pairing approval process after the wallet approves the request.
|
|
67
75
|
*
|
|
68
|
-
* -
|
|
76
|
+
* - Requires `init()` and a pending pairing started via `pair()`.
|
|
69
77
|
*
|
|
70
78
|
* @returns A promise that resolves to the established session.
|
|
71
|
-
* @throws {Error} If called before `pair()` or approval fails.
|
|
79
|
+
* @throws {Error} If called before `pair()` or if approval fails.
|
|
72
80
|
*/
|
|
73
81
|
async approve() {
|
|
74
82
|
if (!this.pendingApproval) {
|
|
@@ -95,13 +103,13 @@ class WalletConnectClient {
|
|
|
95
103
|
/**
|
|
96
104
|
* Sends a JSON-RPC request over the active WalletConnect session.
|
|
97
105
|
*
|
|
98
|
-
* -
|
|
106
|
+
* - Requires `init()` and an active session.
|
|
99
107
|
*
|
|
100
|
-
* @param chainId -
|
|
101
|
-
* @param method -
|
|
102
|
-
* @param params -
|
|
108
|
+
* @param chainId - Target chain ID (e.g. `eip155:1`).
|
|
109
|
+
* @param method - RPC method name.
|
|
110
|
+
* @param params - Parameters for the RPC method.
|
|
103
111
|
* @returns A promise that resolves with the RPC response.
|
|
104
|
-
* @throws {Error} If no active session
|
|
112
|
+
* @throws {Error} If no active session exists.
|
|
105
113
|
*/
|
|
106
114
|
async request(chainId, method, params) {
|
|
107
115
|
const session = this.getSession();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","sources":["../../../src/__wallet__/wallet-connect/client.ts"],"sourcesContent":[null],"names":[],"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,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,mBAAmB,EAAE;AACrD,SAAA,CAAC;;AAEL;;;;"}
|
|
@@ -10,31 +10,39 @@ export declare class WebWalletManager {
|
|
|
10
10
|
readonly connector?: CrossPlatformWalletConnector;
|
|
11
11
|
/**
|
|
12
12
|
* Constructs a WebWalletManager instance based on the provided configuration.
|
|
13
|
-
* Sets up native wallets and WalletConnect support.
|
|
14
13
|
*
|
|
15
|
-
*
|
|
14
|
+
* - Enables native Ethereum and/or Solana wallet support if configured.
|
|
15
|
+
* - Enables WalletConnect support for Ethereum and/or Solana chains if namespaces are provided.
|
|
16
|
+
* - Sets up `CrossPlatformWalletStamper` and `CrossPlatformWalletConnector` if auth or connecting features are enabled.
|
|
17
|
+
*
|
|
18
|
+
* @param cfg - Wallet manager configuration.
|
|
16
19
|
*/
|
|
17
20
|
constructor(cfg: TWalletManagerConfig);
|
|
18
21
|
/**
|
|
19
|
-
* Initializes
|
|
22
|
+
* Initializes WalletConnect components and any registered wallet interfaces.
|
|
20
23
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
24
|
+
* - Initializes the low-level WalletConnect client with the provided config.
|
|
25
|
+
* - Runs any registered async wallet initializers (currently only `WalletConnectWallet`).
|
|
26
|
+
*
|
|
27
|
+
* @param cfg - Wallet manager configuration used for initializing the WalletConnect client.
|
|
23
28
|
*/
|
|
24
29
|
init(cfg: TWalletManagerConfig): Promise<void>;
|
|
25
30
|
/**
|
|
26
|
-
* Retrieves available wallet providers
|
|
31
|
+
* Retrieves available wallet providers, optionally filtered by chain.
|
|
32
|
+
*
|
|
33
|
+
* - If a chain is specified, filters wallet interfaces that support that chain.
|
|
34
|
+
* - Aggregates providers across all wallet interfaces and filters WalletConnect results accordingly.
|
|
27
35
|
*
|
|
28
|
-
* @param chain - Optional chain to filter providers by.
|
|
29
|
-
* @returns A promise that resolves to an array of
|
|
30
|
-
* @throws If no wallet interface is registered for the given chain.
|
|
36
|
+
* @param chain - Optional chain to filter providers by (e.g., Ethereum, Solana).
|
|
37
|
+
* @returns A promise that resolves to an array of `WalletProvider` objects.
|
|
38
|
+
* @throws {Error} If no wallet interface is registered for the given chain.
|
|
31
39
|
*/
|
|
32
40
|
getProviders(chain?: Chain): Promise<WalletProvider[]>;
|
|
33
41
|
/**
|
|
34
|
-
* Registers a wallet interface as supporting a specific blockchain chain.
|
|
42
|
+
* Registers a wallet interface type as supporting a specific blockchain chain.
|
|
35
43
|
*
|
|
36
|
-
* @param chain -
|
|
37
|
-
* @param
|
|
44
|
+
* @param chain - Chain (e.g., Ethereum, Solana).
|
|
45
|
+
* @param interfaceType - Wallet interface type to associate with the chain.
|
|
38
46
|
*/
|
|
39
47
|
private addChainInterface;
|
|
40
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/__wallet__/web/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAG5D,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,KAAK,EACN,MAAM,QAAQ,CAAC;AAIhB,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,YAAY,CAAkC;IAGtD,OAAO,CAAC,QAAQ,CAAC,CAAsB;IAGvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC,CAAM;IAG7E,OAAO,CAAC,iBAAiB,CAAqD;IAG9E,QAAQ,CAAC,OAAO,CAAC,EAAE,0BAA0B,CAAC;IAG9C,QAAQ,CAAC,SAAS,CAAC,EAAE,4BAA4B,CAAC;IAElD
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/__wallet__/web/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAG5D,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,KAAK,EACN,MAAM,QAAQ,CAAC;AAIhB,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,YAAY,CAAkC;IAGtD,OAAO,CAAC,QAAQ,CAAC,CAAsB;IAGvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC,CAAM;IAG7E,OAAO,CAAC,iBAAiB,CAAqD;IAG9E,QAAQ,CAAC,OAAO,CAAC,EAAE,0BAA0B,CAAC;IAG9C,QAAQ,CAAC,SAAS,CAAC,EAAE,4BAA4B,CAAC;IAElD;;;;;;;;OAQG;gBACS,GAAG,EAAE,oBAAoB;IAyDrC;;;;;;;OAOG;IACG,IAAI,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAUpD;;;;;;;;;OASG;IACG,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA4B5D;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB,CAMvB;CACH"}
|
|
@@ -11,9 +11,12 @@ var base$1 = require('../wallet-connect/base.js');
|
|
|
11
11
|
class WebWalletManager {
|
|
12
12
|
/**
|
|
13
13
|
* Constructs a WebWalletManager instance based on the provided configuration.
|
|
14
|
-
* Sets up native wallets and WalletConnect support.
|
|
15
14
|
*
|
|
16
|
-
*
|
|
15
|
+
* - Enables native Ethereum and/or Solana wallet support if configured.
|
|
16
|
+
* - Enables WalletConnect support for Ethereum and/or Solana chains if namespaces are provided.
|
|
17
|
+
* - Sets up `CrossPlatformWalletStamper` and `CrossPlatformWalletConnector` if auth or connecting features are enabled.
|
|
18
|
+
*
|
|
19
|
+
* @param cfg - Wallet manager configuration.
|
|
17
20
|
*/
|
|
18
21
|
constructor(cfg) {
|
|
19
22
|
// queue of async initialization functions
|
|
@@ -23,18 +26,18 @@ class WebWalletManager {
|
|
|
23
26
|
// maps a blockchain chain to its corresponding wallet interface types
|
|
24
27
|
this.chainToInterfaces = {};
|
|
25
28
|
/**
|
|
26
|
-
* Registers a wallet interface as supporting a specific blockchain chain.
|
|
29
|
+
* Registers a wallet interface type as supporting a specific blockchain chain.
|
|
27
30
|
*
|
|
28
|
-
* @param chain -
|
|
29
|
-
* @param
|
|
31
|
+
* @param chain - Chain (e.g., Ethereum, Solana).
|
|
32
|
+
* @param interfaceType - Wallet interface type to associate with the chain.
|
|
30
33
|
*/
|
|
31
|
-
this.addChainInterface = (chain,
|
|
34
|
+
this.addChainInterface = (chain, interfaceType) => {
|
|
32
35
|
if (!this.chainToInterfaces[chain])
|
|
33
36
|
this.chainToInterfaces[chain] = [];
|
|
34
|
-
this.chainToInterfaces[chain].push(
|
|
37
|
+
this.chainToInterfaces[chain].push(interfaceType);
|
|
35
38
|
};
|
|
36
|
-
const enableNativeEvm = cfg.chains.ethereum ?? false;
|
|
37
|
-
const enableNativeSol = cfg.chains.solana ?? false;
|
|
39
|
+
const enableNativeEvm = cfg.chains.ethereum?.native ?? false;
|
|
40
|
+
const enableNativeSol = cfg.chains.solana?.native ?? false;
|
|
38
41
|
const ethereumNamespaces = cfg.chains.ethereum?.walletConnectNamespaces ?? [];
|
|
39
42
|
const solanaNamespaces = cfg.chains.solana?.walletConnectNamespaces ?? [];
|
|
40
43
|
const enableWalletConnectEvm = ethereumNamespaces.length > 0;
|
|
@@ -71,32 +74,37 @@ class WebWalletManager {
|
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
/**
|
|
74
|
-
* Initializes
|
|
77
|
+
* Initializes WalletConnect components and any registered wallet interfaces.
|
|
75
78
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
79
|
+
* - Initializes the low-level WalletConnect client with the provided config.
|
|
80
|
+
* - Runs any registered async wallet initializers (currently only `WalletConnectWallet`).
|
|
81
|
+
*
|
|
82
|
+
* @param cfg - Wallet manager configuration used for initializing the WalletConnect client.
|
|
78
83
|
*/
|
|
79
84
|
async init(cfg) {
|
|
80
85
|
if (this.wcClient) {
|
|
81
86
|
await this.wcClient.init(cfg.walletConnect);
|
|
82
87
|
}
|
|
83
|
-
//
|
|
88
|
+
// we initialize the high-level WalletConnectWallet
|
|
89
|
+
// we do this because we can't init this inside the constructor since it's async
|
|
84
90
|
await Promise.all(this.initializers.map((fn) => fn()));
|
|
85
|
-
await this.stamper?.init();
|
|
86
91
|
}
|
|
87
92
|
/**
|
|
88
|
-
* Retrieves available wallet providers
|
|
93
|
+
* Retrieves available wallet providers, optionally filtered by chain.
|
|
94
|
+
*
|
|
95
|
+
* - If a chain is specified, filters wallet interfaces that support that chain.
|
|
96
|
+
* - Aggregates providers across all wallet interfaces and filters WalletConnect results accordingly.
|
|
89
97
|
*
|
|
90
|
-
* @param chain - Optional chain to filter providers by.
|
|
91
|
-
* @returns A promise that resolves to an array of
|
|
92
|
-
* @throws If no wallet interface is registered for the given chain.
|
|
98
|
+
* @param chain - Optional chain to filter providers by (e.g., Ethereum, Solana).
|
|
99
|
+
* @returns A promise that resolves to an array of `WalletProvider` objects.
|
|
100
|
+
* @throws {Error} If no wallet interface is registered for the given chain.
|
|
93
101
|
*/
|
|
94
102
|
async getProviders(chain) {
|
|
95
103
|
if (chain) {
|
|
96
|
-
const
|
|
97
|
-
if (!
|
|
104
|
+
const interfaceTypes = this.chainToInterfaces[chain];
|
|
105
|
+
if (!interfaceTypes || interfaceTypes.length === 0)
|
|
98
106
|
throw new Error(`No wallet supports chain: ${chain}`);
|
|
99
|
-
const walletsToQuery =
|
|
107
|
+
const walletsToQuery = interfaceTypes
|
|
100
108
|
.map((iface) => this.wallets[iface])
|
|
101
109
|
.filter(Boolean);
|
|
102
110
|
const providersArrays = await Promise.all(walletsToQuery.map((wallet) => wallet.getProviders()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sources":["../../../src/__wallet__/web/manager.ts"],"sourcesContent":[null],"names":["WalletInterfaceType","EthereumWallet","Chain","SolanaWallet","WalletConnectClient","WalletConnectWallet","CrossPlatformWalletStamper","CrossPlatformWalletConnector"],"mappings":";;;;;;;;;;MAca,gBAAgB,CAAA;AAmB3B
|
|
1
|
+
{"version":3,"file":"manager.js","sources":["../../../src/__wallet__/web/manager.ts"],"sourcesContent":[null],"names":["WalletInterfaceType","EthereumWallet","Chain","SolanaWallet","WalletConnectClient","WalletConnectWallet","CrossPlatformWalletStamper","CrossPlatformWalletConnector"],"mappings":";;;;;;;;;;MAca,gBAAgB,CAAA;AAmB3B;;;;;;;;AAQG;AACH,IAAA,WAAA,CAAY,GAAyB,EAAA;;QA1B7B,IAAY,CAAA,YAAA,GAA+B,EAAE;;QAM5C,IAAO,CAAA,OAAA,GAA0D,EAAE;;QAGpE,IAAiB,CAAA,iBAAA,GAAkD,EAAE;AAkI7E;;;;;AAKG;AACK,QAAA,IAAA,CAAA,iBAAiB,GAAG,CAC1B,KAAY,EACZ,aAAkC,KAChC;AACF,YAAA,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;AAAE,gBAAA,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,EAAE;YACtE,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAE,CAAC,IAAI,CAAC,aAAa,CAAC;AACpD,SAAC;QA5HC,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK;QAC5D,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK;QAE1D,MAAM,kBAAkB,GACtB,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,uBAAuB,IAAI,EAAE;QACpD,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,IAAI,E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M,eAAe,GAAG,MAAM,OAAO,CAAC,GAAG,CACvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC,CACnE;AAED,QAAA,OAAO,eAAe,CAAC,IAAI,EAAE;;AAgBhC;;;;"}
|
|
@@ -9,9 +9,12 @@ import { WalletConnectWallet } from '../wallet-connect/base.mjs';
|
|
|
9
9
|
class WebWalletManager {
|
|
10
10
|
/**
|
|
11
11
|
* Constructs a WebWalletManager instance based on the provided configuration.
|
|
12
|
-
* Sets up native wallets and WalletConnect support.
|
|
13
12
|
*
|
|
14
|
-
*
|
|
13
|
+
* - Enables native Ethereum and/or Solana wallet support if configured.
|
|
14
|
+
* - Enables WalletConnect support for Ethereum and/or Solana chains if namespaces are provided.
|
|
15
|
+
* - Sets up `CrossPlatformWalletStamper` and `CrossPlatformWalletConnector` if auth or connecting features are enabled.
|
|
16
|
+
*
|
|
17
|
+
* @param cfg - Wallet manager configuration.
|
|
15
18
|
*/
|
|
16
19
|
constructor(cfg) {
|
|
17
20
|
// queue of async initialization functions
|
|
@@ -21,18 +24,18 @@ class WebWalletManager {
|
|
|
21
24
|
// maps a blockchain chain to its corresponding wallet interface types
|
|
22
25
|
this.chainToInterfaces = {};
|
|
23
26
|
/**
|
|
24
|
-
* Registers a wallet interface as supporting a specific blockchain chain.
|
|
27
|
+
* Registers a wallet interface type as supporting a specific blockchain chain.
|
|
25
28
|
*
|
|
26
|
-
* @param chain -
|
|
27
|
-
* @param
|
|
29
|
+
* @param chain - Chain (e.g., Ethereum, Solana).
|
|
30
|
+
* @param interfaceType - Wallet interface type to associate with the chain.
|
|
28
31
|
*/
|
|
29
|
-
this.addChainInterface = (chain,
|
|
32
|
+
this.addChainInterface = (chain, interfaceType) => {
|
|
30
33
|
if (!this.chainToInterfaces[chain])
|
|
31
34
|
this.chainToInterfaces[chain] = [];
|
|
32
|
-
this.chainToInterfaces[chain].push(
|
|
35
|
+
this.chainToInterfaces[chain].push(interfaceType);
|
|
33
36
|
};
|
|
34
|
-
const enableNativeEvm = cfg.chains.ethereum ?? false;
|
|
35
|
-
const enableNativeSol = cfg.chains.solana ?? false;
|
|
37
|
+
const enableNativeEvm = cfg.chains.ethereum?.native ?? false;
|
|
38
|
+
const enableNativeSol = cfg.chains.solana?.native ?? false;
|
|
36
39
|
const ethereumNamespaces = cfg.chains.ethereum?.walletConnectNamespaces ?? [];
|
|
37
40
|
const solanaNamespaces = cfg.chains.solana?.walletConnectNamespaces ?? [];
|
|
38
41
|
const enableWalletConnectEvm = ethereumNamespaces.length > 0;
|
|
@@ -69,32 +72,37 @@ class WebWalletManager {
|
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
/**
|
|
72
|
-
* Initializes
|
|
75
|
+
* Initializes WalletConnect components and any registered wallet interfaces.
|
|
73
76
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
77
|
+
* - Initializes the low-level WalletConnect client with the provided config.
|
|
78
|
+
* - Runs any registered async wallet initializers (currently only `WalletConnectWallet`).
|
|
79
|
+
*
|
|
80
|
+
* @param cfg - Wallet manager configuration used for initializing the WalletConnect client.
|
|
76
81
|
*/
|
|
77
82
|
async init(cfg) {
|
|
78
83
|
if (this.wcClient) {
|
|
79
84
|
await this.wcClient.init(cfg.walletConnect);
|
|
80
85
|
}
|
|
81
|
-
//
|
|
86
|
+
// we initialize the high-level WalletConnectWallet
|
|
87
|
+
// we do this because we can't init this inside the constructor since it's async
|
|
82
88
|
await Promise.all(this.initializers.map((fn) => fn()));
|
|
83
|
-
await this.stamper?.init();
|
|
84
89
|
}
|
|
85
90
|
/**
|
|
86
|
-
* Retrieves available wallet providers
|
|
91
|
+
* Retrieves available wallet providers, optionally filtered by chain.
|
|
92
|
+
*
|
|
93
|
+
* - If a chain is specified, filters wallet interfaces that support that chain.
|
|
94
|
+
* - Aggregates providers across all wallet interfaces and filters WalletConnect results accordingly.
|
|
87
95
|
*
|
|
88
|
-
* @param chain - Optional chain to filter providers by.
|
|
89
|
-
* @returns A promise that resolves to an array of
|
|
90
|
-
* @throws If no wallet interface is registered for the given chain.
|
|
96
|
+
* @param chain - Optional chain to filter providers by (e.g., Ethereum, Solana).
|
|
97
|
+
* @returns A promise that resolves to an array of `WalletProvider` objects.
|
|
98
|
+
* @throws {Error} If no wallet interface is registered for the given chain.
|
|
91
99
|
*/
|
|
92
100
|
async getProviders(chain) {
|
|
93
101
|
if (chain) {
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
102
|
+
const interfaceTypes = this.chainToInterfaces[chain];
|
|
103
|
+
if (!interfaceTypes || interfaceTypes.length === 0)
|
|
96
104
|
throw new Error(`No wallet supports chain: ${chain}`);
|
|
97
|
-
const walletsToQuery =
|
|
105
|
+
const walletsToQuery = interfaceTypes
|
|
98
106
|
.map((iface) => this.wallets[iface])
|
|
99
107
|
.filter(Boolean);
|
|
100
108
|
const providersArrays = await Promise.all(walletsToQuery.map((wallet) => wallet.getProviders()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.mjs","sources":["../../../src/__wallet__/web/manager.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;MAca,gBAAgB,CAAA;AAmB3B
|
|
1
|
+
{"version":3,"file":"manager.mjs","sources":["../../../src/__wallet__/web/manager.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;MAca,gBAAgB,CAAA;AAmB3B;;;;;;;;AAQG;AACH,IAAA,WAAA,CAAY,GAAyB,EAAA;;QA1B7B,IAAY,CAAA,YAAA,GAA+B,EAAE;;QAM5C,IAAO,CAAA,OAAA,GAA0D,EAAE;;QAGpE,IAAiB,CAAA,iBAAA,GAAkD,EAAE;AAkI7E;;;;;AAKG;AACK,QAAA,IAAA,CAAA,iBAAiB,GAAG,CAC1B,KAAY,EACZ,aAAkC,KAChC;AACF,YAAA,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC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AK,CAAC,6BAA6B,KAAK,CAAA,CAAE,CAAC;YAEvD,MAAM,cAAc,GAAG;AACpB,iBAAA,GAAG,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;iBAClC,MAAM,CAAC,OAAO,CAAsB;YAEvC,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,GAAG,CACvC,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC,CACtD;;AAGD,YAAA,OAAO;AACJ,iBAAA,IAAI;AACJ,iBAAA,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,KAAK,KAAK,CAAC;;;AAInD,QAAA,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,GAAG,CACvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC,CACnE;AAED,QAAA,OAAO,eAAe,CAAC,IAAI,EAAE;;AAgBhC;;;;"}
|
|
@@ -4,9 +4,9 @@ import { EthereumWalletInterface, SignIntent, SwitchableChain, WalletInterfaceTy
|
|
|
4
4
|
* Abstract base class for Ethereum wallet implementations.
|
|
5
5
|
*
|
|
6
6
|
* Provides shared logic for:
|
|
7
|
-
* - Provider discovery via EIP-6963
|
|
8
|
-
* - Connecting
|
|
9
|
-
* - Recovering compressed public keys
|
|
7
|
+
* - Provider discovery via EIP-6963 (request/announce events)
|
|
8
|
+
* - Connecting/disconnecting via EIP-1193
|
|
9
|
+
* - Recovering compressed secp256k1 public keys from EIP-191 signatures
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class BaseEthereumWallet implements EthereumWalletInterface {
|
|
12
12
|
readonly interfaceType = WalletInterfaceType.Ethereum;
|
|
@@ -18,9 +18,12 @@ export declare abstract class BaseEthereumWallet implements EthereumWalletInterf
|
|
|
18
18
|
* @param intent - The intent of the signature (e.g. message signing or transaction sending).
|
|
19
19
|
* @returns A promise resolving to a hex-encoded signature string.
|
|
20
20
|
*/
|
|
21
|
-
abstract sign(
|
|
21
|
+
abstract sign(payload: string | Hex, provider: WalletProvider, intent: SignIntent): Promise<Hex>;
|
|
22
22
|
/**
|
|
23
|
-
* Retrieves the compressed public key by signing a known message.
|
|
23
|
+
* Retrieves the compressed secp256k1 public key by signing a known message.
|
|
24
|
+
*
|
|
25
|
+
* - Signs the fixed string "GET_PUBLIC_KEY" (EIP-191) and recovers the key.
|
|
26
|
+
* - Returns the compressed public key as a hex string (no 0x prefix).
|
|
24
27
|
*
|
|
25
28
|
* @param provider - The wallet provider to use.
|
|
26
29
|
* @returns A promise that resolves to the compressed public key (hex-encoded).
|
|
@@ -29,23 +32,48 @@ export declare abstract class BaseEthereumWallet implements EthereumWalletInterf
|
|
|
29
32
|
/**
|
|
30
33
|
* Discovers EIP-1193 providers using the EIP-6963 standard.
|
|
31
34
|
*
|
|
35
|
+
* - Dispatches "eip6963:requestProvider" and listens for "eip6963:announceProvider".
|
|
36
|
+
* - For each discovered provider, attempts to read `eth_accounts` and `eth_chainId`
|
|
37
|
+
* (silently ignored if unavailable), defaulting to chainId "0x1".
|
|
38
|
+
* - Returns providers discovered during this discovery cycle; may be empty.
|
|
39
|
+
*
|
|
32
40
|
* @returns A promise that resolves to a list of available wallet providers.
|
|
33
41
|
*/
|
|
34
42
|
getProviders: () => Promise<WalletProvider[]>;
|
|
35
43
|
/**
|
|
36
|
-
*
|
|
44
|
+
* Requests or verifies account connection via `eth_requestAccounts`.
|
|
45
|
+
*
|
|
46
|
+
* - If the wallet is already connected, resolves immediately (no prompt).
|
|
47
|
+
* - If not connected, the wallet will typically prompt the user to authorize.
|
|
37
48
|
*
|
|
38
49
|
* @param provider - The wallet provider to use.
|
|
39
|
-
* @returns A promise that resolves once
|
|
50
|
+
* @returns A promise that resolves once at least one account is connected.
|
|
51
|
+
* @throws {Error} If the wallet returns no accounts after the request.
|
|
40
52
|
*/
|
|
41
53
|
connectWalletAccount: (provider: WalletProvider) => Promise<void>;
|
|
42
54
|
/**
|
|
43
|
-
*
|
|
55
|
+
* Attempts to disconnect the wallet by revoking `eth_accounts` permission.
|
|
56
|
+
*
|
|
57
|
+
* - Calls `wallet_revokePermissions` with `{ eth_accounts: {} }`.
|
|
58
|
+
* - Provider behavior is wallet-specific: some implement it, some ignore it,
|
|
59
|
+
* and others (e.g., Phantom) throw “method not supported”.
|
|
44
60
|
*
|
|
45
61
|
* @param provider - The wallet provider to disconnect.
|
|
46
|
-
* @returns A promise that resolves once the
|
|
62
|
+
* @returns A promise that resolves once the request completes (or rejects if the provider errors).
|
|
47
63
|
*/
|
|
48
64
|
disconnectWalletAccount: (provider: WalletProvider) => Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Switches to a new EVM chain, with add-then-switch fallback.
|
|
67
|
+
*
|
|
68
|
+
* - Tries `wallet_switchEthereumChain` first.
|
|
69
|
+
* - If the wallet returns error code 4902 (unknown chain):
|
|
70
|
+
* - If `chainOrId` is a string (hex chainId), throws and asks the caller to pass metadata.
|
|
71
|
+
* - If `chainOrId` is a `SwitchableChain`, calls `wallet_addEthereumChain` and then retries the switch.
|
|
72
|
+
*
|
|
73
|
+
* @param provider - The wallet provider to use.
|
|
74
|
+
* @param chainOrId - Hex chain ID string or full `SwitchableChain` metadata.
|
|
75
|
+
* @throws {Error} If provider is non-EVM, adding/switching fails, or metadata is missing.
|
|
76
|
+
*/
|
|
49
77
|
switchChain(provider: WalletProvider, chainOrId: string | SwitchableChain): Promise<void>;
|
|
50
78
|
}
|
|
51
79
|
/**
|
|
@@ -57,11 +85,17 @@ export declare class EthereumWallet extends BaseEthereumWallet {
|
|
|
57
85
|
/**
|
|
58
86
|
* Signs a message or sends a transaction depending on intent.
|
|
59
87
|
*
|
|
60
|
-
*
|
|
88
|
+
* - `SignMessage` → `personal_sign` (hex signature).
|
|
89
|
+
* - `SignAndSendTransaction` → `eth_sendTransaction` (tx hash).
|
|
90
|
+
* - For transactions, `message` must be a raw tx that `Transaction.from(...)` can parse.
|
|
91
|
+
* - May prompt the user (account access, signing, or send).
|
|
92
|
+
*
|
|
93
|
+
* @param payload - The payload or raw transaction to be signed/sent.
|
|
61
94
|
* @param provider - The wallet provider to use.
|
|
62
95
|
* @param intent - Signing intent (SignMessage or SignAndSendTransaction).
|
|
63
96
|
* @returns A promise that resolves to a hex string (signature or tx hash).
|
|
97
|
+
* @throws {Error} If the intent is unsupported or the wallet rejects the request.
|
|
64
98
|
*/
|
|
65
|
-
sign: (
|
|
99
|
+
sign: (payload: string, provider: WalletProvider, intent: SignIntent) => Promise<Hex>;
|
|
66
100
|
}
|
|
67
101
|
//# sourceMappingURL=ethereum.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../../../src/__wallet__/web/native/ethereum.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,GAAG,EAIJ,MAAM,MAAM,CAAC;AAGd,OAAO,EAEL,uBAAuB,EACvB,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,cAAc,EAGf,MAAM,QAAQ,CAAC;AAMhB;;;;;;;GAOG;AACH,8BAAsB,kBAAmB,YAAW,uBAAuB;IACzE,QAAQ,CAAC,aAAa,gCAAgC;IAEtD;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CACX,OAAO,EAAE,MAAM,GAAG,GAAG,EACrB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,GAAG,CAAC;IAEf
|
|
1
|
+
{"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../../../src/__wallet__/web/native/ethereum.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,GAAG,EAIJ,MAAM,MAAM,CAAC;AAGd,OAAO,EAEL,uBAAuB,EACvB,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,cAAc,EAGf,MAAM,QAAQ,CAAC;A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