@dynamic-labs/solana 0.0.0-exp20240808.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 (91) hide show
  1. package/CHANGELOG.md +3746 -0
  2. package/LICENSE +21 -0
  3. package/README.md +0 -0
  4. package/_virtual/_tslib.cjs +36 -0
  5. package/_virtual/_tslib.js +32 -0
  6. package/package.json +48 -0
  7. package/src/CoinbaseSolana.cjs +52 -0
  8. package/src/CoinbaseSolana.d.ts +9 -0
  9. package/src/CoinbaseSolana.js +48 -0
  10. package/src/Phantom.cjs +44 -0
  11. package/src/Phantom.d.ts +13 -0
  12. package/src/Phantom.js +40 -0
  13. package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.cjs +100 -0
  14. package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.d.ts +21 -0
  15. package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.js +96 -0
  16. package/src/SolanaWalletStandardConnector/index.d.ts +1 -0
  17. package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs +117 -0
  18. package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.d.ts +4 -0
  19. package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js +113 -0
  20. package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/index.d.ts +1 -0
  21. package/src/Solflare.cjs +63 -0
  22. package/src/Solflare.d.ts +9 -0
  23. package/src/Solflare.js +59 -0
  24. package/src/contants.cjs +8 -0
  25. package/src/contants.d.ts +1 -0
  26. package/src/contants.js +4 -0
  27. package/src/errors/SignMessageNotSupportedError.cjs +17 -0
  28. package/src/errors/SignMessageNotSupportedError.d.ts +4 -0
  29. package/src/errors/SignMessageNotSupportedError.js +13 -0
  30. package/src/index.cjs +30 -0
  31. package/src/index.d.ts +7 -0
  32. package/src/index.js +22 -0
  33. package/src/injected/BackpackSol.cjs +46 -0
  34. package/src/injected/BackpackSol.d.ts +9 -0
  35. package/src/injected/BackpackSol.js +42 -0
  36. package/src/injected/FallbackSolanaConnector.cjs +22 -0
  37. package/src/injected/FallbackSolanaConnector.d.ts +9 -0
  38. package/src/injected/FallbackSolanaConnector.js +18 -0
  39. package/src/injected/InjectedWalletBase.cjs +118 -0
  40. package/src/injected/InjectedWalletBase.d.ts +21 -0
  41. package/src/injected/InjectedWalletBase.js +114 -0
  42. package/src/injected/PhantomInjected.cjs +37 -0
  43. package/src/injected/PhantomInjected.d.ts +8 -0
  44. package/src/injected/PhantomInjected.js +33 -0
  45. package/src/injected/UnknownInjected.cjs +21 -0
  46. package/src/injected/UnknownInjected.d.ts +8 -0
  47. package/src/injected/UnknownInjected.js +17 -0
  48. package/src/injected/fetchInjectedWalletConnectors.cjs +63 -0
  49. package/src/injected/fetchInjectedWalletConnectors.d.ts +6 -0
  50. package/src/injected/fetchInjectedWalletConnectors.js +58 -0
  51. package/src/injected/index.d.ts +3 -0
  52. package/src/phantomRedirect/PhantomRedirect.cjs +337 -0
  53. package/src/phantomRedirect/PhantomRedirect.d.ts +37 -0
  54. package/src/phantomRedirect/PhantomRedirect.js +328 -0
  55. package/src/phantomRedirect/storage.cjs +96 -0
  56. package/src/phantomRedirect/storage.d.ts +40 -0
  57. package/src/phantomRedirect/storage.js +91 -0
  58. package/src/phantomRedirect/types.d.ts +1 -0
  59. package/src/phantomRedirect/utils.cjs +56 -0
  60. package/src/phantomRedirect/utils.d.ts +4 -0
  61. package/src/phantomRedirect/utils.js +44 -0
  62. package/src/solProviderHelper.cjs +173 -0
  63. package/src/solProviderHelper.d.ts +36 -0
  64. package/src/solProviderHelper.js +169 -0
  65. package/src/solWalletConnector.cjs +174 -0
  66. package/src/solWalletConnector.d.ts +37 -0
  67. package/src/solWalletConnector.js +170 -0
  68. package/src/types.d.ts +68 -0
  69. package/src/utils/extractNonce.cjs +14 -0
  70. package/src/utils/extractNonce.d.ts +1 -0
  71. package/src/utils/extractNonce.js +10 -0
  72. package/src/utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.cjs +29 -0
  73. package/src/utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.d.ts +3 -0
  74. package/src/utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.js +25 -0
  75. package/src/utils/findWalletProviderFromWalletStandard/index.d.ts +1 -0
  76. package/src/utils/getGenesisHashLSKey.cjs +10 -0
  77. package/src/utils/getGenesisHashLSKey.d.ts +1 -0
  78. package/src/utils/getGenesisHashLSKey.js +6 -0
  79. package/src/utils/isBackpackSolanaSigner.cjs +8 -0
  80. package/src/utils/isBackpackSolanaSigner.d.ts +2 -0
  81. package/src/utils/isBackpackSolanaSigner.js +4 -0
  82. package/src/utils/isSignedMessage.cjs +8 -0
  83. package/src/utils/isSignedMessage.d.ts +2 -0
  84. package/src/utils/isSignedMessage.js +4 -0
  85. package/src/wallet/SolanaWallet.cjs +33 -0
  86. package/src/wallet/SolanaWallet.d.ts +17 -0
  87. package/src/wallet/SolanaWallet.js +29 -0
  88. package/src/wallet/index.d.ts +2 -0
  89. package/src/wallet/isSolanaWallet.cjs +8 -0
  90. package/src/wallet/isSolanaWallet.d.ts +3 -0
  91. package/src/wallet/isSolanaWallet.js +4 -0
