@reown/appkit-solana-react-native 2.0.0 → 2.0.1

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 (75) hide show
  1. package/lib/commonjs/adapter.js +183 -4
  2. package/lib/commonjs/adapter.js.map +1 -1
  3. package/lib/commonjs/connectors/DeeplinkConnector.js +271 -0
  4. package/lib/commonjs/connectors/DeeplinkConnector.js.map +1 -0
  5. package/lib/commonjs/connectors/PhantomConnector.js +18 -226
  6. package/lib/commonjs/connectors/PhantomConnector.js.map +1 -1
  7. package/lib/commonjs/connectors/SolflareConnector.js +39 -0
  8. package/lib/commonjs/connectors/SolflareConnector.js.map +1 -0
  9. package/lib/commonjs/helpers.js +0 -1
  10. package/lib/commonjs/helpers.js.map +1 -1
  11. package/lib/commonjs/index.js +8 -1
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/package.json +1 -0
  14. package/lib/commonjs/providers/DeeplinkProvider.js +432 -0
  15. package/lib/commonjs/providers/DeeplinkProvider.js.map +1 -0
  16. package/lib/commonjs/types.js.map +1 -1
  17. package/lib/commonjs/utils/createSPLTokenTransaction.js +96 -0
  18. package/lib/commonjs/utils/createSPLTokenTransaction.js.map +1 -0
  19. package/lib/commonjs/utils/createSendTransaction.js +30 -0
  20. package/lib/commonjs/utils/createSendTransaction.js.map +1 -0
  21. package/lib/module/adapter.js +184 -4
  22. package/lib/module/adapter.js.map +1 -1
  23. package/lib/module/connectors/DeeplinkConnector.js +265 -0
  24. package/lib/module/connectors/DeeplinkConnector.js.map +1 -0
  25. package/lib/module/connectors/PhantomConnector.js +21 -226
  26. package/lib/module/connectors/PhantomConnector.js.map +1 -1
  27. package/lib/module/connectors/SolflareConnector.js +34 -0
  28. package/lib/module/connectors/SolflareConnector.js.map +1 -0
  29. package/lib/module/helpers.js +2 -1
  30. package/lib/module/helpers.js.map +1 -1
  31. package/lib/module/index.js +7 -4
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/providers/DeeplinkProvider.js +426 -0
  34. package/lib/module/providers/DeeplinkProvider.js.map +1 -0
  35. package/lib/module/types.js +2 -0
  36. package/lib/module/types.js.map +1 -1
  37. package/lib/module/utils/createSPLTokenTransaction.js +92 -0
  38. package/lib/module/utils/createSPLTokenTransaction.js.map +1 -0
  39. package/lib/module/utils/createSendTransaction.js +26 -0
  40. package/lib/module/utils/createSendTransaction.js.map +1 -0
  41. package/lib/typescript/adapter.d.ts +13 -3
  42. package/lib/typescript/adapter.d.ts.map +1 -1
  43. package/lib/typescript/connectors/DeeplinkConnector.d.ts +30 -0
  44. package/lib/typescript/connectors/DeeplinkConnector.d.ts.map +1 -0
  45. package/lib/typescript/connectors/PhantomConnector.d.ts +8 -22
  46. package/lib/typescript/connectors/PhantomConnector.d.ts.map +1 -1
  47. package/lib/typescript/connectors/SolflareConnector.d.ts +12 -0
  48. package/lib/typescript/connectors/SolflareConnector.d.ts.map +1 -0
  49. package/lib/typescript/index.d.ts +3 -2
  50. package/lib/typescript/index.d.ts.map +1 -1
  51. package/lib/typescript/providers/DeeplinkProvider.d.ts +59 -0
  52. package/lib/typescript/providers/DeeplinkProvider.d.ts.map +1 -0
  53. package/lib/typescript/types.d.ts +35 -32
  54. package/lib/typescript/types.d.ts.map +1 -1
  55. package/lib/typescript/utils/createSPLTokenTransaction.d.ts +4 -0
  56. package/lib/typescript/utils/createSPLTokenTransaction.d.ts.map +1 -0
  57. package/lib/typescript/utils/createSendTransaction.d.ts +10 -0
  58. package/lib/typescript/utils/createSendTransaction.d.ts.map +1 -0
  59. package/package.json +13 -5
  60. package/src/adapter.ts +221 -4
  61. package/src/connectors/DeeplinkConnector.ts +353 -0
  62. package/src/connectors/PhantomConnector.ts +19 -311
  63. package/src/connectors/SolflareConnector.ts +36 -0
  64. package/src/index.ts +6 -5
  65. package/src/providers/DeeplinkProvider.ts +605 -0
  66. package/src/types.ts +38 -37
  67. package/src/utils/createSPLTokenTransaction.ts +152 -0
  68. package/src/utils/createSendTransaction.ts +41 -0
  69. package/lib/commonjs/providers/PhantomProvider.js +0 -391
  70. package/lib/commonjs/providers/PhantomProvider.js.map +0 -1
  71. package/lib/module/providers/PhantomProvider.js +0 -383
  72. package/lib/module/providers/PhantomProvider.js.map +0 -1
  73. package/lib/typescript/providers/PhantomProvider.d.ts +0 -37
  74. package/lib/typescript/providers/PhantomProvider.d.ts.map +0 -1
  75. package/src/providers/PhantomProvider.ts +0 -530
