@lightprotocol/stateless.js 0.20.2 → 0.20.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.
Files changed (74) hide show
  1. package/dist/cjs/browser/actions/common.d.ts +4 -1
  2. package/dist/cjs/browser/actions/compress.d.ts +14 -2
  3. package/dist/cjs/browser/actions/create-account.d.ts +27 -3
  4. package/dist/cjs/browser/actions/decompress.d.ts +14 -2
  5. package/dist/cjs/browser/actions/transfer.d.ts +15 -2
  6. package/dist/cjs/browser/constants.d.ts +30 -15
  7. package/dist/cjs/browser/errors.d.ts +40 -49
  8. package/dist/cjs/browser/idl.d.ts +45 -45
  9. package/dist/cjs/browser/index.cjs +9611 -1
  10. package/dist/cjs/browser/index.cjs.map +1 -1
  11. package/dist/cjs/browser/index.d.ts +0 -1
  12. package/dist/cjs/browser/instruction/pack-compressed-accounts.d.ts +24 -5
  13. package/dist/cjs/browser/programs/layout.d.ts +39 -17
  14. package/dist/cjs/browser/programs/system.d.ts +61 -10
  15. package/dist/cjs/browser/rpc-interface.d.ts +1127 -871
  16. package/dist/cjs/browser/rpc.d.ts +158 -34
  17. package/dist/cjs/browser/state/BN254.d.ts +9 -2
  18. package/dist/cjs/browser/state/compressed-account.d.ts +23 -6
  19. package/dist/cjs/browser/state/types.d.ts +1 -1
  20. package/dist/cjs/browser/test-helpers/merkle-tree/indexed-array.d.ts +18 -4
  21. package/dist/cjs/browser/test-helpers/merkle-tree/merkle-tree.d.ts +19 -6
  22. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +12 -3
  23. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +21 -5
  24. package/dist/cjs/browser/test-helpers/test-rpc/get-parsed-events.d.ts +14 -4
  25. package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +135 -31
  26. package/dist/cjs/browser/test-helpers/test-utils.d.ts +5 -1
  27. package/dist/cjs/browser/utils/address.d.ts +12 -3
  28. package/dist/cjs/browser/utils/airdrop.d.ts +14 -2
  29. package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +4 -1
  30. package/dist/cjs/browser/utils/conversion.d.ts +9 -3
  31. package/dist/cjs/browser/utils/get-light-state-tree-info.d.ts +28 -4
  32. package/dist/cjs/browser/utils/parse-validity-proof.d.ts +3 -1
  33. package/dist/cjs/browser/utils/pipe.d.ts +4 -1
  34. package/dist/cjs/browser/utils/send-and-confirm.d.ts +42 -11
  35. package/dist/cjs/browser/utils/validation.d.ts +9 -2
  36. package/dist/cjs/node/actions/common.d.ts +4 -1
  37. package/dist/cjs/node/actions/compress.d.ts +14 -2
  38. package/dist/cjs/node/actions/create-account.d.ts +27 -3
  39. package/dist/cjs/node/actions/decompress.d.ts +14 -2
  40. package/dist/cjs/node/actions/transfer.d.ts +15 -2
  41. package/dist/cjs/node/constants.d.ts +30 -15
  42. package/dist/cjs/node/errors.d.ts +40 -49
  43. package/dist/cjs/node/idl.d.ts +45 -45
  44. package/dist/cjs/node/index.cjs +8310 -1
  45. package/dist/cjs/node/index.cjs.map +1 -1
  46. package/dist/cjs/node/index.d.ts +0 -1
  47. package/dist/cjs/node/instruction/pack-compressed-accounts.d.ts +24 -5
  48. package/dist/cjs/node/programs/layout.d.ts +39 -17
  49. package/dist/cjs/node/programs/system.d.ts +61 -10
  50. package/dist/cjs/node/rpc-interface.d.ts +1127 -871
  51. package/dist/cjs/node/rpc.d.ts +158 -34
  52. package/dist/cjs/node/state/BN254.d.ts +9 -2
  53. package/dist/cjs/node/state/compressed-account.d.ts +23 -6
  54. package/dist/cjs/node/state/types.d.ts +1 -1
  55. package/dist/cjs/node/test-helpers/merkle-tree/indexed-array.d.ts +18 -4
  56. package/dist/cjs/node/test-helpers/merkle-tree/merkle-tree.d.ts +19 -6
  57. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-accounts.d.ts +12 -3
  58. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +21 -5
  59. package/dist/cjs/node/test-helpers/test-rpc/get-parsed-events.d.ts +14 -4
  60. package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +135 -31
  61. package/dist/cjs/node/test-helpers/test-utils.d.ts +5 -1
  62. package/dist/cjs/node/utils/address.d.ts +12 -3
  63. package/dist/cjs/node/utils/airdrop.d.ts +14 -2
  64. package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +4 -1
  65. package/dist/cjs/node/utils/conversion.d.ts +9 -3
  66. package/dist/cjs/node/utils/get-light-state-tree-info.d.ts +28 -4
  67. package/dist/cjs/node/utils/parse-validity-proof.d.ts +3 -1
  68. package/dist/cjs/node/utils/pipe.d.ts +4 -1
  69. package/dist/cjs/node/utils/send-and-confirm.d.ts +42 -11
  70. package/dist/cjs/node/utils/validation.d.ts +9 -2
  71. package/dist/types/index.d.ts +2111 -1141
  72. package/package.json +1 -2
  73. package/dist/cjs/browser/logger.d.ts +0 -1
  74. package/dist/cjs/node/logger.d.ts +0 -1
