@lightprotocol/stateless.js 0.22.1-alpha.0 → 0.22.1-alpha.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 (88) hide show
  1. package/dist/cjs/browser/constants.d.ts +19 -4
  2. package/dist/cjs/browser/index.cjs +1 -1
  3. package/dist/cjs/browser/index.cjs.map +1 -1
  4. package/dist/cjs/browser/index.d.ts +0 -1
  5. package/dist/cjs/browser/programs/system/pack.d.ts +10 -79
  6. package/dist/cjs/browser/rpc-interface.d.ts +275 -275
  7. package/dist/cjs/browser/rpc.d.ts +6 -16
  8. package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +6 -6
  9. package/dist/cjs/browser/utils/address.d.ts +7 -19
  10. package/dist/cjs/browser/utils/conversion.d.ts +1 -1
  11. package/dist/cjs/browser/utils/index.d.ts +1 -1
  12. package/dist/cjs/browser/utils/instruction.d.ts +35 -0
  13. package/dist/cjs/node/constants.d.ts +19 -4
  14. package/dist/cjs/node/index.cjs +1 -1
  15. package/dist/cjs/node/index.cjs.map +1 -1
  16. package/dist/cjs/node/index.d.ts +0 -1
  17. package/dist/cjs/node/programs/system/pack.d.ts +10 -79
  18. package/dist/cjs/node/rpc-interface.d.ts +275 -275
  19. package/dist/cjs/node/rpc.d.ts +6 -16
  20. package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +6 -6
  21. package/dist/cjs/node/utils/address.d.ts +7 -19
  22. package/dist/cjs/node/utils/conversion.d.ts +1 -1
  23. package/dist/cjs/node/utils/index.d.ts +1 -1
  24. package/dist/cjs/node/utils/instruction.d.ts +35 -0
  25. package/dist/es/browser/actions/compress.d.ts +18 -0
  26. package/dist/es/browser/actions/create-account.d.ts +38 -0
  27. package/dist/es/browser/actions/decompress.d.ts +15 -0
  28. package/dist/es/browser/actions/index.d.ts +5 -0
  29. package/dist/es/browser/actions/transfer.d.ts +16 -0
  30. package/dist/es/browser/constants.d.ts +157 -0
  31. package/dist/es/browser/errors.d.ts +74 -0
  32. package/dist/es/browser/index.d.ts +9 -0
  33. package/dist/es/browser/index.js +2 -0
  34. package/dist/es/browser/index.js.map +1 -0
  35. package/dist/es/browser/programs/index.d.ts +1 -0
  36. package/dist/es/browser/programs/system/idl.d.ts +997 -0
  37. package/dist/es/browser/programs/system/index.d.ts +5 -0
  38. package/dist/es/browser/programs/system/layout.d.ts +77 -0
  39. package/dist/es/browser/programs/system/pack.d.ts +74 -0
  40. package/dist/es/browser/programs/system/program.d.ts +175 -0
  41. package/dist/es/browser/programs/system/select-compressed-accounts.d.ts +10 -0
  42. package/dist/es/browser/rpc-interface.d.ts +2779 -0
  43. package/dist/es/browser/rpc.d.ts +284 -0
  44. package/dist/es/browser/state/BN254.d.ts +13 -0
  45. package/dist/es/browser/state/bn.d.ts +3 -0
  46. package/dist/es/browser/state/compressed-account.d.ts +205 -0
  47. package/dist/es/browser/state/index.d.ts +4 -0
  48. package/dist/es/browser/state/types.d.ts +449 -0
  49. package/dist/es/browser/test-helpers/index.d.ts +3 -0
  50. package/dist/es/browser/test-helpers/merkle-tree/index.d.ts +2 -0
  51. package/dist/es/browser/test-helpers/merkle-tree/indexed-array.d.ts +85 -0
  52. package/dist/es/browser/test-helpers/merkle-tree/merkle-tree.d.ts +92 -0
  53. package/dist/es/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +7 -0
  54. package/dist/es/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +40 -0
  55. package/dist/es/browser/test-helpers/test-rpc/get-parsed-events.d.ts +15 -0
  56. package/dist/es/browser/test-helpers/test-rpc/index.d.ts +3 -0
  57. package/dist/es/browser/test-helpers/test-rpc/test-rpc.d.ts +239 -0
  58. package/dist/es/browser/test-helpers/test-utils.d.ts +31 -0
  59. package/dist/es/browser/utils/address.d.ts +64 -0
  60. package/dist/es/browser/utils/airdrop.d.ts +7 -0
  61. package/dist/es/browser/utils/calculate-compute-unit-price.d.ts +7 -0
  62. package/dist/es/browser/utils/conversion.d.ts +36 -0
  63. package/dist/es/browser/utils/dedupe-signer.d.ts +3 -0
  64. package/dist/es/browser/utils/get-state-tree-infos.d.ts +48 -0
  65. package/dist/es/browser/utils/index.d.ts +13 -0
  66. package/dist/es/browser/utils/instruction.d.ts +35 -0
  67. package/dist/es/browser/utils/parse-validity-proof.d.ts +20 -0
  68. package/dist/es/browser/utils/pipe.d.ts +2 -0
  69. package/dist/es/browser/utils/send-and-confirm.d.ts +52 -0
  70. package/dist/es/browser/utils/sleep.d.ts +1 -0
  71. package/dist/es/browser/utils/state-tree-lookup-table.d.ts +68 -0
  72. package/dist/es/browser/utils/validation.d.ts +8 -0
  73. package/dist/types/index.d.ts +109 -667
  74. package/package.json +16 -8
  75. package/dist/cjs/browser/compressible/action.d.ts +0 -77
  76. package/dist/cjs/browser/compressible/index.d.ts +0 -13
  77. package/dist/cjs/browser/compressible/instruction.d.ts +0 -177
  78. package/dist/cjs/browser/compressible/layout.d.ts +0 -47
  79. package/dist/cjs/browser/compressible/types.d.ts +0 -112
  80. package/dist/cjs/browser/compressible/utils.d.ts +0 -16
  81. package/dist/cjs/browser/utils/packed-accounts.d.ts +0 -161
  82. package/dist/cjs/node/compressible/action.d.ts +0 -77
  83. package/dist/cjs/node/compressible/index.d.ts +0 -13
  84. package/dist/cjs/node/compressible/instruction.d.ts +0 -177
  85. package/dist/cjs/node/compressible/layout.d.ts +0 -47
  86. package/dist/cjs/node/compressible/types.d.ts +0 -112
  87. package/dist/cjs/node/compressible/utils.d.ts +0 -16
  88. package/dist/cjs/node/utils/packed-accounts.d.ts +0 -161
