@adelos/sdk 0.1.1 → 0.1.2

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/dist/index.d.ts CHANGED
@@ -1,4 +1,23 @@
1
- import { PublicKey, Connection, TransactionInstruction, Transaction } from '@solana/web3.js';
1
+ import { PublicKey, Connection, TransactionInstruction, Transaction, VersionedTransaction } from '@solana/web3.js';
2
+
3
+ /** Supported Solana clusters */
4
+ type SolanaCluster = "devnet" | "mainnet-beta" | "localnet";
5
+ /** Program IDs for Adelos Registry per cluster */
6
+ declare const PROGRAM_IDS: Record<SolanaCluster, PublicKey>;
7
+ /** RPC URLs per cluster */
8
+ declare const RPC_URLS: Record<SolanaCluster, string>;
9
+ /** Default Program ID (Devnet) */
10
+ declare const PROGRAM_ID: PublicKey;
11
+ /** Memo Program ID for stealth address scanning */
12
+ declare const MEMO_PROGRAM_ID: PublicKey;
13
+ /** Seed prefix for registry PDA derivation */
14
+ declare const REGISTRY_SEED = "registry";
15
+ /** Size of the registry account in bytes */
16
+ declare const REGISTRY_ACCOUNT_SIZE: number;
17
+ /** Adelos Protocol version prefix for memos */
18
+ declare const MEMO_PREFIX = "ADLSv1:";
19
+ /** Stealth address derivation domain separator */
20
+ declare const STEALTH_DOMAIN = "adelos:stealth:v1";
2
21
 
3
22
  /** Represents a registry account data */
