@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 +87 -59
- package/dist/index.d.mts +89 -421
- package/dist/index.d.ts +89 -421
- package/dist/index.js +360 -685
- package/dist/index.mjs +360 -688
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,101 +1,129 @@
|
|
|
1
1
|
# @adelos/sdk
|
|
2
2
|
|
|
3
|
-
Adelos Protocol
|
|
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
|
|
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
|
|
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
|
-
//
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
###
|
|
29
|
+
### AdelosSDK
|
|
33
30
|
|
|
34
|
-
#### Constructor
|
|
31
|
+
#### Constructor Options
|
|
35
32
|
|
|
36
33
|
```typescript
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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)` |
|
|
48
|
-
| `getMetaPubkey(owner)` |
|
|
49
|
-
| `isRegistered(owner)` |
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
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
|
-
|
|
53
|
+
### Crypto Functions
|
|
56
54
|
|
|
57
55
|
```typescript
|
|
58
|
-
import {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
66
|
-
// Generate encryption keypair
|
|
67
|
-
const metaPubkey = crypto.getRandomValues(new Uint8Array(32));
|
|
74
|
+
### Indexer
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
```typescript
|
|
77
|
+
import { AdelosIndexer } from "@adelos/sdk";
|
|
71
78
|
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
const indexer = new AdelosIndexer({
|
|
80
|
+
rpcUrl: "https://api.devnet.solana.com",
|
|
81
|
+
heliusApiKey: "your-api-key" // Optional
|
|
82
|
+
});
|
|
74
83
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
// Scan for incoming stealth transfers
|
|
85
|
+
const transfers = await indexer.scanForStealthTransfers(
|
|
86
|
+
metaSecretKey,
|
|
87
|
+
metaPublicKey,
|
|
88
|
+
100 // limit
|
|
89
|
+
);
|
|
79
90
|
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
// Real-time scanning
|
|
92
|
+
indexer.onTransaction = (tx) => console.log("Received:", tx);
|
|
93
|
+
indexer.startScanning(metaSk, metaPubkey);
|
|
82
94
|
```
|
|
83
95
|
|
|
84
|
-
|
|
96
|
+
### Light Protocol (ZK-Compression)
|
|
85
97
|
|
|
86
98
|
```typescript
|
|
87
|
-
import {
|
|
99
|
+
import { LightClient } from "@adelos/sdk";
|
|
88
100
|
|
|
89
|
-
|
|
90
|
-
const [pda, bump] = deriveRegistryPda(ownerPubkey);
|
|
101
|
+
const light = LightClient.create("https://zk-rpc-endpoint.com");
|
|
91
102
|
|
|
92
|
-
//
|
|
93
|
-
const
|
|
103
|
+
// Get compressed balance
|
|
104
|
+
const balance = await light.getCompressedSolBalance(owner);
|
|
94
105
|
|
|
95
|
-
//
|
|
96
|
-
const
|
|
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
|