@lightprotocol/stateless.js 0.21.0 → 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.
- package/dist/cjs/browser/actions/compress.d.ts +2 -2
- package/dist/cjs/browser/actions/create-account.d.ts +3 -3
- package/dist/cjs/browser/actions/transfer.d.ts +1 -2
- package/dist/cjs/browser/constants.d.ts +26 -3
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/index.d.ts +0 -2
- package/dist/cjs/browser/programs/index.d.ts +0 -1
- package/dist/cjs/browser/{idl.d.ts → programs/system/idl.d.ts} +5 -27
- package/dist/cjs/browser/programs/system/index.d.ts +5 -0
- package/dist/cjs/{node/programs → browser/programs/system}/layout.d.ts +10 -1
- package/dist/cjs/{node/instruction/pack-compressed-accounts.d.ts → browser/programs/system/pack.d.ts} +28 -3
- package/dist/cjs/browser/programs/{system.d.ts → system/program.d.ts} +13 -28
- package/dist/cjs/browser/programs/system/select-compressed-accounts.d.ts +10 -0
- package/dist/cjs/browser/rpc-interface.d.ts +1553 -11
- package/dist/cjs/browser/rpc.d.ts +14 -34
- package/dist/cjs/browser/state/compressed-account.d.ts +140 -6
- package/dist/cjs/browser/state/types.d.ts +265 -26
- package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +1 -10
- package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +2 -2
- package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +14 -38
- package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +1 -1
- package/dist/cjs/browser/utils/conversion.d.ts +2 -0
- package/dist/cjs/browser/utils/get-state-tree-infos.d.ts +16 -9
- package/dist/cjs/browser/utils/index.d.ts +1 -2
- package/dist/cjs/browser/utils/send-and-confirm.d.ts +1 -1
- package/dist/cjs/browser/utils/validation.d.ts +2 -2
- package/dist/cjs/node/actions/compress.d.ts +2 -2
- package/dist/cjs/node/actions/create-account.d.ts +3 -3
- package/dist/cjs/node/actions/transfer.d.ts +1 -2
- package/dist/cjs/node/constants.d.ts +26 -3
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/index.d.ts +0 -2
- package/dist/cjs/node/programs/index.d.ts +0 -1
- package/dist/cjs/node/{idl.d.ts → programs/system/idl.d.ts} +5 -27
- package/dist/cjs/node/programs/system/index.d.ts +5 -0
- package/dist/cjs/{browser/programs → node/programs/system}/layout.d.ts +10 -1
- package/dist/cjs/{browser/instruction/pack-compressed-accounts.d.ts → node/programs/system/pack.d.ts} +28 -3
- package/dist/cjs/node/programs/{system.d.ts → system/program.d.ts} +13 -28
- package/dist/cjs/node/programs/system/select-compressed-accounts.d.ts +10 -0
- package/dist/cjs/node/rpc-interface.d.ts +1553 -11
- package/dist/cjs/node/rpc.d.ts +14 -34
- package/dist/cjs/node/state/compressed-account.d.ts +140 -6
- package/dist/cjs/node/state/types.d.ts +265 -26
- package/dist/cjs/node/test-helpers/test-rpc/get-compressed-accounts.d.ts +1 -10
- package/dist/cjs/node/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +2 -2
- package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +14 -38
- package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +1 -1
- package/dist/cjs/node/utils/conversion.d.ts +2 -0
- package/dist/cjs/node/utils/get-state-tree-infos.d.ts +16 -9
- package/dist/cjs/node/utils/index.d.ts +1 -2
- package/dist/cjs/node/utils/send-and-confirm.d.ts +1 -1
- package/dist/cjs/node/utils/validation.d.ts +2 -2
- package/dist/types/index.d.ts +2784 -877
- package/package.json +13 -6
- package/dist/cjs/browser/instruction/index.d.ts +0 -1
- package/dist/cjs/node/instruction/index.d.ts +0 -1
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export * from './actions';
|
|
2
|
-
export * from './instruction';
|
|
3
2
|
export * from './programs';
|
|
4
3
|
export * from './state';
|
|
5
4
|
export * from './test-helpers';
|
|
6
5
|
export * from './utils';
|
|
7
6
|
export * from './constants';
|
|
8
7
|
export * from './errors';
|
|
9
|
-
export { LightSystemProgram as LightSystemProgramIDL, IDL } from './idl';
|
|
10
8
|
export * from './rpc-interface';
|
|
11
9
|
export * from './rpc';
|
|
@@ -698,7 +698,7 @@ export type LightSystemProgram = {
|
|
|
698
698
|
type: 'u8';
|
|
699
699
|
},
|
|
700
700
|
{
|
|
701
|
-
name: '
|
|
701
|
+
name: 'queuePubkeyIndex';
|
|
702
702
|
type: 'u8';
|
|
703
703
|
},
|
|
704
704
|
{
|
|
@@ -706,30 +706,8 @@ export type LightSystemProgram = {
|
|
|
706
706
|
type: 'u32';
|
|
707
707
|
},
|
|
708
708
|
{
|
|
709
|
-
name: '
|
|
710
|
-
type:
|
|
711
|
-
option: {
|
|
712
|
-
defined: 'QueueIndex';
|
|
713
|
-
};
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
];
|
|
717
|
-
};
|
|
718
|
-
},
|
|
719
|
-
{
|
|
720
|
-
name: 'QueueIndex';
|
|
721
|
-
type: {
|
|
722
|
-
kind: 'struct';
|
|
723
|
-
fields: [
|
|
724
|
-
{
|
|
725
|
-
name: 'queueId';
|
|
726
|
-
docs: ['Id of queue in queue account.'];
|
|
727
|
-
type: 'u8';
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
name: 'index';
|
|
731
|
-
docs: ['Index of compressed account hash in queue.'];
|
|
732
|
-
type: 'u16';
|
|
709
|
+
name: 'proveByIndex';
|
|
710
|
+
type: 'bool';
|
|
733
711
|
}
|
|
734
712
|
];
|
|
735
713
|
};
|
|
@@ -873,8 +851,8 @@ export type LightSystemProgram = {
|
|
|
873
851
|
},
|
|
874
852
|
{
|
|
875
853
|
code: 6009;
|
|
876
|
-
name: '
|
|
877
|
-
msg: '
|
|
854
|
+
name: 'DecompressLamportsUndefinedForCompressSol';
|
|
855
|
+
msg: 'DecompressLamportsUndefinedForCompressSol';
|
|
878
856
|
},
|
|
879
857
|
{
|
|
880
858
|
code: 6010;
|
|
@@ -1,13 +1,22 @@
|
|
|
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 '
|
|
4
|
+
import { InstructionDataInvoke, InstructionDataInvokeCpi, PublicTransactionEvent } from '../../state';
|
|
5
5
|
export declare const CompressedAccountLayout: import("buffer-layout").Layout<unknown>;
|
|
6
6
|
export declare const MerkleContextLayout: import("buffer-layout").Layout<unknown>;
|
|
7
7
|
export declare const NewAddressParamsLayout: import("buffer-layout").Layout<unknown>;
|
|
8
8
|
export declare const InstructionDataInvokeLayout: Layout<InstructionDataInvoke>;
|
|
9
9
|
export declare function encodeInstructionDataInvoke(data: InstructionDataInvoke): Buffer;
|
|
10
10
|
export declare const InstructionDataInvokeCpiLayout: Layout<InstructionDataInvokeCpi>;
|
|
11
|
+
export declare const CompressedProofLayout: import("buffer-layout").Layout<unknown>;
|
|
12
|
+
export declare const CompressedCpiContextLayout: import("buffer-layout").Layout<unknown>;
|
|
13
|
+
export declare const NewAddressParamsAssignedPackedLayout: import("buffer-layout").Layout<unknown>;
|
|
14
|
+
export declare const PackedMerkleContextLayout: import("buffer-layout").Layout<unknown>;
|
|
15
|
+
export declare const InAccountLayout: import("buffer-layout").Layout<unknown>;
|
|
16
|
+
export declare const PackedReadOnlyAddressLayout: import("buffer-layout").Layout<unknown>;
|
|
17
|
+
export declare const PackedReadOnlyCompressedAccountLayout: import("buffer-layout").Layout<unknown>;
|
|
18
|
+
export declare const InstructionDataInvokeCpiWithReadOnlyLayout: import("buffer-layout").Layout<unknown>;
|
|
19
|
+
export declare function decodeInstructionDataInvokeCpiWithReadOnly(buffer: Buffer): unknown;
|
|
11
20
|
export declare function decodeInstructionDataInvoke(buffer: Buffer): InstructionDataInvoke;
|
|
12
21
|
export declare function decodeInstructionDataInvokeCpi(buffer: Buffer): InstructionDataInvokeCpi;
|
|
13
22
|
export type invokeAccountsLayoutParams = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AccountMeta, PublicKey } from '@solana/web3.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AccountProofInput, CompressedAccountLegacy, NewAddressProofInput, OutputCompressedAccountWithPackedContext, PackedCompressedAccountWithMerkleContext, TreeInfo } from '../../state';
|
|
3
|
+
import { CompressedAccountWithMerkleContextLegacy, PackedAddressTreeInfo, PackedStateTreeInfo } from '../../state/compressed-account';
|
|
4
4
|
/**
|
|
5
5
|
* @internal Finds the index of a PublicKey in an array, or adds it if not
|
|
6
6
|
* present
|
|
@@ -24,6 +24,31 @@ export declare function getIndexOrAdd(accountsArray: PublicKey[], key: PublicKey
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey, numberOfOutputCompressedAccounts: number): PublicKey[];
|
|
26
26
|
export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
|
|
27
|
+
export interface PackedStateTreeInfos {
|
|
28
|
+
packedTreeInfos: PackedStateTreeInfo[];
|
|
29
|
+
outputTreeIndex: number;
|
|
30
|
+
}
|
|
31
|
+
export interface PackedTreeInfos {
|
|
32
|
+
stateTrees?: PackedStateTreeInfos;
|
|
33
|
+
addressTrees: PackedAddressTreeInfo[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Packs TreeInfos. Replaces PublicKey with index pointer to remaining accounts.
|
|
37
|
+
*
|
|
38
|
+
* Only use for MUT, CLOSE, NEW_ADDRESSES. For INIT, pass
|
|
39
|
+
* {@link newAddressParamsPacked} and `outputStateTreeIndex` to your program
|
|
40
|
+
* instead.
|
|
41
|
+
*
|
|
42
|
+
*
|
|
43
|
+
* @param remainingAccounts Optional existing array of accounts
|
|
44
|
+
* to append to.
|
|
45
|
+
* @param accountProofInputs Account proof inputs.
|
|
46
|
+
* @param newAddressProofInputs New address proof inputs.
|
|
47
|
+
*
|
|
48
|
+
* @returns Remaining accounts, packed state and address tree infos, state tree
|
|
49
|
+
* output index and address tree infos.
|
|
50
|
+
*/
|
|
51
|
+
export declare function packTreeInfos(remainingAccounts: PublicKey[], accountProofInputs: AccountProofInput[], newAddressProofInputs: NewAddressProofInput[]): PackedTreeInfos;
|
|
27
52
|
/**
|
|
28
53
|
* Packs Compressed Accounts.
|
|
29
54
|
*
|
|
@@ -42,7 +67,7 @@ export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountM
|
|
|
42
67
|
* @param remainingAccounts Optional existing array of accounts
|
|
43
68
|
* to append to.
|
|
44
69
|
**/
|
|
45
|
-
export declare function packCompressedAccounts(inputCompressedAccounts:
|
|
70
|
+
export declare function packCompressedAccounts(inputCompressedAccounts: CompressedAccountWithMerkleContextLegacy[], inputStateRootIndices: number[], outputCompressedAccounts: CompressedAccountLegacy[], outputStateTreeInfo?: TreeInfo, remainingAccounts?: PublicKey[]): {
|
|
46
71
|
packedInputCompressedAccounts: PackedCompressedAccountWithMerkleContext[];
|
|
47
72
|
packedOutputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
|
|
48
73
|
remainingAccounts: PublicKey[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BN from 'bn.js';
|
|
2
2
|
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
-
import {
|
|
4
|
-
import { NewAddressParams } from '
|
|
3
|
+
import { CompressedAccountWithMerkleContext, ValidityProof, TreeInfo, CompressedAccountLegacy } from '../../state';
|
|
4
|
+
import { NewAddressParams } from '../../utils';
|
|
5
5
|
export declare const sumUpLamports: (accounts: CompressedAccountWithMerkleContext[]) => BN;
|
|
6
6
|
/**
|
|
7
7
|
* Create compressed account system transaction params
|
|
@@ -23,11 +23,11 @@ type CreateAccountWithSeedParams = {
|
|
|
23
23
|
* Recent validity proof proving that there's no existing compressed account
|
|
24
24
|
* registered with newAccountAddress
|
|
25
25
|
*/
|
|
26
|
-
recentValidityProof: ValidityProof;
|
|
26
|
+
recentValidityProof: ValidityProof | null;
|
|
27
27
|
/**
|
|
28
28
|
* State tree pubkey. Defaults to a public state tree if unspecified.
|
|
29
29
|
*/
|
|
30
|
-
outputStateTreeInfo?:
|
|
30
|
+
outputStateTreeInfo?: TreeInfo;
|
|
31
31
|
/**
|
|
32
32
|
* Public key of the program to assign as the owner of the created account.
|
|
33
33
|
*/
|
|
@@ -70,15 +70,13 @@ type TransferParams = {
|
|
|
70
70
|
/**
|
|
71
71
|
* The recent state root indices of the input state. The expiry is tied to
|
|
72
72
|
* the proof.
|
|
73
|
-
*
|
|
74
|
-
* TODO: Add support for passing recent-values after instruction creation.
|
|
75
73
|
*/
|
|
76
74
|
recentInputStateRootIndices: number[];
|
|
77
75
|
/**
|
|
78
|
-
* The recent validity proof for state inclusion of the input state.
|
|
79
|
-
*
|
|
76
|
+
* The recent validity proof for state inclusion of the input state. Expires
|
|
77
|
+
* after n slots.
|
|
80
78
|
*/
|
|
81
|
-
recentValidityProof: ValidityProof;
|
|
79
|
+
recentValidityProof: ValidityProof | null;
|
|
82
80
|
};
|
|
83
81
|
/**
|
|
84
82
|
* Defines the parameters for the transfer method
|
|
@@ -97,10 +95,9 @@ type CompressParams = {
|
|
|
97
95
|
*/
|
|
98
96
|
lamports: number | BN;
|
|
99
97
|
/**
|
|
100
|
-
* The state tree that the tx output should be inserted into.
|
|
101
|
-
* public state tree if unspecified.
|
|
98
|
+
* The state tree that the tx output should be inserted into.
|
|
102
99
|
*/
|
|
103
|
-
outputStateTreeInfo:
|
|
100
|
+
outputStateTreeInfo: TreeInfo;
|
|
104
101
|
};
|
|
105
102
|
/**
|
|
106
103
|
* Defines the parameters for the transfer method
|
|
@@ -125,15 +122,13 @@ type DecompressParams = {
|
|
|
125
122
|
/**
|
|
126
123
|
* The recent state root indices of the input state. The expiry is tied to
|
|
127
124
|
* the proof.
|
|
128
|
-
*
|
|
129
|
-
* TODO: Add support for passing recent-values after instruction creation.
|
|
130
125
|
*/
|
|
131
126
|
recentInputStateRootIndices: number[];
|
|
132
127
|
/**
|
|
133
128
|
* The recent validity proof for state inclusion of the input state. It
|
|
134
129
|
* expires after n slots.
|
|
135
130
|
*/
|
|
136
|
-
recentValidityProof: ValidityProof;
|
|
131
|
+
recentValidityProof: ValidityProof | null;
|
|
137
132
|
};
|
|
138
133
|
export declare class LightSystemProgram {
|
|
139
134
|
/**
|
|
@@ -150,17 +145,15 @@ export declare class LightSystemProgram {
|
|
|
150
145
|
*
|
|
151
146
|
*/
|
|
152
147
|
static deriveCompressedSolPda(): PublicKey;
|
|
153
|
-
static createTransferOutputState(inputCompressedAccounts: CompressedAccountWithMerkleContext[], toAddress: PublicKey, lamports: number | BN):
|
|
154
|
-
static createDecompressOutputState(inputCompressedAccounts: CompressedAccountWithMerkleContext[], lamports: number | BN):
|
|
148
|
+
static createTransferOutputState(inputCompressedAccounts: CompressedAccountWithMerkleContext[], toAddress: PublicKey, lamports: number | BN): CompressedAccountLegacy[];
|
|
149
|
+
static createDecompressOutputState(inputCompressedAccounts: CompressedAccountWithMerkleContext[], lamports: number | BN): CompressedAccountLegacy[];
|
|
155
150
|
/**
|
|
156
151
|
* No data by default
|
|
157
152
|
*/
|
|
158
|
-
static createNewAddressOutputState(address: number[], owner: PublicKey, lamports?: BN | number, inputCompressedAccounts?: CompressedAccountWithMerkleContext[]):
|
|
153
|
+
static createNewAddressOutputState(address: number[], owner: PublicKey, lamports?: BN | number, inputCompressedAccounts?: CompressedAccountWithMerkleContext[]): CompressedAccountLegacy[];
|
|
159
154
|
/**
|
|
160
155
|
* Creates instruction to create compressed account with PDA.
|
|
161
156
|
* Cannot write data.
|
|
162
|
-
*
|
|
163
|
-
* TODO: support transfer of lamports to the new account.
|
|
164
157
|
*/
|
|
165
158
|
static createAccount({ payer, newAddressParams, newAddress, recentValidityProof, outputStateTreeInfo, inputCompressedAccounts, inputStateRootIndices, lamports, }: CreateAccountWithSeedParams): Promise<TransactionInstruction>;
|
|
166
159
|
/**
|
|
@@ -179,12 +172,4 @@ export declare class LightSystemProgram {
|
|
|
179
172
|
*/
|
|
180
173
|
static decompress({ payer, inputCompressedAccounts, toAddress, lamports, recentInputStateRootIndices, recentValidityProof, }: DecompressParams): Promise<TransactionInstruction>;
|
|
181
174
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Selects the minimal number of compressed SOL accounts for a transfer.
|
|
184
|
-
*
|
|
185
|
-
* 1. Sorts the accounts by amount in descending order
|
|
186
|
-
* 2. Accumulates the amount until it is greater than or equal to the transfer
|
|
187
|
-
* amount
|
|
188
|
-
*/
|
|
189
|
-
export declare function selectMinCompressedSolAccountsForTransfer(accounts: CompressedAccountWithMerkleContext[], transferLamports: BN | number): [selectedAccounts: CompressedAccountWithMerkleContext[], total: BN];
|
|
190
175
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
import { CompressedAccountWithMerkleContext } from '../../state';
|
|
3
|
+
/**
|
|
4
|
+
* Selects the minimal number of compressed SOL accounts for a transfer.
|
|
5
|
+
*
|
|
6
|
+
* 1. Sorts the accounts by amount in descending order
|
|
7
|
+
* 2. Accumulates the amount until it is greater than or equal to the transfer
|
|
8
|
+
* amount
|
|
9
|
+
*/
|
|
10
|
+
export declare function selectMinCompressedSolAccountsForTransfer(accounts: CompressedAccountWithMerkleContext[], transferLamports: BN | number): [selectedAccounts: CompressedAccountWithMerkleContext[], total: BN];
|