@@ -1,7 +1,7 @@
1
- import { AccountInfo, Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
1
+ import { Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
2
2
  import { Buffer } from 'buffer';
3
3
  import { ValidityProofWithContext, CompressedTransaction, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, HexInputsForProver, ParsedTokenAccount, SignatureWithMetadata, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, WithContext, GetCompressedAccountsByOwnerConfig, WithCursor, AddressWithTree, HashWithTree, CompressedMintTokenHolders, TokenBalance, PaginatedOptions } from './rpc-interface';
4
- import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, ValidityProof, AddressTreeInfo, MerkleContext } from './state';
4
+ import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, ValidityProof, AddressTreeInfo } from './state';
5
5
  import BN from 'bn.js';
6
6
  import { LightWasm } from './test-helpers';
7
7
  import { TreeInfo } from './state/types';
@@ -100,6 +100,10 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
100
100
  * @internal
101
101
  */
102
102
  doFetch(): Promise<TreeInfo[]>;
103
+ /**
104
+ * Get a V2 address tree info.
105
+ */
106
+ getAddressTreeInfoV2(): Promise<TreeInfo>;
103
107
  /**
104
108
  * Fetch the compressed account for the specified account address or hash
105
109
  */
@@ -277,18 +281,4 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
277
281
  * @returns validity proof with context
278
282
  */