@@ -0,0 +1,170 @@
1
+ 'use client'
2
+ import { __awaiter } from '../_virtual/_tslib.js';
3
+ import { PublicKey, Connection, Transaction, TransactionInstruction } from '@solana/web3.js';
4
+ import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
5
+ import { DynamicError, NotSupportedError, isLedgerAddressViaVerifiedCredentials } from '@dynamic-labs/utils';
6
+ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
7
+ import { extractNonce } from './utils/extractNonce.js';
8
+ import { getGenesisHashLSKey } from './utils/getGenesisHashLSKey.js';
9
+ import { SolanaWallet } from './wallet/SolanaWallet.js';
10
+
11
+ const MEMO_PROGRAM_ID = new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
12
+ class SolWalletConnector extends WalletConnectorBase {
13
+ constructor(opts) {
14
+ var _a;
15
+ super(opts);
16
+ this.isHardwareWalletEnabled = false;
17
+ this.verifiedCredentials = [];
18
+ this.ChainWallet = SolanaWallet;
19
+ this.supportedChains = ['SOL'];
20
+ this.connectedChain = 'SOL';
21
+ this.solNetworks = opts.solNetworks;
22
+ this.chainRpcProviders = opts.chainRpcProviders;
23
+ (_a = this.chainRpcProviders) === null || _a === void 0 ? void 0 : _a.registerSolanaProviders();
24
+ }
25
+ getNetwork() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const provider = this.getWalletClient();
28
+ let genesisHash = localStorage.getItem(getGenesisHashLSKey(provider.rpcEndpoint));
29
+ if (!genesisHash) {
30
+ genesisHash = yield provider.getGenesisHash();
31
+ localStorage.setItem(getGenesisHashLSKey(provider.rpcEndpoint), genesisHash);
32
+ }
33
+ genesisHash = genesisHash.substring(0, 32);
34
+ // see: https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip2.md
35
+ let network;
36
+ if (genesisHash === '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp') {
37
+ network = 'mainnet';
38
+ }
39
+ else if (genesisHash === 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1') {
40
+ network = 'devnet';
41
+ }
42
+ else {
43
+ network = 'testnet';
44
+ }
45
+ return network;
46
+ });
47
+ }
48
+ endSession() {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ localStorage.removeItem(getGenesisHashLSKey(this.getWalletClient().rpcEndpoint));
51
+ });
52
+ }
53
+ getWalletClient() {
54
+ var _a;
55
+ const [network] = this.solNetworks;
56
+ if (!network) {
57
+ throw new DynamicError('No enabled networks');
58
+ }
59
+ const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
60
+ return new Connection(rpcUrl, 'confirmed');
61
+ }
62
+ getPublicClient() {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ var _a;
65
+ if (this.solNetworks.length === 0)
66
+ return;
67
+ const configurations = {
68
+ cosmos: [],
69
+ evm: undefined,
70
+ solana: this.solNetworks,
71
+ starknet: undefined,
72
+ };
73
+ if (!this.chainRpcProviders)
74
+ return undefined;
75
+ const providers = this.chainRpcProviders.getProviders(configurations);
76
+ return (_a = this.chainRpcProviders.getSolanaProviderByChainId(providers, '101')) === null || _a === void 0 ? void 0 : _a.provider;
77
+ });
78
+ }
79
+ getBalance(address) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const publicKey = new PublicKey(address);
82
+ const balance = this.lamportsToSol(yield this.getWalletClient().getBalance(publicKey));
83
+ return balance.toString();
84
+ });
85
+ }
86
+ // Solana uses lamports as the smallest unit of currency. This converts lamports to SOL.
87
+ lamportsToSol(lamports) {
88
+ return lamports / 1000000000;
89
+ }
90
+ canConnectWithHardwareWallet() {
91
+ const wallet = findWalletBookWallet(this.walletBook, this.key);
92
+ if (!wallet || !wallet.hardwareWallets)
93
+ return false;
94
+ return wallet.hardwareWallets.includes('ledger');
95
+ }
96
+ signMessage(messageToSign) {
97
+ const _super = Object.create(null, {
98
+ signMessage: { get: () => super.signMessage }
99
+ });
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ if (this.isHardwareWalletEnabled) {
102
+ throw new NotSupportedError(`Message signing is currently not supported on ${this.name} hardware wallet.
103
+ You can use signMessageViaTransaction instead to achieve similar functionality
104
+ by signing a transaction with a memo instruction.
105
+ You can read more about it here https://github.com/solana-labs/solana/issues/21366`);
106
+ }
107
+ return _super.signMessage.call(this, messageToSign);
108
+ });
109
+ }
110
+ proveOwnership(messageToSign) {
111
+ const _super = Object.create(null, {
112
+ proveOwnership: { get: () => super.proveOwnership }
113
+ });
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ if (this.isHardwareWalletEnabled) {
116
+ const nonce = extractNonce(messageToSign);
117
+ if (!nonce) {
118
+ throw new DynamicError('Nonce missing');
119
+ }
120
+ return this.signMessageViaTransaction(nonce);
121
+ }
122
+ return _super.proveOwnership.call(this, messageToSign);
123
+ });
124
+ }
125
+ signMessageViaTransaction(messageToSign) {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ const address = yield this.getAddress();
128
+ if (!address) {
129
+ throw new DynamicError('Address missing');
130
+ }
131
+ const transaction = this.buildAuthTx(messageToSign);
132
+ transaction.feePayer = new PublicKey(address);
133
+ transaction.recentBlockhash = (yield this.getWalletClient().getLatestBlockhash()).blockhash;
134
+ const signer = yield this.getSigner();
135
+ if (!signer) {
136
+ throw new DynamicError('Signer not found');
137
+ }
138
+ const signedTransaction = yield signer.signTransaction(transaction);
139
+ const serializedSignedTransaction = signedTransaction.serialize();
140
+ /**
141
+ * Serializing the transaction and adding the type 'Buffer' is required
142
+ * when connecting with backpack + Ledger, because the returned object is not correctly
143
+ * serialized
144
+ */
145
+ return JSON.stringify({
146
+ signedTransaction: {
147
+ data: Array.from(serializedSignedTransaction),
148
+ type: 'Buffer',
149
+ },
150
+ });
151
+ });
152
+ }
153
+ buildAuthTx(message) {
154
+ const transaction = new Transaction();
155
+ transaction.add(new TransactionInstruction({
156
+ data: Buffer.from(message, 'utf8'),
157
+ keys: [],
158
+ programId: MEMO_PROGRAM_ID,
159
+ }));
160
+ return transaction;
161
+ }
162
+ setVerifiedCredentials(verifiedCredentials) {
163
+ this.verifiedCredentials = verifiedCredentials;
164
+ }
165
+ isLedgerAddress(address) {
166
+ return isLedgerAddressViaVerifiedCredentials(address, this.verifiedCredentials);
167
+ }
168
+ }
169
+
170
+ export { SolWalletConnector };
package/src/types.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ import { Connection, SendOptions, Signer, Transaction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
2
+ import EventEmitter from 'eventemitter3';
3
+ import { ProviderCondition } from '@dynamic-labs/wallet-connector-core';
4
+ declare global {
5
+ interface IWindowPhantom {
6
+ solana: ISolana;
7
+ }
8
+ interface Window {
9
+ coinbaseSolana?: ICoinbaseSolanaSigner;
10
+ glowSolana?: ISolana;
11
+ phantom?: IWindowPhantom;
12
+ solana?: ISolana;
13
+ solflare?: ISolana;
14
+ backpack?: IBackpackSolanaSigner;
15
+ magicEden?: {
16
+ solana: ISolana;
17
+ };
18
+ }
19
+ }
20
+ type PublicKey = {
21
+ toString: () => string;
22
+ };
23
+ export type ConnectionResult = {
24
+ address?: string;
25
+ publicKey?: PublicKey;
26
+ } | undefined;
27
+ interface ISolanaEvents {
28
+ connect(...args: unknown[]): unknown;
29
+ disconnect(...args: unknown[]): unknown;
30
+ accountChanged(publicKey: string): unknown;
31
+ activeWalletDidChange(publicKey: string): unknown;
32
+ }
33
+ export type SignedMessage = {
34
+ signature: Uint8Array;
35
+ };
36
+ export type ISolanaSigner = {
37
+ [key in ExtensionLocator]: boolean;
38
+ } & EventEmitter<ISolanaEvents> & {
39
+ publicKey?: {
40
+ toBytes(): Uint8Array;
41
+ };
42
+ isConnected: boolean;
43
+ providers: ISolanaSigner[];
44
+ signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
45
+ signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
46
+ signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<{
47
+ signature: TransactionSignature;
48
+ }>;
49
+ signMessage(message: Uint8Array, encoding?: string): Promise<SignedMessage>;
50
+ connect: (args?: {
51
+ onlyIfTrusted: boolean;
52
+ }) => Promise<ConnectionResult>;
53
+ disconnect(): Promise<void>;
54
+ };
55
+ type BackpackSolanaSignerResponse = {
56
+ signature: Uint8Array;
57
+ };
58
+ export type IBackpackSolanaSigner = Omit<ISolanaSigner, 'signMessage'> & {
59
+ signMessage: (message: Uint8Array, encoding?: string) => Promise<void | BackpackSolanaSignerResponse | Uint8Array>;
60
+ send: (transaction: Transaction, signers?: Signer[], options?: SendOptions, connection?: Connection, publicKey?: PublicKey) => Promise<TransactionSignature>;
61
+ };
62
+ export type ICoinbaseSolanaSigner = Omit<ISolanaSigner, 'signMessage'> & {
63
+ signMessage: (message: Uint8Array, publicKey?: string) => Promise<void | Uint8Array>;
64
+ };
65
+ export type ISolana = ISolanaSigner | IBackpackSolanaSigner | ICoinbaseSolanaSigner;
66
+ export type ExtensionLocator = 'isBraveWallet' | 'isGlow' | 'isPhantom' | 'isSolflare' | 'isExodus' | 'isBackpack' | 'isMagicEden';
67
+ export type EthProviderCondition = ProviderCondition<ExtensionLocator>;
68
+ export {};
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const extractNonce = (messageToSign) => {
7
+ const regex = messageToSign.match(/Nonce: (.*)/);
8
+ if (regex && regex.length === 2) {
9
+ return regex[1];
10
+ }
11
+ return undefined;
12
+ };
13
+
14
+ exports.extractNonce = extractNonce;
@@ -0,0 +1 @@
1
+ export declare const extractNonce: (messageToSign: string) => string | undefined;
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ const extractNonce = (messageToSign) => {
3
+ const regex = messageToSign.match(/Nonce: (.*)/);
4
+ if (regex && regex.length === 2) {
5
+ return regex[1];
6
+ }
7
+ return undefined;
8
+ };
9
+
10
+ export { extractNonce };
@@ -0,0 +1,29 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var app = require('@wallet-standard/app');
7
+ var utils = require('@dynamic-labs/utils');
8
+
9
+ const findWalletProviderFromWalletStandard = (injectConfig) => {
10
+ const { walletStandardLocators } = injectConfig;
11
+ if (!walletStandardLocators || walletStandardLocators.length === 0) {
12
+ return undefined;
13
+ }
14
+ const wallets = app.getWallets().get();
15
+ return walletStandardLocators.reduce((provider, walletStandardLocator) => {
16
+ /**
17
+ * Return early if the provider is already found
18
+ */
19
+ if (provider) {
20
+ return provider;
21
+ }
22
+ const wallet = wallets.find((w) => w.name === walletStandardLocator.name);
23
+ if (!wallet)
24
+ return undefined;
25
+ return utils.get(wallet, walletStandardLocator.locator);
26
+ }, undefined);
27
+ };
28
+
29
+ exports.findWalletProviderFromWalletStandard = findWalletProviderFromWalletStandard;
@@ -0,0 +1,3 @@
1
+ import { WalletSchema } from '@dynamic-labs/wallet-book';
2
+ import { ISolana } from '../../types';
3
+ export declare const findWalletProviderFromWalletStandard: (injectConfig: NonNullable<WalletSchema['injectedConfig']>[number]) => ISolana | undefined;
@@ -0,0 +1,25 @@
1
+ 'use client'
2
+ import { getWallets } from '@wallet-standard/app';
3
+ import { get } from '@dynamic-labs/utils';
4
+
5
+ const findWalletProviderFromWalletStandard = (injectConfig) => {
6
+ const { walletStandardLocators } = injectConfig;
7
+ if (!walletStandardLocators || walletStandardLocators.length === 0) {
8
+ return undefined;
9
+ }
10
+ const wallets = getWallets().get();
11
+ return walletStandardLocators.reduce((provider, walletStandardLocator) => {
12
+ /**
13
+ * Return early if the provider is already found
14
+ */
15
+ if (provider) {
16
+ return provider;
17
+ }
18
+ const wallet = wallets.find((w) => w.name === walletStandardLocator.name);
19
+ if (!wallet)
20
+ return undefined;
21
+ return get(wallet, walletStandardLocator.locator);
22
+ }, undefined);
23
+ };
24
+
25
+ export { findWalletProviderFromWalletStandard };
@@ -0,0 +1 @@
1
+ export { findWalletProviderFromWalletStandard } from './findWalletProviderFromWalletStandard';
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var contants = require('../contants.cjs');
7
+
8
+ const getGenesisHashLSKey = (rpcEndpoint) => `${rpcEndpoint}_${contants.SOLANA_GENESIS_HASH}`;
9
+
10
+ exports.getGenesisHashLSKey = getGenesisHashLSKey;
@@ -0,0 +1 @@
1
+ export declare const getGenesisHashLSKey: (rpcEndpoint: string) => string;
@@ -0,0 +1,6 @@
1
+ 'use client'
2
+ import { SOLANA_GENESIS_HASH } from '../contants.js';
3
+
4
+ const getGenesisHashLSKey = (rpcEndpoint) => `${rpcEndpoint}_${SOLANA_GENESIS_HASH}`;
5
+
6
+ export { getGenesisHashLSKey };
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isBackpackSolanaSigner = (signer) => Boolean(signer) && signer.send !== undefined;
7
+
8
+ exports.isBackpackSolanaSigner = isBackpackSolanaSigner;
@@ -0,0 +1,2 @@
1
+ import { IBackpackSolanaSigner, ISolana } from '../types';
2
+ export declare const isBackpackSolanaSigner: (signer: ISolana) => signer is IBackpackSolanaSigner;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isBackpackSolanaSigner = (signer) => Boolean(signer) && signer.send !== undefined;
3
+
4
+ export { isBackpackSolanaSigner };
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isSignedMessage = (message) => Boolean(message) && message.signature !== undefined;
7
+
8
+ exports.isSignedMessage = isSignedMessage;
@@ -0,0 +1,2 @@
1
+ import { SignedMessage } from '../types';
2
+ export declare const isSignedMessage: (message: SignedMessage | Uint8Array) => message is SignedMessage;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isSignedMessage = (message) => Boolean(message) && message.signature !== undefined;
3
+
4
+ export { isSignedMessage };
@@ -0,0 +1,33 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../_virtual/_tslib.cjs');
7
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
+
9
+ class SolanaWallet extends walletConnectorCore.Wallet {
10
+ /**
11
+ * Retrieves the RPC connection
12
+ * @returns A promise that resolves to the RPC connection
13
+ */
14
+ getConnnection() {
15
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
16
+ yield this.sync();
17
+ return this._connector.getWalletClient();
18
+ });
19
+ }
20
+ /**
21
+ * Retrieves the solana signer for the wallet.
22
+ * @returns A promise that resolves to the signer,
23
+ * or undefined if the signer cannot be retrieved.
24
+ */
25
+ getSigner() {
26
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
27
+ yield this.sync();
28
+ return this._connector.getSigner();
29
+ });
30
+ }
31
+ }
32
+
33
+ exports.SolanaWallet = SolanaWallet;
@@ -0,0 +1,17 @@
1
+ import { Connection } from '@solana/web3.js';
2
+ import { Wallet } from '@dynamic-labs/wallet-connector-core';
3
+ import { SolWalletConnector } from '../solWalletConnector';
4
+ import { ISolana } from '../types';
5
+ export declare class SolanaWallet extends Wallet<SolWalletConnector> {
6
+ /**
7
+ * Retrieves the RPC connection
8
+ * @returns A promise that resolves to the RPC connection
9
+ */
10
+ getConnnection(): Promise<Connection>;
11
+ /**
12
+ * Retrieves the solana signer for the wallet.
13
+ * @returns A promise that resolves to the signer,
14
+ * or undefined if the signer cannot be retrieved.
15
+ */
16
+ getSigner(): Promise<ISolana | undefined>;
17
+ }
@@ -0,0 +1,29 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../_virtual/_tslib.js';
3
+ import { Wallet } from '@dynamic-labs/wallet-connector-core';
4
+
5
+ class SolanaWallet extends Wallet {
6
+ /**
7
+ * Retrieves the RPC connection
8
+ * @returns A promise that resolves to the RPC connection
9
+ */
10
+ getConnnection() {
11
+ return __awaiter(this, void 0, void 0, function* () {
12
+ yield this.sync();
13
+ return this._connector.getWalletClient();
14
+ });
15
+ }
16
+ /**
17
+ * Retrieves the solana signer for the wallet.
18
+ * @returns A promise that resolves to the signer,
19
+ * or undefined if the signer cannot be retrieved.
20
+ */
21
+ getSigner() {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ yield this.sync();
24
+ return this._connector.getSigner();
25
+ });
26
+ }
27
+ }
28
+
29
+ export { SolanaWallet };
@@ -0,0 +1,2 @@
1
+ export * from './SolanaWallet';
2
+ export * from './isSolanaWallet';
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isSolanaWallet = (wallet) => wallet.chain === 'SOL';
7
+
8
+ exports.isSolanaWallet = isSolanaWallet;
@@ -0,0 +1,3 @@
1
+ import { Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ import { SolanaWallet } from './SolanaWallet';
3
+ export declare const isSolanaWallet: (wallet: Wallet) => wallet is SolanaWallet;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isSolanaWallet = (wallet) => wallet.chain === 'SOL';
3
+
4
+ export { isSolanaWallet };