proof-of-take-sdk 1.0.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/FINAL_USAGE.md +342 -0
- package/LIBRARY_GUIDE.md +400 -0
- package/LICENSE +22 -0
- package/README.md +370 -0
- package/dist/client.d.ts +32 -0
- package/dist/client.js +47 -0
- package/dist/constants/season.d.ts +18 -0
- package/dist/constants/season.js +22 -0
- package/dist/getters/getMiztake.d.ts +11 -0
- package/dist/getters/getMiztake.js +34 -0
- package/dist/getters/getMiztakeStatistics.d.ts +10 -0
- package/dist/getters/getMiztakeStatistics.js +20 -0
- package/dist/getters/getTokenVault.d.ts +30 -0
- package/dist/getters/getTokenVault.js +56 -0
- package/dist/getters/getUserStats.d.ts +21 -0
- package/dist/getters/getUserStats.js +43 -0
- package/dist/getters/index.d.ts +7 -0
- package/dist/getters/index.js +23 -0
- package/dist/idl/idl.d.ts +2 -0
- package/dist/idl/idl.js +8 -0
- package/dist/idl/proof_of_take.json +3803 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +92 -0
- package/dist/instructions/claimReferralPenaltyForWindow.d.ts +38 -0
- package/dist/instructions/claimReferralPenaltyForWindow.js +72 -0
- package/dist/instructions/claimWindowRewards.d.ts +48 -0
- package/dist/instructions/claimWindowRewards.js +94 -0
- package/dist/instructions/confirmedPostOnX.d.ts +51 -0
- package/dist/instructions/confirmedPostOnX.js +78 -0
- package/dist/instructions/createMiztake.d.ts +90 -0
- package/dist/instructions/createMiztake.js +166 -0
- package/dist/instructions/initializeEscrowVault.d.ts +15 -0
- package/dist/instructions/initializeEscrowVault.js +36 -0
- package/dist/instructions/initializeSeasonSettings.d.ts +20 -0
- package/dist/instructions/initializeSeasonSettings.js +39 -0
- package/dist/instructions/initializeSeasonVault.d.ts +20 -0
- package/dist/instructions/initializeSeasonVault.js +43 -0
- package/dist/instructions/initializeStatistics.d.ts +32 -0
- package/dist/instructions/initializeStatistics.js +73 -0
- package/dist/instructions/joinSeason.d.ts +50 -0
- package/dist/instructions/joinSeason.js +120 -0
- package/dist/instructions/toggleSeasonPause.d.ts +22 -0
- package/dist/instructions/toggleSeasonPause.js +42 -0
- package/dist/instructions/updateSeasonAdmin.d.ts +23 -0
- package/dist/instructions/updateSeasonAdmin.js +43 -0
- package/dist/instructions/viewCurrentSeason.d.ts +12 -0
- package/dist/instructions/viewCurrentSeason.js +30 -0
- package/dist/instructions/viewSeasonMembershipStatus.d.ts +16 -0
- package/dist/instructions/viewSeasonMembershipStatus.js +33 -0
- package/dist/instructions/viewWindowStatus.d.ts +15 -0
- package/dist/instructions/viewWindowStatus.js +28 -0
- package/dist/instructions/withdrawSeasonDeposit.d.ts +38 -0
- package/dist/instructions/withdrawSeasonDeposit.js +66 -0
- package/dist/optimistic/index.d.ts +7 -0
- package/dist/optimistic/index.js +33 -0
- package/dist/types/accountTypes.d.ts +121 -0
- package/dist/types/accountTypes.js +2 -0
- package/dist/types/instructionResults.d.ts +44 -0
- package/dist/types/instructionResults.js +2 -0
- package/dist/types/proof_of_take.d.ts +3809 -0
- package/dist/types/proof_of_take.js +2 -0
- package/dist/types.d.ts +232 -0
- package/dist/types.js +16 -0
- package/dist/utils/accountUpdates.d.ts +245 -0
- package/dist/utils/accountUpdates.js +611 -0
- package/dist/utils/anchorHelpers.d.ts +7 -0
- package/dist/utils/anchorHelpers.js +21 -0
- package/dist/utils/constants.d.ts +21 -0
- package/dist/utils/constants.js +31 -0
- package/dist/utils/conversions.d.ts +25 -0
- package/dist/utils/conversions.js +53 -0
- package/dist/utils/enumHelpers.d.ts +63 -0
- package/dist/utils/enumHelpers.js +110 -0
- package/dist/utils/index.d.ts +0 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/pdaManager.d.ts +106 -0
- package/dist/utils/pdaManager.js +89 -0
- package/dist/utils/pdas.d.ts +68 -0
- package/dist/utils/pdas.js +128 -0
- package/dist/utils/programHelpers.d.ts +9 -0
- package/dist/utils/programHelpers.js +18 -0
- package/dist/utils/signerHelpers.d.ts +17 -0
- package/dist/utils/signerHelpers.js +21 -0
- package/dist/utils/simulationHelpers.d.ts +121 -0
- package/dist/utils/simulationHelpers.js +183 -0
- package/dist/utils/tierPenalty.d.ts +9 -0
- package/dist/utils/tierPenalty.js +24 -0
- package/dist/utils/transactionBuilder.d.ts +77 -0
- package/dist/utils/transactionBuilder.js +147 -0
- package/package.json +50 -0
package/FINAL_USAGE.md
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# Proof of Miztake SDK - Final Usage Guide
|
|
2
|
+
|
|
3
|
+
## ✅ **SDK Updated - Connection-Based API**
|
|
4
|
+
|
|
5
|
+
All functions now accept only a `Connection` - no Program instance needed!
|
|
6
|
+
|
|
7
|
+
**Benefits**:
|
|
8
|
+
- ✅ Simpler API - just pass connection
|
|
9
|
+
- ✅ No program initialization needed
|
|
10
|
+
- ✅ Works with any connection
|
|
11
|
+
- ✅ Program created internally
|
|
12
|
+
- ✅ Cleaner code
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🚀 **New Simple Usage**
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { Connection } from "@solana/web3.js";
|
|
20
|
+
import { createMiztake } from "@proof-of-miztake/sdk";
|
|
21
|
+
|
|
22
|
+
// Just need a connection!
|
|
23
|
+
const connection = new Connection("https://api.mainnet-beta.solana.com");
|
|
24
|
+
|
|
25
|
+
// Call functions directly
|
|
26
|
+
const { instructions, signers, miztakePda } = await createMiztake(
|
|
27
|
+
connection, // ← Just connection, no program setup!
|
|
28
|
+
params,
|
|
29
|
+
wallet.publicKey
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// Build and send transaction
|
|
33
|
+
const tx = new Transaction().add(...instructions);
|
|
34
|
+
const signature = await wallet.sendTransaction(tx, connection);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 📝 **Complete Examples**
|
|
40
|
+
|
|
41
|
+
### 1. Create Miztake (Simplified)
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Connection, Transaction } from "@solana/web3.js";
|
|
45
|
+
import { BN } from "@coral-xyz/anchor";
|
|
46
|
+
import { createMiztake } from "@proof-of-miztake/sdk";
|
|
47
|
+
|
|
48
|
+
const connection = new Connection("https://api.mainnet-beta.solana.com");
|
|
49
|
+
|
|
50
|
+
// Get instructions
|
|
51
|
+
const { instructions, signers, miztakePda, userStatsPda } = await createMiztake(
|
|
52
|
+
connection, // ← Just connection!
|
|
53
|
+
{
|
|
54
|
+
telegramId: new BN(12345678),
|
|
55
|
+
telegramUsername: "myusername",
|
|
56
|
+
perceptualHash: "hash1234567890ab",
|
|
57
|
+
averageHash: "hash2345678901cd",
|
|
58
|
+
differenceHash: "hash3456789012ef",
|
|
59
|
+
waveletHash: "hash4567890123gh",
|
|
60
|
+
shaHash: "sha256_hash_minimum_32_characters_required_here_xxx",
|
|
61
|
+
computedAt: new Date().toISOString()
|
|
62
|
+
},
|
|
63
|
+
wallet.publicKey
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// Build and send
|
|
67
|
+
const tx = new Transaction().add(...instructions);
|
|
68
|
+
tx.feePayer = wallet.publicKey;
|
|
69
|
+
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
70
|
+
|
|
71
|
+
const signature = await wallet.sendTransaction(tx, connection);
|
|
72
|
+
|
|
73
|
+
console.log("Miztake created:", miztakePda.toBase58());
|
|
74
|
+
console.log("User stats:", userStatsPda.toBase58());
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### 2. Claim Reward (Dual Signature)
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { claimReward } from "@proof-of-miztake/sdk";
|
|
83
|
+
|
|
84
|
+
const { instructions, signers } = await claimReward(
|
|
85
|
+
connection, // ← Just connection!
|
|
86
|
+
{
|
|
87
|
+
miztakePda,
|
|
88
|
+
userTokenAccount,
|
|
89
|
+
amount: new BN(100_000_000)
|
|
90
|
+
},
|
|
91
|
+
userWallet.publicKey,
|
|
92
|
+
adminWallet.publicKey
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
// signers indicates: [{ publicKey: user, role: "user" }, { publicKey: admin, role: "admin" }]
|
|
96
|
+
|
|
97
|
+
const tx = new Transaction().add(...instructions);
|
|
98
|
+
// Both must sign the transaction
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### 3. Deposit Tokens
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { depositTokens } from "@proof-of-miztake/sdk";
|
|
107
|
+
|
|
108
|
+
const { instructions, signers, tokenVaultPda } = await depositTokens(
|
|
109
|
+
connection, // ← Just connection!
|
|
110
|
+
{
|
|
111
|
+
amount: new BN(1_000_000_000_000),
|
|
112
|
+
depositorTokenAccount
|
|
113
|
+
},
|
|
114
|
+
depositorWallet.publicKey
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const tx = new Transaction().add(...instructions);
|
|
118
|
+
const signature = await wallet.sendTransaction(tx, connection);
|
|
119
|
+
|
|
120
|
+
console.log("Vault PDA:", tokenVaultPda.toBase58());
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### 4. Initialize Statistics (Admin)
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { initializeStatistics } from "@proof-of-miztake/sdk";
|
|
129
|
+
|
|
130
|
+
const { instructions, signers, miztakeStatisticsPda } = await initializeStatistics(
|
|
131
|
+
connection, // ← Just connection!
|
|
132
|
+
adminWallet.publicKey,
|
|
133
|
+
adminWallet.publicKey
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const tx = new Transaction().add(...instructions);
|
|
137
|
+
const signature = await adminWallet.sendTransaction(tx, connection);
|
|
138
|
+
|
|
139
|
+
console.log("Statistics PDA created:", miztakeStatisticsPda.toBase58());
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### 5. Update Config (Admin)
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { updateConfig } from "@proof-of-miztake/sdk";
|
|
148
|
+
|
|
149
|
+
const { instructions, signers } = await updateConfig(
|
|
150
|
+
connection, // ← Just connection!
|
|
151
|
+
{
|
|
152
|
+
newFee: new BN(150_000),
|
|
153
|
+
newDefaultMaxClaimable: new BN(20_000_000_000)
|
|
154
|
+
},
|
|
155
|
+
adminWallet.publicKey
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const tx = new Transaction().add(...instructions);
|
|
159
|
+
await adminWallet.sendTransaction(tx, connection);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### 6. Toggle Pause (Admin)
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { togglePause } from "@proof-of-miztake/sdk";
|
|
168
|
+
|
|
169
|
+
const { instructions, signers } = await togglePause(
|
|
170
|
+
connection, // ← Just connection!
|
|
171
|
+
adminWallet.publicKey
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const tx = new Transaction().add(...instructions);
|
|
175
|
+
await adminWallet.sendTransaction(tx, connection);
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### 7. Withdraw Tokens (Admin)
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { withdrawTokens } from "@proof-of-miztake/sdk";
|
|
184
|
+
|
|
185
|
+
const { instructions, signers } = await withdrawTokens(
|
|
186
|
+
connection, // ← Just connection!
|
|
187
|
+
{
|
|
188
|
+
amount: new BN(500_000_000_000),
|
|
189
|
+
adminTokenAccount
|
|
190
|
+
},
|
|
191
|
+
adminWallet.publicKey
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const tx = new Transaction().add(...instructions);
|
|
195
|
+
await adminWallet.sendTransaction(tx, connection);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 🔍 **Query Functions (Also Simplified)**
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
import {
|
|
204
|
+
canClaim,
|
|
205
|
+
getConfig,
|
|
206
|
+
isProgramPaused,
|
|
207
|
+
getVaultBalance,
|
|
208
|
+
isInitialized
|
|
209
|
+
} from "@proof-of-miztake/sdk";
|
|
210
|
+
|
|
211
|
+
// All now just take connection!
|
|
212
|
+
const config = await getConfig(connection);
|
|
213
|
+
const paused = await isProgramPaused(connection);
|
|
214
|
+
const balance = await getVaultBalance(connection);
|
|
215
|
+
const initialized = await isInitialized(connection);
|
|
216
|
+
|
|
217
|
+
const claimCheck = await canClaim(connection, miztakePda, amount);
|
|
218
|
+
if (!claimCheck.canClaim) {
|
|
219
|
+
console.log("Cannot claim:", claimCheck.reason);
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 🎨 **React Example**
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
|
|
229
|
+
import { Transaction } from "@solana/web3.js";
|
|
230
|
+
import { createMiztake } from "@proof-of-miztake/sdk";
|
|
231
|
+
|
|
232
|
+
function CreateMiztakeButton() {
|
|
233
|
+
const { connection } = useConnection(); // ← Just get connection
|
|
234
|
+
const { publicKey, sendTransaction } = useWallet();
|
|
235
|
+
|
|
236
|
+
const handleCreate = async () => {
|
|
237
|
+
if (!publicKey) return;
|
|
238
|
+
|
|
239
|
+
// Call SDK function with connection
|
|
240
|
+
const { instructions, miztakePda } = await createMiztake(
|
|
241
|
+
connection, // ← Super simple!
|
|
242
|
+
params,
|
|
243
|
+
publicKey
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
// Build and send
|
|
247
|
+
const tx = new Transaction().add(...instructions);
|
|
248
|
+
tx.feePayer = publicKey;
|
|
249
|
+
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
250
|
+
|
|
251
|
+
const signature = await sendTransaction(tx, connection);
|
|
252
|
+
|
|
253
|
+
toast.success(`Created: ${miztakePda.toBase58()}`);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
return <button onClick={handleCreate}>Create Miztake</button>;
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## 📊 **All Functions - Quick Reference**
|
|
263
|
+
|
|
264
|
+
### User Operations:
|
|
265
|
+
```typescript
|
|
266
|
+
// Create miztake
|
|
267
|
+
const result = await createMiztake(connection, params, payer);
|
|
268
|
+
|
|
269
|
+
// Claim reward
|
|
270
|
+
const result = await claimReward(connection, params, userKey, adminKey);
|
|
271
|
+
|
|
272
|
+
// Deposit tokens
|
|
273
|
+
const result = await depositTokens(connection, params, depositor);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Admin Operations:
|
|
277
|
+
```typescript
|
|
278
|
+
// Initialize
|
|
279
|
+
const result = await initializeStatistics(connection, admin, payer);
|
|
280
|
+
|
|
281
|
+
// Withdraw
|
|
282
|
+
const result = await withdrawTokens(connection, params, admin);
|
|
283
|
+
|
|
284
|
+
// Update config
|
|
285
|
+
const result = await updateConfig(connection, params, admin);
|
|
286
|
+
|
|
287
|
+
// Toggle pause
|
|
288
|
+
const result = await togglePause(connection, admin);
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Query Functions:
|
|
292
|
+
```typescript
|
|
293
|
+
// No changes needed - all take connection
|
|
294
|
+
const config = await getConfig(connection);
|
|
295
|
+
const paused = await isProgramPaused(connection);
|
|
296
|
+
const balance = await getVaultBalance(connection);
|
|
297
|
+
const canDoClaim = await canClaim(connection, miztakePda, amount);
|
|
298
|
+
const isSetup = await isInitialized(connection);
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## ✅ **What Changed**
|
|
304
|
+
|
|
305
|
+
### Before:
|
|
306
|
+
```typescript
|
|
307
|
+
// Had to create program first
|
|
308
|
+
const provider = new AnchorProvider(connection, wallet, {});
|
|
309
|
+
const program = new Program(IDL, provider);
|
|
310
|
+
|
|
311
|
+
// Then pass program
|
|
312
|
+
const result = await createMiztake(program, params, wallet.publicKey);
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### After (Now):
|
|
316
|
+
```typescript
|
|
317
|
+
// Just pass connection!
|
|
318
|
+
const result = await createMiztake(connection, params, wallet.publicKey);
|
|
319
|
+
|
|
320
|
+
// SDK creates program internally
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## 🎊 **Perfect API!**
|
|
326
|
+
|
|
327
|
+
Your SDK now has:
|
|
328
|
+
- ✅ Simple API (just connection)
|
|
329
|
+
- ✅ Returns instructions (not executes)
|
|
330
|
+
- ✅ No private keys needed
|
|
331
|
+
- ✅ Works with any wallet
|
|
332
|
+
- ✅ Maximum composability
|
|
333
|
+
- ✅ Professional pattern
|
|
334
|
+
|
|
335
|
+
**Build Status**: ✅ Successful
|
|
336
|
+
**Ready**: Production use
|
|
337
|
+
**Pattern**: Connection → Instructions → You sign & send
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
**No setup needed, just import and use!** 🚀
|
|
342
|
+
|