@reown/appkit-solana-react-native 0.0.0-chore-bump-builder-20250728194329

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/lib/commonjs/adapter.js +211 -0
  2. package/lib/commonjs/adapter.js.map +1 -0
  3. package/lib/commonjs/connectors/PhantomConnector.js +244 -0
  4. package/lib/commonjs/connectors/PhantomConnector.js.map +1 -0
  5. package/lib/commonjs/helpers.js +102 -0
  6. package/lib/commonjs/helpers.js.map +1 -0
  7. package/lib/commonjs/index.js +20 -0
  8. package/lib/commonjs/index.js.map +1 -0
  9. package/lib/commonjs/package.json +1 -0
  10. package/lib/commonjs/providers/PhantomProvider.js +391 -0
  11. package/lib/commonjs/providers/PhantomProvider.js.map +1 -0
  12. package/lib/commonjs/types.js +6 -0
  13. package/lib/commonjs/types.js.map +1 -0
  14. package/lib/commonjs/utils/createSendTransaction.js +44 -0
  15. package/lib/commonjs/utils/createSendTransaction.js.map +1 -0
  16. package/lib/module/adapter.js +205 -0
  17. package/lib/module/adapter.js.map +1 -0
  18. package/lib/module/connectors/PhantomConnector.js +238 -0
  19. package/lib/module/connectors/PhantomConnector.js.map +1 -0
  20. package/lib/module/helpers.js +95 -0
  21. package/lib/module/helpers.js.map +1 -0
  22. package/lib/module/index.js +10 -0
  23. package/lib/module/index.js.map +1 -0
  24. package/lib/module/providers/PhantomProvider.js +385 -0
  25. package/lib/module/providers/PhantomProvider.js.map +1 -0
  26. package/lib/module/types.js +4 -0
  27. package/lib/module/types.js.map +1 -0
  28. package/lib/module/utils/createSendTransaction.js +41 -0
  29. package/lib/module/utils/createSendTransaction.js.map +1 -0
  30. package/lib/typescript/adapter.d.ts +23 -0
  31. package/lib/typescript/adapter.d.ts.map +1 -0
  32. package/lib/typescript/connectors/PhantomConnector.d.ts +27 -0
  33. package/lib/typescript/connectors/PhantomConnector.d.ts.map +1 -0
  34. package/lib/typescript/helpers.d.ts +31 -0
  35. package/lib/typescript/helpers.d.ts.map +1 -0
  36. package/lib/typescript/index.d.ts +4 -0
  37. package/lib/typescript/index.d.ts.map +1 -0
  38. package/lib/typescript/providers/PhantomProvider.d.ts +37 -0
  39. package/lib/typescript/providers/PhantomProvider.d.ts.map +1 -0
  40. package/lib/typescript/types.d.ts +96 -0
  41. package/lib/typescript/types.d.ts.map +1 -0
  42. package/lib/typescript/utils/createSendTransaction.d.ts +10 -0
  43. package/lib/typescript/utils/createSendTransaction.d.ts.map +1 -0
  44. package/package.json +52 -0
  45. package/readme.md +9 -0
  46. package/src/adapter.ts +248 -0
  47. package/src/connectors/PhantomConnector.ts +329 -0
  48. package/src/helpers.ts +102 -0
  49. package/src/index.ts +8 -0
  50. package/src/providers/PhantomProvider.ts +532 -0
  51. package/src/types.ts +131 -0
  52. package/src/utils/createSendTransaction.ts +57 -0
