@turnkey/core 1.0.0-beta.2 → 1.0.0-beta.5
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 +92 -9
- package/dist/__clients__/core.d.ts.map +1 -1
- package/dist/__clients__/core.js +699 -535
- package/dist/__clients__/core.js.map +1 -1
- package/dist/__clients__/core.mjs +702 -538
- 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 -253
- package/dist/__generated__/sdk-client-base.js.map +1 -1
- package/dist/__generated__/sdk-client-base.mjs +156 -253
- 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/__inputs__/public_api.types.d.ts +377 -504
- package/dist/__inputs__/public_api.types.d.ts.map +1 -1
- package/dist/__types__/base.d.ts +193 -75
- package/dist/__types__/base.d.ts.map +1 -1
- package/dist/__types__/base.js +14 -13
- package/dist/__types__/base.js.map +1 -1
- package/dist/__types__/base.mjs +15 -14
- package/dist/__types__/base.mjs.map +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 +81 -15
- package/dist/__wallet__/stamper.js.map +1 -1
- package/dist/__wallet__/stamper.mjs +82 -16
- package/dist/__wallet__/stamper.mjs.map +1 -1
- package/dist/__wallet__/wallet-connect/base.d.ts +102 -19
- package/dist/__wallet__/wallet-connect/base.d.ts.map +1 -1
- package/dist/__wallet__/wallet-connect/base.js +198 -77
- package/dist/__wallet__/wallet-connect/base.js.map +1 -1
- package/dist/__wallet__/wallet-connect/base.mjs +198 -77
- package/dist/__wallet__/wallet-connect/base.mjs.map +1 -1
- package/dist/__wallet__/wallet-connect/client.d.ts +50 -17
- package/dist/__wallet__/wallet-connect/client.d.ts.map +1 -1
- package/dist/__wallet__/wallet-connect/client.js +76 -19
- package/dist/__wallet__/wallet-connect/client.js.map +1 -1
- package/dist/__wallet__/wallet-connect/client.mjs +76 -19
- 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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/utils.d.ts +59 -13
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +105 -30
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +103 -29
- package/dist/utils.mjs.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sources":["../../src/__types__/base.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"base.js","sources":["../../src/__types__/base.ts"],"sourcesContent":[null],"names":["Curve","WalletSource","StamperType","OtpType","FilterType","SessionKey","Chain","SignIntent","WalletInterfaceType"],"mappings":";;AAcA;AACa,MAAA,qCAAqC,GAAG,MAAM;AAqC3D;AACM,MAAO,mBAAoB,SAAQ,KAAK,CAAA;AAI5C,IAAA,WAAA,CAAY,KAAiB,EAAA;QAC3B,IAAI,mBAAmB,GAAG,CAAA,cAAA,EAAiB,KAAK,CAAC,IAAI,CAAA,EAAA,EAAK,KAAK,CAAC,OAAO,CAAA,CAAE;AAEzE,QAAA,IAAI,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE;YACzB,mBAAmB,IAAI,CAAc,WAAA,EAAA,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA,CAAA,CAAG;;QAGvE,KAAK,CAAC,mBAAmB,CAAC;AAE1B,QAAA,IAAI,CAAC,IAAI,GAAG,qBAAqB;QACjC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,IAAI;AACpC,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;;AAEzB;AAyFD;AACYA;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
5
|
-
MethodType[MethodType["List"] = 1] = "List";
|
|
6
|
-
MethodType[MethodType["Command"] = 2] = "Command";
|
|
7
|
-
})(MethodType || (MethodType = {}));
|
|
3
|
+
/**@internal */
|
|
8
4
|
class TurnkeyRequestError extends Error {
|
|
9
5
|
constructor(input) {
|
|
10
6
|
let turnkeyErrorMessage = `Turnkey error ${input.code}: ${input.message}`;
|
|
@@ -17,36 +13,36 @@ class TurnkeyRequestError extends Error {
|
|
|
17
13
|
this.code = input.code;
|
|
18
14
|
}
|
|
19
15
|
}
|
|
16
|
+
/**@internal */
|
|
20
17
|
var Curve;
|
|
21
18
|
(function (Curve) {
|
|
22
19
|
Curve["SECP256K1"] = "CURVE_SECP256K1";
|
|
23
20
|
Curve["ED25519"] = "CURVE_ED25519";
|
|
24
21
|
})(Curve || (Curve = {}));
|
|
22
|
+
/**@internal */
|
|
25
23
|
var WalletSource;
|
|
26
24
|
(function (WalletSource) {
|
|
27
25
|
WalletSource["Embedded"] = "embedded";
|
|
28
26
|
WalletSource["Connected"] = "connected";
|
|
29
27
|
})(WalletSource || (WalletSource = {}));
|
|
30
28
|
/**
|
|
31
|
-
*
|
|
29
|
+
* StamperType defines the type of stamper to use when stamping a request.
|
|
32
30
|
*/
|
|
33
|
-
var AuthClient;
|
|
34
|
-
(function (AuthClient) {
|
|
35
|
-
AuthClient["Passkey"] = "passkey";
|
|
36
|
-
AuthClient["Wallet"] = "wallet";
|
|
37
|
-
AuthClient["IndexedDb"] = "indexed-db";
|
|
38
|
-
})(AuthClient || (AuthClient = {}));
|
|
39
31
|
var StamperType;
|
|
40
32
|
(function (StamperType) {
|
|
41
33
|
StamperType["ApiKey"] = "api-key";
|
|
42
34
|
StamperType["Passkey"] = "passkey";
|
|
43
35
|
StamperType["Wallet"] = "wallet";
|
|
44
36
|
})(StamperType || (StamperType = {}));
|
|
37
|
+
/**
|
|
38
|
+
* OtpType defines the type of OTP to use.
|
|
39
|
+
*/
|
|
45
40
|
var OtpType;
|
|
46
41
|
(function (OtpType) {
|
|
47
42
|
OtpType["Email"] = "OTP_TYPE_EMAIL";
|
|
48
43
|
OtpType["Sms"] = "OTP_TYPE_SMS";
|
|
49
44
|
})(OtpType || (OtpType = {}));
|
|
45
|
+
/**@internal */
|
|
50
46
|
var FilterType;
|
|
51
47
|
(function (FilterType) {
|
|
52
48
|
FilterType["Email"] = "EMAIL";
|
|
@@ -54,25 +50,30 @@ var FilterType;
|
|
|
54
50
|
FilterType["OidcToken"] = "OIDC_TOKEN";
|
|
55
51
|
FilterType["PublicKey"] = "PUBLIC_KEY";
|
|
56
52
|
})(FilterType || (FilterType = {}));
|
|
53
|
+
/**@internal */
|
|
57
54
|
const OtpTypeToFilterTypeMap = {
|
|
58
55
|
[OtpType.Email]: FilterType.Email,
|
|
59
56
|
[OtpType.Sms]: FilterType.Sms,
|
|
60
57
|
};
|
|
58
|
+
/**@internal */
|
|
61
59
|
var SessionKey;
|
|
62
60
|
(function (SessionKey) {
|
|
63
61
|
SessionKey["DefaultSessionkey"] = "@turnkey/session/v3";
|
|
64
62
|
})(SessionKey || (SessionKey = {}));
|
|
63
|
+
/**@internal */
|
|
65
64
|
var Chain;
|
|
66
65
|
(function (Chain) {
|
|
67
66
|
Chain["Ethereum"] = "ethereum";
|
|
68
67
|
Chain["Solana"] = "solana";
|
|
69
68
|
})(Chain || (Chain = {}));
|
|
69
|
+
/**@internal */
|
|
70
70
|
var SignIntent;
|
|
71
71
|
(function (SignIntent) {
|
|
72
72
|
SignIntent["SignMessage"] = "sign_message";
|
|
73
73
|
SignIntent["SignTransaction"] = "sign_transaction";
|
|
74
74
|
SignIntent["SignAndSendTransaction"] = "sign_and_send";
|
|
75
75
|
})(SignIntent || (SignIntent = {}));
|
|
76
|
+
/**@internal */
|
|
76
77
|
var WalletInterfaceType;
|
|
77
78
|
(function (WalletInterfaceType) {
|
|
78
79
|
WalletInterfaceType["Solana"] = "solana";
|
|
@@ -80,5 +81,5 @@ var WalletInterfaceType;
|
|
|
80
81
|
WalletInterfaceType["WalletConnect"] = "wallet_connect";
|
|
81
82
|
})(WalletInterfaceType || (WalletInterfaceType = {}));
|
|
82
83
|
|
|
83
|
-
export {
|
|
84
|
+
export { Chain, Curve, DEFAULT_SESSION_EXPIRATION_IN_SECONDS, FilterType, OtpType, OtpTypeToFilterTypeMap, SessionKey, SignIntent, StamperType, TurnkeyRequestError, WalletInterfaceType, WalletSource };
|
|
84
85
|
//# sourceMappingURL=base.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.mjs","sources":["../../src/__types__/base.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.mjs","sources":["../../src/__types__/base.ts"],"sourcesContent":[null],"names":[],"mappings":"AAcA;AACa,MAAA,qCAAqC,GAAG,MAAM;AAqC3D;AACM,MAAO,mBAAoB,SAAQ,KAAK,CAAA;AAI5C,IAAA,WAAA,CAAY,KAAiB,EAAA;QAC3B,IAAI,mBAAmB,GAAG,CAAA,cAAA,EAAiB,KAAK,CAAC,IAAI,CAAA,EAAA,EAAK,KAAK,CAAC,OAAO,CAAA,CAAE;AAEzE,QAAA,IAAI,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE;YACzB,mBAAmB,IAAI,CAAc,WAAA,EAAA,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA,CAAA,CAAG;;QAGvE,KAAK,CAAC,mBAAmB,CAAC;AAE1B,QAAA,IAAI,CAAC,IAAI,GAAG,qBAAqB;QACjC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,IAAI;AACpC,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;;AAEzB;AAyFD;IACY;AAAZ,CAAA,UAAY,KAAK,EAAA;AACf,IAAA,KAAA,CAAA,WAAA,CAAA,GAAA,iBAA6B;AAC7B,IAAA,KAAA,CAAA,SAAA,CAAA,GAAA,eAAyB;AAC3B,CAAC,EAHW,KA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A,CAAA,GAAA,qBAAyC;AAC3C,CAAC,EAFW,UAAU,KAAV,UAAU,GAErB,EAAA,CAAA,CAAA;AA0GD;IACY;AAAZ,CAAA,UAAY,KAAK,EAAA;AACf,IAAA,KAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACrB,IAAA,KAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EAHW,KAAK,KAAL,KAAK,GAGhB,EAAA,CAAA,CAAA;AAwDD;IACY;AAAZ,CAAA,UAAY,UAAU,EAAA;AACpB,IAAA,UAAA,CAAA,aAAA,CAAA,GAAA,cAA4B;AAC5B,IAAA,UAAA,CAAA,iBAAA,CAAA,GAAA,kBAAoC;AACpC,IAAA,UAAA,CAAA,wBAAA,CAAA,GAAA,eAAwC;AAC1C,CAAC,EAJW,UAAU,KAAV,UAAU,GAIrB,EAAA,CAAA,CAAA;AAED;IACY;AAAZ,CAAA,UAAY,mBAAmB,EAAA;AAC7B,IAAA,mBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,mBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACrB,IAAA,mBAAA,CAAA,eAAA,CAAA,GAAA,gBAAgC;AAClC,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,GAI9B,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type { TWalletManagerConfig, WalletManagerBase } from "@types";
|
|
2
|
+
/**
|
|
3
|
+
* Creates and initializes a wallet manager instance based on the runtime environment.
|
|
4
|
+
*
|
|
5
|
+
* - If the environment is React Native, it creates and initializes a `MobileWalletManager`.
|
|
6
|
+
* - If the environment is Web, it creates and initializes a `WebWalletManager`.
|
|
7
|
+
* - Throws an error if the environment is neither supported.
|
|
8
|
+
*
|
|
9
|
+
* @param cfg - Configuration object used to initialize the wallet manager.
|
|
10
|
+
* @returns A promise that resolves to an initialized `WalletManagerBase` instance.
|
|
11
|
+
* @throws {Error} If the environment is not supported (neither React Native nor Web).
|
|
12
|
+
*/
|
|
2
13
|
export declare function createWalletManager(cfg: TWalletManagerConfig): Promise<WalletManagerBase>;
|
|
3
14
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/__wallet__/base.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAGtE,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAY5B"}
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/__wallet__/base.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAGtE;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAY5B"}
|
package/dist/__wallet__/base.js
CHANGED
|
@@ -4,6 +4,17 @@ var manager$1 = require('./web/manager.js');
|
|
|
4
4
|
var utils = require('../utils.js');
|
|
5
5
|
var manager = require('./mobile/manager.js');
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Creates and initializes a wallet manager instance based on the runtime environment.
|
|
9
|
+
*
|
|
10
|
+
* - If the environment is React Native, it creates and initializes a `MobileWalletManager`.
|
|
11
|
+
* - If the environment is Web, it creates and initializes a `WebWalletManager`.
|
|
12
|
+
* - Throws an error if the environment is neither supported.
|
|
13
|
+
*
|
|
14
|
+
* @param cfg - Configuration object used to initialize the wallet manager.
|
|
15
|
+
* @returns A promise that resolves to an initialized `WalletManagerBase` instance.
|
|
16
|
+
* @throws {Error} If the environment is not supported (neither React Native nor Web).
|
|
17
|
+
*/
|
|
7
18
|
async function createWalletManager(cfg) {
|
|
8
19
|
if (utils.isReactNative()) {
|
|
9
20
|
const manager$1 = new manager.MobileWalletManager(cfg);
|
|
@@ -16,7 +27,7 @@ async function createWalletManager(cfg) {
|
|
|
16
27
|
return manager;
|
|
17
28
|
}
|
|
18
29
|
else {
|
|
19
|
-
throw new Error("Unsupported environment for wallet manager
|
|
30
|
+
throw new Error("Unsupported environment for wallet manager");
|
|
20
31
|
}
|
|
21
32
|
}
|
|
22
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sources":["../../src/__wallet__/base.ts"],"sourcesContent":[null],"names":["isReactNative","manager","MobileWalletManager","isWeb","WebWalletManager"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"base.js","sources":["../../src/__wallet__/base.ts"],"sourcesContent":[null],"names":["isReactNative","manager","MobileWalletManager","isWeb","WebWalletManager"],"mappings":";;;;;;AAKA;;;;;;;;;;AAUG;AACI,eAAe,mBAAmB,CACvC,GAAyB,EAAA;IAEzB,IAAIA,mBAAa,EAAE,EAAE;AACnB,QAAA,MAAMC,SAAO,GAAG,IAAIC,2BAAmB,CAAC,GAAG,CAAC;AAC5C,QAAA,MAAMD,SAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AACvB,QAAA,OAAOA,SAAO;;SACT,IAAIE,WAAK,EAAE,EAAE;AAClB,QAAA,MAAM,OAAO,GAAG,IAAIC,0BAAgB,CAAC,GAAG,CAAC;AACzC,QAAA,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AACvB,QAAA,OAAO,OAAO;;SACT;AACL,QAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC;;AAEjE;;;;"}
|
package/dist/__wallet__/base.mjs
CHANGED
|
@@ -2,6 +2,17 @@ import { WebWalletManager } from './web/manager.mjs';
|
|
|
2
2
|
import { isReactNative, isWeb } from '../utils.mjs';
|
|
3
3
|
import { MobileWalletManager } from './mobile/manager.mjs';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Creates and initializes a wallet manager instance based on the runtime environment.
|
|
7
|
+
*
|
|
8
|
+
* - If the environment is React Native, it creates and initializes a `MobileWalletManager`.
|
|
9
|
+
* - If the environment is Web, it creates and initializes a `WebWalletManager`.
|
|
10
|
+
* - Throws an error if the environment is neither supported.
|
|
11
|
+
*
|
|
12
|
+
* @param cfg - Configuration object used to initialize the wallet manager.
|
|
13
|
+
* @returns A promise that resolves to an initialized `WalletManagerBase` instance.
|
|
14
|
+
* @throws {Error} If the environment is not supported (neither React Native nor Web).
|
|
15
|
+
*/
|
|
5
16
|
async function createWalletManager(cfg) {
|
|
6
17
|
if (isReactNative()) {
|
|
7
18
|
const manager = new MobileWalletManager(cfg);
|
|
@@ -14,7 +25,7 @@ async function createWalletManager(cfg) {
|
|
|
14
25
|
return manager;
|
|
15
26
|
}
|
|
16
27
|
else {
|
|
17
|
-
throw new Error("Unsupported environment for wallet manager
|
|
28
|
+
throw new Error("Unsupported environment for wallet manager");
|
|
18
29
|
}
|
|
19
30
|
}
|
|
20
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.mjs","sources":["../../src/__wallet__/base.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"base.mjs","sources":["../../src/__wallet__/base.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;;;;;;;;;;AAUG;AACI,eAAe,mBAAmB,CACvC,GAAyB,EAAA;IAEzB,IAAI,aAAa,EAAE,EAAE;AACnB,QAAA,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC,GAAG,CAAC;AAC5C,QAAA,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AACvB,QAAA,OAAO,OAAO;;SACT,IAAI,KAAK,EAAE,EAAE;AAClB,QAAA,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC;AACzC,QAAA,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AACvB,QAAA,OAAO,OAAO;;SACT;AACL,QAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC;;AAEjE;;;;"}
|
|
@@ -4,6 +4,15 @@ export interface CrossPlatformWalletConnectorInterface {
|
|
|
4
4
|
}
|
|
5
5
|
export declare class CrossPlatformWalletConnector implements CrossPlatformWalletConnectorInterface {
|
|
6
6
|
private readonly wallets;
|
|
7
|
+
/**
|
|
8
|
+
* Constructs a CrossPlatformWalletConnector.
|
|
9
|
+
*
|
|
10
|
+
* - Validates that at least one wallet interface is provided.
|
|
11
|
+
* - Stores the provided mapping of wallet interfaces.
|
|
12
|
+
*
|
|
13
|
+
* @param wallets - A partial mapping of wallet interfaces by type.
|
|
14
|
+
* @throws {Error} If no wallet interfaces are provided.
|
|
15
|
+
*/
|
|
7
16
|
constructor(wallets: Partial<Record<WalletInterfaceType, WalletInterface>>);
|
|
8
17
|
/**
|
|
9
18
|
* Connects the wallet account for the given provider.
|
|
@@ -19,15 +28,33 @@ export declare class CrossPlatformWalletConnector implements CrossPlatformWallet
|
|
|
19
28
|
* @returns A promise that resolves once the wallet account is disconnected.
|
|
20
29
|
*/
|
|
21
30
|
disconnectWalletAccount(provider: WalletProvider): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Switches the chain for an EVM-compatible wallet provider (native or WalletConnect).
|
|
33
|
+
*
|
|
34
|
+
* - Only supported for wallet providers on the Ethereum namespace.
|
|
35
|
+
* - Native (extension) wallets:
|
|
36
|
+
* - If `chainOrId` is a hex string and the wallet doesn't support it, the switch will fail.
|
|
37
|
+
* - If `chainOrId` is a `SwitchableChain` object, the wallet will attempt to switch; if the chain
|
|
38
|
+
* is unsupported, it will first add the chain (via `wallet_addEthereumChain`) and then retry switching.
|
|
39
|
+
* - WalletConnect wallets:
|
|
40
|
+
* - Chain support is negotiated up front via namespaces. If the target chain isn't in the session's
|
|
41
|
+
* `ethereumNamespaces`, the switch will fail. To support a new chain, you must specify it in the walletConfig.
|
|
42
|
+
*
|
|
43
|
+
* @param provider - The EVM-compatible wallet provider to switch chains for.
|
|
44
|
+
* @param chainOrId - The target chain ID (hex string) or full chain config (`SwitchableChain`).
|
|
45
|
+
* @returns A promise that resolves once the chain switch is complete.
|
|
46
|
+
* @throws {Error} If the provider is not Ethereum-based or doesn't support switching.
|
|
47
|
+
*/
|
|
22
48
|
switchChain(provider: WalletProvider, chainOrId: string | SwitchableChain): Promise<void>;
|
|
23
49
|
/**
|
|
24
|
-
* Signs a
|
|
50
|
+
* Signs a payload using the appropriate wallet based on the provider.
|
|
25
51
|
*
|
|
26
|
-
* @param
|
|
52
|
+
* @param payload - The payload to be signed.
|
|
27
53
|
* @param walletProvider - The wallet provider used for signing.
|
|
28
54
|
* @param intent - The signing intent (e.g., message, transaction).
|
|
29
|
-
* @returns A promise that resolves to
|
|
55
|
+
* @returns A promise that resolves to a hex string (signature or tx hash).
|
|
56
|
+
* @throws {Error} If the wallet is not initialized.
|
|
30
57
|
*/
|
|
31
|
-
sign(
|
|
58
|
+
sign(payload: string, walletProvider: WalletProvider, intent: SignIntent): Promise<string>;
|
|
32
59
|
}
|
|
33
60
|
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/__wallet__/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EAEhB,MAAM,QAAQ,CAAC;AAEhB,MAAM,WAAW,qCAAqC;IACpD,IAAI,CACF,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;AAED,qBAAa,4BACX,YAAW,qCAAqC;
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/__wallet__/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EAEhB,MAAM,QAAQ,CAAC;AAEhB,MAAM,WAAW,qCAAqC;IACpD,IAAI,CACF,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;AAED,qBAAa,4BACX,YAAW,qCAAqC;IAY9C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAV1B;;;;;;;;OAQG;gBAEgB,OAAO,EAAE,OAAO,CAC/B,MAAM,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAC7C;IASH;;;;;OAKG;IACG,oBAAoB,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAUnE;;;;;OAKG;IACG,uBAAuB,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAUtE;;;;;;;;;;;;;;;;OAgBG;IACG,WAAW,CACf,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,MAAM,GAAG,eAAe,GAClC,OAAO,CAAC,IAAI,CAAC;IAehB;;;;;;;;OAQG;IACG,IAAI,CACR,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,MAAM,CAAC;CAWnB"}
|
|
@@ -3,8 +3,20 @@
|
|
|
3
3
|
var base = require('../__types__/base.js');
|
|
4
4
|
|
|
5
5
|
class CrossPlatformWalletConnector {
|
|
6
|
+
/**
|
|
7
|
+
* Constructs a CrossPlatformWalletConnector.
|
|
8
|
+
*
|
|
9
|
+
* - Validates that at least one wallet interface is provided.
|
|
10
|
+
* - Stores the provided mapping of wallet interfaces.
|
|
11
|
+
*
|
|
12
|
+
* @param wallets - A partial mapping of wallet interfaces by type.
|
|
13
|
+
* @throws {Error} If no wallet interfaces are provided.
|
|
14
|
+
*/
|
|
6
15
|
constructor(wallets) {
|
|
7
16
|
this.wallets = wallets;
|
|
17
|
+
if (!Object.keys(wallets).length) {
|
|
18
|
+
throw new Error("Cannot create WalletConnector: no wallet interfaces provided");
|
|
19
|
+
}
|
|
8
20
|
}
|
|
9
21
|
/**
|
|
10
22
|
* Connects the wallet account for the given provider.
|
|
@@ -32,6 +44,23 @@ class CrossPlatformWalletConnector {
|
|
|
32
44
|
}
|
|
33
45
|
await wallet.disconnectWalletAccount(provider);
|
|
34
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Switches the chain for an EVM-compatible wallet provider (native or WalletConnect).
|
|
49
|
+
*
|
|
50
|
+
* - Only supported for wallet providers on the Ethereum namespace.
|
|
51
|
+
* - Native (extension) wallets:
|
|
52
|
+
* - If `chainOrId` is a hex string and the wallet doesn't support it, the switch will fail.
|
|
53
|
+
* - If `chainOrId` is a `SwitchableChain` object, the wallet will attempt to switch; if the chain
|
|
54
|
+
* is unsupported, it will first add the chain (via `wallet_addEthereumChain`) and then retry switching.
|
|
55
|
+
* - WalletConnect wallets:
|
|
56
|
+
* - Chain support is negotiated up front via namespaces. If the target chain isn't in the session's
|
|
57
|
+
* `ethereumNamespaces`, the switch will fail. To support a new chain, you must specify it in the walletConfig.
|
|
58
|
+
*
|
|
59
|
+
* @param provider - The EVM-compatible wallet provider to switch chains for.
|
|
60
|
+
* @param chainOrId - The target chain ID (hex string) or full chain config (`SwitchableChain`).
|
|
61
|
+
* @returns A promise that resolves once the chain switch is complete.
|
|
62
|
+
* @throws {Error} If the provider is not Ethereum-based or doesn't support switching.
|
|
63
|
+
*/
|
|
35
64
|
async switchChain(provider, chainOrId) {
|
|
36
65
|
if (provider.chainInfo.namespace !== base.Chain.Ethereum) {
|
|
37
66
|
throw new Error("Only Ethereum wallets support chain switching");
|
|
@@ -43,19 +72,20 @@ class CrossPlatformWalletConnector {
|
|
|
43
72
|
return wallet.switchChain(provider, chainOrId);
|
|
44
73
|
}
|
|
45
74
|
/**
|
|
46
|
-
* Signs a
|
|
75
|
+
* Signs a payload using the appropriate wallet based on the provider.
|
|
47
76
|
*
|
|
48
|
-
* @param
|
|
77
|
+
* @param payload - The payload to be signed.
|
|
49
78
|
* @param walletProvider - The wallet provider used for signing.
|
|
50
79
|
* @param intent - The signing intent (e.g., message, transaction).
|
|
51
|
-
* @returns A promise that resolves to
|
|
80
|
+
* @returns A promise that resolves to a hex string (signature or tx hash).
|
|
81
|
+
* @throws {Error} If the wallet is not initialized.
|
|
52
82
|
*/
|
|
53
|
-
async sign(
|
|
83
|
+
async sign(payload, walletProvider, intent) {
|
|
54
84
|
const wallet = this.wallets[walletProvider.interfaceType];
|
|
55
85
|
if (!wallet) {
|
|
56
86
|
throw new Error(`Wallet for ${walletProvider.interfaceType} not initialized`);
|
|
57
87
|
}
|
|
58
|
-
return wallet.sign(
|
|
88
|
+
return wallet.sign(payload, walletProvider, intent);
|
|
59
89
|
}
|
|
60
90
|
}
|
|
61
91
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","sources":["../../src/__wallet__/connector.ts"],"sourcesContent":[null],"names":["Chain"],"mappings":";;;;MAiBa,4BAA4B,CAAA;AAGvC,IAAA,WAAA,CACmB,OAEhB,EAAA;QAFgB,IAAO,CAAA,OAAA,GAAP,OAAO
|
|
1
|
+
{"version":3,"file":"connector.js","sources":["../../src/__wallet__/connector.ts"],"sourcesContent":[null],"names":["Chain"],"mappings":";;;;MAiBa,4BAA4B,CAAA;AAGvC;;;;;;;;AAQG;AACH,IAAA,WAAA,CACmB,OAEhB,EAAA;QAFgB,IAAO,CAAA,OAAA,GAAP,OAAO;QAIxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE;AAChC,YAAA,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D;;;AAIL;;;;;AAKG;IACH,MAAM,oBAAoB,CAAC,QAAwB,EAAA;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;QAEnD,IAAI,CAAC,MA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kB,gBAAA,CAAA,CAC7D;;QAGH,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC;;AAEtD;;;;"}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { Chain } from '../__types__/base.mjs';
|
|
2
2
|
|
|
3
3
|
class CrossPlatformWalletConnector {
|
|
4
|
+
/**
|
|
5
|
+
* Constructs a CrossPlatformWalletConnector.
|
|
6
|
+
*
|
|
7
|
+
* - Validates that at least one wallet interface is provided.
|
|
8
|
+
* - Stores the provided mapping of wallet interfaces.
|
|
9
|
+
*
|
|
10
|
+
* @param wallets - A partial mapping of wallet interfaces by type.
|
|
11
|
+
* @throws {Error} If no wallet interfaces are provided.
|
|
12
|
+
*/
|
|
4
13
|
constructor(wallets) {
|
|
5
14
|
this.wallets = wallets;
|
|
15
|
+
if (!Object.keys(wallets).length) {
|
|
16
|
+
throw new Error("Cannot create WalletConnector: no wallet interfaces provided");
|
|
17
|
+
}
|
|
6
18
|
}
|
|
7
19
|
/**
|
|
8
20
|
* Connects the wallet account for the given provider.
|
|
@@ -30,6 +42,23 @@ class CrossPlatformWalletConnector {
|
|
|
30
42
|
}
|
|
31
43
|
await wallet.disconnectWalletAccount(provider);
|
|
32
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Switches the chain for an EVM-compatible wallet provider (native or WalletConnect).
|
|
47
|
+
*
|
|
48
|
+
* - Only supported for wallet providers on the Ethereum namespace.
|
|
49
|
+
* - Native (extension) wallets:
|
|
50
|
+
* - If `chainOrId` is a hex string and the wallet doesn't support it, the switch will fail.
|
|
51
|
+
* - If `chainOrId` is a `SwitchableChain` object, the wallet will attempt to switch; if the chain
|
|
52
|
+
* is unsupported, it will first add the chain (via `wallet_addEthereumChain`) and then retry switching.
|
|
53
|
+
* - WalletConnect wallets:
|
|
54
|
+
* - Chain support is negotiated up front via namespaces. If the target chain isn't in the session's
|
|
55
|
+
* `ethereumNamespaces`, the switch will fail. To support a new chain, you must specify it in the walletConfig.
|
|
56
|
+
*
|
|
57
|
+
* @param provider - The EVM-compatible wallet provider to switch chains for.
|
|
58
|
+
* @param chainOrId - The target chain ID (hex string) or full chain config (`SwitchableChain`).
|
|
59
|
+
* @returns A promise that resolves once the chain switch is complete.
|
|
60
|
+
* @throws {Error} If the provider is not Ethereum-based or doesn't support switching.
|
|
61
|
+
*/
|
|
33
62
|
async switchChain(provider, chainOrId) {
|
|
34
63
|
if (provider.chainInfo.namespace !== Chain.Ethereum) {
|
|
35
64
|
throw new Error("Only Ethereum wallets support chain switching");
|
|
@@ -41,19 +70,20 @@ class CrossPlatformWalletConnector {
|
|
|
41
70
|
return wallet.switchChain(provider, chainOrId);
|
|
42
71
|
}
|
|
43
72
|
/**
|
|
44
|
-
* Signs a
|
|
73
|
+
* Signs a payload using the appropriate wallet based on the provider.
|
|
45
74
|
*
|
|
46
|
-
* @param
|
|
75
|
+
* @param payload - The payload to be signed.
|
|
47
76
|
* @param walletProvider - The wallet provider used for signing.
|
|
48
77
|
* @param intent - The signing intent (e.g., message, transaction).
|
|
49
|
-
* @returns A promise that resolves to
|
|
78
|
+
* @returns A promise that resolves to a hex string (signature or tx hash).
|
|
79
|
+
* @throws {Error} If the wallet is not initialized.
|
|
50
80
|
*/
|
|
51
|
-
async sign(
|
|
81
|
+
async sign(payload, walletProvider, intent) {
|
|
52
82
|
const wallet = this.wallets[walletProvider.interfaceType];
|
|
53
83
|
if (!wallet) {
|
|
54
84
|
throw new Error(`Wallet for ${walletProvider.interfaceType} not initialized`);
|
|
55
85
|
}
|
|
56
|
-
return wallet.sign(
|
|
86
|
+
return wallet.sign(payload, walletProvider, intent);
|
|
57
87
|
}
|
|
58
88
|
}
|
|
59
89
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.mjs","sources":["../../src/__wallet__/connector.ts"],"sourcesContent":[null],"names":[],"mappings":";;MAiBa,4BAA4B,CAAA;AAGvC,IAAA,WAAA,CACmB,OAEhB,EAAA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AG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;AACnD,QAAA,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE;YACxB,MAAM,IAAI,KAAK,CACb,CAAA,OAAA,EAAU,QAAQ,CAAC,aAAa,CAAmC,iCAAA,CAAA,CACpE;;QAGH,OAAO,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC;;AAGhD;;;;;;;;AAQG;AACH,IAAA,MAAM,IAAI,CACR,OAAe,EACf,cAA8B,EAC9B,MAAkB,EAAA;QAElB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC;QAEzD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CACb,CAAA,WAAA,EAAc,cAAc,CAAC,aAAa,CAAkB,gBAAA,CAAA,CAC7D;;QAGH,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC;;AAEtD;;;;"}
|
|
@@ -11,24 +11,40 @@ export declare class MobileWalletManager {
|
|
|
11
11
|
/**
|
|
12
12
|
* Constructs a MobileWalletManager that only uses WalletConnect.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* - Determines enabled chains based on provided namespaces for Ethereum and Solana.
|
|
15
|
+
* - Initializes WalletConnect wallet interface and maps it to supported chains.
|
|
16
|
+
* - Optionally enables stamping and connecting flows based on feature flags that live in the cfg.
|
|
17
|
+
* - Sets up `CrossPlatformWalletStamper` and `CrossPlatformWalletConnector` if auth or connecting features are enabled.
|
|
18
|
+
*
|
|
19
|
+
* @param cfg - Wallet manager configuration (we only use WalletConnect fields).
|
|
15
20
|
*/
|
|
16
21
|
constructor(cfg: TWalletManagerConfig);
|
|
17
22
|
/**
|
|
18
|
-
* Initializes
|
|
23
|
+
* Initializes WalletConnect components and any registered wallet interfaces.
|
|
24
|
+
*
|
|
25
|
+
* - First initializes the low-level WalletConnect client with the provided config.
|
|
26
|
+
* - Then initializes higher-level wallet interface `WalletConnectWallet` using registered async initializers.
|
|
19
27
|
*
|
|
20
|
-
* @param cfg - Wallet manager configuration.
|
|
28
|
+
* @param cfg - Wallet manager configuration used for initializing the WalletConnect client.
|
|
21
29
|
*/
|
|
22
30
|
init(cfg: TWalletManagerConfig): Promise<void>;
|
|
23
31
|
/**
|
|
24
32
|
* Retrieves available wallet providers, optionally filtered by chain.
|
|
25
33
|
*
|
|
34
|
+
* - If a chain is specified, filters wallet interfaces that support that chain.
|
|
35
|
+
* - Aggregates providers across all registered wallet interfaces.
|
|
36
|
+
* - Filters WalletConnect results to match the specified chain.
|
|
37
|
+
*
|
|
26
38
|
* @param chain - Optional chain to filter providers by.
|
|
27
|
-
* @
|
|
39
|
+
* @returns A promise that resolves to an array of `WalletProvider` objects.
|
|
40
|
+
* @throws {Error} If no wallet interface is registered for the given chain.
|
|
28
41
|
*/
|
|
29
42
|
getProviders(chain?: Chain): Promise<WalletProvider[]>;
|
|
30
43
|
/**
|
|
31
|
-
* Registers a wallet interface as supporting a specific blockchain chain.
|
|
44
|
+
* Registers a wallet interface type as supporting a specific blockchain chain.
|
|
45
|
+
*
|
|
46
|
+
* @param chain - Chain (e.g., Ethereum, Solana).
|
|
47
|
+
* @param interfaceType - Wallet interface type to associate with the chain.
|
|
32
48
|
*/
|
|
33
49
|
private addChainInterface;
|
|
34
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/__wallet__/mobile/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,KAAK,EACN,MAAM,QAAQ,CAAC;AAIhB,qBAAa,mBAAmB;IAE9B,OAAO,CAAC,YAAY,CAAkC;IAGtD,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|
10
10
|
/**
|
|
11
11
|
* Constructs a MobileWalletManager that only uses WalletConnect.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* - Determines enabled chains based on provided namespaces for Ethereum and Solana.
|
|
14
|
+
* - Initializes WalletConnect wallet interface and maps it to supported chains.
|
|
15
|
+
* - Optionally enables stamping and connecting flows based on feature flags that live in the cfg.
|
|
16
|
+
* - Sets up `CrossPlatformWalletStamper` and `CrossPlatformWalletConnector` if auth or connecting features are enabled.
|
|
17
|
+
*
|
|
18
|
+
* @param cfg - Wallet manager configuration (we only use WalletConnect fields).
|
|
14
19
|
*/
|
|
15
20
|
constructor(cfg) {
|
|
16
21
|
// queue of async initialization functions
|
|
@@ -20,12 +25,15 @@ class MobileWalletManager {
|
|
|
20
25
|
// maps a blockchain chain to its corresponding wallet interface types
|
|
21
26
|
this.chainToInterfaces = {};
|
|
22
27
|
/**
|
|
23
|
-
* Registers a wallet interface as supporting a specific blockchain chain.
|
|
28
|
+
* Registers a wallet interface type as supporting a specific blockchain chain.
|
|
29
|
+
*
|
|
30
|
+
* @param chain - Chain (e.g., Ethereum, Solana).
|
|
31
|
+
* @param interfaceType - Wallet interface type to associate with the chain.
|
|
24
32
|
*/
|
|
25
|
-
this.addChainInterface = (chain,
|
|
33
|
+
this.addChainInterface = (chain, interfaceType) => {
|
|
26
34
|
if (!this.chainToInterfaces[chain])
|
|
27
35
|
this.chainToInterfaces[chain] = [];
|
|
28
|
-
this.chainToInterfaces[chain].push(
|
|
36
|
+
this.chainToInterfaces[chain].push(interfaceType);
|
|
29
37
|
};
|
|
30
38
|
const ethereumNamespaces = cfg.chains.ethereum?.walletConnectNamespaces ?? [];
|
|
31
39
|
const solanaNamespaces = cfg.chains.solana?.walletConnectNamespaces ?? [];
|
|
@@ -54,30 +62,39 @@ class MobileWalletManager {
|
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
64
|
/**
|
|
57
|
-
* Initializes
|
|
65
|
+
* Initializes WalletConnect components and any registered wallet interfaces.
|
|
66
|
+
*
|
|
67
|
+
* - First initializes the low-level WalletConnect client with the provided config.
|
|
68
|
+
* - Then initializes higher-level wallet interface `WalletConnectWallet` using registered async initializers.
|
|
58
69
|
*
|
|
59
|
-
* @param cfg - Wallet manager configuration.
|
|
70
|
+
* @param cfg - Wallet manager configuration used for initializing the WalletConnect client.
|
|
60
71
|
*/
|
|
61
72
|
async init(cfg) {
|
|
62
73
|
if (this.wcClient) {
|
|
63
74
|
await this.wcClient.init(cfg.walletConnect);
|
|
64
75
|
}
|
|
76
|
+
// we initialize the high-level WalletConnectWallet
|
|
77
|
+
// we do this because we can't init this inside the constructor since it's async
|
|
65
78
|
await Promise.all(this.initializers.map((fn) => fn()));
|
|
66
|
-
await this.stamper?.init();
|
|
67
79
|
}
|
|
68
80
|
/**
|
|
69
81
|
* Retrieves available wallet providers, optionally filtered by chain.
|
|
70
82
|
*
|
|
83
|
+
* - If a chain is specified, filters wallet interfaces that support that chain.
|
|
84
|
+
* - Aggregates providers across all registered wallet interfaces.
|
|
85
|
+
* - Filters WalletConnect results to match the specified chain.
|
|
86
|
+
*
|
|
71
87
|
* @param chain - Optional chain to filter providers by.
|
|
72
|
-
* @
|
|
88
|
+
* @returns A promise that resolves to an array of `WalletProvider` objects.
|
|
89
|
+
* @throws {Error} If no wallet interface is registered for the given chain.
|
|
73
90
|
*/
|
|
74
91
|
async getProviders(chain) {
|
|
75
92
|
if (chain) {
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
93
|
+
const interfaceType = this.chainToInterfaces[chain];
|
|
94
|
+
if (!interfaceType || interfaceType.length === 0) {
|
|
78
95
|
throw new Error(`No wallet supports chain: ${chain}`);
|
|
79
96
|
}
|
|
80
|
-
const walletsToQuery =
|
|
97
|
+
const walletsToQuery = interfaceType
|
|
81
98
|
.map((iface) => this.wallets[iface])
|
|
82
99
|
.filter(Boolean);
|
|
83
100
|
const providersArrays = await Promise.all(walletsToQuery.map((wallet) => wallet.getProviders()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sources":["../../../src/__wallet__/mobile/manager.ts"],"sourcesContent":[null],"names":["WalletConnectClient","WalletConnectWallet","WalletInterfaceType","Chain","CrossPlatformWalletStamper","CrossPlatformWalletConnector"],"mappings":";;;;;;;;MAYa,mBAAmB,CAAA;AAmB9B
|
|
1
|
+
{"version":3,"file":"manager.js","sources":["../../../src/__wallet__/mobile/manager.ts"],"sourcesContent":[null],"names":["WalletConnectClient","WalletConnectWallet","WalletInterfaceType","Chain","CrossPlatformWalletStamper","CrossPlatformWalletConnector"],"mappings":";;;;;;;;MAYa,mBAAmB,CAAA;AAmB9B;;;;;;;;;AASG;AACH,IAAA,WAAA,CAAY,GAAyB,EAAA;;QA3B7B,IAAY,CAAA,YAAA,GAA+B,EAAE;;QAM5C,IAAO,CAAA,OAAA,GAA0D,EAAE;;QAGpE,IAAiB,CAAA,iBAAA,GAAkD,EAAE;AAsH7E;;;;;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;QA/GC,MAAM,kBAAkB,GACtB,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,uBAAuB,IAAI,EAAE;QACpD,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,IAAI,EAAE;AAEzE,QAAA,MAAM,sBAAsB,GAAG,kBAAkB,CAAC,MAAM,GAAG,CAAC;AAC5D,QAAA,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC;AAE1D,QAAA,MAAM,mBAAmB,GACvB,sBAAsB,IAAI,sB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