@vue-solana/core 3.0.0 → 4.0.0-rc.0

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.
Files changed (52) hide show
  1. package/README.md +38 -2
  2. package/dist/action.d.ts +10 -3
  3. package/dist/action.mjs +4 -4
  4. package/dist/address.d.ts +7 -2
  5. package/dist/address.mjs +8 -2
  6. package/dist/clusters.d.ts +1 -1
  7. package/dist/clusters.mjs +10 -1
  8. package/dist/errors.d.ts +1 -1
  9. package/dist/errors.mjs +4 -1
  10. package/dist/index.d.ts +4 -10
  11. package/dist/index.mjs +2 -14
  12. package/dist/ios-wallet.d.ts +1 -2
  13. package/dist/ios-wallet.mjs +659 -4
  14. package/dist/kit.d.ts +1 -1
  15. package/dist/kit.mjs +22 -9
  16. package/dist/mobile-wallet-support.d.ts +3 -0
  17. package/dist/mobile-wallet-support.mjs +5 -0
  18. package/dist/mobile-wallet.d.ts +13 -3
  19. package/dist/mobile-wallet.mjs +4 -9
  20. package/dist/rpc.d.ts +1 -1
  21. package/dist/rpc.mjs +0 -2
  22. package/dist/shared/{core.C9vxHRXl.d.mts → core.BhF1J_tt.d.ts} +40 -2
  23. package/dist/shared/{core.DaUlAmcN.mjs → core.BlqTJRXd.mjs} +56 -5
  24. package/dist/timeout.d.ts +22 -1
  25. package/dist/timeout.mjs +53 -17
  26. package/dist/token-accounts.d.ts +1 -1
  27. package/dist/token-accounts.mjs +31 -2
  28. package/dist/transaction.d.ts +9 -1
  29. package/dist/transaction.mjs +49 -10
  30. package/dist/types.d.ts +1 -1
  31. package/dist/wallet-standard.d.ts +11 -3
  32. package/dist/wallet-standard.mjs +1 -5
  33. package/dist/wallet.d.ts +1 -1
  34. package/package.json +17 -5
  35. package/dist/action.d.mts +0 -28
  36. package/dist/address.d.mts +0 -16
  37. package/dist/buffer-polyfill.d.mts +0 -7
  38. package/dist/clusters.d.mts +0 -10
  39. package/dist/errors.d.mts +0 -17
  40. package/dist/index.d.mts +0 -20
  41. package/dist/ios-wallet.d.mts +0 -62
  42. package/dist/kit.d.mts +0 -3
  43. package/dist/mobile-wallet.d.mts +0 -20
  44. package/dist/rpc.d.mts +0 -7
  45. package/dist/shared/core.C9vxHRXl.d.ts +0 -193
  46. package/dist/shared/core.DuQGQqnc.mjs +0 -575
  47. package/dist/timeout.d.mts +0 -4
  48. package/dist/token-accounts.d.mts +0 -36
  49. package/dist/transaction.d.mts +0 -18
  50. package/dist/types.d.mts +0 -3
  51. package/dist/wallet-standard.d.mts +0 -22
  52. package/dist/wallet.d.mts +0 -25
