@lightprotocol/stateless.js 0.22.1-alpha.7 → 0.23.0-beta.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.
@@ -1,16 +1,47 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
- export declare function deriveAddressSeed(seeds: Uint8Array[], programId: PublicKey): Uint8Array;
3
- export declare function deriveAddress(seed: Uint8Array, addressMerkleTreePubkey?: PublicKey): PublicKey;
2
+ /**
3
+ * @deprecated Use deriveAddressSeed (no programId param) for V2.
4
+ * V1 seed derivation includes programId in hash.
5
+ */
6
+ export declare function deriveAddressSeedLegacy(seeds: Uint8Array[], programId: PublicKey): Uint8Array;
7
+ /**
8
+ * @deprecated Use deriveAddress with programId param for V2.
9
+ * V1 address derivation doesn't include programId.
10
+ */
11
+ export declare function deriveAddressLegacy(seed: Uint8Array, addressMerkleTreePubkey?: PublicKey): PublicKey;
12
+ /**
13
+ * Explicit V2 address seed derivation - always uses V2 behavior regardless of feature flag.
14
+ * Use this when you explicitly want V2 derivation (e.g., in tests).
15
+ */
4
16
  export declare function deriveAddressSeedV2(seeds: Uint8Array[]): Uint8Array;
5
17
  /**
6
- * Derives an address from a seed using the v2 method (matching Rust's derive_address_from_seed)
18
+ * Derive an address seed from multiple seed components.
7
19
  *
8
- * @param addressSeed The address seed (32 bytes)
9
- * @param addressMerkleTreePubkey Merkle tree public key
10
- * @param programId Program ID
11
- * @returns Derived address
20
+ * V2 mode: Does NOT include programId in seed hash. Do not pass programId.
21
+ * V1 mode: Includes programId in seed hash. Must pass programId.
22
+ *
23
+ * @param seeds Array of seed bytes to combine
24
+ * @param programId (V1 only) Program ID - required in V1 mode, must be omitted in V2 mode
25
+ * @returns 32-byte address seed
26
+ */
27
+ export declare function deriveAddressSeed(seeds: Uint8Array[], programId?: PublicKey): Uint8Array;
28
+ /**
29
+ * Explicit V2 address derivation - always uses V2 behavior regardless of feature flag.
30
+ * Use this when you explicitly want V2 derivation (e.g., in tests).
12
31
  */
13
32
  export declare function deriveAddressV2(addressSeed: Uint8Array, addressMerkleTreePubkey: PublicKey, programId: PublicKey): PublicKey;
33
+ /**
34
+ * Derive an address for a compressed account.
35
+ *
36
+ * V2 mode: Requires programId, includes it in final hash.
37
+ * V1 mode: Must not pass programId, uses legacy derivation.
38
+ *
39
+ * @param addressSeed The address seed (32 bytes) from deriveAddressSeed
40
+ * @param addressMerkleTreePubkey Address tree public key
41
+ * @param programId (V2 only) Program ID - required in V2 mode, must be omitted in V1 mode
42
+ * @returns Derived address
43
+ */
44
+ export declare function deriveAddress(addressSeed: Uint8Array, addressMerkleTreePubkey: PublicKey, programId?: PublicKey): PublicKey;
14
45
  export interface NewAddressParams {
15
46
  /**
16
47
  * Seed for the compressed account. Must be seed used to derive
@@ -4,12 +4,25 @@ export declare class PackedAccounts {
4
4
  private systemAccounts;
5
5
  private nextIndex;
6
6
  private map;
7
+ /**
8
+ * Create PackedAccounts with system accounts pre-added.
9
+ * Auto-selects V1 or V2 account layout based on featureFlags.
10
+ */
7
11
  static newWithSystemAccounts(config: SystemAccountMetaConfig): PackedAccounts;
12
+ /**
13
+ * @deprecated Use newWithSystemAccounts - it auto-selects V2 when appropriate.
14
+ */
8
15
  static newWithSystemAccountsV2(config: SystemAccountMetaConfig): PackedAccounts;
9
16
  addPreAccountsSigner(pubkey: PublicKey): void;
10
17
  addPreAccountsSignerMut(pubkey: PublicKey): void;
11
18
  addPreAccountsMeta(accountMeta: AccountMeta): void;
19
+ /**
20
+ * Add Light system accounts. Auto-selects V1 or V2 layout based on featureFlags.
21
+ */
12
22
  addSystemAccounts(config: SystemAccountMetaConfig): void;
23
+ /**
24
+ * @deprecated Use addSystemAccounts - it auto-selects V2 when appropriate.
25
+ */
13
26
  addSystemAccountsV2(config: SystemAccountMetaConfig): void;
14
27
  insertOrGet(pubkey: PublicKey): number;
15
28
  insertOrGetReadOnly(pubkey: PublicKey): number;
@@ -31,5 +44,12 @@ export declare class SystemAccountMetaConfig {
31
44
  static new(selfProgram: PublicKey): SystemAccountMetaConfig;
32
45
  static newWithCpiContext(selfProgram: PublicKey, cpiContext: PublicKey): SystemAccountMetaConfig;
33
46
  }
47
+ /**
48
+ * @deprecated V1 system account layout. Use getLightSystemAccountMetas which auto-selects.
49
+ */
50
+ export declare function getLightSystemAccountMetasLegacy(config: SystemAccountMetaConfig): AccountMeta[];
51
+ /**
52
+ * Get Light system account metas. Auto-selects V1 or V2 layout based on featureFlags.
53
+ */
34
54
  export declare function getLightSystemAccountMetas(config: SystemAccountMetaConfig): AccountMeta[];
35
55
  export declare function getLightSystemAccountMetasV2(config: SystemAccountMetaConfig): AccountMeta[];
@@ -14,7 +14,23 @@ export declare enum VERSION {
14
14
  export declare const featureFlags: {
15
15
  version: VERSION;
16
16
  isV2: () => boolean;
17
+ /**
18
+ * Beta flag for interface methods (not yet deployed on mainnet).
19
+ * Runtime only - check LIGHT_PROTOCOL_BETA env var.
20
+ */
21
+ isBeta: () => boolean;
17
22
  };
23
+ /**
24
+ * Error message for beta-gated interface methods.
25
+ */
26
+ export declare const BETA_REQUIRED_ERROR: string;
27
+ /**
28
+ * Assert that beta features are enabled.
29
+ * Throws if V2 is not enabled OR if beta is not enabled.
30
+ *
31
+ * Use this at the entry point of all interface methods.
32
+ */
33
+ export declare function assertBetaEnabled(): void;
18
34
  /**
19
35
  * Returns the correct endpoint name for the current API version. E.g.
20
36
  * versionedEndpoint('getCompressedAccount') -> 'getCompressedAccount' (V1)