@lightprotocol/stateless.js 0.22.1-alpha.0 → 0.22.1-alpha.1
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/constants.d.ts +19 -4
- 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 -1
- package/dist/cjs/browser/programs/system/pack.d.ts +10 -79
- package/dist/cjs/browser/rpc-interface.d.ts +275 -275
- package/dist/cjs/browser/rpc.d.ts +6 -16
- package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +6 -6
- package/dist/cjs/browser/utils/address.d.ts +7 -19
- package/dist/cjs/browser/utils/conversion.d.ts +1 -1
- package/dist/cjs/browser/utils/index.d.ts +1 -1
- package/dist/cjs/browser/utils/instruction.d.ts +35 -0
- package/dist/cjs/node/constants.d.ts +19 -4
- 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 -1
- package/dist/cjs/node/programs/system/pack.d.ts +10 -79
- package/dist/cjs/node/rpc-interface.d.ts +275 -275
- package/dist/cjs/node/rpc.d.ts +6 -16
- package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +6 -6
- package/dist/cjs/node/utils/address.d.ts +7 -19
- package/dist/cjs/node/utils/conversion.d.ts +1 -1
- package/dist/cjs/node/utils/index.d.ts +1 -1
- package/dist/cjs/node/utils/instruction.d.ts +35 -0
- package/dist/es/browser/actions/compress.d.ts +18 -0
- package/dist/es/browser/actions/create-account.d.ts +38 -0
- package/dist/es/browser/actions/decompress.d.ts +15 -0
- package/dist/es/browser/actions/index.d.ts +5 -0
- package/dist/es/browser/actions/transfer.d.ts +16 -0
- package/dist/es/browser/constants.d.ts +157 -0
- package/dist/es/browser/errors.d.ts +74 -0
- package/dist/es/browser/index.d.ts +9 -0
- package/dist/es/browser/index.js +2 -0
- package/dist/es/browser/index.js.map +1 -0
- package/dist/es/browser/programs/index.d.ts +1 -0
- package/dist/es/browser/programs/system/idl.d.ts +997 -0
- package/dist/es/browser/programs/system/index.d.ts +5 -0
- package/dist/es/browser/programs/system/layout.d.ts +77 -0
- package/dist/es/browser/programs/system/pack.d.ts +74 -0
- package/dist/es/browser/programs/system/program.d.ts +175 -0
- package/dist/es/browser/programs/system/select-compressed-accounts.d.ts +10 -0
- package/dist/es/browser/rpc-interface.d.ts +2779 -0
- package/dist/es/browser/rpc.d.ts +284 -0
- package/dist/es/browser/state/BN254.d.ts +13 -0
- package/dist/es/browser/state/bn.d.ts +3 -0
- package/dist/es/browser/state/compressed-account.d.ts +205 -0
- package/dist/es/browser/state/index.d.ts +4 -0
- package/dist/es/browser/state/types.d.ts +449 -0
- package/dist/es/browser/test-helpers/index.d.ts +3 -0
- package/dist/es/browser/test-helpers/merkle-tree/index.d.ts +2 -0
- package/dist/es/browser/test-helpers/merkle-tree/indexed-array.d.ts +85 -0
- package/dist/es/browser/test-helpers/merkle-tree/merkle-tree.d.ts +92 -0
- package/dist/es/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +7 -0
- package/dist/es/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +40 -0
- package/dist/es/browser/test-helpers/test-rpc/get-parsed-events.d.ts +15 -0
- package/dist/es/browser/test-helpers/test-rpc/index.d.ts +3 -0
- package/dist/es/browser/test-helpers/test-rpc/test-rpc.d.ts +239 -0
- package/dist/es/browser/test-helpers/test-utils.d.ts +31 -0
- package/dist/es/browser/utils/address.d.ts +64 -0
- package/dist/es/browser/utils/airdrop.d.ts +7 -0
- package/dist/es/browser/utils/calculate-compute-unit-price.d.ts +7 -0
- package/dist/es/browser/utils/conversion.d.ts +36 -0
- package/dist/es/browser/utils/dedupe-signer.d.ts +3 -0
- package/dist/es/browser/utils/get-state-tree-infos.d.ts +48 -0
- package/dist/es/browser/utils/index.d.ts +13 -0
- package/dist/es/browser/utils/instruction.d.ts +35 -0
- package/dist/es/browser/utils/parse-validity-proof.d.ts +20 -0
- package/dist/es/browser/utils/pipe.d.ts +2 -0
- package/dist/es/browser/utils/send-and-confirm.d.ts +52 -0
- package/dist/es/browser/utils/sleep.d.ts +1 -0
- package/dist/es/browser/utils/state-tree-lookup-table.d.ts +68 -0
- package/dist/es/browser/utils/validation.d.ts +8 -0
- package/dist/types/index.d.ts +109 -667
- package/package.json +16 -8
- package/dist/cjs/browser/compressible/action.d.ts +0 -77
- package/dist/cjs/browser/compressible/index.d.ts +0 -13
- package/dist/cjs/browser/compressible/instruction.d.ts +0 -177
- package/dist/cjs/browser/compressible/layout.d.ts +0 -47
- package/dist/cjs/browser/compressible/types.d.ts +0 -112
- package/dist/cjs/browser/compressible/utils.d.ts +0 -16
- package/dist/cjs/browser/utils/packed-accounts.d.ts +0 -161
- package/dist/cjs/node/compressible/action.d.ts +0 -77
- package/dist/cjs/node/compressible/index.d.ts +0 -13
- package/dist/cjs/node/compressible/instruction.d.ts +0 -177
- package/dist/cjs/node/compressible/layout.d.ts +0 -47
- package/dist/cjs/node/compressible/types.d.ts +0 -112
- package/dist/cjs/node/compressible/utils.d.ts +0 -16
- package/dist/cjs/node/utils/packed-accounts.d.ts +0 -161
package/dist/cjs/node/rpc.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { Buffer } from 'buffer';
|
|
3
3
|
import { ValidityProofWithContext, CompressedTransaction, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, HexInputsForProver, ParsedTokenAccount, SignatureWithMetadata, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, WithContext, GetCompressedAccountsByOwnerConfig, WithCursor, AddressWithTree, HashWithTree, CompressedMintTokenHolders, TokenBalance, PaginatedOptions } from './rpc-interface';
|
|
4
|
-
import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, ValidityProof, AddressTreeInfo
|
|
4
|
+
import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, ValidityProof, AddressTreeInfo } from './state';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
import { LightWasm } from './test-helpers';
|
|
7
7
|
import { TreeInfo } from './state/types';
|
|
@@ -100,6 +100,10 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
|
|
|
100
100
|
* @internal
|
|
101
101
|
*/
|
|
102
102
|
doFetch(): Promise<TreeInfo[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Get a V2 address tree info.
|
|
105
|
+
*/
|
|
106
|
+
getAddressTreeInfoV2(): Promise<TreeInfo>;
|
|
103
107
|
/**
|
|
104
108
|
* Fetch the compressed account for the specified account address or hash
|
|
105
109
|
*/
|
|
@@ -277,18 +281,4 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
|
|
|
277
281
|
* @returns validity proof with context
|
|
278
282
|
*/
|
|
279
283
|
getValidityProofAndRpcContext(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<WithContext<ValidityProofWithContext>>;
|
|
280
|
-
/**
|
|
281
|
-
* Get account info from either compressed or onchain storage.
|
|
282
|
-
* @param address The account address to fetch.
|
|
283
|
-
* @param programId The owner program ID.
|
|
284
|
-
* @param addressTreeInfo The address tree info used to store the account.
|
|
285
|
-
* @param rpc The RPC client to use.
|
|
286
|
-
*
|
|
287
|
-
* @returns Account info with compression info, or null if account
|
|
288
|
-
* doesn't exist.
|
|
289
|
-
*/
|
|
290
|
-
getCompressibleAccountInfo(address: PublicKey, programId: PublicKey, addressTreeInfo: TreeInfo, rpc: Rpc): Promise<{
|
|
291
|
-
accountInfo: AccountInfo<Buffer>;
|
|
292
|
-
merkleContext?: MerkleContext;
|
|
293
|
-
} | null>;
|
|
294
284
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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,
|
|
5
|
+
import { BN254, CompressedAccountWithMerkleContext, MerkleContextWithMerkleProof } from '../../state';
|
|
6
6
|
import { MerkleContextWithNewAddressProof } from '../../rpc';
|
|
7
7
|
import { TreeInfo } from '../../state/types';
|
|
8
8
|
export interface TestRpcConfig {
|
|
@@ -83,6 +83,10 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
83
83
|
*/
|
|
84
84
|
getStateTreeInfos(): Promise<TreeInfo[]>;
|
|
85
85
|
doFetch(): Promise<TreeInfo[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Get a V2 address tree info.
|
|
88
|
+
*/
|
|
89
|
+
getAddressTreeInfoV2(): Promise<TreeInfo>;
|
|
86
90
|
/**
|
|
87
91
|
* Fetch the compressed account for the specified account hash
|
|
88
92
|
*/
|
|
@@ -232,8 +236,4 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
232
236
|
*/
|
|
233
237
|
getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<ValidityProofWithContext>;
|
|
234
238
|
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>;
|
|
239
239
|
}
|
|
@@ -1,28 +1,16 @@
|
|
|
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;
|
|
13
2
|
export declare function deriveAddressSeed(seeds: Uint8Array[], programId: PublicKey): Uint8Array;
|
|
3
|
+
export declare function deriveAddress(seed: Uint8Array, addressMerkleTreePubkey?: PublicKey): PublicKey;
|
|
4
|
+
export declare function deriveAddressSeedV2(seeds: Uint8Array[]): Uint8Array;
|
|
14
5
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* Derive an address for a compressed account from a seed and an address Merkle
|
|
18
|
-
* tree public key.
|
|
6
|
+
* Derives an address from a seed using the v2 method (matching Rust's derive_address_from_seed)
|
|
19
7
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param addressMerkleTreePubkey Merkle tree public key
|
|
22
|
-
*
|
|
8
|
+
* @param addressSeed The address seed (32 bytes)
|
|
9
|
+
* @param addressMerkleTreePubkey Merkle tree public key
|
|
10
|
+
* @param programId Program ID
|
|
23
11
|
* @returns Derived address
|
|
24
12
|
*/
|
|
25
|
-
export declare function
|
|
13
|
+
export declare function deriveAddressV2(addressSeed: Uint8Array, addressMerkleTreePubkey: PublicKey, programId: PublicKey): PublicKey;
|
|
26
14
|
export interface NewAddressParams {
|
|
27
15
|
/**
|
|
28
16
|
* Seed for the compressed account. Must be seed used to derive
|
|
@@ -21,8 +21,8 @@ export declare const toCamelCase: (object: any) => any;
|
|
|
21
21
|
* @deprecated Use `hashvToBn254FieldSizeBe` instead.
|
|
22
22
|
*/
|
|
23
23
|
export declare function hashToBn254FieldSizeBe(bytes: Buffer): [Buffer, number] | null;
|
|
24
|
+
export declare function hashvToBn254FieldSizeBeU8Array(bytes: Uint8Array[]): Uint8Array;
|
|
24
25
|
/**
|
|
25
|
-
* TODO: make consistent with latest rust. (use u8::max bumpseed)
|
|
26
26
|
* Hash the provided `bytes` with Keccak256 and ensure that the result fits in
|
|
27
27
|
* the BN254 prime field by truncating the resulting hash to 31 bytes.
|
|
28
28
|
*
|
|
@@ -3,6 +3,7 @@ export * from './airdrop';
|
|
|
3
3
|
export * from './calculate-compute-unit-price';
|
|
4
4
|
export * from './conversion';
|
|
5
5
|
export * from './dedupe-signer';
|
|
6
|
+
export * from './instruction';
|
|
6
7
|
export * from './parse-validity-proof';
|
|
7
8
|
export * from './pipe';
|
|
8
9
|
export * from './send-and-confirm';
|
|
@@ -10,4 +11,3 @@ export * from './sleep';
|
|
|
10
11
|
export * from './validation';
|
|
11
12
|
export * from './state-tree-lookup-table';
|
|
12
13
|
export * from './get-state-tree-infos';
|
|
13
|
-
export * from './packed-accounts';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AccountMeta, PublicKey } from '@solana/web3.js';
|
|
2
|
+
export declare class PackedAccounts {
|
|
3
|
+
private preAccounts;
|
|
4
|
+
private systemAccounts;
|
|
5
|
+
private nextIndex;
|
|
6
|
+
private map;
|
|
7
|
+
static newWithSystemAccounts(config: SystemAccountMetaConfig): PackedAccounts;
|
|
8
|
+
static newWithSystemAccountsV2(config: SystemAccountMetaConfig): PackedAccounts;
|
|
9
|
+
addPreAccountsSigner(pubkey: PublicKey): void;
|
|
10
|
+
addPreAccountsSignerMut(pubkey: PublicKey): void;
|
|
11
|
+
addPreAccountsMeta(accountMeta: AccountMeta): void;
|
|
12
|
+
addSystemAccounts(config: SystemAccountMetaConfig): void;
|
|
13
|
+
addSystemAccountsV2(config: SystemAccountMetaConfig): void;
|
|
14
|
+
insertOrGet(pubkey: PublicKey): number;
|
|
15
|
+
insertOrGetReadOnly(pubkey: PublicKey): number;
|
|
16
|
+
insertOrGetConfig(pubkey: PublicKey, isSigner: boolean, isWritable: boolean): number;
|
|
17
|
+
private hashSetAccountsToMetas;
|
|
18
|
+
private getOffsets;
|
|
19
|
+
toAccountMetas(): {
|
|
20
|
+
remainingAccounts: AccountMeta[];
|
|
21
|
+
systemStart: number;
|
|
22
|
+
packedStart: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare class SystemAccountMetaConfig {
|
|
26
|
+
selfProgram: PublicKey;
|
|
27
|
+
cpiContext?: PublicKey;
|
|
28
|
+
solCompressionRecipient?: PublicKey;
|
|
29
|
+
solPoolPda?: PublicKey;
|
|
30
|
+
private constructor();
|
|
31
|
+
static new(selfProgram: PublicKey): SystemAccountMetaConfig;
|
|
32
|
+
static newWithCpiContext(selfProgram: PublicKey, cpiContext: PublicKey): SystemAccountMetaConfig;
|
|
33
|
+
}
|
|
34
|
+
export declare function getLightSystemAccountMetas(config: SystemAccountMetaConfig): AccountMeta[];
|
|
35
|
+
export declare function getLightSystemAccountMetasV2(config: SystemAccountMetaConfig): AccountMeta[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ConfirmOptions, PublicKey, Signer, TransactionSignature } from '@solana/web3.js';
|
|
2
|
+
import { Rpc } from '../rpc';
|
|
3
|
+
import BN from 'bn.js';
|
|
4
|
+
import { TreeInfo } from '../state';
|
|
5
|
+
/**
|
|
6
|
+
* Compress lamports to a solana address
|
|
7
|
+
*
|
|
8
|
+
* @param rpc RPC to use
|
|
9
|
+
* @param payer Payer of the transaction and initialization fees
|
|
10
|
+
* @param lamports Amount of lamports to compress
|
|
11
|
+
* @param toAddress Address of the recipient compressed account
|
|
12
|
+
* @param outputStateTreeInfo Optional output state tree. If not provided,
|
|
13
|
+
* fetches a random active state tree.
|
|
14
|
+
* @param confirmOptions Options for confirming the transaction
|
|
15
|
+
*
|
|
16
|
+
* @return Transaction signature
|
|
17
|
+
*/
|
|
18
|
+
export declare function compress(rpc: Rpc, payer: Signer, lamports: number | BN, toAddress: PublicKey, outputStateTreeInfo?: TreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ConfirmOptions, PublicKey, Signer, TransactionSignature } from '@solana/web3.js';
|
|
2
|
+
import { Rpc } from '../rpc';
|
|
3
|
+
import { AddressTreeInfo, TreeInfo } from '../state';
|
|
4
|
+
import BN from 'bn.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create compressed account with address
|
|
7
|
+
*
|
|
8
|
+
* @param rpc RPC to use
|
|
9
|
+
* @param payer Payer of the transaction and initialization fees
|
|
10
|
+
* @param seeds Seeds to derive the new account address
|
|
11
|
+
* @param programId Owner of the new account
|
|
12
|
+
* @param addressTreeInfo Optional address tree info. Defaults to a current
|
|
13
|
+
* shared address tree.
|
|
14
|
+
* @param outputStateTreeInfo Optional output state tree. Defaults to fetching
|
|
15
|
+
* a current shared state tree.
|
|
16
|
+
* @param confirmOptions Options for confirming the transaction
|
|
17
|
+
*
|
|
18
|
+
* @return Transaction signature
|
|
19
|
+
*/
|
|
20
|
+
export declare function createAccount(rpc: Rpc, payer: Signer, seeds: Uint8Array[], programId: PublicKey, addressTreeInfo?: AddressTreeInfo, outputStateTreeInfo?: TreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
21
|
+
/**
|
|
22
|
+
* Create compressed account with address and lamports
|
|
23
|
+
*
|
|
24
|
+
* @param rpc RPC to use
|
|
25
|
+
* @param payer Payer of the transaction and initialization fees
|
|
26
|
+
* @param seeds Seeds to derive the new account address
|
|
27
|
+
* @param lamports Number of compressed lamports to initialize the
|
|
28
|
+
* account with
|
|
29
|
+
* @param programId Owner of the new account
|
|
30
|
+
* @param addressTreeInfo Optional address tree info. Defaults to a
|
|
31
|
+
* current shared address tree.
|
|
32
|
+
* @param outputStateTreeInfo Optional output state tree. Defaults to a
|
|
33
|
+
* current shared state tree.
|
|
34
|
+
* @param confirmOptions Options for confirming the transaction
|
|
35
|
+
*
|
|
36
|
+
* @return Transaction signature
|
|
37
|
+
*/
|
|
38
|
+
export declare function createAccountWithLamports(rpc: Rpc, payer: Signer, seeds: Uint8Array[], lamports: number | BN, programId: PublicKey, addressTreeInfo?: AddressTreeInfo, outputStateTreeInfo?: TreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConfirmOptions, PublicKey, Signer, TransactionSignature } from '@solana/web3.js';
|
|
2
|
+
import { Rpc } from '../rpc';
|
|
3
|
+
import BN from 'bn.js';
|
|
4
|
+
/**
|
|
5
|
+
* Decompress lamports into a solana account
|
|
6
|
+
*
|
|
7
|
+
* @param rpc RPC to use
|
|
8
|
+
* @param payer Payer of the transaction and initialization fees
|
|
9
|
+
* @param lamports Amount of lamports to compress
|
|
10
|
+
* @param toAddress Address of the recipient compressed account
|
|
11
|
+
* @param confirmOptions Options for confirming the transaction
|
|
12
|
+
*
|
|
13
|
+
* @return Transaction signature
|
|
14
|
+
*/
|
|
15
|
+
export declare function decompress(rpc: Rpc, payer: Signer, lamports: number | BN, recipient: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ConfirmOptions, PublicKey, Signer, TransactionSignature } from '@solana/web3.js';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
import { Rpc } from '../rpc';
|
|
4
|
+
/**
|
|
5
|
+
* Transfer compressed lamports from one owner to another
|
|
6
|
+
*
|
|
7
|
+
* @param rpc Rpc to use
|
|
8
|
+
* @param payer Payer of transaction fees
|
|
9
|
+
* @param lamports Number of lamports to transfer
|
|
10
|
+
* @param owner Owner of the compressed lamports
|
|
11
|
+
* @param toAddress Destination address of the recipient
|
|
12
|
+
* @param confirmOptions Options for confirming the transaction
|
|
13
|
+
*
|
|
14
|
+
* @return Signature of the confirmed transaction
|
|
15
|
+
*/
|
|
16
|
+
export declare function transfer(rpc: Rpc, payer: Signer, lamports: number | BN, owner: Signer, toAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
import { ConfirmOptions, PublicKey } from '@solana/web3.js';
|
|
4
|
+
import { TreeInfo, TreeType } from './state/types';
|
|
5
|
+
export declare enum VERSION {
|
|
6
|
+
V1 = "V1",
|
|
7
|
+
V2 = "V2"
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
* Feature flags. Only use if you know what you are doing.
|
|
13
|
+
*/
|
|
14
|
+
export declare const featureFlags: {
|
|
15
|
+
version: VERSION;
|
|
16
|
+
isV2: () => boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Returns the correct endpoint name for the current API version. E.g.
|
|
20
|
+
* versionedEndpoint('getCompressedAccount') -> 'getCompressedAccount' (V1)
|
|
21
|
+
* or 'getCompressedAccountV2' (V2)
|
|
22
|
+
*/
|
|
23
|
+
export declare const versionedEndpoint: (base: string) => string;
|
|
24
|
+
export declare const FIELD_SIZE: BN;
|
|
25
|
+
export declare const HIGHEST_ADDRESS_PLUS_ONE: BN;
|
|
26
|
+
export declare const COMPUTE_BUDGET_PATTERN: number[];
|
|
27
|
+
export declare const INVOKE_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
28
|
+
export declare const INVOKE_CPI_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
29
|
+
export declare const INVOKE_CPI_WITH_READ_ONLY_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
30
|
+
export declare const INVOKE_CPI_WITH_ACCOUNT_INFO_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
31
|
+
export declare const INSERT_INTO_QUEUES_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
32
|
+
export declare const noopProgram = "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV";
|
|
33
|
+
export declare const lightSystemProgram = "SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7";
|
|
34
|
+
export declare const accountCompressionProgram = "compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq";
|
|
35
|
+
export declare const getRegisteredProgramPda: () => PublicKey;
|
|
36
|
+
export declare const getAccountCompressionAuthority: () => PublicKey;
|
|
37
|
+
export declare const defaultStaticAccounts: () => PublicKey[];
|
|
38
|
+
export declare const defaultStaticAccountsStruct: () => {
|
|
39
|
+
registeredProgramPda: PublicKey;
|
|
40
|
+
noopProgram: PublicKey;
|
|
41
|
+
accountCompressionProgram: PublicKey;
|
|
42
|
+
accountCompressionAuthority: PublicKey;
|
|
43
|
+
cpiSignatureAccount: null;
|
|
44
|
+
};
|
|
45
|
+
export type StateTreeLUTPair = {
|
|
46
|
+
stateTreeLookupTable: PublicKey;
|
|
47
|
+
nullifyLookupTable: PublicKey;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Returns the Default Public State Tree LUTs for Devnet and Mainnet-Beta.
|
|
51
|
+
*/
|
|
52
|
+
export declare const defaultStateTreeLookupTables: () => {
|
|
53
|
+
mainnet: StateTreeLUTPair[];
|
|
54
|
+
devnet: StateTreeLUTPair[];
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export declare const isLocalTest: (url: string) => boolean;
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare const localTestActiveStateTreeInfos: () => TreeInfo[];
|
|
64
|
+
export declare const getDefaultAddressTreeInfo: () => {
|
|
65
|
+
tree: PublicKey;
|
|
66
|
+
queue: PublicKey;
|
|
67
|
+
cpiContext: null;
|
|
68
|
+
treeType: TreeType;
|
|
69
|
+
nextTreeInfo: null;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated use {@link rpc.getStateTreeInfos} and {@link selectStateTreeInfo} instead.
|
|
73
|
+
* for address trees, use {@link getDefaultAddressTreeInfo} instead.
|
|
74
|
+
* Use only with Localnet testing.
|
|
75
|
+
* For public networks, fetch via {@link defaultStateTreeLookupTables} and {@link getAllStateTreeInfos}.
|
|
76
|
+
*/
|
|
77
|
+
export declare const defaultTestStateTreeAccounts: () => {
|
|
78
|
+
nullifierQueue: PublicKey;
|
|
79
|
+
merkleTree: PublicKey;
|
|
80
|
+
merkleTreeHeight: number;
|
|
81
|
+
addressTree: PublicKey;
|
|
82
|
+
addressQueue: PublicKey;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* @internal testing only
|
|
86
|
+
*/
|
|
87
|
+
export declare const defaultTestStateTreeAccounts2: () => {
|
|
88
|
+
nullifierQueue2: PublicKey;
|
|
89
|
+
merkleTree2: PublicKey;
|
|
90
|
+
};
|
|
91
|
+
export declare const COMPRESSED_TOKEN_PROGRAM_ID: PublicKey;
|
|
92
|
+
export declare const stateTreeLookupTableMainnet = "7i86eQs3GSqHjN47WdWLTCGMW6gde1q96G2EVnUyK2st";
|
|
93
|
+
export declare const nullifiedStateTreeLookupTableMainnet = "H9QD4u1fG7KmkAzn2tDXhheushxFe1EcrjGGyEFXeMqT";
|
|
94
|
+
export declare const stateTreeLookupTableDevnet = "Dk9mNkbiZXJZ4By8DfSP6HEE4ojZzRvucwpawLeuwq8q";
|
|
95
|
+
export declare const nullifiedStateTreeLookupTableDevnet = "AXbHzp1NgjLvpfnD6JRTTovXZ7APUCdtWZFCRr5tCxse";
|
|
96
|
+
export declare const nullifierQueuePubkey = "nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148";
|
|
97
|
+
export declare const cpiContextPubkey = "cpi1uHzrEhBG733DoEJNgHCyRS3XmmyVNZx5fonubE4";
|
|
98
|
+
export declare const merkletreePubkey = "smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT";
|
|
99
|
+
export declare const addressTree = "amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2";
|
|
100
|
+
export declare const addressQueue = "aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F";
|
|
101
|
+
export declare const merkleTree2Pubkey = "smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho";
|
|
102
|
+
export declare const nullifierQueue2Pubkey = "nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X";
|
|
103
|
+
export declare const cpiContext2Pubkey = "cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK";
|
|
104
|
+
export declare const batchMerkleTree1 = "bmt1LryLZUMmF7ZtqESaw7wifBXLfXHQYoE4GAmrahU";
|
|
105
|
+
export declare const batchQueue1 = "oq1na8gojfdUhsfCpyjNt6h4JaDWtHf1yQj4koBWfto";
|
|
106
|
+
export declare const batchCpiContext1 = "cpi15BoVPKgEPw5o8wc2T816GE7b378nMXnhH3Xbq4y";
|
|
107
|
+
export declare const batchMerkleTree2 = "bmt2UxoBxB9xWev4BkLvkGdapsz6sZGkzViPNph7VFi";
|
|
108
|
+
export declare const batchQueue2 = "oq2UkeMsJLfXt2QHzim242SUi3nvjJs8Pn7Eac9H9vg";
|
|
109
|
+
export declare const batchCpiContext2 = "cpi2yGapXUR3As5SjnHBAVvmApNiLsbeZpF3euWnW6B";
|
|
110
|
+
export declare const batchMerkleTree3 = "bmt3ccLd4bqSVZVeCJnH1F6C8jNygAhaDfxDwePyyGb";
|
|
111
|
+
export declare const batchQueue3 = "oq3AxjekBWgo64gpauB6QtuZNesuv19xrhaC1ZM1THQ";
|
|
112
|
+
export declare const batchCpiContext3 = "cpi3mbwMpSX8FAGMZVP85AwxqCaQMfEk9Em1v8QK9Rf";
|
|
113
|
+
export declare const batchMerkleTree4 = "bmt4d3p1a4YQgk9PeZv5s4DBUmbF5NxqYpk9HGjQsd8";
|
|
114
|
+
export declare const batchQueue4 = "oq4ypwvVGzCUMoiKKHWh4S1SgZJ9vCvKpcz6RT6A8dq";
|
|
115
|
+
export declare const batchCpiContext4 = "cpi4yyPDc4bCgHAnsenunGA8Y77j3XEDyjgfyCKgcoc";
|
|
116
|
+
export declare const batchMerkleTree5 = "bmt5yU97jC88YXTuSukYHa8Z5Bi2ZDUtmzfkDTA2mG2";
|
|
117
|
+
export declare const batchQueue5 = "oq5oh5ZR3yGomuQgFduNDzjtGvVWfDRGLuDVjv9a96P";
|
|
118
|
+
export declare const batchCpiContext5 = "cpi5ZTjdgYpZ1Xr7B1cMLLUE81oTtJbNNAyKary2nV6";
|
|
119
|
+
export declare const batchAddressTree = "amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx";
|
|
120
|
+
export declare const testBatchAddressTree = "EzKE84aVTkCUhDHLELqyJaq1Y7UVVmqxXqZjVHwHY3rK";
|
|
121
|
+
export declare const batchMerkleTree = "bmt1LryLZUMmF7ZtqESaw7wifBXLfXHQYoE4GAmrahU";
|
|
122
|
+
export declare const batchQueue = "oq1na8gojfdUhsfCpyjNt6h4JaDWtHf1yQj4koBWfto";
|
|
123
|
+
export declare const confirmConfig: ConfirmOptions;
|
|
124
|
+
export declare const DEFAULT_MERKLE_TREE_HEIGHT = 26;
|
|
125
|
+
export declare const DEFAULT_MERKLE_TREE_ROOTS = 2800;
|
|
126
|
+
/** Threshold (per asset) at which new in-UTXOs get merged, in order to reduce UTXO pool size */
|
|
127
|
+
export declare const UTXO_MERGE_THRESHOLD = 20;
|
|
128
|
+
export declare const UTXO_MERGE_MAXIMUM = 10;
|
|
129
|
+
/**
|
|
130
|
+
* Treshold after which the currently used transaction Merkle tree is switched
|
|
131
|
+
* to the next one
|
|
132
|
+
*/
|
|
133
|
+
export declare const TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD: BN;
|
|
134
|
+
/**
|
|
135
|
+
* Fee to provide continous funding for the state Merkle tree.
|
|
136
|
+
* Once the state Merkle tree is at 95% capacity the accumulated fees
|
|
137
|
+
* will be used to fund the next state Merkle tree with the same parameters.
|
|
138
|
+
*
|
|
139
|
+
* Is charged per output compressed account.
|
|
140
|
+
*/
|
|
141
|
+
export declare const STATE_MERKLE_TREE_ROLLOVER_FEE: BN;
|
|
142
|
+
/**
|
|
143
|
+
* Fee to provide continous funding for the address queue and address Merkle tree.
|
|
144
|
+
* Once the address Merkle tree is at 95% capacity the accumulated fees
|
|
145
|
+
* will be used to fund the next address queue and address tree with the same parameters.
|
|
146
|
+
*
|
|
147
|
+
* Is charged per newly created address.
|
|
148
|
+
*/
|
|
149
|
+
export declare const ADDRESS_QUEUE_ROLLOVER_FEE: BN;
|
|
150
|
+
/**
|
|
151
|
+
* Is charged if the transaction nullifies at least one compressed account.
|
|
152
|
+
*/
|
|
153
|
+
export declare const STATE_MERKLE_TREE_NETWORK_FEE: BN;
|
|
154
|
+
/**
|
|
155
|
+
* Is charged if the transaction creates at least one address.
|
|
156
|
+
*/
|
|
157
|
+
export declare const ADDRESS_TREE_NETWORK_FEE: BN;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export declare enum UtxoErrorCode {
|
|
2
|
+
NEGATIVE_LAMPORTS = "NEGATIVE_LAMPORTS",
|
|
3
|
+
NOT_U64 = "NOT_U64",
|
|
4
|
+
BLINDING_EXCEEDS_FIELD_SIZE = "BLINDING_EXCEEDS_FIELD_SIZE"
|
|
5
|
+
}
|
|
6
|
+
export declare enum SelectInUtxosErrorCode {
|
|
7
|
+
FAILED_TO_FIND_UTXO_COMBINATION = "FAILED_TO_FIND_UTXO_COMBINATION",
|
|
8
|
+
INVALID_NUMBER_OF_IN_UTXOS = "INVALID_NUMBER_OF_IN_UTXOS"
|
|
9
|
+
}
|
|
10
|
+
export declare enum CreateUtxoErrorCode {
|
|
11
|
+
OWNER_UNDEFINED = "OWNER_UNDEFINED",
|
|
12
|
+
INVALID_OUTPUT_UTXO_LENGTH = "INVALID_OUTPUT_UTXO_LENGTH",
|
|
13
|
+
UTXO_DATA_UNDEFINED = "UTXO_DATA_UNDEFINED"
|
|
14
|
+
}
|
|
15
|
+
export declare enum RpcErrorCode {
|
|
16
|
+
CONNECTION_UNDEFINED = "CONNECTION_UNDEFINED",
|
|
17
|
+
RPC_PUBKEY_UNDEFINED = "RPC_PUBKEY_UNDEFINED",
|
|
18
|
+
RPC_METHOD_NOT_IMPLEMENTED = "RPC_METHOD_NOT_IMPLEMENTED",
|
|
19
|
+
RPC_INVALID = "RPC_INVALID"
|
|
20
|
+
}
|
|
21
|
+
export declare enum LookupTableErrorCode {
|
|
22
|
+
LOOK_UP_TABLE_UNDEFINED = "LOOK_UP_TABLE_UNDEFINED",
|
|
23
|
+
LOOK_UP_TABLE_NOT_INITIALIZED = "LOOK_UP_TABLE_NOT_INITIALIZED"
|
|
24
|
+
}
|
|
25
|
+
export declare enum HashErrorCode {
|
|
26
|
+
NO_POSEIDON_HASHER_PROVIDED = "NO_POSEIDON_HASHER_PROVIDED"
|
|
27
|
+
}
|
|
28
|
+
export declare enum ProofErrorCode {
|
|
29
|
+
INVALID_PROOF = "INVALID_PROOF",
|
|
30
|
+
PROOF_INPUT_UNDEFINED = "PROOF_INPUT_UNDEFINED",
|
|
31
|
+
PROOF_GENERATION_FAILED = "PROOF_GENERATION_FAILED"
|
|
32
|
+
}
|
|
33
|
+
export declare enum MerkleTreeErrorCode {
|
|
34
|
+
MERKLE_TREE_NOT_INITIALIZED = "MERKLE_TREE_NOT_INITIALIZED",
|
|
35
|
+
SOL_MERKLE_TREE_UNDEFINED = "SOL_MERKLE_TREE_UNDEFINED",
|
|
36
|
+
MERKLE_TREE_UNDEFINED = "MERKLE_TREE_UNDEFINED",
|
|
37
|
+
INPUT_UTXO_NOT_INSERTED_IN_MERKLE_TREE = "INPUT_UTXO_NOT_INSERTED_IN_MERKLE_TREE",
|
|
38
|
+
MERKLE_TREE_INDEX_UNDEFINED = "MERKLE_TREE_INDEX_UNDEFINED",
|
|
39
|
+
MERKLE_TREE_SET_SPACE_UNDEFINED = "MERKLE_TREE_SET_SPACE_UNDEFINED"
|
|
40
|
+
}
|
|
41
|
+
export declare enum UtilsErrorCode {
|
|
42
|
+
ACCOUNT_NAME_UNDEFINED_IN_IDL = "ACCOUNT_NAME_UNDEFINED_IN_IDL",
|
|
43
|
+
PROPERTY_UNDEFINED = "PROPERTY_UNDEFINED",
|
|
44
|
+
LOOK_UP_TABLE_CREATION_FAILED = "LOOK_UP_TABLE_CREATION_FAILED",
|
|
45
|
+
UNSUPPORTED_ARCHITECTURE = "UNSUPPORTED_ARCHITECTURE",
|
|
46
|
+
UNSUPPORTED_PLATFORM = "UNSUPPORTED_PLATFORM",
|
|
47
|
+
ACCOUNTS_UNDEFINED = "ACCOUNTS_UNDEFINED",
|
|
48
|
+
INVALID_NUMBER = "INVALID_NUMBER"
|
|
49
|
+
}
|
|
50
|
+
declare class MetaError extends Error {
|
|
51
|
+
code: string;
|
|
52
|
+
functionName: string;
|
|
53
|
+
codeMessage?: string;
|
|
54
|
+
constructor(code: string, functionName: string, codeMessage?: string);
|
|
55
|
+
}
|
|
56
|
+
export declare class UtxoError extends MetaError {
|
|
57
|
+
}
|
|
58
|
+
export declare class SelectInUtxosError extends MetaError {
|
|
59
|
+
}
|
|
60
|
+
export declare class CreateUtxoError extends MetaError {
|
|
61
|
+
}
|
|
62
|
+
export declare class RpcError extends MetaError {
|
|
63
|
+
}
|
|
64
|
+
export declare class LookupTableError extends MetaError {
|
|
65
|
+
}
|
|
66
|
+
export declare class HashError extends MetaError {
|
|
67
|
+
}
|
|
68
|
+
export declare class ProofError extends MetaError {
|
|
69
|
+
}
|
|
70
|
+
export declare class MerkleTreeError extends MetaError {
|
|
71
|
+
}
|
|
72
|
+
export declare class UtilsError extends MetaError {
|
|
73
|
+
}
|
|
74
|
+
export {};
|