@@ -0,0 +1,30 @@
1
+ import { WalletConnector, type AppKitNetwork, type CaipNetworkId, type ChainNamespace, type ConnectOptions, type Namespaces, type ConnectorInitOptions, type ConnectionProperties } from '@reown/appkit-common-react-native';
2
+ import { DeeplinkProvider } from '../providers/DeeplinkProvider';
3
+ import type { DeeplinkConnectorConfig } from '../types';
4
+ export declare abstract class DeeplinkConnector extends WalletConnector {
5
+ private readonly config;
6
+ private currentCaipNetworkId;
7
+ private dappEncryptionKeyPair?;
8
+ private static readonly SUPPORTED_NAMESPACE;
9
+ constructor(config: DeeplinkConnectorConfig);
10
+ protected abstract getBaseUrl(): string;
11
+ protected abstract getStorageKey(): string;
12
+ protected abstract getDappKeypairStorageKey(): string;
13
+ protected abstract getEncryptionKeyFieldName(): string;
14
+ init(ops: ConnectorInitOptions): Promise<void>;
15
+ private initializeKeyPair;
16
+ connect(opts?: ConnectOptions): Promise<Namespaces | undefined>;
17
+ disconnect(): Promise<void>;
18
+ private clearSession;
19
+ getProvider(): DeeplinkProvider;
20
+ private getStorage;
21
+ getNamespaces(): Namespaces;
22
+ getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
23
+ getProperties(): ConnectionProperties | undefined;
24
+ isConnected(): boolean;
25
+ switchNetwork(network: AppKitNetwork): Promise<void>;
26
+ restoreSession(): Promise<boolean>;
27
+ private saveSession;
28
+ private clearSessionStorage;
29
+ }
30
+ //# sourceMappingURL=DeeplinkConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeeplinkConnector.d.ts","sourceRoot":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AAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CpD,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;YA2DnC,WAAW;YAmBX,mBAAmB;CAOlC"}
@@ -1,26 +1,12 @@
1
- import { WalletConnector, type AppKitNetwork, type CaipNetworkId, type ChainNamespace, type ConnectOptions, type Namespaces, type WalletInfo, type ConnectorInitOptions } from '@reown/appkit-common-react-native';
2
- import { PhantomProvider } from '../providers/PhantomProvider';
1
+ import { type WalletInfo } from '@reown/appkit-common-react-native';
2
+ import { DeeplinkConnector } from './DeeplinkConnector';
3
3
  import type { PhantomConnectorConfig } from '../types';
