@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
|
@@ -6,43 +6,26 @@ var encoding = require('@turnkey/encoding');
|
|
|
6
6
|
var base = require('../../../__types__/base.js');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Abstract base class for Solana wallet implementations using Wallet Standard.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
const asSolana = (p) => {
|
|
16
|
-
if (p.provider &&
|
|
17
|
-
"features" in p.provider &&
|
|
18
|
-
"solana:signMessage" in p.provider.features) {
|
|
19
|
-
return p.provider;
|
|
20
|
-
}
|
|
21
|
-
throw new Error("Expected a Wallet-Standard provider (Solana wallet)");
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Connects the given Solana wallet account.
|
|
25
|
-
*
|
|
26
|
-
* @param w - The wallet to connect.
|
|
27
|
-
* @returns A promise that resolves once the wallet is connected.
|
|
28
|
-
* @throws If the wallet does not support standard:connect.
|
|
29
|
-
*/
|
|
30
|
-
const connectAccount = async (w) => {
|
|
31
|
-
if (w.accounts.length)
|
|
32
|
-
return;
|
|
33
|
-
const stdConnect = w.features["standard:connect"];
|
|
34
|
-
if (stdConnect) {
|
|
35
|
-
await stdConnect.connect();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
throw new Error("Wallet is not connected and does not implement standard:connect");
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Abstract class representing a base Solana wallet.
|
|
11
|
+
* Provides shared logic for:
|
|
12
|
+
* - Provider discovery via `@wallet-standard/app` (`getWallets()`).
|
|
13
|
+
* - Connecting via `standard:connect` and disconnecting via `standard:disconnect`.
|
|
14
|
+
* - Public key retrieval from the wallet's account address (base58 → hex).
|
|
42
15
|
*/
|
|
43
16
|
class BaseSolanaWallet {
|
|
44
17
|
constructor() {
|
|
45
18
|
this.interfaceType = base.WalletInterfaceType.Solana;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves the ed25519 public key for the active account as hex (no 0x prefix).
|
|
21
|
+
*
|
|
22
|
+
* - Ensures the wallet is connected (calls `standard:connect` if needed).
|
|
23
|
+
* - Decodes the Wallet Standard account address (base58) to raw bytes.
|
|
24
|
+
*
|
|
25
|
+
* @param provider - The wallet provider to use.
|
|
26
|
+
* @returns Hex-encoded ed25519 public key (no 0x prefix).
|
|
27
|
+
* @throws {Error} If no account is available.
|
|
28
|
+
*/
|
|
46
29
|
this.getPublicKey = async (provider) => {
|
|
47
30
|
const wallet = asSolana(provider);
|
|
48
31
|
await connectAccount(wallet);
|
|
@@ -53,6 +36,15 @@ class BaseSolanaWallet {
|
|
|
53
36
|
const rawBytes = bs58.decode(account.address);
|
|
54
37
|
return encoding.uint8ArrayToHexString(rawBytes);
|
|
55
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Discovers Solana-capable Wallet Standard providers.
|
|
41
|
+
*
|
|
42
|
+
* - Uses `getWallets().get()` and filters wallets with at least one `chains` entry
|
|
43
|
+
* starting with `"solana:"`.
|
|
44
|
+
* - For each wallet, collects branding info and any currently connected addresses.
|
|
45
|
+
*
|
|
46
|
+
* @returns A list of discovered Solana `WalletProvider`s (may be empty).
|
|
47
|
+
*/
|
|
56
48
|
this.getProviders = async () => {
|
|
57
49
|
const discovered = [];
|
|
58
50
|
const walletsApi = app.getWallets();
|
|
@@ -80,10 +72,29 @@ class BaseSolanaWallet {
|
|
|
80
72
|
}));
|
|
81
73
|
return discovered;
|
|
82
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Connects the wallet account, prompting the user if necessary.
|
|
77
|
+
*
|
|
78
|
+
* - Calls `standard:connect` only if no accounts are present. This will prompt the user to connect their wallet.
|
|
79
|
+
*
|
|
80
|
+
* @param provider - The wallet provider to connect.
|
|
81
|
+
* @returns A promise that resolves once the wallet has ≥ 1 account.
|
|
82
|
+
* @throws {Error} If the wallet does not implement `standard:connect`.
|
|
83
|
+
*/
|
|
83
84
|
this.connectWalletAccount = async (provider) => {
|
|
84
85
|
const wallet = asSolana(provider);
|
|
85
86
|
await connectAccount(wallet);
|
|
86
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Disconnects the wallet account using Wallet Standard.
|
|
90
|
+
*
|
|
91
|
+
* - Calls `standard:disconnect` if implemented.
|
|
92
|
+
* - Throws if the wallet does not implement `standard:disconnect`.
|
|
93
|
+
*
|
|
94
|
+
* @param provider - The wallet provider to disconnect.
|
|
95
|
+
* @returns A promise that resolves once the wallet disconnects.
|
|
96
|
+
* @throws {Error} If `standard:disconnect` is not supported by the wallet.
|
|
97
|
+
*/
|
|
87
98
|
this.disconnectWalletAccount = async (provider) => {
|
|
88
99
|
const wallet = asSolana(provider);
|
|
89
100
|
const disconnectFeature = wallet.features["standard:disconnect"];
|
|
@@ -97,12 +108,22 @@ class BaseSolanaWallet {
|
|
|
97
108
|
}
|
|
98
109
|
}
|
|
99
110
|
/**
|
|
100
|
-
*
|
|
111
|
+
* Signs a message or transaction with the connected Solana wallet.
|
|
112
|
+
*
|
|
113
|
+
* - Ensures the wallet is connected (may prompt via `standard:connect` if its not).
|
|
114
|
+
* - `SignMessage` → `solana:signMessage` (returns hex signature).
|
|
115
|
+
* - `SignTransaction` → `solana:signTransaction` (returns hex signature).
|
|
116
|
+
*
|
|
117
|
+
* @param payload - UTF-8 string (for message) or hex string (for transaction bytes).
|
|
118
|
+
* @param provider - The wallet provider to use.
|
|
119
|
+
* @param intent - The signing intent.
|
|
120
|
+
* @returns Hex-encoded signature (no 0x prefix).
|
|
121
|
+
* @throws {Error} If the provider lacks required features or intent is unsupported.
|
|
101
122
|
*/
|
|
102
123
|
class SolanaWallet extends BaseSolanaWallet {
|
|
103
124
|
constructor() {
|
|
104
125
|
super(...arguments);
|
|
105
|
-
this.sign = async (
|
|
126
|
+
this.sign = async (payload, provider, intent) => {
|
|
106
127
|
const wallet = asSolana(provider);
|
|
107
128
|
await connectAccount(wallet);
|
|
108
129
|
const account = wallet.accounts[0];
|
|
@@ -113,7 +134,7 @@ class SolanaWallet extends BaseSolanaWallet {
|
|
|
113
134
|
const signFeature = wallet.features["solana:signMessage"];
|
|
114
135
|
if (!signFeature)
|
|
115
136
|
throw new Error("Provider does not support solana:signMessage");
|
|
116
|
-
const data = new TextEncoder().encode(
|
|
137
|
+
const data = new TextEncoder().encode(payload);
|
|
117
138
|
const results = await signFeature.signMessage({
|
|
118
139
|
account,
|
|
119
140
|
message: data,
|
|
@@ -127,7 +148,7 @@ class SolanaWallet extends BaseSolanaWallet {
|
|
|
127
148
|
const signFeature = wallet.features["solana:signTransaction"];
|
|
128
149
|
if (!signFeature)
|
|
129
150
|
throw new Error("Provider does not support solana:signTransaction");
|
|
130
|
-
const data = encoding.uint8ArrayFromHexString(
|
|
151
|
+
const data = encoding.uint8ArrayFromHexString(payload);
|
|
131
152
|
const results = await signFeature.signTransaction({
|
|
132
153
|
account,
|
|
133
154
|
transaction: data,
|
|
@@ -143,6 +164,44 @@ class SolanaWallet extends BaseSolanaWallet {
|
|
|
143
164
|
};
|
|
144
165
|
}
|
|
145
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Casts a WalletRpcProvider to a Wallet Standard Solana wallet.
|
|
169
|
+
*
|
|
170
|
+
* - Validates presence of the Wallet Standard `features` map and `solana:signMessage`.
|
|
171
|
+
* - Use this before calling Solana-specific features (signMessage, signTransaction, etc.).
|
|
172
|
+
*
|
|
173
|
+
* @param provider - The wallet provider to cast.
|
|
174
|
+
* @returns The Wallet Standard wallet object.
|
|
175
|
+
* @throws {Error} If the provider is not a Wallet Standard Solana wallet.
|
|
176
|
+
*/
|
|
177
|
+
const asSolana = (provider) => {
|
|
178
|
+
if (provider.provider &&
|
|
179
|
+
"features" in provider.provider &&
|
|
180
|
+
"solana:signMessage" in provider.provider.features) {
|
|
181
|
+
return provider.provider;
|
|
182
|
+
}
|
|
183
|
+
throw new Error("Expected a Wallet-Standard provider (Solana wallet)");
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Ensures the given Wallet Standard wallet has at least one connected account.
|
|
187
|
+
*
|
|
188
|
+
* - If accounts already exist, resolves immediately.
|
|
189
|
+
* - If not, attempts `standard:connect`, which may prompt the user.
|
|
190
|
+
*
|
|
191
|
+
* @param wallet - The Wallet Standard wallet to connect.
|
|
192
|
+
* @returns A promise that resolves once the wallet has ≥ 1 account.
|
|
193
|
+
* @throws {Error} If the wallet does not implement `standard:connect`.
|
|
194
|
+
*/
|
|
195
|
+
const connectAccount = async (wallet) => {
|
|
196
|
+
if (wallet.accounts.length)
|
|
197
|
+
return;
|
|
198
|
+
const stdConnect = wallet.features["standard:connect"];
|
|
199
|
+
if (stdConnect) {
|
|
200
|
+
await stdConnect.connect();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
throw new Error("Wallet is not connected and does not implement standard:connect");
|
|
204
|
+
};
|
|
146
205
|
|
|
147
206
|
exports.BaseSolanaWallet = BaseSolanaWallet;
|
|
148
207
|
exports.SolanaWallet = SolanaWallet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.js","sources":["../../../../src/__wallet__/web/native/solana.ts"],"sourcesContent":[null],"names":["WalletInterfaceType","uint8ArrayToHexString","getWallets","Chain","SignIntent","uint8ArrayFromHexString"],"mappings":";;;;;;;AAiBA
|
|
1
|
+
{"version":3,"file":"solana.js","sources":["../../../../src/__wallet__/web/native/solana.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AAC,EAAE,SAAS,EAAE;AAC9C,wBAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC;;oBAG/D,OAAOJ,8BAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;;AAGpD,gBAAA;AACE,oBAAA,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,CAAA,CAAE,CAAC;;AAE3D,SAAC;;AACF;AAED;;;;;;;;;AASG;AACH,MAAM,QAAQ,GAAG,CAAC,QAAwB,KAAe;IACvD,IACE,QAAQ,CAAC,QAAQ;QACjB,UAAU,IAAI,QAAQ,CAAC,QAAQ;AAC/B,QAAA,oBAAoB,IAAK,QAAQ,CAAC,QAAgB,CAAC,QAAQ,EAC3D;QACA,OAAO,QAAQ,CAAC,QAAqB;;AAEvC,IAAA,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC;AACxE,CAAC;AAED;;;;;;;;;AASG;AACH,MAAM,cAAc,GAAG,OAAO,MAAiB,KAAmB;AAChE,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM;QAAE;IAE5B,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAExC;IAEb,IAAI,UAAU,EAAE;AACd,QAAA,MAAM,UAAU,CAAC,OAAO,EAAE;QAC1B;;AAGF,IAAA,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE;AACH,CAAC;;;;;"}
|
|
@@ -4,43 +4,26 @@ import { uint8ArrayFromHexString, uint8ArrayToHexString } from '@turnkey/encodin
|
|
|
4
4
|
import { SignIntent, WalletInterfaceType, Chain } from '../../../__types__/base.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Abstract base class for Solana wallet implementations using Wallet Standard.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
const asSolana = (p) => {
|
|
14
|
-
if (p.provider &&
|
|
15
|
-
"features" in p.provider &&
|
|
16
|
-
"solana:signMessage" in p.provider.features) {
|
|
17
|
-
return p.provider;
|
|
18
|
-
}
|
|
19
|
-
throw new Error("Expected a Wallet-Standard provider (Solana wallet)");
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Connects the given Solana wallet account.
|
|
23
|
-
*
|
|
24
|
-
* @param w - The wallet to connect.
|
|
25
|
-
* @returns A promise that resolves once the wallet is connected.
|
|
26
|
-
* @throws If the wallet does not support standard:connect.
|
|
27
|
-
*/
|
|
28
|
-
const connectAccount = async (w) => {
|
|
29
|
-
if (w.accounts.length)
|
|
30
|
-
return;
|
|
31
|
-
const stdConnect = w.features["standard:connect"];
|
|
32
|
-
if (stdConnect) {
|
|
33
|
-
await stdConnect.connect();
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
throw new Error("Wallet is not connected and does not implement standard:connect");
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Abstract class representing a base Solana wallet.
|
|
9
|
+
* Provides shared logic for:
|
|
10
|
+
* - Provider discovery via `@wallet-standard/app` (`getWallets()`).
|
|
11
|
+
* - Connecting via `standard:connect` and disconnecting via `standard:disconnect`.
|
|
12
|
+
* - Public key retrieval from the wallet's account address (base58 → hex).
|
|
40
13
|
*/
|
|
41
14
|
class BaseSolanaWallet {
|
|
42
15
|
constructor() {
|
|
43
16
|
this.interfaceType = WalletInterfaceType.Solana;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the ed25519 public key for the active account as hex (no 0x prefix).
|
|
19
|
+
*
|
|
20
|
+
* - Ensures the wallet is connected (calls `standard:connect` if needed).
|
|
21
|
+
* - Decodes the Wallet Standard account address (base58) to raw bytes.
|
|
22
|
+
*
|
|
23
|
+
* @param provider - The wallet provider to use.
|
|
24
|
+
* @returns Hex-encoded ed25519 public key (no 0x prefix).
|
|
25
|
+
* @throws {Error} If no account is available.
|
|
26
|
+
*/
|
|
44
27
|
this.getPublicKey = async (provider) => {
|
|
45
28
|
const wallet = asSolana(provider);
|
|
46
29
|
await connectAccount(wallet);
|
|
@@ -51,6 +34,15 @@ class BaseSolanaWallet {
|
|
|
51
34
|
const rawBytes = bs58.decode(account.address);
|
|
52
35
|
return uint8ArrayToHexString(rawBytes);
|
|
53
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Discovers Solana-capable Wallet Standard providers.
|
|
39
|
+
*
|
|
40
|
+
* - Uses `getWallets().get()` and filters wallets with at least one `chains` entry
|
|
41
|
+
* starting with `"solana:"`.
|
|
42
|
+
* - For each wallet, collects branding info and any currently connected addresses.
|
|
43
|
+
*
|
|
44
|
+
* @returns A list of discovered Solana `WalletProvider`s (may be empty).
|
|
45
|
+
*/
|
|
54
46
|
this.getProviders = async () => {
|
|
55
47
|
const discovered = [];
|
|
56
48
|
const walletsApi = getWallets();
|
|
@@ -78,10 +70,29 @@ class BaseSolanaWallet {
|
|
|
78
70
|
}));
|
|
79
71
|
return discovered;
|
|
80
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Connects the wallet account, prompting the user if necessary.
|
|
75
|
+
*
|
|
76
|
+
* - Calls `standard:connect` only if no accounts are present. This will prompt the user to connect their wallet.
|
|
77
|
+
*
|
|
78
|
+
* @param provider - The wallet provider to connect.
|
|
79
|
+
* @returns A promise that resolves once the wallet has ≥ 1 account.
|
|
80
|
+
* @throws {Error} If the wallet does not implement `standard:connect`.
|
|
81
|
+
*/
|
|
81
82
|
this.connectWalletAccount = async (provider) => {
|
|
82
83
|
const wallet = asSolana(provider);
|
|
83
84
|
await connectAccount(wallet);
|
|
84
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Disconnects the wallet account using Wallet Standard.
|
|
88
|
+
*
|
|
89
|
+
* - Calls `standard:disconnect` if implemented.
|
|
90
|
+
* - Throws if the wallet does not implement `standard:disconnect`.
|
|
91
|
+
*
|
|
92
|
+
* @param provider - The wallet provider to disconnect.
|
|
93
|
+
* @returns A promise that resolves once the wallet disconnects.
|
|
94
|
+
* @throws {Error} If `standard:disconnect` is not supported by the wallet.
|
|
95
|
+
*/
|
|
85
96
|
this.disconnectWalletAccount = async (provider) => {
|
|
86
97
|
const wallet = asSolana(provider);
|
|
87
98
|
const disconnectFeature = wallet.features["standard:disconnect"];
|
|
@@ -95,12 +106,22 @@ class BaseSolanaWallet {
|
|
|
95
106
|
}
|
|
96
107
|
}
|
|
97
108
|
/**
|
|
98
|
-
*
|
|
109
|
+
* Signs a message or transaction with the connected Solana wallet.
|
|
110
|
+
*
|
|
111
|
+
* - Ensures the wallet is connected (may prompt via `standard:connect` if its not).
|
|
112
|
+
* - `SignMessage` → `solana:signMessage` (returns hex signature).
|
|
113
|
+
* - `SignTransaction` → `solana:signTransaction` (returns hex signature).
|
|
114
|
+
*
|
|
115
|
+
* @param payload - UTF-8 string (for message) or hex string (for transaction bytes).
|
|
116
|
+
* @param provider - The wallet provider to use.
|
|
117
|
+
* @param intent - The signing intent.
|
|
118
|
+
* @returns Hex-encoded signature (no 0x prefix).
|
|
119
|
+
* @throws {Error} If the provider lacks required features or intent is unsupported.
|
|
99
120
|
*/
|
|
100
121
|
class SolanaWallet extends BaseSolanaWallet {
|
|
101
122
|
constructor() {
|
|
102
123
|
super(...arguments);
|
|
103
|
-
this.sign = async (
|
|
124
|
+
this.sign = async (payload, provider, intent) => {
|
|
104
125
|
const wallet = asSolana(provider);
|
|
105
126
|
await connectAccount(wallet);
|
|
106
127
|
const account = wallet.accounts[0];
|
|
@@ -111,7 +132,7 @@ class SolanaWallet extends BaseSolanaWallet {
|
|
|
111
132
|
const signFeature = wallet.features["solana:signMessage"];
|
|
112
133
|
if (!signFeature)
|
|
113
134
|
throw new Error("Provider does not support solana:signMessage");
|
|
114
|
-
const data = new TextEncoder().encode(
|
|
135
|
+
const data = new TextEncoder().encode(payload);
|
|
115
136
|
const results = await signFeature.signMessage({
|
|
116
137
|
account,
|
|
117
138
|
message: data,
|
|
@@ -125,7 +146,7 @@ class SolanaWallet extends BaseSolanaWallet {
|
|
|
125
146
|
const signFeature = wallet.features["solana:signTransaction"];
|
|
126
147
|
if (!signFeature)
|
|
127
148
|
throw new Error("Provider does not support solana:signTransaction");
|
|
128
|
-
const data = uint8ArrayFromHexString(
|
|
149
|
+
const data = uint8ArrayFromHexString(payload);
|
|
129
150
|
const results = await signFeature.signTransaction({
|
|
130
151
|
account,
|
|
131
152
|
transaction: data,
|
|
@@ -141,6 +162,44 @@ class SolanaWallet extends BaseSolanaWallet {
|
|
|
141
162
|
};
|
|
142
163
|
}
|
|
143
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Casts a WalletRpcProvider to a Wallet Standard Solana wallet.
|
|
167
|
+
*
|
|
168
|
+
* - Validates presence of the Wallet Standard `features` map and `solana:signMessage`.
|
|
169
|
+
* - Use this before calling Solana-specific features (signMessage, signTransaction, etc.).
|
|
170
|
+
*
|
|
171
|
+
* @param provider - The wallet provider to cast.
|
|
172
|
+
* @returns The Wallet Standard wallet object.
|
|
173
|
+
* @throws {Error} If the provider is not a Wallet Standard Solana wallet.
|
|
174
|
+
*/
|
|
175
|
+
const asSolana = (provider) => {
|
|
176
|
+
if (provider.provider &&
|
|
177
|
+
"features" in provider.provider &&
|
|
178
|
+
"solana:signMessage" in provider.provider.features) {
|
|
179
|
+
return provider.provider;
|
|
180
|
+
}
|
|
181
|
+
throw new Error("Expected a Wallet-Standard provider (Solana wallet)");
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Ensures the given Wallet Standard wallet has at least one connected account.
|
|
185
|
+
*
|
|
186
|
+
* - If accounts already exist, resolves immediately.
|
|
187
|
+
* - If not, attempts `standard:connect`, which may prompt the user.
|
|
188
|
+
*
|
|
189
|
+
* @param wallet - The Wallet Standard wallet to connect.
|
|
190
|
+
* @returns A promise that resolves once the wallet has ≥ 1 account.
|
|
191
|
+
* @throws {Error} If the wallet does not implement `standard:connect`.
|
|
192
|
+
*/
|
|
193
|
+
const connectAccount = async (wallet) => {
|
|
194
|
+
if (wallet.accounts.length)
|
|
195
|
+
return;
|
|
196
|
+
const stdConnect = wallet.features["standard:connect"];
|
|
197
|
+
if (stdConnect) {
|
|
198
|
+
await stdConnect.connect();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
throw new Error("Wallet is not connected and does not implement standard:connect");
|
|
202
|
+
};
|
|
144
203
|
|
|
145
204
|
export { BaseSolanaWallet, SolanaWallet };
|
|
146
205
|
//# sourceMappingURL=solana.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.mjs","sources":["../../../../src/__wallet__/web/native/solana.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAiBA
|
|
1
|
+
{"version":3,"file":"solana.mjs","sources":["../../../../src/__wallet__/web/native/solana.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAiBA;;;;;;;AAOG;MACmB,gBAAgB,CAAA;AAAtC,IAAA,WAAA,GAAA;AACW,QAAA,IAAA,CAAA,aAAa,GAAG,mBAAmB,CAAC,MAAM;AAQnD;;;;;;;;;AASG;AACH,QAAA,IAAA,CAAA,YAAY,GAAG,OAAO,QAAwB,KAAqB;AACjE,YAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC;AACjC,YAAA,MAAM,cAAc,CAAC,MAAM,CAAC;YAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClC,IAAI,CAAC,OAAO,EAAE;AACZ,gBAAA,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;;YAEzC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;AAC7C,YAAA,OAAO,qBAAqB,CAAC,QAAQ,CAAC;AACxC,SAAC;AAED;;;;;;;;AAQG;QACH,IAAY,CAAA,YAAA,GAAG,YAAsC;YACnD,MAAM,UAAU,GAAqB,EAAE;AACvC,YAAA,MAAM,UAAU,GAAG,UAAU,EAAE;YAC/B,MAAM,SAAS,GAAG;AACf,iBA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,CAClE;AACH,CAAC;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export { type TWebauthnStamperConfig, WebauthnStamper, } from "@turnkey/webauthn
|
|
|
5
5
|
export { TurnkeyClient, type TurnkeyClientMethods } from "./__clients__/core";
|
|
6
6
|
export { type TurnkeySDKClientBase } from "./__generated__/sdk-client-base";
|
|
7
7
|
export * from "./__types__/base";
|
|
8
|
-
|
|
8
|
+
/**@internal */
|
|
9
|
+
export { generateWalletAccountsFromAddressFormat, isEthereumProvider, isSolanaProvider, getAuthProxyConfig, addressFormatConfig, } from "./utils";
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,gBAAgB;AAChB,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,oBAAoB,GAC1B,MAAM,0BAA0B,CAAC;AAGlC,gBAAgB;AAChB,OAAO,EACL,KAAK,sBAAsB,EAC3B,eAAe,GAChB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAG5E,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EACL,uCAAuC,EACvC,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,gBAAgB;AAChB,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,oBAAoB,GAC1B,MAAM,0BAA0B,CAAC;AAGlC,gBAAgB;AAChB,OAAO,EACL,KAAK,sBAAsB,EAC3B,eAAe,GAChB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAG5E,cAAc,kBAAkB,CAAC;AAEjC,eAAe;AACf,OAAO,EACL,uCAAuC,EACvC,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,10 +23,6 @@ Object.defineProperty(exports, "WebauthnStamper", {
|
|
|
23
23
|
get: function () { return webauthnStamper.WebauthnStamper; }
|
|
24
24
|
});
|
|
25
25
|
exports.TurnkeyClient = core.TurnkeyClient;
|
|
26
|
-
Object.defineProperty(exports, "AuthClient", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () { return base.AuthClient; }
|
|
29
|
-
});
|
|
30
26
|
Object.defineProperty(exports, "Chain", {
|
|
31
27
|
enumerable: true,
|
|
32
28
|
get: function () { return base.Chain; }
|
|
@@ -40,10 +36,6 @@ Object.defineProperty(exports, "FilterType", {
|
|
|
40
36
|
enumerable: true,
|
|
41
37
|
get: function () { return base.FilterType; }
|
|
42
38
|
});
|
|
43
|
-
Object.defineProperty(exports, "MethodType", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () { return base.MethodType; }
|
|
46
|
-
});
|
|
47
39
|
Object.defineProperty(exports, "OtpType", {
|
|
48
40
|
enumerable: true,
|
|
49
41
|
get: function () { return base.OtpType; }
|
|
@@ -73,6 +65,6 @@ Object.defineProperty(exports, "WalletSource", {
|
|
|
73
65
|
exports.addressFormatConfig = utils.addressFormatConfig;
|
|
74
66
|
exports.generateWalletAccountsFromAddressFormat = utils.generateWalletAccountsFromAddressFormat;
|
|
75
67
|
exports.getAuthProxyConfig = utils.getAuthProxyConfig;
|
|
76
|
-
exports.
|
|
77
|
-
exports.
|
|
68
|
+
exports.isEthereumProvider = utils.isEthereumProvider;
|
|
69
|
+
exports.isSolanaProvider = utils.isSolanaProvider;
|
|
78
70
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ export { ApiKeyStamper, signWithApiKey } from '@turnkey/api-key-stamper';
|
|
|
2
2
|
export { WebauthnStamper } from '@turnkey/webauthn-stamper';
|
|
3
3
|
export { TurnkeyClient } from './__clients__/core.mjs';
|
|
4
4
|
import '@turnkey/http';
|
|
5
|
-
export {
|
|
5
|
+
export { Chain, Curve, DEFAULT_SESSION_EXPIRATION_IN_SECONDS, FilterType, OtpType, OtpTypeToFilterTypeMap, SessionKey, SignIntent, StamperType, TurnkeyRequestError, WalletInterfaceType, WalletSource } from './__types__/base.mjs';
|
|
6
6
|
import '@turnkey/sdk-types';
|
|
7
|
-
export { addressFormatConfig, generateWalletAccountsFromAddressFormat, getAuthProxyConfig,
|
|
7
|
+
export { addressFormatConfig, generateWalletAccountsFromAddressFormat, getAuthProxyConfig, isEthereumProvider, isSolanaProvider } from './utils.mjs';
|
|
8
8
|
//# sourceMappingURL=index.mjs.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import { type v1AddressFormat, type v1HashFunction, type v1PayloadEncoding, type Session, type externaldatav1Timestamp, type ProxyTSignupBody, type v1WalletAccountParams, type v1WalletAccount, v1SignRawPayloadResult, v1TransactionType, ProxyTGetWalletKitConfigResponse } from "@turnkey/sdk-types";
|
|
2
|
-
import { type CreateSubOrgParams,
|
|
1
|
+
import { type v1AddressFormat, type v1HashFunction, type v1PayloadEncoding, type Session, type externaldatav1Timestamp, type ProxyTSignupBody, type v1WalletAccountParams, type v1WalletAccount, TurnkeyErrorCodes, v1SignRawPayloadResult, v1TransactionType, ProxyTGetWalletKitConfigResponse } from "@turnkey/sdk-types";
|
|
2
|
+
import { type CreateSubOrgParams, type WalletProvider, EvmChainInfo, SolanaChainInfo } from "@types";
|
|
3
3
|
type AddressFormatConfig = {
|
|
4
4
|
encoding: v1PayloadEncoding;
|
|
5
5
|
hashFunction: v1HashFunction;
|
|
6
6
|
defaultAccounts: v1WalletAccountParams[] | null;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for all supported address formats.
|
|
11
|
+
*
|
|
12
|
+
* Includes:
|
|
13
|
+
* - encoding type
|
|
14
|
+
* - hash function
|
|
15
|
+
* - default accounts for the address format
|
|
16
|
+
* - display name for the address format
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Example usage:
|
|
20
|
+
* import { addressFormatConfig } from "@turnkey/sdk-core";
|
|
21
|
+
*
|
|
22
|
+
* const config = addressFormatConfig["ADDRESS_FORMAT_ETHEREUM"];
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
9
25
|
export declare const addressFormatConfig: Record<v1AddressFormat, AddressFormatConfig>;
|
|
10
26
|
export declare const googleISS = "https://accounts.google.com";
|
|
11
27
|
export declare const isReactNative: () => boolean;
|
|
@@ -22,18 +38,10 @@ export declare const broadcastTransaction: (params: {
|
|
|
22
38
|
rpcUrl: string;
|
|
23
39
|
transactionType: v1TransactionType;
|
|
24
40
|
}) => Promise<string>;
|
|
25
|
-
export declare const getWalletAccountMethods: (sign: (message: string, provider: WalletProvider, intent: SignIntent) => Promise<string>, provider: WalletProvider) => {
|
|
26
|
-
signMessage: (input: string) => Promise<string>;
|
|
27
|
-
signAndSendTransaction: (input: string) => Promise<string>;
|
|
28
|
-
signTransaction?: never;
|
|
29
|
-
} | {
|
|
30
|
-
signMessage: (input: string) => Promise<string>;
|
|
31
|
-
signTransaction: (input: string) => Promise<string>;
|
|
32
|
-
signAndSendTransaction?: never;
|
|
33
|
-
};
|
|
34
41
|
export declare function splitSignature(signature: string, addressFormat: v1AddressFormat): v1SignRawPayloadResult;
|
|
35
42
|
export declare function isWalletAccountArray(arr: any[]): arr is v1WalletAccountParams[];
|
|
36
43
|
export declare function createWalletAccountFromAddressFormat(addressFormat: v1AddressFormat): v1WalletAccountParams;
|
|
44
|
+
/**@internal */
|
|
37
45
|
export declare function generateWalletAccountsFromAddressFormat(params: {
|
|
38
46
|
addresses: v1AddressFormat[];
|
|
39
47
|
existingWalletAccounts?: v1WalletAccount[];
|
|
@@ -47,8 +55,46 @@ export declare function buildSignUpBody(params: {
|
|
|
47
55
|
* @returns The public key as a hex string
|
|
48
56
|
*/
|
|
49
57
|
export declare function getPublicKeyFromStampHeader(stampHeaderValue: string): string;
|
|
50
|
-
|
|
51
|
-
export declare function
|
|
58
|
+
/**@internal */
|
|
59
|
+
export declare function isEthereumProvider(provider: WalletProvider): provider is WalletProvider & {
|
|
60
|
+
chainInfo: EvmChainInfo;
|
|
61
|
+
};
|
|
62
|
+
/**@internal */
|
|
63
|
+
export declare function isSolanaProvider(provider: WalletProvider): provider is WalletProvider & {
|
|
64
|
+
chainInfo: SolanaChainInfo;
|
|
65
|
+
};
|
|
66
|
+
/** @internal */
|
|
67
|
+
export declare function findWalletProviderFromAddress(address: string, providers: WalletProvider[]): WalletProvider | undefined;
|
|
68
|
+
/**@internal */
|
|
52
69
|
export declare function getAuthProxyConfig(authProxyConfigId: string, authProxyUrl?: string | undefined): Promise<ProxyTGetWalletKitConfigResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
* Executes an async function with error handling.
|
|
73
|
+
*
|
|
74
|
+
* @param fn The async function to execute with error handling
|
|
75
|
+
* @param errorOptions Options for customizing error handling
|
|
76
|
+
* @param errorOptions.catchFn Optional function to execute in the catch block
|
|
77
|
+
* @param errorOptions.errorMessage The default error message to use if no custom message is found
|
|
78
|
+
* @param errorOptions.errorCode The default error code to use if no custom message is found
|
|
79
|
+
* @param errorOptions.customMessageByCodes Optional mapping of error codes to custom messages, if you're trying to target a specific error code and surface a custom message, use this
|
|
80
|
+
* @param errorOptions.customMessageByMessages Optional mapping of error messages to custom messages, if you're trying to target a specific error message and surface a custom message, use this
|
|
81
|
+
* @param finallyFn Optional function to execute in the finally block
|
|
82
|
+
* @returns The result of the async function or throws an error
|
|
83
|
+
*/
|
|
84
|
+
export declare function withTurnkeyErrorHandling<T>(fn: () => Promise<T>, catchOptions: {
|
|
85
|
+
catchFn?: () => Promise<void>;
|
|
86
|
+
errorMessage: string;
|
|
87
|
+
errorCode: TurnkeyErrorCodes;
|
|
88
|
+
customMessageByCodes?: Partial<Record<TurnkeyErrorCodes, {
|
|
89
|
+
message: string;
|
|
90
|
+
code: TurnkeyErrorCodes;
|
|
91
|
+
}>>;
|
|
92
|
+
customMessageByMessages?: Record<string, {
|
|
93
|
+
message: string;
|
|
94
|
+
code: TurnkeyErrorCodes;
|
|
95
|
+
}>;
|
|
96
|
+
}, finallyOptions?: {
|
|
97
|
+
finallyFn: () => Promise<void>;
|
|
98
|
+
}): Promise<T>;
|
|
53
99
|
export {};
|
|
54
100
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAIrB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,uBAAuB,EAC5B,KAAK,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