@@ -9,4 +9,3 @@ export * from './rpc-interface';
9
9
  export * from './rpc';
10
10
  export * from './test-helpers';
11
11
  export { LightSystemProgram as LightSystemProgramIDL, IDL } from './idl';
12
- export * from './logger';
@@ -1,11 +1,18 @@
1
1
  import { AccountMeta, PublicKey } from '@solana/web3.js';
2
- import { CompressedAccount, OutputCompressedAccountWithPackedContext, PackedCompressedAccountWithMerkleContext } from '../state';
2
+ import {
3
+ CompressedAccount,
4
+ OutputCompressedAccountWithPackedContext,
5
+ PackedCompressedAccountWithMerkleContext,
6
+ } from '../state';
3
7
  import { CompressedAccountWithMerkleContext } from '../state/compressed-account';
4
8
  /**
5
9
  * @internal Finds the index of a PublicKey in an array, or adds it if not
6
10
  * present
7
11
  * */
8
- export declare function getIndexOrAdd(accountsArray: PublicKey[], key: PublicKey): number;
12
+ export declare function getIndexOrAdd(
13
+ accountsArray: PublicKey[],
14
+ key: PublicKey,
15
+ ): number;
9
16
  /**
10
17
  * @internal
11
18
  * Pads output state trees with the 0th state tree of the input state.
@@ -22,8 +29,14 @@ export declare function getIndexOrAdd(accountsArray: PublicKey[], key: PublicKey
22
29
  *
23
30
  * @returns Padded output state trees.
24
31
  */
25
- export declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey[] | PublicKey | undefined, numberOfOutputCompressedAccounts: number, inputCompressedAccountsWithMerkleContext: CompressedAccountWithMerkleContext[]): PublicKey[];
26
- export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
32
+ export declare function padOutputStateMerkleTrees(
33
+ outputStateMerkleTrees: PublicKey[] | PublicKey | undefined,
34
+ numberOfOutputCompressedAccounts: number,
35
+ inputCompressedAccountsWithMerkleContext: CompressedAccountWithMerkleContext[],
36
+ ): PublicKey[];
37
+ export declare function toAccountMetas(
38
+ remainingAccounts: PublicKey[],
39
+ ): AccountMeta[];
27
40
  /**
28
41
  * Packs Compressed Accounts.
29
42
  *
@@ -44,7 +57,13 @@ export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountM
44
57
  * @param remainingAccounts Optional existing array of accounts
45
58
  * to append to.
46
59
  **/