4
- export declare class PhantomConnector extends WalletConnector {
5
- private readonly config;
6
- private currentCaipNetworkId;
7
- private dappEncryptionKeyPair?;
8
- private static readonly SUPPORTED_NAMESPACE;
4
+ export declare class PhantomConnector extends DeeplinkConnector {
9
5
  constructor(config?: PhantomConnectorConfig);
10
- init(ops: ConnectorInitOptions): Promise<void>;
11
- private initializeKeyPair;
12
- connect(opts?: ConnectOptions): Promise<Namespaces | undefined>;
13
- disconnect(): Promise<void>;
14
- private clearSession;
15
- getProvider(): PhantomProvider;
16
- private getStorage;
17
- getNamespaces(): Namespaces;
18
- getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
19
- getWalletInfo(): WalletInfo | undefined;
20
- isConnected(): boolean;
21
- switchNetwork(network: AppKitNetwork): Promise<void>;
22
- restoreSession(): Promise<boolean>;
23
- private saveSession;
24
- private clearSessionStorage;
6
+ getWalletInfo(): WalletInfo;
7
+ protected getBaseUrl(): string;
8
+ protected getStorageKey(): string;
9
+ protected getDappKeypairStorageKey(): string;
10
+ protected getEncryptionKeyFieldName(): string;
25
11
  }
26
12
  //# sourceMappingURL=PhantomConnector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhantomConnector.d.ts","sourceRoot":"","sources":["../../../src/connectors/PhantomConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,aAAa,EAClB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AqB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAMvD,qBAAa,gBAAiB,SAAQ,iBAAiB;gBACzC,MAAM,CAAC,EAAE,sBAAsB;IAIlC,aAAa,IAAI,UAAU;IAOpC,SAAS,CAAC,UAAU,IAAI,MAAM;IAI9B,SAAS,CAAC,aAAa,IAAI,MAAM;IAIjC,SAAS,CAAC,wBAAwB,IAAI,MAAM;IAI5C,SAAS,CAAC,yBAAyB,IAAI,MAAM;CAG9C"}
@@ -0,0 +1,12 @@
1
+ import { type WalletInfo } from '@reown/appkit-common-react-native';
2
+ import { DeeplinkConnector } from './DeeplinkConnector';
3
+ import type { SolflareConnectorConfig } from '../types';
4
+ export declare class SolflareConnector extends DeeplinkConnector {
5
+ constructor(config?: SolflareConnectorConfig);
6
+ getWalletInfo(): WalletInfo;
7
+ protected getBaseUrl(): string;
8
+ protected getStorageKey(): string;
9
+ protected getDappKeypairStorageKey(): string;
10
+ protected getEncryptionKeyFieldName(): string;
11
+ }
12
+ //# sourceMappingURL=SolflareConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SolflareConnector.d.ts","sourceRoot":"","sources":["../../../src/connectors/SolflareConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAMxD,qBAAa,iBAAkB,SAAQ,iBAAiB;gBAC1C,MAAM,CAAC,EAAE,uBAAuB;IAInC,aAAa,IAAI,UAAU;IAOpC,SAAS,CAAC,UAAU,IAAI,MAAM;IAI9B,SAAS,CAAC,aAAa,IAAI,MAAM;IAIjC,SAAS,CAAC,wBAAwB,IAAI,MAAM;IAI5C,SAAS,CAAC,yBAAyB,IAAI,MAAM;CAG9C"}
@@ -1,4 +1,5 @@
1
- export { PhantomConnector } from './connectors/PhantomConnector';
2
- export type { PhantomConnectorConfig } from './types';
3
1
  export { SolanaAdapter } from './adapter';
2
+ export type { PhantomConnectorConfig, SolflareConnectorConfig } from './types';
3
+ export { PhantomConnector } from './connectors/PhantomConnector';
4
+ export { SolflareConnector } from './connectors/SolflareConnector';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,YAAY,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAG/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,59 @@
1
+ /// <reference types="node" />
2
+ import type { Provider, RequestArguments, CaipNetworkId } from '@reown/appkit-common-react-native';
3
+ import type { DeeplinkProviderConfig, DeeplinkConnectResult, DeeplinkSession, Cluster } from '../types';
4
+ import EventEmitter from 'events';
5
+ export declare const SOLANA_SIGNING_METHODS: {
6
+ readonly SOLANA_SIGN_TRANSACTION: "solana_signTransaction";
7
+ readonly SOLANA_SIGN_MESSAGE: "solana_signMessage";
8
+ readonly SOLANA_SIGN_AND_SEND_TRANSACTION: "solana_signAndSendTransaction";
9
+ readonly SOLANA_SIGN_ALL_TRANSACTIONS: "solana_signAllTransactions";
10
+ };
11
+ export declare class DeeplinkProvider extends EventEmitter implements Provider {
12
+ private readonly config;
13
+ private dappEncryptionKeyPair;
14
+ private currentCluster;
15
+ private sharedKey;
16
+ private storage;
17
+ private sessionToken;
18
+ private userPublicKey;
19
+ private walletEncryptionPublicKeyBs58;
20
+ private activeSubscription;
21
+ private isOperationPending;
22
+ constructor(config: DeeplinkProviderConfig);
23
+ private getSessionStorageKey;
24
+ /**
25
+ * Cleanup method to be called when the provider is destroyed
26
+ */
27
+ destroy(): void;
28
+ /**
29
+ * Safely cleanup the active subscription
30
+ */
31
+ private cleanupActiveSubscription;
32
+ /**
33
+ * Safely set a new subscription, ensuring no operation is pending
34
+ */
35
+ private setActiveSubscription;
36
+ getUserPublicKey(): string | null;
37
+ isConnected(): boolean;
38
+ getCurrentCluster(): Cluster;
39
+ private buildUrl;
40
+ /**
41
+ * Open a deeplink URL and wait for a redirect back to the app. Handles subscription
42
+ * lifecycle and common error extraction from `errorCode`/`errorMessage` query params.
43
+ */
44
+ private openDeeplinkAndWait;
45
+ private getRpcMethodName;
46
+ private encryptPayload;
47
+ private decryptPayload;
48
+ restoreSession(): Promise<boolean>;
49
+ private saveSession;
50
+ private clearSessionStorage;
51
+ connect<T = DeeplinkConnectResult>(params?: {
52
+ cluster?: Cluster;
53
+ }): Promise<T>;
54
+ disconnect(): Promise<void>;
55
+ clearSession(): Promise<void>;
56
+ setSession(session: DeeplinkSession): void;
57
+ request<T>(args: RequestArguments, _chainId?: CaipNetworkId): Promise<T>;
58
+ }
59
+ //# sourceMappingURL=DeeplinkProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeeplinkProvider.d.ts","sourceRoot":"","sources":["../../../src/providers/DeeplinkProvider.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EAEd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EAYf,OAAO,EACR,MAAM,UAAU,CAAC;AAClB,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,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,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;CAyKtF"}
@@ -1,5 +1,6 @@
1
1
  import type { CaipNetworkId, Namespaces, Storage, WalletInfo } from '@reown/appkit-common-react-native';
2
2
  import type nacl from 'tweetnacl';
3
+ import type { Connection } from '@solana/web3.js';
3
4
  export interface TokenInfo {
4
5
  address: string;
5
6
  symbol: string;
@@ -7,19 +8,20 @@ export interface TokenInfo {
7
8
  decimals: number;
8
9
  logoURI?: string;
9
10
  }
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 {
11
+ export type SPLTokenTransactionArgs = {
12
+ connection: Connection;
13
+ fromAddress: string;
14
+ toAddress: string;
15
+ amount: number;
16
+ tokenMint: string;
17
+ };
18
+ export type Cluster = 'mainnet-beta' | 'testnet' | 'devnet';
19
+ export type DeeplinkConnectResult = DeeplinkSession;
20
+ export interface DeeplinkSession {
19
21
  sessionToken: string;
20
22
  userPublicKey: string;
21
- phantomEncryptionPublicKeyBs58: string;
22
- cluster: PhantomCluster;
23
+ walletEncryptionPublicKeyBs58: string;
24
+ cluster: Cluster;
23
25
  }
24
26
  export interface SignTransactionRequestParams {
25
27
  transaction: string;
@@ -31,8 +33,8 @@ export interface SignMessageRequestParams {
31
33
  export interface SignAllTransactionsRequestParams {
32
34
  transactions: string[];
33
35
  }
34
- export interface PhantomDeeplinkResponse {
35
- phantom_encryption_public_key?: string;
36
+ export interface DeeplinkResponse {
37
+ wallet_encryption_public_key?: string;
36
38
  nonce: string;
37
39
  data: string;
38
40
  }
@@ -40,57 +42,58 @@ export interface DecryptedConnectData {
40
42
  public_key: string;
41
43
  session: string;
42
44
  }
43
- export interface PhantomProviderConfig {
45
+ export interface DeeplinkProviderConfig {
44
46
  appScheme: string;
45
47
  dappUrl: string;
46
48
  storage: Storage;
49
+ cluster?: Cluster;
47
50
  dappEncryptionKeyPair: nacl.BoxKeyPair;
51
+ type: 'phantom' | 'solflare';
52
+ baseUrl: string;
53
+ encryptionKeyFieldName: string;
48
54
  }
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 {
55
+ export type DeeplinkRpcMethod = 'connect' | 'disconnect' | 'signTransaction' | 'signAndSendTransaction' | 'signAllTransactions' | 'signMessage';
56
+ export interface DeeplinkSignTransactionParams {
57
57
  dapp_encryption_public_key: string;
58
58
  redirect_link: string;
59
59
  payload: string;
60
60
  nonce: string;
61
- cluster?: PhantomCluster;
61
+ cluster?: Cluster;
62
62
  }
63
- export interface PhantomSignAllTransactionsParams {
63
+ export interface DeeplinkSignAllTransactionsParams {
64
64
  dapp_encryption_public_key: string;
65
65
  redirect_link: string;
66
66
  payload: string;
67
67
  nonce: string;
68
- cluster?: PhantomCluster;
68
+ cluster?: Cluster;
69
69
  }
70
- export interface PhantomSignMessageParams {
70
+ export interface DeeplinkSignMessageParams {
71
71
  dapp_encryption_public_key: string;
72
72
  redirect_link: string;
73
73
  payload: string;
74
74
  nonce: string;
75
75
  }
76
- export interface PhantomConnectParams {
76
+ export interface DeeplinkConnectParams {
77
77
  app_url: string;
78
78
  dapp_encryption_public_key: string;
79
79
  redirect_link: string;
80
- cluster?: PhantomCluster;
80
+ cluster?: Cluster;
81
81
  }
82
- export interface PhantomDisconnectParams {
82
+ export interface DeeplinkDisconnectParams {
83
83
  dapp_encryption_public_key: string;
84
84
  redirect_link: string;
85
85
  payload: string;
86
86
  nonce: string;
87
87
  }
88
- export interface PhantomConnectorConfig {
89
- cluster?: PhantomCluster;
88
+ export interface DeeplinkConnectorConfig {
89
+ type: 'phantom' | 'solflare';
90
+ cluster?: Cluster;
90
91
  }
91
- export interface PhantomConnectorSessionData {
92
+ export interface DeeplinkConnectorSessionData {
92
93
  namespaces: Namespaces;
93
94
  wallet: WalletInfo;
94
95
  currentCaipNetworkId: CaipNetworkId;
95
96
  }
97
+ export type PhantomConnectorConfig = Pick<DeeplinkConnectorConfig, 'cluster'>;
98
+ export type SolflareConnectorConfig = Pick<DeeplinkConnectorConfig, 'cluster'>;
96
99
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,OAAO,EACP,UAAU,EACX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEnE,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,qBAAqB,EAAE,IAAI,CAAC,UAAU,CAAC;CACxC;AAED,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,8BAA8B,EAAE,MAAM,CAAC;IACvC,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAA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@@ -0,0 +1,4 @@
1
+ import { Transaction } from '@solana/web3.js';
2
+ import type { SPLTokenTransactionArgs } from '../types';
3
+ export declare function createSPLTokenTransaction({ fromAddress, toAddress, amount, tokenMint, connection }: SPLTokenTransactionArgs): Promise<Transaction>;
4
+ //# sourceMappingURL=createSPLTokenTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSPLTokenTransaction.d.ts","sourceRoot":"","sources":["../../../src/utils/createSPLTokenTransaction.ts"],"names":[],"mappings":"AAUA,OAAO,EAIL,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAyBxD,wBAAsB,yBAAyB,CAAC,EAC9C,WAAW,EACX,SAAS,EACT,MAAM,EACN,SAAS,EACT,UAAU,EACX,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CAuGhD"}
@@ -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
+ amount: number;
7
+ };
8
+ export declare function createSendTransaction({ fromAddress, toAddress, amount, 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,EACL,KAAK,UAAU,EAIf,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,WAAW,EACX,SAAS,EACT,MAAM,EACN,UAAU,EACX,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAoB5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reown/appkit-solana-react-native",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "types": "lib/typescript/index.d.ts",
6
6
  "module": "lib/module/index.js",
@@ -28,19 +28,27 @@
28
28
  "react-native"
29
29
  ],
30
30
  "repository": "https://github.com/reown-com/appkit-react-native",
31
- "author": "Reown <support@reown.com> (https://reown.com)",
31
+ "author": "Reown (https://discord.gg/reown)",
32
32
  "homepage": "https://reown.com/appkit",
33
- "license": "Apache-2.0",
33
+ "license": "SEE LICENSE IN LICENSE.md",
34
34
  "bugs": {
35
35
  "url": "https://github.com/reown-com/appkit-react-native/issues"
36
36
  },
37
37
  "publishConfig": {
38
38
  "registry": "https://registry.npmjs.org/",
39
- "access": "public"
39
+ "access": "public",
40
+ "provenance": true
40
41
  },
41
42
  "dependencies": {
42
- "@reown/appkit-common-react-native": "2.0.0",
43
+ "@reown/appkit-common-react-native": "2.0.1",
44
+ "@solana/spl-token": "0.4.13",
45
+ "@solana/web3.js": "1.98.2",
43
46
  "bs58": "6.0.0",
44
47
  "tweetnacl": "1.0.3"
48
+ },
49
+ "peerDependencies": {
50
+ "@walletconnect/react-native-compat": ">=2.16.1",
51
+ "react": ">=18",
52
+ "react-native": ">=0.72"
45
53
  }
46
54
  }
package/src/adapter.ts CHANGED
@@ -7,14 +7,27 @@ import {
7
7
  type GetBalanceResponse
8
8
  } from '@reown/appkit-common-react-native';
9
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
+ import { createSPLTokenTransaction } from './utils/createSPLTokenTransaction';
14
+
15
+ export interface SolanaTransactionData {
16
+ fromAddress: string;
17
+ toAddress: string;
18
+ amount: number;
19
+ network?: AppKitNetwork;
20
+ rpcUrl?: string;
21
+ tokenMint?: string;
22
+ }
10
23
 
11
24
  export class SolanaAdapter extends SolanaBaseAdapter {
12
25
  private static supportedNamespace: ChainNamespace = 'solana';
13
26
 
14
- constructor(configParams: { projectId: string }) {
27
+ constructor() {
15
28
  super({
16
- projectId: configParams.projectId,
17
- supportedNamespace: SolanaAdapter.supportedNamespace
29
+ supportedNamespace: SolanaAdapter.supportedNamespace,
30
+ adapterType: 'solana'
18
31
  });
19
32
  }
20
33
 
@@ -64,10 +77,214 @@ export class SolanaAdapter extends SolanaBaseAdapter {
64
77
  }
65
78
  }
66
79
 
80
+ async signTransaction<T extends Transaction | VersionedTransaction>(
81
+ transaction: T,
82
+ network?: AppKitNetwork
83
+ ): Promise<T> {
84
+ if (!this.connector) {
85
+ throw new Error('SolanaAdapter:signTransaction - no active connector');
86
+ }
87
+
88
+ if (!network) {
89
+ throw new Error('SolanaAdapter:signTransaction - network is undefined');
90
+ }
91
+
92
+ const provider = this.connector.getProvider('solana');
93
+ if (!provider) {
94
+ throw new Error('SolanaAdapter:signTransaction - provider is undefined');
95
+ }
96
+
97
+ try {
98
+ // Check if this is a deeplink provider (Phantom/Solflare)
99
+ const isDeeplinkProvider =
100
+ this.connector.type === 'phantom' || this.connector.type === 'solflare';
101
+
102
+ // Serialize transaction based on provider type
103
+ let serializedTransaction: string;
104
+ if (isDeeplinkProvider) {
105
+ // Deeplink providers (Phantom/Solflare) expect base58
106
+ const transactionBytes = new Uint8Array(transaction.serialize({ verifySignatures: false }));
107
+ serializedTransaction = base58.encode(transactionBytes);
108
+ } else {
109
+ // WalletConnect providers expect base64 (following WalletConnect standard)
110
+ serializedTransaction = Buffer.from(
111
+ new Uint8Array(transaction.serialize({ verifySignatures: false }))
112
+ ).toString('base64');
113
+ }
114
+
115
+ const result = (await provider.request(
116
+ {
117
+ method: 'solana_signTransaction',
118
+ params: {
119
+ transaction: serializedTransaction,
120
+ pubkey: this.getAccounts()?.[0]?.split(':')[2] || ''
121
+ }
122
+ },
123
+ network.caipNetworkId
124
+ )) as { signature?: string; transaction?: string };
125
+
126
+ // Handle different response formats
127
+ if ('signature' in result && result.signature) {
128
+ // Old RPC response format - add signature to transaction
129
+ const decoded = base58.decode(result.signature);
130
+ if (transaction instanceof Transaction && transaction.feePayer) {
131
+ transaction.addSignature(
132
+ transaction.feePayer,
133
+ Buffer.from(decoded) as Buffer & Uint8Array
134
+ );
135
+ }
136
+
137
+ return transaction;
138
+ }
139
+
140
+ if ('transaction' in result && result.transaction) {
141
+ // New response format - deserialize the signed transaction
142
+ let decodedTransaction: Buffer;
143
+
144
+ if (isDeeplinkProvider) {
145
+ // Deeplink providers return base58 encoded transactions
146
+ try {
147
+ const decodedBytes = base58.decode(result.transaction);
148
+ decodedTransaction = Buffer.from(decodedBytes);
149
+ } catch (error) {
150
+ throw new Error('Failed to decode base58 transaction from deeplink provider');
151
+ }
152
+ } else {
153
+ // WalletConnect providers return base64 encoded transactions
154
+ decodedTransaction = Buffer.from(result.transaction, 'base64');
155
+ }
156
+
157
+ if (transaction instanceof VersionedTransaction) {
158
+ return VersionedTransaction.deserialize(new Uint8Array(decodedTransaction)) as T;
159
+ }
160
+
161
+ return Transaction.from(decodedTransaction) as T;
162
+ }
163
+
164
+ throw new Error('SolanaAdapter:signTransaction - invalid response format');
165
+ } catch (error) {
166
+ if (error instanceof Error) {
167
+ throw new Error(`SolanaAdapter:signTransaction - ${error.message}`);
168
+ }
169
+ throw new Error('SolanaAdapter:signTransaction - unknown error occurred');
170
+ }
171
+ }
172
+
173
+ async sendTransaction(data: SolanaTransactionData): Promise<string | null> {
174
+ const { fromAddress, toAddress, amount, network, rpcUrl, tokenMint } = data;
175
+
176
+ if (!this.connector) {
177
+ throw new Error('SolanaAdapter:sendTransaction - no active connector');
178
+ }
179
+
180
+ const provider = this.connector.getProvider('solana');
181
+ if (!provider) {
182
+ throw new Error('SolanaAdapter:sendTransaction - provider is undefined');
183
+ }
184
+
185
+ if (!network) {
186
+ throw new Error('SolanaAdapter:sendTransaction - network is undefined');
187
+ }
188
+
189
+ if (!fromAddress) {
190
+ throw new Error('SolanaAdapter:sendTransaction - fromAddress is undefined');
191
+ }
192
+
193
+ if (!toAddress) {
194
+ throw new Error('SolanaAdapter:sendTransaction - toAddress is undefined');
195
+ }
196
+
197
+ if (!amount || amount <= 0) {
198
+ throw new Error('SolanaAdapter:sendTransaction - amount must be greater than 0');
199
+ }
200
+
201
+ try {
202
+ // Determine RPC URL
203
+ let connectionRpcUrl = rpcUrl;
204
+ if (!connectionRpcUrl && network) {
205
+ connectionRpcUrl = network.rpcUrls?.default?.http?.[0];
206
+ }
207
+ if (!connectionRpcUrl) {
208
+ throw new Error('SolanaAdapter:sendTransaction - no RPC URL available');
209
+ }
210
+
211
+ // Create connection
212
+ const connection = new Connection(connectionRpcUrl, 'confirmed');
213
+
214
+ const transaction = tokenMint
215
+ ? await createSPLTokenTransaction({
216
+ connection,
217
+ fromAddress,
218
+ toAddress,
219
+ amount,
220
+ tokenMint
221
+ })
222
+ : await createSendTransaction({
223
+ connection,
224
+ fromAddress,
225
+ toAddress,
226
+ amount
227
+ });
228
+
229
+ // Sign the transaction
230
+ const signedTransaction = await this.signTransaction(transaction, network);
231
+
232
+ // Send the signed transaction
233
+ const signature = await connection.sendRawTransaction(signedTransaction.serialize(), {
234
+ skipPreflight: false,
235
+ preflightCommitment: 'confirmed'
236
+ });
237
+
238
+ if (!signature) {
239
+ throw new Error('SolanaAdapter:sendTransaction - no signature returned');
240
+ }
241
+
242
+ return signature;
243
+ } catch (error) {
244
+ if (error instanceof Error) {
245
+ throw new Error(`SolanaAdapter:sendTransaction - ${error.message}`);
246
+ }
247
+ throw new Error('SolanaAdapter:sendTransaction - unknown error occurred');
248
+ }
249
+ }
250
+
251
+ override async signMessage(address: string, message: string, chainId?: string): Promise<string> {
252
+ try {
253
+ if (!this.connector) {
254
+ throw new Error('SolanaAdapter:signMessage - no active connector');
255
+ }
256
+
257
+ const provider = this.connector.getProvider('solana');
258
+ if (!provider) {
259
+ throw new Error('SolanaAdapter:signMessage - provider is undefined');
260
+ }
261
+
262
+ const chain = chainId ? `${this.getSupportedNamespace()}:${chainId}` : undefined;
263
+
264
+ const encodedMessage = new TextEncoder().encode(message);
265
+ const params = {
266
+ message: base58.encode(encodedMessage),
267
+ pubkey: address
268
+ // For Phantom, pubkey is not part of signMessage params directly with session
269
+ // For other wallets, it might be needed if they don't infer from session
270
+ };
271
+ const { signature } = (await provider.request(
272
+ { method: 'solana_signMessage', params },
273
+ chain
274
+ )) as {
275
+ signature: string;
276
+ };
277
+
278
+ return signature;
279
+ } catch (error) {
280
+ throw error;
281
+ }
282
+ }
283
+
67
284
  async switchNetwork(network: AppKitNetwork): Promise<void> {
68
285
  if (!this.connector) throw new Error('No active connector');
69
286
 
70
- const provider = this.connector.getProvider();
287
+ const provider = this.connector.getProvider('solana');
71
288
  if (!provider) throw new Error('No active provider');
72
289
 
73
290
  try {