@lightprotocol/stateless.js 0.20.9 → 0.22.0

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 (76) hide show
  1. package/dist/cjs/browser/actions/compress.d.ts +9 -7
  2. package/dist/cjs/browser/actions/create-account.d.ts +25 -28
  3. package/dist/cjs/browser/actions/decompress.d.ts +6 -7
  4. package/dist/cjs/browser/actions/index.d.ts +1 -1
  5. package/dist/cjs/browser/actions/transfer.d.ts +7 -11
  6. package/dist/cjs/browser/constants.d.ts +40 -7
  7. package/dist/cjs/browser/index.cjs +1 -1
  8. package/dist/cjs/browser/index.cjs.map +1 -1
  9. package/dist/cjs/browser/index.d.ts +1 -3
  10. package/dist/cjs/browser/programs/index.d.ts +0 -1
  11. package/dist/cjs/{node → browser/programs/system}/idl.d.ts +5 -27
  12. package/dist/cjs/browser/programs/system/index.d.ts +5 -0
  13. package/dist/cjs/browser/programs/{layout.d.ts → system/layout.d.ts} +37 -1
  14. package/dist/cjs/browser/programs/system/pack.d.ts +74 -0
  15. package/dist/cjs/browser/programs/{system.d.ts → system/program.d.ts} +25 -49
  16. package/dist/cjs/browser/programs/system/select-compressed-accounts.d.ts +10 -0
  17. package/dist/cjs/browser/rpc-interface.d.ts +1689 -82
  18. package/dist/cjs/browser/rpc.d.ts +27 -67
  19. package/dist/cjs/browser/state/BN254.d.ts +0 -1
  20. package/dist/cjs/browser/state/bn.d.ts +3 -0
  21. package/dist/cjs/browser/state/compressed-account.d.ts +189 -15
  22. package/dist/cjs/browser/state/index.d.ts +1 -0
  23. package/dist/cjs/browser/state/types.d.ts +345 -31
  24. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +3 -3
  25. package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +21 -49
  26. package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +1 -1
  27. package/dist/cjs/browser/utils/conversion.d.ts +2 -0
  28. package/dist/cjs/browser/utils/get-state-tree-infos.d.ts +48 -0
  29. package/dist/cjs/browser/utils/index.d.ts +4 -2
  30. package/dist/cjs/browser/utils/parse-validity-proof.d.ts +3 -3
  31. package/dist/cjs/browser/utils/send-and-confirm.d.ts +1 -1
  32. package/dist/cjs/browser/utils/state-tree-lookup-table.d.ts +68 -0
  33. package/dist/cjs/browser/utils/validation.d.ts +2 -2
  34. package/dist/cjs/node/actions/compress.d.ts +9 -7
  35. package/dist/cjs/node/actions/create-account.d.ts +25 -28
  36. package/dist/cjs/node/actions/decompress.d.ts +6 -7
  37. package/dist/cjs/node/actions/index.d.ts +1 -1
  38. package/dist/cjs/node/actions/transfer.d.ts +7 -11
  39. package/dist/cjs/node/constants.d.ts +40 -7
  40. package/dist/cjs/node/index.cjs +1 -1
  41. package/dist/cjs/node/index.cjs.map +1 -1
  42. package/dist/cjs/node/index.d.ts +1 -3
  43. package/dist/cjs/node/programs/index.d.ts +0 -1
  44. package/dist/cjs/{browser → node/programs/system}/idl.d.ts +5 -27
  45. package/dist/cjs/node/programs/system/index.d.ts +5 -0
  46. package/dist/cjs/node/programs/{layout.d.ts → system/layout.d.ts} +37 -1
  47. package/dist/cjs/node/programs/system/pack.d.ts +74 -0
  48. package/dist/cjs/node/programs/{system.d.ts → system/program.d.ts} +25 -49
  49. package/dist/cjs/node/programs/system/select-compressed-accounts.d.ts +10 -0
  50. package/dist/cjs/node/rpc-interface.d.ts +1689 -82
  51. package/dist/cjs/node/rpc.d.ts +27 -67
  52. package/dist/cjs/node/state/BN254.d.ts +0 -1
  53. package/dist/cjs/node/state/bn.d.ts +3 -0
  54. package/dist/cjs/node/state/compressed-account.d.ts +189 -15
  55. package/dist/cjs/node/state/index.d.ts +1 -0
  56. package/dist/cjs/node/state/types.d.ts +345 -31
  57. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +3 -3
  58. package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +21 -49
  59. package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +1 -1
  60. package/dist/cjs/node/utils/conversion.d.ts +2 -0
  61. package/dist/cjs/node/utils/get-state-tree-infos.d.ts +48 -0
  62. package/dist/cjs/node/utils/index.d.ts +4 -2
  63. package/dist/cjs/node/utils/parse-validity-proof.d.ts +3 -3
  64. package/dist/cjs/node/utils/send-and-confirm.d.ts +1 -1
  65. package/dist/cjs/node/utils/state-tree-lookup-table.d.ts +68 -0
  66. package/dist/cjs/node/utils/validation.d.ts +2 -2
  67. package/dist/types/index.d.ts +3177 -1063
  68. package/package.json +16 -8
  69. package/dist/cjs/browser/instruction/index.d.ts +0 -1
  70. package/dist/cjs/browser/instruction/pack-compressed-accounts.d.ts +0 -51
  71. package/dist/cjs/browser/utils/get-light-state-tree-info.d.ts +0 -76
  72. package/dist/cjs/node/instruction/index.d.ts +0 -1
  73. package/dist/cjs/node/instruction/pack-compressed-accounts.d.ts +0 -51
  74. package/dist/cjs/node/utils/get-light-state-tree-info.d.ts +0 -76
  75. /package/dist/cjs/browser/{actions/common.d.ts → utils/dedupe-signer.d.ts} +0 -0
  76. /package/dist/cjs/node/{actions/common.d.ts → utils/dedupe-signer.d.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightprotocol/stateless.js",
3
- "version": "0.20.9",
3
+ "version": "0.22.0",
4
4
  "description": "JavaScript API for Light & ZK Compression",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/node/index.cjs",
@@ -98,24 +98,32 @@
98
98
  "scripts": {
99
99
  "test": "pnpm test:unit:all && pnpm test:e2e:all",
100
100
  "test-all": "vitest run",
101
+ "test:v1": "LIGHT_PROTOCOL_VERSION=V1 pnpm test",
102
+ "test:v2": "LIGHT_PROTOCOL_VERSION=V2 pnpm test",
101
103
  "test:unit:all": "vitest run tests/unit --reporter=verbose",
104
+ "test:unit:all:v1": "LIGHT_PROTOCOL_VERSION=V1 vitest run tests/unit --reporter=verbose",
105
+ "test:unit:all:v2": "LIGHT_PROTOCOL_VERSION=V2 vitest run tests/unit --reporter=verbose",
106
+ "test:unit:tree-info": "vitest run tests/unit/utils/tree-info.test.ts --reporter=verbose",
102
107
  "test:conversions": "vitest run tests/unit/utils/conversion.test.ts --reporter=verbose",
103
- "test-validator": "./../../cli/test_bin/run test-validator --prover-run-mode rpc",
108
+ "test-validator": "./../../cli/test_bin/run test-validator",
109
+ "test-validator-skip-prover": "./../../cli/test_bin/run test-validator --skip-prover",
104
110
  "test:e2e:transfer": "pnpm test-validator && vitest run tests/e2e/transfer.test.ts --reporter=verbose",
105
111
  "test:e2e:compress": "pnpm test-validator && vitest run tests/e2e/compress.test.ts --reporter=verbose",
106
- "test:e2e:test-rpc": "pnpm test-validator && vitest run tests/e2e/test-rpc.test.ts",
107
- "test:e2e:rpc-interop": "pnpm test-validator && vitest run tests/e2e/rpc-interop.test.ts",
108
- "test:e2e:rpc-multi-trees": "pnpm test-validator && vitest run tests/e2e/rpc-multi-trees.test.ts",
112
+ "test:e2e:test-rpc": "pnpm test-validator && vitest run tests/e2e/test-rpc.test.ts --reporter=verbose --bail=1",
113
+ "test:e2e:rpc-interop": "pnpm test-validator && vitest run tests/e2e/rpc-interop.test.ts --reporter=verbose --bail=1",
114
+ "test:e2e:rpc-multi-trees": "pnpm test-validator && vitest run tests/e2e/rpc-multi-trees.test.ts --reporter=verbose --bail=1",
109
115
  "test:e2e:browser": "pnpm playwright test",
110
- "test:e2e:all": "pnpm test-validator && vitest run tests/e2e/test-rpc.test.ts && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/rpc-interop.test.ts && vitest run tests/e2e/rpc-multi-trees.test.ts && vitest run tests/e2e/layout.test.ts && vitest run tests/e2e/safe-conversion.test.ts",
116
+ "test:e2e:all": "pnpm test-validator && vitest run tests/e2e/test-rpc.test.ts && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/rpc-interop.test.ts && pnpm test-validator-skip-prover && vitest run tests/e2e/rpc-multi-trees.test.ts && vitest run tests/e2e/layout.test.ts && vitest run tests/e2e/safe-conversion.test.ts",
111
117
  "test:index": "vitest run tests/e2e/program.test.ts",
112
118
  "test:e2e:layout": "vitest run tests/e2e/layout.test.ts --reporter=verbose",
113
119
  "test:e2e:safe-conversion": "vitest run tests/e2e/safe-conversion.test.ts --reporter=verbose",
114
120
  "test:verbose": "vitest run --reporter=verbose",
115
121
  "test:testnet": "vitest run tests/e2e/testnet.test.ts --reporter=verbose",
116
122
  "pull-idls": "../../scripts/push-stateless-js-idls.sh && ../../scripts/push-compressed-token-idl.sh",
117
- "build": "rimraf dist && pnpm build:bundle",
118
- "build:bundle": "rollup -c",
123
+ "build": "if [ \"$LIGHT_PROTOCOL_VERSION\" = \"V2\" ]; then LIGHT_PROTOCOL_VERSION=V2 pnpm build:bundle; else LIGHT_PROTOCOL_VERSION=V1 pnpm build:bundle; fi",
124
+ "build:bundle": "rimraf dist && rollup -c",
125
+ "build:v1": "LIGHT_PROTOCOL_VERSION=V1 pnpm build:bundle",
126
+ "build:v2": "LIGHT_PROTOCOL_VERSION=V2 pnpm build:bundle",
119
127
  "format": "prettier --write .",
120
128
  "lint": "eslint ."
121
129
  }
@@ -1 +0,0 @@
1
- export * from './pack-compressed-accounts';
@@ -1,51 +0,0 @@
1
- import { AccountMeta, PublicKey } from '@solana/web3.js';
2
- import { CompressedAccount, OutputCompressedAccountWithPackedContext, PackedCompressedAccountWithMerkleContext } from '../state';
3
- import { CompressedAccountWithMerkleContext } from '../state/compressed-account';
4
- /**
5
- * @internal Finds the index of a PublicKey in an array, or adds it if not
6
- * present
7
- * */
8
- export declare function getIndexOrAdd(accountsArray: PublicKey[], key: PublicKey): number;
9
- /**
10
- * @internal
11
- * Pads output state trees with the 0th state tree of the input state.
12
- *
13
- * @param outputStateMerkleTrees Optional output state trees to be
14
- * inserted into the output state.
15
- * Defaults to the 0th state tree of
16
- * the input state. Gets padded to the
17
- * length of outputCompressedAccounts.
18
- * @param numberOfOutputCompressedAccounts The number of output compressed
19
- * accounts.
20
- * @param inputCompressedAccountsWithMerkleContext The input compressed accounts
21
- * with merkle context.
22
- *
23
- * @returns Padded output state trees.
24
- */
25
- export declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey[] | PublicKey | undefined, numberOfOutputCompressedAccounts: number, inputCompressedAccountsWithMerkleContext: CompressedAccountWithMerkleContext[]): PublicKey[];
26
- export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
27
- /**
28
- * Packs Compressed Accounts.
29
- *
30
- * Replaces PublicKey with index pointer to remaining accounts.
31
- *
32
- *
33
- * @param inputCompressedAccounts Ix input state to be consumed
34
- * @param inputStateRootIndices The recent state root indices of the
35
- * input state. The expiry is tied to
36
- * the proof.
37
- * @param outputCompressedAccounts Ix output state to be created
38
- * @param outputStateMerkleTrees Optional output state trees to be
39
- * inserted into the output state.
40
- * Defaults to the 0th state tree of
41
- * the input state. Gets padded to the
42
- * length of outputCompressedAccounts.
43
- *
44
- * @param remainingAccounts Optional existing array of accounts
45
- * to append to.
46
- **/
47
- export declare function packCompressedAccounts(inputCompressedAccounts: CompressedAccountWithMerkleContext[], inputStateRootIndices: number[], outputCompressedAccounts: CompressedAccount[], outputStateMerkleTrees?: PublicKey[] | PublicKey, remainingAccounts?: PublicKey[]): {
48
- packedInputCompressedAccounts: PackedCompressedAccountWithMerkleContext[];
49
- packedOutputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
50
- remainingAccounts: PublicKey[];
51
- };
@@ -1,76 +0,0 @@
1
- import { Connection, Keypair, PublicKey } from '@solana/web3.js';
2
- import { ActiveTreeBundle } from '../state/types';
3
- /**
4
- * Create two lookup tables storing all public state tree and queue addresses
5
- * returns lookup table addresses and txId
6
- *
7
- * @internal
8
- * @param connection - Connection to the Solana network
9
- * @param payer - Keypair of the payer
10
- * @param authority - Keypair of the authority
11
- * @param recentSlot - Slot of the recent block
12
- */
13
- export declare function createStateTreeLookupTable({ connection, payer, authority, recentSlot, }: {
14
- connection: Connection;
15
- payer: Keypair;
16
- authority: Keypair;
17
- recentSlot: number;
18
- }): Promise<{
19
- address: PublicKey;
20
- txId: string;
21
- }>;
22
- /**
23
- * Extend state tree lookup table with new state tree and queue addresses
24
- * @internal
25
- * @param connection - Connection to the Solana network
26
- * @param tableAddress - Address of the lookup table to extend
27
- * @param newStateTreeAddresses - Addresses of the new state trees to add
28
- * @param newQueueAddresses - Addresses of the new queues to add
29
- * @param newCpiContextAddresses - Addresses of the new cpi contexts to add
30
- * @param payer - Keypair of the payer
31
- * @param authority - Keypair of the authority
32
- */
33
- export declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, newCpiContextAddresses, payer, authority, }: {
34
- connection: Connection;
35
- tableAddress: PublicKey;
36
- newStateTreeAddresses: PublicKey[];
37
- newQueueAddresses: PublicKey[];
38
- newCpiContextAddresses: PublicKey[];
39
- payer: Keypair;
40
- authority: Keypair;
41
- }): Promise<{
42
- tableAddress: PublicKey;
43
- txId: string;
44
- }>;
45
- /**
46
- * Adds state tree address to lookup table. Acts as nullifier lookup for rolled
47
- * over state trees.
48
- * @internal
49
- * @param connection - Connection to the Solana network
50
- * @param stateTreeAddress - Address of the state tree to nullify
51
- * @param nullifyTableAddress - Address of the nullifier lookup table to store
52
- * address in
53
- * @param stateTreeLookupTableAddress - lookup table storing all state tree
54
- * addresses
55
- * @param payer - Keypair of the payer
56
- * @param authority - Keypair of the authority
57
- */
58
- export declare function nullifyLookupTable({ connection, fullStateTreeAddress, nullifyTableAddress, stateTreeLookupTableAddress, payer, authority, }: {
59
- connection: Connection;
60
- fullStateTreeAddress: PublicKey;
61
- nullifyTableAddress: PublicKey;
62
- stateTreeLookupTableAddress: PublicKey;
63
- payer: Keypair;
64
- authority: Keypair;
65
- }): Promise<{
66
- txId: string;
67
- }>;
68
- /**
69
- * Get most recent , active state tree data
70
- * we store in lookup table for each public state tree
71
- */
72
- export declare function getLightStateTreeInfo({ connection, stateTreeLookupTableAddress, nullifyTableAddress, }: {
73
- connection: Connection;
74
- stateTreeLookupTableAddress: PublicKey;
75
- nullifyTableAddress: PublicKey;
76
- }): Promise<ActiveTreeBundle[]>;
@@ -1 +0,0 @@
1
- export * from './pack-compressed-accounts';
@@ -1,51 +0,0 @@
1
- import { AccountMeta, PublicKey } from '@solana/web3.js';
2
- import { CompressedAccount, OutputCompressedAccountWithPackedContext, PackedCompressedAccountWithMerkleContext } from '../state';
3
- import { CompressedAccountWithMerkleContext } from '../state/compressed-account';
4
- /**
5
- * @internal Finds the index of a PublicKey in an array, or adds it if not
6
- * present
7
- * */
8
- export declare function getIndexOrAdd(accountsArray: PublicKey[], key: PublicKey): number;
9
- /**
10
- * @internal
11
- * Pads output state trees with the 0th state tree of the input state.
12
- *
13
- * @param outputStateMerkleTrees Optional output state trees to be
14
- * inserted into the output state.
15
- * Defaults to the 0th state tree of
16
- * the input state. Gets padded to the
17
- * length of outputCompressedAccounts.
18
- * @param numberOfOutputCompressedAccounts The number of output compressed
19
- * accounts.
20
- * @param inputCompressedAccountsWithMerkleContext The input compressed accounts
21
- * with merkle context.
22
- *
23
- * @returns Padded output state trees.
24
- */
25
- export declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey[] | PublicKey | undefined, numberOfOutputCompressedAccounts: number, inputCompressedAccountsWithMerkleContext: CompressedAccountWithMerkleContext[]): PublicKey[];
26
- export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
27
- /**
28
- * Packs Compressed Accounts.
29
- *
30
- * Replaces PublicKey with index pointer to remaining accounts.
31
- *
32
- *
33
- * @param inputCompressedAccounts Ix input state to be consumed
34
- * @param inputStateRootIndices The recent state root indices of the
35
- * input state. The expiry is tied to
36
- * the proof.
37
- * @param outputCompressedAccounts Ix output state to be created
38
- * @param outputStateMerkleTrees Optional output state trees to be
39
- * inserted into the output state.
40
- * Defaults to the 0th state tree of
41
- * the input state. Gets padded to the
42
- * length of outputCompressedAccounts.
43
- *
44
- * @param remainingAccounts Optional existing array of accounts
45
- * to append to.
46
- **/
47
- export declare function packCompressedAccounts(inputCompressedAccounts: CompressedAccountWithMerkleContext[], inputStateRootIndices: number[], outputCompressedAccounts: CompressedAccount[], outputStateMerkleTrees?: PublicKey[] | PublicKey, remainingAccounts?: PublicKey[]): {
48
- packedInputCompressedAccounts: PackedCompressedAccountWithMerkleContext[];
49
- packedOutputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
50
- remainingAccounts: PublicKey[];
51
- };
@@ -1,76 +0,0 @@
1
- import { Connection, Keypair, PublicKey } from '@solana/web3.js';
2
- import { ActiveTreeBundle } from '../state/types';
3
- /**
4
- * Create two lookup tables storing all public state tree and queue addresses
5
- * returns lookup table addresses and txId
6
- *
7
- * @internal
8
- * @param connection - Connection to the Solana network
9
- * @param payer - Keypair of the payer
10
- * @param authority - Keypair of the authority
11
- * @param recentSlot - Slot of the recent block
12
- */
13
- export declare function createStateTreeLookupTable({ connection, payer, authority, recentSlot, }: {
14
- connection: Connection;
15
- payer: Keypair;
16
- authority: Keypair;
17
- recentSlot: number;
18
- }): Promise<{
19
- address: PublicKey;
20
- txId: string;
21
- }>;
22
- /**
23
- * Extend state tree lookup table with new state tree and queue addresses
24
- * @internal
25
- * @param connection - Connection to the Solana network
26
- * @param tableAddress - Address of the lookup table to extend
27
- * @param newStateTreeAddresses - Addresses of the new state trees to add
28
- * @param newQueueAddresses - Addresses of the new queues to add
29
- * @param newCpiContextAddresses - Addresses of the new cpi contexts to add
30
- * @param payer - Keypair of the payer
31
- * @param authority - Keypair of the authority
32
- */
33
- export declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, newCpiContextAddresses, payer, authority, }: {
34
- connection: Connection;
35
- tableAddress: PublicKey;
36
- newStateTreeAddresses: PublicKey[];
37
- newQueueAddresses: PublicKey[];
38
- newCpiContextAddresses: PublicKey[];
39
- payer: Keypair;
40
- authority: Keypair;
41
- }): Promise<{
42
- tableAddress: PublicKey;
43
- txId: string;
44
- }>;
45
- /**
46
- * Adds state tree address to lookup table. Acts as nullifier lookup for rolled
47
- * over state trees.
48
- * @internal
49
- * @param connection - Connection to the Solana network
50
- * @param stateTreeAddress - Address of the state tree to nullify
51
- * @param nullifyTableAddress - Address of the nullifier lookup table to store
52
- * address in
53
- * @param stateTreeLookupTableAddress - lookup table storing all state tree
54
- * addresses
55
- * @param payer - Keypair of the payer
56
- * @param authority - Keypair of the authority
57
- */
58
- export declare function nullifyLookupTable({ connection, fullStateTreeAddress, nullifyTableAddress, stateTreeLookupTableAddress, payer, authority, }: {
59
- connection: Connection;
60
- fullStateTreeAddress: PublicKey;
61
- nullifyTableAddress: PublicKey;
62
- stateTreeLookupTableAddress: PublicKey;
63
- payer: Keypair;
64
- authority: Keypair;
65
- }): Promise<{
66
- txId: string;
67
- }>;
68
- /**
69
- * Get most recent , active state tree data
70
- * we store in lookup table for each public state tree
71
- */
72
- export declare function getLightStateTreeInfo({ connection, stateTreeLookupTableAddress, nullifyTableAddress, }: {
73
- connection: Connection;
74
- stateTreeLookupTableAddress: PublicKey;
75
- nullifyTableAddress: PublicKey;
76
- }): Promise<ActiveTreeBundle[]>;