47
- export declare function packCompressedAccounts(inputCompressedAccounts: CompressedAccountWithMerkleContext[], inputStateRootIndices: number[], outputCompressedAccounts: CompressedAccount[], outputStateMerkleTrees?: PublicKey[] | PublicKey, remainingAccounts?: PublicKey[]): {
60
+ export declare function packCompressedAccounts(
61
+ inputCompressedAccounts: CompressedAccountWithMerkleContext[],
62
+ inputStateRootIndices: number[],
63
+ outputCompressedAccounts: CompressedAccount[],
64
+ outputStateMerkleTrees?: PublicKey[] | PublicKey,
65
+ remainingAccounts?: PublicKey[],
66
+ ): {
48
67
  packedInputCompressedAccounts: PackedCompressedAccountWithMerkleContext[];
49
68
  packedOutputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
50
69
  remainingAccounts: PublicKey[];
@@ -1,15 +1,25 @@
1
1
  import { Buffer } from 'buffer';
2
2
  import { PublicKey, AccountMeta } from '@solana/web3.js';
3
3
  import { Layout } from '@coral-xyz/borsh';
4
- import { InstructionDataInvoke, InstructionDataInvokeCpi, PublicTransactionEvent } from '../state';
5
- export declare const CompressedAccountLayout: import("buffer-layout").Layout<unknown>;
6
- export declare const MerkleContextLayout: import("buffer-layout").Layout<unknown>;
7
- export declare const NewAddressParamsLayout: import("buffer-layout").Layout<unknown>;
4
+ import {
5
+ InstructionDataInvoke,
6
+ InstructionDataInvokeCpi,
7
+ PublicTransactionEvent,
8
+ } from '../state';
9
+ export declare const CompressedAccountLayout: import('buffer-layout').Layout<unknown>;
10
+ export declare const MerkleContextLayout: import('buffer-layout').Layout<unknown>;
11
+ export declare const NewAddressParamsLayout: import('buffer-layout').Layout<unknown>;
8
12
  export declare const InstructionDataInvokeLayout: Layout<InstructionDataInvoke>;
9
- export declare function encodeInstructionDataInvoke(data: InstructionDataInvoke): Buffer;
13
+ export declare function encodeInstructionDataInvoke(
14
+ data: InstructionDataInvoke,
15
+ ): Buffer;
10
16
  export declare const InstructionDataInvokeCpiLayout: Layout<InstructionDataInvokeCpi>;
11
- export declare function decodeInstructionDataInvoke(buffer: Buffer): InstructionDataInvoke;
12
- export declare function decodeInstructionDataInvokeCpi(buffer: Buffer): InstructionDataInvokeCpi;
17
+ export declare function decodeInstructionDataInvoke(
18
+ buffer: Buffer,
19
+ ): InstructionDataInvoke;
20
+ export declare function decodeInstructionDataInvokeCpi(
21
+ buffer: Buffer,
22
+ ): InstructionDataInvokeCpi;
13
23
  export type invokeAccountsLayoutParams = {
14
24
  feePayer: PublicKey;
15
25
  authority: PublicKey;
@@ -21,16 +31,24 @@ export type invokeAccountsLayoutParams = {
21
31
  decompressionRecipient: PublicKey | null;
22
32
  systemProgram: PublicKey;
23
33
  };
24
- export declare const invokeAccountsLayout: (accounts: invokeAccountsLayoutParams) => AccountMeta[];
34
+ export declare const invokeAccountsLayout: (
35
+ accounts: invokeAccountsLayoutParams,
36
+ ) => AccountMeta[];
25
37
  export declare const PublicTransactionEventLayout: Layout<PublicTransactionEvent>;
26
- export declare function encodePublicTransactionEvent(data: PublicTransactionEvent): Buffer;
27
- export declare function decodePublicTransactionEvent(buffer: Buffer): PublicTransactionEvent;
28
- export declare const AppendNullifyCreateAddressInputsMetaLayout: import("buffer-layout").Layout<unknown>;
29
- export declare const AppendLeavesInputLayout: import("buffer-layout").Layout<unknown>;
30
- export declare const InsertNullifierInputLayout: import("buffer-layout").Layout<unknown>;
31
- export declare const InsertAddressInputLayout: import("buffer-layout").Layout<unknown>;
32
- export declare const MerkleTreeSequenceNumberLayout: import("buffer-layout").Layout<unknown>;
33
- export declare function deserializeAppendNullifyCreateAddressInputsIndexer(buffer: Buffer): {
38
+ export declare function encodePublicTransactionEvent(
39
+ data: PublicTransactionEvent,
40
+ ): Buffer;
41
+ export declare function decodePublicTransactionEvent(
42
+ buffer: Buffer,
43
+ ): PublicTransactionEvent;
44
+ export declare const AppendNullifyCreateAddressInputsMetaLayout: import('buffer-layout').Layout<unknown>;
45
+ export declare const AppendLeavesInputLayout: import('buffer-layout').Layout<unknown>;
46
+ export declare const InsertNullifierInputLayout: import('buffer-layout').Layout<unknown>;
47
+ export declare const InsertAddressInputLayout: import('buffer-layout').Layout<unknown>;
48
+ export declare const MerkleTreeSequenceNumberLayout: import('buffer-layout').Layout<unknown>;
49
+ export declare function deserializeAppendNullifyCreateAddressInputsIndexer(
50
+ buffer: Buffer,
51
+ ): {
34
52
  meta: unknown;
35
53
  leaves: unknown[];
36
54
  nullifiers: unknown[];
@@ -38,4 +56,8 @@ export declare function deserializeAppendNullifyCreateAddressInputsIndexer(buffe
38
56
  sequence_numbers: unknown[];
39
57
  output_leaf_indices: number[];
40
58
  };
41
- export declare function convertToPublicTransactionEvent(decoded: any, remainingAccounts: PublicKey[], invokeData: InstructionDataInvoke): PublicTransactionEvent;
59
+ export declare function convertToPublicTransactionEvent(
60
+ decoded: any,
61
+ remainingAccounts: PublicKey[],
62
+ invokeData: InstructionDataInvoke,
63
+ ): PublicTransactionEvent;
@@ -1,8 +1,14 @@
1
1
  import BN from 'bn.js';
2
2
  import { PublicKey, TransactionInstruction } from '@solana/web3.js';
3
- import { CompressedAccount, CompressedAccountWithMerkleContext, CompressedProof } from '../state';
3
+ import {
4
+ CompressedAccount,
5
+ CompressedAccountWithMerkleContext,
6
+ CompressedProof,
7
+ } from '../state';
4
8
  import { NewAddressParams } from '../utils';
5
- export declare const sumUpLamports: (accounts: CompressedAccountWithMerkleContext[]) => BN;
9
+ export declare const sumUpLamports: (
10
+ accounts: CompressedAccountWithMerkleContext[],
11
+ ) => BN;
6
12
  /**
7
13
  * Create compressed account system transaction params
8
14
  */
@@ -159,34 +165,76 @@ export declare class LightSystemProgram {
159
165
  *
160
166
  */
161
167
  static deriveCompressedSolPda(): PublicKey;
162
- static createTransferOutputState(inputCompressedAccounts: CompressedAccountWithMerkleContext[], toAddress: PublicKey, lamports: number | BN): CompressedAccount[];
163
- static createDecompressOutputState(inputCompressedAccounts: CompressedAccountWithMerkleContext[], lamports: number | BN): CompressedAccount[];
168
+ static createTransferOutputState(
169
+ inputCompressedAccounts: CompressedAccountWithMerkleContext[],
170
+ toAddress: PublicKey,
171
+ lamports: number | BN,
172
+ ): CompressedAccount[];
173
+ static createDecompressOutputState(
174
+ inputCompressedAccounts: CompressedAccountWithMerkleContext[],
175
+ lamports: number | BN,
176
+ ): CompressedAccount[];
164
177
  /**
165
178
  * No data by default
166
179
  */
167
- static createNewAddressOutputState(address: number[], owner: PublicKey, lamports?: BN | number, inputCompressedAccounts?: CompressedAccountWithMerkleContext[]): CompressedAccount[];
180
+ static createNewAddressOutputState(
181
+ address: number[],
182
+ owner: PublicKey,
183
+ lamports?: BN | number,
184
+ inputCompressedAccounts?: CompressedAccountWithMerkleContext[],
185
+ ): CompressedAccount[];
168
186
  /**
169
187
  * Creates instruction to create compressed account with PDA.
170
188
  * Cannot write data.
171
189
  *
172
190
  * TODO: support transfer of lamports to the new account.
173
191
  */
174
- static createAccount({ payer, newAddressParams, newAddress, recentValidityProof, outputStateTree, inputCompressedAccounts, inputStateRootIndices, lamports, }: CreateAccountWithSeedParams): Promise<TransactionInstruction>;
192
+ static createAccount({
193
+ payer,
194
+ newAddressParams,
195
+ newAddress,
196
+ recentValidityProof,
197
+ outputStateTree,
198
+ inputCompressedAccounts,
199
+ inputStateRootIndices,
200
+ lamports,
201
+ }: CreateAccountWithSeedParams): Promise<TransactionInstruction>;
175
202
  /**
176
203
  * Creates a transaction instruction that transfers compressed lamports from
177
204
  * one owner to another.
178
205
  */
179
- static transfer({ payer, inputCompressedAccounts, toAddress, lamports, recentInputStateRootIndices, recentValidityProof, outputStateTrees, }: TransferParams): Promise<TransactionInstruction>;
206
+ static transfer({
207
+ payer,
208
+ inputCompressedAccounts,
209
+ toAddress,
210
+ lamports,
211
+ recentInputStateRootIndices,
212
+ recentValidityProof,
213
+ outputStateTrees,
214
+ }: TransferParams): Promise<TransactionInstruction>;
180
215
  /**
181
216
  * Creates a transaction instruction that transfers compressed lamports from
182
217
  * one owner to another.
183
218
  */
184
- static compress({ payer, toAddress, lamports, outputStateTree, }: CompressParams): Promise<TransactionInstruction>;
219
+ static compress({
220
+ payer,
221
+ toAddress,
222
+ lamports,
223
+ outputStateTree,
224
+ }: CompressParams): Promise<TransactionInstruction>;
185
225
  /**
186
226
  * Creates a transaction instruction that transfers compressed lamports from
187
227
  * one owner to another.
188
228
  */
189
- static decompress({ payer, inputCompressedAccounts, toAddress, lamports, recentInputStateRootIndices, recentValidityProof, outputStateTree, }: DecompressParams): Promise<TransactionInstruction>;
229
+ static decompress({
230
+ payer,
231
+ inputCompressedAccounts,
232
+ toAddress,
233
+ lamports,
234
+ recentInputStateRootIndices,
235
+ recentValidityProof,
236
+ outputStateTree,
237
+ }: DecompressParams): Promise<TransactionInstruction>;
190
238
  }
191
239
  /**
192
240
  * Selects the minimal number of compressed SOL accounts for a transfer.
@@ -195,5 +243,8 @@ export declare class LightSystemProgram {
195
243
  * 2. Accumulates the amount until it is greater than or equal to the transfer
196
244
  * amount
197
245
  */
198
- export declare function selectMinCompressedSolAccountsForTransfer(accounts: CompressedAccountWithMerkleContext[], transferLamports: BN | number): [selectedAccounts: CompressedAccountWithMerkleContext[], total: BN];
246
+ export declare function selectMinCompressedSolAccountsForTransfer(
247
+ accounts: CompressedAccountWithMerkleContext[],
248
+ transferLamports: BN | number,
249
+ ): [selectedAccounts: CompressedAccountWithMerkleContext[], total: BN];
199
250
  export {};