@adelos/sdk 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,101 +1,129 @@
1
1
  # @adelos/sdk
2
2
 
3
- Adelos Protocol SDK - Privacy Identity Registry on Solana
3
+ TypeScript SDK for Adelos Protocol - Privacy Stealth Transfers on Solana.
4
4
 
5
- ## Installation
5
+ ## 📦 Installation
6
6
 
7
7
  ```bash
8
- npm install @adelos/sdk @solana/web3.js
8
+ npm install @adelos/sdk
9
9
  ```
10
10
 
11
- ## Quick Start
11
+ ## 🚀 Quick Start
12
12
 
13
13
  ```typescript
14
- import { AdelosSDK } from "@adelos/sdk";
15
- import { Keypair, Connection } from "@solana/web3.js";
14
+ import { AdelosSDK, generateStealthAddress } from "@adelos/sdk";
16
15
 
17
- // Initialize SDK
18
- const sdk = new AdelosSDK({
19
- rpcUrl: "https://api.devnet.solana.com",
20
- });
16
+ // Initialize with cluster
17
+ const sdk = new AdelosSDK({ cluster: "devnet" });
21
18
 
22
- // Check if user is registered
23
- const isRegistered = await sdk.isRegistered(walletPubkey);
24
-
25
- // Get meta pubkey (encryption key)
26
- const metaPubkey = await sdk.getMetaPubkey(walletPubkey);
27
- console.log("Meta Pubkey:", metaPubkey);
19
+ // Or with custom RPC (Helius, QuickNode)
20
+ const sdk = new AdelosSDK({
21
+ cluster: "devnet",
22
+ rpcUrl: "https://your-rpc-endpoint.com",
23
+ heliusApiKey: "your-helius-api-key" // Optional, for webhooks
24
+ });
28
25
  ```
29
26
 
30
- ## API Reference
27
+ ## 📖 API Reference
31
28
 
32
- ### `AdelosSDK`
29
+ ### AdelosSDK
33
30
 
34
- #### Constructor
31
+ #### Constructor Options
35
32
 
36
33
  ```typescript
37
- const sdk = new AdelosSDK({
38
- rpcUrl?: string, // Default: "https://api.devnet.solana.com"
39
- programId?: PublicKey,
40
- });
34
+ interface AdelosOptions {
35
+ cluster?: "devnet" | "mainnet-beta" | "localnet";
36
+ rpcUrl?: string; // Custom RPC URL
37
+ heliusApiKey?: string; // For indexer webhooks
38
+ }
41
39
  ```
42
40
 
43
41
  #### Methods
44
42
 
45
43
  | Method | Description |
46
44
  |--------|-------------|
47
- | `getRegistry(owner)` | Gets full registry info for an owner |
48
- | `getMetaPubkey(owner)` | Gets just the meta pubkey |
49
- | `isRegistered(owner)` | Checks if owner has registered |
50
- | `createRegisterTransaction(owner, metaPubkey)` | Creates unsigned register tx |
51
- | `createUpdateTransaction(owner, newMetaPubkey)` | Creates unsigned update tx |
52
- | `createCloseTransaction(owner)` | Creates unsigned close tx |
53
- | `sendAndConfirm(signedTx)` | Sends and confirms transaction |
45
+ | `getRegistry(owner)` | Fetch registry account |
46
+ | `getMetaPubkey(owner)` | Get meta pubkey for stealth derivation |
47
+ | `isRegistered(owner)` | Check if owner has registry |
48
+ | `createRegisterTransactionV0(owner, metaPubkey)` | Create register tx (v0) |
49
+ | `createUpdateTransactionV0(owner, newMetaPubkey)` | Create update tx (v0) |
50
+ | `createCloseTransactionV0(owner)` | Create close tx (v0) |
51
+ | `sendAndConfirmV0(signedTx)` | Send versioned transaction |
54
52
 
55
- ## Usage with Wallet Adapter
53
+ ### Crypto Functions
56
54
 