@@ -1,575 +0,0 @@
1
- import { isAddress } from '@solana/kit';
2
- import bs58 from 'bs58';
3
- import * as naclModule from 'tweetnacl';
4
-
5
- const DEFAULT_IOS_WALLET_CHAINS = [
6
- "solana:mainnet",
7
- "solana:devnet"
8
- ];
9
- const CALLBACK_PARAMS = /* @__PURE__ */ new Set([
10
- "data",
11
- "nonce",
12
- "errorCode",
13
- "errorMessage",
14
- "phantom_encryption_public_key",
15
- "solflare_encryption_public_key",
16
- "wallet_encryption_public_key"
17
- ]);
18
- function isSolanaIosBrowserWalletSupported() {
19
- return isIosBrowser();
20
- }
21
- function isIosBrowser() {
22
- if (typeof window === "undefined" || typeof navigator === "undefined") {
23
- return false;
24
- }
25
- const userAgentDataPlatform = getNavigatorUserAgentDataPlatform();
26
- if (isIosPlatform(userAgentDataPlatform)) {
27
- return true;
28
- }
29
- const userAgent = navigator.userAgent;
30
- const platform = getNavigatorPlatform();
31
- const maxTouchPoints = navigator.maxTouchPoints ?? 0;
32
- return /iPad|iPhone|iPod/i.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
33
- }
34
- function getDefaultIosWalletAppIdentity() {
35
- if (typeof window === "undefined") {
36
- return {
37
- name: "Vue Solana App",
38
- uri: "https://localhost"
39
- };
40
- }
41
- return {
42
- name: document.title || "Vue Solana App",
43
- uri: window.location.origin,
44
- icon: getDocumentIconUrl()
45
- };
46
- }
47
- function getDefaultIosWalletRedirectUrl() {
48
- if (typeof window === "undefined") {
49
- return "https://localhost";
50
- }
51
- const url = new URL(window.location.href);
52
- for (const param of CALLBACK_PARAMS) {
53
- url.searchParams.delete(param);
54
- }
55
- return url.toString();
56
- }
57
- function openIosWalletUrl(url) {
58
- if (typeof window === "undefined") {
59
- throw new Error("iOS wallet links are only available in browser runtimes");
60
- }
61
- window.location.assign(url);
62
- }
63
- function waitForRedirect() {
64
- return new Promise(() => {
65
- });
66
- }
67
- function hasIosWalletCallbackParams(url) {
68
- for (const param of CALLBACK_PARAMS) {
69
- if (url.searchParams.has(param)) {
70
- return true;
71
- }
72
- }
73
- return false;
74
- }
75
- function cleanCallbackUrl(url, clearUrl) {
76
- if (!clearUrl || typeof window === "undefined") {
77
- return;
78
- }
79
- for (const param of CALLBACK_PARAMS) {
80
- url.searchParams.delete(param);
81
- }
82
- window.history.replaceState(window.history.state, document.title, url.toString());
83
- }
84
- function getDocumentIconUrl() {
85
- const icon = document.querySelector(
86
- 'link[rel="icon"], link[rel="shortcut icon"], link[rel="apple-touch-icon"]'
87
- );
88
- return icon?.href;
89
- }
90
- function getNavigatorUserAgentDataPlatform() {
91
- const userAgentData = Reflect.get(navigator, "userAgentData");
92
- if (!isObjectRecord(userAgentData)) {
93
- return void 0;
94
- }
95
- const platform = Reflect.get(userAgentData, "platform");
96
- return typeof platform === "string" ? platform : void 0;
97
- }
98
- function getNavigatorPlatform() {
99
- const platform = Reflect.get(navigator, "platform");
100
- return typeof platform === "string" ? platform : "";
101
- }
102
- function isIosPlatform(platform) {
103
- return platform?.toLowerCase() === "ios";
104
- }
105
- function isObjectRecord(value) {
106
- return typeof value === "object" && value !== null;
107
- }
108
-
109
- const nacl = resolveTweetNaCl();
110
- function createRequestId() {
111
- return bs58.encode(nacl.randomBytes(16));
112
- }
113
- function getSharedSecret(walletEncryptionPublicKey, dappSecretKey) {
114
- if (!walletEncryptionPublicKey) {
115
- throw new Error("Missing iOS wallet encryption public key");
116
- }
117
- return nacl.box.before(bs58.decode(walletEncryptionPublicKey), bs58.decode(dappSecretKey));
118
- }
119
- function encryptPayload(payload, nonce, sharedSecret) {
120
- return bs58.encode(nacl.box.after(encodeJson(payload), nonce, sharedSecret));
121
- }
122
- function decryptPayload(data, nonce, sharedSecret) {
123
- const decrypted = nacl.box.open.after(bs58.decode(data), bs58.decode(nonce), sharedSecret);
124
- if (!decrypted) {
125
- throw new Error("Unable to decrypt iOS wallet callback");
126
- }
127
- return JSON.parse(new TextDecoder().decode(decrypted));
128
- }
129
- function resolveTweetNaCl() {
130
- const moduleDefault = naclModule.default;
131
- const globalNacl = globalThis.nacl;
132
- return "box" in naclModule ? naclModule : moduleDefault ?? globalNacl;
133
- }
134
- function encodeJson(value) {
135
- return new TextEncoder().encode(JSON.stringify(value));
136
- }
137
-
138
- const IOS_WALLETS = [
139
- {
140
- id: "phantom",
141
- name: "Phantom",
142
- icon: "https://phantom.app/img/phantom-logo.svg",
143
- appUrl: "https://phantom.app",
144
- installUrl: "https://phantom.app/download",
145
- encryptionPublicKeyParam: "phantom_encryption_public_key",
146
- connectUrl: "https://phantom.app/ul/v1/connect",
147
- signTransactionUrl: "https://phantom.app/ul/v1/signTransaction",
148
- signAllTransactionsUrl: "https://phantom.app/ul/v1/signAllTransactions"
149
- },
150
- {
151
- id: "solflare",
152
- name: "Solflare",
153
- icon: "https://solflare.com/favicon.ico",
154
- appUrl: "https://solflare.com",
155
- installUrl: "https://solflare.com/download",
156
- encryptionPublicKeyParam: "solflare_encryption_public_key",
157
- connectUrl: "https://solflare.com/ul/v1/connect",
158
- signTransactionUrl: "https://solflare.com/ul/v1/signTransaction",
159
- signAllTransactionsUrl: "https://solflare.com/ul/v1/signAllTransactions",
160
- signAndSendTransactionUrl: "https://solflare.com/ul/v1/signAndSendTransaction"
161
- },
162
- {
163
- id: "backpack",
164
- name: "Backpack",
165
- icon: "https://backpack.app/favicon.ico",
166
- appUrl: "https://backpack.app",
167
- installUrl: "https://backpack.app/download",
168
- encryptionPublicKeyParam: "wallet_encryption_public_key",
169
- connectUrl: "https://backpack.app/ul/v1/connect",
170
- signTransactionUrl: "https://backpack.app/ul/v1/signTransaction",
171
- signAllTransactionsUrl: "https://backpack.app/ul/v1/signAllTransactions",
172
- signAndSendTransactionUrl: "https://backpack.app/ul/v1/signAndSendTransaction"
173
- }
174
- ];
175
- function getIosWalletDefinitionById(walletId) {
176
- const definition = IOS_WALLETS.find((wallet) => wallet.id === walletId);
177
- if (!definition) {
178
- throw new Error(`Unknown iOS wallet: ${walletId}`);
179
- }
180
- return definition;
181
- }
182
- function isIosWalletDefinition(value) {
183
- return typeof value === "object" && value !== null && "id" in value && typeof value.id === "string" && IOS_WALLETS.some((wallet) => wallet.id === value.id);
184
- }
185
-
186
- const PENDING_REQUEST_KEY = "vue-solana:ios-wallet:pending";
187
- const PENDING_REQUEST_TTL_MS = 10 * 60 * 1e3;
188
- const SESSION_PREFIX = "vue-solana:ios-wallet:session:";
189
- function createPendingRequest(walletId, method, keyPair, redirectUrl, requestedTransactionCount) {
190
- return {
191
- id: createRequestId(),
192
- walletId,
193
- method,
194
- dappEncryptionPublicKey: bs58.encode(keyPair.publicKey),
195
- dappEncryptionSecretKey: bs58.encode(keyPair.secretKey),
196
- redirectUrl: redirectUrl ?? getDefaultIosWalletRedirectUrl(),
197
- createdAt: Date.now(),
198
- requestedTransactionCount
199
- };
200
- }
201
- function getStoredIosWalletAccount(walletId, chains) {
202
- const session = getStoredSession(walletId);
203
- if (!session) {
204
- return [];
205
- }
206
- return [
207
- {
208
- address: session.publicKey,
209
- publicKey: bs58.decode(session.publicKey),
210
- chains
211
- }
212
- ];
213
- }
214
- function getStoredSession(walletId) {
215
- return readJson(
216
- `${SESSION_PREFIX}${walletId}`,
217
- (session) => isAddress(session.publicKey)
218
- );
219
- }
220
- function storeSession(session) {
221
- writeJson(`${SESSION_PREFIX}${session.walletId}`, session);
222
- }
223
- function removeStoredSession(walletId) {
224
- removeJson(`${SESSION_PREFIX}${walletId}`);
225
- }
226
- function getPendingRequest() {
227
- return readJson(PENDING_REQUEST_KEY);
228
- }
229
- function storePendingRequest(request) {
230
- writeJson(PENDING_REQUEST_KEY, request);
231
- }
232
- function clearPendingRequest() {
233
- removeJson(PENDING_REQUEST_KEY);
234
- }
235
- function isPendingRequestExpired(request) {
236
- return Date.now() - request.createdAt > PENDING_REQUEST_TTL_MS;
237
- }
238
- function readJson(key, validate) {
239
- const value = getStorage()?.getItem(key);
240
- if (!value) {
241
- return null;
242
- }
243
- try {
244
- const parsed = JSON.parse(value);
245
- if (validate && !validate(parsed)) {
246
- throw new Error("Invalid stored value");
247
- }
248
- return parsed;
249
- } catch {
250
- getStorage()?.removeItem(key);
251
- return null;
252
- }
253
- }
254
- function writeJson(key, value) {
255
- getStorage()?.setItem(key, JSON.stringify(value));
256
- }
257
- function removeJson(key) {
258
- getStorage()?.removeItem(key);
259
- }
260
- function getStorage() {
261
- if (typeof window === "undefined") {
262
- return null;
263
- }
264
- try {
265
- return window.sessionStorage;
266
- } catch {
267
- return null;
268
- }
269
- }
270
-
271
- function handleSolanaIosWalletCallback(options = {}) {
272
- if (typeof window === "undefined") {
273
- return null;
274
- }
275
- const url = new URL(window.location.href);
276
- if (!hasIosWalletCallbackParams(url)) {
277
- return null;
278
- }
279
- const errorCode = url.searchParams.get("errorCode");
280
- const errorMessage = url.searchParams.get("errorMessage");
281
- if (errorCode || errorMessage) {
282
- clearPendingRequest();
283
- cleanCallbackUrl(url, options.clearUrl);
284
- throw new Error(errorMessage || `iOS wallet request failed: ${errorCode}`);
285
- }
286
- const pending = getPendingRequest();
287
- if (!pending) {
288
- cleanCallbackUrl(url, options.clearUrl);
289
- throw new Error("Received an iOS wallet callback without a pending request");
290
- }
291
- if (isPendingRequestExpired(pending)) {
292
- clearPendingRequest();
293
- cleanCallbackUrl(url, options.clearUrl);
294
- throw new Error("Received an expired iOS wallet callback");
295
- }
296
- const definition = getIosWalletDefinitionById(pending.walletId);
297
- const walletEncryptionPublicKey = url.searchParams.get(definition.encryptionPublicKeyParam);
298
- const nonce = url.searchParams.get("nonce");
299
- const data = url.searchParams.get("data");
300
- if (!nonce || !data) {
301
- clearPendingRequest();
302
- cleanCallbackUrl(url, options.clearUrl);
303
- throw new Error("Received an incomplete iOS wallet callback");
304
- }
305
- try {
306
- const sharedSecret = getSharedSecret(
307
- walletEncryptionPublicKey ?? getStoredSession(pending.walletId)?.walletEncryptionPublicKey,
308
- pending.dappEncryptionSecretKey
309
- );
310
- const payload = decryptPayload(data, nonce, sharedSecret);
311
- const result = createCallbackResult(pending, payload);
312
- if (pending.method === "connect") {
313
- if (!walletEncryptionPublicKey) {
314
- throw new Error("iOS wallet connect callback did not include an encryption public key");
315
- }
316
- const publicKey = getPublicKeyField(payload, "public_key");
317
- storeSession({
318
- walletId: pending.walletId,
319
- publicKey,
320
- session: getStringField(payload, "session"),
321
- dappEncryptionPublicKey: pending.dappEncryptionPublicKey,
322
- dappEncryptionSecretKey: pending.dappEncryptionSecretKey,
323
- walletEncryptionPublicKey,
324
- sharedSecret: bs58.encode(sharedSecret)
325
- });
326
- }
327
- return result;
328
- } finally {
329
- clearPendingRequest();
330
- cleanCallbackUrl(url, options.clearUrl);
331
- }
332
- }
333
- function createCallbackResult(pending, payload) {
334
- if (pending.method === "connect") {
335
- return {
336
- walletId: pending.walletId,
337
- method: pending.method,
338
- publicKey: getPublicKeyField(payload, "public_key")
339
- };
340
- }
341
- if (pending.method === "signTransaction") {
342
- return {
343
- walletId: pending.walletId,
344
- method: pending.method,
345
- transaction: bs58.decode(getStringField(payload, "transaction"))
346
- };
347
- }
348
- if (pending.method === "signAllTransactions") {
349
- const transactions = payload.transactions;
350
- if (!Array.isArray(transactions) || transactions.some((transaction) => typeof transaction !== "string")) {
351
- throw new Error("iOS wallet returned invalid signed transactions");
352
- }
353
- if (typeof pending.requestedTransactionCount === "number" && transactions.length !== pending.requestedTransactionCount) {
354
- throw new Error(
355
- `iOS wallet returned ${transactions.length} signed transactions for ${pending.requestedTransactionCount} requested transactions`
356
- );
357
- }
358
- return {
359
- walletId: pending.walletId,
360
- method: pending.method,
361
- transactions: transactions.map((transaction) => bs58.decode(transaction))
362
- };
363
- }
364
- return {
365
- walletId: pending.walletId,
366
- method: pending.method,
367
- signature: getStringField(payload, "signature")
368
- };
369
- }
370
- function getStringField(payload, field) {
371
- const value = payload[field];
372
- if (typeof value !== "string" || !value) {
373
- throw new Error(`iOS wallet callback is missing ${field}`);
374
- }
375
- return value;
376
- }
377
- function getPublicKeyField(payload, field) {
378
- const value = getStringField(payload, field);
379
- if (!isAddress(value)) {
380
- throw new Error(`iOS wallet callback returned an invalid ${field}`);
381
- }
382
- return value;
383
- }
384
-
385
- function launchConnect(definition, options) {
386
- const keyPair = nacl.box.keyPair();
387
- const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
388
- const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
389
- const url = new URL(definition.connectUrl);
390
- url.searchParams.set("app_url", appIdentity.uri);
391
- url.searchParams.set("dapp_encryption_public_key", pending.dappEncryptionPublicKey);
392
- url.searchParams.set("redirect_link", pending.redirectUrl);
393
- if (options.cluster && options.cluster !== "localnet") {
394
- url.searchParams.set("cluster", options.cluster);
395
- }
396
- storePendingRequest(pending);
397
- openIosWalletUrl(url.toString());
398
- }
399
- async function launchSignTransaction(definition, transaction, options) {
400
- const response = await launchEncryptedWalletRequest(definition, "signTransaction", options, {
401
- transaction: bs58.encode(new Uint8Array(transaction))
402
- });
403
- if (!response.transaction) {
404
- throw new Error("iOS wallet did not return a signed transaction");
405
- }
406
- return response.transaction;
407
- }
408
- async function launchSignAllTransactions(definition, transactions, options) {
409
- const response = await launchEncryptedWalletRequest(definition, "signAllTransactions", options, {
410
- transactions: transactions.map((transaction) => bs58.encode(new Uint8Array(transaction)))
411
- });
412
- if (!response.transactions) {
413
- throw new Error("iOS wallet did not return signed transactions");
414
- }
415
- return response.transactions;
416
- }
417
- async function launchSignAndSendTransaction(definition, transaction, sendOptions, options) {
418
- const response = await launchEncryptedWalletRequest(
419
- definition,
420
- "signAndSendTransaction",
421
- options,
422
- {
423
- transaction: bs58.encode(new Uint8Array(transaction)),
424
- sendOptions
425
- }
426
- );
427
- if (!response.signature) {
428
- throw new Error("iOS wallet did not return a transaction signature");
429
- }
430
- return { signature: response.signature };
431
- }
432
- async function launchEncryptedWalletRequest(definition, method, options, payload) {
433
- const session = getStoredSession(definition.id);
434
- if (!session) {
435
- throw new Error("Connect the iOS wallet before signing");
436
- }
437
- const methodUrl = getIosWalletMethodUrl(definition, method);
438
- const pending = createPendingRequest(
439
- definition.id,
440
- method,
441
- {
442
- publicKey: bs58.decode(session.dappEncryptionPublicKey),
443
- secretKey: bs58.decode(session.dappEncryptionSecretKey)
444
- },
445
- options.redirectUrl,
446
- method === "signAllTransactions" && Array.isArray(payload.transactions) ? payload.transactions.length : void 0
447
- );
448
- const nonce = nacl.randomBytes(nacl.box.nonceLength);
449
- const encryptedPayload = encryptPayload(
450
- { ...payload, session: session.session },
451
- nonce,
452
- bs58.decode(session.sharedSecret)
453
- );
454
- const url = new URL(methodUrl);
455
- url.searchParams.set("dapp_encryption_public_key", session.dappEncryptionPublicKey);
456
- url.searchParams.set("nonce", bs58.encode(nonce));
457
- url.searchParams.set("redirect_link", pending.redirectUrl);
458
- url.searchParams.set("payload", encryptedPayload);
459
- storePendingRequest(pending);
460
- openIosWalletUrl(url.toString());
461
- return waitForRedirect();
462
- }
463
- function getIosWalletMethodUrl(definition, method) {
464
- const url = definition[`${method}Url`];
465
- if (!url) {
466
- throw new Error(`${definition.name} does not support ${method} through iOS deeplinks`);
467
- }
468
- return url;
469
- }
470
-
471
- function getSolanaIosWallets(options = {}) {
472
- if (!isSolanaIosBrowserWalletSupported()) {
473
- return [];
474
- }
475
- const chains = options.chains?.length ? options.chains : DEFAULT_IOS_WALLET_CHAINS;
476
- const callbackUrl = options.redirectUrl ?? getDefaultIosWalletRedirectUrl();
477
- return IOS_WALLETS.map((wallet) => ({
478
- name: wallet.name,
479
- icon: wallet.icon,
480
- chains,
481
- platform: "mobile",
482
- source: "deep-link",
483
- appUrl: wallet.appUrl,
484
- installUrl: wallet.installUrl,
485
- callbackUrl,
486
- capabilities: {
487
- connect: true,
488
- disconnect: true,
489
- signTransaction: Boolean(wallet.signTransactionUrl),
490
- signAllTransactions: Boolean(wallet.signAllTransactionsUrl),
491
- signAndSendTransaction: Boolean(wallet.signAndSendTransactionUrl)
492
- },
493
- accounts: getStoredIosWalletAccount(wallet.id, chains),
494
- wallet
495
- }));
496
- }
497
- function adaptSolanaIosWallet(walletInfo, options = {}) {
498
- const definition = getIosWalletDefinition(walletInfo);
499
- let connecting = false;
500
- let disconnecting = false;
501
- let session = getStoredSession(definition.id);
502
- function refreshSession() {
503
- session = getStoredSession(definition.id);
504
- options.onChange?.();
505
- }
506
- return {
507
- get publicKey() {
508
- return session?.publicKey ? session.publicKey : null;
509
- },
510
- get connected() {
511
- return Boolean(session?.publicKey && session.session);
512
- },
513
- get connecting() {
514
- return connecting;
515
- },
516
- get disconnecting() {
517
- return disconnecting;
518
- },
519
- async connect() {
520
- const callback = handleSolanaIosWalletCallback({ clearUrl: true });
521
- if (callback?.walletId === definition.id) {
522
- refreshSession();
523
- return;
524
- }
525
- connecting = true;
526
- options.onChange?.();
527
- try {
528
- launchConnect(definition, options);
529
- await waitForRedirect();
530
- } finally {
531
- connecting = false;
532
- options.onChange?.();
533
- }
534
- },
535
- async disconnect() {
536
- disconnecting = true;
537
- options.onChange?.();
538
- try {
539
- removeStoredSession(definition.id);
540
- refreshSession();
541
- } finally {
542
- disconnecting = false;
543
- options.onChange?.();
544
- }
545
- },
546
- signTransaction: definition.signTransactionUrl ? async (transaction) => {
547
- return launchSignTransaction(definition, transaction, options);
548
- } : void 0,
549
- signAllTransactions: definition.signAllTransactionsUrl ? async (transactions) => {
550
- const signedTransactions = await launchSignAllTransactions(
551
- definition,
552
- transactions,
553
- options
554
- );
555
- if (signedTransactions.length !== transactions.length) {
556
- throw new Error(
557
- `iOS wallet returned ${signedTransactions.length} signed transactions for ${transactions.length} requested transactions`
558
- );
559
- }
560
- return signedTransactions;
561
- } : void 0,
562
- signAndSendTransaction: definition.signAndSendTransactionUrl ? async (transaction, sendOptions) => launchSignAndSendTransaction(definition, transaction, sendOptions, options) : void 0
563
- };
564
- }
565
- function isSolanaIosWalletInfo(walletInfo) {
566
- return walletInfo.source === "deep-link" && isIosWalletDefinition(walletInfo.wallet);
567
- }
568
- function getIosWalletDefinition(walletInfo) {
569
- if (!isIosWalletDefinition(walletInfo.wallet)) {
570
- throw new Error("Solana wallet info is not an iOS wallet");
571
- }
572
- return walletInfo.wallet;
573
- }
574
-
575
- export { adaptSolanaIosWallet as a, getDefaultIosWalletRedirectUrl as b, getSolanaIosWallets as c, isSolanaIosBrowserWalletSupported as d, isSolanaIosWalletInfo as e, getDefaultIosWalletAppIdentity as g, handleSolanaIosWalletCallback as h, isIosBrowser as i };
@@ -1,4 +0,0 @@
1
- declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, createError: () => unknown): Promise<T>;
2
- declare function withSolanaTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, message: string): Promise<T>;
3
-
4
- export { withSolanaTimeout, withTimeout };
@@ -1,36 +0,0 @@
1
- import { Address, Commitment } from '@solana/kit';
2
- import { b as SolanaClient } from './shared/core.C9vxHRXl.mjs';
3
- import '@solana/kit-plugin-rpc';
4
-
5
- interface TokenAccountInfo {
6
- address: Address;
7
- mint: Address;
8
- owner: Address;
9
- amount: bigint;
10
- decimals: number;
11
- state: "frozen" | "initialized" | "uninitialized";
12
- isNative: boolean;
13
- }
14
- interface TokenAccountsByOwnerOptions {
15
- commitment?: Commitment;
16
- programId?: Address;
17
- }
18
- /**
19
- * Get all SPL token accounts for an owner using parsed kit RPC reads.
20
- */
21
- declare function getTokenAccountsByOwner(client: SolanaClient, owner: Address, options?: TokenAccountsByOwnerOptions): Promise<TokenAccountInfo[]>;
22
- /**
23
- * Get a single parsed token account at the given address.
24
- */
25
- declare function getTokenAccount(client: SolanaClient, address: Address, commitment?: Commitment): Promise<TokenAccountInfo | null>;
26
- interface TokenBalanceResult {
27
- amount: bigint;
28
- decimals: number;
29
- }
30
- /**
31
- * Read the token balance of the accounts an owner holds for a given mint.
32
- */
33
- declare function getTokenBalance(client: SolanaClient, mint: Address, owner: Address, commitment?: Commitment): Promise<TokenBalanceResult | null>;
34
-
35
- export { getTokenAccount, getTokenAccountsByOwner, getTokenBalance };
36
- export type { TokenAccountInfo, TokenAccountsByOwnerOptions, TokenBalanceResult };
@@ -1,18 +0,0 @@
1
- import { Signature } from '@solana/kit';
2
- import { b as SolanaClient, C as ConfirmTransactionOptions, T as TransactionConfirmation, k as SolanaWallet, j as SolanaTransaction, S as SendTransactionOptions } from './shared/core.C9vxHRXl.mjs';
3
- import '@solana/kit-plugin-rpc';
4
-
5
- /**
6
- * Sign and send a transaction through a connected wallet.
7
- *
8
- * Walks through the supported kit RPC path: the wallet signs the raw wire
9
- * transaction, and the client sends it via `client.rpc.sendTransaction`.
10
- */
11
- declare function signAndSendTransaction(client: SolanaClient, wallet: SolanaWallet, transaction: SolanaTransaction, options?: SendTransactionOptions): Promise<Signature>;
12
- /**
13
- * Confirm a transaction signature against the kit RPC until it reaches the
14
- * requested commitment.
15
- */
16
- declare function confirmTransactionSignature(client: SolanaClient, signature: Signature, options?: ConfirmTransactionOptions): Promise<TransactionConfirmation>;
17
-
18
- export { confirmTransactionSignature, signAndSendTransaction };
package/dist/types.d.mts DELETED
@@ -1,3 +0,0 @@
1
- import '@solana/kit';
2
- export { C as ConfirmTransactionOptions, S as SendTransactionOptions, a as SolanaChain, c as SolanaCluster, d as SolanaConfig, e as SolanaContext, f as SolanaSignInAccount, g as SolanaSignInInput, h as SolanaSignInResult, i as SolanaSignMessageResult, j as SolanaTransaction, k as SolanaWallet, l as SolanaWalletInfo, T as TransactionConfirmation, m as TransactionStatus } from './shared/core.C9vxHRXl.mjs';
3
- import '@solana/kit-plugin-rpc';
@@ -1,22 +0,0 @@
1
- import { WalletAccount, Wallet } from '@wallet-standard/base';
2
- import { a as SolanaChain, l as SolanaWalletInfo, k as SolanaWallet, c as SolanaCluster } from './shared/core.C9vxHRXl.mjs';
3
- import '@solana/kit-plugin-rpc';
4
- import '@solana/kit';
5
-
6
- interface AdaptSolanaWalletOptions {
7
- chain?: SolanaChain;
8
- account?: WalletAccount;
9
- onChange?: () => void;
10
- }
11
- declare function adaptSolanaStandardWallet(walletInfo: SolanaWalletInfo, options?: AdaptSolanaWalletOptions): SolanaWallet;
12
-
13
- declare const SOLANA_CHAINS: readonly SolanaChain[];
14
- declare function getSolanaChain(cluster: SolanaCluster): SolanaChain;
15
-
16
- declare const SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME = "Mobile Wallet Adapter";
17
- declare function isSolanaStandardWallet(wallet: Wallet): boolean;
18
- declare function getRegisteredSolanaWallets(): SolanaWalletInfo[];
19
- declare function subscribeSolanaWallets(listener: () => void): () => void;
20
-
21
- export { SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets };
22
- export type { AdaptSolanaWalletOptions };
package/dist/wallet.d.mts DELETED
@@ -1,25 +0,0 @@
1
- import { k as SolanaWallet } from './shared/core.C9vxHRXl.mjs';
2
- import { SolanaError } from './errors.mjs';
3
- import '@solana/kit-plugin-rpc';
4
- import '@solana/kit';
5
-
6
- type SolanaWalletErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED";
7
- declare class SolanaWalletError extends SolanaError {
8
- constructor(code: SolanaWalletErrorCode, message: string, options?: {
9
- cause?: unknown;
10
- feature?: string;
11
- });
12
- }
13
- declare function createNoWalletSelectedError(cause?: unknown): SolanaWalletError;
14
- declare function isWalletConnected(wallet: Pick<SolanaWallet, "connected" | "publicKey"> | null | undefined): boolean;
15
- declare function assertWalletConnected(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & {
16
- publicKey: NonNullable<SolanaWallet["publicKey"]>;
17
- };
18
- declare function assertWalletCanSign(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signTransaction">>;
19
- declare function assertWalletCanSignMessage(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signMessage">>;
20
- declare function assertWalletCanSignIn(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signIn">>;
21
- declare function assertWalletCanSignTransactions(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signTransactions">>;
22
- declare function assertWalletCanSignAndSendTransactions(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signAndSendTransactions">>;
23
-
24
- export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignAndSendTransactions, assertWalletCanSignIn, assertWalletCanSignMessage, assertWalletCanSignTransactions, assertWalletConnected, createNoWalletSelectedError, isWalletConnected };
25
- export type { SolanaWalletErrorCode };