@ghostspeak/sdk 1.7.1 → 2.0.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/LICENSE +21 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/GhostSpeakClient-CyeZ6Tyb.d.ts +2061 -0
- package/dist/client.d.ts +5 -0
- package/dist/crypto.d.ts +331 -0
- package/dist/errors.d.ts +119 -0
- package/dist/feature-flags-3POmoO_Z.d.ts +3800 -0
- package/dist/index.d.ts +732 -20882
- package/dist/ipfs-types-KJcvy9Qk.d.ts +553 -0
- package/dist/minimal/core-minimal.d.ts +2399 -0
- package/dist/types.d.ts +396 -0
- package/dist/utils.d.ts +19 -0
- package/package.json +30 -28
- package/dist/index.js +0 -46049
- package/dist/index.js.map +0 -1
package/dist/client.d.ts
ADDED
package/dist/crypto.d.ts
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { Address } from '@solana/addresses';
|
|
2
|
+
import { IInstruction } from '@solana/kit';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unified ElGamal Encryption Module
|
|
6
|
+
*
|
|
7
|
+
* This module consolidates all ElGamal implementations into a single, optimized solution
|
|
8
|
+
* for Solana's Token-2022 confidential transfers with complete ZK proof support.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Twisted ElGamal encryption on curve25519
|
|
12
|
+
* - Bulletproof range proofs (0 to 2^64)
|
|
13
|
+
* - Validity and equality proofs
|
|
14
|
+
* - Homomorphic addition/subtraction
|
|
15
|
+
* - WASM optimization support
|
|
16
|
+
* - Full Solana ZK Proof Program integration
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
interface ElGamalKeypair {
|
|
20
|
+
publicKey: Uint8Array;
|
|
21
|
+
secretKey: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
interface ElGamalCiphertext {
|
|
24
|
+
commitment: PedersenCommitment;
|
|
25
|
+
handle: DecryptHandle;
|
|
26
|
+
}
|
|
27
|
+
interface PedersenCommitment {
|
|
28
|
+
commitment: Uint8Array;
|
|
29
|
+
}
|
|
30
|
+
interface DecryptHandle {
|
|
31
|
+
handle: Uint8Array;
|
|
32
|
+
}
|
|
33
|
+
interface RangeProof {
|
|
34
|
+
proof: Uint8Array;
|
|
35
|
+
commitment: Uint8Array;
|
|
36
|
+
}
|
|
37
|
+
interface ValidityProof {
|
|
38
|
+
proof: Uint8Array;
|
|
39
|
+
}
|
|
40
|
+
interface EqualityProof {
|
|
41
|
+
proof: Uint8Array;
|
|
42
|
+
}
|
|
43
|
+
interface TransferProof {
|
|
44
|
+
rangeProof: RangeProof;
|
|
45
|
+
validityProof: ValidityProof;
|
|
46
|
+
equalityProof: EqualityProof;
|
|
47
|
+
}
|
|
48
|
+
interface WithdrawProof {
|
|
49
|
+
proof: Uint8Array;
|
|
50
|
+
}
|
|
51
|
+
declare const PROOF_SIZES: {
|
|
52
|
+
readonly RANGE_PROOF: 674;
|
|
53
|
+
readonly VALIDITY_PROOF: 160;
|
|
54
|
+
readonly EQUALITY_PROOF: 192;
|
|
55
|
+
readonly WITHDRAW_PROOF: 80;
|
|
56
|
+
readonly ZERO_BALANCE_PROOF: 96;
|
|
57
|
+
readonly FEE_SIGMA_PROOF: 256;
|
|
58
|
+
readonly PUBKEY_VALIDITY_PROOF: 64;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Generate a new ElGamal keypair
|
|
62
|
+
*/
|
|
63
|
+
declare function generateKeypair(): ElGamalKeypair;
|
|
64
|
+
/**
|
|
65
|
+
* Derive ElGamal keypair from seed
|
|
66
|
+
*/
|
|
67
|
+
declare function deriveKeypair(seed: Uint8Array): ElGamalKeypair;
|
|
68
|
+
/**
|
|
69
|
+
* Encrypt a value using twisted ElGamal
|
|
70
|
+
*/
|
|
71
|
+
declare function encrypt(publicKey: Uint8Array, value: bigint): {
|
|
72
|
+
ciphertext: ElGamalCiphertext;
|
|
73
|
+
randomness: Uint8Array;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Decrypt an ElGamal ciphertext (brute force for small values)
|
|
77
|
+
*/
|
|
78
|
+
declare function decrypt(secretKey: Uint8Array, ciphertext: ElGamalCiphertext, maxValue?: number): bigint | null;
|
|
79
|
+
/**
|
|
80
|
+
* Add two ElGamal ciphertexts (homomorphic addition)
|
|
81
|
+
*/
|
|
82
|
+
declare function addCiphertexts(ct1: ElGamalCiphertext, ct2: ElGamalCiphertext): ElGamalCiphertext;
|
|
83
|
+
/**
|
|
84
|
+
* Subtract two ElGamal ciphertexts (homomorphic subtraction)
|
|
85
|
+
*/
|
|
86
|
+
declare function subtractCiphertexts(ct1: ElGamalCiphertext, ct2: ElGamalCiphertext): ElGamalCiphertext;
|
|
87
|
+
/**
|
|
88
|
+
* Generate range proof for encrypted amount
|
|
89
|
+
*/
|
|
90
|
+
declare function generateRangeProof(value: bigint, commitment: PedersenCommitment, randomness: Uint8Array): Promise<RangeProof>;
|
|
91
|
+
/**
|
|
92
|
+
* Generate validity proof for ciphertext
|
|
93
|
+
*/
|
|
94
|
+
declare function generateValidityProof(publicKey: Uint8Array, ciphertext: ElGamalCiphertext, randomness: Uint8Array): Promise<ValidityProof>;
|
|
95
|
+
/**
|
|
96
|
+
* Generate equality proof for transfer
|
|
97
|
+
*/
|
|
98
|
+
declare function generateEqualityProof(sourceCiphertext: ElGamalCiphertext, destCiphertext: ElGamalCiphertext, transferAmount: bigint, sourceRandomness: Uint8Array, destRandomness: Uint8Array): Promise<EqualityProof>;
|
|
99
|
+
/**
|
|
100
|
+
* Generate complete transfer proof
|
|
101
|
+
*/
|
|
102
|
+
declare function generateTransferProof(sourceBalance: bigint, transferAmount: bigint, sourceKeypair: ElGamalKeypair, destPubkey: Uint8Array, _auditorPubkey?: Uint8Array): Promise<TransferProof>;
|
|
103
|
+
/**
|
|
104
|
+
* Generate withdraw proof
|
|
105
|
+
*/
|
|
106
|
+
declare function generateWithdrawProof(balance: bigint, keypair: ElGamalKeypair, ciphertext: ElGamalCiphertext): Promise<WithdrawProof>;
|
|
107
|
+
/**
|
|
108
|
+
* Convert ElGamal public key to Solana address format
|
|
109
|
+
*/
|
|
110
|
+
declare function elGamalPubkeyToAddress(pubkey: Uint8Array): Promise<Address>;
|
|
111
|
+
/**
|
|
112
|
+
* Load WASM module for performance optimization
|
|
113
|
+
*/
|
|
114
|
+
declare function loadWasmModule$1(): Promise<void>;
|
|
115
|
+
declare const _default$2: {
|
|
116
|
+
generateKeypair: typeof generateKeypair;
|
|
117
|
+
deriveKeypair: typeof deriveKeypair;
|
|
118
|
+
encrypt: typeof encrypt;
|
|
119
|
+
decrypt: typeof decrypt;
|
|
120
|
+
addCiphertexts: typeof addCiphertexts;
|
|
121
|
+
subtractCiphertexts: typeof subtractCiphertexts;
|
|
122
|
+
generateRangeProof: typeof generateRangeProof;
|
|
123
|
+
generateValidityProof: typeof generateValidityProof;
|
|
124
|
+
generateEqualityProof: typeof generateEqualityProof;
|
|
125
|
+
generateTransferProof: typeof generateTransferProof;
|
|
126
|
+
generateWithdrawProof: typeof generateWithdrawProof;
|
|
127
|
+
elGamalPubkeyToAddress: typeof elGamalPubkeyToAddress;
|
|
128
|
+
loadWasmModule: typeof loadWasmModule$1;
|
|
129
|
+
PROOF_SIZES: {
|
|
130
|
+
readonly RANGE_PROOF: 674;
|
|
131
|
+
readonly VALIDITY_PROOF: 160;
|
|
132
|
+
readonly EQUALITY_PROOF: 192;
|
|
133
|
+
readonly WITHDRAW_PROOF: 80;
|
|
134
|
+
readonly ZERO_BALANCE_PROOF: 96;
|
|
135
|
+
readonly FEE_SIGMA_PROOF: 256;
|
|
136
|
+
readonly PUBKEY_VALIDITY_PROOF: 64;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
type elgamal_DecryptHandle = DecryptHandle;
|
|
141
|
+
type elgamal_ElGamalCiphertext = ElGamalCiphertext;
|
|
142
|
+
type elgamal_ElGamalKeypair = ElGamalKeypair;
|
|
143
|
+
type elgamal_EqualityProof = EqualityProof;
|
|
144
|
+
declare const elgamal_PROOF_SIZES: typeof PROOF_SIZES;
|
|
145
|
+
type elgamal_PedersenCommitment = PedersenCommitment;
|
|
146
|
+
type elgamal_RangeProof = RangeProof;
|
|
147
|
+
type elgamal_TransferProof = TransferProof;
|
|
148
|
+
type elgamal_ValidityProof = ValidityProof;
|
|
149
|
+
type elgamal_WithdrawProof = WithdrawProof;
|
|
150
|
+
declare const elgamal_addCiphertexts: typeof addCiphertexts;
|
|
151
|
+
declare const elgamal_decrypt: typeof decrypt;
|
|
152
|
+
declare const elgamal_deriveKeypair: typeof deriveKeypair;
|
|
153
|
+
declare const elgamal_elGamalPubkeyToAddress: typeof elGamalPubkeyToAddress;
|
|
154
|
+
declare const elgamal_encrypt: typeof encrypt;
|
|
155
|
+
declare const elgamal_generateEqualityProof: typeof generateEqualityProof;
|
|
156
|
+
declare const elgamal_generateKeypair: typeof generateKeypair;
|
|
157
|
+
declare const elgamal_generateRangeProof: typeof generateRangeProof;
|
|
158
|
+
declare const elgamal_generateTransferProof: typeof generateTransferProof;
|
|
159
|
+
declare const elgamal_generateValidityProof: typeof generateValidityProof;
|
|
160
|
+
declare const elgamal_generateWithdrawProof: typeof generateWithdrawProof;
|
|
161
|
+
declare const elgamal_subtractCiphertexts: typeof subtractCiphertexts;
|
|
162
|
+
declare namespace elgamal {
|
|
163
|
+
export { type elgamal_DecryptHandle as DecryptHandle, type elgamal_ElGamalCiphertext as ElGamalCiphertext, type elgamal_ElGamalKeypair as ElGamalKeypair, type elgamal_EqualityProof as EqualityProof, elgamal_PROOF_SIZES as PROOF_SIZES, type elgamal_PedersenCommitment as PedersenCommitment, type elgamal_RangeProof as RangeProof, type elgamal_TransferProof as TransferProof, type elgamal_ValidityProof as ValidityProof, type elgamal_WithdrawProof as WithdrawProof, elgamal_addCiphertexts as addCiphertexts, elgamal_decrypt as decrypt, _default$2 as default, elgamal_deriveKeypair as deriveKeypair, elgamal_elGamalPubkeyToAddress as elGamalPubkeyToAddress, elgamal_encrypt as encrypt, elgamal_generateEqualityProof as generateEqualityProof, elgamal_generateKeypair as generateKeypair, elgamal_generateRangeProof as generateRangeProof, elgamal_generateTransferProof as generateTransferProof, elgamal_generateValidityProof as generateValidityProof, elgamal_generateWithdrawProof as generateWithdrawProof, loadWasmModule$1 as loadWasmModule, elgamal_subtractCiphertexts as subtractCiphertexts };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Zero-Knowledge Proof Module
|
|
168
|
+
*
|
|
169
|
+
* Handles all ZK proof generation and verification for the GhostSpeak protocol,
|
|
170
|
+
* including integration with Solana's ZK ElGamal Proof Program.
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
declare const ZK_ELGAMAL_PROOF_PROGRAM_ID: Address<"ZkE1Gama1Proof11111111111111111111111111111">;
|
|
174
|
+
declare const ProofInstructions: {
|
|
175
|
+
readonly VERIFY_RANGE_PROOF: 0;
|
|
176
|
+
readonly VERIFY_VALIDITY_PROOF: 1;
|
|
177
|
+
readonly VERIFY_EQUALITY_PROOF: 2;
|
|
178
|
+
readonly VERIFY_WITHDRAW_PROOF: 3;
|
|
179
|
+
readonly VERIFY_ZERO_BALANCE_PROOF: 4;
|
|
180
|
+
readonly VERIFY_FEE_SIGMA_PROOF: 5;
|
|
181
|
+
readonly VERIFY_PUBKEY_VALIDITY_PROOF: 6;
|
|
182
|
+
readonly VERIFY_TRANSFER_PROOF: 7;
|
|
183
|
+
readonly VERIFY_TRANSFER_WITH_FEE_PROOF: 8;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Create instruction to verify range proof
|
|
187
|
+
*/
|
|
188
|
+
declare function createVerifyRangeProofInstruction(proofAccount: Address, rangeProof: RangeProof): IInstruction;
|
|
189
|
+
/**
|
|
190
|
+
* Create instruction to verify validity proof
|
|
191
|
+
*/
|
|
192
|
+
declare function createVerifyValidityProofInstruction(proofAccount: Address, validityProof: ValidityProof): IInstruction;
|
|
193
|
+
/**
|
|
194
|
+
* Create instruction to verify equality proof
|
|
195
|
+
*/
|
|
196
|
+
declare function createVerifyEqualityProofInstruction(proofAccount: Address, equalityProof: EqualityProof): IInstruction;
|
|
197
|
+
/**
|
|
198
|
+
* Create instruction to verify withdraw proof
|
|
199
|
+
*/
|
|
200
|
+
declare function createVerifyWithdrawProofInstruction(proofAccount: Address, withdrawProof: WithdrawProof): IInstruction;
|
|
201
|
+
/**
|
|
202
|
+
* Create instruction to verify complete transfer proof
|
|
203
|
+
*/
|
|
204
|
+
declare function createVerifyTransferProofInstruction(proofAccount: Address, rangeProof: RangeProof, validityProof: ValidityProof, equalityProof: EqualityProof): IInstruction;
|
|
205
|
+
/**
|
|
206
|
+
* Create proof context account for storing proof verification state
|
|
207
|
+
*/
|
|
208
|
+
interface ProofContext {
|
|
209
|
+
authority: Address;
|
|
210
|
+
proofType: keyof typeof ProofInstructions;
|
|
211
|
+
verified: boolean;
|
|
212
|
+
timestamp: bigint;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Derive proof context PDA
|
|
216
|
+
*/
|
|
217
|
+
declare function deriveProofContextPda(authority: Address, nonce: number): Address;
|
|
218
|
+
/**
|
|
219
|
+
* Create instructions for batch proof verification
|
|
220
|
+
*/
|
|
221
|
+
declare function createBatchVerifyProofInstructions(proofs: {
|
|
222
|
+
type: 'range' | 'validity' | 'equality' | 'withdraw';
|
|
223
|
+
proof: RangeProof | ValidityProof | EqualityProof | WithdrawProof;
|
|
224
|
+
account: Address;
|
|
225
|
+
}[]): IInstruction[];
|
|
226
|
+
/**
|
|
227
|
+
* Calculate proof verification cost
|
|
228
|
+
*/
|
|
229
|
+
declare function calculateProofVerificationCost(proofType: keyof typeof ProofInstructions): bigint;
|
|
230
|
+
/**
|
|
231
|
+
* Estimate total transaction cost including proof verification
|
|
232
|
+
*/
|
|
233
|
+
declare function estimateProofTransactionCost(baseComputeUnits: bigint, proofTypes: (keyof typeof ProofInstructions)[]): bigint;
|
|
234
|
+
declare const _default$1: {
|
|
235
|
+
ZK_ELGAMAL_PROOF_PROGRAM_ID: Address<"ZkE1Gama1Proof11111111111111111111111111111">;
|
|
236
|
+
ProofInstructions: {
|
|
237
|
+
readonly VERIFY_RANGE_PROOF: 0;
|
|
238
|
+
readonly VERIFY_VALIDITY_PROOF: 1;
|
|
239
|
+
readonly VERIFY_EQUALITY_PROOF: 2;
|
|
240
|
+
readonly VERIFY_WITHDRAW_PROOF: 3;
|
|
241
|
+
readonly VERIFY_ZERO_BALANCE_PROOF: 4;
|
|
242
|
+
readonly VERIFY_FEE_SIGMA_PROOF: 5;
|
|
243
|
+
readonly VERIFY_PUBKEY_VALIDITY_PROOF: 6;
|
|
244
|
+
readonly VERIFY_TRANSFER_PROOF: 7;
|
|
245
|
+
readonly VERIFY_TRANSFER_WITH_FEE_PROOF: 8;
|
|
246
|
+
};
|
|
247
|
+
createVerifyRangeProofInstruction: typeof createVerifyRangeProofInstruction;
|
|
248
|
+
createVerifyValidityProofInstruction: typeof createVerifyValidityProofInstruction;
|
|
249
|
+
createVerifyEqualityProofInstruction: typeof createVerifyEqualityProofInstruction;
|
|
250
|
+
createVerifyWithdrawProofInstruction: typeof createVerifyWithdrawProofInstruction;
|
|
251
|
+
createVerifyTransferProofInstruction: typeof createVerifyTransferProofInstruction;
|
|
252
|
+
createBatchVerifyProofInstructions: typeof createBatchVerifyProofInstructions;
|
|
253
|
+
deriveProofContextPda: typeof deriveProofContextPda;
|
|
254
|
+
calculateProofVerificationCost: typeof calculateProofVerificationCost;
|
|
255
|
+
estimateProofTransactionCost: typeof estimateProofTransactionCost;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
type zkProofs_ProofContext = ProofContext;
|
|
259
|
+
declare const zkProofs_ProofInstructions: typeof ProofInstructions;
|
|
260
|
+
declare const zkProofs_ZK_ELGAMAL_PROOF_PROGRAM_ID: typeof ZK_ELGAMAL_PROOF_PROGRAM_ID;
|
|
261
|
+
declare const zkProofs_calculateProofVerificationCost: typeof calculateProofVerificationCost;
|
|
262
|
+
declare const zkProofs_createBatchVerifyProofInstructions: typeof createBatchVerifyProofInstructions;
|
|
263
|
+
declare const zkProofs_createVerifyEqualityProofInstruction: typeof createVerifyEqualityProofInstruction;
|
|
264
|
+
declare const zkProofs_createVerifyRangeProofInstruction: typeof createVerifyRangeProofInstruction;
|
|
265
|
+
declare const zkProofs_createVerifyTransferProofInstruction: typeof createVerifyTransferProofInstruction;
|
|
266
|
+
declare const zkProofs_createVerifyValidityProofInstruction: typeof createVerifyValidityProofInstruction;
|
|
267
|
+
declare const zkProofs_createVerifyWithdrawProofInstruction: typeof createVerifyWithdrawProofInstruction;
|
|
268
|
+
declare const zkProofs_deriveProofContextPda: typeof deriveProofContextPda;
|
|
269
|
+
declare const zkProofs_estimateProofTransactionCost: typeof estimateProofTransactionCost;
|
|
270
|
+
declare namespace zkProofs {
|
|
271
|
+
export { type zkProofs_ProofContext as ProofContext, zkProofs_ProofInstructions as ProofInstructions, zkProofs_ZK_ELGAMAL_PROOF_PROGRAM_ID as ZK_ELGAMAL_PROOF_PROGRAM_ID, zkProofs_calculateProofVerificationCost as calculateProofVerificationCost, zkProofs_createBatchVerifyProofInstructions as createBatchVerifyProofInstructions, zkProofs_createVerifyEqualityProofInstruction as createVerifyEqualityProofInstruction, zkProofs_createVerifyRangeProofInstruction as createVerifyRangeProofInstruction, zkProofs_createVerifyTransferProofInstruction as createVerifyTransferProofInstruction, zkProofs_createVerifyValidityProofInstruction as createVerifyValidityProofInstruction, zkProofs_createVerifyWithdrawProofInstruction as createVerifyWithdrawProofInstruction, _default$1 as default, zkProofs_deriveProofContextPda as deriveProofContextPda, zkProofs_estimateProofTransactionCost as estimateProofTransactionCost };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* WASM Bridge for Cryptographic Operations
|
|
276
|
+
*
|
|
277
|
+
* Optional performance optimization layer that loads WASM modules
|
|
278
|
+
* for compute-intensive cryptographic operations.
|
|
279
|
+
*/
|
|
280
|
+
interface WasmModule {
|
|
281
|
+
generate_range_proof: (value: string, commitment: Uint8Array, randomness: Uint8Array) => Promise<Uint8Array>;
|
|
282
|
+
generate_validity_proof: (publicKey: Uint8Array, commitment: Uint8Array, handle: Uint8Array, randomness: Uint8Array) => Promise<Uint8Array>;
|
|
283
|
+
generate_equality_proof: (sourceCommitment: Uint8Array, destCommitment: Uint8Array, amount: string, sourceRandomness: Uint8Array, destRandomness: Uint8Array) => Promise<Uint8Array>;
|
|
284
|
+
generate_withdraw_proof: (balance: string, secretKey: Uint8Array, commitment: Uint8Array, handle: Uint8Array) => Promise<Uint8Array>;
|
|
285
|
+
scalar_multiply: (point: Uint8Array, scalar: Uint8Array) => Uint8Array;
|
|
286
|
+
point_add: (point1: Uint8Array, point2: Uint8Array) => Uint8Array;
|
|
287
|
+
point_subtract: (point1: Uint8Array, point2: Uint8Array) => Uint8Array;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Load WASM module for cryptographic operations
|
|
291
|
+
*/
|
|
292
|
+
declare function loadWasmModule(): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Check if WASM module is available
|
|
295
|
+
*/
|
|
296
|
+
declare function isWasmAvailable(): boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Get WASM module instance
|
|
299
|
+
*/
|
|
300
|
+
declare function getWasmModule(): WasmModule | null;
|
|
301
|
+
/**
|
|
302
|
+
* Benchmark WASM vs JavaScript performance
|
|
303
|
+
*/
|
|
304
|
+
declare function benchmarkWasm(): Promise<{
|
|
305
|
+
wasmTime: number;
|
|
306
|
+
jsTime: number;
|
|
307
|
+
speedup: number;
|
|
308
|
+
} | null>;
|
|
309
|
+
/**
|
|
310
|
+
* Create a function that falls back to JS if WASM fails
|
|
311
|
+
*/
|
|
312
|
+
declare function createWasmFallback<T extends (...args: unknown[]) => unknown>(wasmFn: T | undefined, jsFallback: T): T;
|
|
313
|
+
declare const _default: {
|
|
314
|
+
loadWasmModule: typeof loadWasmModule;
|
|
315
|
+
isWasmAvailable: typeof isWasmAvailable;
|
|
316
|
+
getWasmModule: typeof getWasmModule;
|
|
317
|
+
benchmarkWasm: typeof benchmarkWasm;
|
|
318
|
+
createWasmFallback: typeof createWasmFallback;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
type wasmBridge_WasmModule = WasmModule;
|
|
322
|
+
declare const wasmBridge_benchmarkWasm: typeof benchmarkWasm;
|
|
323
|
+
declare const wasmBridge_createWasmFallback: typeof createWasmFallback;
|
|
324
|
+
declare const wasmBridge_getWasmModule: typeof getWasmModule;
|
|
325
|
+
declare const wasmBridge_isWasmAvailable: typeof isWasmAvailable;
|
|
326
|
+
declare const wasmBridge_loadWasmModule: typeof loadWasmModule;
|
|
327
|
+
declare namespace wasmBridge {
|
|
328
|
+
export { type wasmBridge_WasmModule as WasmModule, wasmBridge_benchmarkWasm as benchmarkWasm, wasmBridge_createWasmFallback as createWasmFallback, _default as default, wasmBridge_getWasmModule as getWasmModule, wasmBridge_isWasmAvailable as isWasmAvailable, wasmBridge_loadWasmModule as loadWasmModule };
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export { type ElGamalCiphertext, type ElGamalKeypair, type ProofContext, type TransferProof, type WasmModule, type WithdrawProof, ZK_ELGAMAL_PROOF_PROGRAM_ID, createVerifyRangeProofInstruction, createVerifyTransferProofInstruction, decrypt, elgamal, encrypt, generateKeypair, generateTransferProof, generateWithdrawProof, isWasmAvailable, loadWasmModule, wasmBridge, zkProofs };
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Address } from '@solana/addresses';
|
|
2
|
+
import { ErrorCode, SDKError } from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Smart Error System with Actionable Solutions
|
|
6
|
+
*
|
|
7
|
+
* Every error includes context and suggested solutions to help developers
|
|
8
|
+
* quickly resolve issues.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Base GhostSpeak error class
|
|
13
|
+
*/
|
|
14
|
+
declare class GhostSpeakError extends Error {
|
|
15
|
+
readonly code: ErrorCode;
|
|
16
|
+
readonly context: Record<string, unknown>;
|
|
17
|
+
readonly solution?: string;
|
|
18
|
+
readonly instruction?: string;
|
|
19
|
+
constructor(code: ErrorCode, message: string, context?: Record<string, unknown>, solution?: string, instruction?: string);
|
|
20
|
+
/**
|
|
21
|
+
* Format error for display
|
|
22
|
+
*/
|
|
23
|
+
toString(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Convert to SDK error type
|
|
26
|
+
*/
|
|
27
|
+
toSDKError(): SDKError;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Network-related errors
|
|
31
|
+
*/
|
|
32
|
+
declare class NetworkError extends GhostSpeakError {
|
|
33
|
+
constructor(endpoint: string, originalError?: Error);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Insufficient balance error
|
|
37
|
+
*/
|
|
38
|
+
declare class InsufficientBalanceError extends GhostSpeakError {
|
|
39
|
+
constructor(required: bigint, available: bigint, address: Address);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Account not found error
|
|
43
|
+
*/
|
|
44
|
+
declare class AccountNotFoundError extends GhostSpeakError {
|
|
45
|
+
constructor(address: Address, accountType: string);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Invalid input error
|
|
49
|
+
*/
|
|
50
|
+
declare class InvalidInputError extends GhostSpeakError {
|
|
51
|
+
constructor(field: string, value: unknown, requirement: string);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Transaction failed error
|
|
55
|
+
*/
|
|
56
|
+
declare class TransactionFailedError extends GhostSpeakError {
|
|
57
|
+
constructor(signature: string, logs: string[], programError?: string);
|
|
58
|
+
private static getSolution;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Simulation failed error
|
|
62
|
+
*/
|
|
63
|
+
declare class SimulationFailedError extends GhostSpeakError {
|
|
64
|
+
constructor(logs: string[], unitsConsumed?: bigint);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Timeout error
|
|
68
|
+
*/
|
|
69
|
+
declare class TimeoutError extends GhostSpeakError {
|
|
70
|
+
constructor(operation: string, timeoutMs: number);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Error factory for creating specific errors
|
|
74
|
+
*/
|
|
75
|
+
declare class ErrorFactory {
|
|
76
|
+
/**
|
|
77
|
+
* Create error from program logs
|
|
78
|
+
*/
|
|
79
|
+
static fromProgramLogs(logs: string[], signature?: string): GhostSpeakError;
|
|
80
|
+
/**
|
|
81
|
+
* Create error from RPC error
|
|
82
|
+
*/
|
|
83
|
+
static fromRpcError(error: unknown, endpoint: string): GhostSpeakError;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Global error handler for consistent error handling
|
|
87
|
+
*/
|
|
88
|
+
declare class ErrorHandler {
|
|
89
|
+
private static handlers;
|
|
90
|
+
/**
|
|
91
|
+
* Register error handler
|
|
92
|
+
*/
|
|
93
|
+
static on(code: ErrorCode, handler: (error: GhostSpeakError) => void): void;
|
|
94
|
+
/**
|
|
95
|
+
* Handle error
|
|
96
|
+
*/
|
|
97
|
+
static handle(error: unknown): SDKError;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Validation error for invalid inputs
|
|
101
|
+
*/
|
|
102
|
+
declare class ValidationError extends GhostSpeakError {
|
|
103
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
104
|
+
}
|
|
105
|
+
declare const _default: {
|
|
106
|
+
GhostSpeakError: typeof GhostSpeakError;
|
|
107
|
+
NetworkError: typeof NetworkError;
|
|
108
|
+
InsufficientBalanceError: typeof InsufficientBalanceError;
|
|
109
|
+
AccountNotFoundError: typeof AccountNotFoundError;
|
|
110
|
+
InvalidInputError: typeof InvalidInputError;
|
|
111
|
+
TransactionFailedError: typeof TransactionFailedError;
|
|
112
|
+
SimulationFailedError: typeof SimulationFailedError;
|
|
113
|
+
TimeoutError: typeof TimeoutError;
|
|
114
|
+
ValidationError: typeof ValidationError;
|
|
115
|
+
ErrorFactory: typeof ErrorFactory;
|
|
116
|
+
ErrorHandler: typeof ErrorHandler;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { AccountNotFoundError, ErrorFactory, ErrorHandler, GhostSpeakError, InsufficientBalanceError, InvalidInputError, NetworkError, SimulationFailedError, TimeoutError, TransactionFailedError, ValidationError, _default as default };
|