@@ -0,0 +1,96 @@
1
+ import type { CaipNetworkId, Namespaces, Storage, WalletInfo } from '@reown/appkit-common-react-native';
2
+ import type nacl from 'tweetnacl';
3
+ export interface TokenInfo {
4
+ address: string;
5
+ symbol: string;
6
+ name: string;
7
+ decimals: number;
8
+ logoURI?: string;
9
+ }
10
+ export type PhantomCluster = 'mainnet-beta' | 'testnet' | 'devnet';
11
+ export interface PhantomProviderConfig {
12
+ appScheme: string;
13
+ dappUrl: string;
14
+ storage: Storage;
15
+ dappEncryptionKeyPair: nacl.BoxKeyPair;
16
+ }
17
+ export type PhantomConnectResult = PhantomSession;
18
+ export interface PhantomSession {
19
+ sessionToken: string;
20
+ userPublicKey: string;
21
+ phantomEncryptionPublicKeyBs58: string;
22
+ cluster: PhantomCluster;
23
+ }
24
+ export interface SignTransactionRequestParams {
25
+ transaction: string;
26
+ }
27
+ export interface SignMessageRequestParams {
28
+ message: Uint8Array | string;
29
+ display?: 'utf8' | 'hex';
30
+ }
31
+ export interface SignAllTransactionsRequestParams {
32
+ transactions: string[];
33
+ }
34
+ export interface PhantomDeeplinkResponse {
35
+ phantom_encryption_public_key?: string;
36
+ nonce: string;
37
+ data: string;
38
+ }
39
+ export interface DecryptedConnectData {
40
+ public_key: string;
41
+ session: string;
42
+ }
43
+ export interface PhantomProviderConfig {
44
+ appScheme: string;
45
+ dappUrl: string;
46
+ storage: Storage;
47
+ dappEncryptionKeyPair: nacl.BoxKeyPair;
48
+ }
49
+ export interface PhantomSession {
50
+ sessionToken: string;
51
+ userPublicKey: string;
52
+ phantomEncryptionPublicKeyBs58: string;
53
+ cluster: PhantomCluster;
54
+ }
55
+ export type PhantomRpcMethod = 'connect' | 'disconnect' | 'signTransaction' | 'signAndSendTransaction' | 'signAllTransactions' | 'signMessage';
56
+ export interface PhantomSignTransactionParams {
57
+ dapp_encryption_public_key: string;
58
+ redirect_link: string;
59
+ payload: string;
60
+ nonce: string;
61
+ cluster?: PhantomCluster;
62
+ }
63
+ export interface PhantomSignAllTransactionsParams {
64
+ dapp_encryption_public_key: string;
65
+ redirect_link: string;
66
+ payload: string;
67
+ nonce: string;
68
+ cluster?: PhantomCluster;
69
+ }
70
+ export interface PhantomSignMessageParams {
71
+ dapp_encryption_public_key: string;
72
+ redirect_link: string;
73
+ payload: string;
74
+ nonce: string;
75
+ }
76
+ export interface PhantomConnectParams {
77
+ app_url: string;
78
+ dapp_encryption_public_key: string;
79
+ redirect_link: string;
80
+ cluster?: PhantomCluster;
81
+ }
82
+ export interface PhantomDisconnectParams {
83
+ dapp_encryption_public_key: string;
84
+ redirect_link: string;
85
+ payload: string;
86
+ nonce: string;
87
+ }
88
+ export interface PhantomConnectorConfig {
89
+ cluster?: PhantomCluster;
90
+ }
91
+ export interface PhantomConnectorSessionData {
92
+ namespaces: Namespaces;
93
+ wallet: WalletInfo;
94
+ currentCaipNetworkId: CaipNetworkId;
95
+ }
96
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EAC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,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,oBAAoB,EAAE,aAAa,CAAC;CACrC"}
@@ -0,0 +1,10 @@
1
+ import { type Connection, Transaction } from '@solana/web3.js';
2
+ type SendTransactionArgs = {
3
+ connection: Connection;
4
+ fromAddress: string;
5
+ toAddress: string;
6
+ value: number;
7
+ };
8
+ export declare function createSendTransaction({ fromAddress, toAddress, value, connection }: SendTransactionArgs): Promise<Transaction>;
9
+ export {};
10
+ //# sourceMappingURL=createSendTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSendTransaction.d.ts","sourceRoot":"","sources":["../../../src/utils/createSendTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAIf,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAIzB,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAWF,wBAAsB,qBAAqB,CAAC,EAC1C,WAAW,EACX,SAAS,EACT,KAAK,EACL,UAAU,EACX,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAwB5C"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@reown/appkit-solana-react-native",
3
+ "version": "0.0.0-chore-bump-builder-20250728194329",
4
+ "main": "lib/commonjs/index.js",
5
+ "types": "lib/typescript/index.d.ts",
6
+ "module": "lib/module/index.js",
7
+ "react-native": "src/index.ts",
8
+ "source": "src/index.ts",
9
+ "scripts": {
10
+ "build": "bob build",
11
+ "clean": "rm -rf lib",
12
+ "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
13
+ },
14
+ "files": [
15
+ "src",
16
+ "lib",
17
+ "!**/__tests__",
18
+ "!**/__fixtures__",
19
+ "!**/__mocks__"
20
+ ],
21
+ "keywords": [
22
+ "web3",
23
+ "crypto",
24
+ "solana",
25
+ "appkit",
26
+ "reown",
27
+ "walletconnect",
28
+ "react-native"
29
+ ],
30
+ "repository": "https://github.com/reown-com/appkit-react-native",
31
+ "author": "Reown (https://discord.gg/reown)",
32
+ "homepage": "https://reown.com/appkit",
33
+ "license": "Apache-2.0",
34
+ "bugs": {
35
+ "url": "https://github.com/reown-com/appkit-react-native/issues"
36
+ },
37
+ "publishConfig": {
38
+ "registry": "https://registry.npmjs.org/",
39
+ "access": "public"
40
+ },
41
+ "dependencies": {
42
+ "@reown/appkit-common-react-native": "0.0.0-chore-bump-builder-20250728194329",
43
+ "@solana/web3.js": "1.98.2",
44
+ "bs58": "6.0.0",
45
+ "tweetnacl": "1.0.3"
46
+ },
47
+ "peerDependencies": {
48
+ "@walletconnect/react-native-compat": ">=2.16.1",
49
+ "react": ">=18",
50
+ "react-native": ">=0.72"
51
+ }
52
+ }
package/readme.md ADDED
@@ -0,0 +1,9 @@
1
+ #### 📚 [Documentation](https://docs.reown.com/appkit/react-native/core/installation)
2
+
3
+ #### 🔎 [Examples](https://github.com/reown-com/react-native-examples)
4
+
5
+ #### 🔗 [Website](https://reown.com/appkit)
6
+
7
+ # AppKit
8
+
9
+ Your on-ramp to web3 multichain. AppKit is a versatile library that makes it super easy to connect users with your Dapp and start interacting with the blockchain.
package/src/adapter.ts ADDED
@@ -0,0 +1,248 @@
1
+ import {
2
+ SolanaBaseAdapter,
3
+ type AppKitNetwork,
4
+ type CaipAddress,
5
+ type ChainNamespace,
6
+ type GetBalanceParams,
7
+ type GetBalanceResponse
8
+ } from '@reown/appkit-common-react-native';
9
+ import { getSolanaNativeBalance, getSolanaTokenBalance } from './helpers';
10
+ import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';
11
+ import base58 from 'bs58';
12
+ import { createSendTransaction } from './utils/createSendTransaction';
13
+
14
+ export interface SolanaTransactionData {
15
+ fromAddress: string;
16
+ toAddress: string;
17
+ amount: number;
18
+ network?: AppKitNetwork;
19
+ rpcUrl?: string;
20
+ }
21
+
22
+ export class SolanaAdapter extends SolanaBaseAdapter {
23
+ private static supportedNamespace: ChainNamespace = 'solana';
24
+
25
+ constructor(configParams: { projectId: string }) {
26
+ super({
27
+ projectId: configParams.projectId,
28
+ supportedNamespace: SolanaAdapter.supportedNamespace,
29
+ adapterType: 'solana'
30
+ });
31
+ }
32
+
33
+ async getBalance(params: GetBalanceParams): Promise<GetBalanceResponse> {
34
+ const { network, address, tokens } = params;
35
+
36
+ if (!this.connector) throw new Error('No active connector');
37
+ if (!network) throw new Error('No network provided');
38
+
39
+ const balanceAddress =
40
+ address || this.getAccounts()?.find(account => account.includes(network.id.toString()));
41
+
42
+ if (!balanceAddress) {
43
+ return { amount: '0.00', symbol: 'SOL' };
44
+ }
45
+
46
+ try {
47
+ const rpcUrl = network.rpcUrls?.default?.http?.[0];
48
+ if (!rpcUrl) throw new Error('No RPC URL available');
49
+
50
+ const base58Address = balanceAddress.split(':')[2];
51
+
52
+ if (!base58Address) throw new Error('Invalid balance address');
53
+
54
+ const token = network?.caipNetworkId && tokens?.[network.caipNetworkId]?.address;
55
+ let balance;
56
+
57
+ if (token) {
58
+ const { amount, symbol } = await getSolanaTokenBalance(rpcUrl, base58Address, token);
59
+ balance = {
60
+ amount,
61
+ symbol
62
+ };
63
+ } else {
64
+ const amount = await getSolanaNativeBalance(rpcUrl, base58Address);
65
+ balance = {
66
+ amount: amount.toString(),
67
+ symbol: 'SOL'
68
+ };
69
+ }
70
+
71
+ this.emit('balanceChanged', { address: balanceAddress, balance });
72
+
73
+ return balance;
74
+ } catch (error) {
75
+ return { amount: '0.00', symbol: 'SOL' };
76
+ }
77
+ }
78
+
79
+ async signTransaction<T extends Transaction | VersionedTransaction>(
80
+ transaction: T,
81
+ network?: AppKitNetwork
82
+ ): Promise<T> {
83
+ if (!this.connector) {
84
+ throw new Error('SolanaAdapter:signTransaction - no active connector');
85
+ }
86
+
87
+ if (!network) {
88
+ throw new Error('SolanaAdapter:signTransaction - network is undefined');
89
+ }
90
+
91
+ const provider = this.connector.getProvider();
92
+ if (!provider) {
93
+ throw new Error('SolanaAdapter:signTransaction - provider is undefined');
94
+ }
95
+
96
+ try {
97
+ // Serialize transaction to base64 (following WalletConnect standard)
98
+ const serializedTransaction = Buffer.from(
99
+ new Uint8Array(transaction.serialize({ verifySignatures: false }))
100
+ ).toString('base64');
101
+
102
+ const result = (await provider.request(
103
+ {
104
+ method: 'solana_signTransaction',
105
+ params: {
106
+ transaction: serializedTransaction,
107
+ pubkey: this.getAccounts()?.[0]?.split(':')[2] || ''
108
+ }
109
+ },
110
+ network.caipNetworkId
111
+ )) as { signature?: string; transaction?: string };
112
+
113
+ // Handle different response formats
114
+ if ('signature' in result && result.signature) {
115
+ // Old RPC response format - add signature to transaction
116
+ const decoded = base58.decode(result.signature);
117
+ if (transaction instanceof Transaction && transaction.feePayer) {
118
+ transaction.addSignature(
119
+ transaction.feePayer,
120
+ Buffer.from(decoded) as Buffer & Uint8Array
121
+ );
122
+ }
123
+
124
+ return transaction;
125
+ }
126
+
127
+ if ('transaction' in result && result.transaction) {
128
+ // New response format - deserialize the signed transaction
129
+ const decodedTransaction = Buffer.from(result.transaction, 'base64');
130
+
131
+ if (transaction instanceof VersionedTransaction) {
132
+ return VersionedTransaction.deserialize(new Uint8Array(decodedTransaction)) as T;
133
+ }
134
+
135
+ return Transaction.from(decodedTransaction) as T;
136
+ }
137
+
138
+ throw new Error('SolanaAdapter:signTransaction - invalid response format');
139
+ } catch (error) {
140
+ if (error instanceof Error) {
141
+ throw new Error(`SolanaAdapter:signTransaction - ${error.message}`);
142
+ }
143
+ throw new Error('SolanaAdapter:signTransaction - unknown error occurred');
144
+ }
145
+ }
146
+
147
+ async sendTransaction(data: SolanaTransactionData): Promise<string | null> {
148
+ const { fromAddress, toAddress, amount, network, rpcUrl } = data;
149
+
150
+ if (!this.connector) {
151
+ throw new Error('SolanaAdapter:sendTransaction - no active connector');
152
+ }
153
+
154
+ const provider = this.connector.getProvider();
155
+ if (!provider) {
156
+ throw new Error('SolanaAdapter:sendTransaction - provider is undefined');
157
+ }
158
+
159
+ if (!network) {
160
+ throw new Error('SolanaAdapter:sendTransaction - network is undefined');
161
+ }
162
+
163
+ if (!fromAddress) {
164
+ throw new Error('SolanaAdapter:sendTransaction - fromAddress is undefined');
165
+ }
166
+
167
+ if (!toAddress) {
168
+ throw new Error('SolanaAdapter:sendTransaction - toAddress is undefined');
169
+ }
170
+
171
+ if (!amount || amount <= 0) {
172
+ throw new Error('SolanaAdapter:sendTransaction - amount must be greater than 0');
173
+ }
174
+
175
+ try {
176
+ // Determine RPC URL
177
+ let connectionRpcUrl = rpcUrl;
178
+ if (!connectionRpcUrl && network) {
179
+ connectionRpcUrl = network.rpcUrls?.default?.http?.[0];
180
+ }
181
+ if (!connectionRpcUrl) {
182
+ throw new Error('SolanaAdapter:sendTransaction - no RPC URL available');
183
+ }
184
+
185
+ // Create connection
186
+ const connection = new Connection(connectionRpcUrl, 'confirmed');
187
+
188
+ const transaction = await createSendTransaction({
189
+ connection,
190
+ fromAddress,
191
+ toAddress,
192
+ value: amount
193
+ });
194
+
195
+ // Sign the transaction
196
+ const signedTransaction = await this.signTransaction(transaction, network);
197
+
198
+ // Send the signed transaction
199
+ const signature = await connection.sendRawTransaction(signedTransaction.serialize(), {
200
+ skipPreflight: false,
201
+ preflightCommitment: 'confirmed'
202
+ });
203
+
204
+ if (!signature) {
205
+ throw new Error('SolanaAdapter:sendTransaction - no signature returned');
206
+ }
207
+
208
+ return signature;
209
+ } catch (error) {
210
+ if (error instanceof Error) {
211
+ throw new Error(`SolanaAdapter:sendTransaction - ${error.message}`);
212
+ }
213
+ throw new Error('SolanaAdapter:sendTransaction - unknown error occurred');
214
+ }
215
+ }
216
+
217
+ async switchNetwork(network: AppKitNetwork): Promise<void> {
218
+ if (!this.connector) throw new Error('No active connector');
219
+
220
+ const provider = this.connector.getProvider();
221
+ if (!provider) throw new Error('No active provider');
222
+
223
+ try {
224
+ await this.connector.switchNetwork(network);
225
+
226
+ return;
227
+ } catch (switchError: any) {
228
+ throw switchError;
229
+ }
230
+ }
231
+
232
+ getAccounts(): CaipAddress[] | undefined {
233
+ if (!this.connector) throw new Error('No active connector');
234
+ const namespaces = this.connector.getNamespaces();
235
+
236
+ return namespaces[this.getSupportedNamespace()]?.accounts;
237
+ }
238
+
239
+ disconnect(): Promise<void> {
240
+ if (!this.connector) throw new Error('No active connector');
241
+
242
+ return this.connector.disconnect();
243
+ }
244
+
245
+ getSupportedNamespace(): ChainNamespace {
246
+ return SolanaAdapter.supportedNamespace;
247
+ }
248
+ }