@lightprotocol/stateless.js 0.22.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.
- package/README.md +10 -10
- package/dist/cjs/browser/compressible/action.d.ts +77 -0
- package/dist/cjs/browser/compressible/index.d.ts +13 -0
- package/dist/cjs/browser/compressible/instruction.d.ts +177 -0
- package/dist/cjs/browser/compressible/layout.d.ts +47 -0
- package/dist/cjs/browser/compressible/types.d.ts +112 -0
- package/dist/cjs/browser/compressible/utils.d.ts +16 -0
- package/dist/cjs/browser/constants.d.ts +7 -5
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/index.d.ts +1 -0
- package/dist/cjs/browser/programs/system/pack.d.ts +79 -10
- package/dist/cjs/browser/rpc-interface.d.ts +47 -47
- package/dist/cjs/browser/rpc.d.ts +17 -3
- package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +6 -2
- package/dist/cjs/browser/utils/address.d.ts +13 -0
- package/dist/cjs/browser/utils/conversion.d.ts +1 -0
- package/dist/cjs/browser/utils/index.d.ts +1 -0
- package/dist/cjs/browser/utils/packed-accounts.d.ts +161 -0
- package/dist/cjs/node/compressible/action.d.ts +77 -0
- package/dist/cjs/node/compressible/index.d.ts +13 -0
- package/dist/cjs/node/compressible/instruction.d.ts +177 -0
- package/dist/cjs/node/compressible/layout.d.ts +47 -0
- package/dist/cjs/node/compressible/types.d.ts +112 -0
- package/dist/cjs/node/compressible/utils.d.ts +16 -0
- package/dist/cjs/node/constants.d.ts +7 -5
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/index.d.ts +1 -0
- package/dist/cjs/node/programs/system/pack.d.ts +79 -10
- package/dist/cjs/node/rpc-interface.d.ts +47 -47
- package/dist/cjs/node/rpc.d.ts +17 -3
- package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +6 -2
- package/dist/cjs/node/utils/address.d.ts +13 -0
- package/dist/cjs/node/utils/conversion.d.ts +1 -0
- package/dist/cjs/node/utils/index.d.ts +1 -0
- package/dist/cjs/node/utils/packed-accounts.d.ts +161 -0
- package/dist/types/index.d.ts +665 -45
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
|
|
1
|
+
import { AccountInfo, 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, MerkleContextWithMerkleProof } from '../../state';
|
|
5
|
+
import { BN254, CompressedAccountWithMerkleContext, MerkleContext, MerkleContextWithMerkleProof } from '../../state';
|
|
6
6
|
import { MerkleContextWithNewAddressProof } from '../../rpc';
|
|
7
7
|
import { TreeInfo } from '../../state/types';
|
|
8
8
|
export interface TestRpcConfig {
|
|
@@ -232,4 +232,8 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
232
232
|
*/
|
|
233
233
|
getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<ValidityProofWithContext>;
|
|
234
234
|
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>;
|
|
235
239
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
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;
|
|
2
13
|
export declare function deriveAddressSeed(seeds: Uint8Array[], programId: PublicKey): Uint8Array;
|
|
3
14
|
/**
|
|
15
|
+
* @deprecated Use {@link deriveAddressV2} instead, unless you're using v1.
|
|
16
|
+
*
|
|
4
17
|
* Derive an address for a compressed account from a seed and an address Merkle
|
|
5
18
|
* tree public key.
|
|
6
19
|
*
|
|
@@ -22,6 +22,7 @@ export declare const toCamelCase: (object: any) => any;
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function hashToBn254FieldSizeBe(bytes: Buffer): [Buffer, number] | null;
|
|
24
24
|
/**
|
|
25
|
+
* TODO: make consistent with latest rust. (use u8::max bumpseed)
|
|
25
26
|
* Hash the provided `bytes` with Keccak256 and ensure that the result fits in
|
|
26
27
|
* the BN254 prime field by truncating the resulting hash to 31 bytes.
|
|
27
28
|
*
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { AccountMeta, PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* This file provides two variants of packed accounts for Light Protocol:
|
|
4
|
+
*
|
|
5
|
+
* 1. PackedAccounts - Matches CpiAccounts (11 system accounts)
|
|
6
|
+
* - Includes: LightSystemProgram, Authority, RegisteredProgramPda, NoopProgram,
|
|
7
|
+
* AccountCompressionAuthority, AccountCompressionProgram, InvokingProgram,
|
|
8
|
+
* [Optional: SolPoolPda, DecompressionRecipient], SystemProgram, [Optional: CpiContext]
|
|
9
|
+
*
|
|
10
|
+
* 2. PackedAccountsSmall - Matches CpiAccountsSmall (9 system accounts max)
|
|
11
|
+
* - Includes: LightSystemProgram, Authority, RegisteredProgramPda,
|
|
12
|
+
* AccountCompressionAuthority, AccountCompressionProgram, SystemProgram,
|
|
13
|
+
* [Optional: SolPoolPda, DecompressionRecipient, CpiContext]
|
|
14
|
+
* - Excludes: NoopProgram and InvokingProgram for a more compact structure
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Create a PackedAccounts instance to pack the light protocol system accounts
|
|
18
|
+
* for your custom program instruction. Typically, you will append them to the
|
|
19
|
+
* end of your instruction's accounts / remainingAccounts.
|
|
20
|
+
*
|
|
21
|
+
* This matches the full CpiAccounts structure with 11 system accounts including
|
|
22
|
+
* NoopProgram and InvokingProgram. For a more compact version, use PackedAccountsSmall.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const packedAccounts = PackedAccounts.newWithSystemAccounts(config);
|
|
27
|
+
*
|
|
28
|
+
* const instruction = new TransactionInstruction({
|
|
29
|
+
* keys: [...yourInstructionAccounts, ...packedAccounts.toAccountMetas()],
|
|
30
|
+
* programId: selfProgram,
|
|
31
|
+
* data: data,
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class PackedAccounts {
|
|
36
|
+
private preAccounts;
|
|
37
|
+
private systemAccounts;
|
|
38
|
+
private nextIndex;
|
|
39
|
+
private map;
|
|
40
|
+
static newWithSystemAccounts(config: SystemAccountMetaConfig): PackedAccounts;
|
|
41
|
+
addPreAccountsSigner(pubkey: PublicKey): void;
|
|
42
|
+
addPreAccountsSignerMut(pubkey: PublicKey): void;
|
|
43
|
+
addPreAccountsMeta(accountMeta: AccountMeta): void;
|
|
44
|
+
addSystemAccounts(config: SystemAccountMetaConfig): void;
|
|
45
|
+
insertOrGet(pubkey: PublicKey): number;
|
|
46
|
+
insertOrGetReadOnly(pubkey: PublicKey): number;
|
|
47
|
+
insertOrGetConfig(pubkey: PublicKey, isSigner: boolean, isWritable: boolean): number;
|
|
48
|
+
private hashSetAccountsToMetas;
|
|
49
|
+
private getOffsets;
|
|
50
|
+
toAccountMetas(): {
|
|
51
|
+
remainingAccounts: AccountMeta[];
|
|
52
|
+
systemStart: number;
|
|
53
|
+
packedStart: number;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a PackedAccounts instance with system accounts for the specified
|
|
58
|
+
* program. This is a convenience wrapper around SystemAccountMetaConfig.new()
|
|
59
|
+
* and PackedAccounts.newWithSystemAccounts().
|
|
60
|
+
*
|
|
61
|
+
* @param programId - The program ID that will be using these system accounts
|
|
62
|
+
* @returns A new PackedAccounts instance with system accounts configured
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const packedAccounts = createPackedAccounts(myProgram.programId);
|
|
67
|
+
*
|
|
68
|
+
* const instruction = new TransactionInstruction({
|
|
69
|
+
* keys: [...yourInstructionAccounts, ...packedAccounts.toAccountMetas().remainingAccounts],
|
|
70
|
+
* programId: myProgram.programId,
|
|
71
|
+
* data: instructionData,
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function createPackedAccounts(programId: PublicKey): PackedAccounts;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a PackedAccounts instance with system accounts and CPI context for the specified program.
|
|
78
|
+
* This is a convenience wrapper that includes CPI context configuration.
|
|
79
|
+
*
|
|
80
|
+
* @param programId - The program ID that will be using these system accounts
|
|
81
|
+
* @param cpiContext - The CPI context account public key
|
|
82
|
+
* @returns A new PackedAccounts instance with system accounts and CPI context configured
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const packedAccounts = createPackedAccountsWithCpiContext(
|
|
87
|
+
* myProgram.programId,
|
|
88
|
+
* cpiContextAccount
|
|
89
|
+
* );
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function createPackedAccountsWithCpiContext(programId: PublicKey, cpiContext: PublicKey): PackedAccounts;
|
|
93
|
+
export declare class SystemAccountMetaConfig {
|
|
94
|
+
selfProgram: PublicKey;
|
|
95
|
+
cpiContext?: PublicKey;
|
|
96
|
+
solCompressionRecipient?: PublicKey;
|
|
97
|
+
solPoolPda?: PublicKey;
|
|
98
|
+
private constructor();
|
|
99
|
+
static new(selfProgram: PublicKey): SystemAccountMetaConfig;
|
|
100
|
+
static newWithCpiContext(selfProgram: PublicKey, cpiContext: PublicKey): SystemAccountMetaConfig;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get the light protocol system accounts for your custom program instruction.
|
|
104
|
+
* Use via `link PackedAccounts.addSystemAccounts(config)`.
|
|
105
|
+
*/
|
|
106
|
+
export declare function getLightSystemAccountMetas(config: SystemAccountMetaConfig): AccountMeta[];
|
|
107
|
+
/**
|
|
108
|
+
* PackedAccountsSmall matches the CpiAccountsSmall structure with simplified account ordering.
|
|
109
|
+
* This is a more compact version that excludes NoopProgram and InvokingProgram.
|
|
110
|
+
*/
|
|
111
|
+
export declare class PackedAccountsSmall {
|
|
112
|
+
private preAccounts;
|
|
113
|
+
private systemAccounts;
|
|
114
|
+
private nextIndex;
|
|
115
|
+
private map;
|
|
116
|
+
static newWithSystemAccounts(config: SystemAccountMetaConfig): PackedAccountsSmall;
|
|
117
|
+
/**
|
|
118
|
+
* Returns the internal map of pubkey to [index, AccountMeta].
|
|
119
|
+
* For debugging purposes only.
|
|
120
|
+
*/
|
|
121
|
+
getNamedMetas(): Map<string, [number, AccountMeta]>;
|
|
122
|
+
addPreAccountsSigner(pubkey: PublicKey): void;
|
|
123
|
+
addPreAccountsSignerMut(pubkey: PublicKey): void;
|
|
124
|
+
addPreAccountsMeta(accountMeta: AccountMeta): void;
|
|
125
|
+
addSystemAccounts(config: SystemAccountMetaConfig): void;
|
|
126
|
+
insertOrGet(pubkey: PublicKey): number;
|
|
127
|
+
insertOrGetReadOnly(pubkey: PublicKey): number;
|
|
128
|
+
insertOrGetConfig(pubkey: PublicKey, isSigner: boolean, isWritable: boolean): number;
|
|
129
|
+
private hashSetAccountsToMetas;
|
|
130
|
+
private getOffsets;
|
|
131
|
+
toAccountMetas(): {
|
|
132
|
+
remainingAccounts: AccountMeta[];
|
|
133
|
+
systemStart: number;
|
|
134
|
+
packedStart: number;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get the light protocol system accounts for the small variant.
|
|
139
|
+
* This matches CpiAccountsSmall ordering: removes NoopProgram and InvokingProgram.
|
|
140
|
+
*/
|
|
141
|
+
export declare function getLightSystemAccountMetasSmall(config: SystemAccountMetaConfig): AccountMeta[];
|
|
142
|
+
/**
|
|
143
|
+
* Creates a PackedAccountsSmall instance with system accounts for the specified program.
|
|
144
|
+
* This uses the simplified account ordering that matches CpiAccountsSmall.
|
|
145
|
+
*/
|
|
146
|
+
export declare function createPackedAccountsSmall(programId: PublicKey): PackedAccountsSmall;
|
|
147
|
+
/**
|
|
148
|
+
* Creates a PackedAccountsSmall instance with system accounts and CPI context.
|
|
149
|
+
*/
|
|
150
|
+
export declare function createPackedAccountsSmallWithCpiContext(programId: PublicKey, cpiContext: PublicKey): PackedAccountsSmall;
|
|
151
|
+
export declare class SystemAccountPubkeys {
|
|
152
|
+
lightSystemProgram: PublicKey;
|
|
153
|
+
systemProgram: PublicKey;
|
|
154
|
+
accountCompressionProgram: PublicKey;
|
|
155
|
+
accountCompressionAuthority: PublicKey;
|
|
156
|
+
registeredProgramPda: PublicKey;
|
|
157
|
+
noopProgram: PublicKey;
|
|
158
|
+
solPoolPda: PublicKey;
|
|
159
|
+
private constructor();
|
|
160
|
+
static default(): SystemAccountPubkeys;
|
|
161
|
+
}
|