@cloak.ag/sdk 1.0.4 → 1.0.6
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 +39 -4
- package/dist/index.cjs +1041 -63
- package/dist/index.d.cts +318 -8
- package/dist/index.d.ts +318 -8
- package/dist/index.js +1025 -63
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,10 +6,10 @@ TypeScript SDK for the Cloak Protocol - Private transactions on Solana using zer
|
|
|
6
6
|
|
|
7
7
|
- 🔒 **Private Transfers**: Send SOL privately using zero-knowledge proofs
|
|
8
8
|
- 👥 **Multi-Recipient**: Support for 1-5 recipients in a single transaction
|
|
9
|
-
- 💱 **Token Swaps**: Swap SOL for SPL tokens privately
|
|
9
|
+
- 💱 **Token Swaps**: Swap SOL for SPL tokens privately (SOL → USDC, etc.)
|
|
10
10
|
- 🔐 **Type-Safe**: Full TypeScript support with comprehensive types
|
|
11
|
-
- 🌐 **Cross-Platform**: Works in browser and Node.js
|
|
12
|
-
- ⚡ **Simple API**: Easy-to-use high-level client
|
|
11
|
+
- 🌐 **Cross-Platform**: Works in browser (React, Next.js) and Node.js
|
|
12
|
+
- ⚡ **Simple API**: Easy-to-use high-level client with wallet adapter support
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -28,8 +28,10 @@ npm install @solana/spl-token
|
|
|
28
28
|
|
|
29
29
|
## Quick Start
|
|
30
30
|
|
|
31
|
+
### Node.js (with Keypair)
|
|
32
|
+
|
|
31
33
|
```typescript
|
|
32
|
-
import { CloakSDK
|
|
34
|
+
import { CloakSDK } from "@cloak.ag/sdk";
|
|
33
35
|
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
34
36
|
|
|
35
37
|
// Initialize connection and keypair
|
|
@@ -56,6 +58,39 @@ const withdrawResult = await sdk.withdraw(
|
|
|
56
58
|
console.log("Withdrawn! TX:", withdrawResult.signature);
|
|
57
59
|
```
|
|
58
60
|
|
|
61
|
+
### React/Next.js (with Wallet Adapter)
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { CloakSDK } from "@cloak.ag/sdk";
|
|
65
|
+
import { useWallet, useConnection } from "@solana/wallet-adapter-react";
|
|
66
|
+
import { PublicKey } from "@solana/web3.js";
|
|
67
|
+
|
|
68
|
+
function PrivateTransfer() {
|
|
69
|
+
const { publicKey, signTransaction, sendTransaction } = useWallet();
|
|
70
|
+
const { connection } = useConnection();
|
|
71
|
+
|
|
72
|
+
// Initialize SDK with wallet adapter
|
|
73
|
+
const sdk = useMemo(() => {
|
|
74
|
+
if (!publicKey) return null;
|
|
75
|
+
return new CloakSDK({
|
|
76
|
+
network: "devnet",
|
|
77
|
+
wallet: {
|
|
78
|
+
publicKey,
|
|
79
|
+
signTransaction: (tx) => signTransaction!(tx),
|
|
80
|
+
sendTransaction: (tx, conn, opts) => sendTransaction(tx, conn, opts),
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}, [publicKey, signTransaction, sendTransaction]);
|
|
84
|
+
|
|
85
|
+
const handleDeposit = async () => {
|
|
86
|
+
const result = await sdk.deposit(connection, 100_000_000);
|
|
87
|
+
console.log("Deposited!", result.signature);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return <button onClick={handleDeposit}>Deposit 0.1 SOL</button>;
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
59
94
|
## Core Methods
|
|
60
95
|
|
|
61
96
|
### Deposit
|