57
55
  ```typescript
58
- import { useWallet } from "@solana/wallet-adapter-react";
59
- import { AdelosSDK } from "@adelos/sdk";
60
-
61
- function RegisterButton() {
62
- const { publicKey, signTransaction } = useWallet();
63
- const sdk = new AdelosSDK();
56
+ import {
57
+ generateStealthAddress,
58
+ generateEphemeralKeypair,
59
+ computeSharedSecret,
60
+ deriveStealthPubkey,
61
+ recoverStealthSecretKey,
62
+ parseStealthMemo
63
+ } from "@adelos/sdk";
64
+
65
+ // Generate stealth address for recipient
66
+ const { stealthPubkey, memo } = await generateStealthAddress(recipientMetaPubkey);
67
+
68
+ // Recipient scans for their transactions
69
+ const ephemeralPubkey = parseStealthMemo(memo);
70
+ const sharedSecret = await computeSharedSecretAsRecipient(metaSk, ephemeralPubkey);
71
+ const stealthSk = recoverStealthSecretKey(metaSk, sharedSecret);
72
+ ```
64
73
 
65
- const handleRegister = async () => {
66
- // Generate encryption keypair
67
- const metaPubkey = crypto.getRandomValues(new Uint8Array(32));
74
+ ### Indexer
68
75
 
69
- // Create transaction
70
- const tx = await sdk.createRegisterTransaction(publicKey!, metaPubkey);
76
+ ```typescript
77
+ import { AdelosIndexer } from "@adelos/sdk";
71
78
 
72
- // Sign with wallet
73
- const signedTx = await signTransaction!(tx);
79
+ const indexer = new AdelosIndexer({
80
+ rpcUrl: "https://api.devnet.solana.com",
81
+ heliusApiKey: "your-api-key" // Optional
82
+ });
74
83
 
75
- // Send
76
- const signature = await sdk.sendAndConfirm(signedTx);
77
- console.log("Registered!", signature);
78
- };
84
+ // Scan for incoming stealth transfers
85
+ const transfers = await indexer.scanForStealthTransfers(
86
+ metaSecretKey,
87
+ metaPublicKey,
88
+ 100 // limit
89
+ );
79
90
 
80
- return <button onClick={handleRegister}>Register Identity</button>;
81
- }
91
+ // Real-time scanning
92
+ indexer.onTransaction = (tx) => console.log("Received:", tx);
93
+ indexer.startScanning(metaSk, metaPubkey);
82
94
  ```
83
95
 
84
- ## Utility Functions
96
+ ### Light Protocol (ZK-Compression)
85
97
 
86
98
  ```typescript
87
- import { deriveRegistryPda, bytesToHex, hexToBytes } from "@adelos/sdk";
99
+ import { LightClient } from "@adelos/sdk";
88
100
 
89
- // Derive PDA
90
- const [pda, bump] = deriveRegistryPda(ownerPubkey);
101
+ const light = LightClient.create("https://zk-rpc-endpoint.com");
91
102
 
92
- // Convert bytes to hex
93
- const hex = bytesToHex(metaPubkey);
103
+ // Get compressed balance
104
+ const balance = await light.getCompressedSolBalance(owner);
94
105
 
95
- // Convert hex to bytes
96
- const bytes = hexToBytes("0101010101...");
106
+ // Create stealth compressed transfer
107
+ const tx = await light.createStealthCompressedTransfer(
108
+ sender,
109
+ stealthPubkey,
110
+ amount,
111
+ memo
112
+ );
113
+ ```
114
+
115
+ ## 🔗 Constants
116
+
117
+ ```typescript
118
+ import {
119
+ PROGRAM_IDS, // Program ID per cluster
120
+ RPC_URLS, // Default RPC URLs
121
+ MEMO_PROGRAM_ID, // Solana Memo Program
122
+ MEMO_PREFIX, // "ADLSv1:"
123
+ STEALTH_DOMAIN // "adelos:stealth:v1"
124
+ } from "@adelos/sdk";
97
125
  ```
98
126
 
99
- ## License
127
+ ## 📄 License
100
128
 
101
129
  MIT