@lightprotocol/stateless.js 0.21.0 → 0.22.1-alpha.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 (77) hide show
  1. package/README.md +10 -10
  2. package/dist/cjs/browser/actions/compress.d.ts +2 -2
  3. package/dist/cjs/browser/actions/create-account.d.ts +3 -3
  4. package/dist/cjs/browser/actions/transfer.d.ts +1 -2
  5. package/dist/cjs/browser/compressible/action.d.ts +77 -0
  6. package/dist/cjs/browser/compressible/index.d.ts +13 -0
  7. package/dist/cjs/browser/compressible/instruction.d.ts +177 -0
  8. package/dist/cjs/browser/compressible/layout.d.ts +47 -0
  9. package/dist/cjs/browser/compressible/types.d.ts +112 -0
  10. package/dist/cjs/browser/compressible/utils.d.ts +16 -0
  11. package/dist/cjs/browser/constants.d.ts +31 -6
  12. package/dist/cjs/browser/index.cjs +1 -1
  13. package/dist/cjs/browser/index.cjs.map +1 -1
  14. package/dist/cjs/browser/index.d.ts +1 -2
  15. package/dist/cjs/browser/programs/index.d.ts +0 -1
  16. package/dist/cjs/browser/{idl.d.ts → programs/system/idl.d.ts} +5 -27
  17. package/dist/cjs/browser/programs/system/index.d.ts +5 -0
  18. package/dist/cjs/{node/programs → browser/programs/system}/layout.d.ts +10 -1
  19. package/dist/cjs/browser/programs/system/pack.d.ts +143 -0
  20. package/dist/cjs/browser/programs/{system.d.ts → system/program.d.ts} +13 -28
  21. package/dist/cjs/browser/programs/system/select-compressed-accounts.d.ts +10 -0
  22. package/dist/cjs/browser/rpc-interface.d.ts +1593 -51
  23. package/dist/cjs/browser/rpc.d.ts +31 -37
  24. package/dist/cjs/browser/state/compressed-account.d.ts +140 -6
  25. package/dist/cjs/browser/state/types.d.ts +265 -26
  26. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +1 -10
  27. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +2 -2
  28. package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +20 -40
  29. package/dist/cjs/browser/utils/address.d.ts +13 -0
  30. package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +1 -1
  31. package/dist/cjs/browser/utils/conversion.d.ts +3 -0
  32. package/dist/cjs/browser/utils/get-state-tree-infos.d.ts +16 -9
  33. package/dist/cjs/browser/utils/index.d.ts +2 -2
  34. package/dist/cjs/browser/utils/packed-accounts.d.ts +161 -0
  35. package/dist/cjs/browser/utils/send-and-confirm.d.ts +1 -1
  36. package/dist/cjs/browser/utils/validation.d.ts +2 -2
  37. package/dist/cjs/node/actions/compress.d.ts +2 -2
  38. package/dist/cjs/node/actions/create-account.d.ts +3 -3
  39. package/dist/cjs/node/actions/transfer.d.ts +1 -2
  40. package/dist/cjs/node/compressible/action.d.ts +77 -0
  41. package/dist/cjs/node/compressible/index.d.ts +13 -0
  42. package/dist/cjs/node/compressible/instruction.d.ts +177 -0
  43. package/dist/cjs/node/compressible/layout.d.ts +47 -0
  44. package/dist/cjs/node/compressible/types.d.ts +112 -0
  45. package/dist/cjs/node/compressible/utils.d.ts +16 -0
  46. package/dist/cjs/node/constants.d.ts +31 -6
  47. package/dist/cjs/node/index.cjs +1 -1
  48. package/dist/cjs/node/index.cjs.map +1 -1
  49. package/dist/cjs/node/index.d.ts +1 -2
  50. package/dist/cjs/node/programs/index.d.ts +0 -1
  51. package/dist/cjs/node/{idl.d.ts → programs/system/idl.d.ts} +5 -27
  52. package/dist/cjs/node/programs/system/index.d.ts +5 -0
  53. package/dist/cjs/{browser/programs → node/programs/system}/layout.d.ts +10 -1
  54. package/dist/cjs/node/programs/system/pack.d.ts +143 -0
  55. package/dist/cjs/node/programs/{system.d.ts → system/program.d.ts} +13 -28
  56. package/dist/cjs/node/programs/system/select-compressed-accounts.d.ts +10 -0
  57. package/dist/cjs/node/rpc-interface.d.ts +1593 -51
  58. package/dist/cjs/node/rpc.d.ts +31 -37
  59. package/dist/cjs/node/state/compressed-account.d.ts +140 -6
  60. package/dist/cjs/node/state/types.d.ts +265 -26
  61. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-accounts.d.ts +1 -10
  62. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +2 -2
  63. package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +20 -40
  64. package/dist/cjs/node/utils/address.d.ts +13 -0
  65. package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +1 -1
  66. package/dist/cjs/node/utils/conversion.d.ts +3 -0
  67. package/dist/cjs/node/utils/get-state-tree-infos.d.ts +16 -9
  68. package/dist/cjs/node/utils/index.d.ts +2 -2
  69. package/dist/cjs/node/utils/packed-accounts.d.ts +161 -0
  70. package/dist/cjs/node/utils/send-and-confirm.d.ts +1 -1
  71. package/dist/cjs/node/utils/validation.d.ts +2 -2
  72. package/dist/types/index.d.ts +3391 -864
  73. package/package.json +13 -6
  74. package/dist/cjs/browser/instruction/index.d.ts +0 -1
  75. package/dist/cjs/browser/instruction/pack-compressed-accounts.d.ts +0 -49
  76. package/dist/cjs/node/instruction/index.d.ts +0 -1
  77. package/dist/cjs/node/instruction/pack-compressed-accounts.d.ts +0 -49
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightprotocol/stateless.js",
3
- "version": "0.21.0",
3
+ "version": "0.22.1-alpha.0",
4
4
  "description": "JavaScript API for Light & ZK Compression",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/node/index.cjs",
