@zelana/sdk 0.1.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/client.d.ts +139 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1807 -0
- package/dist/keypair.d.ts +110 -0
- package/dist/keypair.d.ts.map +1 -0
- package/dist/shielded.d.ts +227 -0
- package/dist/shielded.d.ts.map +1 -0
- package/dist/types.d.ts +221 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +48 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/zelana.d.ts +213 -0
- package/dist/zelana.d.ts.map +1 -0
- package/package.json +47 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zelana API Client
|
|
3
|
+
*
|
|
4
|
+
* Low-level HTTP client for the Zelana L2 sequencer API.
|
|
5
|
+
* Handles request/response serialization and error handling.
|
|
6
|
+
*/
|
|
7
|
+
import type { Bytes32, AccountState, TransferRequest, TransferResponse, WithdrawRequest, WithdrawResponse, WithdrawalStatus, ShieldedRequest, ShieldedResponse, StateRoots, BatchStatusInfo, HealthInfo, GlobalStats, FastWithdrawQuote, CommitteeInfo, MerklePath, ScannedNote, TxSummary, BatchSummary, PaginationParams, DevDepositResponse, DevSealResponse } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* API client configuration
|
|
10
|
+
*/
|
|
11
|
+
export interface ApiClientConfig {
|
|
12
|
+
/** Base URL of the sequencer API (e.g., "http://localhost:3000") */
|
|
13
|
+
baseUrl: string;
|
|
14
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
15
|
+
timeout?: number;
|
|
16
|
+
/** Custom fetch implementation (for Node.js compatibility) */
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Low-level API client for Zelana L2 sequencer
|
|
21
|
+
*/
|
|
22
|
+
export declare class ApiClient {
|
|
23
|
+
private readonly baseUrl;
|
|
24
|
+
private readonly timeout;
|
|
25
|
+
private readonly fetch;
|
|
26
|
+
constructor(config: ApiClientConfig);
|
|
27
|
+
private request;
|
|
28
|
+
private get;
|
|
29
|
+
private post;
|
|
30
|
+
/**
|
|
31
|
+
* Check if the sequencer is healthy
|
|
32
|
+
*/
|
|
33
|
+
health(): Promise<HealthInfo>;
|
|
34
|
+
/**
|
|
35
|
+
* Get current state roots
|
|
36
|
+
*/
|
|
37
|
+
getStateRoots(): Promise<StateRoots>;
|
|
38
|
+
/**
|
|
39
|
+
* Get current batch status
|
|
40
|
+
*/
|
|
41
|
+
getBatchStatus(): Promise<BatchStatusInfo>;
|
|
42
|
+
/**
|
|
43
|
+
* Get global statistics
|
|
44
|
+
*/
|
|
45
|
+
getStats(): Promise<GlobalStats>;
|
|
46
|
+
/**
|
|
47
|
+
* Get account state by ID (hex-encoded public key)
|
|
48
|
+
*/
|
|
49
|
+
getAccount(accountId: string): Promise<AccountState>;
|
|
50
|
+
/**
|
|
51
|
+
* Get account state by public key bytes
|
|
52
|
+
*/
|
|
53
|
+
getAccountByPubkey(pubkey: Bytes32): Promise<AccountState>;
|
|
54
|
+
/**
|
|
55
|
+
* Submit a signed transfer transaction
|
|
56
|
+
*/
|
|
57
|
+
submitTransfer(request: TransferRequest): Promise<TransferResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Submit a signed withdrawal request
|
|
60
|
+
*/
|
|
61
|
+
submitWithdrawal(request: WithdrawRequest): Promise<WithdrawResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Get withdrawal status by transaction hash
|
|
64
|
+
*/
|
|
65
|
+
getWithdrawalStatus(txHash: string): Promise<WithdrawalStatus>;
|
|
66
|
+
/**
|
|
67
|
+
* Get fast withdrawal quote
|
|
68
|
+
*/
|
|
69
|
+
getFastWithdrawQuote(amount: bigint): Promise<FastWithdrawQuote>;
|
|
70
|
+
/**
|
|
71
|
+
* Submit a shielded transaction
|
|
72
|
+
*/
|
|
73
|
+
submitShielded(request: ShieldedRequest): Promise<ShieldedResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Get merkle path for a commitment
|
|
76
|
+
*/
|
|
77
|
+
getMerklePath(position: number): Promise<MerklePath>;
|
|
78
|
+
/**
|
|
79
|
+
* Scan for notes owned by a viewing key
|
|
80
|
+
*/
|
|
81
|
+
scanNotes(decryptionKey: Bytes32, ownerPk: Bytes32, fromPosition?: number, limit?: number): Promise<{
|
|
82
|
+
notes: ScannedNote[];
|
|
83
|
+
scannedTo: number;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Get batch by ID
|
|
87
|
+
*/
|
|
88
|
+
getBatch(batchId: bigint): Promise<BatchSummary | null>;
|
|
89
|
+
/**
|
|
90
|
+
* List batches with pagination
|
|
91
|
+
*/
|
|
92
|
+
listBatches(params?: PaginationParams): Promise<{
|
|
93
|
+
batches: BatchSummary[];
|
|
94
|
+
total: number;
|
|
95
|
+
}>;
|
|
96
|
+
/**
|
|
97
|
+
* Get transaction by hash
|
|
98
|
+
*/
|
|
99
|
+
getTransaction(txHash: string): Promise<TxSummary | null>;
|
|
100
|
+
/**
|
|
101
|
+
* List transactions with pagination and filters
|
|
102
|
+
*/
|
|
103
|
+
listTransactions(params?: PaginationParams & {
|
|
104
|
+
batchId?: bigint;
|
|
105
|
+
txType?: string;
|
|
106
|
+
status?: string;
|
|
107
|
+
}): Promise<{
|
|
108
|
+
transactions: TxSummary[];
|
|
109
|
+
total: number;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* Get threshold encryption committee info
|
|
113
|
+
*/
|
|
114
|
+
getCommittee(): Promise<CommitteeInfo>;
|
|
115
|
+
/**
|
|
116
|
+
* Simulate a deposit from L1 (DEV MODE ONLY)
|
|
117
|
+
*
|
|
118
|
+
* This endpoint is only available when the sequencer is running with DEV_MODE=true.
|
|
119
|
+
* It bypasses the L1 indexer and directly credits funds to an account.
|
|
120
|
+
*
|
|
121
|
+
* @param to - Recipient account (hex-encoded 32-byte public key)
|
|
122
|
+
* @param amount - Amount to deposit in lamports
|
|
123
|
+
* @returns Deposit response with new balance
|
|
124
|
+
* @throws ZelanaError if dev mode is not enabled (404)
|
|
125
|
+
*/
|
|
126
|
+
devDeposit(to: string, amount: bigint): Promise<DevDepositResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* Force seal the current batch (DEV MODE ONLY)
|
|
129
|
+
*
|
|
130
|
+
* This endpoint is only available when the sequencer is running with DEV_MODE=true.
|
|
131
|
+
* It forces the current batch to seal immediately, bypassing the normal seal triggers.
|
|
132
|
+
*
|
|
133
|
+
* @param waitForProof - Whether to wait for proof generation (default: false)
|
|
134
|
+
* @returns Seal response with batch ID and transaction count
|
|
135
|
+
* @throws ZelanaError if dev mode is not enabled (404)
|
|
136
|
+
*/
|
|
137
|
+
devSeal(waitForProof?: boolean): Promise<DevSealResponse>;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,EACT,YAAY,EACZ,gBAAgB,EAEhB,kBAAkB,EAClB,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,K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AY,CAAC,EAAE,MAAM,EACrB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,KAAK,EAAE,WAAW,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IA8BvD;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAkB7D;;OAEG;IACG,WAAW,CACf,MAAM,GAAE,gBAAqB,GAC5B,OAAO,CAAC;QAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAyBtD;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAmB/D;;OAEG;IACG,gBAAgB,CACpB,MAAM,GAAE,gBAAgB,GAAG;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ,GACL,OAAO,CAAC;QAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAiCxD;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC;IA+B5C;;;;;;;;;;OAUG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAkBzE;;;;;;;;;OASG;IACG,OAAO,CAAC,YAAY,GAAE,OAAe,GAAG,OAAO,CAAC,eAAe,CAAC;CAcvE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zelana TypeScript SDK
|
|
3
|
+
*
|
|
4
|
+
* Official SDK for interacting with Zelana L2, a privacy-focused Solana rollup.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { ZelanaClient, Keypair } from '@zelana/sdk';
|
|
9
|
+
*
|
|
10
|
+
* // Generate a new keypair
|
|
11
|
+
* const keypair = Keypair.generate();
|
|
12
|
+
* console.log('Public Key:', keypair.publicKeyBase58);
|
|
13
|
+
*
|
|
14
|
+
* // Create client
|
|
15
|
+
* const client = new ZelanaClient({
|
|
16
|
+
* baseUrl: 'http://localhost:3000',
|
|
17
|
+
* keypair,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Check health
|
|
21
|
+
* const healthy = await client.isHealthy();
|
|
22
|
+
* console.log('Sequencer healthy:', healthy);
|
|
23
|
+
*
|
|
24
|
+
* // Get account balance
|
|
25
|
+
* const balance = await client.getBalance();
|
|
26
|
+
* console.log('Balance:', balance);
|
|
27
|
+
*
|
|
28
|
+
* // Transfer funds
|
|
29
|
+
* const result = await client.transfer(recipientPubkey, 1_000_000n);
|
|
30
|
+
* console.log('TX Hash:', result.txHash);
|
|
31
|
+
*
|
|
32
|
+
* // Wait for confirmation
|
|
33
|
+
* await client.waitForTransaction(result.txHash);
|
|
34
|
+
* console.log('Transfer confirmed!');
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @packageDocumentation
|
|
38
|
+
*/
|
|
39
|
+
export { ZelanaClient } from './zelana';
|
|
40
|
+
export type { ZelanaClientConfig } from './zelana';
|
|
41
|
+
export { Keypair, PublicKey } from './keypair';
|
|
42
|
+
export { ApiClient } from './client';
|
|
43
|
+
export type { ApiClientConfig } from './client';
|
|
44
|
+
export type { Bytes32, AccountState, TxType, TxStatus, TxSummary, BatchStatus, BatchSummary, TransferRequest, TransferResponse, WithdrawRequest, WithdrawResponse, WithdrawalStatus, ShieldedRequest, ShieldedResponse, StateRoots, BatchStatusInfo, HealthInfo, GlobalStats, MerklePath, ScannedNote, FastWithdrawQuote, CommitteeMemberInfo, CommitteeInfo, PaginationParams, PaginatedResponse, DevDepositRequest, DevDepositResponse, DevSealRequest, DevSealResponse, ApiError, } from './types';
|
|
45
|
+
export { ZelanaError } from './types';
|
|
46
|
+
export { shielded, ShieldedTransactionBuilder, generateShieldedKeys, shieldedKeysFromSpendingKey, createNote, noteWithRandomness, computeCommitment, computeNullifier, tryDecryptNote, } from './shielded';
|
|
47
|
+
export type { Note, EncryptedNote, ShieldedKeys, ShieldedInput, ShieldedOutput, PreparedShieldedTx, ShieldedTransaction, ShieldedWitness, ScanResult, MerklePath as ShieldedMerklePath, } from './shielded';
|
|
48
|
+
export { bytesToHex, hexToBytes, bytesToBase58, base58ToBytes, u64ToLeBytes, leBytesToU64, concatBytes, bytesEqual, randomBytes, } from './utils';
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhD,YAAY,EAEV,OAAO,EACP,YAAY,EAGZ,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,EACX,YAAY,EAGZ,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAGhB,UAAU,EACV,eAAe,EACf,UAAU,EACV,WAAW,EAGX,UAAU,EACV,WAAW,EAGX,iBAAiB,EAGjB,mBAAmB,EACnB,aAAa,EAGb,gBAAgB,EAChB,iBAAiB,EAGjB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EAGf,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