279
283
  getValidityProofAndRpcContext(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<WithContext<ValidityProofWithContext>>;
280
- /**
281
- * Get account info from either compressed or onchain storage.
282
- * @param address The account address to fetch.
283
- * @param programId The owner program ID.
284
- * @param addressTreeInfo The address tree info used to store the account.
285
- * @param rpc The RPC client to use.
286
- *
287
- * @returns Account info with compression info, or null if account
288
- * doesn't exist.
289
- */
290
- getCompressibleAccountInfo(address: PublicKey, programId: PublicKey, addressTreeInfo: TreeInfo, rpc: Rpc): Promise<{
291
- accountInfo: AccountInfo<Buffer>;
292
- merkleContext?: MerkleContext;
293
- } | null>;
294
284
  }
@@ -1,8 +1,8 @@
1
- import { AccountInfo, Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
1
+ import { Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
2
2
  import BN from 'bn.js';
3
3
  import { AddressWithTree, CompressedMintTokenHolders, CompressedTransaction, GetCompressedAccountsByOwnerConfig, PaginatedOptions, HashWithTree, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, SignatureWithMetadata, WithContext, WithCursor } from '../../rpc-interface';
4
4
  import { ValidityProofWithContext, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, ParsedTokenAccount, TokenBalance } from '../../rpc-interface';
5
- import { BN254, CompressedAccountWithMerkleContext, MerkleContext, MerkleContextWithMerkleProof } from '../../state';
5
+ import { BN254, CompressedAccountWithMerkleContext, MerkleContextWithMerkleProof } from '../../state';
6
6
  import { MerkleContextWithNewAddressProof } from '../../rpc';
7
7
  import { TreeInfo } from '../../state/types';
8
8
  export interface TestRpcConfig {
@@ -83,6 +83,10 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
83
83
  */
84
84
  getStateTreeInfos(): Promise<TreeInfo[]>;
85
85
  doFetch(): Promise<TreeInfo[]>;
86
+ /**
87
+ * Get a V2 address tree info.
88
+ */
89
+ getAddressTreeInfoV2(): Promise<TreeInfo>;
86
90
  /**
87
91
  * Fetch the compressed account for the specified account hash
88
92
  */
@@ -232,8 +236,4 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
232
236
  */
233
237
  getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<ValidityProofWithContext>;
234
238
  getValidityProofV0(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<ValidityProofWithContext>;
235
- getCompressibleAccountInfo(address: PublicKey, programId: PublicKey, addressTreeInfo: TreeInfo, rpc: TestRpc): Promise<{
236
- accountInfo: AccountInfo<Buffer>;
237
- merkleContext?: MerkleContext;
238
- } | null>;
239
239
  }
@@ -1,28 +1,16 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
- /**
3
- * Derive an address for a compressed account from a seed and an address Merkle
4
- * tree public key.
5
- *
6
- * @param seed 32 bytes seed to derive the address from
7
- * @param addressMerkleTreePubkey Address Merkle tree public key as bytes.
8
- * @param programIdBytes Program ID bytes.
9
- * @returns Derived address as bytes
10
- */
11
- export declare function deriveAddressV2(seed: Uint8Array, addressMerkleTreePubkey: Uint8Array, programIdBytes: Uint8Array): Uint8Array;
12
- export declare function hashVWithBumpSeed(bytes: Uint8Array[]): Uint8Array;
13
2
  export declare function deriveAddressSeed(seeds: Uint8Array[], programId: PublicKey): Uint8Array;
3
+ export declare function deriveAddress(seed: Uint8Array, addressMerkleTreePubkey?: PublicKey): PublicKey;
4
+ export declare function deriveAddressSeedV2(seeds: Uint8Array[]): Uint8Array;
14
5
  /**
15
- * @deprecated Use {@link deriveAddressV2} instead, unless you're using v1.
16
- *
17
- * Derive an address for a compressed account from a seed and an address Merkle
18
- * tree public key.
6
+ * Derives an address from a seed using the v2 method (matching Rust's derive_address_from_seed)
19
7
  *
20
- * @param seed Seed to derive the address from
21
- * @param addressMerkleTreePubkey Merkle tree public key. Defaults to
22
- * defaultTestStateTreeAccounts().addressTree
8
+ * @param addressSeed The address seed (32 bytes)
9
+ * @param addressMerkleTreePubkey Merkle tree public key
10
+ * @param programId Program ID
23
11
  * @returns Derived address
24
12
  */
25
- export declare function deriveAddress(seed: Uint8Array, addressMerkleTreePubkey?: PublicKey): PublicKey;
13
+ export declare function deriveAddressV2(addressSeed: Uint8Array, addressMerkleTreePubkey: PublicKey, programId: PublicKey): PublicKey;
26
14
  export interface NewAddressParams {
27
15
  /**
28
16
  * Seed for the compressed account. Must be seed used to derive
@@ -21,8 +21,8 @@ export declare const toCamelCase: (object: any) => any;
21
21
  * @deprecated Use `hashvToBn254FieldSizeBe` instead.
22
22
  */
23
23
  export declare function hashToBn254FieldSizeBe(bytes: Buffer): [Buffer, number] | null;
24
+ export declare function hashvToBn254FieldSizeBeU8Array(bytes: Uint8Array[]): Uint8Array;
24
25
  /**
25
- * TODO: make consistent with latest rust. (use u8::max bumpseed)
26
26
  * Hash the provided `bytes` with Keccak256 and ensure that the result fits in
27
27
  * the BN254 prime field by truncating the resulting hash to 31 bytes.
28
28
  *
@@ -3,6 +3,7 @@ export * from './airdrop';
3
3
  export * from './calculate-compute-unit-price';
4
4
  export * from './conversion';
5
5
  export * from './dedupe-signer';
6
+ export * from './instruction';
6
7
  export * from './parse-validity-proof';
7
8
  export * from './pipe';
8
9
  export * from './send-and-confirm';
@@ -10,4 +11,3 @@ export * from './sleep';
10
11
  export * from './validation';
11
12
  export * from './state-tree-lookup-table';
12
13
  export * from './get-state-tree-infos';
13
- export * from './packed-accounts';
@@ -0,0 +1,35 @@
1
+ import { AccountMeta, PublicKey } from '@solana/web3.js';
2
+ export declare class PackedAccounts {
3
+ private preAccounts;
4
+ private systemAccounts;
5
+ private nextIndex;
6
+ private map;
7
+ static newWithSystemAccounts(config: SystemAccountMetaConfig): PackedAccounts;
8
+ static newWithSystemAccountsV2(config: SystemAccountMetaConfig): PackedAccounts;
9
+ addPreAccountsSigner(pubkey: PublicKey): void;
10
+ addPreAccountsSignerMut(pubkey: PublicKey): void;
11
+ addPreAccountsMeta(accountMeta: AccountMeta): void;
12
+ addSystemAccounts(config: SystemAccountMetaConfig): void;
13
+ addSystemAccountsV2(config: SystemAccountMetaConfig): void;
14
+ insertOrGet(pubkey: PublicKey): number;
15
+ insertOrGetReadOnly(pubkey: PublicKey): number;
16
+ insertOrGetConfig(pubkey: PublicKey, isSigner: boolean, isWritable: boolean): number;
17
+ private hashSetAccountsToMetas;
18
+ private getOffsets;
19
+ toAccountMetas(): {
20
+ remainingAccounts: AccountMeta[];
21
+ systemStart: number;
22
+ packedStart: number;
23
+ };
24
+ }
25
+ export declare class SystemAccountMetaConfig {
26
+ selfProgram: PublicKey;
27
+ cpiContext?: PublicKey;
28
+ solCompressionRecipient?: PublicKey;
29
+ solPoolPda?: PublicKey;
30
+ private constructor();
31
+ static new(selfProgram: PublicKey): SystemAccountMetaConfig;
32
+ static newWithCpiContext(selfProgram: PublicKey, cpiContext: PublicKey): SystemAccountMetaConfig;
33
+ }
34
+ export declare function getLightSystemAccountMetas(config: SystemAccountMetaConfig): AccountMeta[];
35
+ export declare function getLightSystemAccountMetasV2(config: SystemAccountMetaConfig): AccountMeta[];
@@ -98,13 +98,28 @@ export declare const cpiContextPubkey = "cpi1uHzrEhBG733DoEJNgHCyRS3XmmyVNZx5fon
98
98
  export declare const merkletreePubkey = "smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT";
99
99
  export declare const addressTree = "amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2";
100
100
  export declare const addressQueue = "aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F";
101
- export declare const addressTreeV2: PublicKey;
102
101
  export declare const merkleTree2Pubkey = "smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho";
103
102
  export declare const nullifierQueue2Pubkey = "nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X";
104
103
  export declare const cpiContext2Pubkey = "cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK";
105
- export declare const batchMerkleTree = "HLKs5NJ8FXkJg8BrzJt56adFYYuwg5etzDtBbQYTsixu";
106
- export declare const batchQueue = "6L7SzhYB3anwEQ9cphpJ1U7Scwj57bx2xueReg7R9cKU";
107
- export declare const batchCpiContext = "7Hp52chxaew8bW1ApR4fck2bh6Y8qA1pu3qwH6N9zaLj";
104
+ export declare const batchMerkleTree1 = "bmt1LryLZUMmF7ZtqESaw7wifBXLfXHQYoE4GAmrahU";
105
+ export declare const batchQueue1 = "oq1na8gojfdUhsfCpyjNt6h4JaDWtHf1yQj4koBWfto";
106
+ export declare const batchCpiContext1 = "cpi15BoVPKgEPw5o8wc2T816GE7b378nMXnhH3Xbq4y";
107
+ export declare const batchMerkleTree2 = "bmt2UxoBxB9xWev4BkLvkGdapsz6sZGkzViPNph7VFi";
108
+ export declare const batchQueue2 = "oq2UkeMsJLfXt2QHzim242SUi3nvjJs8Pn7Eac9H9vg";
109
+ export declare const batchCpiContext2 = "cpi2yGapXUR3As5SjnHBAVvmApNiLsbeZpF3euWnW6B";
110
+ export declare const batchMerkleTree3 = "bmt3ccLd4bqSVZVeCJnH1F6C8jNygAhaDfxDwePyyGb";
111
+ export declare const batchQueue3 = "oq3AxjekBWgo64gpauB6QtuZNesuv19xrhaC1ZM1THQ";
112
+ export declare const batchCpiContext3 = "cpi3mbwMpSX8FAGMZVP85AwxqCaQMfEk9Em1v8QK9Rf";
113
+ export declare const batchMerkleTree4 = "bmt4d3p1a4YQgk9PeZv5s4DBUmbF5NxqYpk9HGjQsd8";
114
+ export declare const batchQueue4 = "oq4ypwvVGzCUMoiKKHWh4S1SgZJ9vCvKpcz6RT6A8dq";
115
+ export declare const batchCpiContext4 = "cpi4yyPDc4bCgHAnsenunGA8Y77j3XEDyjgfyCKgcoc";
116
+ export declare const batchMerkleTree5 = "bmt5yU97jC88YXTuSukYHa8Z5Bi2ZDUtmzfkDTA2mG2";
117
+ export declare const batchQueue5 = "oq5oh5ZR3yGomuQgFduNDzjtGvVWfDRGLuDVjv9a96P";
118
+ export declare const batchCpiContext5 = "cpi5ZTjdgYpZ1Xr7B1cMLLUE81oTtJbNNAyKary2nV6";
119
+ export declare const batchAddressTree = "amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx";
120
+ export declare const testBatchAddressTree = "EzKE84aVTkCUhDHLELqyJaq1Y7UVVmqxXqZjVHwHY3rK";
121
+ export declare const batchMerkleTree = "bmt1LryLZUMmF7ZtqESaw7wifBXLfXHQYoE4GAmrahU";
122
+ export declare const batchQueue = "oq1na8gojfdUhsfCpyjNt6h4JaDWtHf1yQj4koBWfto";
108
123
  export declare const confirmConfig: ConfirmOptions;
109
124
  export declare const DEFAULT_MERKLE_TREE_HEIGHT = 26;
110
125
  export declare const DEFAULT_MERKLE_TREE_ROOTS = 2800;