@@ -98,25 +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",
102
106
  "test:unit:tree-info": "vitest run tests/unit/utils/tree-info.test.ts --reporter=verbose",
103
107
  "test:conversions": "vitest run tests/unit/utils/conversion.test.ts --reporter=verbose",
104
- "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",
105
110
  "test:e2e:transfer": "pnpm test-validator && vitest run tests/e2e/transfer.test.ts --reporter=verbose",
106
111
  "test:e2e:compress": "pnpm test-validator && vitest run tests/e2e/compress.test.ts --reporter=verbose",
107
112
  "test:e2e:test-rpc": "pnpm test-validator && vitest run tests/e2e/test-rpc.test.ts --reporter=verbose --bail=1",
108
113
  "test:e2e:rpc-interop": "pnpm test-validator && vitest run tests/e2e/rpc-interop.test.ts --reporter=verbose --bail=1",
109
- "test:e2e:rpc-multi-trees": "pnpm test-validator && vitest run tests/e2e/rpc-multi-trees.test.ts",
114
+ "test:e2e:rpc-multi-trees": "pnpm test-validator && vitest run tests/e2e/rpc-multi-trees.test.ts --reporter=verbose --bail=1",
110
115
  "test:e2e:browser": "pnpm playwright test",
111
- "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",
112
117
  "test:index": "vitest run tests/e2e/program.test.ts",
113
118
  "test:e2e:layout": "vitest run tests/e2e/layout.test.ts --reporter=verbose",
114
119
  "test:e2e:safe-conversion": "vitest run tests/e2e/safe-conversion.test.ts --reporter=verbose",
115
120
  "test:verbose": "vitest run --reporter=verbose",
116
121
  "test:testnet": "vitest run tests/e2e/testnet.test.ts --reporter=verbose",
117
122
  "pull-idls": "../../scripts/push-stateless-js-idls.sh && ../../scripts/push-compressed-token-idl.sh",
118
- "build": "rimraf dist && pnpm build:bundle",
119
- "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",
120
127
  "format": "prettier --write .",
121
128
  "lint": "eslint ."
122
129
  }
@@ -1 +0,0 @@
1
- export * from './pack-compressed-accounts';
@@ -1,49 +0,0 @@
1
- import { AccountMeta, PublicKey } from '@solana/web3.js';
2
- import { CompressedAccount, OutputCompressedAccountWithPackedContext, PackedCompressedAccountWithMerkleContext, StateTreeInfo } 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
14
- * to be inserted into the
15
- * output state. Defaults to
16
- * the 0th state tree of the
17
- * input state. Gets padded to
18
- * the length of
19
- * outputCompressedAccounts.
20
- * @param numberOfOutputCompressedAccounts The number of output
21
- * compressed accounts.
22
- *
23
- * @returns Padded output state trees.
24
- */
25
- export declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey, numberOfOutputCompressedAccounts: number): 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 outputStateTreeInfo The output state tree info. Gets
39
- * padded to the length of
40
- * outputCompressedAccounts.
41
- *
42
- * @param remainingAccounts Optional existing array of accounts
43
- * to append to.
44
- **/
45
- export declare function packCompressedAccounts(inputCompressedAccounts: CompressedAccountWithMerkleContext[], inputStateRootIndices: number[], outputCompressedAccounts: CompressedAccount[], outputStateTreeInfo?: StateTreeInfo, remainingAccounts?: PublicKey[]): {
46
- packedInputCompressedAccounts: PackedCompressedAccountWithMerkleContext[];
47
- packedOutputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
48
- remainingAccounts: PublicKey[];
49
- };
@@ -1 +0,0 @@
1
- export * from './pack-compressed-accounts';
@@ -1,49 +0,0 @@
1
- import { AccountMeta, PublicKey } from '@solana/web3.js';
2
- import { CompressedAccount, OutputCompressedAccountWithPackedContext, PackedCompressedAccountWithMerkleContext, StateTreeInfo } 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
14
- * to be inserted into the
15
- * output state. Defaults to
16
- * the 0th state tree of the
17
- * input state. Gets padded to
18
- * the length of
19
- * outputCompressedAccounts.
20
- * @param numberOfOutputCompressedAccounts The number of output
21
- * compressed accounts.
22
- *
23
- * @returns Padded output state trees.
24
- */
25
- export declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey, numberOfOutputCompressedAccounts: number): 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 outputStateTreeInfo The output state tree info. Gets
39
- * padded to the length of
40
- * outputCompressedAccounts.
41
- *
42
- * @param remainingAccounts Optional existing array of accounts
43
- * to append to.
44
- **/
45
- export declare function packCompressedAccounts(inputCompressedAccounts: CompressedAccountWithMerkleContext[], inputStateRootIndices: number[], outputCompressedAccounts: CompressedAccount[], outputStateTreeInfo?: StateTreeInfo, remainingAccounts?: PublicKey[]): {
46
- packedInputCompressedAccounts: PackedCompressedAccountWithMerkleContext[];
47
- packedOutputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
48
- remainingAccounts: PublicKey[];
49
- };