4
23
  interface RegistryAccount {
@@ -9,12 +28,26 @@ interface RegistryAccount {
9
28
  /** PDA bump seed */
10
29
  bump: number;
11
30
  }
12
- /** Options for initializing the Adelos SDK */
31
+ /**
32
+ * Options for initializing the Adelos SDK
33
+ *
34
+ * @example
35
+ * // Simple usage - just specify cluster
36
+ * const sdk = new AdelosSDK({ cluster: "devnet" });
37
+ *
38
+ * // Custom RPC (e.g., QuickNode, Helius)
39
+ * const sdk = new AdelosSDK({
40
+ * cluster: "devnet",
41
+ * rpcUrl: "https://my-quicknode-endpoint.com"
42
+ * });
43
+ */
13
44
  interface AdelosOptions {
14
- /** Solana cluster URL */
45
+ /** Solana cluster (devnet, mainnet-beta, or localnet) */
46
+ cluster?: SolanaCluster;
47
+ /** Custom RPC URL (optional - overrides cluster default) */
15
48
  rpcUrl?: string;
16
- /** Custom program ID (defaults to Devnet) */
17
- programId?: PublicKey;
49
+ /** Helius API key for indexer webhooks (optional) */
50
+ heliusApiKey?: string;
18
51
  }
19
52
  /** Result of a registry lookup */
20
53
  interface RegistryInfo {
@@ -32,13 +65,20 @@ interface TransactionResult {
32
65
  /** Registry PDA address */
33
66
  registryAddress: PublicKey;
34
67
  }
35
-
36
- /** Program ID for Adelos Registry on Devnet */
37
- declare const PROGRAM_ID: PublicKey;
38
- /** Seed prefix for registry PDA derivation */
39
- declare const REGISTRY_SEED = "registry";
40
- /** Size of the registry account in bytes */
41
- declare const REGISTRY_ACCOUNT_SIZE: number;
68
+ /** Stealth transfer info for sender */
69
+ interface StealthTransferInfo {
70
+ /** Derived stealth address */
71
+ stealthPubkey: Uint8Array;
72
+ /** Ephemeral keypair used for derivation */
73
+ ephemeralKeypair: {
74
+ secretKey: Uint8Array;
75
+ publicKey: Uint8Array;
76
+ };
77
+ /** Shared secret (for debugging, don't expose in production) */
78
+ sharedSecret: Uint8Array;
79
+ /** Memo to include in transaction */
80
+ memo: string;
81
+ }
42
82
 
43
83
  /**
44
84
  * Derives the registry PDA for a given owner
@@ -78,8 +118,31 @@ declare const IDL: {
78
118
  readonly name: "adelos_registry";
79
119
  readonly version: "0.1.0";
80
120
  readonly spec: "0.1.0";
121
+ readonly description: "Privacy Registry for Adelos Protocol";
81
122
  };
82
123
  readonly instructions: readonly [{
124
+ readonly name: "close_registry";
125
+ readonly discriminator: readonly [76, 32, 154, 180, 51, 159, 218, 102];
126
+ readonly accounts: readonly [{
127
+ readonly name: "owner";
128
+ readonly writable: true;
129
+ readonly signer: true;
130
+ readonly relations: readonly ["registry"];
131
+ }, {
132
+ readonly name: "registry";
133
+ readonly writable: true;
134
+ readonly pda: {
135
+ readonly seeds: readonly [{
136
+ readonly kind: "const";
137
+ readonly value: readonly [114, 101, 103, 105, 115, 116, 114, 121];
138
+ }, {
139
+ readonly kind: "account";
140
+ readonly path: "owner";
141
+ }];
142
+ };
143
+ }];
144
+ readonly args: readonly [];
145
+ }, {
83
146
  readonly name: "register_identity";
84
147
  readonly discriminator: readonly [164, 118, 227, 177, 47, 176, 187, 248];
85
148
  readonly accounts: readonly [{
@@ -113,10 +176,24 @@ declare const IDL: {
113
176
  readonly discriminator: readonly [130, 54, 88, 104, 222, 124, 238, 252];
114
177
  readonly accounts: readonly [{
115
178
  readonly name: "owner";
179
+ readonly writable: true;
116
180
  readonly signer: true;
181
+ readonly relations: readonly ["registry"];
117
182
  }, {
118
183
  readonly name: "registry";
119
184
  readonly writable: true;
185
+ readonly pda: {
186
+ readonly seeds: readonly [{
187
+ readonly kind: "const";
188
+ readonly value: readonly [114, 101, 103, 105, 115, 116, 114, 121];
189
+ }, {
190
+ readonly kind: "account";
191
+ readonly path: "owner";
192
+ }];
193
+ };
194
+ }, {
195
+ readonly name: "system_program";
196
+ readonly address: "11111111111111111111111111111111";
120
197
  }];
121
198
  readonly args: readonly [{
122
199
  readonly name: "new_meta_pubkey";
@@ -124,23 +201,20 @@ declare const IDL: {
124
201
  readonly array: readonly ["u8", 32];
125
202
  };
126
203
  }];
127
- }, {
128
- readonly name: "close_registry";
129
- readonly discriminator: readonly [76, 32, 154, 180, 51, 159, 218, 102];
130
- readonly accounts: readonly [{
131
- readonly name: "owner";
132
- readonly writable: true;
133
- readonly signer: true;
134
- }, {
135
- readonly name: "registry";
136
- readonly writable: true;
137
- }];
138
- readonly args: readonly [];
139
204
  }];
140
205
  readonly accounts: readonly [{
141
206
  readonly name: "RegistryAccount";
142
207
  readonly discriminator: readonly [113, 93, 106, 201, 100, 166, 146, 98];
143
208
  }];
209
+ readonly errors: readonly [{
210
+ readonly code: 6000;
211
+ readonly name: "InvalidMetaPubkey";
212
+ readonly msg: "Invalid meta_pubkey";
213
+ }, {
214
+ readonly code: 6001;
215
+ readonly name: "Unauthorized";
216
+ readonly msg: "Unauthorized";
217
+ }];
144
218
  readonly types: readonly [{
145
219
  readonly name: "RegistryAccount";
146
220
  readonly type: {
@@ -159,15 +233,6 @@ declare const IDL: {
159
233
  }];
160
234
  };
161
235
  }];
162
- readonly errors: readonly [{
163
- readonly code: 6000;
164
- readonly name: "InvalidMetaPubkey";
165
- readonly msg: "Invalid meta_pubkey";
166
- }, {
167
- readonly code: 6001;
168
- readonly name: "Unauthorized";
169
- readonly msg: "Unauthorized";
170
- }];
171
236
  };
172
237
  type AdelosIDL = typeof IDL;
173
238
 
@@ -469,6 +534,10 @@ declare class AdelosIndexer {
469
534
  /**
470
535
  * Scans recent transactions for stealth transfers to a recipient
471
536
  *
537
+ * IMPORTANT: We scan the Memo Program, NOT the metaPubkey!
538
+ * The metaPubkey should never appear in transactions - that's the whole point of stealth addresses.
539
+ * We scan memo program for ADLSv1: prefix, then use Trial Decryption to check if it's for us.
540
+ *
472
541
  * @param metaSk - Recipient's meta secret key
473
542
  * @param metaPubkey - Recipient's meta public key
474
543
  * @param limit - Number of transactions to scan
@@ -489,7 +558,9 @@ declare class AdelosIndexer {
489
558
  */
490
559
  private extractMemo;
491
560
  /**
492
- * Parses a transaction to extract stealth transfer info
561
+ * Parses a transaction to extract stealth transfer info using Trial Decryption
562
+ *
563
+ * Trial Decryption: First compute expected stealth address, then find if it exists in tx accounts
493
564
  */
494
565
  private parseStealthTransaction;
495
566
  /**
@@ -532,11 +603,18 @@ declare function createIndexer(config: IndexerConfig): AdelosIndexer;
532
603
  * ```typescript
533
604
  * import { AdelosSDK } from "@adelos/sdk";
534
605
  *
535
- * const sdk = new AdelosSDK({ rpcUrl: "https://api.devnet.solana.com" });
606
+ * // Simple usage with cluster
607
+ * const sdk = new AdelosSDK({ cluster: "devnet" });
608
+ *
609
+ * // With custom RPC (QuickNode, Helius)
610
+ * const sdk = new AdelosSDK({
611
+ * cluster: "devnet",
612
+ * rpcUrl: "https://my-quicknode-endpoint.com"
613
+ * });
536
614
  *
537
615
  * // Register identity
538
616
  * const metaPubkey = new Uint8Array(32).fill(1);
539
- * const result = await sdk.register(wallet, metaPubkey);
617
+ * const tx = await sdk.createRegisterTransactionV0(walletPubkey, metaPubkey);
540
618
  *
541
619
  * // Get registry
542
620
  * const registry = await sdk.getRegistry(ownerPubkey);
@@ -546,7 +624,8 @@ declare function createIndexer(config: IndexerConfig): AdelosIndexer;
546
624
  declare class AdelosSDK {
547
625
  readonly connection: Connection;
548
626
  readonly programId: PublicKey;
549
- private program;
627
+ readonly cluster: SolanaCluster;
628
+ readonly heliusApiKey?: string;
550
629
  constructor(options?: AdelosOptions);
551
630
  /**
552
631
  * Derives the registry PDA for an owner
@@ -582,21 +661,38 @@ declare class AdelosSDK {
582
661
  */
583
662
  createCloseInstruction(owner: PublicKey): TransactionInstruction;
584
663
  /**
585
- * Creates a register transaction (unsigned)
664
+ * Creates a register transaction (unsigned) - Legacy format
586
665
  */
587
666
  createRegisterTransaction(owner: PublicKey, metaPubkey: Uint8Array): Promise<Transaction>;
588
667
  /**
589
- * Creates an update transaction (unsigned)
668
+ * Creates a register transaction (unsigned) - Versioned format (v0)
669
+ * Recommended for modern Solana applications
670
+ */
671
+ createRegisterTransactionV0(owner: PublicKey, metaPubkey: Uint8Array): Promise<VersionedTransaction>;
672
+ /**
673
+ * Creates an update transaction (unsigned) - Legacy format
590
674
  */
591
675
  createUpdateTransaction(owner: PublicKey, newMetaPubkey: Uint8Array): Promise<Transaction>;
592
676
  /**
593
- * Creates a close transaction (unsigned)
677
+ * Creates an update transaction (unsigned) - Versioned format (v0)
678
+ */
679
+ createUpdateTransactionV0(owner: PublicKey, newMetaPubkey: Uint8Array): Promise<VersionedTransaction>;
680
+ /**
681
+ * Creates a close transaction (unsigned) - Legacy format
594
682
  */
595
683
  createCloseTransaction(owner: PublicKey): Promise<Transaction>;
596
684
  /**
597
- * Sends a signed transaction and confirms it
685
+ * Creates a close transaction (unsigned) - Versioned format (v0)
686
+ */
687
+ createCloseTransactionV0(owner: PublicKey): Promise<VersionedTransaction>;
688
+ /**
689
+ * Sends a signed legacy transaction and confirms it
598
690
  */
599
691
  sendAndConfirm(signedTransaction: Transaction): Promise<string>;
692
+ /**
693
+ * Sends a signed versioned transaction and confirms it
694
+ */
695
+ sendAndConfirmV0(signedTransaction: VersionedTransaction): Promise<string>;
600
696
  }
601
697
 
602
- export { type AdelosIDL, AdelosIndexer, type AdelosOptions, AdelosSDK, type CompressedAccount, type CompressedTokenBalance, type HeliusWebhookPayload, IDL, type IndexerConfig, LIGHT_PROGRAM_IDS, LightClient, type LightConfig, PROGRAM_ID, REGISTRY_ACCOUNT_SIZE, REGISTRY_SEED, type RegistryAccount, type RegistryInfo, type StealthTransaction, type TransactionResult, bytesToHex, computeSharedSecret, computeSharedSecretAsRecipient, createIndexer, createLightClient, deriveRegistryPda, deriveStealthPubkey, generateEphemeralKeypair, generateStealthAddress, generateStealthMemo, getDiscriminator, hexToBytes, isStealthTransactionForMe, isValidMetaPubkey, parseStealthMemo, recoverStealthSecretKey };
698
+ export { type AdelosIDL, AdelosIndexer, type AdelosOptions, AdelosSDK, type CompressedAccount, type CompressedTokenBalance, type HeliusWebhookPayload, IDL, type IndexerConfig, LIGHT_PROGRAM_IDS, LightClient, type LightConfig, MEMO_PREFIX, MEMO_PROGRAM_ID, PROGRAM_ID, PROGRAM_IDS, REGISTRY_ACCOUNT_SIZE, REGISTRY_SEED, RPC_URLS, type RegistryAccount, type RegistryInfo, STEALTH_DOMAIN, type SolanaCluster, type StealthTransaction, type StealthTransferInfo, type TransactionResult, bytesToHex, computeSharedSecret, computeSharedSecretAsRecipient, createIndexer, createLightClient, deriveRegistryPda, deriveStealthPubkey, generateEphemeralKeypair, generateStealthAddress, generateStealthMemo, getDiscriminator, hexToBytes, isStealthTransactionForMe, isValidMetaPubkey, parseStealthMemo, recoverStealthSecretKey };